Hi (sorry for the broken thread, I wasn’t subscribed to the list yet)
PyGTK supports this directly by passing a list of selected rows to the handler
Really? Could you show me a example for that?
You’re script does the trick, though it doesn’t work when
double-clicking, and it
doesn’t restore the selection afterwards. But after rewriting it in
Python I
realized that PyGTK has the same behaviour.
The reason I assumed PyGTK handles this is that I saw it in the code of
the
Python music player Quodlibet, but I just now realized that they use a
custom
TreeView which implements that behaviour (see the MultiDragTreeView in
http://www.sacredchao.net/quodlibet/browser/trunk/quodlibet/qltk/views.py).
So, I guess I’ll try to rebuild that class in ruby.
But thanks for your answer, anyway!
Here’s the python version of your script:
#!/usr/bin/env python
import gtk
window = gtk.Window()
model = gtk.TreeStore(str)
tree_view = gtk.TreeView(model)
tree_view.get_selection().set_mode(gtk.SELECTION_MULTIPLE)
prev_selected = []
selected = []
def changed(selection):
global prev_selected, selected
prev_selected = selected
model, selected = selection.get_selected_rows()
tree_view.get_selection().connect(“changed”, changed)
def row_activated(widget, path, column):
global prev_selected
print prev_selected
False
tree_view.connect(“row-activated”, row_activated)
cell = gtk.CellRendererText()
column = gtk.TreeViewColumn(“column”, cell)
column.add_attribute(cell, “text”, 0)
tree_view.append_column(column)
for i in range(0, 10):
model.append(None, row=[str(i)])
window.add(tree_view)
window.show_all()
gtk.main()
Cheers
Markus
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net’s Techsay panel and you’ll get the chance to share
your
opinions on IT & business topics through brief surveys – and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV