From 6721c0592dfd1492b2dffa63899adb40d9a512d1 Mon Sep 17 00:00:00 2001 From: Tomasz Szatkowski Date: Wed, 23 Mar 2011 22:05:40 +0100 Subject: [PATCH] Drop files or URLs onto tab labels Fixes: https://bugs.launchpad.net/midori/+bug/735769 --- midori/midori-view.c | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/midori/midori-view.c b/midori/midori-view.c index 654db5f1..091d139f 100644 --- a/midori/midori-view.c +++ b/midori/midori-view.c @@ -4704,6 +4704,32 @@ midori_view_get_label_ellipsize (MidoriView* view) return PANGO_ELLIPSIZE_END; } +static void midori_view_tab_label_data_received (GtkWidget* widget, + GdkDragContext* context, + gint x, + gint y, + GtkSelectionData* data, + guint ttype, + guint timestamp, + MidoriView* view) +{ + gchar **uri; + gchar* text; + + uri = gtk_selection_data_get_uris (data); + if (uri != NULL) + { + midori_view_set_uri (view, uri[0]); + g_strfreev (uri); + } + else + { + text = gtk_selection_data_get_text (data); + midori_view_set_uri (view, text); + g_free (text); + } +} + /** * midori_view_get_proxy_tab_label: * @view: a #MidoriView @@ -4796,6 +4822,13 @@ midori_view_get_proxy_tab_label (MidoriView* view) g_signal_connect (view->tab_label, "parent-set", G_CALLBACK (midori_view_tab_label_parent_set), view); + gtk_drag_dest_set (view->tab_label, GTK_DEST_DEFAULT_ALL, NULL, + 0, GDK_ACTION_COPY); + gtk_drag_dest_add_text_targets (view->tab_label); + gtk_drag_dest_add_uri_targets (view->tab_label); + g_signal_connect (view->tab_label, "drag-data-received", + G_CALLBACK (midori_view_tab_label_data_received), + view); } return view->tab_label; } -- 2.39.5