[gnome-tweak-tool] top_bar: Enable 'appmenu' window button when disabling App Menu



commit 5009c2f87700baa8adb76839d7f441b3ba0ef3a4
Author: Jeremy Bicha <jbicha ubuntu com>
Date:   Sun Jun 11 14:53:02 2017 -0400

    top_bar: Enable 'appmenu' window button when disabling App Menu
    
    The Application Menu switch is supposed to toggle between showing
    the GNOME appmenu in the Top Bar or in the app itself.
    
    The in-app appmenu only works if 'appmenu' is listed in button-layout
    but many Ubuntu users do not have that in their button-layout,
    so turning off Application Menu would completely hide the menu!

 gtweak/tweaks/tweak_group_top_bar.py |   31 +++++++++++++++++++++++++++++--
 1 files changed, 29 insertions(+), 2 deletions(-)
---
diff --git a/gtweak/tweaks/tweak_group_top_bar.py b/gtweak/tweaks/tweak_group_top_bar.py
index 44f33d5..988b8ea 100644
--- a/gtweak/tweaks/tweak_group_top_bar.py
+++ b/gtweak/tweaks/tweak_group_top_bar.py
@@ -18,7 +18,7 @@
 
 import gtweak
 from gtweak.gshellwrapper import GnomeShellFactory
-from gtweak.widgets import ListBoxTweakGroup, GSettingsSwitchTweak, GetterSetterSwitchTweak, Title
+from gtweak.widgets import ListBoxTweakGroup, GSettingsSwitchTweak, GetterSetterSwitchTweak, Title, 
_GSettingsTweak
 from gtweak.utils import XSettingsOverrides
 
 _shell = GnomeShellFactory().get_shell()
@@ -27,7 +27,14 @@ _shell_loaded = _shell is not None
 class ApplicationMenuTweak(GetterSetterSwitchTweak):
     def __init__(self, **options):
         self._xsettings = XSettingsOverrides()
-        GetterSetterSwitchTweak.__init__(self, _("Application Menu"), **options)
+        name = _("Application Menu")
+        GetterSetterSwitchTweak.__init__(self, name, **options)
+
+        _GSettingsTweak.__init__(self,
+                                 name,
+                                 "org.gnome.desktop.wm.preferences",
+                                 "button-layout",
+                                 **options)
 
     def get_active(self):
         return self._xsettings.get_shell_shows_app_menu()
@@ -35,6 +42,26 @@ class ApplicationMenuTweak(GetterSetterSwitchTweak):
     def set_active(self, v):
         self._xsettings.set_shell_shows_app_menu(v)
 
+        if v:
+            return
+        val = self.settings.get_string(self.key_name)
+        (left, colon, right) = val.partition(":")
+
+        if "close" in right:
+            rsplit = right.split(",")
+            rsplit = [x for x in rsplit if x in ["minimize", "maximize", "close"]]
+            rsplit.append("appmenu")
+            rsplit.sort(key=lambda x: ["appmenu", "minimize", "maximize", "close"].index(x))
+            self.settings.set_string(self.key_name, left + colon + ",".join(rsplit))
+
+        else:
+            rsplit = left.split(",")
+            rsplit = [x for x in rsplit if x in ["minimize", "maximize", "close"]]
+            rsplit.append("appmenu")
+            rsplit.sort(key=lambda x: ["close", "minimize", "maximize", "appmenu"].index(x))
+            self.settings.set_string(self.key_name, ",".join(rsplit) + colon + right)
+
+
 TWEAK_GROUPS = [
     ListBoxTweakGroup(_("Top Bar"),
         ApplicationMenuTweak(),


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]