changeset 1618:552648eff4f2

do not block the files sent to external editors like gimp
author nadvornik
date Sun, 31 May 2009 11:08:00 +0000
parents d4d12f872398
children d35a0836c6b5
files src/editors.c src/editors.h src/utilops.c
diffstat 3 files changed, 31 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/editors.c	Sat May 30 20:18:22 2009 +0000
+++ b/src/editors.c	Sun May 31 11:08:00 2009 +0000
@@ -1282,6 +1282,23 @@
 	return !!(editor->flags & EDITOR_NO_PARAM);
 }
 
+gboolean editor_blocks_file(const gchar *key)
+{
+	EditorDescription *editor;
+	if (!key) return FALSE;
+	
+	editor = g_hash_table_lookup(editors, key);
+	if (!editor) return FALSE;
+
+	/* Decide if the image file should be blocked during editor execution
+	   Editors like gimp can be used long time after the original file was
+	   saved, for editing unrelated files.
+	   %f vs. %F seems to be a good heuristic to detect this kind of editors.
+	*/
+	   
+	return !(editor->flags & EDITOR_SINGLE_COMMAND);
+}
+
 const gchar *editor_get_error_str(EditorFlags flags)
 {
 	if (flags & EDITOR_ERROR_EMPTY) return _("Editor template is empty.");
--- a/src/editors.h	Sat May 30 20:18:22 2009 +0000
+++ b/src/editors.h	Sun May 31 11:08:00 2009 +0000
@@ -112,6 +112,8 @@
 const gchar *editor_get_name(const gchar *key);
 
 gboolean is_valid_editor_command(const gchar *key);
+gboolean editor_blocks_file(const gchar *key);
+
 EditorFlags editor_command_parse(const EditorDescription *editor, GList *list, gchar **output);
 
 #endif
--- a/src/utilops.c	Sat May 30 20:18:22 2009 +0000
+++ b/src/utilops.c	Sun May 31 11:08:00 2009 +0000
@@ -845,7 +845,18 @@
 			}
 		else
 			{
-			flags = start_editor_from_filelist_full(ud->external_command, ud->flist, file_util_perform_ci_cb, ud);
+			if (editor_blocks_file(ud->external_command))
+				{
+				DEBUG_1("Starting %s and waiting for results", ud->external_command);
+				flags = start_editor_from_filelist_full(ud->external_command, ud->flist, file_util_perform_ci_cb, ud);
+				}
+			else
+				{
+				/* start the editor without callback and finish the operation internally */
+				DEBUG_1("Starting %s and finishing the operation", ud->external_command);
+				flags = start_editor_from_filelist(ud->external_command, ud->flist);
+				file_util_perform_ci_internal(ud);
+				}
 			}
 
 		if (flags)