Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions data/notifications.metainfo.xml.in
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
</description>
<issues>
<issue url="https://github.com/elementary/notifications/issues/279">Notification Focus Settings</issue>
<issue url="https://github.com/elementary/notifications/issues/284">Missing, notification banner icon</issue>
</issues>
</release>

Expand Down
4 changes: 1 addition & 3 deletions src/Bubble.vala
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
44 changes: 26 additions & 18 deletions src/Notification.vala
Original file line number Diff line number Diff line change
Expand Up @@ -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; }

Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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 ();
Expand All @@ -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
*/
Expand Down