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

Proposed by Marco Trevisan (Treviño)
Status: Merged
Approved by: Sebastien Bacher
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 Approve
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.
Revision history for this message
Sebastien Bacher (seb128) wrote :

looks good, thanks

review: Approve
12908. By Marco Trevisan (Treviño)

Appearance: code cleanup

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== 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-06-27 16:08:20 +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,239 @@
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 g_return_if_fail (IS_GSETTINGS_GROUPED (self));
471
472 for (l = self->priv->settings_list; l; l = l->next)
473 g_settings_set_value (G_SETTINGS (l->data), key, value);
474}
475
476static GSettings *
477grouped_gsettings_add (GroupedGSettings *self,
478 GSettingsSchema *settings_schema,
479 const gchar *settings_path,
480 const gchar *profile,
481 GSettings **remote_settings)
482{
483 GSettings *settings;
484
485 g_return_val_if_fail (IS_GSETTINGS_GROUPED (self), NULL);
486
487 settings = g_settings_new_full (settings_schema, /*backend*/ NULL, settings_path);
488 self->priv->settings_list = g_list_prepend (self->priv->settings_list, settings);
489 self->priv->remote_gs = remote_settings;
490
491 g_signal_connect (settings, "changed", G_CALLBACK (on_default_settings_changed), self);
492 g_signal_handlers_block_by_func (settings, on_default_settings_changed, self);
493
494 if (!profile)
495 {
496 profile = settings_path;
497 }
498
499 g_object_set_data_full (G_OBJECT (settings), "profile",
500 (gpointer) g_strdup (profile), g_free);
501
502 if (!self->priv->default_gs)
503 {
504 grouped_gsettings_set_default_profile (self, profile);
505 }
506
507 return settings;
508}
509
510
511static GSettings *
512compiz_grouped_gsettings_add (GroupedGSettings *self,
513 GSettingsSchema *settings_schema,
514 const gchar *settings_base_path,
515 const gchar *compiz_profile,
516 GSettings **remote_settings)
517{
518 GSettings *settings;
519 gchar *settings_path;
520
521 compiz_profile = compiz_profile ? compiz_profile : UNITY_NORMAL_PROFILE;
522 settings_path = g_strdup_printf (settings_base_path, compiz_profile);
523 settings = grouped_gsettings_add (self, settings_schema, settings_path,
524 compiz_profile, remote_settings);
525 g_free (settings_path);
526
527 return settings;
528}
529
530GroupedGSettings *
531compiz_grouped_gsettings_new (GSettingsSchema *settings_schema,
532 GSettings *compiz_settings,
533 const gchar *settings_base_path,
534 GSettings **remote_settings)
535{
536 GroupedGSettings *ggs;
537 GSettings *settings;
538 gchar *compiz_profile;
539
540 g_return_val_if_fail (settings_base_path, NULL);
541
542 ggs = g_object_new (grouped_gsettings_get_type (), NULL);
543 compiz_profile = g_settings_get_string (compiz_settings,
544 COMPIZ_CURRENT_PROFILE_KEY);
545
546 compiz_grouped_gsettings_add (ggs, settings_schema, settings_base_path,
547 UNITY_NORMAL_PROFILE, remote_settings);
548 compiz_grouped_gsettings_add (ggs, settings_schema, settings_base_path,
549 UNITY_LOWGFX_PROFILE, remote_settings);
550
551 grouped_gsettings_set_default_profile (ggs, compiz_profile);
552 g_free (compiz_profile);
553
554 return ggs;
555}
556
557/* GroupedGSettings definition end */
558
294static void559static void
295source_update_edit_box (CcAppearancePanelPrivate *priv,560source_update_edit_box (CcAppearancePanelPrivate *priv,
296 gboolean initial)561 gboolean initial)
@@ -1387,11 +1652,11 @@
1387}1652}
13881653
1389static void1654static void
1390ext_iconsize_changed_callback (GSettings* settings,1655ext_iconsize_changed_callback (GroupedGSettings* compiz_gs,
1391 guint key,1656 gchar *key,
1392 gpointer user_data)1657 gpointer user_data)
1393{1658{
1394 iconsize_widget_refresh (GTK_ADJUSTMENT (user_data), settings);1659 iconsize_widget_refresh (GTK_ADJUSTMENT (user_data), grouped_gsettings_peek_default (compiz_gs));
1395}1660}
13961661
1397static gchar *1662static gchar *
@@ -1401,9 +1666,9 @@
1401}1666}
14021667
1403static void1668static void
1404on_iconsize_changed (GtkAdjustment *adj, GSettings *unity_settings)1669on_iconsize_changed (GtkAdjustment *adj, CcAppearancePanel *self)
1405{1670{
1406 g_settings_set_int (unity_settings, UNITY_ICONSIZE_KEY, (gint)gtk_adjustment_get_value (adj) * 2);1671 grouped_gsettings_set_value (self->priv->unity_compiz_gs, UNITY_ICONSIZE_KEY, g_variant_new_int32 ((gint) gtk_adjustment_get_value (adj) * 2));
1407}1672}
14081673
1409static void1674static void
@@ -1459,8 +1724,8 @@
1459}1724}
14601725
1461static void1726static void
1462ext_hidelauncher_changed_callback (GSettings* settings,1727ext_hidelauncher_changed_callback (GroupedGSettings* compiz_gs,
1463 guint key,1728 gchar *key,
1464 gpointer user_data)1729 gpointer user_data)
1465{1730{
1466 hidelauncher_widget_refresh (CC_APPEARANCE_PANEL (user_data));1731 hidelauncher_widget_refresh (CC_APPEARANCE_PANEL (user_data));
@@ -1485,7 +1750,7 @@
1485 }1750 }
14861751
1487 /* 3d */1752 /* 3d */
1488 g_settings_set_int (self->priv->unity_settings, UNITY_LAUNCHERHIDE_KEY, value);1753 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));1754 hidelauncher_set_sensitivity_reveal (self, (value != -1));
1490}1755}
14911756
@@ -1507,8 +1772,8 @@
1507}1772}
15081773
1509static void1774static void
1510ext_reveallauncher_changed_callback (GSettings* settings,1775ext_reveallauncher_changed_callback (GroupedGSettings* compiz_gs,
1511 guint key,1776 gchar *key,
1512 gpointer user_data)1777 gpointer user_data)
1513{1778{
1514 reveallauncher_widget_refresh (CC_APPEARANCE_PANEL (user_data));1779 reveallauncher_widget_refresh (CC_APPEARANCE_PANEL (user_data));
@@ -1526,7 +1791,7 @@
1526 if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (WID ("unity_reveal_spot_left"))))1791 if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (WID ("unity_reveal_spot_left"))))
1527 reveal_spot = 0;1792 reveal_spot = 0;
15281793
1529 g_settings_set_int (priv->unity_settings, UNITY_LAUNCHERREVEAL_KEY, reveal_spot);1794 grouped_gsettings_set_value (priv->unity_compiz_gs, UNITY_LAUNCHERREVEAL_KEY, g_variant_new_int32 (reveal_spot));
1530 reveallauncher_widget_refresh (self);1795 reveallauncher_widget_refresh (self);
1531}1796}
15321797
@@ -1538,11 +1803,11 @@
1538}1803}
15391804
1540static void1805static void
1541ext_launchersensitivity_changed_callback (GSettings* settings,1806ext_launchersensitivity_changed_callback (GroupedGSettings* compiz_gs,
1542 guint key,1807 gchar *key,
1543 gpointer user_data)1808 gpointer user_data)
1544{1809{
1545 launcher_sensitivity_widget_refresh (GTK_ADJUSTMENT (user_data), settings);1810 launcher_sensitivity_widget_refresh (GTK_ADJUSTMENT (user_data), grouped_gsettings_peek_default (compiz_gs));
1546}1811}
15471812
1548static void1813static void
@@ -1552,7 +1817,7 @@
1552 CcAppearancePanelPrivate *priv = self->priv;1817 CcAppearancePanelPrivate *priv = self->priv;
1553 gdouble value = gtk_adjustment_get_value (adj);1818 gdouble value = gtk_adjustment_get_value (adj);
15541819
1555 g_settings_set_double (priv->unity_settings, UNITY_LAUNCHERSENSITIVITY_KEY, value);1820 grouped_gsettings_set_value (priv->unity_compiz_gs, UNITY_LAUNCHERSENSITIVITY_KEY, g_variant_new_double (value));
1556}1821}
15571822
1558gboolean1823gboolean
@@ -1577,12 +1842,12 @@
1577}1842}
15781843
1579static void1844static void
1580ext_enableworkspaces_changed_callback (GSettings* settings,1845ext_enableworkspaces_changed_callback (GroupedGSettings* compiz_gs,
1581 guint key,1846 gchar *key,
1582 gpointer user_data)1847 gpointer user_data)
1583{1848{
1584 g_idle_add((GSourceFunc) enable_workspaces_widget_refresh, user_data);1849 g_idle_add((GSourceFunc) enable_workspaces_widget_refresh, user_data);
1585} 1850}
15861851
1587static void1852static void
1588on_enable_workspaces_changed (GtkToggleButton *button, gpointer user_data)1853on_enable_workspaces_changed (GtkToggleButton *button, gpointer user_data)
@@ -1597,8 +1862,8 @@
1597 hsize = vsize = 2;1862 hsize = vsize = 2;
1598 }1863 }
15991864
1600 g_settings_set_int (priv->compizcore_settings, COMPIZCORE_HSIZE_KEY, hsize);1865 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);1866 grouped_gsettings_set_value (priv->compizcore_compiz_gs, COMPIZCORE_VSIZE_KEY, g_variant_new_int32 (hsize));
1602}1867}
16031868
1604static void1869static void
@@ -1625,8 +1890,8 @@
1625}1890}
16261891
1627static void1892static void
1628ext_enableshowdesktop_changed_callback (GSettings* settings,1893ext_enableshowdesktop_changed_callback (GroupedGSettings* compiz_gs,
1629 guint key,1894 gchar *key,
1630 gpointer user_data)1895 gpointer user_data)
1631{1896{
1632 enable_showdesktop_widget_refresh (user_data);1897 enable_showdesktop_widget_refresh (user_data);
@@ -1691,19 +1956,15 @@
1691 if (!self->priv->unity_own_settings)1956 if (!self->priv->unity_own_settings)
1692 return FALSE;1957 return FALSE;
16931958
1694 gchar** unity_keys;1959 GSettingsSchema *unity_schema;
1695 gchar** key;1960 gboolean has_key;
16961961
1697 unity_keys = g_settings_list_keys (self->priv->unity_own_settings);1962 g_object_get (self->priv->unity_own_settings,
16981963 "settings-schema", &unity_schema, NULL);
1699 for (key = unity_keys; *key; ++key)1964 has_key = g_settings_schema_has_key (unity_schema, key_name);
1700 {1965 g_settings_schema_unref (unity_schema);
1701 if (g_strcmp0 (*key, key_name) == 0)1966
1702 return TRUE;1967 return has_key;
1703 }
1704
1705 g_strfreev (unity_keys);
1706 return FALSE;
1707}1968}
17081969
1709static void1970static void
@@ -1728,8 +1989,8 @@
1728}1989}
17291990
1730static void1991static void
1731ext_menulocation_changed_callback (GSettings* settings,1992ext_menulocation_changed_callback (GroupedGSettings* compiz_gs,
1732 guint key,1993 gchar *key,
1733 gpointer user_data)1994 gpointer user_data)
1734{1995{
1735 menulocation_widget_refresh (CC_APPEARANCE_PANEL (user_data));1996 menulocation_widget_refresh (CC_APPEARANCE_PANEL (user_data));
@@ -1768,9 +2029,9 @@
1768}2029}
17692030
1770static void2031static void
1771ext_menuvisibility_changed_callback (GSettings* settings,2032ext_menuvisibility_changed_callback (GroupedGSettings* compiz_gs,
1772 guint key,2033 gchar *key,
1773 gpointer user_data)2034 gpointer user_data)
1774{2035{
1775 menuvisibility_widget_refresh (CC_APPEARANCE_PANEL (user_data));2036 menuvisibility_widget_refresh (CC_APPEARANCE_PANEL (user_data));
1776}2037}
@@ -1787,17 +2048,41 @@
1787}2048}
17882049
1789static void2050static void
2051ext_compiz_profile_changed_callback (GSettings* compiz_settings,
2052 gchar *key,
2053 gpointer user_data)
2054{
2055 CcAppearancePanel *self = user_data;
2056 gchar *compiz_profile;
2057 gboolean low_enabled;
2058
2059 compiz_profile = g_settings_get_string (compiz_settings, COMPIZ_CURRENT_PROFILE_KEY);
2060
2061 if (g_strcmp0 (compiz_profile, UNITY_NORMAL_PROFILE) != 0 &&
2062 g_strcmp0 (compiz_profile, UNITY_LOWGFX_PROFILE) != 0)
2063 {
2064 g_free (compiz_profile);
2065 return;
2066 }
2067
2068 grouped_gsettings_set_default_profile (self->priv->unity_compiz_gs, compiz_profile);
2069 grouped_gsettings_set_default_profile (self->priv->compizcore_compiz_gs, compiz_profile);
2070
2071 g_free (compiz_profile);
2072}
2073
2074static void
1790on_restore_defaults_page2_clicked (GtkButton *button, gpointer user_data)2075on_restore_defaults_page2_clicked (GtkButton *button, gpointer user_data)
1791{2076{
1792 CcAppearancePanel *self = CC_APPEARANCE_PANEL (user_data);2077 CcAppearancePanel *self = CC_APPEARANCE_PANEL (user_data);
1793 CcAppearancePanelPrivate *priv = self->priv;2078 CcAppearancePanelPrivate *priv = self->priv;
17942079
1795 /* reset defaut for the profile and get the default */2080 /* reset defaut for the profile and get the default */
1796 g_settings_reset (priv->unity_settings, UNITY_LAUNCHERHIDE_KEY);2081 grouped_gsettings_reset (priv->unity_compiz_gs, UNITY_LAUNCHERHIDE_KEY);
1797 g_settings_reset (priv->unity_settings, UNITY_LAUNCHERSENSITIVITY_KEY);2082 grouped_gsettings_reset (priv->unity_compiz_gs, UNITY_LAUNCHERSENSITIVITY_KEY);
1798 g_settings_reset (priv->unity_settings, UNITY_LAUNCHERREVEAL_KEY);2083 grouped_gsettings_reset (priv->unity_compiz_gs, UNITY_LAUNCHERREVEAL_KEY);
1799 g_settings_reset (priv->compizcore_settings, COMPIZCORE_HSIZE_KEY);2084 grouped_gsettings_reset (priv->compizcore_compiz_gs, COMPIZCORE_HSIZE_KEY);
1800 g_settings_reset (priv->compizcore_settings, COMPIZCORE_VSIZE_KEY);2085 grouped_gsettings_reset (priv->compizcore_compiz_gs, COMPIZCORE_VSIZE_KEY);
18012086
1802 if (unity_own_setting_exists (self, UNITY_INTEGRATED_MENUS_KEY))2087 if (unity_own_setting_exists (self, UNITY_INTEGRATED_MENUS_KEY))
1803 g_settings_reset (priv->unity_own_settings, UNITY_INTEGRATED_MENUS_KEY);2088 g_settings_reset (priv->unity_own_settings, UNITY_INTEGRATED_MENUS_KEY);
@@ -1847,20 +2132,6 @@
1847}2132}
18482133
1849/* </hacks> */2134/* </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 void2135static void
1865setup_unity_settings (CcAppearancePanel *self)2136setup_unity_settings (CcAppearancePanel *self)
1866{2137{
@@ -1871,59 +2142,69 @@
1871 GtkScale* launcher_sensitivity_scale;2142 GtkScale* launcher_sensitivity_scale;
1872 GSettingsSchema *schema;2143 GSettingsSchema *schema;
1873 GSettingsSchemaSource* source;2144 GSettingsSchemaSource* source;
1874 gchar *settings_path;
18752145
1876 source = g_settings_schema_source_get_default ();2146 source = g_settings_schema_source_get_default ();
1877 schema = g_settings_schema_source_lookup (source, UNITY_OWN_GSETTINGS_SCHEMA, TRUE);2147 schema = g_settings_schema_source_lookup (source, UNITY_OWN_GSETTINGS_SCHEMA, TRUE);
1878 if (schema)2148 if (schema)
1879 {2149 {
1880 priv->unity_own_settings = g_settings_new (UNITY_OWN_GSETTINGS_SCHEMA);2150 priv->unity_own_settings = g_settings_new_full (schema, /*backend*/ NULL, /*path*/ NULL);
2151 g_settings_schema_unref (schema);
2152 }
2153 schema = g_settings_schema_source_lookup (source, COMPIZ_GSETTINGS_SCHEMA, TRUE);
2154 if (schema)
2155 {
2156 priv->compiz_settings = g_settings_new_full (schema, /*backend*/ NULL, /*path*/ NULL);
1881 g_settings_schema_unref (schema);2157 g_settings_schema_unref (schema);
1882 }2158 }
1883 schema = g_settings_schema_source_lookup (source, UNITY_LAUNCHER_GSETTINGS_SCHEMA, TRUE);2159 schema = g_settings_schema_source_lookup (source, UNITY_LAUNCHER_GSETTINGS_SCHEMA, TRUE);
1884 if (schema)2160 if (schema)
1885 {2161 {
1886 priv->unity_launcher_settings = g_settings_new (UNITY_LAUNCHER_GSETTINGS_SCHEMA);2162 priv->unity_launcher_settings = g_settings_new_full (schema, /*backend*/ NULL, /*path*/ NULL);
1887 g_settings_schema_unref (schema);2163 g_settings_schema_unref (schema);
1888 }2164 }
1889 schema = g_settings_schema_source_lookup (source, UNITY_GSETTINGS_SCHEMA, TRUE);2165 schema = g_settings_schema_source_lookup (source, UNITY_GSETTINGS_SCHEMA, TRUE);
1890 if (schema)2166 if (schema)
1891 {2167 {
1892 settings_path = compiz_profile_gsettings_path (UNITY_GSETTINGS_PATH);2168 priv->unity_compiz_gs = compiz_grouped_gsettings_new (schema,
1893 priv->unity_settings = g_settings_new_with_path (UNITY_GSETTINGS_SCHEMA, settings_path);2169 priv->compiz_settings,
2170 UNITY_GSETTINGS_PATH,
2171 &priv->unity_settings);
1894 g_settings_schema_unref (schema);2172 g_settings_schema_unref (schema);
1895 g_free (settings_path);
1896 }2173 }
1897 schema = g_settings_schema_source_lookup (source, COMPIZCORE_GSETTINGS_SCHEMA, TRUE);2174 schema = g_settings_schema_source_lookup (source, COMPIZCORE_GSETTINGS_SCHEMA, TRUE);
1898 if (schema)2175 if (schema)
1899 {2176 {
1900 settings_path = compiz_profile_gsettings_path (COMPIZCORE_GSETTINGS_PATH);2177 priv->compizcore_compiz_gs = compiz_grouped_gsettings_new (schema,
1901 priv->compizcore_settings = g_settings_new_with_path (COMPIZCORE_GSETTINGS_SCHEMA, settings_path);2178 priv->compiz_settings,
2179 COMPIZCORE_GSETTINGS_PATH,
2180 &priv->compizcore_settings);
1902 g_settings_schema_unref (schema);2181 g_settings_schema_unref (schema);
1903 g_free (settings_path);
1904 }2182 }
19052183
1906 if (!priv->unity_settings || !priv->compizcore_settings || !priv->unity_own_settings || !priv->unity_launcher_settings)2184 if (!priv->unity_compiz_gs || !priv->compizcore_compiz_gs || !priv->unity_own_settings || !priv->unity_launcher_settings)
1907 return;2185 return;
19082186
2187 g_signal_connect (priv->compiz_settings, "changed::" COMPIZ_CURRENT_PROFILE_KEY,
2188 G_CALLBACK (ext_compiz_profile_changed_callback), self);
2189
1909 /* Icon size change - we halve the sizes so we can only get even values*/2190 /* 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);2191 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"));2192 iconsize_scale = GTK_SCALE (WID ("unity-iconsize-scale"));
1912 gtk_range_set_adjustment (GTK_RANGE (iconsize_scale), iconsize_adj);2193 gtk_range_set_adjustment (GTK_RANGE (iconsize_scale), iconsize_adj);
1913 gtk_scale_add_mark (iconsize_scale, DEFAULT_ICONSIZE / 2, GTK_POS_BOTTOM, NULL);2194 gtk_scale_add_mark (iconsize_scale, DEFAULT_ICONSIZE / 2, GTK_POS_BOTTOM, NULL);
1914 g_signal_connect (priv->unity_settings, "changed::" UNITY_ICONSIZE_KEY,2195 g_signal_connect (priv->unity_compiz_gs, "changed::" UNITY_ICONSIZE_KEY,
1915 G_CALLBACK (ext_iconsize_changed_callback), iconsize_adj);2196 G_CALLBACK (ext_iconsize_changed_callback), iconsize_adj);
19162197
1917 g_signal_connect (G_OBJECT (iconsize_scale), "format-value",2198 g_signal_connect (G_OBJECT (iconsize_scale), "format-value",
1918 G_CALLBACK (on_iconsize_format_value), NULL);2199 G_CALLBACK (on_iconsize_format_value), NULL);
1919 g_signal_connect (iconsize_adj, "value_changed",2200 g_signal_connect (iconsize_adj, "value_changed",
1920 G_CALLBACK (on_iconsize_changed), priv->unity_settings);2201 G_CALLBACK (on_iconsize_changed), self);
1921 g_signal_connect (G_OBJECT (iconsize_scale), "scroll-event",2202 g_signal_connect (G_OBJECT (iconsize_scale), "scroll-event",
1922 G_CALLBACK (on_scale_scroll_event), NULL);2203 G_CALLBACK (on_scale_scroll_event), NULL);
1923 iconsize_widget_refresh (iconsize_adj, priv->unity_settings);2204 iconsize_widget_refresh (iconsize_adj, priv->unity_settings);
19242205
1925 /* Reveal spot setting */2206 /* Reveal spot setting */
1926 g_signal_connect (priv->unity_settings, "changed::" UNITY_LAUNCHERREVEAL_KEY,2207 g_signal_connect (priv->unity_compiz_gs, "changed::" UNITY_LAUNCHERREVEAL_KEY,
1927 G_CALLBACK (ext_reveallauncher_changed_callback), self);2208 G_CALLBACK (ext_reveallauncher_changed_callback), self);
1928 g_signal_connect (WID ("unity_reveal_spot_topleft"), "toggled",2209 g_signal_connect (WID ("unity_reveal_spot_topleft"), "toggled",
1929 G_CALLBACK (on_reveallauncher_changed), self);2210 G_CALLBACK (on_reveallauncher_changed), self);
@@ -1936,7 +2217,7 @@
1936 launcher_sensitivity_scale = GTK_SCALE (WID ("unity-launcher-sensitivity"));2217 launcher_sensitivity_scale = GTK_SCALE (WID ("unity-launcher-sensitivity"));
1937 gtk_range_set_adjustment (GTK_RANGE (launcher_sensitivity_scale), launcher_sensitivity_adj);2218 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);2219 gtk_scale_add_mark (launcher_sensitivity_scale, 2, GTK_POS_BOTTOM, NULL);
1939 g_signal_connect (priv->unity_settings, "changed::" UNITY_LAUNCHERSENSITIVITY_KEY,2220 g_signal_connect (priv->unity_compiz_gs, "changed::" UNITY_LAUNCHERSENSITIVITY_KEY,
1940 G_CALLBACK (ext_launchersensitivity_changed_callback), launcher_sensitivity_adj);2221 G_CALLBACK (ext_launchersensitivity_changed_callback), launcher_sensitivity_adj);
1941 g_signal_connect (launcher_sensitivity_adj, "value_changed",2222 g_signal_connect (launcher_sensitivity_adj, "value_changed",
1942 G_CALLBACK (on_launchersensitivity_changed), self);2223 G_CALLBACK (on_launchersensitivity_changed), self);
@@ -1945,16 +2226,16 @@
1945 launcher_sensitivity_widget_refresh (launcher_sensitivity_adj, priv->unity_settings);2226 launcher_sensitivity_widget_refresh (launcher_sensitivity_adj, priv->unity_settings);
19462227
1947 /* Autohide launcher setting */2228 /* Autohide launcher setting */
1948 g_signal_connect (priv->unity_settings, "changed::" UNITY_LAUNCHERHIDE_KEY,2229 g_signal_connect (priv->unity_compiz_gs, "changed::" UNITY_LAUNCHERHIDE_KEY,
1949 G_CALLBACK (ext_hidelauncher_changed_callback), self);2230 G_CALLBACK (ext_hidelauncher_changed_callback), self);
1950 g_signal_connect (WID ("unity_launcher_autohide"), "notify::active",2231 g_signal_connect (WID ("unity_launcher_autohide"), "notify::active",
1951 G_CALLBACK (on_hidelauncher_changed), self);2232 G_CALLBACK (on_hidelauncher_changed), self);
1952 hidelauncher_widget_refresh (self);2233 hidelauncher_widget_refresh (self);
19532234
1954 /* Enabling workspaces */2235 /* Enabling workspaces */
1955 g_signal_connect (priv->compizcore_settings, "changed::" COMPIZCORE_HSIZE_KEY,2236 g_signal_connect (priv->compizcore_compiz_gs, "changed::" COMPIZCORE_HSIZE_KEY,
1956 G_CALLBACK (ext_enableworkspaces_changed_callback), self);2237 G_CALLBACK (ext_enableworkspaces_changed_callback), self);
1957 g_signal_connect (priv->compizcore_settings, "changed::" COMPIZCORE_VSIZE_KEY,2238 g_signal_connect (priv->compizcore_compiz_gs, "changed::" COMPIZCORE_VSIZE_KEY,
1958 G_CALLBACK (ext_enableworkspaces_changed_callback), self);2239 G_CALLBACK (ext_enableworkspaces_changed_callback), self);
1959 g_signal_connect (WID ("check_enable_workspaces"), "toggled",2240 g_signal_connect (WID ("check_enable_workspaces"), "toggled",
1960 G_CALLBACK (on_enable_workspaces_changed), self);2241 G_CALLBACK (on_enable_workspaces_changed), self);

Subscribers

People subscribed via source and target branches