Sophie

Sophie

distrib > Mageia > 1 > i586 > media > core-release-src > by-pkgid > 09dcd98fd5f0860af87d05da859ba4a2 > files > 3

gqview-2.1.5-11.mga1.src.rpm

--- old/src/bar_sort.c
+++ new/src/bar_sort.c
@@ -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)