aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorB Stack <bgstack15@gmail.com>2019-06-12 07:12:47 -0400
committerB Stack <bgstack15@gmail.com>2019-06-12 07:12:47 -0400
commitc2456c4bac2c93f500e112dd998e4b781821f7c2 (patch)
tree84fb5620a44d7d3309a8f7b9fa3d54d62f7d6785
parentWIP: add major logic (diff)
downloadlogout-manager-c2456c4bac2c93f500e112dd998e4b781821f7c2.tar.gz
logout-manager-c2456c4bac2c93f500e112dd998e4b781821f7c2.tar.bz2
logout-manager-c2456c4bac2c93f500e112dd998e4b781821f7c2.zip
add icon error handling
-rw-r--r--.gitignore1
-rwxr-xr-xlogout-manager.py17
2 files changed, 16 insertions, 2 deletions
diff --git a/.gitignore b/.gitignore
index a4bc7e0..6ad48aa 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1 +1,2 @@
*.2019-*
+*.swp
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,
bgstack15