aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog67
-rw-r--r--data/ui/epiphany-toolbar.xml.in66
-rwxr-xr-xlib/egg/egg-editable-toolbar.c10
-rwxr-xr-xlib/egg/egg-editable-toolbar.h2
-rwxr-xr-xlib/egg/egg-toolbar-editor.c8
-rwxr-xr-xlib/egg/egg-toolbars-model.c210
-rwxr-xr-xlib/egg/egg-toolbars-model.h35
-rw-r--r--lib/egg/eggtoolbar.c1
-rw-r--r--lib/ephy-dnd.c45
-rw-r--r--lib/ephy-dnd.h3
-rw-r--r--lib/widgets/ephy-node-view.c66
-rw-r--r--lib/widgets/ephy-node-view.h8
-rw-r--r--lib/widgets/ephy-tree-model-sort.c148
-rw-r--r--lib/widgets/ephy-tree-model-sort.h4
-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
-rw-r--r--src/ephy-history-window.c19
-rwxr-xr-xsrc/ephy-toolbars-model.c293
-rwxr-xr-xsrc/ephy-toolbars-model.h9
-rwxr-xr-xsrc/toolbar.c100
22 files changed, 654 insertions, 571 deletions
diff --git a/ChangeLog b/ChangeLog
index 41922e9be..5fbeab05e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,70 @@
+2003-07-27 Marco Pesenti Gritti <marco@it.gnome.org>
+
+ * data/ui/epiphany-toolbar.xml.in:
+ * lib/egg/egg-editable-toolbar.c: (drag_data_received_cb):
+ * lib/egg/egg-editable-toolbar.h:
+ * lib/egg/egg-toolbar-editor.c: (parse_item_list):
+ * lib/egg/egg-toolbars-model.c: (egg_toolbars_model_to_xml),
+ (safe_save_xml), (egg_toolbars_model_save), (toolbars_item_new),
+ (free_item_node), (egg_toolbars_model_add_separator),
+ (egg_toolbars_model_add_item), (parse_item_list),
+ (impl_get_item_id), (impl_get_item_name), (impl_get_item_type),
+ (egg_toolbars_model_class_init), (egg_toolbars_model_item_nth),
+ (egg_toolbars_model_toolbar_nth), (egg_toolbars_model_get_item_id),
+ (egg_toolbars_model_get_item_name),
+ (egg_toolbars_model_get_item_type):
+ * lib/egg/egg-toolbars-model.h:
+ * lib/egg/eggtoolbar.c: (egg_toolbar_finalize):
+ * lib/ephy-dnd.c: (add_one_topic), (ephy_dnd_drag_data_get):
+ * lib/ephy-dnd.h:
+ * lib/widgets/ephy-node-view.c: (drag_data_received_cb),
+ (ephy_node_view_select_node_by_key), (ephy_node_view_construct),
+ (ephy_node_view_add_data_column),
+ (ephy_node_view_enable_drag_source):
+ * lib/widgets/ephy-node-view.h:
+ * lib/widgets/ephy-tree-model-sort.c:
+ (ephy_tree_model_sort_class_init), (ephy_tree_model_sort_init),
+ (ephy_tree_model_sort_multi_row_draggable),
+ (ephy_tree_model_sort_set_column_id),
+ (each_property_get_data_binder),
+ (ephy_tree_model_sort_multi_drag_data_get):
+ * lib/widgets/ephy-tree-model-sort.h:
+ * src/bookmarks/ephy-bookmark-properties.c:
+ (toolbar_checkbox_changed_cb), (build_ui):
+ * src/bookmarks/ephy-bookmarks-editor.c:
+ (cmd_show_in_bookmarks_bar), (ephy_bookmarks_editor_update_menu),
+ (node_dropped_cb), (provide_keyword_uri),
+ (ephy_bookmarks_editor_construct):
+ * src/bookmarks/ephy-bookmarks.c: (ephy_bookmarks_init_defaults),
+ (ephy_bookmarks_remove_keyword), (ephy_bookmarks_get_topic_uri),
+ (ephy_bookmarks_find_keyword):
+ * src/bookmarks/ephy-bookmarks.h:
+ * src/ephy-history-window.c: (ephy_history_window_construct):
+ * src/ephy-toolbars-model.c: (ephy_toolbars_model_get_action_name),
+ (ephy_toolbars_model_get_node), (bookmark_destroy_cb),
+ (impl_get_item_name), (impl_get_item_id), (impl_get_item_type),
+ (connect_item), (ephy_toolbars_model_set_bookmarks),
+ (ephy_toolbars_model_class_init), (save_changes), (item_added),
+ (item_removed), (toolbar_added), (toolbar_removed),
+ (ephy_toolbars_model_init), (ephy_toolbars_model_finalize),
+ (ephy_toolbars_model_remove_bookmark),
+ (ephy_toolbars_model_add_bookmark),
+ (ephy_toolbars_model_has_bookmark):
+ * src/ephy-toolbars-model.h:
+ * src/toolbar.c: (bookmark_destroy_cb), (toolbar_ensure_action):
+
+ Remove the NODE drag types. They sucks because they use internal
+ ids. I think it's better to use the topic name and the standard uri
+ types instead, we are ensuring they are unique anyway.
+ Add some apis to the toolbar model for better custom items support
+ solve also a memory leak. This change the format so toolbar
+ configuration will be lost.
+ For bookmarks/topics dnd use format that can be used also
+ externally (url list for bookmarks).
+ Cleanup toolbars model implementation using similar action
+ names for bookmarks / topics.
+ Set a version on the toolbar xml and make it low disk safe.
+
2003-07-27 Christian Persch <chpe@cvs.gnome.org>
* lib/widgets/ephy-node-view.c: (ephy_node_view_remove):
diff --git a/data/ui/epiphany-toolbar.xml.in b/data/ui/epiphany-toolbar.xml.in
index 4727602d3..6accae2fb 100644
--- a/data/ui/epiphany-toolbar.xml.in
+++ b/data/ui/epiphany-toolbar.xml.in
@@ -1,44 +1,44 @@
<editabletoolbar>
<available>
- <toolitem verb="NavigationBack"/>
- <toolitem verb="NavigationForward"/>
- <toolitem verb="NavigationUp"/>
- <toolitem verb="ViewStop"/>
- <toolitem verb="ViewReload"/>
- <toolitem verb="GoHome"/>
- <toolitem verb="GoHistory"/>
- <toolitem verb="GoBookmarks"/>
- <toolitem verb="FileNewTab"/>
- <toolitem verb="FileNewWindow"/>
- <toolitem verb="FileOpen"/>
- <toolitem verb="FileSaveAs"/>
- <toolitem verb="FilePrint"/>
- <toolitem verb="FileBookmarkPage"/>
- <toolitem verb="ViewFullscreen"/>
- <toolitem verb="EditFind"/>
- <toolitem verb="Favicon"/>
- <toolitem verb="Location"/>
- <toolitem verb="Spinner"/>
- <toolitem verb="ToolbarGo"/>
- <toolitem verb="Zoom"/>
+ <toolitem name="NavigationBack"/>
+ <toolitem name="NavigationForward"/>
+ <toolitem name="NavigationUp"/>
+ <toolitem name="ViewStop"/>
+ <toolitem name="ViewReload"/>
+ <toolitem name="GoHome"/>
+ <toolitem name="GoHistory"/>
+ <toolitem name="GoBookmarks"/>
+ <toolitem name="FileNewTab"/>
+ <toolitem name="FileNewWindow"/>
+ <toolitem name="FileOpen"/>
+ <toolitem name="FileSaveAs"/>
+ <toolitem name="FilePrint"/>
+ <toolitem name="FileBookmarkPage"/>
+ <toolitem name="ViewFullscreen"/>
+ <toolitem name="EditFind"/>
+ <toolitem name="Favicon"/>
+ <toolitem name="Location"/>
+ <toolitem name="Spinner"/>
+ <toolitem name="ToolbarGo"/>
+ <toolitem name="Zoom"/>
</available>
<toolbar name="DefaultToolbar">
- <toolitem verb="NavigationBack"/>
- <toolitem verb="NavigationForward"/>
- <toolitem verb="ViewStop"/>
- <toolitem verb="ViewReload"/>
+ <toolitem name="NavigationBack"/>
+ <toolitem name="NavigationForward"/>
+ <toolitem name="ViewStop"/>
+ <toolitem name="ViewReload"/>
<separator/>
- <toolitem verb="GoHome"/>
- <toolitem verb="GoHistory"/>
- <toolitem verb="GoBookmarks"/>
+ <toolitem name="GoHome"/>
+ <toolitem name="GoHistory"/>
+ <toolitem name="GoBookmarks"/>
<separator/>
- <toolitem verb="EditFind"/>
- <toolitem verb="Spinner"/>
+ <toolitem name="EditFind"/>
+ <toolitem name="Spinner"/>
</toolbar>
<toolbar name="EntryToolbar">
- <toolitem verb="Favicon"/>
- <toolitem verb="Location"/>
- <toolitem verb="ToolbarGo"/>
+ <toolitem name="Favicon"/>
+ <toolitem name="Location"/>
+ <toolitem name="ToolbarGo"/>
</toolbar>
<toolbar name="BookmarksBar">
</toolbar>
diff --git a/lib/egg/egg-editable-toolbar.c b/lib/egg/egg-editable-toolbar.c
index 81a7c1a58..2fc401cde 100755
--- a/lib/egg/egg-editable-toolbar.c
+++ b/lib/egg/egg-editable-toolbar.c
@@ -180,11 +180,17 @@ drag_data_received_cb (GtkWidget *widget,
else
{
GdkAtom target;
+ char *type;
+ char *id;
target = gtk_drag_dest_find_target (widget, context, NULL);
+ type = egg_toolbars_model_get_item_type (etoolbar->priv->model, target);
+ id = egg_toolbars_model_get_item_id (etoolbar->priv->model, type,
+ selection_data->data);
egg_toolbars_model_add_item (etoolbar->priv->model,
- toolbar_pos, pos, target,
- selection_data->data);
+ toolbar_pos, pos, id, type);
+ g_free (type);
+ g_free (id);
}
}
diff --git a/lib/egg/egg-editable-toolbar.h b/lib/egg/egg-editable-toolbar.h
index 28b9976a2..6460d724a 100755
--- a/lib/egg/egg-editable-toolbar.h
+++ b/lib/egg/egg-editable-toolbar.h
@@ -39,8 +39,6 @@ typedef struct EggEditableToolbarClass EggEditableToolbarClass;
typedef struct EggEditableToolbar EggEditableToolbar;
typedef struct EggEditableToolbarPrivate EggEditableToolbarPrivate;
-#define EGG_TOOLBAR_ITEM_TYPE "application/x-toolbar-item"
-
struct EggEditableToolbar
{
GtkVBox parent_object;
diff --git a/lib/egg/egg-toolbar-editor.c b/lib/egg/egg-toolbar-editor.c
index a373b520c..2813d992b 100755
--- a/lib/egg/egg-toolbar-editor.c
+++ b/lib/egg/egg-toolbar-editor.c
@@ -494,11 +494,11 @@ parse_item_list (EggToolbarEditor *t,
{
if (xmlStrEqual (child->name, "toolitem"))
{
- xmlChar *verb;
+ xmlChar *name;
- verb = xmlGetProp (child, "verb");
- egg_toolbar_editor_add_action (t, verb);
- xmlFree (verb);
+ name = xmlGetProp (child, "name");
+ egg_toolbar_editor_add_action (t, name);
+ xmlFree (name);
}
child = child->next;
}
diff --git a/lib/egg/egg-toolbars-model.c b/lib/egg/egg-toolbars-model.c
index 8d8829dcf..e030bd29d 100755
--- a/lib/egg/egg-toolbars-model.c
+++ b/lib/egg/egg-toolbars-model.c
@@ -21,6 +21,7 @@
#include <string.h>
#include <libxml/tree.h>
+#include <gdk/gdkproperty.h>
static void egg_toolbars_model_class_init (EggToolbarsModelClass *klass);
static void egg_toolbars_model_init (EggToolbarsModel *t);
@@ -44,7 +45,8 @@ typedef struct
typedef struct
{
- char *action_name;
+ char *id;
+ char *type;
gboolean separator;
} EggToolbarsItem;
@@ -118,8 +120,12 @@ egg_toolbars_model_to_xml (EggToolbarsModel *t)
}
else
{
+ char *name;
+
node = xmlNewChild (tnode, NULL, "toolitem", NULL);
- xmlSetProp (node, "verb", item->action_name);
+ name = egg_toolbars_model_get_item_name (t, item->type, item->id);
+ xmlSetProp (node, "type", item->type);
+ xmlSetProp (node, "name", name);
}
}
}
@@ -127,16 +133,76 @@ egg_toolbars_model_to_xml (EggToolbarsModel *t)
return doc;
}
+gboolean
+safe_save_xml (const char *xml_file, xmlDocPtr doc)
+{
+ char *tmp_file;
+ char *old_file;
+ gboolean old_exist;
+ gboolean retval = TRUE;
+
+ tmp_file = g_strconcat (xml_file, ".tmp", NULL);
+ old_file = g_strconcat (xml_file, ".old", NULL);
+
+ if (!xmlSaveFormatFile (tmp_file, doc, 1))
+ {
+ g_warning ("Failed to write XML data to %s", tmp_file);
+ goto failed;
+ }
+
+ old_exist = g_file_test (xml_file, G_FILE_TEST_EXISTS);
+
+ if (old_exist)
+ {
+ if (rename (xml_file, old_file) < 0)
+ {
+ g_warning ("Failed to rename %s to %s", xml_file, old_file);
+ retval = FALSE;
+ goto failed;
+ }
+ }
+
+ if (rename (tmp_file, xml_file) < 0)
+ {
+ g_warning ("Failed to rename %s to %s", tmp_file, xml_file);
+
+ if (rename (old_file, xml_file) < 0)
+ {
+ g_warning ("Failed to restore %s from %s", xml_file, tmp_file);
+ }
+ retval = FALSE;
+ goto failed;
+ }
+
+ if (old_exist)
+ {
+ if (unlink (old_file) < 0)
+ {
+ g_warning ("Failed to delete old file %s", old_file);
+ }
+ }
+
+ failed:
+ g_free (old_file);
+ g_free (tmp_file);
+
+ return retval;
+}
+
void
egg_toolbars_model_save (EggToolbarsModel *t,
- const char *xml_file)
+ const char *xml_file,
+ const char *version)
{
xmlDocPtr doc;
+ xmlNodePtr root;
g_return_if_fail (IS_EGG_TOOLBARS_MODEL (t));
doc = egg_toolbars_model_to_xml (t);
- xmlSaveFormatFile (xml_file, doc, 1);
+ root = xmlDocGetRootElement (doc);
+ xmlSetProp (root, "version", version);
+ safe_save_xml (xml_file, doc);
xmlFreeDoc (doc);
}
@@ -153,15 +219,18 @@ toolbars_toolbar_new (const char *name)
}
static EggToolbarsItem *
-toolbars_item_new (const char *action,
+toolbars_item_new (const char *id,
+ const char *type,
gboolean separator)
{
EggToolbarsItem *item;
- g_return_val_if_fail (action != NULL, NULL);
+ g_return_val_if_fail (id != NULL, NULL);
+ g_return_val_if_fail (type != NULL, NULL);
item = g_new0 (EggToolbarsItem, 1);
- item->action_name = g_strdup (action);
+ item->id = g_strdup (id);
+ item->type = g_strdup (type);
item->separator = separator;
return item;
@@ -181,7 +250,8 @@ free_item_node (EggToolbarsItem *item)
{
g_return_if_fail (item != NULL);
- g_free (item->action_name);
+ g_free (item->id);
+ g_free (item->type);
g_free (item);
}
@@ -227,46 +297,39 @@ egg_toolbars_model_add_separator (EggToolbarsModel *t,
GNode *parent_node;
GNode *node;
EggToolbarsItem *item;
+ int real_position;
g_return_if_fail (IS_EGG_TOOLBARS_MODEL (t));
parent_node = g_node_nth_child (t->priv->toolbars, toolbar_position);
- item = toolbars_item_new ("separator", TRUE);
+ item = toolbars_item_new ("separator", "separator", TRUE);
node = g_node_new (item);
g_node_insert (parent_node, position, node);
+ real_position = g_node_child_position (parent_node, node);
+
g_signal_emit (G_OBJECT (t), egg_toolbars_model_signals[ITEM_ADDED], 0,
- toolbar_position, position);
+ toolbar_position, real_position);
}
-const char *
+void
egg_toolbars_model_add_item (EggToolbarsModel *t,
int toolbar_position,
int position,
- GdkAtom type,
- const char *name)
-{
- EggToolbarsModelClass *klass = EGG_TOOLBARS_MODEL_GET_CLASS (t);
- return klass->add_item (t, toolbar_position, position, type, name);
-}
-
-const char *
-impl_add_item (EggToolbarsModel *t,
- int toolbar_position,
- int position,
- GdkAtom type,
- const char *name)
+ const char *id,
+ const char *type)
{
GNode *parent_node;
GNode *node;
EggToolbarsItem *item;
int real_position;
- g_return_val_if_fail (IS_EGG_TOOLBARS_MODEL (t), NULL);
- g_return_val_if_fail (name != NULL, NULL);
+ g_return_if_fail (IS_EGG_TOOLBARS_MODEL (t));
+ g_return_if_fail (id != NULL);
+ g_return_if_fail (type != NULL);
parent_node = g_node_nth_child (t->priv->toolbars, toolbar_position);
- item = toolbars_item_new (name, FALSE);
+ item = toolbars_item_new (id, type, FALSE);
node = g_node_new (item);
g_node_insert (parent_node, position, node);
@@ -274,8 +337,6 @@ impl_add_item (EggToolbarsModel *t,
g_signal_emit (G_OBJECT (t), egg_toolbars_model_signals[ITEM_ADDED], 0,
toolbar_position, real_position);
-
- return item->action_name;
}
static void
@@ -287,11 +348,24 @@ parse_item_list (EggToolbarsModel *t,
{
if (xmlStrEqual (child->name, "toolitem"))
{
- xmlChar *verb;
+ xmlChar *name, *type;
+ char *id;
- verb = xmlGetProp (child, "verb");
- egg_toolbars_model_add_item (t, position, -1, NULL, verb);
- xmlFree (verb);
+ name = xmlGetProp (child, "name");
+ type = xmlGetProp (child, "type");
+ if (type == NULL)
+ {
+ type = g_strdup (EGG_TOOLBAR_ITEM_TYPE);
+ }
+
+ id = egg_toolbars_model_get_item_id (t, type, name);
+ if (id != NULL)
+ {
+ egg_toolbars_model_add_item (t, position, -1, id, type);
+ }
+ xmlFree (name);
+ g_free (type);
+ g_free (id);
}
else if (xmlStrEqual (child->name, "separator"))
{
@@ -363,6 +437,44 @@ egg_toolbars_model_load (EggToolbarsModel *t,
xmlFreeDoc (doc);
}
+char *
+impl_get_item_id (EggToolbarsModel *t,
+ const char *type,
+ const char *name)
+{
+ if (strcmp (type, EGG_TOOLBAR_ITEM_TYPE) == 0)
+ {
+ return g_strdup (name);
+ }
+
+ return NULL;
+}
+
+char *
+impl_get_item_name (EggToolbarsModel *t,
+ const char *type,
+ const char *id)
+{
+ if (strcmp (type, EGG_TOOLBAR_ITEM_TYPE) == 0)
+ {
+ return g_strdup (id);
+ }
+
+ return NULL;
+}
+
+char *
+impl_get_item_type (EggToolbarsModel *t,
+ GdkAtom type)
+{
+ if (gdk_atom_intern (EGG_TOOLBAR_ITEM_TYPE, FALSE) == type)
+ {
+ return g_strdup (EGG_TOOLBAR_ITEM_TYPE);
+ }
+
+ return NULL;
+}
+
static void
egg_toolbars_model_class_init (EggToolbarsModelClass *klass)
{
@@ -372,7 +484,9 @@ egg_toolbars_model_class_init (EggToolbarsModelClass *klass)
object_class->finalize = egg_toolbars_model_finalize;
- klass->add_item = impl_add_item;
+ klass->get_item_id = impl_get_item_id;
+ klass->get_item_name = impl_get_item_name;
+ klass->get_item_type = impl_get_item_type;
egg_toolbars_model_signals[ITEM_ADDED] =
g_signal_new ("item_added",
@@ -525,7 +639,7 @@ egg_toolbars_model_item_nth (EggToolbarsModel *t,
*is_separator = idata->separator;
- return idata->action_name;
+ return idata->id;
}
int
@@ -548,3 +662,29 @@ egg_toolbars_model_toolbar_nth (EggToolbarsModel *t,
return tdata->name;
}
+
+char *
+egg_toolbars_model_get_item_id (EggToolbarsModel *t,
+ const char *type,
+ const char *name)
+{
+ EggToolbarsModelClass *klass = EGG_TOOLBARS_MODEL_GET_CLASS (t);
+ return klass->get_item_id (t, type, name);
+}
+
+char *
+egg_toolbars_model_get_item_name (EggToolbarsModel *t,
+ const char *type,
+ const char *id)
+{
+ EggToolbarsModelClass *klass = EGG_TOOLBARS_MODEL_GET_CLASS (t);
+ return klass->get_item_name (t, type, id);
+}
+
+char *
+egg_toolbars_model_get_item_type (EggToolbarsModel *t,
+ GdkAtom type)
+{
+ EggToolbarsModelClass *klass = EGG_TOOLBARS_MODEL_GET_CLASS (t);
+ return klass->get_item_type (t, type);
+}
diff --git a/lib/egg/egg-toolbars-model.h b/lib/egg/egg-toolbars-model.h
index 5d79787b9..5de72fbcb 100755
--- a/lib/egg/egg-toolbars-model.h
+++ b/lib/egg/egg-toolbars-model.h
@@ -21,7 +21,7 @@
#include <glib.h>
#include <glib-object.h>
-#include "gdk/gdktypes.h"
+#include <gdk/gdktypes.h>
G_BEGIN_DECLS
@@ -37,6 +37,8 @@ typedef struct EggToolbarsModelClass EggToolbarsModelClass;
typedef struct EggToolbarsModel EggToolbarsModel;
typedef struct EggToolbarsModelPrivate EggToolbarsModelPrivate;
+#define EGG_TOOLBAR_ITEM_TYPE "application/x-toolbar-item"
+
typedef enum
{
EGG_TB_MODEL_NOT_REMOVABLE = 1,
@@ -68,12 +70,14 @@ struct EggToolbarsModelClass
int position);
/* Virtual Table */
- const char * (* add_item) (EggToolbarsModel *t,
- int toolbar_position,
- int position,
- GdkAtom type,
- const char *item_name);
-
+ char * (* get_item_type) (EggToolbarsModel *t,
+ GdkAtom dnd_type);
+ char * (* get_item_id) (EggToolbarsModel *t,
+ const char *type,
+ const char *name);
+ char * (* get_item_name) (EggToolbarsModel *t,
+ const char *type,
+ const char *id);
};
GType egg_toolbars_model_get_type (void);
@@ -81,7 +85,8 @@ EggToolbarsModel *egg_toolbars_model_new (void);
void egg_toolbars_model_load (EggToolbarsModel *t,
const char *xml_file);
void egg_toolbars_model_save (EggToolbarsModel *t,
- const char *xml_file);
+ const char *xml_file,
+ const char *version);
int egg_toolbars_model_add_toolbar (EggToolbarsModel *t,
int position,
const char *name);
@@ -93,11 +98,19 @@ void egg_toolbars_model_set_flags (EggToolbarsModel *t,
void egg_toolbars_model_add_separator (EggToolbarsModel *t,
int toolbar_position,
int position);
-const char *egg_toolbars_model_add_item (EggToolbarsModel *t,
+char *egg_toolbars_model_get_item_type (EggToolbarsModel *t,
+ GdkAtom dnd_type);
+char *egg_toolbars_model_get_item_id (EggToolbarsModel *t,
+ const char *type,
+ const char *name);
+char *egg_toolbars_model_get_item_name (EggToolbarsModel *t,
+ const char *type,
+ const char *id);
+void egg_toolbars_model_add_item (EggToolbarsModel *t,
int toolbar_position,
int position,
- GdkAtom type,
- const char *item_name);
+ const char *id,
+ const char *type);
void egg_toolbars_model_remove_toolbar (EggToolbarsModel *t,
int position);
void egg_toolbars_model_remove_item (EggToolbarsModel *t,
diff --git a/lib/egg/eggtoolbar.c b/lib/egg/eggtoolbar.c
index bae64f324..547f0e33c 100644
--- a/lib/egg/eggtoolbar.c
+++ b/lib/egg/eggtoolbar.c
@@ -494,7 +494,6 @@ static void
egg_toolbar_finalize (GObject *object)
{
EggToolbar *toolbar = EGG_TOOLBAR (object);
- GList *list;
if (toolbar->tooltips)
g_object_unref (GTK_OBJECT (toolbar->tooltips));
diff --git a/lib/ephy-dnd.c b/lib/ephy-dnd.c
index 4bf9cd2cd..a9e4b0c33 100644
--- a/lib/ephy-dnd.c
+++ b/lib/ephy-dnd.c
@@ -53,14 +53,14 @@ add_one_uri (const char *uri, int x, int y, int w, int h, gpointer data)
}
static void
-add_one_node (const char *uri, int x, int y, int w, int h, gpointer data)
+add_one_topic (const char *uri, int x, int y, int w, int h, gpointer data)
{
GString *result;
result = (GString *) data;
g_string_append (result, uri);
- g_string_append (result, ";");
+ g_string_append (result, "\r\n");
}
gboolean
@@ -87,12 +87,11 @@ ephy_dnd_drag_data_get (GtkWidget *widget,
result = g_string_new (NULL);
(* each_selected_item_iterator) (add_one_netscape_url, container_context, result);
}
- else if (target == gdk_atom_intern (EPHY_DND_TOPIC_TYPE, FALSE) ||
- target == gdk_atom_intern (EPHY_DND_BOOKMARK_TYPE, FALSE))
+ else if (target == gdk_atom_intern (EPHY_DND_TOPIC_TYPE, FALSE))
{
result = g_string_new (NULL);
- (* each_selected_item_iterator) (add_one_node, container_context, result);
- g_string_erase (result, result->len - 1, -1);
+ (* each_selected_item_iterator) (add_one_topic, container_context, result);
+ g_string_erase (result, result->len - 2, -1);
}
else
{
@@ -107,37 +106,3 @@ ephy_dnd_drag_data_get (GtkWidget *widget,
return TRUE;
}
-
-GList *
-ephy_dnd_node_list_extract_nodes (const char *node_list)
-{
- GList *result = NULL;
- char **nodes;
- int i;
-
- nodes = g_strsplit (node_list, ";", -1);
-
- for (i = 0; nodes[i] != NULL && nodes[i+1] != NULL; i = i + 2)
- {
- gulong id;
- EphyNodeDb *db;
-
- db = ephy_node_db_get_by_name (nodes[i]);
- g_return_val_if_fail (db != NULL, NULL);
-
- if (ephy_string_to_int (nodes[i + 1], &id))
- {
- EphyNode *node;
-
- node = ephy_node_db_get_node_from_id (db, id);
- g_return_val_if_fail (node != NULL, NULL);
- result = g_list_prepend (result, node);
- }
- }
-
- result = g_list_reverse (result);
-
- g_strfreev (nodes);
-
- return result;
-}
diff --git a/lib/ephy-dnd.h b/lib/ephy-dnd.h
index e708654f5..8f6a16a51 100644
--- a/lib/ephy-dnd.h
+++ b/lib/ephy-dnd.h
@@ -30,7 +30,6 @@ G_BEGIN_DECLS
#define EPHY_DND_TEXT_TYPE "text/plain"
#define EPHY_DND_URL_TYPE "_NETSCAPE_URL"
#define EPHY_DND_TOPIC_TYPE "ephy_topic_node"
-#define EPHY_DND_BOOKMARK_TYPE "ephy_bookmark_node"
typedef void (* EphyDragEachSelectedItemDataGet) (const char *url,
int x, int y, int w, int h,
@@ -47,8 +46,6 @@ gboolean ephy_dnd_drag_data_get (GtkWidget *widget,
gpointer container_context,
EphyDragEachSelectedItemIterator each_selected_item_iterator);
-GList *ephy_dnd_node_list_extract_nodes (const char *node_list);
-
G_END_DECLS
#endif
diff --git a/lib/widgets/ephy-node-view.c b/lib/widgets/ephy-node-view.c
index 86eb48f49..0a83d0744 100644
--- a/lib/widgets/ephy-node-view.c
+++ b/lib/widgets/ephy-node-view.c
@@ -24,6 +24,7 @@
#include <gtk/gtkcellrendererpixbuf.h>
#include <gtk/gtkwindow.h>
#include <gdk/gdkkeysyms.h>
+#include <libgnomevfs/gnome-vfs-uri.h>
#include "eggtreemodelfilter.h"
#include "ephy-node-view.h"
@@ -306,18 +307,15 @@ drag_data_received_cb (GtkWidget *widget,
x, y, &path, &pos))
{
EphyNode *node;
- GList *src_nodes;
+ GList *uris;
node = get_node_from_path (view, path);
- src_nodes = ephy_dnd_node_list_extract_nodes
- (selection_data->data);
-
+ uris = gnome_vfs_uri_list_parse (selection_data->data);
g_signal_emit (G_OBJECT (view),
ephy_node_view_signals[NODE_DROPPED], 0,
- node, src_nodes);
-
- g_list_free (src_nodes);
+ node, uris);
+ gnome_vfs_uri_list_free (uris);
gtk_tree_path_free (path);
}
@@ -426,7 +424,7 @@ ephy_node_view_select_node_by_key (EphyNodeView *view, GdkEventKey *event)
gboolean found = FALSE;
gchar outbuf[6];
gint length;
-
+
length = g_unichar_to_utf8 (gdk_keyval_to_unicode (event->keyval), outbuf);
event_string = g_utf8_casefold (outbuf, length);
@@ -456,7 +454,7 @@ ephy_node_view_select_node_by_key (EphyNodeView *view, GdkEventKey *event)
{
iter = last_iter;
}
-
+
path = gtk_tree_model_get_path (view->priv->sortmodel, &iter);
gtk_tree_view_set_cursor (GTK_TREE_VIEW (view), path, NULL, FALSE);
gtk_tree_path_free (path);
@@ -573,22 +571,6 @@ ephy_node_view_get_property (GObject *object,
}
static void
-node_from_sort_iter_cb (EphyTreeModelSort *model,
- GtkTreeIter *iter,
- void **node,
- EphyNodeView *view)
-{
- GtkTreeIter filter_iter, node_iter;
-
- gtk_tree_model_sort_convert_iter_to_child_iter (GTK_TREE_MODEL_SORT (model),
- &filter_iter, iter);
- egg_tree_model_filter_convert_iter_to_child_iter (EGG_TREE_MODEL_FILTER (view->priv->filtermodel),
- &node_iter, &filter_iter);
- *node = ephy_tree_model_node_node_from_iter
- (EPHY_TREE_MODEL_NODE (view->priv->nodemodel), &node_iter);
-}
-
-static void
ephy_node_view_construct (EphyNodeView *view)
{
GtkTreeSelection *selection;
@@ -600,11 +582,6 @@ ephy_node_view_construct (EphyNodeView *view)
egg_tree_model_filter_set_visible_column (EGG_TREE_MODEL_FILTER (view->priv->filtermodel),
EPHY_TREE_MODEL_NODE_COL_VISIBLE);
view->priv->sortmodel = ephy_tree_model_sort_new (view->priv->filtermodel);
- g_signal_connect_object (G_OBJECT (view->priv->sortmodel),
- "node_from_iter",
- G_CALLBACK (node_from_sort_iter_cb),
- view,
- 0);
gtk_tree_view_set_model (GTK_TREE_VIEW (view), GTK_TREE_MODEL (view->priv->sortmodel));
g_signal_connect_object (G_OBJECT (view),
"button_press_event",
@@ -779,6 +756,29 @@ provide_text_weight (EphyNode *node, GValue *value, EphyNodeView *view)
}
}
+int
+ephy_node_view_add_data_column (EphyNodeView *view,
+ GType value_type,
+ int prop_id,
+ EphyTreeModelNodeValueFunc func,
+ gpointer data)
+{
+ int column;
+
+ if (func)
+ {
+ column = ephy_tree_model_node_add_func_column
+ (view->priv->nodemodel, value_type, func, data);
+ }
+ else
+ {
+ column = ephy_tree_model_node_add_prop_column
+ (view->priv->nodemodel, value_type, prop_id);
+ }
+
+ return column;
+}
+
GtkTreeViewColumn *
ephy_node_view_add_column (EphyNodeView *view,
const char *title,
@@ -1040,7 +1040,7 @@ void
ephy_node_view_enable_drag_source (EphyNodeView *view,
GtkTargetEntry *types,
int n_types,
- guint prop_id)
+ int column)
{
GtkWidget *treeview;
@@ -1055,8 +1055,8 @@ ephy_node_view_enable_drag_source (EphyNodeView *view,
types, n_types,
GDK_ACTION_COPY);
- ephy_tree_model_sort_set_drag_property (EPHY_TREE_MODEL_SORT (view->priv->sortmodel),
- prop_id);
+ ephy_tree_model_sort_set_column_id (EPHY_TREE_MODEL_SORT (view->priv->sortmodel),
+ column);
}
void
diff --git a/lib/widgets/ephy-node-view.h b/lib/widgets/ephy-node-view.h
index 1ccc6cda4..55fab714a 100644
--- a/lib/widgets/ephy-node-view.h
+++ b/lib/widgets/ephy-node-view.h
@@ -85,6 +85,12 @@ GtkTreeViewColumn *ephy_node_view_add_column (EphyNodeView *view,
EphyNodeViewFlags flags,
EphyTreeModelNodeValueFunc icon_func);
+int ephy_node_view_add_data_column (EphyNodeView *view,
+ GType value_type,
+ int prop_id,
+ EphyTreeModelNodeValueFunc func,
+ gpointer data);
+
void ephy_node_view_remove (EphyNodeView *view);
gboolean ephy_node_view_has_selection (EphyNodeView *view,
@@ -98,7 +104,7 @@ void ephy_node_view_select_node (EphyNodeView *view,
void ephy_node_view_enable_drag_source (EphyNodeView *view,
GtkTargetEntry *types,
int n_types,
- guint prop_id);
+ int column_id);
void ephy_node_view_enable_drag_dest (EphyNodeView *view,
GtkTargetEntry *types,
diff --git a/lib/widgets/ephy-tree-model-sort.c b/lib/widgets/ephy-tree-model-sort.c
index d3b425325..14096989b 100644
--- a/lib/widgets/ephy-tree-model-sort.c
+++ b/lib/widgets/ephy-tree-model-sort.c
@@ -44,19 +44,11 @@ static gboolean ephy_tree_model_sort_multi_drag_data_delete (EggTreeMultiDragSou
struct EphyTreeModelSortPrivate
{
char *str_list;
- guint drag_property_id;
-};
-
-enum
-{
- NODE_FROM_ITER,
- LAST_SIGNAL
+ int drag_column_id;
};
static GObjectClass *parent_class = NULL;
-static guint ephy_tree_model_sort_signals[LAST_SIGNAL] = { 0 };
-
GType
ephy_tree_model_sort_get_type (void)
{
@@ -103,18 +95,6 @@ ephy_tree_model_sort_class_init (EphyTreeModelSortClass *klass)
parent_class = g_type_class_peek_parent (klass);
object_class->finalize = ephy_tree_model_sort_finalize;
-
- ephy_tree_model_sort_signals[NODE_FROM_ITER] =
- g_signal_new ("node_from_iter",
- G_OBJECT_CLASS_TYPE (object_class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (EphyTreeModelSortClass, node_from_iter),
- NULL, NULL,
- ephy_marshal_VOID__POINTER_POINTER,
- G_TYPE_NONE,
- 2,
- G_TYPE_POINTER,
- G_TYPE_POINTER);
}
static void
@@ -122,7 +102,7 @@ ephy_tree_model_sort_init (EphyTreeModelSort *ma)
{
ma->priv = g_new0 (EphyTreeModelSortPrivate, 1);
- ma->priv->drag_property_id = -1;
+ ma->priv->drag_column_id = -1;
}
static void
@@ -166,36 +146,14 @@ ephy_tree_model_sort_multi_drag_source_init (EggTreeMultiDragSourceIface *iface)
static gboolean
ephy_tree_model_sort_multi_row_draggable (EggTreeMultiDragSource *drag_source, GList *path_list)
{
- GList *l;
-
- for (l = path_list; l != NULL; l = g_list_next (l))
- {
- GtkTreeIter iter;
- GtkTreePath *path;
- EphyNode *node = NULL;
-
- path = gtk_tree_row_reference_get_path (l->data);
- gtk_tree_model_get_iter (GTK_TREE_MODEL (drag_source), &iter, path);
- g_signal_emit (G_OBJECT (drag_source),
- ephy_tree_model_sort_signals[NODE_FROM_ITER],
- 0, &iter, &node);
-
- gtk_tree_path_free (path);
-
- if (node == NULL)
- {
- return FALSE;
- }
- }
-
- return TRUE;
+ return (EPHY_TREE_MODEL_SORT (drag_source)->priv->drag_column_id > 0);
}
void
-ephy_tree_model_sort_set_drag_property (EphyTreeModelSort *ms,
- guint id)
+ephy_tree_model_sort_set_column_id (EphyTreeModelSort *ms,
+ int id)
{
- ms->priv->drag_property_id = id;
+ ms->priv->drag_column_id = id;
}
static gboolean
@@ -206,75 +164,36 @@ ephy_tree_model_sort_multi_drag_data_delete (EggTreeMultiDragSource *drag_source
}
static void
-each_url_get_data_binder (EphyDragEachSelectedItemDataGet iteratee,
- gpointer iterator_context, gpointer data)
+each_property_get_data_binder (EphyDragEachSelectedItemDataGet iteratee,
+ gpointer iterator_context, gpointer data)
{
gpointer *context = (gpointer *) iterator_context;
GList *path_list = (GList *) (context[0]);
GList *i;
- GtkTreeModel *model = GTK_TREE_MODEL (context[1]);
+ EphyTreeModelSort *model = EPHY_TREE_MODEL_SORT (context[1]);
+ GValue value = {0, };
for (i = path_list; i != NULL; i = i->next)
{
GtkTreeIter iter;
GtkTreePath *path = NULL;
- EphyNode *node = NULL;
- const char *value;
+ const char *svalue;
path = gtk_tree_row_reference_get_path (i->data);
-
gtk_tree_model_get_iter (GTK_TREE_MODEL (model), &iter, path);
- g_signal_emit (G_OBJECT (model),
- ephy_tree_model_sort_signals[NODE_FROM_ITER],
- 0, &iter, &node);
+ gtk_tree_model_get_value (GTK_TREE_MODEL (model), &iter,
+ model->priv->drag_column_id,
+ &value);
+ svalue = g_value_get_string (&value);
- gtk_tree_path_free (path);
-
- if (node == NULL)
- return;
-
- value = ephy_node_get_property_string
- (node, EPHY_TREE_MODEL_SORT (model)->priv->drag_property_id);
-
- LOG ("Data get %s", value)
-
- iteratee (value, -1, -1, -1, -1, data);
- }
-}
+ g_return_if_fail (svalue != NULL);
-static void
-each_node_get_data_binder (EphyDragEachSelectedItemDataGet iteratee,
- gpointer iterator_context, gpointer data)
-{
- gpointer *context = (gpointer *) iterator_context;
- GList *path_list = (GList *) (context[0]);
- GList *i;
- GtkTreeModel *model = GTK_TREE_MODEL (context[1]);
+ LOG ("Data get %s", svalue)
- for (i = path_list; i != NULL; i = i->next)
- {
- GtkTreeIter iter;
- GtkTreePath *path = NULL;
- EphyNode *node = NULL;
- EphyNodeDb *db;
- char *value;
+ iteratee (svalue, -1, -1, -1, -1, data);
- path = gtk_tree_row_reference_get_path (i->data);
- gtk_tree_model_get_iter (GTK_TREE_MODEL (model), &iter, path);
- g_signal_emit (G_OBJECT (model),
- ephy_tree_model_sort_signals[NODE_FROM_ITER],
- 0, &iter, &node);
gtk_tree_path_free (path);
-
- if (node == NULL)
- return;
-
- db = ephy_node_get_db (node);
- value = g_strdup_printf ("%s;%ld",
- ephy_node_db_get_name (db),
- ephy_node_get_id (node));
- iteratee (value, -1, -1, -1, -1, data);
- g_free (value);
+ g_value_unset (&value);
}
}
@@ -283,32 +202,13 @@ ephy_tree_model_sort_multi_drag_data_get (EggTreeMultiDragSource *drag_source,
GList *path_list,
GtkSelectionData *selection_data)
{
- GdkAtom target;
-
- target = selection_data->target;
-
- if (target == gdk_atom_intern (EPHY_DND_BOOKMARK_TYPE, FALSE) ||
- target == gdk_atom_intern (EPHY_DND_TOPIC_TYPE, FALSE))
- {
- gpointer icontext[2];
-
- icontext[0] = path_list;
- icontext[1] = drag_source;
+ gpointer icontext[2];
- ephy_dnd_drag_data_get (NULL, NULL, selection_data,
- 0, &icontext, each_node_get_data_binder);
+ icontext[0] = path_list;
+ icontext[1] = drag_source;
- }
- else
- {
- gpointer icontext[2];
-
- icontext[0] = path_list;
- icontext[1] = drag_source;
-
- ephy_dnd_drag_data_get (NULL, NULL, selection_data,
- 0, &icontext, each_url_get_data_binder);
- }
+ ephy_dnd_drag_data_get (NULL, NULL, selection_data,
+ 0, &icontext, each_property_get_data_binder);
return TRUE;
}
diff --git a/lib/widgets/ephy-tree-model-sort.h b/lib/widgets/ephy-tree-model-sort.h
index 2b8b38be9..abe21ddbb 100644
--- a/lib/widgets/ephy-tree-model-sort.h
+++ b/lib/widgets/ephy-tree-model-sort.h
@@ -53,8 +53,8 @@ GType ephy_tree_model_sort_get_type (void);
GtkTreeModel *ephy_tree_model_sort_new (GtkTreeModel *child_model);
-void ephy_tree_model_sort_set_drag_property (EphyTreeModelSort *ms,
- guint id);
+void ephy_tree_model_sort_set_column_id (EphyTreeModelSort *ms,
+ int id);
G_END_DECLS
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);
diff --git a/src/ephy-history-window.c b/src/ephy-history-window.c
index bbd8a6190..6ef64dea8 100644
--- a/src/ephy-history-window.c
+++ b/src/ephy-history-window.c
@@ -57,8 +57,7 @@ static GtkTargetEntry page_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_page_drag_types = G_N_ELEMENTS (page_drag_types);
@@ -955,7 +954,7 @@ ephy_history_window_construct (EphyHistoryWindow *editor)
EggActionGroup *action_group;
EggAction *action;
GdkPixbuf *icon;
- int i;
+ int i, col_id;
gtk_window_set_title (GTK_WINDOW (editor), _("History"));
@@ -1016,12 +1015,15 @@ ephy_history_window_construct (EphyHistoryWindow *editor)
gtk_widget_show (scrolled_window);
sites_view = ephy_node_view_new (node, NULL);
add_focus_monitor (editor, sites_view);
+ col_id = ephy_node_view_add_data_column (EPHY_NODE_VIEW (sites_view),
+ G_TYPE_STRING,
+ EPHY_NODE_PAGE_PROP_LOCATION,
+ NULL, NULL);
ephy_node_view_select_node (EPHY_NODE_VIEW (sites_view),
ephy_history_get_pages (editor->priv->history));
ephy_node_view_enable_drag_source (EPHY_NODE_VIEW (sites_view),
page_drag_types,
- n_page_drag_types,
- EPHY_NODE_PAGE_PROP_LOCATION);
+ n_page_drag_types, col_id);
selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (sites_view));
gtk_tree_selection_set_mode (selection, GTK_SELECTION_BROWSE);
ephy_node_view_add_column (EPHY_NODE_VIEW (sites_view), _("Sites"),
@@ -1067,10 +1069,13 @@ ephy_history_window_construct (EphyHistoryWindow *editor)
add_focus_monitor (editor, pages_view);
selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (pages_view));
gtk_tree_view_set_rules_hint (GTK_TREE_VIEW (pages_view), TRUE);
+ col_id = ephy_node_view_add_data_column (EPHY_NODE_VIEW (pages_view),
+ G_TYPE_STRING,
+ EPHY_NODE_PAGE_PROP_LOCATION,
+ NULL, NULL);
ephy_node_view_enable_drag_source (EPHY_NODE_VIEW (pages_view),
page_drag_types,
- n_page_drag_types,
- EPHY_NODE_PAGE_PROP_LOCATION);
+ n_page_drag_types, col_id);
col = ephy_node_view_add_column (EPHY_NODE_VIEW (pages_view), _("Title"),
G_TYPE_STRING, EPHY_NODE_PAGE_PROP_TITLE,
-1, EPHY_NODE_VIEW_USER_SORT |
diff --git a/src/ephy-toolbars-model.c b/src/ephy-toolbars-model.c
index fb70e7c50..6bfce6264 100755
--- a/src/ephy-toolbars-model.c
+++ b/src/ephy-toolbars-model.c
@@ -33,10 +33,12 @@ static void ephy_toolbars_model_class_init (EphyToolbarsModelClass *klass);
static void ephy_toolbars_model_init (EphyToolbarsModel *t);
static void ephy_toolbars_model_finalize (GObject *object);
+#define EPHY_TOOLBARS_XML_VERSION "1.0"
+
enum
{
- ACTION_ADDED,
- LAST_SIGNAL
+ ACTION_ADDED,
+ LAST_SIGNAL
};
enum
@@ -57,6 +59,7 @@ struct EphyToolbarsModelPrivate
{
EphyBookmarks *bookmarks;
char *xml_file;
+ gboolean loading;
};
GType
@@ -88,50 +91,24 @@ ephy_toolbars_model_get_type (void)
char *
ephy_toolbars_model_get_action_name (EphyToolbarsModel *model,
- gboolean topic, long id)
+ long id)
{
- char *action_name;
- const char *name;
- EphyNode *node;
- EphyNodePriority priority;
-
- node = ephy_bookmarks_get_from_id (model->priv->bookmarks, id);
- g_return_val_if_fail (node != NULL, NULL);
+ return g_strdup_printf ("GoBookmark-%ld", id);
+}
- priority = ephy_node_get_property_int
- (node, EPHY_NODE_KEYWORD_PROP_PRIORITY);
+EphyNode *
+ephy_toolbars_model_get_node (EphyToolbarsModel *model,
+ const char *action_name)
+{
+ EphyBookmarks *bookmarks = EPHY_TOOLBARS_MODEL (model)->priv->bookmarks;
+ long node_id;
- if (topic)
- {
- if (priority != EPHY_NODE_NORMAL_PRIORITY)
- {
- action_name = g_strdup_printf ("GoSpecialTopic-%ld", id);
- }
- else
- {
- name = ephy_node_get_property_string
- (node, EPHY_NODE_KEYWORD_PROP_NAME);
- action_name = g_strdup_printf ("GoTopic-%s", name);
- }
- }
- else
+ if (!ephy_string_to_int (action_name + strlen ("GoBookmark-"), &node_id))
{
- name = ephy_node_get_property_string
- (node, EPHY_NODE_BMK_PROP_LOCATION);
- action_name = g_strdup_printf ("GoBookmark-%s", name);
+ return NULL;
}
- return action_name;
-}
-
-static void
-topic_destroy_cb (EphyNode *node,
- EphyToolbarsModel *model)
-{
- long id;
-
- id = ephy_node_get_id (node);
- ephy_toolbars_model_remove_bookmark (model, TRUE, id);
+ return ephy_bookmarks_get_from_id (bookmarks, node_id);
}
static void
@@ -141,118 +118,69 @@ bookmark_destroy_cb (EphyNode *node,
long id;
id = ephy_node_get_id (node);
- ephy_toolbars_model_remove_bookmark (model, FALSE, id);
+ ephy_toolbars_model_remove_bookmark (model, id);
}
-static gboolean
-setup_item (EphyToolbarsModel *model,
- const char *name,
- gboolean *is_bookmark,
- gboolean *is_topic,
- long *id)
+static char *
+impl_get_item_name (EggToolbarsModel *t,
+ const char *type,
+ const char *id)
{
- EphyBookmarks *bookmarks = model->priv->bookmarks;
- EphyNode *node = NULL;
-
- *is_topic = FALSE;
+ EphyToolbarsModel *model = EPHY_TOOLBARS_MODEL (t);
+ EphyNode *node;
- if (g_str_has_prefix (name, "GoBookmark-"))
+ if (strcmp (type, EPHY_DND_TOPIC_TYPE) == 0)
{
- node = ephy_bookmarks_find_bookmark
- (bookmarks, name + strlen ("GoBookmark-"));
- if (node == NULL) return FALSE;
+ char *uri;
- ephy_node_signal_connect_object (node,
- EPHY_NODE_DESTROY,
- (EphyNodeCallback) bookmark_destroy_cb,
- G_OBJECT (model));
- }
- else if (g_str_has_prefix (name, "GoTopic-"))
- {
- EphyNode *node;
+ node = ephy_toolbars_model_get_node (model, id);
+ g_return_val_if_fail (node != NULL, NULL);
- node = ephy_bookmarks_find_keyword
- (bookmarks, name + strlen ("GoTopic-"), FALSE);
- if (node == NULL) return FALSE;
+ uri = ephy_bookmarks_get_topic_uri
+ (model->priv->bookmarks, node);
- ephy_node_signal_connect_object (node,
- EPHY_NODE_DESTROY,
- (EphyNodeCallback) topic_destroy_cb,
- G_OBJECT (model));
- *is_topic = TRUE;
+ return uri;
}
- else if (g_str_has_prefix (name, "GoSpecialTopic-"))
+ else if (strcmp (type, EPHY_DND_URL_TYPE) == 0)
{
- EphyNode *node;
- long id;
-
- if (!ephy_string_to_int (name + strlen ("GoSpecialTopic-"), &id))
- {
- return FALSE;
- }
+ const char *name;
- node = ephy_bookmarks_get_from_id (bookmarks, id);
- if (node == NULL) return FALSE;
+ node = ephy_toolbars_model_get_node (model, id);
+ g_return_val_if_fail (node != NULL, NULL);
- ephy_node_signal_connect_object (node,
- EPHY_NODE_DESTROY,
- (EphyNodeCallback) topic_destroy_cb,
- G_OBJECT (model));
-
- *is_topic = TRUE;
- }
+ name = ephy_node_get_property_string
+ (node, EPHY_NODE_BMK_PROP_LOCATION);
- if (node)
- {
- *is_bookmark = TRUE;
- *id = ephy_node_get_id (node);
+ return g_strdup (name);
}
- return TRUE;
+ return EGG_TOOLBARS_MODEL_CLASS (parent_class)->get_item_name (t, type, id);
}
-static const char *
-impl_add_item (EggToolbarsModel *t,
- int toolbar_position,
- int position,
- GdkAtom type,
- const char *name)
+static char *
+impl_get_item_id (EggToolbarsModel *t,
+ const char *type,
+ const char *name)
{
- char *action_name = NULL;
- const char *res;
- gboolean valid, duped_bookmark = FALSE, is_bookmark, is_topic;
- long id = -1;
-
- LOG ("Add item %s", name)
+ EphyToolbarsModel *model = EPHY_TOOLBARS_MODEL (t);
+ EphyBookmarks *bookmarks = model->priv->bookmarks;
- if (gdk_atom_intern (EPHY_DND_TOPIC_TYPE, FALSE) == type)
+ if (strcmp (type, EPHY_DND_TOPIC_TYPE) == 0)
{
- GList *nodes;
+ EphyNode *topic;
- nodes = ephy_dnd_node_list_extract_nodes (name);
- id = ephy_node_get_id (nodes->data);
- action_name = ephy_toolbars_model_get_action_name
- (EPHY_TOOLBARS_MODEL (t), TRUE, id);
- g_list_free (nodes);
- }
- else if (gdk_atom_intern (EPHY_DND_BOOKMARK_TYPE, FALSE) == type)
- {
- GList *nodes;
+ topic = ephy_bookmarks_find_keyword (bookmarks, name, FALSE);
+ if (topic == NULL) return NULL;
- nodes = ephy_dnd_node_list_extract_nodes (name);
- id = ephy_node_get_id (nodes->data);
- action_name = ephy_toolbars_model_get_action_name
- (EPHY_TOOLBARS_MODEL (t), FALSE, id);
- g_list_free (nodes);
+ return ephy_toolbars_model_get_action_name
+ (model, ephy_node_get_id (topic));
}
- else if (gdk_atom_intern (EPHY_DND_URL_TYPE, FALSE) == type)
+ else if (strcmp (type, EPHY_DND_URL_TYPE) == 0)
{
EphyNode *node = NULL;
- EphyBookmarks *bookmarks;
gchar **netscape_url;
netscape_url = g_strsplit (name, "\n", 2);
- bookmarks = ephy_shell_get_bookmarks (ephy_shell);
node = ephy_bookmarks_find_bookmark (bookmarks, netscape_url[URL]);
if (!node)
@@ -273,34 +201,49 @@ impl_add_item (EggToolbarsModel *t,
}
}
- id = ephy_node_get_id (node);
- action_name = ephy_toolbars_model_get_action_name
- (EPHY_TOOLBARS_MODEL (t), FALSE, id);
g_strfreev (netscape_url);
+
+ g_return_val_if_fail (node != NULL, NULL);
+
+ return ephy_toolbars_model_get_action_name
+ (model, ephy_node_get_id (node));
}
- res = action_name ? action_name : name;
+ return EGG_TOOLBARS_MODEL_CLASS (parent_class)->get_item_id (t, type, name);
+}
- valid = setup_item (EPHY_TOOLBARS_MODEL (t), res, &is_bookmark, &is_topic, &id);
- if (!valid)
+static char *
+impl_get_item_type (EggToolbarsModel *t,
+ GdkAtom type)
+{
+ if (gdk_atom_intern (EPHY_DND_TOPIC_TYPE, FALSE) == type)
{
- g_warning ("Invalid bookmark in the toolbar. Removed.");
- return NULL;
+ return g_strdup (EPHY_DND_TOPIC_TYPE);
}
-
- if (is_bookmark)
+ else if (gdk_atom_intern (EPHY_DND_URL_TYPE, FALSE) == type)
{
- duped_bookmark = ephy_toolbars_model_has_bookmark
- (EPHY_TOOLBARS_MODEL (t), is_topic, id);
+ return g_strdup (EPHY_DND_URL_TYPE);
}
- if (!duped_bookmark)
+ return EGG_TOOLBARS_MODEL_CLASS (parent_class)->get_item_type (t, type);
+}
+
+static void
+connect_item (EphyToolbarsModel *model,
+ const char *name)
+{
+ EphyNode *node;
+
+ if (g_str_has_prefix (name, "GoBookmark-"))
{
- EGG_TOOLBARS_MODEL_CLASS (parent_class)->add_item
- (t, toolbar_position, position, type, res);
- }
+ node = ephy_toolbars_model_get_node (model, name);
+ g_return_if_fail (node != NULL);
- return res;
+ ephy_node_signal_connect_object (node,
+ EPHY_NODE_DESTROY,
+ (EphyNodeCallback) bookmark_destroy_cb,
+ G_OBJECT (model));
+ }
}
static void
@@ -311,6 +254,8 @@ ephy_toolbars_model_set_bookmarks (EphyToolbarsModel *model, EphyBookmarks *book
model->priv->bookmarks = bookmarks;
g_object_ref (model->priv->bookmarks);
+ model->priv->loading = TRUE;
+
if (g_file_test (model->priv->xml_file, G_FILE_TEST_EXISTS))
{
egg_toolbars_model_load (egg_model,
@@ -323,6 +268,8 @@ ephy_toolbars_model_set_bookmarks (EphyToolbarsModel *model, EphyBookmarks *book
default_xml = ephy_file ("epiphany-toolbar.xml");
egg_toolbars_model_load (egg_model, default_xml);
}
+
+ model->priv->loading = FALSE;
}
static void
@@ -375,7 +322,9 @@ ephy_toolbars_model_class_init (EphyToolbarsModelClass *klass)
object_class->set_property = ephy_toolbars_model_set_property;
object_class->get_property = ephy_toolbars_model_get_property;
- etm_class->add_item = impl_add_item;
+ etm_class->get_item_id = impl_get_item_id;
+ etm_class->get_item_name = impl_get_item_name;
+ etm_class->get_item_type = impl_get_item_type;
g_object_class_install_property (object_class,
PROP_BOOKMARKS,
@@ -387,31 +336,49 @@ ephy_toolbars_model_class_init (EphyToolbarsModelClass *klass)
}
static void
+save_changes (EphyToolbarsModel *model)
+{
+ if (!model->priv->loading)
+ {
+ egg_toolbars_model_save (EGG_TOOLBARS_MODEL (model),
+ model->priv->xml_file,
+ EPHY_TOOLBARS_XML_VERSION);
+ }
+}
+
+static void
item_added (EphyToolbarsModel *model, int toolbar_position, int position)
{
- egg_toolbars_model_save (EGG_TOOLBARS_MODEL (model),
- model->priv->xml_file);
+ const char *i_name;
+ gboolean is_separator;
+
+ i_name = egg_toolbars_model_item_nth
+ (EGG_TOOLBARS_MODEL (model), toolbar_position,
+ position, &is_separator);
+ if (!is_separator)
+ {
+ connect_item (model, i_name);
+ }
+
+ save_changes (model);
}
static void
item_removed (EphyToolbarsModel *model, int toolbar_position, int position)
{
- egg_toolbars_model_save (EGG_TOOLBARS_MODEL (model),
- model->priv->xml_file);
+ save_changes (model);
}
static void
toolbar_added (EphyToolbarsModel *model, int position)
{
- egg_toolbars_model_save (EGG_TOOLBARS_MODEL (model),
- model->priv->xml_file);
+ save_changes (model);
}
static void
toolbar_removed (EphyToolbarsModel *model, int position)
{
- egg_toolbars_model_save (EGG_TOOLBARS_MODEL (model),
- model->priv->xml_file);
+ save_changes (model);
}
static void
@@ -419,9 +386,9 @@ ephy_toolbars_model_init (EphyToolbarsModel *t)
{
t->priv = g_new0 (EphyToolbarsModelPrivate, 1);
t->priv->bookmarks = NULL;
-
+ t->priv->loading = FALSE;
t->priv->xml_file = g_build_filename (ephy_dot_dir (),
- "ephy-toolbars.xml",
+ "epiphany-toolbars.xml",
NULL);
g_signal_connect (t, "item_added", G_CALLBACK (item_added), NULL);
@@ -438,6 +405,8 @@ ephy_toolbars_model_finalize (GObject *object)
g_return_if_fail (object != NULL);
g_return_if_fail (IS_EPHY_TOOLBARS_MODEL (object));
+ save_changes (t);
+
g_object_unref (t->priv->bookmarks);
g_free (t->priv->xml_file);
@@ -526,13 +495,12 @@ get_toolbar_and_item_pos (EphyToolbarsModel *model,
void
ephy_toolbars_model_remove_bookmark (EphyToolbarsModel *model,
- gboolean topic,
long id)
{
char *action_name;
int toolbar, position;
- action_name = ephy_toolbars_model_get_action_name (model, topic, id);
+ action_name = ephy_toolbars_model_get_action_name (model, id);
g_return_if_fail (action_name != NULL);
if (get_toolbar_and_item_pos (model, action_name, &toolbar, &position))
@@ -549,32 +517,29 @@ ephy_toolbars_model_add_bookmark (EphyToolbarsModel *model,
gboolean topic,
long id)
{
- char *action_name;
+ char *name;
int toolbar_position;
- action_name = ephy_toolbars_model_get_action_name (model, topic, id);
- g_return_if_fail (action_name != NULL);
-
toolbar_position = get_toolbar_pos (model, "BookmarksBar");
g_return_if_fail (toolbar_position != -1);
+ name = ephy_toolbars_model_get_action_name (model, id);
egg_toolbars_model_add_item (EGG_TOOLBARS_MODEL (model),
- toolbar_position, -1,
- 0, action_name);
-
- g_free (action_name);
+ toolbar_position, -1, name,
+ topic ? EPHY_DND_TOPIC_TYPE :
+ EPHY_DND_URL_TYPE);
+ g_free (name);
}
gboolean
ephy_toolbars_model_has_bookmark (EphyToolbarsModel *model,
- gboolean topic,
long id)
{
char *action_name;
gboolean found;
int toolbar, pos;
- action_name = ephy_toolbars_model_get_action_name (model, topic, id);
+ action_name = ephy_toolbars_model_get_action_name (model, id);
g_return_val_if_fail (action_name != NULL, FALSE);
found = get_toolbar_and_item_pos (model, action_name, &toolbar, &pos);
diff --git a/src/ephy-toolbars-model.h b/src/ephy-toolbars-model.h
index dd8814dc9..0261a85fb 100755
--- a/src/ephy-toolbars-model.h
+++ b/src/ephy-toolbars-model.h
@@ -52,20 +52,21 @@ GType ephy_toolbars_model_get_type (void);
EphyToolbarsModel *ephy_toolbars_model_new (EphyBookmarks *bookmarks);
void ephy_toolbars_model_add_bookmark (EphyToolbarsModel *model,
- gboolean topic,
+ gboolean topic,
long id);
gboolean ephy_toolbars_model_has_bookmark (EphyToolbarsModel *model,
- gboolean topic,
long id);
+
void ephy_toolbars_model_remove_bookmark (EphyToolbarsModel *model,
- gboolean topic,
long id);
char *ephy_toolbars_model_get_action_name (EphyToolbarsModel *model,
- gboolean topic,
long id);
+EphyNode *ephy_toolbars_model_get_node (EphyToolbarsModel *model,
+ const char *action_name);
+
void ephy_toolbars_model_set_flag (EphyToolbarsModel *model,
EggTbModelFlags flags);
diff --git a/src/toolbar.c b/src/toolbar.c
index ae6a8f13f..b57284727 100755
--- a/src/toolbar.c
+++ b/src/toolbar.c
@@ -67,8 +67,7 @@ toolbar_get_property (GObject *object,
static GtkTargetEntry drag_targets[] = {
{ EGG_TOOLBAR_ITEM_TYPE, 0, 0 },
{ EPHY_DND_TOPIC_TYPE, 0, 1 },
- { EPHY_DND_BOOKMARK_TYPE, 0, 2 },
- { EPHY_DND_URL_TYPE, 0, 3 },
+ { EPHY_DND_URL_TYPE, 0, 2 },
};
static int n_drag_targets = G_N_ELEMENTS (drag_targets);
@@ -134,29 +133,6 @@ zoom_to_level_cb (EggAction *action, float zoom, EphyWindow *window)
}
static void
-topic_destroy_cb (EphyNode *node,
- Toolbar *t)
-{
- EggAction *action;
- char *name;
- EphyToolbarsModel *model;
- long id;
-
- model = EPHY_TOOLBARS_MODEL
- (ephy_shell_get_toolbars_model (ephy_shell));
-
- id = ephy_node_get_id (node);
- name = ephy_toolbars_model_get_action_name (model, TRUE, id);
- action = egg_action_group_get_action (t->priv->action_group, name);
- if (action)
- {
- egg_action_group_remove_action (t->priv->action_group, action);
- }
-
- g_free (name);
-}
-
-static void
bookmark_destroy_cb (EphyNode *node,
Toolbar *t)
{
@@ -169,7 +145,7 @@ bookmark_destroy_cb (EphyNode *node,
(ephy_shell_get_toolbars_model (ephy_shell));
id = ephy_node_get_id (node);
- name = ephy_toolbars_model_get_action_name (model, FALSE, id);
+ name = ephy_toolbars_model_get_action_name (model, id);
action = egg_action_group_get_action (t->priv->action_group, name);
if (action)
{
@@ -184,78 +160,44 @@ toolbar_ensure_action (Toolbar *t,
const char *name)
{
EggAction *action = NULL;
+ EphyToolbarsModel *model;
EphyBookmarks *bookmarks;
+ EphyNode *bmks, *topics;
- LOG ("Ensure action %s", name)
-
+ model = EPHY_TOOLBARS_MODEL
+ (ephy_shell_get_toolbars_model (ephy_shell));
bookmarks = ephy_shell_get_bookmarks (ephy_shell);
+ bmks = ephy_bookmarks_get_bookmarks (bookmarks);
+ topics = ephy_bookmarks_get_keywords (bookmarks);
- if (g_str_has_prefix (name, "GoBookmark-"))
- {
- EphyNode *node;
-
- LOG ("Create action %s", name)
-
- node = ephy_bookmarks_find_bookmark
- (bookmarks, name + strlen ("GoBookmark-"));
- g_return_if_fail (node != NULL);
-
- action = ephy_bookmark_action_new (name, ephy_node_get_id (node));
- g_signal_connect (action, "go_location",
- G_CALLBACK (go_location_cb), t->priv->window);
- egg_action_group_add_action (t->priv->action_group, action);
- g_object_unref (action);
+ LOG ("Ensure action %s", name)
- ephy_node_signal_connect_object (node,
- EPHY_NODE_DESTROY,
- (EphyNodeCallback) bookmark_destroy_cb,
- G_OBJECT (t));
- }
- else if (g_str_has_prefix (name, "GoTopic-"))
+ if (g_str_has_prefix (name, "GoBookmark-"))
{
EphyNode *node;
- LOG ("Create action %s", name)
-
- node = ephy_bookmarks_find_keyword
- (bookmarks, name + strlen ("GoTopic-"), FALSE);
+ node = ephy_toolbars_model_get_node (model,name);
g_return_if_fail (node != NULL);
- action = ephy_topic_action_new (name, ephy_node_get_id (node));
- g_signal_connect (action, "go_location",
- G_CALLBACK (go_location_cb),
- t->priv->window);
- egg_action_group_add_action (t->priv->action_group, action);
- g_object_unref (action);
-
- ephy_node_signal_connect_object (node,
- EPHY_NODE_DESTROY,
- (EphyNodeCallback) topic_destroy_cb,
- G_OBJECT (t));
- }
- else if (g_str_has_prefix (name, "GoSpecialTopic-"))
- {
- EphyNode *node;
- long id;
-
- LOG ("Create action %s", name)
-
- if (!ephy_string_to_int (name + strlen ("GoSpecialTopic-"), &id))
+ if (ephy_node_has_child (topics, node))
+ {
+ action = ephy_topic_action_new (name, ephy_node_get_id (node));
+ }
+ else if (ephy_node_has_child (bmks, node))
{
- return;
+ action = ephy_bookmark_action_new (name, ephy_node_get_id (node));
}
- action = ephy_topic_action_new (name, id);
+ g_return_if_fail (action != NULL);
+
g_signal_connect (action, "go_location",
- G_CALLBACK (go_location_cb),
- t->priv->window);
+ G_CALLBACK (go_location_cb), t->priv->window);
egg_action_group_add_action (t->priv->action_group, action);
g_object_unref (action);
- node = ephy_bookmarks_get_from_id (bookmarks, id);
ephy_node_signal_connect_object (node,
EPHY_NODE_DESTROY,
- (EphyNodeCallback) topic_destroy_cb,
+ (EphyNodeCallback) bookmark_destroy_cb,
G_OBJECT (t));
}
}