Commit 4bb1692f authored by Sven Neumann's avatar Sven Neumann Committed by Sven Neumann

made time a property and added utility functions to work the undo's age.

2007-02-06  Sven Neumann  <sven@gimp.org>

	* app/core/gimpundo.[ch]: made time a property and added utility
	functions to work the undo's age.
	
	* app/tools/gimptexttool.c: use the utility functions.


svn path=/trunk/; revision=21854
parent 2e914e6f
2007-02-06 Sven Neumann <sven@gimp.org>
* app/core/gimpundo.[ch]: made time a property and added utility
functions to work the undo's age.
* app/tools/gimptexttool.c: use the utility functions.
2007-02-05 Sven Neumann <sven@gimp.org>
* app/dialogs/file-save-dialog.c (file_save_dialog_save_image):
......@@ -51,6 +51,7 @@ enum
{
PROP_0,
PROP_IMAGE,
PROP_TIME,
PROP_UNDO_TYPE,
PROP_DIRTY_MASK
};
......@@ -149,6 +150,11 @@ gimp_undo_class_init (GimpUndoClass *klass)
GIMP_PARAM_READWRITE |
G_PARAM_CONSTRUCT_ONLY));
g_object_class_install_property (object_class, PROP_TIME,
g_param_spec_uint ("time", NULL, NULL,
0, G_MAXUINT, 0,
GIMP_PARAM_READWRITE));
g_object_class_install_property (object_class, PROP_UNDO_TYPE,
g_param_spec_enum ("undo-type", NULL, NULL,
GIMP_TYPE_UNDO_TYPE,
......@@ -222,6 +228,9 @@ gimp_undo_set_property (GObject *object,
/* don't ref */
undo->image = g_value_get_object (value);
break;
case PROP_TIME:
undo->time = g_value_get_uint (value);
break;
case PROP_UNDO_TYPE:
undo->undo_type = g_value_get_enum (value);
break;
......@@ -248,6 +257,9 @@ gimp_undo_get_property (GObject *object,
case PROP_IMAGE:
g_value_set_object (value, undo->image);
break;
case PROP_TIME:
g_value_set_uint (value, undo->time);
break;
case PROP_UNDO_TYPE:
g_value_set_enum (value, undo->undo_type);
break;
......@@ -421,8 +433,8 @@ gimp_undo_create_preview (GimpUndo *undo,
undo->preview_idle_id =
g_idle_add_full (G_PRIORITY_DEFAULT_IDLE,
gimp_undo_create_preview_idle,
idle, (GDestroyNotify) gimp_undo_idle_free);
gimp_undo_create_preview_idle, idle,
(GDestroyNotify) gimp_undo_idle_free);
}
}
......@@ -549,3 +561,36 @@ gimp_undo_is_weak (GimpUndo *undo)
return FALSE;
}
/**
* gimp_undo_get_age:
* @undo:
*
* Return value: the time in seconds since this undo item was created
*/
gint
gimp_undo_get_age (GimpUndo *undo)
{
guint now = time (NULL);
g_return_val_if_fail (GIMP_IS_UNDO (undo), 0);
g_return_val_if_fail (now >= undo->time, 0);
return now - undo->time;
}
/**
* gimp_undo_reset_age:
* @undo:
*
* Changes the creation time of this undo item to the current time.
*/
void
gimp_undo_reset_age (GimpUndo *undo)
{
g_return_if_fail (GIMP_IS_UNDO (undo));
undo->time = time (NULL);
g_object_notify (G_OBJECT (undo), "time");
}
......@@ -87,5 +87,8 @@ void gimp_undo_refresh_preview (GimpUndo *undo,
const gchar * gimp_undo_type_to_name (GimpUndoType type);
gboolean gimp_undo_is_weak (GimpUndo *undo);
gint gimp_undo_get_age (GimpUndo *undo);
void gimp_undo_reset_age (GimpUndo *undo);
#endif /* __GIMP_UNDO_H__ */
......@@ -543,15 +543,12 @@ gimp_text_tool_apply (GimpTextTool *text_tool)
if (text_undo->pspec == pspec)
{
guint now = time (NULL);
if (now >= undo->time &&
now - undo->time < TEXT_UNDO_TIMEOUT)
if (gimp_undo_get_age (undo) < TEXT_UNDO_TIMEOUT)
{
GimpTool *tool = GIMP_TOOL (text_tool);
push_undo = FALSE;
undo->time = now;
gimp_undo_reset_age (undo);
gimp_undo_refresh_preview (undo,
GIMP_CONTEXT (gimp_tool_get_options (tool)));
}
......
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