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

Proposed by Marco Trevisan (Treviño)
Status: Merged
Approved by: Sebastien Bacher
Approved revision: 12869
Merged at revision: 12870
Proposed branch: lp:~3v1n0/unity-control-center/grouped-compiz-gsettings-support-x
Merge into: lp:unity-control-center/16.04
Prerequisite: lp:~ci-train-bot/unity-control-center/unity-control-center-ubuntu-xenial-2462
Diff against target: 740 lines (+380/-84)
2 files modified
debian/changelog (+9/-0)
panels/appearance/cc-appearance-panel.c (+371/-84)
To merge this branch: bzr merge lp:~3v1n0/unity-control-center/grouped-compiz-gsettings-support-x
Reviewer Review Type Date Requested Status
Andrea Azzarone (community) Approve
Unity Control Center development team Pending
Review via email: mp+326789@code.launchpad.net

This proposal supersedes a proposal from 2017-06-27.

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.
Revision history for this message
Andrea Azzarone (azzar1) wrote :

+1

review: Approve
Revision history for this message
Sebastien Bacher (seb128) wrote :

looks fine but is there is a need to SRU those changes to xenial?

Revision history for this message
Marco Trevisan (Treviño) (3v1n0) wrote :

> looks fine but is there is a need to SRU those changes to xenial?

This is part of the work needed to get proper lowgfx setup working, and to fix issues with settings not being properly preserved between the two modes.

Now, being Xenial the main target for unity7 at this point, I think it just make sense to put the fixes we have there.
As they're proved to run fine in the current dev releases for a while.

12870. By Marco Trevisan (Treviño)

Merging with lp:unity-control-center/16.04

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'debian/changelog'
--- debian/changelog 2017-10-31 15:49:22 +0000
+++ debian/changelog 2017-11-30 23:11:54 +0000
@@ -1,3 +1,12 @@
1unity-control-center (15.04.0+16.04.20160705-0ubuntu2) UNRELEASED; urgency=medium
2
3 * Appearance: create GroupedGSettings class to manage group of
4 gsettings sharing the schema (LP: #1700600)
5 * Appearance: set show-desktop to false when resetting the settings
6 (LP: #1705063)
7
8 -- Marco Trevisan (Treviño) <mail@3v1n0.net> Tue, 27 Jun 2017 18:12:20 +0200
9
1unity-control-center (15.04.0+16.04.20170214-0ubuntu2) xenial; urgency=medium10unity-control-center (15.04.0+16.04.20170214-0ubuntu2) xenial; urgency=medium
211
3 [ Andrea Azzarone ]12 [ Andrea Azzarone ]
413
=== modified file 'panels/appearance/cc-appearance-panel.c'
--- panels/appearance/cc-appearance-panel.c 2016-07-05 14:26:25 +0000
+++ panels/appearance/cc-appearance-panel.c 2017-11-30 23:11:54 +0000
@@ -5,15 +5,15 @@
5 * it under the terms of the GNU General Public License as published by5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 2 of the License, or6 * the Free Software Foundation, either version 2 of the License, or
7 * (at your option) any later version.7 * (at your option) any later version.
8 * 8 *
9 * This program is distributed in the hope that it will be useful,9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.12 * GNU General Public License for more details.
13 * 13 *
14 * You should have received a copy of the GNU General Public License14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 * 16 *
17 * Author: Thomas Wood <thomas.wood@intel.com>17 * Author: Thomas Wood <thomas.wood@intel.com>
18 *18 *
19 */19 */
@@ -55,6 +55,10 @@
55#define APPEARANCE_PANEL_PRIVATE(o) \55#define APPEARANCE_PANEL_PRIVATE(o) \
56 (G_TYPE_INSTANCE_GET_PRIVATE ((o), CC_TYPE_APPEARANCE_PANEL, CcAppearancePanelPrivate))56 (G_TYPE_INSTANCE_GET_PRIVATE ((o), CC_TYPE_APPEARANCE_PANEL, CcAppearancePanelPrivate))
5757
58typedef struct _GroupedGSettings GroupedGSettings;
59typedef struct _GroupedGSettingsClass GroupedGSettingsClass;
60typedef struct _GroupedGSettingsPrivate GroupedGSettingsPrivate;
61
58struct _CcAppearancePanelPrivate62struct _CcAppearancePanelPrivate
59{63{
60 GtkBuilder *builder;64 GtkBuilder *builder;
@@ -70,11 +74,15 @@
70 GSettings *settings;74 GSettings *settings;
71 GSettings *interface_settings;75 GSettings *interface_settings;
72 GSettings *wm_theme_settings;76 GSettings *wm_theme_settings;
73 GSettings *unity_settings;
74 GSettings *compizcore_settings;
75 GSettings *unity_own_settings;77 GSettings *unity_own_settings;
76 GSettings *unity_launcher_settings;78 GSettings *unity_launcher_settings;
7779
80 GroupedGSettings *unity_compiz_gs;
81 GroupedGSettings *compizcore_compiz_gs;
82 GSettings *compiz_settings;
83 GSettings *compizcore_settings;
84 GSettings *unity_settings;
85
78 GnomeDesktopThumbnailFactory *thumb_factory;86 GnomeDesktopThumbnailFactory *thumb_factory;
7987
80 CcAppearanceItem *current_background;88 CcAppearanceItem *current_background;
@@ -98,7 +106,13 @@
98#endif106#endif
99};107};
100108
101#define UNITY_GSETTINGS_SCHEMA "org.compiz.unityshell"109#define COMPIZ_GSETTINGS_SCHEMA "org.compiz"
110#define COMPIZ_CURRENT_PROFILE_KEY "current-profile"
111
112#define UNITY_NORMAL_PROFILE "unity"
113#define UNITY_LOWGFX_PROFILE "unity-lowgfx"
114
115#define UNITY_GSETTINGS_SCHEMA COMPIZ_GSETTINGS_SCHEMA ".unityshell"
102#define UNITY_PROFILE_PATH "/org/compiz/profiles/%s/plugins/"116#define UNITY_PROFILE_PATH "/org/compiz/profiles/%s/plugins/"
103#define UNITY_GSETTINGS_PATH UNITY_PROFILE_PATH"unityshell/"117#define UNITY_GSETTINGS_PATH UNITY_PROFILE_PATH"unityshell/"
104#define UNITY_ICONSIZE_KEY "icon-size"118#define UNITY_ICONSIZE_KEY "icon-size"
@@ -107,7 +121,7 @@
107#define UNITY_LAUNCHERREVEAL_KEY "reveal-trigger"121#define UNITY_LAUNCHERREVEAL_KEY "reveal-trigger"
108#define CANONICAL_DESKTOP_INTERFACE "com.canonical.desktop.interface"122#define CANONICAL_DESKTOP_INTERFACE "com.canonical.desktop.interface"
109123
110#define COMPIZCORE_GSETTINGS_SCHEMA "org.compiz.core"124#define COMPIZCORE_GSETTINGS_SCHEMA COMPIZ_GSETTINGS_SCHEMA ".core"
111#define COMPIZCORE_GSETTINGS_PATH UNITY_PROFILE_PATH"core/"125#define COMPIZCORE_GSETTINGS_PATH UNITY_PROFILE_PATH"core/"
112#define COMPIZCORE_HSIZE_KEY "hsize"126#define COMPIZCORE_HSIZE_KEY "hsize"
113#define COMPIZCORE_VSIZE_KEY "vsize"127#define COMPIZCORE_VSIZE_KEY "vsize"
@@ -211,12 +225,30 @@
211 priv->wm_theme_settings = NULL;225 priv->wm_theme_settings = NULL;
212 }226 }
213227
228 if (priv->unity_compiz_gs)
229 {
230 g_object_unref (priv->unity_compiz_gs);
231 priv->unity_compiz_gs = NULL;
232 }
233
234 if (priv->compizcore_compiz_gs)
235 {
236 g_object_unref (priv->compizcore_compiz_gs);
237 priv->compizcore_compiz_gs = NULL;
238 }
239
214 if (priv->unity_settings)240 if (priv->unity_settings)
215 {241 {
216 g_object_unref (priv->unity_settings);242 g_object_unref (priv->unity_settings);
217 priv->unity_settings = NULL;243 priv->unity_settings = NULL;
218 }244 }
219245
246 if (priv->compiz_settings)
247 {
248 g_object_unref (priv->compiz_settings);
249 priv->compiz_settings = NULL;
250 }
251
220 if (priv->compizcore_settings)252 if (priv->compizcore_settings)
221 {253 {
222 g_object_unref (priv->compizcore_settings);254 g_object_unref (priv->compizcore_settings);
@@ -291,6 +323,245 @@
291{323{
292}324}
293325
326/* Implementation of GroupedGSettings a class to manage multiple gsettings
327 * who share schema but with different paths
328 */
329#define IS_GSETTINGS_GROUPED(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), \
330 grouped_gsettings_get_type ()))
331
332GType grouped_gsettings_get_type (void) G_GNUC_CONST;
333
334struct _GroupedGSettings {
335 GObject parent_instance;
336 GroupedGSettingsPrivate *priv;
337};
338
339struct _GroupedGSettingsClass {
340 GObjectClass parent_class;
341};
342
343struct _GroupedGSettingsPrivate
344{
345 GList *settings_list;
346 GSettings *default_gs;
347 GSettings **remote_gs;
348};
349
350G_DEFINE_TYPE (GroupedGSettings, grouped_gsettings, G_TYPE_OBJECT)
351
352static void
353grouped_gsettings_dispose (GObject *object)
354{
355 GroupedGSettings *self = (GroupedGSettings *) object;
356
357 if (self->priv->settings_list)
358 {
359 g_list_free_full (self->priv->settings_list, g_object_unref);
360 self->priv->settings_list = NULL;
361 }
362
363 if (G_OBJECT_CLASS (grouped_gsettings_parent_class))
364 G_OBJECT_CLASS (grouped_gsettings_parent_class)->dispose (object);
365}
366
367static void
368grouped_gsettings_class_init (GroupedGSettingsClass *klass)
369{
370 GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
371
372 g_type_class_add_private (klass, sizeof (GroupedGSettingsPrivate));
373
374 gobject_class->dispose = grouped_gsettings_dispose;
375
376 g_signal_new ("changed", G_TYPE_FROM_CLASS (klass),
377 G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED, 0,
378 NULL, NULL, g_cclosure_marshal_VOID__STRING, G_TYPE_NONE,
379 1, G_TYPE_STRING | G_SIGNAL_TYPE_STATIC_SCOPE);
380}
381
382static void
383grouped_gsettings_init (GroupedGSettings *self)
384{
385 self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, grouped_gsettings_get_type (),
386 GroupedGSettingsPrivate);
387}
388
389static void
390on_default_settings_changed (GSettings *settings,
391 gchar *key,
392 GroupedGSettings *self)
393{
394 gchar *signal = g_strdup_printf ("changed::%s", key);
395 g_signal_emit_by_name (self, signal, key);
396 g_free (signal);
397}
398
399static GSettings *
400grouped_gsettings_peek_default (GroupedGSettings *self)
401{
402 g_return_val_if_fail (IS_GSETTINGS_GROUPED (self), NULL);
403 return self->priv->default_gs;
404}
405
406static void
407grouped_gsettings_set_default_profile (GroupedGSettings *self,
408 const gchar *profile)
409{
410 GList *l;
411 GroupedGSettingsPrivate *priv;
412
413 g_return_if_fail (IS_GSETTINGS_GROUPED (self));
414 g_return_if_fail (profile);
415
416 priv = self->priv;
417
418 for (l = priv->settings_list; l; l = l->next)
419 {
420 GSettings *settings;
421 const gchar *settings_profile;
422
423 settings = l->data;
424 settings_profile = g_object_get_data (G_OBJECT (settings), "profile");
425
426 if (g_strcmp0 (settings_profile, profile) == 0)
427 {
428 if (priv->default_gs == settings)
429 {
430 return;
431 }
432
433 if (priv->default_gs)
434 {
435 g_signal_handlers_block_by_func (priv->default_gs,
436 on_default_settings_changed, self);
437 }
438
439 priv->default_gs = settings;
440 g_signal_handlers_unblock_by_func (settings,
441 on_default_settings_changed, self);
442
443 if (priv->remote_gs)
444 {
445 if (G_IS_SETTINGS (*priv->remote_gs))
446 g_object_unref (*priv->remote_gs);
447
448 *priv->remote_gs = g_object_ref (settings);
449 }
450
451 return;
452 }
453 }
454}
455
456static void
457grouped_gsettings_reset (GroupedGSettings *self, const gchar *key)
458{
459 g_return_if_fail (IS_GSETTINGS_GROUPED (self));
460 g_list_foreach (self->priv->settings_list,
461 (GFunc) g_settings_reset, (gpointer) key);
462}
463
464static void
465grouped_gsettings_set_value (GroupedGSettings *self,
466 const gchar *key,
467 GVariant *value)
468{
469 GList *l;
470
471 g_return_if_fail (IS_GSETTINGS_GROUPED (self));
472 g_return_if_fail (g_variant_get_type (value));
473
474 g_variant_ref_sink (value);
475
476 for (l = self->priv->settings_list; l; l = l->next)
477 g_settings_set_value (G_SETTINGS (l->data), key, value);
478
479 g_variant_unref (value);
480}
481
482static GSettings *
483grouped_gsettings_add (GroupedGSettings *self,
484 GSettingsSchema *settings_schema,
485 const gchar *settings_path,
486 const gchar *profile,
487 GSettings **remote_settings)
488{
489 GSettings *settings;
490
491 g_return_val_if_fail (IS_GSETTINGS_GROUPED (self), NULL);
492
493 settings = g_settings_new_full (settings_schema, /*backend*/ NULL, settings_path);
494 self->priv->settings_list = g_list_prepend (self->priv->settings_list, settings);
495 self->priv->remote_gs = remote_settings;
496
497 g_signal_connect (settings, "changed", G_CALLBACK (on_default_settings_changed), self);
498 g_signal_handlers_block_by_func (settings, on_default_settings_changed, self);
499
500 if (!profile)
501 {
502 profile = settings_path;
503 }
504
505 g_object_set_data_full (G_OBJECT (settings), "profile",
506 (gpointer) g_strdup (profile), g_free);
507
508 if (!self->priv->default_gs)
509 {
510 grouped_gsettings_set_default_profile (self, profile);
511 }
512
513 return settings;
514}
515
516
517static GSettings *
518compiz_grouped_gsettings_add (GroupedGSettings *self,
519 GSettingsSchema *settings_schema,
520 const gchar *settings_base_path,
521 const gchar *compiz_profile,
522 GSettings **remote_settings)
523{
524 GSettings *settings;
525 gchar *settings_path;
526
527 compiz_profile = compiz_profile ? compiz_profile : UNITY_NORMAL_PROFILE;
528 settings_path = g_strdup_printf (settings_base_path, compiz_profile);
529 settings = grouped_gsettings_add (self, settings_schema, settings_path,
530 compiz_profile, remote_settings);
531 g_free (settings_path);
532
533 return settings;
534}
535
536GroupedGSettings *
537compiz_grouped_gsettings_new (GSettingsSchema *settings_schema,
538 GSettings *compiz_settings,
539 const gchar *settings_base_path,
540 GSettings **remote_settings)
541{
542 GroupedGSettings *ggs;
543 GSettings *settings;
544 gchar *compiz_profile;
545
546 g_return_val_if_fail (settings_base_path, NULL);
547
548 ggs = g_object_new (grouped_gsettings_get_type (), NULL);
549 compiz_profile = g_settings_get_string (compiz_settings,
550 COMPIZ_CURRENT_PROFILE_KEY);
551
552 compiz_grouped_gsettings_add (ggs, settings_schema, settings_base_path,
553 UNITY_NORMAL_PROFILE, remote_settings);
554 compiz_grouped_gsettings_add (ggs, settings_schema, settings_base_path,
555 UNITY_LOWGFX_PROFILE, remote_settings);
556
557 grouped_gsettings_set_default_profile (ggs, compiz_profile);
558 g_free (compiz_profile);
559
560 return ggs;
561}
562
563/* GroupedGSettings definition end */
564
294static void565static void
295source_update_edit_box (CcAppearancePanelPrivate *priv,566source_update_edit_box (CcAppearancePanelPrivate *priv,
296 gboolean initial)567 gboolean initial)
@@ -1387,11 +1658,11 @@
1387}1658}
13881659
1389static void1660static void
1390ext_iconsize_changed_callback (GSettings* settings,1661ext_iconsize_changed_callback (GroupedGSettings* compiz_gs,
1391 guint key,1662 gchar *key,
1392 gpointer user_data)1663 gpointer user_data)
1393{1664{
1394 iconsize_widget_refresh (GTK_ADJUSTMENT (user_data), settings);1665 iconsize_widget_refresh (GTK_ADJUSTMENT (user_data), grouped_gsettings_peek_default (compiz_gs));
1395}1666}
13961667
1397static gchar *1668static gchar *
@@ -1401,9 +1672,9 @@
1401}1672}
14021673
1403static void1674static void
1404on_iconsize_changed (GtkAdjustment *adj, GSettings *unity_settings)1675on_iconsize_changed (GtkAdjustment *adj, CcAppearancePanel *self)
1405{1676{
1406 g_settings_set_int (unity_settings, UNITY_ICONSIZE_KEY, (gint)gtk_adjustment_get_value (adj) * 2);1677 grouped_gsettings_set_value (self->priv->unity_compiz_gs, UNITY_ICONSIZE_KEY, g_variant_new_int32 ((gint) gtk_adjustment_get_value (adj) * 2));
1407}1678}
14081679
1409static void1680static void
@@ -1459,8 +1730,8 @@
1459}1730}
14601731
1461static void1732static void
1462ext_hidelauncher_changed_callback (GSettings* settings,1733ext_hidelauncher_changed_callback (GroupedGSettings* compiz_gs,
1463 guint key,1734 gchar *key,
1464 gpointer user_data)1735 gpointer user_data)
1465{1736{
1466 hidelauncher_widget_refresh (CC_APPEARANCE_PANEL (user_data));1737 hidelauncher_widget_refresh (CC_APPEARANCE_PANEL (user_data));
@@ -1485,7 +1756,7 @@
1485 }1756 }
14861757
1487 /* 3d */1758 /* 3d */
1488 g_settings_set_int (self->priv->unity_settings, UNITY_LAUNCHERHIDE_KEY, value);1759 grouped_gsettings_set_value (self->priv->unity_compiz_gs, UNITY_LAUNCHERHIDE_KEY, g_variant_new_int32 (value));
1489 hidelauncher_set_sensitivity_reveal (self, (value != -1));1760 hidelauncher_set_sensitivity_reveal (self, (value != -1));
1490}1761}
14911762
@@ -1507,8 +1778,8 @@
1507}1778}
15081779
1509static void1780static void
1510ext_reveallauncher_changed_callback (GSettings* settings,1781ext_reveallauncher_changed_callback (GroupedGSettings* compiz_gs,
1511 guint key,1782 gchar *key,
1512 gpointer user_data)1783 gpointer user_data)
1513{1784{
1514 reveallauncher_widget_refresh (CC_APPEARANCE_PANEL (user_data));1785 reveallauncher_widget_refresh (CC_APPEARANCE_PANEL (user_data));
@@ -1526,7 +1797,7 @@
1526 if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (WID ("unity_reveal_spot_left"))))1797 if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (WID ("unity_reveal_spot_left"))))
1527 reveal_spot = 0;1798 reveal_spot = 0;
15281799
1529 g_settings_set_int (priv->unity_settings, UNITY_LAUNCHERREVEAL_KEY, reveal_spot);1800 grouped_gsettings_set_value (priv->unity_compiz_gs, UNITY_LAUNCHERREVEAL_KEY, g_variant_new_int32 (reveal_spot));
1530 reveallauncher_widget_refresh (self);1801 reveallauncher_widget_refresh (self);
1531}1802}
15321803
@@ -1538,11 +1809,11 @@
1538}1809}
15391810
1540static void1811static void
1541ext_launchersensitivity_changed_callback (GSettings* settings,1812ext_launchersensitivity_changed_callback (GroupedGSettings* compiz_gs,
1542 guint key,1813 gchar *key,
1543 gpointer user_data)1814 gpointer user_data)
1544{1815{
1545 launcher_sensitivity_widget_refresh (GTK_ADJUSTMENT (user_data), settings);1816 launcher_sensitivity_widget_refresh (GTK_ADJUSTMENT (user_data), grouped_gsettings_peek_default (compiz_gs));
1546}1817}
15471818
1548static void1819static void
@@ -1552,7 +1823,7 @@
1552 CcAppearancePanelPrivate *priv = self->priv;1823 CcAppearancePanelPrivate *priv = self->priv;
1553 gdouble value = gtk_adjustment_get_value (adj);1824 gdouble value = gtk_adjustment_get_value (adj);
15541825
1555 g_settings_set_double (priv->unity_settings, UNITY_LAUNCHERSENSITIVITY_KEY, value);1826 grouped_gsettings_set_value (priv->unity_compiz_gs, UNITY_LAUNCHERSENSITIVITY_KEY, g_variant_new_double (value));
1556}1827}
15571828
1558gboolean1829gboolean
@@ -1577,12 +1848,12 @@
1577}1848}
15781849
1579static void1850static void
1580ext_enableworkspaces_changed_callback (GSettings* settings,1851ext_enableworkspaces_changed_callback (GroupedGSettings* compiz_gs,
1581 guint key,1852 gchar *key,
1582 gpointer user_data)1853 gpointer user_data)
1583{1854{
1584 g_idle_add((GSourceFunc) enable_workspaces_widget_refresh, user_data);1855 g_idle_add((GSourceFunc) enable_workspaces_widget_refresh, user_data);
1585} 1856}
15861857
1587static void1858static void
1588on_enable_workspaces_changed (GtkToggleButton *button, gpointer user_data)1859on_enable_workspaces_changed (GtkToggleButton *button, gpointer user_data)
@@ -1597,8 +1868,8 @@
1597 hsize = vsize = 2;1868 hsize = vsize = 2;
1598 }1869 }
15991870
1600 g_settings_set_int (priv->compizcore_settings, COMPIZCORE_HSIZE_KEY, hsize);1871 grouped_gsettings_set_value (priv->compizcore_compiz_gs, COMPIZCORE_HSIZE_KEY, g_variant_new_int32 (hsize));
1601 g_settings_set_int (priv->compizcore_settings, COMPIZCORE_VSIZE_KEY, hsize);1872 grouped_gsettings_set_value (priv->compizcore_compiz_gs, COMPIZCORE_VSIZE_KEY, g_variant_new_int32 (vsize));
1602}1873}
16031874
1604static void1875static void
@@ -1625,8 +1896,8 @@
1625}1896}
16261897
1627static void1898static void
1628ext_enableshowdesktop_changed_callback (GSettings* settings,1899ext_enableshowdesktop_changed_callback (GroupedGSettings* compiz_gs,
1629 guint key,1900 gchar *key,
1630 gpointer user_data)1901 gpointer user_data)
1631{1902{
1632 enable_showdesktop_widget_refresh (user_data);1903 enable_showdesktop_widget_refresh (user_data);
@@ -1691,19 +1962,15 @@
1691 if (!self->priv->unity_own_settings)1962 if (!self->priv->unity_own_settings)
1692 return FALSE;1963 return FALSE;
16931964
1694 gchar** unity_keys;1965 GSettingsSchema *unity_schema;
1695 gchar** key;1966 gboolean has_key;
16961967
1697 unity_keys = g_settings_list_keys (self->priv->unity_own_settings);1968 g_object_get (self->priv->unity_own_settings,
16981969 "settings-schema", &unity_schema, NULL);
1699 for (key = unity_keys; *key; ++key)1970 has_key = g_settings_schema_has_key (unity_schema, key_name);
1700 {1971 g_settings_schema_unref (unity_schema);
1701 if (g_strcmp0 (*key, key_name) == 0)1972
1702 return TRUE;1973 return has_key;
1703 }
1704
1705 g_strfreev (unity_keys);
1706 return FALSE;
1707}1974}
17081975
1709static void1976static void
@@ -1728,8 +1995,8 @@
1728}1995}
17291996
1730static void1997static void
1731ext_menulocation_changed_callback (GSettings* settings,1998ext_menulocation_changed_callback (GroupedGSettings* compiz_gs,
1732 guint key,1999 gchar *key,
1733 gpointer user_data)2000 gpointer user_data)
1734{2001{
1735 menulocation_widget_refresh (CC_APPEARANCE_PANEL (user_data));2002 menulocation_widget_refresh (CC_APPEARANCE_PANEL (user_data));
@@ -1768,9 +2035,9 @@
1768}2035}
17692036
1770static void2037static void
1771ext_menuvisibility_changed_callback (GSettings* settings,2038ext_menuvisibility_changed_callback (GroupedGSettings* compiz_gs,
1772 guint key,2039 gchar *key,
1773 gpointer user_data)2040 gpointer user_data)
1774{2041{
1775 menuvisibility_widget_refresh (CC_APPEARANCE_PANEL (user_data));2042 menuvisibility_widget_refresh (CC_APPEARANCE_PANEL (user_data));
1776}2043}
@@ -1787,17 +2054,41 @@
1787}2054}
17882055
1789static void2056static void
2057ext_compiz_profile_changed_callback (GSettings* compiz_settings,
2058 gchar *key,
2059 gpointer user_data)
2060{
2061 CcAppearancePanel *self = user_data;
2062 gchar *compiz_profile;
2063 gboolean low_enabled;
2064
2065 compiz_profile = g_settings_get_string (compiz_settings, COMPIZ_CURRENT_PROFILE_KEY);
2066
2067 if (g_strcmp0 (compiz_profile, UNITY_NORMAL_PROFILE) != 0 &&
2068 g_strcmp0 (compiz_profile, UNITY_LOWGFX_PROFILE) != 0)
2069 {
2070 g_free (compiz_profile);
2071 return;
2072 }
2073
2074 grouped_gsettings_set_default_profile (self->priv->unity_compiz_gs, compiz_profile);
2075 grouped_gsettings_set_default_profile (self->priv->compizcore_compiz_gs, compiz_profile);
2076
2077 g_free (compiz_profile);
2078}
2079
2080static void
1790on_restore_defaults_page2_clicked (GtkButton *button, gpointer user_data)2081on_restore_defaults_page2_clicked (GtkButton *button, gpointer user_data)
1791{2082{
1792 CcAppearancePanel *self = CC_APPEARANCE_PANEL (user_data);2083 CcAppearancePanel *self = CC_APPEARANCE_PANEL (user_data);
1793 CcAppearancePanelPrivate *priv = self->priv;2084 CcAppearancePanelPrivate *priv = self->priv;
17942085
1795 /* reset defaut for the profile and get the default */2086 /* reset defaut for the profile and get the default */
1796 g_settings_reset (priv->unity_settings, UNITY_LAUNCHERHIDE_KEY);2087 grouped_gsettings_reset (priv->unity_compiz_gs, UNITY_LAUNCHERHIDE_KEY);
1797 g_settings_reset (priv->unity_settings, UNITY_LAUNCHERSENSITIVITY_KEY);2088 grouped_gsettings_reset (priv->unity_compiz_gs, UNITY_LAUNCHERSENSITIVITY_KEY);
1798 g_settings_reset (priv->unity_settings, UNITY_LAUNCHERREVEAL_KEY);2089 grouped_gsettings_reset (priv->unity_compiz_gs, UNITY_LAUNCHERREVEAL_KEY);
1799 g_settings_reset (priv->compizcore_settings, COMPIZCORE_HSIZE_KEY);2090 grouped_gsettings_reset (priv->compizcore_compiz_gs, COMPIZCORE_HSIZE_KEY);
1800 g_settings_reset (priv->compizcore_settings, COMPIZCORE_VSIZE_KEY);2091 grouped_gsettings_reset (priv->compizcore_compiz_gs, COMPIZCORE_VSIZE_KEY);
18012092
1802 if (unity_own_setting_exists (self, UNITY_INTEGRATED_MENUS_KEY))2093 if (unity_own_setting_exists (self, UNITY_INTEGRATED_MENUS_KEY))
1803 g_settings_reset (priv->unity_own_settings, UNITY_INTEGRATED_MENUS_KEY);2094 g_settings_reset (priv->unity_own_settings, UNITY_INTEGRATED_MENUS_KEY);
@@ -1806,7 +2097,7 @@
1806 g_settings_reset (priv->unity_own_settings, UNITY_ALWAYS_SHOW_MENUS_KEY);2097 g_settings_reset (priv->unity_own_settings, UNITY_ALWAYS_SHOW_MENUS_KEY);
18072098
1808 GtkToggleButton *showdesktop = GTK_TOGGLE_BUTTON (WID ("check_showdesktop_in_launcher"));2099 GtkToggleButton *showdesktop = GTK_TOGGLE_BUTTON (WID ("check_showdesktop_in_launcher"));
1809 gtk_toggle_button_set_active(showdesktop, TRUE);2100 gtk_toggle_button_set_active(showdesktop, FALSE);
1810}2101}
18112102
1812/* <hacks> */2103/* <hacks> */
@@ -1847,20 +2138,6 @@
1847}2138}
18482139
1849/* </hacks> */2140/* </hacks> */
1850
1851static gchar *
1852compiz_profile_gsettings_path (const gchar *path)
1853{
1854 const gchar *profile = "unity";
1855
1856 if (g_strcmp0 (g_getenv ("COMPIZ_CONFIG_PROFILE"), "ubuntu-lowgfx") == 0)
1857 {
1858 profile = "unity-lowgfx";
1859 }
1860
1861 return g_strdup_printf (path, profile);
1862}
1863
1864static void2141static void
1865setup_unity_settings (CcAppearancePanel *self)2142setup_unity_settings (CcAppearancePanel *self)
1866{2143{
@@ -1871,59 +2148,69 @@
1871 GtkScale* launcher_sensitivity_scale;2148 GtkScale* launcher_sensitivity_scale;
1872 GSettingsSchema *schema;2149 GSettingsSchema *schema;
1873 GSettingsSchemaSource* source;2150 GSettingsSchemaSource* source;
1874 gchar *settings_path;
18752151
1876 source = g_settings_schema_source_get_default ();2152 source = g_settings_schema_source_get_default ();
1877 schema = g_settings_schema_source_lookup (source, UNITY_OWN_GSETTINGS_SCHEMA, TRUE);2153 schema = g_settings_schema_source_lookup (source, UNITY_OWN_GSETTINGS_SCHEMA, TRUE);
1878 if (schema)2154 if (schema)
1879 {2155 {
1880 priv->unity_own_settings = g_settings_new (UNITY_OWN_GSETTINGS_SCHEMA);2156 priv->unity_own_settings = g_settings_new_full (schema, /*backend*/ NULL, /*path*/ NULL);
2157 g_settings_schema_unref (schema);
2158 }
2159 schema = g_settings_schema_source_lookup (source, COMPIZ_GSETTINGS_SCHEMA, TRUE);
2160 if (schema)
2161 {
2162 priv->compiz_settings = g_settings_new_full (schema, /*backend*/ NULL, /*path*/ NULL);
1881 g_settings_schema_unref (schema);2163 g_settings_schema_unref (schema);
1882 }2164 }
1883 schema = g_settings_schema_source_lookup (source, UNITY_LAUNCHER_GSETTINGS_SCHEMA, TRUE);2165 schema = g_settings_schema_source_lookup (source, UNITY_LAUNCHER_GSETTINGS_SCHEMA, TRUE);
1884 if (schema)2166 if (schema)
1885 {2167 {
1886 priv->unity_launcher_settings = g_settings_new (UNITY_LAUNCHER_GSETTINGS_SCHEMA);2168 priv->unity_launcher_settings = g_settings_new_full (schema, /*backend*/ NULL, /*path*/ NULL);
1887 g_settings_schema_unref (schema);2169 g_settings_schema_unref (schema);
1888 }2170 }
1889 schema = g_settings_schema_source_lookup (source, UNITY_GSETTINGS_SCHEMA, TRUE);2171 schema = g_settings_schema_source_lookup (source, UNITY_GSETTINGS_SCHEMA, TRUE);
1890 if (schema)2172 if (schema)
1891 {2173 {
1892 settings_path = compiz_profile_gsettings_path (UNITY_GSETTINGS_PATH);2174 priv->unity_compiz_gs = compiz_grouped_gsettings_new (schema,
1893 priv->unity_settings = g_settings_new_with_path (UNITY_GSETTINGS_SCHEMA, settings_path);2175 priv->compiz_settings,
2176 UNITY_GSETTINGS_PATH,
2177 &priv->unity_settings);
1894 g_settings_schema_unref (schema);2178 g_settings_schema_unref (schema);
1895 g_free (settings_path);
1896 }2179 }
1897 schema = g_settings_schema_source_lookup (source, COMPIZCORE_GSETTINGS_SCHEMA, TRUE);2180 schema = g_settings_schema_source_lookup (source, COMPIZCORE_GSETTINGS_SCHEMA, TRUE);
1898 if (schema)2181 if (schema)
1899 {2182 {
1900 settings_path = compiz_profile_gsettings_path (COMPIZCORE_GSETTINGS_PATH);2183 priv->compizcore_compiz_gs = compiz_grouped_gsettings_new (schema,
1901 priv->compizcore_settings = g_settings_new_with_path (COMPIZCORE_GSETTINGS_SCHEMA, settings_path);2184 priv->compiz_settings,
2185 COMPIZCORE_GSETTINGS_PATH,
2186 &priv->compizcore_settings);
1902 g_settings_schema_unref (schema);2187 g_settings_schema_unref (schema);
1903 g_free (settings_path);
1904 }2188 }
19052189
1906 if (!priv->unity_settings || !priv->compizcore_settings || !priv->unity_own_settings || !priv->unity_launcher_settings)2190 if (!priv->unity_compiz_gs || !priv->compizcore_compiz_gs || !priv->unity_own_settings || !priv->unity_launcher_settings)
1907 return;2191 return;
19082192
2193 g_signal_connect (priv->compiz_settings, "changed::" COMPIZ_CURRENT_PROFILE_KEY,
2194 G_CALLBACK (ext_compiz_profile_changed_callback), self);
2195
1909 /* Icon size change - we halve the sizes so we can only get even values*/2196 /* Icon size change - we halve the sizes so we can only get even values*/
1910 iconsize_adj = gtk_adjustment_new (DEFAULT_ICONSIZE / 2, MIN_ICONSIZE / 2, MAX_ICONSIZE / 2, 1, 4, 0);2197 iconsize_adj = gtk_adjustment_new (DEFAULT_ICONSIZE / 2, MIN_ICONSIZE / 2, MAX_ICONSIZE / 2, 1, 4, 0);
1911 iconsize_scale = GTK_SCALE (WID ("unity-iconsize-scale"));2198 iconsize_scale = GTK_SCALE (WID ("unity-iconsize-scale"));
1912 gtk_range_set_adjustment (GTK_RANGE (iconsize_scale), iconsize_adj);2199 gtk_range_set_adjustment (GTK_RANGE (iconsize_scale), iconsize_adj);
1913 gtk_scale_add_mark (iconsize_scale, DEFAULT_ICONSIZE / 2, GTK_POS_BOTTOM, NULL);2200 gtk_scale_add_mark (iconsize_scale, DEFAULT_ICONSIZE / 2, GTK_POS_BOTTOM, NULL);
1914 g_signal_connect (priv->unity_settings, "changed::" UNITY_ICONSIZE_KEY,2201 g_signal_connect (priv->unity_compiz_gs, "changed::" UNITY_ICONSIZE_KEY,
1915 G_CALLBACK (ext_iconsize_changed_callback), iconsize_adj);2202 G_CALLBACK (ext_iconsize_changed_callback), iconsize_adj);
19162203
1917 g_signal_connect (G_OBJECT (iconsize_scale), "format-value",2204 g_signal_connect (G_OBJECT (iconsize_scale), "format-value",
1918 G_CALLBACK (on_iconsize_format_value), NULL);2205 G_CALLBACK (on_iconsize_format_value), NULL);
1919 g_signal_connect (iconsize_adj, "value_changed",2206 g_signal_connect (iconsize_adj, "value_changed",
1920 G_CALLBACK (on_iconsize_changed), priv->unity_settings);2207 G_CALLBACK (on_iconsize_changed), self);
1921 g_signal_connect (G_OBJECT (iconsize_scale), "scroll-event",2208 g_signal_connect (G_OBJECT (iconsize_scale), "scroll-event",
1922 G_CALLBACK (on_scale_scroll_event), NULL);2209 G_CALLBACK (on_scale_scroll_event), NULL);
1923 iconsize_widget_refresh (iconsize_adj, priv->unity_settings);2210 iconsize_widget_refresh (iconsize_adj, priv->unity_settings);
19242211
1925 /* Reveal spot setting */2212 /* Reveal spot setting */
1926 g_signal_connect (priv->unity_settings, "changed::" UNITY_LAUNCHERREVEAL_KEY,2213 g_signal_connect (priv->unity_compiz_gs, "changed::" UNITY_LAUNCHERREVEAL_KEY,
1927 G_CALLBACK (ext_reveallauncher_changed_callback), self);2214 G_CALLBACK (ext_reveallauncher_changed_callback), self);
1928 g_signal_connect (WID ("unity_reveal_spot_topleft"), "toggled",2215 g_signal_connect (WID ("unity_reveal_spot_topleft"), "toggled",
1929 G_CALLBACK (on_reveallauncher_changed), self);2216 G_CALLBACK (on_reveallauncher_changed), self);
@@ -1936,7 +2223,7 @@
1936 launcher_sensitivity_scale = GTK_SCALE (WID ("unity-launcher-sensitivity"));2223 launcher_sensitivity_scale = GTK_SCALE (WID ("unity-launcher-sensitivity"));
1937 gtk_range_set_adjustment (GTK_RANGE (launcher_sensitivity_scale), launcher_sensitivity_adj);2224 gtk_range_set_adjustment (GTK_RANGE (launcher_sensitivity_scale), launcher_sensitivity_adj);
1938 gtk_scale_add_mark (launcher_sensitivity_scale, 2, GTK_POS_BOTTOM, NULL);2225 gtk_scale_add_mark (launcher_sensitivity_scale, 2, GTK_POS_BOTTOM, NULL);
1939 g_signal_connect (priv->unity_settings, "changed::" UNITY_LAUNCHERSENSITIVITY_KEY,2226 g_signal_connect (priv->unity_compiz_gs, "changed::" UNITY_LAUNCHERSENSITIVITY_KEY,
1940 G_CALLBACK (ext_launchersensitivity_changed_callback), launcher_sensitivity_adj);2227 G_CALLBACK (ext_launchersensitivity_changed_callback), launcher_sensitivity_adj);
1941 g_signal_connect (launcher_sensitivity_adj, "value_changed",2228 g_signal_connect (launcher_sensitivity_adj, "value_changed",
1942 G_CALLBACK (on_launchersensitivity_changed), self);2229 G_CALLBACK (on_launchersensitivity_changed), self);
@@ -1945,16 +2232,16 @@
1945 launcher_sensitivity_widget_refresh (launcher_sensitivity_adj, priv->unity_settings);2232 launcher_sensitivity_widget_refresh (launcher_sensitivity_adj, priv->unity_settings);
19462233
1947 /* Autohide launcher setting */2234 /* Autohide launcher setting */
1948 g_signal_connect (priv->unity_settings, "changed::" UNITY_LAUNCHERHIDE_KEY,2235 g_signal_connect (priv->unity_compiz_gs, "changed::" UNITY_LAUNCHERHIDE_KEY,
1949 G_CALLBACK (ext_hidelauncher_changed_callback), self);2236 G_CALLBACK (ext_hidelauncher_changed_callback), self);
1950 g_signal_connect (WID ("unity_launcher_autohide"), "notify::active",2237 g_signal_connect (WID ("unity_launcher_autohide"), "notify::active",
1951 G_CALLBACK (on_hidelauncher_changed), self);2238 G_CALLBACK (on_hidelauncher_changed), self);
1952 hidelauncher_widget_refresh (self);2239 hidelauncher_widget_refresh (self);
19532240
1954 /* Enabling workspaces */2241 /* Enabling workspaces */
1955 g_signal_connect (priv->compizcore_settings, "changed::" COMPIZCORE_HSIZE_KEY,2242 g_signal_connect (priv->compizcore_compiz_gs, "changed::" COMPIZCORE_HSIZE_KEY,
1956 G_CALLBACK (ext_enableworkspaces_changed_callback), self);2243 G_CALLBACK (ext_enableworkspaces_changed_callback), self);
1957 g_signal_connect (priv->compizcore_settings, "changed::" COMPIZCORE_VSIZE_KEY,2244 g_signal_connect (priv->compizcore_compiz_gs, "changed::" COMPIZCORE_VSIZE_KEY,
1958 G_CALLBACK (ext_enableworkspaces_changed_callback), self);2245 G_CALLBACK (ext_enableworkspaces_changed_callback), self);
1959 g_signal_connect (WID ("check_enable_workspaces"), "toggled",2246 g_signal_connect (WID ("check_enable_workspaces"), "toggled",
1960 G_CALLBACK (on_enable_workspaces_changed), self);2247 G_CALLBACK (on_enable_workspaces_changed), self);

Subscribers

People subscribed via source and target branches