From f37b1581f11a32b512123a09cf779f266e573d47 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danielle=20For=C3=A9?= Date: Fri, 21 Nov 2025 08:48:24 -0800 Subject: [PATCH 1/5] Notification: create find_icon function --- src/Bubble.vala | 4 +--- src/Notification.vala | 41 ++++++++++++++++++++++++----------------- 2 files changed, 25 insertions(+), 20 deletions(-) diff --git a/src/Bubble.vala b/src/Bubble.vala index 88b068ec..f1f6a60f 100644 --- a/src/Bubble.vala +++ b/src/Bubble.vala @@ -74,9 +74,7 @@ public class Notifications.Bubble : AbstractBubble { } construct { - var app_image = new Gtk.Image () { - gicon = notification.primary_icon - }; + var app_image = new Gtk.Image.from_gicon (notification.primary_icon); var image_overlay = new Gtk.Overlay (); image_overlay.valign = Gtk.Align.START; diff --git a/src/Notification.vala b/src/Notification.vala index a0ebafef..465583d6 100644 --- a/src/Notification.vala +++ b/src/Notification.vala @@ -104,18 +104,7 @@ public class Notifications.Notification : GLib.Object { } } - // Always "" if sent by GLib.Notification - if (app_icon == "" && app_info != null) { - primary_icon = app_info.get_icon (); - } else if (app_icon.contains ("/")) { - var file = File.new_for_uri (app_icon); - if (file.query_exists ()) { - primary_icon = new FileIcon (file); - } - } else { - // Icon name set directly, such as by Notify.Notification - primary_icon = new ThemedIcon (app_icon); - } + primary_icon = find_icon (); // GLib.Notification.set_icon () if ((variant = hints.lookup ("image-path")) != null || (variant = hints.lookup ("image_path")) != null) { @@ -142,11 +131,6 @@ public class Notifications.Notification : GLib.Object { } } - // Display a generic notification icon if there is no notification image - if (image == null && primary_icon == null) { - primary_icon = new ThemedIcon ("dialog-information"); - } - // Always "" if sent by GLib.Notification if (app_name == "" && app_info != null) { app_name = app_info.get_display_name (); @@ -162,6 +146,29 @@ public class Notifications.Notification : GLib.Object { } } + private GLib.Icon find_icon () { + var icon_theme = Gtk.IconTheme.get_for_display (Gdk.Display.get_default ()); + + // Always "" if sent by GLib.Notification + if (app_icon == "" && app_info != null && icon_theme.has_gicon (app_info.get_icon ())) { + return app_info.get_icon (); + } + + if (app_icon.contains ("/")) { + var file = File.new_for_uri (app_icon); + if (file.query_exists ()) { + return new FileIcon (file); + } + } + + // Icon name set directly, such as by Notify.Notification + if (app_icon != "" && icon_theme.has_icon (app_icon)) { + return new ThemedIcon (app_icon); + } + + return new ThemedIcon ("application-default-icon"); + } + /** * Copied from gnome-shell, fixes the mess of markup that is sent to us */ From 81fcd3a4da4969110bbae5d11cdec0f488cb5f33 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danielle=20For=C3=A9?= Date: Fri, 21 Nov 2025 08:53:08 -0800 Subject: [PATCH 2/5] Add issue link --- data/notifications.metainfo.xml.in | 1 + 1 file changed, 1 insertion(+) diff --git a/data/notifications.metainfo.xml.in b/data/notifications.metainfo.xml.in index b570ad01..289c6501 100644 --- a/data/notifications.metainfo.xml.in +++ b/data/notifications.metainfo.xml.in @@ -42,6 +42,7 @@ Notification Focus Settings + Missing, notification banner icon From 0c24516fb13a4ba24de8ce0544a1997eb66372d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danielle=20For=C3=A9?= Date: Fri, 21 Nov 2025 08:53:48 -0800 Subject: [PATCH 3/5] lint --- src/Notification.vala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Notification.vala b/src/Notification.vala index 465583d6..082ce129 100644 --- a/src/Notification.vala +++ b/src/Notification.vala @@ -153,7 +153,7 @@ public class Notifications.Notification : GLib.Object { if (app_icon == "" && app_info != null && icon_theme.has_gicon (app_info.get_icon ())) { return app_info.get_icon (); } - + if (app_icon.contains ("/")) { var file = File.new_for_uri (app_icon); if (file.query_exists ()) { From a354349470bc417062fad73dacc84790ca677866 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danielle=20For=C3=A9?= Date: Fri, 21 Nov 2025 08:54:39 -0800 Subject: [PATCH 4/5] private set, no longer nullable --- src/Notification.vala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Notification.vala b/src/Notification.vala index 082ce129..631cc3cf 100644 --- a/src/Notification.vala +++ b/src/Notification.vala @@ -30,7 +30,7 @@ public class Notifications.Notification : GLib.Object { public string body { get; construct set; } public string summary { get; construct set; } - public GLib.Icon? primary_icon { get; set; default = null; } + public GLib.Icon primary_icon { get; private set; } public GLib.Icon? badge_icon { get; set; default = null; } public MaskedImage? image { get; set; default = null; } From 2e2dcdfa6c0e085498feb7cce4b5e7d44f65c73e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danielle=20For=C3=A9?= Date: Tue, 25 Nov 2025 08:56:51 -0800 Subject: [PATCH 5/5] cache icon from appinfo --- src/Notification.vala | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Notification.vala b/src/Notification.vala index 631cc3cf..7068d684 100644 --- a/src/Notification.vala +++ b/src/Notification.vala @@ -149,9 +149,10 @@ public class Notifications.Notification : GLib.Object { private GLib.Icon find_icon () { var icon_theme = Gtk.IconTheme.get_for_display (Gdk.Display.get_default ()); + var gicon = app_info?.get_icon (); // Always "" if sent by GLib.Notification - if (app_icon == "" && app_info != null && icon_theme.has_gicon (app_info.get_icon ())) { - return app_info.get_icon (); + if (app_icon == "" && gicon != null && icon_theme.has_gicon (gicon)) { + return gicon; } if (app_icon.contains ("/")) {