From bdc9122c7e64f5f245dc832ed3ba552c578122b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danielle=20For=C3=A9?= Date: Thu, 3 Sep 2026 18:32:54 -0700 Subject: [PATCH 1/6] NotificationsList: consume all view widgets --- src/Indicator.vala | 61 +----------------------------- src/Widgets/NotificationsList.vala | 52 ++++++++++++++++++++++++- 2 files changed, 53 insertions(+), 60 deletions(-) diff --git a/src/Indicator.vala b/src/Indicator.vala index 1eeceddc..bb322ab6 100644 --- a/src/Indicator.vala +++ b/src/Indicator.vala @@ -13,8 +13,6 @@ public class Notifications.Indicator : Wingpanel.Indicator { private Gee.HashMap app_settings_cache; private GLib.Settings notify_settings; - private Gtk.Box? main_box = null; - private Wingpanel.PopoverMenuItem clear_all_btn; private NotificationsIndicator.Symbol? dynamic_icon = null; private NotificationsList nlist; private NotificationsMonitor monitor; @@ -87,55 +85,14 @@ public class Notifications.Indicator : Wingpanel.Indicator { } public override Gtk.Widget? get_widget () { - if (main_box == null) { - var not_disturb_switch = new Granite.SwitchModelButton (_("Do Not Disturb")); - not_disturb_switch.add_css_class (Granite.STYLE_CLASS_H4_LABEL); - - var dnd_switch_separator = new Gtk.Separator (Gtk.Orientation.HORIZONTAL) { - margin_top = 3, - margin_bottom = 3 - }; - - var clear_all_btn_separator = new Gtk.Separator (Gtk.Orientation.HORIZONTAL) { - margin_top = 3, - margin_bottom = 3 - }; - - clear_all_btn = new Wingpanel.PopoverMenuItem () { - text = _("Clear All Notifications") - }; - - var settings_btn = new Wingpanel.PopoverMenuItem () { - text = _("Notifications Settings…") - }; - - main_box = new Gtk.Box (VERTICAL, 0) { - width_request = 360 - }; - main_box.append (not_disturb_switch); - main_box.append (dnd_switch_separator); - main_box.append (nlist); - main_box.append (clear_all_btn_separator); - main_box.append (clear_all_btn); - main_box.append (settings_btn); - - notify_settings.bind ("do-not-disturb", not_disturb_switch, "active", GLib.SettingsBindFlags.DEFAULT); - + if (nlist == null) { nlist.close_popover.connect (() => close ()); - nlist.items_changed.connect (update_clear_all_sensitivity); - - clear_all_btn.clicked.connect (() => { - nlist.clear_all (); // This calls each appentry's clear method, which also clears session - }); - - settings_btn.clicked.connect (show_settings); } - return main_box; + return nlist; } public override void opened () { - update_clear_all_sensitivity (); } public override void closed () { @@ -163,10 +120,6 @@ public class Notifications.Indicator : Wingpanel.Indicator { set_display_icon_name (); } - private void update_clear_all_sensitivity () { - clear_all_btn.sensitive = nlist.notification_items.get_n_items () > 0; - } - private void on_notification_closed (uint32 id, Notification.CloseReason reason) { for (int i = 0; i < nlist.notification_items.get_n_items (); i++) { var notification = (Notification) nlist.notification_items.get_item (i); @@ -188,16 +141,6 @@ public class Notifications.Indicator : Wingpanel.Indicator { update_tooltip (); } - private void show_settings () { - close (); - - try { - AppInfo.launch_default_for_uri ("settings://notifications", null); - } catch (Error e) { - warning ("Failed to open notifications settings: %s", e.message); - } - } - private void update_tooltip () { var number_of_notifications = nlist.notification_items.get_n_items (); string[] accels = {}; diff --git a/src/Widgets/NotificationsList.vala b/src/Widgets/NotificationsList.vala index 2b1bde1c..e9580276 100644 --- a/src/Widgets/NotificationsList.vala +++ b/src/Widgets/NotificationsList.vala @@ -19,12 +19,34 @@ public class Notifications.NotificationsList : Granite.Bin { } } + private Gtk.Button clear_all_btn; private Gtk.SortListModel sort_list_model; private Gtk.Stack stack; construct { app_datetime = new GLib.HashTable (str_hash, str_equal); + var not_disturb_switch = new Granite.SwitchModelButton (_("Do Not Disturb")); + not_disturb_switch.add_css_class (Granite.STYLE_CLASS_H4_LABEL); + + var dnd_switch_separator = new Gtk.Separator (Gtk.Orientation.HORIZONTAL) { + margin_top = 3, + margin_bottom = 3 + }; + + var clear_all_btn_separator = new Gtk.Separator (Gtk.Orientation.HORIZONTAL) { + margin_top = 3, + margin_bottom = 3 + }; + + clear_all_btn = new Wingpanel.PopoverMenuItem () { + text = _("Clear All Notifications") + }; + + var settings_btn = new Wingpanel.PopoverMenuItem () { + text = _("Notifications Settings…") + }; + var placeholder = new Gtk.Label (_("No Notifications")) { margin_top = 24, margin_bottom = 24, @@ -59,7 +81,17 @@ public class Notifications.NotificationsList : Granite.Bin { stack.add_named (placeholder, "placeholder"); stack.add_named (scrolled, "list"); - child = stack; + var main_box = new Gtk.Box (VERTICAL, 0) { + width_request = 360 + }; + main_box.append (not_disturb_switch); + main_box.append (dnd_switch_separator); + main_box.append (scrolled); + main_box.append (clear_all_btn_separator); + main_box.append (clear_all_btn); + main_box.append (settings_btn); + + child = main_box; insert_action_group (ACTION_GROUP_PREFIX, new NotificationsMonitor ().notifications_action_group); @@ -74,6 +106,12 @@ public class Notifications.NotificationsList : Granite.Bin { add_entry (notification); } }); + + var settings = new GLib.Settings ("io.elementary.notifications"); + settings.bind ("do-not-disturb", not_disturb_switch, "active", DEFAULT); + + clear_all_btn.clicked.connect (clear_all); + settings_btn.clicked.connect (show_settings); } private static int section_compare (Notification a, Notification b) { @@ -128,6 +166,16 @@ public class Notifications.NotificationsList : Granite.Bin { close_popover (); } + private void show_settings () { + close_popover (); + + try { + AppInfo.launch_default_for_uri ("settings://notifications", null); + } catch (Error e) { + warning ("Failed to open notifications settings: %s", e.message); + } + } + public uint get_n_app_items () { var app_list = new GenericSet (str_hash, str_equal); for (var i = 0; i < list_store.n_items; i++) { @@ -160,6 +208,8 @@ public class Notifications.NotificationsList : Granite.Bin { stack.visible_child_name = "list"; } + clear_all_btn.sensitive = list_store.n_items > 0; + items_changed (); } From 9368dcdffdd229750ef93f754b314bd3ff600da1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danielle=20For=C3=A9?= Date: Thu, 3 Sep 2026 18:34:09 -0700 Subject: [PATCH 2/6] little cleanup --- src/Indicator.vala | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/Indicator.vala b/src/Indicator.vala index bb322ab6..ed1b1128 100644 --- a/src/Indicator.vala +++ b/src/Indicator.vala @@ -92,12 +92,9 @@ public class Notifications.Indicator : Wingpanel.Indicator { return nlist; } - public override void opened () { - } - - public override void closed () { + public override void opened () { } - } + public override void closed () { } private void on_notification_received (DBusMessage message, uint32 id) { var notification = new Notification.from_message (message, id); From 51d2ccd91cb3fb82b20657ca49a1cc39fe2c1576 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danielle=20For=C3=A9?= Date: Thu, 3 Sep 2026 21:22:36 -0700 Subject: [PATCH 3/6] Update to UriLauncher --- src/Widgets/NotificationsList.vala | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/Widgets/NotificationsList.vala b/src/Widgets/NotificationsList.vala index aab3db28..5278b87d 100644 --- a/src/Widgets/NotificationsList.vala +++ b/src/Widgets/NotificationsList.vala @@ -29,7 +29,6 @@ public class Notifications.NotificationsList : Granite.Bin { construct { var not_disturb_switch = new Granite.SwitchModelButton (_("Do Not Disturb")); - not_disturb_switch.add_css_class (Granite.STYLE_CLASS_H4_LABEL); var dnd_switch_separator = new Gtk.Separator (HORIZONTAL) { margin_top = 3, @@ -185,11 +184,14 @@ public class Notifications.NotificationsList : Granite.Bin { private void show_settings () { close_popover (); - try { - AppInfo.launch_default_for_uri ("settings://notifications", null); - } catch (Error e) { - warning ("Failed to open notifications settings: %s", e.message); - } + var uri_launcher = new Gtk.UriLauncher ("settings://notifications"); + uri_launcher.launch.begin ((Gtk.Window) get_root (), null, (obj, res) => { + try { + uri_launcher.launch.end (res); + } catch (Error e) { + warning ("Failed to open notifications settings: %s", e.message); + } + }); } public uint get_n_app_items () { From 4c2827d8511907c37d19fb30617e01ca6d45a81b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danielle=20For=C3=A9?= Date: Thu, 3 Sep 2026 21:23:44 -0700 Subject: [PATCH 4/6] Use Granite constant --- src/Widgets/NotificationsList.vala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Widgets/NotificationsList.vala b/src/Widgets/NotificationsList.vala index 5278b87d..eee98f8c 100644 --- a/src/Widgets/NotificationsList.vala +++ b/src/Widgets/NotificationsList.vala @@ -184,7 +184,7 @@ public class Notifications.NotificationsList : Granite.Bin { private void show_settings () { close_popover (); - var uri_launcher = new Gtk.UriLauncher ("settings://notifications"); + var uri_launcher = new Gtk.UriLauncher (Granite.SettingsUri.NOTIFICATIONS); uri_launcher.launch.begin ((Gtk.Window) get_root (), null, (obj, res) => { try { uri_launcher.launch.end (res); From d616bf0939343bd276ca0281c107f123208bfbf0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danielle=20For=C3=A9?= Date: Thu, 3 Sep 2026 21:25:56 -0700 Subject: [PATCH 5/6] fix extra , --- src/Widgets/NotificationsList.vala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Widgets/NotificationsList.vala b/src/Widgets/NotificationsList.vala index 6290f601..30972c59 100644 --- a/src/Widgets/NotificationsList.vala +++ b/src/Widgets/NotificationsList.vala @@ -31,7 +31,7 @@ public class Notifications.NotificationsList : Granite.Bin { var not_disturb_switch = new Granite.SwitchModelButton (_("Do Not Disturb")); var dnd_switch_separator = new Gtk.Separator (HORIZONTAL) { - margin_top = 3, + margin_top = 3 }; var clear_all_btn_separator = new Gtk.Separator (HORIZONTAL) { From c823988be0d3cc1f6c6bb32e015bb5389c9cd2c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danielle=20For=C3=A9?= Date: Fri, 4 Sep 2026 08:46:53 -0700 Subject: [PATCH 6/6] fix packing stack --- src/Widgets/NotificationsList.vala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Widgets/NotificationsList.vala b/src/Widgets/NotificationsList.vala index 30972c59..0f12f9e8 100644 --- a/src/Widgets/NotificationsList.vala +++ b/src/Widgets/NotificationsList.vala @@ -95,7 +95,7 @@ public class Notifications.NotificationsList : Granite.Bin { }; main_box.append (not_disturb_switch); main_box.append (dnd_switch_separator); - main_box.append (scrolled); + main_box.append (stack); main_box.append (clear_all_btn_separator); main_box.append (clear_all_btn); main_box.append (settings_btn);