diff --git a/ChangeLog b/ChangeLog index b1f2651805..0d7f50e41a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2007-06-25 Emmanuele Bassi + + * 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) + 2007-06-25 Tor Lillqvist * gdk/win32/gdkevents-win32.c (gdk_pointer_grab): Revert my 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; }