[network-manager-applet/danw/bridge: 1/3] connection-editor: update bond page when slave connection changes name
- From: Dan Winship <danw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [network-manager-applet/danw/bridge: 1/3] connection-editor: update bond page when slave connection changes name
- Date: Fri, 2 Nov 2012 15:04:03 +0000 (UTC)
commit 4d3b31719697d3476252ecb16dfc1776414d8c80
Author: Dan Winship <danw gnome org>
Date: Thu Nov 1 18:05:03 2012 -0400
connection-editor: update bond page when slave connection changes name
src/connection-editor/page-bond.c | 65 +++++++++++++++++++++++++++----------
1 files changed, 48 insertions(+), 17 deletions(-)
---
diff --git a/src/connection-editor/page-bond.c b/src/connection-editor/page-bond.c
index 67056e7..ba2b766 100644
--- a/src/connection-editor/page-bond.c
+++ b/src/connection-editor/page-bond.c
@@ -199,6 +199,27 @@ stuff_changed (GtkWidget *w, gpointer user_data)
ce_page_changed (CE_PAGE (user_data));
}
+static gboolean
+find_connection (CEPageBond *self, NMRemoteConnection *connection, GtkTreeIter *iter)
+{
+ CEPageBondPrivate *priv = CE_PAGE_BOND_GET_PRIVATE (self);
+
+ if (!gtk_tree_model_get_iter_first (priv->connections_model, iter))
+ return FALSE;
+
+ do {
+ NMRemoteConnection *candidate = NULL;
+
+ gtk_tree_model_get (priv->connections_model, iter,
+ COL_CONNECTION, &candidate,
+ -1);
+ if (candidate == connection)
+ return TRUE;
+ } while (gtk_tree_model_iter_next (priv->connections_model, iter));
+
+ return FALSE;
+}
+
static void
connection_removed (NMRemoteConnection *connection, gpointer user_data)
{
@@ -206,26 +227,34 @@ connection_removed (NMRemoteConnection *connection, gpointer user_data)
CEPageBondPrivate *priv = CE_PAGE_BOND_GET_PRIVATE (self);
GtkTreeIter iter;
- if (!gtk_tree_model_get_iter_first (priv->connections_model, &iter))
+ if (!find_connection (self, connection, &iter))
return;
- do {
- NMRemoteConnection *candidate = NULL;
+ gtk_list_store_remove (GTK_LIST_STORE (priv->connections_model), &iter);
+ stuff_changed (NULL, self);
- gtk_tree_model_get (priv->connections_model, &iter,
- COL_CONNECTION, &candidate,
- -1);
- if (candidate == connection) {
- gtk_list_store_remove (GTK_LIST_STORE (priv->connections_model), &iter);
- stuff_changed (NULL, self);
-
- if (!gtk_tree_model_get_iter_first (priv->connections_model, &iter)) {
- priv->slave_type = G_TYPE_INVALID;
- priv->new_slave_func = NULL;
- }
- return;
- }
- } while (gtk_tree_model_iter_next (priv->connections_model, &iter));
+ if (!gtk_tree_model_get_iter_first (priv->connections_model, &iter)) {
+ priv->slave_type = G_TYPE_INVALID;
+ priv->new_slave_func = NULL;
+ }
+}
+
+static void
+connection_updated (NMRemoteConnection *connection, gpointer user_data)
+{
+ CEPageBond *self = CE_PAGE_BOND (user_data);
+ CEPageBondPrivate *priv = CE_PAGE_BOND_GET_PRIVATE (self);
+ GtkTreeIter iter;
+ NMSettingConnection *s_con;
+
+ if (!find_connection (self, connection, &iter))
+ return;
+
+ /* Name might have changed */
+ s_con = nm_connection_get_setting_connection (NM_CONNECTION (connection));
+ gtk_list_store_set (GTK_LIST_STORE (priv->connections_model), &iter,
+ COL_NAME, nm_setting_connection_get_id (s_con),
+ -1);
}
static void
@@ -283,6 +312,8 @@ connection_added (NMRemoteSettings *settings,
g_signal_connect (connection, NM_REMOTE_CONNECTION_REMOVED,
G_CALLBACK (connection_removed), self);
+ g_signal_connect (connection, NM_REMOTE_CONNECTION_UPDATED,
+ G_CALLBACK (connection_updated), self);
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]