forked from AuroraMiddleware/gtk
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.
This commit is contained in:
parent
4de444ca61
commit
4c971c6f5e
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user