Package: gqview Version: 2.0.1-1 Severity: normal Tags: patch
The current version does not support multiple file move/copy/link actions (and the equivalents undo actions) in the folder-sort bar...(CTRL+S). I solved the problem with the following patch (it has been tested on Debian GNU/Linux i386 and powerpc). -- System Information: Debian Release: testing/unstable APT prefers testing APT policy: (990, 'testing'), (500, 'unstable'), (500, 'stable'), (1, 'experimental') Architecture: i386 (i686) Shell: /bin/sh linked to /bin/bash Kernel: Linux 2.6.13.2 Locale: [EMAIL PROTECTED], [EMAIL PROTECTED] (charmap=ISO-8859-15) (ignored: LC_ALL set to [EMAIL PROTECTED]) Versions of packages gqview depends on: ii libatk1.0-0 1.10.3-1 The ATK accessibility toolkit ii libc6 2.3.5-6 GNU C Library: Shared libraries an ii libglib2.0-0 2.8.3-1 The GLib library of C routines ii libgtk2.0-0 2.6.10-1 The GTK+ graphical user interface ii libpango1.0-0 1.8.2-3 Layout and rendering of internatio Versions of packages gqview recommends: ii libjpeg-progs 6b-10 Programs for manipulating JPEG fil -- no debconf information
diff -Nur gqview-cvs-2005-10-13/src/bar_sort.c gqview-multi-cvs-2005-10-13.test/src/bar_sort.c --- gqview-cvs-2005-10-13/src/bar_sort.c 2005-10-13 20:06:42.000000000 +0200 +++ gqview-multi-cvs-2005-10-13.test/src/bar_sort.c 2005-10-13 23:43:05.000000000 +0200 @@ -68,6 +68,7 @@ GtkWidget *undo_button; SortActionType undo_action; GList *undo_src_list; + GList *undo_dest_list; gchar *undo_src; gchar *undo_dest; }; @@ -174,8 +175,24 @@ { path_list_free(sd->undo_src_list); sd->undo_src_list = src_list; - + if (src_list) + { + /* we should create the undo_dest_list to use it later... */ + path_list_free(sd->undo_dest_list); + sd->undo_dest_list=NULL; + GList *tmp = src_list; + while(tmp) + { + gchar *filename = g_strdup(filename_from_path(tmp->data)); + gchar *dest_path = concat_dir_and_file(g_strdup(dest), filename); + sd->undo_dest_list = g_list_prepend(sd->undo_dest_list, g_strdup(dest_path) ); + tmp = tmp->next; + } + sd->undo_dest_list = g_list_reverse(sd->undo_dest_list); + } g_free(sd->undo_src); + + /* i think this is useless if we always provide a list... can we ? */ sd->undo_src = g_strdup(src); g_free(sd->undo_dest); sd->undo_dest = g_strdup(dest); @@ -191,7 +208,7 @@ static void bar_sort_undo_folder(SortData *sd, GtkWidget *button) { - if (!sd->undo_src || !sd->undo_dest) return; + if (!((sd->undo_src && sd->undo_dest) || (sd->undo_src_list && sd->undo_dest_list))) return; switch (sd->undo_action) { @@ -199,25 +216,75 @@ { GList *list; gchar *src_dir; + gchar *src_path; - list = g_list_append(NULL, g_strdup(sd->undo_dest)); - src_dir = remove_level_from_path(sd->undo_src); - file_util_move_simple(list, src_dir); - g_free(src_dir); + if (sd->undo_src_list) + { + /* multiple files case */ + src_path = g_strdup(sd->undo_src_list->data); + src_dir = remove_level_from_path(src_path); + list = path_list_copy(sd->undo_dest_list); + file_util_move_simple(list, src_dir); + g_free(src_dir); + } + else + { + list = g_list_append(NULL, g_strdup(sd->undo_dest)); + src_dir = remove_level_from_path(sd->undo_src); + file_util_move_simple(list, src_dir); + g_free(src_dir); + } } break; case BAR_SORT_COPY: - file_util_delete(sd->undo_dest, NULL, button); - break; + /* should work with multiple files */ + if (sd->undo_src_list) + { + /* multiple files case */ + GList *delete_list; + gchar *dest_path; + delete_list = path_list_copy(sd->undo_dest_list); + /* GYR: dans le cas d'un copy/undo(delete)/cancel ? on ne peut plus faire d'undo... */ + file_util_delete(NULL, delete_list, button); + } + else + { + /* GYR: single file case */ + file_util_delete(sd->undo_dest, NULL, button); + } + break; case BAR_SORT_LINK: - if (!unlink_file(sd->undo_dest)) + /* should work with multiple files */ + if (sd->undo_src_list) { - gchar *buf; - - buf = g_strdup_printf("Unable to remove symbolic link:\n%s", sd->undo_dest); - file_util_warning_dialog(_("Unlink failed"), buf, GTK_STOCK_DIALOG_ERROR, button); - g_free(buf); + /* multiple files case */ + GList *tmp; + tmp = sd->undo_dest_list; + while(tmp) + { + if (!unlink_file(tmp->data)) + { + gchar *buf; + + buf = g_strdup_printf("Unable to remove symbolic link:\n%s", tmp->data); + file_util_warning_dialog(_("Unlink failed"), buf, GTK_STOCK_DIALOG_ERROR, button); + g_free(buf); + } + tmp = tmp->next; + } } + else + { + /* single file case */ + if (!unlink_file(sd->undo_dest)) + { + gchar *buf; + + buf = g_strdup_printf("Unable to remove symbolic link:\n%s", sd->undo_dest); + file_util_warning_dialog(_("Unlink failed"), buf, GTK_STOCK_DIALOG_ERROR, button); + g_free(buf); + } + } break; } @@ -264,46 +331,57 @@ static void bar_sort_bookmark_select_folder(SortData *sd, const gchar *source, const gchar *path) { - GList *list; gchar *dest_path; - + GList *orig_list; + GList *action_list; + GList *undo_src_list; + GList *tmp; if (!isdir(path)) return; - dest_path = concat_dir_and_file(path, filename_from_path(source)); - bar_sort_undo_set(sd, NULL, source, dest_path); + orig_list = layout_selection_list(sd->lw); + + action_list = path_list_copy(orig_list); + undo_src_list = path_list_copy(orig_list); + orig_list = NULL; - list = g_list_append(NULL, g_strdup(source)); + bar_sort_undo_set(sd, undo_src_list, NULL, path); switch (sd->action) { case BAR_SORT_COPY: - file_util_copy_simple(list, path); - list = NULL; + file_util_copy_simple(action_list, path); + action_list = NULL; layout_image_next(sd->lw); break; case BAR_SORT_MOVE: - file_util_move_simple(list, path); - list = NULL; + file_util_move_simple(action_list, path); + action_list = NULL; break; case BAR_SORT_LINK: - if (symlink_utf8(source, dest_path)) + tmp=action_list; + while(tmp) { - layout_image_next(sd->lw); - } - else - { - gchar *buf; - - buf = g_strdup_printf("Unable to create symbolic link:\n%s", dest_path); - file_util_warning_dialog(_("Link failed"), buf, GTK_STOCK_DIALOG_ERROR, sd->bookmarks); - - g_free(buf); + dest_path = concat_dir_and_file(path, filename_from_path(tmp->data)); + if (symlink_utf8(tmp->data, dest_path)) + { + layout_image_next(sd->lw); + } + else + { + gchar *buf; + + buf = g_strdup_printf("Unable to create symbolic link:\n%s", dest_path); + file_util_warning_dialog(_("Link failed"), buf, GTK_STOCK_DIALOG_ERROR, sd->bookmarks); + + g_free(buf); + } + tmp=tmp->next; + g_free(dest_path); } break; } - g_list_free(list); - g_free(dest_path); + g_list_free(action_list); } static void bar_sort_bookmark_select_collection(SortData *sd, const gchar *source, const gchar *path)