From bad018f59a72de6730bf50d2997c00eedb504569 Mon Sep 17 00:00:00 2001 From: Jeff Woods Date: Mon, 4 Feb 2013 17:51:03 -0800 Subject: [PATCH] desktop files that specify an absolute path to an icon will use that path, rather than stripping the path and trying to find a matching icon. This allows for applications that use an icon in a non-standard directory. --- src/xdgmenumaker | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/src/xdgmenumaker b/src/xdgmenumaker index 2602393..d2fc637 100755 --- a/src/xdgmenumaker +++ b/src/xdgmenumaker @@ -108,18 +108,24 @@ class MenuEntry: 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 + # If the icon path is absolute and exists, leave it alone. + # This takes care of software that has its own icons stored + # in non-standard directories + if os.path.exists(icon) == True: + return icon + else: + 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): global desktop