changeset 1654:b45f0ab6367f

improved file list update priority - update list with lower priority than the priority of file operations - make sure that it is updated at least once per 2 seconds
author nadvornik
date Sun, 21 Jun 2009 20:14:53 +0000
parents 7ed0b45c80ae
children 437c37d965ff
files src/typedefs.h src/view_file.c
diffstat 2 files changed, 11 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/typedefs.h	Sun Jun 21 13:28:02 2009 +0000
+++ b/src/typedefs.h	Sun Jun 21 20:14:53 2009 +0000
@@ -749,6 +749,7 @@
 	
 	/* refresh */
 	guint refresh_idle_id; /* event source id */
+	time_t time_refresh_set; /* time when refresh_idle_id was set */
 
 	/* file list for edit menu */
 	GList *editmenu_fd_list;
--- a/src/view_file.c	Sun Jun 21 13:28:02 2009 +0000
+++ b/src/view_file.c	Sun Jun 21 20:14:53 2009 +0000
@@ -1013,7 +1013,16 @@
 {
 	if (!vf->refresh_idle_id)
 		{
-		vf->refresh_idle_id = g_idle_add(vf_refresh_idle_cb, vf);
+		vf->time_refresh_set = time(NULL);
+		/* file operations run with G_PRIORITY_DEFAULT_IDLE */
+		vf->refresh_idle_id = g_idle_add_full(G_PRIORITY_DEFAULT_IDLE + 50, vf_refresh_idle_cb, vf, NULL);
+		}
+	else if (time(NULL) - vf->time_refresh_set > 1)
+		{
+		/* more than 1 sec since last update - increase priority */
+		vf_refresh_idle_cancel(vf);
+		vf->time_refresh_set = time(NULL);
+		vf->refresh_idle_id = g_idle_add_full(G_PRIORITY_DEFAULT_IDLE - 50, vf_refresh_idle_cb, vf, NULL);
 		}
 }