From 71ff4bbfdbc6e989383bfb89478c8585d4a964dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danielle=20For=C3=A9?= Date: Fri, 12 Jan 2024 07:57:51 -0800 Subject: [PATCH] VPNPage: set status through page (#385) * VPNPage: set status through page * Simplify add_interface * Remove unused default arg --------- Co-authored-by: Leo Co-authored-by: Jeremy Wootten --- src/MainView.vala | 24 +++++++++--------------- src/Views/VPNPage.vala | 7 ++----- src/Widgets/DeviceItem.vala | 6 +++--- 3 files changed, 14 insertions(+), 23 deletions(-) diff --git a/src/MainView.vala b/src/MainView.vala index 17904c09..c814e034 100644 --- a/src/MainView.vala +++ b/src/MainView.vala @@ -40,11 +40,10 @@ public class Network.MainView : Gtk.Box { }; proxy.page = new Widgets.ProxyPage (proxy); - var vpn = new Widgets.DeviceItem (_("VPN"), "network-vpn") { + vpn_page = new VPNPage (); + var vpn = new Widgets.DeviceItem.from_page (vpn_page) { item_type = VIRTUAL }; - vpn_page = new VPNPage (vpn); - vpn.page = vpn_page; device_list = new Gtk.ListBox () { activate_on_single_click = true, @@ -265,19 +264,14 @@ public class Network.MainView : Gtk.Box { private void add_interface (Widgets.Page page) { Widgets.DeviceItem item; - if (page is WifiInterface) { - item = new Widgets.DeviceItem.from_page (page); - } else if (page is Widgets.HotspotInterface) { - item = new Widgets.DeviceItem.from_page (page); - item.item_type = VIRTUAL; - } else if (page is Widgets.ModemInterface) { - item = new Widgets.DeviceItem.from_page (page); + if (page is Widgets.HotspotInterface) { + item = new Widgets.DeviceItem.from_page (page) { + item_type = VIRTUAL + }; + } else if (page.device.get_iface ().has_prefix ("usb")) { + item = new Widgets.DeviceItem.from_page (page, "drive-removable-media"); } else { - if (page.device.get_iface ().has_prefix ("usb")) { - item = new Widgets.DeviceItem.from_page (page, "drive-removable-media"); - } else { - item = new Widgets.DeviceItem.from_page (page); - } + item = new Widgets.DeviceItem.from_page (page); } if (content.get_children ().find (page) == null) { diff --git a/src/Views/VPNPage.vala b/src/Views/VPNPage.vala index 7bddad6f..389ed91c 100644 --- a/src/Views/VPNPage.vala +++ b/src/Views/VPNPage.vala @@ -18,7 +18,6 @@ */ public class Network.VPNPage : Network.Widgets.Page { - public Network.Widgets.DeviceItem owner { get; construct; } private Gee.List active_connections; private Gtk.ListBox vpn_list; @@ -26,10 +25,9 @@ public class Network.VPNPage : Network.Widgets.Page { private VPNMenuItem? sel_row; private Granite.Widgets.Toast remove_vpn_toast; - public VPNPage (Network.Widgets.DeviceItem owner) { + public VPNPage () { Object ( - owner: owner, - title: _("Virtual Private Network"), + title: _("VPN"), icon_name: "network-vpn" ); } @@ -195,7 +193,6 @@ public class Network.VPNPage : Network.Widgets.Page { } } - owner.switch_status (Utils.CustomMode.INVALID, state); update_switch (); } diff --git a/src/Widgets/DeviceItem.vala b/src/Widgets/DeviceItem.vala index b82b9505..5ec06997 100644 --- a/src/Widgets/DeviceItem.vala +++ b/src/Widgets/DeviceItem.vala @@ -28,7 +28,7 @@ namespace Network.Widgets { private Gtk.Image status_image; - public DeviceItem (string title, string icon_name = "network-wired") { + public DeviceItem (string title, string icon_name) { Object ( title: title, icon_name: icon_name @@ -43,8 +43,8 @@ namespace Network.Widgets { page: page ); - page.bind_property ("title", this, "title"); - page.bind_property ("icon-name", this, "icon-name", GLib.BindingFlags.SYNC_CREATE); + page.bind_property ("title", this, "title", SYNC_CREATE); + page.bind_property ("icon-name", this, "icon-name", SYNC_CREATE); switch_status (Utils.CustomMode.INVALID, page.state); page.notify["state"].connect (() => {