diff options
author | Marco Pesenti Gritti <marco@it.gnome.org> | 2003-01-30 07:20:47 +0800 |
---|---|---|
committer | Marco Pesenti Gritti <mpeseng@src.gnome.org> | 2003-01-30 07:20:47 +0800 |
commit | c1008f8781b7940bb7096bc6e5fe250ec6ebcaf2 (patch) | |
tree | 73461aa9c690a3fc83c05e8b2df5d768c64b269a | |
parent | dff9e866bb4f2fc18074d5c638733ee860746f9b (diff) | |
download | gsoc2013-epiphany-c1008f8781b7940bb7096bc6e5fe250ec6ebcaf2.tar gsoc2013-epiphany-c1008f8781b7940bb7096bc6e5fe250ec6ebcaf2.tar.gz gsoc2013-epiphany-c1008f8781b7940bb7096bc6e5fe250ec6ebcaf2.tar.bz2 gsoc2013-epiphany-c1008f8781b7940bb7096bc6e5fe250ec6ebcaf2.tar.lz gsoc2013-epiphany-c1008f8781b7940bb7096bc6e5fe250ec6ebcaf2.tar.xz gsoc2013-epiphany-c1008f8781b7940bb7096bc6e5fe250ec6ebcaf2.tar.zst gsoc2013-epiphany-c1008f8781b7940bb7096bc6e5fe250ec6ebcaf2.zip |
Fix bookmarks/smart bookmarks add to the toolbars.
2003-01-30 Marco Pesenti Gritti <marco@it.gnome.org>
* lib/ephy-dnd.c: (ephy_dnd_url_drag_source_set),
(ephy_dnd_enable_model_drag_source):
* lib/ephy-dnd.h:
* lib/widgets/ephy-editable-toolbar.c: (item_node_new),
(add_action), (parse_item_list), (toolbar_list_to_xml),
(drag_data_received_cb), (setup_toolbar_drag):
* src/toolbar.c: (toolbar_get_action):
Fix bookmarks/smart bookmarks add to the toolbars.
-rw-r--r-- | ChangeLog | 12 | ||||
-rw-r--r-- | lib/ephy-dnd.c | 5 | ||||
-rw-r--r-- | lib/ephy-dnd.h | 4 | ||||
-rwxr-xr-x | lib/widgets/ephy-editable-toolbar.c | 35 | ||||
-rwxr-xr-x | src/toolbar.c | 7 |
5 files changed, 42 insertions, 21 deletions
@@ -1,3 +1,15 @@ +2003-01-30 Marco Pesenti Gritti <marco@it.gnome.org> + + * lib/ephy-dnd.c: (ephy_dnd_url_drag_source_set), + (ephy_dnd_enable_model_drag_source): + * lib/ephy-dnd.h: + * lib/widgets/ephy-editable-toolbar.c: (item_node_new), + (add_action), (parse_item_list), (toolbar_list_to_xml), + (drag_data_received_cb), (setup_toolbar_drag): + * src/toolbar.c: (toolbar_get_action): + + Fix bookmarks/smart bookmarks add to the toolbars. + 2003-01-29 Marco Pesenti Gritti <marco@it.gnome.org> * lib/ephy-bonobo-extensions.c: (ephy_bonobo_clear_path), diff --git a/lib/ephy-dnd.c b/lib/ephy-dnd.c index b70fa284a..03fa83544 100644 --- a/lib/ephy-dnd.c +++ b/lib/ephy-dnd.c @@ -27,6 +27,7 @@ static GtkTargetEntry url_drag_types [] = { EPHY_DND_TEXT_TYPE, 0, EPHY_DND_TEXT }, { EPHY_DND_URL_TYPE, 0, EPHY_DND_URL } }; +static int n_url_drag_types = G_N_ELEMENTS (url_drag_types); /* Encode a "_NETSCAPE_URL_" selection. * As far as I can tell, Netscape is expecting a single @@ -94,7 +95,7 @@ ephy_dnd_url_drag_source_set (GtkWidget *widget) gtk_drag_source_set (widget, GDK_BUTTON1_MASK, url_drag_types, - G_N_ELEMENTS (url_drag_types), + n_url_drag_types, GDK_ACTION_COPY); } @@ -103,7 +104,7 @@ ephy_dnd_enable_model_drag_source (GtkWidget *treeview) { gtk_tree_view_enable_model_drag_source (GTK_TREE_VIEW (treeview), GDK_BUTTON1_MASK, - url_drag_types, G_N_ELEMENTS (url_drag_types), + url_drag_types, n_url_drag_types, GDK_ACTION_COPY); } diff --git a/lib/ephy-dnd.h b/lib/ephy-dnd.h index 87b6008d9..7d5281128 100644 --- a/lib/ephy-dnd.h +++ b/lib/ephy-dnd.h @@ -31,14 +31,12 @@ G_BEGIN_DECLS #define EPHY_DND_URI_LIST_TYPE "text/uri-list" #define EPHY_DND_TEXT_TYPE "text/plain" #define EPHY_DND_URL_TYPE "_NETSCAPE_URL" -#define EPHY_DND_EPHY_URL_TYPE "EPHY_URL" -#define EPHY_DND_EPHY_BOOKMARK_TYPE "EPHY_BOOKMARK" /* Standard Drag & Drop types. */ typedef enum { EPHY_DND_URI_LIST, - EPHY_DND_URL, EPHY_DND_TEXT, + EPHY_DND_URL } EphyIconDndTargetType; typedef void (* EphyDragEachSelectedItemDataGet) (const char *url, diff --git a/lib/widgets/ephy-editable-toolbar.c b/lib/widgets/ephy-editable-toolbar.c index f6b6f8f7f..b082d6c31 100755 --- a/lib/widgets/ephy-editable-toolbar.c +++ b/lib/widgets/ephy-editable-toolbar.c @@ -44,9 +44,7 @@ static GtkTargetEntry dest_drag_types [] = static GtkTargetEntry source_drag_types [] = { - { "EPHY_TOOLBAR_BUTTON", 0, 0 }, - /* FIXME generic way to add types */ - { EPHY_DND_URL_TYPE, 0, EPHY_DND_URL } + { "EPHY_TOOLBAR_BUTTON", 0, 0 } }; static void ephy_editable_toolbar_class_init (EphyEditableToolbarClass *klass); @@ -90,6 +88,7 @@ typedef struct { gboolean separator; EggAction *action; + char *type; } ItemNode; GType @@ -133,13 +132,14 @@ toolbar_node_new (void) } static ItemNode * -item_node_new (EggAction *action, gboolean separator) +item_node_new (EggAction *action, const char *type, gboolean separator) { ItemNode *item; item = g_new0 (ItemNode, 1); item->action = action; item->separator = separator; + item->type = type ? g_strdup (type) : NULL; return item; } @@ -220,7 +220,7 @@ add_action (EphyEditableToolbar *t, action = ephy_editable_toolbar_get_action (t, type, name); } - item = item_node_new (action, separator); + item = item_node_new (action, type, separator); node = g_node_new (item); g_node_insert_before (parent, sibling, node); @@ -236,11 +236,14 @@ parse_item_list (EphyEditableToolbar *t, if (xmlStrEqual (child->name, "toolitem")) { xmlChar *verb; + xmlChar *type; verb = xmlGetProp (child, "verb"); - add_action (t, parent, NULL, NULL, verb); + type = xmlGetProp (child, "type"); + add_action (t, parent, NULL, type, verb); xmlFree (verb); + xmlFree (type); } else if (xmlStrEqual (child->name, "separator")) { @@ -364,6 +367,10 @@ toolbar_list_to_xml (EphyEditableToolbar *t, GNode *tl) { node = xmlNewChild (tnode, NULL, "toolitem", NULL); xmlSetProp (node, "verb", item->action->name); + if (item->type) + { + xmlSetProp (node, "type", item->type); + } } } } @@ -454,6 +461,8 @@ drag_data_received_cb (GtkWidget *widget, GNode *toolbar; GNode *parent; GNode *sibling; + const char *type = NULL; + GdkAtom target; toolbar = (GNode *)g_object_get_data (G_OBJECT (widget), "toolbar_node"); @@ -468,7 +477,13 @@ drag_data_received_cb (GtkWidget *widget, parent = toolbar; } - add_action (etoolbar, parent, sibling, NULL, selection_data->data); + target = gtk_drag_dest_find_target (widget, context, NULL); + if (target == gdk_atom_intern (EPHY_DND_URL_TYPE, FALSE)) + { + type = EPHY_DND_URL_TYPE; + } + + add_action (etoolbar, parent, sibling, type, selection_data->data); queue_ui_update (etoolbar); } @@ -529,7 +544,8 @@ setup_toolbar_drag (EphyEditableToolbar *etoolbar, GNode *toolbars) g_object_set_data (G_OBJECT (toolbar), "drag_dest_set", GINT_TO_POINTER (TRUE)); gtk_drag_dest_set (toolbar, GTK_DEST_DEFAULT_ALL, - dest_drag_types, 2, GDK_ACTION_MOVE); + dest_drag_types, 2, + GDK_ACTION_MOVE | GDK_ACTION_COPY); g_signal_connect (toolbar, "drag_data_received", G_CALLBACK (drag_data_received_cb), etoolbar); @@ -563,7 +579,8 @@ setup_toolbar_drag (EphyEditableToolbar *etoolbar, GNode *toolbars) g_object_set_data (G_OBJECT (toolitem), "drag_dest_set", GINT_TO_POINTER (TRUE)); gtk_drag_dest_set (toolitem, GTK_DEST_DEFAULT_ALL, - dest_drag_types, 2, GDK_ACTION_MOVE); + dest_drag_types, 2, + GDK_ACTION_COPY | GDK_ACTION_MOVE); g_signal_connect (toolitem, "drag_data_received", G_CALLBACK (drag_data_received_cb), etoolbar); diff --git a/src/toolbar.c b/src/toolbar.c index 29ae4665f..826adc596 100755 --- a/src/toolbar.c +++ b/src/toolbar.c @@ -129,14 +129,7 @@ toolbar_get_action (EphyEditableToolbar *etoolbar, snprintf (action_name, 255, "GoBookmarkId%ld", id); action = ephy_bookmark_action_new (name, id); - } - else if (g_str_has_prefix (name, "GoBookmarkId")) - { - ephy_str_to_int (name + strlen ("GoBookmarkId"), &id); - } - if (action) - { g_signal_connect (action, "go_location", G_CALLBACK (go_location_cb), t->priv->window); egg_action_group_add_action (t->priv->action_group, action); |