--- gnome-utils-2.24.1.orig/gnome-screenshot/gnome-screenshot.c
+++ gnome-utils-2.24.1/gnome-screenshot/gnome-screenshot.c
@@ -39,6 +39,7 @@
 #include <glib/gi18n.h>
 #include <gio/gio.h>
 #include <pwd.h>
+#include <time.h>
 #include <X11/Xutil.h>
 
 #include "screenshot-shadow.h"
@@ -56,6 +57,7 @@
 #define BORDER_EFFECT_KEY       GNOME_SCREENSHOT_GCONF "/border_effect"
 #define DELAY_KEY               GNOME_SCREENSHOT_GCONF "/delay"
 #define TAKE_WINDOW_SHOT_KEY    GNOME_SCREENSHOT_GCONF "/take_window_shot"
+#define FILENAME_FORMAT_KEY     GNOME_SCREENSHOT_GCONF "/filename_format"
 
 
 enum
@@ -767,11 +769,118 @@
   return FALSE;
 }
 
+static char *expand_custom_format_uri(char *format, char *window_title,
+                          int iteration)
+{
+  const int maxlen = 1024;
+  char f2[maxlen], f3[maxlen];
+  int i = -1, j = 0;        /* position in format and f2
+                        respectively */
+  int iteration_present = 0;  /* have we seen @i or @I yet? */
+  while(format[++i] && j < maxlen) {
+    /* literal @ */
+    if(format[i] == '@' && format[i + 1] == '@') {
+      i++;
+      f2[j++] = '@';
+    }
+    /* username */
+    else if(format[i] == '@' && format[i + 1] == 'u') {
+      i++;
+      struct passwd *pw;
+      pw = getpwuid(geteuid());
+      if(!pw)
+        continue;  /* handle error? */
+      strncpy(&f2[j], pw->pw_name, maxlen - j);
+      j += strlen(pw->pw_name);
+    }
+    /* hostname */
+    else if(format[i] == '@' && format[i + 1] == 'h') {
+      i++;
+      char hostname[128];   /* HOST_NAME_MAX should be defined to 
+                        128... */
+      gethostname(hostname, 128);
+      strncpy(&f2[j], hostname, maxlen - j);
+      j += strlen(hostname);
+    }
+    /* $DISPLAY */
+    else if(format[i] == '@' && format[i + 1] == 'd') {
+      i++;
+      char *dpy = getenv("DISPLAY");
+      strncpy(&f2[j], dpy, maxlen - j);
+      j += strlen(dpy);
+    }
+    /* 'Screenshot' as translatable string */
+    else if(format[i] == '@' && format[i + 1] == 's') {
+      i++;
+      char *sshot;
+      sshot = _("Screenshot");  /* should be _("Screenshot") */
+      strncpy(&f2[j], sshot, maxlen - j);
+      j += strlen(sshot);
+    }
+    /* window title (maybe NULL); @T will have - prepended (unless
+      NULL) */
+    else if(format[i] == '@'
+          && (format[i + 1] == 't' || format[i + 1] == 'T')) {
+      i++;
+      char *window_title = NULL; // "[window title]";
+      if(window_title == NULL)
+        continue;
+      if(format[i] == 'T')
+        f2[j++] = '-';
+      strncpy(&f2[j], window_title, maxlen - j);
+      j += strlen(window_title);
+    }
+    /* iteration number; it will disappear if zero, and will -
+      prepended with @I */
+    else if(format[i] == '@'
+          && (format[i + 1] == 'i' || format[i + 1] == 'I')) {
+      i++;
+      iteration_present = 1;
+      if(iteration == 0)
+        continue;
+      if(format[i] == 'I')
+        f2[j++] = '-';
+      j += snprintf(&f2[j], maxlen - j, "%d", iteration);
+    }
+    /* plain character copy */
+    else {
+      f2[j++] = format[i];
+    }
+  };
+  /* if there was no number in the filename, append it anyway since
+    otherwise we might get infinite loop looking for non-existent
+    filename */
+  if(!iteration_present) {
+    fprintf(stderr,
+          "Iteration @i not present in format string, appending number!");
+    j += snprintf(&f2[j], maxlen - j, "%d", iteration);
+  }
+
+  f2[j] = 0;  // NULL terminator
+
+  /* now f2 contains the format string with our custom @... escapes
+    expanded */
+
+  time_t t;
+  struct tm *tmp;
+  t = time(NULL);
+  tmp = localtime(&t);
+  if(!tmp) {
+    perror("localtime");
+    return strncpy(f3, "(Error calling localtime?)", maxlen);
+  }
+  if(strftime(f3, maxlen, f2, tmp) == 0) {
+    fprintf(stderr, "strftime returned 0");
+    return strncpy(f3, "Error calling strftime?)", maxlen);
+  }
+  return g_strdup(f3);
+}
+
 static char *
 build_uri (AsyncExistenceJob *job)
 {
   char *retval, *file_name;
-
+#if 0
   if (window_title)
     {
       /* translators: this is the name of the file that gets made up
@@ -805,7 +914,14 @@
           file_name = g_strdup_printf (_("Screenshot-%d.png"), job->iteration);
         }
     }
+#endif
+
+  GConfClient *gconf_client;
+  gconf_client = gconf_client_get_default ();
+  gchar* format=gconf_client_get_string(gconf_client,FILENAME_FORMAT_KEY,NULL);
+  if(!format) format="@s@T@I.png"; /* the old format, consolidates the code commented out above */
 
+  file_name=expand_custom_format_uri(format,window_title,job->iteration);
   retval = g_build_filename (job->base_uris[job->type], file_name, NULL);
   g_free (file_name);
   
--- gnome-utils-2.24.1.orig/gnome-screenshot/gnome-screenshot.schemas.in
+++ gnome-utils-2.24.1/gnome-screenshot/gnome-screenshot.schemas.in
@@ -76,5 +76,24 @@
       </locale>
     </schema>
 
+    <schema>
+      <key>/schemas/apps/gnome-screenshot/filename_format</key>
+      <applyto>/apps/gnome-screenshot/filename_format</applyto>
+      <owner>gnome-screenshot</owner>
+      <type>string</type>
+      <default>@s@T@I.png</default>
+      <locale name="C">
+        <short>Format of the default filename to save the screenshot</short>
+        <long>The format string combines 2 sets of escape sequences.
+		  
+		  The first one is @[character]: @u (replaced by username), @h (hostname), @d ($DISPLAY), @s (Screenshot, but translated to the current locale), @t (window title, may be empty), @T (window title with - appended; may be empty), @i and @I (number that will be increased if the file already exists; disappears if 0), @@ (literal @).
+
+		  The second set is %[characters] and is passed to the strftime function (see documentation; for example, %Y%M%d will give 20081228).
+
+		  The format should always contain @i or @I and should end with .png .
+      </long>
+      </locale>
+    </schema>
+
   </schemalist>
 </gconfschemafile>

