Merge lp:~3v1n0/unity-control-center/unity-menu-visibilty-toggle into lp:unity-control-center
- unity-menu-visibilty-toggle
- Merge into trunk
Proposed by
Marco Trevisan (Treviño)
on 2016-01-28
| Status: | Merged |
|---|---|
| Approved by: | Sebastien Bacher on 2016-02-08 |
| Approved revision: | 12840 |
| Merged at revision: | 12846 |
| Proposed branch: | lp:~3v1n0/unity-control-center/unity-menu-visibilty-toggle |
| Merge into: | lp:unity-control-center |
| Diff against target: |
394 lines (+224/-79) 2 files modified
panels/appearance/appearance.ui (+168/-76) panels/appearance/cc-appearance-panel.c (+56/-3) |
| To merge this branch: | bzr merge lp:~3v1n0/unity-control-center/unity-menu-visibilty-toggle |
| Related bugs: |
| Reviewer | Review Type | Date Requested | Status |
|---|---|---|---|
| Sebastien Bacher | 2016-01-28 | Approve on 2016-02-08 | |
|
Review via email:
|
|||
Commit Message
Appearance: Add radiobox to toggle the always show menu option
Description of the Change
To post a comment you must log in.
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-03-05 16:24:17 +0000 |
| 3 | +++ panels/appearance/appearance.ui 2016-01-28 16:19:07 +0000 |
| 4 | @@ -331,6 +331,7 @@ |
| 5 | <object class="GtkIconView" id="backgrounds-iconview"> |
| 6 | <property name="visible">True</property> |
| 7 | <property name="can_focus">True</property> |
| 8 | + <property name="margin">0</property> |
| 9 | <property name="row_spacing">0</property> |
| 10 | <property name="column_spacing">0</property> |
| 11 | <child> |
| 12 | @@ -918,49 +919,159 @@ |
| 13 | <object class="GtkBox" id="unity_menus_box"> |
| 14 | <property name="visible">True</property> |
| 15 | <property name="can_focus">False</property> |
| 16 | - <property name="margin_left">10</property> |
| 17 | - <property name="margin_right">10</property> |
| 18 | - <property name="border_width">0</property> |
| 19 | <property name="orientation">vertical</property> |
| 20 | - <property name="spacing">2</property> |
| 21 | - <child> |
| 22 | - <object class="GtkLabel" id="label3"> |
| 23 | - <property name="visible">True</property> |
| 24 | - <property name="can_focus">False</property> |
| 25 | - <property name="xalign">0</property> |
| 26 | - <property name="label" translatable="yes"><b>Show the menus for a window</b></property> |
| 27 | - <property name="use_markup">True</property> |
| 28 | - <accessibility> |
| 29 | - <relation type="label-for" target="unity_global_menus"/> |
| 30 | - <relation type="label-for" target="unity_local_menus"/> |
| 31 | - </accessibility> |
| 32 | - </object> |
| 33 | - <packing> |
| 34 | - <property name="expand">False</property> |
| 35 | - <property name="fill">True</property> |
| 36 | - <property name="position">0</property> |
| 37 | - </packing> |
| 38 | - </child> |
| 39 | - <child> |
| 40 | - <object class="GtkBox" id="unity_menus_type_box"> |
| 41 | + <child> |
| 42 | + <object class="GtkBox" id="box8"> |
| 43 | <property name="visible">True</property> |
| 44 | <property name="can_focus">False</property> |
| 45 | <property name="margin_left">10</property> |
| 46 | - <property name="margin_top">9</property> |
| 47 | - <property name="orientation">vertical</property> |
| 48 | - <child> |
| 49 | - <object class="GtkRadioButton" id="unity_global_menus"> |
| 50 | - <property name="label" translatable="yes">In the menu bar</property> |
| 51 | - <property name="visible">True</property> |
| 52 | - <property name="can_focus">True</property> |
| 53 | - <property name="receives_default">False</property> |
| 54 | - <property name="xalign">0</property> |
| 55 | - <property name="active">True</property> |
| 56 | - <property name="draw_indicator">True</property> |
| 57 | - <property name="group">unity_local_menus</property> |
| 58 | - <accessibility> |
| 59 | - <relation type="labelled-by" target="label3"/> |
| 60 | - </accessibility> |
| 61 | + <property name="margin_right">10</property> |
| 62 | + <property name="homogeneous">True</property> |
| 63 | + <child> |
| 64 | + <object class="GtkBox" id="unity_menus_location_box"> |
| 65 | + <property name="visible">True</property> |
| 66 | + <property name="can_focus">False</property> |
| 67 | + <property name="orientation">vertical</property> |
| 68 | + <child> |
| 69 | + <object class="GtkLabel" id="label3"> |
| 70 | + <property name="visible">True</property> |
| 71 | + <property name="can_focus">False</property> |
| 72 | + <property name="xalign">0</property> |
| 73 | + <property name="label" translatable="yes"><b>Show the menus for a window</b></property> |
| 74 | + <property name="use_markup">True</property> |
| 75 | + <accessibility> |
| 76 | + <relation type="label-for" target="unity_global_menus"/> |
| 77 | + <relation type="label-for" target="unity_local_menus"/> |
| 78 | + </accessibility> |
| 79 | + </object> |
| 80 | + <packing> |
| 81 | + <property name="expand">False</property> |
| 82 | + <property name="fill">True</property> |
| 83 | + <property name="position">0</property> |
| 84 | + </packing> |
| 85 | + </child> |
| 86 | + <child> |
| 87 | + <object class="GtkBox" id="unity_menus_type_box"> |
| 88 | + <property name="visible">True</property> |
| 89 | + <property name="can_focus">False</property> |
| 90 | + <property name="margin_left">10</property> |
| 91 | + <property name="margin_top">9</property> |
| 92 | + <property name="orientation">vertical</property> |
| 93 | + <child> |
| 94 | + <object class="GtkRadioButton" id="unity_global_menus"> |
| 95 | + <property name="label" translatable="yes">In the menu bar</property> |
| 96 | + <property name="visible">True</property> |
| 97 | + <property name="can_focus">True</property> |
| 98 | + <property name="receives_default">False</property> |
| 99 | + <property name="xalign">0</property> |
| 100 | + <property name="draw_indicator">True</property> |
| 101 | + <property name="group">unity_local_menus</property> |
| 102 | + </object> |
| 103 | + <packing> |
| 104 | + <property name="expand">False</property> |
| 105 | + <property name="fill">True</property> |
| 106 | + <property name="position">1</property> |
| 107 | + </packing> |
| 108 | + </child> |
| 109 | + <child> |
| 110 | + <object class="GtkRadioButton" id="unity_local_menus"> |
| 111 | + <property name="label" translatable="yes">In the window's title bar</property> |
| 112 | + <property name="visible">True</property> |
| 113 | + <property name="can_focus">True</property> |
| 114 | + <property name="receives_default">False</property> |
| 115 | + <property name="xalign">0</property> |
| 116 | + <property name="draw_indicator">True</property> |
| 117 | + <property name="group">unity_global_menus</property> |
| 118 | + </object> |
| 119 | + <packing> |
| 120 | + <property name="expand">False</property> |
| 121 | + <property name="fill">True</property> |
| 122 | + <property name="position">2</property> |
| 123 | + </packing> |
| 124 | + </child> |
| 125 | + </object> |
| 126 | + <packing> |
| 127 | + <property name="expand">False</property> |
| 128 | + <property name="fill">True</property> |
| 129 | + <property name="position">1</property> |
| 130 | + </packing> |
| 131 | + </child> |
| 132 | + </object> |
| 133 | + <packing> |
| 134 | + <property name="expand">False</property> |
| 135 | + <property name="fill">True</property> |
| 136 | + <property name="position">0</property> |
| 137 | + </packing> |
| 138 | + </child> |
| 139 | + <child> |
| 140 | + <object class="GtkBox" id="unity_menus_visibility_box"> |
| 141 | + <property name="visible">True</property> |
| 142 | + <property name="can_focus">False</property> |
| 143 | + <property name="orientation">vertical</property> |
| 144 | + <child> |
| 145 | + <object class="GtkLabel" id="label5"> |
| 146 | + <property name="visible">True</property> |
| 147 | + <property name="can_focus">False</property> |
| 148 | + <property name="xalign">0</property> |
| 149 | + <property name="label" translatable="yes"><b>Menus visibility</b></property> |
| 150 | + <property name="use_markup">True</property> |
| 151 | + <accessibility> |
| 152 | + <relation type="label-for" target="unity_global_menus"/> |
| 153 | + <relation type="label-for" target="unity_local_menus"/> |
| 154 | + </accessibility> |
| 155 | + </object> |
| 156 | + <packing> |
| 157 | + <property name="expand">False</property> |
| 158 | + <property name="fill">True</property> |
| 159 | + <property name="position">0</property> |
| 160 | + </packing> |
| 161 | + </child> |
| 162 | + <child> |
| 163 | + <object class="GtkBox" id="unity_menus_visibility_type_box"> |
| 164 | + <property name="visible">True</property> |
| 165 | + <property name="can_focus">False</property> |
| 166 | + <property name="margin_left">10</property> |
| 167 | + <property name="margin_top">9</property> |
| 168 | + <property name="orientation">vertical</property> |
| 169 | + <child> |
| 170 | + <object class="GtkRadioButton" id="unity_auto_hide_menus"> |
| 171 | + <property name="label" translatable="yes">Displayed on mouse hovering</property> |
| 172 | + <property name="visible">True</property> |
| 173 | + <property name="can_focus">True</property> |
| 174 | + <property name="receives_default">False</property> |
| 175 | + <property name="xalign">0</property> |
| 176 | + <property name="draw_indicator">True</property> |
| 177 | + <property name="group">unity_always_show_menus</property> |
| 178 | + </object> |
| 179 | + <packing> |
| 180 | + <property name="expand">False</property> |
| 181 | + <property name="fill">True</property> |
| 182 | + <property name="position">1</property> |
| 183 | + </packing> |
| 184 | + </child> |
| 185 | + <child> |
| 186 | + <object class="GtkRadioButton" id="unity_always_show_menus"> |
| 187 | + <property name="label" translatable="yes">Always displayed</property> |
| 188 | + <property name="visible">True</property> |
| 189 | + <property name="can_focus">True</property> |
| 190 | + <property name="receives_default">False</property> |
| 191 | + <property name="xalign">0</property> |
| 192 | + <property name="draw_indicator">True</property> |
| 193 | + <property name="group">unity_auto_hide_menus</property> |
| 194 | + </object> |
| 195 | + <packing> |
| 196 | + <property name="expand">False</property> |
| 197 | + <property name="fill">True</property> |
| 198 | + <property name="position">2</property> |
| 199 | + </packing> |
| 200 | + </child> |
| 201 | + </object> |
| 202 | + <packing> |
| 203 | + <property name="expand">False</property> |
| 204 | + <property name="fill">True</property> |
| 205 | + <property name="position">1</property> |
| 206 | + </packing> |
| 207 | + </child> |
| 208 | </object> |
| 209 | <packing> |
| 210 | <property name="expand">False</property> |
| 211 | @@ -968,52 +1079,33 @@ |
| 212 | <property name="position">1</property> |
| 213 | </packing> |
| 214 | </child> |
| 215 | - <child> |
| 216 | - <object class="GtkRadioButton" id="unity_local_menus"> |
| 217 | - <property name="label" translatable="yes">In the window's title bar</property> |
| 218 | - <property name="visible">True</property> |
| 219 | - <property name="can_focus">True</property> |
| 220 | - <property name="receives_default">False</property> |
| 221 | - <property name="xalign">0</property> |
| 222 | - <property name="draw_indicator">True</property> |
| 223 | - <property name="group">unity_global_menus</property> |
| 224 | - <accessibility> |
| 225 | - <relation type="labelled-by" target="label3"/> |
| 226 | - </accessibility> |
| 227 | - </object> |
| 228 | - <packing> |
| 229 | - <property name="expand">False</property> |
| 230 | - <property name="fill">True</property> |
| 231 | - <property name="position">2</property> |
| 232 | - </packing> |
| 233 | - </child> |
| 234 | - </object> |
| 235 | - <packing> |
| 236 | - <property name="expand">False</property> |
| 237 | - <property name="fill">True</property> |
| 238 | - <property name="position">2</property> |
| 239 | + </object> |
| 240 | + <packing> |
| 241 | + <property name="expand">False</property> |
| 242 | + <property name="fill">True</property> |
| 243 | + <property name="padding">5</property> |
| 244 | + <property name="position">0</property> |
| 245 | + </packing> |
| 246 | + </child> |
| 247 | + <child> |
| 248 | + <object class="GtkSeparator" id="menu_separator"> |
| 249 | + <property name="visible">True</property> |
| 250 | + <property name="can_focus">False</property> |
| 251 | + </object> |
| 252 | + <packing> |
| 253 | + <property name="expand">False</property> |
| 254 | + <property name="fill">True</property> |
| 255 | + <property name="position">1</property> |
| 256 | </packing> |
| 257 | </child> |
| 258 | </object> |
| 259 | <packing> |
| 260 | <property name="expand">False</property> |
| 261 | <property name="fill">True</property> |
| 262 | - <property name="padding">5</property> |
| 263 | <property name="position">4</property> |
| 264 | </packing> |
| 265 | </child> |
| 266 | <child> |
| 267 | - <object class="GtkSeparator" id="menu_separator"> |
| 268 | - <property name="visible">True</property> |
| 269 | - <property name="can_focus">False</property> |
| 270 | - </object> |
| 271 | - <packing> |
| 272 | - <property name="expand">False</property> |
| 273 | - <property name="fill">True</property> |
| 274 | - <property name="position">5</property> |
| 275 | - </packing> |
| 276 | - </child> |
| 277 | - <child> |
| 278 | <object class="GtkBox" id="box5"> |
| 279 | <property name="height_request">36</property> |
| 280 | <property name="visible">True</property> |
| 281 | @@ -1041,7 +1133,7 @@ |
| 282 | <packing> |
| 283 | <property name="expand">False</property> |
| 284 | <property name="fill">True</property> |
| 285 | - <property name="position">6</property> |
| 286 | + <property name="position">7</property> |
| 287 | </packing> |
| 288 | </child> |
| 289 | </object> |
| 290 | |
| 291 | === modified file 'panels/appearance/cc-appearance-panel.c' |
| 292 | --- panels/appearance/cc-appearance-panel.c 2014-12-17 17:13:08 +0000 |
| 293 | +++ panels/appearance/cc-appearance-panel.c 2016-01-28 16:19:07 +0000 |
| 294 | @@ -116,6 +116,7 @@ |
| 295 | #define UNITY_LAUNCHER_GSETTINGS_SCHEMA "com.canonical.Unity.Launcher" |
| 296 | #define UNITY_FAVORITES_KEY "favorites" |
| 297 | #define UNITY_INTEGRATED_MENUS_KEY "integrated-menus" |
| 298 | +#define UNITY_ALWAYS_SHOW_MENUS_KEY "always-show-menus" |
| 299 | #define SHOW_DESKTOP_UNITY_FAVORITE_STR "unity://desktop-icon" |
| 300 | |
| 301 | #define MIN_ICONSIZE 16.0 |
| 302 | @@ -1682,7 +1683,6 @@ |
| 303 | g_ptr_array_add (newfavorites, NULL); |
| 304 | g_settings_set_strv (priv->unity_launcher_settings, UNITY_FAVORITES_KEY, (const gchar **)newfavorites->pdata); |
| 305 | g_ptr_array_free (newfavorites, TRUE); |
| 306 | - |
| 307 | } |
| 308 | |
| 309 | static gboolean |
| 310 | @@ -1712,8 +1712,9 @@ |
| 311 | CcAppearancePanelPrivate *priv = self->priv; |
| 312 | |
| 313 | gboolean has_setting = unity_own_setting_exists (self, UNITY_INTEGRATED_MENUS_KEY); |
| 314 | - gtk_widget_set_visible (WID ("unity_menus_box"), has_setting); |
| 315 | - gtk_widget_set_visible (WID ("menu_separator"), has_setting); |
| 316 | + gboolean has_menu_settings = has_setting && unity_own_setting_exists (self, UNITY_ALWAYS_SHOW_MENUS_KEY); |
| 317 | + gtk_widget_set_visible (WID ("unity_menus_location_box"), has_setting); |
| 318 | + gtk_widget_set_visible (WID ("unity_menus_box"), has_menu_settings); |
| 319 | |
| 320 | if (!has_setting) |
| 321 | return; |
| 322 | @@ -1746,6 +1747,46 @@ |
| 323 | } |
| 324 | |
| 325 | static void |
| 326 | +menuvisibility_widget_refresh (CcAppearancePanel *self) |
| 327 | +{ |
| 328 | + CcAppearancePanelPrivate *priv = self->priv; |
| 329 | + |
| 330 | + gboolean has_setting = unity_own_setting_exists (self, UNITY_ALWAYS_SHOW_MENUS_KEY); |
| 331 | + gboolean has_menu_settings = has_setting && unity_own_setting_exists (self, UNITY_INTEGRATED_MENUS_KEY); |
| 332 | + gtk_widget_set_visible (WID ("unity_menus_location_box"), has_setting); |
| 333 | + gtk_widget_set_visible (WID ("unity_menus_box"), has_menu_settings); |
| 334 | + |
| 335 | + if (!has_setting) |
| 336 | + return; |
| 337 | + |
| 338 | + gboolean value = g_settings_get_boolean (priv->unity_own_settings, UNITY_ALWAYS_SHOW_MENUS_KEY); |
| 339 | + |
| 340 | + if (value) |
| 341 | + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (WID ("unity_always_show_menus")), TRUE); |
| 342 | + else |
| 343 | + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (WID ("unity_auto_hide_menus")), TRUE); |
| 344 | +} |
| 345 | + |
| 346 | +static void |
| 347 | +ext_menuvisibility_changed_callback (GSettings* settings, |
| 348 | + guint key, |
| 349 | + gpointer user_data) |
| 350 | +{ |
| 351 | + menuvisibility_widget_refresh (CC_APPEARANCE_PANEL (user_data)); |
| 352 | +} |
| 353 | + |
| 354 | +static void |
| 355 | +on_menuvisibility_changed (GtkToggleButton *button, gpointer user_data) |
| 356 | +{ |
| 357 | + CcAppearancePanel *self = CC_APPEARANCE_PANEL (user_data); |
| 358 | + CcAppearancePanelPrivate *priv = self->priv; |
| 359 | + gboolean always_show_menus = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (WID ("unity_always_show_menus"))); |
| 360 | + |
| 361 | + g_settings_set_boolean (priv->unity_own_settings, UNITY_ALWAYS_SHOW_MENUS_KEY, always_show_menus); |
| 362 | + menuvisibility_widget_refresh (self); |
| 363 | +} |
| 364 | + |
| 365 | +static void |
| 366 | on_restore_defaults_page2_clicked (GtkButton *button, gpointer user_data) |
| 367 | { |
| 368 | CcAppearancePanel *self = CC_APPEARANCE_PANEL (user_data); |
| 369 | @@ -1761,6 +1802,9 @@ |
| 370 | if (unity_own_setting_exists (self, UNITY_INTEGRATED_MENUS_KEY)) |
| 371 | g_settings_reset (priv->unity_own_settings, UNITY_INTEGRATED_MENUS_KEY); |
| 372 | |
| 373 | + if (unity_own_setting_exists (self, UNITY_ALWAYS_SHOW_MENUS_KEY)) |
| 374 | + g_settings_reset (priv->unity_own_settings, UNITY_ALWAYS_SHOW_MENUS_KEY); |
| 375 | + |
| 376 | GtkToggleButton *showdesktop = GTK_TOGGLE_BUTTON (WID ("check_showdesktop_in_launcher")); |
| 377 | gtk_toggle_button_set_active(showdesktop, TRUE); |
| 378 | } |
| 379 | @@ -1914,6 +1958,15 @@ |
| 380 | G_CALLBACK (on_menulocation_changed), self); |
| 381 | menulocation_widget_refresh (self); |
| 382 | |
| 383 | + /* Menu visibility */ |
| 384 | + g_signal_connect (priv->unity_own_settings, "changed::" UNITY_ALWAYS_SHOW_MENUS_KEY, |
| 385 | + G_CALLBACK (ext_menuvisibility_changed_callback), self); |
| 386 | + g_signal_connect (WID ("unity_always_show_menus"), "toggled", |
| 387 | + G_CALLBACK (on_menuvisibility_changed), self); |
| 388 | + g_signal_connect (WID ("unity_auto_hide_menus"), "toggled", |
| 389 | + G_CALLBACK (on_menuvisibility_changed), self); |
| 390 | + menuvisibility_widget_refresh (self); |
| 391 | + |
| 392 | /* Restore defaut on second page */ |
| 393 | g_signal_connect (WID ("button-restore-unitybehavior"), "clicked", |
| 394 | G_CALLBACK (on_restore_defaults_page2_clicked), self); |


Thanks, that seems to do the work!