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

added GIMP_UNDO_CHANNEL_COLOR.

2003-03-17  Michael Natterer  <mitch@gimp.org>

	* app/core/core-enums.[ch]: added GIMP_UNDO_CHANNEL_COLOR.

	* app/core/gimpchannel.[ch]: added "gboolean push_undo" to
	gimp_channel_set_color().

	* app/core/gimpimage-undo-push.[ch]: added
	gimp_image_undo_push_channel_color().

	* app/core/gimpimage-qmask.c
	* app/gui/qmask-commands.c
	* app/widgets/gimpchannellistitem.c
	* tools/pdbgen/pdb/channel.pdb: changed accordingly.

	* app/gui/channels-commands.c
	* app/gui/layers-commands.c
	* app/gui/vectors-commands.c: ditto. Use gimp_item_rename().

	* app/pdb/channel_cmds.c: regenerated.
parent 6e41b136
2003-03-17 Michael Natterer <mitch@gimp.org>
* app/core/core-enums.[ch]: added GIMP_UNDO_CHANNEL_COLOR.
* app/core/gimpchannel.[ch]: added "gboolean push_undo" to
gimp_channel_set_color().
* app/core/gimpimage-undo-push.[ch]: added
gimp_image_undo_push_channel_color().
* app/core/gimpimage-qmask.c
* app/gui/qmask-commands.c
* app/widgets/gimpchannellistitem.c
* tools/pdbgen/pdb/channel.pdb: changed accordingly.
* app/gui/channels-commands.c
* app/gui/layers-commands.c
* app/gui/vectors-commands.c: ditto. Use gimp_item_rename().
* app/pdb/channel_cmds.c: regenerated.
2003-03-17 Manish Singh <yosh@gimp.org>
* tools/pdbgen/pdb/channel.pdb
......@@ -33,7 +33,6 @@
#include "core/gimpimage.h"
#include "core/gimpimage-mask.h"
#include "core/gimpimage-undo.h"
#include "core/gimpimage-undo-push.h"
#include "core/gimpimage-mask-select.h"
#include "widgets/gimpcolorpanel.h"
......@@ -478,27 +477,36 @@ edit_channel_query_ok_callback (GtkWidget *widget,
{
const gchar *new_name;
GimpRGB color;
gboolean name_changed = FALSE;
gboolean color_changed = FALSE;
new_name = gtk_entry_get_text (GTK_ENTRY (options->name_entry));
if (strcmp (new_name, gimp_object_get_name (GIMP_OBJECT (channel))))
{
gimp_image_undo_push_item_rename (options->gimage,
_("Rename Channel"),
GIMP_ITEM (channel));
gimp_object_set_name (GIMP_OBJECT (channel), new_name);
}
gimp_color_button_get_color (GIMP_COLOR_BUTTON (options->color_panel),
&color);
if (strcmp (new_name, gimp_object_get_name (GIMP_OBJECT (channel))))
name_changed = TRUE;
if (gimp_rgba_distance (&color, &channel->color) > 0.0001)
{
gimp_channel_set_color (channel, &color);
color_changed = TRUE;
if (name_changed && color_changed)
gimp_image_undo_group_start (options->gimage,
GIMP_UNDO_GROUP_ITEM_PROPERTIES,
_("Channel Attributes"));
if (name_changed)
gimp_item_rename (GIMP_ITEM (channel), new_name);
if (color_changed)
gimp_channel_set_color (channel, &color, TRUE);
if (name_changed && color_changed)
gimp_image_undo_group_end (options->gimage);
gimp_image_flush (options->gimage);
}
if (name_changed || color_changed)
gimp_image_flush (options->gimage);
}
gtk_widget_destroy (options->query_box);
......
......@@ -34,7 +34,6 @@
#include "core/gimpimage-mask.h"
#include "core/gimpimage-merge.h"
#include "core/gimpimage-undo.h"
#include "core/gimpimage-undo-push.h"
#include "core/gimplayer.h"
#include "core/gimplayer-floating-sel.h"
#include "core/gimplayermask.h"
......@@ -730,8 +729,9 @@ edit_layer_query_ok_callback (GtkWidget *widget,
GimpLayer *layer;
options = (EditLayerOptions *) data;
layer = options->layer;
if ((layer = options->layer))
if (options->gimage)
{
const gchar *new_name;
......@@ -739,29 +739,11 @@ edit_layer_query_ok_callback (GtkWidget *widget,
if (strcmp (new_name, gimp_object_get_name (GIMP_OBJECT (layer))))
{
gimp_image_undo_group_start (options->gimage,
GIMP_UNDO_GROUP_ITEM_PROPERTIES,
_("Rename Layer"));
if (gimp_layer_is_floating_sel (layer))
{
/* If the layer is a floating selection, make it a layer */
floating_sel_to_layer (layer);
}
gimp_image_undo_push_item_rename (options->gimage,
_("Rename Layer"),
GIMP_ITEM (layer));
gimp_object_set_name (GIMP_OBJECT (layer), new_name);
gimp_image_undo_group_end (options->gimage);
gimp_item_rename (GIMP_ITEM (layer), new_name);
gimp_image_flush (options->gimage);
}
}
gimp_image_flush (options->gimage);
gtk_widget_destroy (options->query_box);
}
......
......@@ -226,7 +226,7 @@ qmask_query_ok_callback (GtkWidget *widget,
if (gimp_rgba_distance (&color, &channel->color) > 0.0001)
{
gimp_channel_set_color (channel, &color);
gimp_channel_set_color (channel, &color, TRUE);
gimp_image_flush (options->gimage);
}
......
......@@ -226,7 +226,7 @@ qmask_query_ok_callback (GtkWidget *widget,
if (gimp_rgba_distance (&color, &channel->color) > 0.0001)
{
gimp_channel_set_color (channel, &color);
gimp_channel_set_color (channel, &color, TRUE);
gimp_image_flush (options->gimage);
}
......
......@@ -32,7 +32,6 @@
#include "core/gimpimage.h"
#include "core/gimpimage-mask.h"
#include "core/gimpimage-mask-select.h"
#include "core/gimpimage-undo-push.h"
#include "core/gimplist.h"
#include "core/gimppaintinfo.h"
#include "core/gimptoolinfo.h"
......@@ -524,11 +523,8 @@ edit_vectors_query_ok_callback (GtkWidget *widget,
if (strcmp (new_name, gimp_object_get_name (GIMP_OBJECT (vectors))))
{
gimp_image_undo_push_item_rename (options->gimage,
_("Rename Path"),
GIMP_ITEM (vectors));
gimp_object_set_name (GIMP_OBJECT (vectors), new_name);
gimp_item_rename (GIMP_ITEM (vectors), new_name);
gimp_image_flush (options->gimage);
}
}
......
......@@ -472,6 +472,7 @@ static const GEnumValue gimp_undo_type_enum_values[] =
{ GIMP_UNDO_CHANNEL_REMOVE, N_("Delete Channel"), "channel-remove" },
{ GIMP_UNDO_CHANNEL_MOD, N_("Channel Mod"), "channel-mod" },
{ GIMP_UNDO_CHANNEL_REPOSITION, N_("Channel Reposition"), "channel-reposition" },
{ GIMP_UNDO_CHANNEL_COLOR, N_("Channel Color"), "channel-color" },
{ GIMP_UNDO_VECTORS_ADD, N_("New Vectors"), "vectors-add" },
{ GIMP_UNDO_VECTORS_REMOVE, N_("Delete Vectors"), "vectors-remove" },
{ GIMP_UNDO_VECTORS_MOD, N_("Vectors Mod"), "vectors-mod" },
......
......@@ -371,6 +371,7 @@ typedef enum /*< pdb-skip >*/
GIMP_UNDO_CHANNEL_REMOVE, /*< desc="Delete Channel" >*/
GIMP_UNDO_CHANNEL_MOD, /*< desc="Channel Mod" >*/
GIMP_UNDO_CHANNEL_REPOSITION, /*< desc="Channel Reposition" >*/
GIMP_UNDO_CHANNEL_COLOR, /*< desc="Channel Color" >*/
GIMP_UNDO_VECTORS_ADD, /*< desc="New Vectors" >*/
GIMP_UNDO_VECTORS_REMOVE, /*< desc="Delete Vectors" >*/
GIMP_UNDO_VECTORS_MOD, /*< desc="Vectors Mod" >*/
......
......@@ -329,13 +329,25 @@ gimp_channel_new_from_component (GimpImage *gimage,
void
gimp_channel_set_color (GimpChannel *channel,
const GimpRGB *color)
const GimpRGB *color,
gboolean push_undo)
{
g_return_if_fail (GIMP_IS_CHANNEL (channel));
g_return_if_fail (color != NULL);
if (gimp_rgba_distance (&channel->color, color) > 0.0001)
{
if (push_undo)
{
GimpImage *gimage;
gimage = gimp_item_get_image (GIMP_ITEM (channel));
if (gimage)
gimp_image_undo_push_channel_color (gimage, _("Set Channel Color"),
channel);
}
channel->color = *color;
gimp_drawable_update (GIMP_DRAWABLE (channel),
......
......@@ -90,7 +90,8 @@ void gimp_channel_set_opacity (GimpChannel *channel,
void gimp_channel_get_color (const GimpChannel *channel,
GimpRGB *color);
void gimp_channel_set_color (GimpChannel *channel,
const GimpRGB *color);
const GimpRGB *color,
gboolean push_undo);
gboolean gimp_channel_get_show_masked (GimpChannel *channel);
void gimp_channel_set_show_masked (GimpChannel *channel,
......
......@@ -329,13 +329,25 @@ gimp_channel_new_from_component (GimpImage *gimage,
void
gimp_channel_set_color (GimpChannel *channel,
const GimpRGB *color)
const GimpRGB *color,
gboolean push_undo)
{
g_return_if_fail (GIMP_IS_CHANNEL (channel));
g_return_if_fail (color != NULL);
if (gimp_rgba_distance (&channel->color, color) > 0.0001)
{
if (push_undo)
{
GimpImage *gimage;
gimage = gimp_item_get_image (GIMP_ITEM (channel));
if (gimage)
gimp_image_undo_push_channel_color (gimage, _("Set Channel Color"),
channel);
}
channel->color = *color;
gimp_drawable_update (GIMP_DRAWABLE (channel),
......
......@@ -90,7 +90,8 @@ void gimp_channel_set_opacity (GimpChannel *channel,
void gimp_channel_get_color (const GimpChannel *channel,
GimpRGB *color);
void gimp_channel_set_color (GimpChannel *channel,
const GimpRGB *color);
const GimpRGB *color,
gboolean push_undo);
gboolean gimp_channel_get_show_masked (GimpChannel *channel);
void gimp_channel_set_show_masked (GimpChannel *channel,
......
......@@ -99,9 +99,10 @@ gimp_image_set_qmask_state (GimpImage *gimage,
FALSE));
gimp_image_mask_clear (gimage, NULL); /* Clear the selection */
gimp_channel_set_color (mask, &color, FALSE);
gimp_item_rename (GIMP_ITEM (mask), "Qmask");
gimp_image_add_channel (gimage, mask, 0);
gimp_channel_set_color (mask, &color);
gimp_object_set_name (GIMP_OBJECT (mask), "Qmask");
}
if (gimage->qmask_inverted)
......
......@@ -99,9 +99,10 @@ gimp_image_set_qmask_state (GimpImage *gimage,
FALSE));
gimp_image_mask_clear (gimage, NULL); /* Clear the selection */
gimp_channel_set_color (mask, &color, FALSE);
gimp_item_rename (GIMP_ITEM (mask), "Qmask");
gimp_image_add_channel (gimage, mask, 0);
gimp_channel_set_color (mask, &color);
gimp_object_set_name (GIMP_OBJECT (mask), "Qmask");
}
if (gimage->qmask_inverted)
......
......@@ -1993,6 +1993,80 @@ undo_free_channel_reposition (GimpUndo *undo,
}
/************************/
/* Channel color Undo */
/************************/
typedef struct _ChannelColorUndo ChannelColorUndo;
struct _ChannelColorUndo
{
GimpChannel *channel;
GimpRGB old_color;
};
static gboolean undo_pop_channel_color (GimpUndo *undo,
GimpUndoMode undo_mode,
GimpUndoAccumulator *accum);
static void undo_free_channel_color (GimpUndo *undo,
GimpUndoMode undo_mode);
gboolean
gimp_image_undo_push_channel_color (GimpImage *gimage,
const gchar *undo_desc,
GimpChannel *channel)
{
GimpUndo *new;
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), FALSE);
g_return_val_if_fail (GIMP_IS_CHANNEL (channel), FALSE);
if ((new = gimp_image_undo_push (gimage,
sizeof (ChannelColorUndo),
sizeof (ChannelColorUndo),
GIMP_UNDO_CHANNEL_COLOR, undo_desc,
TRUE,
undo_pop_channel_color,
undo_free_channel_color)))
{
ChannelColorUndo *ccu;
ccu = new->data;
ccu->channel = channel;
gimp_channel_get_color (channel , &ccu->old_color);
return TRUE;
}
return FALSE;
}
static gboolean
undo_pop_channel_color (GimpUndo *undo,
GimpUndoMode undo_mode,
GimpUndoAccumulator *accum)
{
ChannelColorUndo *ccu;
GimpRGB color;
ccu = (ChannelColorUndo *) undo->data;
gimp_channel_get_color (ccu->channel, &color);
gimp_channel_set_color (ccu->channel, &ccu->old_color, FALSE);
ccu->old_color = color;
return TRUE;
}
static void
undo_free_channel_color (GimpUndo *undo,
GimpUndoMode undo_mode)
{
g_free (undo->data);
}
/*****************************/
/* Add/Remove Vectors Undo */
/*****************************/
......
......@@ -114,6 +114,9 @@ gboolean gimp_image_undo_push_channel_mod (GimpImage *gimage,
gboolean gimp_image_undo_push_channel_reposition (GimpImage *gimage,
const gchar *undo_desc,
GimpChannel *channel);
gboolean gimp_image_undo_push_channel_color (GimpImage *gimage,
const gchar *undo_desc,
GimpChannel *channel);
/* vectors undos */
......
......@@ -33,7 +33,6 @@
#include "core/gimpimage.h"
#include "core/gimpimage-mask.h"
#include "core/gimpimage-undo.h"
#include "core/gimpimage-undo-push.h"
#include "core/gimpimage-mask-select.h"
#include "widgets/gimpcolorpanel.h"
......@@ -478,27 +477,36 @@ edit_channel_query_ok_callback (GtkWidget *widget,
{
const gchar *new_name;
GimpRGB color;
gboolean name_changed = FALSE;
gboolean color_changed = FALSE;
new_name = gtk_entry_get_text (GTK_ENTRY (options->name_entry));
if (strcmp (new_name, gimp_object_get_name (GIMP_OBJECT (channel))))
{
gimp_image_undo_push_item_rename (options->gimage,
_("Rename Channel"),
GIMP_ITEM (channel));
gimp_object_set_name (GIMP_OBJECT (channel), new_name);
}
gimp_color_button_get_color (GIMP_COLOR_BUTTON (options->color_panel),
&color);
if (strcmp (new_name, gimp_object_get_name (GIMP_OBJECT (channel))))
name_changed = TRUE;
if (gimp_rgba_distance (&color, &channel->color) > 0.0001)
{
gimp_channel_set_color (channel, &color);
color_changed = TRUE;
if (name_changed && color_changed)
gimp_image_undo_group_start (options->gimage,
GIMP_UNDO_GROUP_ITEM_PROPERTIES,
_("Channel Attributes"));
if (name_changed)
gimp_item_rename (GIMP_ITEM (channel), new_name);
if (color_changed)
gimp_channel_set_color (channel, &color, TRUE);
if (name_changed && color_changed)
gimp_image_undo_group_end (options->gimage);
gimp_image_flush (options->gimage);
}
if (name_changed || color_changed)
gimp_image_flush (options->gimage);
}
gtk_widget_destroy (options->query_box);
......
......@@ -34,7 +34,6 @@
#include "core/gimpimage-mask.h"
#include "core/gimpimage-merge.h"
#include "core/gimpimage-undo.h"
#include "core/gimpimage-undo-push.h"
#include "core/gimplayer.h"
#include "core/gimplayer-floating-sel.h"
#include "core/gimplayermask.h"
......@@ -730,8 +729,9 @@ edit_layer_query_ok_callback (GtkWidget *widget,
GimpLayer *layer;
options = (EditLayerOptions *) data;
layer = options->layer;
if ((layer = options->layer))
if (options->gimage)
{
const gchar *new_name;
......@@ -739,29 +739,11 @@ edit_layer_query_ok_callback (GtkWidget *widget,
if (strcmp (new_name, gimp_object_get_name (GIMP_OBJECT (layer))))
{
gimp_image_undo_group_start (options->gimage,
GIMP_UNDO_GROUP_ITEM_PROPERTIES,
_("Rename Layer"));
if (gimp_layer_is_floating_sel (layer))
{
/* If the layer is a floating selection, make it a layer */
floating_sel_to_layer (layer);
}
gimp_image_undo_push_item_rename (options->gimage,
_("Rename Layer"),
GIMP_ITEM (layer));
gimp_object_set_name (GIMP_OBJECT (layer), new_name);
gimp_image_undo_group_end (options->gimage);
gimp_item_rename (GIMP_ITEM (layer), new_name);
gimp_image_flush (options->gimage);
}
}
gimp_image_flush (options->gimage);
gtk_widget_destroy (options->query_box);
}
......
......@@ -226,7 +226,7 @@ qmask_query_ok_callback (GtkWidget *widget,
if (gimp_rgba_distance (&color, &channel->color) > 0.0001)
{
gimp_channel_set_color (channel, &color);
gimp_channel_set_color (channel, &color, TRUE);
gimp_image_flush (options->gimage);
}
......
......@@ -32,7 +32,6 @@
#include "core/gimpimage.h"
#include "core/gimpimage-mask.h"
#include "core/gimpimage-mask-select.h"
#include "core/gimpimage-undo-push.h"
#include "core/gimplist.h"
#include "core/gimppaintinfo.h"
#include "core/gimptoolinfo.h"
......@@ -524,11 +523,8 @@ edit_vectors_query_ok_callback (GtkWidget *widget,
if (strcmp (new_name, gimp_object_get_name (GIMP_OBJECT (vectors))))
{
gimp_image_undo_push_item_rename (options->gimage,
_("Rename Path"),
GIMP_ITEM (vectors));
gimp_object_set_name (GIMP_OBJECT (vectors), new_name);
gimp_item_rename (GIMP_ITEM (vectors), new_name);
gimp_image_flush (options->gimage);
}
}
......
......@@ -870,7 +870,7 @@ channel_set_color_invoker (Gimp *gimp,
GimpRGB rgb_color = color;
rgb_color.a = channel->color.a;
gimp_channel_set_color(channel, &rgb_color);
gimp_channel_set_color (channel, &rgb_color, TRUE);
}
return procedural_db_return_args (&channel_set_color_proc, success);
......
......@@ -93,7 +93,7 @@ gimp_channel_list_item_drop_color (GtkWidget *widget,
channel =
GIMP_CHANNEL (GIMP_PREVIEW (GIMP_LIST_ITEM (widget)->preview)->viewable);
gimp_channel_set_color (channel, color);
gimp_channel_set_color (channel, color, TRUE);
gimp_image_flush (gimp_item_get_image (GIMP_ITEM (channel)));
}
......@@ -98,7 +98,7 @@ sub channel_set_prop_proc {
GimpRGB rgb_color = color;
rgb_color.a = channel->color.a;
gimp_channel_set_color(channel, &rgb_color);
gimp_channel_set_color (channel, &rgb_color, TRUE);
}
CODE
);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment