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