Commit 237310c6 authored by Erik Reider's avatar Erik Reider

Fixed notifications list not scrolling when changing focus

parent 3069f712
...@@ -20,89 +20,101 @@ ...@@ -20,89 +20,101 @@
<property name="vexpand">True</property> <property name="vexpand">True</property>
<property name="orientation">vertical</property> <property name="orientation">vertical</property>
<child> <child>
<object class="GtkScrolledWindow" id="scrolled_window"> <object class="GtkBox" id="notifications_box">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can-focus">True</property> <property name="can-focus">False</property>
<property name="hscrollbar-policy">never</property> <property name="orientation">vertical</property>
<child> <child>
<object class="GtkViewport" id="viewport"> <object class="GtkStack" id="stack">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can-focus">False</property> <property name="can-focus">False</property>
<property name="vexpand">True</property> <property name="transition-type">crossfade</property>
<property name="shadow-type">none</property>
<child> <child>
<object class="GtkStack" id="stack"> <object class="GtkScrolledWindow" id="scrolled_window">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can-focus">False</property> <property name="can-focus">True</property>
<property name="transition-type">crossfade</property> <property name="hscrollbar-policy">never</property>
<child> <child>
<object class="GtkBox"> <object class="GtkViewport" id="viewport">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can-focus">False</property> <property name="can-focus">False</property>
<property name="halign">center</property>
<property name="valign">center</property>
<property name="hexpand">True</property>
<property name="vexpand">True</property> <property name="vexpand">True</property>
<property name="orientation">vertical</property> <property name="shadow-type">none</property>
<property name="spacing">12</property>
<child>
<object class="GtkImage">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="pixel-size">96</property>
<property name="icon-name">preferences-system-notifications-symbolic</property>
<property name="use-fallback">True</property>
<property name="icon_size">0</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child> <child>
<object class="GtkLabel"> <object class="GtkListBox" id="list_box">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can-focus">False</property> <property name="can-focus">False</property>
<property name="label" translatable="yes">No Notifications</property> <property name="valign">end</property>
<property name="selection-mode">none</property>
<property name="activate-on-single-click">False</property>
<style>
<class name="control-center-list"/>
</style>
</object> </object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child> </child>
<style> </object>
<class name="control-center-list-placeholder"/> </child>
</style> </object>
<packing>
<property name="name">notifications-list</property>
</packing>
</child>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="halign">center</property>
<property name="valign">center</property>
<property name="hexpand">True</property>
<property name="vexpand">True</property>
<property name="orientation">vertical</property>
<property name="spacing">12</property>
<child>
<object class="GtkImage">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="pixel-size">96</property>
<property name="icon-name">preferences-system-notifications-symbolic</property>
<property name="use-fallback">True</property>
<property name="icon_size">0</property>
</object> </object>
<packing> <packing>
<property name="name">notifications-placeholder</property> <property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing> </packing>
</child> </child>
<child> <child>
<object class="GtkListBox" id="list_box"> <object class="GtkLabel">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can-focus">False</property> <property name="can-focus">False</property>
<property name="valign">end</property> <property name="label" translatable="yes">No Notifications</property>
<property name="selection-mode">none</property>
<property name="activate-on-single-click">False</property>
<style>
<class name="control-center-list"/>
</style>
</object> </object>
<packing> <packing>
<property name="name">notifications-list</property> <property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property> <property name="position">1</property>
</packing> </packing>
</child> </child>
<style>
<class name="control-center-list-placeholder"/>
</style>
</object> </object>
<packing>
<property name="name">notifications-placeholder</property>
<property name="position">1</property>
</packing>
</child> </child>
</object> </object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child> </child>
</object> </object>
<packing> <packing>
<property name="expand">True</property> <property name="expand">False</property>
<property name="fill">True</property> <property name="fill">True</property>
<property name="position">0</property> <property name="position">0</property>
</packing> </packing>
......
...@@ -3,6 +3,8 @@ namespace SwayNotificationCenter { ...@@ -3,6 +3,8 @@ namespace SwayNotificationCenter {
public class ControlCenter : Gtk.ApplicationWindow { public class ControlCenter : Gtk.ApplicationWindow {
[GtkChild] [GtkChild]
unowned Gtk.Box notifications_box;
[GtkChild]
unowned Gtk.ScrolledWindow scrolled_window; unowned Gtk.ScrolledWindow scrolled_window;
[GtkChild] [GtkChild]
unowned Gtk.Viewport viewport; unowned Gtk.Viewport viewport;
...@@ -243,11 +245,11 @@ namespace SwayNotificationCenter { ...@@ -243,11 +245,11 @@ namespace SwayNotificationCenter {
if (w.length == 0) w = DEFAULT_WIDGETS; if (w.length == 0) w = DEFAULT_WIDGETS;
bool has_notification = false; bool has_notification = false;
foreach (string key in w) { foreach (string key in w) {
// Reposition the scrolled_window // Reposition the notifications_box
if (key == "notifications") { if (key == "notifications") {
has_notification = true; has_notification = true;
uint pos = box.get_children ().length (); 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; continue;
} }
// Add the widget if it is valid // Add the widget if it is valid
...@@ -261,7 +263,7 @@ namespace SwayNotificationCenter { ...@@ -261,7 +263,7 @@ namespace SwayNotificationCenter {
if (!has_notification) { if (!has_notification) {
warning ("Notification widget not included in \"widgets\" config. Using default bottom position"); warning ("Notification widget not included in \"widgets\" config. Using default bottom position");
uint pos = box.get_children ().length (); 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));
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment