Merge lp:~desrt/indicator-datetime/readonly-binding into lp:indicator-datetime/0.4

Proposed by Allison Karlitskaya
Status: Merged
Approved by: Ted Gould
Approved revision: 159
Merged at revision: 160
Proposed branch: lp:~desrt/indicator-datetime/readonly-binding
Merge into: lp:indicator-datetime/0.4
Diff against target: 91 lines (+9/-29)
1 file modified
src/indicator-datetime.c (+9/-29)
To merge this branch: bzr merge lp:~desrt/indicator-datetime/readonly-binding
Reviewer Review Type Date Requested Status
Ted Gould (community) Approve
Review via email: mp+96454@code.launchpad.net

Description of the change

Establish read-only bindings to GSettings from the indicator

The bindings to GSettings are established in the GTypeInstance _init
function of the indicator. During this time, the property notify queue
is frozen. After the construction completes, the queue thaws and the
rush of property change notifications causes GSettings writes to occur.

We can fix this by switching to using readonly bindings.

To post a comment you must log in.
Revision history for this message
Ted Gould (ted) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'src/indicator-datetime.c'
--- src/indicator-datetime.c 2012-03-02 03:02:57 +0000
+++ src/indicator-datetime.c 2012-03-07 21:02:18 +0000
@@ -162,7 +162,6 @@
162static GtkMenu * get_menu (IndicatorObject * io);162static GtkMenu * get_menu (IndicatorObject * io);
163static const gchar * get_accessible_desc (IndicatorObject * io);163static const gchar * get_accessible_desc (IndicatorObject * io);
164static const gchar * get_name_hint (IndicatorObject * io);164static const gchar * get_name_hint (IndicatorObject * io);
165static GVariant * bind_enum_set (const GValue * value, const GVariantType * type, gpointer user_data);
166static gboolean bind_enum_get (GValue * value, GVariant * variant, gpointer user_data);165static gboolean bind_enum_get (GValue * value, GVariant * variant, gpointer user_data);
167static gchar * generate_format_string_now (IndicatorDatetime * self);166static gchar * generate_format_string_now (IndicatorDatetime * self);
168static void update_label (IndicatorDatetime * io, GDateTime ** datetime);167static void update_label (IndicatorDatetime * io, GDateTime ** datetime);
@@ -321,45 +320,44 @@
321 SETTINGS_SHOW_CLOCK_S,320 SETTINGS_SHOW_CLOCK_S,
322 self,321 self,
323 PROP_SHOW_CLOCK_S,322 PROP_SHOW_CLOCK_S,
324 G_SETTINGS_BIND_DEFAULT);323 G_SETTINGS_BIND_GET);
325 g_settings_bind_with_mapping(self->priv->settings,324 g_settings_bind_with_mapping(self->priv->settings,
326 SETTINGS_TIME_FORMAT_S,325 SETTINGS_TIME_FORMAT_S,
327 self,326 self,
328 PROP_TIME_FORMAT_S,327 PROP_TIME_FORMAT_S,
329 G_SETTINGS_BIND_DEFAULT,328 G_SETTINGS_BIND_GET,
330 bind_enum_get,329 bind_enum_get,
331 bind_enum_set,330 NULL, NULL, NULL); /* set mapping, userdata and destroy func */
332 NULL, NULL); /* Userdata and destroy func */
333 g_settings_bind(self->priv->settings,331 g_settings_bind(self->priv->settings,
334 SETTINGS_SHOW_SECONDS_S,332 SETTINGS_SHOW_SECONDS_S,
335 self,333 self,
336 PROP_SHOW_SECONDS_S,334 PROP_SHOW_SECONDS_S,
337 G_SETTINGS_BIND_DEFAULT);335 G_SETTINGS_BIND_GET);
338 g_settings_bind(self->priv->settings,336 g_settings_bind(self->priv->settings,
339 SETTINGS_SHOW_DAY_S,337 SETTINGS_SHOW_DAY_S,
340 self,338 self,
341 PROP_SHOW_DAY_S,339 PROP_SHOW_DAY_S,
342 G_SETTINGS_BIND_DEFAULT);340 G_SETTINGS_BIND_GET);
343 g_settings_bind(self->priv->settings,341 g_settings_bind(self->priv->settings,
344 SETTINGS_SHOW_DATE_S,342 SETTINGS_SHOW_DATE_S,
345 self,343 self,
346 PROP_SHOW_DATE_S,344 PROP_SHOW_DATE_S,
347 G_SETTINGS_BIND_DEFAULT);345 G_SETTINGS_BIND_GET);
348 g_settings_bind(self->priv->settings,346 g_settings_bind(self->priv->settings,
349 SETTINGS_CUSTOM_TIME_FORMAT_S,347 SETTINGS_CUSTOM_TIME_FORMAT_S,
350 self,348 self,
351 PROP_CUSTOM_TIME_FORMAT_S,349 PROP_CUSTOM_TIME_FORMAT_S,
352 G_SETTINGS_BIND_DEFAULT);350 G_SETTINGS_BIND_GET);
353 g_settings_bind(self->priv->settings,351 g_settings_bind(self->priv->settings,
354 SETTINGS_SHOW_WEEK_NUMBERS_S,352 SETTINGS_SHOW_WEEK_NUMBERS_S,
355 self,353 self,
356 PROP_SHOW_WEEK_NUMBERS_S,354 PROP_SHOW_WEEK_NUMBERS_S,
357 G_SETTINGS_BIND_DEFAULT);355 G_SETTINGS_BIND_GET);
358 g_settings_bind(self->priv->settings,356 g_settings_bind(self->priv->settings,
359 SETTINGS_SHOW_CALENDAR_S,357 SETTINGS_SHOW_CALENDAR_S,
360 self,358 self,
361 PROP_SHOW_CALENDAR_S,359 PROP_SHOW_CALENDAR_S,
362 G_SETTINGS_BIND_DEFAULT);360 G_SETTINGS_BIND_GET);
363 } else {361 } else {
364 g_warning("Unable to get settings for '" SETTINGS_INTERFACE "'");362 g_warning("Unable to get settings for '" SETTINGS_INTERFACE "'");
365 }363 }
@@ -470,24 +468,6 @@
470 return;468 return;
471}469}
472470
473/* Turns the int value into a string GVariant */
474static GVariant *
475bind_enum_set (const GValue * value, const GVariantType * type, gpointer user_data)
476{
477 switch (g_value_get_int(value)) {
478 case SETTINGS_TIME_LOCALE:
479 return g_variant_new_string("locale-default");
480 case SETTINGS_TIME_12_HOUR:
481 return g_variant_new_string("12-hour");
482 case SETTINGS_TIME_24_HOUR:
483 return g_variant_new_string("24-hour");
484 case SETTINGS_TIME_CUSTOM:
485 return g_variant_new_string("custom");
486 default:
487 return NULL;
488 }
489}
490
491/* Turns a string GVariant into an int value */471/* Turns a string GVariant into an int value */
492static gboolean472static gboolean
493bind_enum_get (GValue * value, GVariant * variant, gpointer user_data)473bind_enum_get (GValue * value, GVariant * variant, gpointer user_data)

Subscribers

People subscribed via source and target branches