[gtk+/wip/alexl/file-chooser-portal] portal: Fall back when the portal doesn't work



commit a21156750d5aad7ee4a29a7bd4fdb007d496c57d
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 06e10c8..7290f7a 100644
--- a/gtk/gtkfilechoosernative.c
+++ b/gtk/gtkfilechoosernative.c
@@ -494,6 +494,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 7e50d17..4ef2247 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]