gnome-main-menu r417 - trunk/libslab
- From: federico svn gnome org
- To: svn-commits-list gnome org
- Subject: gnome-main-menu r417 - trunk/libslab
- Date: Sat, 5 Apr 2008 00:41:12 +0100 (BST)
Author: federico
Date: Sat Apr 5 00:41:12 2008
New Revision: 417
URL: http://svn.gnome.org/viewvc/gnome-main-menu?rev=417&view=rev
Log:
New public bookmark_agent_update_from_bookmark_file() Main-menu uses two BookmarkAgent objects that monitor the same ~/.recently-used.xbel. As a result, that file gets read and parsed *twice* on every update.
With this, we start a new strategy to update BookmarkAgents. They get
updated explicitly by the caller, not implicitly with a GnomeVFS file
monitor. This also lets us have less files to monitor, and more
control for when expensive operations are performed.
Signed-off-by: Federico Mena Quintero <federico gnu org>
Modified:
trunk/libslab/bookmark-agent.c
trunk/libslab/bookmark-agent.h
Modified: trunk/libslab/bookmark-agent.c
==============================================================================
--- trunk/libslab/bookmark-agent.c (original)
+++ trunk/libslab/bookmark-agent.c Sat Apr 5 00:41:12 2008
@@ -322,6 +322,81 @@
save_store (this);
}
+static GList *
+make_items_from_bookmark_file (BookmarkAgent *this, GBookmarkFile *store)
+{
+ BookmarkAgentPrivate *priv = PRIVATE (this);
+ gchar **uris;
+ gint i;
+ GList *items_ordered;
+
+ if (!store)
+ return NULL;
+
+ uris = g_bookmark_file_get_uris (store, NULL);
+ items_ordered = NULL;
+
+ for (i = 0; uris && uris [i]; ++i) {
+ gboolean include;
+
+ if (priv->type == BOOKMARK_STORE_RECENT_APPS)
+ include = g_bookmark_file_has_group (store, uris [i], "recently-used-apps", NULL);
+ else
+ include = ! g_bookmark_file_get_is_private (store, uris [i], NULL);
+
+ if (include) {
+ BookmarkItem *item;
+
+ item = g_new0 (BookmarkItem, 1);
+
+ item->uri = g_strdup (uris [i]);
+ item->mime_type = g_bookmark_file_get_mime_type (store, uris [i], NULL);
+ item->mtime = g_bookmark_file_get_modified (store, uris [i], NULL);
+
+ items_ordered = g_list_insert_sorted (items_ordered, item, recent_item_mru_comp_func);
+ }
+ }
+
+ g_strfreev (uris);
+ g_bookmark_file_free (store);
+
+ return items_ordered;
+}
+
+void
+bookmark_agent_update_from_bookmark_file (BookmarkAgent *this, GBookmarkFile *store)
+{
+ BookmarkAgentPrivate *priv;
+ GList *items_ordered;
+ GList *node;
+
+ g_return_if_fail (IS_BOOKMARK_AGENT (this));
+
+ priv = PRIVATE (this);
+
+ libslab_checkpoint ("bookmark_agent_update_from_bookmark_file(): start updating");
+
+ items_ordered = make_items_from_bookmark_file (this, store);
+
+ g_bookmark_file_free (priv->store);
+ priv->store = g_bookmark_file_new ();
+
+ for (node = items_ordered; node; node = node->next) {
+ BookmarkItem *item;
+
+ item = (BookmarkItem *) node->data;
+
+ g_bookmark_file_set_mime_type (priv->store, item->uri, item->mime_type);
+ g_bookmark_file_set_modified (priv->store, item->uri, item->mtime);
+
+ bookmark_item_free (item);
+ }
+
+ g_list_free (items_ordered);
+
+ libslab_checkpoint ("bookmark_agent_update_from_bookmark_file(): end updating");
+}
+
void
bookmark_item_free (BookmarkItem *item)
{
@@ -919,6 +994,8 @@
bookmark_item_free (item);
}
+ /* FIXME: free items_ordered! */
+
libslab_checkpoint ("load_recent_store(): end processing items from %s", priv->store_path);
}
Modified: trunk/libslab/bookmark-agent.h
==============================================================================
--- trunk/libslab/bookmark-agent.h (original)
+++ trunk/libslab/bookmark-agent.h Sat Apr 5 00:41:12 2008
@@ -80,6 +80,8 @@
void bookmark_agent_remove_item (BookmarkAgent *this, const gchar *uri);
void bookmark_agent_reorder_items (BookmarkAgent *this, const gchar **uris);
+void bookmark_agent_update_from_bookmark_file (BookmarkAgent *this, GBookmarkFile *store);
+
void bookmark_item_free (BookmarkItem *item);
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]