From 84aa87727f6341a441fb1e5cb32e3bbe857e44a5 Mon Sep 17 00:00:00 2001 From: Michael Webster Date: Sat, 20 Apr 2013 19:19:32 -0400 Subject: [PATCH] Add option to remember last category or search when reopening the menu (default to true, which was previous behavior). --- .../linuxmint/mintMenu/mintMenuConfig.glade | 21 +++++++++++++++- usr/lib/linuxmint/mintMenu/mintMenuConfig.py | 3 +++ .../mintMenu/plugins/applications.py | 24 ++++++++++++++----- .../com.linuxmint.mintmenu.gschema.xml | 6 +++++ 4 files changed, 47 insertions(+), 7 deletions(-) diff --git a/usr/lib/linuxmint/mintMenu/mintMenuConfig.glade b/usr/lib/linuxmint/mintMenu/mintMenuConfig.glade index bad374e..3c62fd5 100644 --- a/usr/lib/linuxmint/mintMenu/mintMenuConfig.glade +++ b/usr/lib/linuxmint/mintMenu/mintMenuConfig.glade @@ -958,7 +958,7 @@ True False GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - 7 + 8 2 5 True @@ -1146,6 +1146,25 @@ 5 + + + Remember the last category or search + True + True + False + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + False + True + + + 2 + 7 + 8 + GTK_FILL + + 5 + + diff --git a/usr/lib/linuxmint/mintMenu/mintMenuConfig.py b/usr/lib/linuxmint/mintMenu/mintMenuConfig.py index 382486a..fc453b4 100755 --- a/usr/lib/linuxmint/mintMenu/mintMenuConfig.py +++ b/usr/lib/linuxmint/mintMenu/mintMenuConfig.py @@ -54,6 +54,7 @@ class mintMenuConfig( object ): self.builder.get_object("showAppComments").set_label(_("Show application comments")) self.builder.get_object("showCategoryIcons").set_label(_("Show category icons")) self.builder.get_object("hover").set_label(_("Hover")) + self.builder.get_object("remember_filter").set_label(_("Remember the last category or search")) self.builder.get_object("use_apt").set_label(_("Search for packages to install")) self.builder.get_object("swapGeneric").set_label(_("Swap name and generic name")) @@ -126,6 +127,7 @@ class mintMenuConfig( object ): self.swapGeneric = self.builder.get_object("swapGeneric") self.hover = self.builder.get_object( "hover" ) self.hoverDelay = self.builder.get_object( "hoverDelay" ) + self.rememberFilter = self.builder.get_object( "remember_filter" ) self.iconSize = self.builder.get_object( "iconSize" ) self.favIconSize = self.builder.get_object( "favIconSize" ) self.placesIconSize = self.builder.get_object( "placesIconSize" ) @@ -210,6 +212,7 @@ class mintMenuConfig( object ): self.bindGSettingsValueToWidget( self.settingsApplications, "int", "icon-size", self.iconSize, "value-changed", self.iconSize.set_value, self.iconSize.get_value ) self.bindGSettingsValueToWidget( self.settingsApplications, "int", "favicon-size", self.favIconSize, "value-changed", self.favIconSize.set_value, self.favIconSize.get_value ) 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.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 ) diff --git a/usr/lib/linuxmint/mintMenu/plugins/applications.py b/usr/lib/linuxmint/mintMenu/plugins/applications.py index 586f5d6..b0eae5c 100755 --- a/usr/lib/linuxmint/mintMenu/plugins/applications.py +++ b/usr/lib/linuxmint/mintMenu/plugins/applications.py @@ -297,6 +297,7 @@ class pluginclass( object ): self.settings.notifyAdd( "show-application-comments", self.changeShowApplicationComments ) self.settings.notifyAdd( "use-apt", self.switchAPTUsage) self.settings.notifyAdd( "fav-cols", self.changeFavCols ) + self.settings.notifyAdd( "remember-filter", self.changeRememberFilter) self.settings.bindGSettingsEntryToVar( "int", "category-hover-delay", self, "categoryhoverdelay" ) self.settings.bindGSettingsEntryToVar( "bool", "do-not-filter", self, "donotfilterapps" ) @@ -322,7 +323,7 @@ class pluginclass( object ): self.drag_origin = None self.rebuildLock = False - self.activeFilter = (1, "") + self.activeFilter = (1, "", self.searchEntry) self.adminMenu = None @@ -443,6 +444,9 @@ class pluginclass( object ): self.useAPT = settings.get_boolean(key) self.refresh_apt_cache() + def changeRememberFilter( self, settings, key, args): + self.rememberFilter = settings.get_boolean(key) + def changeShowApplicationComments( self, settings, key, args ): self.showapplicationcomments = settings.get_boolean(key) for child in self.applicationsBox: @@ -502,6 +506,7 @@ class pluginclass( object ): self.categoryhoverdelay = self.settings.get( "int", "category-hover-delay") self.showapplicationcomments = self.settings.get( "bool", "show-application-comments") self.useAPT = self.settings.get( "bool", "use-apt") + self.rememberFilter = self.settings.get( "bool", "remember-filter") self.lastActiveTab = self.settings.get( "int", "last-active-tab") self.defaultTab = self.settings.get( "int", "default-tab") @@ -553,6 +558,10 @@ class pluginclass( object ): self.changeTab( 1 ) self.searchEntry.select_region( 0, -1 ) + if self.rememberFilter: + self.Filter(self.activeFilter[2], self.activeFilter[1]) + else: + self.Filter(self.searchEntry, "") def onHideMenu( self ): self.settings.set( "int", "last-active-tab", self.lastActiveTab ) @@ -565,7 +574,6 @@ class pluginclass( object ): notebook.set_current_page( 1 ) self.lastActiveTab = tabNum - self.focusSearchEntry() def Todos( self ): @@ -581,7 +589,10 @@ class pluginclass( object ): # restoring the original selection is somehow broken, so just select the end # of the existing text, that's the most likely candidate anyhow self.searchEntry.grab_focus() - gtk.gtk_editable_set_position(hash(self.searchEntry), -1) + if self.rememberFilter: + gtk.gtk_editable_set_position(hash(self.searchEntry), -1) + else: + self.searchEntry.set_text("") def buildButtonList( self ): if self.buildingButtonList: @@ -800,7 +811,8 @@ class pluginclass( object ): if self.donotfilterapps: widget.set_text( "" ) else: - self.changeTab( 1 ) + if self.lastActiveTab != 1: + self.changeTab( 1 ) text = widget.get_text() showns = False # Are any app shown? for i in self.applicationsBox.get_children(): @@ -835,10 +847,10 @@ class pluginclass( object ): allButton = self.categoriesBox.get_children()[0]; allButton.set_relief( Gtk.ReliefStyle.HALF ) - self.activeFilter = (0, text) + self.activeFilter = (0, text, widget) else: #print "CATFILTER" - self.activeFilter = (1, category) + self.activeFilter = (1, category, widget) if category == "": listedDesktopFiles = [] for i in self.applicationsBox.get_children(): 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 c11e00d..f6a0488 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 @@ -313,6 +313,12 @@ + + + true + + +