1
2 #define MATEWEATHER_I_KNOW_THIS_IS_UNSTABLE
3 #include <gtk/gtk.h>
4 #include "location-entry.h"
5 #include "timezone-menu.h"
6
7 static void
deleted(GtkWidget * widget,GdkEvent * event,gpointer data)8 deleted (GtkWidget *widget, GdkEvent *event, gpointer data)
9 {
10 gtk_main_quit ();
11 }
12
13 static void
location_changed(GObject * object,GParamSpec * param,gpointer tzmenu)14 location_changed (GObject *object, GParamSpec *param, gpointer tzmenu)
15 {
16 MateWeatherLocationEntry *entry = MATEWEATHER_LOCATION_ENTRY (object);
17 MateWeatherLocation *loc;
18 MateWeatherTimezone *zone;
19
20 loc = mateweather_location_entry_get_location (entry);
21 g_return_if_fail (loc != NULL);
22 zone = mateweather_location_get_timezone (loc);
23 if (zone)
24 mateweather_timezone_menu_set_tzid (tzmenu, mateweather_timezone_get_tzid (zone));
25 else
26 mateweather_timezone_menu_set_tzid (tzmenu, NULL);
27 if (zone)
28 mateweather_timezone_unref (zone);
29 mateweather_location_unref (loc);
30 }
31
32 int
main(int argc,char ** argv)33 main (int argc, char **argv)
34 {
35 MateWeatherLocation *loc;
36 GtkWidget *window, *vbox, *entry;
37 GtkWidget *combo;
38 gtk_init (&argc, &argv);
39
40 window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
41 gtk_window_set_title (GTK_WINDOW (window), "location");
42 gtk_container_set_border_width (GTK_CONTAINER (window), 8);
43 g_signal_connect (window, "delete-event",
44 G_CALLBACK (deleted), NULL);
45
46 vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 8);
47 gtk_container_add (GTK_CONTAINER (window), vbox);
48
49 loc = mateweather_location_new_world (FALSE);
50 entry = mateweather_location_entry_new (loc);
51 gtk_widget_set_size_request (entry, 400, -1);
52 gtk_box_pack_start (GTK_BOX (vbox), entry, FALSE, TRUE, 0);
53
54 combo = mateweather_timezone_menu_new (loc);
55 mateweather_location_unref (loc);
56 gtk_box_pack_start (GTK_BOX (vbox), combo, FALSE, TRUE, 0);
57
58 g_signal_connect (entry, "notify::location",
59 G_CALLBACK (location_changed), combo);
60
61 gtk_widget_show_all (window);
62
63 gtk_main ();
64
65 return 0;
66 }
67