1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
#include <gweather-version.h>
#include "gweather-location-entry.h"
#include "gweather-timezone-menu.h"
static void
deleted (GtkWidget *widget, GdkEvent *event, gpointer data)
{
gtk_main_quit ();
}
static void
location_changed (GObject *object, GParamSpec *param, gpointer tzmenu)
{
GWeatherLocationEntry *entry = GWEATHER_LOCATION_ENTRY (object);
GWeatherLocation *loc;
GWeatherTimezone *zone;
loc = gweather_location_entry_get_location (entry);
if (loc == NULL)
return;
zone = gweather_location_get_timezone (loc);
if (zone)
gweather_timezone_menu_set_tzid (tzmenu, gweather_timezone_get_tzid (zone));
else
gweather_timezone_menu_set_tzid (tzmenu, NULL);
if (zone)
gweather_timezone_unref (zone);
gweather_location_unref (loc);
}
int
main (int argc, char **argv)
{
GtkWidget *window, *vbox, *entry;
GtkWidget *combo;
gtk_init (&argc, &argv);
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_window_set_title (GTK_WINDOW (window), "location");
gtk_container_set_border_width (GTK_CONTAINER (window), 8);
g_signal_connect (window, "delete-event",
G_CALLBACK (deleted), NULL);
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 8);
gtk_container_add (GTK_CONTAINER (window), vbox);
entry = g_object_new (GWEATHER_TYPE_LOCATION_ENTRY,
"show-named-timezones", TRUE,
NULL);
gtk_widget_set_size_request (entry, 400, -1);
gtk_box_pack_start (GTK_BOX (vbox), entry, FALSE, TRUE, 0);
combo = gweather_timezone_menu_new (NULL);
gtk_box_pack_start (GTK_BOX (vbox), combo, FALSE, TRUE, 0);
g_signal_connect (entry, "notify::location",
G_CALLBACK (location_changed), combo);
gtk_widget_show_all (window);
gtk_main ();
return 0;
}
|