? gnome-screenshot-allow-new-filename-patch.diff
Index: gnome-panel-screenshot.c
===================================================================
RCS file: /cvs/gnome/gnome-utils/gnome-screenshot/gnome-panel-screenshot.c,v
retrieving revision 1.91
diff -u -p -r1.91 gnome-panel-screenshot.c
--- gnome-panel-screenshot.c	7 Feb 2006 15:15:36 -0000	1.91
+++ gnome-panel-screenshot.c	23 Apr 2006 10:53:34 -0000
@@ -269,6 +269,8 @@ run_dialog (ScreenshotDialog *dialog)
 	       * correct location */
 	      if (! try_to_save (dialog, uri))
 		keep_going = TRUE;
+	      gtk_widget_grab_focus (GTK_WIDGET(dialog->filename_entry));
+	      screenshot_editable_select_filename_omit_extension (GTK_EDITABLE(dialog->filename_entry));
 	    }
 	  break;
 	default:
@@ -364,7 +366,6 @@ prepare_screenshot (void)
   screenshot_save_start (screenshot, save_done_notification, dialog);
 
   run_dialog (dialog);
-
 }
 
 static gboolean
Index: screenshot-dialog.c
===================================================================
RCS file: /cvs/gnome/gnome-utils/gnome-screenshot/screenshot-dialog.c,v
retrieving revision 1.11
diff -u -p -r1.11 screenshot-dialog.c
--- screenshot-dialog.c	14 Feb 2006 14:29:36 -0000	1.11
+++ screenshot-dialog.c	23 Apr 2006 10:53:34 -0000
@@ -12,17 +12,6 @@ static GtkTargetEntry drag_types[] =
   { "text/uri-list", 0, 0 }
 };
 
-struct ScreenshotDialog
-{
-  GladeXML *xml;
-  GdkPixbuf *screenshot;
-  GdkPixbuf *preview_image;
-  GtkWidget *save_widget;
-  GtkWidget *filename_entry;
-  gint drag_x;
-  gint drag_y;
-};
-
 static gboolean
 on_toplevel_key_press_event (GtkWidget *widget,
 			     GdkEventKey *key)
@@ -170,8 +159,6 @@ screenshot_dialog_new (GdkPixbuf *screen
   gint width, height;
   char *current_folder;
   char *current_name;
-  char *ext;
-  gint pos;
   GnomeVFSURI *tmp_uri;
   GnomeVFSURI *parent_uri;
 
@@ -248,17 +235,7 @@ screenshot_dialog_new (GdkPixbuf *screen
   /* select the name of the file but leave out the extension if there's any;
    * the dialog must be realized for select_region to work
    */
-  ext = g_utf8_strchr (current_name, -1, '.');
-  if (ext && ext != current_name)
-    pos = ext - current_name;
-  else
-    pos = -1;
-
-  gtk_editable_select_region (GTK_EDITABLE (dialog->filename_entry),
-			      0,
-			      pos);
-  
-  g_free (current_name);
+  screenshot_editable_select_filename_omit_extension (GTK_EDITABLE(dialog->filename_entry));
 
   return dialog;
 }
Index: screenshot-dialog.h
===================================================================
RCS file: /cvs/gnome/gnome-utils/gnome-screenshot/screenshot-dialog.h,v
retrieving revision 1.2
diff -u -p -r1.2 screenshot-dialog.h
--- screenshot-dialog.h	10 Nov 2004 06:20:32 -0000	1.2
+++ screenshot-dialog.h	23 Apr 2006 10:53:34 -0000
@@ -5,6 +5,16 @@
 #include <glade/glade.h>
 
 typedef struct ScreenshotDialog ScreenshotDialog;
+struct ScreenshotDialog
+{
+  GladeXML *xml;
+  GdkPixbuf *screenshot;
+  GdkPixbuf *preview_image;
+  GtkWidget *save_widget;
+  GtkWidget *filename_entry;
+  gint drag_x;
+  gint drag_y;
+};
 
 ScreenshotDialog *screenshot_dialog_new          (GdkPixbuf        *screenshot,
 						  char             *initial_uri,
Index: screenshot-utils.c
===================================================================
RCS file: /cvs/gnome/gnome-utils/gnome-screenshot/screenshot-utils.c,v
retrieving revision 1.3
diff -u -p -r1.3 screenshot-utils.c
--- screenshot-utils.c	14 Dec 2005 14:29:17 -0000	1.3
+++ screenshot-utils.c	23 Apr 2006 10:53:34 -0000
@@ -610,3 +610,22 @@ screenshot_get_window_title (Window w)
   return g_strdup (_("Untitled Window"));
 }
 
+void
+screenshot_editable_select_filename_omit_extension (GtkEditable *editable)
+{
+  gchar *current_name = gtk_editable_get_chars (editable, 0, -1);
+  const gchar *ext;
+  gint	pos;
+
+  ext = g_utf8_strchr (current_name, -1, '.');
+  if (ext && ext != current_name)
+    pos = ext - current_name;
+  else
+    pos = -1;
+
+  gtk_editable_select_region (editable,
+			      0,
+			      pos);
+  
+  g_free (current_name);
+}
Index: screenshot-utils.h
===================================================================
RCS file: /cvs/gnome/gnome-utils/gnome-screenshot/screenshot-utils.h,v
retrieving revision 1.2
diff -u -p -r1.2 screenshot-utils.h
--- screenshot-utils.h	24 Oct 2004 01:23:39 -0000	1.2
+++ screenshot-utils.h	23 Apr 2006 10:53:34 -0000
@@ -9,5 +9,6 @@ void       screenshot_release_lock      
 gchar     *screenshot_get_window_title    (Window   w);
 Window     screenshot_find_current_window (gboolean include_decoration);
 GdkPixbuf *screenshot_get_pixbuf          (Window   w);
+void	   screenshot_editable_select_filename_omit_extension (GtkEditable *editable);
 
 #endif /* __SCREENSHOT_UTILS_H__ */
Index: screenshot-xfer.c
===================================================================
RCS file: /cvs/gnome/gnome-utils/gnome-screenshot/screenshot-xfer.c,v
retrieving revision 1.4
diff -u -p -r1.4 screenshot-xfer.c
--- screenshot-xfer.c	21 Dec 2005 13:34:20 -0000	1.4
+++ screenshot-xfer.c	23 Apr 2006 10:53:34 -0000
@@ -18,6 +18,7 @@ typedef struct
   gboolean delete_target;
   guint timeout_id;
   gboolean canceled;
+  gboolean duplicate;
 } TransferInfo;
 
 static gboolean show_dialog_timeout (TransferInfo *transfer_info);
@@ -83,7 +84,7 @@ handle_transfer_ok (const GnomeVFSXferPr
 	  gtk_widget_destroy (transfer_info->progress_dialog);
 	  transfer_info->progress_dialog = NULL;
 	}
-      gtk_main_quit ();
+      if (!transfer_info->duplicate) gtk_main_quit ();
       return 0;
     }
 
@@ -151,7 +152,7 @@ static gint
 handle_transfer_vfs_error (GnomeVFSXferProgressInfo *progress_info,
 			   TransferInfo             *transfer_info)
 {
-  g_print ("handle_transfer_vfs_error!\n");
+  if (!transfer_info->duplicate) g_print ("handle_transfer_vfs_error!\n");
   remove_timeout (transfer_info);
   if (transfer_info->progress_dialog)
     {
@@ -195,7 +196,10 @@ handle_transfer_overwrite (const GnomeVF
   if (response == GTK_RESPONSE_OK)
     return GNOME_VFS_XFER_OVERWRITE_ACTION_REPLACE;
   else
-    return GNOME_VFS_XFER_OVERWRITE_ACTION_SKIP;
+    {
+      transfer_info->duplicate = TRUE;
+      return GNOME_VFS_XFER_OVERWRITE_ACTION_ABORT;
+    }
 
   if (need_timeout)
     add_timeout (transfer_info);
@@ -259,6 +263,7 @@ screenshot_xfer_uri (GnomeVFSURI *source
 
   transfer_info = g_new0 (TransferInfo, 1);
   transfer_info->parent_dialog = parent;
+  transfer_info->duplicate = FALSE;
   add_timeout (transfer_info);
 
   result = gnome_vfs_async_xfer (&transfer_info->handle,
@@ -269,14 +274,19 @@ screenshot_xfer_uri (GnomeVFSURI *source
 				 GNOME_VFS_PRIORITY_DEFAULT,
 				 screenshot_async_xfer_progress, transfer_info,
 				 NULL, NULL);
+
   gtk_main ();
   remove_timeout (transfer_info);
+
   g_list_free (source_uri_list);
   g_list_free (target_uri_list);
 
   if (transfer_info->delete_target)
     ;/* try to delete the target, iff it started writing */
 
-  return GNOME_VFS_OK;
+  if (transfer_info->duplicate)
+    return GNOME_VFS_ERROR_FILE_EXISTS;
+  else
+    return GNOME_VFS_OK;
 }
 
