[epiphany/mcatanzaro/#1800: 27/27] window-commands: work around GTK native dialog hang
- From: Michael Catanzaro <mcatanzaro src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [epiphany/mcatanzaro/#1800: 27/27] window-commands: work around GTK native dialog hang
- Date: Wed, 3 Aug 2022 16:57:07 +0000 (UTC)
commit 4b1e57d4b2b950ae4f52b6ca383af9b7d41a5aa7
Author: Michael Catanzaro <mcatanzaro redhat com>
Date: Wed Aug 3 11:51:51 2022 -0500
window-commands: work around GTK native dialog hang
When importing bookmarks, we have:
(1) EphyWindow, transient parent of
(2) GtkDialog to select where to import bookmarks from, transient
parent of
(3) The native file chooser dialog (in case of GVDB or HTML import)
Sadly, opening a native dialog on a modal dialog hangs the application,
gtk#5011. To dodge this problem, we can close the second dialog
dialog when opening the third dialog, and make the EphyWindow the
transient parent of the third dialog. This is inconvenient because it
means you're all the way back to step one if you decide to cancel the
third dialog and want to go back to the second dialog, but it's better
than a hang.
Exporting bookmarks does not have this problem, because there we skip
step 2.
Importing passwords does not have this problem, because there we don't
have a native file chooser. (At least, I think so. Didn't test this
because I do not have Chrome installed.)
src/window-commands.c | 29 +++++++++++++++--------------
1 file changed, 15 insertions(+), 14 deletions(-)
---
diff --git a/src/window-commands.c b/src/window-commands.c
index 14f0011bb..bed446b70 100644
--- a/src/window-commands.c
+++ b/src/window-commands.c
@@ -299,7 +299,7 @@ show_firefox_profile_selector_cb (GtkDialog *selector,
g_autoptr (GError) error = NULL;
gboolean imported = ephy_bookmarks_import_from_firefox (manager, selected_profile, &error);
- show_import_export_result (parent, imported, imported, error,
+ show_import_export_result (parent, FALSE, imported, error,
_("Bookmarks successfully imported!"));
}
}
@@ -374,7 +374,7 @@ dialog_bookmarks_import_file_chooser_cb (GtkNativeDialog *file_chooser_dialog,
filename = g_file_get_path (file);
imported = ephy_bookmarks_import (manager, filename, &error);
- show_import_export_result (parent, imported, imported, error,
+ show_import_export_result (parent, FALSE, imported, error,
_("Bookmarks successfully imported!"));
}
@@ -421,7 +421,7 @@ dialog_bookmarks_import_from_html_file_chooser_cb (GtkNativeDialog *file_chooser
filename = g_file_get_path (file);
imported = ephy_bookmarks_import_from_html (manager, filename, &error);
- show_import_export_result (parent, imported, imported, error,
+ show_import_export_result (parent, FALSE, imported, error,
_("Bookmarks successfully imported!"));
}
@@ -464,7 +464,7 @@ dialog_bookmarks_import_from_firefox (GtkWindow *parent)
if (num_profiles == 1) {
imported = ephy_bookmarks_import_from_firefox (manager, profiles->data, &error);
- show_import_export_result (parent, imported, imported, error,
+ show_import_export_result (parent, FALSE, imported, error,
_("Bookmarks successfully imported!"));
} else if (num_profiles > 1) {
show_firefox_profile_selector (parent, profiles);
@@ -487,7 +487,7 @@ dialog_bookmarks_import_from_chrome (GtkWindow *parent)
imported = ephy_bookmarks_import_from_chrome (manager, filename, &error);
- show_import_export_result (parent, imported, imported, error,
+ show_import_export_result (parent, FALSE, imported, error,
_("Bookmarks successfully imported!"));
}
@@ -503,34 +503,35 @@ dialog_bookmarks_import_from_chromium (GtkWindow *parent)
imported = ephy_bookmarks_import_from_chrome (manager, filename, &error);
- show_import_export_result (parent, imported, imported, error,
+ show_import_export_result (parent, FALSE, imported, error,
_("Bookmarks successfully imported!"));
}
static void
-dialog_bookmarks_import_cb (GtkWindow *parent,
+dialog_bookmarks_import_cb (GtkDialog *dialog,
GtkResponseType response,
GtkComboBox *combo_box)
{
+ GtkWindow *window = gtk_window_get_transient_for (GTK_WINDOW (dialog));
const char *active;
if (response == GTK_RESPONSE_OK) {
active = gtk_combo_box_get_active_id (combo_box);
if (strcmp (active, IMPORT_FROM_GVDB_ID) == 0)
- dialog_bookmarks_import (parent);
+ dialog_bookmarks_import (window);
else if (strcmp (active, IMPORT_FROM_HTML_ID) == 0)
- dialog_bookmarks_import_from_html (parent);
+ dialog_bookmarks_import_from_html (window);
else if (strcmp (active, IMPORT_FROM_FIREFOX_ID) == 0)
- dialog_bookmarks_import_from_firefox (parent);
+ dialog_bookmarks_import_from_firefox (window);
else if (strcmp (active, IMPORT_FROM_CHROME_ID) == 0)
- dialog_bookmarks_import_from_chrome (parent);
+ dialog_bookmarks_import_from_chrome (window);
else if (strcmp (active, IMPORT_FROM_CHROMIUM_ID) == 0)
- dialog_bookmarks_import_from_chromium (parent);
+ dialog_bookmarks_import_from_chromium (window);
else
g_assert_not_reached ();
- } else if (response == GTK_RESPONSE_CANCEL) {
- gtk_widget_destroy (GTK_WIDGET (parent));
}
+
+ gtk_widget_destroy (GTK_WIDGET (dialog));
}
void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]