improved external delete command
authorVladimir Nadvornik <nadvornik@suse.cz>
Thu, 16 Aug 2007 20:57:09 +0000 (20:57 +0000)
committerVladimir Nadvornik <nadvornik@suse.cz>
Thu, 16 Aug 2007 20:57:09 +0000 (20:57 +0000)
src/editors.c
src/editors.h
src/utilops.c

index 6170591..4213893 100644 (file)
@@ -396,7 +396,7 @@ static gint editor_command_one(const gchar *template, const gchar *path, EditorV
                }
        else
                {
-               ret = system(result->str);
+               ret = !system(result->str);
                }
 
        if (path_change) chdir(current_path);
@@ -450,7 +450,7 @@ static gint editor_command_next(EditorVerboseData *vd)
        return FALSE;
 }
 
-static void editor_command_start(const gchar *template, const gchar *text, GList *list)
+static gint editor_command_start(const gchar *template, const gchar *text, GList *list)
 {
        EditorVerboseData *vd;
 
@@ -458,7 +458,7 @@ static void editor_command_start(const gchar *template, const gchar *text, GList
        vd->list = path_list_copy(list);
        vd->total = g_list_length(list);
 
-       editor_command_next(vd);
+       return editor_command_next(vd);
 }
 
 static gint editor_line_break(const gchar *template, gchar **front, const gchar **end)
@@ -544,7 +544,7 @@ static gint editor_command_run(const gchar *template, const gchar *text, GList *
                        while (work)
                                {
                                gchar *path = work->data;
-                               editor_command_one(template, path, NULL);
+                               ret = editor_command_one(template, path, NULL);
                                work = work->next;
                                }
                        }
@@ -588,14 +588,11 @@ static gint editor_command_run(const gchar *template, const gchar *text, GList *
 
                        vd = editor_verbose_window(template, text);
                        editor_verbose_window_progress(vd, _("running..."));
-                       editor_verbose_start(vd, result->str);
+                       ret = editor_verbose_start(vd, result->str);
                        }
                else
                        {
-                       int status = system(result->str);
-                       /* FIXME: consistent return values */
-                       if (!WIFEXITED(status) || WEXITSTATUS(status))
-                               ret = FALSE;
+                       ret = !system(result->str);
                        }
 
                g_free(front);
index ea2e7b3..5701791 100644 (file)
@@ -17,7 +17,6 @@
 void editor_reset_defaults(void);
 gint start_editor_from_file(gint n, const gchar *path);
 gint start_editor_from_path_list(gint n, GList *list);
-
 gint editor_window_flag_set(gint n);
 
 
index 6051d0e..53a9a16 100644 (file)
@@ -1233,10 +1233,6 @@ static gint file_util_unlink(const gchar *path)
 
        if (!isfile(path)) return FALSE;
 
-       if (editor_command[CMD_DELETE])
-               {
-               return start_editor_from_file(CMD_DELETE, path);
-               }
 
        if (!safe_delete_enable)
                {
@@ -1327,6 +1323,26 @@ static void file_util_delete_multiple_ok_cb(GenericDialog *gd, gpointer data)
 {
        GList *source_list = data;
 
+       if (editor_command[CMD_DELETE])
+               {
+               if (!start_editor_from_path_list(CMD_DELETE, source_list))
+                       {
+                       file_util_warning_dialog(_("File deletion failed"), _("Unable to delete files by external command\n"), GTK_STOCK_DIALOG_ERROR, NULL);
+                       }
+               else
+                       {
+                       while (source_list)
+                               {
+                               gchar *path = source_list->data;
+                               source_list = g_list_remove(source_list, path);
+                               file_maint_removed(path, source_list);
+                               g_free(path);
+                               }
+                       }
+               return;
+               }
+
+
        while (source_list)
                {
                gchar *path = source_list->data;
@@ -1527,7 +1543,20 @@ static void file_util_delete_ok_cb(GenericDialog *gd, gpointer data)
 {
        gchar *path = data;
 
-       if (!file_util_unlink(path))
+       if (editor_command[CMD_DELETE])
+               {
+               if (!start_editor_from_file(CMD_DELETE, path))
+                       {
+                       gchar *text = g_strdup_printf(_("Unable to delete file by external command:\n%s"), path);
+                       file_util_warning_dialog(_("File deletion failed"), text, GTK_STOCK_DIALOG_ERROR, NULL);
+                       g_free(text);
+                       }
+               else
+                       {
+                       file_maint_removed(path, NULL);
+                       }
+               }
+       else if (!file_util_unlink(path))
                {
                gchar *text = g_strdup_printf(_("Unable to delete file:\n%s"), path);
                file_util_warning_dialog(_("File deletion failed"), text, GTK_STOCK_DIALOG_ERROR, NULL);