Highlight newly installed applications
This commit is contained in:
parent
b6f3353305
commit
ec963baeab
1
debian/changelog
vendored
1
debian/changelog
vendored
@ -5,6 +5,7 @@ mintmenu (5.0.6) julia; urgency=low
|
||||
* 150ms default hover delay
|
||||
* Fixed empty application list bug
|
||||
* Fixed mouse grab issue
|
||||
* Highlights newly installed applications
|
||||
|
||||
-- Clement Lefebvre <root@linuxmint.com> Mon, 13 Sep 2010 12:09:00 +0000
|
||||
|
||||
|
@ -222,7 +222,6 @@ class pluginclass( object ):
|
||||
|
||||
@print_timing
|
||||
def __init__( self, mintMenuWin, toggleButton ):
|
||||
os.system("echo `date` > /var/tmp/mintmenu.log")
|
||||
self.apt_cache = None
|
||||
try:
|
||||
self.apt_cache = apt.Cache()
|
||||
@ -587,7 +586,6 @@ class pluginclass( object ):
|
||||
self.searchEntry.select_region( sel[0], sel[1] )
|
||||
|
||||
def buildButtonList( self ):
|
||||
os.system("echo buildButtonList >> /var/tmp/mintmenu.log")
|
||||
if self.buildingButtonList:
|
||||
self.stopBuildingButtonList = True
|
||||
gobject.timeout_add( 100, self.buildButtonList )
|
||||
@ -595,7 +593,7 @@ class pluginclass( object ):
|
||||
|
||||
self.stopBuildingButtonList = False
|
||||
|
||||
self.updateBoxes()
|
||||
self.updateBoxes(False)
|
||||
|
||||
def categoryBtnFocus( self, widget, event, category ):
|
||||
self.scrollItemIntoView( widget )
|
||||
@ -1556,34 +1554,28 @@ class pluginclass( object ):
|
||||
if self.menuChangedTimer:
|
||||
gobject.source_remove( self.menuChangedTimer )
|
||||
|
||||
self.menuChangedTimer = gobject.timeout_add( 100, self.updateBoxes )
|
||||
self.menuChangedTimer = gobject.timeout_add( 100, self.updateBoxes, True )
|
||||
|
||||
def updateBoxes( self ):
|
||||
os.system("echo updateboxes >> /var/tmp/mintmenu.log")
|
||||
def updateBoxes( self, menu_has_changed ):
|
||||
# FIXME: This is really bad!
|
||||
if self.rebuildLock:
|
||||
os.system("echo rebuildLock >> /var/tmp/mintmenu.log")
|
||||
return
|
||||
|
||||
self.rebuildLock = True
|
||||
|
||||
self.menuChangedTimer = None
|
||||
|
||||
os.system("echo step1 >> /var/tmp/mintmenu.log")
|
||||
self.loadMenuFiles()
|
||||
os.system("echo step2 >> /var/tmp/mintmenu.log")
|
||||
|
||||
# Find added and removed categories than update the category list
|
||||
newCategoryList = self.buildCategoryList()
|
||||
os.system("echo \"%d categories\" >> /var/tmp/mintmenu.log" % len(newCategoryList))
|
||||
addedCategories = []
|
||||
removedCategories = []
|
||||
|
||||
# TODO: optimize this!!!
|
||||
if not self.categoryList:
|
||||
os.system("echo a >> /var/tmp/mintmenu.log")
|
||||
addedCategories = newCategoryList
|
||||
else:
|
||||
os.system("echo b >> /var/tmp/mintmenu.log")
|
||||
for item in newCategoryList:
|
||||
found = False
|
||||
for item2 in self.categoryList:
|
||||
@ -1611,17 +1603,12 @@ class pluginclass( object ):
|
||||
else:
|
||||
categoryIconSize = 0
|
||||
|
||||
os.system("echo c >> /var/tmp/mintmenu.log")
|
||||
|
||||
for key in removedCategories:
|
||||
self.categoryList[key]["button"].destroy()
|
||||
del self.categoryList[key]
|
||||
|
||||
os.system("echo d >> /var/tmp/mintmenu.log")
|
||||
|
||||
if addedCategories:
|
||||
sortedCategoryList = []
|
||||
os.system("echo e >> /var/tmp/mintmenu.log")
|
||||
for item in self.categoryList:
|
||||
self.categoriesBox.remove( item["button"] )
|
||||
sortedCategoryList.append( ( str(item["index"]) + item["name"], item["button"] ) )
|
||||
@ -1642,10 +1629,8 @@ class pluginclass( object ):
|
||||
|
||||
self.categoryList.append( item )
|
||||
sortedCategoryList.append( ( str(item["index"]) + item["name"], item["button"] ) )
|
||||
os.system("echo f >> /var/tmp/mintmenu.log")
|
||||
sortedCategoryList.sort()
|
||||
|
||||
os.system("echo g >> /var/tmp/mintmenu.log")
|
||||
for item in sortedCategoryList:
|
||||
self.categoriesBox.pack_start( item[1], False )
|
||||
|
||||
@ -1655,13 +1640,10 @@ class pluginclass( object ):
|
||||
addedApplications = []
|
||||
removedApplications = []
|
||||
|
||||
os.system("echo h >> /var/tmp/mintmenu.log")
|
||||
# TODO: optimize this!!!
|
||||
if not self.applicationList:
|
||||
os.system("echo i >> /var/tmp/mintmenu.log")
|
||||
addedApplications = newApplicationList
|
||||
else:
|
||||
os.system("echo j >> /var/tmp/mintmenu.log")
|
||||
for item in newApplicationList:
|
||||
found = False
|
||||
for item2 in self.applicationList:
|
||||
@ -1685,25 +1667,22 @@ class pluginclass( object ):
|
||||
# because when it is removed the index of all later items is
|
||||
# going to be decreased
|
||||
key += 1
|
||||
os.system("echo k >> /var/tmp/mintmenu.log")
|
||||
|
||||
for key in removedApplications:
|
||||
self.applicationList[key]["button"].destroy()
|
||||
del self.applicationList[key]
|
||||
os.system("echo l >> /var/tmp/mintmenu.log")
|
||||
if addedApplications:
|
||||
sortedApplicationList = []
|
||||
for item in self.applicationList:
|
||||
self.applicationsBox.remove( item["button"] )
|
||||
sortedApplicationList.append( ( item["button"].appName, item["button"] ) )
|
||||
os.system("echo \"%d added apps\" >> /var/tmp/mintmenu.log" % len(addedApplications))
|
||||
for item in addedApplications:
|
||||
item["button"] = MenuApplicationLauncher( item["entry"].get_desktop_file_path(), self.iconSize, item["category"], self.showapplicationcomments )
|
||||
item["button"] = MenuApplicationLauncher( item["entry"].get_desktop_file_path(), self.iconSize, item["category"], self.showapplicationcomments, highlight=(True and menu_has_changed) )
|
||||
if item["button"].appExec:
|
||||
self.mintMenuWin.setTooltip( item["button"], item["button"].getTooltip() )
|
||||
item["button"].connect( "button-release-event", self.menuPopup )
|
||||
item["button"].connect( "focus-in-event", self.scrollItemIntoView )
|
||||
item["button"].connect( "clicked", lambda w: self.mintMenuWin.hide() )
|
||||
os.system("echo \"%s '%s' filter\" >> /var/tmp/mintmenu.log" % (self.activeFilter[0], self.activeFilter[1]))
|
||||
if self.activeFilter[0] == 0:
|
||||
item["button"].filterText( self.activeFilter[1] )
|
||||
else:
|
||||
@ -1715,13 +1694,10 @@ class pluginclass( object ):
|
||||
|
||||
|
||||
sortedApplicationList.sort()
|
||||
os.system("echo \"%d apps\" >> /var/tmp/mintmenu.log" % len(sortedApplicationList))
|
||||
for item in sortedApplicationList:
|
||||
self.applicationsBox.pack_start( item[1], False )
|
||||
|
||||
self.rebuildLock = False
|
||||
os.system("echo fin >> /var/tmp/mintmenu.log")
|
||||
|
||||
|
||||
# Reload the menufiles from the filesystem
|
||||
def loadMenuFiles( self ):
|
||||
|
@ -12,7 +12,7 @@ from execute import *
|
||||
import xdg.DesktopEntry
|
||||
import xdg.Menu
|
||||
from filemonitor import monitor as filemonitor
|
||||
|
||||
import glib
|
||||
|
||||
|
||||
class IconManager(gobject.GObject):
|
||||
@ -102,7 +102,7 @@ class IconManager(gobject.GObject):
|
||||
|
||||
return icon
|
||||
except Exception, e:
|
||||
print "Excpetion " + e.__class__.__name__ + ": " + e.message
|
||||
print "Exception " + e.__class__.__name__ + ": " + e.message
|
||||
return None
|
||||
|
||||
def getIconSize( self, iconSize ):
|
||||
@ -154,7 +154,6 @@ class easyButton( gtk.Button ):
|
||||
self.buttonImage.show()
|
||||
HBox1.pack_start( self.buttonImage, False, False, 5 )
|
||||
|
||||
|
||||
if labels:
|
||||
for label in labels:
|
||||
if isinstance( label, basestring ):
|
||||
@ -189,7 +188,11 @@ class easyButton( gtk.Button ):
|
||||
|
||||
|
||||
def addLabel( self, text, styles = None ):
|
||||
label = gtk.Label( text )
|
||||
label = gtk.Label()
|
||||
if "<b>" in text:
|
||||
label.set_markup(text) # don't remove our pango
|
||||
else:
|
||||
label.set_markup(glib.markup_escape_text(text))
|
||||
|
||||
if styles:
|
||||
labelStyle = pango.AttrList()
|
||||
@ -246,7 +249,7 @@ class easyButton( gtk.Button ):
|
||||
|
||||
class ApplicationLauncher( easyButton ):
|
||||
|
||||
def __init__( self, desktopFile, iconSize ):
|
||||
def __init__( self, desktopFile, iconSize):
|
||||
|
||||
if isinstance( desktopFile, xdg.Menu.MenuEntry ):
|
||||
desktopItem = desktopFile.DesktopEntry
|
||||
@ -482,10 +485,11 @@ class ApplicationLauncher( easyButton ):
|
||||
|
||||
class MenuApplicationLauncher( ApplicationLauncher ):
|
||||
|
||||
def __init__( self, desktopFile, iconSize, category, showComment ):
|
||||
def __init__( self, desktopFile, iconSize, category, showComment, highlight=False ):
|
||||
|
||||
self.showComment = showComment
|
||||
self.appCategory = category
|
||||
self.highlight = highlight
|
||||
|
||||
ApplicationLauncher.__init__( self, desktopFile, iconSize )
|
||||
|
||||
@ -497,15 +501,37 @@ class MenuApplicationLauncher( ApplicationLauncher ):
|
||||
self.hide()
|
||||
|
||||
def setupLabels( self ):
|
||||
appName = self.appName
|
||||
appComment = self.appComment
|
||||
if self.highlight:
|
||||
try:
|
||||
color = self.labelBox.rc_get_style().fg[ gtk.STATE_SELECTED ].to_string()
|
||||
if len(color) > 0 and color[0] == "#":
|
||||
appName = "<span foreground=\"%s\"><b>%s</b></span>" % (color, appName);
|
||||
appComment = "<span foreground=\"%s\"><b>%s</b></span>" % (color, appComment);
|
||||
else:
|
||||
appName = "<b>%s</b>" % (appName);
|
||||
appComment = "<b>%s</b>" % (appComment);
|
||||
except Exception, detail:
|
||||
print detail
|
||||
pass
|
||||
|
||||
if self.showComment and self.appComment != "":
|
||||
if self.iconSize <= 2:
|
||||
self.addLabel( self.appName, [ pango.AttrScale( pango.SCALE_SMALL, 0, -1 ) ] )
|
||||
self.addLabel( self.appComment, [ pango.AttrScale( pango.SCALE_X_SMALL, 0, -1 ) ] )
|
||||
self.addLabel( appName, [ pango.AttrScale( pango.SCALE_SMALL, 0, -1 ) ] )
|
||||
self.addLabel( appComment, [ pango.AttrScale( pango.SCALE_X_SMALL, 0, -1 ) ] )
|
||||
else:
|
||||
self.addLabel( self.appName )
|
||||
self.addLabel( self.appComment, [ pango.AttrScale( pango.SCALE_SMALL, 0, -1 ) ] )
|
||||
self.addLabel( appName )
|
||||
self.addLabel( appComment, [ pango.AttrScale( pango.SCALE_SMALL, 0, -1 ) ] )
|
||||
else:
|
||||
self.addLabel( self.appName )
|
||||
self.addLabel( appName )
|
||||
|
||||
def execute( self, *args ):
|
||||
self.highlight = False
|
||||
for child in self.labelBox:
|
||||
child.destroy()
|
||||
self.setupLabels()
|
||||
return super(MenuApplicationLauncher, self).execute(*args)
|
||||
|
||||
def setShowComment( self, showComment ):
|
||||
self.showComment = showComment
|
||||
|
Loading…
Reference in New Issue
Block a user