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

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

looks good, thanks

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

Appearance: avoid the flip-flop between settings ignoring signals

12896. By Marco Trevisan (Treviño)

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
=== modified file 'panels/appearance/appearance.ui'
--- panels/appearance/appearance.ui 2017-07-10 11:00:57 +0000
+++ panels/appearance/appearance.ui 2017-07-18 16:32:14 +0000
@@ -178,6 +178,19 @@
178 </packing>178 </packing>
179 </child>179 </child>
180 <child>180 <child>
181 <object class="GtkLabel" id="slide-label">
182 <property name="visible">True</property>
183 <property name="can_focus">False</property>
184 <property name="label" translatable="yes" comments="This refers to a slideshow background">Changes throughout the day</property>
185 <property name="xalign">0</property>
186 </object>
187 <packing>
188 <property name="expand">False</property>
189 <property name="fill">True</property>
190 <property name="position">1</property>
191 </packing>
192 </child>
193 <child>
181 <object class="GtkLabel" id="strut">194 <object class="GtkLabel" id="strut">
182 <property name="visible">True</property>195 <property name="visible">True</property>
183 <property name="can_focus">False</property>196 <property name="can_focus">False</property>
@@ -189,19 +202,6 @@
189 <property name="position">1</property>202 <property name="position">1</property>
190 </packing>203 </packing>
191 </child>204 </child>
192 <child>
193 <object class="GtkLabel" id="slide-label">
194 <property name="visible">True</property>
195 <property name="can_focus">False</property>
196 <property name="label" translatable="yes" comments="This refers to a slideshow background">Changes throughout the day</property>
197 <property name="xalign">0</property>
198 </object>
199 <packing>
200 <property name="expand">False</property>
201 <property name="fill">True</property>
202 <property name="position">1</property>
203 </packing>
204 </child>
205 </object>205 </object>
206 <packing>206 <packing>
207 <property name="expand">True</property>207 <property name="expand">True</property>
@@ -1083,7 +1083,7 @@
1083 </packing>1083 </packing>
1084 </child>1084 </child>
1085 <child>1085 <child>
1086 <object class="GtkBox" id="unity_gfx_mode_selector_box">1086 <object class="GtkBox" id="unity_gfx_mode_box">
1087 <property name="visible">True</property>1087 <property name="visible">True</property>
1088 <property name="can_focus">False</property>1088 <property name="can_focus">False</property>
1089 <property name="margin_left">10</property>1089 <property name="margin_left">10</property>
@@ -1123,7 +1123,7 @@
1123 <property name="orientation">vertical</property>1123 <property name="orientation">vertical</property>
1124 <property name="spacing">2</property>1124 <property name="spacing">2</property>
1125 <child>1125 <child>
1126 <object class="GtkBox">1126 <object class="GtkBox" id="unity_gfx_mode_selectors_box">
1127 <property name="visible">True</property>1127 <property name="visible">True</property>
1128 <property name="can_focus">False</property>1128 <property name="can_focus">False</property>
1129 <property name="spacing">5</property>1129 <property name="spacing">5</property>
11301130
=== modified file 'panels/appearance/cc-appearance-panel.c'
--- panels/appearance/cc-appearance-panel.c 2017-07-10 11:00:57 +0000
+++ panels/appearance/cc-appearance-panel.c 2017-07-18 16:32:14 +0000
@@ -302,6 +302,8 @@
302 g_object_unref (priv->current_background);302 g_object_unref (priv->current_background);
303 priv->current_background = NULL;303 priv->current_background = NULL;
304 }304 }
305
306 g_source_remove_by_user_data (object);
305307
306 G_OBJECT_CLASS (cc_appearance_panel_parent_class)->finalize (object);308 G_OBJECT_CLASS (cc_appearance_panel_parent_class)->finalize (object);
307}309}
@@ -2077,6 +2079,36 @@
2077 return is_available;2079 return is_available;
2078}2080}
20792081
2082static void gfx_mode_widget_refresh (CcAppearancePanel *self);
2083
2084static gboolean
2085gfx_mode_changed_timeout (gpointer data)
2086{
2087 CcAppearancePanel *self = CC_APPEARANCE_PANEL (data);
2088 CcAppearancePanelPrivate *priv = self->priv;
2089
2090 gfx_mode_widget_refresh (self);
2091 gtk_widget_set_sensitive (WID ("unity_gfx_mode_selectors_box"), TRUE);
2092
2093 return FALSE;
2094}
2095
2096static void
2097on_gfx_mode_changed (GtkToggleButton *button,
2098 gpointer user_data)
2099{
2100 CcAppearancePanel *self = CC_APPEARANCE_PANEL (user_data);
2101 CcAppearancePanelPrivate *priv = self->priv;
2102
2103 gboolean low_enabled = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (WID ("unity_gfx_mode_low_enable")));
2104 gtk_widget_set_sensitive (WID ("unity_gfx_mode_selectors_box"), FALSE);
2105
2106 g_settings_set_boolean (priv->unity_own_settings, UNITY_LOWGFX_KEY, low_enabled);
2107
2108 gfx_mode_widget_refresh (self);
2109 g_timeout_add (200, gfx_mode_changed_timeout, self);
2110}
2111
2080static void2112static void
2081gfx_mode_widget_refresh (CcAppearancePanel *self)2113gfx_mode_widget_refresh (CcAppearancePanel *self)
2082{2114{
@@ -2090,32 +2122,19 @@
2090 2122
2091 if (!has_setting || !has_profile)2123 if (!has_setting || !has_profile)
2092 return;2124 return;
2093 2125
2094 gboolean enable_lowgfx = g_settings_get_boolean (priv->unity_own_settings, UNITY_LOWGFX_KEY);2126 GtkToggleButton *active_toggle, *low_toggle, *full_toggle;
20952127 gchar *compiz_profile = g_settings_get_string (priv->compiz_settings, COMPIZ_CURRENT_PROFILE_KEY);
2096 if (enable_lowgfx == FALSE)2128 gboolean enable_lowgfx = g_strcmp0 (compiz_profile, UNITY_LOWGFX_PROFILE) == 0;
2097 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (WID ("unity_gfx_mode_full_enable")), TRUE);2129 low_toggle = GTK_TOGGLE_BUTTON (WID ("unity_gfx_mode_low_enable"));
2098 else2130 full_toggle = GTK_TOGGLE_BUTTON (WID ("unity_gfx_mode_full_enable"));
2099 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (WID ("unity_gfx_mode_low_enable")), TRUE);2131 active_toggle = enable_lowgfx ? low_toggle : full_toggle;
2100}2132
21012133 g_signal_handlers_block_by_func (low_toggle, on_gfx_mode_changed, self);
2102static void2134 gtk_toggle_button_set_active (active_toggle, TRUE);
2103on_gfx_mode_changed (GtkToggleButton *button,2135 g_signal_handlers_unblock_by_func (low_toggle, on_gfx_mode_changed, self);
2104 gpointer user_data)2136
2105{2137 g_free (compiz_profile);
2106 CcAppearancePanel *self = CC_APPEARANCE_PANEL (user_data);
2107 CcAppearancePanelPrivate *priv = self->priv;
2108
2109 gboolean low_enabled = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (WID ("unity_gfx_mode_low_enable")));
2110 g_settings_set_boolean (priv->unity_own_settings, UNITY_LOWGFX_KEY, low_enabled);
2111}
2112
2113static void
2114ext_lowgfx_changed_callback (GroupedGSettings* compiz_gs,
2115 gchar *key,
2116 gpointer user_data)
2117{
2118 gfx_mode_widget_refresh (CC_APPEARANCE_PANEL (user_data));
2119}2138}
21202139
2121static void2140static void
@@ -2138,6 +2157,7 @@
21382157
2139 grouped_gsettings_set_default_profile (self->priv->unity_compiz_gs, compiz_profile);2158 grouped_gsettings_set_default_profile (self->priv->unity_compiz_gs, compiz_profile);
2140 grouped_gsettings_set_default_profile (self->priv->compizcore_compiz_gs, compiz_profile);2159 grouped_gsettings_set_default_profile (self->priv->compizcore_compiz_gs, compiz_profile);
2160 gfx_mode_widget_refresh (self);
21412161
2142 g_free (compiz_profile);2162 g_free (compiz_profile);
2143}2163}
@@ -2165,7 +2185,7 @@
2165 g_settings_reset (priv->unity_own_settings, UNITY_LOWGFX_KEY);2185 g_settings_reset (priv->unity_own_settings, UNITY_LOWGFX_KEY);
21662186
2167 GtkToggleButton *showdesktop = GTK_TOGGLE_BUTTON (WID ("check_showdesktop_in_launcher"));2187 GtkToggleButton *showdesktop = GTK_TOGGLE_BUTTON (WID ("check_showdesktop_in_launcher"));
2168 gtk_toggle_button_set_active(showdesktop, TRUE);2188 gtk_toggle_button_set_active(showdesktop, FALSE);
2169}2189}
21702190
2171/* <hacks> */2191/* <hacks> */
@@ -2341,10 +2361,6 @@
2341 menuvisibility_widget_refresh (self);2361 menuvisibility_widget_refresh (self);
23422362
2343 /* Low gfx */2363 /* Low gfx */
2344 g_signal_connect (priv->unity_own_settings, "changed::" UNITY_LOWGFX_KEY,
2345 G_CALLBACK (ext_lowgfx_changed_callback), self);
2346 g_signal_connect (WID ("unity_gfx_mode_full_enable"), "toggled",
2347 G_CALLBACK (on_gfx_mode_changed), self);
2348 g_signal_connect (WID ("unity_gfx_mode_low_enable"), "toggled",2364 g_signal_connect (WID ("unity_gfx_mode_low_enable"), "toggled",
2349 G_CALLBACK (on_gfx_mode_changed), self);2365 G_CALLBACK (on_gfx_mode_changed), self);
2350 gfx_mode_widget_refresh (self);2366 gfx_mode_widget_refresh (self);

Subscribers

People subscribed via source and target branches