Re: Custom drag and drop with GtkTreeView
| From: | Andre Colomb | Date: | Wed, 09 May 2007 15:19:47 +0000 |
| Subject: | Re: Custom drag and drop with GtkTreeView | ||
| References: | 1 | Groups: | php.gtk.general |
| Request: | Send a blank email to php-gtk-general+get-7812@lists.php.net to get a copy of this message | ||
On Thu, 15 Mar 2007 13:35:15 +0100
"Andre Colomb" <acolomb@schickhardt.org> wrote:
> 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.
Well, I still haven't solved my problem, but I tried some different
approaches now. kksou's examples were very helpful. However, I can not
get them to work with a GtkTreeStore instead of GtkListStore. I am
using GtkTreeView::set_reorderable(true) now and tried connecting to
various signals.
The main problem is getting the target path in a signal handler for the
"drag-drop" or "drag-data-received" signal. Using
GtkTreeView::get_path_at_pos() yields very strange results, even with
sorting turned off and the column headers disabled. I do not understand
how one should make a decision based on the tree path returned by this
function.
For example, dropping a row "on top of" another row, to make it a child
of the target row, gives me the same tree path as dropping it just
before the target row. Those are two totally different things, and my
decision if the drop is possible may depend just on that information.
Besides, how does GTK distinguish the two cases at all? There must be
some other function to translate the drop coordinates to a position and
parent iter in the GtkTreeStore. After all, the standard behavior with
the "reorderable" property set to true does it right in each of the two
situations.
I still haven't figured out how the "offset" in the path returned by
GtkTreeView::get_path_at_pos() applies to GtkTreeStore paths, and what
it all has to do with the column headers being visible. Guess there is
a whole lot of work to be done on the documentation side and in Gtk
itself regarding this issue. The suggested techniques for implementing
tool tips in a GtkTreeView also sound more like a workaround than a
clean solution to a very common problem, rooted in the unclear usage of
tree view coordinates.
I hope someone knows a way to implement this correctly. Thanks for any
hints, pointers or code samples!
Regards,
Andre
--
Greetings...
From: Andre Colomb <acolomb@schickhardt.org>