aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPeter Harvey <peter.a.harvey@gmail.com>2006-01-17 06:50:01 +0800
committerPeter Anthony Harvey <paharvey@src.gnome.org>2006-01-17 06:50:01 +0800
commit8b7a35d4587cbd28c7c7bebabddb8a27c9f12bc9 (patch)
tree6286455f6a9adcb856907d3a4a6494af633c140c
parent0d14d3a9aebf4dc47e77a7ff16f8a8bd3632392a (diff)
downloadgsoc2013-epiphany-8b7a35d4587cbd28c7c7bebabddb8a27c9f12bc9.tar
gsoc2013-epiphany-8b7a35d4587cbd28c7c7bebabddb8a27c9f12bc9.tar.gz
gsoc2013-epiphany-8b7a35d4587cbd28c7c7bebabddb8a27c9f12bc9.tar.bz2
gsoc2013-epiphany-8b7a35d4587cbd28c7c7bebabddb8a27c9f12bc9.tar.lz
gsoc2013-epiphany-8b7a35d4587cbd28c7c7bebabddb8a27c9f12bc9.tar.xz
gsoc2013-epiphany-8b7a35d4587cbd28c7c7bebabddb8a27c9f12bc9.tar.zst
gsoc2013-epiphany-8b7a35d4587cbd28c7c7bebabddb8a27c9f12bc9.zip
src/bookmarks/ephy-topic-action.c
2006-01-17 Peter Harvey <peter.a.harvey@gmail.com> * src/bookmarks/ephy-topic-action.c Handle DnD to topics on the toolbar.
-rw-r--r--ChangeLog6
-rw-r--r--src/bookmarks/ephy-topic-action.c58
2 files changed, 64 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
index 6c245a445..667780985 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,11 @@
2006-01-17 Peter Harvey <peter.a.harvey@gmail.com>
+ * src/bookmarks/ephy-topic-action.c
+
+ Handle DnD to topics on the toolbar.
+
+2006-01-17 Peter Harvey <peter.a.harvey@gmail.com>
+
* lib/egg/egg-editable-toolbar.h
Checking in forgotten changes to the editable toolbar API.
diff --git a/src/bookmarks/ephy-topic-action.c b/src/bookmarks/ephy-topic-action.c
index dd3844af4..0bac49b06 100644
--- a/src/bookmarks/ephy-topic-action.c
+++ b/src/bookmarks/ephy-topic-action.c
@@ -28,8 +28,10 @@
#include "ephy-bookmarks.h"
#include "ephy-bookmarks-ui.h"
#include "ephy-bookmarks-menu.h"
+#include "ephy-shell.h"
#include "ephy-gui.h"
#include "ephy-debug.h"
+#include "ephy-dnd.h"
#include <glib/gi18n.h>
#include <gtk/gtkwidget.h>
@@ -47,6 +49,10 @@
#include <libgnomevfs/gnome-vfs-uri.h>
#include <string.h>
+static const GtkTargetEntry dest_drag_types[] = {
+ {EPHY_DND_URL_TYPE, 0, 0},
+};
+
#define TOOLITEM_WIDTH_CHARS 24
#define MENUITEM_WIDTH_CHARS 32
#define LABEL_WIDTH_CHARS 32
@@ -100,6 +106,53 @@ ephy_topic_action_get_type (void)
return type;
}
+static void
+drag_data_received_cb (GtkWidget *widget,
+ GdkDragContext *context,
+ gint x,
+ gint y,
+ GtkSelectionData *selection_data,
+ guint info,
+ guint time,
+ GtkAction *action)
+{
+ const char *data;
+ EphyBookmarks *bookmarks;
+ EphyNode *bookmark, *topic;
+ gchar **netscape_url;
+
+ topic = ephy_topic_action_get_topic (EPHY_TOPIC_ACTION (action));
+
+ data = (char *)selection_data->data;
+ bookmarks = ephy_shell_get_bookmarks (ephy_shell);
+
+ netscape_url = g_strsplit (data, "\n", 2);
+ if (!netscape_url || !netscape_url[0])
+ {
+ g_strfreev (netscape_url);
+ gtk_drag_finish (context, FALSE, FALSE, time);
+ return;
+ }
+
+ bookmark = ephy_bookmarks_find_bookmark (bookmarks, netscape_url[0]);
+ if (bookmark == NULL)
+ {
+ bookmark = ephy_bookmarks_add (bookmarks, netscape_url[1], netscape_url[0]);
+ }
+
+ g_strfreev (netscape_url);
+
+ if (bookmark != NULL)
+ {
+ ephy_bookmarks_set_keyword (bookmarks, topic, bookmark);
+ gtk_drag_finish (context, TRUE, FALSE, time);
+ }
+ else
+ {
+ gtk_drag_finish (context, FALSE, FALSE, time);
+ }
+}
+
static GtkWidget *
create_tool_item (GtkAction *action)
{
@@ -320,6 +373,11 @@ connect_proxy (GtkAction *action, GtkWidget *proxy)
G_CALLBACK (button_press_cb), action);
g_signal_connect (button, "button-release-event",
G_CALLBACK (button_release_cb), action);
+
+ g_signal_connect (button, "drag_data_received",
+ G_CALLBACK (drag_data_received_cb), action);
+ gtk_drag_dest_set (button, GTK_DEST_DEFAULT_ALL, dest_drag_types,
+ G_N_ELEMENTS (dest_drag_types), GDK_ACTION_COPY);
}
else if (GTK_IS_MENU_ITEM (proxy))
{