Browse Source

Improve icon extension handling

In addition to other icon file types, also detect svgz icons. Do not
use them in any case, since none of the supported WMs can use them.

Also, make the extension detection case-insensitive. I've never seen an
icon extension with capitals in the wild, but who knows...

Finally, clean up the code a bit, so it reads easier.
pull/9/head
George Vlahavas 8 years ago
parent
commit
85dffdd9a5
  1. 13
      src/xdgmenumaker

13
src/xdgmenumaker

@ -269,12 +269,10 @@ def usage():
def icon_strip(icon):
# strip the directory and extension from the icon name
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', '')
main, ext = os.path.splitext(icon)
ext = ext.lower()
if ext == '.png' or ext == '.svg' or ext == '.svgz' or ext == '.xpm':
return main
return icon
@ -299,7 +297,8 @@ def icon_full_path(icon):
# But we don't want to do this for svg icons, since none of the WMs
# supports them. In that case, just fall back to looking for the icon
# elsewhere in the system.
if os.path.exists(icon) and os.path.splitext(icon)[1] != ".svg":
ext = os.path.splitext(icon)[1].lower()
if os.path.exists(icon) and ext != ".svg" and ext != ".svgz":
if max_icon_size:
return icon_max_size(icon)
else:

Loading…
Cancel
Save