From f95d5e830f20c5e4a2ec256e62225d184fd38544 Mon Sep 17 00:00:00 2001 From: wangkaiqiang Date: Thu, 26 Jun 2025 09:23:37 +0800 Subject: [PATCH] [Bug]Close the editor when nm-connection-editor exits to #22196 Close the editor when nm-connection-editor exits --- ...dd-ToastOverlay-to-connection-editor.patch | 176 ++++++++++++++++++ ...on-editor-Close-the-editor-when-nm-c.patch | 85 +++++++++ gnome-control-center.spec | 8 +- 3 files changed, 268 insertions(+), 1 deletion(-) create mode 100644 0002-network-Add-ToastOverlay-to-connection-editor.patch create mode 100644 0003-network-connection-editor-Close-the-editor-when-nm-c.patch diff --git a/0002-network-Add-ToastOverlay-to-connection-editor.patch b/0002-network-Add-ToastOverlay-to-connection-editor.patch new file mode 100644 index 0000000..411d8f4 --- /dev/null +++ b/0002-network-Add-ToastOverlay-to-connection-editor.patch @@ -0,0 +1,176 @@ +From e6336ec43336794a1ed3d61752fa55f45eb18561 Mon Sep 17 00:00:00 2001 +From: Felipe Borges +Date: Wed, 3 May 2023 12:04:43 +0200 +Subject: [PATCH] network: Add ToastOverlay to connection-editor + +--- + .../connection-editor/connection-editor.ui | 52 ++++++++++--------- + .../connection-editor/net-connection-editor.c | 50 +++++++----------- + 2 files changed, 46 insertions(+), 56 deletions(-) + +diff --git a/panels/network/connection-editor/connection-editor.ui b/panels/network/connection-editor/connection-editor.ui +index 18031e8ac..2bff4d0ab 100644 +--- a/panels/network/connection-editor/connection-editor.ui ++++ b/panels/network/connection-editor/connection-editor.ui +@@ -28,41 +28,45 @@ + vertical + 0 + +- +- True +- True +- +- +- center +- center +- True +- +- +- +- +- False +- +- +- +- ++ ++ ++ ++ True + True + +- +- True ++ ++ center ++ center ++ True ++ ++ ++ ++ ++ False ++ ++ ++ ++ + True +- vertical + +- ++ + True + True +- 300 +- start ++ vertical ++ ++ ++ True ++ True ++ 300 ++ start ++ ++ + + + + + +- ++ + + + +diff --git a/panels/network/connection-editor/net-connection-editor.c b/panels/network/connection-editor/net-connection-editor.c +index 297c6607e..e67da42b2 100644 +--- a/panels/network/connection-editor/net-connection-editor.c ++++ b/panels/network/connection-editor/net-connection-editor.c +@@ -56,6 +56,7 @@ struct _NetConnectionEditor + GtkButton *apply_button; + GtkButton *cancel_button; + GtkNotebook *notebook; ++ AdwToastOverlay *toast_overlay; + GtkStack *toplevel_stack; + + NMClient *client; +@@ -335,6 +336,7 @@ net_connection_editor_class_init (NetConnectionEditorClass *class) + gtk_widget_class_bind_template_child (widget_class, NetConnectionEditor, apply_button); + gtk_widget_class_bind_template_child (widget_class, NetConnectionEditor, cancel_button); + gtk_widget_class_bind_template_child (widget_class, NetConnectionEditor, notebook); ++ gtk_widget_class_bind_template_child (widget_class, NetConnectionEditor, toast_overlay); + gtk_widget_class_bind_template_child (widget_class, NetConnectionEditor, toplevel_stack); + + gtk_widget_class_bind_template_callback (widget_class, cancel_clicked_cb); +@@ -342,33 +344,6 @@ net_connection_editor_class_init (NetConnectionEditorClass *class) + gtk_widget_class_bind_template_callback (widget_class, apply_clicked_cb); + } + +-static void +-net_connection_editor_error_dialog (NetConnectionEditor *self, +- const char *primary_text, +- const char *secondary_text) +-{ +- GtkWidget *dialog; +- GtkWindow *parent; +- +- if (gtk_widget_is_visible (GTK_WIDGET (self))) +- parent = GTK_WINDOW (self); +- else +- parent = gtk_window_get_transient_for (GTK_WINDOW (self)); +- +- dialog = gtk_message_dialog_new (parent, +- GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT, +- GTK_MESSAGE_ERROR, +- GTK_BUTTONS_OK, +- "%s", primary_text); +- +- if (secondary_text) { +- gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog), +- "%s", secondary_text); +- } +- +- gtk_window_present (GTK_WINDOW (dialog)); +-} +- + static void + net_connection_editor_do_fallback (NetConnectionEditor *self, const gchar *type) + { +@@ -384,10 +359,15 @@ net_connection_editor_do_fallback (NetConnectionEditor *self, const gchar *type) + + g_spawn_command_line_async (cmdline, &error); + +- if (error) +- net_connection_editor_error_dialog (self, +- _("Unable to open connection editor"), +- error->message); ++ if (error) { ++ AdwToast *toast; ++ g_autofree gchar *message = NULL; ++ ++ message = g_strdup_printf (_("Unable to open connection editor: %s"), error->message); ++ toast = adw_toast_new (message); ++ ++ adw_toast_overlay_add_toast (self->toast_overlay, toast); ++ } + + g_signal_emit (self, signals[DONE], 0, FALSE); + } +@@ -745,7 +725,13 @@ vpn_import_complete (NMConnection *connection, gpointer user_data) + NMSettingConnection *s_con; + + if (!connection) { +- /* The import code shows its own error dialogs. */ ++ AdwToast *toast; ++ g_autofree gchar *message = NULL; ++ ++ message = g_strdup_printf (_("Invalid VPN configuration file")); ++ toast = adw_toast_new (message); ++ adw_toast_overlay_add_toast (self->toast_overlay, toast); ++ + g_signal_emit (self, signals[DONE], 0, FALSE); + return; + } +-- +2.39.3 + diff --git a/0003-network-connection-editor-Close-the-editor-when-nm-c.patch b/0003-network-connection-editor-Close-the-editor-when-nm-c.patch new file mode 100644 index 0000000..b17960c --- /dev/null +++ b/0003-network-connection-editor-Close-the-editor-when-nm-c.patch @@ -0,0 +1,85 @@ +From f0d04a180f969ee5b3b703ab39746a55c800ecf3 Mon Sep 17 00:00:00 2001 +From: Jonathan Kang +Date: Mon, 9 Oct 2023 09:14:03 +0800 +Subject: [PATCH] network-connection-editor: Close the editor when + nm-connection-editor exits + +Previously, when editing a connection that doesn't have native editor +support, nm-connection-editor is spawned to do the work. But after +closing nm-connection-editor, an empty editor dialog still exists. + +Fix that in this commit. +--- + .../connection-editor/net-connection-editor.c | 40 ++++++++++++++++--- + 1 file changed, 35 insertions(+), 5 deletions(-) + +diff --git a/panels/network/connection-editor/net-connection-editor.c b/panels/network/connection-editor/net-connection-editor.c +index d3e351080..6a3194114 100644 +--- a/panels/network/connection-editor/net-connection-editor.c ++++ b/panels/network/connection-editor/net-connection-editor.c +@@ -362,20 +362,48 @@ net_connection_editor_class_init (NetConnectionEditorClass *class) + gtk_widget_class_bind_template_callback (widget_class, apply_clicked_cb); + } + ++static void ++nm_connection_editor_watch_cb (GPid pid, ++ gint status, ++ gpointer user_data) ++{ ++ g_debug ("Child %d" G_PID_FORMAT " exited %s", pid, ++ g_spawn_check_wait_status (status, NULL) ? "normally" : "abnormally"); ++ ++ g_spawn_close_pid (pid); ++ /* Close the dialog when nm-connection-editor exits. */ ++ gtk_window_destroy (GTK_WINDOW (user_data)); ++} ++ + static void + net_connection_editor_do_fallback (NetConnectionEditor *self, const gchar *type) + { +- g_autofree gchar *cmdline = NULL; + g_autoptr(GError) error = NULL; ++ g_autoptr(GStrvBuilder) builder = NULL; ++ g_auto(GStrv) argv = NULL; ++ GPid child_pid; ++ ++ builder = g_strv_builder_new (); ++ g_strv_builder_add (builder, "nm-connection-editor"); + + if (self->is_new_connection) { +- cmdline = g_strdup_printf ("nm-connection-editor --type='%s' --create", type); ++ g_autofree gchar *type_str = NULL; ++ ++ type_str = g_strdup_printf ("--type=%s", type); ++ g_strv_builder_add (builder, type_str); ++ g_strv_builder_add (builder, "--create"); + } else { +- cmdline = g_strdup_printf ("nm-connection-editor --edit='%s'", +- nm_connection_get_uuid (self->connection)); ++ g_autofree gchar *edit_str = NULL; ++ ++ edit_str = g_strdup_printf ("--edit=%s", nm_connection_get_uuid (self->connection)); ++ g_strv_builder_add (builder, edit_str); + } + +- g_spawn_command_line_async (cmdline, &error); ++ g_strv_builder_add (builder, NULL); ++ argv = g_strv_builder_end (builder); ++ ++ g_spawn_async_with_pipes (NULL, argv, NULL, G_SPAWN_DO_NOT_REAP_CHILD | G_SPAWN_SEARCH_PATH, ++ NULL, NULL, &child_pid, NULL, NULL, NULL, &error); + + if (error) { + AdwToast *toast; +@@ -385,6 +413,8 @@ net_connection_editor_do_fallback (NetConnectionEditor *self, const gchar *type) + toast = adw_toast_new (message); + + adw_toast_overlay_add_toast (self->toast_overlay, toast); ++ } else { ++ g_child_watch_add (child_pid, nm_connection_editor_watch_cb, self); + } + + g_signal_emit (self, signals[DONE], 0, FALSE); +-- +2.39.3 + diff --git a/gnome-control-center.spec b/gnome-control-center.spec index 15c71b4..c0ab9ca 100644 --- a/gnome-control-center.spec +++ b/gnome-control-center.spec @@ -1,4 +1,4 @@ -%define anolis_release 3 +%define anolis_release 4 Name: gnome-control-center Version: 44.1 @@ -9,6 +9,8 @@ License: GPLv2+ and CC-BY-SA URL: http://www.gnome.org Source0: https://download.gnome.org/sources/%{name}/44/%{name}-%{version}.tar.xz Patch0001: 0001-gnome-control-center-can-t-get-cpu-information-on-lo.patch +Patch0002: 0002-network-Add-ToastOverlay-to-connection-editor.patch +Patch0003: 0003-network-connection-editor-Close-the-editor-when-nm-c.patch BuildRequires: docbook-style-xsl libxslt BuildRequires: gcc gettext meson >= 0.57.0 @@ -181,6 +183,10 @@ rm -rf $RPM_BUILD_ROOT%{_datadir}/gnome/cursor-fonts %doc NEWS README.md %changelog +* Thu Jun 26 2025 Kaiqiang Wang - 44.1-4 +- fix bug #22196 +- Close the editor when nm-connection-editor exits + * Tue Apr 15 2025 Hong Wei Qin - 44.1-3 - Fix build fail -- Gitee