Fallback header notifications icon (#20)

This commit is contained in:
bleakgrey 2018-06-17 11:40:24 +03:00
parent 86e4215270
commit 708e6d6566
2 changed files with 16 additions and 5 deletions

View File

@ -52,4 +52,9 @@ public class Tootle.Desktop {
network.queue (msg);
}
public static string fallback_icon (string normal, string fallback) {
var theme = Gtk.IconTheme.get_default ();
return theme.has_icon (normal) ? normal : fallback;
}
}

View File

@ -5,23 +5,29 @@ public class Tootle.NotificationsView : AbstractView {
public NotificationsView () {
base ();
view.remove.connect (on_remove);
Tootle.accounts.switched.connect(on_account_changed);
Tootle.app.refresh.connect(on_refresh);
Tootle.network.notification.connect (prepend);
accounts.switched.connect(on_account_changed);
app.refresh.connect(on_refresh);
network.notification.connect (prepend);
request ();
}
public override string get_icon () {
return "notification-symbolic";
return get_notifications_icon (false);
}
public override string get_name () {
return _("Notifications");
}
private string get_notifications_icon (bool has_new) {
if (has_new)
return Desktop.fallback_icon ("notification-new-symbolic", "user-available-symbolic");
else
return Desktop.fallback_icon ("notification-symbolic", "user-invisible-symbolic");
}
public void prepend (ref Notification notification) {
append (ref notification, true);
}