[gtk+/portal: 5/14] portal: Fall back when the portal doesn't work



commit 849e36f452443f8639db4e1e2067d2395e7a4f09
Author: Matthias Clasen <mclasen redhat com>
Date:   Sat Jun 11 10:14:36 2016 -0400

    portal: Fall back when the portal doesn't work
    
    Show the fallback dialog in cases where we tried to call out to
    portal, but it didn't work.

 gtk/gtkfilechoosernative.c        |    7 +++++++
 gtk/gtkfilechoosernativeportal.c  |    4 ++++
 gtk/gtkfilechoosernativeprivate.h |    2 ++
 3 files changed, 13 insertions(+), 0 deletions(-)
---
diff --git a/gtk/gtkfilechoosernative.c b/gtk/gtkfilechoosernative.c
index be96b69..6e347eb 100644
--- a/gtk/gtkfilechoosernative.c
+++ b/gtk/gtkfilechoosernative.c
@@ -511,6 +511,13 @@ hide_dialog (GtkFileChooserNative *self)
   gtk_widget_hide (self->dialog);
 }
 
+void
+gtk_file_chooser_native_show_fallback (GtkFileChooserNative *self)
+{
+  self->mode = MODE_FALLBACK;
+  show_dialog (self);
+}
+
 static gboolean
 gtk_file_chooser_native_set_current_folder (GtkFileChooser    *chooser,
                                             GFile             *file,
diff --git a/gtk/gtkfilechoosernativeportal.c b/gtk/gtkfilechoosernativeportal.c
index dfd4fdc..322c5e9 100644
--- a/gtk/gtkfilechoosernativeportal.c
+++ b/gtk/gtkfilechoosernativeportal.c
@@ -224,6 +224,10 @@ open_file_msg_cb (GObject *source_object,
         _gtk_native_dialog_emit_response (GTK_NATIVE_DIALOG (self), GTK_RESPONSE_DELETE_EVENT);
       g_warning ("Can't open portal file chooser: %s\n", error->message);
       filechooser_portal_data_free (data);
+
+      /* fall back manually */
+      gtk_file_chooser_native_show_fallback (GTK_FILE_CHOOSER_NATIVE (self));
+
       return;
     }
 
diff --git a/gtk/gtkfilechoosernativeprivate.h b/gtk/gtkfilechoosernativeprivate.h
index ab3b6cf..d2eedba 100644
--- a/gtk/gtkfilechoosernativeprivate.h
+++ b/gtk/gtkfilechoosernativeprivate.h
@@ -51,6 +51,8 @@ void gtk_file_chooser_native_win32_hide (GtkFileChooserNative *self);
 gboolean gtk_file_chooser_native_portal_show (GtkFileChooserNative *self);
 void gtk_file_chooser_native_portal_hide (GtkFileChooserNative *self);
 
+void gtk_file_chooser_native_show_fallback (GtkFileChooserNative *self);
+
 G_END_DECLS
 
 #endif /* __GTK_FILE_CHOOSER_NATIVE_PRIVATE_H__ */


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