+static void
+drag_begin_cb (GtkWidget *widget,
+ GdkDragContext *context,
+ gpointer data)
+{
+ GtkTextView *text_view;
+ gchar *text;
+ GdkPixmap *pixmap = NULL;
+
+ g_signal_handlers_disconnect_by_func (widget, drag_begin_cb, NULL);
+
+ text_view = GTK_TEXT_VIEW (widget);
+
+ text = _gtk_text_view_get_selected_text (text_view);
+ pixmap = _gtk_text_util_create_drag_icon (widget, text, -1);
+
+ if (pixmap)
+ gtk_drag_set_icon_pixmap (context,
+ gdk_drawable_get_colormap (pixmap),
+ pixmap,
+ NULL,
+ -2, -2);
+ else
+ gtk_drag_set_icon_default (context);
+
+ if (pixmap)
+ g_object_unref (pixmap);
+ g_free (text);
+}
+