Improve editor commands error display:
authorLaurent Monin <geeqie@norz.org>
Fri, 16 May 2008 09:10:56 +0000 (09:10 +0000)
committerLaurent Monin <geeqie@norz.org>
Fri, 16 May 2008 09:10:56 +0000 (09:10 +0000)
- display all errors (not only syntax errors)
- display errors from Preferences (checks are made on Apply or OK)

src/editors.c
src/preferences.c

index d71f177..c602535 100644 (file)
@@ -814,9 +814,9 @@ gint start_editor_from_filelist_full(gint n, GList *list, EditorCallback cb, gpo
        error = editor_command_start(command, options->editor_name[n], list, cb, data);
        g_free(command);
 
-       if (n < GQ_EDITOR_GENERIC_SLOTS && (error & EDITOR_ERROR_SYNTAX))
+       if (n < GQ_EDITOR_GENERIC_SLOTS && (error & EDITOR_ERROR_MASK))
                {
-               gchar *text = g_strdup_printf(_("Syntax error in the editor template \"%s\":\n%s"),
+               gchar *text = g_strdup_printf(_("%s\n#%d \"%s\":\n%s"), editor_get_error_str(error), n+1,
                                              options->editor_name[n], options->editor_command[n]);
                
                file_util_warning_dialog(_("Invalid editor command"), text, GTK_STOCK_DIALOG_ERROR, NULL);
index f39033b..418ca66 100644 (file)
@@ -157,6 +157,9 @@ static void config_window_apply(void)
        gint i;
        gint refresh = FALSE;
 
+       {
+       GString *errmsg = g_string_new("");
+
        for (i = 0; i < GQ_EDITOR_SLOTS; i++)
                {
                if (i < GQ_EDITOR_GENERIC_SLOTS)
@@ -170,8 +173,28 @@ static void config_window_apply(void)
                g_free(options->editor_command[i]);
                options->editor_command[i] = NULL;
                buf = gtk_entry_get_text(GTK_ENTRY(editor_command_entry[i]));
-               if (buf && strlen(buf) > 0) options->editor_command[i] = g_strdup(buf);
+               if (buf && strlen(buf) > 0)
+                       {
+                       gint flags = editor_command_parse(buf, NULL, NULL);
+               
+                       if (flags & EDITOR_ERROR_MASK)
+                               {
+                               if (errmsg->str[0]) g_string_append(errmsg, "\n\n");
+                               g_string_append_printf(errmsg, _("%s\n#%d \"%s\":\n%s"), editor_get_error_str(flags),
+                                                      i+1, options->editor_name[i], buf);
+
+                               }
+                       options->editor_command[i] = g_strdup(buf);
+                       }
                }
+       
+       if (errmsg->str[0])
+               {
+               file_util_warning_dialog(_("Invalid editor command"), errmsg->str, GTK_STOCK_DIALOG_ERROR, NULL);
+               }
+
+       g_string_free(errmsg, TRUE);
+       }
        layout_edit_update_all();
 
        g_free(options->file_ops.safe_delete_path);