Simplify constructing of file operation progress dialog.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
This commit is contained in:
Andrew Borodin 2011-11-15 11:56:01 +03:00
parent efb0197656
commit dad538e7dc

View File

@ -110,11 +110,6 @@ int classic_progressbar = 1;
/* Hack: the vfs code should not rely on this */
#define WITH_FULL_PATHS 1
/* File operate window sizes */
#define WX 58
#define WY 11
#define FCOPY_LABEL_X 3
#define truncFileString(ui, s) str_trunc (s, 52)
#define truncFileStringSecure(ui, s) path_trunc (s, 52)
@ -526,11 +521,10 @@ file_op_context_create_ui_without_init (FileOpContext * ctx, gboolean with_eta,
filegui_dialog_type_t dialog_type)
{
FileOpContextUI *ui;
int minus = 0, total_reserve = 0;
const char *abort_button_label = N_("&Abort");
const char *skip_button_label = N_("&Skip");
int abort_button_width, skip_button_width, buttons_width;
int dlg_width;
int dlg_width, dlg_height;
g_return_if_fail (ctx != NULL);
g_return_if_fail (ctx->ui == NULL);
@ -544,7 +538,8 @@ file_op_context_create_ui_without_init (FileOpContext * ctx, gboolean with_eta,
skip_button_width = str_term_width1 (skip_button_label) + 3;
buttons_width = abort_button_width + skip_button_width + 2;
dlg_width = max (WX, buttons_width + 6);
dlg_width = max (58, buttons_width + 6);
dlg_height = 17; /* to make compiler happy :) */
ui = g_new0 (FileOpContextUI, 1);
ctx->ui = ui;
@ -554,16 +549,13 @@ file_op_context_create_ui_without_init (FileOpContext * ctx, gboolean with_eta,
switch (dialog_type)
{
case FILEGUI_DIALOG_ONE_ITEM:
total_reserve = 0;
minus = verbose ? 0 : 2;
dlg_height = verbose ? 12 : 10;
break;
case FILEGUI_DIALOG_MULTI_ITEM:
total_reserve = 5;
minus = verbose ? (file_op_compute_totals ? 0 : 2) : 7;
dlg_height = !verbose ? 10 : file_op_compute_totals ? 17 : 15;
break;
case FILEGUI_DIALOG_DELETE_ITEM:
total_reserve = -5;
minus = 0;
dlg_height = 7;
break;
}
@ -574,45 +566,42 @@ file_op_context_create_ui_without_init (FileOpContext * ctx, gboolean with_eta,
ui->showing_bps = with_eta;
ui->op_dlg =
create_dlg (TRUE, 0, 0, WY - minus + 1 + total_reserve, dlg_width,
create_dlg (TRUE, 0, 0, dlg_height, dlg_width,
dialog_colors, NULL, NULL, op_names[ctx->operation], DLG_CENTER | DLG_REVERSE);
add_widget (ui->op_dlg,
button_new (WY - minus - 2 + total_reserve,
dlg_width / 2 + 1, FILE_ABORT,
button_new (dlg_height - 3, dlg_width / 2 + 1, FILE_ABORT,
NORMAL_BUTTON, abort_button_label, NULL));
add_widget (ui->op_dlg,
button_new (WY - minus - 2 + total_reserve,
dlg_width / 2 - 1 - skip_button_width, FILE_SKIP,
button_new (dlg_height - 3, dlg_width / 2 - 1 - skip_button_width, FILE_SKIP,
NORMAL_BUTTON, skip_button_label, NULL));
if (verbose && dialog_type == FILEGUI_DIALOG_MULTI_ITEM)
{
int dy = file_op_compute_totals ? 0 : 2;
add_widget (ui->op_dlg, hline_new (8, 1, dlg_width - 2));
add_widget (ui->op_dlg, ui->total_bytes_label = label_new (8, FCOPY_LABEL_X + 15, ""));
int dy = file_op_compute_totals ? 2 : 0;
if (file_op_compute_totals)
add_widget (ui->op_dlg, ui->progress_total_gauge =
gauge_new (9 - dy, FCOPY_LABEL_X + 3, 0, 100, 0));
gauge_new (7 + dy, 3 + 3, 0, 100, 0));
add_widget (ui->op_dlg, ui->total_files_processed_label =
label_new (11 - dy, FCOPY_LABEL_X, ""));
label_new (9 + dy, 3, ""));
add_widget (ui->op_dlg, ui->time_label = label_new (12 - dy, FCOPY_LABEL_X, ""));
add_widget (ui->op_dlg, ui->time_label = label_new (10 + dy, 3, ""));
add_widget (ui->op_dlg, ui->total_bytes_label = label_new (8, 3 + 15, ""));
add_widget (ui->op_dlg, hline_new (8, 1, dlg_width - 2));
}
add_widget (ui->op_dlg, ui->progress_file_label = label_new (7, FCOPY_LABEL_X, ""));
add_widget (ui->op_dlg, ui->progress_file_label = label_new (7, 3, ""));
add_widget (ui->op_dlg, ui->progress_file_gauge = gauge_new (6, FCOPY_LABEL_X + 3, 0, 100, 0));
add_widget (ui->op_dlg, ui->progress_file_gauge = gauge_new (6, 3 + 3, 0, 100, 0));
add_widget (ui->op_dlg, ui->file_string[1] = label_new (5, FCOPY_LABEL_X, ""));
add_widget (ui->op_dlg, ui->file_string[1] = label_new (5, 3, ""));
add_widget (ui->op_dlg, ui->file_label[1] = label_new (4, FCOPY_LABEL_X, ""));
add_widget (ui->op_dlg, ui->file_string[0] = label_new (3, FCOPY_LABEL_X, ""));
add_widget (ui->op_dlg, ui->file_label[0] = label_new (2, FCOPY_LABEL_X, ""));
add_widget (ui->op_dlg, ui->file_label[1] = label_new (4, 3, ""));
add_widget (ui->op_dlg, ui->file_string[0] = label_new (3, 3, ""));
add_widget (ui->op_dlg, ui->file_label[0] = label_new (2, 3, ""));
if ((right_panel == current_panel) && !classic_progressbar)
{