Add row_draggable() vfunc, and wrapper function.

Mon Nov  5 22:34:29 2001  Owen Taylor  <otaylor@redhat.com>

	* gtk/gtktreednd.[ch] (struct _GtkTreeDragSourceIface):
	Add row_draggable() vfunc, and wrapper function.

	* gtk/gtktreednd.[ch] (struct _GtkTreeDragDestIface): Make
	row_drop_possible take a GtkSelectionData, rather than
	model/row pair.

	* gtk/gtktreestore.c gtk/gtkliststore.c: Update for
	new DND interfaces.

	* gtk/gtktreeview.[ch]: Remove the row_draggable_func
	location_dropable_func from gtk_tree_view_set_rows_drag_source/dest.
	and rename them to enable_model_drag_source/dest.

	* gtk/treeviewcolumn.c: Add DND of columns between rows.
	Still can't drop _to_ the left tree, but other places
	work.

	* gtk/gtktreeview.c (unset_reorderable): Unset the
	reorderable property if unset/enable_model_drag_source/dest
	are called manually.

	* gtk/gtktreestore.c (gtk_tree_store_row_drop_possible):
	Correct for change in depth count handling.

	* gtk/gtktreeview.c (gtk_tree_view_create_row_drag_icon):
	Pass in a expose area to gtk_tree_view_column_cell_render()
This commit is contained in:
Owen Taylor
2001-11-06 19:10:03 +00:00
committed by Owen Taylor
parent 9bb17278c4
commit 57479a86be
15 changed files with 638 additions and 215 deletions

View File

@ -83,9 +83,8 @@ static gboolean gtk_tree_store_drag_data_received (GtkTreeDragDest *drag_dest,
GtkTreePath *dest,
GtkSelectionData *selection_data);
static gboolean gtk_tree_store_row_drop_possible (GtkTreeDragDest *drag_dest,
GtkTreeModel *src_model,
GtkTreePath *src_path,
GtkTreePath *dest_path);
GtkTreePath *dest_path,
GtkSelectionData *selection_data);
/* Sortable Interfaces */
@ -1587,45 +1586,55 @@ gtk_tree_store_drag_data_received (GtkTreeDragDest *drag_dest,
}
static gboolean
gtk_tree_store_row_drop_possible (GtkTreeDragDest *drag_dest,
GtkTreeModel *src_model,
GtkTreePath *src_path,
GtkTreePath *dest_path)
gtk_tree_store_row_drop_possible (GtkTreeDragDest *drag_dest,
GtkTreePath *dest_path,
GtkSelectionData *selection_data)
{
GtkTreeModel *src_model = NULL;
GtkTreePath *src_path = NULL;
GtkTreePath *tmp = NULL;
gboolean retval = FALSE;
if (!gtk_tree_get_row_drag_data (selection_data,
&src_model,
&src_path))
goto out;
/* can only drag to ourselves */
if (src_model != GTK_TREE_MODEL (drag_dest))
return FALSE;
goto out;
/* Can't drop into ourself. */
if (gtk_tree_path_is_ancestor (src_path,
dest_path))
return FALSE;
goto out;
/* Can't drop if dest_path's parent doesn't exist */
{
GtkTreeIter iter;
GtkTreePath *tmp = gtk_tree_path_copy (dest_path);
/* if we can't go up, we know the parent exists, the root
* always exists.
*/
if (gtk_tree_path_up (tmp))
if (gtk_tree_path_get_depth (dest_path) > 1)
{
if (!gtk_tree_model_get_iter (GTK_TREE_MODEL (drag_dest),
&iter, tmp))
{
if (tmp)
gtk_tree_path_free (tmp);
return FALSE;
}
tmp = gtk_tree_path_copy (dest_path);
gtk_tree_path_up (tmp);
if (!gtk_tree_model_get_iter (GTK_TREE_MODEL (drag_dest),
&iter, tmp))
goto out;
}
if (tmp)
gtk_tree_path_free (tmp);
}
/* Can otherwise drop anywhere. */
return TRUE;
retval = TRUE;
out:
if (src_path)
gtk_tree_path_free (src_path);
if (tmp)
gtk_tree_path_free (tmp);
return retval;
}
/* Sorting */