diff options
author | B Stack <bgstack15@gmail.com> | 2019-06-12 07:12:47 -0400 |
---|---|---|
committer | B Stack <bgstack15@gmail.com> | 2019-06-12 07:12:47 -0400 |
commit | c2456c4bac2c93f500e112dd998e4b781821f7c2 (patch) | |
tree | 84fb5620a44d7d3309a8f7b9fa3d54d62f7d6785 /logout-manager.py | |
parent | WIP: add major logic (diff) | |
download | logout-manager-c2456c4bac2c93f500e112dd998e4b781821f7c2.tar.gz logout-manager-c2456c4bac2c93f500e112dd998e4b781821f7c2.tar.bz2 logout-manager-c2456c4bac2c93f500e112dd998e4b781821f7c2.zip |
add icon error handling
Diffstat (limited to 'logout-manager.py')
-rwxr-xr-x | logout-manager.py | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/logout-manager.py b/logout-manager.py index d1583e6..33795fd 100755 --- a/logout-manager.py +++ b/logout-manager.py @@ -54,8 +54,21 @@ def get_scaled_icon(icon_name, size=24, fallback_icon_name = "", icon_theme = "d icon_info = this_theme.lookup_icon(icon_name, size, 0) iconfilename = icon_info.get_filename() except: - icon_info = this_theme.lookup_icon(fallback_icon_name, size, 0) - iconfilename = icon_info.get_filename() + try: + icon_info = this_theme.lookup_icon(fallback_icon_name, size, 0) + iconfilename = icon_info.get_filename() + except: + # no icon in the current theme. Try a hard-coded fallback: + try: + # if debuglev 3 + print("Error: could not find default icon for",icon_name+", so using fallback.") + this_theme = Gtk.IconTheme.new() + this_theme.set_custom_theme("Numix-Circle") + icon_info = this_theme.lookup_icon(icon_name, size, 0) + iconfilename = icon_info.get_filename() + except: + print("Error: Could not find any icon for",icon_name) + return None #print(iconfilename) return Gtk.Image.new_from_pixbuf(Pixbuf.new_from_file_at_scale( filename=iconfilename, |