Subject: gthumb: overwrite dialog should suggest new name Package: gthumb Version: 3:2.10.11-1 Severity: wishlist Tags: patch
*** Please type your report below this line *** When moving images around, if you happen to have two files of the same name, an overwrite dialog appears. One of the options is to rename the new file; the text box presents the original file name and allows you to edit that. I find it's more useful if the textbox instead presents you with a suggested alternate name, the way Konqueror's overwrite dialog does, so that you can just select that radio box and click OK, rather than having to type into the box (and keep track of how many similarly-named images you're trying to move). I've included a patch that adds this functionality. If you have "Picture.jpg", the name "Picture_1.jpg" will be suggested. If that isn't available, then "Picture_2.jpg" will be suggested, and so on. -- System Information: Debian Release: squeeze/sid APT prefers testing-proposed-updates APT policy: (500, 'testing-proposed-updates'), (500, 'testing') Architecture: i386 (i686) Kernel: Linux 2.6.26-2-686 (SMP w/2 CPU cores) Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8) Shell: /bin/sh linked to /bin/bash Versions of packages gthumb depends on: ii gthumb-data 3:2.10.11-1 an image viewer and browser - arch ii libart-2.0-2 2.3.20-2 Library of functions for 2D graphi ii libbonobo2-0 2.24.1-1 Bonobo CORBA interfaces library ii libc6 2.9-12 GNU C Library: Shared libraries ii libcairo2 1.8.6-2+b1 The Cairo 2D vector graphics libra ii libexif12 0.6.17-1 library to parse EXIF files ii libgconf2-4 2.26.0-1 GNOME configuration database syste ii libglade2-0 1:2.6.4-1 library to load .glade files at ru ii libglib2.0-0 2.20.1-2 The GLib library of C routines ii libgnome2-0 2.26.0-1 The GNOME library - runtime files ii libgnomecanvas2-0 2.26.0-1 A powerful object-oriented display ii libgnomeui-0 2.24.1-1 The GNOME 2 libraries (User Interf ii libgnomevfs2-0 1:2.24.1-1 GNOME Virtual File System (runtime ii libgphoto2-2 2.4.5-1 gphoto2 digital camera library ii libgphoto2-port0 2.4.5-1 gphoto2 digital camera port librar ii libgtk2.0-0 2.16.1-2 The GTK+ graphical user interface ii libiptcdata0 1.0.3-1 Library to parse IPTC metadata ii libjpeg62 6b-14 The Independent JPEG Group's JPEG ii libopenrawgnome1 0.0.7-1 free implementation for RAW decodi ii liborbit2 1:2.14.17-0.1 libraries for ORBit2 - a CORBA ORB ii libpango1.0-0 1.24.0-3+b1 Layout and rendering of internatio ii libpng12-0 1.2.35-1 PNG library - runtime ii libtiff4 3.8.2-11 Tag Image File Format (TIFF) libra ii libx11-6 2:1.2.1-1 X11 client-side library ii libxml2 2.7.3.dfsg-1 GNOME XML library ii libxrender1 1:0.9.4-2 X Rendering Extension client libra gthumb recommends no packages. gthumb suggests no packages. -- no debconf information
diff -Naur gthumb-2.10.11-old/src/.directory gthumb-2.10.11-new-uncompiled/src/.directory --- gthumb-2.10.11-old/src/.directory 1969-12-31 16:00:00.000000000 -0800 +++ gthumb-2.10.11-new-uncompiled/src/.directory 2009-05-28 15:13:40.000000000 -0700 @@ -0,0 +1,3 @@ +[Dolphin] +Timestamp=2009,5,28,15,13,40 +ViewMode=1 diff -Naur gthumb-2.10.11-old/src/dlg-file-utils.c gthumb-2.10.11-new-uncompiled/src/dlg-file-utils.c --- gthumb-2.10.11-old/src/dlg-file-utils.c 2009-02-24 02:18:11.000000000 -0800 +++ gthumb-2.10.11-new-uncompiled/src/dlg-file-utils.c 2009-05-28 20:43:26.000000000 -0700 @@ -23,6 +23,8 @@ #include <config.h> #include <string.h> #include <unistd.h> +#include <stdlib.h> +#include <stdio.h> #include <glib/gi18n.h> #include <gtk/gtk.h> @@ -592,6 +594,33 @@ gtk_toggle_button_get_active (button)); } +const char *file_name_from_path_uniquify(const char *file_name) +{ + /* return a (hopefully) unique filename within a directory. Return the original filename on failure. */ + int malloc_size = strlen(file_name) + DLG_FILE_MAX_RNAMECHR + 2; + int i; + + char *name_copy = malloc(strlen(file_name)); + char *exten; + char *temp = malloc( malloc_size ); + + exten = strrchr(name_copy,'.')+1; + *strrchr(name_copy,'.') = 0; + + for (i = 1; i < DLG_FILE_MAX_RENAME; i++) { + snprintf(temp, (size_t) malloc_size, "%s_%d.%s", name_copy, i, exten); + if (path_is_file (temp)) { + continue; + } + else { + free(name_copy); + return file_name_from_path(temp); + } + } + free(name_copy); + return file_name_from_path(file_name); +} + static DlgOverwriteData * create_overwrite_dialog (GthWindow *window, @@ -698,7 +727,7 @@ gtk_widget_set_sensitive (owdata->overwrite_rename_entry, default_overwrite_mode == OVERWRITE_RESULT_RENAME); _gtk_entry_set_filename_text (GTK_ENTRY (owdata->overwrite_rename_entry), - file_name_from_path (new_filename)); + file_name_from_path_uniquify (new_filename)); if (default_overwrite_mode == OVERWRITE_RESULT_RENAME) gtk_widget_grab_focus (owdata->overwrite_rename_entry); diff -Naur gthumb-2.10.11-old/src/dlg-file-utils.h gthumb-2.10.11-new-uncompiled/src/dlg-file-utils.h --- gthumb-2.10.11-old/src/dlg-file-utils.h 2009-02-24 02:18:11.000000000 -0800 +++ gthumb-2.10.11-new-uncompiled/src/dlg-file-utils.h 2009-05-28 20:07:54.000000000 -0700 @@ -26,6 +26,8 @@ #include <libgnomevfs/gnome-vfs-result.h> #include "gth-window.h" +#define DLG_FILE_MAX_RENAME 1000 +#define DLG_FILE_MAX_RNAMECHR 4 gboolean dlg_file_delete__confirm (GthWindow *window, GList *list,
signature.asc
Description: This is a digitally signed message part.