aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/bookmarks/ephy-bookmark-action.c119
-rw-r--r--src/bookmarks/ephy-bookmark-properties.c8
-rw-r--r--src/bookmarks/ephy-bookmarks-editor.c112
-rw-r--r--src/bookmarks/ephy-bookmarks-import.c62
-rw-r--r--src/bookmarks/ephy-bookmarks-import.h6
-rw-r--r--src/bookmarks/ephy-bookmarks.c68
-rw-r--r--src/bookmarks/ephy-bookmarks.h9
-rw-r--r--src/bookmarks/ephy-new-bookmark.c14
-rw-r--r--src/bookmarks/ephy-new-bookmark.h3
-rw-r--r--src/ephy-shell.c83
-rw-r--r--src/popup-commands.c5
11 files changed, 292 insertions, 197 deletions
diff --git a/src/bookmarks/ephy-bookmark-action.c b/src/bookmarks/ephy-bookmark-action.c
index 96e011f6f..4264483d7 100644
--- a/src/bookmarks/ephy-bookmark-action.c
+++ b/src/bookmarks/ephy-bookmark-action.c
@@ -21,6 +21,7 @@
#endif
#include <bonobo/bonobo-i18n.h>
+#include <libgnomevfs/gnome-vfs-uri.h>
#include "ephy-bookmark-action.h"
#include "ephy-bookmarks.h"
@@ -38,7 +39,7 @@ struct EphyBookmarkActionPrivate
{
int bookmark_id;
char *location;
- char *smart_url;
+ gboolean smart_url;
char *icon;
};
@@ -101,11 +102,8 @@ create_menu_item (EggAction *action)
static GtkWidget *
create_tool_item (EggAction *action)
{
- GtkWidget *item;
- GtkWidget *button;
- GtkWidget *hbox;
- GtkWidget *label;
- GtkWidget *icon;
+ GtkWidget *item, *button, *hbox, *label,
+ *icon, *entry;
item = (* EGG_ACTION_CLASS (parent_class)->create_tool_item) (action);
@@ -119,16 +117,10 @@ create_tool_item (EggAction *action)
gtk_container_add (GTK_CONTAINER (hbox), button);
g_object_set_data (G_OBJECT (item), "button", button);
- if (EPHY_BOOKMARK_ACTION (action)->priv->smart_url)
- {
- GtkWidget *entry;
-
- entry = gtk_entry_new ();
- gtk_widget_set_size_request (entry, 120, -1);
- gtk_widget_show (entry);
- gtk_box_pack_start (GTK_BOX (hbox), entry, TRUE, TRUE, 0);
- g_object_set_data (G_OBJECT (item), "entry", entry);
- }
+ entry = gtk_entry_new ();
+ gtk_widget_set_size_request (entry, 120, -1);
+ gtk_box_pack_start (GTK_BOX (hbox), entry, TRUE, TRUE, 0);
+ g_object_set_data (G_OBJECT (item), "entry", entry);
hbox = gtk_hbox_new (FALSE, 0);
gtk_widget_show (hbox);
@@ -148,6 +140,28 @@ create_tool_item (EggAction *action)
}
static void
+ephy_bookmark_action_sync_smart_url (EggAction *action, GParamSpec *pspec, GtkWidget *proxy)
+{
+ if (EGG_IS_TOOL_ITEM (proxy))
+ {
+ GtkWidget *entry;
+ gboolean smart_url;
+
+ smart_url = EPHY_BOOKMARK_ACTION (action)->priv->smart_url;
+ entry = GTK_WIDGET (g_object_get_data (G_OBJECT (proxy), "entry"));
+
+ if (smart_url)
+ {
+ gtk_widget_show (entry);
+ }
+ else
+ {
+ gtk_widget_hide (entry);
+ }
+ }
+}
+
+static void
ephy_bookmark_action_sync_icon (EggAction *action, GParamSpec *pspec, GtkWidget *proxy)
{
char *icon_location;
@@ -243,7 +257,7 @@ entry_activated_cb (GtkWidget *entry, EggAction *action)
text = gtk_editable_get_chars (GTK_EDITABLE (entry), 0, -1);
if (text == NULL) return;
- smart_url = EPHY_BOOKMARK_ACTION (action)->priv->smart_url;
+ smart_url = EPHY_BOOKMARK_ACTION (action)->priv->location;
solved = ephy_bookmarks_solve_smart_url (bookmarks,
smart_url,
text);
@@ -257,15 +271,38 @@ entry_activated_cb (GtkWidget *entry, EggAction *action)
static void
activate_cb (GtkWidget *widget, EggAction *action)
{
+ EphyBookmarkAction *baction = EPHY_BOOKMARK_ACTION (action);
+ char *location = NULL;
+
+ if (baction->priv->smart_url)
+ {
+ GnomeVFSURI *uri;
+
+ uri = gnome_vfs_uri_new (baction->priv->location);
+
+ if (uri)
+ {
+ location = g_strdup (gnome_vfs_uri_get_scheme (uri));
+ gnome_vfs_uri_unref (uri);
+ }
+ }
+
+ if (location == NULL)
+ {
+ location = g_strdup (baction->priv->location);
+ }
+
g_signal_emit (action,
ephy_bookmark_action_signals[GO_LOCATION],
- 0, EPHY_BOOKMARK_ACTION (action)->priv->location);
+ 0, location);
+
+ g_free (location);
}
static void
connect_proxy (EggAction *action, GtkWidget *proxy)
{
- GtkWidget *button;
+ GtkWidget *button, *entry;
(* EGG_ACTION_CLASS (parent_class)->connect_proxy) (action, proxy);
@@ -277,24 +314,22 @@ connect_proxy (EggAction *action, GtkWidget *proxy)
g_signal_connect_object (action, "notify::icon",
G_CALLBACK (ephy_bookmark_action_sync_icon), proxy, 0);
+ ephy_bookmark_action_sync_smart_url (action, NULL, proxy);
+ g_signal_connect_object (action, "notify::smarturl",
+ G_CALLBACK (ephy_bookmark_action_sync_smart_url), proxy, 0);
+
if (EGG_IS_TOOL_ITEM (proxy))
{
button = GTK_WIDGET (g_object_get_data (G_OBJECT (proxy), "button"));
g_signal_connect (button, "clicked", G_CALLBACK (activate_cb), action);
+
+ entry = GTK_WIDGET (g_object_get_data (G_OBJECT (proxy), "entry"));
+ g_signal_connect (entry, "activate", G_CALLBACK (entry_activated_cb), action);
}
else if (GTK_IS_MENU_ITEM (proxy))
{
g_signal_connect (proxy, "activate", G_CALLBACK (activate_cb), action);
}
-
- if (EPHY_BOOKMARK_ACTION (action)->priv->smart_url &&
- EGG_IS_TOOL_ITEM (proxy))
- {
- GtkWidget *entry;
-
- entry = GTK_WIDGET (g_object_get_data (G_OBJECT (proxy), "entry"));
- g_signal_connect (entry, "activate", G_CALLBACK (entry_activated_cb), action);
- }
}
static void
@@ -317,13 +352,13 @@ ephy_bookmark_action_set_property (GObject *object,
bmk->priv->location = g_strdup (g_value_get_string (value));
break;
case PROP_SMART_URL:
- g_free (bmk->priv->smart_url);
- bmk->priv->smart_url = g_strdup (g_value_get_string (value));
+ bmk->priv->smart_url = g_value_get_boolean (value);
+ g_object_notify (object, "smarturl");
break;
case PROP_ICON:
g_free (bmk->priv->icon);
bmk->priv->icon = g_strdup (g_value_get_string (value));
- g_object_notify(object, "icon");
+ g_object_notify (object, "icon");
break;
}
}
@@ -358,7 +393,6 @@ ephy_bookmark_action_finalize (GObject *object)
g_return_if_fail (eba->priv != NULL);
g_free (eba->priv->location);
- g_free (eba->priv->smart_url);
g_free (eba->priv->icon);
g_free (eba->priv);
@@ -415,11 +449,11 @@ ephy_bookmark_action_class_init (EphyBookmarkActionClass *class)
G_PARAM_READWRITE));
g_object_class_install_property (object_class,
PROP_SMART_URL,
- g_param_spec_string ("smart_url",
- "Smart url",
- "Smart url",
- NULL,
- G_PARAM_READWRITE));
+ g_param_spec_boolean ("smarturl",
+ "Smart url",
+ "Smart url",
+ FALSE,
+ G_PARAM_READWRITE));
g_object_class_install_property (object_class,
PROP_ICON,
g_param_spec_string ("icon",
@@ -432,7 +466,8 @@ ephy_bookmark_action_class_init (EphyBookmarkActionClass *class)
static void
sync_bookmark_properties (EggAction *action, EphyNode *bmk)
{
- const char *title, *location, *smart_url, *icon;
+ const char *title, *location, *icon;
+ gboolean smart_url;
icon = ephy_node_get_property_string
(bmk, EPHY_NODE_BMK_PROP_ICON);
@@ -440,14 +475,13 @@ sync_bookmark_properties (EggAction *action, EphyNode *bmk)
(bmk, EPHY_NODE_BMK_PROP_TITLE);
location = ephy_node_get_property_string
(bmk, EPHY_NODE_BMK_PROP_LOCATION);
- smart_url = ephy_node_get_property_string
- (bmk, EPHY_NODE_BMK_PROP_SMART_LOCATION);
- if (smart_url && *smart_url == '\0') smart_url = NULL;
+ smart_url = ephy_node_get_property_boolean
+ (bmk, EPHY_NODE_BMK_PROP_HAS_SMART_ADDRESS);
g_object_set (action,
"label", title,
"location", location,
- "smart_url", smart_url,
+ "smarturl", smart_url,
"icon", icon,
NULL);
}
@@ -474,7 +508,6 @@ ephy_bookmark_action_init (EphyBookmarkAction *action)
action->priv = g_new0 (EphyBookmarkActionPrivate, 1);
action->priv->location = NULL;
- action->priv->smart_url = NULL;
action->priv->icon = NULL;
diff --git a/src/bookmarks/ephy-bookmark-properties.c b/src/bookmarks/ephy-bookmark-properties.c
index 5180d3863..1e0ae60e9 100644
--- a/src/bookmarks/ephy-bookmark-properties.c
+++ b/src/bookmarks/ephy-bookmark-properties.c
@@ -256,7 +256,13 @@ title_entry_changed_cb (GtkWidget *entry, EphyBookmarkProperties *props)
static void
location_entry_changed_cb (GtkWidget *entry, EphyBookmarkProperties *props)
{
- update_entry (props, entry, EPHY_NODE_BMK_PROP_LOCATION);
+ char *text;
+
+ text = gtk_editable_get_chars (GTK_EDITABLE (entry), 0, -1);
+ ephy_bookmarks_set_address (props->priv->bookmarks,
+ props->priv->bookmark,
+ text);
+ g_free (text);
}
static void
diff --git a/src/bookmarks/ephy-bookmarks-editor.c b/src/bookmarks/ephy-bookmarks-editor.c
index 616fa10b9..48dd0f7d3 100644
--- a/src/bookmarks/ephy-bookmarks-editor.c
+++ b/src/bookmarks/ephy-bookmarks-editor.c
@@ -35,6 +35,7 @@
#include "ephy-bookmarks-editor.h"
#include "ephy-bookmark-properties.h"
+#include "ephy-bookmarks-import.h"
#include "ephy-node-common.h"
#include "ephy-node-view.h"
#include "ephy-window.h"
@@ -101,6 +102,8 @@ static void cmd_delete (EggAction *action,
EphyBookmarksEditor *editor);
static void cmd_bookmark_properties (EggAction *action,
EphyBookmarksEditor *editor);
+static void cmd_bookmarks_import (EggAction *action,
+ EphyBookmarksEditor *editor);
static void cmd_add_topic (EggAction *action,
EphyBookmarksEditor *editor);
static void cmd_rename (EggAction *action,
@@ -171,6 +174,9 @@ static EggActionGroupEntry ephy_bookmark_popup_entries [] = {
{ "Properties", N_("_Properties"), GTK_STOCK_PROPERTIES, "<alt>Return",
N_("View or modify the properties of the selected bookmark"),
G_CALLBACK (cmd_bookmark_properties), NULL },
+ { "Import", N_("_Import bookmarks..."), NULL, NULL,
+ N_("Import bookmarks from another browser or a bookmarks file"),
+ G_CALLBACK (cmd_bookmarks_import), NULL },
{ "Close", N_("_Close"), GTK_STOCK_CLOSE, "<control>W",
N_("Close the bookmarks window"),
G_CALLBACK (cmd_close), NULL },
@@ -441,6 +447,112 @@ show_properties_dialog (EphyBookmarksEditor *editor, EphyNode *node)
}
static void
+add_bookmarks_source_menu (GtkWidget *menu,
+ const char *desc,
+ const char *dir,
+ const char *filename)
+{
+ GSList *l;
+ char *path;
+
+ path = g_build_filename (g_get_home_dir (), dir, NULL);
+ l = ephy_file_find (path, filename, 4);
+ g_free (path);
+
+ if (l)
+ {
+ GtkWidget *item;
+
+ item = gtk_menu_item_new_with_label (desc);
+ gtk_widget_show (item);
+ gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
+ g_object_set_data_full (G_OBJECT (item), "bookmarks_file",
+ g_strdup (l->data), g_free);
+ }
+
+ g_slist_foreach (l, (GFunc) g_free, NULL);
+ g_slist_free (l);
+}
+
+static void
+import_dialog_response_cb (GtkDialog *dialog, gint response,
+ GtkWidget *optionmenu)
+{
+ if (response == GTK_RESPONSE_OK)
+ {
+ char *filename;
+ GtkWidget *item, *menu;
+ EphyBookmarks *bookmarks;
+
+ menu = gtk_option_menu_get_menu (GTK_OPTION_MENU (optionmenu));
+ item = gtk_menu_get_active (GTK_MENU (menu));
+ filename = g_object_get_data (G_OBJECT (item), "bookmarks_file");
+
+ bookmarks = ephy_shell_get_bookmarks (ephy_shell);
+ ephy_bookmarks_import (bookmarks, filename);
+ }
+
+ gtk_widget_destroy (GTK_WIDGET (dialog));
+}
+
+static void
+cmd_bookmarks_import (EggAction *action,
+ EphyBookmarksEditor *editor)
+{
+ GtkWidget *dialog;
+ GtkWidget *label;
+ GtkWidget *vbox;
+ GtkWidget *menu;
+ GtkWidget *option_menu;
+
+ dialog = gtk_dialog_new_with_buttons (_("Import Bookmarks"),
+ GTK_WINDOW (editor),
+ GTK_DIALOG_DESTROY_WITH_PARENT |
+ GTK_DIALOG_NO_SEPARATOR,
+ GTK_STOCK_CANCEL,
+ GTK_RESPONSE_CANCEL,
+ GTK_STOCK_OK,
+ GTK_RESPONSE_OK,
+ NULL);
+ gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_OK);
+ gtk_container_set_border_width (GTK_CONTAINER (dialog), 6);
+ gtk_box_set_spacing (GTK_BOX (GTK_DIALOG (dialog)->vbox), 12);
+
+ vbox = gtk_vbox_new (FALSE, 6);
+ gtk_widget_show (vbox);
+ gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), vbox,
+ TRUE, TRUE, 0);
+
+ label = gtk_label_new (_("Choose the bookmarks source:"));
+ gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
+ gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
+ gtk_box_pack_start (GTK_BOX (vbox), label, TRUE, TRUE, 0);
+ gtk_widget_show (label);
+
+ menu = gtk_menu_new ();
+ gtk_widget_show (menu);
+
+ add_bookmarks_source_menu (menu, _("Mozilla bookmarks"),
+ ".mozilla", "bookmarks.html");
+ add_bookmarks_source_menu (menu, _("Galeon bookmarks"),
+ ".galeon", "bookmarks.xbel");
+ add_bookmarks_source_menu (menu, _("Konqueror bookmarks"),
+ ".kde/share/apps/konqueror",
+ "bookmarks.xml");
+
+ option_menu = gtk_option_menu_new ();
+ gtk_option_menu_set_menu (GTK_OPTION_MENU (option_menu), menu);
+ gtk_widget_show (option_menu);
+ gtk_box_pack_start (GTK_BOX (vbox), option_menu, TRUE, TRUE, 0);
+
+ g_signal_connect (dialog, "response",
+ G_CALLBACK (import_dialog_response_cb),
+ option_menu);
+
+ gtk_widget_show (dialog);
+}
+
+static void
cmd_bookmark_properties (EggAction *action,
EphyBookmarksEditor *editor)
{
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);
diff --git a/src/bookmarks/ephy-bookmarks-import.h b/src/bookmarks/ephy-bookmarks-import.h
index 79f83c897..fad58fc11 100644
--- a/src/bookmarks/ephy-bookmarks-import.h
+++ b/src/bookmarks/ephy-bookmarks-import.h
@@ -23,12 +23,14 @@
G_BEGIN_DECLS
+gboolean ephy_bookmarks_import (EphyBookmarks *bookmarks,
+ const char *filename);
+
gboolean ephy_bookmarks_import_mozilla (EphyBookmarks *bookmarks,
const char *filename);
gboolean ephy_bookmarks_import_xbel (EphyBookmarks *bookmarks,
- const char *filename,
- const char *default_keyword);
+ const char *filename);
G_END_DECLS
diff --git a/src/bookmarks/ephy-bookmarks.c b/src/bookmarks/ephy-bookmarks.c
index 801aadc87..9d4269a4e 100644
--- a/src/bookmarks/ephy-bookmarks.c
+++ b/src/bookmarks/ephy-bookmarks.c
@@ -68,7 +68,7 @@ static const EphyBookmarksBookmarkInfo default_bookmarks [] =
* "http://www.google.nl" and "http://www.google.nl/search?q=%s"
*/
- { N_("Search the web"), N_("http://www.google.com"), N_("http://www.google.com/search?q=%s&ie=UTF-8&oe=UTF-8") }
+ { N_("Search the web"), N_("http://www.google.com/search?q=%s&ie=UTF-8&oe=UTF-8") }
};
static int n_default_bookmarks = G_N_ELEMENTS (default_bookmarks);
@@ -169,29 +169,20 @@ ephy_bookmarks_autocompletion_source_foreach (EphyAutocompletionSource *source,
for (i = 0; i < children->len; i++)
{
EphyNode *kid;
- const char *url, *smart_url, *title, *keywords;
+ const char *url, *title, *keywords;
+ gboolean smart_url;
kid = g_ptr_array_index (children, i);
url = ephy_node_get_property_string
(kid, EPHY_NODE_BMK_PROP_LOCATION);
- smart_url = ephy_node_get_property_string
- (kid, EPHY_NODE_BMK_PROP_SMART_LOCATION);
+ smart_url = ephy_node_get_property_boolean
+ (kid, EPHY_NODE_BMK_PROP_HAS_SMART_ADDRESS);
title = ephy_node_get_property_string
(kid, EPHY_NODE_BMK_PROP_TITLE);
keywords = ephy_node_get_property_string
(kid, EPHY_NODE_BMK_PROP_KEYWORDS);
- if (smart_url == NULL ||
- g_utf8_strlen (smart_url, -1) == 0)
- {
- smart_url = NULL;
- }
-
- func (source,
- smart_url ? NULL : keywords,
- title,
- smart_url ? smart_url : url,
- (smart_url != NULL),
+ func (source, keywords, title, url, smart_url,
TRUE, 0, data);
}
ephy_node_thaw (eb->priv->bookmarks);
@@ -224,8 +215,7 @@ ephy_bookmarks_init_defaults (EphyBookmarks *eb)
for (i = 0; i < n_default_bookmarks; i++)
{
ephy_bookmarks_add (eb, default_bookmarks[i].title,
- default_bookmarks[i].location,
- default_bookmarks[i].smart_url);
+ default_bookmarks[i].location);
node = ephy_bookmarks_find_bookmark (eb, default_bookmarks[i].location);
if (node == NULL) break;
@@ -584,6 +574,7 @@ static void
update_topics_list (EphyNode *bookmark, const char *list)
{
GValue value = { 0, };
+
g_value_init (&value, G_TYPE_STRING);
g_value_set_string (&value, list);
ephy_node_set_property (bookmark, EPHY_NODE_BMK_PROP_KEYWORDS,
@@ -763,11 +754,28 @@ ephy_bookmarks_new ()
return tab;
}
+static void
+update_has_smart_address (EphyNode *bmk, const char *address)
+{
+ gboolean smart = FALSE;
+ GValue value = { 0, };
+
+ if (address)
+ {
+ smart = strstr (address, "%s") != NULL;
+ }
+
+ g_value_init (&value, G_TYPE_BOOLEAN);
+ g_value_set_boolean (&value, smart);
+ ephy_node_set_property (bmk, EPHY_NODE_BMK_PROP_HAS_SMART_ADDRESS,
+ &value);
+ g_value_unset (&value);
+}
+
EphyNode *
ephy_bookmarks_add (EphyBookmarks *eb,
const char *title,
- const char *url,
- const char *smart_url)
+ const char *url)
{
EphyNode *bm;
GValue value = { 0, };
@@ -786,11 +794,7 @@ ephy_bookmarks_add (EphyBookmarks *eb,
&value);
g_value_unset (&value);
- g_value_init (&value, G_TYPE_STRING);
- g_value_set_string (&value, smart_url);
- ephy_node_set_property (bm, EPHY_NODE_BMK_PROP_SMART_LOCATION,
- &value);
- g_value_unset (&value);
+ update_has_smart_address (bm, url);
ephy_node_add_child (eb->priv->bookmarks, bm);
ephy_node_add_child (eb->priv->notcategorized, bm);
@@ -801,6 +805,22 @@ ephy_bookmarks_add (EphyBookmarks *eb,
return bm;
}
+void
+ephy_bookmarks_set_address (EphyBookmarks *eb,
+ EphyNode *bookmark,
+ const char *address)
+{
+ GValue value = { 0, };
+
+ g_value_init (&value, G_TYPE_STRING);
+ g_value_set_string (&value, address);
+ ephy_node_set_property (bookmark, EPHY_NODE_BMK_PROP_LOCATION,
+ &value);
+ g_value_unset (&value);
+
+ update_has_smart_address (bookmark, address);
+}
+
EphyNode*
ephy_bookmarks_find_bookmark (EphyBookmarks *eb,
const char *url)
diff --git a/src/bookmarks/ephy-bookmarks.h b/src/bookmarks/ephy-bookmarks.h
index 0119315ce..2a72a8810 100644
--- a/src/bookmarks/ephy-bookmarks.h
+++ b/src/bookmarks/ephy-bookmarks.h
@@ -42,7 +42,7 @@ enum
EPHY_NODE_BMK_PROP_LOCATION = 3,
EPHY_NODE_BMK_PROP_KEYWORDS = 4,
EPHY_NODE_KEYWORD_PROP_NAME = 5,
- EPHY_NODE_BMK_PROP_SMART_LOCATION = 6,
+ EPHY_NODE_BMK_PROP_HAS_SMART_ADDRESS = 9,
EPHY_NODE_BMK_PROP_ICON = 7,
EPHY_NODE_KEYWORD_PROP_PRIORITY = 8
};
@@ -73,8 +73,7 @@ void ephy_bookmarks_save (EphyBookmarks *eb);
EphyNode *ephy_bookmarks_add (EphyBookmarks *eb,
const char *title,
- const char *url,
- const char *smart_url);
+ const char *url);
EphyNode* ephy_bookmarks_find_bookmark (EphyBookmarks *eb,
const char *url);
@@ -83,6 +82,10 @@ void ephy_bookmarks_set_icon (EphyBookmarks *eb,
const char *url,
const char *icon);
+void ephy_bookmarks_set_address (EphyBookmarks *eb,
+ EphyNode *bookmark,
+ const char *address);
+
char *ephy_bookmarks_solve_smart_url (EphyBookmarks *eb,
const char *smart_url,
const char *content);
diff --git a/src/bookmarks/ephy-new-bookmark.c b/src/bookmarks/ephy-new-bookmark.c
index 69e190ebc..067b48cee 100644
--- a/src/bookmarks/ephy-new-bookmark.c
+++ b/src/bookmarks/ephy-new-bookmark.c
@@ -54,7 +54,6 @@ struct EphyNewBookmarkPrivate
{
EphyBookmarks *bookmarks;
char *location;
- char *smarturl;
char *icon;
gulong id;
@@ -140,7 +139,6 @@ ephy_new_bookmark_finalize (GObject *object)
g_return_if_fail (editor->priv != NULL);
g_free (editor->priv->location);
- g_free (editor->priv->smarturl);
g_free (editor->priv->icon);
g_free (editor->priv);
@@ -160,8 +158,7 @@ ephy_new_bookmark_add (EphyNewBookmark *new_bookmark)
title = gtk_editable_get_chars
(GTK_EDITABLE (new_bookmark->priv->title_entry), 0, -1);
node = ephy_bookmarks_add (new_bookmark->priv->bookmarks, title,
- new_bookmark->priv->location,
- new_bookmark->priv->smarturl);
+ new_bookmark->priv->location);
new_bookmark->priv->id = ephy_node_get_id (node);
ephy_topics_selector_set_bookmark (selector, node);
@@ -466,7 +463,6 @@ ephy_new_bookmark_init (EphyNewBookmark *editor)
{
editor->priv = g_new0 (EphyNewBookmarkPrivate, 1);
editor->priv->location = NULL;
- editor->priv->smarturl = NULL;
editor->priv->icon = NULL;
editor->priv->id = 0;
}
@@ -481,14 +477,6 @@ ephy_new_bookmark_set_title (EphyNewBookmark *bookmark,
}
void
-ephy_new_bookmark_set_smarturl (EphyNewBookmark *bookmark,
- const char *url)
-{
- g_free (bookmark->priv->smarturl);
- bookmark->priv->smarturl = g_strdup (url);
-}
-
-void
ephy_new_bookmark_set_icon (EphyNewBookmark *bookmark,
const char *icon)
{
diff --git a/src/bookmarks/ephy-new-bookmark.h b/src/bookmarks/ephy-new-bookmark.h
index 15b3c2c1b..35ccc06e4 100644
--- a/src/bookmarks/ephy-new-bookmark.h
+++ b/src/bookmarks/ephy-new-bookmark.h
@@ -64,9 +64,6 @@ void ephy_new_bookmark_set_title (EphyNewBookmark *bookmark,
void ephy_new_bookmark_set_icon (EphyNewBookmark *bookmark,
const char *icon);
-void ephy_new_bookmark_set_smarturl (EphyNewBookmark *bookmark,
- const char *url);
-
gulong ephy_new_bookmark_get_id (EphyNewBookmark *bookmark);
G_END_DECLS
diff --git a/src/ephy-shell.c b/src/ephy-shell.c
index 631e6f44a..e126562c8 100644
--- a/src/ephy-shell.c
+++ b/src/ephy-shell.c
@@ -127,84 +127,6 @@ ephy_shell_class_init (EphyShellClass *klass)
}
static void
-ephy_shell_command_cb (EphyEmbedShell *shell,
- char *command,
- char *param,
- gpointer data)
-{
- EphyBookmarks *bookmarks;
- GtkWidget *dialog;
- const gchar *message = NULL;
- GtkMessageType message_type = GTK_MESSAGE_INFO;
- EphyWindow *window;
-
- bookmarks = ephy_shell_get_bookmarks (EPHY_SHELL (shell));
-
- if (strcmp (command, "import-mozilla-bookmarks") == 0)
- {
- if (ephy_bookmarks_import_mozilla (bookmarks, param))
- {
- message_type = GTK_MESSAGE_INFO;
- message = _("Mozilla bookmarks imported successfully.");
- }
- else
- {
- message_type = GTK_MESSAGE_ERROR;
- message = _("Importing Mozilla bookmarks failed.");
- }
- }
- else if (strcmp (command, "import-galeon-bookmarks") == 0)
- {
- if (ephy_bookmarks_import_xbel (bookmarks, param,
- _("Galeon")))
- {
- message_type = GTK_MESSAGE_INFO;
- message = _("Galeon bookmarks imported successfully.");
- }
- else
- {
- message_type = GTK_MESSAGE_ERROR;
- message = _("Importing Galeon bookmarks failed.");
- }
- }
- else if (strcmp (command, "import-konqueror-bookmarks") == 0)
- {
- if (ephy_bookmarks_import_xbel (bookmarks, param,
- _("Konqueror")))
- {
- message_type = GTK_MESSAGE_INFO;
- message = _("Konqueror bookmarks imported successfully.");
- }
- else
- {
- message_type = GTK_MESSAGE_ERROR;
- message = _("Importing Konqueror bookmarks failed.");
- }
- }
- else if (strcmp (command, "configure-network") == 0)
- {
- ephy_file_launch_application ("gnome-network-preferences",
- NULL,
- FALSE);
- }
-
- if (message != NULL)
- {
- window = ephy_shell_get_active_window (EPHY_SHELL (shell));
- dialog = gtk_message_dialog_new (GTK_WINDOW (window),
- GTK_DIALOG_DESTROY_WITH_PARENT,
- message_type,
- GTK_BUTTONS_OK,
- message);
- gtk_dialog_set_has_separator (GTK_DIALOG (dialog), FALSE);
- g_signal_connect_swapped (G_OBJECT (dialog), "response",
- G_CALLBACK (gtk_widget_destroy),
- G_OBJECT (dialog));
- gtk_widget_show (dialog);
- }
-}
-
-static void
ephy_shell_new_window_cb (EphyEmbedShell *shell,
EphyEmbed **new_embed,
EmbedChromeMask chromemask,
@@ -254,11 +176,6 @@ ephy_shell_init (EphyShell *gs)
G_CALLBACK(ephy_shell_new_window_cb),
NULL);
- g_signal_connect (G_OBJECT (gs),
- "command",
- G_CALLBACK(ephy_shell_command_cb),
- NULL);
-
ephy_init_services (gs);
}
diff --git a/src/popup-commands.c b/src/popup-commands.c
index 64311ddf3..9a75a8ac6 100644
--- a/src/popup-commands.c
+++ b/src/popup-commands.c
@@ -164,11 +164,10 @@ popup_cmd_bookmark_link (EggAction *action,
location))
{
new_bookmark = ephy_new_bookmark_new
- (bookmarks, GTK_WINDOW (window), location);
+ (bookmarks, GTK_WINDOW (window),
+ rel ? rel : location);
ephy_new_bookmark_set_title
(EPHY_NEW_BOOKMARK (new_bookmark), title);
- ephy_new_bookmark_set_smarturl
- (EPHY_NEW_BOOKMARK (new_bookmark), rel);
gtk_widget_show (new_bookmark);
}
}