[recipes] Update all callers



commit bc9ddbebd2d293a0943f83f9be5b60934ce98d8a
Author: Matthias Clasen <mclasen redhat com>
Date:   Tue Mar 14 19:35:09 2017 -0400

    Update all callers
    
    Update all callers to use the new portal check API instead
    of showing dialogs themselves and add the check to a few
    more places where we may use portals. This fixes a problem
    where using Import from the app menu would only print a
    warning on stderr when portals were missing.

 src/gr-image-viewer.c          |   13 ++-----------
 src/gr-recipe-printer.c        |   12 +-----------
 src/gr-shopping-list-printer.c |   13 ++-----------
 src/gr-window.c                |   13 +++++++++----
 4 files changed, 14 insertions(+), 37 deletions(-)
---
diff --git a/src/gr-image-viewer.c b/src/gr-image-viewer.c
index b74b74b..606a3dd 100644
--- a/src/gr-image-viewer.c
+++ b/src/gr-image-viewer.c
@@ -605,18 +605,9 @@ open_filechooser (GrImageViewer *viewer)
 
         window = gtk_widget_get_ancestor (GTK_WIDGET (viewer), GTK_TYPE_APPLICATION_WINDOW);
 
-        if (in_flatpak_sandbox () && !portals_available ()) {
-                GtkWidget *dialog;
-
-                dialog = gtk_message_dialog_new (GTK_WINDOW (window),
-                                                 GTK_DIALOG_MODAL|GTK_DIALOG_DESTROY_WITH_PARENT,
-                                                 GTK_MESSAGE_ERROR,
-                                                 GTK_BUTTONS_OK,
-                                                 _("Missing the desktop portals needed to open files from 
inside a flatpak sandbox. Please install xdg-desktop-portal and xdg-desktop-portal-gtk on your system."));
-                g_signal_connect (dialog, "response", G_CALLBACK (gtk_widget_destroy), NULL);
-                gtk_widget_show (dialog);
+        if (in_flatpak_sandbox () &&
+            !portal_available (GTK_WINDOW (window), "org.freedesktop.portal.FileChooser"))
                 return;
-        }
 
         chooser = gtk_file_chooser_native_new (_("Select an Image"),
                                                GTK_WINDOW (window),
diff --git a/src/gr-recipe-printer.c b/src/gr-recipe-printer.c
index 3daea17..c37a89e 100644
--- a/src/gr-recipe-printer.c
+++ b/src/gr-recipe-printer.c
@@ -431,18 +431,8 @@ gr_recipe_printer_print (GrRecipePrinter *printer,
 {
         GtkPrintOperation *operation;
 
-        if (in_flatpak_sandbox () && !portals_available ()) {
-                GtkWidget *dialog;
-
-                dialog = gtk_message_dialog_new (GTK_WINDOW (printer->window),
-                                                 GTK_DIALOG_MODAL|GTK_DIALOG_DESTROY_WITH_PARENT,
-                                                 GTK_MESSAGE_ERROR,
-                                                 GTK_BUTTONS_OK,
-                                                 _("Missing the desktop portals needed to print from inside 
a flatpak sandbox. Please install xdg-desktop-portal and xdg-desktop-portal-gtk on your system."));
-                g_signal_connect (dialog, "response", G_CALLBACK (gtk_widget_destroy), NULL);
-                gtk_widget_show (dialog);
+        if (in_flatpak_sandbox () && !portal_available (printer->window, "org.freedesktop.portal.Printing"))
                 return;
-        }
 
         printer->recipe = g_object_ref (recipe);
 
diff --git a/src/gr-shopping-list-printer.c b/src/gr-shopping-list-printer.c
index 0734650..f156c8f 100644
--- a/src/gr-shopping-list-printer.c
+++ b/src/gr-shopping-list-printer.c
@@ -319,18 +319,9 @@ gr_shopping_list_printer_print (GrShoppingListPrinter *printer,
 {
         GtkPrintOperation *operation;
 
-        if (in_flatpak_sandbox () && !portals_available ()) {
-                GtkWidget *dialog;
-
-                dialog = gtk_message_dialog_new (GTK_WINDOW (printer->window),
-                                                 GTK_DIALOG_MODAL|GTK_DIALOG_DESTROY_WITH_PARENT,
-                                                 GTK_MESSAGE_ERROR,
-                                                 GTK_BUTTONS_OK,
-                                                 _("Missing the desktop portals needed to print from inside 
a flatpak sandbox. Please install xdg-desktop-portal and xdg-desktop-portal-gtk on your system."));
-                g_signal_connect (dialog, "response", G_CALLBACK (gtk_widget_destroy), NULL);
-                gtk_widget_show (dialog);
+        if (in_flatpak_sandbox () &&
+            !portal_available (GTK_WINDOW (printer->window), "org.freedesktop.portal.Printing"))
                 return;
-        }
 
         printer->recipes = g_list_copy_deep (recipes, (GCopyFunc)g_object_ref, NULL);
         printer->items = g_list_copy_deep (items, (GCopyFunc)shopping_item_copy, NULL);
diff --git a/src/gr-window.c b/src/gr-window.c
index 2583cba..b135cfa 100644
--- a/src/gr-window.c
+++ b/src/gr-window.c
@@ -1122,6 +1122,10 @@ gr_window_load_recipe (GrWindow *window,
         if (window->file_chooser)
                 return;
 
+        if (//in_flatpak_sandbox () &&
+            !portal_available (GTK_WINDOW (window), "org.freedesktop.portal.FileChooser"))
+                return;
+
         window->file_chooser = (GObject *)gtk_file_chooser_native_new (_("Select a recipe file"),
                                                                        GTK_WINDOW (window),
                                                                        GTK_FILE_CHOOSER_ACTION_OPEN,
@@ -1560,9 +1564,10 @@ void
 gr_window_show_report_issue (GrWindow *window)
 {
         const char *uri = "https://bugzilla.gnome.org/enter_bug.cgi?product=recipes";;
-        g_autoptr(GError) error = NULL;
 
-        gtk_show_uri_on_window (GTK_WINDOW (window), uri, GDK_CURRENT_TIME, &error);
-        if (error)
-                g_warning ("Unable to show '%s': %s", uri, error->message);
+        if (in_flatpak_sandbox () &&
+            !portal_available (GTK_WINDOW (window), "org.freedesktop.portal.OpenURI"))
+                return;
+
+        gtk_show_uri_on_window (GTK_WINDOW (window), uri, GDK_CURRENT_TIME, NULL);
 }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]