From 6101635251b611916c8f4ba7d18a6d396038ff3a Mon Sep 17 00:00:00 2001 From: Clement Lefebvre Date: Mon, 6 Feb 2023 10:07:02 +0100 Subject: sessions: Make the list scrollable. Ported from Slick Greeter ported by Mike Gabriel. https://github.com/linuxmint/slick-greeter/commit/1480b029099ea24724d307943dc742a42fcd3159 --- src/toggle-box.vala | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/toggle-box.vala b/src/toggle-box.vala index 518275f..5301583 100644 --- a/src/toggle-box.vala +++ b/src/toggle-box.vala @@ -24,6 +24,7 @@ public class ToggleBox : Gtk.Box public string default_key {get; construct;} public string starting_key {get; construct;} public string selected_key {get; protected set;} + protected Gtk.Box scrolled_box; public static string font = AGSettings.get_string (AGSettings.KEY_FONT_NAME); public static string font_family = "sans"; @@ -33,6 +34,16 @@ public class ToggleBox : Gtk.Box { Object (default_key: default_key, starting_key: starting_key, selected_key: starting_key); + Gtk.ScrolledWindow scrolled_window = new Gtk.ScrolledWindow (null, null); + scrolled_box = new Gtk.Box (Gtk.Orientation.VERTICAL, 2); + add (scrolled_window); + scrolled_window.add (scrolled_box); + scrolled_window.show (); + scrolled_box.show (); + scrolled_window.set_max_content_height (210); // Show a max of 5 sessions + scrolled_window.set_propagate_natural_height (true); + scrolled_window.set_policy (Gtk.PolicyType.NEVER, Gtk.PolicyType.AUTOMATIC); + scrolled_window.set_shadow_type (Gtk.ShadowType.NONE); /* Split font family and size via regular expression. */ Regex font_regexp = new Regex ("^([[:blank:]]*)(?[ a-zA-Z0-9]+) (?[0-9]+)([[:blank:]]*)$"); @@ -55,7 +66,7 @@ public class ToggleBox : Gtk.Box select (item); item.show (); - add (item); + scrolled_box.add (item); } public void set_normal_button_style (Gtk.Button button) -- cgit v1.2.3