aboutsummaryrefslogtreecommitdiff
path: root/logout-manager-tcl.py
diff options
context:
space:
mode:
Diffstat (limited to 'logout-manager-tcl.py')
-rwxr-xr-xlogout-manager-tcl.py36
1 files changed, 12 insertions, 24 deletions
diff --git a/logout-manager-tcl.py b/logout-manager-tcl.py
index cfeb851..5b0d29d 100755
--- a/logout-manager-tcl.py
+++ b/logout-manager-tcl.py
@@ -248,24 +248,6 @@ class Tooltip:
tw.destroy()
self.tw = None
-def get_gtk3_default_theme():
- # WORKHERE: move this to lmlib
- # abstracted so it does not clutter get_scaled_icon
- name = "hicolor"
- gtk3_config_path = os.path.join(os.path.expanduser("~"),".config","gtk-3.0","settings.ini")
- gtk3_config = configparser.ConfigParser()
- gtk3_config.read(gtk3_config_path)
- try:
- if 'Settings' in gtk3_config:
- name = gtk3_config['Settings']['gtk-icon-theme-name']
- elif 'settings' in gtk3_config:
- name = gtk3_config['settings']['gtk-icon-theme-name']
- except:
- # supposed failsafe
- name = "hicolor"
- print("Found gtk3 default theme:",name)
- return name
-
def tryint(s):
try:
return int(s)
@@ -309,13 +291,20 @@ def get_filename_of_icon(name, theme = "hicolor", size = 48, category = "actions
# example: Adwaita system-log-out
if theme == "default" or theme is None:
- theme = "hicolor"
+ try:
+ theme = lmlib.get_gtk3_default_icon_theme()
+ except:
+ theme = "hicolor"
# first, find all files underneath /usr/share/icons/$THEME/$SIZE
# WORKHERE, allow a prioritization of category, but tolerate any category if the requested category has no matches but another category does
print("Finding filename of icon, theme=",theme,"category=",category,"name=",name)
# WORKHERE: this glob affects if scalable/ dir is included. When support for svg is added (which is beyond PIL), need to add a conditional and use a second glob if USE_SVG=1.
+ results = []
results = glob.glob("/usr/share/icons/"+theme+"/*/"+category+"/"+name+".*")
+ if len(results) == 0:
+ # no results with that category, so try all categories
+ results = glob.glob("/usr/share/icons/"+theme+"/*/*/"+name+".*")
# the sort arranges it so a Numix/24 dir comes before a Numix/24@2x dir
results = sorted(results, key=sort_sizes)
#print(results)
@@ -333,9 +322,8 @@ def get_scaled_icon(icon_name, size = 24, icon_theme = "default", fallback_icon_
else:
if icon_theme == "default":
- # retrieve default theme from config file
- print("Discovering default icon theme...")
- icon_theme = get_gtk3_default_theme()
+ # this should not happen, because the Initialize_config should have checked gtk3 default value.
+ icon_theme = "hicolor"
# so now that icon_theme is defined, let us go find the icon that matches the requested name and size, in the actions category
#print("Using icon theme",icon_theme)
iconfilename = get_filename_of_icon(name=icon_name, theme=icon_theme, size=size, category=config.get_icon_category())
@@ -420,14 +408,14 @@ root = tk.Tk()
# MAIN LOOP
root.title("Log out options")
#root.iconbitmap(r'/usr/share/icons/Numix/48/actions/system-logout.svg')
-imgicon = get_scaled_icon(config.get_logout_icon(),24)
+imgicon = get_scaled_icon(config.get_logout_icon(),24,config.get_icon_theme())
#if USE_PRIVATE_TCL_IMAGES is None:
# #imgicon = PhotoImage(file=os.path.join("/usr/share/icons/Adwaita/24x24/actions","system-log-out.png"))
# imgicon = get_scaled_icon(config.get_logout_icon(),24)
#else:
# #imgicon = PhotoImage_from_png(file=os.path.join("/usr/share/icons/Adwaita/24x24/actions","system-log-out.png"))
# imgicon = get_scaled_icon(config.get_logout_icon(),24)
-print(imgicon)
+#print(imgicon)
root.tk.call('wm','iconphoto', root._w, imgicon)
app = App(root)
root.mainloop()
bgstack15