Handle category additions/removals one by one
This commit is contained in:
parent
d8372a6846
commit
55160de553
@ -1631,8 +1631,7 @@ class pluginclass( object ):
|
|||||||
break
|
break
|
||||||
if not found:
|
if not found:
|
||||||
addedCategories.append(item)
|
addedCategories.append(item)
|
||||||
|
|
||||||
key = 0
|
|
||||||
for item in self.categoryList:
|
for item in self.categoryList:
|
||||||
found = False
|
found = False
|
||||||
for item2 in newCategoryList:
|
for item2 in newCategoryList:
|
||||||
@ -1640,47 +1639,60 @@ class pluginclass( object ):
|
|||||||
found = True
|
found = True
|
||||||
break
|
break
|
||||||
if not found:
|
if not found:
|
||||||
removedCategories.append( key )
|
removedCategories.append( item )
|
||||||
else:
|
|
||||||
key += 1
|
|
||||||
|
|
||||||
if self.showcategoryicons == True:
|
if self.showcategoryicons == True:
|
||||||
categoryIconSize = self.iconSize
|
categoryIconSize = self.iconSize
|
||||||
else:
|
else:
|
||||||
categoryIconSize = 0
|
categoryIconSize = 0
|
||||||
|
|
||||||
for key in removedCategories:
|
for item in removedCategories:
|
||||||
self.categoryList[key]["button"].destroy()
|
try:
|
||||||
del self.categoryList[key]
|
button = item["button"]
|
||||||
|
self.categoryList.remove(item)
|
||||||
|
button.destroy()
|
||||||
|
del item
|
||||||
|
except Exception, e:
|
||||||
|
print e
|
||||||
|
|
||||||
if addedCategories:
|
if addedCategories:
|
||||||
sortedCategoryList = []
|
sortedCategoryList = []
|
||||||
for item in self.categoryList:
|
for item in self.categoryList:
|
||||||
self.categoriesBox.remove( item["button"] )
|
try:
|
||||||
sortedCategoryList.append( ( str(item["index"]) + item["name"], item["button"] ) )
|
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
|
# Create new category buttons and add the to the list
|
||||||
for item in addedCategories:
|
for item in addedCategories:
|
||||||
item["button"] = CategoryButton( item["icon"], categoryIconSize, [ item["name"] ], item["filter"] )
|
try:
|
||||||
self.mintMenuWin.setTooltip( item["button"], item["tooltip"] )
|
item["button"] = CategoryButton( item["icon"], categoryIconSize, [ item["name"] ], item["filter"] )
|
||||||
|
self.mintMenuWin.setTooltip( item["button"], item["tooltip"] )
|
||||||
|
|
||||||
if self.categories_mouse_over:
|
if self.categories_mouse_over:
|
||||||
startId = item["button"].connect( "enter", self.StartFilter, item["filter"] )
|
startId = item["button"].connect( "enter", self.StartFilter, item["filter"] )
|
||||||
stopId = item["button"].connect( "leave", self.StopFilter )
|
stopId = item["button"].connect( "leave", self.StopFilter )
|
||||||
item["button"].mouseOverHandlerIds = ( startId, stopId )
|
item["button"].mouseOverHandlerIds = ( startId, stopId )
|
||||||
else:
|
else:
|
||||||
item["button"].mouseOverHandlerIds = None
|
item["button"].mouseOverHandlerIds = None
|
||||||
|
|
||||||
item["button"].connect( "clicked", self.Filter, item["filter"] )
|
item["button"].connect( "clicked", self.Filter, item["filter"] )
|
||||||
item["button"].connect( "focus-in-event", self.categoryBtnFocus, item["filter"] )
|
item["button"].connect( "focus-in-event", self.categoryBtnFocus, item["filter"] )
|
||||||
item["button"].show()
|
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()
|
sortedCategoryList.sort()
|
||||||
|
|
||||||
for item in sortedCategoryList:
|
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
|
# Find added and removed applications add update the application list
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
|
|
||||||
from gi.repository import Gtk, GdkPixbuf, Gdk, GLib
|
from gi.repository import Gtk, Gdk, GLib
|
||||||
from gi.repository import Pango
|
from gi.repository import Pango
|
||||||
#import matedesktop
|
|
||||||
from gi.repository import GObject
|
from gi.repository import GObject
|
||||||
import os.path
|
import os.path
|
||||||
import shutil
|
import shutil
|
||||||
|
Loading…
Reference in New Issue
Block a user