changeset 165:d7067ec71042

basic support for marks in view_file_icon.c
author nadvornik
date Sat, 22 Dec 2007 09:51:12 +0000
parents f8bd5d49eed8
children 4d14387b7bb7
files src/layout.c src/view_file_icon.c src/view_file_icon.h
diffstat 3 files changed, 65 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/layout.c	Thu Dec 20 22:43:52 2007 +0000
+++ b/src/layout.c	Sat Dec 22 09:51:12 2007 +0000
@@ -906,7 +906,7 @@
 	if (!layout_valid(&lw)) return;
 
 	if (lw->vfl) vflist_mark_to_selection(lw->vfl, mark, mode);
-	// FIXME vficon
+	if (lw->vfi) vficon_mark_to_selection(lw->vfi, mark, mode);
 }
 
 void layout_selection_to_mark(LayoutWindow *lw, gint mark, SelectionToMarkMode mode)
@@ -914,7 +914,7 @@
 	if (!layout_valid(&lw)) return;
 
 	if (lw->vfl) vflist_selection_to_mark(lw->vfl, mark, mode);
-	// FIXME vficon
+	if (lw->vfi) vficon_selection_to_mark(lw->vfi, mark, mode);
 	
 	layout_status_update_info(lw, NULL); /* osd in fullscreen mode */
 }
--- a/src/view_file_icon.c	Thu Dec 20 22:43:52 2007 +0000
+++ b/src/view_file_icon.c	Sat Dec 22 09:51:12 2007 +0000
@@ -1028,6 +1028,67 @@
 	vficon_select_by_id(vfi, id);
 }
 
+void vficon_mark_to_selection(ViewFileIcon *vfi, gint mark, MarkToSelectionMode mode)
+{
+	GList *work;
+
+	work = vfi->list;
+	while (work)
+		{
+		IconData *id = work->data;
+		FileData *fd = id->fd;
+		gboolean mark_val, selected;
+
+		g_assert(fd->magick == 0x12345678); 
+
+		mark_val = fd->marks[mark];
+		selected = (id->selected & SELECTION_SELECTED);
+		
+		switch (mode) 
+			{
+			case MTS_MODE_SET: selected = mark_val;
+				break;
+			case MTS_MODE_OR: selected = mark_val | selected;
+				break;
+			case MTS_MODE_AND: selected = mark_val & selected;
+				break;
+			case MTS_MODE_MINUS: selected = !mark_val & selected;
+				break;
+			}
+		
+		vficon_select_util(vfi, id, selected);
+
+		work = work->next;
+		}
+}
+
+void vficon_selection_to_mark(ViewFileIcon *vfi, gint mark, SelectionToMarkMode mode)
+{
+	GList *slist;
+	GList *work;
+
+	g_assert(mark >= 0 && mark < FILEDATA_MARKS_SIZE);
+
+	slist = vficon_selection_get_list(vfi);
+	work = slist;
+	while (work)
+		{
+		FileData *fd = work->data;
+		
+		switch (mode)
+			{
+			case STM_MODE_SET: fd->marks[mark] = 1;
+				break;
+			case STM_MODE_RESET: fd->marks[mark] = 0;
+				break;
+			case STM_MODE_TOGGLE: fd->marks[mark] = !fd->marks[mark];
+				break;
+			}
+			
+		work = work->next;
+		}
+	filelist_free(slist);
+}
 
 
 /*
--- a/src/view_file_icon.h	Thu Dec 20 22:43:52 2007 +0000
+++ b/src/view_file_icon.h	Sat Dec 22 09:51:12 2007 +0000
@@ -45,6 +45,8 @@
 void vficon_select_by_path(ViewFileIcon *vfi, const gchar *path);
 void vficon_select_by_fd(ViewFileIcon *vfi, FileData *fd);
 
+void vficon_mark_to_selection(ViewFileIcon *vfi, gint mark, MarkToSelectionMode mode);
+void vficon_selection_to_mark(ViewFileIcon *vfi, gint mark, SelectionToMarkMode mode);
 
 gint vficon_maint_renamed(ViewFileIcon *vfi, FileData *fd);
 gint vficon_maint_removed(ViewFileIcon *vfi, FileData *fd, GList *ignore_list);