changeset 1221:584eae03d747

perform internal commands in idle call
author nadvornik
date Thu, 25 Dec 2008 12:19:37 +0000
parents a0c249bcc4ff
children 31dc2f240afb
files src/utilops.c
diffstat 1 files changed, 17 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/src/utilops.c	Tue Dec 23 22:42:57 2008 +0000
+++ b/src/utilops.c	Thu Dec 25 12:19:37 2008 +0000
@@ -285,6 +285,8 @@
 	
 	gint update_idle_id;
 
+	gint perform_idle_id;
+
 	gboolean with_sidecars; /* operate on grouped or single files; TRUE = use file_data_sc_, FALSE = use file_data_ functions */
 	
 	/* alternative dialog parts */
@@ -339,6 +341,7 @@
 	ud->type = type;
 	ud->phase = UTILITY_PHASE_START;
 	ud->update_idle_id = -1;
+	ud->perform_idle_id = -1;
 	ud->external_command = -1;
 	return ud;
 }
@@ -348,6 +351,7 @@
 	if (!ud) return;
 
 	if (ud->update_idle_id != -1) g_source_remove(ud->update_idle_id);
+	if (ud->perform_idle_id != -1) g_source_remove(ud->perform_idle_id);
 
 	file_data_unref(ud->dir_fd);
 	filelist_free(ud->content_list);
@@ -464,7 +468,7 @@
 }
 
 
-static void file_util_perform_ci_internal(UtilityData *ud);
+static gboolean file_util_perform_ci_internal(gpointer data);
 void file_util_dialog_run(UtilityData *ud);
 static gint file_util_perform_ci_cb(gpointer resume_data, gint flags, GList *list, gpointer data);
 
@@ -578,10 +582,16 @@
  */
 
 
-static void file_util_perform_ci_internal(UtilityData *ud)
+static gboolean file_util_perform_ci_internal(gpointer data)
 {
+	UtilityData *ud = data;
+
+	/* this is removed when ud is destroyed */
+	if (ud->perform_idle_id == -1) ud->perform_idle_id = g_idle_add(file_util_perform_ci_internal, ud);
+
+	g_assert(ud->flist);
 	
-	while (ud->flist)
+	if (ud->flist)
 		{
 		gint ret;
 		
@@ -597,16 +607,16 @@
 		ret = file_util_perform_ci_cb(GINT_TO_POINTER(!last), status, single_entry, ud);
 		g_list_free(single_entry);
 		
-		if (ret == EDITOR_CB_SUSPEND || last) return;
+		if (ret == EDITOR_CB_SUSPEND || last) return FALSE;
 		
 		if (ret == EDITOR_CB_SKIP)
 			{
 			file_util_perform_ci_cb(NULL, EDITOR_ERROR_SKIPPED, ud->flist, ud);
+			return FALSE;
 			}
-		
-		/* FIXME: convert the loop to idle call */
-		
 		}
+	
+	return TRUE;
 }
 
 static void file_util_perform_ci_dir(UtilityData *ud, gboolean internal, gboolean ext_result)