diff options
author | Christian Persch <chpe@cvs.gnome.org> | 2005-04-08 21:26:25 +0800 |
---|---|---|
committer | Christian Persch <chpe@src.gnome.org> | 2005-04-08 21:26:25 +0800 |
commit | 30cfaa4a4929d85f303b3afc9c8ec240d548ff87 (patch) | |
tree | 833970d4a40cf2aabd3fb62b87ca16e640c0523f | |
parent | 3ddeef804136e9f47f66c38c80d126a4285d525d (diff) | |
download | gsoc2013-epiphany-30cfaa4a4929d85f303b3afc9c8ec240d548ff87.tar gsoc2013-epiphany-30cfaa4a4929d85f303b3afc9c8ec240d548ff87.tar.gz gsoc2013-epiphany-30cfaa4a4929d85f303b3afc9c8ec240d548ff87.tar.bz2 gsoc2013-epiphany-30cfaa4a4929d85f303b3afc9c8ec240d548ff87.tar.lz gsoc2013-epiphany-30cfaa4a4929d85f303b3afc9c8ec240d548ff87.tar.xz gsoc2013-epiphany-30cfaa4a4929d85f303b3afc9c8ec240d548ff87.tar.zst gsoc2013-epiphany-30cfaa4a4929d85f303b3afc9c8ec240d548ff87.zip |
Implement a more flexible approach at saving a EphyNodeDb, by allowing to
2005-04-08 Christian Persch <chpe@cvs.gnome.org>
* embed/ephy-favicon-cache.c: (ephy_favicon_cache_finalize):
* embed/ephy-history.c: (save_filter), (ephy_history_save):
* lib/ephy-node-db.c: (ephy_node_db_write_to_xml_valist):
* lib/ephy-node.h:
* lib/ephy-state.c: (ephy_states_save):
* src/bookmarks/ephy-bookmarks.c: (save_filter),
(ephy_bookmarks_save):
Implement a more flexible approach at saving a EphyNodeDb, by allowing
to specify a filter func to exclude certain nodes, instead of a fixed
list.
-rw-r--r-- | ChangeLog | 14 | ||||
-rw-r--r-- | embed/ephy-favicon-cache.c | 3 | ||||
-rw-r--r-- | embed/ephy-history.c | 11 | ||||
-rw-r--r-- | lib/ephy-node-db.c | 19 | ||||
-rw-r--r-- | lib/ephy-node.h | 1 | ||||
-rw-r--r-- | lib/ephy-state.c | 2 | ||||
-rw-r--r-- | src/bookmarks/ephy-bookmarks.c | 17 |
7 files changed, 47 insertions, 20 deletions
@@ -1,5 +1,19 @@ 2005-04-08 Christian Persch <chpe@cvs.gnome.org> + * embed/ephy-favicon-cache.c: (ephy_favicon_cache_finalize): + * embed/ephy-history.c: (save_filter), (ephy_history_save): + * lib/ephy-node-db.c: (ephy_node_db_write_to_xml_valist): + * lib/ephy-node.h: + * lib/ephy-state.c: (ephy_states_save): + * src/bookmarks/ephy-bookmarks.c: (save_filter), + (ephy_bookmarks_save): + + Implement a more flexible approach at saving a EphyNodeDb, by allowing + to specify a filter func to exclude certain nodes, instead of a fixed + list. + +2005-04-08 Christian Persch <chpe@cvs.gnome.org> + * embed/ephy-embed.c: (ephy_embed_base_init): * embed/ephy-embed.h: * embed/mozilla/EphyBrowser.cpp: diff --git a/embed/ephy-favicon-cache.c b/embed/ephy-favicon-cache.c index 6d7269a48..0e283e229 100644 --- a/embed/ephy-favicon-cache.c +++ b/embed/ephy-favicon-cache.c @@ -291,7 +291,8 @@ ephy_favicon_cache_finalize (GObject *object) EPHY_FAVICON_CACHE_XML_ROOT, EPHY_FAVICON_CACHE_XML_VERSION, NULL, - cache->priv->icons, 0, NULL); + cache->priv->icons, NULL, NULL, + NULL); g_free (cache->priv->xml_file); g_free (cache->priv->directory); diff --git a/embed/ephy-history.c b/embed/ephy-history.c index 31873b51f..e6c8f08c9 100644 --- a/embed/ephy-history.c +++ b/embed/ephy-history.c @@ -256,6 +256,13 @@ remove_obsolete_pages (EphyHistory *eb) } } +static gboolean +save_filter (EphyNode *node, + EphyNode *page_node) +{ + return node != page_node; +} + static void ephy_history_save (EphyHistory *eb) { @@ -275,8 +282,8 @@ ephy_history_save (EphyHistory *eb) EPHY_HISTORY_XML_VERSION, NULL, /* comment */ eb->priv->hosts, - 1, eb->priv->pages, - eb->priv->pages, 0, + (EphyNodeFilterFunc) save_filter, eb->priv->pages, + eb->priv->pages, NULL, NULL, NULL); if (ret >=0) diff --git a/lib/ephy-node-db.c b/lib/ephy-node-db.c index 8f553491a..c98f7b4f7 100644 --- a/lib/ephy-node-db.c +++ b/lib/ephy-node-db.c @@ -504,24 +504,21 @@ ephy_node_db_write_to_xml_valist (EphyNodeDb *db, while (node != NULL) { GPtrArray *children; - guint n_exceptions, i; - GSList *exceptions = NULL; + EphyNodeFilterFunc filter; + gpointer user_data; + int i; - n_exceptions = va_arg (argptr, guint); - for (i=0; i < n_exceptions; i++) - { - exceptions = g_slist_prepend (exceptions, - va_arg (argptr, EphyNode *)); - } + filter = va_arg (argptr, EphyNodeFilterFunc); + user_data = va_arg (argptr, gpointer); children = ephy_node_get_children (node); - for (i=0; i < children->len; i++) + for (i = 0; i < children->len; i++) { EphyNode *kid; kid = g_ptr_array_index (children, i); - if (g_slist_find (exceptions, kid) == NULL) + if (!filter || filter (kid, user_data)) { ret = ephy_node_write_to_xml (kid, writer); if (ret < 0) break; @@ -529,8 +526,6 @@ ephy_node_db_write_to_xml_valist (EphyNodeDb *db, } if (ret < 0) break; - g_slist_free (exceptions); - node = va_arg (argptr, EphyNode *); } if (ret < 0) goto out; diff --git a/lib/ephy-node.h b/lib/ephy-node.h index 7335616dd..ecdb32588 100644 --- a/lib/ephy-node.h +++ b/lib/ephy-node.h @@ -47,6 +47,7 @@ typedef enum #include "ephy-node-db.h" typedef void (*EphyNodeCallback) (EphyNode *node, ...); +typedef gboolean (*EphyNodeFilterFunc) (EphyNode *, gpointer); GType ephy_node_get_type (void) G_GNUC_CONST; diff --git a/lib/ephy-state.c b/lib/ephy-state.c index ad8c6e018..f12ada4bc 100644 --- a/lib/ephy-state.c +++ b/lib/ephy-state.c @@ -67,7 +67,7 @@ ephy_states_save (void) EPHY_STATES_XML_ROOT, EPHY_STATES_XML_VERSION, NULL, /* comment */ - states, 0, + states, NULL, NULL, NULL); g_free (xml_file); diff --git a/src/bookmarks/ephy-bookmarks.c b/src/bookmarks/ephy-bookmarks.c index 0043d845a..9129181e2 100644 --- a/src/bookmarks/ephy-bookmarks.c +++ b/src/bookmarks/ephy-bookmarks.c @@ -309,6 +309,17 @@ ephy_bookmarks_class_init (EphyBookmarksClass *klass) g_type_class_add_private (object_class, sizeof(EphyBookmarksPrivate)); } +static gboolean +save_filter (EphyNode *node, + EphyBookmarks *bookmarks) +{ + EphyBookmarksPrivate *priv = bookmarks->priv; + + return node != priv->bookmarks && + node != priv->favorites && + node != priv->notcategorized; +} + static void ephy_bookmarks_save (EphyBookmarks *eb) { @@ -321,10 +332,8 @@ ephy_bookmarks_save (EphyBookmarks *eb) (xmlChar *) EPHY_BOOKMARKS_XML_ROOT, (xmlChar *) EPHY_BOOKMARKS_XML_VERSION, (xmlChar *) "Do not rely on this file, it's only for internal use. Use bookmarks.rdf instead.", - eb->priv->keywords, - 3, eb->priv->bookmarks, eb->priv->favorites, eb->priv->notcategorized, - eb->priv->bookmarks, - 0, + eb->priv->keywords, (EphyNodeFilterFunc) save_filter, eb, + eb->priv->bookmarks, NULL, NULL, NULL); /* Export bookmarks in rdf */ |