Merge lp:~3v1n0/unity-control-center/lowgfx-listens-compiz-profile into lp:unity-control-center

Proposed by Marco Trevisan (Treviño) on 2017-07-14
Status: Merged
Approved by: Sebastien Bacher on 2017-07-17
Approved revision: 12894
Merged at revision: 12894
Proposed branch: lp:~3v1n0/unity-control-center/lowgfx-listens-compiz-profile
Merge into: lp:unity-control-center
Diff against target: 185 lines (+62/-46)
2 files modified
panels/appearance/appearance.ui (+15/-15)
panels/appearance/cc-appearance-panel.c (+47/-31)
To merge this branch: bzr merge lp:~3v1n0/unity-control-center/lowgfx-listens-compiz-profile
Reviewer Review Type Date Requested Status
Sebastien Bacher 2017-07-14 Approve on 2017-07-17
Review via email: mp+327400@code.launchpad.net

Commit message

Appearance: listen to compiz-profile key instead of lowgfx

In order to know whether we're running in lowgfx mode or
not is safer to use the compiz profile in use, since the gsettings
key might be unset, and thus in this case we just fallback
to automatic mode.

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

looks good, thanks

review: Approve
12895. By Marco Trevisan (Treviño) on 2017-07-18

Appearance: avoid the flip-flop between settings ignoring signals

12896. By Marco Trevisan (Treviño) on 2017-07-18

Appearance: set show-desktop to false when resetting the settings

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'panels/appearance/appearance.ui'
2--- panels/appearance/appearance.ui 2017-07-10 11:00:57 +0000
3+++ panels/appearance/appearance.ui 2017-07-18 16:32:14 +0000
4@@ -178,6 +178,19 @@
5 </packing>
6 </child>
7 <child>
8+ <object class="GtkLabel" id="slide-label">
9+ <property name="visible">True</property>
10+ <property name="can_focus">False</property>
11+ <property name="label" translatable="yes" comments="This refers to a slideshow background">Changes throughout the day</property>
12+ <property name="xalign">0</property>
13+ </object>
14+ <packing>
15+ <property name="expand">False</property>
16+ <property name="fill">True</property>
17+ <property name="position">1</property>
18+ </packing>
19+ </child>
20+ <child>
21 <object class="GtkLabel" id="strut">
22 <property name="visible">True</property>
23 <property name="can_focus">False</property>
24@@ -189,19 +202,6 @@
25 <property name="position">1</property>
26 </packing>
27 </child>
28- <child>
29- <object class="GtkLabel" id="slide-label">
30- <property name="visible">True</property>
31- <property name="can_focus">False</property>
32- <property name="label" translatable="yes" comments="This refers to a slideshow background">Changes throughout the day</property>
33- <property name="xalign">0</property>
34- </object>
35- <packing>
36- <property name="expand">False</property>
37- <property name="fill">True</property>
38- <property name="position">1</property>
39- </packing>
40- </child>
41 </object>
42 <packing>
43 <property name="expand">True</property>
44@@ -1083,7 +1083,7 @@
45 </packing>
46 </child>
47 <child>
48- <object class="GtkBox" id="unity_gfx_mode_selector_box">
49+ <object class="GtkBox" id="unity_gfx_mode_box">
50 <property name="visible">True</property>
51 <property name="can_focus">False</property>
52 <property name="margin_left">10</property>
53@@ -1123,7 +1123,7 @@
54 <property name="orientation">vertical</property>
55 <property name="spacing">2</property>
56 <child>
57- <object class="GtkBox">
58+ <object class="GtkBox" id="unity_gfx_mode_selectors_box">
59 <property name="visible">True</property>
60 <property name="can_focus">False</property>
61 <property name="spacing">5</property>
62
63=== modified file 'panels/appearance/cc-appearance-panel.c'
64--- panels/appearance/cc-appearance-panel.c 2017-07-10 11:00:57 +0000
65+++ panels/appearance/cc-appearance-panel.c 2017-07-18 16:32:14 +0000
66@@ -302,6 +302,8 @@
67 g_object_unref (priv->current_background);
68 priv->current_background = NULL;
69 }
70+
71+ g_source_remove_by_user_data (object);
72
73 G_OBJECT_CLASS (cc_appearance_panel_parent_class)->finalize (object);
74 }
75@@ -2077,6 +2079,36 @@
76 return is_available;
77 }
78
79+static void gfx_mode_widget_refresh (CcAppearancePanel *self);
80+
81+static gboolean
82+gfx_mode_changed_timeout (gpointer data)
83+{
84+ CcAppearancePanel *self = CC_APPEARANCE_PANEL (data);
85+ CcAppearancePanelPrivate *priv = self->priv;
86+
87+ gfx_mode_widget_refresh (self);
88+ gtk_widget_set_sensitive (WID ("unity_gfx_mode_selectors_box"), TRUE);
89+
90+ return FALSE;
91+}
92+
93+static void
94+on_gfx_mode_changed (GtkToggleButton *button,
95+ gpointer user_data)
96+{
97+ CcAppearancePanel *self = CC_APPEARANCE_PANEL (user_data);
98+ CcAppearancePanelPrivate *priv = self->priv;
99+
100+ gboolean low_enabled = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (WID ("unity_gfx_mode_low_enable")));
101+ gtk_widget_set_sensitive (WID ("unity_gfx_mode_selectors_box"), FALSE);
102+
103+ g_settings_set_boolean (priv->unity_own_settings, UNITY_LOWGFX_KEY, low_enabled);
104+
105+ gfx_mode_widget_refresh (self);
106+ g_timeout_add (200, gfx_mode_changed_timeout, self);
107+}
108+
109 static void
110 gfx_mode_widget_refresh (CcAppearancePanel *self)
111 {
112@@ -2090,32 +2122,19 @@
113
114 if (!has_setting || !has_profile)
115 return;
116-
117- gboolean enable_lowgfx = g_settings_get_boolean (priv->unity_own_settings, UNITY_LOWGFX_KEY);
118-
119- if (enable_lowgfx == FALSE)
120- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (WID ("unity_gfx_mode_full_enable")), TRUE);
121- else
122- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (WID ("unity_gfx_mode_low_enable")), TRUE);
123-}
124-
125-static void
126-on_gfx_mode_changed (GtkToggleButton *button,
127- gpointer user_data)
128-{
129- CcAppearancePanel *self = CC_APPEARANCE_PANEL (user_data);
130- CcAppearancePanelPrivate *priv = self->priv;
131-
132- gboolean low_enabled = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (WID ("unity_gfx_mode_low_enable")));
133- g_settings_set_boolean (priv->unity_own_settings, UNITY_LOWGFX_KEY, low_enabled);
134-}
135-
136-static void
137-ext_lowgfx_changed_callback (GroupedGSettings* compiz_gs,
138- gchar *key,
139- gpointer user_data)
140-{
141- gfx_mode_widget_refresh (CC_APPEARANCE_PANEL (user_data));
142+
143+ GtkToggleButton *active_toggle, *low_toggle, *full_toggle;
144+ gchar *compiz_profile = g_settings_get_string (priv->compiz_settings, COMPIZ_CURRENT_PROFILE_KEY);
145+ gboolean enable_lowgfx = g_strcmp0 (compiz_profile, UNITY_LOWGFX_PROFILE) == 0;
146+ low_toggle = GTK_TOGGLE_BUTTON (WID ("unity_gfx_mode_low_enable"));
147+ full_toggle = GTK_TOGGLE_BUTTON (WID ("unity_gfx_mode_full_enable"));
148+ active_toggle = enable_lowgfx ? low_toggle : full_toggle;
149+
150+ g_signal_handlers_block_by_func (low_toggle, on_gfx_mode_changed, self);
151+ gtk_toggle_button_set_active (active_toggle, TRUE);
152+ g_signal_handlers_unblock_by_func (low_toggle, on_gfx_mode_changed, self);
153+
154+ g_free (compiz_profile);
155 }
156
157 static void
158@@ -2138,6 +2157,7 @@
159
160 grouped_gsettings_set_default_profile (self->priv->unity_compiz_gs, compiz_profile);
161 grouped_gsettings_set_default_profile (self->priv->compizcore_compiz_gs, compiz_profile);
162+ gfx_mode_widget_refresh (self);
163
164 g_free (compiz_profile);
165 }
166@@ -2165,7 +2185,7 @@
167 g_settings_reset (priv->unity_own_settings, UNITY_LOWGFX_KEY);
168
169 GtkToggleButton *showdesktop = GTK_TOGGLE_BUTTON (WID ("check_showdesktop_in_launcher"));
170- gtk_toggle_button_set_active(showdesktop, TRUE);
171+ gtk_toggle_button_set_active(showdesktop, FALSE);
172 }
173
174 /* <hacks> */
175@@ -2341,10 +2361,6 @@
176 menuvisibility_widget_refresh (self);
177
178 /* Low gfx */
179- g_signal_connect (priv->unity_own_settings, "changed::" UNITY_LOWGFX_KEY,
180- G_CALLBACK (ext_lowgfx_changed_callback), self);
181- g_signal_connect (WID ("unity_gfx_mode_full_enable"), "toggled",
182- G_CALLBACK (on_gfx_mode_changed), self);
183 g_signal_connect (WID ("unity_gfx_mode_low_enable"), "toggled",
184 G_CALLBACK (on_gfx_mode_changed), self);
185 gfx_mode_widget_refresh (self);

Subscribers

People subscribed via source and target branches