[gnome-control-center] network: ensure we refresh the UI if coldplug devices are changed
- From: Richard Hughes <rhughes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-control-center] network: ensure we refresh the UI if coldplug devices are changed
- Date: Fri, 11 Mar 2011 16:13:59 +0000 (UTC)
commit ed04eaeb03512e6f1a6e98580e047c6332af0a5d
Author: Richard Hughes <richard hughsie com>
Date: Fri Mar 11 16:13:17 2011 +0000
network: ensure we refresh the UI if coldplug devices are changed
panels/network/cc-network-panel.c | 36 ++++++++++++++++++++----------------
panels/network/net-device.c | 14 ++++++++++++++
2 files changed, 34 insertions(+), 16 deletions(-)
---
diff --git a/panels/network/cc-network-panel.c b/panels/network/cc-network-panel.c
index 5bf4e8b..8e28d01 100644
--- a/panels/network/cc-network-panel.c
+++ b/panels/network/cc-network-panel.c
@@ -372,6 +372,20 @@ out:
}
static void
+device_state_notify_changed_cb (NMDevice *device,
+ GParamSpec *pspec,
+ gpointer user_data)
+{
+ CcNetworkPanel *panel = CC_NETWORK_PANEL (user_data);
+
+ /* only refresh the selected device */
+ if (g_strcmp0 (panel->priv->current_device,
+ nm_device_get_udi (device)) == 0) {
+ nm_device_refresh_device_ui (panel, device);
+ }
+}
+
+static void
panel_add_device (CcNetworkPanel *panel, NMDevice *device)
{
GtkListStore *liststore_devices;
@@ -387,6 +401,8 @@ panel_add_device (CcNetworkPanel *panel, NMDevice *device)
g_ptr_array_add (panel->priv->devices,
g_object_ref (device));
+ g_signal_connect (G_OBJECT (device), "notify::state",
+ (GCallback) device_state_notify_changed_cb, panel);
/* do we have to get additonal data from ModemManager */
type = nm_device_get_device_type (device);
@@ -583,6 +599,7 @@ add_access_point (CcNetworkPanel *panel, NMAccessPoint *ap, NMAccessPoint *activ
}
}
+#if 0
static gchar *
ip4_address_as_string (guint32 ip)
{
@@ -655,6 +672,7 @@ panel_show_ip4_config (NMIP4Config *cfg)
}
}
}
+#endif
static GPtrArray *
panel_get_strongest_unique_aps (const GPtrArray *aps)
@@ -855,9 +873,11 @@ nm_device_refresh_device_ui (CcNetworkPanel *panel, NMDevice *device)
if (sub_pane == NULL)
goto out;
+#if 0
/* FIXME? should we need to do something with this? */
if (state == NM_DEVICE_STATE_ACTIVATED)
panel_show_ip4_config (nm_device_get_ip4_config (device));
+#endif
if (type == NM_DEVICE_TYPE_ETHERNET) {
@@ -1220,26 +1240,10 @@ active_connections_changed (NMClient *client, GParamSpec *pspec, gpointer user_d
}
static void
-device_state_notify_changed_cb (NMDevice *device,
- GParamSpec *pspec,
- gpointer user_data)
-{
- CcNetworkPanel *panel = CC_NETWORK_PANEL (user_data);
-
- /* only refresh the selected device */
- if (g_strcmp0 (panel->priv->current_device,
- nm_device_get_udi (device)) == 0) {
- nm_device_refresh_device_ui (panel, device);
- }
-}
-
-static void
device_added_cb (NMClient *client, NMDevice *device, CcNetworkPanel *panel)
{
g_debug ("New device added");
panel_add_device (panel, device);
- g_signal_connect (G_OBJECT (device), "notify::state",
- (GCallback) device_state_notify_changed_cb, NULL);
}
static void
diff --git a/panels/network/net-device.c b/panels/network/net-device.c
index 0743cd4..bcb7253 100644
--- a/panels/network/net-device.c
+++ b/panels/network/net-device.c
@@ -35,10 +35,24 @@ struct _NetDevicePrivate
G_DEFINE_TYPE (NetDevice, net_device, NET_TYPE_OBJECT)
+static void
+state_changed_cb (NMDevice *device,
+ NMDeviceState new_state,
+ NMDeviceState old_state,
+ NMDeviceStateReason reason,
+ NetDevice *net_device)
+{
+ net_object_emit_changed (NET_OBJECT (net_device));
+}
+
void
net_device_set_nm_device (NetDevice *device, NMDevice *nm_device)
{
device->priv->nm_device = g_object_ref (nm_device);
+ g_signal_connect (nm_device,
+ "state-changed",
+ G_CALLBACK (state_changed_cb),
+ device);
}
NMDevice *
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]