aboutsummaryrefslogtreecommitdiffstats
path: root/src/bookmarks
diff options
context:
space:
mode:
Diffstat (limited to 'src/bookmarks')
-rw-r--r--src/bookmarks/ephy-bookmark-properties.c4
-rw-r--r--src/bookmarks/ephy-bookmarks-editor.c52
-rw-r--r--src/bookmarks/ephy-bookmarks.c72
-rw-r--r--src/bookmarks/ephy-bookmarks.h3
4 files changed, 105 insertions, 26 deletions
diff --git a/src/bookmarks/ephy-bookmark-properties.c b/src/bookmarks/ephy-bookmark-properties.c
index 9fda1cfea..050fa21cc 100644
--- a/src/bookmarks/ephy-bookmark-properties.c
+++ b/src/bookmarks/ephy-bookmark-properties.c
@@ -285,7 +285,7 @@ toolbar_checkbox_changed_cb (GtkWidget *checkbox, EphyBookmarkProperties *props)
else
{
ephy_toolbars_model_remove_bookmark
- (props->priv->tb_model, FALSE, id);
+ (props->priv->tb_model, id);
}
}
@@ -418,7 +418,7 @@ build_ui (EphyBookmarkProperties *editor)
checkbox = gtk_check_button_new_with_mnemonic (_("_Show in bookmarks bar"));
id = ephy_node_get_id (editor->priv->bookmark);
- state = ephy_toolbars_model_has_bookmark (editor->priv->tb_model, FALSE, id);
+ state = ephy_toolbars_model_has_bookmark (editor->priv->tb_model, id);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (checkbox), state);
g_signal_connect (checkbox, "toggled",
G_CALLBACK (toolbar_checkbox_changed_cb), editor);
diff --git a/src/bookmarks/ephy-bookmarks-editor.c b/src/bookmarks/ephy-bookmarks-editor.c
index 900e576ba..2556fdd99 100644
--- a/src/bookmarks/ephy-bookmarks-editor.c
+++ b/src/bookmarks/ephy-bookmarks-editor.c
@@ -32,6 +32,7 @@
#include <gdk/gdkkeysyms.h>
#include <bonobo/bonobo-i18n.h>
#include <libgnomeui/gnome-stock-icons.h>
+#include <libgnomevfs/gnome-vfs-uri.h>
#include <string.h>
#include "ephy-bookmarks-editor.h"
@@ -60,7 +61,7 @@
static GtkTargetEntry topic_drag_dest_types [] =
{
- { EPHY_DND_BOOKMARK_TYPE, 0, 0 }
+ { EPHY_DND_URI_LIST_TYPE, 0, 0 }
};
static int n_topic_drag_dest_types = G_N_ELEMENTS (topic_drag_dest_types);
@@ -69,8 +70,7 @@ static GtkTargetEntry bmk_drag_types [] =
{
{ EPHY_DND_URI_LIST_TYPE, 0, 0 },
{ EPHY_DND_TEXT_TYPE, 0, 1 },
- { EPHY_DND_URL_TYPE, 0, 2 },
- { EPHY_DND_BOOKMARK_TYPE, 0, 3 }
+ { EPHY_DND_URL_TYPE, 0, 2 }
};
static int n_bmk_drag_types = G_N_ELEMENTS (bmk_drag_types);
@@ -334,7 +334,7 @@ cmd_show_in_bookmarks_bar (EggAction *action,
else
{
ephy_toolbars_model_remove_bookmark
- (editor->priv->tb_model, topic, id);
+ (editor->priv->tb_model, id);
}
g_list_free (selection);
@@ -827,7 +827,7 @@ ephy_bookmarks_editor_update_menu (EphyBookmarksEditor *editor)
id = ephy_node_get_id (node);
show_in_bookmarks_bar = ephy_toolbars_model_has_bookmark
- (editor->priv->tb_model, TRUE, id);
+ (editor->priv->tb_model, id);
priority = ephy_node_get_property_int
(node, EPHY_NODE_KEYWORD_PROP_PRIORITY);
@@ -847,7 +847,7 @@ ephy_bookmarks_editor_update_menu (EphyBookmarksEditor *editor)
id = ephy_node_get_id (node);
show_in_bookmarks_bar = ephy_toolbars_model_has_bookmark
- (editor->priv->tb_model, FALSE, id);
+ (editor->priv->tb_model, id);
g_list_free (selected);
}
@@ -1150,9 +1150,18 @@ node_dropped_cb (EphyNodeView *view, EphyNode *node,
for (l = nodes; l != NULL; l = l->next)
{
- EphyNode *bmk = l->data;
+ GnomeVFSURI *uri = l->data;
+ char *url;
+ EphyNode *bmk;
+
+ url = gnome_vfs_uri_to_string (uri, GNOME_VFS_URI_HIDE_NONE);
+ bmk = ephy_bookmarks_find_bookmark (editor->priv->bookmarks, url);
+ g_free (url);
- ephy_bookmarks_set_keyword (editor->priv->bookmarks, node, bmk);
+ if (bmk)
+ {
+ ephy_bookmarks_set_keyword (editor->priv->bookmarks, node, bmk);
+ }
}
}
@@ -1186,6 +1195,19 @@ view_selection_changed_cb (GtkWidget *view, EphyBookmarksEditor *editor)
}
static void
+provide_keyword_uri (EphyNode *node, GValue *value, gpointer data)
+{
+ EphyBookmarks *bookmarks = EPHY_BOOKMARKS_EDITOR (data)->priv->bookmarks;
+ char *uri;
+
+ uri = ephy_bookmarks_get_topic_uri (bookmarks, node);
+
+ g_value_init (value, G_TYPE_STRING);
+ g_value_set_string (value, uri);
+ g_free (uri);
+}
+
+static void
ephy_bookmarks_editor_construct (EphyBookmarksEditor *editor)
{
GtkTreeSelection *selection;
@@ -1197,7 +1219,7 @@ ephy_bookmarks_editor_construct (EphyBookmarksEditor *editor)
EggActionGroup *action_group;
EggAction *action;
GdkPixbuf *icon;
- int i;
+ int i, col_id;
gtk_window_set_title (GTK_WINDOW (editor), _("Bookmarks"));
@@ -1260,10 +1282,12 @@ ephy_bookmarks_editor_construct (EphyBookmarksEditor *editor)
/* Keywords View */
key_view = ephy_node_view_new (node, NULL);
add_focus_monitor (editor, key_view);
+ col_id = ephy_node_view_add_data_column (EPHY_NODE_VIEW (key_view),
+ G_TYPE_STRING, -1,
+ provide_keyword_uri, editor);
ephy_node_view_enable_drag_source (EPHY_NODE_VIEW (key_view),
topic_drag_types,
- n_topic_drag_types,
- -1);
+ n_topic_drag_types, col_id);
ephy_node_view_enable_drag_dest (EPHY_NODE_VIEW (key_view),
topic_drag_dest_types,
n_topic_drag_dest_types);
@@ -1326,10 +1350,14 @@ ephy_bookmarks_editor_construct (EphyBookmarksEditor *editor)
/* Bookmarks View */
bm_view = ephy_node_view_new (node, editor->priv->bookmarks_filter);
add_focus_monitor (editor, bm_view);
+ col_id = ephy_node_view_add_data_column (EPHY_NODE_VIEW (bm_view),
+ G_TYPE_STRING,
+ EPHY_NODE_BMK_PROP_LOCATION,
+ NULL, NULL);
ephy_node_view_enable_drag_source (EPHY_NODE_VIEW (bm_view),
bmk_drag_types,
n_bmk_drag_types,
- EPHY_NODE_BMK_PROP_LOCATION);
+ col_id);
ephy_node_view_add_column (EPHY_NODE_VIEW (bm_view), _("Title"),
G_TYPE_STRING, EPHY_NODE_BMK_PROP_TITLE, -1,
EPHY_NODE_VIEW_AUTO_SORT |
diff --git a/src/bookmarks/ephy-bookmarks.c b/src/bookmarks/ephy-bookmarks.c
index 187efc9be..2ba82aa78 100644
--- a/src/bookmarks/ephy-bookmarks.c
+++ b/src/bookmarks/ephy-bookmarks.c
@@ -210,8 +210,7 @@ ephy_bookmarks_autocompletion_source_init (EphyAutocompletionSourceIface *iface)
static void
ephy_bookmarks_init_defaults (EphyBookmarks *eb)
{
- int i, id;
- EphyNode *node;
+ int i;
for (i = 0; i < n_default_topics; i++)
{
@@ -220,13 +219,12 @@ 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);
+ EphyNode *bmk;
- node = ephy_bookmarks_find_bookmark (eb, default_bookmarks[i].location);
- if (node == NULL) break;
- id = ephy_node_get_id (node);
- ephy_toolbars_model_add_bookmark (eb->priv->toolbars_model, FALSE, id);
+ bmk = ephy_bookmarks_add (eb, default_bookmarks[i].title,
+ default_bookmarks[i].location);
+ ephy_toolbars_model_add_bookmark (eb->priv->toolbars_model, FALSE,
+ ephy_node_get_id (bmk));
}
}
@@ -1119,13 +1117,44 @@ ephy_bookmarks_add_keyword (EphyBookmarks *eb,
return key;
}
-void
+void
ephy_bookmarks_remove_keyword (EphyBookmarks *eb,
- EphyNode *keyword)
+ EphyNode *keyword)
{
ephy_node_remove_child (eb->priv->keywords, keyword);
}
+char *
+ephy_bookmarks_get_topic_uri (EphyBookmarks *eb,
+ EphyNode *node)
+{
+ char *uri;
+
+ if (ephy_bookmarks_get_bookmarks (eb) == node)
+ {
+ uri = g_strdup ("topic://Special/All");
+ }
+ else if (ephy_bookmarks_get_not_categorized (eb) == node)
+ {
+ uri = g_strdup ("topic://Special/NotCategorized");
+ }
+ else if (ephy_bookmarks_get_favorites (eb) == node)
+ {
+ uri = g_strdup ("topic://Special/Favorites");
+ }
+ else
+ {
+ const char *name;
+
+ name = ephy_node_get_property_string
+ (node, EPHY_NODE_KEYWORD_PROP_NAME);
+
+ uri = g_strdup_printf ("topic://%s", name);
+ }
+
+ return uri;
+}
+
EphyNode *
ephy_bookmarks_find_keyword (EphyBookmarks *eb,
const char *name,
@@ -1134,9 +1163,11 @@ ephy_bookmarks_find_keyword (EphyBookmarks *eb,
EphyNode *node;
GPtrArray *children;
int i;
+ const char *topic_name;
g_return_val_if_fail (name != NULL, NULL);
+ topic_name = name;
if (g_utf8_strlen (name, -1) == 0)
{
@@ -1144,6 +1175,23 @@ ephy_bookmarks_find_keyword (EphyBookmarks *eb,
return NULL;
}
+ if (strcmp (name, "topic://Special/All") == 0)
+ {
+ return ephy_bookmarks_get_bookmarks (eb);
+ }
+ else if (strcmp (name, "topic://Special/NotCategorized") == 0)
+ {
+ return ephy_bookmarks_get_not_categorized (eb);
+ }
+ else if (strcmp (name, "topic://Special/Favorites") == 0)
+ {
+ return ephy_bookmarks_get_favorites (eb);
+ }
+ else if (g_str_has_prefix (name, "topic://"))
+ {
+ topic_name += strlen ("topic://");
+ }
+
children = ephy_node_get_children (eb->priv->keywords);
node = NULL;
for (i = 0; i < children->len; i++)
@@ -1154,8 +1202,8 @@ ephy_bookmarks_find_keyword (EphyBookmarks *eb,
kid = g_ptr_array_index (children, i);
key = ephy_node_get_property_string (kid, EPHY_NODE_KEYWORD_PROP_NAME);
- if ((partial_match && g_str_has_prefix (key, name) > 0) ||
- (!partial_match && strcmp (key, name) == 0))
+ if ((partial_match && g_str_has_prefix (key, topic_name) > 0) ||
+ (!partial_match && strcmp (key, topic_name) == 0))
{
node = kid;
}
diff --git a/src/bookmarks/ephy-bookmarks.h b/src/bookmarks/ephy-bookmarks.h
index 55c03bca0..962326d24 100644
--- a/src/bookmarks/ephy-bookmarks.h
+++ b/src/bookmarks/ephy-bookmarks.h
@@ -112,6 +112,9 @@ void ephy_bookmarks_unset_keyword (EphyBookmarks *eb,
EphyNode *keyword,
EphyNode *bookmark);
+char *ephy_bookmarks_get_topic_uri (EphyBookmarks *eb,
+ EphyNode *node);
+
/* Favorites */
EphyNode *ephy_bookmarks_get_favorites (EphyBookmarks *eb);