improved file list update priority
authorVladimir Nadvornik <nadvornik@suse.cz>
Sun, 21 Jun 2009 20:14:53 +0000 (20:14 +0000)
committerVladimir Nadvornik <nadvornik@suse.cz>
Sun, 21 Jun 2009 20:14:53 +0000 (20:14 +0000)
- update list with lower priority than the priority of file operations
- make sure that it is updated at least once per 2 seconds

src/typedefs.h
src/view_file.c

index abd9224..b9a347d 100644 (file)
@@ -752,6 +752,7 @@ struct _ViewFile
        
        /* 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;
index 574e9d0..d29c846 100644 (file)
@@ -1010,7 +1010,16 @@ void vf_refresh_idle(ViewFile *vf)
 {
        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);
                }
 }