GNOME Bugzilla – Bug 506853
gtk_tree_view_enable_model_drag_[source|dest] problem
Last modified: 2008-06-10 12:34:07 UTC
gtk_tree_view_enable_model_drag_[source|dest] calls gtk_drag_[source|dest]_set with the passed-in targets list, but it also stores the targets list internally. That makes it impossible to add targets later on, e.g. with gtk_drag_*_add_text_targets and gtk_drag_*_add_uri_targets.
Created attachment 101989 [details] [review] proposed patch No need to store the source/dest targets lists; gtk_drag_*_get_target_list provides it. While I was there, I converted the file to use GSlice for small allocations.
Looks fine to me, assuming you have given it some testing.
*shrug*, I haven't written the DnD code for GtkTreeView and it is quite a big mess in my opinion (will be rewriting all DnD code at some point in my experimental tree view thing). I cannot really say whether storing the target list internally was done deliberately to make some things impossible or not ... To me it feels like that the complete thing will blow up if the user clears or sets another target list without the GTK_TREE_MODEL_ROW entry if the patch is applied. Without the patch applied this will not happen ...
Kris: calling gtk_tree_view_enable_model_drag_dest/source unsets the reorderable property, and if you turn it on afterwards, it calls gtk_tree_view_enable_model_drag_dest and _source with the "GTK_TREE_MODEL_ROW" target. So this isn't a problem with the patch. I can certainly add documentation to gtk_tree_view_enable_model_drag_dest/source that one should not call gtk_drag_dest/source_set directly but only those methods.
Kris: ping?
Sorry for the long delay.... I looked at it again now and it all makes sense and looks fine to me. Could you please commit the GSlice refactorings separately from the target list business? Thanks!
Committed in 2 runs: * gtk/gtktreeview.c: (gtk_tree_view_button_release_drag_column), (dest_row_free), (set_dest_row), (ensure_info), (gtk_tree_view_remove), (gtk_tree_view_put), (gtk_tree_view_set_column_drag_info): Use GSlice. Patch from bug #506853. * gtk/gtktreeview.c: (destroy_info), (set_destination_row), (gtk_tree_view_maybe_begin_dragging_row), (gtk_tree_view_set_reorderable), (gtk_tree_view_enable_model_drag_source), (gtk_tree_view_enable_model_drag_dest), (gtk_tree_view_unset_rows_drag_source), (gtk_tree_view_unset_rows_drag_dest): Make gtk_tree_view_enable_model_drag_[source|dest] compatible with gtk_drag_[source|dest]_add_*_targets. Bug #506853.