renamed undo_push_layer_rename() to undo_push_item_rename(), so

2002-02-26  Michael Natterer  <mitch@gimp.org>

	* app/undo.[ch]: renamed undo_push_layer_rename() to
	undo_push_item_rename(), so channel/vectors renaming is undoable.
	Use "gsize" for all undo size variables. Cleanup.

	* app/undo_types.h: s/LAYER_RENAME_UNDO/ITEM_RENAME_UNDO/.

	* app/core/core-types.h: added LAYER_PROPERTIES_UNDO_GROUP.

	* app/core/gimpimage.c: s/Vectors/Path/ in all user-visible strings.

	* app/core/gimpitem.[ch]: cleanup.

	* app/gui/menus.c: s/"New Path"/"New Path..."/, pass
	"vectors_menu_update" to gimp_item_factory_new().

	* app/gui/layers-commands.c: renaming the floating layer
	transforms it into an ordinary layer. Push an undo group around
	around both the "fs_to_layer" and the renaming.

	* app/gui/channels-commands.c
	* app/gui/vectors-commands.c: made renaming undoable, cleanup.

	* app/widgets/gimpitemlistview.c: added an EEKY hack so "Delete"
	is not broken any more for floating selections. Need a better
	solution...
This commit is contained in:
Michael Natterer 2002-02-26 00:04:55 +00:00 committed by Michael Natterer
parent 86b7e87e56
commit b20880ad38
20 changed files with 528 additions and 421 deletions

View File

@ -1,3 +1,31 @@
2002-02-26 Michael Natterer <mitch@gimp.org>
* app/undo.[ch]: renamed undo_push_layer_rename() to
undo_push_item_rename(), so channel/vectors renaming is undoable.
Use "gsize" for all undo size variables. Cleanup.
* app/undo_types.h: s/LAYER_RENAME_UNDO/ITEM_RENAME_UNDO/.
* app/core/core-types.h: added LAYER_PROPERTIES_UNDO_GROUP.
* app/core/gimpimage.c: s/Vectors/Path/ in all user-visible strings.
* app/core/gimpitem.[ch]: cleanup.
* app/gui/menus.c: s/"New Path"/"New Path..."/, pass
"vectors_menu_update" to gimp_item_factory_new().
* app/gui/layers-commands.c: renaming the floating layer
transforms it into an ordinary layer. Push an undo group around
around both the "fs_to_layer" and the renaming.
* app/gui/channels-commands.c
* app/gui/vectors-commands.c: made renaming undoable, cleanup.
* app/widgets/gimpitemlistview.c: added an EEKY hack so "Delete"
is not broken any more for floating selections. Need a better
solution...
2002-02-25 Sven Neumann <sven@gimp.org>
* tools/pdbgen/pdb/fileops.pdb: changed dot to underscore in

View File

@ -492,16 +492,23 @@ edit_channel_query_ok_callback (GtkWidget *widget,
{
EditChannelOptions *options;
GimpChannel *channel;
GimpRGB color;
options = (EditChannelOptions *) data;
channel = options->channel;
if (options->gimage)
{
/* Set the new channel name */
gimp_object_set_name (GIMP_OBJECT (channel),
gtk_entry_get_text (GTK_ENTRY (options->name_entry)));
const gchar *new_name;
GimpRGB color;
new_name = gtk_entry_get_text (GTK_ENTRY (options->name_entry));
if (strcmp (new_name, gimp_object_get_name (GIMP_OBJECT (channel))))
{
undo_push_item_rename (options->gimage, GIMP_ITEM (channel));
gimp_object_set_name (GIMP_OBJECT (channel), new_name);
}
gimp_color_button_get_color (GIMP_COLOR_BUTTON (options->color_panel),
&color);
@ -672,5 +679,5 @@ channels_menu_update (GtkItemFactory *factory,
SET_SENSITIVE ("/Delete Channel", !fs && channel);
SET_SENSITIVE ("/Edit Channel Attributes...", !fs && channel);
#undef SET_OPS_SENSITIVE
#undef SET_SENSITIVE
}

View File

@ -746,20 +746,27 @@ edit_layer_query_ok_callback (GtkWidget *widget,
if ((layer = options->layer))
{
/* Set the new layer name */
if (GIMP_OBJECT (layer)->name && gimp_layer_is_floating_sel (layer))
const gchar *new_name;
new_name = gtk_entry_get_text (GTK_ENTRY (options->name_entry));
if (strcmp (new_name, gimp_object_get_name (GIMP_OBJECT (layer))))
{
undo_push_group_start (options->gimage, LAYER_PROPERTIES_UNDO_GROUP);
if (gimp_layer_is_floating_sel (layer))
{
/* If the layer is a floating selection, make it a layer */
floating_sel_to_layer (layer);
}
else
{
/* We're doing a plain rename */
undo_push_layer_rename (options->gimage, layer);
}
gimp_object_set_name (GIMP_OBJECT (layer),
gtk_entry_get_text (GTK_ENTRY (options->name_entry)));
undo_push_item_rename (options->gimage, GIMP_ITEM (layer));
gimp_object_set_name (GIMP_OBJECT (layer), new_name);
undo_push_group_end (options->gimage);
}
}
gdisplays_flush ();

View File

@ -458,7 +458,7 @@ vectors_new_vectors_query (GimpImage *gimage,
gtk_box_pack_start (GTK_BOX (vbox), table, FALSE, FALSE, 0);
/* The name entry hbox, label and entry */
label = gtk_label_new (_("Vectors name:"));
label = gtk_label_new (_("Path name:"));
gtk_misc_set_alignment (GTK_MISC (label), 1.0, 0.5);
gtk_table_attach (GTK_TABLE (table), label, 0, 1, 0, 1,
GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 0);
@ -469,7 +469,7 @@ vectors_new_vectors_query (GimpImage *gimage,
gtk_table_attach_defaults (GTK_TABLE (table), options->name_entry,
1, 2, 0, 1);
gtk_entry_set_text (GTK_ENTRY (options->name_entry),
(vectors_name ? vectors_name : _("New Vectors")));
(vectors_name ? vectors_name : _("New Path")));
gtk_widget_show (options->name_entry);
gtk_widget_show (table);
@ -505,9 +505,16 @@ edit_vectors_query_ok_callback (GtkWidget *widget,
if (options->gimage)
{
/* Set the new vectors name */
gimp_object_set_name (GIMP_OBJECT (vectors),
gtk_entry_get_text (GTK_ENTRY (options->name_entry)));
const gchar *new_name;
new_name = gtk_entry_get_text (GTK_ENTRY (options->name_entry));
if (strcmp (new_name, gimp_object_get_name (GIMP_OBJECT (vectors))))
{
undo_push_item_rename (options->gimage, GIMP_ITEM (vectors));
gimp_object_set_name (GIMP_OBJECT (vectors), new_name);
}
}
gtk_widget_destroy (options->query_box);
@ -569,7 +576,7 @@ vectors_edit_vectors_query (GimpVectors *vectors)
gtk_box_pack_start (GTK_BOX (vbox), table, FALSE, FALSE, 0);
/* The name entry */
label = gtk_label_new (_("Vectors name:"));
label = gtk_label_new (_("Path name:"));
gtk_misc_set_alignment (GTK_MISC (label), 1.0, 0.5);
gtk_table_attach (GTK_TABLE (table), label, 0, 1, 0, 1,
GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
@ -595,7 +602,7 @@ vectors_menu_update (GtkItemFactory *factory,
{
GimpImage *gimage;
GimpVectors *vectors;
gboolean fs;
gboolean mask_empty;
GList *list;
GList *next = NULL;
GList *prev = NULL;
@ -604,7 +611,7 @@ vectors_menu_update (GtkItemFactory *factory,
vectors = gimp_image_get_active_vectors (gimage);
fs = (gimp_image_floating_sel (gimage) != NULL);
mask_empty = gimp_image_mask_is_empty (gimage);
for (list = GIMP_LIST (gimage->vectors)->list;
list;
@ -621,16 +628,18 @@ vectors_menu_update (GtkItemFactory *factory,
#define SET_SENSITIVE(menu,condition) \
gimp_item_factory_set_sensitive (factory, menu, (condition) != 0)
SET_SENSITIVE ("/New Vectors...", !fs);
SET_SENSITIVE ("/Raise Vectors", !fs && vectors && prev);
SET_SENSITIVE ("/Lower Vectors", !fs && vectors && next);
SET_SENSITIVE ("/Duplicate Vectors", !fs && vectors);
SET_SENSITIVE ("/Vectors to Selection", !fs && vectors);
SET_SENSITIVE ("/Add to Selection", !fs && vectors);
SET_SENSITIVE ("/Subtract from Selection", !fs && vectors);
SET_SENSITIVE ("/Intersect with Selection", !fs && vectors);
SET_SENSITIVE ("/Delete Vectors", !fs && vectors);
SET_SENSITIVE ("/Edit Vectors Attributes...", !fs && vectors);
SET_SENSITIVE ("/New Path...", TRUE);
SET_SENSITIVE ("/Raise Path", vectors && prev);
SET_SENSITIVE ("/Lower Path", vectors && next);
SET_SENSITIVE ("/Duplicate Path", vectors);
SET_SENSITIVE ("/Path to Selection", vectors);
SET_SENSITIVE ("/Add to Selection", vectors);
SET_SENSITIVE ("/Subtract from Selection", vectors);
SET_SENSITIVE ("/Intersect with Selection", vectors);
SET_SENSITIVE ("/Selection to Path", ! mask_empty);
SET_SENSITIVE ("/Stroke Path", vectors);
SET_SENSITIVE ("/Delete Path", vectors);
SET_SENSITIVE ("/Edit Path Attributes...", vectors);
#undef SET_OPS_SENSITIVE
#undef SET_SENSITIVE
}

View File

@ -142,6 +142,7 @@ typedef enum /*< pdb-skip >*/ /*< skip >*/
IMAGE_LAYERS_MERGE_UNDO_GROUP,
IMAGE_QMASK_UNDO_GROUP,
IMAGE_GUIDE_UNDO_GROUP,
LAYER_PROPERTIES_UNDO_GROUP,
LAYER_SCALE_UNDO_GROUP,
LAYER_RESIZE_UNDO_GROUP,
LAYER_DISPLACE_UNDO_GROUP,

View File

@ -95,7 +95,7 @@ struct _Undo
{
UndoType type; /* undo type */
gpointer data; /* data to implement the undo, NULL for group */
glong bytes; /* size of undo item */
gsize bytes; /* size of undo item */
gboolean dirties_image; /* TRUE if undo mutates image */
gboolean group_boundary; /* TRUE if this is the start/end of a group */
@ -107,7 +107,7 @@ struct _Undo
static const gchar * undo_type_to_name (UndoType undo_type);
static Undo * undo_new (UndoType undo_type,
glong size,
gsize size,
gboolean dirties_image);
@ -195,10 +195,11 @@ remove_stack_bottom (GimpImage *gimage)
/* Allocate and initialise a new Undo. Leaves data and function
* pointers zeroed ready to be filled in by caller. */
* pointers zeroed ready to be filled in by caller.
*/
static Undo *
undo_new (UndoType type,
glong size,
gsize size,
gboolean dirties_image)
{
Undo *new;
@ -232,7 +233,7 @@ undo_free_up_space (GimpImage *gimage)
static Undo *
undo_push (GimpImage *gimage,
glong size,
gsize size,
UndoType type,
gboolean dirties_image)
{
@ -709,7 +710,7 @@ undo_push_image (GimpImage *gimage,
gint y2)
{
Undo *new;
glong size;
gsize size;
x1 = CLAMP (x1, 0, gimp_drawable_width (drawable));
y1 = CLAMP (y1, 0, gimp_drawable_height (drawable));
@ -768,7 +769,7 @@ undo_push_image_mod (GimpImage *gimage,
gboolean sparse)
{
Undo *new;
glong size;
gsize size;
gint dwidth, dheight;
if (! tiles)
@ -1163,14 +1164,12 @@ undo_push_image_mask (GimpImage *gimage,
gint y)
{
Undo *new;
gint size;
gsize size;
size = sizeof (MaskUndo);
if (tiles)
size =
tile_manager_width (tiles) *
tile_manager_height (tiles);
else
size = 0;
size += tile_manager_get_memsize (tiles);
if ((new = undo_push (gimage, size, IMAGE_MASK_UNDO, FALSE)))
{
@ -1439,7 +1438,7 @@ undo_free_image_guide (UndoState state,
{
GuideUndo *data;
data = data_ptr;
data = (GuideUndo *) data_ptr;
data->guide->ref_count--;
if (data->guide->position < 0 && data->guide->ref_count <= 0)
@ -1451,6 +1450,80 @@ undo_free_image_guide (UndoState state,
}
/**********************/
/* Item Rename Undo */
typedef struct _ItemRenameUndo ItemRenameUndo;
struct _ItemRenameUndo
{
GimpItem *item;
gchar *old_name;
};
static gboolean undo_pop_item_rename (GimpImage *,
UndoState, UndoType, gpointer);
static void undo_free_item_rename (UndoState, UndoType, gpointer);
gboolean
undo_push_item_rename (GimpImage *gimage,
GimpItem *item)
{
Undo *new;
if ((new = undo_push (gimage, sizeof (ItemRenameUndo),
ITEM_RENAME_UNDO, TRUE)))
{
ItemRenameUndo *iru;
iru = g_new0 (ItemRenameUndo, 1);
new->data = iru;
new->pop_func = undo_pop_item_rename;
new->free_func = undo_free_item_rename;
iru->item = item;
iru->old_name = g_strdup (gimp_object_get_name (GIMP_OBJECT (item)));
return TRUE;
}
return FALSE;
}
static gboolean
undo_pop_item_rename (GimpImage *gimage,
UndoState state,
UndoType type,
gpointer iru_ptr)
{
ItemRenameUndo *iru;
gchar *tmp;
iru = (ItemRenameUndo *) iru_ptr;
tmp = g_strdup (gimp_object_get_name (GIMP_OBJECT (iru->item)));
gimp_object_set_name (GIMP_OBJECT (iru->item), iru->old_name);
g_free (iru->old_name);
iru->old_name = tmp;
return TRUE;
}
static void
undo_free_item_rename (UndoState state,
UndoType type,
gpointer iru_ptr)
{
ItemRenameUndo *iru;
iru = (ItemRenameUndo *) iru_ptr;
g_free (iru->old_name);
g_free (iru);
}
/***************************/
/* Layer Add/Remove Undo */
@ -1500,7 +1573,7 @@ undo_push_layer (GimpImage *gimage,
GimpLayer *prev_layer)
{
Undo *new;
gint size;
gsize size;
g_return_val_if_fail (type == LAYER_ADD_UNDO ||
type == LAYER_REMOVE_UNDO,
@ -1508,8 +1581,7 @@ undo_push_layer (GimpImage *gimage,
size = sizeof (LayerUndo) + gimp_object_get_memsize (GIMP_OBJECT (layer));
if ((new = undo_push (gimage, size,
type, TRUE)))
if ((new = undo_push (gimage, size, type, TRUE)))
{
LayerUndo *lu;
@ -1541,12 +1613,14 @@ undo_pop_layer (GimpImage *gimage,
lu = (LayerUndo *) lu_ptr;
/* remove layer */
if ((state == UNDO && type == LAYER_ADD_UNDO) ||
(state == REDO && type == LAYER_REMOVE_UNDO))
{
/* remove layer */
/* record the current position */
lu->prev_position = gimp_image_get_layer_index (gimage, lu->layer);
/* set the previous layer */
gimp_image_set_active_layer (gimage, lu->prev_layer);
@ -1569,9 +1643,10 @@ undo_pop_layer (GimpImage *gimage,
GIMP_DRAWABLE (lu->layer)->width,
GIMP_DRAWABLE (lu->layer)->height);
}
/* restore layer */
else
{
/* restore layer */
/* record the active layer */
lu->prev_layer = gimp_image_get_active_layer (gimage);
@ -1638,14 +1713,13 @@ undo_push_layer_mod (GimpImage *gimage,
{
Undo *new;
TileManager *tiles;
gint size;
gsize size;
tiles = GIMP_DRAWABLE (layer)->tiles;
size = sizeof (LayerModUndo) + tile_manager_get_memsize (tiles);
if ((new = undo_push (gimage, size,
LAYER_MOD_UNDO, TRUE)))
if ((new = undo_push (gimage, size, LAYER_MOD_UNDO, TRUE)))
{
LayerModUndo *lmu;
@ -1673,9 +1747,9 @@ static gboolean
undo_pop_layer_mod (GimpImage *gimage,
UndoState state,
UndoType type,
gpointer data_ptr)
gpointer lmu_ptr)
{
LayerModUndo *data;
LayerModUndo *lmu;
gint layer_type;
gint offset_x, offset_y;
TileManager *tiles;
@ -1683,11 +1757,12 @@ undo_pop_layer_mod (GimpImage *gimage,
GimpLayer *layer;
gboolean old_has_alpha;
data = (LayerModUndo *) data_ptr;
layer = data->layer;
tiles = data->tiles;
offset_x = data->offset_x;
offset_y = data->offset_y;
lmu = (LayerModUndo *) lmu_ptr;
layer = lmu->layer;
tiles = lmu->tiles;
offset_x = lmu->offset_x;
offset_y = lmu->offset_y;
/* Issue the first update */
gimp_image_update (gimage,
@ -1699,11 +1774,11 @@ undo_pop_layer_mod (GimpImage *gimage,
/* Create a tile manager to store the current layer contents */
temp = GIMP_DRAWABLE (layer)->tiles;
data->offset_x = GIMP_DRAWABLE (layer)->offset_x;
data->offset_y = GIMP_DRAWABLE (layer)->offset_y;
lmu->offset_x = GIMP_DRAWABLE (layer)->offset_x;
lmu->offset_y = GIMP_DRAWABLE (layer)->offset_y;
layer_type = data->type;
data->type = GIMP_DRAWABLE (layer)->type;
layer_type = lmu->type;
lmu->type = GIMP_DRAWABLE (layer)->type;
old_has_alpha = GIMP_DRAWABLE (layer)->has_alpha;
@ -1729,7 +1804,7 @@ undo_pop_layer_mod (GimpImage *gimage,
}
/* Set the new tile manager */
data->tiles = temp;
lmu->tiles = temp;
/* Issue the second update */
gimp_drawable_update (GIMP_DRAWABLE (layer),
@ -1743,17 +1818,18 @@ undo_pop_layer_mod (GimpImage *gimage,
static void
undo_free_layer_mod (UndoState state,
UndoType type,
gpointer data_ptr)
gpointer lmu_ptr)
{
gpointer *data;
LayerModUndo *lmu;
data = (gpointer *) data_ptr;
tile_manager_destroy ((TileManager *) data[1]);
g_free (data);
lmu = (LayerModUndo *) lmu_ptr;
tile_manager_destroy (lmu->tiles);
g_free (lmu);
}
/*********************************/
/********************************/
/* Layer Mask Add/Remove Undo */
typedef struct _LayerMaskUndo LayerMaskUndo;
@ -1797,7 +1873,7 @@ undo_push_layer_mask (GimpImage *gimage,
GimpLayerMask *mask)
{
Undo *new;
gint size;
gsize size;
g_return_val_if_fail (type == LAYER_MASK_ADD_UNDO ||
type == LAYER_MASK_REMOVE_UNDO,
@ -1805,8 +1881,7 @@ undo_push_layer_mask (GimpImage *gimage,
size = sizeof (LayerMaskUndo) + gimp_object_get_memsize (GIMP_OBJECT (mask));
if ((new = undo_push (gimage, size,
type, TRUE)))
if ((new = undo_push (gimage, size, type, TRUE)))
{
LayerMaskUndo *lmu;
@ -1868,76 +1943,6 @@ undo_free_layer_mask (UndoState state,
}
/**********************/
/* Layer Rename Undo */
typedef struct _LayerRenameUndo LayerRenameUndo;
struct _LayerRenameUndo
{
GimpLayer *layer;
gchar *old_name;
};
static gboolean undo_pop_layer_rename (GimpImage *,
UndoState, UndoType, gpointer);
static void undo_free_layer_rename (UndoState, UndoType, gpointer);
gboolean
undo_push_layer_rename (GimpImage *gimage,
GimpLayer *layer)
{
Undo *new;
if ((new = undo_push (gimage, sizeof (LayerRenameUndo),
LAYER_RENAME_UNDO, TRUE)))
{
LayerRenameUndo *lru;
lru = g_new0 (LayerRenameUndo, 1);
new->data = lru;
new->pop_func = undo_pop_layer_rename;
new->free_func = undo_free_layer_rename;
lru->layer = layer;
lru->old_name = g_strdup (gimp_object_get_name (GIMP_OBJECT (layer)));
return TRUE;
}
return FALSE;
}
static gboolean
undo_pop_layer_rename (GimpImage *gimage,
UndoState state,
UndoType type,
void *data_ptr)
{
LayerRenameUndo *data = data_ptr;
gchar *tmp;
tmp = g_strdup (gimp_object_get_name (GIMP_OBJECT (data->layer)));
gimp_object_set_name (GIMP_OBJECT (data->layer), data->old_name);
g_free (data->old_name);
data->old_name = tmp;
return TRUE;
}
static void
undo_free_layer_rename (UndoState state,
UndoType type,
gpointer data_ptr)
{
LayerRenameUndo *data = data_ptr;
g_free (data->old_name);
g_free (data);
}
/***************************/
/* Layer re-position Undo */
@ -2172,7 +2177,7 @@ undo_push_channel (GimpImage *gimage,
GimpChannel *prev_channel)
{
Undo *new;
gint size;
gsize size;
g_return_val_if_fail (type == CHANNEL_ADD_UNDO ||
type == CHANNEL_REMOVE_UNDO,
@ -2212,10 +2217,11 @@ undo_pop_channel (GimpImage *gimage,
cu = (ChannelUndo *) cu_ptr;
/* remove channel */
if ((state == UNDO && type == CHANNEL_ADD_UNDO) ||
(state == REDO && type == CHANNEL_REMOVE_UNDO))
{
/* remove channel */
/* record the current position */
cu->prev_position = gimp_image_get_channel_index (gimage, cu->channel);
@ -2234,9 +2240,10 @@ undo_pop_channel (GimpImage *gimage,
GIMP_DRAWABLE (cu->channel)->width,
GIMP_DRAWABLE (cu->channel)->height);
}
/* restore channel */
else
{
/* restore channel */
/* record the active channel */
cu->prev_channel = gimp_image_get_active_channel (gimage);
@ -2244,11 +2251,8 @@ undo_pop_channel (GimpImage *gimage,
gimp_container_insert (gimage->channels,
GIMP_OBJECT (cu->channel), cu->prev_position);
if (cu->channel)
{
/* set the new channel */
gimp_image_set_active_channel (gimage, cu->channel);
}
/* update the area */
gimp_drawable_update (GIMP_DRAWABLE (cu->channel),
@ -2297,14 +2301,13 @@ undo_push_channel_mod (GimpImage *gimage,
{
TileManager *tiles;
Undo *new;
gint size;
gsize size;
tiles = GIMP_DRAWABLE (channel)->tiles;
size = sizeof (ChannelModUndo) + tile_manager_get_memsize (tiles);
if ((new = undo_push (gimage, size,
CHANNEL_MOD_UNDO, TRUE)))
if ((new = undo_push (gimage, size, CHANNEL_MOD_UNDO, TRUE)))
{
ChannelModUndo *cmu;
@ -2500,7 +2503,7 @@ undo_push_vectors (GimpImage *gimage,
GimpVectors *prev_vectors)
{
Undo *new;
gint size;
gsize size;
g_return_val_if_fail (type == VECTORS_ADD_UNDO ||
type == VECTORS_REMOVE_UNDO,
@ -2568,12 +2571,9 @@ undo_pop_vectors (GimpImage *gimage,
gimp_container_insert (gimage->vectors,
GIMP_OBJECT (vu->vectors), vu->prev_position);
if (vu->vectors)
{
/* set the new vectors */
gimp_image_set_active_vectors (gimage, vu->vectors);
}
}
return TRUE;
}
@ -2613,13 +2613,12 @@ undo_push_vectors_mod (GimpImage *gimage,
GimpVectors *vectors)
{
Undo *new;
gint size;
gsize size;
size = (sizeof (VectorsModUndo) +
gimp_object_get_memsize (GIMP_OBJECT (vectors)));
if ((new = undo_push (gimage, size,
VECTORS_MOD_UNDO, TRUE)))
if ((new = undo_push (gimage, size, VECTORS_MOD_UNDO, TRUE)))
{
VectorsModUndo *vmu;
@ -3474,17 +3473,18 @@ undo_push_cantundo (GimpImage *gimage,
* any adequate undo facility.
*/
new = undo_push (gimage, 0, CANT_UNDO, TRUE);
if (!new)
return FALSE;
new->data = (void*) action;
if ((new = undo_push (gimage, 0, CANT_UNDO, TRUE)))
{
new->data = (gpointer) action;
new->pop_func = undo_pop_cantundo;
new->free_func = undo_free_cantundo;
return TRUE;
}
return FALSE;
}
static gboolean
undo_pop_cantundo (GimpImage *gimage,
UndoState state,
@ -3530,6 +3530,7 @@ undo_name[] =
{ IMAGE_LAYERS_MERGE_UNDO_GROUP, N_("Merge Layers") },
{ IMAGE_QMASK_UNDO_GROUP, N_("QuickMask") },
{ IMAGE_GUIDE_UNDO_GROUP, N_("Guide") },
{ LAYER_PROPERTIES_UNDO_GROUP, N_("Layer Properties") },
{ LAYER_SCALE_UNDO_GROUP, N_("Scale Layer") },
{ LAYER_RESIZE_UNDO_GROUP, N_("Resize Layer") },
{ LAYER_DISPLACE_UNDO_GROUP, N_("Move Layer") },
@ -3554,12 +3555,12 @@ undo_name[] =
{ IMAGE_MASK_UNDO, N_("Selection Mask") },
{ IMAGE_QMASK_UNDO, N_("QuickMask") },
{ IMAGE_GUIDE_UNDO, N_("Guide") },
{ ITEM_RENAME_UNDO, N_("Rename Item") },
{ LAYER_ADD_UNDO, N_("New Layer") },
{ LAYER_REMOVE_UNDO, N_("Delete Layer") },
{ LAYER_MOD_UNDO, N_("Layer Mod") },
{ LAYER_MASK_ADD_UNDO, N_("Add Layer Mask") },
{ LAYER_MASK_REMOVE_UNDO, N_("Delete Layer Mask") },
{ LAYER_RENAME_UNDO, N_("Rename Layer") },
{ LAYER_REPOSITION_UNDO, N_("Layer Reposition") },
{ LAYER_DISPLACE_UNDO, N_("Layer Move") },
{ CHANNEL_ADD_UNDO, N_("New Channel") },

View File

@ -93,6 +93,12 @@ gboolean undo_push_image_guide (GimpImage *gimage,
GimpGuide *guide);
/* item undos */
gboolean undo_push_item_rename (GimpImage *gimage,
GimpItem *item);
/* layer undos */
gboolean undo_push_layer_add (GimpImage *gimage,
@ -111,8 +117,6 @@ gboolean undo_push_layer_mask_add (GimpImage *gimage,
gboolean undo_push_layer_mask_remove (GimpImage *gimage,
GimpLayer *layer,
GimpLayerMask *mask);
gboolean undo_push_layer_rename (GimpImage *gimage,
GimpLayer *layer);
gboolean undo_push_layer_reposition (GimpImage *gimage,
GimpLayer *layer);
gboolean undo_push_layer_displace (GimpImage *gimage,

View File

@ -3169,7 +3169,7 @@ gimp_image_raise_vectors (GimpImage *gimage,
GIMP_OBJECT (vectors));
if (index == 0)
{
g_message (_("Vectors cannot be raised higher."));
g_message (_("Path cannot be raised higher."));
return FALSE;
}
@ -3189,7 +3189,7 @@ gimp_image_lower_vectors (GimpImage *gimage,
GIMP_OBJECT (vectors));
if (index == gimp_container_num_children (gimage->vectors) - 1)
{
g_message (_("Vectors cannot be lowered more."));
g_message (_("Path cannot be lowered more."));
return FALSE;
}

View File

@ -333,9 +333,13 @@ gimp_item_set_image (GimpItem *item,
g_return_if_fail (! gimage || GIMP_IS_IMAGE (gimage));;
if (gimage == NULL)
{
item->tattoo = 0;
}
else if (item->tattoo == 0 || item->gimage != gimage)
{
item->tattoo = gimp_image_get_new_tattoo (gimage);
}
item->gimage = gimage;
}
@ -347,7 +351,8 @@ gimp_item_parasite_attach (GimpItem *item,
g_return_if_fail (GIMP_IS_ITEM (item));
/* only set the dirty bit manually if we can be saved and the new
parasite differs from the current one and we arn't undoable */
* parasite differs from the current one and we arn't undoable
*/
if (gimp_parasite_is_undoable (parasite))
{
/* do a group in case we have attach_parent set */
@ -385,22 +390,28 @@ gimp_item_parasite_attach (GimpItem *item,
void
gimp_item_parasite_detach (GimpItem *item,
const gchar *parasite)
const gchar *name)
{
GimpParasite *p;
GimpParasite *parasite;
g_return_if_fail (GIMP_IS_ITEM (item));
if (! (p = gimp_parasite_list_find (item->parasites, parasite)))
parasite = gimp_parasite_list_find (item->parasites, name);
if (! parasite)
return;
if (gimp_parasite_is_undoable (p))
if (gimp_parasite_is_undoable (parasite))
{
undo_push_item_parasite_remove (item->gimage, item,
gimp_parasite_name (p));
else if (gimp_parasite_is_persistent (p))
gimp_parasite_name (parasite));
}
else if (gimp_parasite_is_persistent (parasite))
{
undo_push_cantundo (item->gimage, _("parasite detached from item"));
}
gimp_parasite_list_remove (item->parasites, parasite);
gimp_parasite_list_remove (item->parasites, name);
}
GimpParasite *
@ -413,11 +424,11 @@ gimp_item_parasite_find (const GimpItem *item,
}
static void
gimp_item_parasite_list_foreach_func (gchar *key,
GimpParasite *p,
gimp_item_parasite_list_foreach_func (gchar *name,
GimpParasite *parasite,
gchar ***cur)
{
*(*cur)++ = (gchar *) g_strdup (key);
*(*cur)++ = (gchar *) g_strdup (name);
}
gchar **
@ -431,6 +442,7 @@ gimp_item_parasite_list (const GimpItem *item,
g_return_val_if_fail (count != NULL, NULL);
*count = gimp_parasite_list_length (item->parasites);
cur = list = g_new (gchar *, *count);
gimp_parasite_list_foreach (item->parasites,

View File

@ -38,7 +38,7 @@ struct _GimpItem
GimpViewable parent_instance;
gint ID; /* provides a unique ID */
guint32 tattoo; /* provides a perminant ID */
guint32 tattoo; /* provides a permanent ID */
GimpImage *gimage; /* gimage owner */
@ -72,7 +72,7 @@ void gimp_item_set_image (GimpItem *item,
void gimp_item_parasite_attach (GimpItem *item,
GimpParasite *parasite);
void gimp_item_parasite_detach (GimpItem *item,
const gchar *parasite);
const gchar *name);
GimpParasite * gimp_item_parasite_find (const GimpItem *item,
const gchar *name);
gchar ** gimp_item_parasite_list (const GimpItem *item,

View File

@ -492,16 +492,23 @@ edit_channel_query_ok_callback (GtkWidget *widget,
{
EditChannelOptions *options;
GimpChannel *channel;
GimpRGB color;
options = (EditChannelOptions *) data;
channel = options->channel;
if (options->gimage)
{
/* Set the new channel name */
gimp_object_set_name (GIMP_OBJECT (channel),
gtk_entry_get_text (GTK_ENTRY (options->name_entry)));
const gchar *new_name;
GimpRGB color;
new_name = gtk_entry_get_text (GTK_ENTRY (options->name_entry));
if (strcmp (new_name, gimp_object_get_name (GIMP_OBJECT (channel))))
{
undo_push_item_rename (options->gimage, GIMP_ITEM (channel));
gimp_object_set_name (GIMP_OBJECT (channel), new_name);
}
gimp_color_button_get_color (GIMP_COLOR_BUTTON (options->color_panel),
&color);
@ -672,5 +679,5 @@ channels_menu_update (GtkItemFactory *factory,
SET_SENSITIVE ("/Delete Channel", !fs && channel);
SET_SENSITIVE ("/Edit Channel Attributes...", !fs && channel);
#undef SET_OPS_SENSITIVE
#undef SET_SENSITIVE
}

View File

@ -746,20 +746,27 @@ edit_layer_query_ok_callback (GtkWidget *widget,
if ((layer = options->layer))
{
/* Set the new layer name */
if (GIMP_OBJECT (layer)->name && gimp_layer_is_floating_sel (layer))
const gchar *new_name;
new_name = gtk_entry_get_text (GTK_ENTRY (options->name_entry));
if (strcmp (new_name, gimp_object_get_name (GIMP_OBJECT (layer))))
{
undo_push_group_start (options->gimage, LAYER_PROPERTIES_UNDO_GROUP);
if (gimp_layer_is_floating_sel (layer))
{
/* If the layer is a floating selection, make it a layer */
floating_sel_to_layer (layer);
}
else
{
/* We're doing a plain rename */
undo_push_layer_rename (options->gimage, layer);
}
gimp_object_set_name (GIMP_OBJECT (layer),
gtk_entry_get_text (GTK_ENTRY (options->name_entry)));
undo_push_item_rename (options->gimage, GIMP_ITEM (layer));
gimp_object_set_name (GIMP_OBJECT (layer), new_name);
undo_push_group_end (options->gimage);
}
}
gdisplays_flush ();

View File

@ -1171,7 +1171,7 @@ static GimpItemFactoryEntry channels_entries[] =
static GimpItemFactoryEntry vectors_entries[] =
{
{ { N_("/New Path"), "<control>N",
{ { N_("/New Path..."), "<control>N",
vectors_new_vectors_cmd_callback, 0,
"<StockItem>", GTK_STOCK_NEW },
NULL,
@ -1995,7 +1995,7 @@ menus_init (Gimp *gimp)
vectors_factory = gimp_item_factory_new (GTK_TYPE_MENU,
"<Vectors>", "vectors",
NULL,
vectors_menu_update,
G_N_ELEMENTS (vectors_entries),
vectors_entries,
gimp,

View File

@ -458,7 +458,7 @@ vectors_new_vectors_query (GimpImage *gimage,
gtk_box_pack_start (GTK_BOX (vbox), table, FALSE, FALSE, 0);
/* The name entry hbox, label and entry */
label = gtk_label_new (_("Vectors name:"));
label = gtk_label_new (_("Path name:"));
gtk_misc_set_alignment (GTK_MISC (label), 1.0, 0.5);
gtk_table_attach (GTK_TABLE (table), label, 0, 1, 0, 1,
GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 0);
@ -469,7 +469,7 @@ vectors_new_vectors_query (GimpImage *gimage,
gtk_table_attach_defaults (GTK_TABLE (table), options->name_entry,
1, 2, 0, 1);
gtk_entry_set_text (GTK_ENTRY (options->name_entry),
(vectors_name ? vectors_name : _("New Vectors")));
(vectors_name ? vectors_name : _("New Path")));
gtk_widget_show (options->name_entry);
gtk_widget_show (table);
@ -505,9 +505,16 @@ edit_vectors_query_ok_callback (GtkWidget *widget,
if (options->gimage)
{
/* Set the new vectors name */
gimp_object_set_name (GIMP_OBJECT (vectors),
gtk_entry_get_text (GTK_ENTRY (options->name_entry)));
const gchar *new_name;
new_name = gtk_entry_get_text (GTK_ENTRY (options->name_entry));
if (strcmp (new_name, gimp_object_get_name (GIMP_OBJECT (vectors))))
{
undo_push_item_rename (options->gimage, GIMP_ITEM (vectors));
gimp_object_set_name (GIMP_OBJECT (vectors), new_name);
}
}
gtk_widget_destroy (options->query_box);
@ -569,7 +576,7 @@ vectors_edit_vectors_query (GimpVectors *vectors)
gtk_box_pack_start (GTK_BOX (vbox), table, FALSE, FALSE, 0);
/* The name entry */
label = gtk_label_new (_("Vectors name:"));
label = gtk_label_new (_("Path name:"));
gtk_misc_set_alignment (GTK_MISC (label), 1.0, 0.5);
gtk_table_attach (GTK_TABLE (table), label, 0, 1, 0, 1,
GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
@ -595,7 +602,7 @@ vectors_menu_update (GtkItemFactory *factory,
{
GimpImage *gimage;
GimpVectors *vectors;
gboolean fs;
gboolean mask_empty;
GList *list;
GList *next = NULL;
GList *prev = NULL;
@ -604,7 +611,7 @@ vectors_menu_update (GtkItemFactory *factory,
vectors = gimp_image_get_active_vectors (gimage);
fs = (gimp_image_floating_sel (gimage) != NULL);
mask_empty = gimp_image_mask_is_empty (gimage);
for (list = GIMP_LIST (gimage->vectors)->list;
list;
@ -621,16 +628,18 @@ vectors_menu_update (GtkItemFactory *factory,
#define SET_SENSITIVE(menu,condition) \
gimp_item_factory_set_sensitive (factory, menu, (condition) != 0)
SET_SENSITIVE ("/New Vectors...", !fs);
SET_SENSITIVE ("/Raise Vectors", !fs && vectors && prev);
SET_SENSITIVE ("/Lower Vectors", !fs && vectors && next);
SET_SENSITIVE ("/Duplicate Vectors", !fs && vectors);
SET_SENSITIVE ("/Vectors to Selection", !fs && vectors);
SET_SENSITIVE ("/Add to Selection", !fs && vectors);
SET_SENSITIVE ("/Subtract from Selection", !fs && vectors);
SET_SENSITIVE ("/Intersect with Selection", !fs && vectors);
SET_SENSITIVE ("/Delete Vectors", !fs && vectors);
SET_SENSITIVE ("/Edit Vectors Attributes...", !fs && vectors);
SET_SENSITIVE ("/New Path...", TRUE);
SET_SENSITIVE ("/Raise Path", vectors && prev);
SET_SENSITIVE ("/Lower Path", vectors && next);
SET_SENSITIVE ("/Duplicate Path", vectors);
SET_SENSITIVE ("/Path to Selection", vectors);
SET_SENSITIVE ("/Add to Selection", vectors);
SET_SENSITIVE ("/Subtract from Selection", vectors);
SET_SENSITIVE ("/Intersect with Selection", vectors);
SET_SENSITIVE ("/Selection to Path", ! mask_empty);
SET_SENSITIVE ("/Stroke Path", vectors);
SET_SENSITIVE ("/Delete Path", vectors);
SET_SENSITIVE ("/Edit Path Attributes...", vectors);
#undef SET_OPS_SENSITIVE
#undef SET_SENSITIVE
}

View File

@ -1171,7 +1171,7 @@ static GimpItemFactoryEntry channels_entries[] =
static GimpItemFactoryEntry vectors_entries[] =
{
{ { N_("/New Path"), "<control>N",
{ { N_("/New Path..."), "<control>N",
vectors_new_vectors_cmd_callback, 0,
"<StockItem>", GTK_STOCK_NEW },
NULL,
@ -1995,7 +1995,7 @@ menus_init (Gimp *gimp)
vectors_factory = gimp_item_factory_new (GTK_TYPE_MENU,
"<Vectors>", "vectors",
NULL,
vectors_menu_update,
G_N_ELEMENTS (vectors_entries),
vectors_entries,
gimp,

View File

@ -95,7 +95,7 @@ struct _Undo
{
UndoType type; /* undo type */
gpointer data; /* data to implement the undo, NULL for group */
glong bytes; /* size of undo item */
gsize bytes; /* size of undo item */
gboolean dirties_image; /* TRUE if undo mutates image */
gboolean group_boundary; /* TRUE if this is the start/end of a group */
@ -107,7 +107,7 @@ struct _Undo
static const gchar * undo_type_to_name (UndoType undo_type);
static Undo * undo_new (UndoType undo_type,
glong size,
gsize size,
gboolean dirties_image);
@ -195,10 +195,11 @@ remove_stack_bottom (GimpImage *gimage)
/* Allocate and initialise a new Undo. Leaves data and function
* pointers zeroed ready to be filled in by caller. */
* pointers zeroed ready to be filled in by caller.
*/
static Undo *
undo_new (UndoType type,
glong size,
gsize size,
gboolean dirties_image)
{
Undo *new;
@ -232,7 +233,7 @@ undo_free_up_space (GimpImage *gimage)
static Undo *
undo_push (GimpImage *gimage,
glong size,
gsize size,
UndoType type,
gboolean dirties_image)
{
@ -709,7 +710,7 @@ undo_push_image (GimpImage *gimage,
gint y2)
{
Undo *new;
glong size;
gsize size;
x1 = CLAMP (x1, 0, gimp_drawable_width (drawable));
y1 = CLAMP (y1, 0, gimp_drawable_height (drawable));
@ -768,7 +769,7 @@ undo_push_image_mod (GimpImage *gimage,
gboolean sparse)
{
Undo *new;
glong size;
gsize size;
gint dwidth, dheight;
if (! tiles)
@ -1163,14 +1164,12 @@ undo_push_image_mask (GimpImage *gimage,
gint y)
{
Undo *new;
gint size;
gsize size;
size = sizeof (MaskUndo);
if (tiles)
size =
tile_manager_width (tiles) *
tile_manager_height (tiles);
else
size = 0;
size += tile_manager_get_memsize (tiles);
if ((new = undo_push (gimage, size, IMAGE_MASK_UNDO, FALSE)))
{
@ -1439,7 +1438,7 @@ undo_free_image_guide (UndoState state,
{
GuideUndo *data;
data = data_ptr;
data = (GuideUndo *) data_ptr;
data->guide->ref_count--;
if (data->guide->position < 0 && data->guide->ref_count <= 0)
@ -1451,6 +1450,80 @@ undo_free_image_guide (UndoState state,
}
/**********************/
/* Item Rename Undo */
typedef struct _ItemRenameUndo ItemRenameUndo;
struct _ItemRenameUndo
{
GimpItem *item;
gchar *old_name;
};
static gboolean undo_pop_item_rename (GimpImage *,
UndoState, UndoType, gpointer);
static void undo_free_item_rename (UndoState, UndoType, gpointer);
gboolean
undo_push_item_rename (GimpImage *gimage,
GimpItem *item)
{
Undo *new;
if ((new = undo_push (gimage, sizeof (ItemRenameUndo),
ITEM_RENAME_UNDO, TRUE)))
{
ItemRenameUndo *iru;
iru = g_new0 (ItemRenameUndo, 1);
new->data = iru;
new->pop_func = undo_pop_item_rename;
new->free_func = undo_free_item_rename;
iru->item = item;
iru->old_name = g_strdup (gimp_object_get_name (GIMP_OBJECT (item)));
return TRUE;
}
return FALSE;
}
static gboolean
undo_pop_item_rename (GimpImage *gimage,
UndoState state,
UndoType type,
gpointer iru_ptr)
{
ItemRenameUndo *iru;
gchar *tmp;
iru = (ItemRenameUndo *) iru_ptr;
tmp = g_strdup (gimp_object_get_name (GIMP_OBJECT (iru->item)));
gimp_object_set_name (GIMP_OBJECT (iru->item), iru->old_name);
g_free (iru->old_name);
iru->old_name = tmp;
return TRUE;
}
static void
undo_free_item_rename (UndoState state,
UndoType type,
gpointer iru_ptr)
{
ItemRenameUndo *iru;
iru = (ItemRenameUndo *) iru_ptr;
g_free (iru->old_name);
g_free (iru);
}
/***************************/
/* Layer Add/Remove Undo */
@ -1500,7 +1573,7 @@ undo_push_layer (GimpImage *gimage,
GimpLayer *prev_layer)
{
Undo *new;
gint size;
gsize size;
g_return_val_if_fail (type == LAYER_ADD_UNDO ||
type == LAYER_REMOVE_UNDO,
@ -1508,8 +1581,7 @@ undo_push_layer (GimpImage *gimage,
size = sizeof (LayerUndo) + gimp_object_get_memsize (GIMP_OBJECT (layer));
if ((new = undo_push (gimage, size,
type, TRUE)))
if ((new = undo_push (gimage, size, type, TRUE)))
{
LayerUndo *lu;
@ -1541,12 +1613,14 @@ undo_pop_layer (GimpImage *gimage,
lu = (LayerUndo *) lu_ptr;
/* remove layer */
if ((state == UNDO && type == LAYER_ADD_UNDO) ||
(state == REDO && type == LAYER_REMOVE_UNDO))
{
/* remove layer */
/* record the current position */
lu->prev_position = gimp_image_get_layer_index (gimage, lu->layer);
/* set the previous layer */
gimp_image_set_active_layer (gimage, lu->prev_layer);
@ -1569,9 +1643,10 @@ undo_pop_layer (GimpImage *gimage,
GIMP_DRAWABLE (lu->layer)->width,
GIMP_DRAWABLE (lu->layer)->height);
}
/* restore layer */
else
{
/* restore layer */
/* record the active layer */
lu->prev_layer = gimp_image_get_active_layer (gimage);
@ -1638,14 +1713,13 @@ undo_push_layer_mod (GimpImage *gimage,
{
Undo *new;
TileManager *tiles;
gint size;
gsize size;
tiles = GIMP_DRAWABLE (layer)->tiles;
size = sizeof (LayerModUndo) + tile_manager_get_memsize (tiles);
if ((new = undo_push (gimage, size,
LAYER_MOD_UNDO, TRUE)))
if ((new = undo_push (gimage, size, LAYER_MOD_UNDO, TRUE)))
{
LayerModUndo *lmu;
@ -1673,9 +1747,9 @@ static gboolean
undo_pop_layer_mod (GimpImage *gimage,
UndoState state,
UndoType type,
gpointer data_ptr)
gpointer lmu_ptr)
{
LayerModUndo *data;
LayerModUndo *lmu;
gint layer_type;
gint offset_x, offset_y;
TileManager *tiles;
@ -1683,11 +1757,12 @@ undo_pop_layer_mod (GimpImage *gimage,
GimpLayer *layer;
gboolean old_has_alpha;
data = (LayerModUndo *) data_ptr;
layer = data->layer;
tiles = data->tiles;
offset_x = data->offset_x;
offset_y = data->offset_y;
lmu = (LayerModUndo *) lmu_ptr;
layer = lmu->layer;
tiles = lmu->tiles;
offset_x = lmu->offset_x;
offset_y = lmu->offset_y;
/* Issue the first update */
gimp_image_update (gimage,
@ -1699,11 +1774,11 @@ undo_pop_layer_mod (GimpImage *gimage,
/* Create a tile manager to store the current layer contents */
temp = GIMP_DRAWABLE (layer)->tiles;
data->offset_x = GIMP_DRAWABLE (layer)->offset_x;
data->offset_y = GIMP_DRAWABLE (layer)->offset_y;
lmu->offset_x = GIMP_DRAWABLE (layer)->offset_x;
lmu->offset_y = GIMP_DRAWABLE (layer)->offset_y;
layer_type = data->type;
data->type = GIMP_DRAWABLE (layer)->type;
layer_type = lmu->type;
lmu->type = GIMP_DRAWABLE (layer)->type;
old_has_alpha = GIMP_DRAWABLE (layer)->has_alpha;
@ -1729,7 +1804,7 @@ undo_pop_layer_mod (GimpImage *gimage,
}
/* Set the new tile manager */
data->tiles = temp;
lmu->tiles = temp;
/* Issue the second update */
gimp_drawable_update (GIMP_DRAWABLE (layer),
@ -1743,17 +1818,18 @@ undo_pop_layer_mod (GimpImage *gimage,
static void
undo_free_layer_mod (UndoState state,
UndoType type,
gpointer data_ptr)
gpointer lmu_ptr)
{
gpointer *data;
LayerModUndo *lmu;
data = (gpointer *) data_ptr;
tile_manager_destroy ((TileManager *) data[1]);
g_free (data);
lmu = (LayerModUndo *) lmu_ptr;
tile_manager_destroy (lmu->tiles);
g_free (lmu);
}
/*********************************/
/********************************/
/* Layer Mask Add/Remove Undo */
typedef struct _LayerMaskUndo LayerMaskUndo;
@ -1797,7 +1873,7 @@ undo_push_layer_mask (GimpImage *gimage,
GimpLayerMask *mask)
{
Undo *new;
gint size;
gsize size;
g_return_val_if_fail (type == LAYER_MASK_ADD_UNDO ||
type == LAYER_MASK_REMOVE_UNDO,
@ -1805,8 +1881,7 @@ undo_push_layer_mask (GimpImage *gimage,
size = sizeof (LayerMaskUndo) + gimp_object_get_memsize (GIMP_OBJECT (mask));
if ((new = undo_push (gimage, size,
type, TRUE)))
if ((new = undo_push (gimage, size, type, TRUE)))
{
LayerMaskUndo *lmu;
@ -1868,76 +1943,6 @@ undo_free_layer_mask (UndoState state,
}
/**********************/
/* Layer Rename Undo */
typedef struct _LayerRenameUndo LayerRenameUndo;
struct _LayerRenameUndo
{
GimpLayer *layer;
gchar *old_name;
};
static gboolean undo_pop_layer_rename (GimpImage *,
UndoState, UndoType, gpointer);
static void undo_free_layer_rename (UndoState, UndoType, gpointer);
gboolean
undo_push_layer_rename (GimpImage *gimage,
GimpLayer *layer)
{
Undo *new;
if ((new = undo_push (gimage, sizeof (LayerRenameUndo),
LAYER_RENAME_UNDO, TRUE)))
{
LayerRenameUndo *lru;
lru = g_new0 (LayerRenameUndo, 1);
new->data = lru;
new->pop_func = undo_pop_layer_rename;
new->free_func = undo_free_layer_rename;
lru->layer = layer;
lru->old_name = g_strdup (gimp_object_get_name (GIMP_OBJECT (layer)));
return TRUE;
}
return FALSE;
}
static gboolean
undo_pop_layer_rename (GimpImage *gimage,
UndoState state,
UndoType type,
void *data_ptr)
{
LayerRenameUndo *data = data_ptr;
gchar *tmp;
tmp = g_strdup (gimp_object_get_name (GIMP_OBJECT (data->layer)));
gimp_object_set_name (GIMP_OBJECT (data->layer), data->old_name);
g_free (data->old_name);
data->old_name = tmp;
return TRUE;
}
static void
undo_free_layer_rename (UndoState state,
UndoType type,
gpointer data_ptr)
{
LayerRenameUndo *data = data_ptr;
g_free (data->old_name);
g_free (data);
}
/***************************/
/* Layer re-position Undo */
@ -2172,7 +2177,7 @@ undo_push_channel (GimpImage *gimage,
GimpChannel *prev_channel)
{
Undo *new;
gint size;
gsize size;
g_return_val_if_fail (type == CHANNEL_ADD_UNDO ||
type == CHANNEL_REMOVE_UNDO,
@ -2212,10 +2217,11 @@ undo_pop_channel (GimpImage *gimage,
cu = (ChannelUndo *) cu_ptr;
/* remove channel */
if ((state == UNDO && type == CHANNEL_ADD_UNDO) ||
(state == REDO && type == CHANNEL_REMOVE_UNDO))
{
/* remove channel */
/* record the current position */
cu->prev_position = gimp_image_get_channel_index (gimage, cu->channel);
@ -2234,9 +2240,10 @@ undo_pop_channel (GimpImage *gimage,
GIMP_DRAWABLE (cu->channel)->width,
GIMP_DRAWABLE (cu->channel)->height);
}
/* restore channel */
else
{
/* restore channel */
/* record the active channel */
cu->prev_channel = gimp_image_get_active_channel (gimage);
@ -2244,11 +2251,8 @@ undo_pop_channel (GimpImage *gimage,
gimp_container_insert (gimage->channels,
GIMP_OBJECT (cu->channel), cu->prev_position);
if (cu->channel)
{
/* set the new channel */
gimp_image_set_active_channel (gimage, cu->channel);
}
/* update the area */
gimp_drawable_update (GIMP_DRAWABLE (cu->channel),
@ -2297,14 +2301,13 @@ undo_push_channel_mod (GimpImage *gimage,
{
TileManager *tiles;
Undo *new;
gint size;
gsize size;
tiles = GIMP_DRAWABLE (channel)->tiles;
size = sizeof (ChannelModUndo) + tile_manager_get_memsize (tiles);
if ((new = undo_push (gimage, size,
CHANNEL_MOD_UNDO, TRUE)))
if ((new = undo_push (gimage, size, CHANNEL_MOD_UNDO, TRUE)))
{
ChannelModUndo *cmu;
@ -2500,7 +2503,7 @@ undo_push_vectors (GimpImage *gimage,
GimpVectors *prev_vectors)
{
Undo *new;
gint size;
gsize size;
g_return_val_if_fail (type == VECTORS_ADD_UNDO ||
type == VECTORS_REMOVE_UNDO,
@ -2568,12 +2571,9 @@ undo_pop_vectors (GimpImage *gimage,
gimp_container_insert (gimage->vectors,
GIMP_OBJECT (vu->vectors), vu->prev_position);
if (vu->vectors)
{
/* set the new vectors */
gimp_image_set_active_vectors (gimage, vu->vectors);
}
}
return TRUE;
}
@ -2613,13 +2613,12 @@ undo_push_vectors_mod (GimpImage *gimage,
GimpVectors *vectors)
{
Undo *new;
gint size;
gsize size;
size = (sizeof (VectorsModUndo) +
gimp_object_get_memsize (GIMP_OBJECT (vectors)));
if ((new = undo_push (gimage, size,
VECTORS_MOD_UNDO, TRUE)))
if ((new = undo_push (gimage, size, VECTORS_MOD_UNDO, TRUE)))
{
VectorsModUndo *vmu;
@ -3474,17 +3473,18 @@ undo_push_cantundo (GimpImage *gimage,
* any adequate undo facility.
*/
new = undo_push (gimage, 0, CANT_UNDO, TRUE);
if (!new)
return FALSE;
new->data = (void*) action;
if ((new = undo_push (gimage, 0, CANT_UNDO, TRUE)))
{
new->data = (gpointer) action;
new->pop_func = undo_pop_cantundo;
new->free_func = undo_free_cantundo;
return TRUE;
}
return FALSE;
}
static gboolean
undo_pop_cantundo (GimpImage *gimage,
UndoState state,
@ -3530,6 +3530,7 @@ undo_name[] =
{ IMAGE_LAYERS_MERGE_UNDO_GROUP, N_("Merge Layers") },
{ IMAGE_QMASK_UNDO_GROUP, N_("QuickMask") },
{ IMAGE_GUIDE_UNDO_GROUP, N_("Guide") },
{ LAYER_PROPERTIES_UNDO_GROUP, N_("Layer Properties") },
{ LAYER_SCALE_UNDO_GROUP, N_("Scale Layer") },
{ LAYER_RESIZE_UNDO_GROUP, N_("Resize Layer") },
{ LAYER_DISPLACE_UNDO_GROUP, N_("Move Layer") },
@ -3554,12 +3555,12 @@ undo_name[] =
{ IMAGE_MASK_UNDO, N_("Selection Mask") },
{ IMAGE_QMASK_UNDO, N_("QuickMask") },
{ IMAGE_GUIDE_UNDO, N_("Guide") },
{ ITEM_RENAME_UNDO, N_("Rename Item") },
{ LAYER_ADD_UNDO, N_("New Layer") },
{ LAYER_REMOVE_UNDO, N_("Delete Layer") },
{ LAYER_MOD_UNDO, N_("Layer Mod") },
{ LAYER_MASK_ADD_UNDO, N_("Add Layer Mask") },
{ LAYER_MASK_REMOVE_UNDO, N_("Delete Layer Mask") },
{ LAYER_RENAME_UNDO, N_("Rename Layer") },
{ LAYER_REPOSITION_UNDO, N_("Layer Reposition") },
{ LAYER_DISPLACE_UNDO, N_("Layer Move") },
{ CHANNEL_ADD_UNDO, N_("New Channel") },

View File

@ -93,6 +93,12 @@ gboolean undo_push_image_guide (GimpImage *gimage,
GimpGuide *guide);
/* item undos */
gboolean undo_push_item_rename (GimpImage *gimage,
GimpItem *item);
/* layer undos */
gboolean undo_push_layer_add (GimpImage *gimage,
@ -111,8 +117,6 @@ gboolean undo_push_layer_mask_add (GimpImage *gimage,
gboolean undo_push_layer_mask_remove (GimpImage *gimage,
GimpLayer *layer,
GimpLayerMask *mask);
gboolean undo_push_layer_rename (GimpImage *gimage,
GimpLayer *layer);
gboolean undo_push_layer_reposition (GimpImage *gimage,
GimpLayer *layer);
gboolean undo_push_layer_displace (GimpImage *gimage,

View File

@ -34,12 +34,12 @@ typedef enum
IMAGE_MASK_UNDO,
IMAGE_QMASK_UNDO,
IMAGE_GUIDE_UNDO,
ITEM_RENAME_UNDO,
LAYER_ADD_UNDO,
LAYER_REMOVE_UNDO,
LAYER_MOD_UNDO,
LAYER_MASK_ADD_UNDO,
LAYER_MASK_REMOVE_UNDO,
LAYER_RENAME_UNDO,
LAYER_REPOSITION_UNDO,
LAYER_DISPLACE_UNDO,
CHANNEL_ADD_UNDO,

View File

@ -682,6 +682,11 @@ gimp_item_list_view_delete_clicked (GtkWidget *widget,
viewable = view->get_item_func (view->gimage);
/* EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEK */
if (GIMP_IS_LAYER (viewable) &&
gimp_layer_is_floating_sel (GIMP_LAYER (viewable)))
floating_sel_remove (GIMP_LAYER (viewable));
else
view->remove_item_func (view->gimage, viewable);
gdisplays_flush ();

View File

@ -682,6 +682,11 @@ gimp_item_list_view_delete_clicked (GtkWidget *widget,
viewable = view->get_item_func (view->gimage);
/* EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEK */
if (GIMP_IS_LAYER (viewable) &&
gimp_layer_is_floating_sel (GIMP_LAYER (viewable)))
floating_sel_remove (GIMP_LAYER (viewable));
else
view->remove_item_func (view->gimage, viewable);
gdisplays_flush ();