Bug Summary

File:cafeweather/cafeweather-pref.c
Warning:line 266, column 21
Value stored to 'gw_applet' during its initialization is never read

Annotated Source Code

Press '?' to see keyboard shortcuts

clang -cc1 -cc1 -triple x86_64-pc-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name cafeweather-pref.c -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model pic -pic-level 2 -pic-is-pie -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fcoverage-compilation-dir=/rootdir/cafeweather -resource-dir /usr/lib/llvm-16/lib/clang/16 -D HAVE_CONFIG_H -I . -I .. -I . -I .. -D CAFEWEATHER_MENU_UI_DIR="/usr/share/cafe/ui" -I /usr/include/cafe-panel-4.0/libcafe-panel-applet -I /usr/include/glib-2.0 -I /usr/lib/x86_64-linux-gnu/glib-2.0/include -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/ctk-3.0 -I /usr/include/pango-1.0 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/fribidi -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/x86_64-linux-gnu -I /usr/include/webp -I /usr/include/gio-unix-2.0 -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib/x86_64-linux-gnu/dbus-1.0/include -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/glib-2.0 -I /usr/lib/x86_64-linux-gnu/glib-2.0/include -I /usr/include/libpng16 -I /usr/include/x86_64-linux-gnu -I /usr/include/webp -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/glib-2.0 -I /usr/lib/x86_64-linux-gnu/glib-2.0/include -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/libpng16 -I /usr/include/x86_64-linux-gnu -I /usr/include/webp -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/ctk-3.0 -I /usr/include/pango-1.0 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/fribidi -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gio-unix-2.0 -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib/x86_64-linux-gnu/dbus-1.0/include -I /usr/include/libxml2 -I /usr/include/libsoup-3.0 -I /usr/include/sysprof-6 -I /usr/include/dbus-1.0 -I /usr/lib/x86_64-linux-gnu/dbus-1.0/include -I /usr/include/glib-2.0 -I /usr/lib/x86_64-linux-gnu/glib-2.0/include -internal-isystem /usr/lib/llvm-16/lib/clang/16/include -internal-isystem /usr/local/include -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/13/../../../../x86_64-linux-gnu/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -fdebug-compilation-dir=/rootdir/cafeweather -ferror-limit 19 -fgnuc-version=4.2.1 -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2024-04-16-122014-85828-1 -x c cafeweather-pref.c
1/* $Id$ */
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 * Preferences dialog
10 *
11 */
12
13/* Radar map on by default. */
14#define RADARMAP
15
16#ifdef HAVE_CONFIG_H1
17 #include <config.h>
18#endif
19
20#include <stdio.h>
21#include <stdlib.h>
22#include <string.h>
23#include <assert.h>
24#include <ctype.h>
25#include <locale.h>
26
27#include <cafe-panel-applet.h>
28#include <gio/gio.h>
29
30#define CAFEWEATHER_I_KNOW_THIS_IS_UNSTABLE
31
32#include <libcafeweather/cafeweather-xml.h>
33#include "cafeweather.h"
34#include "cafeweather-pref.h"
35#include "cafeweather-applet.h"
36#include "cafeweather-dialog.h"
37
38#define NEVER_SENSITIVE"never_sensitive" "never_sensitive"
39
40struct _CafeWeatherPrefPrivate {
41 CtkWidget* notebook;
42
43 CtkWidget* basic_temp_combo;
44 CtkWidget* basic_speed_combo;
45 CtkWidget* basic_dist_combo;
46 CtkWidget* basic_pres_combo;
47 CtkWidget* find_entry;
48 CtkWidget* find_next_btn;
49
50 #ifdef RADARMAP
51 CtkWidget* basic_radar_btn;
52 CtkWidget* basic_radar_url_btn;
53 CtkWidget* basic_radar_url_hbox;
54 CtkWidget* basic_radar_url_entry;
55 #endif /* RADARMAP */
56
57 #ifdef HAVE_LIBNOTIFY1
58 CtkWidget* basic_show_notifications_btn;
59 #endif
60
61 CtkWidget* basic_update_spin;
62 CtkWidget* basic_update_btn;
63 CtkWidget* tree;
64
65 CtkTreeModel* model;
66
67 CafeWeatherApplet* applet;
68};
69
70enum {
71 PROP_0,
72 PROP_CAFEWEATHER_APPLET,
73};
74
75G_DEFINE_TYPE_WITH_PRIVATE (CafeWeatherPref, cafeweather_pref, CTK_TYPE_DIALOG)static void cafeweather_pref_init (CafeWeatherPref *self); static
void cafeweather_pref_class_init (CafeWeatherPrefClass *klass
); static GType cafeweather_pref_get_type_once (void); static
gpointer cafeweather_pref_parent_class = ((void*)0); static gint
CafeWeatherPref_private_offset; static void cafeweather_pref_class_intern_init
(gpointer klass) { cafeweather_pref_parent_class = g_type_class_peek_parent
(klass); if (CafeWeatherPref_private_offset != 0) g_type_class_adjust_private_offset
(klass, &CafeWeatherPref_private_offset); cafeweather_pref_class_init
((CafeWeatherPrefClass*) klass); } __attribute__ ((__unused__
)) static inline gpointer cafeweather_pref_get_instance_private
(CafeWeatherPref *self) { return (((gpointer) ((guint8*) (self
) + (glong) (CafeWeatherPref_private_offset)))); } GType cafeweather_pref_get_type
(void) { static gsize static_g_define_type_id = 0; if ((__extension__
({ _Static_assert (sizeof *(&static_g_define_type_id) ==
sizeof (gpointer), "Expression evaluates to false"); (void) (
0 ? (gpointer) *(&static_g_define_type_id) : ((void*)0));
(!(__extension__ ({ _Static_assert (sizeof *(&static_g_define_type_id
) == sizeof (gpointer), "Expression evaluates to false"); __typeof__
(*(&static_g_define_type_id)) gapg_temp_newval; __typeof__
((&static_g_define_type_id)) gapg_temp_atomic = (&static_g_define_type_id
); __atomic_load (gapg_temp_atomic, &gapg_temp_newval, 5)
; gapg_temp_newval; })) && g_once_init_enter (&static_g_define_type_id
)); }))) { GType g_define_type_id = cafeweather_pref_get_type_once
(); (__extension__ ({ _Static_assert (sizeof *(&static_g_define_type_id
) == sizeof (gpointer), "Expression evaluates to false"); 0 ?
(void) (*(&static_g_define_type_id) = (g_define_type_id)
) : (void) 0; g_once_init_leave ((&static_g_define_type_id
), (gsize) (g_define_type_id)); })); } return static_g_define_type_id
; } __attribute__ ((__noinline__)) static GType cafeweather_pref_get_type_once
(void) { GType g_define_type_id = g_type_register_static_simple
((ctk_dialog_get_type ()), g_intern_static_string ("CafeWeatherPref"
), sizeof (CafeWeatherPrefClass), (GClassInitFunc)(void (*)(void
)) cafeweather_pref_class_intern_init, sizeof (CafeWeatherPref
), (GInstanceInitFunc)(void (*)(void)) cafeweather_pref_init,
(GTypeFlags) 0); { {{ CafeWeatherPref_private_offset = g_type_add_instance_private
(g_define_type_id, sizeof (CafeWeatherPrefPrivate)); };} } return
g_define_type_id; }
;
76
77/* set sensitive and setup NEVER_SENSITIVE appropriately */
78static void hard_set_sensitive(CtkWidget* w, gboolean sensitivity)
79{
80 ctk_widget_set_sensitive(w, sensitivity);
81 g_object_set_data(G_OBJECT(w)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((w)), (((GType) ((20) << (2))))))))
, NEVER_SENSITIVE"never_sensitive", GINT_TO_POINTER(!sensitivity)((gpointer) (glong) (!sensitivity)));
82}
83
84
85/* set sensitive, but always insensitive if NEVER_SENSITIVE is set */
86static void soft_set_sensitive(CtkWidget* w, gboolean sensitivity)
87{
88 if (g_object_get_data(G_OBJECT(w)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((w)), (((GType) ((20) << (2))))))))
, NEVER_SENSITIVE"never_sensitive"))
89 {
90 ctk_widget_set_sensitive(w, FALSE(0));
91 }
92 else
93 {
94 ctk_widget_set_sensitive(w, sensitivity);
95 }
96}
97
98/* sets up ATK Relation between the widgets */
99static void add_atk_relation(CtkWidget* widget1, CtkWidget* widget2, AtkRelationType type)
100{
101 AtkObject* atk_obj1;
102 AtkObject* atk_obj2;
103 AtkRelationSet* relation_set;
104 AtkRelation* relation;
105
106 atk_obj1 = ctk_widget_get_accessible(widget1);
107
108 if (!CTK_IS_ACCESSIBLE(atk_obj1)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(atk_obj1)); GType __t = ((ctk_accessible_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; }))))
)
109 {
110 return;
111 }
112
113 atk_obj2 = ctk_widget_get_accessible(widget2);
114
115 relation_set = atk_object_ref_relation_set(atk_obj1);
116 relation = atk_relation_new(&atk_obj2, 1, type);
117 atk_relation_set_add(relation_set, relation);
118 g_object_unref(G_OBJECT(relation)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((relation)), (((GType) ((20) << (2))))))))
);
119}
120
121/* sets accessible name and description */
122void set_access_namedesc(CtkWidget* widget, const gchar* name, const gchar* desc)
123{
124 AtkObject* obj = ctk_widget_get_accessible(widget);
125
126 if (!CTK_IS_ACCESSIBLE(obj)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(obj)); GType __t = ((ctk_accessible_get_type ())); gboolean __r
; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; }))))
)
127 {
128 return;
129 }
130
131 if (desc)
132 {
133 atk_object_set_description(obj, desc);
134 }
135
136 if (name)
137 {
138 atk_object_set_name(obj, name);
139 }
140}
141
142/* sets accessible name, description, CONTROLLED_BY
143 * and CONTROLLER_FOR relations for the components
144 * in cafeweather preference dialog.
145 */
146static void cafeweather_pref_set_accessibility(CafeWeatherPref* pref)
147{
148 /* Relation between components in General page */
149 add_atk_relation(pref->priv->basic_update_btn, pref->priv->basic_update_spin, ATK_RELATION_CONTROLLER_FOR);
150 add_atk_relation(pref->priv->basic_radar_btn, pref->priv->basic_radar_url_btn, ATK_RELATION_CONTROLLER_FOR);
151 add_atk_relation(pref->priv->basic_radar_btn, pref->priv->basic_radar_url_entry, ATK_RELATION_CONTROLLER_FOR);
152
153 add_atk_relation(pref->priv->basic_update_spin, pref->priv->basic_update_btn, ATK_RELATION_CONTROLLED_BY);
154 add_atk_relation(pref->priv->basic_radar_url_btn, pref->priv->basic_radar_btn, ATK_RELATION_CONTROLLED_BY);
155 add_atk_relation(pref->priv->basic_radar_url_entry, pref->priv->basic_radar_btn, ATK_RELATION_CONTROLLED_BY);
156
157 /* Accessible Name and Description for the components in Preference Dialog */
158 set_access_namedesc(pref->priv->tree, _("Location view")gettext ("Location view"), _("Select Location from the list")gettext ("Select Location from the list"));
159 set_access_namedesc(pref->priv->basic_update_spin, _("Update spin button")gettext ("Update spin button"), _("Spinbutton for updating")gettext ("Spinbutton for updating"));
160 set_access_namedesc(pref->priv->basic_radar_url_entry, _("Address Entry")gettext ("Address Entry"), _("Enter the URL")gettext ("Enter the URL"));
161}
162
163
164/* Update pref dialog from cafeweather_pref */
165static gboolean update_dialog(CafeWeatherPref* pref)
166{
167 CafeWeatherApplet* gw_applet = pref->priv->applet;
168
169 g_return_val_if_fail(gw_applet->cafeweather_pref.location != NULL, FALSE)do { if ((gw_applet->cafeweather_pref.location != ((void*)
0))) { } else { g_return_if_fail_warning (((gchar*) 0), ((const
char*) (__func__)), "gw_applet->cafeweather_pref.location != NULL"
); return ((0)); } } while (0)
;
170
171 ctk_spin_button_set_value(CTK_SPIN_BUTTON(pref->priv->basic_update_spin)((((CtkSpinButton*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((pref->priv->basic_update_spin)), ((ctk_spin_button_get_type
()))))))
, gw_applet->cafeweather_pref.update_interval / 60);
172 ctk_toggle_button_set_active(CTK_TOGGLE_BUTTON(pref->priv->basic_update_btn)((((CtkToggleButton*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((pref->priv->basic_update_btn)), ((ctk_toggle_button_get_type
()))))))
, gw_applet->cafeweather_pref.update_enabled);
173 soft_set_sensitive(pref->priv->basic_update_spin, gw_applet->cafeweather_pref.update_enabled);
174
175 ctk_combo_box_set_active(CTK_COMBO_BOX(pref->priv->basic_temp_combo)((((CtkComboBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((pref->priv->basic_temp_combo)), ((ctk_combo_box_get_type
()))))))
, gw_applet->cafeweather_pref.temperature_unit - 2);
176
177 ctk_combo_box_set_active(CTK_COMBO_BOX(pref->priv->basic_speed_combo)((((CtkComboBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((pref->priv->basic_speed_combo)), ((ctk_combo_box_get_type
()))))))
, gw_applet->cafeweather_pref.speed_unit - 2);
178
179 ctk_combo_box_set_active(CTK_COMBO_BOX(pref->priv->basic_pres_combo)((((CtkComboBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((pref->priv->basic_pres_combo)), ((ctk_combo_box_get_type
()))))))
, gw_applet->cafeweather_pref.pressure_unit - 2);
180
181 ctk_combo_box_set_active(CTK_COMBO_BOX(pref->priv->basic_dist_combo)((((CtkComboBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((pref->priv->basic_dist_combo)), ((ctk_combo_box_get_type
()))))))
, gw_applet->cafeweather_pref.distance_unit - 2);
182
183 #ifdef RADARMAP
184 ctk_toggle_button_set_active(CTK_TOGGLE_BUTTON(pref->priv->basic_radar_btn)((((CtkToggleButton*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((pref->priv->basic_radar_btn)), ((ctk_toggle_button_get_type
()))))))
, gw_applet->cafeweather_pref.radar_enabled);
185
186 soft_set_sensitive(pref->priv->basic_radar_url_btn, gw_applet->cafeweather_pref.radar_enabled);
187 ctk_toggle_button_set_active(CTK_TOGGLE_BUTTON(pref->priv->basic_radar_url_btn)((((CtkToggleButton*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((pref->priv->basic_radar_url_btn)), ((ctk_toggle_button_get_type
()))))))
, gw_applet->cafeweather_pref.use_custom_radar_url);
188 soft_set_sensitive(pref->priv->basic_radar_url_hbox, gw_applet->cafeweather_pref.radar_enabled);
189
190 if (gw_applet->cafeweather_pref.radar)
191 {
192 ctk_entry_set_text(CTK_ENTRY(pref->priv->basic_radar_url_entry)((((CtkEntry*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((pref->priv->basic_radar_url_entry)), ((ctk_entry_get_type
()))))))
, gw_applet->cafeweather_pref.radar);
193 }
194
195 #endif /* RADARMAP */
196
197 #ifdef HAVE_LIBNOTIFY1
198 ctk_toggle_button_set_active(CTK_TOGGLE_BUTTON(pref->priv->basic_show_notifications_btn)((((CtkToggleButton*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((pref->priv->basic_show_notifications_btn)), ((ctk_toggle_button_get_type
()))))))
, gw_applet->cafeweather_pref.show_notifications);
199 #endif
200 return TRUE(!(0));
201}
202
203static void row_selected_cb(CtkTreeSelection* selection, CafeWeatherPref* pref)
204{
205 CafeWeatherApplet* gw_applet = pref->priv->applet;
206 CtkTreeModel* model;
207 WeatherLocation* loc = NULL((void*)0);
208 CtkTreeIter iter;
209
210 if (!ctk_tree_selection_get_selected(selection, &model, &iter))
211 return;
212
213 ctk_tree_model_get(model, &iter, CAFEWEATHER_XML_COL_POINTER, &loc, -1);
214
215 if (!loc)
216 {
217 return;
218 }
219
220 g_settings_set_string (gw_applet->settings, "location1", loc->code);
221 g_settings_set_string (gw_applet->settings, "location2", loc->zone);
222 g_settings_set_string (gw_applet->settings, "location3", loc->radar);
223 g_settings_set_string (gw_applet->settings, "location4", loc->name);
224 g_settings_set_string (gw_applet->settings, "coordinates", loc->coordinates);
225
226 if (gw_applet->cafeweather_pref.location)
227 {
228 weather_location_free(gw_applet->cafeweather_pref.location);
229 }
230
231 gw_applet->cafeweather_pref.location =
232 weather_location_new (loc->name, loc->code, loc->zone, loc->radar, loc->coordinates,
233 NULL((void*)0), NULL((void*)0));
234
235 cafeweather_update(gw_applet);
236}
237
238static gboolean compare_location(CtkTreeModel* model, CtkTreePath* path, CtkTreeIter* iter, gpointer user_data)
239{
240 CafeWeatherPref* pref = user_data;
241 WeatherLocation* loc;
242 CtkTreeView* view;
243
244 ctk_tree_model_get(model, iter, CAFEWEATHER_XML_COL_POINTER, &loc, -1);
245
246 if (!loc)
247 {
248 return FALSE(0);
249 }
250
251 if (!weather_location_equal(loc, pref->priv->applet->cafeweather_pref.location))
252 {
253 return FALSE(0);
254 }
255
256 view = CTK_TREE_VIEW(pref->priv->tree)((((CtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((pref->priv->tree)), ((ctk_tree_view_get_type ())))
)))
;
257 ctk_tree_view_expand_to_path(view, path);
258 ctk_tree_view_set_cursor(view, path, NULL((void*)0), FALSE(0));
259 ctk_tree_view_scroll_to_cell(view, path, NULL((void*)0), TRUE(!(0)), 0.5, 0.5);
260
261 return TRUE(!(0));
262}
263
264static void load_locations(CafeWeatherPref* pref)
265{
266 CafeWeatherApplet* gw_applet = pref->priv->applet;
Value stored to 'gw_applet' during its initialization is never read
267 CtkTreeView* tree = CTK_TREE_VIEW(pref->priv->tree)((((CtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((pref->priv->tree)), ((ctk_tree_view_get_type ())))
)))
;
268 CtkTreeViewColumn* column;
269 CtkCellRenderer* cell_renderer;
270 WeatherLocation* current_location;
271
272 /* Add a column for the locations */
273 cell_renderer = ctk_cell_renderer_text_new();
274 column = ctk_tree_view_column_new_with_attributes("not used", cell_renderer, "text", CAFEWEATHER_XML_COL_LOC, NULL((void*)0));
275 ctk_tree_view_append_column(tree, column);
276 ctk_tree_view_set_expander_column(CTK_TREE_VIEW(tree)((((CtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((tree)), ((ctk_tree_view_get_type ()))))))
, column);
277
278 /* load locations from xml file */
279 pref->priv->model = cafeweather_xml_load_locations();
280
281 if (!pref->priv->model)
282 {
283 CtkWidget* d = ctk_message_dialog_new(NULL((void*)0), 0, CTK_MESSAGE_ERROR, CTK_BUTTONS_OK, _("Failed to load the Locations XML database. Please report this as a bug.")gettext ("Failed to load the Locations XML database. Please report this as a bug."
)
);
284 ctk_dialog_run(CTK_DIALOG(d)((((CtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((d)), ((ctk_dialog_get_type ()))))))
);
285 ctk_widget_destroy(d);
286 }
287
288 ctk_tree_view_set_model (tree, pref->priv->model);
289
290 if (pref->priv->applet->cafeweather_pref.location)
291 {
292 /* Select the current (default) location */
293 ctk_tree_model_foreach(CTK_TREE_MODEL(pref->priv->model)((((CtkTreeModel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((pref->priv->model)), ((ctk_tree_model_get_type ())
)))))
, compare_location, pref);
294 }
295}
296
297static void show_notifications_toggled(CtkToggleButton* button, CafeWeatherPref* pref)
298{
299 CafeWeatherApplet* gw_applet = pref->priv->applet;
300
301 gboolean toggled = ctk_toggle_button_get_active(button);
302
303 if (toggled != gw_applet->cafeweather_pref.show_notifications)
304 {
305 /* sync with cafeweather_pref struct */
306 gw_applet->cafeweather_pref.show_notifications = toggled;
307
308 /* sync with gsettings */
309 g_settings_set_boolean (gw_applet->settings, "show-notifications", toggled);
310 }
311}
312
313static void auto_update_toggled(CtkToggleButton* button, CafeWeatherPref* pref)
314{
315 CafeWeatherApplet* gw_applet = pref->priv->applet;
316 gboolean toggled;
317 gint nxtSunEvent;
318
319 toggled = ctk_toggle_button_get_active(button);
320 gw_applet->cafeweather_pref.update_enabled = toggled;
321 soft_set_sensitive(pref->priv->basic_update_spin, toggled);
322 g_settings_set_boolean (gw_applet->settings, "auto-update", toggled);
323
324 if (gw_applet->timeout_tag > 0)
325 {
326 g_source_remove(gw_applet->timeout_tag);
327 }
328
329 if (gw_applet->suncalc_timeout_tag > 0)
330 {
331 g_source_remove(gw_applet->suncalc_timeout_tag);
332 }
333
334 if (gw_applet->cafeweather_pref.update_enabled)
335 {
336 gw_applet->timeout_tag = g_timeout_add_seconds(gw_applet->cafeweather_pref.update_interval, timeout_cb, gw_applet);
337 nxtSunEvent = weather_info_next_sun_event(gw_applet->cafeweather_info);
338
339 if (nxtSunEvent >= 0)
340 {
341 gw_applet->suncalc_timeout_tag = g_timeout_add_seconds(nxtSunEvent, suncalc_timeout_cb, gw_applet);
342 }
343 }
344}
345
346static void temp_combo_changed_cb(CtkComboBox* combo, CafeWeatherPref* pref)
347{
348 CafeWeatherApplet* gw_applet = pref->priv->applet;
349 TempUnit new_unit, old_unit;
350
351 g_return_if_fail(gw_applet != NULL)do { if ((gw_applet != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "gw_applet != NULL"
); return; } } while (0)
;
352
353 new_unit = ctk_combo_box_get_active(combo) + 2;
354
355 old_unit = gw_applet->cafeweather_pref.temperature_unit;
356
357 if (new_unit == old_unit)
358 {
359 return;
360 }
361
362 gw_applet->cafeweather_pref.temperature_unit = new_unit;
363
364 g_settings_set_enum (gw_applet->settings, "temperature-unit", new_unit);
365
366 ctk_label_set_text(CTK_LABEL(gw_applet->label)((((CtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gw_applet->label)), ((ctk_label_get_type ()))))))
, weather_info_get_temp_summary(gw_applet->cafeweather_info));
367
368 if (gw_applet->details_dialog)
369 {
370 cafeweather_dialog_update(CAFEWEATHER_DIALOG(gw_applet->details_dialog)((((CafeWeatherDialog*) (void *) g_type_check_instance_cast (
(GTypeInstance*) ((gw_applet->details_dialog)), ((cafeweather_dialog_get_type
()))))))
);
371 }
372}
373
374static void speed_combo_changed_cb(CtkComboBox* combo, CafeWeatherPref* pref)
375{
376 CafeWeatherApplet* gw_applet = pref->priv->applet;
377 SpeedUnit new_unit, old_unit;
378
379 g_return_if_fail(gw_applet != NULL)do { if ((gw_applet != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "gw_applet != NULL"
); return; } } while (0)
;
380
381 new_unit = ctk_combo_box_get_active(combo) + 2;
382
383 old_unit = gw_applet->cafeweather_pref.speed_unit;
384
385 if (new_unit == old_unit)
386 {
387 return;
388 }
389
390 gw_applet->cafeweather_pref.speed_unit = new_unit;
391
392 g_settings_set_enum (gw_applet->settings, "speed-unit", new_unit);
393
394 if (gw_applet->details_dialog)
395 {
396 cafeweather_dialog_update(CAFEWEATHER_DIALOG(gw_applet->details_dialog)((((CafeWeatherDialog*) (void *) g_type_check_instance_cast (
(GTypeInstance*) ((gw_applet->details_dialog)), ((cafeweather_dialog_get_type
()))))))
);
397 }
398}
399
400static void pres_combo_changed_cb(CtkComboBox* combo, CafeWeatherPref* pref)
401{
402 CafeWeatherApplet* gw_applet = pref->priv->applet;
403 PressureUnit new_unit, old_unit;
404
405 g_return_if_fail(gw_applet != NULL)do { if ((gw_applet != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "gw_applet != NULL"
); return; } } while (0)
;
406
407 new_unit = ctk_combo_box_get_active(combo) + 2;
408
409 old_unit = gw_applet->cafeweather_pref.pressure_unit;
410
411 if (new_unit == old_unit)
412 {
413 return;
414 }
415
416 gw_applet->cafeweather_pref.pressure_unit = new_unit;
417
418 g_settings_set_enum (gw_applet->settings, "pressure-unit", new_unit);
419
420 if (gw_applet->details_dialog)
421 {
422 cafeweather_dialog_update(CAFEWEATHER_DIALOG(gw_applet->details_dialog)((((CafeWeatherDialog*) (void *) g_type_check_instance_cast (
(GTypeInstance*) ((gw_applet->details_dialog)), ((cafeweather_dialog_get_type
()))))))
);
423 }
424}
425
426static void dist_combo_changed_cb(CtkComboBox* combo, CafeWeatherPref* pref)
427{
428 CafeWeatherApplet* gw_applet = pref->priv->applet;
429 DistanceUnit new_unit, old_unit;
430
431 g_return_if_fail(gw_applet != NULL)do { if ((gw_applet != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "gw_applet != NULL"
); return; } } while (0)
;
432
433 new_unit = ctk_combo_box_get_active(combo) + 2;
434
435 old_unit = gw_applet->cafeweather_pref.distance_unit;
436
437 if (new_unit == old_unit)
438 {
439 return;
440 }
441
442 gw_applet->cafeweather_pref.distance_unit = new_unit;
443
444 g_settings_set_enum (gw_applet->settings, "distance-unit", new_unit);
445
446 if (gw_applet->details_dialog)
447 {
448 cafeweather_dialog_update(CAFEWEATHER_DIALOG(gw_applet->details_dialog)((((CafeWeatherDialog*) (void *) g_type_check_instance_cast (
(GTypeInstance*) ((gw_applet->details_dialog)), ((cafeweather_dialog_get_type
()))))))
);
449 }
450}
451
452static void radar_toggled(CtkToggleButton* button, CafeWeatherPref* pref)
453{
454 CafeWeatherApplet* gw_applet = pref->priv->applet;
455 gboolean toggled;
456
457 toggled = ctk_toggle_button_get_active(button);
458 gw_applet->cafeweather_pref.radar_enabled = toggled;
459 g_settings_set_boolean (gw_applet->settings, "enable-radar-map", toggled);
460 soft_set_sensitive(pref->priv->basic_radar_url_btn, toggled);
461
462 if (toggled == FALSE(0) || ctk_toggle_button_get_active(CTK_TOGGLE_BUTTON (pref->priv->basic_radar_url_btn)((((CtkToggleButton*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((pref->priv->basic_radar_url_btn)), ((ctk_toggle_button_get_type
()))))))
) == TRUE(!(0)))
463 {
464 soft_set_sensitive (pref->priv->basic_radar_url_hbox, toggled);
465 }
466}
467
468static void use_radar_url_toggled(CtkToggleButton* button, CafeWeatherPref* pref)
469{
470 CafeWeatherApplet* gw_applet = pref->priv->applet;
471 gboolean toggled;
472
473 toggled = ctk_toggle_button_get_active(button);
474 gw_applet->cafeweather_pref.use_custom_radar_url = toggled;
475 g_settings_set_boolean (gw_applet->settings, "use-custom-radar-url", toggled);
476 soft_set_sensitive(pref->priv->basic_radar_url_hbox, toggled);
477}
478
479static gboolean radar_url_changed(CtkWidget* widget, CdkEventFocus* event, CafeWeatherPref* pref)
480{
481 CafeWeatherApplet* gw_applet = pref->priv->applet;
482 gchar *text;
483
484 text = ctk_editable_get_chars(CTK_EDITABLE(widget)((((CtkEditable*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((ctk_editable_get_type ()))))))
, 0, -1);
485
486 if (gw_applet->cafeweather_pref.radar)
487 {
488 g_free(gw_applet->cafeweather_pref.radar);
489 }
490
491 if (text)
492 {
493 gw_applet->cafeweather_pref.radar = g_strdup(text)g_strdup_inline (text);
494 g_free (text);
495 }
496 else
497 {
498 gw_applet->cafeweather_pref.radar = NULL((void*)0);
499 }
500
501 g_settings_set_string (gw_applet->settings, "radar", gw_applet->cafeweather_pref.radar);
502
503 return FALSE(0);
504}
505
506static void update_interval_changed(CtkSpinButton* button, CafeWeatherPref* pref)
507{
508 CafeWeatherApplet* gw_applet = pref->priv->applet;
509
510 gw_applet->cafeweather_pref.update_interval = ctk_spin_button_get_value_as_int(button)*60;
511 g_settings_set_int (gw_applet->settings, "auto-update-interval", gw_applet->cafeweather_pref.update_interval);
512
513 if (gw_applet->timeout_tag > 0)
514 {
515 g_source_remove(gw_applet->timeout_tag);
516 }
517
518 if (gw_applet->cafeweather_pref.update_enabled)
519 {
520 gw_applet->timeout_tag = g_timeout_add_seconds(gw_applet->cafeweather_pref.update_interval, timeout_cb, gw_applet);
521 }
522}
523
524static gboolean free_data(CtkTreeModel* model, CtkTreePath* path, CtkTreeIter* iter, gpointer data)
525{
526 WeatherLocation* location;
527
528 ctk_tree_model_get(model, iter, CAFEWEATHER_XML_COL_POINTER, &location, -1);
529
530 if (!location)
531 {
532 return FALSE(0);
533 }
534
535 weather_location_free(location);
536
537 return FALSE(0);
538}
539
540
541static CtkWidget* create_hig_category(CtkWidget* main_box, gchar* title)
542{
543 CtkWidget* vbox;
544 CtkWidget* vbox2;
545 CtkWidget* hbox;
546 CtkWidget*label;
547 gchar* tmp;
548
549 vbox = ctk_box_new (CTK_ORIENTATION_VERTICAL, 6);
550 ctk_box_pack_start (CTK_BOX (main_box)((((CtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((main_box)), ((ctk_box_get_type ()))))))
, vbox, FALSE(0), FALSE(0), 0);
551
552 tmp = g_strdup_printf ("<b>%s</b>", title);
553 label = ctk_label_new (NULL((void*)0));
554 ctk_label_set_xalign (CTK_LABEL (label)((((CtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((label)), ((ctk_label_get_type ()))))))
, 0.0);
555 ctk_label_set_markup (CTK_LABEL (label)((((CtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((label)), ((ctk_label_get_type ()))))))
, tmp);
556 g_free (tmp);
557 ctk_box_pack_start (CTK_BOX (vbox)((((CtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((vbox)), ((ctk_box_get_type ()))))))
, label, TRUE(!(0)), FALSE(0), 0);
558
559 hbox = ctk_box_new (CTK_ORIENTATION_HORIZONTAL, 0);
560 ctk_box_pack_start (CTK_BOX (vbox)((((CtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((vbox)), ((ctk_box_get_type ()))))))
, hbox, FALSE(0), FALSE(0), 0);
561
562 label = ctk_label_new (" ");
563 ctk_box_pack_start (CTK_BOX (hbox)((((CtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((hbox)), ((ctk_box_get_type ()))))))
, label, FALSE(0), FALSE(0), 0);
564
565 vbox2 = ctk_box_new (CTK_ORIENTATION_VERTICAL, 6);
566 ctk_box_pack_start (CTK_BOX (hbox)((((CtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((hbox)), ((ctk_box_get_type ()))))))
, vbox2, TRUE(!(0)), TRUE(!(0)), 0);
567
568 return vbox2;
569}
570
571static gboolean find_location(CtkTreeModel* model, CtkTreeIter* iter, const gchar* location, gboolean go_parent)
572{
573 CtkTreeIter iter_child;
574 CtkTreeIter iter_parent;
575 gchar* aux_loc;
576 gboolean valid;
577 int len;
578
579 len = strlen (location);
580
581 if (len <= 0)
582 {
583 return FALSE(0);
584 }
585
586 do {
587
588 ctk_tree_model_get (model, iter, CAFEWEATHER_XML_COL_LOC, &aux_loc, -1);
589
590 if (g_ascii_strncasecmp (aux_loc, location, len) == 0)
591 {
592 g_free (aux_loc);
593 return TRUE(!(0));
594 }
595
596 if (ctk_tree_model_iter_has_child(model, iter))
597 {
598 ctk_tree_model_iter_nth_child(model, &iter_child, iter, 0);
599
600 if (find_location (model, &iter_child, location, FALSE(0)))
601 {
602 /* Manual copying of the iter */
603 iter->stamp = iter_child.stamp;
604 iter->user_data = iter_child.user_data;
605 iter->user_data2 = iter_child.user_data2;
606 iter->user_data3 = iter_child.user_data3;
607
608 g_free (aux_loc);
609
610 return TRUE(!(0));
611 }
612 }
613
614 g_free (aux_loc);
615
616 valid = ctk_tree_model_iter_next(model, iter);
617
618 } while (valid);
619
620 if (go_parent)
621 {
622 iter_parent = *iter;
623
624 while (ctk_tree_model_iter_parent (model, iter, &iter_parent))
625 {
626 if (ctk_tree_model_iter_next (model, iter))
627 {
628 return find_location (model, iter, location, TRUE(!(0)));
629 }
630
631 iter_parent = *iter;
632 }
633 }
634
635 return FALSE(0);
636}
637
638static void find_next_clicked(CtkButton* button, CafeWeatherPref* pref)
639{
640 CtkTreeView *tree;
641 CtkTreeModel *model;
642 CtkEntry *entry;
643 CtkTreeSelection *selection;
644 CtkTreeIter iter;
645 CtkTreeIter iter_parent;
646 CtkTreePath *path;
647 const gchar *location;
648
649 tree = CTK_TREE_VIEW (pref->priv->tree)((((CtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((pref->priv->tree)), ((ctk_tree_view_get_type ())))
)))
;
650 model = ctk_tree_view_get_model (tree);
651 entry = CTK_ENTRY (pref->priv->find_entry)((((CtkEntry*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((pref->priv->find_entry)), ((ctk_entry_get_type ())
)))))
;
652
653 selection = ctk_tree_view_get_selection (CTK_TREE_VIEW (tree)((((CtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((tree)), ((ctk_tree_view_get_type ()))))))
);
654
655 if (ctk_tree_selection_count_selected_rows (selection) >= 1)
656 {
657 ctk_tree_selection_get_selected (selection, &model, &iter);
658 /* Select next or select parent */
659 if (!ctk_tree_model_iter_next (model, &iter))
660 {
661 iter_parent = iter;
662
663 if (!ctk_tree_model_iter_parent (model, &iter, &iter_parent) || !ctk_tree_model_iter_next (model, &iter))
664 {
665 ctk_tree_model_get_iter_first (model, &iter);
666 }
667 }
668
669 }
670 else
671 {
672 ctk_tree_model_get_iter_first (model, &iter);
673 }
674
675 location = ctk_entry_get_text (entry);
676
677 if (find_location (model, &iter, location, TRUE(!(0))))
678 {
679 ctk_widget_set_sensitive (pref->priv->find_next_btn, TRUE(!(0)));
680
681 path = ctk_tree_model_get_path (model, &iter);
682 ctk_tree_view_expand_to_path (tree, path);
683 ctk_tree_selection_select_path (selection, path);
684 ctk_tree_view_scroll_to_cell (tree, path, NULL((void*)0), TRUE(!(0)), 0.5, 0);
685
686 ctk_tree_path_free (path);
687 }
688 else
689 {
690 ctk_widget_set_sensitive (pref->priv->find_next_btn, FALSE(0));
691 }
692}
693
694static void find_entry_changed(CtkEditable* entry, CafeWeatherPref* pref)
695{
696 CtkTreeView *tree;
697 CtkTreeModel *model;
698 CtkTreeSelection *selection;
699 CtkTreeIter iter;
700 CtkTreePath *path;
701 const gchar *location;
702
703 tree = CTK_TREE_VIEW (pref->priv->tree)((((CtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((pref->priv->tree)), ((ctk_tree_view_get_type ())))
)))
;
704 model = ctk_tree_view_get_model (tree);
705
706 g_return_if_fail (model != NULL)do { if ((model != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "model != NULL");
return; } } while (0)
;
707
708 selection = ctk_tree_view_get_selection (CTK_TREE_VIEW (tree)((((CtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((tree)), ((ctk_tree_view_get_type ()))))))
);
709 ctk_tree_model_get_iter_first (model, &iter);
710
711 location = ctk_entry_get_text (CTK_ENTRY (entry)((((CtkEntry*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((entry)), ((ctk_entry_get_type ()))))))
);
712
713 if (find_location (model, &iter, location, TRUE(!(0))))
714 {
715 ctk_widget_set_sensitive (pref->priv->find_next_btn, TRUE(!(0)));
716
717 path = ctk_tree_model_get_path (model, &iter);
718 ctk_tree_view_expand_to_path (tree, path);
719 ctk_tree_selection_select_iter (selection, &iter);
720 ctk_tree_view_scroll_to_cell (tree, path, NULL((void*)0), TRUE(!(0)), 0.5, 0);
721
722 ctk_tree_path_free (path);
723 }
724 else
725 {
726 ctk_widget_set_sensitive (pref->priv->find_next_btn, FALSE(0));
727 }
728}
729
730
731static void help_cb(CtkDialog* dialog, CafeWeatherPref* pref)
732{
733 gint current_page;
734 gchar *uri;
735 GError* error = NULL((void*)0);
736
737 current_page = ctk_notebook_get_current_page (CTK_NOTEBOOK (pref->priv->notebook)((((CtkNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((pref->priv->notebook)), ((ctk_notebook_get_type ()
))))))
);
738 uri = g_strdup_printf ("help:cafeweather/cafeweather-prefs#cafeweather-%s", (current_page == 0) ? "metric" : "change-location");
739 ctk_show_uri_on_window (CTK_WINDOW (dialog)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dialog)), ((ctk_window_get_type ()))))))
,
740 uri,
741 ctk_get_current_event_time (),
742 &error);
743 g_free (uri);
744
745 if (error)
746 {
747 CtkWidget* error_dialog = ctk_message_dialog_new (NULL((void*)0), CTK_DIALOG_MODAL, CTK_MESSAGE_ERROR, CTK_BUTTONS_CLOSE, _("There was an error displaying help: %s")gettext ("There was an error displaying help: %s"), error->message);
748 g_signal_connect (G_OBJECT (error_dialog), "response", G_CALLBACK (ctk_widget_destroy), NULL)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((error_dialog)), (((GType) ((20) <<
(2))))))))), ("response"), (((GCallback) (ctk_widget_destroy
))), (((void*)0)), ((void*)0), (GConnectFlags) 0)
;
749 ctk_window_set_resizable (CTK_WINDOW (error_dialog)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((error_dialog)), ((ctk_window_get_type ()))))))
, FALSE(0));
750 ctk_window_set_screen (CTK_WINDOW (error_dialog)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((error_dialog)), ((ctk_window_get_type ()))))))
, ctk_widget_get_screen (CTK_WIDGET (dialog)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dialog)), ((ctk_widget_get_type ()))))))
));
751 ctk_widget_show (error_dialog);
752 g_error_free (error);
753 error = NULL((void*)0);
754 }
755}
756
757
758static void response_cb(CtkDialog* dialog, gint id, CafeWeatherPref* pref)
759{
760 if (id == CTK_RESPONSE_HELP)
761 {
762 help_cb(dialog, pref);
763 }
764 else
765 {
766 ctk_widget_destroy(CTK_WIDGET(dialog)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dialog)), ((ctk_widget_get_type ()))))))
);
767 }
768}
769
770
771static void cafeweather_pref_create(CafeWeatherPref* pref)
772{
773 CtkWidget* pref_vbox;
774 #ifdef RADARMAP
775 CtkWidget* radar_toggle_hbox;
776 #endif /* RADARMAP */
777 CtkWidget* pref_basic_update_lbl;
778 CtkWidget* pref_basic_update_hbox;
779 CtkAdjustment* pref_basic_update_spin_adj;
780 CtkWidget* pref_basic_update_sec_lbl;
781 CtkWidget* pref_basic_note_lbl;
782 CtkWidget* pref_loc_hbox;
783 CtkWidget* pref_loc_note_lbl;
784 CtkWidget* scrolled_window;
785 CtkWidget* label;
786 CtkWidget* value_hbox;
787 CtkWidget* tree_label;
788 CtkTreeSelection *selection;
789 CtkWidget* pref_basic_vbox;
790 CtkWidget* vbox;
791 CtkWidget* frame;
792 CtkWidget* temp_label;
793 CtkWidget* temp_combo;
794 CtkWidget* speed_label;
795 CtkWidget* speed_combo;
796 CtkWidget* pres_label;
797 CtkWidget* pres_combo;
798 CtkWidget* dist_label;
799 CtkWidget* dist_combo;
800 CtkWidget* unit_grid;
801 CtkWidget* pref_find_label;
802 CtkWidget* pref_find_hbox;
803 CtkWidget* image;
804
805
806 g_object_set (pref, "destroy-with-parent", TRUE(!(0)), NULL((void*)0));
807 ctk_window_set_title (CTK_WINDOW (pref)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((pref)), ((ctk_window_get_type ()))))))
, _("Weather Preferences")gettext ("Weather Preferences"));
808 ctk_dialog_add_buttons (CTK_DIALOG (pref)((((CtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((pref)), ((ctk_dialog_get_type ()))))))
, "ctk-close", CTK_RESPONSE_CLOSE, "ctk-help", CTK_RESPONSE_HELP, NULL((void*)0));
809 ctk_dialog_set_default_response (CTK_DIALOG (pref)((((CtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((pref)), ((ctk_dialog_get_type ()))))))
, CTK_RESPONSE_CLOSE);
810 ctk_container_set_border_width (CTK_CONTAINER (pref)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((pref)), ((ctk_container_get_type ()))))))
, 5);
811 ctk_window_set_resizable (CTK_WINDOW (pref)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((pref)), ((ctk_window_get_type ()))))))
, TRUE(!(0)));
812 ctk_window_set_screen (CTK_WINDOW (pref)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((pref)), ((ctk_window_get_type ()))))))
, ctk_widget_get_screen (CTK_WIDGET (pref->priv->applet->applet)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((pref->priv->applet->applet)), ((ctk_widget_get_type
()))))))
));
813
814 pref_vbox = ctk_dialog_get_content_area (CTK_DIALOG (pref)((((CtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((pref)), ((ctk_dialog_get_type ()))))))
);
815 ctk_box_set_spacing (CTK_BOX (pref_vbox)((((CtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((pref_vbox)), ((ctk_box_get_type ()))))))
, 2);
816 ctk_widget_show (pref_vbox);
817
818 pref->priv->notebook = ctk_notebook_new ();
819 ctk_container_set_border_width (CTK_CONTAINER (pref->priv->notebook)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((pref->priv->notebook)), ((ctk_container_get_type (
)))))))
, 5);
820 ctk_widget_show (pref->priv->notebook);
821 ctk_box_pack_start (CTK_BOX (pref_vbox)((((CtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((pref_vbox)), ((ctk_box_get_type ()))))))
, pref->priv->notebook, TRUE(!(0)), TRUE(!(0)), 0);
822
823 /*
824 * General settings page.
825 */
826
827 pref_basic_vbox = ctk_box_new (CTK_ORIENTATION_VERTICAL, 18);
828 ctk_container_set_border_width (CTK_CONTAINER (pref_basic_vbox)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((pref_basic_vbox)), ((ctk_container_get_type ()))))))
, 12);
829 ctk_container_add (CTK_CONTAINER (pref->priv->notebook)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((pref->priv->notebook)), ((ctk_container_get_type (
)))))))
, pref_basic_vbox);
830
831 pref->priv->basic_update_btn = ctk_check_button_new_with_mnemonic (_("_Automatically update every:")gettext ("_Automatically update every:"));
832 ctk_widget_set_halign (pref->priv->basic_update_btn, CTK_ALIGN_START);
833 ctk_widget_set_vexpand (pref->priv->basic_update_btn, TRUE(!(0)));
834 ctk_widget_show (pref->priv->basic_update_btn);
835 g_signal_connect (G_OBJECT (pref->priv->basic_update_btn), "toggled", G_CALLBACK (auto_update_toggled), pref)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((pref->priv->basic_update_btn)), ((
(GType) ((20) << (2))))))))), ("toggled"), (((GCallback
) (auto_update_toggled))), (pref), ((void*)0), (GConnectFlags
) 0)
;
836
837 if (!g_settings_is_writable (pref->priv->applet->settings, "auto-update"))
838 {
839 hard_set_sensitive (pref->priv->basic_update_btn, FALSE(0));
840 }
841
842 /*
843 * Units settings page.
844 */
845
846 /* Temperature Unit */
847 temp_label = ctk_label_new_with_mnemonic (_("_Temperature unit:")gettext ("_Temperature unit:"));
848 ctk_label_set_use_markup (CTK_LABEL (temp_label)((((CtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((temp_label)), ((ctk_label_get_type ()))))))
, TRUE(!(0)));
849 ctk_label_set_justify (CTK_LABEL (temp_label)((((CtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((temp_label)), ((ctk_label_get_type ()))))))
, CTK_JUSTIFY_LEFT);
850 ctk_label_set_xalign (CTK_LABEL (temp_label)((((CtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((temp_label)), ((ctk_label_get_type ()))))))
, 0.0);
851 ctk_widget_show (temp_label);
852
853 temp_combo = ctk_combo_box_text_new ();
854 pref->priv->basic_temp_combo = temp_combo;
855 ctk_label_set_mnemonic_widget (CTK_LABEL (temp_label)((((CtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((temp_label)), ((ctk_label_get_type ()))))))
, temp_combo);
856 //ctk_combo_box_append_text (CTK_COMBO_BOX (temp_combo), _("Default"));
857 ctk_combo_box_text_append_text (CTK_COMBO_BOX_TEXT (temp_combo)((((CtkComboBoxText*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((temp_combo)), ((ctk_combo_box_text_get_type ()))))))
, _("Kelvin")gettext ("Kelvin"));
858 /* TRANSLATORS: Celsius is sometimes referred Centigrade */
859 ctk_combo_box_text_append_text (CTK_COMBO_BOX_TEXT (temp_combo)((((CtkComboBoxText*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((temp_combo)), ((ctk_combo_box_text_get_type ()))))))
, _("Celsius")gettext ("Celsius"));
860 ctk_combo_box_text_append_text (CTK_COMBO_BOX_TEXT (temp_combo)((((CtkComboBoxText*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((temp_combo)), ((ctk_combo_box_text_get_type ()))))))
, _("Fahrenheit")gettext ("Fahrenheit"));
861 ctk_widget_show (temp_combo);
862
863 if ( ! g_settings_is_writable (pref->priv->applet->settings, "temperature-unit"))
864 {
865 hard_set_sensitive (pref->priv->basic_temp_combo, FALSE(0));
866 }
867
868 /* Speed Unit */
869 speed_label = ctk_label_new_with_mnemonic (_("_Wind speed unit:")gettext ("_Wind speed unit:"));
870 ctk_label_set_use_markup (CTK_LABEL (speed_label)((((CtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((speed_label)), ((ctk_label_get_type ()))))))
, TRUE(!(0)));
871 ctk_label_set_justify (CTK_LABEL (speed_label)((((CtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((speed_label)), ((ctk_label_get_type ()))))))
, CTK_JUSTIFY_LEFT);
872 ctk_label_set_xalign (CTK_LABEL (speed_label)((((CtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((speed_label)), ((ctk_label_get_type ()))))))
, 0.0);
873 ctk_widget_show (speed_label);
874
875 speed_combo = ctk_combo_box_text_new ();
876 pref->priv->basic_speed_combo = speed_combo;
877 ctk_label_set_mnemonic_widget (CTK_LABEL (speed_label)((((CtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((speed_label)), ((ctk_label_get_type ()))))))
, speed_combo);
878 //ctk_combo_box_append_text (CTK_COMBO_BOX (speed_combo), _("Default"));
879 /* TRANSLATOR: The wind speed unit "meters per second" */
880 ctk_combo_box_text_append_text (CTK_COMBO_BOX_TEXT (speed_combo)((((CtkComboBoxText*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((speed_combo)), ((ctk_combo_box_text_get_type ()))))))
, _("m/s")gettext ("m/s"));
881 /* TRANSLATOR: The wind speed unit "kilometers per hour" */
882 ctk_combo_box_text_append_text (CTK_COMBO_BOX_TEXT (speed_combo)((((CtkComboBoxText*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((speed_combo)), ((ctk_combo_box_text_get_type ()))))))
, _("km/h")gettext ("km/h"));
883 /* TRANSLATOR: The wind speed unit "miles per hour" */
884 ctk_combo_box_text_append_text (CTK_COMBO_BOX_TEXT (speed_combo)((((CtkComboBoxText*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((speed_combo)), ((ctk_combo_box_text_get_type ()))))))
, _("mph")gettext ("mph"));
885 /* TRANSLATOR: The wind speed unit "knots" */
886 ctk_combo_box_text_append_text (CTK_COMBO_BOX_TEXT (speed_combo)((((CtkComboBoxText*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((speed_combo)), ((ctk_combo_box_text_get_type ()))))))
, _("knots")gettext ("knots"));
887 ctk_combo_box_text_append_text (CTK_COMBO_BOX_TEXT (speed_combo)((((CtkComboBoxText*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((speed_combo)), ((ctk_combo_box_text_get_type ()))))))
, _("Beaufort scale")gettext ("Beaufort scale"));
888 ctk_widget_show (speed_combo);
889
890 if (!g_settings_is_writable (pref->priv->applet->settings, "speed-unit"))
891 {
892 hard_set_sensitive (pref->priv->basic_speed_combo, FALSE(0));
893 }
894
895 /* Pressure Unit */
896 pres_label = ctk_label_new_with_mnemonic (_("_Pressure unit:")gettext ("_Pressure unit:"));
897 ctk_label_set_use_markup (CTK_LABEL (pres_label)((((CtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((pres_label)), ((ctk_label_get_type ()))))))
, TRUE(!(0)));
898 ctk_label_set_justify (CTK_LABEL (pres_label)((((CtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((pres_label)), ((ctk_label_get_type ()))))))
, CTK_JUSTIFY_LEFT);
899 ctk_label_set_xalign (CTK_LABEL (pres_label)((((CtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((pres_label)), ((ctk_label_get_type ()))))))
, 0.0);
900 ctk_widget_show (pres_label);
901
902 pres_combo = ctk_combo_box_text_new ();
903 pref->priv->basic_pres_combo = pres_combo;
904 ctk_label_set_mnemonic_widget (CTK_LABEL (pres_label)((((CtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((pres_label)), ((ctk_label_get_type ()))))))
, pres_combo);
905 //ctk_combo_box_append_text (CTK_COMBO_BOX (pres_combo), _("Default"));
906 /* TRANSLATOR: The pressure unit "kiloPascals" */
907 ctk_combo_box_text_append_text (CTK_COMBO_BOX_TEXT (pres_combo)((((CtkComboBoxText*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((pres_combo)), ((ctk_combo_box_text_get_type ()))))))
, _("kPa")gettext ("kPa"));
908 /* TRANSLATOR: The pressure unit "hectoPascals" */
909 ctk_combo_box_text_append_text (CTK_COMBO_BOX_TEXT (pres_combo)((((CtkComboBoxText*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((pres_combo)), ((ctk_combo_box_text_get_type ()))))))
, _("hPa")gettext ("hPa"));
910 /* TRANSLATOR: The pressure unit "millibars" */
911 ctk_combo_box_text_append_text (CTK_COMBO_BOX_TEXT (pres_combo)((((CtkComboBoxText*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((pres_combo)), ((ctk_combo_box_text_get_type ()))))))
, _("mb")gettext ("mb"));
912 /* TRANSLATOR: The pressure unit "millibars of mercury" */
913 ctk_combo_box_text_append_text (CTK_COMBO_BOX_TEXT (pres_combo)((((CtkComboBoxText*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((pres_combo)), ((ctk_combo_box_text_get_type ()))))))
, _("mmHg")gettext ("mmHg"));
914 /* TRANSLATOR: The pressure unit "inches of mercury" */
915 ctk_combo_box_text_append_text (CTK_COMBO_BOX_TEXT (pres_combo)((((CtkComboBoxText*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((pres_combo)), ((ctk_combo_box_text_get_type ()))))))
, _("inHg")gettext ("inHg"));
916 /* TRANSLATOR: The pressure unit "atmospheres" */
917 ctk_combo_box_text_append_text (CTK_COMBO_BOX_TEXT (pres_combo)((((CtkComboBoxText*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((pres_combo)), ((ctk_combo_box_text_get_type ()))))))
, _("atm")gettext ("atm"));
918 ctk_widget_show (pres_combo);
919
920 if (!g_settings_is_writable(pref->priv->applet->settings, "pressure-unit"))
921 {
922 hard_set_sensitive(pref->priv->basic_pres_combo, FALSE(0));
923 }
924
925 /* Distance Unit */
926 dist_label = ctk_label_new_with_mnemonic (_("_Visibility unit:")gettext ("_Visibility unit:"));
927 ctk_label_set_use_markup (CTK_LABEL (dist_label)((((CtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dist_label)), ((ctk_label_get_type ()))))))
, TRUE(!(0)));
928 ctk_label_set_justify (CTK_LABEL (dist_label)((((CtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dist_label)), ((ctk_label_get_type ()))))))
, CTK_JUSTIFY_LEFT);
929 ctk_label_set_xalign (CTK_LABEL (dist_label)((((CtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dist_label)), ((ctk_label_get_type ()))))))
, 0.0);
930 ctk_widget_show (dist_label);
931
932 dist_combo = ctk_combo_box_text_new ();
933 pref->priv->basic_dist_combo = dist_combo;
934 ctk_label_set_mnemonic_widget (CTK_LABEL (dist_label)((((CtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dist_label)), ((ctk_label_get_type ()))))))
, dist_combo);
935 //ctk_combo_box_append_text (CTK_COMBO_BOX (dist_combo), _("Default"));
936 /* TRANSLATOR: The distance unit "meters" */
937 ctk_combo_box_text_append_text (CTK_COMBO_BOX_TEXT (dist_combo)((((CtkComboBoxText*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dist_combo)), ((ctk_combo_box_text_get_type ()))))))
, _("meters")gettext ("meters"));
938 /* TRANSLATOR: The distance unit "kilometers" */
939 ctk_combo_box_text_append_text (CTK_COMBO_BOX_TEXT (dist_combo)((((CtkComboBoxText*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dist_combo)), ((ctk_combo_box_text_get_type ()))))))
, _("km")gettext ("km"));
940 /* TRANSLATOR: The distance unit "miles" */
941 ctk_combo_box_text_append_text (CTK_COMBO_BOX_TEXT (dist_combo)((((CtkComboBoxText*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dist_combo)), ((ctk_combo_box_text_get_type ()))))))
, _("miles")gettext ("miles"));
942 ctk_widget_show (dist_combo);
943
944 if ( ! g_settings_is_writable (pref->priv->applet->settings, "distance-unit"))
945 hard_set_sensitive (pref->priv->basic_dist_combo, FALSE(0));
946
947 unit_grid = ctk_grid_new ();
948 ctk_grid_set_row_spacing(CTK_GRID(unit_grid)((((CtkGrid*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((unit_grid)), ((ctk_grid_get_type ()))))))
, 6);
949 ctk_grid_set_column_spacing(CTK_GRID(unit_grid)((((CtkGrid*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((unit_grid)), ((ctk_grid_get_type ()))))))
, 12);
950 ctk_widget_set_halign (temp_label, CTK_ALIGN_START);
951 ctk_grid_attach(CTK_GRID(unit_grid)((((CtkGrid*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((unit_grid)), ((ctk_grid_get_type ()))))))
, temp_label, 0, 0, 1, 1);
952 ctk_grid_attach(CTK_GRID(unit_grid)((((CtkGrid*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((unit_grid)), ((ctk_grid_get_type ()))))))
, temp_combo, 1, 0, 1, 1);
953 ctk_widget_set_halign (speed_label, CTK_ALIGN_START);
954 ctk_grid_attach(CTK_GRID(unit_grid)((((CtkGrid*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((unit_grid)), ((ctk_grid_get_type ()))))))
, speed_label, 0, 1, 1, 1);
955 ctk_grid_attach(CTK_GRID(unit_grid)((((CtkGrid*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((unit_grid)), ((ctk_grid_get_type ()))))))
, speed_combo, 1, 1, 1, 1);
956 ctk_widget_set_halign (pres_label, CTK_ALIGN_START);
957 ctk_grid_attach(CTK_GRID(unit_grid)((((CtkGrid*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((unit_grid)), ((ctk_grid_get_type ()))))))
, pres_label, 0, 2, 1, 1);
958 ctk_grid_attach(CTK_GRID(unit_grid)((((CtkGrid*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((unit_grid)), ((ctk_grid_get_type ()))))))
, pres_combo, 1, 2, 1, 1);
959 ctk_widget_set_halign (dist_label, CTK_ALIGN_START);
960 ctk_grid_attach(CTK_GRID(unit_grid)((((CtkGrid*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((unit_grid)), ((ctk_grid_get_type ()))))))
, dist_label, 0, 3, 1, 1);
961 ctk_grid_attach(CTK_GRID(unit_grid)((((CtkGrid*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((unit_grid)), ((ctk_grid_get_type ()))))))
, dist_combo, 1, 3, 1, 1);
962 ctk_widget_show(unit_grid);
963
964 g_signal_connect (temp_combo, "changed", G_CALLBACK (temp_combo_changed_cb), pref)g_signal_connect_data ((temp_combo), ("changed"), (((GCallback
) (temp_combo_changed_cb))), (pref), ((void*)0), (GConnectFlags
) 0)
;
965 g_signal_connect (speed_combo, "changed", G_CALLBACK (speed_combo_changed_cb), pref)g_signal_connect_data ((speed_combo), ("changed"), (((GCallback
) (speed_combo_changed_cb))), (pref), ((void*)0), (GConnectFlags
) 0)
;
966 g_signal_connect (dist_combo, "changed", G_CALLBACK (dist_combo_changed_cb), pref)g_signal_connect_data ((dist_combo), ("changed"), (((GCallback
) (dist_combo_changed_cb))), (pref), ((void*)0), (GConnectFlags
) 0)
;
967 g_signal_connect (pres_combo, "changed", G_CALLBACK (pres_combo_changed_cb), pref)g_signal_connect_data ((pres_combo), ("changed"), (((GCallback
) (pres_combo_changed_cb))), (pref), ((void*)0), (GConnectFlags
) 0)
;
968
969
970 #ifdef RADARMAP
971 pref->priv->basic_radar_btn = ctk_check_button_new_with_mnemonic (_("Enable _radar map")gettext ("Enable _radar map"));
972 ctk_widget_show (pref->priv->basic_radar_btn);
973 g_signal_connect (G_OBJECT (pref->priv->basic_radar_btn), "toggled", G_CALLBACK (radar_toggled), pref)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((pref->priv->basic_radar_btn)), (((
GType) ((20) << (2))))))))), ("toggled"), (((GCallback)
(radar_toggled))), (pref), ((void*)0), (GConnectFlags) 0)
;
974
975 if (!g_settings_is_writable (pref->priv->applet->settings, "enable-radar-map"))
976 {
977 hard_set_sensitive(pref->priv->basic_radar_btn, FALSE(0));
978 }
979
980 radar_toggle_hbox = ctk_box_new (CTK_ORIENTATION_HORIZONTAL, 12);
981 ctk_widget_show(radar_toggle_hbox);
982
983 label = ctk_label_new (" ");
984 ctk_widget_show (label);
985 ctk_box_pack_start (CTK_BOX (radar_toggle_hbox)((((CtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((radar_toggle_hbox)), ((ctk_box_get_type ()))))))
, label, FALSE(0), FALSE(0), 0);
986
987 pref->priv->basic_radar_url_btn = ctk_check_button_new_with_mnemonic (_("Use _custom address for radar map")gettext ("Use _custom address for radar map"));
988 ctk_widget_show (pref->priv->basic_radar_url_btn);
989 ctk_box_pack_start (CTK_BOX (radar_toggle_hbox)((((CtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((radar_toggle_hbox)), ((ctk_box_get_type ()))))))
, pref->priv->basic_radar_url_btn, FALSE(0), FALSE(0), 0);
990
991 g_signal_connect (G_OBJECT (pref->priv->basic_radar_url_btn), "toggled", G_CALLBACK (use_radar_url_toggled), pref)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((pref->priv->basic_radar_url_btn)),
(((GType) ((20) << (2))))))))), ("toggled"), (((GCallback
) (use_radar_url_toggled))), (pref), ((void*)0), (GConnectFlags
) 0)
;
992
993 if ( ! g_settings_is_writable (pref->priv->applet->settings, "use-custom-radar-url"))
994 {
995 hard_set_sensitive (pref->priv->basic_radar_url_btn, FALSE(0));
996 }
997
998 pref->priv->basic_radar_url_hbox = ctk_box_new (CTK_ORIENTATION_HORIZONTAL, 12);
999 ctk_widget_show (pref->priv->basic_radar_url_hbox);
1000
1001 label = ctk_label_new (" ");
1002 ctk_widget_show (label);
1003 ctk_box_pack_start (CTK_BOX (pref->priv->basic_radar_url_hbox)((((CtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((pref->priv->basic_radar_url_hbox)), ((ctk_box_get_type
()))))))
, label, FALSE(0), FALSE(0), 0);
1004
1005 label = ctk_label_new_with_mnemonic (_("A_ddress:")gettext ("A_ddress:"));
1006 ctk_widget_show (label);
1007 ctk_box_pack_start (CTK_BOX (pref->priv->basic_radar_url_hbox)((((CtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((pref->priv->basic_radar_url_hbox)), ((ctk_box_get_type
()))))))
, label, FALSE(0), FALSE(0), 0);
1008 pref->priv->basic_radar_url_entry = ctk_entry_new ();
1009 ctk_widget_show (pref->priv->basic_radar_url_entry);
1010 ctk_box_pack_start (CTK_BOX (pref->priv->basic_radar_url_hbox)((((CtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((pref->priv->basic_radar_url_hbox)), ((ctk_box_get_type
()))))))
, pref->priv->basic_radar_url_entry, TRUE(!(0)), TRUE(!(0)), 0);
1011 g_signal_connect (G_OBJECT (pref->priv->basic_radar_url_entry), "focus_out_event", G_CALLBACK (radar_url_changed), pref)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((pref->priv->basic_radar_url_entry)
), (((GType) ((20) << (2))))))))), ("focus_out_event"),
(((GCallback) (radar_url_changed))), (pref), ((void*)0), (GConnectFlags
) 0)
;
1012 if ( ! g_settings_is_writable (pref->priv->applet->settings, "radar"))
1013 {
1014 hard_set_sensitive (pref->priv->basic_radar_url_entry, FALSE(0));
1015 }
1016 #endif /* RADARMAP */
1017
1018 #ifdef HAVE_LIBNOTIFY1
1019 /* setup show-notifications button */
1020 pref->priv->basic_show_notifications_btn = ctk_check_button_new_with_mnemonic (_("Show _notifications")gettext ("Show _notifications"));
1021
1022 if (!g_settings_is_writable (pref->priv->applet->settings, "show-notifications"))
1023 {
1024 hard_set_sensitive (pref->priv->basic_show_notifications_btn, FALSE(0));
1025 }
1026
1027 g_signal_connect (G_OBJECT (pref->priv->basic_show_notifications_btn), "toggled", G_CALLBACK (show_notifications_toggled), pref)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((pref->priv->basic_show_notifications_btn
)), (((GType) ((20) << (2))))))))), ("toggled"), (((GCallback
) (show_notifications_toggled))), (pref), ((void*)0), (GConnectFlags
) 0)
;
1028 #endif
1029
1030 frame = create_hig_category (pref_basic_vbox, _("Update")gettext ("Update"));
1031
1032 pref_basic_update_hbox = ctk_box_new (CTK_ORIENTATION_HORIZONTAL, 12);
1033
1034 pref_basic_update_lbl = ctk_label_new_with_mnemonic (_("_Automatically update every:")gettext ("_Automatically update every:"));
1035 ctk_widget_show (pref_basic_update_lbl);
1036
1037 ctk_widget_show (pref_basic_update_hbox);
1038
1039 pref_basic_update_spin_adj = ctk_adjustment_new (30, 1, 3600, 5, 25, 1);
1040 pref->priv->basic_update_spin = ctk_spin_button_new (pref_basic_update_spin_adj, 1, 0);
1041 ctk_widget_show (pref->priv->basic_update_spin);
1042
1043 ctk_spin_button_set_numeric (CTK_SPIN_BUTTON (pref->priv->basic_update_spin)((((CtkSpinButton*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((pref->priv->basic_update_spin)), ((ctk_spin_button_get_type
()))))))
, TRUE(!(0)));
1044 ctk_spin_button_set_update_policy (CTK_SPIN_BUTTON (pref->priv->basic_update_spin)((((CtkSpinButton*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((pref->priv->basic_update_spin)), ((ctk_spin_button_get_type
()))))))
, CTK_UPDATE_IF_VALID);
1045 g_signal_connect (G_OBJECT (pref->priv->basic_update_spin), "value_changed", G_CALLBACK (update_interval_changed), pref)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((pref->priv->basic_update_spin)), (
((GType) ((20) << (2))))))))), ("value_changed"), (((GCallback
) (update_interval_changed))), (pref), ((void*)0), (GConnectFlags
) 0)
;
1046
1047 pref_basic_update_sec_lbl = ctk_label_new (_("minutes")gettext ("minutes"));
1048 ctk_widget_show (pref_basic_update_sec_lbl);
1049
1050 if ( ! g_settings_is_writable (pref->priv->applet->settings, "auto-update-interval"))
1051 {
1052 hard_set_sensitive (pref->priv->basic_update_spin, FALSE(0));
1053 hard_set_sensitive (pref_basic_update_sec_lbl, FALSE(0));
1054 }
1055
1056 value_hbox = ctk_box_new (CTK_ORIENTATION_HORIZONTAL, 6);
1057
1058 ctk_box_pack_start (CTK_BOX (pref_basic_update_hbox)((((CtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((pref_basic_update_hbox)), ((ctk_box_get_type ()))))))
, pref->priv->basic_update_btn, FALSE(0), TRUE(!(0)), 0);
1059 ctk_box_pack_start (CTK_BOX (pref_basic_update_hbox)((((CtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((pref_basic_update_hbox)), ((ctk_box_get_type ()))))))
, value_hbox, FALSE(0), FALSE(0), 0);
1060 ctk_box_pack_start (CTK_BOX (value_hbox)((((CtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((value_hbox)), ((ctk_box_get_type ()))))))
, pref->priv->basic_update_spin, FALSE(0), FALSE(0), 0);
1061 ctk_box_pack_start (CTK_BOX (value_hbox)((((CtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((value_hbox)), ((ctk_box_get_type ()))))))
, pref_basic_update_sec_lbl, FALSE(0), FALSE(0), 0);
1062
1063 ctk_container_add (CTK_CONTAINER (frame)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((frame)), ((ctk_container_get_type ()))))))
, pref_basic_update_hbox);
1064
1065 frame = create_hig_category (pref_basic_vbox, _("Display")gettext ("Display"));
1066
1067 vbox = ctk_box_new (CTK_ORIENTATION_VERTICAL, 6);
1068
1069 ctk_box_pack_start (CTK_BOX (vbox)((((CtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((vbox)), ((ctk_box_get_type ()))))))
, unit_grid, TRUE(!(0)), TRUE(!(0)), 0);
1070
1071 #ifdef RADARMAP
1072 ctk_box_pack_start (CTK_BOX (vbox)((((CtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((vbox)), ((ctk_box_get_type ()))))))
, pref->priv->basic_radar_btn, TRUE(!(0)), TRUE(!(0)), 0);
1073 ctk_box_pack_start (CTK_BOX (vbox)((((CtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((vbox)), ((ctk_box_get_type ()))))))
, radar_toggle_hbox, TRUE(!(0)), TRUE(!(0)), 0);
1074 ctk_box_pack_start (CTK_BOX (vbox)((((CtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((vbox)), ((ctk_box_get_type ()))))))
, pref->priv->basic_radar_url_hbox, TRUE(!(0)), TRUE(!(0)), 0);
1075 #endif /* RADARMAP */
1076
1077 #ifdef HAVE_LIBNOTIFY1
1078 /* add the show-notification toggle button to the vbox of the display section */
1079 ctk_box_pack_start (CTK_BOX (vbox)((((CtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((vbox)), ((ctk_box_get_type ()))))))
, pref->priv->basic_show_notifications_btn, TRUE(!(0)), TRUE(!(0)), 0);
1080 #endif
1081
1082 ctk_container_add (CTK_CONTAINER (frame)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((frame)), ((ctk_container_get_type ()))))))
, vbox);
1083
1084 pref_basic_note_lbl = ctk_label_new (_("General")gettext ("General"));
1085 ctk_widget_show (pref_basic_note_lbl);
1086 ctk_notebook_set_tab_label (CTK_NOTEBOOK (pref->priv->notebook)((((CtkNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((pref->priv->notebook)), ((ctk_notebook_get_type ()
))))))
, ctk_notebook_get_nth_page (CTK_NOTEBOOK (pref->priv->notebook)((((CtkNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((pref->priv->notebook)), ((ctk_notebook_get_type ()
))))))
, 0), pref_basic_note_lbl);
1087
1088 /*
1089 * Location page.
1090 */
1091 pref_loc_hbox = ctk_box_new (CTK_ORIENTATION_VERTICAL, 6);
1092 ctk_container_set_border_width (CTK_CONTAINER (pref_loc_hbox)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((pref_loc_hbox)), ((ctk_container_get_type ()))))))
, 12);
1093 ctk_container_add (CTK_CONTAINER (pref->priv->notebook)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((pref->priv->notebook)), ((ctk_container_get_type (
)))))))
, pref_loc_hbox);
1094
1095 tree_label = ctk_label_new_with_mnemonic (_("_Select a location:")gettext ("_Select a location:"));
1096 ctk_label_set_xalign (CTK_LABEL (tree_label)((((CtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((tree_label)), ((ctk_label_get_type ()))))))
, 0.0);
1097 ctk_box_pack_start (CTK_BOX (pref_loc_hbox)((((CtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((pref_loc_hbox)), ((ctk_box_get_type ()))))))
, tree_label, FALSE(0), FALSE(0), 0);
1098
1099 scrolled_window = ctk_scrolled_window_new (NULL((void*)0), NULL((void*)0));
1100 ctk_scrolled_window_set_shadow_type (CTK_SCROLLED_WINDOW (scrolled_window)((((CtkScrolledWindow*) (void *) g_type_check_instance_cast (
(GTypeInstance*) ((scrolled_window)), ((ctk_scrolled_window_get_type
()))))))
, CTK_SHADOW_IN);
1101 ctk_scrolled_window_set_policy (CTK_SCROLLED_WINDOW (scrolled_window)((((CtkScrolledWindow*) (void *) g_type_check_instance_cast (
(GTypeInstance*) ((scrolled_window)), ((ctk_scrolled_window_get_type
()))))))
, CTK_POLICY_AUTOMATIC, CTK_POLICY_AUTOMATIC);
1102
1103 pref->priv->tree = ctk_tree_view_new ();
1104 ctk_label_set_mnemonic_widget (CTK_LABEL (tree_label)((((CtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((tree_label)), ((ctk_label_get_type ()))))))
, CTK_WIDGET (pref->priv->tree)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((pref->priv->tree)), ((ctk_widget_get_type ()))))))
);
1105 ctk_tree_view_set_headers_visible (CTK_TREE_VIEW (pref->priv->tree)((((CtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((pref->priv->tree)), ((ctk_tree_view_get_type ())))
)))
, FALSE(0));
1106
1107 selection = ctk_tree_view_get_selection (CTK_TREE_VIEW (pref->priv->tree)((((CtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((pref->priv->tree)), ((ctk_tree_view_get_type ())))
)))
);
1108 g_signal_connect (G_OBJECT (selection), "changed", G_CALLBACK (row_selected_cb), pref)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((selection)), (((GType) ((20) << (2
))))))))), ("changed"), (((GCallback) (row_selected_cb))), (pref
), ((void*)0), (GConnectFlags) 0)
;
1109
1110 ctk_container_add (CTK_CONTAINER (scrolled_window)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((scrolled_window)), ((ctk_container_get_type ()))))))
, pref->priv->tree);
1111 ctk_widget_show (pref->priv->tree);
1112 ctk_widget_show (scrolled_window);
1113 ctk_box_pack_start (CTK_BOX (pref_loc_hbox)((((CtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((pref_loc_hbox)), ((ctk_box_get_type ()))))))
, scrolled_window, TRUE(!(0)), TRUE(!(0)), 0);
1114 load_locations(pref);
1115
1116 pref_find_hbox = ctk_box_new (CTK_ORIENTATION_HORIZONTAL, 6);
1117 pref_find_label = ctk_label_new (_("_Find:")gettext ("_Find:"));
1118 ctk_label_set_use_underline (CTK_LABEL (pref_find_label)((((CtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((pref_find_label)), ((ctk_label_get_type ()))))))
, TRUE(!(0)));
1119
1120 pref->priv->find_entry = ctk_entry_new ();
1121 ctk_label_set_mnemonic_widget (CTK_LABEL (pref_find_label)((((CtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((pref_find_label)), ((ctk_label_get_type ()))))))
, pref->priv->find_entry);
1122
1123 pref->priv->find_next_btn = ctk_button_new_with_mnemonic (_("Find _Next")gettext ("Find _Next"));
1124 ctk_widget_set_sensitive (pref->priv->find_next_btn, FALSE(0));
1125
1126 image = ctk_image_new_from_icon_name ("edit-find", CTK_ICON_SIZE_BUTTON);
1127 ctk_button_set_image (CTK_BUTTON (pref->priv->find_next_btn)((((CtkButton*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((pref->priv->find_next_btn)), ((ctk_button_get_type
()))))))
, image);
1128
1129 g_signal_connect (G_OBJECT (pref->priv->find_next_btn), "clicked", G_CALLBACK (find_next_clicked), pref)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((pref->priv->find_next_btn)), (((GType
) ((20) << (2))))))))), ("clicked"), (((GCallback) (find_next_clicked
))), (pref), ((void*)0), (GConnectFlags) 0)
;
1130 g_signal_connect (G_OBJECT (pref->priv->find_entry), "changed", G_CALLBACK (find_entry_changed), pref)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((pref->priv->find_entry)), (((GType
) ((20) << (2))))))))), ("changed"), (((GCallback) (find_entry_changed
))), (pref), ((void*)0), (GConnectFlags) 0)
;
1131
1132 ctk_container_set_border_width (CTK_CONTAINER (pref_find_hbox)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((pref_find_hbox)), ((ctk_container_get_type ()))))))
, 0);
1133 ctk_box_pack_start (CTK_BOX (pref_find_hbox)((((CtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((pref_find_hbox)), ((ctk_box_get_type ()))))))
, pref_find_label, FALSE(0), FALSE(0), 0);
1134 ctk_box_pack_start (CTK_BOX (pref_find_hbox)((((CtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((pref_find_hbox)), ((ctk_box_get_type ()))))))
, pref->priv->find_entry, TRUE(!(0)), TRUE(!(0)), 0);
1135 ctk_box_pack_start (CTK_BOX (pref_find_hbox)((((CtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((pref_find_hbox)), ((ctk_box_get_type ()))))))
, pref->priv->find_next_btn, FALSE(0), FALSE(0), 0);
1136
1137 ctk_box_pack_start (CTK_BOX (pref_loc_hbox)((((CtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((pref_loc_hbox)), ((ctk_box_get_type ()))))))
, pref_find_hbox, FALSE(0), FALSE(0), 0);
1138
1139 if ( ! g_settings_is_writable (pref->priv->applet->settings, "location0"))
1140 {
1141 hard_set_sensitive (scrolled_window, FALSE(0));
1142 }
1143
1144 pref_loc_note_lbl = ctk_label_new (_("Location")gettext ("Location"));
1145 ctk_widget_show (pref_loc_note_lbl);
1146 ctk_notebook_set_tab_label (CTK_NOTEBOOK (pref->priv->notebook)((((CtkNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((pref->priv->notebook)), ((ctk_notebook_get_type ()
))))))
, ctk_notebook_get_nth_page (CTK_NOTEBOOK (pref->priv->notebook)((((CtkNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((pref->priv->notebook)), ((ctk_notebook_get_type ()
))))))
, 1), pref_loc_note_lbl);
1147
1148
1149 g_signal_connect (G_OBJECT (pref), "response", G_CALLBACK (response_cb), pref)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((pref)), (((GType) ((20) << (2)))))
)))), ("response"), (((GCallback) (response_cb))), (pref), ((
void*)0), (GConnectFlags) 0)
;
1150
1151 cafeweather_pref_set_accessibility (pref);
1152 ctk_label_set_mnemonic_widget (CTK_LABEL (pref_basic_update_sec_lbl)((((CtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((pref_basic_update_sec_lbl)), ((ctk_label_get_type ()))))
))
, pref->priv->basic_update_spin);
1153 ctk_label_set_mnemonic_widget (CTK_LABEL (label)((((CtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((label)), ((ctk_label_get_type ()))))))
, pref->priv->basic_radar_url_entry);
1154}
1155
1156
1157static void cafeweather_pref_set_property(GObject* object, guint prop_id, const GValue* value, GParamSpec *pspec)
1158{
1159 CafeWeatherPref* pref = CAFEWEATHER_PREF(object)((((CafeWeatherPref*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((object)), ((cafeweather_pref_get_type ()))))))
;
1160
1161 switch (prop_id)
1162 {
1163 case PROP_CAFEWEATHER_APPLET:
1164 pref->priv->applet = g_value_get_pointer(value);
1165 break;
1166 }
1167}
1168
1169
1170static void cafeweather_pref_get_property(GObject* object, guint prop_id, GValue* value, GParamSpec* pspec)
1171{
1172 CafeWeatherPref* pref = CAFEWEATHER_PREF(object)((((CafeWeatherPref*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((object)), ((cafeweather_pref_get_type ()))))))
;
1173
1174 switch (prop_id)
1175 {
1176 case PROP_CAFEWEATHER_APPLET:
1177 g_value_set_pointer(value, pref->priv->applet);
1178 break;
1179 }
1180}
1181
1182
1183static void cafeweather_pref_init(CafeWeatherPref* self)
1184{
1185 self->priv = cafeweather_pref_get_instance_private(self);
1186}
1187
1188
1189static GObject* cafeweather_pref_constructor(GType type, guint n_construct_params, GObjectConstructParam* construct_params)
1190{
1191 GObject* object;
1192 CafeWeatherPref* self;
1193
1194 object = G_OBJECT_CLASS(cafeweather_pref_parent_class)((((GObjectClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((cafeweather_pref_parent_class)), (((GType) ((20) <<
(2))))))))
->constructor(type, n_construct_params, construct_params);
1195 self = CAFEWEATHER_PREF(object)((((CafeWeatherPref*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((object)), ((cafeweather_pref_get_type ()))))))
;
1196
1197 cafeweather_pref_create(self);
1198 update_dialog(self);
1199
1200 return object;
1201}
1202
1203
1204CtkWidget* cafeweather_pref_new(CafeWeatherApplet* applet)
1205{
1206 return g_object_new(CAFEWEATHER_TYPE_PREF(cafeweather_pref_get_type ()), "cafeweather-applet", applet, NULL((void*)0));
1207}
1208
1209
1210static void cafeweather_pref_finalize(GObject* object)
1211{
1212 CafeWeatherPref* self = CAFEWEATHER_PREF(object)((((CafeWeatherPref*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((object)), ((cafeweather_pref_get_type ()))))))
;
1213
1214 ctk_tree_model_foreach(self->priv->model, free_data, NULL((void*)0));
1215 g_object_unref(G_OBJECT(self->priv->model)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((self->priv->model)), (((GType) ((20) << (2))
))))))
);
1216
1217 G_OBJECT_CLASS(cafeweather_pref_parent_class)((((GObjectClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((cafeweather_pref_parent_class)), (((GType) ((20) <<
(2))))))))
->finalize(object);
1218}
1219
1220
1221static void cafeweather_pref_class_init(CafeWeatherPrefClass* klass)
1222{
1223 GObjectClass* object_class = G_OBJECT_CLASS(klass)((((GObjectClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((klass)), (((GType) ((20) << (2))))))))
;
1224
1225 cafeweather_pref_parent_class = g_type_class_peek_parent(klass);
1226
1227 object_class->set_property = cafeweather_pref_set_property;
1228 object_class->get_property = cafeweather_pref_get_property;
1229 object_class->constructor = cafeweather_pref_constructor;
1230 object_class->finalize = cafeweather_pref_finalize;
1231
1232 /* This becomes an OBJECT property when CafeWeatherApplet is redone */
1233 g_object_class_install_property(object_class, PROP_CAFEWEATHER_APPLET, g_param_spec_pointer("cafeweather-applet", "CafeWeather Applet", "The CafeWeather Applet", G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
1234}
1235
1236