app: Show "(overwritten)" and "(exported)" status of image

When an import source has been overwritten with File -> Overwrite
<file.png>, or exported by whatever means, reflect this status in the
title bar of the image window. Do this by adding some string building
logic to gimp_display_shell_format_filename().
This commit is contained in:
Martin Nordholts 2009-07-05 09:14:16 +02:00
parent 1662ff2523
commit 073d026f6c
1 changed files with 51 additions and 10 deletions

View File

@ -441,24 +441,65 @@ gimp_display_shell_format_filename (gchar *buf,
GimpImage *image,
const gchar *filename)
{
const gchar *source = g_object_get_data (G_OBJECT (image),
GIMP_FILE_IMPORT_SOURCE_URI_KEY);
gint incr = 0;
const gchar *name_format = NULL;
const gchar *name = NULL;
const gchar *export_status = NULL;
const gchar *format_string = NULL;
const gchar *source = NULL;
const gchar *export_to = NULL;
source = g_object_get_data (G_OBJECT (image),
GIMP_FILE_IMPORT_SOURCE_URI_KEY);
export_to = g_object_get_data (G_OBJECT (image),
GIMP_FILE_EXPORT_TO_URI_KEY);
if (source)
{
/* As soon as the image is saved the source is forgotten, so the
* above condition is enough to figure out name_format and name
*/
name_format = "[%s]";
name = source;
}
else
{
name_format = "%s";
name = gimp_object_get_name (GIMP_OBJECT (image));
}
if (! gimp_image_is_export_dirty (image))
{
if (export_to)
export_status = _(" (exported)");
else if (source)
export_status = _(" (overwritten)");
else
g_warning ("Unexpected code path, Save+export implementation is buggy!");
}
else if (source)
{
export_status = _(" (imported)");
}
format_string = g_strconcat (name_format, export_status, NULL);
if (source)
{
gchar *source_no_ext = file_utils_uri_with_new_ext (source, NULL);
gchar *source_basename = file_utils_uri_display_basename (source_no_ext);
gint incr;
incr = print (buf, len, start,
/* image import source as shown in the title of
the image window */
_("[%s] (imported)"), source_basename);
incr = print (buf, len, start, format_string, source_basename);
g_free (source_basename);
g_free (source_no_ext);
return incr;
}
else
{
incr = print (buf, len, start, format_string, filename);
}
return print (buf, len, start, "%s", filename);
g_free (format_string);
return incr;
}