From 55160de553672534421d3e43d16753e5bf88b219 Mon Sep 17 00:00:00 2001 From: Clement Lefebvre Date: Mon, 25 Nov 2013 16:06:22 +0000 Subject: [PATCH] Handle category additions/removals one by one --- .../mintMenu/plugins/applications.py | 62 +++++++++++-------- .../linuxmint/mintMenu/plugins/easybuttons.py | 3 +- 2 files changed, 38 insertions(+), 27 deletions(-) diff --git a/usr/lib/linuxmint/mintMenu/plugins/applications.py b/usr/lib/linuxmint/mintMenu/plugins/applications.py index 56969e1..c41ebcf 100755 --- a/usr/lib/linuxmint/mintMenu/plugins/applications.py +++ b/usr/lib/linuxmint/mintMenu/plugins/applications.py @@ -1631,8 +1631,7 @@ class pluginclass( object ): break if not found: addedCategories.append(item) - - key = 0 + for item in self.categoryList: found = False for item2 in newCategoryList: @@ -1640,47 +1639,60 @@ class pluginclass( object ): found = True break if not found: - removedCategories.append( key ) - else: - key += 1 + removedCategories.append( item ) if self.showcategoryicons == True: categoryIconSize = self.iconSize else: categoryIconSize = 0 - - for key in removedCategories: - self.categoryList[key]["button"].destroy() - del self.categoryList[key] + + for item in removedCategories: + try: + button = item["button"] + self.categoryList.remove(item) + button.destroy() + del item + except Exception, e: + print e if addedCategories: sortedCategoryList = [] for item in self.categoryList: - self.categoriesBox.remove( item["button"] ) - sortedCategoryList.append( ( str(item["index"]) + item["name"], item["button"] ) ) + try: + self.categoriesBox.remove( item["button"] ) + sortedCategoryList.append( ( str(item["index"]) + item["name"], item["button"] ) ) + except Exception, e: + print e # Create new category buttons and add the to the list for item in addedCategories: - item["button"] = CategoryButton( item["icon"], categoryIconSize, [ item["name"] ], item["filter"] ) - self.mintMenuWin.setTooltip( item["button"], item["tooltip"] ) + try: + item["button"] = CategoryButton( item["icon"], categoryIconSize, [ item["name"] ], item["filter"] ) + self.mintMenuWin.setTooltip( item["button"], item["tooltip"] ) - if self.categories_mouse_over: - startId = item["button"].connect( "enter", self.StartFilter, item["filter"] ) - stopId = item["button"].connect( "leave", self.StopFilter ) - item["button"].mouseOverHandlerIds = ( startId, stopId ) - else: - item["button"].mouseOverHandlerIds = None + if self.categories_mouse_over: + startId = item["button"].connect( "enter", self.StartFilter, item["filter"] ) + stopId = item["button"].connect( "leave", self.StopFilter ) + item["button"].mouseOverHandlerIds = ( startId, stopId ) + else: + item["button"].mouseOverHandlerIds = None - item["button"].connect( "clicked", self.Filter, item["filter"] ) - item["button"].connect( "focus-in-event", self.categoryBtnFocus, item["filter"] ) - item["button"].show() + item["button"].connect( "clicked", self.Filter, item["filter"] ) + item["button"].connect( "focus-in-event", self.categoryBtnFocus, item["filter"] ) + item["button"].show() + + self.categoryList.append( item ) + sortedCategoryList.append( ( str(item["index"]) + item["name"], item["button"] ) ) + except Exception, e: + print e - self.categoryList.append( item ) - sortedCategoryList.append( ( str(item["index"]) + item["name"], item["button"] ) ) sortedCategoryList.sort() for item in sortedCategoryList: - self.categoriesBox.pack_start( item[1], False, False, 0 ) + try: + self.categoriesBox.pack_start( item[1], False, False, 0 ) + except Exception, e: + print e # Find added and removed applications add update the application list diff --git a/usr/lib/linuxmint/mintMenu/plugins/easybuttons.py b/usr/lib/linuxmint/mintMenu/plugins/easybuttons.py index 1898b23..9da9c0c 100755 --- a/usr/lib/linuxmint/mintMenu/plugins/easybuttons.py +++ b/usr/lib/linuxmint/mintMenu/plugins/easybuttons.py @@ -1,8 +1,7 @@ #!/usr/bin/env python -from gi.repository import Gtk, GdkPixbuf, Gdk, GLib +from gi.repository import Gtk, Gdk, GLib from gi.repository import Pango -#import matedesktop from gi.repository import GObject import os.path import shutil