[epiphany/gnome-42] window-commands: work around GTK native dialog hang



commit 130f25b0131b0e96f7744a959b6cc91f0521c485
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.)
    
    
    (cherry picked from commit 4b1e57d4b2b950ae4f52b6ca383af9b7d41a5aa7)

 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 24709b227..c8f2517e5 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!"));
   }
 }
@@ -372,7 +372,7 @@ dialog_bookmarks_import_file_chooser_cb (GtkNativeDialog *file_chooser_dialog,
   filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (file_chooser_dialog));
   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!"));
 }
 
@@ -417,7 +417,7 @@ dialog_bookmarks_import_from_html_file_chooser_cb (GtkNativeDialog *file_chooser
   filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (file_chooser_dialog));
   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!"));
 }
 
@@ -460,7 +460,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);
@@ -483,7 +483,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!"));
 }
 
@@ -499,34 +499,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]