1 | /* $Id: gweather-dialog.c,v 1.1.1.3 2004-10-04 03:07:37 ghudson Exp $ */ |
---|
2 | |
---|
3 | /* |
---|
4 | * Papadimitriou Spiros <spapadim+@cs.cmu.edu> |
---|
5 | * |
---|
6 | * This code released under the GNU GPL. |
---|
7 | * Read the file COPYING for more information. |
---|
8 | * |
---|
9 | * Main status dialog |
---|
10 | * |
---|
11 | */ |
---|
12 | |
---|
13 | #ifdef HAVE_CONFIG_H |
---|
14 | # include <config.h> |
---|
15 | #endif |
---|
16 | |
---|
17 | #include <stdio.h> |
---|
18 | #include <stdlib.h> |
---|
19 | #include <assert.h> |
---|
20 | |
---|
21 | #include <gnome.h> |
---|
22 | |
---|
23 | #include "weather.h" |
---|
24 | #include "gweather.h" |
---|
25 | #include "gweather-applet.h" |
---|
26 | #include "gweather-pref.h" |
---|
27 | #include "gweather-dialog.h" |
---|
28 | |
---|
29 | |
---|
30 | static void response_cb (GtkDialog *dialog, gint id, gpointer data) |
---|
31 | { |
---|
32 | GWeatherApplet *gw_applet = (GWeatherApplet *)data; |
---|
33 | |
---|
34 | if (id == GTK_RESPONSE_OK) { |
---|
35 | gweather_update (gw_applet); |
---|
36 | |
---|
37 | gweather_dialog_update (gw_applet); |
---|
38 | |
---|
39 | return; |
---|
40 | } |
---|
41 | |
---|
42 | gweather_dialog_close(gw_applet); |
---|
43 | return; |
---|
44 | } |
---|
45 | |
---|
46 | static void link_cb (GtkButton *button, gpointer data) |
---|
47 | { |
---|
48 | gnome_url_show("http://www.weather.com/", NULL); |
---|
49 | return; |
---|
50 | button = NULL; |
---|
51 | data = NULL; |
---|
52 | } |
---|
53 | |
---|
54 | void gweather_dialog_create (GWeatherApplet *gw_applet) |
---|
55 | { |
---|
56 | GtkWidget *weather_vbox; |
---|
57 | GtkWidget *weather_notebook; |
---|
58 | GtkWidget *cond_hbox; |
---|
59 | GtkWidget *cond_table; |
---|
60 | GtkWidget *cond_location_lbl; |
---|
61 | GtkWidget *cond_update_lbl; |
---|
62 | GtkWidget *cond_temp_lbl; |
---|
63 | GtkWidget *cond_cond_lbl; |
---|
64 | GtkWidget *cond_sky_lbl; |
---|
65 | GtkWidget *cond_wind_lbl; |
---|
66 | GtkWidget *cond_humidity_lbl; |
---|
67 | GtkWidget *cond_pressure_lbl; |
---|
68 | GtkWidget *cond_vis_lbl; |
---|
69 | GtkWidget *cond_dew_lbl; |
---|
70 | GtkWidget *cond_apparent_lbl; |
---|
71 | GtkWidget *cond_frame_alignment; |
---|
72 | GtkWidget *current_note_lbl; |
---|
73 | GtkWidget *forecast_note_lbl; |
---|
74 | GtkWidget *radar_note_lbl; |
---|
75 | GtkWidget *radar_vbox; |
---|
76 | GtkWidget *radar_link_btn; |
---|
77 | GtkWidget *radar_link_alignment; |
---|
78 | GtkWidget *forecast_hbox; |
---|
79 | GtkWidget *ebox; |
---|
80 | GtkWidget *scrolled_window; |
---|
81 | GtkWidget *imagescroll_window; |
---|
82 | |
---|
83 | gw_applet->gweather_dialog = gtk_dialog_new_with_buttons (_("Details"), NULL, |
---|
84 | GTK_DIALOG_DESTROY_WITH_PARENT, |
---|
85 | _("_Update"), |
---|
86 | GTK_RESPONSE_OK, |
---|
87 | GTK_STOCK_CLOSE, |
---|
88 | GTK_RESPONSE_CLOSE, |
---|
89 | NULL); |
---|
90 | |
---|
91 | gtk_dialog_set_default_response (GTK_DIALOG (gw_applet->gweather_dialog), |
---|
92 | GTK_RESPONSE_CLOSE); |
---|
93 | |
---|
94 | if (gw_applet->gweather_pref.radar_enabled) |
---|
95 | gtk_window_set_default_size (GTK_WINDOW(gw_applet->gweather_dialog), 570,440); |
---|
96 | else |
---|
97 | gtk_window_set_default_size (GTK_WINDOW(gw_applet->gweather_dialog), 590, 340); |
---|
98 | |
---|
99 | gtk_window_set_screen (GTK_WINDOW (gw_applet->gweather_dialog), |
---|
100 | gtk_widget_get_screen (GTK_WIDGET (gw_applet->applet))); |
---|
101 | gtk_window_set_policy (GTK_WINDOW (gw_applet->gweather_dialog), FALSE, FALSE, FALSE); |
---|
102 | |
---|
103 | weather_vbox = GTK_DIALOG (gw_applet->gweather_dialog)->vbox; |
---|
104 | gtk_widget_show (weather_vbox); |
---|
105 | |
---|
106 | weather_notebook = gtk_notebook_new (); |
---|
107 | gtk_container_set_border_width (GTK_CONTAINER (weather_notebook), 5); |
---|
108 | gtk_widget_show (weather_notebook); |
---|
109 | gtk_box_pack_start (GTK_BOX (weather_vbox), weather_notebook, TRUE, TRUE, 0); |
---|
110 | |
---|
111 | cond_hbox = gtk_hbox_new (FALSE, 2); |
---|
112 | gtk_widget_show (cond_hbox); |
---|
113 | gtk_container_add (GTK_CONTAINER (weather_notebook), cond_hbox); |
---|
114 | gtk_container_set_border_width (GTK_CONTAINER (cond_hbox), 4); |
---|
115 | |
---|
116 | cond_table = gtk_table_new (11, 2, FALSE); |
---|
117 | gtk_widget_show (cond_table); |
---|
118 | gtk_box_pack_start (GTK_BOX (cond_hbox), cond_table, TRUE, TRUE, 0); |
---|
119 | gtk_container_set_border_width (GTK_CONTAINER (cond_table), 12); |
---|
120 | gtk_table_set_row_spacings (GTK_TABLE (cond_table), 6); |
---|
121 | gtk_table_set_col_spacings (GTK_TABLE (cond_table), 12); |
---|
122 | |
---|
123 | cond_location_lbl = gtk_label_new (_("City:")); |
---|
124 | gtk_widget_show (cond_location_lbl); |
---|
125 | gtk_table_attach (GTK_TABLE (cond_table), cond_location_lbl, 0, 1, 0, 1, |
---|
126 | (GtkAttachOptions) (GTK_FILL), |
---|
127 | (GtkAttachOptions) (0), 0, 0); |
---|
128 | gtk_label_set_justify (GTK_LABEL (cond_location_lbl), GTK_JUSTIFY_LEFT); |
---|
129 | gtk_misc_set_alignment (GTK_MISC (cond_location_lbl), 0, 0.5); |
---|
130 | |
---|
131 | cond_update_lbl = gtk_label_new (_("Last update:")); |
---|
132 | gtk_widget_show (cond_update_lbl); |
---|
133 | gtk_table_attach (GTK_TABLE (cond_table), cond_update_lbl, 0, 1, 1, 2, |
---|
134 | (GtkAttachOptions) (GTK_FILL), |
---|
135 | (GtkAttachOptions) (0), 0, 0); |
---|
136 | gtk_label_set_justify (GTK_LABEL (cond_update_lbl), GTK_JUSTIFY_LEFT); |
---|
137 | gtk_misc_set_alignment (GTK_MISC (cond_update_lbl), 0, 0.5); |
---|
138 | |
---|
139 | cond_cond_lbl = gtk_label_new (_("Conditions:")); |
---|
140 | gtk_widget_show (cond_cond_lbl); |
---|
141 | gtk_table_attach (GTK_TABLE (cond_table), cond_cond_lbl, 0, 1, 2, 3, |
---|
142 | (GtkAttachOptions) (GTK_FILL), |
---|
143 | (GtkAttachOptions) (0), 0, 0); |
---|
144 | gtk_label_set_justify (GTK_LABEL (cond_cond_lbl), GTK_JUSTIFY_LEFT); |
---|
145 | gtk_misc_set_alignment (GTK_MISC (cond_cond_lbl), 0, 0.5); |
---|
146 | |
---|
147 | cond_sky_lbl = gtk_label_new (_("Sky:")); |
---|
148 | gtk_widget_show (cond_sky_lbl); |
---|
149 | gtk_table_attach (GTK_TABLE (cond_table), cond_sky_lbl, 0, 1, 3, 4, |
---|
150 | (GtkAttachOptions) (GTK_FILL), |
---|
151 | (GtkAttachOptions) (0), 0, 0); |
---|
152 | gtk_label_set_justify (GTK_LABEL (cond_sky_lbl), GTK_JUSTIFY_LEFT); |
---|
153 | gtk_misc_set_alignment (GTK_MISC (cond_sky_lbl), 0, 0.5); |
---|
154 | |
---|
155 | cond_temp_lbl = gtk_label_new (_("Temperature:")); |
---|
156 | gtk_widget_show (cond_temp_lbl); |
---|
157 | gtk_table_attach (GTK_TABLE (cond_table), cond_temp_lbl, 0, 1, 4, 5, |
---|
158 | (GtkAttachOptions) (GTK_FILL), |
---|
159 | (GtkAttachOptions) (0), 0, 0); |
---|
160 | gtk_label_set_justify (GTK_LABEL (cond_temp_lbl), GTK_JUSTIFY_LEFT); |
---|
161 | gtk_misc_set_alignment (GTK_MISC (cond_temp_lbl), 0, 0.5); |
---|
162 | |
---|
163 | cond_apparent_lbl = gtk_label_new (_("Feels like:")); |
---|
164 | gtk_widget_show (cond_apparent_lbl); |
---|
165 | gtk_table_attach (GTK_TABLE (cond_table), cond_apparent_lbl, 0, 1, 5, 6, |
---|
166 | (GtkAttachOptions) (GTK_FILL), |
---|
167 | (GtkAttachOptions) (0), 0, 0); |
---|
168 | gtk_label_set_justify (GTK_LABEL (cond_apparent_lbl), GTK_JUSTIFY_LEFT); |
---|
169 | gtk_misc_set_alignment (GTK_MISC (cond_apparent_lbl), 0, 0.5); |
---|
170 | |
---|
171 | cond_dew_lbl = gtk_label_new (_("Dew point:")); |
---|
172 | gtk_widget_show (cond_dew_lbl); |
---|
173 | gtk_table_attach (GTK_TABLE (cond_table), cond_dew_lbl, 0, 1, 6, 7, |
---|
174 | (GtkAttachOptions) (GTK_FILL), |
---|
175 | (GtkAttachOptions) (0), 0, 0); |
---|
176 | gtk_label_set_justify (GTK_LABEL (cond_dew_lbl), GTK_JUSTIFY_LEFT); |
---|
177 | gtk_misc_set_alignment (GTK_MISC (cond_dew_lbl), 0, 0.5); |
---|
178 | |
---|
179 | cond_humidity_lbl = gtk_label_new (_("Relative humidity:")); |
---|
180 | gtk_widget_show (cond_humidity_lbl); |
---|
181 | gtk_table_attach (GTK_TABLE (cond_table), cond_humidity_lbl, 0, 1, 7, 8, |
---|
182 | (GtkAttachOptions) (GTK_FILL), |
---|
183 | (GtkAttachOptions) (0), 0, 0); |
---|
184 | gtk_label_set_justify (GTK_LABEL (cond_humidity_lbl), GTK_JUSTIFY_LEFT); |
---|
185 | gtk_misc_set_alignment (GTK_MISC (cond_humidity_lbl), 0, 0.5); |
---|
186 | |
---|
187 | cond_wind_lbl = gtk_label_new (_("Wind:")); |
---|
188 | gtk_widget_show (cond_wind_lbl); |
---|
189 | gtk_table_attach (GTK_TABLE (cond_table), cond_wind_lbl, 0, 1, 8, 9, |
---|
190 | (GtkAttachOptions) (GTK_FILL), |
---|
191 | (GtkAttachOptions) (0), 0, 0); |
---|
192 | gtk_label_set_justify (GTK_LABEL (cond_wind_lbl), GTK_JUSTIFY_LEFT); |
---|
193 | gtk_misc_set_alignment (GTK_MISC (cond_wind_lbl), 0, 0.5); |
---|
194 | |
---|
195 | cond_pressure_lbl = gtk_label_new (_("Pressure:")); |
---|
196 | gtk_widget_show (cond_pressure_lbl); |
---|
197 | gtk_table_attach (GTK_TABLE (cond_table), cond_pressure_lbl, 0, 1, 9, 10, |
---|
198 | (GtkAttachOptions) (GTK_FILL), |
---|
199 | (GtkAttachOptions) (0), 0, 0); |
---|
200 | gtk_label_set_justify (GTK_LABEL (cond_pressure_lbl), GTK_JUSTIFY_LEFT); |
---|
201 | gtk_misc_set_alignment (GTK_MISC (cond_pressure_lbl), 0, 0.5); |
---|
202 | |
---|
203 | cond_vis_lbl = gtk_label_new (_("Visibility:")); |
---|
204 | gtk_widget_show (cond_vis_lbl); |
---|
205 | gtk_table_attach (GTK_TABLE (cond_table), cond_vis_lbl, 0, 1, 10, 11, |
---|
206 | (GtkAttachOptions) (GTK_FILL), |
---|
207 | (GtkAttachOptions) (0), 0, 0); |
---|
208 | gtk_label_set_justify (GTK_LABEL (cond_vis_lbl), GTK_JUSTIFY_LEFT); |
---|
209 | gtk_misc_set_alignment (GTK_MISC (cond_vis_lbl), 0, 0.5); |
---|
210 | |
---|
211 | gw_applet->cond_location = gtk_label_new (""); |
---|
212 | gtk_widget_show (gw_applet->cond_location); |
---|
213 | gtk_table_attach (GTK_TABLE (cond_table), gw_applet->cond_location, 1, 2, 0, 1, |
---|
214 | (GtkAttachOptions) (GTK_EXPAND | GTK_FILL), |
---|
215 | (GtkAttachOptions) (0), 0, 0); |
---|
216 | gtk_label_set_justify (GTK_LABEL (gw_applet->cond_location), GTK_JUSTIFY_LEFT); |
---|
217 | gtk_misc_set_alignment (GTK_MISC (gw_applet->cond_location), 0, 0.5); |
---|
218 | |
---|
219 | gw_applet->cond_update = gtk_label_new (""); |
---|
220 | gtk_widget_show (gw_applet->cond_update); |
---|
221 | gtk_table_attach (GTK_TABLE (cond_table), gw_applet->cond_update, 1, 2, 1, 2, |
---|
222 | (GtkAttachOptions) (GTK_EXPAND | GTK_FILL), |
---|
223 | (GtkAttachOptions) (0), 0, 0); |
---|
224 | gtk_label_set_justify (GTK_LABEL (gw_applet->cond_update), GTK_JUSTIFY_LEFT); |
---|
225 | gtk_misc_set_alignment (GTK_MISC (gw_applet->cond_update), 0, 0.5); |
---|
226 | |
---|
227 | gw_applet->cond_cond = gtk_label_new (""); |
---|
228 | gtk_widget_show (gw_applet->cond_cond); |
---|
229 | gtk_table_attach (GTK_TABLE (cond_table), gw_applet->cond_cond, 1, 2, 2, 3, |
---|
230 | (GtkAttachOptions) (GTK_EXPAND | GTK_FILL), |
---|
231 | (GtkAttachOptions) (0), 0, 0); |
---|
232 | gtk_label_set_justify (GTK_LABEL (gw_applet->cond_cond), GTK_JUSTIFY_LEFT); |
---|
233 | gtk_misc_set_alignment (GTK_MISC (gw_applet->cond_cond), 0, 0.5); |
---|
234 | |
---|
235 | gw_applet->cond_sky = gtk_label_new (""); |
---|
236 | gtk_widget_show (gw_applet->cond_sky); |
---|
237 | gtk_table_attach (GTK_TABLE (cond_table), gw_applet->cond_sky, 1, 2, 3, 4, |
---|
238 | (GtkAttachOptions) (GTK_EXPAND | GTK_FILL), |
---|
239 | (GtkAttachOptions) (0), 0, 0); |
---|
240 | gtk_label_set_justify (GTK_LABEL (gw_applet->cond_sky), GTK_JUSTIFY_LEFT); |
---|
241 | gtk_misc_set_alignment (GTK_MISC (gw_applet->cond_sky), 0, 0.5); |
---|
242 | |
---|
243 | gw_applet->cond_temp = gtk_label_new (""); |
---|
244 | gtk_widget_show (gw_applet->cond_temp); |
---|
245 | gtk_table_attach (GTK_TABLE (cond_table), gw_applet->cond_temp, 1, 2, 4, 5, |
---|
246 | (GtkAttachOptions) (GTK_EXPAND | GTK_FILL), |
---|
247 | (GtkAttachOptions) (0), 0, 0); |
---|
248 | gtk_label_set_justify (GTK_LABEL (gw_applet->cond_temp), GTK_JUSTIFY_LEFT); |
---|
249 | gtk_misc_set_alignment (GTK_MISC (gw_applet->cond_temp), 0, 0.5); |
---|
250 | |
---|
251 | gw_applet->cond_apparent = gtk_label_new (""); |
---|
252 | gtk_widget_show (gw_applet->cond_apparent); |
---|
253 | gtk_table_attach (GTK_TABLE (cond_table), gw_applet->cond_apparent, 1, 2, 5, 6, |
---|
254 | (GtkAttachOptions) (GTK_EXPAND | GTK_FILL), |
---|
255 | (GtkAttachOptions) (0), 0, 0); |
---|
256 | gtk_label_set_justify (GTK_LABEL (gw_applet->cond_apparent), GTK_JUSTIFY_LEFT); |
---|
257 | gtk_misc_set_alignment (GTK_MISC (gw_applet->cond_apparent), 0, 0.5); |
---|
258 | |
---|
259 | gw_applet->cond_dew = gtk_label_new (""); |
---|
260 | gtk_widget_show (gw_applet->cond_dew); |
---|
261 | gtk_table_attach (GTK_TABLE (cond_table), gw_applet->cond_dew, 1, 2, 6, 7, |
---|
262 | (GtkAttachOptions) (GTK_EXPAND | GTK_FILL), |
---|
263 | (GtkAttachOptions) (0), 0, 0); |
---|
264 | gtk_label_set_justify (GTK_LABEL (gw_applet->cond_dew), GTK_JUSTIFY_LEFT); |
---|
265 | gtk_misc_set_alignment (GTK_MISC (gw_applet->cond_dew), 0, 0.5); |
---|
266 | |
---|
267 | gw_applet->cond_humidity = gtk_label_new (""); |
---|
268 | gtk_widget_show (gw_applet->cond_humidity); |
---|
269 | gtk_table_attach (GTK_TABLE (cond_table), gw_applet->cond_humidity, 1, 2, 7, 8, |
---|
270 | (GtkAttachOptions) (GTK_EXPAND | GTK_FILL), |
---|
271 | (GtkAttachOptions) (0), 0, 0); |
---|
272 | gtk_label_set_justify (GTK_LABEL (gw_applet->cond_humidity), GTK_JUSTIFY_LEFT); |
---|
273 | gtk_misc_set_alignment (GTK_MISC (gw_applet->cond_humidity), 0, 0.5); |
---|
274 | |
---|
275 | gw_applet->cond_wind = gtk_label_new (""); |
---|
276 | gtk_widget_show (gw_applet->cond_wind); |
---|
277 | gtk_table_attach (GTK_TABLE (cond_table), gw_applet->cond_wind, 1, 2, 8, 9, |
---|
278 | (GtkAttachOptions) (GTK_EXPAND | GTK_FILL), |
---|
279 | (GtkAttachOptions) (0), 0, 0); |
---|
280 | gtk_label_set_justify (GTK_LABEL (gw_applet->cond_wind), GTK_JUSTIFY_LEFT); |
---|
281 | gtk_misc_set_alignment (GTK_MISC (gw_applet->cond_wind), 0, 0.5); |
---|
282 | |
---|
283 | gw_applet->cond_pressure = gtk_label_new (""); |
---|
284 | gtk_widget_show (gw_applet->cond_pressure); |
---|
285 | gtk_table_attach (GTK_TABLE (cond_table), gw_applet->cond_pressure, 1, 2, 9, 10, |
---|
286 | (GtkAttachOptions) (GTK_EXPAND | GTK_FILL), |
---|
287 | (GtkAttachOptions) (0), 0, 0); |
---|
288 | gtk_label_set_justify (GTK_LABEL (gw_applet->cond_pressure), GTK_JUSTIFY_LEFT); |
---|
289 | gtk_misc_set_alignment (GTK_MISC (gw_applet->cond_pressure), 0, 0.5); |
---|
290 | |
---|
291 | gw_applet->cond_vis = gtk_label_new (""); |
---|
292 | gtk_widget_show (gw_applet->cond_vis); |
---|
293 | gtk_table_attach (GTK_TABLE (cond_table), gw_applet->cond_vis, 1, 2, 10, 11, |
---|
294 | (GtkAttachOptions) (GTK_EXPAND | GTK_FILL), |
---|
295 | (GtkAttachOptions) (0), 0, 0); |
---|
296 | gtk_label_set_justify (GTK_LABEL (gw_applet->cond_vis), GTK_JUSTIFY_LEFT); |
---|
297 | gtk_misc_set_alignment (GTK_MISC (gw_applet->cond_vis), 0, 0.5); |
---|
298 | |
---|
299 | cond_frame_alignment = gtk_alignment_new (0.5, 0, 1, 0); |
---|
300 | gtk_widget_show (cond_frame_alignment); |
---|
301 | gtk_box_pack_end (GTK_BOX (cond_hbox), cond_frame_alignment, FALSE, FALSE, 0); |
---|
302 | gtk_container_set_border_width (GTK_CONTAINER (cond_frame_alignment), 2); |
---|
303 | |
---|
304 | weather_info_get_pixbuf (NULL, &(gw_applet->dialog_pixbuf)); |
---|
305 | gw_applet->cond_image = gtk_image_new_from_pixbuf (gw_applet->dialog_pixbuf); |
---|
306 | gtk_widget_show (gw_applet->cond_image); |
---|
307 | gtk_container_add (GTK_CONTAINER (cond_frame_alignment), gw_applet->cond_image); |
---|
308 | |
---|
309 | current_note_lbl = gtk_label_new (_("Current Conditions")); |
---|
310 | gtk_widget_show (current_note_lbl); |
---|
311 | gtk_notebook_set_tab_label (GTK_NOTEBOOK (weather_notebook), gtk_notebook_get_nth_page (GTK_NOTEBOOK (weather_notebook), 0), current_note_lbl); |
---|
312 | |
---|
313 | if (gw_applet->gweather_pref.location->zone_valid) { |
---|
314 | |
---|
315 | forecast_hbox = gtk_hbox_new(FALSE, 0); |
---|
316 | gtk_container_set_border_width (GTK_CONTAINER (forecast_hbox), 12); |
---|
317 | gtk_widget_show (forecast_hbox); |
---|
318 | |
---|
319 | scrolled_window = gtk_scrolled_window_new (NULL, NULL); |
---|
320 | gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window), |
---|
321 | GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); |
---|
322 | gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolled_window), |
---|
323 | GTK_SHADOW_ETCHED_IN); |
---|
324 | |
---|
325 | gw_applet->forecast_text = gtk_text_view_new (); |
---|
326 | set_access_namedesc (gw_applet->forecast_text, _("Forecast Report"), _("See the ForeCast Details")); |
---|
327 | gtk_container_add (GTK_CONTAINER (scrolled_window), gw_applet->forecast_text); |
---|
328 | gtk_text_view_set_editable (GTK_TEXT_VIEW (gw_applet->forecast_text), FALSE); |
---|
329 | gtk_text_view_set_left_margin (GTK_TEXT_VIEW (gw_applet->forecast_text), 6); |
---|
330 | gtk_widget_show (gw_applet->forecast_text); |
---|
331 | gtk_widget_show (scrolled_window); |
---|
332 | gtk_box_pack_start (GTK_BOX (forecast_hbox), scrolled_window, TRUE, TRUE, 0); |
---|
333 | |
---|
334 | gtk_container_add (GTK_CONTAINER (weather_notebook), forecast_hbox); |
---|
335 | |
---|
336 | forecast_note_lbl = gtk_label_new (_("Forecast")); |
---|
337 | gtk_widget_show (forecast_note_lbl); |
---|
338 | gtk_notebook_set_tab_label (GTK_NOTEBOOK (weather_notebook), gtk_notebook_get_nth_page (GTK_NOTEBOOK (weather_notebook), 1), forecast_note_lbl); |
---|
339 | |
---|
340 | } |
---|
341 | |
---|
342 | if (gw_applet->gweather_pref.radar_enabled) { |
---|
343 | |
---|
344 | radar_note_lbl = gtk_label_new_with_mnemonic (_("Radar Map")); |
---|
345 | gtk_widget_show (radar_note_lbl); |
---|
346 | |
---|
347 | radar_vbox = gtk_vbox_new (FALSE, 6); |
---|
348 | gtk_widget_show (radar_vbox); |
---|
349 | gtk_notebook_append_page (GTK_NOTEBOOK (weather_notebook), radar_vbox, radar_note_lbl); |
---|
350 | gtk_container_set_border_width (GTK_CONTAINER (radar_vbox), 6); |
---|
351 | |
---|
352 | gw_applet->radar_image = gtk_image_new_from_pixbuf (gw_applet->dialog_pixbuf); /* Tmp hack */ |
---|
353 | |
---|
354 | imagescroll_window = gtk_scrolled_window_new (NULL, NULL); |
---|
355 | gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (imagescroll_window), |
---|
356 | GTK_POLICY_AUTOMATIC, |
---|
357 | GTK_POLICY_AUTOMATIC); |
---|
358 | gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (imagescroll_window), |
---|
359 | GTK_SHADOW_ETCHED_IN); |
---|
360 | |
---|
361 | ebox = gtk_event_box_new (); |
---|
362 | gtk_widget_show (ebox); |
---|
363 | |
---|
364 | gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(imagescroll_window),ebox); |
---|
365 | gtk_box_pack_start (GTK_BOX (radar_vbox), imagescroll_window, TRUE, TRUE, 0); |
---|
366 | gtk_widget_show (gw_applet->radar_image); |
---|
367 | gtk_widget_show (imagescroll_window); |
---|
368 | |
---|
369 | gtk_container_add (GTK_CONTAINER (ebox), gw_applet->radar_image); |
---|
370 | |
---|
371 | radar_link_alignment = gtk_alignment_new (0.5, 0.5, 0, 0); |
---|
372 | gtk_widget_show (radar_link_alignment); |
---|
373 | gtk_box_pack_start (GTK_BOX (radar_vbox), radar_link_alignment, FALSE, FALSE, 0); |
---|
374 | |
---|
375 | radar_link_btn = gtk_button_new_with_mnemonic (_("_Visit Weather.com")); |
---|
376 | set_access_namedesc (radar_link_btn, _("Visit Weather.com"), _("Click to Enter Weather.com")); |
---|
377 | gtk_widget_set_usize(radar_link_btn, 450, -2); |
---|
378 | gtk_widget_show (radar_link_btn); |
---|
379 | gtk_container_add (GTK_CONTAINER (radar_link_alignment), radar_link_btn); |
---|
380 | |
---|
381 | gtk_signal_connect (GTK_OBJECT (radar_link_btn), "clicked", |
---|
382 | GTK_SIGNAL_FUNC (link_cb), NULL); |
---|
383 | |
---|
384 | } |
---|
385 | |
---|
386 | g_signal_connect (G_OBJECT (gw_applet->gweather_dialog), "response", |
---|
387 | G_CALLBACK (response_cb), gw_applet); |
---|
388 | |
---|
389 | } |
---|
390 | |
---|
391 | void gweather_dialog_open (GWeatherApplet *gw_applet) |
---|
392 | { |
---|
393 | if (gw_applet->gweather_dialog == NULL) |
---|
394 | gweather_dialog_create(gw_applet); |
---|
395 | else { |
---|
396 | gtk_window_set_screen (GTK_WINDOW (gw_applet->gweather_dialog), |
---|
397 | gtk_widget_get_screen (GTK_WIDGET (gw_applet->applet))); |
---|
398 | |
---|
399 | gtk_window_present (GTK_WINDOW (gw_applet->gweather_dialog)); |
---|
400 | } |
---|
401 | |
---|
402 | gweather_dialog_update(gw_applet); |
---|
403 | gtk_dialog_set_has_separator (GTK_DIALOG (gw_applet->gweather_dialog), FALSE); |
---|
404 | gtk_container_set_border_width (GTK_CONTAINER (gw_applet->gweather_dialog), 5); |
---|
405 | gtk_box_set_spacing (GTK_BOX (GTK_DIALOG (gw_applet->gweather_dialog)->vbox), 2); |
---|
406 | gtk_window_set_resizable(GTK_WINDOW(gw_applet->gweather_dialog), TRUE); |
---|
407 | gtk_widget_show(gw_applet->gweather_dialog); |
---|
408 | } |
---|
409 | |
---|
410 | void gweather_dialog_close (GWeatherApplet *gw_applet) |
---|
411 | { |
---|
412 | g_return_if_fail(gw_applet->gweather_dialog != NULL); |
---|
413 | gtk_widget_destroy(gw_applet->gweather_dialog); |
---|
414 | gw_applet->gweather_dialog = NULL; |
---|
415 | gw_applet->dialog_mask = NULL; |
---|
416 | } |
---|
417 | |
---|
418 | void gweather_dialog_display_toggle (GWeatherApplet *gw_applet) |
---|
419 | { |
---|
420 | if (!gw_applet->gweather_dialog || !GTK_WIDGET_VISIBLE(gw_applet->gweather_dialog)) |
---|
421 | gweather_dialog_open(gw_applet); |
---|
422 | else |
---|
423 | gweather_dialog_close(gw_applet); |
---|
424 | } |
---|
425 | |
---|
426 | void gweather_dialog_update (GWeatherApplet *gw_applet) |
---|
427 | { |
---|
428 | const gchar *forecast; |
---|
429 | GtkTextBuffer *buffer; |
---|
430 | /*GdkFont* detailed_forecast_font = gdk_fontset_load ( "fixed" );*/ |
---|
431 | |
---|
432 | /* Check for parallel network update in progress */ |
---|
433 | if(gw_applet->gweather_info == NULL) |
---|
434 | return; |
---|
435 | |
---|
436 | if (!gw_applet->gweather_dialog) |
---|
437 | return; |
---|
438 | |
---|
439 | /* Update pixbuf */ |
---|
440 | weather_info_get_pixbuf(gw_applet->gweather_info, |
---|
441 | &(gw_applet->dialog_pixbuf)); |
---|
442 | gtk_image_set_from_pixbuf (GTK_IMAGE (gw_applet->cond_image), |
---|
443 | gw_applet->dialog_pixbuf); |
---|
444 | |
---|
445 | /* Update current condition fields and forecast */ |
---|
446 | gtk_label_set_text(GTK_LABEL(gw_applet->cond_location), weather_info_get_location(gw_applet->gweather_info)); |
---|
447 | gtk_label_set_text(GTK_LABEL(gw_applet->cond_update), weather_info_get_update(gw_applet->gweather_info)); |
---|
448 | gtk_label_set_text(GTK_LABEL(gw_applet->cond_cond), weather_info_get_conditions(gw_applet->gweather_info)); |
---|
449 | gtk_label_set_text(GTK_LABEL(gw_applet->cond_sky), weather_info_get_sky(gw_applet->gweather_info)); |
---|
450 | gtk_label_set_text(GTK_LABEL(gw_applet->cond_temp), weather_info_get_temp(gw_applet->gweather_info)); |
---|
451 | gtk_label_set_text(GTK_LABEL(gw_applet->cond_apparent), weather_info_get_apparent(gw_applet->gweather_info)); |
---|
452 | gtk_label_set_text(GTK_LABEL(gw_applet->cond_dew), weather_info_get_dew(gw_applet->gweather_info)); |
---|
453 | gtk_label_set_text(GTK_LABEL(gw_applet->cond_humidity), weather_info_get_humidity(gw_applet->gweather_info)); |
---|
454 | gtk_label_set_text(GTK_LABEL(gw_applet->cond_wind), weather_info_get_wind(gw_applet->gweather_info)); |
---|
455 | gtk_label_set_text(GTK_LABEL(gw_applet->cond_pressure), weather_info_get_pressure(gw_applet->gweather_info)); |
---|
456 | gtk_label_set_text(GTK_LABEL(gw_applet->cond_vis), weather_info_get_visibility(gw_applet->gweather_info)); |
---|
457 | |
---|
458 | /* Update forecast */ |
---|
459 | if (gw_applet->gweather_pref.location->zone_valid) { |
---|
460 | buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (gw_applet->forecast_text)); |
---|
461 | forecast = weather_info_get_forecast(gw_applet->gweather_info); |
---|
462 | if (forecast) { |
---|
463 | gtk_text_buffer_set_text(buffer, forecast, -1); |
---|
464 | } else { |
---|
465 | gtk_text_buffer_set_text(buffer, _("Forecast not currently available for this location."), -1); |
---|
466 | } |
---|
467 | } |
---|
468 | |
---|
469 | /* Update radar map */ |
---|
470 | if (gw_applet->gweather_pref.radar_enabled) { |
---|
471 | GdkPixmap *radar = weather_info_get_radar(gw_applet->gweather_info); |
---|
472 | if (radar) { |
---|
473 | gtk_image_set_from_pixmap (GTK_IMAGE (gw_applet->radar_image), |
---|
474 | radar, gw_applet->gweather_info->radar_mask); |
---|
475 | } |
---|
476 | } |
---|
477 | } |
---|