Skip to content

Commit

Permalink
VPNPage: set status through page (#385)
Browse files Browse the repository at this point in the history
* VPNPage: set status through page

* Simplify add_interface

* Remove unused default arg

---------

Co-authored-by: Leo <lenemter@gmail.com>
Co-authored-by: Jeremy Wootten <jeremywootten@gmail.com>
  • Loading branch information
3 people authored Jan 12, 2024
1 parent 79953a9 commit 71ff4bb
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 23 deletions.
24 changes: 9 additions & 15 deletions src/MainView.vala
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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) {
Expand Down
7 changes: 2 additions & 5 deletions src/Views/VPNPage.vala
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,16 @@
*/

public class Network.VPNPage : Network.Widgets.Page {
public Network.Widgets.DeviceItem owner { get; construct; }
private Gee.List<NM.ActiveConnection> active_connections;

private Gtk.ListBox vpn_list;
private uint timeout_id = 0;
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"
);
}
Expand Down Expand Up @@ -195,7 +193,6 @@ public class Network.VPNPage : Network.Widgets.Page {
}
}

owner.switch_status (Utils.CustomMode.INVALID, state);
update_switch ();
}

Expand Down
6 changes: 3 additions & 3 deletions src/Widgets/DeviceItem.vala
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 (() => {
Expand Down

0 comments on commit 71ff4bb

Please sign in to comment.