[gnome-control-center] network: Set transient window from outside NetConnectionEditor constructor
- From: Georges Basile Stavracas Neto <gbsneto src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-control-center] network: Set transient window from outside NetConnectionEditor constructor
- Date: Thu, 17 Dec 2020 21:31:04 +0000 (UTC)
commit a1e26cdac16c2b9c3e20c335e265b342e95d6114
Author: Robert Ancell <robert ancell canonical com>
Date: Thu Nov 19 11:17:22 2020 +1300
network: Set transient window from outside NetConnectionEditor constructor
panels/network/cc-network-panel.c | 5 ++---
panels/network/connection-editor/net-connection-editor.c | 12 ++----------
panels/network/connection-editor/net-connection-editor.h | 3 +--
panels/network/net-device-ethernet.c | 12 ++++--------
panels/network/net-device-wifi.c | 6 ++----
panels/network/net-vpn.c | 8 ++------
6 files changed, 13 insertions(+), 33 deletions(-)
---
diff --git a/panels/network/cc-network-panel.c b/panels/network/cc-network-panel.c
index b87e58b45..0bfd14b72 100644
--- a/panels/network/cc-network-panel.c
+++ b/panels/network/cc-network-panel.c
@@ -682,10 +682,9 @@ create_connection_cb (GtkWidget *button,
CcNetworkPanel *self)
{
NetConnectionEditor *editor;
- GtkWindow *toplevel;
- toplevel = GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (self)));
- editor = net_connection_editor_new (toplevel, NULL, NULL, NULL, self->client);
+ editor = net_connection_editor_new (NULL, NULL, NULL, self->client);
+ gtk_window_set_transient_for (GTK_WINDOW (editor), GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET
(self))));
net_connection_editor_run (editor);
}
diff --git a/panels/network/connection-editor/net-connection-editor.c
b/panels/network/connection-editor/net-connection-editor.c
index b231caf53..4233d7393 100644
--- a/panels/network/connection-editor/net-connection-editor.c
+++ b/panels/network/connection-editor/net-connection-editor.c
@@ -59,7 +59,6 @@ struct _NetConnectionEditor
GtkNotebook *notebook;
GtkStack *toplevel_stack;
- GtkWidget *parent_window;
NMClient *client;
NMDevice *device;
@@ -199,7 +198,6 @@ net_connection_editor_finalize (GObject *object)
g_clear_object (&self->connection);
g_clear_object (&self->orig_connection);
- g_clear_object (&self->parent_window);
g_clear_object (&self->device);
g_clear_object (&self->client);
g_clear_object (&self->ap);
@@ -250,7 +248,7 @@ net_connection_editor_error_dialog (NetConnectionEditor *self,
if (gtk_widget_is_visible (GTK_WIDGET (self)))
parent = GTK_WINDOW (self);
else
- parent = GTK_WINDOW (self->parent_window);
+ parent = gtk_window_get_transient_for (GTK_WINDOW (self));
dialog = gtk_message_dialog_new (parent,
GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
@@ -786,8 +784,7 @@ permission_changed (NetConnectionEditor *self,
}
NetConnectionEditor *
-net_connection_editor_new (GtkWindow *parent_window,
- NMConnection *connection,
+net_connection_editor_new (NMConnection *connection,
NMDevice *device,
NMAccessPoint *ap,
NMClient *client)
@@ -799,11 +796,6 @@ net_connection_editor_new (GtkWindow *parent_window,
"use-header-bar", 1,
NULL);
- if (parent_window) {
- self->parent_window = GTK_WIDGET (g_object_ref (parent_window));
- gtk_window_set_transient_for (GTK_WINDOW (self),
- parent_window);
- }
if (ap)
self->ap = g_object_ref (ap);
if (device)
diff --git a/panels/network/connection-editor/net-connection-editor.h
b/panels/network/connection-editor/net-connection-editor.h
index ba4bf34cb..c8132e39e 100644
--- a/panels/network/connection-editor/net-connection-editor.h
+++ b/panels/network/connection-editor/net-connection-editor.h
@@ -28,8 +28,7 @@ G_BEGIN_DECLS
G_DECLARE_FINAL_TYPE (NetConnectionEditor, net_connection_editor, NET, CONNECTION_EDITOR, GtkDialog)
-NetConnectionEditor *net_connection_editor_new (GtkWindow *parent_window,
- NMConnection *connection,
+NetConnectionEditor *net_connection_editor_new (NMConnection *connection,
NMDevice *device,
NMAccessPoint *ap,
NMClient *client);
diff --git a/panels/network/net-device-ethernet.c b/panels/network/net-device-ethernet.c
index 0f652e309..ac019f684 100644
--- a/panels/network/net-device-ethernet.c
+++ b/panels/network/net-device-ethernet.c
@@ -217,15 +217,13 @@ show_details (NetDeviceEthernet *self, GtkButton *button, const gchar *title)
{
GtkWidget *row;
NMConnection *connection;
- GtkWidget *window;
NetConnectionEditor *editor;
- window = gtk_widget_get_toplevel (GTK_WIDGET (self));
-
row = g_object_get_data (G_OBJECT (button), "row");
connection = NM_CONNECTION (g_object_get_data (G_OBJECT (row), "connection"));
- editor = net_connection_editor_new (GTK_WINDOW (window), connection, self->device, NULL,
self->client);
+ editor = net_connection_editor_new (connection, self->device, NULL, self->client);
+ gtk_window_set_transient_for (GTK_WINDOW (editor), GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET
(self))));
if (title)
net_connection_editor_set_title (editor, title);
g_signal_connect_object (editor, "done", G_CALLBACK (editor_done), self, G_CONNECT_SWAPPED);
@@ -391,7 +389,6 @@ add_profile_button_clicked_cb (NetDeviceEthernet *self)
g_autofree gchar *uuid = NULL;
g_autofree gchar *id = NULL;
NetConnectionEditor *editor;
- GtkWidget *window;
const GPtrArray *connections;
connection = nm_simple_connection_new ();
@@ -412,9 +409,8 @@ add_profile_button_clicked_cb (NetDeviceEthernet *self)
nm_connection_add_setting (connection, nm_setting_wired_new ());
- window = gtk_widget_get_toplevel (GTK_WIDGET (self));
-
- editor = net_connection_editor_new (GTK_WINDOW (window), connection, self->device, NULL,
self->client);
+ editor = net_connection_editor_new (connection, self->device, NULL, self->client);
+ gtk_window_set_transient_for (GTK_WINDOW (editor), GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET
(self))));
g_signal_connect_object (editor, "done", G_CALLBACK (editor_done), self, G_CONNECT_SWAPPED);
net_connection_editor_run (editor);
}
diff --git a/panels/network/net-device-wifi.c b/panels/network/net-device-wifi.c
index 7f2de4c7f..8d262fd80 100644
--- a/panels/network/net-device-wifi.c
+++ b/panels/network/net-device-wifi.c
@@ -967,15 +967,13 @@ show_details_for_row (NetDeviceWifi *self, CcWifiConnectionRow *row, CcWifiConne
{
NMConnection *connection;
NMAccessPoint *ap;
- GtkWidget *window;
NetConnectionEditor *editor;
- window = gtk_widget_get_toplevel (GTK_WIDGET (row));
-
connection = cc_wifi_connection_row_get_connection (row);
ap = cc_wifi_connection_row_best_access_point (row);
- editor = net_connection_editor_new (GTK_WINDOW (window), connection, self->device, ap, self->client);
+ editor = net_connection_editor_new (connection, self->device, ap, self->client);
+ gtk_window_set_transient_for (GTK_WINDOW (editor), GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET
(row))));
net_connection_editor_run (editor);
}
diff --git a/panels/network/net-vpn.c b/panels/network/net-vpn.c
index 89c5777be..a1b8821ba 100644
--- a/panels/network/net-vpn.c
+++ b/panels/network/net-vpn.c
@@ -150,15 +150,11 @@ editor_done (NetVpn *self)
static void
edit_connection (NetVpn *self)
{
- GtkWidget *window;
NetConnectionEditor *editor;
g_autofree gchar *title = NULL;
- window = gtk_widget_get_toplevel (GTK_WIDGET (self));
-
- editor = net_connection_editor_new (GTK_WINDOW (window),
- self->connection,
- NULL, NULL, self->client);
+ editor = net_connection_editor_new (self->connection, NULL, NULL, self->client);
+ gtk_window_set_transient_for (GTK_WINDOW (editor), GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET
(self))));
title = g_strdup_printf (_("%s VPN"), nm_connection_get_id (self->connection));
net_connection_editor_set_title (editor, title);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]