Announcement (2017-05-07): www.ruby-forum.com is now read-only since I
unfortunately do not have the time to support and maintain the forum any
more. Please see rubyonrails.org/community and ruby-lang.org/en/community
for other Rails- und Ruby-related community platforms.

So I've been struggling with this for a while, can someone help?
Below is an example of what I'm trying to do, which is, drag items
from one treeview into another which uses a filtered model.
Basically, I'm trying to implement "tagging" and the first model is a
list of tags and the second is an association of items with these
tags. [though this example just uses random numbers in place of tags]
First, how do I actually get the selection in the drag destination
signal handler.
Second, how do I get rid of this message:
"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."
thanks,
Alex
-----
require 'gtk2'
DND_ME = [["GTK_TREE_MODEL_ROW", Gtk::Drag::TARGET_SAME_APP, 0]]
#create two stores, both with random values in them
m1 = Gtk::ListStore.new(Float)
m2 = Gtk::ListStore.new(Integer, Float)
#put some random data in there
(0..10).each do |i|
iter = m1.append
iter[0] = rand
end
# put some random data in there, iter[0] can be seen as an id of an item
# and iter[1] could be a tag.
(0..100).each do |i|
iter = m2.append
iter[0] = i % 10
iter[1] = rand
end
#create a view
v1 = Gtk::TreeView.new(m1)
renderer = Gtk::CellRendererText.new
col = Gtk::TreeViewColumn.new("Source", renderer, :text => 0)
v1.append_column(col)
#create a filtered tree model
fm = Gtk::TreeModelFilter.new(m2)
fm.set_visible_func{|model, iter|
if iter[0] == 0
next true
else
next false
end
}
fm.refilter
#make a view with the filtered model
v2 = Gtk::TreeView.new(fm)
renderer = Gtk::CellRendererText.new
col = Gtk::TreeViewColumn.new("Dest [Filtered]", renderer, :text => 1)
v2.append_column(col)
#make the first view a drag source
v1.enable_model_drag_source(Gdk::Window::BUTTON1_MASK, DND_ME,
Gdk::DragContext::ACTION_LINK)
#make the second view [with the filtered model] a drag destination
v2.enable_model_drag_dest(DND_ME, Gdk::DragContext::ACTION_LINK)
#create the signal handlers
v2.signal_connect("drag_data_received") do |w, dc, x, y,
selectiondata, info, time|
puts "got something!"
puts selectiondata.type
puts selectiondata.format
puts selectiondata.target
#XXX i need help here!
true
end
#make the windows
w1 = Gtk::Window.new("floatme: source")
w2 = Gtk::Window.new("floatme: dest")
w1.add(v1)
w2.add(v2)
w1.show_all
w2.show_all
Gtk::main