From 476cf29d38fed4889767a8a9f9712babd354ad1f Mon Sep 17 00:00:00 2001 From: Clement Lefebvre Date: Tue, 14 May 2019 17:15:42 +0100 Subject: [PATCH] Add option to show search bar on top Ported from https://github.com/linuxmint/mintmenu/pull/221 --- usr/lib/linuxmint/mintMenu/mintMenuConfig.glade | 16 ++++++++++++++++ usr/lib/linuxmint/mintMenu/mintMenuConfig.py | 7 ++++--- .../mintMenu/plugins/applications.glade | 11 ++++++----- .../linuxmint/mintMenu/plugins/applications.py | 16 ++++++++++++++++ .../schemas/com.linuxmint.mintmenu.gschema.xml | 6 ++++++ 5 files changed, 48 insertions(+), 8 deletions(-) diff --git a/usr/lib/linuxmint/mintMenu/mintMenuConfig.glade b/usr/lib/linuxmint/mintMenu/mintMenuConfig.glade index 0e1cf81..ec2ba76 100644 --- a/usr/lib/linuxmint/mintMenu/mintMenuConfig.glade +++ b/usr/lib/linuxmint/mintMenu/mintMenuConfig.glade @@ -885,6 +885,22 @@ 2 + + + Show search bar on top + True + True + False + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + start + True + + + 0 + 9 + 2 + + diff --git a/usr/lib/linuxmint/mintMenu/mintMenuConfig.py b/usr/lib/linuxmint/mintMenu/mintMenuConfig.py index 0a3d6cd..4f6175c 100755 --- a/usr/lib/linuxmint/mintMenu/mintMenuConfig.py +++ b/usr/lib/linuxmint/mintMenu/mintMenuConfig.py @@ -49,6 +49,7 @@ class mintMenuConfig(object): self.showPlacesPlugin = self.builder.get_object("showPlacesPlugin") self.showTooltips = self.builder.get_object("showToolTips") + self.showSearchOnTop = self.builder.get_object("showSearchOnTop") self.swapGeneric = self.builder.get_object("swapGeneric") self.hover = self.builder.get_object("hover") @@ -137,6 +138,8 @@ class mintMenuConfig(object): self.bindGSettingsValueToWidget(self.settingsApplications, "int", "fav-cols", self.favCols, "value-changed", self.favCols.set_value, self.favCols.get_value) self.bindGSettingsValueToWidget(self.settingsApplications, "bool", "remember-filter", self.rememberFilter, "toggled", self.rememberFilter.set_active, self.rememberFilter.get_active) self.bindGSettingsValueToWidget(self.settingsApplications, "bool", "enable-internet-search", self.enableInternetSearch, "toggled", self.enableInternetSearch.set_active, self.enableInternetSearch.get_active) + self.bindGSettingsValueToWidget(self.settingsApplications, "string", "search-command", self.searchCommand, "changed", self.searchCommand.set_text, self.searchCommand.get_text) + self.bindGSettingsValueToWidget(self.settingsApplications, "bool", "search-on-top", self.showSearchOnTop, "toggled", self.showSearchOnTop.set_active, self.showSearchOnTop.get_active) self.bindGSettingsValueToWidget(self.settingsPlaces, "int", "icon-size", self.placesIconSize, "value-changed", self.placesIconSize.set_value, self.placesIconSize.get_value) self.bindGSettingsValueToWidget(self.settingsSystem, "int", "icon-size", self.systemIconSize, "value-changed", self.systemIconSize.set_value, self.systemIconSize.get_value) @@ -148,7 +151,7 @@ class mintMenuConfig(object): self.bindGSettingsValueToWidget(self.settings, "string", "applet-text", self.buttonText, "changed", self.buttonText.set_text, self.buttonText.get_text) self.bindGSettingsValueToWidget(self.settings, "string", "hot-key", self.hotkeyWidget, "accel-edited", self.hotkeyWidget.set_val, self.hotkeyWidget.get_val) self.bindGSettingsValueToWidget(self.settings, "string", "applet-icon", self.buttonIconChooser, "file-set", self.setButtonIcon, self.buttonIconChooser.get_filename) - self.bindGSettingsValueToWidget(self.settingsApplications, "string", "search-command", self.searchCommand, "changed", self.searchCommand.set_text, self.searchCommand.get_text) + self.bindGSettingsValueToWidget(self.settings, "bool", "tooltips-enabled", self.showTooltips, "toggled", self.showTooltips.set_active, self.showTooltips.get_active) self.getPluginsToggle() self.showRecentPlugin.connect("toggled", self.setPluginsLayout) @@ -156,8 +159,6 @@ class mintMenuConfig(object): self.showSystemPlugin.connect("toggled", self.setPluginsLayout) self.showPlacesPlugin.connect("toggled", self.setPluginsLayout) - self.bindGSettingsValueToWidget(self.settings, "bool", "tooltips-enabled", self.showTooltips, "toggled", self.showTooltips.set_active, self.showTooltips.get_active) - self.bindGSettingsValueToWidget(self.settingsPlaces, "bool", "show-computer", self.computertoggle, "toggled", self.computertoggle.set_active, self.computertoggle.get_active) self.bindGSettingsValueToWidget(self.settingsPlaces, "bool", "show-home-folder", self.homefoldertoggle, "toggled", self.homefoldertoggle.set_active, self.homefoldertoggle.get_active) self.bindGSettingsValueToWidget(self.settingsPlaces, "bool", "show-network", self.networktoggle, "toggled", self.networktoggle.set_active, self.networktoggle.get_active) diff --git a/usr/lib/linuxmint/mintMenu/plugins/applications.glade b/usr/lib/linuxmint/mintMenu/plugins/applications.glade index f74ec29..8f901c2 100644 --- a/usr/lib/linuxmint/mintMenu/plugins/applications.glade +++ b/usr/lib/linuxmint/mintMenu/plugins/applications.glade @@ -17,9 +17,10 @@ True False - + True False + 3 vertical @@ -180,7 +181,7 @@ vertical 3 - + True False True @@ -261,7 +262,7 @@ - + True False @@ -358,8 +359,8 @@ - - 30 + + 20 True False diff --git a/usr/lib/linuxmint/mintMenu/plugins/applications.py b/usr/lib/linuxmint/mintMenu/plugins/applications.py index e3c5076..cacaca9 100755 --- a/usr/lib/linuxmint/mintMenu/plugins/applications.py +++ b/usr/lib/linuxmint/mintMenu/plugins/applications.py @@ -172,6 +172,9 @@ class pluginclass(object): self.builder.add_from_file (os.path.join(os.path.dirname(__file__), "applications.glade")) # Read GLADE file + self.main_box = self.builder.get_object("main_box") + self.notebook = self.builder.get_object("notebook2") + self.search_bar = self.builder.get_object("search_bar") self.searchEntry = self.builder.get_object("searchEntry") self.searchButton = self.builder.get_object("searchButton") self.showAllAppsButton = self.builder.get_object("showAllAppsButton") @@ -230,6 +233,7 @@ class pluginclass(object): self.settings.notifyAdd("swap-generic-name", self.changeSwapGenericName) self.settings.notifyAdd("show-category-icons", self.changeShowCategoryIcons) self.settings.notifyAdd("show-application-comments", self.changeShowApplicationComments) + self.settings.notifyAdd("search-on-top", self.positionSearchBar) self.settings.notifyAdd("use-apt", self.switchAPTUsage) self.settings.notifyAdd("fav-cols", self.changeFavCols) self.settings.notifyAdd("remember-filter", self.changeRememberFilter) @@ -243,6 +247,8 @@ class pluginclass(object): except Exception as e: print(e) + self.positionSearchBar() + self.currentFavCol = 0 self.favorites = [] @@ -380,6 +386,16 @@ class pluginclass(object): if isinstance(child, FavApplicationLauncher): child.setIconSize(self.faviconsize) + def positionSearchBar(self, settings=None, key=None, args=None): + self.main_box.remove(self.notebook) + self.main_box.remove(self.search_bar) + if self.settings.get("bool", "search-on-top"): + self.main_box.pack_start(self.search_bar, False, False, 0) + self.main_box.pack_start(self.notebook, True, True, 0) + else: + self.main_box.pack_start(self.notebook, True, True, 0) + self.main_box.pack_start(self.search_bar, False, False, 0) + def switchAPTUsage(self, settings, key, args): self.useAPT = settings.get_boolean(key) self.refresh_apt_cache() diff --git a/usr/share/glib-2.0/schemas/com.linuxmint.mintmenu.gschema.xml b/usr/share/glib-2.0/schemas/com.linuxmint.mintmenu.gschema.xml index 95f078c..124f180 100644 --- a/usr/share/glib-2.0/schemas/com.linuxmint.mintmenu.gschema.xml +++ b/usr/share/glib-2.0/schemas/com.linuxmint.mintmenu.gschema.xml @@ -307,6 +307,12 @@ + + + false + + +