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



commit 073d026f6cbd5c566c5c7d94d46d55d80c6a48c2
Author: Martin Nordholts <martinn src gnome org>
Date:   Sun Jul 5 09:14:16 2009 +0200

    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().

 app/display/gimpdisplayshell-title.c |   61 ++++++++++++++++++++++++++++-----
 1 files changed, 51 insertions(+), 10 deletions(-)
---
diff --git a/app/display/gimpdisplayshell-title.c b/app/display/gimpdisplayshell-title.c
index f987e31..4793583 100644
--- a/app/display/gimpdisplayshell-title.c
+++ b/app/display/gimpdisplayshell-title.c
@@ -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);
+    }
+
+  g_free (format_string);
 
-  return print (buf, len, start, "%s", filename);
+  return incr;
 }



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]