# Drag and drop between treeviews

**URL:** <https://www.ruby-forum.com/t/drag-and-drop-between-treeviews/110895>\
**Category:** Ruby-Gnome 2\
**Created:** [July 31, 2007, 9:54pm UTC](https://www.ruby-forum.com/t/drag-and-drop-between-treeviews/110895 "2007-07-31T21:54:37Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![alex](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/db5fbb/32.png) [@alex](https://www.ruby-forum.com/u/alex)\
**Post date:** [July 31, 2007, 9:54pm UTC](https://www.ruby-forum.com/t/drag-and-drop-between-treeviews/110895/1 "2007-07-31T21:54:37Z")

</div>

I want to enable drag and drop between two different tree views… one  
treeview actually uses a treefiltermodel, which I guess doesn’t  
implement the dragdest interface…

I enabled dragging from the one treeview:

@treeview.enable\_model\_drag\_source(Gdk:🪟:BUTTON1\_MASK,  
DND\_TAG\_TO\_AUDIO\_WORK,  
Gdk::DragContext::ACTION\_COPY)

and in the other treeview [the one i want to be the dest] i’ve tried  
both:

enable\_model\_drag\_dest(DND\_TAG\_TO\_AUDIO\_WORK,  
Gdk::DragContext::ACTION\_COPY)

signal\_connect(“drag\_data\_received”) { |\*args|  
puts “got”  
true  
}

and

Gtk::Drag.dest\_set(self, Gtk::Drag::DEST\_DEFAULT\_MOTION |  
Gtk::Drag::DEST\_DEFAULT\_HIGHLIGHT,  
DND\_TAG\_TO\_AUDIO\_WORK,  
Gdk::DragContext::ACTION\_COPY)

signal\_connect(“drag-data-received”) do |w, dc, x, y, selectiondata,  
info, time|  
dc.targets.each do |target|  
if target.name == “test” ||  
selectiondata.type == Gdk::Selection::TYPE\_STRING  
puts selectiondata.data  
else  
puts “got”  
end  
end  
true  
end

signal\_connect(“drag-drop”) do |w, dc, x, y, time|  
Gtk::Drag.get\_data(w, dc, dc.targets[0], time)  
true  
end

each method gives me “got” on the console when I drop something, but I  
also see  
this printed:  
Gtk-WARNING \*\*:You must override the default ‘drag\_data\_received’  
handler on GtkTreeView when using models that don’t support the  
GtkTreeDragDest interface and enabling drag-and-drop. The simplest way  
to do this is to connect to ‘drag\_data\_received’ and call  
g\_signal\_stop\_emission\_by\_name() in your signal handler to prevent the  
default handler from running. Look at the source code for the default  
handler in gtktreeview.c to get an idea what your handler should do.  
(gtktreeview.c is in the GTK source code.) If you’re using GTK from a  
language other than C, there may be a more natural way to override  
default handlers, e.g. via derivation.

Basically, I’m wondering what the best way to do this is, and how do I  
get rid  
of this warning?

-Alex

* * *

This [SF.net](http://SF.net) email is sponsored by: Splunk Inc.  
Still grepping through log files to find problems? Stop.  
Now Search log events and configuration files using AJAX and a browser.  
Download your FREE copy of Splunk now \>\> [http://get.splunk.com/](http://get.splunk.com/)
