From 2f1329de7d6e5444234ac515d3ab6ed339c39c4a Mon Sep 17 00:00:00 2001 From: gm10 <13855078+gm10@users.noreply.github.com> Date: Mon, 21 Jan 2019 16:37:01 +0100 Subject: [PATCH] Applications: Fix keypress event handler (#205) * Applications: Fix keypress event handler * further fix and simplify the keypress handler * disconnect the keyPress handler when destroying the plugin --- .../mintMenu/plugins/applications.py | 26 ++++++------------- 1 file changed, 8 insertions(+), 18 deletions(-) diff --git a/usr/lib/linuxmint/mintMenu/plugins/applications.py b/usr/lib/linuxmint/mintMenu/plugins/applications.py index c6f588c..9508af5 100755 --- a/usr/lib/linuxmint/mintMenu/plugins/applications.py +++ b/usr/lib/linuxmint/mintMenu/plugins/applications.py @@ -215,7 +215,7 @@ class pluginclass( object ): self.filterTimer = None self.menuChangedTimer = None # Hookup for text input - self.content_holder.connect( "key-press-event", self.keyPress ) + self.keyPress_handler = self.mintMenuWin.window.connect( "key-press-event", self.keyPress ) self.favoritesBox.connect( "drag-data-received", self.ReceiveCallback ) @@ -250,7 +250,7 @@ class pluginclass( object ): print detail self.currentFavCol = 0 self.favorites = [] - + self.content_holder.set_size_request( self.width, self.height ) self.categoriesBox.set_size_request( self.width / 3, -1 ) self.applicationsBox.set_size_request( self.width / 2, -1 ) @@ -283,7 +283,7 @@ class pluginclass( object ): self.icon_theme = Gtk.IconTheme.get_default(); self.icon_theme.connect("changed", self.on_icon_theme_changed) - + def refresh_apt_cache(self): if self.useAPT: os.system("mkdir -p %s/.linuxmint/mintMenu/" % home) @@ -324,6 +324,8 @@ class pluginclass( object ): self.categoriesBox.destroy() self.favoritesBox.destroy() + self.mintMenuWin.window.disconnect(self.keyPress_handler) + self.settings.notifyRemoveAll() def changePluginSize( self, settings, key, args ): @@ -843,23 +845,11 @@ class pluginclass( object ): self.searchEntry.set_text( "" ) self.Filter( widget, category ) - # Forward all text to the search box def keyPress( self, widget, event ): - - if event.string.strip() != "" or event.keyval == Gdk.KEY_BackSpace: - self.searchEntry.grab_focus() - self.searchEntry.set_position( -1 ) + """ Forward all text to the search box """ + if event.string.strip() or event.keyval == Gdk.KEY_space: self.searchEntry.event( event ) return True - - - if event.keyval == Gdk.KEY_space: - self.searchEntry.event( event ) - return True - - if event.keyval == Gdk.KEY_Down and self.searchEntry.is_focus(): - self.applicationsBox.get_children()[0].grab_focus() - return False def favPopup( self, widget, event ): @@ -1481,7 +1471,7 @@ class pluginclass( object ): self.favoritesReorder( favButton.position, position ) self.favoritesSave() - + def favoritesRemove( self, position ): tmp = self.favorites[ position ] self.favorites.remove( self.favorites[ position ] )