mirror of
https://github.com/MidnightCommander/mc
synced 2024-12-22 20:36:50 +03:00
Ticket #2076: make copy/move/delete progress dialog wider.
Initial step: get rid of hardcoded width of progress bar. Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
This commit is contained in:
parent
4b3d88f07c
commit
2176e5f283
@ -49,9 +49,6 @@
|
||||
|
||||
/*** file scope macro definitions ****************************************************************/
|
||||
|
||||
/* Currently width is hardcoded here for text mode */
|
||||
#define gauge_len 47
|
||||
|
||||
/*** file scope type declarations ****************************************************************/
|
||||
|
||||
/*** file scope variables ************************************************************************/
|
||||
@ -64,21 +61,25 @@ gauge_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm, void *d
|
||||
WGauge *g = GAUGE (w);
|
||||
WDialog *h = w->owner;
|
||||
|
||||
if (msg == MSG_INIT)
|
||||
switch (msg)
|
||||
{
|
||||
case MSG_INIT:
|
||||
return MSG_HANDLED;
|
||||
|
||||
/* We don't want to get the focus */
|
||||
if (msg == MSG_FOCUS)
|
||||
case MSG_FOCUS:
|
||||
return MSG_NOT_HANDLED;
|
||||
|
||||
if (msg == MSG_DRAW)
|
||||
{
|
||||
case MSG_DRAW:
|
||||
widget_move (w, 0, 0);
|
||||
tty_setcolor (h->color[DLG_COLOR_NORMAL]);
|
||||
if (!g->shown)
|
||||
tty_printf ("%*s", gauge_len, "");
|
||||
{
|
||||
tty_setcolor (h->color[DLG_COLOR_NORMAL]);
|
||||
tty_printf ("%*s", w->cols, "");
|
||||
}
|
||||
else
|
||||
{
|
||||
int gauge_len;
|
||||
int percentage, columns;
|
||||
long total = g->max;
|
||||
long done = g->current;
|
||||
@ -95,30 +96,34 @@ gauge_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm, void *d
|
||||
total /= 256;
|
||||
done /= 256;
|
||||
}
|
||||
|
||||
gauge_len = w->cols - 7; /* 7 positions for percentage */
|
||||
|
||||
percentage = (200 * done / total + 1) / 2;
|
||||
columns = (2 * (gauge_len - 7) * done / total + 1) / 2;
|
||||
columns = (2 * gauge_len * done / total + 1) / 2;
|
||||
tty_print_char ('[');
|
||||
if (g->from_left_to_right)
|
||||
{
|
||||
tty_setcolor (GAUGE_COLOR);
|
||||
tty_printf ("%*s", (int) columns, "");
|
||||
tty_setcolor (h->color[DLG_COLOR_NORMAL]);
|
||||
tty_printf ("%*s] %3d%%", (int) (gauge_len - 7 - columns), "", (int) percentage);
|
||||
tty_printf ("%*s] %3d%%", gauge_len - columns, "", percentage);
|
||||
}
|
||||
else
|
||||
{
|
||||
tty_setcolor (h->color[DLG_COLOR_NORMAL]);
|
||||
tty_printf ("%*s", gauge_len - columns - 7, "");
|
||||
tty_printf ("%*s", gauge_len - columns, "");
|
||||
tty_setcolor (GAUGE_COLOR);
|
||||
tty_printf ("%*s", columns, "");
|
||||
tty_setcolor (h->color[DLG_COLOR_NORMAL]);
|
||||
tty_printf ("] %3d%%", 100 * columns / (gauge_len - 7), percentage);
|
||||
tty_printf ("] %3d%%", 100 * columns / gauge_len, percentage);
|
||||
}
|
||||
}
|
||||
return MSG_HANDLED;
|
||||
}
|
||||
|
||||
default:
|
||||
return widget_default_callback (w, sender, msg, parm, data);
|
||||
}
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
@ -126,14 +131,16 @@ gauge_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm, void *d
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
WGauge *
|
||||
gauge_new (int y, int x, gboolean shown, int max, int current)
|
||||
gauge_new (int y, int x, int cols, gboolean shown, int max, int current)
|
||||
{
|
||||
WGauge *g;
|
||||
Widget *w;
|
||||
|
||||
g = g_new (WGauge, 1);
|
||||
w = WIDGET (g);
|
||||
init_widget (w, y, x, 1, gauge_len, gauge_callback, NULL);
|
||||
init_widget (w, y, x, 1, cols, gauge_callback, NULL);
|
||||
widget_want_cursor (w, FALSE);
|
||||
widget_want_hotkey (w, FALSE);
|
||||
|
||||
g->shown = shown;
|
||||
if (max == 0)
|
||||
@ -142,9 +149,6 @@ gauge_new (int y, int x, gboolean shown, int max, int current)
|
||||
g->current = current;
|
||||
g->from_left_to_right = TRUE;
|
||||
|
||||
widget_want_cursor (w, FALSE);
|
||||
widget_want_hotkey (w, FALSE);
|
||||
|
||||
return g;
|
||||
}
|
||||
|
||||
|
@ -27,7 +27,7 @@ typedef struct WGauge
|
||||
|
||||
/*** declarations of public functions ************************************************************/
|
||||
|
||||
WGauge *gauge_new (int y, int x, gboolean shown, int max, int current);
|
||||
WGauge *gauge_new (int y, int x, int cols, gboolean shown, int max, int current);
|
||||
void gauge_set_value (WGauge * g, int max, int current);
|
||||
void gauge_show (WGauge * g, gboolean shown);
|
||||
|
||||
|
@ -735,7 +735,7 @@ file_op_context_create_ui (FileOpContext * ctx, gboolean with_eta,
|
||||
ui->file_string[1] = label_new (y++, x, "");
|
||||
add_widget (ui->op_dlg, ui->file_string[1]);
|
||||
|
||||
ui->progress_file_gauge = gauge_new (y++, x + 3, 0, 100, 0);
|
||||
ui->progress_file_gauge = gauge_new (y++, x + 3, dlg_width - (x + 3) * 2, FALSE, 100, 0);
|
||||
if (!classic_progressbar && (current_panel == right_panel))
|
||||
ui->progress_file_gauge->from_left_to_right = FALSE;
|
||||
add_widget (ui->op_dlg, ui->progress_file_gauge);
|
||||
@ -752,7 +752,8 @@ file_op_context_create_ui (FileOpContext * ctx, gboolean with_eta,
|
||||
|
||||
if (file_op_compute_totals)
|
||||
{
|
||||
ui->progress_total_gauge = gauge_new (y++, x + 3, 0, 100, 0);
|
||||
ui->progress_total_gauge =
|
||||
gauge_new (y++, x + 3, dlg_width - (x + 3) * 2, FALSE, 100, 0);
|
||||
if (!classic_progressbar && (current_panel == right_panel))
|
||||
ui->progress_total_gauge->from_left_to_right = FALSE;
|
||||
add_widget (ui->op_dlg, ui->progress_total_gauge);
|
||||
|
Loading…
Reference in New Issue
Block a user