Web lists-archives.com

Re: GTK4: gtk_tree_view_enable_model_drag_dest () and GdkContentFormats

I have found the solution for the dragging part.
gtk_tree_view_enable_model_drag_source (GTK_TREE_VIEW (treeview), 1, enable_list, GDK_ACTION_MOVE); // enable_list is a GtkTargetEntry structure
was working in GTK3 (in fact this was a leftover from the GTK2 beginnings of the program), it has to be now
gtk_tree_view_enable_model_drag_source (GTK_TREE_VIEW (treeview), GDK_BUTTON1_MASK, content_formats, GDK_ACTION_MOVE); // content_formats is a GdkContentFormats structure

So the real difference was using GDK_BUTTON1_MASK in GTK4.

The actual process of moving the tree rows inside the tree view is not yet working in the GTK4 version, but if I can't make it work I can come back here later.

2018-03-12 21:30 GMT+01:00 <lrn1986@xxxxxxxxx>:
On 12.03.2018 19:45, Marcus Schätzle wrote:
Hi all,

I've done a port of a program to GTK4 (3.93.3); there is a part that I have not yet gotten to work and that is drag and drop inside a tree view.

I have particularly trouble understanding using the target formats inside gtk_tree_view_enable_model_drag_dest (). For the GTK 3 version I use a GtkTargetEntry structure initialised with {{ "STRING", GTK_TARGET_SAME_WIDGET, 0 }}, which has always worked fine so far.

That is surprising. Usually i'd go for "UTF8_STRING".

For GTK 4 I am supposed to use GdkContentFormats. But which mime types am I supposed to fill into gtk_content_formats_new ()?

"text/plain;charset=utf-8" is the GTK4 equivalent of "UTF8_STRING"

That's all i know.

Note that last time i checked there was a bug that prevented DnD from working correctly in some cases. For example, DnD of text didn't work for GtkTextView, but did work for GtkEntry.

gtk-list mailing list

gtk-list mailing list