From 88a374a4325bc23af17556150ba773baea2d92c9 Mon Sep 17 00:00:00 2001 From: Slava Zanko Date: Tue, 23 Feb 2010 11:43:47 +0200 Subject: [PATCH] Added ability to show progressbars (when copy files) from right to left. For activate this, need to add into ini-file: [Layout] progressbar_always_left2right=0 Signed-off-by: Slava Zanko --- src/filegui.c | 9 +++++++++ src/widget.c | 18 ++++++++++++++---- src/widget.h | 1 + 3 files changed, 24 insertions(+), 4 deletions(-) diff --git a/src/filegui.c b/src/filegui.c index 271c5f92b..aeddaaec6 100644 --- a/src/filegui.c +++ b/src/filegui.c @@ -79,6 +79,7 @@ #include "lib/global.h" #include "lib/tty/key.h" /* tty_get_event */ +#include "lib/mcconfig.h" #include "lib/search.h" #include "lib/vfs/mc-vfs/vfs.h" #include "lib/strescape.h" @@ -332,6 +333,14 @@ file_op_context_create_ui_without_init (FileOpContext *ctx, gboolean with_eta, g label_new (3, FCOPY_GAUGE_X, sixty)); add_widget (ui->op_dlg, ui->file_label[0] = label_new (3, FCOPY_LABEL_X, fifteen)); + + if ( + ! mc_config_get_bool (mc_main_config,"Layout", "progressbar_always_left2right", TRUE) && + right_panel == current_panel + ) { + ui->progress_gauge[0]->from_left_to_right = FALSE; + ui->progress_gauge[1]->from_left_to_right = FALSE; + } } void diff --git a/src/widget.c b/src/widget.c index 679792e0b..4df7a5a66 100644 --- a/src/widget.c +++ b/src/widget.c @@ -885,10 +885,19 @@ gauge_callback (Widget *w, widget_msg_t msg, int parm) percentage = (200 * done / total + 1) / 2; columns = (2 * (gauge_len - 7) * done / total + 1) / 2; tty_print_char ('['); - tty_setcolor (GAUGE_COLOR); - tty_printf ("%*s", (int) columns, ""); - tty_setcolor (DLG_NORMALC (h)); - tty_printf ("%*s] %3d%%", (int)(gauge_len - 7 - columns), "", (int) percentage); + if (g->from_left_to_right) { + tty_setcolor (GAUGE_COLOR); + tty_printf ("%*s", (int) columns, ""); + tty_setcolor (DLG_NORMALC (h)); + tty_printf ("%*s] %3d%%", (int)(gauge_len - 7 - columns), "", (int) percentage); + } else { + tty_setcolor (DLG_NORMALC (h)); + tty_printf ("%*s", gauge_len - columns - 7, ""); + tty_setcolor (GAUGE_COLOR); + tty_printf ("%*s", columns, ""); + tty_setcolor (DLG_NORMALC (h)); + tty_printf ("] %3d%%", 100 * columns / (gauge_len - 7), percentage); + } } return MSG_HANDLED; } @@ -929,6 +938,7 @@ gauge_new (int y, int x, int shown, int max, int current) max = 1; /* I do not like division by zero :) */ g->max = max; g->current = current; + g->from_left_to_right = TRUE; widget_want_cursor (g->widget, 0); return g; } diff --git a/src/widget.h b/src/widget.h index 28691892f..00c9269b8 100644 --- a/src/widget.h +++ b/src/widget.h @@ -89,6 +89,7 @@ typedef struct WGauge { int shown; int max; int current; + gboolean from_left_to_right; } WGauge; GList *history_get (const char *input_name); -- 2.11.4.GIT