maemo.org - Talk

maemo.org - Talk (https://talk.maemo.org/index.php)
-   Development (https://talk.maemo.org/forumdisplay.php?f=13)
-   -   HildonTimeZoneChooser (https://talk.maemo.org/showthread.php?t=56101)

qwerty12 2010-06-13 19:51

HildonTimeZoneChooser
 
Code:

//gcc time.c $(pkg-config --cflags --libs hildon-1 libcityinfo0-0 libclockcore0-0) -ltime -lhildon-time-zone-chooser0 -I/usr/include/clockd -Wall

#include <stdlib.h>
#include <clock/clockcore.h> /* Includes cityinfo, libtime and **** for us */
#include <gtk/gtk.h>
#include <hildon/hildon.h>

/* Refs:
 * /usr/include/clockd/libtime.h
 * All headers in /usr/include/clock/
 * /usr/include/cityinfo.h
 * maemo.org/api_refs/5.0/5.0-final/cityinfo/cityinfo-cityinfo.html
 * maemo.org/api_refs/5.0/5.0-final/libtime/libtime_8h.html
 * maemo.org/api_refs/5.0/5.0-final/clockd
 */

extern GtkWidget* hildon_time_zone_chooser_new (void); /* Knowing GObject, this is probably a "HildonTimeZoneChooser" type, derived from HildonStackableWindow -- actually, probably a GObject that has a HildonStackableWindow in its private struct */
extern gint hildon_time_zone_chooser_run (gpointer); /* Probably guint */
extern void hildon_time_zone_chooser_set_city (gpointer, Cityinfo*);
extern Cityinfo* hildon_time_zone_chooser_get_city (gpointer);
extern void hildon_time_zone_chooser_free (gpointer); /* Probably guint */

static GtkWidget *time_chooser;

gint main (gint argc, gchar *argv[])
{
        Citytime *home_loc;

        hildon_gtk_init (&argc, &argv);

        home_loc = clock_get_home_location ();

        time_chooser = hildon_time_zone_chooser_new ();
        hildon_time_zone_chooser_set_city (time_chooser, home_loc->city);

        switch (hildon_time_zone_chooser_run (time_chooser))
        {
                case 1: /* City chosen */
                        break;

                case 2: /* Back button hit */
                default: /* Head for the choppers, everybody get out! I am not Triumph, I am Arnold; get down! */
                        g_assert_not_reached ();
        }

        const Cityinfo *time_chooser_time = hildon_time_zone_chooser_get_city (time_chooser);
        g_printerr ("%s\n", cityinfo_get_zone (time_chooser_time));
        hildon_time_zone_chooser_free (time_chooser);       

        g_idle_add ((GSourceFunc) gtk_main_quit, NULL);

        gtk_main ();

        return EXIT_SUCCESS;
}



All times are GMT. The time now is 19:28.

vBulletin® Version 3.8.8