[gnome-control-center] wifi: Add a refresh button
- From: Georges Basile Stavracas Neto <gbsneto src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-control-center] wifi: Add a refresh button
- Date: Sun, 21 Jan 2018 15:13:18 +0000 (UTC)
commit 5ad72b6faa0437f1b329f30845fa7cd9216ceee6
Author: Xiang Fan <sfanxiang gmail com>
Date: Fri Nov 3 22:54:10 2017 +0800
wifi: Add a refresh button
This way, user can scan anytime without having to wait.
https://bugzilla.gnome.org/show_bug.cgi?id=789869
panels/network/cc-wifi-panel.c | 22 ++++++++++++++++++++++
panels/network/net-device-wifi.c | 16 ++++++++++++++++
panels/network/net-device-wifi.h | 1 +
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 7fceb35..b85e990 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 2a765da..8632d63 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 d8baf50..0ae1537 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 8bb01ed..c15096e 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>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]