wifi: Add a refresh button
This way, user can scan anytime without having to wait. https://bugzilla.gnome.org/show_bug.cgi?id=789869
This commit is contained in:
parent
c12c3b9298
commit
5ad72b6faa
4 changed files with 65 additions and 2 deletions
|
@ -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");
|
||||
}
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue