diff --git a/app/actions/channels-commands.c b/app/actions/channels-commands.c index 8c7b214060..d4d6854236 100644 --- a/app/actions/channels-commands.c +++ b/app/actions/channels-commands.c @@ -166,7 +166,8 @@ channels_new_last_vals_cmd_callback (GtkAction *action, action_data_get_context (data), GIMP_TRANSPARENT_FILL); - gimp_image_add_channel (image, new_channel, -1, TRUE); + /* FIXME tree */ + gimp_image_add_channel (image, new_channel, NULL, -1, TRUE); gimp_image_undo_group_end (image); @@ -262,7 +263,8 @@ channels_duplicate_cmd_callback (GtkAction *action, G_TYPE_FROM_INSTANCE (channel))); } - gimp_image_add_channel (image, new_channel, -1, TRUE); + /* FIXME tree */ + gimp_image_add_channel (image, new_channel, NULL, -1, TRUE); gimp_image_flush (image); } @@ -356,7 +358,8 @@ channels_new_channel_response (GtkWidget *widget, GIMP_TRANSPARENT_FILL); } - gimp_image_add_channel (options->image, new_channel, -1, TRUE); + /* FIXME tree */ + gimp_image_add_channel (options->image, new_channel, NULL, -1, TRUE); gimp_image_flush (options->image); } diff --git a/app/actions/debug-commands.c b/app/actions/debug-commands.c index ca1e7f0797..c511032398 100644 --- a/app/actions/debug-commands.c +++ b/app/actions/debug-commands.c @@ -364,7 +364,7 @@ debug_show_image_graph (GimpImage *source_image) new_name, 1.0, GIMP_NORMAL_MODE); - gimp_image_add_layer (new_image, layer, 0, FALSE); + gimp_image_add_layer (new_image, layer, NULL, 0, FALSE); gimp_create_display (gimp, new_image, GIMP_UNIT_PIXEL, 1.0); /* Cleanup */ diff --git a/app/actions/edit-commands.c b/app/actions/edit-commands.c index 3a7a09c8c0..50f34640fc 100644 --- a/app/actions/edit-commands.c +++ b/app/actions/edit-commands.c @@ -348,7 +348,8 @@ edit_paste_as_new_layer_cmd_callback (GtkAction *action, GIMP_OPACITY_OPAQUE, GIMP_NORMAL_MODE); g_object_unref (buffer); - gimp_image_add_layer (image, layer, -1, TRUE); + /* FIXME tree */ + gimp_image_add_layer (image, layer, NULL, -1, TRUE); gimp_image_flush (image); } @@ -495,8 +496,9 @@ edit_paste (GimpDisplay *display, if (svg) { + /* FIXME tree */ if (gimp_vectors_import_buffer (display->image, svg, svg_size, - TRUE, TRUE, -1, NULL, NULL)) + TRUE, TRUE, NULL, -1, NULL, NULL)) { gimp_image_flush (display->image); } diff --git a/app/actions/layers-commands.c b/app/actions/layers-commands.c index f1bac828bf..bb6caa7a10 100644 --- a/app/actions/layers-commands.c +++ b/app/actions/layers-commands.c @@ -329,7 +329,8 @@ layers_new_last_vals_cmd_callback (GtkAction *action, layer_fill_type); gimp_item_translate (GIMP_ITEM (new_layer), off_x, off_y, FALSE); - gimp_image_add_layer (image, new_layer, -1, TRUE); + /* FIXME tree */ + gimp_image_add_layer (image, new_layer, NULL, -1, TRUE); gimp_image_undo_group_end (image); @@ -352,7 +353,8 @@ layers_new_from_visible_cmd_callback (GtkAction *action, gimp_image_base_type_with_alpha (image), _("Visible"), GIMP_OPACITY_OPAQUE, GIMP_NORMAL_MODE); - gimp_image_add_layer (image, layer, -1, TRUE); + /* FIXME tree */ + gimp_image_add_layer (image, layer, NULL, -1, TRUE); gimp_image_flush (image); } @@ -445,7 +447,8 @@ layers_duplicate_cmd_callback (GtkAction *action, new_layer = GIMP_LAYER (gimp_item_duplicate (GIMP_ITEM (layer), G_TYPE_FROM_INSTANCE (layer))); - gimp_image_add_layer (image, new_layer, -1, TRUE); + /* FIXME tree */ + gimp_image_add_layer (image, new_layer, NULL, -1, TRUE); gimp_image_flush (image); } @@ -520,8 +523,8 @@ layers_text_to_vectors_cmd_callback (GtkAction *action, gimp_item_get_offset (GIMP_ITEM (layer), &x, &y); gimp_item_translate (GIMP_ITEM (vectors), x, y, FALSE); - gimp_image_add_vectors (image, vectors, -1, TRUE); - gimp_image_set_active_vectors (image, vectors); + /* FIXME tree */ + gimp_image_add_vectors (image, vectors, NULL, -1, TRUE); gimp_image_flush (image); } @@ -548,8 +551,8 @@ layers_text_along_vectors_cmd_callback (GtkAction *action, gimp_item_set_visible (GIMP_ITEM (new_vectors), TRUE, FALSE); - gimp_image_add_vectors (image, new_vectors, -1, TRUE); - gimp_image_set_active_vectors (image, new_vectors); + /* FIXME tree */ + gimp_image_add_vectors (image, new_vectors, NULL, -1, TRUE); gimp_image_flush (image); } @@ -965,7 +968,8 @@ layers_new_layer_response (GtkWidget *widget, gimp_drawable_fill_by_type (GIMP_DRAWABLE (layer), dialog->context, layer_fill_type); - gimp_image_add_layer (dialog->image, layer, -1, TRUE); + /* FIXME tree */ + gimp_image_add_layer (dialog->image, layer, NULL, -1, TRUE); gimp_image_flush (dialog->image); } diff --git a/app/actions/vectors-commands.c b/app/actions/vectors-commands.c index 837f0de8c2..636c3f936d 100644 --- a/app/actions/vectors-commands.c +++ b/app/actions/vectors-commands.c @@ -187,7 +187,8 @@ vectors_new_last_vals_cmd_callback (GtkAction *action, new_vectors = gimp_vectors_new (image, vectors_name ? vectors_name : _("New Path")); - gimp_image_add_vectors (image, new_vectors, -1, TRUE); + /* FIXME tree */ + gimp_image_add_vectors (image, new_vectors, NULL, -1, TRUE); gimp_image_flush (image); } @@ -251,7 +252,8 @@ vectors_duplicate_cmd_callback (GtkAction *action, new_vectors = GIMP_VECTORS (gimp_item_duplicate (GIMP_ITEM (vectors), G_TYPE_FROM_INSTANCE (vectors))); - gimp_image_add_vectors (image, new_vectors, -1, TRUE); + /* FIXME tree */ + gimp_image_add_vectors (image, new_vectors, NULL, -1, TRUE); gimp_image_flush (image); } @@ -476,8 +478,9 @@ vectors_paste_cmd_callback (GtkAction *action, { GError *error = NULL; + /* FIXME tree */ if (! gimp_vectors_import_buffer (image, svg, svg_size, - TRUE, TRUE, -1, NULL, &error)) + TRUE, TRUE, NULL, -1, NULL, &error)) { gimp_message (image->gimp, G_OBJECT (widget), GIMP_MESSAGE_ERROR, "%s", error->message); @@ -622,7 +625,8 @@ vectors_new_vectors_response (GtkWidget *widget, new_vectors = gimp_vectors_new (options->image, vectors_name); - gimp_image_add_vectors (options->image, new_vectors, -1, TRUE); + /* FIXME tree */ + gimp_image_add_vectors (options->image, new_vectors, NULL, -1, TRUE); gimp_image_flush (options->image); } @@ -668,9 +672,10 @@ vectors_import_response (GtkWidget *widget, filename = gtk_file_chooser_get_filename (chooser); + /* FIXME tree */ if (gimp_vectors_import_file (dialog->image, filename, vectors_import_merge, vectors_import_scale, - -1, NULL, &error)) + NULL, -1, NULL, &error)) { gimp_image_flush (dialog->image); } diff --git a/app/core/gimp-edit.c b/app/core/gimp-edit.c index 4de1733d81..7ab271912e 100644 --- a/app/core/gimp-edit.c +++ b/app/core/gimp-edit.c @@ -270,7 +270,7 @@ gimp_edit_paste (GimpImage *image, if (drawable) floating_sel_attach (layer, drawable); else - gimp_image_add_layer (image, layer, 0, TRUE); + gimp_image_add_layer (image, layer, NULL, 0, TRUE); /* end the group undo */ gimp_image_undo_group_end (image); @@ -330,7 +330,7 @@ gimp_edit_paste_as_new (Gimp *gimp, return NULL; } - gimp_image_add_layer (image, layer, 0, TRUE); + gimp_image_add_layer (image, layer, NULL, 0, TRUE); gimp_image_undo_enable (image); diff --git a/app/core/gimpchannelundo.c b/app/core/gimpchannelundo.c index 1a8114cdec..8cd2ecddd0 100644 --- a/app/core/gimpchannelundo.c +++ b/app/core/gimpchannelundo.c @@ -29,6 +29,7 @@ enum { PROP_0, + PROP_PREV_PARENT, PROP_PREV_POSITION, PROP_PREV_CHANNEL }; @@ -74,14 +75,23 @@ gimp_channel_undo_class_init (GimpChannelUndoClass *klass) undo_class->pop = gimp_channel_undo_pop; + g_object_class_install_property (object_class, PROP_PREV_PARENT, + g_param_spec_object ("prev-parent", + NULL, NULL, + GIMP_TYPE_CHANNEL, + GIMP_PARAM_READWRITE | + G_PARAM_CONSTRUCT_ONLY)); + g_object_class_install_property (object_class, PROP_PREV_POSITION, - g_param_spec_int ("prev-position", NULL, NULL, + g_param_spec_int ("prev-position", + NULL, NULL, 0, G_MAXINT, 0, GIMP_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)); g_object_class_install_property (object_class, PROP_PREV_CHANNEL, - g_param_spec_object ("prev-channel", NULL, NULL, + g_param_spec_object ("prev-channel", + NULL, NULL, GIMP_TYPE_CHANNEL, GIMP_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)); @@ -119,6 +129,9 @@ gimp_channel_undo_set_property (GObject *object, switch (property_id) { + case PROP_PREV_PARENT: + channel_undo->prev_parent = g_value_get_object (value); + break; case PROP_PREV_POSITION: channel_undo->prev_position = g_value_get_int (value); break; @@ -142,6 +155,9 @@ gimp_channel_undo_get_property (GObject *object, switch (property_id) { + case PROP_PREV_PARENT: + g_value_set_object (value, channel_undo->prev_parent); + break; case PROP_PREV_POSITION: g_value_set_int (value, channel_undo->prev_position); break; @@ -187,7 +203,10 @@ gimp_channel_undo_pop (GimpUndo *undo, { /* remove channel */ - /* record the current position */ + /* record the current parent and position */ + channel_undo->prev_parent = + GIMP_CHANNEL (gimp_viewable_get_parent (GIMP_VIEWABLE (channel))); + channel_undo->prev_position = gimp_item_get_index (GIMP_ITEM (channel)); gimp_image_remove_channel (undo->image, channel, FALSE, @@ -201,6 +220,7 @@ gimp_channel_undo_pop (GimpUndo *undo, channel_undo->prev_channel = gimp_image_get_active_channel (undo->image); gimp_image_add_channel (undo->image, channel, + channel_undo->prev_parent, channel_undo->prev_position, FALSE); GIMP_ITEM (channel)->removed = FALSE; diff --git a/app/core/gimpchannelundo.h b/app/core/gimpchannelundo.h index ddbe14599b..8801f29df0 100644 --- a/app/core/gimpchannelundo.h +++ b/app/core/gimpchannelundo.h @@ -36,6 +36,7 @@ struct _GimpChannelUndo { GimpItemUndo parent_instance; + GimpChannel *prev_parent; gint prev_position; /* former position in list */ GimpChannel *prev_channel; /* previous active channel */ }; diff --git a/app/core/gimpimage-duplicate.c b/app/core/gimpimage-duplicate.c index d802e747d0..b3099ff210 100644 --- a/app/core/gimpimage-duplicate.c +++ b/app/core/gimpimage-duplicate.c @@ -225,6 +225,9 @@ gimp_image_duplicate_layers (GimpImage *image, new_image, G_TYPE_FROM_INSTANCE (layer))); + g_object_set_data (G_OBJECT (layer), "gimp-image-duplicate-item", + new_layer); + /* Make sure the copied layer doesn't say: " copy" */ gimp_object_set_name (GIMP_OBJECT (new_layer), gimp_object_get_name (GIMP_OBJECT (layer))); @@ -246,9 +249,24 @@ gimp_image_duplicate_layers (GimpImage *image, *new_floating_sel_drawable = GIMP_DRAWABLE (new_layer); if (*floating_layer != new_layer) - gimp_image_add_layer (new_image, new_layer, count++, FALSE); + { + GimpViewable *parent; + GimpLayer *new_parent = NULL; + + parent = gimp_viewable_get_parent (GIMP_VIEWABLE (layer)); + + if (parent) + new_parent = g_object_get_data (G_OBJECT (parent), + "gimp-image-duplicate-item"); + + gimp_image_add_layer (new_image, new_layer, + new_parent, count++, FALSE); + } } + for (list = all_layers; list; list = g_list_next (list)) + g_object_set_data (list->data, "gimp-image-duplicate-item", NULL); + g_list_free (all_layers); return active_layer; @@ -271,13 +289,18 @@ gimp_image_duplicate_channels (GimpImage *image, list; list = g_list_next (list)) { - GimpChannel *channel = list->data; - GimpChannel *new_channel; + GimpChannel *channel = list->data; + GimpChannel *new_channel; + GimpViewable *parent; + GimpChannel *new_parent = NULL; new_channel = GIMP_CHANNEL (gimp_item_convert (GIMP_ITEM (channel), new_image, G_TYPE_FROM_INSTANCE (channel))); + g_object_set_data (G_OBJECT (channel), "gimp-image-duplicate-item", + new_channel); + /* Make sure the copied channel doesn't say: " copy" */ gimp_object_set_name (GIMP_OBJECT (new_channel), gimp_object_get_name (GIMP_OBJECT (channel))); @@ -288,9 +311,19 @@ gimp_image_duplicate_channels (GimpImage *image, if (floating_sel_drawable == GIMP_DRAWABLE (channel)) *new_floating_sel_drawable = GIMP_DRAWABLE (new_channel); - gimp_image_add_channel (new_image, new_channel, count++, FALSE); + parent = gimp_viewable_get_parent (GIMP_VIEWABLE (channel)); + + if (parent) + new_parent = g_object_get_data (G_OBJECT (parent), + "gimp-image-duplicate-item"); + + gimp_image_add_channel (new_image, new_channel, + new_parent, count++, FALSE); } + for (list = all_channels; list; list = g_list_next (list)) + g_object_set_data (list->data, "gimp-image-duplicate-item", NULL); + g_list_free (all_channels); return active_channel; @@ -311,13 +344,18 @@ gimp_image_duplicate_vectors (GimpImage *image, list; list = g_list_next (list)) { - GimpVectors *vectors = list->data; - GimpVectors *new_vectors; + GimpVectors *vectors = list->data; + GimpVectors *new_vectors; + GimpViewable *parent; + GimpVectors *new_parent = NULL; new_vectors = GIMP_VECTORS (gimp_item_convert (GIMP_ITEM (vectors), new_image, G_TYPE_FROM_INSTANCE (vectors))); + g_object_set_data (G_OBJECT (vectors), "gimp-image-duplicate-item", + new_vectors); + /* Make sure the copied vectors doesn't say: " copy" */ gimp_object_set_name (GIMP_OBJECT (new_vectors), gimp_object_get_name (GIMP_OBJECT (vectors))); @@ -325,9 +363,19 @@ gimp_image_duplicate_vectors (GimpImage *image, if (gimp_image_get_active_vectors (image) == vectors) active_vectors = new_vectors; - gimp_image_add_vectors (new_image, new_vectors, count++, FALSE); + parent = gimp_viewable_get_parent (GIMP_VIEWABLE (vectors)); + + if (parent) + new_parent = g_object_get_data (G_OBJECT (parent), + "gimp-image-duplicate-item"); + + gimp_image_add_vectors (new_image, new_vectors, + new_parent, count++, FALSE); } + for (list = all_vectors; list; list = g_list_next (list)) + g_object_set_data (list->data, "gimp-image-duplicate-item", NULL); + g_list_free (all_vectors); return active_vectors; diff --git a/app/core/gimpimage-merge.c b/app/core/gimpimage-merge.c index c71a47454b..55065e5297 100644 --- a/app/core/gimpimage-merge.c +++ b/app/core/gimpimage-merge.c @@ -276,7 +276,8 @@ gimp_image_merge_visible_vectors (GimpImage *image, g_slist_free (merge_list); - gimp_image_add_vectors (image, target_vectors, pos, TRUE); + /* FIXME tree */ + gimp_image_add_vectors (image, target_vectors, NULL, pos, TRUE); gimp_unset_busy (image->gimp); gimp_image_undo_group_end (image); @@ -591,14 +592,17 @@ gimp_image_merge_layers (GimpImage *image, gimp_image_remove_layer (image, layer, TRUE, NULL); } - gimp_image_add_layer (image, merge_layer, position, TRUE); + /* FIXME tree */ + gimp_image_add_layer (image, merge_layer, NULL, position, TRUE); } else { /* Add the layer to the image */ + + /* FIXME tree */ gimp_image_add_layer (image, merge_layer, - gimp_container_get_n_children (image->layers) - position + 1, + NULL, gimp_container_get_n_children (image->layers) - position + 1, TRUE); } diff --git a/app/core/gimpimage-quick-mask.c b/app/core/gimpimage-quick-mask.c index 9f746e0f32..8179c5db63 100644 --- a/app/core/gimpimage-quick-mask.c +++ b/app/core/gimpimage-quick-mask.c @@ -116,7 +116,7 @@ gimp_image_set_quick_mask_state (GimpImage *image, if (image->quick_mask_inverted) gimp_channel_invert (mask, FALSE); - gimp_image_add_channel (image, mask, 0, TRUE); + gimp_image_add_channel (image, mask, NULL, 0, TRUE); gimp_image_undo_group_end (image); } diff --git a/app/core/gimpimage-undo-push.c b/app/core/gimpimage-undo-push.c index c7f0900204..bb5b55ebc6 100644 --- a/app/core/gimpimage-undo-push.c +++ b/app/core/gimpimage-undo-push.c @@ -427,12 +427,15 @@ GimpUndo * gimp_image_undo_push_layer_remove (GimpImage *image, const gchar *undo_desc, GimpLayer *layer, + GimpLayer *prev_parent, gint prev_position, GimpLayer *prev_layer) { g_return_val_if_fail (GIMP_IS_IMAGE (image), NULL); g_return_val_if_fail (GIMP_IS_LAYER (layer), NULL); g_return_val_if_fail (gimp_item_is_attached (GIMP_ITEM (layer)), NULL); + g_return_val_if_fail (prev_parent == NULL || GIMP_IS_LAYER (prev_parent), + NULL); g_return_val_if_fail (prev_layer == NULL || GIMP_IS_LAYER (prev_layer), NULL); @@ -440,6 +443,7 @@ gimp_image_undo_push_layer_remove (GimpImage *image, GIMP_UNDO_LAYER_REMOVE, undo_desc, GIMP_DIRTY_IMAGE_STRUCTURE, "item", layer, + "prev-parent", prev_parent, "prev-position", prev_position, "prev-layer", prev_layer, NULL); @@ -656,12 +660,15 @@ GimpUndo * gimp_image_undo_push_channel_remove (GimpImage *image, const gchar *undo_desc, GimpChannel *channel, + GimpChannel *prev_parent, gint prev_position, GimpChannel *prev_channel) { g_return_val_if_fail (GIMP_IS_IMAGE (image), NULL); g_return_val_if_fail (GIMP_IS_CHANNEL (channel), NULL); g_return_val_if_fail (gimp_item_is_attached (GIMP_ITEM (channel)), NULL); + g_return_val_if_fail (prev_parent == NULL || GIMP_IS_CHANNEL (prev_parent), + NULL); g_return_val_if_fail (prev_channel == NULL || GIMP_IS_CHANNEL (prev_channel), NULL); @@ -669,6 +676,7 @@ gimp_image_undo_push_channel_remove (GimpImage *image, GIMP_UNDO_CHANNEL_REMOVE, undo_desc, GIMP_DIRTY_IMAGE_STRUCTURE, "item", channel, + "prev-parent", prev_parent, "prev-position", prev_position, "prev-channel", prev_channel, NULL); @@ -735,12 +743,15 @@ GimpUndo * gimp_image_undo_push_vectors_remove (GimpImage *image, const gchar *undo_desc, GimpVectors *vectors, + GimpVectors *prev_parent, gint prev_position, GimpVectors *prev_vectors) { g_return_val_if_fail (GIMP_IS_IMAGE (image), NULL); g_return_val_if_fail (GIMP_IS_VECTORS (vectors), NULL); g_return_val_if_fail (gimp_item_is_attached (GIMP_ITEM (vectors)), NULL); + g_return_val_if_fail (prev_parent == NULL || GIMP_IS_VECTORS (prev_parent), + NULL); g_return_val_if_fail (prev_vectors == NULL || GIMP_IS_VECTORS (prev_vectors), NULL); @@ -748,6 +759,7 @@ gimp_image_undo_push_vectors_remove (GimpImage *image, GIMP_UNDO_VECTORS_REMOVE, undo_desc, GIMP_DIRTY_IMAGE_STRUCTURE, "item", vectors, + "prev-parent", prev_parent, "prev-position", prev_position, "prev-vectors", prev_vectors, NULL); diff --git a/app/core/gimpimage-undo-push.h b/app/core/gimpimage-undo-push.h index 99bfe22782..16247e1537 100644 --- a/app/core/gimpimage-undo-push.h +++ b/app/core/gimpimage-undo-push.h @@ -111,6 +111,7 @@ GimpUndo * gimp_image_undo_push_layer_add (GimpImage *image, GimpUndo * gimp_image_undo_push_layer_remove (GimpImage *image, const gchar *undo_desc, GimpLayer *layer, + GimpLayer *prev_parent, gint prev_position, GimpLayer *prev_layer); GimpUndo * gimp_image_undo_push_layer_reposition (GimpImage *image, @@ -165,6 +166,7 @@ GimpUndo * gimp_image_undo_push_channel_add (GimpImage *image, GimpUndo * gimp_image_undo_push_channel_remove (GimpImage *image, const gchar *undo_desc, GimpChannel *channel, + GimpChannel *prev_parent, gint prev_position, GimpChannel *prev_channel); GimpUndo * gimp_image_undo_push_channel_reposition (GimpImage *image, @@ -183,7 +185,8 @@ GimpUndo * gimp_image_undo_push_vectors_add (GimpImage *image, GimpVectors *prev_vectors); GimpUndo * gimp_image_undo_push_vectors_remove (GimpImage *image, const gchar *undo_desc, - GimpVectors *channel, + GimpVectors *vectors, + GimpVectors *prev_parent, gint prev_position, GimpVectors *prev_vectors); GimpUndo * gimp_image_undo_push_vectors_mod (GimpImage *image, diff --git a/app/core/gimpimage.c b/app/core/gimpimage.c index c4e6a2e3f5..18e49053c5 100644 --- a/app/core/gimpimage.c +++ b/app/core/gimpimage.c @@ -2949,10 +2949,10 @@ gimp_image_get_vectors_by_name (const GimpImage *image, gboolean gimp_image_add_layer (GimpImage *image, GimpLayer *layer, + GimpLayer *parent, gint position, gboolean push_undo) { - GimpLayer *parent = NULL; GimpLayer *active_layer; GimpContainer *container; GimpLayer *floating_sel; @@ -3085,8 +3085,8 @@ gimp_image_remove_layer (GimpImage *image, } if (push_undo) - gimp_image_undo_push_layer_remove (image, undo_desc, - layer, index, active_layer); + gimp_image_undo_push_layer_remove (image, undo_desc, layer, + parent, index, active_layer); g_object_ref (layer); @@ -3155,6 +3155,7 @@ gimp_image_remove_layer (GimpImage *image, void gimp_image_add_layers (GimpImage *image, GList *layers, + GimpLayer *parent, gint position, gint x, gint y, @@ -3172,14 +3173,30 @@ gimp_image_add_layers (GimpImage *image, g_return_if_fail (GIMP_IS_IMAGE (image)); g_return_if_fail (layers != NULL); + g_return_if_fail (parent == NULL || GIMP_IS_LAYER (parent)); + g_return_if_fail (parent == NULL || + gimp_item_is_attached (GIMP_ITEM (parent))); + g_return_if_fail (parent == NULL || + gimp_item_get_image (GIMP_ITEM (parent)) == image); if (position == -1) { GimpLayer *active_layer = gimp_image_get_active_layer (image); if (active_layer) - position = gimp_item_get_index (GIMP_ITEM (active_layer)); - else + { + GimpContainer *container; + + if (parent) + container = gimp_viewable_get_children (GIMP_VIEWABLE (parent)); + else + container = image->layers; + + position = gimp_container_get_child_index (container, + GIMP_OBJECT (active_layer)); + } + + if (position == -1) position = 0; } @@ -3210,7 +3227,8 @@ gimp_image_add_layers (GimpImage *image, gimp_item_translate (new_item, offset_x, offset_y, FALSE); - gimp_image_add_layer (image, GIMP_LAYER (new_item), position, TRUE); + gimp_image_add_layer (image, GIMP_LAYER (new_item), + parent, position, TRUE); position++; } @@ -3338,10 +3356,10 @@ gimp_image_position_layer (GimpImage *image, gboolean gimp_image_add_channel (GimpImage *image, GimpChannel *channel, + GimpChannel *parent, gint position, gboolean push_undo) { - GimpVectors *parent = NULL; GimpChannel *active_channel; GimpContainer *container; @@ -3438,8 +3456,8 @@ gimp_image_remove_channel (GimpImage *image, index = gimp_item_get_index (GIMP_ITEM (channel)); if (push_undo) - gimp_image_undo_push_channel_remove (image, _("Remove Channel"), - channel, index, active_channel); + gimp_image_undo_push_channel_remove (image, _("Remove Channel"), channel, + parent, index, active_channel); g_object_ref (channel); @@ -3610,10 +3628,10 @@ gimp_image_position_channel (GimpImage *image, gboolean gimp_image_add_vectors (GimpImage *image, GimpVectors *vectors, + GimpVectors *parent, gint position, gboolean push_undo) { - GimpVectors *parent = NULL; GimpVectors *active_vectors; GimpContainer *container; @@ -3691,8 +3709,8 @@ gimp_image_remove_vectors (GimpImage *image, index = gimp_item_get_index (GIMP_ITEM (vectors)); if (push_undo) - gimp_image_undo_push_vectors_remove (image, _("Remove Path"), - vectors, index, active_vectors); + gimp_image_undo_push_vectors_remove (image, _("Remove Path"), vectors, + parent, index, active_vectors); g_object_ref (vectors); diff --git a/app/core/gimpimage.h b/app/core/gimpimage.h index 32110b3ef7..13cd1f63a7 100644 --- a/app/core/gimpimage.h +++ b/app/core/gimpimage.h @@ -462,6 +462,7 @@ GimpVectors * gimp_image_get_vectors_by_name (const GimpImage *image, gboolean gimp_image_add_layer (GimpImage *image, GimpLayer *layer, + GimpLayer *parent, gint position, gboolean push_undo); void gimp_image_remove_layer (GimpImage *image, @@ -471,6 +472,7 @@ void gimp_image_remove_layer (GimpImage *image, void gimp_image_add_layers (GimpImage *image, GList *layers, + GimpLayer *parent, gint position, gint x, gint y, @@ -496,6 +498,7 @@ gboolean gimp_image_position_layer (GimpImage *image, gboolean gimp_image_add_channel (GimpImage *image, GimpChannel *channel, + GimpChannel *parent, gint position, gboolean push_undo); void gimp_image_remove_channel (GimpImage *image, @@ -521,6 +524,7 @@ gboolean gimp_image_position_channel (GimpImage *image, gboolean gimp_image_add_vectors (GimpImage *image, GimpVectors *vectors, + GimpVectors *parent, gint position, gboolean push_undo); void gimp_image_remove_vectors (GimpImage *image, diff --git a/app/core/gimplayer-floating-sel.c b/app/core/gimplayer-floating-sel.c index 6e5c1fbd5c..7b3e1694d1 100644 --- a/app/core/gimplayer-floating-sel.c +++ b/app/core/gimplayer-floating-sel.c @@ -80,7 +80,7 @@ floating_sel_attach (GimpLayer *layer, gimp_layer_set_floating_sel_drawable (layer, drawable); /* add the layer to the image */ - gimp_image_add_layer (image, layer, 0, TRUE); + gimp_image_add_layer (image, layer, NULL, 0, TRUE); } void diff --git a/app/core/gimplayerundo.c b/app/core/gimplayerundo.c index 31502f4927..779adc6504 100644 --- a/app/core/gimplayerundo.c +++ b/app/core/gimplayerundo.c @@ -29,6 +29,7 @@ enum { PROP_0, + PROP_PREV_PARENT, PROP_PREV_POSITION, PROP_PREV_LAYER }; @@ -74,6 +75,13 @@ gimp_layer_undo_class_init (GimpLayerUndoClass *klass) undo_class->pop = gimp_layer_undo_pop; + g_object_class_install_property (object_class, PROP_PREV_PARENT, + g_param_spec_object ("prev-parent", + NULL, NULL, + GIMP_TYPE_LAYER, + GIMP_PARAM_READWRITE | + G_PARAM_CONSTRUCT_ONLY)); + g_object_class_install_property (object_class, PROP_PREV_POSITION, g_param_spec_int ("prev-position", NULL, NULL, 0, G_MAXINT, 0, @@ -119,6 +127,9 @@ gimp_layer_undo_set_property (GObject *object, switch (property_id) { + case PROP_PREV_PARENT: + layer_undo->prev_parent = g_value_get_object (value); + break; case PROP_PREV_POSITION: layer_undo->prev_position = g_value_get_int (value); break; @@ -142,6 +153,9 @@ gimp_layer_undo_get_property (GObject *object, switch (property_id) { + case PROP_PREV_PARENT: + g_value_set_object (value, layer_undo->prev_parent); + break; case PROP_PREV_POSITION: g_value_set_int (value, layer_undo->prev_position); break; @@ -187,7 +201,10 @@ gimp_layer_undo_pop (GimpUndo *undo, { /* remove layer */ - /* record the current position */ + /* record the current parent and position */ + layer_undo->prev_parent = + GIMP_LAYER (gimp_viewable_get_parent (GIMP_VIEWABLE (layer))); + layer_undo->prev_position = gimp_item_get_index (GIMP_ITEM (layer)); gimp_image_remove_layer (undo->image, layer, FALSE, @@ -201,6 +218,7 @@ gimp_layer_undo_pop (GimpUndo *undo, layer_undo->prev_layer = gimp_image_get_active_layer (undo->image); gimp_image_add_layer (undo->image, layer, + layer_undo->prev_parent, layer_undo->prev_position, FALSE); GIMP_ITEM (layer)->removed = FALSE; diff --git a/app/core/gimplayerundo.h b/app/core/gimplayerundo.h index 4bf8dddb71..0d741e2285 100644 --- a/app/core/gimplayerundo.h +++ b/app/core/gimplayerundo.h @@ -36,6 +36,7 @@ struct _GimpLayerUndo { GimpItemUndo parent_instance; + GimpLayer *prev_parent; gint prev_position; /* former position in list */ GimpLayer *prev_layer; /* previous active layer */ }; diff --git a/app/core/gimpselection.c b/app/core/gimpselection.c index d4a824a257..07009b0333 100644 --- a/app/core/gimpselection.c +++ b/app/core/gimpselection.c @@ -615,7 +615,8 @@ gimp_selection_save (GimpSelection *selection) /* saved selections are not visible by default */ gimp_item_set_visible (GIMP_ITEM (new_channel), FALSE, FALSE); - gimp_image_add_channel (image, new_channel, -1, TRUE); + /* FIXME tree */ + gimp_image_add_channel (image, new_channel, NULL, -1, TRUE); return new_channel; } diff --git a/app/core/gimptemplate.c b/app/core/gimptemplate.c index 7a676ffdc7..e887a9a4d4 100644 --- a/app/core/gimptemplate.c +++ b/app/core/gimptemplate.c @@ -407,7 +407,7 @@ gimp_template_create_image (Gimp *gimp, gimp_drawable_fill_by_type (GIMP_DRAWABLE (layer), context, template->fill_type); - gimp_image_add_layer (image, layer, 0, FALSE); + gimp_image_add_layer (image, layer, NULL, 0, FALSE); gimp_image_undo_enable (image); gimp_image_clean_all (image); diff --git a/app/dialogs/file-open-dialog.c b/app/dialogs/file-open-dialog.c index e523c84767..5e7852ef57 100644 --- a/app/dialogs/file-open-dialog.c +++ b/app/dialogs/file-open-dialog.c @@ -247,7 +247,8 @@ file_open_dialog_open_layers (GtkWidget *open_dialog, if (new_layers) { - gimp_image_add_layers (image, new_layers, -1, + /* FIXME tree */ + gimp_image_add_layers (image, new_layers, NULL, -1, 0, 0, gimp_image_get_width (image), gimp_image_get_height (image), diff --git a/app/display/gimpdisplayshell-dnd.c b/app/display/gimpdisplayshell-dnd.c index 545a8d614d..247158cfcb 100644 --- a/app/display/gimpdisplayshell-dnd.c +++ b/app/display/gimpdisplayshell-dnd.c @@ -260,7 +260,8 @@ gimp_display_shell_drop_drawable (GtkWidget *widget, gimp_item_set_visible (new_item, TRUE, FALSE); gimp_item_set_linked (new_item, FALSE, FALSE); - gimp_image_add_layer (image, new_layer, -1, TRUE); + /* FIXME tree */ + gimp_image_add_layer (image, new_layer, NULL, -1, TRUE); gimp_image_undo_group_end (image); @@ -300,7 +301,8 @@ gimp_display_shell_drop_vectors (GtkWidget *widget, gimp_image_undo_group_start (image, GIMP_UNDO_GROUP_EDIT_PASTE, _("Drop New Path")); - gimp_image_add_vectors (image, new_vectors, -1, TRUE); + /* FIXME tree */ + gimp_image_add_vectors (image, new_vectors, NULL, -1, TRUE); gimp_image_undo_group_end (image); @@ -328,9 +330,10 @@ gimp_display_shell_drop_svg (GtkWidget *widget, if (! image) return; + /* FIXME tree */ if (! gimp_vectors_import_buffer (image, (const gchar *) svg_data, svg_data_len, - TRUE, TRUE, -1, NULL, &error)) + TRUE, TRUE, NULL, -1, NULL, &error)) { gimp_message_literal (shell->display->gimp, G_OBJECT (shell->display), GIMP_MESSAGE_ERROR, @@ -492,7 +495,8 @@ gimp_display_shell_drop_uri_list (GtkWidget *widget, gimp_display_shell_untransform_viewport (shell, &x, &y, &width, &height); - gimp_image_add_layers (image, new_layers, -1, + /* FIXME tree */ + gimp_image_add_layers (image, new_layers, NULL, -1, x, y, width, height, _("Drop layers")); @@ -588,7 +592,8 @@ gimp_display_shell_drop_component (GtkWidget *widget, gimp_display_shell_dnd_position_item (shell, new_item); - gimp_image_add_layer (dest_image, new_layer, -1, TRUE); + /* FIXME tree */ + gimp_image_add_layer (dest_image, new_layer, NULL, -1, TRUE); gimp_image_undo_group_end (dest_image); @@ -660,7 +665,8 @@ gimp_display_shell_drop_pixbuf (GtkWidget *widget, if (! new_image) gimp_display_shell_dnd_position_item (shell, new_item); - gimp_image_add_layer (image, new_layer, -1, TRUE); + /* FIXME tree */ + gimp_image_add_layer (image, new_layer, NULL, -1, TRUE); gimp_image_undo_group_end (image); diff --git a/app/pdb/image-cmds.c b/app/pdb/image-cmds.c index 1342c8c758..c57b0414d6 100644 --- a/app/pdb/image-cmds.c +++ b/app/pdb/image-cmds.c @@ -914,7 +914,9 @@ image_add_layer_invoker (GimpProcedure *procedure, GIMP_IMAGE_TYPE_BASE_TYPE (gimp_drawable_type (GIMP_DRAWABLE (layer))), error)) { - success = gimp_image_add_layer (image, layer, MAX (position, -1), TRUE); + /* FIXME tree */ + success = gimp_image_add_layer (image, layer, + NULL, MAX (position, -1), TRUE); } else { @@ -1104,7 +1106,9 @@ image_add_channel_invoker (GimpProcedure *procedure, { if (gimp_pdb_item_is_floating (GIMP_ITEM (channel), image, error)) { - success = gimp_image_add_channel (image, channel, MAX (position, -1), TRUE); + /* FIXME tree */ + success = gimp_image_add_channel (image, channel, + NULL, MAX (position, -1), TRUE); } else { @@ -1246,7 +1250,9 @@ image_add_vectors_invoker (GimpProcedure *procedure, { if (gimp_pdb_item_is_floating (GIMP_ITEM (vectors), image, error)) { - success = gimp_image_add_vectors (image, vectors, MAX (position, -1), TRUE); + /* FIXME tree */ + success = gimp_image_add_vectors (image, vectors, + NULL, MAX (position, -1), TRUE); } else { diff --git a/app/pdb/paths-cmds.c b/app/pdb/paths-cmds.c index 18ecb96d6c..758caa7b25 100644 --- a/app/pdb/paths-cmds.c +++ b/app/pdb/paths-cmds.c @@ -302,7 +302,7 @@ path_set_points_invoker (GimpProcedure *procedure, g_free (points); if (vectors) - success = gimp_image_add_vectors (image, vectors, 0, TRUE); + success = gimp_image_add_vectors (image, vectors, NULL, 0, TRUE); else success = FALSE; } @@ -676,7 +676,7 @@ path_import_invoker (GimpProcedure *procedure, if (success) { success = gimp_vectors_import_file (image, filename, - merge, scale, -1, NULL, NULL); + merge, scale, NULL, -1, NULL, NULL); } return gimp_procedure_get_return_values (procedure, success, diff --git a/app/pdb/vectors-cmds.c b/app/pdb/vectors-cmds.c index 888fd6307b..87d84cc6be 100644 --- a/app/pdb/vectors-cmds.c +++ b/app/pdb/vectors-cmds.c @@ -1291,8 +1291,10 @@ vectors_import_from_file_invoker (GimpProcedure *procedure, { GList *list, *vectors_list = NULL; + /* FIXME tree */ success = gimp_vectors_import_file (image, filename, - merge, scale, -1, &vectors_list, error); + merge, scale, NULL, -1, + &vectors_list, error); if (success) { @@ -1353,8 +1355,10 @@ vectors_import_from_string_invoker (GimpProcedure *procedure, { GList *list, *vectors_list = NULL; + /* FIXME tree */ success = gimp_vectors_import_buffer (image, string, length, - merge, scale, -1, &vectors_list, error); + merge, scale, NULL, -1, + &vectors_list, error); if (success) { diff --git a/app/text/gimptext-compat.c b/app/text/gimptext-compat.c index 135e198529..8f01a55603 100644 --- a/app/text/gimptext-compat.c +++ b/app/text/gimptext-compat.c @@ -119,7 +119,7 @@ text_render (GimpImage *image, if (drawable == NULL) { /* If the drawable is NULL, create a new layer */ - gimp_image_add_layer (image, layer, -1, TRUE); + gimp_image_add_layer (image, layer, NULL, -1, TRUE); } else { diff --git a/app/tools/gimptexttool.c b/app/tools/gimptexttool.c index dbfcc3822d..d12a6b068b 100644 --- a/app/tools/gimptexttool.c +++ b/app/tools/gimptexttool.c @@ -2173,7 +2173,8 @@ gimp_text_tool_create_layer (GimpTextTool *text_tool, gimp_item_set_offset (GIMP_ITEM (layer), x1, y1); - gimp_image_add_layer (image, layer, -1, TRUE); + /* FIXME tree */ + gimp_image_add_layer (image, layer, NULL, -1, TRUE); if (text_tool->text_box_fixed) { @@ -2790,7 +2791,8 @@ gimp_text_tool_create_vectors (GimpTextTool *text_tool) gimp_item_translate (GIMP_ITEM (vectors), x, y, FALSE); } - gimp_image_add_vectors (text_tool->image, vectors, -1, TRUE); + /* FIXME tree */ + gimp_image_add_vectors (text_tool->image, vectors, NULL, -1, TRUE); gimp_image_flush (text_tool->image); } @@ -2817,8 +2819,8 @@ gimp_text_tool_create_vectors_warped (GimpTextTool *text_tool) gimp_vectors_warp_vectors (vectors0, vectors, 0.5 * box_height); - gimp_image_add_vectors (text_tool->image, vectors, -1, TRUE); - gimp_image_set_active_vectors (text_tool->image, vectors); + /* FIXME tree */ + gimp_image_add_vectors (text_tool->image, vectors, NULL, -1, TRUE); gimp_item_set_visible (GIMP_ITEM (vectors), TRUE, FALSE); gimp_image_flush (text_tool->image); diff --git a/app/tools/gimpvectortool.c b/app/tools/gimpvectortool.c index f674a6d419..77b6ea6ae2 100644 --- a/app/tools/gimpvectortool.c +++ b/app/tools/gimpvectortool.c @@ -305,7 +305,8 @@ gimp_vector_tool_button_press (GimpTool *tool, vector_tool->undo_motion = TRUE; - gimp_image_add_vectors (display->image, vectors, -1, TRUE); + /* FIXME tree */ + gimp_image_add_vectors (display->image, vectors, NULL, -1, TRUE); gimp_image_flush (display->image); gimp_vector_tool_set_vectors (vector_tool, vectors); diff --git a/app/vectors/gimpvectors-import.c b/app/vectors/gimpvectors-import.c index 40add09003..dcccc982f6 100644 --- a/app/vectors/gimpvectors-import.c +++ b/app/vectors/gimpvectors-import.c @@ -97,6 +97,7 @@ static gboolean gimp_vectors_import (GimpImage *image, gsize len, gboolean merge, gboolean scale, + GimpVectors *parent, gint position, GList **ret_vectors, GError **error); @@ -198,16 +199,19 @@ gimp_vectors_import_file (GimpImage *image, const gchar *filename, gboolean merge, gboolean scale, + GimpVectors *parent, gint position, GList **ret_vectors, GError **error) { g_return_val_if_fail (GIMP_IS_IMAGE (image), FALSE); g_return_val_if_fail (filename != NULL, FALSE); + g_return_val_if_fail (parent == NULL || GIMP_IS_VECTORS (parent), FALSE); g_return_val_if_fail (ret_vectors == NULL || *ret_vectors == NULL, FALSE); g_return_val_if_fail (error == NULL || *error == NULL, FALSE); - return gimp_vectors_import (image, filename, NULL, 0, merge, scale, position, + return gimp_vectors_import (image, filename, NULL, 0, merge, scale, + parent, position, ret_vectors, error); } @@ -230,16 +234,19 @@ gimp_vectors_import_buffer (GimpImage *image, gsize len, gboolean merge, gboolean scale, + GimpVectors *parent, gint position, GList **ret_vectors, GError **error) { g_return_val_if_fail (GIMP_IS_IMAGE (image), FALSE); g_return_val_if_fail (buffer != NULL || len == 0, FALSE); + g_return_val_if_fail (parent == NULL || GIMP_IS_VECTORS (parent), FALSE); g_return_val_if_fail (ret_vectors == NULL || *ret_vectors == NULL, FALSE); g_return_val_if_fail (error == NULL || *error == NULL, FALSE); - return gimp_vectors_import (image, NULL, buffer, len, merge, scale, position, + return gimp_vectors_import (image, NULL, buffer, len, merge, scale, + parent, position, ret_vectors, error); } @@ -250,6 +257,7 @@ gimp_vectors_import (GimpImage *image, gsize len, gboolean merge, gboolean scale, + GimpVectors *parent, gint position, GList **ret_vectors, GError **error) @@ -305,7 +313,8 @@ gimp_vectors_import (GimpImage *image, vectors = gimp_vectors_new (image, ((merge || !path->id) ? _("Imported Path") : path->id)); - gimp_image_add_vectors (image, vectors, position, TRUE); + gimp_image_add_vectors (image, vectors, + parent, position, TRUE); gimp_vectors_freeze (vectors); if (ret_vectors) diff --git a/app/vectors/gimpvectors-import.h b/app/vectors/gimpvectors-import.h index fc8b951c1b..7ab74fce97 100644 --- a/app/vectors/gimpvectors-import.h +++ b/app/vectors/gimpvectors-import.h @@ -26,6 +26,7 @@ gboolean gimp_vectors_import_file (GimpImage *image, const gchar *filename, gboolean merge, gboolean scale, + GimpVectors *parent, gint position, GList **ret_vectors, GError **error); @@ -34,6 +35,7 @@ gboolean gimp_vectors_import_buffer (GimpImage *image, gsize len, gboolean merge, gboolean scale, + GimpVectors *parent, gint position, GList **ret_vectors, GError **error); diff --git a/app/vectors/gimpvectorsundo.c b/app/vectors/gimpvectorsundo.c index 5f8e730094..fff52b6ef5 100644 --- a/app/vectors/gimpvectorsundo.c +++ b/app/vectors/gimpvectorsundo.c @@ -30,6 +30,7 @@ enum { PROP_0, + PROP_PREV_PARENT, PROP_PREV_POSITION, PROP_PREV_VECTORS }; @@ -75,6 +76,13 @@ gimp_vectors_undo_class_init (GimpVectorsUndoClass *klass) undo_class->pop = gimp_vectors_undo_pop; + g_object_class_install_property (object_class, PROP_PREV_PARENT, + g_param_spec_object ("prev-parent", + NULL, NULL, + GIMP_TYPE_VECTORS, + GIMP_PARAM_READWRITE | + G_PARAM_CONSTRUCT_ONLY)); + g_object_class_install_property (object_class, PROP_PREV_POSITION, g_param_spec_int ("prev-position", NULL, NULL, 0, G_MAXINT, 0, @@ -120,6 +128,9 @@ gimp_vectors_undo_set_property (GObject *object, switch (property_id) { + case PROP_PREV_PARENT: + vectors_undo->prev_parent = g_value_get_object (value); + break; case PROP_PREV_POSITION: vectors_undo->prev_position = g_value_get_int (value); break; @@ -143,6 +154,9 @@ gimp_vectors_undo_get_property (GObject *object, switch (property_id) { + case PROP_PREV_PARENT: + g_value_set_object (value, vectors_undo->prev_parent); + break; case PROP_PREV_POSITION: g_value_set_int (value, vectors_undo->prev_position); break; @@ -188,7 +202,10 @@ gimp_vectors_undo_pop (GimpUndo *undo, { /* remove vectors */ - /* record the current position */ + /* record the current parent and position */ + vectors_undo->prev_parent = + GIMP_VECTORS (gimp_viewable_get_parent (GIMP_VIEWABLE (vectors))); + vectors_undo->prev_position = gimp_item_get_index (GIMP_ITEM (vectors)); gimp_image_remove_vectors (undo->image, vectors, FALSE, @@ -202,6 +219,7 @@ gimp_vectors_undo_pop (GimpUndo *undo, vectors_undo->prev_vectors = gimp_image_get_active_vectors (undo->image); gimp_image_add_vectors (undo->image, vectors, + vectors_undo->prev_parent, vectors_undo->prev_position, FALSE); GIMP_ITEM (vectors)->removed = FALSE; diff --git a/app/vectors/gimpvectorsundo.h b/app/vectors/gimpvectorsundo.h index bde3f4a7ad..857dc82995 100644 --- a/app/vectors/gimpvectorsundo.h +++ b/app/vectors/gimpvectorsundo.h @@ -36,6 +36,7 @@ struct _GimpVectorsUndo { GimpItemUndo parent_instance; + GimpVectors *prev_parent; gint prev_position; /* former position in list */ GimpVectors *prev_vectors; /* previous active vectors */ }; diff --git a/app/widgets/gimpchanneltreeview.c b/app/widgets/gimpchanneltreeview.c index 9d43b561e3..b469a32884 100644 --- a/app/widgets/gimpchanneltreeview.c +++ b/app/widgets/gimpchanneltreeview.c @@ -2,7 +2,7 @@ * Copyright (C) 1995 Spencer Kimball and Peter Mattis * * gimpchanneltreeview.c - * Copyright (C) 2001-2004 Michael Natterer + * Copyright (C) 2001-2009 Michael Natterer * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -51,9 +51,9 @@ struct _GimpChannelTreeViewPriv { - GtkWidget *component_editor; + GtkWidget *component_editor; - GtkWidget *toselection_button; + GtkWidget *toselection_button; }; @@ -212,24 +212,22 @@ gimp_channel_tree_view_drop_viewable (GimpContainerTreeView *tree_view, GtkTreeViewDropPosition drop_pos) { GimpItemTreeView *item_view = GIMP_ITEM_TREE_VIEW (tree_view); + GimpImage *image = gimp_item_tree_view_get_image (item_view); GimpItemTreeViewClass *item_view_class; item_view_class = GIMP_ITEM_TREE_VIEW_GET_CLASS (item_view); if (GIMP_IS_DRAWABLE (src_viewable) && - (gimp_item_tree_view_get_image (item_view) != gimp_item_get_image (GIMP_ITEM (src_viewable)) || + (image != gimp_item_get_image (GIMP_ITEM (src_viewable)) || G_TYPE_FROM_INSTANCE (src_viewable) != item_view_class->item_type)) { GimpItem *new_item; - gint index = -1; + GimpItem *parent; + gint index; - if (dest_viewable) - { - index = gimp_item_get_index (GIMP_ITEM (dest_viewable)); - - if (drop_pos == GTK_TREE_VIEW_DROP_AFTER) - index++; - } + index = gimp_item_tree_view_get_drop_index (item_view, dest_viewable, + drop_pos, + (GimpViewable **) &parent); new_item = gimp_item_convert (GIMP_ITEM (src_viewable), gimp_item_tree_view_get_image (item_view), @@ -237,8 +235,10 @@ gimp_channel_tree_view_drop_viewable (GimpContainerTreeView *tree_view, gimp_item_set_linked (new_item, FALSE, FALSE); - item_view_class->add_item (gimp_item_tree_view_get_image (item_view), new_item, index, TRUE); - gimp_image_flush (gimp_item_tree_view_get_image (item_view)); + item_view_class->add_item (image, new_item, parent, index, TRUE); + + gimp_image_flush (image); + return; } @@ -256,18 +256,16 @@ gimp_channel_tree_view_drop_component (GimpContainerTreeView *tree_view, GtkTreeViewDropPosition drop_pos) { GimpItemTreeView *item_view = GIMP_ITEM_TREE_VIEW (tree_view); + GimpImage *image = gimp_item_tree_view_get_image (item_view); GimpItem *new_item; - gint index = -1; + GimpChannel *parent; + gint index; const gchar *desc; gchar *name; - if (dest_viewable) - { - index = gimp_item_get_index (GIMP_ITEM (dest_viewable)); - - if (drop_pos == GTK_TREE_VIEW_DROP_AFTER) - index++; - } + index = gimp_item_tree_view_get_drop_index (item_view, dest_viewable, + drop_pos, + (GimpViewable **) &parent); gimp_enum_get_value (GIMP_TYPE_CHANNEL_TYPE, component, NULL, NULL, &desc, NULL); @@ -283,12 +281,12 @@ gimp_channel_tree_view_drop_component (GimpContainerTreeView *tree_view, g_free (name); - if (src_image != gimp_item_tree_view_get_image (item_view)) - GIMP_ITEM_GET_CLASS (new_item)->convert (new_item, gimp_item_tree_view_get_image (item_view)); + if (src_image != image) + GIMP_ITEM_GET_CLASS (new_item)->convert (new_item, image); - gimp_image_add_channel (gimp_item_tree_view_get_image (item_view), GIMP_CHANNEL (new_item), index, - TRUE); - gimp_image_flush (gimp_item_tree_view_get_image (item_view)); + gimp_image_add_channel (image, GIMP_CHANNEL (new_item), parent, index, TRUE); + + gimp_image_flush (image); } @@ -346,7 +344,8 @@ gimp_channel_tree_view_item_new (GimpImage *image) gimp_image_get_height (image), _("Empty Channel"), &color); - gimp_image_add_channel (image, new_channel, -1, TRUE); + /* FIXME tree */ + gimp_image_add_channel (image, new_channel, NULL, -1, TRUE); gimp_image_undo_group_end (image); diff --git a/app/widgets/gimpitemtreeview.c b/app/widgets/gimpitemtreeview.c index 0087a5a5a8..b98247c297 100644 --- a/app/widgets/gimpitemtreeview.c +++ b/app/widgets/gimpitemtreeview.c @@ -2,7 +2,7 @@ * Copyright (C) 1995 Spencer Kimball and Peter Mattis * * gimpitemtreeview.c - * Copyright (C) 2001-2003 Michael Natterer + * Copyright (C) 2001-2009 Michael Natterer * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -493,6 +493,45 @@ gimp_item_tree_view_get_edit_button (GimpItemTreeView *view) return view->priv->edit_button; } +gint +gimp_item_tree_view_get_drop_index (GimpItemTreeView *view, + GimpViewable *dest_viewable, + GtkTreeViewDropPosition drop_pos, + GimpViewable **parent) +{ + gint index = -1; + + g_return_val_if_fail (GIMP_IS_ITEM_TREE_VIEW (view), -1); + g_return_val_if_fail (dest_viewable == NULL || + GIMP_IS_VIEWABLE (dest_viewable), -1); + g_return_val_if_fail (parent != NULL, -1); + + *parent = NULL; + + if (dest_viewable) + { + *parent = gimp_viewable_get_parent (dest_viewable); + index = gimp_item_get_index (GIMP_ITEM (dest_viewable)); + + if (drop_pos == GTK_TREE_VIEW_DROP_AFTER) + { + GimpContainer *children = gimp_viewable_get_children (dest_viewable); + + if (children) + { + *parent = dest_viewable; + index = 0; + } + else + { + index++; + } + } + } + + return index; +} + static void gimp_item_tree_view_real_set_image (GimpItemTreeView *view, GimpImage *image) @@ -768,19 +807,22 @@ gimp_item_tree_view_drop_viewable (GimpContainerTreeView *tree_view, { GType item_type = item_view_class->item_type; GimpItem *new_item; + GimpItem *parent; if (g_type_is_a (G_TYPE_FROM_INSTANCE (src_viewable), item_type)) item_type = G_TYPE_FROM_INSTANCE (src_viewable); - if (dest_viewable && drop_pos == GTK_TREE_VIEW_DROP_AFTER) - dest_index++; + dest_index = gimp_item_tree_view_get_drop_index (item_view, dest_viewable, + drop_pos, + (GimpViewable **) &parent); new_item = gimp_item_convert (GIMP_ITEM (src_viewable), item_view->priv->image, item_type); gimp_item_set_linked (new_item, FALSE, FALSE); - item_view_class->add_item (item_view->priv->image, new_item, dest_index, TRUE); + item_view_class->add_item (item_view->priv->image, new_item, + parent, dest_index, TRUE); } else if (dest_viewable) { diff --git a/app/widgets/gimpitemtreeview.h b/app/widgets/gimpitemtreeview.h index a6d3ed27b1..a2a58bc8c2 100644 --- a/app/widgets/gimpitemtreeview.h +++ b/app/widgets/gimpitemtreeview.h @@ -36,6 +36,7 @@ typedef void (* GimpReorderItemFunc) (GimpImage *image, const gchar *undo_desc); typedef void (* GimpAddItemFunc) (GimpImage *image, GimpItem *item, + GimpItem *parent, gint index, gboolean push_undo); typedef void (* GimpRemoveItemFunc) (GimpImage *image, @@ -117,5 +118,10 @@ GimpImage * gimp_item_tree_view_get_image (GimpItemTreeView *view); GtkWidget * gimp_item_tree_view_get_new_button (GimpItemTreeView *view); GtkWidget * gimp_item_tree_view_get_edit_button (GimpItemTreeView *view); +gint gimp_item_tree_view_get_drop_index (GimpItemTreeView *view, + GimpViewable *dest_viewable, + GtkTreeViewDropPosition drop_pos, + GimpViewable **parent); + #endif /* __GIMP_ITEM_TREE_VIEW_H__ */ diff --git a/app/widgets/gimplayertreeview.c b/app/widgets/gimplayertreeview.c index 3fccc655ff..d3e769343b 100644 --- a/app/widgets/gimplayertreeview.c +++ b/app/widgets/gimplayertreeview.c @@ -2,7 +2,7 @@ * Copyright (C) 1995 Spencer Kimball and Peter Mattis * * gimplayertreeview.c - * Copyright (C) 2001-2003 Michael Natterer + * Copyright (C) 2001-2009 Michael Natterer * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -715,16 +715,13 @@ gimp_layer_tree_view_drop_uri_list (GimpContainerTreeView *view, GimpItemTreeView *item_view = GIMP_ITEM_TREE_VIEW (view); GimpContainerView *cont_view = GIMP_CONTAINER_VIEW (view); GimpImage *image = gimp_item_tree_view_get_image (item_view); - gint index = -1; + GimpLayer *parent; + gint index; GList *list; - if (dest_viewable) - { - index = gimp_item_get_index (GIMP_ITEM (dest_viewable)); - - if (drop_pos == GTK_TREE_VIEW_DROP_AFTER) - index++; - } + index = gimp_item_tree_view_get_drop_index (item_view, dest_viewable, + drop_pos, + (GimpViewable **) &parent); for (list = uri_list; list; list = g_list_next (list)) { @@ -742,7 +739,7 @@ gimp_layer_tree_view_drop_uri_list (GimpContainerTreeView *view, if (new_layers) { - gimp_image_add_layers (image, new_layers, index, + gimp_image_add_layers (image, new_layers, parent, index, 0, 0, gimp_image_get_width (image), gimp_image_get_height (image), @@ -776,22 +773,20 @@ gimp_layer_tree_view_drop_component (GimpContainerTreeView *tree_view, GtkTreeViewDropPosition drop_pos) { GimpItemTreeView *item_view = GIMP_ITEM_TREE_VIEW (tree_view); + GimpImage *image = gimp_item_tree_view_get_image (item_view); GimpChannel *channel; GimpItem *new_item; + GimpLayer *parent; + gint index; const gchar *desc; - gint index = -1; - if (dest_viewable) - { - index = gimp_item_get_index (GIMP_ITEM (dest_viewable)); - - if (drop_pos == GTK_TREE_VIEW_DROP_AFTER) - index++; - } + index = gimp_item_tree_view_get_drop_index (item_view, dest_viewable, + drop_pos, + (GimpViewable **) &parent); channel = gimp_channel_new_from_component (src_image, component, NULL, NULL); - new_item = gimp_item_convert (GIMP_ITEM (channel), gimp_item_tree_view_get_image (item_view), + new_item = gimp_item_convert (GIMP_ITEM (channel), image, GIMP_TYPE_LAYER); g_object_unref (channel); @@ -801,8 +796,9 @@ gimp_layer_tree_view_drop_component (GimpContainerTreeView *tree_view, gimp_object_take_name (GIMP_OBJECT (new_item), g_strdup_printf (_("%s Channel Copy"), desc)); - gimp_image_add_layer (gimp_item_tree_view_get_image (item_view), GIMP_LAYER (new_item), index, TRUE); - gimp_image_flush (gimp_item_tree_view_get_image (item_view)); + gimp_image_add_layer (image, GIMP_LAYER (new_item), parent, index, TRUE); + + gimp_image_flush (image); } static void @@ -814,15 +810,12 @@ gimp_layer_tree_view_drop_pixbuf (GimpContainerTreeView *tree_view, GimpItemTreeView *item_view = GIMP_ITEM_TREE_VIEW (tree_view); GimpImage *image = gimp_item_tree_view_get_image (item_view); GimpLayer *new_layer; - gint index = -1; + GimpLayer *parent; + gint index; - if (dest_viewable) - { - index = gimp_item_get_index (GIMP_ITEM (dest_viewable)); - - if (drop_pos == GTK_TREE_VIEW_DROP_AFTER) - index++; - } + index = gimp_item_tree_view_get_drop_index (item_view, dest_viewable, + drop_pos, + (GimpViewable **) &parent); new_layer = gimp_layer_new_from_pixbuf (pixbuf, image, @@ -830,7 +823,8 @@ gimp_layer_tree_view_drop_pixbuf (GimpContainerTreeView *tree_view, _("Dropped Buffer"), GIMP_OPACITY_OPAQUE, GIMP_NORMAL_MODE); - gimp_image_add_layer (image, new_layer, index, TRUE); + gimp_image_add_layer (image, new_layer, parent, index, TRUE); + gimp_image_flush (image); } @@ -869,7 +863,8 @@ gimp_layer_tree_view_item_new (GimpImage *image) gimp_image_base_type_with_alpha (image), _("Empty Layer"), 1.0, GIMP_NORMAL_MODE); - gimp_image_add_layer (image, new_layer, -1, TRUE); + /* FIXME tree */ + gimp_image_add_layer (image, new_layer, NULL, -1, TRUE); gimp_image_undo_group_end (image); diff --git a/app/widgets/gimptoolbox-dnd.c b/app/widgets/gimptoolbox-dnd.c index cc377d7826..174d287e57 100644 --- a/app/widgets/gimptoolbox-dnd.c +++ b/app/widgets/gimptoolbox-dnd.c @@ -226,7 +226,7 @@ gimp_toolbox_drop_drawable (GtkWidget *widget, gimp_layer_set_opacity (new_layer, GIMP_OPACITY_OPAQUE, FALSE); gimp_layer_set_lock_alpha (new_layer, FALSE, FALSE); - gimp_image_add_layer (new_image, new_layer, 0, TRUE); + gimp_image_add_layer (new_image, new_layer, NULL, 0, TRUE); gimp_image_undo_enable (new_image); @@ -312,7 +312,7 @@ gimp_toolbox_drop_component (GtkWidget *widget, gimp_object_take_name (GIMP_OBJECT (new_layer), g_strdup_printf (_("%s Channel Copy"), desc)); - gimp_image_add_layer (new_image, new_layer, 0, TRUE); + gimp_image_add_layer (new_image, new_layer, NULL, 0, TRUE); gimp_image_undo_enable (new_image); @@ -361,7 +361,7 @@ gimp_toolbox_drop_pixbuf (GtkWidget *widget, _("Dropped Buffer"), GIMP_OPACITY_OPAQUE, GIMP_NORMAL_MODE); - gimp_image_add_layer (new_image, new_layer, 0, TRUE); + gimp_image_add_layer (new_image, new_layer, NULL, 0, TRUE); gimp_image_undo_enable (new_image); diff --git a/app/widgets/gimpvectorstreeview.c b/app/widgets/gimpvectorstreeview.c index 55f72ba997..4e0c248bda 100644 --- a/app/widgets/gimpvectorstreeview.c +++ b/app/widgets/gimpvectorstreeview.c @@ -2,7 +2,7 @@ * Copyright (C) 1995 Spencer Kimball and Peter Mattis * * gimpvectorstreeview.c - * Copyright (C) 2001-2004 Michael Natterer + * Copyright (C) 2001-2009 Michael Natterer * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -225,24 +225,21 @@ gimp_vectors_tree_view_drop_svg (GimpContainerTreeView *tree_view, GimpViewable *dest_viewable, GtkTreeViewDropPosition drop_pos) { - GimpItemTreeView *view = GIMP_ITEM_TREE_VIEW (tree_view); - GimpImage *image = gimp_item_tree_view_get_image (view); - gint index = -1; + GimpItemTreeView *item_view = GIMP_ITEM_TREE_VIEW (tree_view); + GimpImage *image = gimp_item_tree_view_get_image (item_view); + GimpVectors *parent; + gint index; GError *error = NULL; if (image->gimp->be_verbose) g_print ("%s: SVG dropped (len = %d)\n", G_STRFUNC, (gint) svg_data_len); - if (dest_viewable) - { - index = gimp_item_get_index (GIMP_ITEM (dest_viewable)); - - if (drop_pos == GTK_TREE_VIEW_DROP_AFTER) - index++; - } + index = gimp_item_tree_view_get_drop_index (item_view, dest_viewable, + drop_pos, + (GimpViewable **) &parent); if (! gimp_vectors_import_buffer (image, svg_data, svg_data_len, - TRUE, TRUE, index, NULL, &error)) + TRUE, TRUE, parent, index, NULL, &error)) { gimp_message_literal (image->gimp, G_OBJECT (tree_view), GIMP_MESSAGE_ERROR, @@ -262,7 +259,8 @@ gimp_vectors_tree_view_item_new (GimpImage *image) new_vectors = gimp_vectors_new (image, _("Empty Path")); - gimp_image_add_vectors (image, new_vectors, -1, TRUE); + /* FIXME tree */ + gimp_image_add_vectors (image, new_vectors, NULL, -1, TRUE); return GIMP_ITEM (new_vectors); } diff --git a/app/xcf/xcf-load.c b/app/xcf/xcf-load.c index 48d0e1aa4a..8f7eeea926 100644 --- a/app/xcf/xcf-load.c +++ b/app/xcf/xcf-load.c @@ -200,6 +200,7 @@ xcf_load_image (Gimp *gimp, /* add the layer to the image if its not the floating selection */ if (layer != info->floating_sel) gimp_image_add_layer (image, layer, + NULL, /* FIXME tree */ gimp_container_get_n_children (image->layers), FALSE); @@ -242,6 +243,7 @@ xcf_load_image (Gimp *gimp, /* add the channel to the image if its not the selection */ if (channel != gimp_image_get_mask (image)) gimp_image_add_channel (image, channel, + NULL, /* FIXME tree */ gimp_container_get_n_children (image->channels), FALSE); @@ -1630,6 +1632,7 @@ xcf_load_old_path (XcfInfo *info, gimp_item_set_tattoo (GIMP_ITEM (vectors), tattoo); gimp_image_add_vectors (image, vectors, + NULL, /* can't be a tree */ gimp_container_get_n_children (image->vectors), FALSE); @@ -1822,6 +1825,7 @@ xcf_load_vector (XcfInfo *info, } gimp_image_add_vectors (image, vectors, + NULL, /* FIXME tree */ gimp_container_get_n_children (image->vectors), FALSE); diff --git a/tools/pdbgen/pdb/image.pdb b/tools/pdbgen/pdb/image.pdb index ffb1cee746..7bdc071916 100644 --- a/tools/pdbgen/pdb/image.pdb +++ b/tools/pdbgen/pdb/image.pdb @@ -1013,7 +1013,9 @@ HELP GIMP_IMAGE_TYPE_BASE_TYPE (gimp_drawable_type (GIMP_DRAWABLE (layer))), error)) { - success = gimp_image_add_layer (image, layer, MAX (position, -1), TRUE); + /* FIXME tree */ + success = gimp_image_add_layer (image, layer, + NULL, MAX (position, -1), TRUE); } else { @@ -1218,7 +1220,9 @@ HELP { if (gimp_pdb_item_is_floating (GIMP_ITEM (channel), image, error)) { - success = gimp_image_add_channel (image, channel, MAX (position, -1), TRUE); + /* FIXME tree */ + success = gimp_image_add_channel (image, channel, + NULL, MAX (position, -1), TRUE); } else { @@ -1282,7 +1286,9 @@ HELP { if (gimp_pdb_item_is_floating (GIMP_ITEM (vectors), image, error)) { - success = gimp_image_add_vectors (image, vectors, MAX (position, -1), TRUE); + /* FIXME tree */ + success = gimp_image_add_vectors (image, vectors, + NULL, MAX (position, -1), TRUE); } else { diff --git a/tools/pdbgen/pdb/paths.pdb b/tools/pdbgen/pdb/paths.pdb index b793f95268..abe5d7606a 100644 --- a/tools/pdbgen/pdb/paths.pdb +++ b/tools/pdbgen/pdb/paths.pdb @@ -241,7 +241,7 @@ sub path_set_points { g_free (points); if (vectors) - success = gimp_image_add_vectors (image, vectors, 0, TRUE); + success = gimp_image_add_vectors (image, vectors, NULL, 0, TRUE); else success = FALSE; } @@ -588,7 +588,7 @@ sub path_import { code => <<'CODE' { success = gimp_vectors_import_file (image, filename, - merge, scale, -1, NULL, NULL); + merge, scale, NULL, -1, NULL, NULL); } CODE ); diff --git a/tools/pdbgen/pdb/vectors.pdb b/tools/pdbgen/pdb/vectors.pdb index 3df438e7ac..eaa1ec857d 100644 --- a/tools/pdbgen/pdb/vectors.pdb +++ b/tools/pdbgen/pdb/vectors.pdb @@ -1265,8 +1265,10 @@ HELP { GList *list, *vectors_list = NULL; + /* FIXME tree */ success = gimp_vectors_import_file (image, filename, - merge, scale, -1, &vectors_list, error); + merge, scale, NULL, -1, + &vectors_list, error); if (success) { @@ -1328,8 +1330,10 @@ HELP { GList *list, *vectors_list = NULL; + /* FIXME tree */ success = gimp_vectors_import_buffer (image, string, length, - merge, scale, -1, &vectors_list, error); + merge, scale, NULL, -1, + &vectors_list, error); if (success) {