[gnome-control-center/wip/networking2: 33/36] network: Update device icons on state changes
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-control-center/wip/networking2: 33/36] network: Update device icons on state changes
- Date: Mon, 7 Jan 2013 05:16:59 +0000 (UTC)
commit 180119e3b7b54286282c861c8c107e6c3bb01dcf
Author: Matthias Clasen <mclasen redhat com>
Date: Mon Jan 7 00:07:38 2013 -0500
network: Update device icons on state changes
The wired icon depends on the state, so should update it
when the state changes.
panels/network/cc-network-panel.c | 34 ++++++++++++++++++++++++++++++----
1 files changed, 30 insertions(+), 4 deletions(-)
---
diff --git a/panels/network/cc-network-panel.c b/panels/network/cc-network-panel.c
index bf48559..2a4ea1c 100644
--- a/panels/network/cc-network-panel.c
+++ b/panels/network/cc-network-panel.c
@@ -97,7 +97,7 @@ enum {
PROP_ARGV
};
-static NetObject *find_in_model_by_id (CcNetworkPanel *panel, const gchar *id);
+static NetObject *find_in_model_by_id (CcNetworkPanel *panel, const gchar *id, GtkTreeIter *iter_out);
static void handle_argv (CcNetworkPanel *panel);
static void
@@ -598,6 +598,28 @@ handle_argv (CcNetworkPanel *panel)
g_debug ("Could not handle argv operation, no matching device yet?");
}
+static void
+state_changed_cb (NMDevice *device,
+ NMDeviceState new_state,
+ NMDeviceState old_state,
+ NMDeviceStateReason reason,
+ CcNetworkPanel *panel)
+{
+ GtkListStore *store;
+ GtkTreeIter iter;
+
+ if (!find_in_model_by_id (panel, nm_device_get_udi (device), &iter)) {
+ return;
+ }
+
+ store = GTK_LIST_STORE (gtk_builder_get_object (panel->priv->builder,
+ "liststore_devices"));
+
+ gtk_list_store_set (store, &iter,
+ PANEL_DEVICES_COLUMN_ICON, panel_device_to_icon_name (device),
+ -1);
+}
+
static gboolean
panel_add_device (CcNetworkPanel *panel, NMDevice *device)
{
@@ -611,7 +633,7 @@ panel_add_device (CcNetworkPanel *panel, NMDevice *device)
GType device_g_type;
/* do we have an existing object with this id? */
- if (find_in_model_by_id (panel, nm_device_get_udi (device)) != NULL)
+ if (find_in_model_by_id (panel, nm_device_get_udi (device), NULL) != NULL)
goto out;
type = nm_device_get_device_type (device);
@@ -671,6 +693,8 @@ panel_add_device (CcNetworkPanel *panel, NMDevice *device)
PANEL_DEVICES_COLUMN_SORT, panel_device_to_sortable_string (device),
PANEL_DEVICES_COLUMN_OBJECT, net_device,
-1);
+ g_signal_connect (device, "state-changed",
+ G_CALLBACK (state_changed_cb), panel);
out:
return FALSE;
@@ -938,7 +962,7 @@ out:
}
static NetObject *
-find_in_model_by_id (CcNetworkPanel *panel, const gchar *id)
+find_in_model_by_id (CcNetworkPanel *panel, const gchar *id, GtkTreeIter *iter_out)
{
gboolean ret;
NetObject *object_tmp;
@@ -967,6 +991,8 @@ find_in_model_by_id (CcNetworkPanel *panel, const gchar *id)
}
} while (object == NULL && gtk_tree_model_iter_next (model, &iter));
out:
+ if (iter_out)
+ *iter_out = iter;
return object;
}
@@ -983,7 +1009,7 @@ panel_add_vpn_device (CcNetworkPanel *panel, NMConnection *connection)
/* does already exist */
id = nm_connection_get_path (connection);
- if (find_in_model_by_id (panel, id) != NULL)
+ if (find_in_model_by_id (panel, id, NULL) != NULL)
return;
/* add as a virtual object */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]