Skip to content

Commit

Permalink
Minor grouped notifications fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
ErikReider committed Dec 14, 2023
1 parent 86166a4 commit a6cf977
Showing 1 changed file with 23 additions and 18 deletions.
41 changes: 23 additions & 18 deletions src/notificationGroup/notificationGroup.vala
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,23 @@ namespace SwayNotificationCenter {
}
}

private void set_icon () {
if (is_empty ()) return;

unowned Notification first = (Notification) group.widgets.first ().data;
unowned NotifyParams param = first.param;
// Get the app icon
Icon ? icon = null;
if (param.desktop_app_info != null
&& (icon = param.desktop_app_info.get_icon ()) != null) {
app_icon.set_from_gicon (icon, Gtk.IconSize.LARGE_TOOLBAR);
app_icon.show ();
} else {
app_icon.set_from_icon_name ("application-x-executable-symbolic",
Gtk.IconSize.LARGE_TOOLBAR);
}
}

/// Returns if there's more than one notification
public bool only_single_notification () {
unowned Gtk.Widget ? widget = group.widgets.nth_data (1);
Expand Down Expand Up @@ -190,7 +207,11 @@ namespace SwayNotificationCenter {
}
group.add (noti);
if (!only_single_notification ()) {
group.set_sensitive (false);
if (!group.is_expanded) {
group.set_sensitive (false);
}
} else {
set_icon ();
}
}

Expand Down Expand Up @@ -240,23 +261,7 @@ namespace SwayNotificationCenter {
}

public void update () {
if (!is_empty ()) {
unowned Notification first = (Notification) group.widgets.first ().data;
unowned NotifyParams param = first.param;
// Get the app icon
Icon ? icon = null;
if (param.desktop_app_info != null
&& (icon = param.desktop_app_info.get_icon ()) != null) {
app_icon.set_from_gicon (icon, Gtk.IconSize.LARGE_TOOLBAR);
app_icon.show ();
} else {
app_icon.set_from_icon_name ("application-x-executable-symbolic",
Gtk.IconSize.LARGE_TOOLBAR);
// app_icon.hide ();
}
} else {
// app_icon.hide ();
}
set_icon ();
foreach (unowned Gtk.Widget widget in group.widgets) {
var noti = (Notification) widget;
if (noti != null) noti.set_time ();
Expand Down

0 comments on commit a6cf977

Please sign in to comment.