mirror of
https://gitlab.gnome.org/GNOME/gimp
synced 2024-10-19 14:23:33 +00:00
don't allow to select anything but the floating selection. Fixes bug
2004-01-18 Michael Natterer <mitch@gimp.org> * app/core/gimpimage.c (gimp_image_set_active_layer): don't allow to select anything but the floating selection. Fixes bug #128025. (gimp_image_set_active_layer,channel,vectors): allow to pass NULL to unselect the active item. Removed the silly feature that passing some random item of another image would select the first item in the list (was unused anyway). (gimp_image_unset_active_channel): use gimp_image_set_active_channel() now that it accepts NULL. (gimp_image_add_layer,channel,vectors): cleaned up / simplified. (gimp_image_remove_layer,channel,vectors): cleanup, simplification, use gimp_image_set_active_layer,channel,vectors() now that they accept NULL, make sure the item next to the removed item becomes the active one (and not the first in the list, which was a severe usability problem in the dialogs). * app/core/gimpimage-undo-push.c (undo_pop_layer,channel): pass NULL to the set_active functions, cleanup. * app/core/gimpimage-duplicate.c: attach the floating selection before setting the active layer. Code relied on broken gimp_image_set_active_layer() behaviour before. * app/core/gimplayer-floating-sel.c: no need to set gimage->floating_sel before calling gimp_image_add_layer(). The weird GUI mentioned in the comment existed in 1.2 only. * app/display/gimpdisplayshell-layer-select.c (layer_select_advance): don't assume that setting the active_layer always succeeds. * tools/pdbgen/pdb/image.pdb: behave as the documentation says and return an execution error if setting the active layer or channel failed. Unrelated: * tools/pdbgen/pdb/image.pdb * tools/pdbgen/pdb/layer.pdb: removed leftover cruft from the old guchar based color API. * tools/pdbgen/pdb/channel.pdb: simplified code which handles the channel's color. * app/pdb/channel_cmds.c * app/pdb/image_cmds.c: regenerated.
This commit is contained in:
parent
b18e38c714
commit
370a16fafe
51
ChangeLog
51
ChangeLog
|
@ -1,3 +1,54 @@
|
|||
2004-01-18 Michael Natterer <mitch@gimp.org>
|
||||
|
||||
* app/core/gimpimage.c (gimp_image_set_active_layer): don't allow
|
||||
to select anything but the floating selection. Fixes bug #128025.
|
||||
|
||||
(gimp_image_set_active_layer,channel,vectors): allow to pass NULL
|
||||
to unselect the active item. Removed the silly feature that
|
||||
passing some random item of another image would select the first
|
||||
item in the list (was unused anyway).
|
||||
|
||||
(gimp_image_unset_active_channel): use gimp_image_set_active_channel()
|
||||
now that it accepts NULL.
|
||||
|
||||
(gimp_image_add_layer,channel,vectors): cleaned up / simplified.
|
||||
|
||||
(gimp_image_remove_layer,channel,vectors): cleanup,
|
||||
simplification, use gimp_image_set_active_layer,channel,vectors()
|
||||
now that they accept NULL, make sure the item next to the removed
|
||||
item becomes the active one (and not the first in the list, which
|
||||
was a severe usability problem in the dialogs).
|
||||
|
||||
* app/core/gimpimage-undo-push.c (undo_pop_layer,channel): pass
|
||||
NULL to the set_active functions, cleanup.
|
||||
|
||||
* app/core/gimpimage-duplicate.c: attach the floating selection
|
||||
before setting the active layer. Code relied on broken
|
||||
gimp_image_set_active_layer() behaviour before.
|
||||
|
||||
* app/core/gimplayer-floating-sel.c: no need to set
|
||||
gimage->floating_sel before calling gimp_image_add_layer(). The
|
||||
weird GUI mentioned in the comment existed in 1.2 only.
|
||||
|
||||
* app/display/gimpdisplayshell-layer-select.c (layer_select_advance):
|
||||
don't assume that setting the active_layer always succeeds.
|
||||
|
||||
* tools/pdbgen/pdb/image.pdb: behave as the documentation says
|
||||
and return an execution error if setting the active layer or
|
||||
channel failed.
|
||||
|
||||
Unrelated:
|
||||
|
||||
* tools/pdbgen/pdb/image.pdb
|
||||
* tools/pdbgen/pdb/layer.pdb: removed leftover cruft from the old
|
||||
guchar based color API.
|
||||
|
||||
* tools/pdbgen/pdb/channel.pdb: simplified code which handles the
|
||||
channel's color.
|
||||
|
||||
* app/pdb/channel_cmds.c
|
||||
* app/pdb/image_cmds.c: regenerated.
|
||||
|
||||
2004-01-18 Simon Budig <simon@gimp.org>
|
||||
|
||||
* app/gui/about-dialog.c: fixed typo.
|
||||
|
|
|
@ -197,6 +197,9 @@ gimp_image_duplicate (GimpImage *gimage)
|
|||
new_gimage->selection_mask->boundary_known = FALSE;
|
||||
}
|
||||
|
||||
if (floating_layer)
|
||||
floating_sel_attach (floating_layer, new_floating_sel_drawable);
|
||||
|
||||
/* Set active layer, active channel, active vectors */
|
||||
if (active_layer)
|
||||
gimp_image_set_active_layer (new_gimage, active_layer);
|
||||
|
@ -207,9 +210,6 @@ gimp_image_duplicate (GimpImage *gimage)
|
|||
if (active_vectors)
|
||||
gimp_image_set_active_vectors (new_gimage, active_vectors);
|
||||
|
||||
if (floating_layer)
|
||||
floating_sel_attach (floating_layer, new_floating_sel_drawable);
|
||||
|
||||
/* Copy state of all color channels */
|
||||
for (count = 0; count < MAX_CHANNELS; count++)
|
||||
{
|
||||
|
|
|
@ -1511,7 +1511,6 @@ undo_pop_layer (GimpUndo *undo,
|
|||
/* record the current position */
|
||||
lu->prev_position = gimp_image_get_layer_index (undo->gimage, layer);
|
||||
|
||||
/* remove the layer */
|
||||
gimp_container_remove (undo->gimage->layers, GIMP_OBJECT (layer));
|
||||
undo->gimage->layer_stack = g_slist_remove (undo->gimage->layer_stack,
|
||||
layer);
|
||||
|
@ -1539,8 +1538,7 @@ undo_pop_layer (GimpUndo *undo,
|
|||
}
|
||||
else
|
||||
{
|
||||
undo->gimage->active_layer = NULL;
|
||||
gimp_image_active_layer_changed (undo->gimage);
|
||||
gimp_image_set_active_layer (undo->gimage, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1567,7 +1565,6 @@ undo_pop_layer (GimpUndo *undo,
|
|||
if (gimp_layer_is_floating_sel (layer))
|
||||
undo->gimage->floating_sel = layer;
|
||||
|
||||
/* add the new layer */
|
||||
gimp_container_insert (undo->gimage->layers,
|
||||
GIMP_OBJECT (layer), lu->prev_position);
|
||||
gimp_image_set_active_layer (undo->gimage, layer);
|
||||
|
@ -2277,9 +2274,7 @@ undo_pop_channel (GimpUndo *undo,
|
|||
cu->prev_position = gimp_image_get_channel_index (undo->gimage,
|
||||
channel);
|
||||
|
||||
/* remove the channel */
|
||||
gimp_container_remove (undo->gimage->channels, GIMP_OBJECT (channel));
|
||||
|
||||
gimp_item_removed (GIMP_ITEM (channel));
|
||||
|
||||
if (channel == gimp_image_get_active_channel (undo->gimage))
|
||||
|
@ -2299,7 +2294,6 @@ undo_pop_channel (GimpUndo *undo,
|
|||
/* record the active channel */
|
||||
cu->prev_channel = gimp_image_get_active_channel (undo->gimage);
|
||||
|
||||
/* add the new channel */
|
||||
gimp_container_insert (undo->gimage->channels,
|
||||
GIMP_OBJECT (channel), cu->prev_position);
|
||||
gimp_image_set_active_channel (undo->gimage, channel);
|
||||
|
@ -2694,24 +2688,12 @@ undo_pop_vectors (GimpUndo *undo,
|
|||
vu->prev_position = gimp_image_get_vectors_index (undo->gimage,
|
||||
vectors);
|
||||
|
||||
/* remove the vectors */
|
||||
gimp_container_remove (undo->gimage->vectors, GIMP_OBJECT (vectors));
|
||||
|
||||
gimp_item_removed (GIMP_ITEM (vectors));
|
||||
|
||||
if (vectors == gimp_image_get_active_vectors (undo->gimage))
|
||||
{
|
||||
if (vu->prev_vectors)
|
||||
{
|
||||
gimp_image_set_active_vectors (undo->gimage, vu->prev_vectors);
|
||||
}
|
||||
else
|
||||
{
|
||||
undo->gimage->active_vectors = NULL;
|
||||
gimp_image_active_vectors_changed (undo->gimage);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* restore vectors */
|
||||
|
@ -2721,7 +2703,6 @@ undo_pop_vectors (GimpUndo *undo,
|
|||
/* record the active vectors */
|
||||
vu->prev_vectors = gimp_image_get_active_vectors (undo->gimage);
|
||||
|
||||
/* add the new vectors */
|
||||
gimp_container_insert (undo->gimage->vectors,
|
||||
GIMP_OBJECT (vectors), vu->prev_position);
|
||||
gimp_image_set_active_vectors (undo->gimage, vectors);
|
||||
|
|
|
@ -2133,14 +2133,19 @@ GimpLayer *
|
|||
gimp_image_set_active_layer (GimpImage *gimage,
|
||||
GimpLayer *layer)
|
||||
{
|
||||
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), NULL);
|
||||
g_return_val_if_fail (GIMP_IS_LAYER (layer), NULL);
|
||||
GimpLayer *floating_sel;
|
||||
|
||||
/* First, find the layer in the gimage
|
||||
* If it isn't valid, find the first layer that is
|
||||
*/
|
||||
if (! gimp_container_have (gimage->layers, GIMP_OBJECT (layer)))
|
||||
layer = (GimpLayer *) gimp_container_get_child_by_index (gimage->layers, 0);
|
||||
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), NULL);
|
||||
g_return_val_if_fail (layer == NULL || GIMP_IS_LAYER (layer), NULL);
|
||||
g_return_val_if_fail (layer == NULL ||
|
||||
gimp_container_have (gimage->layers,
|
||||
GIMP_OBJECT (layer)), NULL);
|
||||
|
||||
floating_sel = gimp_image_floating_sel (gimage);
|
||||
|
||||
/* Make sure the floating_sel always is the active layer */
|
||||
if (floating_sel && layer != floating_sel)
|
||||
return floating_sel;
|
||||
|
||||
if (layer != gimage->active_layer)
|
||||
{
|
||||
|
@ -2149,25 +2154,21 @@ gimp_image_set_active_layer (GimpImage *gimage,
|
|||
/* Configure the layer stack to reflect this change */
|
||||
gimage->layer_stack = g_slist_remove (gimage->layer_stack, layer);
|
||||
gimage->layer_stack = g_slist_prepend (gimage->layer_stack, layer);
|
||||
}
|
||||
|
||||
/* Don't cache selection info for the previous active layer */
|
||||
gimp_drawable_invalidate_boundary (GIMP_DRAWABLE (layer));
|
||||
}
|
||||
if (gimage->active_layer)
|
||||
gimp_drawable_invalidate_boundary (GIMP_DRAWABLE (gimage->active_layer));
|
||||
|
||||
gimage->active_layer = layer;
|
||||
|
||||
g_signal_emit (gimage, gimp_image_signals[ACTIVE_LAYER_CHANGED], 0);
|
||||
|
||||
if (gimage->active_channel)
|
||||
{
|
||||
gimage->active_channel = NULL;
|
||||
|
||||
g_signal_emit (gimage, gimp_image_signals[ACTIVE_CHANNEL_CHANGED], 0);
|
||||
}
|
||||
if (layer && gimage->active_channel)
|
||||
gimp_image_set_active_channel (gimage, NULL);
|
||||
}
|
||||
|
||||
/* return the layer */
|
||||
return layer;
|
||||
return gimage->active_layer;
|
||||
}
|
||||
|
||||
GimpChannel *
|
||||
|
@ -2175,38 +2176,26 @@ gimp_image_set_active_channel (GimpImage *gimage,
|
|||
GimpChannel *channel)
|
||||
{
|
||||
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), NULL);
|
||||
g_return_val_if_fail (GIMP_IS_CHANNEL (channel), NULL);
|
||||
g_return_val_if_fail (channel == NULL || GIMP_IS_CHANNEL (channel), NULL);
|
||||
g_return_val_if_fail (channel == NULL ||
|
||||
gimp_container_have (gimage->channels,
|
||||
GIMP_OBJECT (channel)), NULL);
|
||||
|
||||
/* Not if there is a floating selection */
|
||||
if (gimp_image_floating_sel (gimage))
|
||||
if (channel && gimp_image_floating_sel (gimage))
|
||||
return NULL;
|
||||
|
||||
/* First, find the channel
|
||||
* If it doesn't exist, find the first channel that does
|
||||
*/
|
||||
if (! gimp_container_have (gimage->channels, GIMP_OBJECT (channel)))
|
||||
channel = (GimpChannel *)
|
||||
gimp_container_get_child_by_index (gimage->channels, 0);
|
||||
|
||||
if (channel != gimage->active_channel)
|
||||
{
|
||||
gimage->active_channel = channel;
|
||||
|
||||
g_signal_emit (gimage, gimp_image_signals[ACTIVE_CHANNEL_CHANGED], 0);
|
||||
|
||||
if (gimage->active_layer)
|
||||
{
|
||||
/* Don't cache selection info for the previous active layer */
|
||||
gimp_drawable_invalidate_boundary (GIMP_DRAWABLE (gimage->active_layer));
|
||||
|
||||
gimage->active_layer = NULL;
|
||||
|
||||
g_signal_emit (gimage, gimp_image_signals[ACTIVE_LAYER_CHANGED], 0);
|
||||
}
|
||||
if (channel && gimage->active_layer)
|
||||
gimp_image_set_active_layer (gimage, NULL);
|
||||
}
|
||||
|
||||
/* return the channel */
|
||||
return channel;
|
||||
return gimage->active_channel;
|
||||
}
|
||||
|
||||
GimpChannel *
|
||||
|
@ -2220,16 +2209,10 @@ gimp_image_unset_active_channel (GimpImage *gimage)
|
|||
|
||||
if (channel)
|
||||
{
|
||||
gimage->active_channel = NULL;
|
||||
|
||||
g_signal_emit (gimage, gimp_image_signals[ACTIVE_CHANNEL_CHANGED], 0);
|
||||
gimp_image_set_active_channel (gimage, NULL);
|
||||
|
||||
if (gimage->layer_stack)
|
||||
{
|
||||
GimpLayer *layer = gimage->layer_stack->data;
|
||||
|
||||
gimp_image_set_active_layer (gimage, layer);
|
||||
}
|
||||
gimp_image_set_active_layer (gimage, gimage->layer_stack->data);
|
||||
}
|
||||
|
||||
return channel;
|
||||
|
@ -2240,14 +2223,10 @@ gimp_image_set_active_vectors (GimpImage *gimage,
|
|||
GimpVectors *vectors)
|
||||
{
|
||||
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), NULL);
|
||||
g_return_val_if_fail (GIMP_IS_VECTORS (vectors), NULL);
|
||||
|
||||
/* First, find the vectors
|
||||
* If it doesn't exist, find the first vectors that does
|
||||
*/
|
||||
if (! gimp_container_have (gimage->vectors, GIMP_OBJECT (vectors)))
|
||||
vectors = (GimpVectors *)
|
||||
gimp_container_get_child_by_index (gimage->vectors, 0);
|
||||
g_return_val_if_fail (vectors == NULL || GIMP_IS_VECTORS (vectors), NULL);
|
||||
g_return_val_if_fail (vectors == NULL ||
|
||||
gimp_container_have (gimage->vectors,
|
||||
GIMP_OBJECT (vectors)), NULL);
|
||||
|
||||
if (vectors != gimage->active_vectors)
|
||||
{
|
||||
|
@ -2256,7 +2235,7 @@ gimp_image_set_active_vectors (GimpImage *gimage,
|
|||
g_signal_emit (gimage, gimp_image_signals[ACTIVE_VECTORS_CHANGED], 0);
|
||||
}
|
||||
|
||||
return vectors;
|
||||
return gimage->active_vectors;
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -2414,6 +2393,8 @@ gimp_image_add_layer (GimpImage *gimage,
|
|||
GimpLayer *layer,
|
||||
gint position)
|
||||
{
|
||||
GimpLayer *active_layer;
|
||||
GimpLayer *floating_sel;
|
||||
gboolean alpha_changed = FALSE;
|
||||
|
||||
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), FALSE);
|
||||
|
@ -2434,48 +2415,45 @@ gimp_image_add_layer (GimpImage *gimage,
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
floating_sel = gimp_image_floating_sel (gimage);
|
||||
|
||||
if (floating_sel && gimp_layer_is_floating_sel (layer))
|
||||
{
|
||||
g_warning ("%s: trying to add floating layer to image which alyready "
|
||||
"has a floating selection.",
|
||||
G_GNUC_PRETTY_FUNCTION);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
active_layer = gimp_image_get_active_layer (gimage);
|
||||
|
||||
gimp_image_undo_push_layer_add (gimage, _("Add Layer"),
|
||||
layer, 0,
|
||||
gimp_image_get_active_layer (gimage));
|
||||
layer, 0, active_layer);
|
||||
|
||||
gimp_item_set_image (GIMP_ITEM (layer), gimage);
|
||||
|
||||
if (layer->mask)
|
||||
gimp_item_set_image (GIMP_ITEM (layer->mask), gimage);
|
||||
|
||||
/* If the layer is a floating selection, set the ID */
|
||||
if (gimp_layer_is_floating_sel (layer))
|
||||
gimage->floating_sel = layer;
|
||||
|
||||
/* let the layer know about the gimage */
|
||||
gimp_item_set_image (GIMP_ITEM (layer), gimage);
|
||||
|
||||
/* If the layer has a mask, set the mask's gimage */
|
||||
if (layer->mask)
|
||||
gimp_item_set_image (GIMP_ITEM (layer->mask), gimage);
|
||||
|
||||
/* add the layer to the list at the specified position */
|
||||
if (position == -1)
|
||||
{
|
||||
GimpLayer *active_layer;
|
||||
|
||||
active_layer = gimp_image_get_active_layer (gimage);
|
||||
|
||||
if (active_layer)
|
||||
{
|
||||
position = gimp_container_get_child_index (gimage->layers,
|
||||
GIMP_OBJECT (active_layer));
|
||||
}
|
||||
else
|
||||
{
|
||||
position = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/* If there is a floating selection (and this isn't it!),
|
||||
* make sure the insert position is greater than 0
|
||||
*/
|
||||
if (position == 0 &&
|
||||
gimp_image_floating_sel (gimage) &&
|
||||
(gimage->floating_sel != layer))
|
||||
{
|
||||
if (position == 0 && floating_sel)
|
||||
position = 1;
|
||||
}
|
||||
|
||||
if (gimp_container_num_children (gimage->layers) == 1 &&
|
||||
! gimp_drawable_has_alpha (GIMP_LIST (gimage->layers)->list->data))
|
||||
|
@ -2503,20 +2481,26 @@ void
|
|||
gimp_image_remove_layer (GimpImage *gimage,
|
||||
GimpLayer *layer)
|
||||
{
|
||||
GimpLayer *active_layer;
|
||||
gint index;
|
||||
|
||||
g_return_if_fail (GIMP_IS_IMAGE (gimage));
|
||||
g_return_if_fail (GIMP_IS_LAYER (layer));
|
||||
g_return_if_fail (gimp_container_have (gimage->layers,
|
||||
GIMP_OBJECT (layer)));
|
||||
|
||||
g_return_if_fail (gimp_container_have (gimage->layers, GIMP_OBJECT (layer)));
|
||||
active_layer = gimp_image_get_active_layer (gimage);
|
||||
|
||||
index = gimp_container_get_child_index (gimage->layers,
|
||||
GIMP_OBJECT (layer));
|
||||
|
||||
gimp_image_undo_push_layer_remove (gimage, _("Remove Layer"),
|
||||
layer,
|
||||
gimp_container_get_child_index (gimage->layers,
|
||||
GIMP_OBJECT (layer)),
|
||||
gimp_image_get_active_layer (gimage));
|
||||
layer, index, active_layer);
|
||||
|
||||
g_object_ref (layer);
|
||||
|
||||
/* Make sure we're not caching any old selection info */
|
||||
if (layer == active_layer)
|
||||
gimp_drawable_invalidate_boundary (GIMP_DRAWABLE (layer));
|
||||
|
||||
gimp_container_remove (gimage->layers, GIMP_OBJECT (layer));
|
||||
|
@ -2530,20 +2514,32 @@ gimp_image_remove_layer (GimpImage *gimage,
|
|||
floating_sel_reset (layer);
|
||||
}
|
||||
|
||||
if (layer == gimp_image_get_active_layer (gimage))
|
||||
if (layer == active_layer)
|
||||
{
|
||||
if (gimage->layer_stack)
|
||||
{
|
||||
gimp_image_set_active_layer (gimage, gimage->layer_stack->data);
|
||||
active_layer = gimage->layer_stack->data;
|
||||
}
|
||||
else
|
||||
{
|
||||
gimage->active_layer = NULL;
|
||||
g_signal_emit (gimage, gimp_image_signals[ACTIVE_LAYER_CHANGED], 0);
|
||||
gint n_children = gimp_container_num_children (gimage->layers);
|
||||
|
||||
if (n_children > 0)
|
||||
{
|
||||
index = CLAMP (index, 0, n_children - 1);
|
||||
|
||||
active_layer = (GimpLayer *)
|
||||
gimp_container_get_child_by_index (gimage->layers, index);
|
||||
}
|
||||
else
|
||||
{
|
||||
active_layer = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/* Send out REMOVED signal from layer */
|
||||
gimp_image_set_active_layer (gimage, active_layer);
|
||||
}
|
||||
|
||||
gimp_item_removed (GIMP_ITEM (layer));
|
||||
|
||||
g_object_unref (layer);
|
||||
|
@ -2726,6 +2722,8 @@ gimp_image_add_channel (GimpImage *gimage,
|
|||
GimpChannel *channel,
|
||||
gint position)
|
||||
{
|
||||
GimpChannel *active_channel;
|
||||
|
||||
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), FALSE);
|
||||
g_return_val_if_fail (GIMP_IS_CHANNEL (channel), FALSE);
|
||||
|
||||
|
@ -2744,30 +2742,22 @@ gimp_image_add_channel (GimpImage *gimage,
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
/* let the channel know about the gimage */
|
||||
gimp_item_set_image (GIMP_ITEM (channel), gimage);
|
||||
active_channel = gimp_image_get_active_channel (gimage);
|
||||
|
||||
gimp_image_undo_push_channel_add (gimage, _("Add Channel"),
|
||||
channel, 0,
|
||||
gimp_image_get_active_channel (gimage));
|
||||
channel, 0, active_channel);
|
||||
|
||||
gimp_item_set_image (GIMP_ITEM (channel), gimage);
|
||||
|
||||
/* add the layer to the list at the specified position */
|
||||
if (position == -1)
|
||||
{
|
||||
GimpChannel *active_channel;
|
||||
|
||||
active_channel = gimp_image_get_active_channel (gimage);
|
||||
|
||||
if (active_channel)
|
||||
{
|
||||
position = gimp_container_get_child_index (gimage->channels,
|
||||
GIMP_OBJECT (active_channel));
|
||||
}
|
||||
else
|
||||
{
|
||||
position = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/* Don't add at a non-existing index */
|
||||
if (position > gimp_container_num_children (gimage->channels))
|
||||
|
@ -2786,33 +2776,39 @@ void
|
|||
gimp_image_remove_channel (GimpImage *gimage,
|
||||
GimpChannel *channel)
|
||||
{
|
||||
GimpChannel *active_channel;
|
||||
gint index;
|
||||
|
||||
g_return_if_fail (GIMP_IS_IMAGE (gimage));
|
||||
g_return_if_fail (GIMP_IS_CHANNEL (channel));
|
||||
|
||||
g_return_if_fail (gimp_container_have (gimage->channels,
|
||||
GIMP_OBJECT (channel)));
|
||||
|
||||
active_channel = gimp_image_get_active_channel (gimage);
|
||||
|
||||
index = gimp_container_get_child_index (gimage->channels,
|
||||
GIMP_OBJECT (channel));
|
||||
|
||||
gimp_image_undo_push_channel_remove (gimage, _("Remove Channel"),
|
||||
channel,
|
||||
gimp_container_get_child_index (gimage->channels,
|
||||
GIMP_OBJECT (channel)),
|
||||
gimp_image_get_active_channel (gimage));
|
||||
channel, index, active_channel);
|
||||
|
||||
g_object_ref (channel);
|
||||
|
||||
gimp_container_remove (gimage->channels, GIMP_OBJECT (channel));
|
||||
|
||||
/* Send out REMOVED signal from channel */
|
||||
gimp_item_removed (GIMP_ITEM (channel));
|
||||
|
||||
if (channel == gimp_image_get_active_channel (gimage))
|
||||
if (channel == active_channel)
|
||||
{
|
||||
if (gimp_container_num_children (gimage->channels) > 0)
|
||||
gint n_children = gimp_container_num_children (gimage->channels);
|
||||
|
||||
if (n_children > 0)
|
||||
{
|
||||
gimp_image_set_active_channel
|
||||
(gimage,
|
||||
GIMP_CHANNEL (gimp_container_get_child_by_index (gimage->channels,
|
||||
0)));
|
||||
index = CLAMP (index, 0, n_children - 1);
|
||||
|
||||
active_channel = (GimpChannel *)
|
||||
gimp_container_get_child_by_index (gimage->channels, index);
|
||||
|
||||
gimp_image_set_active_channel (gimage, active_channel);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -2919,6 +2915,8 @@ gimp_image_add_vectors (GimpImage *gimage,
|
|||
GimpVectors *vectors,
|
||||
gint position)
|
||||
{
|
||||
GimpVectors *active_vectors;
|
||||
|
||||
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), FALSE);
|
||||
g_return_val_if_fail (GIMP_IS_VECTORS (vectors), FALSE);
|
||||
|
||||
|
@ -2937,29 +2935,22 @@ gimp_image_add_vectors (GimpImage *gimage,
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
active_vectors = gimp_image_get_active_vectors (gimage);
|
||||
|
||||
gimp_image_undo_push_vectors_add (gimage, _("Add Path"),
|
||||
vectors, 0,
|
||||
gimp_image_get_active_vectors (gimage));
|
||||
vectors, 0, active_vectors);
|
||||
|
||||
gimp_item_set_image (GIMP_ITEM (vectors), gimage);
|
||||
|
||||
/* add the layer to the list at the specified position */
|
||||
if (position == -1)
|
||||
{
|
||||
GimpVectors *active_vectors;
|
||||
|
||||
active_vectors = gimp_image_get_active_vectors (gimage);
|
||||
|
||||
if (active_vectors)
|
||||
{
|
||||
position = gimp_container_get_child_index (gimage->vectors,
|
||||
GIMP_OBJECT (active_vectors));
|
||||
}
|
||||
else
|
||||
{
|
||||
position = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/* Don't add at a non-existing index */
|
||||
if (position > gimp_container_num_children (gimage->vectors))
|
||||
|
@ -2978,39 +2969,44 @@ void
|
|||
gimp_image_remove_vectors (GimpImage *gimage,
|
||||
GimpVectors *vectors)
|
||||
{
|
||||
GimpVectors *active_vectors;
|
||||
gint index;
|
||||
|
||||
g_return_if_fail (GIMP_IS_IMAGE (gimage));
|
||||
g_return_if_fail (GIMP_IS_VECTORS (vectors));
|
||||
|
||||
g_return_if_fail (gimp_container_have (gimage->vectors,
|
||||
GIMP_OBJECT (vectors)));
|
||||
|
||||
active_vectors = gimp_image_get_active_vectors (gimage);
|
||||
|
||||
index = gimp_container_get_child_index (gimage->vectors,
|
||||
GIMP_OBJECT (vectors));
|
||||
|
||||
gimp_image_undo_push_vectors_remove (gimage, _("Remove Path"),
|
||||
vectors,
|
||||
gimp_container_get_child_index (gimage->vectors,
|
||||
GIMP_OBJECT (vectors)),
|
||||
gimp_image_get_active_vectors (gimage));
|
||||
vectors, index, active_vectors);
|
||||
|
||||
g_object_ref (vectors);
|
||||
|
||||
gimp_container_remove (gimage->vectors, GIMP_OBJECT (vectors));
|
||||
|
||||
/* Send out REMOVED signal from vectors */
|
||||
gimp_item_removed (GIMP_ITEM (vectors));
|
||||
|
||||
if (vectors == gimp_image_get_active_vectors (gimage))
|
||||
if (vectors == active_vectors)
|
||||
{
|
||||
if (gimp_container_num_children (gimage->vectors) > 0)
|
||||
gint n_children = gimp_container_num_children (gimage->vectors);
|
||||
|
||||
if (n_children > 0)
|
||||
{
|
||||
gimp_image_set_active_vectors
|
||||
(gimage,
|
||||
GIMP_VECTORS (gimp_container_get_child_by_index (gimage->vectors,
|
||||
0)));
|
||||
index = CLAMP (index, 0, n_children - 1);
|
||||
|
||||
active_vectors = (GimpVectors *)
|
||||
gimp_container_get_child_by_index (gimage->vectors, index);
|
||||
}
|
||||
else
|
||||
{
|
||||
gimage->active_vectors = NULL;
|
||||
g_signal_emit (gimage, gimp_image_signals[ACTIVE_VECTORS_CHANGED], 0);
|
||||
active_vectors = NULL;
|
||||
}
|
||||
|
||||
gimp_image_set_active_vectors (gimage, active_vectors);
|
||||
}
|
||||
|
||||
g_object_unref (vectors);
|
||||
|
|
|
@ -70,12 +70,6 @@ floating_sel_attach (GimpLayer *layer,
|
|||
GIMP_ITEM (layer)->height,
|
||||
gimp_drawable_bytes (drawable));
|
||||
|
||||
/* Set gimage->floating_sel *before* adding the floating layer to
|
||||
* the image so views can recognize the newly added floating layer
|
||||
* and treat it accordingly.
|
||||
*/
|
||||
gimage->floating_sel = layer;
|
||||
|
||||
/* add the layer to the gimage */
|
||||
gimp_image_add_layer (gimage, layer, 0);
|
||||
|
||||
|
|
|
@ -217,12 +217,16 @@ layer_select_advance (LayerSelect *layer_select,
|
|||
|
||||
if (next_layer && next_layer != current_layer)
|
||||
{
|
||||
gimp_preview_set_viewable (GIMP_PREVIEW (layer_select->preview),
|
||||
GIMP_VIEWABLE (next_layer));
|
||||
gtk_label_set_text (GTK_LABEL (layer_select->label),
|
||||
GIMP_OBJECT (next_layer)->name);
|
||||
current_layer = gimp_image_set_active_layer (layer_select->gimage,
|
||||
next_layer);
|
||||
|
||||
gimp_image_set_active_layer (layer_select->gimage, next_layer);
|
||||
if (current_layer)
|
||||
{
|
||||
gimp_preview_set_viewable (GIMP_PREVIEW (layer_select->preview),
|
||||
GIMP_VIEWABLE (current_layer));
|
||||
gtk_label_set_text (GTK_LABEL (layer_select->label),
|
||||
GIMP_OBJECT (current_layer)->name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -536,9 +536,7 @@ channel_get_color_invoker (Gimp *gimp,
|
|||
success = FALSE;
|
||||
|
||||
if (success)
|
||||
{
|
||||
gimp_channel_get_color (channel, &color);
|
||||
}
|
||||
|
||||
return_args = procedural_db_return_args (&channel_get_color_proc, success);
|
||||
|
||||
|
|
|
@ -2893,7 +2893,7 @@ image_set_active_layer_invoker (Gimp *gimp,
|
|||
success = FALSE;
|
||||
|
||||
if (success)
|
||||
gimp_image_set_active_layer (gimage, active_layer);
|
||||
success = (gimp_image_set_active_layer (gimage, active_layer) == active_layer);
|
||||
|
||||
return procedural_db_return_args (&image_set_active_layer_proc, success);
|
||||
}
|
||||
|
@ -3003,7 +3003,7 @@ image_set_active_channel_invoker (Gimp *gimp,
|
|||
success = FALSE;
|
||||
|
||||
if (success)
|
||||
gimp_image_set_active_channel (gimage, active_channel);
|
||||
success = (gimp_image_set_active_channel (gimage, active_channel) == active_channel);
|
||||
|
||||
return procedural_db_return_args (&image_set_active_channel_proc, success);
|
||||
}
|
||||
|
|
|
@ -53,16 +53,8 @@ sub channel_get_prop_proc {
|
|||
$outargs[0]->{alias} .= "$alias";
|
||||
|
||||
if ($type eq 'color') {
|
||||
$outargs[0]->{init} = 1;
|
||||
delete @{$outargs[0]}{qw(alias no_declare)};
|
||||
|
||||
$invoke{headers} = [ qw("core/gimpimage.h") ];
|
||||
|
||||
$invoke{code} = <<'CODE'
|
||||
{
|
||||
gimp_channel_get_color (channel, &color);
|
||||
}
|
||||
CODE
|
||||
$invoke{code} = 'gimp_channel_get_color (channel, &color);';
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -92,8 +84,7 @@ sub channel_set_prop_proc {
|
|||
: "gimp_${core_type}_set_$prop ($core_var, $prop);";
|
||||
|
||||
if ($type eq 'color') {
|
||||
%invoke = (
|
||||
code => <<'CODE'
|
||||
$invoke{code} = <<'CODE'
|
||||
{
|
||||
GimpRGB rgb_color = color;
|
||||
|
||||
|
@ -101,7 +92,6 @@ sub channel_set_prop_proc {
|
|||
gimp_channel_set_color (channel, &rgb_color, TRUE);
|
||||
}
|
||||
CODE
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -135,17 +135,6 @@ sub image_get_prop_proc {
|
|||
my $alias = $func ? "gimp_image_get_$prop (gimage)" : "gimage->$prop";
|
||||
$alias = "g_strdup ($alias)" if $type eq 'string';
|
||||
$outargs[0]->{alias} .= "$alias";
|
||||
|
||||
if ($type eq 'color') {
|
||||
$outargs[0]->{init} = 1;
|
||||
delete @{$outargs[0]}{qw(alias no_declare)};
|
||||
|
||||
$invoke{code} = "{\n color = g_new (guchar, 3);\n";
|
||||
foreach (map { "${_}_PIX" } qw(RED GREEN BLUE)) {
|
||||
$invoke{code} .= " $prop\[$_] = image->col[$_];\n";
|
||||
}
|
||||
$invoke{code} .= "}\n";
|
||||
}
|
||||
}
|
||||
|
||||
sub image_set_prop_proc {
|
||||
|
@ -173,16 +162,6 @@ sub image_set_prop_proc {
|
|||
|
||||
$invoke{code} = $func ? "gimp_image_set_$prop (gimage, $prop);"
|
||||
: "gimage->$prop = $prop;";
|
||||
|
||||
if ($type eq 'color') {
|
||||
%invoke = (
|
||||
vars => [ 'int i' ],
|
||||
code => <<CODE
|
||||
for (i = 0; i < 3; i++)
|
||||
gimage->col[i] = $prop\[i];
|
||||
CODE
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
sub image_accessors {
|
||||
|
@ -1123,11 +1102,14 @@ channel is currently active, then no layer will be. If a layer mask is active,
|
|||
then this will return the associated layer.
|
||||
HELP
|
||||
CODE1
|
||||
$invoke{code} =~ s/;//g;
|
||||
$invoke{code} = "success = ($invoke{code} == active_layer);";
|
||||
|
||||
$help = <<'HELP';
|
||||
If the layer exists, it is set as the active layer in the image. Any previous
|
||||
active layer or channel is set to inactive. An exception is a previously
|
||||
existing floating selection, in which case this procedure will return an
|
||||
execution error.
|
||||
If the layer exists, it is set as the active layer in the image. Any
|
||||
previous active layer or channel is set to inactive. An exception is a
|
||||
previously existing floating selection, in which case this procedure
|
||||
will return an execution error.
|
||||
HELP
|
||||
CODE2
|
||||
|
||||
|
@ -1142,11 +1124,14 @@ CODE2
|
|||
If there is an active channel, this will return the channel ID, otherwise, -1.
|
||||
HELP
|
||||
CODE1
|
||||
$invoke{code} =~ s/;//g;
|
||||
$invoke{code} = "success = ($invoke{code} == active_channel);";
|
||||
|
||||
$help = <<'HELP';
|
||||
If the channel exists, it is set as the active channel in the image. Any
|
||||
previous active channel or channel is set to inactive. An exception is a
|
||||
previously existing floating selection, in which case this procedure will
|
||||
return an execution error.
|
||||
If the channel exists, it is set as the active channel in the
|
||||
image. Any previous active channel or channel is set to inactive. An
|
||||
exception is a previously existing floating selection, in which case
|
||||
this procedure will return an execution error.
|
||||
HELP
|
||||
CODE2
|
||||
|
||||
|
|
|
@ -129,19 +129,6 @@ sub layer_get_prop_proc {
|
|||
my $alias = "gimp_${core_type}_get_$prop ($core_var)";
|
||||
$alias = "g_strdup ($alias)" if $type eq 'string';
|
||||
$outargs[0]->{alias} .= "$alias";
|
||||
|
||||
if ($type eq 'color') {
|
||||
$outargs[0]->{init} = 1;
|
||||
delete @{$outargs[0]}{qw(alias no_declare)};
|
||||
|
||||
$invoke{headers} = [ qw("gimpimage.h") ];
|
||||
|
||||
$invoke{code} = "{\n color = g_new (guchar, 3);\n";
|
||||
foreach (map { "${_}_PIX" } qw(RED GREEN BLUE)) {
|
||||
$invoke{code} .= " $prop\[$_] = layer->col[$_];\n";
|
||||
}
|
||||
$invoke{code} .= "}\n";
|
||||
}
|
||||
}
|
||||
|
||||
sub layer_set_prop_proc {
|
||||
|
@ -168,16 +155,6 @@ sub layer_set_prop_proc {
|
|||
|
||||
$invoke{code} = $undo ? "gimp_${core_type}_set_$prop ($core_var, $prop, TRUE);"
|
||||
: "gimp_${core_type}_set_$prop ($core_var, $prop);";
|
||||
|
||||
if ($type eq 'color') {
|
||||
%invoke = (
|
||||
vars => [ 'int i' ],
|
||||
code => <<CODE
|
||||
for (i = 0; i < 3; i++)
|
||||
layer->col[i] = $prop\[i];
|
||||
CODE
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
sub layer_accessors {
|
||||
|
|
Loading…
Reference in a new issue