aboutsummaryrefslogtreecommitdiffstats
path: root/src/bookmarks/ephy-bookmarks-import.c
diff options
context:
space:
mode:
authorMarco Pesenti Gritti <marco@it.gnome.org>2003-06-09 19:49:43 +0800
committerMarco Pesenti Gritti <mpeseng@src.gnome.org>2003-06-09 19:49:43 +0800
commit50bb5af3f6a571e8e341d26cdd5b7a1b2178d8dd (patch)
tree4e8a7a54ff0f66f5c611e4cda2cb33138873cb6f /src/bookmarks/ephy-bookmarks-import.c
parent715e6da7a85512491ac612dc5f97e48809ea5b4a (diff)
downloadgsoc2013-epiphany-50bb5af3f6a571e8e341d26cdd5b7a1b2178d8dd.tar.gz
gsoc2013-epiphany-50bb5af3f6a571e8e341d26cdd5b7a1b2178d8dd.tar.zst
gsoc2013-epiphany-50bb5af3f6a571e8e341d26cdd5b7a1b2178d8dd.zip
Get rid of starthere: and default to google, as discussed with Seth. Add a
2003-06-09 Marco Pesenti Gritti <marco@it.gnome.org> * data/epiphany.schemas.in: * data/ui/epiphany-bookmark-editor-ui.xml.in: * embed/ephy-embed-shell.c: (ephy_embed_shell_class_init): * embed/mozilla/Makefile.am: * embed/mozilla/MozRegisterComponents.cpp: * lib/Makefile.am: * src/bookmarks/ephy-bookmark-action.c: (create_tool_item), (ephy_bookmark_action_sync_smart_url), (entry_activated_cb), (activate_cb), (connect_proxy), (ephy_bookmark_action_set_property), (ephy_bookmark_action_finalize), (ephy_bookmark_action_class_init), (sync_bookmark_properties), (ephy_bookmark_action_init): * src/bookmarks/ephy-bookmark-properties.c: (location_entry_changed_cb): * src/bookmarks/ephy-bookmarks-editor.c: (show_properties_dialog), (add_bookmarks_source_menu), (import_dialog_response_cb), (cmd_bookmarks_import): * src/bookmarks/ephy-bookmarks-import.c: (ephy_bookmarks_import), (mozilla_parse_bookmarks), (xbel_parse_folder), (xbel_parse_bookmarks), (ephy_bookmarks_import_xbel): * src/bookmarks/ephy-bookmarks-import.h: * src/bookmarks/ephy-bookmarks.c: (ephy_bookmarks_autocompletion_source_foreach), (ephy_bookmarks_init_defaults), (update_topics_list), (update_has_smart_address), (ephy_bookmarks_add), (ephy_bookmarks_set_address): * src/bookmarks/ephy-bookmarks.h: * src/bookmarks/ephy-new-bookmark.c: (ephy_new_bookmark_finalize), (ephy_new_bookmark_add), (ephy_new_bookmark_init), (ephy_new_bookmark_set_title): * src/bookmarks/ephy-new-bookmark.h: * src/ephy-shell.c: (ephy_shell_init): * src/popup-commands.c: (popup_cmd_bookmark_link): Get rid of starthere: and default to google, as discussed with Seth. Add a way to import bookmarks from the editor. (you still cant specificy a file, that's sort of low priority for me, but we have a plan on how to do it). Allow to edit smart bookmarks in the user interface. The address field is used and when there is a %s, it's considered a smart url. (like mozilla does it).
Diffstat (limited to 'src/bookmarks/ephy-bookmarks-import.c')
-rw-r--r--src/bookmarks/ephy-bookmarks-import.c62
1 files changed, 40 insertions, 22 deletions
diff --git a/src/bookmarks/ephy-bookmarks-import.c b/src/bookmarks/ephy-bookmarks-import.c
index 950560d8f..f574654ae 100644
--- a/src/bookmarks/ephy-bookmarks-import.c
+++ b/src/bookmarks/ephy-bookmarks-import.c
@@ -19,9 +19,10 @@
#include <glib.h>
#include <libxml/HTMLtree.h>
#include <string.h>
+#include <libgnomevfs/gnome-vfs-mime-utils.h>
#include "ephy-bookmarks-import.h"
-#include "ephy-string.h"
+#include "ephy-debug.h"
typedef struct _XbelInfo
{
@@ -47,6 +48,28 @@ set_folder (EphyBookmarks *bookmarks,
return topic;
}
+gboolean
+ephy_bookmarks_import (EphyBookmarks *bookmarks,
+ const char *filename)
+{
+ char *type;
+
+ type = gnome_vfs_get_mime_type (filename);
+
+ LOG ("Importing bookmarks of type %s", type)
+
+ if (type == NULL) return FALSE;
+
+ if (strcmp (type, "application/x-mozilla-bookmarks") == 0)
+ {
+ return ephy_bookmarks_import_mozilla (bookmarks, filename);
+ }
+ else
+ {
+ return ephy_bookmarks_import_xbel (bookmarks, filename);
+ }
+}
+
static void
mozilla_parse_bookmarks (EphyBookmarks *bookmarks,
htmlNodePtr node,
@@ -69,8 +92,7 @@ mozilla_parse_bookmarks (EphyBookmarks *bookmarks,
url = xmlGetProp (child, "href");
bmk = ephy_bookmarks_add (bookmarks,
title,
- url,
- NULL);
+ url);
set_folder (bookmarks, bmk, *keyword);
xmlFree (title);
xmlFree (url);
@@ -119,11 +141,10 @@ xbel_parse_single_bookmark (EphyBookmarks *bookmarks,
static void
xbel_parse_folder (EphyBookmarks *bookmarks,
- xmlNodePtr node,
- const char *default_keyword)
+ xmlNodePtr node)
{
xmlNodePtr child = node;
- xmlChar *keyword = g_strdup (default_keyword);
+ xmlChar *keyword = NULL;
while (child != NULL)
{
@@ -147,15 +168,16 @@ xbel_parse_folder (EphyBookmarks *bookmarks,
child->children,
xbel);
+ /* FIXME need to import also smart bookmark */
bmk = ephy_bookmarks_add (bookmarks,
xbel->title,
- url,
- xbel->smarturl);
- set_folder (bookmarks, bmk, keyword);
-
- if (url)
- xmlFree (url);
+ url);
+ if (keyword)
+ {
+ set_folder (bookmarks, bmk, keyword);
+ }
+ xmlFree (url);
if (xbel && xbel->title)
xmlFree (xbel->title);
@@ -168,11 +190,10 @@ xbel_parse_folder (EphyBookmarks *bookmarks,
else if (xmlStrEqual (child->name, "folder"))
{
xbel_parse_folder (bookmarks,
- child->children,
- keyword);
+ child->children);
g_free (keyword);
- keyword = g_strdup (default_keyword);
+ keyword = NULL;
}
child = child->next;
@@ -184,8 +205,7 @@ xbel_parse_folder (EphyBookmarks *bookmarks,
static void
xbel_parse_bookmarks (EphyBookmarks *bookmarks,
- xmlNodePtr node,
- const char *default_keyword)
+ xmlNodePtr node)
{
xmlNodePtr child = node;
@@ -194,8 +214,7 @@ xbel_parse_bookmarks (EphyBookmarks *bookmarks,
if (xmlStrEqual (child->name, "xbel"))
{
xbel_parse_folder (bookmarks,
- child->children,
- default_keyword);
+ child->children);
}
child = child->next;
@@ -229,8 +248,7 @@ ephy_bookmarks_import_mozilla (EphyBookmarks *bookmarks,
gboolean
ephy_bookmarks_import_xbel (EphyBookmarks *bookmarks,
- const char *filename,
- const char *default_keyword)
+ const char *filename)
{
xmlDocPtr doc;
xmlNodePtr child;
@@ -242,7 +260,7 @@ ephy_bookmarks_import_xbel (EphyBookmarks *bookmarks,
g_assert (doc != NULL);
child = doc->children;
- xbel_parse_bookmarks (bookmarks, child, default_keyword);
+ xbel_parse_bookmarks (bookmarks, child);
xmlFreeDoc (doc);