Merge lp:~3v1n0/unity-control-center/appmoptions into lp:unity-control-center

Proposed by Marco Trevisan (Treviño)
Status: Merged
Approved by: Sebastien Bacher
Approved revision: 12708
Merged at revision: 12719
Proposed branch: lp:~3v1n0/unity-control-center/appmoptions
Merge into: lp:unity-control-center
Diff against target: 356 lines (+202/-23)
2 files modified
panels/appearance/appearance.ui (+105/-10)
panels/appearance/cc-appearance-panel.c (+97/-13)
To merge this branch: bzr merge lp:~3v1n0/unity-control-center/appmoptions
Reviewer Review Type Date Requested Status
Sebastien Bacher Approve
PS Jenkins bot (community) continuous-integration Approve
Review via email: mp+207461@code.launchpad.net

Commit message

Appearance: Add Application Menu settings to Unity behaviour tab

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Sebastien Bacher (seb128) wrote :

Thanks for the work!

review: Approve

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 2014-01-28 22:26:00 +0000
3+++ panels/appearance/appearance.ui 2014-02-20 15:19:10 +0000
4@@ -363,9 +363,6 @@
5 <property name="can_focus">False</property>
6 <property name="toolbar_style">icons</property>
7 <property name="icon_size">1</property>
8- <style>
9- <class name="inline-toolbar"/>
10- </style>
11 <child>
12 <object class="GtkToolButton" id="add_button">
13 <property name="visible">True</property>
14@@ -393,6 +390,9 @@
15 <property name="homogeneous">True</property>
16 </packing>
17 </child>
18+ <style>
19+ <class name="inline-toolbar"/>
20+ </style>
21 </object>
22 <packing>
23 <property name="expand">False</property>
24@@ -883,10 +883,111 @@
25 </packing>
26 </child>
27 <child>
28+ <object class="GtkSeparator" id="separator4">
29+ <property name="visible">True</property>
30+ <property name="can_focus">False</property>
31+ </object>
32+ <packing>
33+ <property name="expand">False</property>
34+ <property name="fill">True</property>
35+ <property name="position">3</property>
36+ </packing>
37+ </child>
38+ <child>
39+ <object class="GtkBox" id="unity_menus_box">
40+ <property name="visible">True</property>
41+ <property name="can_focus">False</property>
42+ <property name="margin_left">10</property>
43+ <property name="margin_right">10</property>
44+ <property name="border_width">0</property>
45+ <property name="orientation">vertical</property>
46+ <property name="spacing">2</property>
47+ <child>
48+ <object class="GtkLabel" id="label3">
49+ <property name="visible">True</property>
50+ <property name="can_focus">False</property>
51+ <property name="xalign">0</property>
52+ <property name="label" translatable="yes">&lt;b&gt;Application Menu&lt;/b&gt;</property>
53+ <property name="use_markup">True</property>
54+ </object>
55+ <packing>
56+ <property name="expand">False</property>
57+ <property name="fill">True</property>
58+ <property name="position">0</property>
59+ </packing>
60+ </child>
61+ <child>
62+ <object class="GtkBox" id="unity_menus_type_box">
63+ <property name="visible">True</property>
64+ <property name="can_focus">False</property>
65+ <property name="margin_left">10</property>
66+ <property name="margin_top">9</property>
67+ <property name="orientation">vertical</property>
68+ <child>
69+ <object class="GtkRadioButton" id="unity_global_menus">
70+ <property name="label" translatable="yes">In top bar</property>
71+ <property name="visible">True</property>
72+ <property name="can_focus">True</property>
73+ <property name="receives_default">False</property>
74+ <property name="xalign">0</property>
75+ <property name="active">True</property>
76+ <property name="draw_indicator">True</property>
77+ <property name="group">unity_local_menus</property>
78+ </object>
79+ <packing>
80+ <property name="expand">False</property>
81+ <property name="fill">True</property>
82+ <property name="position">1</property>
83+ </packing>
84+ </child>
85+ <child>
86+ <object class="GtkRadioButton" id="unity_local_menus">
87+ <property name="label" translatable="yes">In window title bars</property>
88+ <property name="visible">True</property>
89+ <property name="can_focus">True</property>
90+ <property name="receives_default">False</property>
91+ <property name="xalign">0</property>
92+ <property name="draw_indicator">True</property>
93+ <property name="group">unity_global_menus</property>
94+ </object>
95+ <packing>
96+ <property name="expand">False</property>
97+ <property name="fill">True</property>
98+ <property name="position">2</property>
99+ </packing>
100+ </child>
101+ </object>
102+ <packing>
103+ <property name="expand">False</property>
104+ <property name="fill">True</property>
105+ <property name="position">2</property>
106+ </packing>
107+ </child>
108+ </object>
109+ <packing>
110+ <property name="expand">False</property>
111+ <property name="fill">True</property>
112+ <property name="padding">5</property>
113+ <property name="position">4</property>
114+ </packing>
115+ </child>
116+ <child>
117+ <object class="GtkSeparator" id="menu_separator">
118+ <property name="visible">True</property>
119+ <property name="can_focus">False</property>
120+ </object>
121+ <packing>
122+ <property name="expand">False</property>
123+ <property name="fill">True</property>
124+ <property name="position">5</property>
125+ </packing>
126+ </child>
127+ <child>
128 <object class="GtkBox" id="box5">
129 <property name="height_request">36</property>
130 <property name="visible">True</property>
131 <property name="can_focus">False</property>
132+ <property name="margin_top">10</property>
133 <child>
134 <object class="GtkButton" id="button-restore-unitybehavior">
135 <property name="label" translatable="yes">Restore Default Behaviours</property>
136@@ -909,15 +1010,9 @@
137 <packing>
138 <property name="expand">False</property>
139 <property name="fill">True</property>
140- <property name="position">3</property>
141+ <property name="position">6</property>
142 </packing>
143 </child>
144- <child>
145- <placeholder/>
146- </child>
147- <child>
148- <placeholder/>
149- </child>
150 </object>
151 <packing>
152 <property name="position">1</property>
153
154=== modified file 'panels/appearance/cc-appearance-panel.c'
155--- panels/appearance/cc-appearance-panel.c 2014-02-18 23:45:31 +0000
156+++ panels/appearance/cc-appearance-panel.c 2014-02-20 15:19:10 +0000
157@@ -74,6 +74,7 @@
158 GSettings *unity_settings;
159 GSettings *compizcore_settings;
160 GSettings *unity_own_settings;
161+ GSettings *unity_launcher_settings;
162
163 GnomeDesktopThumbnailFactory *thumb_factory;
164
165@@ -112,8 +113,10 @@
166 #define COMPIZCORE_HSIZE_KEY "hsize"
167 #define COMPIZCORE_VSIZE_KEY "vsize"
168
169-#define UNITY_OWN_GSETTINGS_SCHEMA "com.canonical.Unity.Launcher"
170+#define UNITY_OWN_GSETTINGS_SCHEMA "com.canonical.Unity"
171+#define UNITY_LAUNCHER_GSETTINGS_SCHEMA "com.canonical.Unity.Launcher"
172 #define UNITY_FAVORITES_KEY "favorites"
173+#define UNITY_INTEGRATED_MENUS_KEY "integrated-menus"
174 #define SHOW_DESKTOP_UNITY_FAVORITE_STR "unity://desktop-icon"
175
176 #define MIN_ICONSIZE 16.0
177@@ -233,10 +236,10 @@
178 priv->compizcore_settings = NULL;
179 }
180
181- if (priv->unity_own_settings)
182+ if (priv->unity_launcher_settings)
183 {
184- g_object_unref (priv->unity_own_settings);
185- priv->unity_own_settings = NULL;
186+ g_object_unref (priv->unity_launcher_settings);
187+ priv->unity_launcher_settings = NULL;
188 }
189
190 if (priv->copy_cancellable)
191@@ -1626,7 +1629,7 @@
192 gchar **favorites = NULL;
193 gboolean show_desktop_found = FALSE;
194
195- favorites = g_settings_get_strv (priv->unity_own_settings, UNITY_FAVORITES_KEY);
196+ favorites = g_settings_get_strv (priv->unity_launcher_settings, UNITY_FAVORITES_KEY);
197 while (*favorites != NULL)
198 {
199 if (g_strcmp0 (*favorites, SHOW_DESKTOP_UNITY_FAVORITE_STR) == 0)
200@@ -1658,7 +1661,7 @@
201 GPtrArray* newfavorites = g_ptr_array_new ();
202 gboolean show_desktop_in_array = FALSE;
203
204- favorites = g_settings_get_strv (priv->unity_own_settings, UNITY_FAVORITES_KEY);
205+ favorites = g_settings_get_strv (priv->unity_launcher_settings, UNITY_FAVORITES_KEY);
206 if (gtk_toggle_button_get_active (button))
207 {
208
209@@ -1697,11 +1700,71 @@
210 }
211 }
212 g_ptr_array_add (newfavorites, NULL);
213- g_settings_set_strv (priv->unity_own_settings, UNITY_FAVORITES_KEY, (const gchar **)newfavorites->pdata);
214+ g_settings_set_strv (priv->unity_launcher_settings, UNITY_FAVORITES_KEY, (const gchar **)newfavorites->pdata);
215 g_ptr_array_free (newfavorites, TRUE);
216
217 }
218
219+static gboolean
220+unity_own_setting_exists (CcAppearancePanel *self, const gchar* key_name)
221+{
222+ if (!self->priv->unity_own_settings)
223+ return FALSE;
224+
225+ gchar** unity_keys;
226+ gchar** key;
227+
228+ unity_keys = g_settings_list_keys (self->priv->unity_own_settings);
229+
230+ for (key = unity_keys; *key; ++key)
231+ {
232+ if (g_strcmp0 (*key, key_name) == 0)
233+ return TRUE;
234+ }
235+
236+ g_strfreev (unity_keys);
237+ return FALSE;
238+}
239+
240+static void
241+menulocation_widget_refresh (CcAppearancePanel *self)
242+{
243+ CcAppearancePanelPrivate *priv = self->priv;
244+
245+ gboolean has_setting = unity_own_setting_exists (self, UNITY_INTEGRATED_MENUS_KEY);
246+ gtk_widget_set_visible (WID ("unity_menus_box"), has_setting);
247+ gtk_widget_set_visible (WID ("menu_separator"), has_setting);
248+
249+ if (!has_setting)
250+ return;
251+
252+ gboolean value = g_settings_get_boolean (priv->unity_own_settings, UNITY_INTEGRATED_MENUS_KEY);
253+
254+ if (value)
255+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (WID ("unity_local_menus")), TRUE);
256+ else
257+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (WID ("unity_global_menus")), TRUE);
258+}
259+
260+static void
261+ext_menulocation_changed_callback (GSettings* settings,
262+ guint key,
263+ gpointer user_data)
264+{
265+ menulocation_widget_refresh (CC_APPEARANCE_PANEL (user_data));
266+}
267+
268+static void
269+on_menulocation_changed (GtkToggleButton *button, gpointer user_data)
270+{
271+ CcAppearancePanel *self = CC_APPEARANCE_PANEL (user_data);
272+ CcAppearancePanelPrivate *priv = self->priv;
273+ gboolean local_menus = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (WID ("unity_local_menus")));
274+
275+ g_settings_set_boolean (priv->unity_own_settings, UNITY_INTEGRATED_MENUS_KEY, local_menus);
276+ menulocation_widget_refresh (self);
277+}
278+
279 static void
280 on_restore_defaults_page2_clicked (GtkButton *button, gpointer user_data)
281 {
282@@ -1714,6 +1777,9 @@
283 g_settings_reset (priv->unity_settings, UNITY_LAUNCHERREVEAL_KEY);
284 g_settings_reset (priv->compizcore_settings, COMPIZCORE_HSIZE_KEY);
285 g_settings_reset (priv->compizcore_settings, COMPIZCORE_VSIZE_KEY);
286+
287+ if (unity_own_setting_exists (self, UNITY_INTEGRATED_MENUS_KEY))
288+ g_settings_reset (priv->unity_own_settings, UNITY_INTEGRATED_MENUS_KEY);
289 }
290
291 /* <hacks> */
292@@ -1764,27 +1830,36 @@
293 GtkScale* iconsize_scale;
294 GtkScale* launcher_sensitivity_scale;
295 GSettingsSchema *schema;
296-
297- schema = g_settings_schema_source_lookup (g_settings_schema_source_get_default (), UNITY_OWN_GSETTINGS_SCHEMA, TRUE);
298+ GSettingsSchemaSource* source;
299+
300+ source = g_settings_schema_source_get_default ();
301+
302+ schema = g_settings_schema_source_lookup (source, UNITY_OWN_GSETTINGS_SCHEMA, TRUE);
303 if (schema)
304 {
305 priv->unity_own_settings = g_settings_new (UNITY_OWN_GSETTINGS_SCHEMA);
306 g_object_unref (schema);
307 }
308- schema = g_settings_schema_source_lookup (g_settings_schema_source_get_default (), UNITY_GSETTINGS_SCHEMA, TRUE);
309+ schema = g_settings_schema_source_lookup (source, UNITY_LAUNCHER_GSETTINGS_SCHEMA, TRUE);
310+ if (schema)
311+ {
312+ priv->unity_launcher_settings = g_settings_new (UNITY_LAUNCHER_GSETTINGS_SCHEMA);
313+ g_object_unref (schema);
314+ }
315+ schema = g_settings_schema_source_lookup (source, UNITY_GSETTINGS_SCHEMA, TRUE);
316 if (schema)
317 {
318 priv->unity_settings = g_settings_new_with_path (UNITY_GSETTINGS_SCHEMA, UNITY_GSETTINGS_PATH);
319 g_object_unref (schema);
320 }
321- schema = g_settings_schema_source_lookup (g_settings_schema_source_get_default (), COMPIZCORE_GSETTINGS_SCHEMA, TRUE);
322+ schema = g_settings_schema_source_lookup (source, COMPIZCORE_GSETTINGS_SCHEMA, TRUE);
323 if (schema)
324 {
325 priv->compizcore_settings = g_settings_new_with_path (COMPIZCORE_GSETTINGS_SCHEMA, COMPIZCORE_GSETTINGS_PATH);
326 g_object_unref (schema);
327 }
328
329- if (!priv->unity_settings || !priv->compizcore_settings || !priv->unity_own_settings)
330+ if (!priv->unity_settings || !priv->compizcore_settings || !priv->unity_own_settings || !priv->unity_launcher_settings)
331 return;
332
333 /* Icon size change */
334@@ -1844,12 +1919,21 @@
335 enable_workspaces_widget_refresh (self);
336
337 /* Enabling show desktop icon */
338- g_signal_connect (priv->unity_own_settings, "changed::" UNITY_FAVORITES_KEY,
339+ g_signal_connect (priv->unity_launcher_settings, "changed::" UNITY_FAVORITES_KEY,
340 G_CALLBACK (ext_enableshowdesktop_changed_callback), self);
341 g_signal_connect (WID ("check_showdesktop_in_launcher"), "toggled",
342 G_CALLBACK (on_enable_showdesktop_changed), self);
343 enable_showdesktop_widget_refresh (self);
344
345+ /* Menu location */
346+ g_signal_connect (priv->unity_own_settings, "changed::" UNITY_INTEGRATED_MENUS_KEY,
347+ G_CALLBACK (ext_menulocation_changed_callback), self);
348+ g_signal_connect (WID ("unity_global_menus"), "toggled",
349+ G_CALLBACK (on_menulocation_changed), self);
350+ g_signal_connect (WID ("unity_local_menus"), "toggled",
351+ G_CALLBACK (on_menulocation_changed), self);
352+ menulocation_widget_refresh (self);
353+
354 /* Restore defaut on second page */
355 g_signal_connect (WID ("button-restore-unitybehavior"), "clicked",
356 G_CALLBACK (on_restore_defaults_page2_clicked), self);

Subscribers

People subscribed via source and target branches