Browse Source

Fix icons search problem

The icons search algorithm was searching first under the
/usr/share/pixmaps directory for the icons which had as a
result to miss the 256x256 icon under /usr/share/icons/hicolor/256x256/apps/
and retrieve the 48x48 icon

Now the algorithm first searches the $XDG_DATA_DIRS
and then the fallback directory (/usr/share/pixmaps)
doc-issue-template
MrS0m30n3 9 years ago
parent
commit
cff894b18f
1 changed files with 25 additions and 27 deletions
  1. 52
      youtube_dl_gui/utils.py

52
youtube_dl_gui/utils.py

@ -110,33 +110,33 @@ def get_time(seconds):
return dtime
def get_locale_file():
"""Search for youtube-dlg locale file.
Returns:
The path to youtube-dlg locale file if exists else None.
Note:
Paths that get_locale_file() func searches.
__main__ dir, library dir, /usr/share/youtube-dlg/locale
"""
DIR_NAME = 'locale'
SEARCH_DIRS = [
os.path.join(absolute_path(sys.argv[0]), DIR_NAME),
os.path.join(os.path.dirname(__file__), DIR_NAME),
os.path.join('/usr', 'share', __appname__.lower(), DIR_NAME)
]
for directory in SEARCH_DIRS:
if os.path.isdir(directory):
return directory
return None
def get_icon_file():
"""Search for youtube-dlg app icon.
@ -155,33 +155,31 @@ def get_icon_file():
ICONS_LIST = [ICON_NAME % size for size in SIZES]
SEARCH_DIRS = [
search_dirs = [
os.path.join(absolute_path(sys.argv[0]), 'icons'),
os.path.join(os.path.dirname(__file__), 'icons'),
'/usr/share/pixmaps'
]
for directory in SEARCH_DIRS:
for icon in ICONS_LIST:
icon_file = os.path.join(directory, icon)
if os.path.exists(icon_file):
return icon_file
# Search $XDG_DATA_DIRS
# Append $XDG_DATA_DIRS on search_dirs
path = os.getenv('XDG_DATA_DIRS')
if path is not None:
for xdg_path in path.split(':'):
xdg_path = os.path.join(xdg_path, 'icons', 'hicolor')
for size in SIZES:
icon_name = ICON_NAME % size
icon_file = os.path.join(xdg_path, size, 'apps', icon_name)
if os.path.exists(icon_file):
return icon_file
search_dirs.append(os.path.join(xdg_path, size, 'apps'))
# Also append /usr/share/pixmaps on search_dirs
search_dirs.append('/usr/share/pixmaps')
for directory in search_dirs:
for icon in ICONS_LIST:
icon_file = os.path.join(directory, icon)
if os.path.exists(icon_file):
return icon_file
return None

Loading…
Cancel
Save