How to use the xdg.IconTheme.getIconPath function in xdg

To help you get started, we’ve selected a few xdg examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ssokolow / game_launcher / gui_qt / icon_provider.py View on Github external
# Always let the cache service requests first
        if icon_name in self.icon_cache:
            return self.icon_cache[icon_name]

        # Skip right to the fallback if it's None or an empty string
        if icon_name:
            # Give Qt the opportunity to make a fool out of itself
            if os.path.isfile(icon_name):
                icon = QIcon(icon_name)
            else:
                icon = QIcon.fromTheme(icon_name)

            # Resort to PyXDG to walk the fallback chain properly
            # TODO: Better resolution handling
            if not icon or icon.isNull():
                icon = QIcon(getIconPath(icon_name, icon_size,
                                         theme=QIcon.themeName()))
        else:
            icon = None

        if not icon or icon.isNull():
            icon = self.lookup_local(icon_name)

        # If we still couldn't get a result, retrieve the fallback icon in a
        # way which will allow a cache entry here without duplication
        if not icon or icon.isNull() and icon_name != self.fallback_name:
            icon = self.get_icon(self.fallback_name, icon_size)

        # Populate the cache
        icon = self.ensure_icon_size(icon, icon_size)
        self.icon_cache[icon_name] = icon
        return icon
github linkinpark342 / firefoxnotify / src / chrome / content / download_complete_notify.py View on Github external
def get_icon():
    try:
        import xdg.IconTheme
    except ImportError:
        return POSSIBLE_ICON_NAMES[0]
    else:
        for name in POSSIBLE_ICON_NAMES:
            if xdg.IconTheme.getIconPath(name) is not None:
                return name
        return POSSIBLE_ICON_NAMES[0]
github RazZziel / PortableLinuxGames / AppImageAssistant.AppDir / xdgappdir.py View on Github external
def get_icon_path_by_icon_name(self, icon_name):
        """Return the path of the icon for a given icon name"""
        for format in ["png", "xpm"] :
            icon = xdg.IconTheme.getIconPath(icon_name, 48, None, format)
            if icon != None :
                return icon
        return None # If we have not found an icon
github ju1ius / uxdgmenu / usr / lib / uxdgmenu / uxm / icon_finder.py View on Github external
def lookup(self, name):
        """Lookup icon by name using xdg.IconTheme"""
        if os.path.isabs(name):
            return name
        path = xdg.IconTheme.getIconPath(name, self.size, self.theme)
        if not path:
            # icon was not found in theme or 'hicolor', try with fallbacks
            for theme in self.theme_fallbacks:
                path = xdg.IconTheme.getIconPath(name, self.size, theme)
                if path:
                    break
        return path
github emgram769 / lighthouse / config / lighthouse / cmd.py View on Github external
def get_icon(desktop_entry):

        icon_name = desktop_entry.getIcon()
        if not icon_name:
            return
        else:
            icon_path = xdg.IconTheme.getIconPath(icon_name)
            return icon_path
github ju1ius / uxdgmenu / usr / lib / uxdgmenu / uxm / icon_finder.py View on Github external
def lookup(self, name):
        """Lookup icon by name using xdg.IconTheme"""
        if os.path.isabs(name):
            return name
        path = xdg.IconTheme.getIconPath(name, self.size, self.theme)
        if not path:
            # icon was not found in theme or 'hicolor', try with fallbacks
            for theme in self.theme_fallbacks:
                path = xdg.IconTheme.getIconPath(name, self.size, theme)
                if path:
                    break
        return path