changeset 1619:011e8dbda7f2

changed selection behavior as requested at http://sourceforge.net/tracker/?func=detail&aid=2789933&group_id=222125&atid=1054680 file view - sidecars are added to the selection if they were expicitly selected or if the entry is collapsed icon view - selection always contains sidecars file operations splits partially selected groups - selected files have disabled grouping
author nadvornik
date Tue, 02 Jun 2009 22:33:53 +0000
parents f47b8dc207f5
children f0bd1152d774
files src/filedata.c src/filedata.h src/utilops.c src/view_file_icon.c src/view_file_list.c
diffstat 5 files changed, 145 insertions(+), 23 deletions(-) [+]
line wrap: on
line diff
--- a/src/filedata.c	Mon Jun 01 16:37:30 2009 +0000
+++ b/src/filedata.c	Tue Jun 02 22:33:53 2009 +0000
@@ -2335,8 +2335,89 @@
 	return TRUE;
 }
 
+static gboolean file_data_list_contains_whole_group(GList *list, FileData *fd)
+{
+	GList *work;
+	if (fd->parent) fd = fd->parent;
+	if (!g_list_find(list, fd)) return FALSE;
+	
+	work = fd->sidecar_files;
+	while (work)
+		{
+		if (!g_list_find(list, work->data)) return FALSE;
+		work = work->next;
+		}
+	return TRUE;
+}
+
+#if 0
+static gboolean file_data_list_dump(GList *list)
+{
+	GList *work, *work2;
+
+	work = list;
+	while (work)
+		{
+		FileData *fd = work->data;
+		printf("%s\n", fd->name);
+		work2 = fd->sidecar_files;
+		while (work2)
+			{
+			FileData *fd = work2->data;
+			printf("       %s\n", fd->name);
+			work2 = work2->next;
+			}
+		work = work->next;
+		}
+	return TRUE;
+}
+#endif
+
+GList *file_data_process_groups(GList *list)
+{
+	GList *out = NULL;
+	GList *work = list;
+
+	/* change partial groups to independent files */
+	while (work)
+		{
+		FileData *fd = work->data;
+		work = work->next;
+		
+		if (!file_data_list_contains_whole_group(list, fd)) 
+			file_data_disable_grouping(fd, TRUE);
+		}
+	
+	/* remove sidecars from the list, 
+	   they can be still acessed via main_fd->sidecar_files */
+	work = list;
+	while (work)
+		{
+		FileData *fd = work->data;
+		work = work->next;
+		
+		if (!fd->parent)
+			{
+			out = g_list_prepend(out, fd);
+			}
+		else
+			{
+			file_data_unref(fd);
+			}
+		}
+		
+	g_list_free(list);
+	out = g_list_reverse(out);
+
+	return out;
+}
+
+
+
+
+
 /*
- * notify other modules about the change described by FileFataChangeInfo
+ * notify other modules about the change described by FileDataChangeInfo
  */
 
 /* might use file_maint_ functions for now, later it should be changed to a system of callbacks
--- a/src/filedata.h	Mon Jun 01 16:37:30 2009 +0000
+++ b/src/filedata.h	Tue Jun 02 22:33:53 2009 +0000
@@ -126,6 +126,9 @@
 void file_data_sc_free_ci(FileData *fd);
 void file_data_sc_free_ci_list(GList *fd_list);
 
+GList *file_data_process_groups(GList *list);
+
+
 typedef void (*FileDataNotifyFunc)(FileData *fd, NotifyType type, gpointer data);
 gboolean file_data_register_notify_func(FileDataNotifyFunc func, gpointer data, NotifyPriority priority);
 gboolean file_data_unregister_notify_func(FileDataNotifyFunc func, gpointer data);
--- a/src/utilops.c	Mon Jun 01 16:37:30 2009 +0000
+++ b/src/utilops.c	Tue Jun 02 22:33:53 2009 +0000
@@ -1700,20 +1700,6 @@
 	file_util_warning_dialog(title, _("Another operation in progress.\n"), GTK_STOCK_DIALOG_ERROR, NULL);
 }
 
-static void file_util_disable_grouping_sc_list(GList *list)
-{
-	GList *work = list;
-	
-	while (work)
-		{
-		FileData *fd = work->data;
-		work = work->next;
-		
-		if (fd->parent) file_data_disable_grouping(fd, TRUE);
-		}
-		
-}
-
 static void file_util_details_dialog_close_cb(GtkWidget *widget, gpointer data)
 {
 	gtk_widget_destroy(data);
@@ -1943,7 +1929,7 @@
 
 	if (!flist) return;
 	
-	file_util_disable_grouping_sc_list(flist);
+	flist = file_data_process_groups(flist);
 	
 	if (!file_data_sc_add_ci_delete_list(flist))
 		{
@@ -2030,7 +2016,7 @@
 
 	if (!flist) return;
 
-	file_util_disable_grouping_sc_list(flist);
+	flist = file_data_process_groups(flist);
 
 	if (!file_data_sc_add_ci_move_list(flist, dest_path))
 		{
@@ -2071,7 +2057,7 @@
 
 	if (!flist) return;
 
-	file_util_disable_grouping_sc_list(flist);
+	flist = file_data_process_groups(flist);
 
 	if (!file_data_sc_add_ci_copy_list(flist, dest_path))
 		{
@@ -2112,7 +2098,7 @@
 
 	if (!flist) return;
 
-	file_util_disable_grouping_sc_list(flist);
+	flist = file_data_process_groups(flist);
 
 	if (!file_data_sc_add_ci_rename_list(flist, dest_path))
 		{
@@ -2153,7 +2139,7 @@
 
 	if (!flist) return;
 
-	file_util_disable_grouping_sc_list(flist);
+	flist = file_data_process_groups(flist);
 
 	if (!file_data_sc_add_ci_unspecified_list(flist, dest_path))
 		{
--- a/src/view_file_icon.c	Mon Jun 01 16:37:30 2009 +0000
+++ b/src/view_file_icon.c	Tue Jun 02 22:33:53 2009 +0000
@@ -170,7 +170,8 @@
 		return vf_selection_get_list(vf);
 		}
 
-	return g_list_append(NULL, file_data_ref(VFICON(vf)->click_id->fd));
+	
+	return g_list_prepend(filelist_copy(VFICON(vf)->click_id->fd->sidecar_files), file_data_ref(VFICON(vf)->click_id->fd));
 }
 
 void vficon_pop_menu_view_cb(GtkWidget *widget, gpointer data)
@@ -907,7 +908,7 @@
 GList *vficon_selection_get_list(ViewFile *vf)
 {
 	GList *list = NULL;
-	GList *work;
+	GList *work, *work2;
 
 	work = VFICON(vf)->selection;
 	while (work)
@@ -917,6 +918,14 @@
 		g_assert(fd->magick == 0x12345678);
 
 		list = g_list_prepend(list, file_data_ref(fd));
+		
+		work2 = fd->sidecar_files;
+		while (work2)
+			{
+			fd = work2->data;
+			list = g_list_prepend(list, file_data_ref(fd));
+			work2 = work2->next;
+			}
 
 		work = work->next;
 		}
--- a/src/view_file_list.c	Mon Jun 01 16:37:30 2009 +0000
+++ b/src/view_file_list.c	Tue Jun 02 22:33:53 2009 +0000
@@ -362,6 +362,7 @@
 
 GList *vflist_pop_menu_file_list(ViewFile *vf)
 {
+	GList *list;
 	if (!VFLIST(vf)->click_fd) return NULL;
 
 	if (vflist_row_is_selected(vf, VFLIST(vf)->click_fd))
@@ -369,7 +370,37 @@
 		return vf_selection_get_list(vf);
 		}
 
-	return g_list_append(NULL, file_data_ref(VFLIST(vf)->click_fd));
+	list = g_list_append(NULL, file_data_ref(VFLIST(vf)->click_fd));
+
+	if (VFLIST(vf)->click_fd->sidecar_files)
+		{
+		/* check if the row is expanded */
+		GtkTreeModel *store;
+		GtkTreeIter iter;
+		
+		store = gtk_tree_view_get_model(GTK_TREE_VIEW(vf->listview));
+		if (vflist_find_row(vf, VFLIST(vf)->click_fd, &iter) >= 0)
+			{
+			GtkTreePath *tpath;
+
+			tpath = gtk_tree_model_get_path(store, &iter);
+			if (!gtk_tree_view_row_expanded(GTK_TREE_VIEW(vf->listview), tpath))
+				{
+				/* unexpanded - add whole group */
+				GList *work = VFLIST(vf)->click_fd->sidecar_files;
+				while (work)
+					{
+					FileData *sfd = work->data;
+					list = g_list_prepend(list, file_data_ref(sfd));
+					work = work->next;
+					}
+				}
+			gtk_tree_path_free(tpath);
+			}
+		list = g_list_reverse(list);
+		}
+
+	return list;
 }
 
 void vflist_pop_menu_view_cb(GtkWidget *widget, gpointer data)
@@ -1307,6 +1338,18 @@
 		gtk_tree_model_get(store, &iter, FILE_COLUMN_POINTER, &fd, -1);
 
 		list = g_list_prepend(list, file_data_ref(fd));
+		
+		if (!fd->parent && !gtk_tree_view_row_expanded(GTK_TREE_VIEW(vf->listview), tpath))
+			{
+			/* unexpanded - add whole group */
+			GList *work2 = fd->sidecar_files;
+			while (work2)
+				{
+				FileData *sfd = work2->data;
+				list = g_list_prepend(list, file_data_ref(sfd));
+				work2 = work2->next;
+				}
+			}
 
 		work = work->next;
 		}