Commit af76f2bb authored by Michael Natterer's avatar Michael Natterer 😴 Committed by Michael Natterer

removed the layer mask functions.

2001-03-06  Michael Natterer  <mitch@gimp.org>

	* app/gimage.[ch]: removed the layer mask functions.

	* app/gimpchannel.[ch]: added a boolean "dummy" parameter to
	gimp_channel_copy() so it has the same signature as
	gimp_layer_copy() and can be used by the GimpDrawableListView to
	generically duplicate drawables.

	* app/gimpcontainerview.c: call "select_item" with a NULL item
	before changing the underlying GimpContainer so subclasses have
	a chance to update (e.g. set button sensitivity).

	* app/gimpdnd.c: folded all the GtkType comparing code into a
	utility function (much more readable now).

	* app/gimpdrawablelistview.[ch]: activated the "raise", "lower",
	"duplicate" and "delete". I'm not really happy with all those
	function pointers passed to the constructor (and the dummy
	parameters I've added to some GimpChannel functions) -- OTOH the
	generic view maybe worth the "gboolean dummy" cruft hanging around
	in the channel class.

	* app/gimplayer.[ch]: removed the "apply_mask", "edit_mask" and
	"show_mask" booleans ...

	* app/gimplayermask.[ch]: .. and added them here together with
	proper accessors and "*_changed" signals.

	This also makes the layer mask undo code much clearer as we don't
	have to store the booleans separately.

	* app/gimplayerlistitem.c: badly hacked to acheive the correct
	indicator being drawn around the active drawable. This needs
	a new GimpPreview function for setting the border color.

	* app/gimplistitem.c: smaller horizontal spacing.

	* app/gimppreview.[ch]: added the "border_width" parameter also to
	gimp_preview_set_size() so we can modify all previews the same way
	after creation.

	* app/layers_dialog.c: no need to push an undo group around
	the "duplicate layer" code. Was this an artefact or did I miss
	something here ???

	* app/channel_ops.c
	* app/channels_dialog.c
	* app/gimage_mask.c
	* app/gimpcontainergridview.c
	* app/gimpcontainerlistview.c
	* app/gimpdrawablelistitem.c
	* app/gimpimage.[ch]
	* app/qmask.c
	* app/test_commands.c
	* app/undo.c
	* app/xcf.c
	* app/pdb/channel_cmds.c
	* tools/pdbgen/pdb/channel.pdb
	* app/pdb/selection_cmds.c
	* tools/pdbgen/pdb/selection.pdb: changed accordingly.

	* app/pdb/internal_procs.c
	* app/pdb/layer_cmds.c
	* libgimp/gimplayer_pdb.[ch]
	* tools/pdbgen/pdb/layer.pdb: commented out the layer mask accessors
	from the perl code, so the functions temporarily disappeared all
	over the place.

	* plug-ins/Makefile.am: don't build XJT until the layer mask stuff
	is back.

	* pixmaps/eye.xpm: cropped it to it's minimal size.
parent 75e8e387
2001-03-06 Michael Natterer <mitch@gimp.org>
* app/gimage.[ch]: removed the layer mask functions.
* app/gimpchannel.[ch]: added a boolean "dummy" parameter to
gimp_channel_copy() so it has the same signature as
gimp_layer_copy() and can be used by the GimpDrawableListView to
generically duplicate drawables.
* app/gimpcontainerview.c: call "select_item" with a NULL item
before changing the underlying GimpContainer so subclasses have
a chance to update (e.g. set button sensitivity).
* app/gimpdnd.c: folded all the GtkType comparing code into a
utility function (much more readable now).
* app/gimpdrawablelistview.[ch]: activated the "raise", "lower",
"duplicate" and "delete" buttons. I'm not really happy with all
those function pointers passed to the constructor (and the dummy
parameters I've added to some GimpChannel functions) -- OTOH the
generic view maybe worth the "gboolean dummy" cruft hanging around
in the channel class.
* app/gimplayer.[ch]: removed the "apply_mask", "edit_mask" and
"show_mask" booleans ...
* app/gimplayermask.[ch]: .. and added them here together with
proper accessors and "*_changed" signals.
This also makes the layer mask undo code much clearer as we don't
have to store the booleans separately.
* app/gimplayerlistitem.c: badly hacked to acheive the correct
indicator being drawn around the active drawable. This needs
a new GimpPreview function for setting the border color.
* app/gimplistitem.c: smaller horizontal spacing.
* app/gimppreview.[ch]: added the "border_width" parameter also to
gimp_preview_set_size() so we can modify all previews the same way
after creation.
* app/layers_dialog.c: no need to push an undo group around
the "duplicate layer" code. Was this an artefact or did I miss
something here ???
* app/channel_ops.c
* app/channels_dialog.c
* app/gimage_mask.c
* app/gimpcontainergridview.c
* app/gimpcontainerlistview.c
* app/gimpdrawablelistitem.c
* app/gimpimage.[ch]
* app/qmask.c
* app/test_commands.c
* app/undo.c
* app/xcf.c
* app/pdb/channel_cmds.c
* tools/pdbgen/pdb/channel.pdb
* app/pdb/selection_cmds.c
* tools/pdbgen/pdb/selection.pdb: changed accordingly.
* app/pdb/internal_procs.c
* app/pdb/layer_cmds.c
* libgimp/gimplayer_pdb.[ch]
* tools/pdbgen/pdb/layer.pdb: commented out the layer mask accessors
from the perl code, so the functions temporarily disappeared all
over the place.
* plug-ins/Makefile.am: don't build XJT until the layer mask stuff
is back.
* pixmaps/eye.xpm: cropped it to it's minimal size.
2001-03-05 Sven Neumann <sven@gimp.org>
* app/Makefile.am
......
......@@ -244,7 +244,7 @@ qmask_activate (GtkWidget *widget,
{
/* if selection */
gmask = gimp_channel_copy (gimp_image_get_mask (gimg));
gmask = gimp_channel_copy (gimp_image_get_mask (gimg), TRUE);
gimp_image_add_channel (gimg, gmask, 0);
gimp_channel_set_color (gmask, &color);
gimp_object_set_name (GIMP_OBJECT (gmask), "Qmask");
......
......@@ -244,7 +244,7 @@ qmask_activate (GtkWidget *widget,
{
/* if selection */
gmask = gimp_channel_copy (gimp_image_get_mask (gimg));
gmask = gimp_channel_copy (gimp_image_get_mask (gimg), TRUE);
gimp_image_add_channel (gimg, gmask, 0);
gimp_channel_set_color (gmask, &color);
gimp_object_set_name (GIMP_OBJECT (gmask), "Qmask");
......
......@@ -648,7 +648,7 @@ duplicate (GimpImage *gimage)
{
channel = (GimpChannel *) list->data;
new_channel = gimp_channel_copy (channel);
new_channel = gimp_channel_copy (channel, TRUE);
gimp_drawable_set_gimage (GIMP_DRAWABLE (new_channel), new_gimage);
......
......@@ -1076,7 +1076,7 @@ channels_dialog_duplicate_channel_callback (GtkWidget *widget,
if ((active_channel = gimp_image_get_active_channel (gimage)))
{
new_channel = gimp_channel_copy (active_channel);
new_channel = gimp_channel_copy (active_channel, TRUE);
gimp_image_add_channel (gimage, new_channel, -1);
gdisplays_flush ();
}
......@@ -1129,7 +1129,7 @@ channels_dialog_add_channel_to_sel_callback (GtkWidget *widget,
if ((active_channel = gimp_image_get_active_channel (gimage)))
{
new_channel = gimp_channel_copy (gimp_image_get_mask (gimage));
new_channel = gimp_channel_copy (gimp_image_get_mask (gimage), TRUE);
gimp_channel_combine_mask (new_channel,
active_channel,
CHANNEL_OP_ADD,
......@@ -1153,7 +1153,7 @@ channels_dialog_sub_channel_from_sel_callback (GtkWidget *widget,
if ((active_channel = gimp_image_get_active_channel (gimage)))
{
new_channel = gimp_channel_copy (gimp_image_get_mask (gimage));
new_channel = gimp_channel_copy (gimp_image_get_mask (gimage), TRUE);
gimp_channel_combine_mask (new_channel,
active_channel,
CHANNEL_OP_SUB,
......@@ -1177,7 +1177,7 @@ channels_dialog_intersect_channel_with_sel_callback (GtkWidget *widget,
if ((active_channel = gimp_image_get_active_channel (gimage)))
{
new_channel = gimp_channel_copy (gimp_image_get_mask (gimage));
new_channel = gimp_channel_copy (gimp_image_get_mask (gimage), TRUE);
gimp_channel_combine_mask (new_channel,
active_channel,
CHANNEL_OP_INTERSECT,
......@@ -1675,7 +1675,7 @@ channel_widget_idle_drop_channel (gpointer data)
cd = (ChannelDrop *) data;
gimp_image_position_channel (cd->gimage, cd->channel, cd->dest_index);
gimp_image_position_channel (cd->gimage, cd->channel, cd->dest_index, TRUE);
gdisplays_flush ();
g_free (cd);
......
......@@ -174,7 +174,13 @@ gimp_channel_new (GimpImage *gimage,
}
GimpChannel *
gimp_channel_copy (const GimpChannel *channel)
gimp_channel_copy (const GimpChannel *channel,
gboolean dummy) /* the dummy is for symmetry with
* gimp_layer_copy() because
* both functions are used as
* function pointers in
* GimpDrawableListView --Mitch
*/
{
gchar *channel_name;
GimpChannel *new_channel;
......
......@@ -90,7 +90,8 @@ GimpChannel * gimp_channel_new (GimpImage *gimage,
gint height,
const gchar *name,
const GimpRGB *color);
GimpChannel * gimp_channel_copy (const GimpChannel *channel);
GimpChannel * gimp_channel_copy (const GimpChannel *channel,
gboolean dummy);
gint gimp_channel_get_opacity (const GimpChannel *channel);
void gimp_channel_set_opacity (GimpChannel *channel,
......
......@@ -174,7 +174,13 @@ gimp_channel_new (GimpImage *gimage,
}
GimpChannel *
gimp_channel_copy (const GimpChannel *channel)
gimp_channel_copy (const GimpChannel *channel,
gboolean dummy) /* the dummy is for symmetry with
* gimp_layer_copy() because
* both functions are used as
* function pointers in
* GimpDrawableListView --Mitch
*/
{
gchar *channel_name;
GimpChannel *new_channel;
......
......@@ -90,7 +90,8 @@ GimpChannel * gimp_channel_new (GimpImage *gimage,
gint height,
const gchar *name,
const GimpRGB *color);
GimpChannel * gimp_channel_copy (const GimpChannel *channel);
GimpChannel * gimp_channel_copy (const GimpChannel *channel,
gboolean dummy);
gint gimp_channel_get_opacity (const GimpChannel *channel);
void gimp_channel_set_opacity (GimpChannel *channel,
......
......@@ -648,7 +648,7 @@ duplicate (GimpImage *gimage)
{
channel = (GimpChannel *) list->data;
new_channel = gimp_channel_copy (channel);
new_channel = gimp_channel_copy (channel, TRUE);
gimp_drawable_set_gimage (GIMP_DRAWABLE (new_channel), new_gimage);
......
......@@ -648,7 +648,7 @@ duplicate (GimpImage *gimage)
{
channel = (GimpChannel *) list->data;
new_channel = gimp_channel_copy (channel);
new_channel = gimp_channel_copy (channel, TRUE);
gimp_drawable_set_gimage (GIMP_DRAWABLE (new_channel), new_gimage);
......
......@@ -1727,7 +1727,7 @@ gimp_image_construct_layers (GimpImage *gimage,
TRUE);
/* If we're showing the layer mask instead of the layer... */
if (layer->mask && layer->show_mask)
if (layer->mask && layer->mask->show_mask)
{
pixel_region_init (&src2PR,
gimp_drawable_data (GIMP_DRAWABLE (layer->mask)),
......@@ -1744,7 +1744,7 @@ gimp_image_construct_layers (GimpImage *gimage,
(x1 - off_x), (y1 - off_y),
(x2 - x1), (y2 - y1), FALSE);
if (layer->mask && layer->apply_mask)
if (layer->mask && layer->mask->apply_mask)
{
pixel_region_init (&maskPR,
gimp_drawable_data (GIMP_DRAWABLE (layer->mask)),
......@@ -3091,7 +3091,7 @@ gimp_image_merge_layers (GimpImage *gimage,
(x4 - x3), (y4 - y3),
FALSE);
if (layer->mask && layer->apply_mask)
if (layer->mask && layer->mask->apply_mask)
{
pixel_region_init (&maskPR,
gimp_drawable_data (GIMP_DRAWABLE (layer->mask)),
......@@ -3336,7 +3336,7 @@ gimp_image_raise_channel (GimpImage *gimage,
return FALSE;
}
return gimp_image_position_channel (gimage, channel, index - 1);
return gimp_image_position_channel (gimage, channel, index - 1, TRUE);
}
gboolean
......@@ -3359,13 +3359,14 @@ gimp_image_lower_channel (GimpImage *gimage,
return FALSE;
}
return gimp_image_position_channel (gimage, channel, index + 1);
return gimp_image_position_channel (gimage, channel, index + 1, TRUE);
}
gboolean
gimp_image_position_channel (GimpImage *gimage,
GimpChannel *channel,
gint new_index)
gint new_index,
gboolean push_undo /* FIXME unused */)
{
gint index;
gint num_channels;
......@@ -3383,11 +3384,7 @@ gimp_image_position_channel (GimpImage *gimage,
num_channels = gimp_container_num_children (gimage->channels);
if (new_index < 0)
new_index = 0;
if (new_index >= num_channels)
new_index = num_channels - 1;
new_index = CLAMP (new_index, 0, num_channels - 1);
if (new_index == index)
return TRUE;
......@@ -3530,7 +3527,7 @@ gimp_image_active_drawable (const GimpImage *gimage)
layer = gimage->active_layer;
if (layer->mask && layer->edit_mask)
if (layer->mask && layer->mask->edit_mask)
return GIMP_DRAWABLE (layer->mask);
else
return GIMP_DRAWABLE (layer);
......@@ -3941,7 +3938,7 @@ gimp_image_get_new_preview (GimpViewable *viewable,
src2PR.data = temp_buf_data (layer_buf) +
(y1 - y) * src2PR.rowstride + (x1 - x) * src2PR.bytes;
if (layer->mask && layer->apply_mask)
if (layer->mask && layer->mask->apply_mask)
{
mask_buf = gimp_viewable_get_preview (GIMP_VIEWABLE (layer->mask),
w, h);
......
......@@ -367,7 +367,8 @@ gboolean gimp_image_lower_channel (GimpImage *gimage,
GimpChannel *channel);
gboolean gimp_image_position_channel (GimpImage *gimage,
GimpChannel *channel,
gint position);
gint new_index,
gboolean push_undo);
gboolean gimp_image_add_channel (GimpImage *gimage,
GimpChannel *channel,
gint position);
......
......@@ -553,7 +553,7 @@ gimage_mask_save (GImage *gimage)
{
GimpChannel *new_channel;
new_channel = gimp_channel_copy (gimp_image_get_mask (gimage));
new_channel = gimp_channel_copy (gimp_image_get_mask (gimage), TRUE);
/* saved selections are not visible by default */
gimp_drawable_set_visible (GIMP_DRAWABLE (new_channel), FALSE);
......
......@@ -1727,7 +1727,7 @@ gimp_image_construct_layers (GimpImage *gimage,
TRUE);
/* If we're showing the layer mask instead of the layer... */
if (layer->mask && layer->show_mask)
if (layer->mask && layer->mask->show_mask)
{
pixel_region_init (&src2PR,
gimp_drawable_data (GIMP_DRAWABLE (layer->mask)),
......@@ -1744,7 +1744,7 @@ gimp_image_construct_layers (GimpImage *gimage,
(x1 - off_x), (y1 - off_y),
(x2 - x1), (y2 - y1), FALSE);
if (layer->mask && layer->apply_mask)
if (layer->mask && layer->mask->apply_mask)
{
pixel_region_init (&maskPR,
gimp_drawable_data (GIMP_DRAWABLE (layer->mask)),
......@@ -3091,7 +3091,7 @@ gimp_image_merge_layers (GimpImage *gimage,
(x4 - x3), (y4 - y3),
FALSE);
if (layer->mask && layer->apply_mask)
if (layer->mask && layer->mask->apply_mask)
{
pixel_region_init (&maskPR,
gimp_drawable_data (GIMP_DRAWABLE (layer->mask)),
......@@ -3336,7 +3336,7 @@ gimp_image_raise_channel (GimpImage *gimage,
return FALSE;
}
return gimp_image_position_channel (gimage, channel, index - 1);
return gimp_image_position_channel (gimage, channel, index - 1, TRUE);
}
gboolean
......@@ -3359,13 +3359,14 @@ gimp_image_lower_channel (GimpImage *gimage,
return FALSE;
}
return gimp_image_position_channel (gimage, channel, index + 1);
return gimp_image_position_channel (gimage, channel, index + 1, TRUE);
}
gboolean
gimp_image_position_channel (GimpImage *gimage,
GimpChannel *channel,
gint new_index)
gint new_index,
gboolean push_undo /* FIXME unused */)
{
gint index;
gint num_channels;
......@@ -3383,11 +3384,7 @@ gimp_image_position_channel (GimpImage *gimage,
num_channels = gimp_container_num_children (gimage->channels);
if (new_index < 0)
new_index = 0;
if (new_index >= num_channels)
new_index = num_channels - 1;
new_index = CLAMP (new_index, 0, num_channels - 1);
if (new_index == index)
return TRUE;
......@@ -3530,7 +3527,7 @@ gimp_image_active_drawable (const GimpImage *gimage)
layer = gimage->active_layer;
if (layer->mask && layer->edit_mask)
if (layer->mask && layer->mask->edit_mask)
return GIMP_DRAWABLE (layer->mask);
else
return GIMP_DRAWABLE (layer);
......@@ -3941,7 +3938,7 @@ gimp_image_get_new_preview (GimpViewable *viewable,
src2PR.data = temp_buf_data (layer_buf) +
(y1 - y) * src2PR.rowstride + (x1 - x) * src2PR.bytes;
if (layer->mask && layer->apply_mask)
if (layer->mask && layer->mask->apply_mask)
{
mask_buf = gimp_viewable_get_preview (GIMP_VIEWABLE (layer->mask),
w, h);
......
......@@ -367,7 +367,8 @@ gboolean gimp_image_lower_channel (GimpImage *gimage,
GimpChannel *channel);
gboolean gimp_image_position_channel (GimpImage *gimage,
GimpChannel *channel,
gint position);
gint new_index,
gboolean push_undo);
gboolean gimp_image_add_channel (GimpImage *gimage,
GimpChannel *channel,
gint position);
......
......@@ -1727,7 +1727,7 @@ gimp_image_construct_layers (GimpImage *gimage,
TRUE);
/* If we're showing the layer mask instead of the layer... */
if (layer->mask && layer->show_mask)
if (layer->mask && layer->mask->show_mask)
{
pixel_region_init (&src2PR,
gimp_drawable_data (GIMP_DRAWABLE (layer->mask)),
......@@ -1744,7 +1744,7 @@ gimp_image_construct_layers (GimpImage *gimage,
(x1 - off_x), (y1 - off_y),
(x2 - x1), (y2 - y1), FALSE);
if (layer->mask && layer->apply_mask)
if (layer->mask && layer->mask->apply_mask)
{
pixel_region_init (&maskPR,
gimp_drawable_data (GIMP_DRAWABLE (layer->mask)),
......@@ -3091,7 +3091,7 @@ gimp_image_merge_layers (GimpImage *gimage,
(x4 - x3), (y4 - y3),
FALSE);
if (layer->mask && layer->apply_mask)
if (layer->mask && layer->mask->apply_mask)
{
pixel_region_init (&maskPR,
gimp_drawable_data (GIMP_DRAWABLE (layer->mask)),
......@@ -3336,7 +3336,7 @@ gimp_image_raise_channel (GimpImage *gimage,
return FALSE;
}
return gimp_image_position_channel (gimage, channel, index - 1);
return gimp_image_position_channel (gimage, channel, index - 1, TRUE);
}
gboolean
......@@ -3359,13 +3359,14 @@ gimp_image_lower_channel (GimpImage *gimage,
return FALSE;
}
return gimp_image_position_channel (gimage, channel, index + 1);
return gimp_image_position_channel (gimage, channel, index + 1, TRUE);
}
gboolean
gimp_image_position_channel (GimpImage *gimage,
GimpChannel *channel,
gint new_index)
gint new_index,
gboolean push_undo /* FIXME unused */)
{
gint index;
gint num_channels;
......@@ -3383,11 +3384,7 @@ gimp_image_position_channel (GimpImage *gimage,
num_channels = gimp_container_num_children (gimage->channels);
if (new_index < 0)
new_index = 0;
if (new_index >= num_channels)
new_index = num_channels - 1;
new_index = CLAMP (new_index, 0, num_channels - 1);
if (new_index == index)
return TRUE;
......@@ -3530,7 +3527,7 @@ gimp_image_active_drawable (const GimpImage *gimage)
layer = gimage->active_layer;
if (layer->mask && layer->edit_mask)
if (layer->mask && layer->mask->edit_mask)
return GIMP_DRAWABLE (layer->mask);
else
return GIMP_DRAWABLE (layer);
......@@ -3941,7 +3938,7 @@ gimp_image_get_new_preview (GimpViewable *viewable,
src2PR.data = temp_buf_data (layer_buf) +
(y1 - y) * src2PR.rowstride + (x1 - x) * src2PR.bytes;
if (layer->mask && layer->apply_mask)
if (layer->mask && layer->mask->apply_mask)
{
mask_buf = gimp_viewable_get_preview (GIMP_VIEWABLE (layer->mask),
w, h);
......
......@@ -367,7 +367,8 @@ gboolean gimp_image_lower_channel (GimpImage *gimage,
GimpChannel *channel);
gboolean gimp_image_position_channel (GimpImage *gimage,
GimpChannel *channel,
gint position);
gint new_index,
gboolean push_undo);
gboolean gimp_image_add_channel (GimpImage *gimage,
GimpChannel *channel,
gint position);
......
......@@ -244,7 +244,7 @@ qmask_activate (GtkWidget *widget,
{
/* if selection */
gmask = gimp_channel_copy (gimp_image_get_mask (gimg));
gmask = gimp_channel_copy (gimp_image_get_mask (gimg), TRUE);
gimp_image_add_channel (gimg, gmask, 0);
gimp_channel_set_color (gmask, &color);
gimp_object_set_name (GIMP_OBJECT (gmask), "Qmask");
......
......@@ -244,7 +244,7 @@ qmask_activate (GtkWidget *widget,
{
/* if selection */
gmask = gimp_channel_copy (gimp_image_get_mask (gimg));
gmask = gimp_channel_copy (gimp_image_get_mask (gimg), TRUE);
gimp_image_add_channel (gimg, gmask, 0);
gimp_channel_set_color (gmask, &color);
gimp_object_set_name (GIMP_OBJECT (gmask), "Qmask");
......
......@@ -1727,7 +1727,7 @@ gimp_image_construct_layers (GimpImage *gimage,
TRUE);
/* If we're showing the layer mask instead of the layer... */
if (layer->mask && layer->show_mask)
if (layer->mask && layer->mask->show_mask)
{
pixel_region_init (&src2PR,
gimp_drawable_data (GIMP_DRAWABLE (layer->mask)),
......@@ -1744,7 +1744,7 @@ gimp_image_construct_layers (GimpImage *gimage,
(x1 - off_x), (y1 - off_y),
(x2 - x1), (y2 - y1), FALSE);
if (layer->mask && layer->apply_mask)
if (layer->mask && layer->mask->apply_mask)
{
pixel_region_init (&maskPR,
gimp_drawable_data (GIMP_DRAWABLE (layer->mask)),
......@@ -3091,7 +3091,7 @@ gimp_image_merge_layers (GimpImage *gimage,
(x4 - x3), (y4 - y3),
FALSE);
if (layer->mask && layer->apply_mask)
if (layer->mask && layer->mask->apply_mask)
{
pixel_region_init (&maskPR,
gimp_drawable_data (GIMP_DRAWABLE (layer->mask)),
......@@ -3336,7 +3336,7 @@ gimp_image_raise_channel (GimpImage *gimage,
return FALSE;
}
return gimp_image_position_channel (gimage, channel, index - 1);
return gimp_image_position_channel (gimage, channel, index - 1, TRUE);
}
gboolean
......@@ -3359,13 +3359,14 @@ gimp_image_lower_channel (GimpImage *gimage,
return FALSE;
}
return gimp_image_position_channel (gimage, channel, index + 1);
return gimp_image_position_channel (gimage, channel, index + 1, TRUE);
}
gboolean
gimp_image_position_channel (GimpImage *gimage,
GimpChannel *channel,
gint new_index)
gint new_index,
gboolean push_undo /* FIXME unused */)
{
gint index;
gint num_channels;
......@@ -3383,11 +3384,7 @@ gimp_image_position_channel (GimpImage *gimage,
num_channels = gimp_container_num_children (gimage->channels);
if (new_index < 0)
new_index = 0;
if (new_index >= num_channels)
new_index = num_channels - 1;
new_index = CLAMP (new_index, 0, num_channels - 1);
if (new_index == index)
return TRUE;
......@@ -3530,7 +3527,7 @@ gimp_image_active_drawable (const GimpImage *gimage)
layer = gimage->active_layer;
if (layer->mask && layer->edit_mask)
if (layer->mask && layer->mask->edit_mask)
return GIMP_DRAWABLE (layer->mask);
else
return GIMP_DRAWABLE (layer);
......@@ -3941,7 +3938,7 @@ gimp_image_get_new_preview (GimpViewable *viewable,
src2PR.data = temp_buf_data (layer_buf) +
(y1 - y) * src2PR.rowstride + (x1 - x) * src2PR.bytes;
if (layer->mask && layer->apply_mask)
if (layer->mask && layer->mask->apply_mask)
{
mask_buf = gimp_viewable_get_preview (GIMP_VIEWABLE (layer->mask),
w, h);
......
......@@ -367,7 +367,8 @@ gboolean gimp_image_lower_channel (GimpImage *gimage,
GimpChannel *channel);
gboolean gimp_image_position_channel (GimpImage *gimage,
GimpChannel *channel,
gint position);
gint new_index,
gboolean push_undo);
gboolean gimp_image_add_channel (GimpImage *gimage,
GimpChannel *channel,
gint position);
......
......@@ -1727,7 +1727,7 @@ gimp_image_construct_layers (GimpImage *gimage,
TRUE);
/* If we're showing the layer mask instead of the layer... */
if (layer->mask && layer->show_mask)
if (layer->mask && layer->mask->show_mask)
{
pixel_region_init (&src2PR,
gimp_drawable_data (GIMP_DRAWABLE (layer->mask)),
......@@ -1744,7 +1744,7 @@ gimp_image_construct_layers (GimpImage *gimage,
(x1 - off_x), (y1 - off_y),
(x2 - x1), (y2 - y1), FALSE);
if (layer->mask && layer->apply_mask)
if (layer->mask && layer->mask->apply_mask)
{
pixel_region_init (&maskPR,
gimp_drawable_data (GIMP_DRAWABLE (layer->mask)),
......@@ -3091,7 +3091,7 @@ gimp_image_merge_layers (GimpImage *gimage,
(x4 - x3), (y4 - y3),
FALSE);
if (layer->mask && layer->apply_mask)
if (layer->mask && layer->mask->apply_mask)
{
pixel_region_init (&maskPR,
gimp_drawable_data (GIMP_DRAWABLE (layer->mask)),
......@@ -3336,7 +3336,7 @@ gimp_image_raise_channel (GimpImage *gimage,
return FALSE;
}
return gimp_image_position_channel (gimage, channel, index - 1);
return gimp_image_position_channel (gimage, channel, index - 1, TRUE);
}
gboolean
......@@ -3359,13 +3359,14 @@ gimp_image_lower_channel (GimpImage *gimage,
return FALSE;
}
return gimp_image_position_channel (gimage, channel, index + 1);
return gimp_image_position_channel (gimage, channel, index + 1, TRUE);
}
gboolean
gimp_image_position_channel (GimpImage *gimage,
GimpChannel *channel,
gint new_index)
gint new_index,
gboolean push_undo /* FIXME unused */)
{
gint index;
gint num_channels;
......@@ -3383,11 +3384,7 @@ gimp_image_position_channel (GimpImage *gimage,
num_channels = gimp_container_num_children (gimage->channels);
if (new_index < 0)
new_index = 0;
if (new_index >= num_channels)
new_index = num_channels - 1;
new_index = CLAMP (new_index, 0, num_channels - 1);
if (new_index == index)
return TRUE;
......@@ -3530,7 +3527,7 @@ gimp_image_active_drawable (const GimpImage *gimage)
layer = gimage->active_layer;
if (layer->mask && layer->edit_mask)
if (layer->mask && layer->mask->edit_mask)
return GIMP_DRAWABLE (layer->mask);
else
return GIMP_DRAWABLE (layer);
......@@ -3941,7 +3938,7 @@ gimp_image_get_new_preview (GimpViewable *viewable,
src2PR.data = temp_buf_data (layer_buf) +
(y1 - y) * src2PR.rowstride + (x1 - x) * src2PR.bytes