Skip to content

Commit

Permalink
improved external delete command
Browse files Browse the repository at this point in the history
  • Loading branch information
nadvornik committed Aug 16, 2007
1 parent 19d0a14 commit a4e6574
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 15 deletions.
15 changes: 6 additions & 9 deletions src/editors.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -450,15 +450,15 @@ 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;

vd = editor_verbose_window(template, text);
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)
Expand Down Expand Up @@ -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;
}
}
Expand Down Expand Up @@ -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);
Expand Down
1 change: 0 additions & 1 deletion src/editors.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);


Expand Down
39 changes: 34 additions & 5 deletions src/utilops.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit a4e6574

Please sign in to comment.