From e4bb3b5a38b30253ac52985773a966f733722364 Mon Sep 17 00:00:00 2001 From: Marco Pesenti Gritti Date: Mon, 21 Jun 2004 22:37:45 +0000 Subject: Keep the whole hierarchy of folders in the topic name, separated by |. 2004-06-22 Marco Pesenti Gritti * src/bookmarks/ephy-bookmarks-import.c: (folders_list_to_topic_name), (ephy_bookmarks_import_mozilla): Keep the whole hierarchy of folders in the topic name, separated by |. Mozilla importer only for now. --- ChangeLog | 8 +++++ src/bookmarks/ephy-bookmarks-import.c | 61 ++++++++++++++++++++++------------- 2 files changed, 47 insertions(+), 22 deletions(-) diff --git a/ChangeLog b/ChangeLog index 17ec1c225..2a0f04e0d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2004-06-22 Marco Pesenti Gritti + + * src/bookmarks/ephy-bookmarks-import.c: + (folders_list_to_topic_name), (ephy_bookmarks_import_mozilla): + + Keep the whole hierarchy of folders in the topic name, separated + by |. Mozilla importer only for now. + 2004-06-22 Marco Pesenti Gritti * src/bookmarks/ephy-bookmarks-import.c: (bookmark_add), diff --git a/src/bookmarks/ephy-bookmarks-import.c b/src/bookmarks/ephy-bookmarks-import.c index 336a2a5e2..faa6072aa 100644 --- a/src/bookmarks/ephy-bookmarks-import.c +++ b/src/bookmarks/ephy-bookmarks-import.c @@ -670,15 +670,34 @@ 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, "|"); + g_string_append (topic, l->data); + } + + return g_string_free (topic, FALSE); +} + gboolean ephy_bookmarks_import_mozilla (EphyBookmarks *bookmarks, const char *filename) { FILE *bf; /* bookmark file */ - GString *name; - char *parsedname; - GString *url; - GList *folders = NULL, *l; + GString *name, *url; + char *parsedname, *topic; + EphyNode *keyword; + GList *folders = NULL; if (eel_gconf_get_boolean (CONF_LOCKDOWN_DISABLE_BOOKMARK_EDITING)) return FALSE; @@ -698,14 +717,16 @@ ephy_bookmarks_import_mozilla (EphyBookmarks *bookmarks, switch (t) { case NS_FOLDER: - folders = g_list_prepend (folders, ns_parse_bookmark_item (name)); + folders = g_list_append (folders, ns_parse_bookmark_item (name)); break; case NS_FOLDER_END: if (folders) { - /* remove first entry */ - g_free (folders->data); - folders = g_list_delete_link (folders, folders); + GList *last = g_list_last (folders); + + /* remove last entry */ + g_free (last->data); + folders = g_list_delete_link (folders, last); } break; case NS_SITE: @@ -718,24 +739,20 @@ ephy_bookmarks_import_mozilla (EphyBookmarks *bookmarks, node = ephy_bookmarks_find_bookmark (bookmarks, url->str); } - for (l = folders; l != NULL; l = l->next) - { - char *topic = (char *) l->data; - EphyNode *keyword; - - keyword = ephy_bookmarks_find_keyword (bookmarks, topic, FALSE); + topic = folders_list_to_topic_name (folders); + keyword = ephy_bookmarks_find_keyword (bookmarks, topic, FALSE); - if (keyword == NULL) - { - keyword = ephy_bookmarks_add_keyword (bookmarks, topic); - } + if (keyword == NULL) + { + keyword = ephy_bookmarks_add_keyword (bookmarks, topic); + } - if (node != NULL && keyword != NULL) - { - ephy_bookmarks_set_keyword (bookmarks, keyword, node); - } + if (node != NULL && keyword != NULL) + { + ephy_bookmarks_set_keyword (bookmarks, keyword, node); } + g_free (topic); g_free (parsedname); break; -- cgit v1.2.3