From 237310c62710f170b1bde920e32ef2457309b5bc Mon Sep 17 00:00:00 2001 From: Erik Reider <35975961+ErikReider@users.noreply.github.com> Date: Tue, 26 Sep 2023 17:04:56 +0200 Subject: [PATCH] Fixed notifications list not scrolling when changing focus --- src/controlCenter/controlCenter.ui | 112 +++++++++++++++------------ src/controlCenter/controlCenter.vala | 8 +- 2 files changed, 67 insertions(+), 53 deletions(-) diff --git a/src/controlCenter/controlCenter.ui b/src/controlCenter/controlCenter.ui index 6f4dd74..fe11730 100644 --- a/src/controlCenter/controlCenter.ui +++ b/src/controlCenter/controlCenter.ui @@ -20,89 +20,101 @@ True vertical - + True - True - never + False + vertical - + True False - True - none + crossfade - + True - False - crossfade + True + never - + True False - center - center - True True - vertical - 12 + none - + True False - 96 - preferences-system-notifications-symbolic - True - 0 + end + none + False + - - False - True - 0 - - - - True - False - No Notifications - - - False - True - 1 - - - + + + + + notifications-list + + + + + True + False + center + center + True + True + vertical + 12 + + + True + False + 96 + preferences-system-notifications-symbolic + True + 0 - notifications-placeholder + False + True + 0 - + True False - end - none - False - + No Notifications - notifications-list + False + True 1 + + + notifications-placeholder + 1 + + + False + True + 0 + - True + False True 0 diff --git a/src/controlCenter/controlCenter.vala b/src/controlCenter/controlCenter.vala index 3e6d91a..9241b2e 100644 --- a/src/controlCenter/controlCenter.vala +++ b/src/controlCenter/controlCenter.vala @@ -2,6 +2,8 @@ namespace SwayNotificationCenter { [GtkTemplate (ui = "/org/erikreider/sway-notification-center/controlCenter/controlCenter.ui")] public class ControlCenter : Gtk.ApplicationWindow { + [GtkChild] + unowned Gtk.Box notifications_box; [GtkChild] unowned Gtk.ScrolledWindow scrolled_window; [GtkChild] @@ -243,11 +245,11 @@ namespace SwayNotificationCenter { if (w.length == 0) w = DEFAULT_WIDGETS; bool has_notification = false; foreach (string key in w) { - // Reposition the scrolled_window + // Reposition the notifications_box if (key == "notifications") { has_notification = true; uint pos = box.get_children ().length (); - box.reorder_child (scrolled_window, (int) (pos > 0 ? --pos : 0)); + box.reorder_child (notifications_box, (int) (pos > 0 ? --pos : 0)); continue; } // Add the widget if it is valid @@ -261,7 +263,7 @@ namespace SwayNotificationCenter { if (!has_notification) { warning ("Notification widget not included in \"widgets\" config. Using default bottom position"); uint pos = box.get_children ().length (); - box.reorder_child (scrolled_window, (int) (pos > 0 ? --pos : 0)); + box.reorder_child (notifications_box, (int) (pos > 0 ? --pos : 0)); } }