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
1=== modified file 'src/indicator-datetime.c'
2--- src/indicator-datetime.c 2012-03-02 03:02:57 +0000
3+++ src/indicator-datetime.c 2012-03-07 21:02:18 +0000
4@@ -162,7 +162,6 @@
5 static GtkMenu * get_menu (IndicatorObject * io);
6 static const gchar * get_accessible_desc (IndicatorObject * io);
7 static const gchar * get_name_hint (IndicatorObject * io);
8-static GVariant * bind_enum_set (const GValue * value, const GVariantType * type, gpointer user_data);
9 static gboolean bind_enum_get (GValue * value, GVariant * variant, gpointer user_data);
10 static gchar * generate_format_string_now (IndicatorDatetime * self);
11 static void update_label (IndicatorDatetime * io, GDateTime ** datetime);
12@@ -321,45 +320,44 @@
13 SETTINGS_SHOW_CLOCK_S,
14 self,
15 PROP_SHOW_CLOCK_S,
16- G_SETTINGS_BIND_DEFAULT);
17+ G_SETTINGS_BIND_GET);
18 g_settings_bind_with_mapping(self->priv->settings,
19 SETTINGS_TIME_FORMAT_S,
20 self,
21 PROP_TIME_FORMAT_S,
22- G_SETTINGS_BIND_DEFAULT,
23+ G_SETTINGS_BIND_GET,
24 bind_enum_get,
25- bind_enum_set,
26- NULL, NULL); /* Userdata and destroy func */
27+ NULL, NULL, NULL); /* set mapping, userdata and destroy func */
28 g_settings_bind(self->priv->settings,
29 SETTINGS_SHOW_SECONDS_S,
30 self,
31 PROP_SHOW_SECONDS_S,
32- G_SETTINGS_BIND_DEFAULT);
33+ G_SETTINGS_BIND_GET);
34 g_settings_bind(self->priv->settings,
35 SETTINGS_SHOW_DAY_S,
36 self,
37 PROP_SHOW_DAY_S,
38- G_SETTINGS_BIND_DEFAULT);
39+ G_SETTINGS_BIND_GET);
40 g_settings_bind(self->priv->settings,
41 SETTINGS_SHOW_DATE_S,
42 self,
43 PROP_SHOW_DATE_S,
44- G_SETTINGS_BIND_DEFAULT);
45+ G_SETTINGS_BIND_GET);
46 g_settings_bind(self->priv->settings,
47 SETTINGS_CUSTOM_TIME_FORMAT_S,
48 self,
49 PROP_CUSTOM_TIME_FORMAT_S,
50- G_SETTINGS_BIND_DEFAULT);
51+ G_SETTINGS_BIND_GET);
52 g_settings_bind(self->priv->settings,
53 SETTINGS_SHOW_WEEK_NUMBERS_S,
54 self,
55 PROP_SHOW_WEEK_NUMBERS_S,
56- G_SETTINGS_BIND_DEFAULT);
57+ G_SETTINGS_BIND_GET);
58 g_settings_bind(self->priv->settings,
59 SETTINGS_SHOW_CALENDAR_S,
60 self,
61 PROP_SHOW_CALENDAR_S,
62- G_SETTINGS_BIND_DEFAULT);
63+ G_SETTINGS_BIND_GET);
64 } else {
65 g_warning("Unable to get settings for '" SETTINGS_INTERFACE "'");
66 }
67@@ -470,24 +468,6 @@
68 return;
69 }
70
71-/* Turns the int value into a string GVariant */
72-static GVariant *
73-bind_enum_set (const GValue * value, const GVariantType * type, gpointer user_data)
74-{
75- switch (g_value_get_int(value)) {
76- case SETTINGS_TIME_LOCALE:
77- return g_variant_new_string("locale-default");
78- case SETTINGS_TIME_12_HOUR:
79- return g_variant_new_string("12-hour");
80- case SETTINGS_TIME_24_HOUR:
81- return g_variant_new_string("24-hour");
82- case SETTINGS_TIME_CUSTOM:
83- return g_variant_new_string("custom");
84- default:
85- return NULL;
86- }
87-}
88-
89 /* Turns a string GVariant into an int value */
90 static gboolean
91 bind_enum_get (GValue * value, GVariant * variant, gpointer user_data)

Subscribers

People subscribed via source and target branches