aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMarco Pesenti Gritti <marco@gnome.org>2004-06-22 06:37:45 +0800
committerMarco Pesenti Gritti <marco@src.gnome.org>2004-06-22 06:37:45 +0800
commite4bb3b5a38b30253ac52985773a966f733722364 (patch)
tree0c810d0cb7191a96d2bf615c0584795d2ae1011b /src
parent220d812d83540192c0c484b425163a2545753e24 (diff)
downloadgsoc2013-epiphany-e4bb3b5a38b30253ac52985773a966f733722364.tar
gsoc2013-epiphany-e4bb3b5a38b30253ac52985773a966f733722364.tar.gz
gsoc2013-epiphany-e4bb3b5a38b30253ac52985773a966f733722364.tar.bz2
gsoc2013-epiphany-e4bb3b5a38b30253ac52985773a966f733722364.tar.lz
gsoc2013-epiphany-e4bb3b5a38b30253ac52985773a966f733722364.tar.xz
gsoc2013-epiphany-e4bb3b5a38b30253ac52985773a966f733722364.tar.zst
gsoc2013-epiphany-e4bb3b5a38b30253ac52985773a966f733722364.zip
Keep the whole hierarchy of folders in the topic name, separated by |.
2004-06-22 Marco Pesenti Gritti <marco@gnome.org> * 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.
Diffstat (limited to 'src')
-rw-r--r--src/bookmarks/ephy-bookmarks-import.c61
1 files changed, 39 insertions, 22 deletions
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;