From a21156750d5aad7ee4a29a7bd4fdb007d496c57d Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Sat, 11 Jun 2016 10:14:36 -0400 Subject: [PATCH] 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(+) diff --git a/gtk/gtkfilechoosernative.c b/gtk/gtkfilechoosernative.c index 06e10c8d5f..7290f7aea6 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 7e50d1743b..4ef2247c44 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 ab3b6cf0c7..d2eedba080 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__ */