diff options
author | Mohammed Sadiq <sadiq@sadiqpk.org> | 2023-03-22 12:15:57 +0530 |
---|---|---|
committer | Robert Ancell <robert.ancell@gmail.com> | 2023-03-24 00:40:33 +0000 |
commit | 842438b6e160527554c92a6b9508a3a820c44346 (patch) | |
tree | ac22abfe0531dc14cb35a5842e540979731f307e | |
parent | ba13ca1f4a76e7f564e2295bee561e4c45db4a1b (diff) | |
download | gnome-control-center-842438b6e160527554c92a6b9508a3a820c44346.tar.gz |
network: proxy: Add a method to get selected proxy mode
Also replace the code with the method where it's used.
We shall use this elsewhere in the next commit
-rw-r--r-- | panels/network/cc-net-proxy-page.c | 39 |
1 files changed, 27 insertions, 12 deletions
diff --git a/panels/network/cc-net-proxy-page.c b/panels/network/cc-net-proxy-page.c index 9ff78416f..20b1a81b8 100644 --- a/panels/network/cc-net-proxy-page.c +++ b/panels/network/cc-net-proxy-page.c @@ -118,6 +118,32 @@ set_ignore_hosts (const GValue *value, } /* + * Get the currently selected mode, which may not have saved + * to settings yet. This method will always return one of + * %MODE_AUTOMATIC or %MODE_MANUAL, regardless of whether the + * proxy is enabled or not. + */ +static ProxyMode +proxy_get_selected_mode (CcNetProxyPage *self) +{ + guint selected; + + g_assert (CC_IS_NET_PROXY_PAGE (self)); + + selected = adw_combo_row_get_selected (self->proxy_type_row); + + if (selected == ROW_AUTOMATIC) + return MODE_AUTOMATIC; + + if (selected == ROW_MANUAL) + return MODE_MANUAL; + + g_assert_not_reached (); + + return -1; +} + +/* * Get the current mode, which may not have saved * to settings yet */ @@ -125,7 +151,6 @@ static ProxyMode proxy_get_current_mode (CcNetProxyPage *self) { ProxyMode mode; - guint selected; g_assert (CC_IS_NET_PROXY_PAGE (self)); @@ -140,17 +165,7 @@ proxy_get_current_mode (CcNetProxyPage *self) if (self->is_loading) return mode; - selected = adw_combo_row_get_selected (self->proxy_type_row); - - if (selected == ROW_AUTOMATIC) - return MODE_AUTOMATIC; - - if (selected == ROW_MANUAL) - return MODE_MANUAL; - - g_assert_not_reached (); - - return -1; + return proxy_get_selected_mode (self); } static void |