author | yippi |
Mon, 27 Sep 2010 21:07:51 +0000 | |
changeset 20108 | 51df67ca9307 |
parent 16388 | bfed3836a61c |
permissions | -rw-r--r-- |
16374 | 1 |
/jds/bin/diff -uprN gnome-panel-2.27.91.old/applets/clock/clock.c gnome-panel-2.27.91/applets/clock/clock.c |
16388
bfed3836a61c
* patches/gnome-panel-14-hide-show-weather.diff : Rework for 2.27.91
mattman
parents:
16374
diff
changeset
|
2 |
--- gnome-panel-2.27.91.old/applets/clock/clock.c 2009-08-27 18:45:22.763599000 +0100 |
bfed3836a61c
* patches/gnome-panel-14-hide-show-weather.diff : Rework for 2.27.91
mattman
parents:
16374
diff
changeset
|
3 |
+++ gnome-panel-2.27.91/applets/clock/clock.c 2009-08-27 18:57:31.552271000 +0100 |
16374 | 4 |
@@ -146,6 +146,8 @@ struct _ClockData { |
14982 | 5 |
GtkWidget *minutes_spin; |
6 |
GtkWidget *seconds_spin; |
|
7 |
GtkWidget *set_time_button; |
|
8 |
+ GtkWidget *show_weather_toggle; |
|
9 |
+ GtkWidget *show_temperature_toggle; |
|
10 |
||
11 |
GtkListStore *cities_store; |
|
12 |
GtkWidget *cities_section; |
|
16374 | 13 |
@@ -234,6 +236,7 @@ static void applet_change_orient (PanelA |
14982 | 14 |
ClockData *cd); |
15 |
||
16 |
static void edit_hide (GtkWidget *unused, ClockData *cd); |
|
17 |
+static void update_show_weather_toggles (ClockData *cd); |
|
18 |
static gboolean edit_delete (GtkWidget *unused, GdkEvent *event, ClockData *cd); |
|
19 |
static void save_cities_store (ClockData *cd); |
|
20 |
||
16388
bfed3836a61c
* patches/gnome-panel-14-hide-show-weather.diff : Rework for 2.27.91
mattman
parents:
16374
diff
changeset
|
21 |
@@ -1975,11 +1978,38 @@ update_panel_weather (ClockData *cd) |
bfed3836a61c
* patches/gnome-panel-14-hide-show-weather.diff : Rework for 2.27.91
mattman
parents:
16374
diff
changeset
|
22 |
gtk_widget_hide (cd->panel_temperature_label); |
bfed3836a61c
* patches/gnome-panel-14-hide-show-weather.diff : Rework for 2.27.91
mattman
parents:
16374
diff
changeset
|
23 |
|
bfed3836a61c
* patches/gnome-panel-14-hide-show-weather.diff : Rework for 2.27.91
mattman
parents:
16374
diff
changeset
|
24 |
if ((cd->show_weather || cd->show_temperature) && |
16374 | 25 |
- g_list_length (cd->locations) > 0) |
26 |
- gtk_widget_show (cd->weather_obox); |
|
27 |
- else |
|
28 |
- gtk_widget_hide (cd->weather_obox); |
|
16388
bfed3836a61c
* patches/gnome-panel-14-hide-show-weather.diff : Rework for 2.27.91
mattman
parents:
16374
diff
changeset
|
29 |
+ g_list_length (cd->locations) > 0) { |
14982 | 30 |
+ ClockLocation *loc = NULL; |
31 |
+ GList *locations, *l; |
|
32 |
+ gboolean current_found = FALSE; |
|
16388
bfed3836a61c
* patches/gnome-panel-14-hide-show-weather.diff : Rework for 2.27.91
mattman
parents:
16374
diff
changeset
|
33 |
|
bfed3836a61c
* patches/gnome-panel-14-hide-show-weather.diff : Rework for 2.27.91
mattman
parents:
16374
diff
changeset
|
34 |
+ /* need to process locations, if there is no current |
bfed3836a61c
* patches/gnome-panel-14-hide-show-weather.diff : Rework for 2.27.91
mattman
parents:
16374
diff
changeset
|
35 |
+ location then hide the weather/temperature on panel */ |
16374 | 36 |
+ locations = cd->locations; |
14982 | 37 |
+ for (l = locations; l; l = l->next) { |
38 |
+ loc = l->data; |
|
39 |
+ if (clock_location_is_current (loc)) { |
|
40 |
+ current_found = TRUE; |
|
41 |
+ break; |
|
42 |
+ } |
|
43 |
+ } |
|
44 |
+ if (current_found == FALSE) { |
|
45 |
+ /* There is no current location so hide the obox */ |
|
46 |
+ gtk_widget_hide(cd->weather_obox); |
|
47 |
+ } else { |
|
48 |
+ gtk_widget_show(cd->weather_obox); |
|
49 |
+ } |
|
50 |
+ } else { |
|
16388
bfed3836a61c
* patches/gnome-panel-14-hide-show-weather.diff : Rework for 2.27.91
mattman
parents:
16374
diff
changeset
|
51 |
+ gtk_widget_hide (cd->weather_obox); |
14982 | 52 |
+ } |
16388
bfed3836a61c
* patches/gnome-panel-14-hide-show-weather.diff : Rework for 2.27.91
mattman
parents:
16374
diff
changeset
|
53 |
+ |
14982 | 54 |
+ if (g_list_length (cd->locations) <= 0) { |
55 |
+ if (cd->panel_weather_icon) |
|
56 |
+ gtk_image_set_from_pixbuf (GTK_IMAGE (cd->panel_weather_icon), |
|
57 |
+ NULL); |
|
58 |
+ if (cd->panel_temperature_label) |
|
59 |
+ gtk_label_set_text (GTK_LABEL (cd->panel_temperature_label), ""); |
|
60 |
+ } |
|
16388
bfed3836a61c
* patches/gnome-panel-14-hide-show-weather.diff : Rework for 2.27.91
mattman
parents:
16374
diff
changeset
|
61 |
gtk_widget_queue_resize (cd->applet); |
14982 | 62 |
} |
63 |
||
16388
bfed3836a61c
* patches/gnome-panel-14-hide-show-weather.diff : Rework for 2.27.91
mattman
parents:
16374
diff
changeset
|
64 |
@@ -2074,19 +2104,7 @@ locations_changed (ClockData *cd) |
14982 | 65 |
ClockLocation *loc; |
66 |
glong id; |
|
67 |
||
68 |
- if (!cd->locations) { |
|
69 |
- if (cd->weather_obox) |
|
70 |
- gtk_widget_hide (cd->weather_obox); |
|
71 |
- if (cd->panel_weather_icon) |
|
72 |
- gtk_image_set_from_pixbuf (GTK_IMAGE (cd->panel_weather_icon), |
|
73 |
- NULL); |
|
74 |
- if (cd->panel_temperature_label) |
|
75 |
- gtk_label_set_text (GTK_LABEL (cd->panel_temperature_label), |
|
76 |
- ""); |
|
77 |
- } else { |
|
78 |
- if (cd->weather_obox) |
|
79 |
- gtk_widget_show (cd->weather_obox); |
|
80 |
- } |
|
16388
bfed3836a61c
* patches/gnome-panel-14-hide-show-weather.diff : Rework for 2.27.91
mattman
parents:
16374
diff
changeset
|
81 |
+ update_panel_weather (cd); |
14982 | 82 |
|
83 |
for (l = cd->locations; l; l = l->next) { |
|
84 |
loc = l->data; |
|
16388
bfed3836a61c
* patches/gnome-panel-14-hide-show-weather.diff : Rework for 2.27.91
mattman
parents:
16374
diff
changeset
|
85 |
@@ -3121,12 +3139,25 @@ edit_clear (ClockData *cd) |
14982 | 86 |
} |
87 |
||
88 |
static void |
|
89 |
+update_show_weather_toggles(ClockData *cd) |
|
90 |
+{ |
|
91 |
+ if (g_list_length (cd->locations) <= 0) { |
|
92 |
+ gtk_widget_set_sensitive (cd->show_weather_toggle, FALSE); |
|
93 |
+ gtk_widget_set_sensitive (cd->show_temperature_toggle, FALSE); |
|
94 |
+ } else { |
|
95 |
+ gtk_widget_set_sensitive (cd->show_weather_toggle, TRUE); |
|
96 |
+ gtk_widget_set_sensitive (cd->show_temperature_toggle, TRUE); |
|
97 |
+ } |
|
98 |
+} |
|
99 |
+ |
|
100 |
+static void |
|
101 |
edit_hide (GtkWidget *unused, ClockData *cd) |
|
102 |
{ |
|
16374 | 103 |
GtkWidget *edit_window = _clock_get_widget (cd, "edit-location-window"); |
14982 | 104 |
|
105 |
gtk_widget_hide (edit_window); |
|
106 |
edit_clear (cd); |
|
107 |
+ update_show_weather_toggles (cd); |
|
108 |
} |
|
109 |
||
110 |
static gboolean |
|
16388
bfed3836a61c
* patches/gnome-panel-14-hide-show-weather.diff : Rework for 2.27.91
mattman
parents:
16374
diff
changeset
|
111 |
@@ -3197,6 +3228,8 @@ run_prefs_locations_remove (GtkButton *b |
14982 | 112 |
GtkTreeSelection *sel = gtk_tree_view_get_selection (GTK_TREE_VIEW (cd->prefs_locations)); |
113 |
||
114 |
gtk_tree_selection_selected_foreach (sel, remove_tree_row, cd); |
|
115 |
+ update_panel_weather (cd); |
|
116 |
+ update_show_weather_toggles (cd); |
|
117 |
} |
|
118 |
||
119 |
static void |
|
16388
bfed3836a61c
* patches/gnome-panel-14-hide-show-weather.diff : Rework for 2.27.91
mattman
parents:
16374
diff
changeset
|
120 |
@@ -3413,17 +3446,22 @@ fill_prefs_window (ClockData *cd) |
14982 | 121 |
G_CALLBACK (set_show_seconds_cb), cd); |
122 |
||
123 |
/* Set the "Show weather" checkbox */ |
|
16374 | 124 |
- widget = _clock_get_widget (cd, "weather_check"); |
14982 | 125 |
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), cd->show_weather); |
126 |
- g_signal_connect (widget, "toggled", |
|
16388
bfed3836a61c
* patches/gnome-panel-14-hide-show-weather.diff : Rework for 2.27.91
mattman
parents:
16374
diff
changeset
|
127 |
+ cd->show_weather_toggle = _clock_get_widget (cd, "weather_check"); |
14982 | 128 |
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (cd->show_weather_toggle), |
129 |
+ cd->show_weather); |
|
130 |
+ g_signal_connect (cd->show_weather_toggle, "toggled", |
|
16388
bfed3836a61c
* patches/gnome-panel-14-hide-show-weather.diff : Rework for 2.27.91
mattman
parents:
16374
diff
changeset
|
131 |
G_CALLBACK (set_show_weather_cb), cd); |
14982 | 132 |
|
133 |
/* Set the "Show temperature" checkbox */ |
|
16374 | 134 |
- widget = _clock_get_widget (cd, "temperature_check"); |
14982 | 135 |
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), cd->show_temperature); |
136 |
- g_signal_connect (widget, "toggled", |
|
16388
bfed3836a61c
* patches/gnome-panel-14-hide-show-weather.diff : Rework for 2.27.91
mattman
parents:
16374
diff
changeset
|
137 |
+ cd->show_temperature_toggle = _clock_get_widget (cd, "temperature_check"); |
14982 | 138 |
+ gtk_toggle_button_set_active ( |
16388
bfed3836a61c
* patches/gnome-panel-14-hide-show-weather.diff : Rework for 2.27.91
mattman
parents:
16374
diff
changeset
|
139 |
+ GTK_TOGGLE_BUTTON (cd->show_temperature_toggle), cd->show_temperature); |
14982 | 140 |
+ g_signal_connect (cd->show_temperature_toggle, "toggled", |
16388
bfed3836a61c
* patches/gnome-panel-14-hide-show-weather.diff : Rework for 2.27.91
mattman
parents:
16374
diff
changeset
|
141 |
G_CALLBACK (set_show_temperature_cb), cd); |
bfed3836a61c
* patches/gnome-panel-14-hide-show-weather.diff : Rework for 2.27.91
mattman
parents:
16374
diff
changeset
|
142 |
|
bfed3836a61c
* patches/gnome-panel-14-hide-show-weather.diff : Rework for 2.27.91
mattman
parents:
16374
diff
changeset
|
143 |
+ /* If no Locations then cannot show/hide weather/temperature */ |
bfed3836a61c
* patches/gnome-panel-14-hide-show-weather.diff : Rework for 2.27.91
mattman
parents:
16374
diff
changeset
|
144 |
+ update_show_weather_toggles (cd); |
14982 | 145 |
+ |
146 |
/* Fill the Cities list */ |
|
16374 | 147 |
widget = _clock_get_widget (cd, "cities_list"); |
16388
bfed3836a61c
* patches/gnome-panel-14-hide-show-weather.diff : Rework for 2.27.91
mattman
parents:
16374
diff
changeset
|
148 |
|
bfed3836a61c
* patches/gnome-panel-14-hide-show-weather.diff : Rework for 2.27.91
mattman
parents:
16374
diff
changeset
|
149 |
@@ -3490,8 +3528,10 @@ ensure_prefs_window_is_created (ClockDat |
14982 | 150 |
GtkTreeSelection *selection; |
151 |
GWeatherLocation *world; |
|
152 |
||
153 |
- if (cd->prefs_window) |
|
154 |
+ if (cd->prefs_window) { |
|
155 |
+ update_show_weather_toggles (cd); |
|
156 |
return; |
|
157 |
+ } |
|
158 |
||
16374 | 159 |
cd->prefs_window = _clock_get_widget (cd, "prefs-window"); |
14982 | 160 |