Custom drag and drop with GtkTreeView
| From: | Andre Colomb | Date: | Thu, 15 Mar 2007 12:35:15 +0000 |
| Subject: | Custom drag and drop with GtkTreeView | ||
| Groups: | php.gtk.general | ||
| Request: | Send a blank email to php-gtk-general+get-7749@lists.php.net to get a copy of this message | ||
Hi again!
My application needs drag-and-drop support in a GtkTreeView, but with
specific rules where a selected row can be dropped depending on its
contents.
The GTK+ reference says there are two ways to customize the drag and
drop behaviour in a tree view: either the low-level dnd API or the
higher-level interfaces GtkTreeDragSource and GtkTreeDragDest.
Unfortunately, those two interfaces aren't documented in the PHP-GTK2
manual yet.
I have been trying to overload the two methods in GtkTreeDragDest to
implement my own dropping rules. However, it seems that they don't even
get called when using GtkTreeView::set_reorderable(true) (or, in my
case, setting the "reorderable" property in the GladeXML file).
Could anyone please give me a hint on how to implement custom
drag-and-drop behaviour without re-inventing the wheel (that is,
hover-to-open, autoscroll, etc...)
This is the code snippet where I tried to overload the GtkTreeDragDest
methods:
---SNIP---
class MyTreeStore extends GtkTreeStore
{
public function row_drop_possible($dest_path, GtkSelectionData
$selection_data)
{
echo "My row_drop_possible()!\n"; // Cannot see this!
}
public function drag_dest_received($dest, GtkSelectionData
$selection_data)
{
echo "My drag_dest_received!\n"; // Cannot see this!
}
}
$model = new MyTreeStore(Gtk::TYPE_LONG);
$treeview = new GtkTreeView($model);
$treeview->set_reorderable(true);
$renderer = new GtkCellRendererText;
$col = new GtkTreeViewColumn('test', $renderer, 'text', 0);
$treeview->append_column($col);
---SNIP---
Thanks for any hints!
Regards,
Andre
--
Greetings...
From: Andre Colomb <acolomb@schickhardt.org>