[network-manager-applet/jk/editor-create-connection-rh1255735] editor: read all connections even when we create a new connection (rh #1255735)
- From: Jiří Klimeš <jklimes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [network-manager-applet/jk/editor-create-connection-rh1255735] editor: read all connections even when we create a new connection (rh #1255735)
- Date: Wed, 26 Aug 2015 12:27:24 +0000 (UTC)
commit 8d5e1654d8337da270e547b9872376001258f913
Author: Jiří Klimeš <jklimes redhat com>
Date: Wed Aug 26 14:17:35 2015 +0200
editor: read all connections even when we create a new connection (rh #1255735)
Some connection types may require other connections. For example, when creating
a VLAN connection, we add other connections to "Parent interface" list.
$ nm-connection-editor -t vlan -c
https://bugzilla.redhat.com/show_bug.cgi?id=1255735
src/connection-editor/nm-connection-list.c | 46 ++++++++++++++++++++++++----
src/connection-editor/nm-connection-list.h | 1 +
2 files changed, 41 insertions(+), 6 deletions(-)
---
diff --git a/src/connection-editor/nm-connection-list.c b/src/connection-editor/nm-connection-list.c
index 2f109fc..217dabf 100644
--- a/src/connection-editor/nm-connection-list.c
+++ b/src/connection-editor/nm-connection-list.c
@@ -851,6 +851,8 @@ initial_connections_read (NMRemoteSettings *settings, gpointer user_data)
GtkTreePath *path;
GtkTreeIter iter;
+ list->connections_available = TRUE;
+
g_signal_handlers_disconnect_by_func (settings, G_CALLBACK (initial_connections_read), list);
if (gtk_tree_model_get_iter_first (GTK_TREE_MODEL (list->sortable), &iter)) {
@@ -932,6 +934,33 @@ nm_connection_list_set_type (NMConnectionList *self, GType ctype)
self->displayed_type = ctype;
}
+typedef struct {
+ NMConnectionList *self;
+ const char *detail;
+ PageNewConnectionFunc new_connection_func;
+} CreateConnectionData;
+
+static gboolean
+create_connection (CreateConnectionData *data)
+{
+ static guint idle_func_id = 0;
+
+ if (data->self->connections_available) {
+ new_connection_of_type (GTK_WINDOW (data->self->dialog),
+ data->detail,
+ data->self->settings,
+ data->new_connection_func,
+ really_add_connection,
+ data->self);
+ g_slice_free (CreateConnectionData, data);
+ return FALSE;
+ } else {
+ if (!idle_func_id)
+ idle_func_id = g_idle_add ((GSourceFunc) create_connection, data);
+ return TRUE;
+ }
+}
+
void
nm_connection_list_create (NMConnectionList *self, GType ctype, const char *detail)
{
@@ -957,12 +986,17 @@ nm_connection_list_create (NMConnectionList *self, GType ctype, const char *deta
nm_connection_editor_error (NULL, _("Error creating connection"), error_msg);
g_free (error_msg);
} else {
- new_connection_of_type (GTK_WINDOW (self->dialog),
- detail,
- self->settings,
- types[i].new_connection_func,
- really_add_connection,
- self);
+ CreateConnectionData *data;
+
+ data = g_slice_new0 (CreateConnectionData);
+ data->self = self;
+ data->detail = detail;
+ data->new_connection_func = types[i].new_connection_func;
+
+ /* We need a complete list of connections even when creating a new
+ * connection, because we may depend on another connection. Thus we
+ * have to wait for connections to be available. */
+ create_connection (data);
}
}
diff --git a/src/connection-editor/nm-connection-list.h b/src/connection-editor/nm-connection-list.h
index e77c58a..4eda1de 100644
--- a/src/connection-editor/nm-connection-list.h
+++ b/src/connection-editor/nm-connection-list.h
@@ -50,6 +50,7 @@ typedef struct {
GtkWidget *dialog;
gboolean signals_connected;
+ gboolean connections_available;
} NMConnectionList;
typedef struct {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]