network: Set transient window from outside NetConnectionEditor constructor

This commit is contained in:
Robert Ancell 2020-11-19 11:17:22 +13:00 committed by Georges Basile Stavracas Neto
parent 2d8e3d786e
commit a1e26cdac1
6 changed files with 13 additions and 33 deletions

View file

@ -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);
}

View file

@ -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)

View file

@ -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);

View file

@ -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);
}

View file

@ -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);
}

View file

@ -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);