150 lines
5.6 KiB
Diff
150 lines
5.6 KiB
Diff
From 381bf2e84fbd5728dbe967a1ab4efda95654a3e4 Mon Sep 17 00:00:00 2001
|
|
From: Beniamino Galvani <bgalvani@redhat.com>
|
|
Date: Sat, 12 Jan 2019 21:43:21 +0100
|
|
Subject: [PATCH 1/2] wifi-dialog: remember the specific_connection construct
|
|
parameter
|
|
|
|
The specific_connection parameter is passed to
|
|
connection_combo_init(), which stores the connection in
|
|
priv->connection. When the user changes device, device_combo_changed()
|
|
calls again connection_combo_init() passing a NULL argument and so the
|
|
specific connection gets lost.
|
|
|
|
Store the specific_connection in the dialog private data and use it
|
|
when the connection combo is re-initialized.
|
|
|
|
https://bugzilla.redhat.com/show_bug.cgi?id=1665653
|
|
(cherry picked from commit 348cc284bf3497dcef6394e8438a9c4a8411852e)
|
|
---
|
|
src/libnma/nma-wifi-dialog.c | 19 ++++++++++++-------
|
|
1 file changed, 12 insertions(+), 7 deletions(-)
|
|
|
|
diff --git a/src/libnma/nma-wifi-dialog.c b/src/libnma/nma-wifi-dialog.c
|
|
index 3ac5fd68..8d05e585 100644
|
|
--- a/src/libnma/nma-wifi-dialog.c
|
|
+++ b/src/libnma/nma-wifi-dialog.c
|
|
@@ -48,6 +48,7 @@ typedef struct {
|
|
|
|
GtkBuilder *builder;
|
|
|
|
+ NMConnection *specific_connection;
|
|
NMConnection *connection;
|
|
NMDevice *device;
|
|
NMAccessPoint *ap;
|
|
@@ -421,7 +422,7 @@ alphabetize_connections (NMConnection *a, NMConnection *b)
|
|
}
|
|
|
|
static gboolean
|
|
-connection_combo_init (NMAWifiDialog *self, NMConnection *connection)
|
|
+connection_combo_init (NMAWifiDialog *self)
|
|
{
|
|
NMAWifiDialogPrivate *priv = NMA_WIFI_DIALOG_GET_PRIVATE (self);
|
|
GtkListStore *store;
|
|
@@ -439,8 +440,8 @@ connection_combo_init (NMAWifiDialog *self, NMConnection *connection)
|
|
store = gtk_list_store_new (4, G_TYPE_STRING, G_TYPE_OBJECT, G_TYPE_BOOLEAN, G_TYPE_BOOLEAN);
|
|
priv->connection_model = GTK_TREE_MODEL (store);
|
|
|
|
- if (connection) {
|
|
- s_con = nm_connection_get_setting_connection (connection);
|
|
+ if (priv->specific_connection) {
|
|
+ s_con = nm_connection_get_setting_connection (priv->specific_connection);
|
|
g_assert (s_con);
|
|
id = nm_setting_connection_get_id (s_con);
|
|
if (id == NULL) {
|
|
@@ -454,7 +455,7 @@ connection_combo_init (NMAWifiDialog *self, NMConnection *connection)
|
|
gtk_list_store_append (store, &tree_iter);
|
|
gtk_list_store_set (store, &tree_iter,
|
|
C_NAME_COLUMN, id,
|
|
- C_CON_COLUMN, connection, -1);
|
|
+ C_CON_COLUMN, priv->specific_connection, -1);
|
|
} else {
|
|
GSList *to_add = NULL, *iter;
|
|
const GPtrArray *connections;
|
|
@@ -551,7 +552,7 @@ connection_combo_init (NMAWifiDialog *self, NMConnection *connection)
|
|
gtk_combo_box_set_active (GTK_COMBO_BOX (widget), 0);
|
|
g_signal_connect (G_OBJECT (widget), "changed",
|
|
G_CALLBACK (connection_combo_changed), self);
|
|
- if (connection || !num_added) {
|
|
+ if (priv->specific_connection || !num_added) {
|
|
gtk_widget_hide (GTK_WIDGET (gtk_builder_get_object (priv->builder, "connection_label")));
|
|
gtk_widget_hide (widget);
|
|
}
|
|
@@ -579,7 +580,7 @@ device_combo_changed (GtkWidget *combo,
|
|
g_object_unref (priv->device);
|
|
gtk_tree_model_get (model, &iter, D_DEV_COLUMN, &priv->device, -1);
|
|
|
|
- if (!connection_combo_init (self, NULL)) {
|
|
+ if (!connection_combo_init (self)) {
|
|
g_warning ("Couldn't change connection combo box.");
|
|
return;
|
|
}
|
|
@@ -1053,6 +1054,9 @@ internal_init (NMAWifiDialog *self,
|
|
else
|
|
icon_name = "network-wireless";
|
|
|
|
+ if (specific_connection)
|
|
+ priv->specific_connection = g_object_ref (specific_connection);
|
|
+
|
|
gtk_window_set_icon_name (GTK_WINDOW (self), icon_name);
|
|
widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "image1"));
|
|
gtk_image_set_from_icon_name (GTK_IMAGE (widget), icon_name, GTK_ICON_SIZE_DIALOG);
|
|
@@ -1104,7 +1108,7 @@ internal_init (NMAWifiDialog *self,
|
|
return FALSE;
|
|
}
|
|
|
|
- if (!connection_combo_init (self, specific_connection)) {
|
|
+ if (!connection_combo_init (self)) {
|
|
g_warning ("Couldn't set up connection combo box.");
|
|
return FALSE;
|
|
}
|
|
@@ -1401,6 +1405,7 @@ dispose (GObject *object)
|
|
|
|
g_clear_object (&priv->group);
|
|
|
|
+ g_clear_object (&priv->specific_connection);
|
|
g_clear_object (&priv->connection);
|
|
|
|
g_clear_object (&priv->device);
|
|
--
|
|
2.20.1
|
|
|
|
From b972be7df89f127bc64342f221b7a31197eff8bf Mon Sep 17 00:00:00 2001
|
|
From: Beniamino Galvani <bgalvani@redhat.com>
|
|
Date: Sat, 12 Jan 2019 22:35:10 +0100
|
|
Subject: [PATCH 2/2] wifi-dialog: fix connection combo signals
|
|
|
|
We need to connect to "changed" signal only when the widget is
|
|
displayed. Also, connection_combo_init() can be called multiple times
|
|
and so we need to clear previous handlers registration or the
|
|
function can be called multiple times.
|
|
|
|
(cherry picked from commit cf176a76898e6e06a1524f3f98bfcfdf842747f6)
|
|
---
|
|
src/libnma/nma-wifi-dialog.c | 7 +++++--
|
|
1 file changed, 5 insertions(+), 2 deletions(-)
|
|
|
|
diff --git a/src/libnma/nma-wifi-dialog.c b/src/libnma/nma-wifi-dialog.c
|
|
index 8d05e585..6b68e601 100644
|
|
--- a/src/libnma/nma-wifi-dialog.c
|
|
+++ b/src/libnma/nma-wifi-dialog.c
|
|
@@ -550,11 +550,14 @@ connection_combo_init (NMAWifiDialog *self)
|
|
NULL);
|
|
|
|
gtk_combo_box_set_active (GTK_COMBO_BOX (widget), 0);
|
|
- g_signal_connect (G_OBJECT (widget), "changed",
|
|
- G_CALLBACK (connection_combo_changed), self);
|
|
+
|
|
+ g_signal_handlers_disconnect_by_func (widget, connection_combo_changed, self);
|
|
if (priv->specific_connection || !num_added) {
|
|
gtk_widget_hide (GTK_WIDGET (gtk_builder_get_object (priv->builder, "connection_label")));
|
|
gtk_widget_hide (widget);
|
|
+ } else {
|
|
+ g_signal_connect (widget, "changed",
|
|
+ G_CALLBACK (connection_combo_changed), self);
|
|
}
|
|
if (gtk_tree_model_get_iter_first (priv->connection_model, &tree_iter))
|
|
gtk_tree_model_get (priv->connection_model, &tree_iter, C_CON_COLUMN, &priv->connection, -1);
|
|
--
|
|
2.20.1
|
|
|