recentmanager: follow gtk-recent-files-enabled GtkSetting

https://bugzilla.gnome.org/show_bug.cgi?id=693724
This commit is contained in:
Cosimo Cecchi 2013-02-13 11:05:47 -05:00
parent c896adc9e9
commit 382c5f63b0

View File

@ -213,6 +213,7 @@ static void gtk_recent_manager_set_filename (GtkRecentManager *manag
const gchar *filename);
static void gtk_recent_manager_clamp_to_age (GtkRecentManager *manager,
gint age);
static void gtk_recent_manager_enabled_changed (GtkRecentManager *manager);
static void build_recent_items_list (GtkRecentManager *manager);
@ -340,6 +341,7 @@ static void
gtk_recent_manager_init (GtkRecentManager *manager)
{
GtkRecentManagerPrivate *priv;
GtkSettings *settings;
manager->priv = G_TYPE_INSTANCE_GET_PRIVATE (manager,
GTK_TYPE_RECENT_MANAGER,
@ -348,6 +350,10 @@ gtk_recent_manager_init (GtkRecentManager *manager)
priv->size = 0;
priv->filename = NULL;
settings = gtk_settings_get_default ();
g_signal_connect_swapped (settings, "notify::gtk-recent-files-enabled",
G_CALLBACK (gtk_recent_manager_enabled_changed), manager);
}
static void
@ -437,6 +443,13 @@ gtk_recent_manager_dispose (GObject *gobject)
G_OBJECT_CLASS (gtk_recent_manager_parent_class)->dispose (gobject);
}
static void
gtk_recent_manager_enabled_changed (GtkRecentManager *manager)
{
manager->priv->is_dirty = TRUE;
gtk_recent_manager_changed (manager);
}
static void
gtk_recent_manager_real_changed (GtkRecentManager *manager)
{
@ -465,15 +478,20 @@ gtk_recent_manager_real_changed (GtkRecentManager *manager)
{
GtkSettings *settings = gtk_settings_get_default ();
gint age = 30;
gboolean enabled;
g_object_get (G_OBJECT (settings), "gtk-recent-files-max-age", &age, NULL);
if (age > 0)
gtk_recent_manager_clamp_to_age (manager, age);
else if (age == 0)
g_object_get (G_OBJECT (settings),
"gtk-recent-files-max-age", &age,
"gtk-recent-files-enabled", &enabled,
NULL);
if (age == 0 || !enabled)
{
g_bookmark_file_free (priv->recent_items);
priv->recent_items = g_bookmark_file_new ();
}
else if (age > 0)
gtk_recent_manager_clamp_to_age (manager, age);
}
write_error = NULL;
@ -875,6 +893,8 @@ gtk_recent_manager_add_full (GtkRecentManager *manager,
const GtkRecentData *data)
{
GtkRecentManagerPrivate *priv;
GtkSettings *settings;
gboolean enabled;
g_return_val_if_fail (GTK_IS_RECENT_MANAGER (manager), FALSE);
g_return_val_if_fail (uri != NULL, FALSE);
@ -927,7 +947,12 @@ gtk_recent_manager_add_full (GtkRecentManager *manager,
uri);
return FALSE;
}
settings = gtk_settings_get_default ();
g_object_get (G_OBJECT (settings), "gtk-recent-files-enabled", &enabled, NULL);
if (!enabled)
return TRUE;
priv = manager->priv;
if (!priv->recent_items)