C File for the Bicycle Ride Calorie Calculator (original) (raw)
Below follows the example C source code for the calculator.
/*
- FILE:
- biker.c
- FUNCTION:
- Demonstrate how to hook up DWI to a generic GLib GObject.
- This is the 'main program' for the Bicycle Ride Calorie
- Calculator. It does little else but to initialize the
- the GUI and DWI systems, and create an instance of the
- bike-calc object. Its mostly 'boiler-plate'.
- HISTORY:
- Linas Vepstas linas@linas.org March 2004 */
#include "config.h"
#include <stdio.h>
#include <glib.h> #include <gnome.h> #include <glade/glade.h>
#include "perr.h" #include "readfile.h"
#include "bike-calc.h" #include "time-hms.h"
int main (int argc, char argv[]) { / Generic gnome/glib boiler-plate */ g_type_init (); gnome_program_init ("dwi-run", VERSION, LIBGNOMEUI_MODULE, argc, argv, GNOME_PROGRAM_STANDARD_PROPERTIES, NULL); glade_gnome_init();
#define ERR_ONLY G_LOG_LEVEL_ERROR | G_LOG_LEVEL_CRITICAL | G_LOG_LEVEL_WARNING g_log_set_handler (G_LOG_DOMAIN, ERR_ONLY, dui_show_message, NULL);
/* Initialize DWI, and read in the controlliing DWI file. */
DuiInterface *di = dui_interface_new();
dui_interface_parse (di, "biker.dui");
/* Create an instance of our object, and tell DWI about it.
* The second argument to dui_interface_add_object() is important:
* it is the name by which we will refer to this instance in the
* active-object.dui file. */
GObject *biker = bike_calc_new ();
dui_interface_add_object (di, "ibiker", biker);
GObject *time_converter = time_hms_new ();
dui_interface_add_object (di, "time-conv", time_converter);
/* OK, now let it run. */
dui_interface_realize (di, TRUE);
gtk_main ();
dui_interface_destroy(di);
printf ("Bye! Please Come Again!\n");
return 0;}
/* ========================== END OF FILE ============================ */