From efff2a4d4edb3f523f62705b36ab0b8d7ec3c776 Mon Sep 17 00:00:00 2001 From: Pavel Roskin Date: Fri, 23 Jan 2004 21:59:38 +0000 Subject: [PATCH] * fileopctx.h: Add "operation" filed to FileOpContext. * fileopctx.c (file_op_context_new): Add "operation" argument. * filegui.c (file_op_context_create_ui): Remove "operation" argument, it's known already. Adjust all callers. --- src/ChangeLog | 7 +++++++ src/cmd.c | 4 ++-- src/file.c | 4 ++-- src/filegui.c | 18 ++++++++---------- src/fileopctx.c | 3 ++- src/fileopctx.h | 18 ++++++++++-------- src/tree.c | 12 ++++++------ 7 files changed, 37 insertions(+), 29 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index ffba7af67..88c74ee3c 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,10 @@ +2004-01-23 Pavel Roskin + + * fileopctx.h: Add "operation" filed to FileOpContext. + * fileopctx.c (file_op_context_new): Add "operation" argument. + * filegui.c (file_op_context_create_ui): Remove "operation" + argument, it's known already. Adjust all callers. + 2004-01-23 Andrew V. Samoilov * user.c (execute_menu_command): Put /bin/sh in the beginning of diff --git a/src/cmd.c b/src/cmd.c index e327e4932..59de42b17 100644 --- a/src/cmd.c +++ b/src/cmd.c @@ -577,8 +577,8 @@ check_for_default(char *default_file, char *file) if (mc_stat (default_file, &s)){ return -1; } - ctx = file_op_context_new (); - file_op_context_create_ui (ctx, OP_COPY, 0); + ctx = file_op_context_new (OP_COPY); + file_op_context_create_ui (ctx, 0); copy_file_file (ctx, default_file, file, 1, &count, &bytes, 1); file_op_context_destroy (ctx); } diff --git a/src/file.c b/src/file.c index 80bac10d2..a3f77f7b5 100644 --- a/src/file.c +++ b/src/file.c @@ -1826,7 +1826,7 @@ panel_operate (void *source_panel, FileOperation operation, /* Generate confirmation prompt */ panel_operate_generate_prompt (panel, operation, source, &src_stat); - ctx = file_op_context_new (); + ctx = file_op_context_new (operation); /* Show confirmation dialog */ if (operation == OP_DELETE && confirm_delete) { @@ -1905,7 +1905,7 @@ panel_operate (void *source_panel, FileOperation operation, if (do_bg) ctx->ui = NULL; else - file_op_context_create_ui (ctx, operation, 1); + file_op_context_create_ui (ctx, 1); /* This code is only called by the tree and panel code */ if (single_entry) { diff --git a/src/filegui.c b/src/filegui.c index 5904a1836..6fcb9057f 100644 --- a/src/filegui.c +++ b/src/filegui.c @@ -165,8 +165,7 @@ check_progress_buttons (FileOpContext *ctx) /* {{{ File progress display routines */ void -file_op_context_create_ui (FileOpContext *ctx, FileOperation op, - int with_eta) +file_op_context_create_ui (FileOpContext *ctx, int with_eta) { FileOpContextUI *ui; int x_size; @@ -195,8 +194,10 @@ file_op_context_create_ui (FileOpContext *ctx, FileOperation op, ui->eta_extra = with_eta ? WX_ETA_EXTRA : 0; x_size = (WX + 4) + ui->eta_extra; - ui->op_dlg = create_dlg (0, 0, WY - minus + 4, x_size, dialog_colors, - NULL, NULL, op_names[op], DLG_CENTER | DLG_REVERSE); + ui->op_dlg = + create_dlg (0, 0, WY - minus + 4, x_size, dialog_colors, NULL, + NULL, op_names[ctx->operation], + DLG_CENTER | DLG_REVERSE); last_hint_line = the_hint->widget.y; if ((ui->op_dlg->y + ui->op_dlg->lines) > last_hint_line) @@ -213,22 +214,19 @@ file_op_context_create_ui (FileOpContext *ctx, FileOperation op, gauge_new (7, FCOPY_GAUGE_X, 0, 100, 0)); add_widget (ui->op_dlg, ui->progress_label[2] = label_new (7, FCOPY_LABEL_X, fifteen)); - add_widget (ui->op_dlg, ui->bps_label = - label_new (7, WX, "")); + add_widget (ui->op_dlg, ui->bps_label = label_new (7, WX, "")); add_widget (ui->op_dlg, ui->progress_gauge[1] = gauge_new (8, FCOPY_GAUGE_X, 0, 100, 0)); add_widget (ui->op_dlg, ui->progress_label[1] = label_new (8, FCOPY_LABEL_X, fifteen)); - add_widget (ui->op_dlg, ui->stalled_label = - label_new (8, WX, "")); + add_widget (ui->op_dlg, ui->stalled_label = label_new (8, WX, "")); add_widget (ui->op_dlg, ui->progress_gauge[0] = gauge_new (6, FCOPY_GAUGE_X, 0, 100, 0)); add_widget (ui->op_dlg, ui->progress_label[0] = label_new (6, FCOPY_LABEL_X, fifteen)); - add_widget (ui->op_dlg, ui->eta_label = - label_new (6, WX, "")); + add_widget (ui->op_dlg, ui->eta_label = label_new (6, WX, "")); add_widget (ui->op_dlg, ui->file_string[1] = label_new (4, FCOPY_GAUGE_X, sixty)); diff --git a/src/fileopctx.c b/src/fileopctx.c index 4c36225e1..02af52595 100644 --- a/src/fileopctx.c +++ b/src/fileopctx.c @@ -36,11 +36,12 @@ * Return value: The newly-created context, filled with the default file mask values. **/ FileOpContext * -file_op_context_new (void) +file_op_context_new (FileOperation op) { FileOpContext *ctx; ctx = g_new0 (FileOpContext, 1); + ctx->operation = op; ctx->eta_secs = 0.0; ctx->progress_bytes = 0.0; ctx->op_preserve = TRUE; diff --git a/src/fileopctx.h b/src/fileopctx.h index cb092639d..0006155d3 100644 --- a/src/fileopctx.h +++ b/src/fileopctx.h @@ -13,6 +13,11 @@ #include #include "eregex.h" +typedef enum { + OP_COPY, + OP_MOVE, + OP_DELETE +} FileOperation; typedef int (*mc_stat_fn) (char *filename, struct stat *buf); @@ -20,6 +25,9 @@ typedef int (*mc_stat_fn) (char *filename, struct stat *buf); * the progress windows and pass around options. */ typedef struct FileOpContext { + /* Operation type (copy, move, delete) */ + FileOperation operation; + /* The estimated time of arrival in seconds */ double eta_secs; @@ -103,16 +111,10 @@ typedef struct FileOpContext { } FileOpContext; -FileOpContext *file_op_context_new (void); +FileOpContext *file_op_context_new (FileOperation op); void file_op_context_destroy (FileOpContext *ctx); -typedef enum { - OP_COPY, - OP_MOVE, - OP_DELETE -} FileOperation; - extern char *op_names [3]; typedef enum { @@ -138,7 +140,7 @@ enum OperationMode { /* The following functions are implemented separately by each port */ -void file_op_context_create_ui (FileOpContext *ctx, FileOperation op, int with_eta); +void file_op_context_create_ui (FileOpContext *ctx, int with_eta); void file_op_context_destroy_ui (FileOpContext *ctx); FileProgressStatus file_progress_show (FileOpContext *ctx, off_t done, off_t total); diff --git a/src/tree.c b/src/tree.c index 3fc1385d0..aa2321459 100644 --- a/src/tree.c +++ b/src/tree.c @@ -600,8 +600,8 @@ static void tree_copy (WTree *tree, char *default_dest) return; } - ctx = file_op_context_new (); - file_op_context_create_ui (ctx, OP_COPY, FALSE); + ctx = file_op_context_new (OP_COPY); + file_op_context_create_ui (ctx, FALSE); copy_dir_dir (ctx, tree->selected_ptr->name, dest, 1, 0, 0, 0, &count, &bytes); file_op_context_destroy (ctx); @@ -651,8 +651,8 @@ static void tree_move (WTree *tree, char *default_dest) return; } - ctx = file_op_context_new (); - file_op_context_create_ui (ctx, OP_MOVE, FALSE); + ctx = file_op_context_new (OP_MOVE); + file_op_context_create_ui (ctx, FALSE); move_dir_dir (ctx, tree->selected_ptr->name, dest, &count, &bytes); file_op_context_destroy (ctx); @@ -711,8 +711,8 @@ tree_rmdir_cmd (WTree *tree) return; } - ctx = file_op_context_new (); - file_op_context_create_ui (ctx, OP_DELETE, FALSE); + ctx = file_op_context_new (OP_DELETE); + file_op_context_create_ui (ctx, FALSE); if (erase_dir (ctx, tree->selected_ptr->name, &count, &bytes) == FILE_CONT) tree_forget_cmd (tree);