aboutsummaryrefslogtreecommitdiffstats
path: root/src/bookmarks/ephy-bookmarks-import.c
diff options
context:
space:
mode:
authorChristian Persch <chpe@cvs.gnome.org>2005-10-19 04:53:55 +0800
committerChristian Persch <chpe@src.gnome.org>2005-10-19 04:53:55 +0800
commit62a6c9ce277ecfaf989b35c83668ce9691545de2 (patch)
tree718a9724f1b99a0bb3d32ebe5cc0839b389cac91 /src/bookmarks/ephy-bookmarks-import.c
parentc8121f1b9552aa3c078925516f1621cd2c63c005 (diff)
downloadgsoc2013-epiphany-62a6c9ce277ecfaf989b35c83668ce9691545de2.tar.gz
gsoc2013-epiphany-62a6c9ce277ecfaf989b35c83668ce9691545de2.tar.zst
gsoc2013-epiphany-62a6c9ce277ecfaf989b35c83668ce9691545de2.zip
Adapt folder import to new menu code, patch by Peter Harvey.
2005-10-18 Christian Persch <chpe@cvs.gnome.org> * src/bookmarks/ephy-bookmarks-import.c: (xbel_parse_folder), (ephy_bookmarks_import_mozilla): Adapt folder import to new menu code, patch by Peter Harvey.
Diffstat (limited to 'src/bookmarks/ephy-bookmarks-import.c')
-rw-r--r--src/bookmarks/ephy-bookmarks-import.c92
1 files changed, 36 insertions, 56 deletions
diff --git a/src/bookmarks/ephy-bookmarks-import.c b/src/bookmarks/ephy-bookmarks-import.c
index e56442437..c7cb2ba48 100644
--- a/src/bookmarks/ephy-bookmarks-import.c
+++ b/src/bookmarks/ephy-bookmarks-import.c
@@ -261,7 +261,7 @@ xbel_parse_bookmark (EphyBookmarks *eb, xmlTextReaderPtr reader, EphyNode **ret_
}
static int
-xbel_parse_folder (EphyBookmarks *eb, xmlTextReaderPtr reader, char *parent_folder)
+xbel_parse_folder (EphyBookmarks *eb, xmlTextReaderPtr reader, GList *folders)
{
EphyXBELImporterState state = STATE_FOLDER;
char *folder = NULL;
@@ -285,22 +285,9 @@ xbel_parse_folder (EphyBookmarks *eb, xmlTextReaderPtr reader, char *parent_fold
{
if (state == STATE_TITLE && folder == NULL)
{
- char *title;
-
- title = (char *) xmlTextReaderValue (reader);
-
- if (!parent_folder)
- {
- folder = g_strdup (title);
- }
- else
- {
- folder = g_strconcat (parent_folder,
- BOOKMARKS_HIERARCHY_SEP,
- title, NULL);
- }
-
- g_free (title);
+ folder = (char *) xmlTextReaderValue (reader);
+
+ folders = g_list_prepend (folders, folder);
}
else
{
@@ -310,19 +297,27 @@ xbel_parse_folder (EphyBookmarks *eb, xmlTextReaderPtr reader, char *parent_fold
else if (xmlStrEqual (tag, (xmlChar *) "bookmark") && type == 1 && state == STATE_FOLDER)
{
EphyNode *node = NULL, *keyword;
+ GList *l;
ret = xbel_parse_bookmark (eb, reader, &node);
- keyword = ephy_bookmarks_find_keyword (eb, folder ? folder : "", FALSE);
-
- if (keyword == NULL && folder != NULL && folder[0] != '\0')
+ for (l = folders; l != NULL; l=l->next)
{
- keyword = ephy_bookmarks_add_keyword (eb, folder);
- }
+ char *title;
+
+ title = l->data ? (char *) l->data : "";
+
+ keyword = ephy_bookmarks_find_keyword (eb, title, FALSE);
+
+ if (keyword == NULL && title[0] != '\0')
+ {
+ keyword = ephy_bookmarks_add_keyword (eb, title);
+ }
- if (node != NULL && keyword != NULL)
- {
- ephy_bookmarks_set_keyword (eb, keyword, node);
+ if (node != NULL && keyword != NULL)
+ {
+ ephy_bookmarks_set_keyword (eb, keyword, node);
+ }
}
if (ret != 1) break;
@@ -332,7 +327,7 @@ xbel_parse_folder (EphyBookmarks *eb, xmlTextReaderPtr reader, char *parent_fold
{
if (type == XML_READER_TYPE_ELEMENT)
{
- ret = xbel_parse_folder (eb, reader, folder ? folder : "");
+ ret = xbel_parse_folder (eb, reader, folders);
if (ret != 1) break;
}
@@ -384,8 +379,12 @@ xbel_parse_folder (EphyBookmarks *eb, xmlTextReaderPtr reader, char *parent_fold
/* next one, please */
ret = xmlTextReaderRead (reader);
}
-
- g_free (folder);
+
+ if (folder)
+ {
+ folders = g_list_remove (folders, folder);
+ g_free (folder);
+ }
return ret;
}
@@ -660,25 +659,6 @@ ns_parse_bookmark_item (GString *string)
return temp;
}
-static char *
-folders_list_to_topic_name (GList *folders)
-{
- GString *topic;
- GList *l;
-
- g_return_val_if_fail (folders != NULL, NULL);
-
- topic = g_string_new (folders->data);
-
- for (l = folders->next; l != NULL; l = l->next)
- {
- g_string_append (topic, BOOKMARKS_HIERARCHY_SEP);
- g_string_append (topic, l->data);
- }
-
- return g_string_free (topic, FALSE);
-}
-
gboolean
ephy_bookmarks_import_mozilla (EphyBookmarks *bookmarks,
const char *filename)
@@ -733,18 +713,18 @@ ephy_bookmarks_import_mozilla (EphyBookmarks *bookmarks,
if (folders != NULL)
{
EphyNode *keyword;
+ GList *l;
- topic = folders_list_to_topic_name (folders);
- g_return_val_if_fail (topic != NULL, FALSE);
-
- keyword = ephy_bookmarks_find_keyword (bookmarks, topic, FALSE);
- if (keyword == NULL)
+ for (l = folders; l != NULL; l = l->next)
{
- keyword = ephy_bookmarks_add_keyword (bookmarks, topic);
- }
- g_free (topic);
+ keyword = ephy_bookmarks_find_keyword (bookmarks, l->data, FALSE);
+ if (keyword == NULL)
+ {
+ keyword = ephy_bookmarks_add_keyword (bookmarks, l->data);
+ }
- ephy_bookmarks_set_keyword (bookmarks, keyword, node);
+ ephy_bookmarks_set_keyword (bookmarks, keyword, node);
+ }
}
g_free (parsedname);