changeset 772:f53c2bb5b1b1

replaced vflist_maint functions by vflist_refresh - it allows to follow changes made by external editors more precisely
author nadvornik
date Sat, 31 May 2008 19:44:41 +0000
parents 24726eddb252
children 4acde7a0bb01
files src/typedefs.h src/view_file_list.c
diffstat 2 files changed, 63 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/typedefs.h	Fri May 30 21:41:46 2008 +0000
+++ b/src/typedefs.h	Sat May 31 19:44:41 2008 +0000
@@ -633,6 +633,9 @@
 	gint marks_enabled;
 	gint active_mark;
 	gint clicked_mark;
+	
+	/* refresh */
+	gint refresh_idle_id; /* used only in vflist for now */
 };
 
 struct _ViewFileInfoList
--- a/src/view_file_list.c	Fri May 30 21:41:46 2008 +0000
+++ b/src/view_file_list.c	Sat May 31 19:44:41 2008 +0000
@@ -1579,6 +1579,22 @@
 	return ret;
 }
 
+static gint vflist_refresh_idle_cb(gpointer data)
+{
+	ViewFile *vf = data;
+
+	vflist_refresh(vf);
+	vf->refresh_idle_id = -1;
+	return FALSE;
+}
+
+static void vflist_refresh_idle_cancel(ViewFile *vf)
+{
+	if (vf->refresh_idle_id != -1) g_source_remove(vf->refresh_idle_id);
+	vf->refresh_idle_id = -1;
+}
+
+
 /* this overrides the low default of a GtkCellRenderer from 100 to CELL_HEIGHT_OVERRIDE, something sane for our purposes */
 
 #define CELL_HEIGHT_OVERRIDE 512
@@ -1744,6 +1760,7 @@
 	ViewFile *vf = data;
 
 	vflist_select_idle_cancel(vf);
+	vflist_refresh_idle_cancel(vf);
 	vflist_thumb_stop(vf);
 
 	filelist_free(vf->list);
@@ -1764,6 +1781,8 @@
 	VFLIST_INFO(vf, thumbs_enabled) = FALSE;
 
 	VFLIST_INFO(vf, select_idle_id) = -1;
+	vf->refresh_idle_id = -1;
+
 
 	flist_types[FILE_COLUMN_POINTER] = G_TYPE_POINTER;
 	flist_types[FILE_COLUMN_VERSION] = G_TYPE_INT;
@@ -1841,6 +1860,46 @@
  *-----------------------------------------------------------------------------
  */
 
+void vflist_maint(ViewFile *vf, FileData *fd)
+{
+	gchar *source_base;
+	gchar *dest_base;
+	
+	if (vf->refresh_idle_id != -1) return;
+	
+	source_base = remove_level_from_path(fd->change->source);
+	dest_base = remove_level_from_path(fd->change->dest);
+
+	if (strcmp(source_base, vf->path) == 0 ||
+	    strcmp(dest_base, vf->path) == 0 ||
+	    strcmp(fd->path, vf->path) == 0)
+		{
+		vf->refresh_idle_id = g_idle_add(vflist_refresh_idle_cb, vf);
+		}
+	g_free(source_base);
+	g_free(dest_base);
+}
+
+/* the plan is to drop these functions and use vflist_maint directly */
+
+gint vflist_maint_renamed(ViewFile *vf, FileData *fd)
+{
+	vflist_maint(vf, fd);
+	return TRUE;
+}
+gint vflist_maint_removed(ViewFile *vf, FileData *fd, GList *ignore_list)
+{
+	vflist_maint(vf, fd);
+	return TRUE;
+}
+gint vflist_maint_moved(ViewFile *vf, FileData *fd, GList *ignore_list)
+{
+	vflist_maint(vf, fd);
+	return TRUE;
+}
+
+
+#if 0
 static gint vflist_maint_find_closest(ViewFile *vf, gint row, gint count, GList *ignore_list)
 {
 	GList *list = NULL;
@@ -2045,3 +2104,4 @@
 
 	return ret;
 }
+#endif