[recipes] Warn about lack of the print portal



commit ae8d8fc5e79fdc4c590028904d70092eea09679e
Author: Matthias Clasen <mclasen redhat com>
Date:   Wed Jan 18 07:39:58 2017 -0500

    Warn about lack of the print portal

 src/gr-recipe-printer.c        |   13 +++++++++++++
 src/gr-shopping-list-printer.c |   14 ++++++++++++++
 2 files changed, 27 insertions(+), 0 deletions(-)
---
diff --git a/src/gr-recipe-printer.c b/src/gr-recipe-printer.c
index ed12aa9..9cb59da 100644
--- a/src/gr-recipe-printer.c
+++ b/src/gr-recipe-printer.c
@@ -477,6 +477,19 @@ 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);
+                return;
+        }
+
         printer->recipe = g_object_ref (recipe);
 
         operation = gtk_print_operation_new ();
diff --git a/src/gr-shopping-list-printer.c b/src/gr-shopping-list-printer.c
index c0bd2de..3b6ea37 100644
--- a/src/gr-shopping-list-printer.c
+++ b/src/gr-shopping-list-printer.c
@@ -23,6 +23,7 @@
 #include <glib/gi18n.h>
 
 #include "gr-shopping-list-printer.h"
+#include "gr-utils.h"
 
 
 static void
@@ -321,6 +322,19 @@ 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);
+                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);
 


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