Add option to show search bar on top

Ported from https://github.com/linuxmint/mintmenu/pull/221
This commit is contained in:
Clement Lefebvre 2019-05-14 17:15:42 +01:00
parent 1984d57525
commit 476cf29d38
5 changed files with 48 additions and 8 deletions

View File

@ -885,6 +885,22 @@
<property name="width">2</property>
</packing>
</child>
<child>
<object class="GtkCheckButton" id="showSearchOnTop">
<property name="label" translatable="yes">Show search bar on top</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="halign">start</property>
<property name="draw_indicator">True</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">9</property>
<property name="width">2</property>
</packing>
</child>
</object>
</child>
</object>

View File

@ -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)

View File

@ -17,9 +17,10 @@
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<object class="GtkBox" id="vbox4">
<object class="GtkBox" id="main_box">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="border_width">3</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkNotebook" id="notebook2">
@ -180,7 +181,7 @@
<property name="orientation">vertical</property>
<property name="spacing">3</property>
<child>
<object class="GtkBox" id="hbox3">
<object class="GtkBox" id="title_bar">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="homogeneous">True</property>
@ -261,7 +262,7 @@
</packing>
</child>
<child>
<object class="GtkBox" id="hbox5">
<object class="GtkBox" id="applications">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
@ -358,8 +359,8 @@
</packing>
</child>
<child>
<object class="GtkBox" id="hbox9">
<property name="height_request">30</property>
<object class="GtkBox" id="search_bar">
<property name="height_request">20</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>

View File

@ -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()

View File

@ -307,6 +307,12 @@
<summary></summary>
<description></description>
</key>
<key type="b" name="search-on-top">
<default>false</default>
<summary></summary>
<description></description>
</key>
</schema>
<schema id="com.linuxmint.mintmenu.plugins.system_management" path="/com/linuxmint/mintmenu/plugins/system_management/">