Handle category additions/removals one by one

This commit is contained in:
Clement Lefebvre 2013-11-25 16:06:22 +00:00
parent d8372a6846
commit 55160de553
2 changed files with 38 additions and 27 deletions

View File

@ -1632,7 +1632,6 @@ class pluginclass( object ):
if not found:
addedCategories.append(item)
key = 0
for item in self.categoryList:
found = False
for item2 in newCategoryList:
@ -1640,27 +1639,34 @@ 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:
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:
try:
item["button"] = CategoryButton( item["icon"], categoryIconSize, [ item["name"] ], item["filter"] )
self.mintMenuWin.setTooltip( item["button"], item["tooltip"] )
@ -1677,10 +1683,16 @@ class pluginclass( object ):
self.categoryList.append( item )
sortedCategoryList.append( ( str(item["index"]) + item["name"], item["button"] ) )
except Exception, e:
print e
sortedCategoryList.sort()
for item in sortedCategoryList:
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

View File

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