From a69570a2c77bce463cb501e553d01b83a1d99474 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danielle=20For=C3=A9?= Date: Sat, 6 Jan 2024 20:19:18 -0800 Subject: [PATCH] MainView: Gtk4 prep and cleanup (#366) * MainView: Gtk4 prep and cleanup * explicit expands --- src/MainView.vala | 47 ++++++++++++++++++----------------------------- 1 file changed, 18 insertions(+), 29 deletions(-) diff --git a/src/MainView.vala b/src/MainView.vala index 9f1b8e70..806d6685 100644 --- a/src/MainView.vala +++ b/src/MainView.vala @@ -17,7 +17,7 @@ * Authored by: Adam Bieńkowski */ -public class Network.MainView : Gtk.Paned { +public class Network.MainView : Gtk.Box { protected GLib.List? network_interface; public NM.DeviceState state { private set; get; default = NM.DeviceState.PREPARE; } @@ -30,7 +30,10 @@ public class Network.MainView : Gtk.Paned { construct { network_interface = new GLib.List (); - device_list = new Widgets.DeviceList (); + device_list = new Widgets.DeviceList () { + hexpand = true, + vexpand = true + }; var footer = new Widgets.Footer (); @@ -60,19 +63,20 @@ public class Network.MainView : Gtk.Paned { content.add_named (no_devices, "no-devices-info"); var scrolled_window = new Gtk.ScrolledWindow (null, null) { - expand = true + child = device_list }; - scrolled_window.add (device_list); - var sidebar = new Gtk.Grid () { - orientation = Gtk.Orientation.VERTICAL - }; + var sidebar = new Gtk.Box (VERTICAL, 0); sidebar.add (scrolled_window); sidebar.add (footer); - position = 240; - pack1 (sidebar, false, false); - pack2 (content, true, false); + var paned = new Gtk.Paned (HORIZONTAL) { + position = 200 + }; + paned.pack1 (sidebar, false, false); + paned.pack2 (content, true, false); + + add (paned); device_list.row_activated.connect ((row) => { var page = ((Widgets.DeviceItem)row).page; @@ -107,7 +111,7 @@ public class Network.MainView : Gtk.Paned { nm_client.device_removed.connect (device_removed_cb); nm_client.get_devices ().foreach ((device) => device_added_cb (device)); - nm_client.get_connections ().foreach ((connection) => add_connection (connection)); + nm_client.get_connections ().foreach ((connection) => device_list.add_connection (connection)); show_all (); } @@ -146,13 +150,13 @@ public class Network.MainView : Gtk.Paned { private void connection_added_cb (Object obj) { var connection = (NM.RemoteConnection)obj; - add_connection (connection); + device_list.add_connection (connection); } private void connection_removed_cb (Object obj) { var connection = (NM.RemoteConnection)obj; - remove_connection (connection); + device_list.add_connection (connection); } private void device_added_cb (NM.Device device) { @@ -196,10 +200,7 @@ public class Network.MainView : Gtk.Paned { } update_interfaces_names (); - update_all (); - } - private void update_all () { foreach (var inter in network_interface) { inter.update (); } @@ -231,7 +232,7 @@ public class Network.MainView : Gtk.Paned { if (row != null && row.get_index () >= 0) { device_list.get_row_at_index (index).activate (); } else { - select_first (); + device_list.select_first_item (); } } else { device_list.remove_iface_from_list (widget_interface); @@ -240,18 +241,6 @@ public class Network.MainView : Gtk.Paned { widget_interface.destroy (); } - private void add_connection (NM.RemoteConnection connection) { - device_list.add_connection (connection); - } - - private void remove_connection (NM.RemoteConnection connection) { - device_list.remove_connection (connection); - } - - private void select_first () { - device_list.select_first_item (); - } - private void update_networking_state () { unowned NetworkManager network_manager = NetworkManager.get_default (); if (network_manager.client.networking_get_enabled ()) {