Skip to content

Commit

Permalink
Remove old HOTSPOT constant and rename CustomMode to ProxyMode
Browse files Browse the repository at this point in the history
  • Loading branch information
milouse committed Oct 10, 2023
1 parent 58c58f8 commit d77491c
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 20 deletions.
4 changes: 1 addition & 3 deletions src/Utils.vala
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,10 @@ namespace Network {
return true;
}

public enum CustomMode {
public enum ProxyMode {
PROXY_NONE = 0,
PROXY_MANUAL,
PROXY_AUTO,
HOTSPOT_ENABLED,
HOTSPOT_DISABLED,
INVALID
}

Expand Down
10 changes: 5 additions & 5 deletions src/Views/ProxyPage.vala
Original file line number Diff line number Diff line change
Expand Up @@ -75,22 +75,22 @@ namespace Network.Widgets {
}

private void update_mode () {
var mode = Utils.CustomMode.INVALID;
var mode = Utils.ProxyMode.INVALID;
switch (Network.Plug.proxy_settings.get_string ("mode")) {
case "none":
mode = Utils.CustomMode.PROXY_NONE;
mode = Utils.ProxyMode.PROXY_NONE;
status_switch.active = false;
break;
case "manual":
mode = Utils.CustomMode.PROXY_MANUAL;
mode = Utils.ProxyMode.PROXY_MANUAL;
status_switch.active = true;
break;
case "auto":
mode = Utils.CustomMode.PROXY_AUTO;
mode = Utils.ProxyMode.PROXY_AUTO;
status_switch.active = true;
break;
default:
mode = Utils.CustomMode.INVALID;
mode = Utils.ProxyMode.INVALID;
break;
}

Expand Down
2 changes: 1 addition & 1 deletion src/Views/VPNPage.vala
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ public class Network.VPNPage : Network.Widgets.Page {
}
}

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

Expand Down
23 changes: 12 additions & 11 deletions src/Widgets/DeviceItem.vala
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ namespace Network.Widgets {
page.bind_property ("title", this, "title");
page.bind_property ("icon-name", this, "icon-name", GLib.BindingFlags.SYNC_CREATE);

switch_status (Utils.CustomMode.INVALID, page.state);
switch_status (Utils.ProxyMode.INVALID, page.state);
page.notify["state"].connect (() => {
switch_status (Utils.CustomMode.INVALID, page.state);
switch_status (Utils.ProxyMode.INVALID, page.state);
});
}

Expand Down Expand Up @@ -101,7 +101,7 @@ namespace Network.Widgets {
show_all ();
}

public void switch_status (Utils.CustomMode custom_mode, NM.DeviceState? state = null) {
public void switch_status (Utils.ProxyMode custom_mode, NM.DeviceState? state = null) {
if (state != null) {
switch (state) {
case NM.DeviceState.ACTIVATED:
Expand All @@ -123,24 +123,25 @@ namespace Network.Widgets {
} else {
subtitle = Utils.state_to_string (state);
}
} else if (custom_mode != Utils.CustomMode.INVALID) {
} else {
switch (custom_mode) {
case Utils.CustomMode.PROXY_NONE:
case Utils.ProxyMode.PROXY_NONE:
subtitle = _("Disabled");
status_image.icon_name = "user-offline";
break;
case Utils.CustomMode.PROXY_MANUAL:
case Utils.ProxyMode.PROXY_MANUAL:
subtitle = _("Enabled (manual mode)");
status_image.icon_name = "user-available";
break;
case Utils.CustomMode.PROXY_AUTO:
case Utils.ProxyMode.PROXY_AUTO:
subtitle = _("Enabled (auto mode)");
status_image.icon_name = "user-available";
break;
default:
// do nothing
return;
}
case Utils.ProxyMode.INVALID:
subtitle = _("Disabled (error)");
status_image.icon_name = "user-busy";
break;
}
}

subtitle = "<span font_size='small'>" + subtitle + "</span>";
Expand Down

0 comments on commit d77491c

Please sign in to comment.