diff options
author | Xiang Fan <sfanxiang@gmail.com> | 2017-11-03 22:54:10 +0800 |
---|---|---|
committer | Georges Basile Stavracas Neto <georges.stavracas@gmail.com> | 2018-01-21 13:12:29 -0200 |
commit | 5ad72b6faa0437f1b329f30845fa7cd9216ceee6 (patch) | |
tree | 8d5c3613fc054a2114f2ed9f60d89184f1151665 | |
parent | c12c3b92986191063fc763584f06a7a1a967cc00 (diff) | |
download | gnome-control-center-5ad72b6faa0437f1b329f30845fa7cd9216ceee6.tar.gz |
wifi: Add a refresh button
This way, user can scan anytime without having to wait.
https://bugzilla.gnome.org/show_bug.cgi?id=789869
-rw-r--r-- | panels/network/cc-wifi-panel.c | 22 | ||||
-rw-r--r-- | panels/network/net-device-wifi.c | 16 | ||||
-rw-r--r-- | panels/network/net-device-wifi.h | 1 | ||||
-rw-r--r-- | panels/network/wifi.ui | 28 |
4 files changed, 65 insertions, 2 deletions
diff --git a/panels/network/cc-wifi-panel.c b/panels/network/cc-wifi-panel.c index 7fceb354a..b85e99086 100644 --- a/panels/network/cc-wifi-panel.c +++ b/panels/network/cc-wifi-panel.c @@ -451,6 +451,27 @@ rfkill_switch_notify_activate_cb (GtkSwitch *rfkill_switch, NULL); } +static void +button_refresh_clicked_cb (GtkButton *button, + CcWifiPanel *self) +{ + const gchar *id; + guint i; + + id = gtk_stack_get_visible_child_name (self->stack); + + for (i = 0; i < self->devices->len; i++) + { + NetObject *object = g_ptr_array_index (self->devices, i); + + if (g_strcmp0 (net_object_get_id (object), id) == 0) + { + net_device_wifi_request_scan (NET_DEVICE_WIFI (object)); + break; + } + } +} + /* Overrides */ static const gchar * @@ -595,6 +616,7 @@ cc_wifi_panel_class_init (CcWifiPanelClass *klass) gtk_widget_class_bind_template_child (widget_class, CcWifiPanel, stack); gtk_widget_class_bind_template_callback (widget_class, rfkill_switch_notify_activate_cb); + gtk_widget_class_bind_template_callback (widget_class, button_refresh_clicked_cb); g_object_class_override_property (object_class, PROP_PARAMETERS, "parameters"); } diff --git a/panels/network/net-device-wifi.c b/panels/network/net-device-wifi.c index 2a765da66..8632d6313 100644 --- a/panels/network/net-device-wifi.c +++ b/panels/network/net-device-wifi.c @@ -92,6 +92,22 @@ net_device_wifi_get_title_widget (NetDeviceWifi *device_wifi) return GTK_WIDGET (gtk_builder_get_object (device_wifi->priv->builder, "center_box")); } +void +net_device_wifi_request_scan (NetDeviceWifi *device_wifi) +{ + NMDevice *nm_device; + GError *error = NULL; + + nm_device = net_device_get_nm_device (NET_DEVICE (device_wifi)); + g_return_if_fail (nm_device_get_device_type (nm_device) == NM_DEVICE_TYPE_WIFI); + + nm_device_wifi_request_scan (NM_DEVICE_WIFI (nm_device), NULL, &error); + if (error) { + g_debug ("scan request failed: %s", error->message); + g_error_free (error); + } +} + static GtkWidget * device_wifi_proxy_add_to_stack (NetObject *object, GtkStack *stack, diff --git a/panels/network/net-device-wifi.h b/panels/network/net-device-wifi.h index d8baf5075..0ae1537fe 100644 --- a/panels/network/net-device-wifi.h +++ b/panels/network/net-device-wifi.h @@ -53,6 +53,7 @@ struct _NetDeviceWifiClass GType net_device_wifi_get_type (void) G_GNUC_CONST; GtkWidget *net_device_wifi_get_header_widget (NetDeviceWifi *device_wifi); GtkWidget *net_device_wifi_get_title_widget (NetDeviceWifi *device_wifi); +void net_device_wifi_request_scan (NetDeviceWifi *device_wifi); G_END_DECLS diff --git a/panels/network/wifi.ui b/panels/network/wifi.ui index 8bb01ed82..c15096e49 100644 --- a/panels/network/wifi.ui +++ b/panels/network/wifi.ui @@ -189,14 +189,14 @@ <object class="GtkBox"> <property name="visible">True</property> <property name="hexpand">True</property> - <property name="halign">start</property> <property name="spacing">6</property> + <property name="margin_bottom">6</property> <child> <object class="GtkLabel"> <property name="visible">True</property> <property name="label" translatable="yes">Visible Networks</property> <property name="xalign">0.0</property> - <property name="margin_bottom">12</property> + <property name="margin_bottom">6</property> <attributes> <attribute name="weight" value="bold"/> </attributes> @@ -205,8 +205,32 @@ <child> <object class="GtkSpinner" id="spinner"> <property name="hexpand">True</property> + <property name="margin_bottom">6</property> </object> </child> + <child> + <object class="GtkButton"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="halign">end</property> + <property name="relief">none</property> + <signal name="clicked" handler="button_refresh_clicked_cb" object="CcWifiPanel" swapped="no"/> + <child> + <object class="GtkImage"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="icon_name">view-refresh-symbolic</property> + <property name="icon_size">button</property> + </object> + </child> + <style> + <class name="image-button"/> + </style> + </object> + <packing> + <property name="pack-type">end</property> + </packing> + </child> </object> <packing> <property name="left-attach">1</property> |