handle drops of items of all types from all images and convert them if

2005-01-15  Michael Natterer  <mitch@gimp.org>

	* app/widgets/gimpitemtreeview.c
	(gimp_item_tree_view_drop_viewable): handle drops of items of all
	types from all images and convert them if needed.

	* app/widgets/gimplayertreeview.c: enable dropping of all kinds of
	drawables. Addresses bug #158133.
This commit is contained in:
Michael Natterer 2005-01-15 03:24:42 +00:00 committed by Michael Natterer
parent 6dda0d82a6
commit bb3a6002cf
3 changed files with 27 additions and 8 deletions

View File

@ -1,3 +1,12 @@
2005-01-15 Michael Natterer <mitch@gimp.org>
* app/widgets/gimpitemtreeview.c
(gimp_item_tree_view_drop_viewable): handle drops of items of all
types from all images and convert them if needed.
* app/widgets/gimplayertreeview.c: enable dropping of all kinds of
drawables. Addresses bug #158133.
2005-01-15 Michael Natterer <mitch@gimp.org>
* app/widgets/widgets-enums.h (enum GimpDndType): reordered so

View File

@ -742,34 +742,40 @@ gimp_item_tree_view_drop_viewable (GimpContainerTreeView *tree_view,
GimpItemTreeView *item_view = GIMP_ITEM_TREE_VIEW (tree_view);
GimpItemTreeViewClass *item_view_class;
GimpContainer *container;
gint src_index;
gint dest_index;
container = gimp_container_view_get_container (container_view);
src_index = gimp_container_get_child_index (container,
GIMP_OBJECT (src_viewable));
dest_index = gimp_container_get_child_index (container,
GIMP_OBJECT (dest_viewable));
item_view_class = GIMP_ITEM_TREE_VIEW_GET_CLASS (item_view);
if (item_view->gimage != gimp_item_get_image (GIMP_ITEM (src_viewable)))
if (item_view->gimage != gimp_item_get_image (GIMP_ITEM (src_viewable)) ||
! g_type_is_a (G_TYPE_FROM_INSTANCE (src_viewable),
item_view_class->item_type))
{
GType item_type = item_view_class->item_type;
GimpItem *new_item;
if (g_type_is_a (G_TYPE_FROM_INSTANCE (src_viewable), item_type))
item_type = G_TYPE_FROM_INSTANCE (src_viewable);
if (drop_pos == GTK_TREE_VIEW_DROP_AFTER)
dest_index++;
new_item = gimp_item_convert (GIMP_ITEM (src_viewable),
item_view->gimage,
G_TYPE_FROM_INSTANCE (src_viewable),
TRUE);
item_view->gimage, item_type, TRUE);
item_view_class->add_item (item_view->gimage, new_item, dest_index);
}
else
{
gint src_index;
src_index = gimp_container_get_child_index (container,
GIMP_OBJECT (src_viewable));
if (drop_pos == GTK_TREE_VIEW_DROP_AFTER && src_index > dest_index)
{
dest_index++;

View File

@ -412,6 +412,10 @@ gimp_layer_tree_view_constructor (GType type,
NULL, tree_view);
gimp_dnd_viewable_dest_add (GTK_WIDGET (tree_view->view), GIMP_TYPE_PATTERN,
NULL, tree_view);
gimp_dnd_viewable_dest_add (GTK_WIDGET (tree_view->view), GIMP_TYPE_CHANNEL,
NULL, tree_view);
gimp_dnd_viewable_dest_add (GTK_WIDGET (tree_view->view), GIMP_TYPE_LAYER_MASK,
NULL, tree_view);
/* hide basically useless edit button */
gtk_widget_hide (GIMP_ITEM_TREE_VIEW (layer_view)->edit_button);
@ -655,7 +659,7 @@ gimp_layer_tree_view_drop_possible (GimpContainerTreeView *tree_view,
if (src_type == GIMP_DND_TYPE_URI_LIST ||
src_type == GIMP_DND_TYPE_TEXT_PLAIN ||
src_type == GIMP_DND_TYPE_NETSCAPE_URL ||
GIMP_IS_LAYER (src_viewable))
GIMP_IS_DRAWABLE (src_viewable))
{
GimpLayer *dest_layer = GIMP_LAYER (dest_viewable);
GimpImage *dest_image = gimp_item_get_image (GIMP_ITEM (dest_layer));