Merge lp:~indicator-applet-developers/ubuntu/precise/indicator-datetime/upstream into lp:~ubuntu-desktop/indicator-datetime/ubuntu
- Precise (12.04)
- upstream
- Merge into ubuntu
Proposed by
Ted Gould
Status: | Merged | ||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Merged at revision: | 138 | ||||||||||||||||||||||||||||
Proposed branch: | lp:~indicator-applet-developers/ubuntu/precise/indicator-datetime/upstream | ||||||||||||||||||||||||||||
Merge into: | lp:~ubuntu-desktop/indicator-datetime/ubuntu | ||||||||||||||||||||||||||||
Diff against target: |
1165 lines (+393/-375) (has conflicts) 11 files modified
AUTHORS (+1/-0) ChangeLog (+105/-0) configure (+10/-10) configure.ac (+1/-1) data/indicator-datetime-preferences.desktop (+16/-0) debian/changelog (+15/-0) src/datetime-interface.c (+3/-10) src/datetime-prefs-locations.c (+1/-1) src/datetime-prefs.c (+36/-40) src/datetime-service.c (+175/-240) src/indicator-datetime.c (+30/-73) Text conflict in debian/changelog |
||||||||||||||||||||||||||||
To merge this branch: | bzr merge lp:~indicator-applet-developers/ubuntu/precise/indicator-datetime/upstream | ||||||||||||||||||||||||||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Sebastien Bacher | Pending | ||
Ken VanDine | Pending | ||
Review via email: mp+96680@code.launchpad.net |
Commit message
Description of the change
0.3.91
To post a comment you must log in.
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'AUTHORS' |
2 | --- AUTHORS 2012-02-17 22:18:45 +0000 |
3 | +++ AUTHORS 2012-03-08 23:08:19 +0000 |
4 | @@ -21,5 +21,6 @@ |
5 | Michael Terry |
6 | Robert Ancell |
7 | Rodrigo Moya |
8 | + Ryan Lortie |
9 | Sebastien Bacher |
10 | Ted Gould |
11 | |
12 | === modified file 'ChangeLog' |
13 | --- ChangeLog 2012-02-17 22:18:45 +0000 |
14 | +++ ChangeLog 2012-03-08 23:08:19 +0000 |
15 | @@ -1,5 +1,110 @@ |
16 | # Generated by Makefile. Do not edit. |
17 | |
18 | +2012-03-08 Ted Gould <ted@gould.cx> |
19 | + |
20 | + 0.3.91 |
21 | + |
22 | +2012-03-08 Ted Gould <ted@gould.cx> |
23 | + |
24 | + Change GSetting bindings to be read only |
25 | + |
26 | +2012-03-07 Ryan Lortie <desrt@desrt.ca> |
27 | + |
28 | + Establish read-only bindings to GSettings from the indicator |
29 | + |
30 | + The bindings to GSettings are established in the GTypeInstance _init |
31 | + function of the indicator. During this time, the property notify queue |
32 | + is frozen. After the construction completes, the queue thaws and the |
33 | + rush of property change notifications causes GSettings writes to occur. |
34 | + |
35 | + We can fix this by switching to using readonly bindings. |
36 | + |
37 | +2012-03-08 Ted Gould <ted@gould.cx> |
38 | + |
39 | + Specify types explicitly to GVariantBuilder |
40 | + |
41 | +2012-03-07 Ryan Lortie <desrt@desrt.ca> |
42 | + |
43 | + more GVariantBuilder vs. G_VARIANT_TYPE_ARRAY fixes |
44 | + |
45 | +2012-03-05 Charles Kerr <charles.kerr@canonical.com> |
46 | + |
47 | + merge lp:~charlesk/indicator-datetime/fix-943747 to silence the Coverity warning reported in bug #943747 |
48 | + |
49 | +2012-03-03 Charles Kerr <charles.kerr@canonical.com> |
50 | + |
51 | + In Bug #943747, Coverity reported that use of sscanf() needed to be inspected by a human to verify there aren't buffer overruns. This commit adds /* coverity[secure_coding] */ to the lines before the calls to tell Coverity that they've been checked. |
52 | + |
53 | +2012-03-05 Charles Kerr <charles.kerr@canonical.com> |
54 | + |
55 | + merge lp:~charlesk/indicator-datetime/lp-943746 to fix the warning that Coverity reported in bug #943746 |
56 | + |
57 | +2012-03-03 Charles Kerr <charles.kerr@canonical.com> |
58 | + |
59 | + remove unused code in populate_appointment_instances(). |
60 | + |
61 | + It looks like the local variables 'datetime', 'appointment_zone', and 'current_zone' were used in earlier revisions of the code, but this was removed in <http://bazaar.launchpad.net/~indicator-applet-developers/indicator-datetime/trunk.0.4/revision/57>. They're currently leftover code, and removing them should fix Bug #943746. |
62 | + |
63 | +2012-03-03 Charles Kerr <charles.kerr@canonical.com> |
64 | + |
65 | + merging lp:~charlesk/indicator-datetime/fix-833337 and lp:~charlesk/indicator-datetime/fix-leaks |
66 | + |
67 | +2012-03-02 Charles Kerr <charles.kerr@canonical.com> |
68 | + |
69 | + simplify the code by removing special handling for geo_location and current_location, and adding them to the same 'locations' list that we use when pruning duplicates from the user-specified list of locations |
70 | + |
71 | +2012-03-02 Charles Kerr <charles.kerr@canonical.com> |
72 | + |
73 | + use g_return_if_fail() instead of g_assert() in the new code |
74 | + |
75 | +2012-03-02 Charles Kerr <charles.kerr@canonical.com> |
76 | + |
77 | + remove duplicate timezone entries |
78 | + |
79 | +2012-03-01 Charles Kerr <charles.kerr@canonical.com> |
80 | + |
81 | + rename dconflocations as location_menu_items |
82 | + |
83 | +2012-03-01 Charles Kerr <charles.kerr@canonical.com> |
84 | + |
85 | + make update_timezone_menu_items() a void function; its args and return value were unused |
86 | + |
87 | +2012-03-01 Charles Kerr <charles.kerr@canonical.com> |
88 | + |
89 | + make the private fields 'conf' and 'gconf' static and init them to NULL |
90 | + |
91 | +2012-03-01 Charles Kerr <charles.kerr@canonical.com> |
92 | + |
93 | + more use of g_clear_object() where appropriate |
94 | + |
95 | +2012-03-01 Charles Kerr <charles.kerr@canonical.com> |
96 | + |
97 | + in dispose(), add g_clear_object() for priv.ido_calendar and priv.service_proxy_cancel |
98 | + |
99 | +2012-03-01 Charles Kerr <charles.kerr@canonical.com> |
100 | + |
101 | + tweak: use g_clear_object() in dispose() |
102 | + |
103 | +2012-03-01 Charles Kerr <charles.kerr@canonical.com> |
104 | + |
105 | + fix potential minor memory leak in update_timezone_menu_items() |
106 | + |
107 | +2012-03-01 Charles Kerr <charles.kerr@canonical.com> |
108 | + |
109 | + remove unnecessary strdup+free in update_appointment_menu_items() |
110 | + |
111 | +2012-03-01 Charles Kerr <charles.kerr@canonical.com> |
112 | + |
113 | + fix memory leak in update_appointment_menu_items() |
114 | + |
115 | +2012-03-01 Charles Kerr <charles.kerr@canonical.com> |
116 | + |
117 | + fix memory leaks in day_selected_double_click_cb() |
118 | + |
119 | +2012-03-01 Charles Kerr <charles.kerr@canonical.com> |
120 | + |
121 | + extract method on common code |
122 | + |
123 | 2012-02-17 Ted Gould <ted@gould.cx> |
124 | |
125 | 0.3.90 |
126 | |
127 | === modified file 'configure' |
128 | --- configure 2012-02-17 22:18:45 +0000 |
129 | +++ configure 2012-03-08 23:08:19 +0000 |
130 | @@ -1,6 +1,6 @@ |
131 | #! /bin/sh |
132 | # Guess values for system-dependent variables and create Makefiles. |
133 | -# Generated by GNU Autoconf 2.68 for indicator-datetime 0.3.90. |
134 | +# Generated by GNU Autoconf 2.68 for indicator-datetime 0.3.91. |
135 | # |
136 | # Report bugs to <http://bugs.launchpad.net/indicator-datetime>. |
137 | # |
138 | @@ -572,8 +572,8 @@ |
139 | # Identity of this package. |
140 | PACKAGE_NAME='indicator-datetime' |
141 | PACKAGE_TARNAME='indicator-datetime' |
142 | -PACKAGE_VERSION='0.3.90' |
143 | -PACKAGE_STRING='indicator-datetime 0.3.90' |
144 | +PACKAGE_VERSION='0.3.91' |
145 | +PACKAGE_STRING='indicator-datetime 0.3.91' |
146 | PACKAGE_BUGREPORT='http://bugs.launchpad.net/indicator-datetime' |
147 | PACKAGE_URL='http://launchpad.net/indicator-datetime' |
148 | |
149 | @@ -1395,7 +1395,7 @@ |
150 | # Omit some internal or obsolete options to make the list less imposing. |
151 | # This message is too long to be a string in the A/UX 3.1 sh. |
152 | cat <<_ACEOF |
153 | -\`configure' configures indicator-datetime 0.3.90 to adapt to many kinds of systems. |
154 | +\`configure' configures indicator-datetime 0.3.91 to adapt to many kinds of systems. |
155 | |
156 | Usage: $0 [OPTION]... [VAR=VALUE]... |
157 | |
158 | @@ -1466,7 +1466,7 @@ |
159 | |
160 | if test -n "$ac_init_help"; then |
161 | case $ac_init_help in |
162 | - short | recursive ) echo "Configuration of indicator-datetime 0.3.90:";; |
163 | + short | recursive ) echo "Configuration of indicator-datetime 0.3.91:";; |
164 | esac |
165 | cat <<\_ACEOF |
166 | |
167 | @@ -1600,7 +1600,7 @@ |
168 | test -n "$ac_init_help" && exit $ac_status |
169 | if $ac_init_version; then |
170 | cat <<\_ACEOF |
171 | -indicator-datetime configure 0.3.90 |
172 | +indicator-datetime configure 0.3.91 |
173 | generated by GNU Autoconf 2.68 |
174 | |
175 | Copyright (C) 2010 Free Software Foundation, Inc. |
176 | @@ -1971,7 +1971,7 @@ |
177 | This file contains any messages produced by compilers while |
178 | running configure, to aid debugging if configure makes a mistake. |
179 | |
180 | -It was created by indicator-datetime $as_me 0.3.90, which was |
181 | +It was created by indicator-datetime $as_me 0.3.91, which was |
182 | generated by GNU Autoconf 2.68. Invocation command line was |
183 | |
184 | $ $0 $@ |
185 | @@ -2795,7 +2795,7 @@ |
186 | |
187 | # Define the identity of the package. |
188 | PACKAGE='indicator-datetime' |
189 | - VERSION='0.3.90' |
190 | + VERSION='0.3.91' |
191 | |
192 | |
193 | cat >>confdefs.h <<_ACEOF |
194 | @@ -15041,7 +15041,7 @@ |
195 | # report actual input values of CONFIG_FILES etc. instead of their |
196 | # values after options handling. |
197 | ac_log=" |
198 | -This file was extended by indicator-datetime $as_me 0.3.90, which was |
199 | +This file was extended by indicator-datetime $as_me 0.3.91, which was |
200 | generated by GNU Autoconf 2.68. Invocation command line was |
201 | |
202 | CONFIG_FILES = $CONFIG_FILES |
203 | @@ -15108,7 +15108,7 @@ |
204 | cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 |
205 | ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" |
206 | ac_cs_version="\\ |
207 | -indicator-datetime config.status 0.3.90 |
208 | +indicator-datetime config.status 0.3.91 |
209 | configured by $0, generated by GNU Autoconf 2.68, |
210 | with options \\"\$ac_cs_config\\" |
211 | |
212 | |
213 | === modified file 'configure.ac' |
214 | --- configure.ac 2012-02-17 22:18:45 +0000 |
215 | +++ configure.ac 2012-03-08 23:08:19 +0000 |
216 | @@ -1,5 +1,5 @@ |
217 | AC_INIT([indicator-datetime], |
218 | - [0.3.90], |
219 | + [0.3.91], |
220 | [http://bugs.launchpad.net/indicator-datetime], |
221 | [indicator-datetime], |
222 | [http://launchpad.net/indicator-datetime]) |
223 | |
224 | === added file 'data/indicator-datetime-preferences.desktop' |
225 | --- data/indicator-datetime-preferences.desktop 1970-01-01 00:00:00 +0000 |
226 | +++ data/indicator-datetime-preferences.desktop 2012-03-08 23:08:19 +0000 |
227 | @@ -0,0 +1,16 @@ |
228 | +[Desktop Entry] |
229 | +Version=1.0 |
230 | + |
231 | +Name=Time & Date |
232 | +Comment=Change your clock and date settings |
233 | + |
234 | +Icon=preferences-system-time |
235 | +TryExec=gnome-control-center |
236 | +Exec=gnome-control-center indicator-datetime |
237 | + |
238 | +StartupNotify=true |
239 | + |
240 | +Type=Application |
241 | +Categories=GNOME;GTK;Utility;DesktopSettings;Settings;X-GNOME-SystemSettings;X-GNOME-Settings-Panel; |
242 | +X-GNOME-Settings-Panel=indicator-datetime |
243 | +OnlyShowIn=Unity; |
244 | |
245 | === modified file 'debian/changelog' |
246 | --- debian/changelog 2012-02-20 18:40:49 +0000 |
247 | +++ debian/changelog 2012-03-08 23:08:19 +0000 |
248 | @@ -1,4 +1,19 @@ |
249 | +<<<<<<< TREE |
250 | indicator-datetime (0.3.90-0ubuntu1) precise; urgency=low |
251 | +======= |
252 | +indicator-datetime (0.3.91-0ubuntu1~ppa1) precise; urgency=low |
253 | + |
254 | + * New upstream release. |
255 | + * Make GSettings readonly to fix DConf service starting on boot |
256 | + * Explicitly give types to GVariant Builder |
257 | + * Confirm scanf usage for Coverity (LP: #943747) |
258 | + * Remove unused code (LP: #943746) |
259 | + * Fix timezone ordering in the menu (LP: #833325, LP: #833337) |
260 | + |
261 | + -- Ted Gould <ted@ubuntu.com> Thu, 08 Mar 2012 16:58:28 -0600 |
262 | + |
263 | +indicator-datetime (0.3.90-0ubuntu1~ppa1) precise; urgency=low |
264 | +>>>>>>> MERGE-SOURCE |
265 | |
266 | * New upstream release. |
267 | * Still need to distribute these files even if we're not building it |
268 | |
269 | === modified file 'src/datetime-interface.c' |
270 | --- src/datetime-interface.c 2011-01-10 22:20:55 +0000 |
271 | +++ src/datetime-interface.c 2012-03-08 23:08:19 +0000 |
272 | @@ -124,10 +124,7 @@ |
273 | g_warn_if_fail(priv->bus == NULL); |
274 | priv->bus = connection; |
275 | |
276 | - if (priv->bus_cancel != NULL) { |
277 | - g_object_unref(priv->bus_cancel); |
278 | - priv->bus_cancel = NULL; |
279 | - } |
280 | + g_clear_object (&priv->bus_cancel); |
281 | |
282 | /* Now register our object on our new connection */ |
283 | priv->dbus_registration = g_dbus_connection_register_object(priv->bus, |
284 | @@ -158,15 +155,11 @@ |
285 | priv->dbus_registration = 0; |
286 | } |
287 | |
288 | - if (priv->bus != NULL) { |
289 | - g_object_unref(priv->bus); |
290 | - priv->bus = NULL; |
291 | - } |
292 | + g_clear_object (&priv->bus); |
293 | |
294 | if (priv->bus_cancel != NULL) { |
295 | g_cancellable_cancel(priv->bus_cancel); |
296 | - g_object_unref(priv->bus_cancel); |
297 | - priv->bus_cancel = NULL; |
298 | + g_clear_object (&priv->bus_cancel); |
299 | } |
300 | |
301 | G_OBJECT_CLASS (datetime_interface_parent_class)->dispose (object); |
302 | |
303 | === modified file 'src/datetime-prefs-locations.c' |
304 | --- src/datetime-prefs-locations.c 2012-01-09 13:06:50 +0000 |
305 | +++ src/datetime-prefs-locations.c 2012-03-08 23:08:19 +0000 |
306 | @@ -339,7 +339,7 @@ |
307 | { |
308 | gboolean empty = TRUE; |
309 | GVariantBuilder builder; |
310 | - g_variant_builder_init (&builder, G_VARIANT_TYPE_ARRAY); |
311 | + g_variant_builder_init (&builder, G_VARIANT_TYPE_STRING_ARRAY); |
312 | |
313 | GtkTreeIter iter; |
314 | if (gtk_tree_model_get_iter_first (GTK_TREE_MODEL (store), &iter)) { |
315 | |
316 | === modified file 'src/datetime-prefs.c' |
317 | --- src/datetime-prefs.c 2012-01-09 13:06:50 +0000 |
318 | +++ src/datetime-prefs.c 2012-03-08 23:08:19 +0000 |
319 | @@ -405,6 +405,7 @@ |
320 | if (is_locale_12h ()) { // TODO: make this look-at/watch gsettings? |
321 | char ampm[51]; |
322 | |
323 | + /* coverity[secure_coding] */ |
324 | scanned = sscanf (text, "%u:%u:%u %50s", &hour_in, &minute_in, &second_in, ampm); |
325 | passed = (scanned == 4); |
326 | |
327 | @@ -415,6 +416,7 @@ |
328 | } |
329 | } |
330 | } else { |
331 | + /* coverity[secure_coding] */ |
332 | scanned = sscanf (text, "%u:%u:%u", &hour_in, &minute_in, &second_in); |
333 | passed = (scanned == 3); |
334 | } |
335 | @@ -433,6 +435,7 @@ |
336 | else { |
337 | gint year_in, month_in, day_in; |
338 | |
339 | + /* coverity[secure_coding] */ |
340 | scanned = sscanf (text, "%u-%u-%u", &year_in, &month_in, &day_in); |
341 | |
342 | if (scanned != 3 || year_in < 1 || year_in > 9999 || |
343 | @@ -776,46 +779,39 @@ |
344 | indicator_datetime_panel_dispose (GObject * object) |
345 | { |
346 | IndicatorDatetimePanel * self = (IndicatorDatetimePanel *) object; |
347 | - |
348 | - if (self->priv->builder) { |
349 | - g_object_unref (self->priv->builder); |
350 | - self->priv->builder = NULL; |
351 | - } |
352 | - |
353 | - if (self->priv->proxy) { |
354 | - g_object_unref (self->priv->proxy); |
355 | - self->priv->proxy = NULL; |
356 | - } |
357 | - |
358 | - if (self->priv->loc_dlg) { |
359 | - gtk_widget_destroy (self->priv->loc_dlg); |
360 | - self->priv->loc_dlg = NULL; |
361 | - } |
362 | - |
363 | - if (self->priv->save_time_id) { |
364 | - g_source_remove (self->priv->save_time_id); |
365 | - self->priv->save_time_id = 0; |
366 | - } |
367 | - |
368 | - if (self->priv->completion) { |
369 | - cc_timezone_completion_watch_entry (self->priv->completion, NULL); |
370 | - g_object_unref (self->priv->completion); |
371 | - self->priv->completion = NULL; |
372 | - } |
373 | - |
374 | - if (self->priv->tz_entry) { |
375 | - gtk_widget_destroy (self->priv->tz_entry); |
376 | - self->priv->tz_entry = NULL; |
377 | - } |
378 | - |
379 | - if (self->priv->time_spin) { |
380 | - gtk_widget_destroy (self->priv->time_spin); |
381 | - self->priv->time_spin = NULL; |
382 | - } |
383 | - |
384 | - if (self->priv->date_spin) { |
385 | - gtk_widget_destroy (self->priv->date_spin); |
386 | - self->priv->date_spin = NULL; |
387 | + IndicatorDatetimePanelPrivate * priv = self->priv; |
388 | + |
389 | + g_clear_object (&priv->builder); |
390 | + g_clear_object (&priv->proxy); |
391 | + |
392 | + if (priv->loc_dlg) { |
393 | + gtk_widget_destroy (priv->loc_dlg); |
394 | + priv->loc_dlg = NULL; |
395 | + } |
396 | + |
397 | + if (priv->save_time_id) { |
398 | + g_source_remove (priv->save_time_id); |
399 | + priv->save_time_id = 0; |
400 | + } |
401 | + |
402 | + if (priv->completion) { |
403 | + cc_timezone_completion_watch_entry (priv->completion, NULL); |
404 | + g_clear_object (&priv->completion); |
405 | + } |
406 | + |
407 | + if (priv->tz_entry) { |
408 | + gtk_widget_destroy (priv->tz_entry); |
409 | + priv->tz_entry = NULL; |
410 | + } |
411 | + |
412 | + if (priv->time_spin) { |
413 | + gtk_widget_destroy (priv->time_spin); |
414 | + priv->time_spin = NULL; |
415 | + } |
416 | + |
417 | + if (priv->date_spin) { |
418 | + gtk_widget_destroy (priv->date_spin); |
419 | + priv->date_spin = NULL; |
420 | } |
421 | } |
422 | |
423 | |
424 | === modified file 'src/datetime-service.c' |
425 | --- src/datetime-service.c 2012-02-17 22:18:45 +0000 |
426 | +++ src/datetime-service.c 2012-03-08 23:08:19 +0000 |
427 | @@ -62,12 +62,14 @@ |
428 | |
429 | static void geo_create_client (GeoclueMaster * master, GeoclueMasterClient * client, gchar * path, GError * error, gpointer user_data); |
430 | static gboolean update_appointment_menu_items (gpointer user_data); |
431 | -static gboolean update_timezone_menu_items(gpointer user_data); |
432 | +static void update_location_menu_items (void); |
433 | static void setup_timer (void); |
434 | static void geo_client_invalid (GeoclueMasterClient * client, gpointer user_data); |
435 | static void geo_address_change (GeoclueMasterClient * client, gchar * a, gchar * b, gchar * c, gchar * d, gpointer user_data); |
436 | static gboolean get_greeter_mode (void); |
437 | |
438 | +static void quick_set_tz (DbusmenuMenuitem * menuitem, guint timestamp, gpointer user_data); |
439 | + |
440 | static IndicatorService * service = NULL; |
441 | static GMainLoop * mainloop = NULL; |
442 | static DbusmenuServer * server = NULL; |
443 | @@ -80,17 +82,14 @@ |
444 | static DbusmenuMenuitem * settings = NULL; |
445 | static DbusmenuMenuitem * events_separator = NULL; |
446 | static DbusmenuMenuitem * locations_separator = NULL; |
447 | -static DbusmenuMenuitem * geo_location = NULL; |
448 | -static DbusmenuMenuitem * current_location = NULL; |
449 | -//static DbusmenuMenuitem * ecal_location = NULL; |
450 | static DbusmenuMenuitem * add_appointment = NULL; |
451 | -static GList * appointments = NULL; |
452 | -static GList * dconflocations = NULL; |
453 | -static GList * comp_instances = NULL; |
454 | +static GList * appointments = NULL; |
455 | +static GSList * location_menu_items = NULL; |
456 | +static GList * comp_instances = NULL; |
457 | static gboolean updating_appointments = FALSE; |
458 | -static time_t start_time_appointments = (time_t) 0; |
459 | -GSettings *conf; |
460 | -GConfClient* gconf; |
461 | +static time_t start_time_appointments = (time_t) 0; |
462 | +static GSettings * conf = NULL; |
463 | +static GConfClient * gconf = NULL; |
464 | |
465 | |
466 | /* Geoclue trackers */ |
467 | @@ -108,115 +107,141 @@ |
468 | ESource *source; |
469 | }; |
470 | |
471 | -static void |
472 | -set_timezone_label (DbusmenuMenuitem * mi, const gchar * location) |
473 | -{ |
474 | - gchar * zone, * name; |
475 | - split_settings_location (location, &zone, &name); |
476 | - |
477 | - dbusmenu_menuitem_property_set (mi, TIMEZONE_MENUITEM_PROP_NAME, name); |
478 | - dbusmenu_menuitem_property_set (mi, TIMEZONE_MENUITEM_PROP_ZONE, zone); |
479 | - |
480 | - g_free (zone); |
481 | - g_free (name); |
482 | -} |
483 | - |
484 | -static void |
485 | -set_current_timezone_label (DbusmenuMenuitem * mi, const gchar * location) |
486 | -{ |
487 | - gchar * name = get_current_zone_name (location); |
488 | - |
489 | - dbusmenu_menuitem_property_set (mi, TIMEZONE_MENUITEM_PROP_NAME, name); |
490 | - dbusmenu_menuitem_property_set (mi, TIMEZONE_MENUITEM_PROP_ZONE, location); |
491 | - |
492 | - g_free (name); |
493 | -} |
494 | - |
495 | -/* Check to see if our timezones are the same */ |
496 | -static void |
497 | -check_timezone_sync (void) { |
498 | - gchar * label; |
499 | - gboolean in_sync = FALSE; |
500 | - |
501 | - if (geo_timezone == NULL) { |
502 | - in_sync = TRUE; |
503 | - } |
504 | - |
505 | - if (current_timezone == NULL) { |
506 | - in_sync = TRUE; |
507 | - } |
508 | - |
509 | - if (!in_sync && g_strcmp0(geo_timezone, current_timezone) == 0) { |
510 | - in_sync = TRUE; |
511 | - } |
512 | - |
513 | - if (in_sync) { |
514 | - g_debug("Timezones in sync"); |
515 | +/** |
516 | + * A temp struct used by update_location_menu_items() for pruning duplicates. |
517 | + */ |
518 | +struct TimeLocation |
519 | +{ |
520 | + gint32 offset; |
521 | + gchar * zone; |
522 | + gchar * name; |
523 | +}; |
524 | +static void |
525 | +time_location_free (struct TimeLocation * loc) |
526 | +{ |
527 | + g_free (loc->name); |
528 | + g_free (loc->zone); |
529 | + g_free (loc); |
530 | +} |
531 | +static struct TimeLocation* |
532 | +time_location_new (const char * zone, const char * name) |
533 | +{ |
534 | + struct TimeLocation * loc = g_new (struct TimeLocation, 1); |
535 | + GTimeZone * tz = g_time_zone_new (zone); |
536 | + loc->offset = g_time_zone_get_offset (tz, 0); |
537 | + loc->zone = g_strdup (zone); |
538 | + loc->name = g_strdup (name); |
539 | + g_time_zone_unref (tz); |
540 | + return loc; |
541 | +} |
542 | +static int |
543 | +time_location_compare (const struct TimeLocation * a, const struct TimeLocation * b) |
544 | +{ |
545 | + int ret; |
546 | + if (a->offset != b->offset) /* primary key s.t. we can sort by timezone order */ |
547 | + ret = a->offset - b->offset; |
548 | + else |
549 | + ret = g_strcmp0 (a->name, b->name); /* secondary key */ |
550 | + g_debug ("%s comparing '%s' (%d) to '%s' (%d), returning %d", G_STRLOC, a->name, (int)a->offset, b->name, (int)b->offset, ret); |
551 | + return ret; |
552 | +} |
553 | +static GSList* |
554 | +locations_add (GSList * locations, const char * zone, const char * name) |
555 | +{ |
556 | + struct TimeLocation * loc = time_location_new (zone, name); |
557 | + |
558 | + if (g_slist_find_custom (locations, loc, (GCompareFunc)time_location_compare) == NULL) { |
559 | + g_debug ("%s Adding zone '%s', name '%s'", G_STRLOC, zone, name); |
560 | + locations = g_slist_prepend (locations, loc); |
561 | } else { |
562 | - g_debug("Timezones are different"); |
563 | - } |
564 | - |
565 | - gboolean show = g_settings_get_boolean (conf, SETTINGS_SHOW_LOCATIONS_S); |
566 | - |
567 | - if (geo_location != NULL && current_location != NULL) { |
568 | - g_debug("Got timezone %s", current_timezone); |
569 | - g_debug("Got timezone %s", geo_timezone); |
570 | - // Show neither current location nor geo location if both are the same |
571 | - // however, we want to set their time and label accordingly |
572 | - if (in_sync) { |
573 | - if (current_timezone == NULL && geo_timezone == NULL) { |
574 | - dbusmenu_menuitem_property_set_bool(locations_separator, DBUSMENU_MENUITEM_PROP_VISIBLE, FALSE); |
575 | - dbusmenu_menuitem_property_set_bool (current_location, DBUSMENU_MENUITEM_PROP_VISIBLE, FALSE); |
576 | - dbusmenu_menuitem_property_set_bool (geo_location, DBUSMENU_MENUITEM_PROP_VISIBLE, FALSE); |
577 | - update_timezone_menu_items(NULL); // Update the timezone menu items |
578 | - return; |
579 | - } |
580 | - |
581 | - dbusmenu_menuitem_property_set_bool (locations_separator, DBUSMENU_MENUITEM_PROP_VISIBLE, FALSE); |
582 | - dbusmenu_menuitem_property_set_bool (current_location, DBUSMENU_MENUITEM_PROP_VISIBLE, FALSE); |
583 | - dbusmenu_menuitem_property_set_bool (current_location, DBUSMENU_MENUITEM_PROP_ENABLED, TRUE); |
584 | - dbusmenu_menuitem_property_set_bool (geo_location, DBUSMENU_MENUITEM_PROP_VISIBLE, FALSE); |
585 | - dbusmenu_menuitem_property_set_bool (geo_location, DBUSMENU_MENUITEM_PROP_ENABLED, TRUE); |
586 | - |
587 | - if (current_timezone != NULL) { |
588 | - label = current_timezone; |
589 | - } else { |
590 | - label = geo_timezone; |
591 | - } |
592 | - |
593 | - if (label != NULL) { |
594 | - // TODO work out the current location name in a nice way |
595 | - set_current_timezone_label (current_location, label); |
596 | - // TODO work out the current time at that location |
597 | - dbusmenu_menuitem_property_set_bool (current_location, DBUSMENU_MENUITEM_PROP_VISIBLE, show); |
598 | - dbusmenu_menuitem_property_set_bool(current_location, TIMEZONE_MENUITEM_PROP_RADIO, TRUE); |
599 | - } else { |
600 | - g_debug("Label for current location is null, this shouldn't happen"); |
601 | - } |
602 | - if (geo_timezone != NULL) { |
603 | - // TODO work out the geo location name in a nice way |
604 | - set_current_timezone_label (geo_location, geo_timezone); |
605 | - // TODO work out the current time at that location |
606 | - dbusmenu_menuitem_property_set_bool (geo_location, DBUSMENU_MENUITEM_PROP_VISIBLE, show); |
607 | - } |
608 | - } else { |
609 | - // TODO work out the geo location name in a nice way |
610 | - set_current_timezone_label (geo_location, geo_timezone); |
611 | - // TODO work out the current time at that location |
612 | - dbusmenu_menuitem_property_set_bool(geo_location, DBUSMENU_MENUITEM_PROP_VISIBLE, show); |
613 | - |
614 | - // TODO work out the current location name in a nice way |
615 | - set_current_timezone_label (current_location, current_timezone); |
616 | - // TODO work out the current time at that location |
617 | - dbusmenu_menuitem_property_set_bool(current_location, TIMEZONE_MENUITEM_PROP_RADIO, TRUE); |
618 | - dbusmenu_menuitem_property_set_bool(current_location, DBUSMENU_MENUITEM_PROP_VISIBLE, show); |
619 | - dbusmenu_menuitem_property_set_bool(locations_separator, DBUSMENU_MENUITEM_PROP_VISIBLE, show); |
620 | + g_debug("%s Skipping duplicate zone '%s' name '%s'", G_STRLOC, zone, name); |
621 | + time_location_free (loc); |
622 | + } |
623 | + return locations; |
624 | +} |
625 | + |
626 | +/* Update the timezone entries */ |
627 | +static void |
628 | +update_location_menu_items (void) |
629 | +{ |
630 | + /* if we're in greeter mode, don't bother */ |
631 | + if (locations_separator == NULL) |
632 | + return; |
633 | + |
634 | + /* remove the previous locations */ |
635 | + while (location_menu_items != NULL) { |
636 | + DbusmenuMenuitem * item = DBUSMENU_MENUITEM(location_menu_items->data); |
637 | + location_menu_items = g_slist_remove(location_menu_items, item); |
638 | + dbusmenu_menuitem_child_delete(root, DBUSMENU_MENUITEM(item)); |
639 | + g_object_unref(G_OBJECT(item)); |
640 | + } |
641 | + |
642 | + /*** |
643 | + **** Build a list of locations to add: use geo_timezone, |
644 | + **** current_timezone, and SETTINGS_LOCATIONS_S, but omit duplicates. |
645 | + ***/ |
646 | + |
647 | + GSList * locations = NULL; |
648 | + |
649 | + /* maybe add geo_timezone */ |
650 | + if (geo_timezone != NULL) { |
651 | + gchar * name = get_current_zone_name (geo_timezone); |
652 | + locations = locations_add (locations, geo_timezone, name); |
653 | + g_free (name); |
654 | + } |
655 | + |
656 | + /* maybe add current_timezone */ |
657 | + if (current_timezone != NULL) { |
658 | + gchar * name = get_current_zone_name (current_timezone); |
659 | + locations = locations_add (locations, current_timezone, name); |
660 | + g_free (name); |
661 | + } |
662 | + |
663 | + /* maybe add the user-specified custom locations */ |
664 | + gchar ** user_locations = g_settings_get_strv (conf, SETTINGS_LOCATIONS_S); |
665 | + if (user_locations != NULL) { |
666 | + gint i; |
667 | + const guint location_count = g_strv_length (user_locations); |
668 | + g_debug ("%s Found %u user-specified locations", G_STRLOC, location_count); |
669 | + for (i=0; i<location_count; i++) { |
670 | + gchar * zone; |
671 | + gchar * name; |
672 | + split_settings_location (user_locations[i], &zone, &name); |
673 | + locations = locations_add (locations, zone, name); |
674 | + g_free (name); |
675 | + g_free (zone); |
676 | } |
677 | - } |
678 | - g_debug("Finished checking timezone sync"); |
679 | - update_timezone_menu_items(NULL); // Update the timezone menu items |
680 | - |
681 | - return; |
682 | + g_strfreev (user_locations); |
683 | + user_locations = NULL; |
684 | + } |
685 | + |
686 | + /* sort the list by timezone offset */ |
687 | + locations = g_slist_sort (locations, (GCompareFunc)time_location_compare); |
688 | + |
689 | + /* finally create menuitems for each location */ |
690 | + gint offset = dbusmenu_menuitem_get_position (locations_separator, root)+1; |
691 | + const gboolean show_locations = g_settings_get_boolean (conf, SETTINGS_SHOW_LOCATIONS_S); |
692 | + GSList * l; |
693 | + for (l=locations; l!=NULL; l=l->next) { |
694 | + struct TimeLocation * loc = l->data; |
695 | + g_debug("%s Adding location: zone '%s', name '%s'", G_STRLOC, loc->zone, loc->name); |
696 | + DbusmenuMenuitem * item = dbusmenu_menuitem_new(); |
697 | + dbusmenu_menuitem_property_set (item, DBUSMENU_MENUITEM_PROP_TYPE, TIMEZONE_MENUITEM_TYPE); |
698 | + dbusmenu_menuitem_property_set (item, TIMEZONE_MENUITEM_PROP_NAME, loc->name); |
699 | + dbusmenu_menuitem_property_set (item, TIMEZONE_MENUITEM_PROP_ZONE, loc->zone); |
700 | + dbusmenu_menuitem_property_set_bool (item, TIMEZONE_MENUITEM_PROP_RADIO, FALSE); |
701 | + dbusmenu_menuitem_property_set_bool (item, DBUSMENU_MENUITEM_PROP_ENABLED, TRUE); |
702 | + dbusmenu_menuitem_property_set_bool (item, DBUSMENU_MENUITEM_PROP_VISIBLE, show_locations); |
703 | + dbusmenu_menuitem_child_add_position (root, item, offset++); |
704 | + g_signal_connect(G_OBJECT(item), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, G_CALLBACK(quick_set_tz), NULL); |
705 | + location_menu_items = g_slist_append (location_menu_items, item); |
706 | + time_location_free (loc); |
707 | + } |
708 | + g_slist_free (locations); |
709 | + locations = NULL; |
710 | + |
711 | + /* if there's at least one item being shown, show the separator too */ |
712 | + dbusmenu_menuitem_property_set_bool (locations_separator, DBUSMENU_MENUITEM_PROP_VISIBLE, show_locations && (location_menu_items!=NULL)); |
713 | } |
714 | |
715 | /* Update the current timezone */ |
716 | @@ -235,7 +260,7 @@ |
717 | |
718 | g_debug("System timezone is: %s", current_timezone); |
719 | |
720 | - check_timezone_sync(); |
721 | + update_location_menu_items(); |
722 | |
723 | return; |
724 | } |
725 | @@ -331,7 +356,7 @@ |
726 | |
727 | /* Run a particular program based on an activation */ |
728 | static void |
729 | -activate_cb (DbusmenuMenuitem * menuitem, guint timestamp, const gchar *command) |
730 | +execute_command (const gchar * command) |
731 | { |
732 | GError * error = NULL; |
733 | |
734 | @@ -342,6 +367,15 @@ |
735 | } |
736 | } |
737 | |
738 | +/* Run a particular program based on an activation */ |
739 | +static void |
740 | +activate_cb (DbusmenuMenuitem * menuitem G_GNUC_UNUSED, |
741 | + guint timestamp G_GNUC_UNUSED, |
742 | + const gchar * command) |
743 | +{ |
744 | + execute_command (command); |
745 | +} |
746 | + |
747 | static gboolean |
748 | update_appointment_menu_items_idle (gpointer user_data) |
749 | { |
750 | @@ -411,22 +445,22 @@ |
751 | } |
752 | |
753 | static gboolean |
754 | -day_selected_double_click_cb (DbusmenuMenuitem * menuitem, gchar *name, GVariant *variant, guint timestamp) |
755 | +day_selected_double_click_cb (DbusmenuMenuitem * menuitem G_GNUC_UNUSED, |
756 | + gchar * name G_GNUC_UNUSED, |
757 | + GVariant * variant, |
758 | + guint timestamp G_GNUC_UNUSED) |
759 | { |
760 | - time_t evotime = (time_t)g_variant_get_uint32(variant); |
761 | + const time_t evotime = (time_t)g_variant_get_uint32(variant); |
762 | |
763 | g_debug("Received day-selected-double-click with timestamp: %d -> %s",(int)evotime, ctime(&evotime)); |
764 | |
765 | gchar *ad = isodate_from_time_t(evotime); |
766 | gchar *cmd = g_strconcat("evolution calendar:///?startdate=", ad, NULL); |
767 | |
768 | - GError * error = NULL; |
769 | + execute_command (cmd); |
770 | |
771 | - g_debug("Issuing command '%s'", cmd); |
772 | - if (!g_spawn_command_line_async(cmd, &error)) { |
773 | - g_warning("Unable to start %s: %s", (char *)cmd, error->message); |
774 | - g_error_free(error); |
775 | - } |
776 | + g_free (cmd); |
777 | + g_free (ad); |
778 | |
779 | return TRUE; |
780 | } |
781 | @@ -557,68 +591,6 @@ |
782 | return FALSE; |
783 | } |
784 | |
785 | - |
786 | -static gboolean |
787 | -update_timezone_menu_items(gpointer user_data) { |
788 | - g_debug("Updating timezone menu items"); |
789 | - |
790 | - if (locations_separator == NULL || current_location == NULL) { |
791 | - return FALSE; |
792 | - } |
793 | - |
794 | - gchar ** locations = g_settings_get_strv(conf, SETTINGS_LOCATIONS_S); |
795 | - |
796 | - if (locations == NULL) { |
797 | - g_debug("No locations configured (NULL)"); |
798 | - return FALSE; |
799 | - } |
800 | - guint len = g_strv_length(locations); |
801 | - DbusmenuMenuitem *item; |
802 | - gint i, offset; |
803 | - |
804 | - /* Remove all of the previous locations */ |
805 | - if (dconflocations != NULL) { |
806 | - while (dconflocations != NULL) { |
807 | - DbusmenuMenuitem * litem = DBUSMENU_MENUITEM(dconflocations->data); |
808 | - // Remove all the existing menu items which are in dconflocations. |
809 | - dconflocations = g_list_remove(dconflocations, litem); |
810 | - dbusmenu_menuitem_child_delete(root, DBUSMENU_MENUITEM(litem)); |
811 | - g_object_unref(G_OBJECT(litem)); |
812 | - } |
813 | - } |
814 | - |
815 | - gboolean show = g_settings_get_boolean (conf, SETTINGS_SHOW_LOCATIONS_S); |
816 | - |
817 | - dbusmenu_menuitem_property_set_bool (locations_separator, DBUSMENU_MENUITEM_PROP_VISIBLE, show); |
818 | - dbusmenu_menuitem_property_set_bool (current_location, DBUSMENU_MENUITEM_PROP_VISIBLE, show); |
819 | - dbusmenu_menuitem_property_set_bool (current_location, DBUSMENU_MENUITEM_PROP_ENABLED, TRUE); |
820 | - |
821 | - if (len == 0) { |
822 | - g_debug("No locations configured (Empty List)"); |
823 | - return FALSE; |
824 | - } |
825 | - |
826 | - offset = dbusmenu_menuitem_get_position (current_location, root)+1; |
827 | - for (i = 0; i < len; i++) { |
828 | - // Iterate over configured places and add any which aren't already listed |
829 | - if ((current_timezone == NULL || !g_str_has_prefix(locations[i], current_timezone)) && |
830 | - (geo_timezone == NULL || !g_str_has_prefix(locations[i], geo_timezone))) { |
831 | - g_debug("Adding timezone in update_timezones %s", locations[i]); |
832 | - item = dbusmenu_menuitem_new(); |
833 | - dbusmenu_menuitem_property_set (item, DBUSMENU_MENUITEM_PROP_TYPE, TIMEZONE_MENUITEM_TYPE); |
834 | - set_timezone_label (item, locations[i]); |
835 | - dbusmenu_menuitem_property_set_bool (item, TIMEZONE_MENUITEM_PROP_RADIO, FALSE); |
836 | - dbusmenu_menuitem_property_set_bool (item, DBUSMENU_MENUITEM_PROP_ENABLED, TRUE); |
837 | - dbusmenu_menuitem_property_set_bool (item, DBUSMENU_MENUITEM_PROP_VISIBLE, show); |
838 | - dbusmenu_menuitem_child_add_position (root, item, offset++); |
839 | - g_signal_connect(G_OBJECT(item), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, G_CALLBACK(quick_set_tz), NULL); |
840 | - dconflocations = g_list_append(dconflocations, item); |
841 | - } |
842 | - } |
843 | - g_strfreev (locations); |
844 | - return FALSE; |
845 | -} |
846 | - |
847 | // Authentication function |
848 | static gchar * |
849 | auth_func (ECal *ecal, |
850 | @@ -668,25 +640,7 @@ |
851 | if (status == ICAL_STATUS_COMPLETED || status == ICAL_STATUS_CANCELLED) return FALSE; |
852 | |
853 | g_object_ref(comp); |
854 | - |
855 | - ECalComponentDateTime datetime; |
856 | - icaltimezone *appointment_zone = NULL; |
857 | - icaltimezone *current_zone = NULL; |
858 | - |
859 | - if (vtype == E_CAL_COMPONENT_EVENT) |
860 | - e_cal_component_get_dtstart (comp, &datetime); |
861 | - else |
862 | - e_cal_component_get_due (comp, &datetime); |
863 | |
864 | - appointment_zone = icaltimezone_get_builtin_timezone_from_tzid(datetime.tzid); |
865 | - current_zone = icaltimezone_get_builtin_timezone_from_tzid(current_timezone); |
866 | - if (!appointment_zone || datetime.value->is_date) { // If it's today put in the current timezone? |
867 | - appointment_zone = current_zone; |
868 | - } |
869 | - |
870 | - // TODO: Convert the timezone into a 3 letter abbreviation if it's different to current_timezone |
871 | - // TODO: Add the appointment timezone to the list if it's not already there. |
872 | - |
873 | struct comp_instance *ci; |
874 | ci = g_new (struct comp_instance, 1); |
875 | |
876 | @@ -718,7 +672,6 @@ |
877 | updating_appointments = TRUE; |
878 | |
879 | time_t curtime = 0, t1 = 0, t2 = 0; |
880 | - gchar *ad; |
881 | GList *l; |
882 | GSList *g; |
883 | GError *gerror = NULL; |
884 | @@ -877,15 +830,13 @@ |
885 | } |
886 | |
887 | GVariantBuilder markeddays; |
888 | - g_variant_builder_init (&markeddays, G_VARIANT_TYPE_ARRAY); |
889 | + g_variant_builder_init (&markeddays, G_VARIANT_TYPE ("ai")); |
890 | |
891 | i = 0; |
892 | GList * cached_appointment = appointments; |
893 | for (l = sorted_comp_instances; l; l = l->next) { |
894 | struct comp_instance *ci = l->data; |
895 | ECalComponent *ecalcomp = ci->comp; |
896 | - ECalComponentText valuetext; |
897 | - gchar *summary, *cmd; |
898 | char right[20]; |
899 | //const gchar *uri; |
900 | DbusmenuMenuitem * item; |
901 | @@ -942,12 +893,11 @@ |
902 | |
903 | |
904 | // Label text |
905 | + ECalComponentText valuetext; |
906 | e_cal_component_get_summary (ecalcomp, &valuetext); |
907 | - summary = g_strdup (valuetext.value); |
908 | - |
909 | + const gchar * summary = valuetext.value; |
910 | + g_debug("Summary: %s", summary); |
911 | dbusmenu_menuitem_property_set (item, APPOINTMENT_MENUITEM_PROP_LABEL, summary); |
912 | - g_debug("Summary: %s", summary); |
913 | - g_free (summary); |
914 | |
915 | gboolean full_day = FALSE; |
916 | if (vtype == E_CAL_COMPONENT_EVENT) { |
917 | @@ -986,12 +936,12 @@ |
918 | // Now we pull out the URI for the calendar event and try to create a URI that'll work when we execute evolution |
919 | // FIXME Because the URI stuff is really broken, we're going to open the calendar at todays date instead |
920 | //e_cal_component_get_uid(ecalcomp, &uri); |
921 | - ad = isodate_from_time_t(mktime(due)); |
922 | - cmd = g_strconcat("evolution calendar:///?startdate=", ad, NULL); |
923 | - g_signal_connect (G_OBJECT(item), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, |
924 | - G_CALLBACK (activate_cb), cmd); |
925 | - |
926 | + gchar * ad = isodate_from_time_t(mktime(due)); |
927 | + gchar * cmd = g_strconcat("evolution calendar:///?startdate=", ad, NULL); |
928 | g_debug("Command to Execute: %s", cmd); |
929 | + g_signal_connect_data (G_OBJECT(item), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, |
930 | + G_CALLBACK(activate_cb), cmd, (GClosureNotify)g_free, 0); |
931 | + g_free (ad); |
932 | |
933 | const gchar *color_spec = e_source_peek_color_spec(ci->source); |
934 | g_debug("Colour to use: %s", color_spec); |
935 | @@ -1099,7 +1049,7 @@ |
936 | show_locations_changed (void) |
937 | { |
938 | /* Re-calculate */ |
939 | - check_timezone_sync(); |
940 | + update_location_menu_items(); |
941 | } |
942 | |
943 | static void |
944 | @@ -1142,22 +1092,7 @@ |
945 | dbusmenu_menuitem_property_set_bool (locations_separator, DBUSMENU_MENUITEM_PROP_VISIBLE, FALSE); |
946 | dbusmenu_menuitem_child_append(root, locations_separator); |
947 | |
948 | - geo_location = dbusmenu_menuitem_new(); |
949 | - dbusmenu_menuitem_property_set (geo_location, DBUSMENU_MENUITEM_PROP_TYPE, TIMEZONE_MENUITEM_TYPE); |
950 | - set_current_timezone_label (geo_location, ""); |
951 | - dbusmenu_menuitem_property_set_bool (geo_location, DBUSMENU_MENUITEM_PROP_ENABLED, FALSE); |
952 | - dbusmenu_menuitem_property_set_bool (geo_location, DBUSMENU_MENUITEM_PROP_VISIBLE, TRUE); |
953 | - g_signal_connect(G_OBJECT(geo_location), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, G_CALLBACK(quick_set_tz), NULL); |
954 | - dbusmenu_menuitem_child_append(root, geo_location); |
955 | - |
956 | - current_location = dbusmenu_menuitem_new(); |
957 | - dbusmenu_menuitem_property_set (current_location, DBUSMENU_MENUITEM_PROP_TYPE, TIMEZONE_MENUITEM_TYPE); |
958 | - set_current_timezone_label (current_location, ""); |
959 | - dbusmenu_menuitem_property_set_bool (current_location, DBUSMENU_MENUITEM_PROP_ENABLED, FALSE); |
960 | - dbusmenu_menuitem_property_set_bool (current_location, DBUSMENU_MENUITEM_PROP_VISIBLE, FALSE); |
961 | - dbusmenu_menuitem_child_append(root, current_location); |
962 | - |
963 | - check_timezone_sync(); |
964 | + update_location_menu_items(); |
965 | |
966 | g_signal_connect (conf, "changed::" SETTINGS_SHOW_LOCATIONS_S, G_CALLBACK (show_locations_changed), NULL); |
967 | g_signal_connect (conf, "changed::" SETTINGS_LOCATIONS_S, G_CALLBACK (show_locations_changed), NULL); |
968 | @@ -1298,7 +1233,7 @@ |
969 | geo_timezone = g_strdup((gchar *)tz_hash); |
970 | } |
971 | |
972 | - check_timezone_sync(); |
973 | + update_location_menu_items(); |
974 | |
975 | return; |
976 | } |
977 | @@ -1395,7 +1330,7 @@ |
978 | geo_timezone = NULL; |
979 | } |
980 | |
981 | - check_timezone_sync(); |
982 | + update_location_menu_items(); |
983 | |
984 | return; |
985 | } |
986 | @@ -1417,7 +1352,7 @@ |
987 | geo_timezone = NULL; |
988 | } |
989 | |
990 | - check_timezone_sync(); |
991 | + update_location_menu_items(); |
992 | |
993 | return; |
994 | } |
995 | |
996 | === modified file 'src/indicator-datetime.c' |
997 | --- src/indicator-datetime.c 2012-02-17 22:18:45 +0000 |
998 | +++ src/indicator-datetime.c 2012-03-08 23:08:19 +0000 |
999 | @@ -162,7 +162,6 @@ |
1000 | static GtkMenu * get_menu (IndicatorObject * io); |
1001 | static const gchar * get_accessible_desc (IndicatorObject * io); |
1002 | static const gchar * get_name_hint (IndicatorObject * io); |
1003 | -static GVariant * bind_enum_set (const GValue * value, const GVariantType * type, gpointer user_data); |
1004 | static gboolean bind_enum_get (GValue * value, GVariant * variant, gpointer user_data); |
1005 | static gchar * generate_format_string_now (IndicatorDatetime * self); |
1006 | static void update_label (IndicatorDatetime * io, GDateTime ** datetime); |
1007 | @@ -321,45 +320,44 @@ |
1008 | SETTINGS_SHOW_CLOCK_S, |
1009 | self, |
1010 | PROP_SHOW_CLOCK_S, |
1011 | - G_SETTINGS_BIND_DEFAULT); |
1012 | + G_SETTINGS_BIND_GET); |
1013 | g_settings_bind_with_mapping(self->priv->settings, |
1014 | SETTINGS_TIME_FORMAT_S, |
1015 | self, |
1016 | PROP_TIME_FORMAT_S, |
1017 | - G_SETTINGS_BIND_DEFAULT, |
1018 | + G_SETTINGS_BIND_GET, |
1019 | bind_enum_get, |
1020 | - bind_enum_set, |
1021 | - NULL, NULL); /* Userdata and destroy func */ |
1022 | + NULL, NULL, NULL); /* set mapping, userdata and destroy func */ |
1023 | g_settings_bind(self->priv->settings, |
1024 | SETTINGS_SHOW_SECONDS_S, |
1025 | self, |
1026 | PROP_SHOW_SECONDS_S, |
1027 | - G_SETTINGS_BIND_DEFAULT); |
1028 | + G_SETTINGS_BIND_GET); |
1029 | g_settings_bind(self->priv->settings, |
1030 | SETTINGS_SHOW_DAY_S, |
1031 | self, |
1032 | PROP_SHOW_DAY_S, |
1033 | - G_SETTINGS_BIND_DEFAULT); |
1034 | + G_SETTINGS_BIND_GET); |
1035 | g_settings_bind(self->priv->settings, |
1036 | SETTINGS_SHOW_DATE_S, |
1037 | self, |
1038 | PROP_SHOW_DATE_S, |
1039 | - G_SETTINGS_BIND_DEFAULT); |
1040 | + G_SETTINGS_BIND_GET); |
1041 | g_settings_bind(self->priv->settings, |
1042 | SETTINGS_CUSTOM_TIME_FORMAT_S, |
1043 | self, |
1044 | PROP_CUSTOM_TIME_FORMAT_S, |
1045 | - G_SETTINGS_BIND_DEFAULT); |
1046 | + G_SETTINGS_BIND_GET); |
1047 | g_settings_bind(self->priv->settings, |
1048 | SETTINGS_SHOW_WEEK_NUMBERS_S, |
1049 | self, |
1050 | PROP_SHOW_WEEK_NUMBERS_S, |
1051 | - G_SETTINGS_BIND_DEFAULT); |
1052 | + G_SETTINGS_BIND_GET); |
1053 | g_settings_bind(self->priv->settings, |
1054 | SETTINGS_SHOW_CALENDAR_S, |
1055 | self, |
1056 | PROP_SHOW_CALENDAR_S, |
1057 | - G_SETTINGS_BIND_DEFAULT); |
1058 | + G_SETTINGS_BIND_GET); |
1059 | } else { |
1060 | g_warning("Unable to get settings for '" SETTINGS_INTERFACE "'"); |
1061 | } |
1062 | @@ -405,10 +403,7 @@ |
1063 | |
1064 | GDBusProxy * proxy = g_dbus_proxy_new_for_bus_finish(res, &error); |
1065 | |
1066 | - if (priv->service_proxy_cancel != NULL) { |
1067 | - g_object_unref(priv->service_proxy_cancel); |
1068 | - priv->service_proxy_cancel = NULL; |
1069 | - } |
1070 | + g_clear_object (&priv->service_proxy_cancel); |
1071 | |
1072 | if (error != NULL) { |
1073 | g_warning("Could not grab DBus proxy for %s: %s", SERVICE_NAME, error->message); |
1074 | @@ -429,46 +424,26 @@ |
1075 | indicator_datetime_dispose (GObject *object) |
1076 | { |
1077 | IndicatorDatetime * self = INDICATOR_DATETIME(object); |
1078 | - |
1079 | - if (self->priv->label != NULL) { |
1080 | - g_object_unref(self->priv->label); |
1081 | - self->priv->label = NULL; |
1082 | - } |
1083 | - |
1084 | - if (self->priv->timer != 0) { |
1085 | - g_source_remove(self->priv->timer); |
1086 | - self->priv->timer = 0; |
1087 | - } |
1088 | - |
1089 | - if (self->priv->idle_measure != 0) { |
1090 | - g_source_remove(self->priv->idle_measure); |
1091 | - self->priv->idle_measure = 0; |
1092 | - } |
1093 | - |
1094 | - if (self->priv->menu != NULL) { |
1095 | - g_object_unref(G_OBJECT(self->priv->menu)); |
1096 | - self->priv->menu = NULL; |
1097 | - } |
1098 | - |
1099 | - if (self->priv->sm != NULL) { |
1100 | - g_object_unref(G_OBJECT(self->priv->sm)); |
1101 | - self->priv->sm = NULL; |
1102 | - } |
1103 | - |
1104 | - if (self->priv->settings != NULL) { |
1105 | - g_object_unref(G_OBJECT(self->priv->settings)); |
1106 | - self->priv->settings = NULL; |
1107 | - } |
1108 | - |
1109 | - if (self->priv->service_proxy != NULL) { |
1110 | - g_object_unref(self->priv->service_proxy); |
1111 | - self->priv->service_proxy = NULL; |
1112 | - } |
1113 | - |
1114 | - if (self->priv->indicator_right_group != NULL) { |
1115 | - g_object_unref(G_OBJECT(self->priv->indicator_right_group)); |
1116 | - self->priv->indicator_right_group = NULL; |
1117 | - } |
1118 | + IndicatorDatetimePrivate * priv = self->priv; |
1119 | + |
1120 | + if (priv->timer != 0) { |
1121 | + g_source_remove(priv->timer); |
1122 | + priv->timer = 0; |
1123 | + } |
1124 | + |
1125 | + if (priv->idle_measure != 0) { |
1126 | + g_source_remove(priv->idle_measure); |
1127 | + priv->idle_measure = 0; |
1128 | + } |
1129 | + |
1130 | + g_clear_object (&priv->label); |
1131 | + g_clear_object (&priv->menu); |
1132 | + g_clear_object (&priv->sm); |
1133 | + g_clear_object (&priv->settings); |
1134 | + g_clear_object (&priv->service_proxy); |
1135 | + g_clear_object (&priv->indicator_right_group); |
1136 | + g_clear_object (&priv->ido_calendar); |
1137 | + g_clear_object (&priv->service_proxy_cancel); |
1138 | |
1139 | G_OBJECT_CLASS (indicator_datetime_parent_class)->dispose (object); |
1140 | return; |
1141 | @@ -493,24 +468,6 @@ |
1142 | return; |
1143 | } |
1144 | |
1145 | -/* Turns the int value into a string GVariant */ |
1146 | -static GVariant * |
1147 | -bind_enum_set (const GValue * value, const GVariantType * type, gpointer user_data) |
1148 | -{ |
1149 | - switch (g_value_get_int(value)) { |
1150 | - case SETTINGS_TIME_LOCALE: |
1151 | - return g_variant_new_string("locale-default"); |
1152 | - case SETTINGS_TIME_12_HOUR: |
1153 | - return g_variant_new_string("12-hour"); |
1154 | - case SETTINGS_TIME_24_HOUR: |
1155 | - return g_variant_new_string("24-hour"); |
1156 | - case SETTINGS_TIME_CUSTOM: |
1157 | - return g_variant_new_string("custom"); |
1158 | - default: |
1159 | - return NULL; |
1160 | - } |
1161 | -} |
1162 | - |
1163 | /* Turns a string GVariant into an int value */ |
1164 | static gboolean |
1165 | bind_enum_get (GValue * value, GVariant * variant, gpointer user_data) |