|
@ -14,28 +14,40 @@ desktop = False |
|
|
|
|
|
|
|
|
de = dentry.DesktopEntry(filename = '/usr/share/desktop-directories/xdgmenumaker-applications.directory') |
|
|
de = dentry.DesktopEntry(filename = '/usr/share/desktop-directories/xdgmenumaker-applications.directory') |
|
|
applications = de.getName().encode('utf-8') |
|
|
applications = de.getName().encode('utf-8') |
|
|
|
|
|
applications_icon = de.getIcon() |
|
|
de = dentry.DesktopEntry(filename = '/usr/share/desktop-directories/xdgmenumaker-accessories.directory') |
|
|
de = dentry.DesktopEntry(filename = '/usr/share/desktop-directories/xdgmenumaker-accessories.directory') |
|
|
accessories = de.getName().encode('utf-8') |
|
|
accessories = de.getName().encode('utf-8') |
|
|
|
|
|
accessories_icon = de.getIcon() |
|
|
de = dentry.DesktopEntry(filename = '/usr/share/desktop-directories/xdgmenumaker-development.directory') |
|
|
de = dentry.DesktopEntry(filename = '/usr/share/desktop-directories/xdgmenumaker-development.directory') |
|
|
development = de.getName().encode('utf-8') |
|
|
development = de.getName().encode('utf-8') |
|
|
|
|
|
development_icon = de.getIcon() |
|
|
de = dentry.DesktopEntry(filename = '/usr/share/desktop-directories/xdgmenumaker-education.directory') |
|
|
de = dentry.DesktopEntry(filename = '/usr/share/desktop-directories/xdgmenumaker-education.directory') |
|
|
education = de.getName().encode('utf-8') |
|
|
education = de.getName().encode('utf-8') |
|
|
|
|
|
education_icon = de.getIcon() |
|
|
de = dentry.DesktopEntry(filename = '/usr/share/desktop-directories/xdgmenumaker-games.directory') |
|
|
de = dentry.DesktopEntry(filename = '/usr/share/desktop-directories/xdgmenumaker-games.directory') |
|
|
games = de.getName().encode('utf-8') |
|
|
games = de.getName().encode('utf-8') |
|
|
|
|
|
games_icon = de.getIcon() |
|
|
de = dentry.DesktopEntry(filename = '/usr/share/desktop-directories/xdgmenumaker-graphics.directory') |
|
|
de = dentry.DesktopEntry(filename = '/usr/share/desktop-directories/xdgmenumaker-graphics.directory') |
|
|
graphics = de.getName().encode('utf-8') |
|
|
graphics = de.getName().encode('utf-8') |
|
|
|
|
|
graphics_icon = de.getIcon() |
|
|
de = dentry.DesktopEntry(filename = '/usr/share/desktop-directories/xdgmenumaker-multimedia.directory') |
|
|
de = dentry.DesktopEntry(filename = '/usr/share/desktop-directories/xdgmenumaker-multimedia.directory') |
|
|
multimedia = de.getName().encode('utf-8') |
|
|
multimedia = de.getName().encode('utf-8') |
|
|
|
|
|
multimedia_icon = de.getIcon() |
|
|
de = dentry.DesktopEntry(filename = '/usr/share/desktop-directories/xdgmenumaker-network.directory') |
|
|
de = dentry.DesktopEntry(filename = '/usr/share/desktop-directories/xdgmenumaker-network.directory') |
|
|
network = de.getName().encode('utf-8') |
|
|
network = de.getName().encode('utf-8') |
|
|
|
|
|
network_icon = de.getIcon() |
|
|
de = dentry.DesktopEntry(filename = '/usr/share/desktop-directories/xdgmenumaker-office.directory') |
|
|
de = dentry.DesktopEntry(filename = '/usr/share/desktop-directories/xdgmenumaker-office.directory') |
|
|
office = de.getName().encode('utf-8') |
|
|
office = de.getName().encode('utf-8') |
|
|
|
|
|
office_icon = de.getIcon() |
|
|
de = dentry.DesktopEntry(filename = '/usr/share/desktop-directories/xdgmenumaker-settings.directory') |
|
|
de = dentry.DesktopEntry(filename = '/usr/share/desktop-directories/xdgmenumaker-settings.directory') |
|
|
settings = de.getName().encode('utf-8') |
|
|
settings = de.getName().encode('utf-8') |
|
|
|
|
|
settings_icon = de.getIcon() |
|
|
de = dentry.DesktopEntry(filename = '/usr/share/desktop-directories/xdgmenumaker-system.directory') |
|
|
de = dentry.DesktopEntry(filename = '/usr/share/desktop-directories/xdgmenumaker-system.directory') |
|
|
system = de.getName().encode('utf-8') |
|
|
system = de.getName().encode('utf-8') |
|
|
|
|
|
system_icon = de.getIcon() |
|
|
de = dentry.DesktopEntry(filename = '/usr/share/desktop-directories/xdgmenumaker-other.directory') |
|
|
de = dentry.DesktopEntry(filename = '/usr/share/desktop-directories/xdgmenumaker-other.directory') |
|
|
other = de.getName().encode('utf-8') |
|
|
other = de.getName().encode('utf-8') |
|
|
|
|
|
other_icon = de.getIcon() |
|
|
|
|
|
|
|
|
def main(argv): |
|
|
def main(argv): |
|
|
global desktop |
|
|
global desktop |
|
@ -88,6 +100,20 @@ class MenuEntry: |
|
|
def __repr__(self): |
|
|
def __repr__(self): |
|
|
return repr((self.category, self.name, self.icon, self.command)) |
|
|
return repr((self.category, self.name, self.icon, self.command)) |
|
|
|
|
|
|
|
|
|
|
|
def icon_full_path(icon): |
|
|
|
|
|
icon = os.path.basename(icon) |
|
|
|
|
|
if icon.endswith('.png'): |
|
|
|
|
|
icon = icon.replace('.png', '') |
|
|
|
|
|
elif icon.endswith('.svg'): |
|
|
|
|
|
icon = icon.replace('.svg', '') |
|
|
|
|
|
elif icon.endswith('.xpm'): |
|
|
|
|
|
icon = icon.replace('.xpm', '') |
|
|
|
|
|
icon_theme = gtk.icon_theme_get_default() |
|
|
|
|
|
icon = icon_theme.lookup_icon(icon, 16, gtk.ICON_LOOKUP_NO_SVG) |
|
|
|
|
|
if icon: |
|
|
|
|
|
icon = icon.get_filename() |
|
|
|
|
|
return icon |
|
|
|
|
|
|
|
|
def get_entry_info(desktopfile): |
|
|
def get_entry_info(desktopfile): |
|
|
global desktop |
|
|
global desktop |
|
|
global seticon |
|
|
global seticon |
|
@ -97,17 +123,8 @@ def get_entry_info(desktopfile): |
|
|
|
|
|
|
|
|
if seticon == True: |
|
|
if seticon == True: |
|
|
# strip the directory and extension from the icon name |
|
|
# strip the directory and extension from the icon name |
|
|
icon = os.path.basename(de.getIcon()) |
|
|
icon = de.getIcon() |
|
|
if icon.endswith('.png'): |
|
|
icon = icon_full_path(icon) |
|
|
icon = icon.replace('.png', '') |
|
|
|
|
|
elif icon.endswith('.svg'): |
|
|
|
|
|
icon = icon.replace('.svg', '') |
|
|
|
|
|
elif icon.endswith('.xpm'): |
|
|
|
|
|
icon = icon.replace('.xpm', '') |
|
|
|
|
|
icon_theme = gtk.icon_theme_get_default() |
|
|
|
|
|
icon = icon_theme.lookup_icon(icon, 16, gtk.ICON_LOOKUP_NO_SVG) |
|
|
|
|
|
if icon: |
|
|
|
|
|
icon = icon.get_filename() |
|
|
|
|
|
else: |
|
|
else: |
|
|
icon = None |
|
|
icon = None |
|
|
|
|
|
|
|
@ -184,7 +201,6 @@ def desktopfilelist(): |
|
|
filelist.append(localdir+'/'+i) |
|
|
filelist.append(localdir+'/'+i) |
|
|
return filelist |
|
|
return filelist |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def menu(): |
|
|
def menu(): |
|
|
applist = [] |
|
|
applist = [] |
|
|
for desktopfile in desktopfilelist(): |
|
|
for desktopfile in desktopfilelist(): |
|
@ -207,11 +223,50 @@ def menu(): |
|
|
menu.append([c, appsincategory]) |
|
|
menu.append([c, appsincategory]) |
|
|
return menu |
|
|
return menu |
|
|
|
|
|
|
|
|
|
|
|
def category_icon(category): |
|
|
|
|
|
if category == accessories: |
|
|
|
|
|
icon = accessories_icon |
|
|
|
|
|
elif category == development: |
|
|
|
|
|
icon = development_icon |
|
|
|
|
|
elif category == education: |
|
|
|
|
|
icon = education_icon |
|
|
|
|
|
elif category == games: |
|
|
|
|
|
icon = games_icon |
|
|
|
|
|
elif category == graphics: |
|
|
|
|
|
icon = graphics_icon |
|
|
|
|
|
elif category == multimedia: |
|
|
|
|
|
icon = multimedia_icon |
|
|
|
|
|
elif category == network: |
|
|
|
|
|
icon = network_icon |
|
|
|
|
|
elif category == office: |
|
|
|
|
|
icon = office_icon |
|
|
|
|
|
elif category == settings: |
|
|
|
|
|
icon = settings_icon |
|
|
|
|
|
elif category == system: |
|
|
|
|
|
icon = system_icon |
|
|
|
|
|
elif category == other: |
|
|
|
|
|
icon = other_icon |
|
|
|
|
|
else: |
|
|
|
|
|
icon = None |
|
|
|
|
|
return icon |
|
|
|
|
|
|
|
|
def fluxboxmenu(): |
|
|
def fluxboxmenu(): |
|
|
print '[submenu] ('+applications+')' |
|
|
if seticon == True: |
|
|
|
|
|
app_icon = icon_full_path(applications_icon) |
|
|
|
|
|
print '[submenu] ('+applications+') <'+app_icon+'>' |
|
|
|
|
|
else: |
|
|
|
|
|
print '[submenu] ('+applications+')' |
|
|
for i in menu(): |
|
|
for i in menu(): |
|
|
category = i[0] |
|
|
category = i[0] |
|
|
print ' [submenu] ('+category+')' |
|
|
if seticon == True: |
|
|
|
|
|
cat_icon = category_icon(category) |
|
|
|
|
|
cat_icon = icon_full_path(cat_icon) |
|
|
|
|
|
if cat_icon: |
|
|
|
|
|
print ' [submenu] ('+category+') <'+cat_icon+'>' |
|
|
|
|
|
else: |
|
|
|
|
|
print ' [submenu] ('+category+')' |
|
|
|
|
|
else: |
|
|
|
|
|
print ' [submenu] ('+category+')' |
|
|
for j in i[1]: |
|
|
for j in i[1]: |
|
|
name = j[0] |
|
|
name = j[0] |
|
|
icon = j[1] |
|
|
icon = j[1] |
|
|