[gimp: 4/27] app: Show imported image basename in titlebar



commit 88e1064ed3f808f1dcb422798ae3093927a99e9c
Author: Martin Nordholts <martinn src gnome org>
Date:   Sun Apr 26 10:15:35 2009 +0200

    app: Show imported image basename in titlebar
    
    If an image is imported, make the image window title be
    'Untitled (imported from <filename>)' instead of just 'Untitled'.
---
 app/display/gimpdisplayshell-title.c |   35 ++++++++++++++++++++++++++++++++-
 1 files changed, 33 insertions(+), 2 deletions(-)

diff --git a/app/display/gimpdisplayshell-title.c b/app/display/gimpdisplayshell-title.c
index 1b2f488..abee94e 100644
--- a/app/display/gimpdisplayshell-title.c
+++ b/app/display/gimpdisplayshell-title.c
@@ -36,6 +36,7 @@
 #include "core/gimpunit.h"
 
 #include "file/file-utils.h"
+#include "file/gimp-file.h"
 
 #include "gimpdisplay.h"
 #include "gimpdisplayshell.h"
@@ -55,6 +56,11 @@ static gint     gimp_display_shell_format_title      (GimpDisplayShell *display,
                                                       gchar            *title,
                                                       gint              title_len,
                                                       const gchar      *format);
+static gint     gimp_display_shell_format_filename   (gchar            *buf,
+                                                      gint              len,
+                                                      gint              start,
+                                                      GimpImage        *image,
+                                                      const gchar      *filename);
 
 
 /*  public functions  */
@@ -202,7 +208,7 @@ gimp_display_shell_format_title (GimpDisplayShell *shell,
               {
                 const gchar *name = gimp_image_get_display_name (image);
 
-                i += print (title, title_len, i, "%s", name);
+                i += gimp_display_shell_format_filename (title, title_len, i, image, name);
               }
               break;
 
@@ -213,7 +219,7 @@ gimp_display_shell_format_title (GimpDisplayShell *shell,
 
                 filename = file_utils_uri_display_name (uri);
 
-                i += print (title, title_len, i, "%s", filename);
+                i += gimp_display_shell_format_filename (title, title_len, i, image, filename);
 
                 g_free (filename);
               }
@@ -427,3 +433,28 @@ gimp_display_shell_format_title (GimpDisplayShell *shell,
 
   return i;
 }
+
+static gint
+gimp_display_shell_format_filename (gchar       *buf,
+                                    gint         len,
+                                    gint         start,
+                                    GimpImage   *image,
+                                    const gchar *filename)
+{
+  gint         incr   = 0;
+  const gchar *source = g_object_get_data (G_OBJECT (image),
+                                           GIMP_FILE_IMPORT_SOURCE_URI_KEY);
+  if (! source)
+    {
+      incr = print (buf, len, start, "%s", filename);
+    }
+  else
+    {
+      gchar *source_basename = file_utils_uri_display_basename (source);
+      incr = print (buf, len, start,
+                    "%s (%s %s)", filename,  _("imported from"), source_basename);
+      g_free (source_basename);
+    }
+
+  return incr;
+}



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