[gtk+] file chooser: Respect recent settings
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] file chooser: Respect recent settings
- Date: Sat, 30 May 2015 13:23:05 +0000 (UTC)
commit 4c971c6f5eef9693a8c6a6d12a798901c9689f96
Author: Matthias Clasen <mclasen redhat com>
Date: Sat May 30 09:21:16 2015 -0400
file chooser: Respect recent settings
When recent files are not supported in gvfs, or turned off by
settings, we should not try to load them even if the startup
mode says so. This prevents inconsistency with the places
sidebar where 'Recent' will not appear in this case.
gtk/gtkfilechooserwidget.c | 38 ++++++++++++++++++++++++++++++++++++--
1 files changed, 36 insertions(+), 2 deletions(-)
---
diff --git a/gtk/gtkfilechooserwidget.c b/gtk/gtkfilechooserwidget.c
index be004bc..ea96292 100644
--- a/gtk/gtkfilechooserwidget.c
+++ b/gtk/gtkfilechooserwidget.c
@@ -3206,6 +3206,36 @@ switch_to_cwd (GtkFileChooserWidget *impl)
g_free (current_working_dir);
}
+static gboolean
+recent_files_setting_is_enabled (GtkFileChooserWidget *impl)
+{
+ GtkSettings *settings;
+ gboolean enabled;
+
+ settings = gtk_widget_get_settings (GTK_WIDGET (impl));
+ g_object_get (settings, "gtk-recent-files-enabled", &enabled, NULL);
+
+ return enabled;
+}
+
+static gboolean
+recent_scheme_is_supported (void)
+{
+ const gchar * const *supported;
+
+ supported = g_vfs_get_supported_uri_schemes (g_vfs_get_default ());
+ if (supported != NULL)
+ return g_strv_contains (supported, "recent");
+
+ return FALSE;
+}
+
+static gboolean
+can_show_recent (GtkFileChooserWidget *impl)
+{
+ return recent_files_setting_is_enabled (impl) && recent_scheme_is_supported ();
+}
+
/* Sets the file chooser to showing Recent Files or $CWD, depending on the
* user’s settings.
*/
@@ -3217,8 +3247,12 @@ set_startup_mode (GtkFileChooserWidget *impl)
switch (priv->startup_mode)
{
case STARTUP_MODE_RECENT:
- operation_mode_set (impl, OPERATION_MODE_RECENT);
- break;
+ if (can_show_recent (impl))
+ {
+ operation_mode_set (impl, OPERATION_MODE_RECENT);
+ break;
+ }
+ /* else fall thru */
case STARTUP_MODE_CWD:
switch_to_cwd (impl);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]