diff --git a/data/notifications.metainfo.xml.in b/data/notifications.metainfo.xml.in index b570ad0..289c650 100644 --- a/data/notifications.metainfo.xml.in +++ b/data/notifications.metainfo.xml.in @@ -42,6 +42,7 @@ Notification Focus Settings + Missing, notification banner icon diff --git a/src/Bubble.vala b/src/Bubble.vala index b556b25..533a521 100644 --- a/src/Bubble.vala +++ b/src/Bubble.vala @@ -85,9 +85,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 5280953..d88da16 100644 --- a/src/Notification.vala +++ b/src/Notification.vala @@ -17,7 +17,7 @@ public class Notifications.Notification : Object { public string app_id { get; private set; default = OTHER_APP_ID; } - 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; } @@ -66,18 +66,7 @@ public class Notifications.Notification : 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 (); unowned Variant? variant = null; @@ -106,11 +95,6 @@ public class Notifications.Notification : 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 (); @@ -126,6 +110,30 @@ public class Notifications.Notification : 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 == "" && gicon != null && icon_theme.has_gicon (gicon)) { + return gicon; + } + + 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 */