def __init__( self ):
GObject.GObject.__init__( self )
self.icons = { }
self.count = 0
# Some apps don't put a default icon in the default theme folder, so we will search all themes
def createTheme( d ):
theme = Gtk.IconTheme()
theme.set_custom_theme( d )
return theme
# This takes to much time and there are only a very few applications that use icons from different themes
#self.themes = map( createTheme, [ d for d in os.listdir( "/usr/share/icons" ) if os.path.isdir( os.path.join( "/usr/share/icons", d ) ) ] )
self.defaultTheme = Gtk.IconTheme.get_default()
# Setup and clean up the temp icon dir
configDir = GLib.get_user_config_dir()
self.iconDir = os.path.join(configDir, "ukui-menu")
if not os.path.exists(self.iconDir):
os.makedirs(self.iconDir)
# Skip over files and dirs belonging to the applications plugin
contents = frozenset(os.listdir(self.iconDir)) - frozenset(('applications', 'applications.list'))
for fn in contents:
if os.path.isfile(os.path.join(self.iconDir, fn)):
print (("Removing file : " + os.path.join(self.iconDir, fn)))
os.remove(os.path.join(self.iconDir, fn))
else:
print ((os.path.join(self.iconDir, fn) + " is not a file, skipping delete."))
self.defaultTheme.append_search_path(self.iconDir)
# Themes with the same content as the default them aren't needed
#self.themes = [ theme for theme in self.themes if theme.list_icons() != defaultTheme.list_icons() ]
self.themes = [ self.defaultTheme ]
# Listen for changes in the themes
for theme in self.themes:
theme.connect("changed", self.themeChanged )
评论列表
文章目录