From 880391cded8d49331c90e4b44a65ff281b9714b0 Mon Sep 17 00:00:00 2001 From: Cosimo Cecchi Date: Wed, 13 Feb 2013 11:39:53 -0500 Subject: [PATCH] filechooser: follow the gtk-recent-files-enabled GtkSetting Avoid showing the Recent files entry if the setting is FALSE. https://bugzilla.gnome.org/show_bug.cgi?id=693709 --- gtk/gtkfilechooserdefault.c | 24 +++++++++++++++++++++++- gtk/gtkfilechooserprivate.h | 1 + 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/gtk/gtkfilechooserdefault.c b/gtk/gtkfilechooserdefault.c index 3eff2206a7..3f900986f1 100644 --- a/gtk/gtkfilechooserdefault.c +++ b/gtk/gtkfilechooserdefault.c @@ -1736,11 +1736,31 @@ shortcuts_append_search (GtkFileChooserDefault *impl) impl->has_search = TRUE; } +static gboolean +shortcuts_get_recent_enabled (GtkWidget *widget) +{ + GtkSettings *settings; + gboolean enabled; + + if (gtk_widget_has_screen (widget)) + settings = gtk_settings_get_for_screen (gtk_widget_get_screen (widget)); + else + settings = gtk_settings_get_default (); + + g_object_get (settings, "gtk-recent-files-enabled", &enabled, NULL); + return enabled; +} + static void shortcuts_append_recent (GtkFileChooserDefault *impl) { GdkPixbuf *pixbuf; GtkTreeIter iter; + gboolean enabled; + + enabled = shortcuts_get_recent_enabled (GTK_WIDGET (impl)); + if (!enabled) + return; pixbuf = render_recent_icon (impl); @@ -1756,6 +1776,8 @@ shortcuts_append_recent (GtkFileChooserDefault *impl) if (pixbuf) g_object_unref (pixbuf); + + impl->has_recent = TRUE; } /* Appends an item for the user's home directory to the shortcuts model */ @@ -1871,7 +1893,7 @@ shortcuts_get_index (GtkFileChooserDefault *impl, if (where == SHORTCUTS_RECENT) goto out; - n += 1; /* we always have the recently-used item */ + n += impl->has_recent ? 1 : 0; if (where == SHORTCUTS_RECENT_SEPARATOR) goto out; diff --git a/gtk/gtkfilechooserprivate.h b/gtk/gtkfilechooserprivate.h index 907c9df236..2a74e39f7e 100644 --- a/gtk/gtkfilechooserprivate.h +++ b/gtk/gtkfilechooserprivate.h @@ -308,6 +308,7 @@ struct _GtkFileChooserDefault guint has_home : 1; guint has_desktop : 1; guint has_search : 1; + guint has_recent: 1; guint show_size_column : 1; guint create_folders : 1;