Commit 13a3975b authored by Michael Natterer's avatar Michael Natterer 😴 Committed by Michael Natterer
Browse files

add support for GIMP_UNDO_TEXT_LAYER_MODIFIED.

2007-01-30  Michael Natterer  <mitch@gimp.org>

	* app/text/gimptextundo.[ch]: add support for
	GIMP_UNDO_TEXT_LAYER_MODIFIED.

	* app/core/gimpimage-undo-push.c: use it here.


svn path=/trunk/; revision=21816
parent f0d1d864
2007-01-30 Michael Natterer <mitch@gimp.org>
* app/text/gimptextundo.[ch]: add support for
GIMP_UNDO_TEXT_LAYER_MODIFIED.
* app/core/gimpimage-undo-push.c: use it here.
2007-01-30 Michael Natterer <mitch@gimp.org>
 
* app/core/Makefile.am
......@@ -703,9 +703,9 @@ gimp_image_undo_push_layer_lock_alpha (GimpImage *image,
}
/*********************/
/* Text Layer Undo */
/*********************/
/**********************/
/* Text Layer Undos */
/**********************/
GimpUndo *
gimp_image_undo_push_text_layer (GimpImage *image,
......@@ -727,86 +727,22 @@ gimp_image_undo_push_text_layer (GimpImage *image,
NULL);
}
/******************************/
/* Text Layer Modified Undo */
/******************************/
typedef struct _TextLayerModifiedUndo TextLayerModifiedUndo;
struct _TextLayerModifiedUndo
{
gboolean old_modified;
};
static gboolean undo_pop_text_layer_modified (GimpUndo *undo,
GimpUndoMode undo_mode,
GimpUndoAccumulator *accum);
static void undo_free_text_layer_modified (GimpUndo *undo,
GimpUndoMode undo_mode);
GimpUndo *
gimp_image_undo_push_text_layer_modified (GimpImage *image,
const gchar *undo_desc,
GimpTextLayer *layer)
{
GimpUndo *new;
g_return_val_if_fail (GIMP_IS_IMAGE (image), NULL);
g_return_val_if_fail (GIMP_IS_TEXT_LAYER (layer), NULL);
g_return_val_if_fail (gimp_item_is_attached (GIMP_ITEM (layer)), NULL);
if ((new = gimp_image_undo_push (image, GIMP_TYPE_ITEM_UNDO,
sizeof (TextLayerModifiedUndo),
sizeof (TextLayerModifiedUndo),
GIMP_UNDO_TEXT_LAYER_MODIFIED, undo_desc,
GIMP_DIRTY_ITEM_META,
undo_pop_text_layer_modified,
undo_free_text_layer_modified,
"item", layer,
NULL)))
{
TextLayerModifiedUndo *modified_undo = new->data;
modified_undo->old_modified = layer->modified;
return new;
}
return NULL;
}
static gboolean
undo_pop_text_layer_modified (GimpUndo *undo,
GimpUndoMode undo_mode,
GimpUndoAccumulator *accum)
{
TextLayerModifiedUndo *modified_undo = undo->data;
GimpTextLayer *layer;
gboolean modified;
layer = GIMP_TEXT_LAYER (GIMP_ITEM_UNDO (undo)->item);
#if 0
g_print ("setting layer->modified from %s to %s\n",
layer->modified ? "TRUE" : "FALSE",
modified_undo->old_modified ? "TRUE" : "FALSE");
#endif
modified = layer->modified;
g_object_set (layer, "modified", modified_undo->old_modified, NULL);
modified_undo->old_modified = modified;
gimp_viewable_invalidate_preview (GIMP_VIEWABLE (layer));
return TRUE;
}
static void
undo_free_text_layer_modified (GimpUndo *undo,
GimpUndoMode undo_mode)
{
g_free (undo->data);
return gimp_image_undo_push (image, GIMP_TYPE_TEXT_UNDO,
0, 0,
GIMP_UNDO_TEXT_LAYER_MODIFIED, undo_desc,
GIMP_DIRTY_ITEM_META,
NULL, NULL,
"item", layer,
NULL);
}
......
......@@ -112,19 +112,31 @@ gimp_text_undo_constructor (GType type,
layer = GIMP_TEXT_LAYER (GIMP_ITEM_UNDO (text_undo)->item);
if (text_undo->pspec)
switch (GIMP_UNDO (object)->undo_type)
{
g_assert (text_undo->pspec->owner_type == GIMP_TYPE_TEXT);
case GIMP_UNDO_TEXT_LAYER:
if (text_undo->pspec)
{
g_assert (text_undo->pspec->owner_type == GIMP_TYPE_TEXT);
text_undo->value = g_new0 (GValue, 1);
g_value_init (text_undo->value, text_undo->pspec->value_type);
g_object_get_property (G_OBJECT (layer->text),
text_undo->pspec->name, text_undo->value);
}
else if (layer->text)
{
text_undo->text = gimp_config_duplicate (GIMP_CONFIG (layer->text));
}
break;
text_undo->value = g_new0 (GValue, 1);
case GIMP_UNDO_TEXT_LAYER_MODIFIED:
text_undo->modified = layer->modified;
break;
g_value_init (text_undo->value, text_undo->pspec->value_type);
g_object_get_property (G_OBJECT (layer->text),
text_undo->pspec->name, text_undo->value);
}
else if (layer->text)
{
text_undo->text = gimp_config_duplicate (GIMP_CONFIG (layer->text));
default:
g_assert_not_reached ();
}
return object;
......@@ -143,6 +155,7 @@ gimp_text_undo_set_property (GObject *object,
case PROP_PARAM:
text_undo->pspec = g_value_get_param (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
......@@ -162,6 +175,7 @@ gimp_text_undo_get_property (GObject *object,
case PROP_PARAM:
g_value_set_param (value, (GParamSpec *) text_undo->pspec);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
......@@ -193,46 +207,72 @@ gimp_text_undo_pop (GimpUndo *undo,
GimpTextUndo *text_undo = GIMP_TEXT_UNDO (undo);
GimpTextLayer *layer = GIMP_TEXT_LAYER (GIMP_ITEM_UNDO (undo)->item);
if (text_undo->pspec)
GIMP_UNDO_CLASS (parent_class)->pop (undo, undo_mode, accum);
switch (undo->undo_type)
{
GValue *value;
case GIMP_UNDO_TEXT_LAYER:
if (text_undo->pspec)
{
GValue *value;
g_return_if_fail (layer->text != NULL);
g_return_if_fail (layer->text != NULL);
value = g_new0 (GValue, 1);
g_value_init (value, text_undo->pspec->value_type);
value = g_new0 (GValue, 1);
g_value_init (value, text_undo->pspec->value_type);
g_object_get_property (G_OBJECT (layer->text),
text_undo->pspec->name, value);
g_object_get_property (G_OBJECT (layer->text),
text_undo->pspec->name, value);
g_object_set_property (G_OBJECT (layer->text),
text_undo->pspec->name, text_undo->value);
g_object_set_property (G_OBJECT (layer->text),
text_undo->pspec->name, text_undo->value);
g_value_unset (text_undo->value);
g_free (text_undo->value);
g_value_unset (text_undo->value);
g_free (text_undo->value);
text_undo->value = value;
}
else
{
GimpText *text;
text_undo->value = value;
}
else
{
GimpText *text;
text = (layer->text ?
gimp_config_duplicate (GIMP_CONFIG (layer->text)) : NULL);
text = (layer->text ?
gimp_config_duplicate (GIMP_CONFIG (layer->text)) : NULL);
if (layer->text && text_undo->text)
gimp_config_sync (G_OBJECT (text_undo->text),
G_OBJECT (layer->text), 0);
else
gimp_text_layer_set_text (layer, text_undo->text);
if (layer->text && text_undo->text)
gimp_config_sync (G_OBJECT (text_undo->text),
G_OBJECT (layer->text), 0);
else
gimp_text_layer_set_text (layer, text_undo->text);
if (text_undo->text)
g_object_unref (text_undo->text);
if (text_undo->text)
g_object_unref (text_undo->text);
text_undo->text = text;
}
text_undo->text = text;
}
break;
GIMP_UNDO_CLASS (parent_class)->pop (undo, undo_mode, accum);
case GIMP_UNDO_TEXT_LAYER_MODIFIED:
{
gboolean modified;
#if 0
g_print ("setting layer->modified from %s to %s\n",
layer->modified ? "TRUE" : "FALSE",
text_undo->modified ? "TRUE" : "FALSE");
#endif
modified = layer->modified;
g_object_set (layer, "modified", text_undo->modified, NULL);
text_undo->modified = modified;
gimp_viewable_invalidate_preview (GIMP_VIEWABLE (layer));
}
break;
default:
g_assert_not_reached ();
}
}
static void
......
......@@ -40,6 +40,7 @@ struct _GimpTextUndo
GimpText *text;
const GParamSpec *pspec;
GValue *value;
gboolean modified;
};
struct _GimpTextUndoClass
......
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