Add option to show search bar on top

This commit is contained in:
gm10 2019-02-11 21:50:37 +01:00
parent 8988476df2
commit 9d2c905c1f
No known key found for this signature in database
GPG Key ID: A981D4EA8CF993A9
5 changed files with 70 additions and 26 deletions

View File

@ -830,30 +830,19 @@
</packing>
</child>
<child>
<object class="GtkLabel" id="label5">
<object class="GtkCheckButton" id="search_on_top">
<property name="label" translatable="yes">Show search bar on top</property>
<property name="visible">True</property>
<property name="can_focus">False</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="label" translatable="yes">Search command:</property>
<property name="draw_indicator">True</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">5</property>
</packing>
</child>
<child>
<object class="GtkEntry" id="search_command">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_STRUCTURE_MASK</property>
<property name="invisible_char">●</property>
<property name="primary_icon_activatable">False</property>
<property name="secondary_icon_activatable">False</property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">5</property>
<property name="width">2</property>
</packing>
</child>
<child>
@ -904,6 +893,33 @@
<property name="width">2</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="search_command_label">
<property name="visible">True</property>
<property name="can_focus">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="label" translatable="yes">Search command:</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">9</property>
</packing>
</child>
<child>
<object class="GtkEntry" id="search_command">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_STRUCTURE_MASK</property>
<property name="invisible_char">●</property>
<property name="primary_icon_activatable">False</property>
<property name="secondary_icon_activatable">False</property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">9</property>
</packing>
</child>
</object>
</child>
</object>

View File

@ -41,6 +41,7 @@ class mintMenuConfig(object):
self.startWithFavorites = self.builder.get_object("startWithFavorites")
self.showAppComments = self.builder.get_object("showAppComments")
self.search_on_top = self.builder.get_object("search_on_top")
self.useAPT = self.builder.get_object("use_apt")
self.showCategoryIcons = self.builder.get_object("showCategoryIcons")
self.showRecentPlugin = self.builder.get_object("showRecentPlugin")
@ -122,6 +123,7 @@ class mintMenuConfig(object):
self.bindGSettingsValueToWidget(self.settings, "bool", "start-with-favorites", self.startWithFavorites, "toggled", self.startWithFavorites.set_active, self.startWithFavorites.get_active)
self.bindGSettingsValueToWidget(self.settingsApplications, "bool", "show-application-comments", self.showAppComments, "toggled", self.showAppComments.set_active, self.showAppComments.get_active)
self.bindGSettingsValueToWidget(self.settingsApplications, "bool", "search-on-top", self.search_on_top, "toggled", self.search_on_top.set_active, self.search_on_top.get_active)
self.bindGSettingsValueToWidget(self.settingsApplications, "bool", "use-apt", self.useAPT, "toggled", self.useAPT.set_active, self.useAPT.get_active)
self.bindGSettingsValueToWidget(self.settingsApplications, "bool", "show-category-icons", self.showCategoryIcons, "toggled", self.showCategoryIcons.set_active, self.showCategoryIcons.get_active)
self.bindGSettingsValueToWidget(self.settingsApplications, "bool", "categories-mouse-over", self.hover, "toggled", self.hover.set_active, self.hover.get_active)

View File

@ -17,7 +17,7 @@
<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="orientation">vertical</property>
@ -180,7 +180,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 +261,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,7 +358,7 @@
</packing>
</child>
<child>
<object class="GtkBox" id="hbox9">
<object class="GtkBox" id="search_bar">
<property name="height_request">30</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
@ -415,7 +415,6 @@
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="pack_type">end</property>
<property name="position">1</property>
</packing>
</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")
@ -181,7 +184,6 @@ class pluginclass(object):
self.favoritesBox = self.builder.get_object("favoritesBox")
self.applicationsScrolledWindow = self.builder.get_object("applicationsScrolledWindow")
self.headingstocolor = [self.builder.get_object("label6"), self.builder.get_object("label2")]
self.numApps = 0
# These properties are NECESSARY to maintain consistency
@ -230,6 +232,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.switch_search_bar_position)
self.settings.notifyAdd("use-apt", self.switchAPTUsage)
self.settings.notifyAdd("fav-cols", self.changeFavCols)
self.settings.notifyAdd("remember-filter", self.changeRememberFilter)
@ -243,6 +246,9 @@ class pluginclass(object):
except Exception as e:
print(e)
# Position search bar
self.position_search_bar()
self.currentFavCol = 0
self.favorites = []
@ -376,6 +382,21 @@ class pluginclass(object):
if isinstance(child, FavApplicationLauncher):
child.setIconSize(self.faviconsize)
def switch_search_bar_position(self, settings, key, args):
self.search_on_top = settings.get_boolean(key)
self.position_search_bar()
def position_search_bar(self):
""" Set search bar position (top/bottom) based on self.search_on_top """
self.main_box.remove(self.notebook)
self.main_box.remove(self.search_bar)
if self.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()
@ -462,6 +483,7 @@ class pluginclass(object):
self.showcategoryicons = self.settings.get("bool", "show-category-icons")
self.categoryhoverdelay = self.settings.get("int", "category-hover-delay")
self.showapplicationcomments = self.settings.get("bool", "show-application-comments")
self.search_on_top = self.settings.get("bool", "search-on-top")
self.useAPT = self.settings.get("bool", "use-apt")
self.rememberFilter = self.settings.get("bool", "remember-filter")
self.enableInternetSearch = self.settings.get("bool", "enable-internet-search")
@ -520,11 +542,10 @@ class pluginclass(object):
self.settings.set("int", "last-active-tab", self.lastActiveTab)
def changeTab(self, tabNum, clear = True):
notebook = self.builder.get_object("notebook2")
if tabNum == 0:
notebook.set_current_page(0)
self.notebook.set_current_page(0)
elif tabNum == 1:
notebook.set_current_page(1)
self.notebook.set_current_page(1)
self.focusSearchEntry(clear)
self.lastActiveTab = tabNum

View File

@ -248,6 +248,12 @@
<description></description>
</key>
<key type="b" name="search-on-top">
<default>false</default>
<summary></summary>
<description></description>
</key>
<key type="b" name="use-apt">
<default>true</default>
<summary></summary>