app: Keep track of GimpImage export dirtiness

Since save and export are separate activities we need to keep track of
image dirtiness for both of them. For this purpose, add a
'export_dirty' member to GimpImage which has the same semantics as
'dirty', but for export. Set it to clean whenever a document is
exported by whatever means. Do this with a new function
gimp_image_export_clean_all(). Also add gimp_image_is_export_dirty().
This commit is contained in:
Martin Nordholts 2009-07-03 22:51:11 +02:00
parent c4601b298d
commit 1662ff2523
4 changed files with 38 additions and 1 deletions

View File

@ -600,6 +600,8 @@ gimp_image_init (GimpImage *image)
image->dirty_time = 0;
image->undo_freeze_count = 0;
image->export_dirty = 1;
image->instance_count = 0;
image->disp_count = 0;
@ -2028,6 +2030,7 @@ gimp_image_dirty (GimpImage *image,
g_return_val_if_fail (GIMP_IS_IMAGE (image), FALSE);
image->dirty++;
image->export_dirty++;
if (! image->dirty_time)
image->dirty_time = time (NULL);
@ -2046,6 +2049,7 @@ gimp_image_clean (GimpImage *image,
g_return_val_if_fail (GIMP_IS_IMAGE (image), FALSE);
image->dirty--;
image->export_dirty--;
g_signal_emit (image, gimp_image_signals[CLEAN], 0, dirty_mask);
@ -2065,6 +2069,16 @@ gimp_image_clean_all (GimpImage *image)
g_signal_emit (image, gimp_image_signals[CLEAN], 0, GIMP_DIRTY_ALL);
}
void
gimp_image_export_clean_all (GimpImage *image)
{
g_return_if_fail (GIMP_IS_IMAGE (image));
image->export_dirty = 0;
g_signal_emit (image, gimp_image_signals[CLEAN], 0, GIMP_DIRTY_ALL);
}
/**
* gimp_image_is_dirty:
* @image:
@ -2077,6 +2091,18 @@ gimp_image_is_dirty (const GimpImage *image)
return image->dirty != 0;
}
/**
* gimp_image_is_export_dirty:
* @image:
*
* Returns: True if the image export is dirty, false otherwise.
**/
gboolean
gimp_image_is_export_dirty (const GimpImage *image)
{
return image->export_dirty != 0;
}
/**
* gimp_image_saved:
* @image:

View File

@ -121,6 +121,8 @@ struct _GimpImage
guint dirty_time; /* time when image became dirty */
gint undo_freeze_count; /* counts the _freeze's */
gint export_dirty; /* 'dirty' but for export */
gint instance_count; /* number of instances */
gint disp_count; /* number of displays */
@ -350,6 +352,8 @@ gint gimp_image_clean (GimpImage *image,
GimpDirtyMask dirty_mask);
void gimp_image_clean_all (GimpImage *image);
gint gimp_image_is_dirty (const GimpImage *image);
gboolean gimp_image_is_export_dirty (const GimpImage *image);
void gimp_image_export_clean_all (GimpImage *image);
/* flush this image's displays */

View File

@ -598,7 +598,10 @@ file_open_sanitize_image (GimpImage *image,
while (image->undo_freeze_count)
gimp_image_undo_thaw (image);
/* set the image to clean */
/* Set the image to clean. Note that export dirtiness is not set to
* clean here; we can only consider export clean after the first
* export
*/
gimp_image_clean_all (image);
/* make sure the entire projection is properly constructed, because

View File

@ -162,6 +162,10 @@ file_save (Gimp *gimp,
gimp_image_clean_all (image);
}
else if (export)
{
gimp_image_export_clean_all (image);
}
if (export)
gimp_image_exported (image, uri);