From 3d69339443e7f45fd1a5c28cd0d88fb4a22eff49 Mon Sep 17 00:00:00 2001 From: Krzysztof Mierzejewski Date: Tue, 8 Feb 2022 16:54:58 +0100 Subject: [PATCH 1/2] Set GTK ApplicationWindow default icon for /usr installed application. --- pick/__main__.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/pick/__main__.py b/pick/__main__.py index 5dca3dc..4204262 100644 --- a/pick/__main__.py +++ b/pick/__main__.py @@ -328,8 +328,8 @@ def start_everything_first_time(self, on_window_map=None): if os.path.exists(licon): # print("Using local icon", licon) image = Gtk.Image.new_from_file(licon) - else: - # probably we're in a snap + elif os.environ.get('SNAP'): + # we're in a snap sicon = os.path.join( os.path.split(__file__)[0], os.environ.get('SNAP'), "usr", "share", "icons", "hicolor", @@ -337,6 +337,14 @@ def start_everything_first_time(self, on_window_map=None): if os.path.exists(sicon): # print("Using local snap icon", sicon) image = Gtk.Image.new_from_file(sicon) + if not image: + # last resort - assume the application data has been installed to User Programs + uicon = os.path.join( + sys.prefix, "share", "icons", "hicolor", + "48x48", "apps", "pick-colour-picker.png") + if os.path.exists(uicon): + # print("Using User Programs shared icon", uicon) + image = Gtk.Image.new_from_file(uicon) # and set this as the default icon if it exists if image: self.w.set_default_icon(image.get_pixbuf()) From 91a0723eb6da3e381e5ac35c52e063dcbf5b750f Mon Sep 17 00:00:00 2001 From: Krzysztof Mierzejewski Date: Tue, 8 Feb 2022 17:24:51 +0100 Subject: [PATCH 2/2] Set GTK HeaderBar icon for /usr installed application. --- pick/__main__.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/pick/__main__.py b/pick/__main__.py index 4204262..8606aa1 100644 --- a/pick/__main__.py +++ b/pick/__main__.py @@ -226,11 +226,17 @@ def start_everything_first_time(self, on_window_map=None): image = Gtk.Image.new_from_gicon(icon, Gtk.IconSize.BUTTON) else: # not in the theme, so we're probably running locally; - # use the local one - image = Gtk.Image.new_from_file(os.path.join( + # try to use the local one + licon = os.path.join( os.path.split(__file__)[0], "..", - "data", "icons", "scalable", "apps", - "pick-colour-picker-symbolic.svg")) + "data", "icons", "scalable", "apps", "pick-colour-picker-symbolic.svg") + if os.path.exists(licon): + image = Gtk.Image.new_from_file(licon) + else: + # last resort - assume the application data has been installed to User Programs + image = Gtk.Image.new_from_file(os.path.join( + sys.prefix, "share", "icons", "hicolor", + "scalable", "apps", "pick-colour-picker-symbolic.svg")) btngrab.add(image) head.pack_start(btngrab) btngrab.connect("clicked", self.grab)