Merge lp:~3v1n0/unity-control-center/grouped-compiz-gsettings-support into lp:unity-control-center

Proposed by Marco Trevisan (Treviño) on 2017-06-26
Status: Merged
Approved by: Sebastien Bacher on 2017-06-26
Approved revision: no longer in the source branch.
Merged at revision: 12886
Proposed branch: lp:~3v1n0/unity-control-center/grouped-compiz-gsettings-support
Merge into: lp:unity-control-center
Diff against target: 708 lines (+364/-83)
1 file modified
panels/appearance/cc-appearance-panel.c (+364/-83)
To merge this branch: bzr merge lp:~3v1n0/unity-control-center/grouped-compiz-gsettings-support
Reviewer Review Type Date Requested Status
Sebastien Bacher 2017-06-26 Approve on 2017-06-26
Review via email: mp+326310@code.launchpad.net

Commit message

Appearance: create GroupedGSettings class to manage group of gsettings sharing the schema

Settings might have the same schema, but different path. With this class we manage them
all at once. In this case we use this to correctly read the setting values depending on
the compiz profile we're actually using.

To post a comment you must log in.
Sebastien Bacher (seb128) wrote :

looks good, thanks

review: Approve
12908. By Marco Trevisan (Treviño) on 2017-06-27

Appearance: code cleanup

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'panels/appearance/cc-appearance-panel.c'
2--- panels/appearance/cc-appearance-panel.c 2016-07-05 14:26:25 +0000
3+++ panels/appearance/cc-appearance-panel.c 2017-06-27 16:08:20 +0000
4@@ -5,15 +5,15 @@
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 2 of the License, or
7 * (at your option) any later version.
8- *
9+ *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14- *
15+ *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18- *
19+ *
20 * Author: Thomas Wood <thomas.wood@intel.com>
21 *
22 */
23@@ -55,6 +55,10 @@
24 #define APPEARANCE_PANEL_PRIVATE(o) \
25 (G_TYPE_INSTANCE_GET_PRIVATE ((o), CC_TYPE_APPEARANCE_PANEL, CcAppearancePanelPrivate))
26
27+typedef struct _GroupedGSettings GroupedGSettings;
28+typedef struct _GroupedGSettingsClass GroupedGSettingsClass;
29+typedef struct _GroupedGSettingsPrivate GroupedGSettingsPrivate;
30+
31 struct _CcAppearancePanelPrivate
32 {
33 GtkBuilder *builder;
34@@ -70,11 +74,15 @@
35 GSettings *settings;
36 GSettings *interface_settings;
37 GSettings *wm_theme_settings;
38- GSettings *unity_settings;
39- GSettings *compizcore_settings;
40 GSettings *unity_own_settings;
41 GSettings *unity_launcher_settings;
42
43+ GroupedGSettings *unity_compiz_gs;
44+ GroupedGSettings *compizcore_compiz_gs;
45+ GSettings *compiz_settings;
46+ GSettings *compizcore_settings;
47+ GSettings *unity_settings;
48+
49 GnomeDesktopThumbnailFactory *thumb_factory;
50
51 CcAppearanceItem *current_background;
52@@ -98,7 +106,13 @@
53 #endif
54 };
55
56-#define UNITY_GSETTINGS_SCHEMA "org.compiz.unityshell"
57+#define COMPIZ_GSETTINGS_SCHEMA "org.compiz"
58+#define COMPIZ_CURRENT_PROFILE_KEY "current-profile"
59+
60+#define UNITY_NORMAL_PROFILE "unity"
61+#define UNITY_LOWGFX_PROFILE "unity-lowgfx"
62+
63+#define UNITY_GSETTINGS_SCHEMA COMPIZ_GSETTINGS_SCHEMA ".unityshell"
64 #define UNITY_PROFILE_PATH "/org/compiz/profiles/%s/plugins/"
65 #define UNITY_GSETTINGS_PATH UNITY_PROFILE_PATH"unityshell/"
66 #define UNITY_ICONSIZE_KEY "icon-size"
67@@ -107,7 +121,7 @@
68 #define UNITY_LAUNCHERREVEAL_KEY "reveal-trigger"
69 #define CANONICAL_DESKTOP_INTERFACE "com.canonical.desktop.interface"
70
71-#define COMPIZCORE_GSETTINGS_SCHEMA "org.compiz.core"
72+#define COMPIZCORE_GSETTINGS_SCHEMA COMPIZ_GSETTINGS_SCHEMA ".core"
73 #define COMPIZCORE_GSETTINGS_PATH UNITY_PROFILE_PATH"core/"
74 #define COMPIZCORE_HSIZE_KEY "hsize"
75 #define COMPIZCORE_VSIZE_KEY "vsize"
76@@ -211,12 +225,30 @@
77 priv->wm_theme_settings = NULL;
78 }
79
80+ if (priv->unity_compiz_gs)
81+ {
82+ g_object_unref (priv->unity_compiz_gs);
83+ priv->unity_compiz_gs = NULL;
84+ }
85+
86+ if (priv->compizcore_compiz_gs)
87+ {
88+ g_object_unref (priv->compizcore_compiz_gs);
89+ priv->compizcore_compiz_gs = NULL;
90+ }
91+
92 if (priv->unity_settings)
93 {
94 g_object_unref (priv->unity_settings);
95 priv->unity_settings = NULL;
96 }
97
98+ if (priv->compiz_settings)
99+ {
100+ g_object_unref (priv->compiz_settings);
101+ priv->compiz_settings = NULL;
102+ }
103+
104 if (priv->compizcore_settings)
105 {
106 g_object_unref (priv->compizcore_settings);
107@@ -291,6 +323,239 @@
108 {
109 }
110
111+/* Implementation of GroupedGSettings a class to manage multiple gsettings
112+ * who share schema but with different paths
113+ */
114+#define IS_GSETTINGS_GROUPED(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), \
115+ grouped_gsettings_get_type ()))
116+
117+GType grouped_gsettings_get_type (void) G_GNUC_CONST;
118+
119+struct _GroupedGSettings {
120+ GObject parent_instance;
121+ GroupedGSettingsPrivate *priv;
122+};
123+
124+struct _GroupedGSettingsClass {
125+ GObjectClass parent_class;
126+};
127+
128+struct _GroupedGSettingsPrivate
129+{
130+ GList *settings_list;
131+ GSettings *default_gs;
132+ GSettings **remote_gs;
133+};
134+
135+G_DEFINE_TYPE (GroupedGSettings, grouped_gsettings, G_TYPE_OBJECT)
136+
137+static void
138+grouped_gsettings_dispose (GObject *object)
139+{
140+ GroupedGSettings *self = (GroupedGSettings *) object;
141+
142+ if (self->priv->settings_list)
143+ {
144+ g_list_free_full (self->priv->settings_list, g_object_unref);
145+ self->priv->settings_list = NULL;
146+ }
147+
148+ if (G_OBJECT_CLASS (grouped_gsettings_parent_class))
149+ G_OBJECT_CLASS (grouped_gsettings_parent_class)->dispose (object);
150+}
151+
152+static void
153+grouped_gsettings_class_init (GroupedGSettingsClass *klass)
154+{
155+ GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
156+
157+ g_type_class_add_private (klass, sizeof (GroupedGSettingsPrivate));
158+
159+ gobject_class->dispose = grouped_gsettings_dispose;
160+
161+ g_signal_new ("changed", G_TYPE_FROM_CLASS (klass),
162+ G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED, 0,
163+ NULL, NULL, g_cclosure_marshal_VOID__STRING, G_TYPE_NONE,
164+ 1, G_TYPE_STRING | G_SIGNAL_TYPE_STATIC_SCOPE);
165+}
166+
167+static void
168+grouped_gsettings_init (GroupedGSettings *self)
169+{
170+ self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, grouped_gsettings_get_type (),
171+ GroupedGSettingsPrivate);
172+}
173+
174+static void
175+on_default_settings_changed (GSettings *settings,
176+ gchar *key,
177+ GroupedGSettings *self)
178+{
179+ gchar *signal = g_strdup_printf ("changed::%s", key);
180+ g_signal_emit_by_name (self, signal, key);
181+ g_free (signal);
182+}
183+
184+static GSettings *
185+grouped_gsettings_peek_default (GroupedGSettings *self)
186+{
187+ g_return_val_if_fail (IS_GSETTINGS_GROUPED (self), NULL);
188+ return self->priv->default_gs;
189+}
190+
191+static void
192+grouped_gsettings_set_default_profile (GroupedGSettings *self,
193+ const gchar *profile)
194+{
195+ GList *l;
196+ GroupedGSettingsPrivate *priv;
197+
198+ g_return_if_fail (IS_GSETTINGS_GROUPED (self));
199+ g_return_if_fail (profile);
200+
201+ priv = self->priv;
202+
203+ for (l = priv->settings_list; l; l = l->next)
204+ {
205+ GSettings *settings;
206+ const gchar *settings_profile;
207+
208+ settings = l->data;
209+ settings_profile = g_object_get_data (G_OBJECT (settings), "profile");
210+
211+ if (g_strcmp0 (settings_profile, profile) == 0)
212+ {
213+ if (priv->default_gs == settings)
214+ {
215+ return;
216+ }
217+
218+ if (priv->default_gs)
219+ {
220+ g_signal_handlers_block_by_func (priv->default_gs,
221+ on_default_settings_changed, self);
222+ }
223+
224+ priv->default_gs = settings;
225+ g_signal_handlers_unblock_by_func (settings,
226+ on_default_settings_changed, self);
227+
228+ if (priv->remote_gs)
229+ {
230+ if (G_IS_SETTINGS (*priv->remote_gs))
231+ g_object_unref (*priv->remote_gs);
232+
233+ *priv->remote_gs = g_object_ref (settings);
234+ }
235+
236+ return;
237+ }
238+ }
239+}
240+
241+static void
242+grouped_gsettings_reset (GroupedGSettings *self, const gchar *key)
243+{
244+ g_return_if_fail (IS_GSETTINGS_GROUPED (self));
245+ g_list_foreach (self->priv->settings_list,
246+ (GFunc) g_settings_reset, (gpointer) key);
247+}
248+
249+static void
250+grouped_gsettings_set_value (GroupedGSettings *self,
251+ const gchar *key,
252+ GVariant *value)
253+{
254+ GList *l;
255+ g_return_if_fail (IS_GSETTINGS_GROUPED (self));
256+
257+ for (l = self->priv->settings_list; l; l = l->next)
258+ g_settings_set_value (G_SETTINGS (l->data), key, value);
259+}
260+
261+static GSettings *
262+grouped_gsettings_add (GroupedGSettings *self,
263+ GSettingsSchema *settings_schema,
264+ const gchar *settings_path,
265+ const gchar *profile,
266+ GSettings **remote_settings)
267+{
268+ GSettings *settings;
269+
270+ g_return_val_if_fail (IS_GSETTINGS_GROUPED (self), NULL);
271+
272+ settings = g_settings_new_full (settings_schema, /*backend*/ NULL, settings_path);
273+ self->priv->settings_list = g_list_prepend (self->priv->settings_list, settings);
274+ self->priv->remote_gs = remote_settings;
275+
276+ g_signal_connect (settings, "changed", G_CALLBACK (on_default_settings_changed), self);
277+ g_signal_handlers_block_by_func (settings, on_default_settings_changed, self);
278+
279+ if (!profile)
280+ {
281+ profile = settings_path;
282+ }
283+
284+ g_object_set_data_full (G_OBJECT (settings), "profile",
285+ (gpointer) g_strdup (profile), g_free);
286+
287+ if (!self->priv->default_gs)
288+ {
289+ grouped_gsettings_set_default_profile (self, profile);
290+ }
291+
292+ return settings;
293+}
294+
295+
296+static GSettings *
297+compiz_grouped_gsettings_add (GroupedGSettings *self,
298+ GSettingsSchema *settings_schema,
299+ const gchar *settings_base_path,
300+ const gchar *compiz_profile,
301+ GSettings **remote_settings)
302+{
303+ GSettings *settings;
304+ gchar *settings_path;
305+
306+ compiz_profile = compiz_profile ? compiz_profile : UNITY_NORMAL_PROFILE;
307+ settings_path = g_strdup_printf (settings_base_path, compiz_profile);
308+ settings = grouped_gsettings_add (self, settings_schema, settings_path,
309+ compiz_profile, remote_settings);
310+ g_free (settings_path);
311+
312+ return settings;
313+}
314+
315+GroupedGSettings *
316+compiz_grouped_gsettings_new (GSettingsSchema *settings_schema,
317+ GSettings *compiz_settings,
318+ const gchar *settings_base_path,
319+ GSettings **remote_settings)
320+{
321+ GroupedGSettings *ggs;
322+ GSettings *settings;
323+ gchar *compiz_profile;
324+
325+ g_return_val_if_fail (settings_base_path, NULL);
326+
327+ ggs = g_object_new (grouped_gsettings_get_type (), NULL);
328+ compiz_profile = g_settings_get_string (compiz_settings,
329+ COMPIZ_CURRENT_PROFILE_KEY);
330+
331+ compiz_grouped_gsettings_add (ggs, settings_schema, settings_base_path,
332+ UNITY_NORMAL_PROFILE, remote_settings);
333+ compiz_grouped_gsettings_add (ggs, settings_schema, settings_base_path,
334+ UNITY_LOWGFX_PROFILE, remote_settings);
335+
336+ grouped_gsettings_set_default_profile (ggs, compiz_profile);
337+ g_free (compiz_profile);
338+
339+ return ggs;
340+}
341+
342+/* GroupedGSettings definition end */
343+
344 static void
345 source_update_edit_box (CcAppearancePanelPrivate *priv,
346 gboolean initial)
347@@ -1387,11 +1652,11 @@
348 }
349
350 static void
351-ext_iconsize_changed_callback (GSettings* settings,
352- guint key,
353+ext_iconsize_changed_callback (GroupedGSettings* compiz_gs,
354+ gchar *key,
355 gpointer user_data)
356 {
357- iconsize_widget_refresh (GTK_ADJUSTMENT (user_data), settings);
358+ iconsize_widget_refresh (GTK_ADJUSTMENT (user_data), grouped_gsettings_peek_default (compiz_gs));
359 }
360
361 static gchar *
362@@ -1401,9 +1666,9 @@
363 }
364
365 static void
366-on_iconsize_changed (GtkAdjustment *adj, GSettings *unity_settings)
367+on_iconsize_changed (GtkAdjustment *adj, CcAppearancePanel *self)
368 {
369- g_settings_set_int (unity_settings, UNITY_ICONSIZE_KEY, (gint)gtk_adjustment_get_value (adj) * 2);
370+ grouped_gsettings_set_value (self->priv->unity_compiz_gs, UNITY_ICONSIZE_KEY, g_variant_new_int32 ((gint) gtk_adjustment_get_value (adj) * 2));
371 }
372
373 static void
374@@ -1459,8 +1724,8 @@
375 }
376
377 static void
378-ext_hidelauncher_changed_callback (GSettings* settings,
379- guint key,
380+ext_hidelauncher_changed_callback (GroupedGSettings* compiz_gs,
381+ gchar *key,
382 gpointer user_data)
383 {
384 hidelauncher_widget_refresh (CC_APPEARANCE_PANEL (user_data));
385@@ -1485,7 +1750,7 @@
386 }
387
388 /* 3d */
389- g_settings_set_int (self->priv->unity_settings, UNITY_LAUNCHERHIDE_KEY, value);
390+ grouped_gsettings_set_value (self->priv->unity_compiz_gs, UNITY_LAUNCHERHIDE_KEY, g_variant_new_int32 (value));
391 hidelauncher_set_sensitivity_reveal (self, (value != -1));
392 }
393
394@@ -1507,8 +1772,8 @@
395 }
396
397 static void
398-ext_reveallauncher_changed_callback (GSettings* settings,
399- guint key,
400+ext_reveallauncher_changed_callback (GroupedGSettings* compiz_gs,
401+ gchar *key,
402 gpointer user_data)
403 {
404 reveallauncher_widget_refresh (CC_APPEARANCE_PANEL (user_data));
405@@ -1526,7 +1791,7 @@
406 if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (WID ("unity_reveal_spot_left"))))
407 reveal_spot = 0;
408
409- g_settings_set_int (priv->unity_settings, UNITY_LAUNCHERREVEAL_KEY, reveal_spot);
410+ grouped_gsettings_set_value (priv->unity_compiz_gs, UNITY_LAUNCHERREVEAL_KEY, g_variant_new_int32 (reveal_spot));
411 reveallauncher_widget_refresh (self);
412 }
413
414@@ -1538,11 +1803,11 @@
415 }
416
417 static void
418-ext_launchersensitivity_changed_callback (GSettings* settings,
419- guint key,
420+ext_launchersensitivity_changed_callback (GroupedGSettings* compiz_gs,
421+ gchar *key,
422 gpointer user_data)
423 {
424- launcher_sensitivity_widget_refresh (GTK_ADJUSTMENT (user_data), settings);
425+ launcher_sensitivity_widget_refresh (GTK_ADJUSTMENT (user_data), grouped_gsettings_peek_default (compiz_gs));
426 }
427
428 static void
429@@ -1552,7 +1817,7 @@
430 CcAppearancePanelPrivate *priv = self->priv;
431 gdouble value = gtk_adjustment_get_value (adj);
432
433- g_settings_set_double (priv->unity_settings, UNITY_LAUNCHERSENSITIVITY_KEY, value);
434+ grouped_gsettings_set_value (priv->unity_compiz_gs, UNITY_LAUNCHERSENSITIVITY_KEY, g_variant_new_double (value));
435 }
436
437 gboolean
438@@ -1577,12 +1842,12 @@
439 }
440
441 static void
442-ext_enableworkspaces_changed_callback (GSettings* settings,
443- guint key,
444+ext_enableworkspaces_changed_callback (GroupedGSettings* compiz_gs,
445+ gchar *key,
446 gpointer user_data)
447 {
448 g_idle_add((GSourceFunc) enable_workspaces_widget_refresh, user_data);
449-}
450+}
451
452 static void
453 on_enable_workspaces_changed (GtkToggleButton *button, gpointer user_data)
454@@ -1597,8 +1862,8 @@
455 hsize = vsize = 2;
456 }
457
458- g_settings_set_int (priv->compizcore_settings, COMPIZCORE_HSIZE_KEY, hsize);
459- g_settings_set_int (priv->compizcore_settings, COMPIZCORE_VSIZE_KEY, hsize);
460+ grouped_gsettings_set_value (priv->compizcore_compiz_gs, COMPIZCORE_HSIZE_KEY, g_variant_new_int32 (hsize));
461+ grouped_gsettings_set_value (priv->compizcore_compiz_gs, COMPIZCORE_VSIZE_KEY, g_variant_new_int32 (hsize));
462 }
463
464 static void
465@@ -1625,8 +1890,8 @@
466 }
467
468 static void
469-ext_enableshowdesktop_changed_callback (GSettings* settings,
470- guint key,
471+ext_enableshowdesktop_changed_callback (GroupedGSettings* compiz_gs,
472+ gchar *key,
473 gpointer user_data)
474 {
475 enable_showdesktop_widget_refresh (user_data);
476@@ -1691,19 +1956,15 @@
477 if (!self->priv->unity_own_settings)
478 return FALSE;
479
480- gchar** unity_keys;
481- gchar** key;
482-
483- unity_keys = g_settings_list_keys (self->priv->unity_own_settings);
484-
485- for (key = unity_keys; *key; ++key)
486- {
487- if (g_strcmp0 (*key, key_name) == 0)
488- return TRUE;
489- }
490-
491- g_strfreev (unity_keys);
492- return FALSE;
493+ GSettingsSchema *unity_schema;
494+ gboolean has_key;
495+
496+ g_object_get (self->priv->unity_own_settings,
497+ "settings-schema", &unity_schema, NULL);
498+ has_key = g_settings_schema_has_key (unity_schema, key_name);
499+ g_settings_schema_unref (unity_schema);
500+
501+ return has_key;
502 }
503
504 static void
505@@ -1728,8 +1989,8 @@
506 }
507
508 static void
509-ext_menulocation_changed_callback (GSettings* settings,
510- guint key,
511+ext_menulocation_changed_callback (GroupedGSettings* compiz_gs,
512+ gchar *key,
513 gpointer user_data)
514 {
515 menulocation_widget_refresh (CC_APPEARANCE_PANEL (user_data));
516@@ -1768,9 +2029,9 @@
517 }
518
519 static void
520-ext_menuvisibility_changed_callback (GSettings* settings,
521- guint key,
522- gpointer user_data)
523+ext_menuvisibility_changed_callback (GroupedGSettings* compiz_gs,
524+ gchar *key,
525+ gpointer user_data)
526 {
527 menuvisibility_widget_refresh (CC_APPEARANCE_PANEL (user_data));
528 }
529@@ -1787,17 +2048,41 @@
530 }
531
532 static void
533+ext_compiz_profile_changed_callback (GSettings* compiz_settings,
534+ gchar *key,
535+ gpointer user_data)
536+{
537+ CcAppearancePanel *self = user_data;
538+ gchar *compiz_profile;
539+ gboolean low_enabled;
540+
541+ compiz_profile = g_settings_get_string (compiz_settings, COMPIZ_CURRENT_PROFILE_KEY);
542+
543+ if (g_strcmp0 (compiz_profile, UNITY_NORMAL_PROFILE) != 0 &&
544+ g_strcmp0 (compiz_profile, UNITY_LOWGFX_PROFILE) != 0)
545+ {
546+ g_free (compiz_profile);
547+ return;
548+ }
549+
550+ grouped_gsettings_set_default_profile (self->priv->unity_compiz_gs, compiz_profile);
551+ grouped_gsettings_set_default_profile (self->priv->compizcore_compiz_gs, compiz_profile);
552+
553+ g_free (compiz_profile);
554+}
555+
556+static void
557 on_restore_defaults_page2_clicked (GtkButton *button, gpointer user_data)
558 {
559 CcAppearancePanel *self = CC_APPEARANCE_PANEL (user_data);
560 CcAppearancePanelPrivate *priv = self->priv;
561
562 /* reset defaut for the profile and get the default */
563- g_settings_reset (priv->unity_settings, UNITY_LAUNCHERHIDE_KEY);
564- g_settings_reset (priv->unity_settings, UNITY_LAUNCHERSENSITIVITY_KEY);
565- g_settings_reset (priv->unity_settings, UNITY_LAUNCHERREVEAL_KEY);
566- g_settings_reset (priv->compizcore_settings, COMPIZCORE_HSIZE_KEY);
567- g_settings_reset (priv->compizcore_settings, COMPIZCORE_VSIZE_KEY);
568+ grouped_gsettings_reset (priv->unity_compiz_gs, UNITY_LAUNCHERHIDE_KEY);
569+ grouped_gsettings_reset (priv->unity_compiz_gs, UNITY_LAUNCHERSENSITIVITY_KEY);
570+ grouped_gsettings_reset (priv->unity_compiz_gs, UNITY_LAUNCHERREVEAL_KEY);
571+ grouped_gsettings_reset (priv->compizcore_compiz_gs, COMPIZCORE_HSIZE_KEY);
572+ grouped_gsettings_reset (priv->compizcore_compiz_gs, COMPIZCORE_VSIZE_KEY);
573
574 if (unity_own_setting_exists (self, UNITY_INTEGRATED_MENUS_KEY))
575 g_settings_reset (priv->unity_own_settings, UNITY_INTEGRATED_MENUS_KEY);
576@@ -1847,20 +2132,6 @@
577 }
578
579 /* </hacks> */
580-
581-static gchar *
582-compiz_profile_gsettings_path (const gchar *path)
583-{
584- const gchar *profile = "unity";
585-
586- if (g_strcmp0 (g_getenv ("COMPIZ_CONFIG_PROFILE"), "ubuntu-lowgfx") == 0)
587- {
588- profile = "unity-lowgfx";
589- }
590-
591- return g_strdup_printf (path, profile);
592-}
593-
594 static void
595 setup_unity_settings (CcAppearancePanel *self)
596 {
597@@ -1871,59 +2142,69 @@
598 GtkScale* launcher_sensitivity_scale;
599 GSettingsSchema *schema;
600 GSettingsSchemaSource* source;
601- gchar *settings_path;
602
603 source = g_settings_schema_source_get_default ();
604 schema = g_settings_schema_source_lookup (source, UNITY_OWN_GSETTINGS_SCHEMA, TRUE);
605 if (schema)
606 {
607- priv->unity_own_settings = g_settings_new (UNITY_OWN_GSETTINGS_SCHEMA);
608+ priv->unity_own_settings = g_settings_new_full (schema, /*backend*/ NULL, /*path*/ NULL);
609+ g_settings_schema_unref (schema);
610+ }
611+ schema = g_settings_schema_source_lookup (source, COMPIZ_GSETTINGS_SCHEMA, TRUE);
612+ if (schema)
613+ {
614+ priv->compiz_settings = g_settings_new_full (schema, /*backend*/ NULL, /*path*/ NULL);
615 g_settings_schema_unref (schema);
616 }
617 schema = g_settings_schema_source_lookup (source, UNITY_LAUNCHER_GSETTINGS_SCHEMA, TRUE);
618 if (schema)
619 {
620- priv->unity_launcher_settings = g_settings_new (UNITY_LAUNCHER_GSETTINGS_SCHEMA);
621+ priv->unity_launcher_settings = g_settings_new_full (schema, /*backend*/ NULL, /*path*/ NULL);
622 g_settings_schema_unref (schema);
623 }
624 schema = g_settings_schema_source_lookup (source, UNITY_GSETTINGS_SCHEMA, TRUE);
625 if (schema)
626 {
627- settings_path = compiz_profile_gsettings_path (UNITY_GSETTINGS_PATH);
628- priv->unity_settings = g_settings_new_with_path (UNITY_GSETTINGS_SCHEMA, settings_path);
629+ priv->unity_compiz_gs = compiz_grouped_gsettings_new (schema,
630+ priv->compiz_settings,
631+ UNITY_GSETTINGS_PATH,
632+ &priv->unity_settings);
633 g_settings_schema_unref (schema);
634- g_free (settings_path);
635 }
636 schema = g_settings_schema_source_lookup (source, COMPIZCORE_GSETTINGS_SCHEMA, TRUE);
637 if (schema)
638 {
639- settings_path = compiz_profile_gsettings_path (COMPIZCORE_GSETTINGS_PATH);
640- priv->compizcore_settings = g_settings_new_with_path (COMPIZCORE_GSETTINGS_SCHEMA, settings_path);
641+ priv->compizcore_compiz_gs = compiz_grouped_gsettings_new (schema,
642+ priv->compiz_settings,
643+ COMPIZCORE_GSETTINGS_PATH,
644+ &priv->compizcore_settings);
645 g_settings_schema_unref (schema);
646- g_free (settings_path);
647 }
648
649- if (!priv->unity_settings || !priv->compizcore_settings || !priv->unity_own_settings || !priv->unity_launcher_settings)
650+ if (!priv->unity_compiz_gs || !priv->compizcore_compiz_gs || !priv->unity_own_settings || !priv->unity_launcher_settings)
651 return;
652
653+ g_signal_connect (priv->compiz_settings, "changed::" COMPIZ_CURRENT_PROFILE_KEY,
654+ G_CALLBACK (ext_compiz_profile_changed_callback), self);
655+
656 /* Icon size change - we halve the sizes so we can only get even values*/
657 iconsize_adj = gtk_adjustment_new (DEFAULT_ICONSIZE / 2, MIN_ICONSIZE / 2, MAX_ICONSIZE / 2, 1, 4, 0);
658 iconsize_scale = GTK_SCALE (WID ("unity-iconsize-scale"));
659 gtk_range_set_adjustment (GTK_RANGE (iconsize_scale), iconsize_adj);
660 gtk_scale_add_mark (iconsize_scale, DEFAULT_ICONSIZE / 2, GTK_POS_BOTTOM, NULL);
661- g_signal_connect (priv->unity_settings, "changed::" UNITY_ICONSIZE_KEY,
662+ g_signal_connect (priv->unity_compiz_gs, "changed::" UNITY_ICONSIZE_KEY,
663 G_CALLBACK (ext_iconsize_changed_callback), iconsize_adj);
664
665 g_signal_connect (G_OBJECT (iconsize_scale), "format-value",
666 G_CALLBACK (on_iconsize_format_value), NULL);
667 g_signal_connect (iconsize_adj, "value_changed",
668- G_CALLBACK (on_iconsize_changed), priv->unity_settings);
669+ G_CALLBACK (on_iconsize_changed), self);
670 g_signal_connect (G_OBJECT (iconsize_scale), "scroll-event",
671 G_CALLBACK (on_scale_scroll_event), NULL);
672 iconsize_widget_refresh (iconsize_adj, priv->unity_settings);
673
674 /* Reveal spot setting */
675- g_signal_connect (priv->unity_settings, "changed::" UNITY_LAUNCHERREVEAL_KEY,
676+ g_signal_connect (priv->unity_compiz_gs, "changed::" UNITY_LAUNCHERREVEAL_KEY,
677 G_CALLBACK (ext_reveallauncher_changed_callback), self);
678 g_signal_connect (WID ("unity_reveal_spot_topleft"), "toggled",
679 G_CALLBACK (on_reveallauncher_changed), self);
680@@ -1936,7 +2217,7 @@
681 launcher_sensitivity_scale = GTK_SCALE (WID ("unity-launcher-sensitivity"));
682 gtk_range_set_adjustment (GTK_RANGE (launcher_sensitivity_scale), launcher_sensitivity_adj);
683 gtk_scale_add_mark (launcher_sensitivity_scale, 2, GTK_POS_BOTTOM, NULL);
684- g_signal_connect (priv->unity_settings, "changed::" UNITY_LAUNCHERSENSITIVITY_KEY,
685+ g_signal_connect (priv->unity_compiz_gs, "changed::" UNITY_LAUNCHERSENSITIVITY_KEY,
686 G_CALLBACK (ext_launchersensitivity_changed_callback), launcher_sensitivity_adj);
687 g_signal_connect (launcher_sensitivity_adj, "value_changed",
688 G_CALLBACK (on_launchersensitivity_changed), self);
689@@ -1945,16 +2226,16 @@
690 launcher_sensitivity_widget_refresh (launcher_sensitivity_adj, priv->unity_settings);
691
692 /* Autohide launcher setting */
693- g_signal_connect (priv->unity_settings, "changed::" UNITY_LAUNCHERHIDE_KEY,
694+ g_signal_connect (priv->unity_compiz_gs, "changed::" UNITY_LAUNCHERHIDE_KEY,
695 G_CALLBACK (ext_hidelauncher_changed_callback), self);
696 g_signal_connect (WID ("unity_launcher_autohide"), "notify::active",
697 G_CALLBACK (on_hidelauncher_changed), self);
698 hidelauncher_widget_refresh (self);
699
700 /* Enabling workspaces */
701- g_signal_connect (priv->compizcore_settings, "changed::" COMPIZCORE_HSIZE_KEY,
702+ g_signal_connect (priv->compizcore_compiz_gs, "changed::" COMPIZCORE_HSIZE_KEY,
703 G_CALLBACK (ext_enableworkspaces_changed_callback), self);
704- g_signal_connect (priv->compizcore_settings, "changed::" COMPIZCORE_VSIZE_KEY,
705+ g_signal_connect (priv->compizcore_compiz_gs, "changed::" COMPIZCORE_VSIZE_KEY,
706 G_CALLBACK (ext_enableworkspaces_changed_callback), self);
707 g_signal_connect (WID ("check_enable_workspaces"), "toggled",
708 G_CALLBACK (on_enable_workspaces_changed), self);

Subscribers

People subscribed via source and target branches