diff --git a/panels/network/cc-network-panel.c b/panels/network/cc-network-panel.c index b87e58b45a558fcefc3407bdf4395e0a4cc9a6bb..01b164ea0e739518c1d95ca105f553c7d672a7a0 100644 --- a/panels/network/cc-network-panel.c +++ b/panels/network/cc-network-panel.c @@ -682,11 +682,10 @@ 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); - net_connection_editor_run (editor); + 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)))); + gtk_window_present (GTK_WINDOW (editor)); } static void diff --git a/panels/network/connection-editor/connection-editor.ui b/panels/network/connection-editor/connection-editor.ui index 17a096f8659979d1677bb5189b074a25904cb09c..746e86b1c7d6a3456907cb05160c9da63ea48561 100644 --- a/panels/network/connection-editor/connection-editor.ui +++ b/panels/network/connection-editor/connection-editor.ui @@ -43,6 +43,12 @@ True True + + + True + True + + True diff --git a/panels/network/connection-editor/net-connection-editor.c b/panels/network/connection-editor/net-connection-editor.c index b231caf5332d70d0ebfab01af14d156343ed1db9..505b8ee25b8fb4c993258f1c62cfb9ed0faab544 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; @@ -70,12 +69,10 @@ struct _NetConnectionEditor NMAccessPoint *ap; GSList *initializing_pages; - GSList *pages; NMClientPermissionResult can_modify; gboolean title_set; - gboolean show_when_initialized; }; G_DEFINE_TYPE (NetConnectionEditor, net_connection_editor, GTK_TYPE_DIALOG) @@ -192,14 +189,9 @@ static void net_connection_editor_finalize (GObject *object) { NetConnectionEditor *self = NET_CONNECTION_EDITOR (object); - GSList *l; - - for (l = self->pages; l != NULL; l = l->next) - g_signal_handlers_disconnect_by_func (l->data, page_changed, self); 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 +242,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, @@ -331,7 +323,7 @@ update_sensitivity (NetConnectionEditor *self) { NMSettingConnection *sc; gboolean sensitive; - GSList *l; + GList *pages; if (!editor_is_initialized (self)) return; @@ -344,29 +336,34 @@ update_sensitivity (NetConnectionEditor *self) sensitive = self->can_modify; } - for (l = self->pages; l; l = l->next) - gtk_widget_set_sensitive (GTK_WIDGET (l->data), sensitive); + pages = gtk_container_get_children (GTK_CONTAINER (self->notebook)); + for (GList *l = pages; l; l = l->next) { + CEPage *page = l->data; + gtk_widget_set_sensitive (GTK_WIDGET (page), sensitive); + } } static void validate (NetConnectionEditor *self) { gboolean valid = FALSE; - GSList *l; + GList *pages; if (!editor_is_initialized (self)) goto done; valid = TRUE; - for (l = self->pages; l; l = l->next) { + pages = gtk_container_get_children (GTK_CONTAINER (self->notebook)); + for (GList *l = pages; l; l = l->next) { + CEPage *page = l->data; g_autoptr(GError) error = NULL; - if (!ce_page_validate (CE_PAGE (l->data), self->connection, &error)) { + if (!ce_page_validate (page, self->connection, &error)) { valid = FALSE; if (error) { - g_debug ("Invalid setting %s: %s", ce_page_get_title (CE_PAGE (l->data)), error->message); + g_debug ("Invalid setting %s: %s", ce_page_get_title (page), error->message); } else { - g_debug ("Invalid setting %s", ce_page_get_title (CE_PAGE (l->data))); + g_debug ("Invalid setting %s", ce_page_get_title (page)); } } } @@ -398,11 +395,9 @@ recheck_initialization (NetConnectionEditor *self) if (!editor_is_initialized (self)) return; + gtk_stack_set_visible_child (self->toplevel_stack, GTK_WIDGET (self->notebook)); gtk_notebook_set_current_page (self->notebook, 0); - if (self->show_when_initialized) - gtk_window_present (GTK_WINDOW (self)); - g_idle_add (idle_validate, self); } @@ -429,7 +424,6 @@ page_initialized (NetConnectionEditor *self, GError *error, CEPage *page) gtk_notebook_insert_page (self->notebook, GTK_WIDGET (page), label, i); self->initializing_pages = g_slist_remove (self->initializing_pages, page); - self->pages = g_slist_append (self->pages, page); recheck_initialization (self); } @@ -786,8 +780,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 +792,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) @@ -822,16 +810,6 @@ net_connection_editor_new (GtkWindow *parent_window, return self; } -void -net_connection_editor_run (NetConnectionEditor *self) -{ - if (!editor_is_initialized (self)) { - self->show_when_initialized = TRUE; - return; - } - gtk_window_present (GTK_WINDOW (self)); -} - static void forgotten_cb (GObject *source_object, GAsyncResult *res, diff --git a/panels/network/connection-editor/net-connection-editor.h b/panels/network/connection-editor/net-connection-editor.h index ba4bf34cbc2f76f4f86f652e7e1cd52ea320198c..cbd197f9f2e03ea1745c2a64f4b306cd9c4bef19 100644 --- a/panels/network/connection-editor/net-connection-editor.h +++ b/panels/network/connection-editor/net-connection-editor.h @@ -28,14 +28,12 @@ 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); void net_connection_editor_set_title (NetConnectionEditor *editor, const gchar *title); -void net_connection_editor_run (NetConnectionEditor *editor); void net_connection_editor_forget (NetConnectionEditor *editor); G_END_DECLS diff --git a/panels/network/net-device-ethernet.c b/panels/network/net-device-ethernet.c index 0f652e309d5cae78f030952f41a733d78e7bd86f..73adb62fc38c205f7f2d2c38b47cf842889eaba9 100644 --- a/panels/network/net-device-ethernet.c +++ b/panels/network/net-device-ethernet.c @@ -217,19 +217,17 @@ 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); - net_connection_editor_run (editor); + gtk_window_present (GTK_WINDOW (editor)); } static void @@ -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,11 +409,10 @@ 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); + gtk_window_present (GTK_WINDOW (editor)); } static void diff --git a/panels/network/net-device-wifi.c b/panels/network/net-device-wifi.c index 7f2de4c7f94aa1d99572828230aba69c9ed7d60e..69fe2e122312271e00b981fd9baa79decd6bf445 100644 --- a/panels/network/net-device-wifi.c +++ b/panels/network/net-device-wifi.c @@ -967,16 +967,14 @@ 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); - net_connection_editor_run (editor); + 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)))); + gtk_window_present (GTK_WINDOW (editor)); } static void diff --git a/panels/network/net-vpn.c b/panels/network/net-vpn.c index 89c5777bec045c4785d88058aa4742c07556f164..44400662b56677bab1748de5629c2bf154aae5e5 100644 --- a/panels/network/net-vpn.c +++ b/panels/network/net-vpn.c @@ -150,20 +150,16 @@ 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); g_signal_connect_object (editor, "done", G_CALLBACK (editor_done), self, G_CONNECT_SWAPPED); - net_connection_editor_run (editor); + gtk_window_present (GTK_WINDOW (editor)); } static void