diff options
author | Mohammed Sadiq <sadiq@sadiqpk.org> | 2020-12-17 17:55:42 +0530 |
---|---|---|
committer | Robert Ancell <robert.ancell@gmail.com> | 2021-01-08 02:54:15 +0000 |
commit | 452439a036ce3072c45f829efabc08981fc551e0 (patch) | |
tree | 4c41f61249ccf01d35729d5bc81958862d90374a | |
parent | ca7002b0ae14d62b00dd93d8dcc77ae434405852 (diff) | |
download | gnome-control-center-452439a036ce3072c45f829efabc08981fc551e0.tar.gz |
wifi: Simplify airplane mode switch
-rw-r--r-- | panels/network/cc-wifi-panel.c | 23 | ||||
-rw-r--r-- | panels/network/cc-wifi-panel.ui | 84 |
2 files changed, 28 insertions, 79 deletions
diff --git a/panels/network/cc-wifi-panel.c b/panels/network/cc-wifi-panel.c index 8608a7fe2..9ca6e6ee5 100644 --- a/panels/network/cc-wifi-panel.c +++ b/panels/network/cc-wifi-panel.c @@ -23,6 +23,7 @@ #include "net-device-wifi.h" #include "network-dialogs.h" #include "panel-common.h" +#include "cc-list-row.h" #include "shell/cc-application.h" #include "shell/cc-debug.h" @@ -48,7 +49,7 @@ struct _CcWifiPanel /* RFKill (Airplane Mode) */ GDBusProxy *rfkill_proxy; - GtkSwitch *rfkill_switch; + CcListRow *rfkill_row; GtkWidget *rfkill_widget; /* Main widgets */ @@ -74,7 +75,7 @@ struct _CcWifiPanel gchar *arg_access_point; }; -static void rfkill_switch_notify_activate_cb (GtkSwitch *rfkill_switch, +static void rfkill_switch_notify_activate_cb (CcListRow *rfkill_row, GParamSpec *pspec, CcWifiPanel *self); @@ -443,7 +444,7 @@ check_main_stack_page (CcWifiPanel *self) nm_version = nm_client_get_version (self->client); wireless_enabled = nm_client_wireless_get_enabled (self->client); - airplane_mode_active = gtk_switch_get_active (self->rfkill_switch); + airplane_mode_active = cc_list_row_get_active (self->rfkill_row); if (!nm_version) gtk_stack_set_visible_child_name (self->main_stack, "nm-not-running"); @@ -507,19 +508,19 @@ sync_airplane_mode_switch (CcWifiPanel *self) enabled |= hw_enabled; - if (enabled != gtk_switch_get_active (self->rfkill_switch)) + if (enabled != cc_list_row_get_active (self->rfkill_row)) { - g_signal_handlers_block_by_func (self->rfkill_switch, + g_signal_handlers_block_by_func (self->rfkill_row, rfkill_switch_notify_activate_cb, self); - gtk_switch_set_active (self->rfkill_switch, enabled); + g_object_set (self->rfkill_row, "active", enabled, NULL); check_main_stack_page (self); - g_signal_handlers_unblock_by_func (self->rfkill_switch, + g_signal_handlers_unblock_by_func (self->rfkill_row, rfkill_switch_notify_activate_cb, self); } - gtk_widget_set_sensitive (GTK_WIDGET (self->rfkill_switch), !hw_enabled); + cc_list_row_set_switch_sensitive (self->rfkill_row, !hw_enabled); check_main_stack_page (self); } @@ -796,13 +797,13 @@ rfkill_proxy_acquired_cb (GObject *source_object, } static void -rfkill_switch_notify_activate_cb (GtkSwitch *rfkill_switch, +rfkill_switch_notify_activate_cb (CcListRow *row, GParamSpec *pspec, CcWifiPanel *self) { gboolean enable; - enable = gtk_switch_get_active (rfkill_switch); + enable = cc_list_row_get_active (row); g_dbus_proxy_call (self->rfkill_proxy, "org.freedesktop.DBus.Properties.Set", @@ -1013,7 +1014,7 @@ cc_wifi_panel_class_init (CcWifiPanelClass *klass) gtk_widget_class_bind_template_child (widget_class, CcWifiPanel, hotspot_box); gtk_widget_class_bind_template_child (widget_class, CcWifiPanel, list_label); gtk_widget_class_bind_template_child (widget_class, CcWifiPanel, main_stack); - gtk_widget_class_bind_template_child (widget_class, CcWifiPanel, rfkill_switch); + gtk_widget_class_bind_template_child (widget_class, CcWifiPanel, rfkill_row); gtk_widget_class_bind_template_child (widget_class, CcWifiPanel, rfkill_widget); gtk_widget_class_bind_template_child (widget_class, CcWifiPanel, spinner); gtk_widget_class_bind_template_child (widget_class, CcWifiPanel, stack); diff --git a/panels/network/cc-wifi-panel.ui b/panels/network/cc-wifi-panel.ui index 783012728..81f4061b0 100644 --- a/panels/network/cc-wifi-panel.ui +++ b/panels/network/cc-wifi-panel.ui @@ -26,78 +26,26 @@ <!-- Airplane Mode --> <child> - <object class="GtkFrame" id="rfkill_widget"> + <object class="GtkListBox" id="rfkill_widget"> <property name="visible">True</property> - <property name="vexpand">False</property> <property name="margin_bottom">32</property> + <property name="selection-mode">none</property> + <style> + <class name="frame"/> + </style> <child> - <object class="GtkListBox"> + <object class="CcListRow" id="rfkill_row"> <property name="visible">True</property> - <property name="selection-mode">none</property> - <child> - <object class="GtkListBoxRow"> - <property name="visible">True</property> - <property name="can-focus">False</property> - <property name="activatable">False</property> - <child> - <object class="GtkGrid"> - <property name="visible">True</property> - <property name="border-width">12</property> - <property name="margin_left">6</property> - <property name="margin_right">6</property> - <property name="column-spacing">12</property> - <property name="row-spacing">2</property> - <child> - <object class="GtkLabel"> - <property name="visible">True</property> - <property name="hexpand">True</property> - <property name="label" translatable="yes">Airplane Mode</property> - <property name="xalign">0.0</property> - <attributes> - <attribute name="weight" value="bold"/> - </attributes> - </object> - <packing> - <property name="left-attach">0</property> - <property name="top-attach">0</property> - </packing> - </child> - <child> - <object class="GtkLabel"> - <property name="visible">True</property> - <property name="hexpand">True</property> - <property name="wrap">True</property> - <property name="label" translatable="yes">Disables Wi-Fi, Bluetooth and mobile broadband</property> - <property name="xalign">0.0</property> - <attributes> - <attribute name="scale" value="0.88"/> - </attributes> - <style> - <class name="dim-label"/> - </style> - </object> - <packing> - <property name="left-attach">0</property> - <property name="top-attach">1</property> - </packing> - </child> - <child> - <object class="GtkSwitch" id="rfkill_switch"> - <property name="visible">True</property> - <property name="can-focus">True</property> - <property name="valign">center</property> - <signal name="notify::active" handler="rfkill_switch_notify_activate_cb" object="CcWifiPanel" swapped="no" /> - </object> - <packing> - <property name="left-attach">1</property> - <property name="top-attach">0</property> - <property name="height">2</property> - </packing> - </child> - </object> - </child> - </object> - </child> + <property name="margin-start">6</property> + <property name="margin-end">6</property> + <property name="margin-top">6</property> + <property name="margin-bottom">6</property> + <property name="activatable">False</property> + <property name="show-switch">True</property> + <property name="bold">True</property> + <property name="title" translatable="yes">Airplane Mode</property> + <property name="subtitle" translatable="yes">Disables Wi-Fi, Bluetooth and mobile broadband</property> + <signal name="notify::active" handler="rfkill_switch_notify_activate_cb" object="CcWifiPanel" swapped="no" /> </object> </child> </object> |