Refactored icon setting

This commit is contained in:
Erik Reider
2021-07-27 22:45:47 +02:00
parent 176f719e19
commit 4427a8d672

View File

@@ -46,17 +46,23 @@ namespace SwayNotificatonCenter {
if (param.app_icon != "") { if (param.app_icon != "") {
img.set_from_icon_name (param.app_icon, Gtk.IconSize.DIALOG); img.set_from_icon_name (param.app_icon, Gtk.IconSize.DIALOG);
} else { } else {
// Get the app icon
GLib.Icon ? icon = null;
foreach (var app in AppInfo.get_all ()) { foreach (var app in AppInfo.get_all ()) {
if (app.get_name ().down () == param.app_name.down ()) { if (app.get_name ().down () == param.app_name.down ()) {
img.set_from_gicon (app.get_icon (), Gtk.IconSize.DIALOG); icon = app.get_icon ();
break; break;
} }
} }
if (icon != null) {
img.set_from_gicon (icon, Gtk.IconSize.DIALOG);
}
} }
} }
public delegate void On_hide_cb (Notification noti); public delegate void On_hide_cb (Notification noti);
// Called to show a temp notification
public void show_notification (On_hide_cb callback) { public void show_notification (On_hide_cb callback) {
this.show (); this.show ();
int ms = param.expire_timeout > 0 ? param.expire_timeout : millis; int ms = param.expire_timeout > 0 ? param.expire_timeout : millis;