diff options
author | Emmanuele Bassi <ebassi@gnome.org> | 2007-06-25 16:15:21 +0000 |
---|---|---|
committer | Emmanuele Bassi <ebassi@src.gnome.org> | 2007-06-25 16:15:21 +0000 |
commit | 970988756e54eb29b7fea1dea2746e15e5ebff39 (patch) | |
tree | c6470a251fbbd09e40709d2260851c59edbf6f56 /gtk/gtkrecentmanager.c | |
parent | 64923390c5d654679e30b615daa9e7a99bb2b9d6 (diff) | |
download | gtk+-970988756e54eb29b7fea1dea2746e15e5ebff39.tar.gz |
building a GtkRecentInfo can never fail.
2007-06-25 Emmanuele Bassi <ebassi@gnome.org>
* gtk/gtkrecentmanager.c:
(build_recent_info): building a GtkRecentInfo can never fail.
(gtk_recent_manager_get_items): Clamp the list while building
it so we don't need to traverse it more than once. (#446532,
Philip Withnall)
svn path=/trunk/; revision=18228
Diffstat (limited to 'gtk/gtkrecentmanager.c')
-rw-r--r-- | gtk/gtkrecentmanager.c | 48 |
1 files changed, 7 insertions, 41 deletions
diff --git a/gtk/gtkrecentmanager.c b/gtk/gtkrecentmanager.c index 6f038fcd5f..d8311d4097 100644 --- a/gtk/gtkrecentmanager.c +++ b/gtk/gtkrecentmanager.c @@ -1077,7 +1077,7 @@ gtk_recent_manager_has_item (GtkRecentManager *manager, return g_bookmark_file_has_item (priv->recent_items, uri); } -static gboolean +static void build_recent_info (GBookmarkFile *bookmarks, GtkRecentInfo *info) { @@ -1137,8 +1137,6 @@ build_recent_info (GBookmarkFile *bookmarks, } g_strfreev (apps); - - return TRUE; } /** @@ -1165,7 +1163,6 @@ gtk_recent_manager_lookup_item (GtkRecentManager *manager, { GtkRecentManagerPrivate *priv; GtkRecentInfo *info = NULL; - gboolean res; g_return_val_if_fail (GTK_IS_RECENT_MANAGER (manager), NULL); g_return_val_if_fail (uri != NULL, NULL); @@ -1200,14 +1197,8 @@ gtk_recent_manager_lookup_item (GtkRecentManager *manager, /* fill the RecentInfo structure with the data retrieved by our * parser object from the storage file */ - res = build_recent_info (priv->recent_items, info); - if (!res) - { - gtk_recent_info_free (info); - - return NULL; - } - + build_recent_info (priv->recent_items, info); + return info; } @@ -1303,42 +1294,17 @@ gtk_recent_manager_get_items (GtkRecentManager *manager) for (i = 0; i < uris_len; i++) { GtkRecentInfo *info; - gboolean res; + + if (priv->limit != -1 && i == priv->limit) + break; info = gtk_recent_info_new (uris[i]); - res = build_recent_info (priv->recent_items, info); - if (!res) - { - g_warning ("Unable to create a RecentInfo object for " - "item with URI `%s'", - uris[i]); - gtk_recent_info_free (info); - - continue; - } + build_recent_info (priv->recent_items, info); retval = g_list_prepend (retval, info); } g_strfreev (uris); - - /* clamp the list, if a limit is present */ - if ((priv->limit != -1) && - (g_list_length (retval) > priv->limit)) - { - GList *clamp, *l; - - clamp = g_list_nth (retval, priv->limit - 1); - - if (!clamp) - return retval; - - l = clamp->next; - clamp->next = NULL; - - g_list_foreach (l, (GFunc) gtk_recent_info_free, NULL); - g_list_free (l); - } return retval; } |