Merge branch '2076_copy_progress_width'
* 2076_copy_progress_width: WHLine: allow draw text over horizontal line. Copy/move/delete progress dialog occupies at least 2/3 of screen width. Ticket #2076: make copy/move/delete progress dialog wider.
Этот коммит содержится в:
Коммит
64542733b6
@ -49,9 +49,6 @@
|
|||||||
|
|
||||||
/*** file scope macro definitions ****************************************************************/
|
/*** file scope macro definitions ****************************************************************/
|
||||||
|
|
||||||
/* Currently width is hardcoded here for text mode */
|
|
||||||
#define gauge_len 47
|
|
||||||
|
|
||||||
/*** file scope type declarations ****************************************************************/
|
/*** file scope type declarations ****************************************************************/
|
||||||
|
|
||||||
/*** file scope variables ************************************************************************/
|
/*** 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);
|
WGauge *g = GAUGE (w);
|
||||||
WDialog *h = w->owner;
|
WDialog *h = w->owner;
|
||||||
|
|
||||||
if (msg == MSG_INIT)
|
switch (msg)
|
||||||
|
{
|
||||||
|
case MSG_INIT:
|
||||||
return MSG_HANDLED;
|
return MSG_HANDLED;
|
||||||
|
|
||||||
/* We don't want to get the focus */
|
/* We don't want to get the focus */
|
||||||
if (msg == MSG_FOCUS)
|
case MSG_FOCUS:
|
||||||
return MSG_NOT_HANDLED;
|
return MSG_NOT_HANDLED;
|
||||||
|
|
||||||
if (msg == MSG_DRAW)
|
case MSG_DRAW:
|
||||||
{
|
|
||||||
widget_move (w, 0, 0);
|
widget_move (w, 0, 0);
|
||||||
tty_setcolor (h->color[DLG_COLOR_NORMAL]);
|
|
||||||
if (!g->shown)
|
if (!g->shown)
|
||||||
tty_printf ("%*s", gauge_len, "");
|
{
|
||||||
|
tty_setcolor (h->color[DLG_COLOR_NORMAL]);
|
||||||
|
tty_printf ("%*s", w->cols, "");
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
int gauge_len;
|
||||||
int percentage, columns;
|
int percentage, columns;
|
||||||
long total = g->max;
|
long total = g->max;
|
||||||
long done = g->current;
|
long done = g->current;
|
||||||
@ -95,30 +96,34 @@ gauge_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm, void *d
|
|||||||
total /= 256;
|
total /= 256;
|
||||||
done /= 256;
|
done /= 256;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gauge_len = w->cols - 7; /* 7 positions for percentage */
|
||||||
|
|
||||||
percentage = (200 * done / total + 1) / 2;
|
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 ('[');
|
tty_print_char ('[');
|
||||||
if (g->from_left_to_right)
|
if (g->from_left_to_right)
|
||||||
{
|
{
|
||||||
tty_setcolor (GAUGE_COLOR);
|
tty_setcolor (GAUGE_COLOR);
|
||||||
tty_printf ("%*s", (int) columns, "");
|
tty_printf ("%*s", (int) columns, "");
|
||||||
tty_setcolor (h->color[DLG_COLOR_NORMAL]);
|
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
|
else
|
||||||
{
|
{
|
||||||
tty_setcolor (h->color[DLG_COLOR_NORMAL]);
|
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_setcolor (GAUGE_COLOR);
|
||||||
tty_printf ("%*s", columns, "");
|
tty_printf ("%*s", columns, "");
|
||||||
tty_setcolor (h->color[DLG_COLOR_NORMAL]);
|
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;
|
return MSG_HANDLED;
|
||||||
}
|
|
||||||
|
|
||||||
return widget_default_callback (w, sender, msg, parm, data);
|
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 *
|
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;
|
WGauge *g;
|
||||||
Widget *w;
|
Widget *w;
|
||||||
|
|
||||||
g = g_new (WGauge, 1);
|
g = g_new (WGauge, 1);
|
||||||
w = WIDGET (g);
|
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;
|
g->shown = shown;
|
||||||
if (max == 0)
|
if (max == 0)
|
||||||
@ -142,9 +149,6 @@ gauge_new (int y, int x, gboolean shown, int max, int current)
|
|||||||
g->current = current;
|
g->current = current;
|
||||||
g->from_left_to_right = TRUE;
|
g->from_left_to_right = TRUE;
|
||||||
|
|
||||||
widget_want_cursor (w, FALSE);
|
|
||||||
widget_want_hotkey (w, FALSE);
|
|
||||||
|
|
||||||
return g;
|
return g;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -27,7 +27,7 @@ typedef struct WGauge
|
|||||||
|
|
||||||
/*** declarations of public functions ************************************************************/
|
/*** 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_set_value (WGauge * g, int max, int current);
|
||||||
void gauge_show (WGauge * g, gboolean shown);
|
void gauge_show (WGauge * g, gboolean shown);
|
||||||
|
|
||||||
|
@ -41,6 +41,7 @@
|
|||||||
#include "lib/tty/tty.h"
|
#include "lib/tty/tty.h"
|
||||||
#include "lib/tty/color.h"
|
#include "lib/tty/color.h"
|
||||||
#include "lib/skin.h"
|
#include "lib/skin.h"
|
||||||
|
#include "lib/strutil.h"
|
||||||
#include "lib/widget.h"
|
#include "lib/widget.h"
|
||||||
|
|
||||||
/*** global variables ****************************************************************************/
|
/*** global variables ****************************************************************************/
|
||||||
@ -98,6 +99,15 @@ hline_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm, void *d
|
|||||||
widget_move (w, 0, w->cols - 1);
|
widget_move (w, 0, w->cols - 1);
|
||||||
tty_print_alt_char (ACS_RTEE, FALSE);
|
tty_print_alt_char (ACS_RTEE, FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (l->text != NULL)
|
||||||
|
{
|
||||||
|
int text_width;
|
||||||
|
|
||||||
|
text_width = str_term_width1 (l->text);
|
||||||
|
widget_move (w, 0, (w->cols - text_width) / 2);
|
||||||
|
tty_print_string (l->text);
|
||||||
|
}
|
||||||
return MSG_HANDLED;
|
return MSG_HANDLED;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@ -119,6 +129,7 @@ hline_new (int y, int x, int width)
|
|||||||
l = g_new (WHLine, 1);
|
l = g_new (WHLine, 1);
|
||||||
w = WIDGET (l);
|
w = WIDGET (l);
|
||||||
init_widget (w, y, x, lines, width < 0 ? 1 : width, hline_callback, NULL);
|
init_widget (w, y, x, lines, width < 0 ? 1 : width, hline_callback, NULL);
|
||||||
|
l->text = NULL;
|
||||||
l->auto_adjust_cols = (width < 0);
|
l->auto_adjust_cols = (width < 0);
|
||||||
l->transparent = FALSE;
|
l->transparent = FALSE;
|
||||||
widget_want_cursor (w, FALSE);
|
widget_want_cursor (w, FALSE);
|
||||||
@ -128,3 +139,19 @@ hline_new (int y, int x, int width)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------- */
|
/* --------------------------------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
void
|
||||||
|
hline_set_text (WHLine * l, const char *text)
|
||||||
|
{
|
||||||
|
g_free (l->text);
|
||||||
|
|
||||||
|
if (text == NULL || *text == '\0')
|
||||||
|
l->text = NULL;
|
||||||
|
else
|
||||||
|
l->text = g_strdup (text);
|
||||||
|
|
||||||
|
if (WIDGET (l)->owner != NULL)
|
||||||
|
send_message (l, NULL, MSG_DRAW, 0, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------- */
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
Widget widget;
|
Widget widget;
|
||||||
|
char *text;
|
||||||
gboolean auto_adjust_cols; /* Compute widget.cols from parent width? */
|
gboolean auto_adjust_cols; /* Compute widget.cols from parent width? */
|
||||||
gboolean transparent; /* Paint in the default color fg/bg */
|
gboolean transparent; /* Paint in the default color fg/bg */
|
||||||
} WHLine;
|
} WHLine;
|
||||||
@ -26,6 +27,7 @@ typedef struct
|
|||||||
/*** declarations of public functions ************************************************************/
|
/*** declarations of public functions ************************************************************/
|
||||||
|
|
||||||
WHLine *hline_new (int y, int x, int width);
|
WHLine *hline_new (int y, int x, int width);
|
||||||
|
void hline_set_text (WHLine * l, const char *text);
|
||||||
|
|
||||||
/*** inline functions ****************************************************************************/
|
/*** inline functions ****************************************************************************/
|
||||||
|
|
||||||
|
@ -197,8 +197,8 @@ int classic_progressbar = 1;
|
|||||||
/* Hack: the vfs code should not rely on this */
|
/* Hack: the vfs code should not rely on this */
|
||||||
#define WITH_FULL_PATHS 1
|
#define WITH_FULL_PATHS 1
|
||||||
|
|
||||||
#define truncFileString(ui, s) str_trunc (s, 52)
|
#define truncFileString(dlg, s) str_trunc (s, WIDGET (dlg)->cols - 10)
|
||||||
#define truncFileStringSecure(ui, s) path_trunc (s, 52)
|
#define truncFileStringSecure(dlg, s) path_trunc (s, WIDGET (dlg)->cols - 10)
|
||||||
|
|
||||||
/*** file scope type declarations ****************************************************************/
|
/*** file scope type declarations ****************************************************************/
|
||||||
|
|
||||||
@ -248,7 +248,7 @@ typedef struct
|
|||||||
|
|
||||||
WLabel *total_files_processed_label;
|
WLabel *total_files_processed_label;
|
||||||
WLabel *time_label;
|
WLabel *time_label;
|
||||||
WLabel *total_bytes_label;
|
WHLine *total_bytes_label;
|
||||||
|
|
||||||
/* Query replace dialog */
|
/* Query replace dialog */
|
||||||
WDialog *replace_dlg;
|
WDialog *replace_dlg;
|
||||||
@ -735,27 +735,27 @@ file_op_context_create_ui (FileOpContext * ctx, gboolean with_eta,
|
|||||||
ui->file_string[1] = label_new (y++, x, "");
|
ui->file_string[1] = label_new (y++, x, "");
|
||||||
add_widget (ui->op_dlg, ui->file_string[1]);
|
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))
|
if (!classic_progressbar && (current_panel == right_panel))
|
||||||
ui->progress_file_gauge->from_left_to_right = FALSE;
|
ui->progress_file_gauge->from_left_to_right = FALSE;
|
||||||
add_widget (ui->op_dlg, ui->progress_file_gauge);
|
add_widget_autopos (ui->op_dlg, ui->progress_file_gauge, WPOS_KEEP_TOP | WPOS_KEEP_HORZ, NULL);
|
||||||
|
|
||||||
ui->progress_file_label = label_new (y++, x, "");
|
ui->progress_file_label = label_new (y++, x, "");
|
||||||
add_widget (ui->op_dlg, ui->progress_file_label);
|
add_widget (ui->op_dlg, ui->progress_file_label);
|
||||||
|
|
||||||
if (verbose && dialog_type == FILEGUI_DIALOG_MULTI_ITEM)
|
if (verbose && dialog_type == FILEGUI_DIALOG_MULTI_ITEM)
|
||||||
{
|
{
|
||||||
add_widget (ui->op_dlg, hline_new (y, -1, -1));
|
ui->total_bytes_label = hline_new (y++, -1, -1);
|
||||||
|
|
||||||
ui->total_bytes_label = label_new (y++, x + 15, "");
|
|
||||||
add_widget (ui->op_dlg, ui->total_bytes_label);
|
add_widget (ui->op_dlg, ui->total_bytes_label);
|
||||||
|
|
||||||
if (file_op_compute_totals)
|
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))
|
if (!classic_progressbar && (current_panel == right_panel))
|
||||||
ui->progress_total_gauge->from_left_to_right = FALSE;
|
ui->progress_total_gauge->from_left_to_right = FALSE;
|
||||||
add_widget (ui->op_dlg, ui->progress_total_gauge);
|
add_widget_autopos (ui->op_dlg, ui->progress_total_gauge,
|
||||||
|
WPOS_KEEP_TOP | WPOS_KEEP_HORZ, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
ui->total_files_processed_label = label_new (y++, x, "");
|
ui->total_files_processed_label = label_new (y++, x, "");
|
||||||
@ -806,7 +806,7 @@ file_op_context_create_ui (FileOpContext * ctx, gboolean with_eta,
|
|||||||
progress_buttons[3].len;
|
progress_buttons[3].len;
|
||||||
|
|
||||||
/* adjust dialog sizes */
|
/* adjust dialog sizes */
|
||||||
dlg_set_size (ui->op_dlg, y + 3, dlg_width);
|
dlg_set_size (ui->op_dlg, y + 3, max (COLS * 2 / 3, buttons_width + 6));
|
||||||
|
|
||||||
place_progress_buttons (ui->op_dlg, FALSE);
|
place_progress_buttons (ui->op_dlg, FALSE);
|
||||||
|
|
||||||
@ -976,7 +976,7 @@ file_progress_show_total (FileOpTotalContext * tctx, FileOpContext * ctx, uintma
|
|||||||
g_snprintf (buffer, BUF_TINY, _(" Total: %s/%s "), buffer2, buffer3);
|
g_snprintf (buffer, BUF_TINY, _(" Total: %s/%s "), buffer2, buffer3);
|
||||||
}
|
}
|
||||||
|
|
||||||
label_set_text (ui->total_bytes_label, buffer);
|
hline_set_text (ui->total_bytes_label, buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* }}} */
|
/* }}} */
|
||||||
@ -999,7 +999,7 @@ file_progress_show_source (FileOpContext * ctx, const vfs_path_t * s_vpath)
|
|||||||
|
|
||||||
s = vfs_path_tokens_get (s_vpath, -1, 1);
|
s = vfs_path_tokens_get (s_vpath, -1, 1);
|
||||||
label_set_text (ui->file_label[0], _("Source"));
|
label_set_text (ui->file_label[0], _("Source"));
|
||||||
label_set_text (ui->file_string[0], truncFileString (ui, s));
|
label_set_text (ui->file_string[0], truncFileString (ui->op_dlg, s));
|
||||||
g_free (s);
|
g_free (s);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -1027,7 +1027,7 @@ file_progress_show_target (FileOpContext * ctx, const vfs_path_t * s_vpath)
|
|||||||
|
|
||||||
s = vfs_path_to_str (s_vpath);
|
s = vfs_path_to_str (s_vpath);
|
||||||
label_set_text (ui->file_label[1], _("Target"));
|
label_set_text (ui->file_label[1], _("Target"));
|
||||||
label_set_text (ui->file_string[1], truncFileStringSecure (ui, s));
|
label_set_text (ui->file_string[1], truncFileStringSecure (ui->op_dlg, s));
|
||||||
g_free (s);
|
g_free (s);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -1049,7 +1049,7 @@ file_progress_show_deleting (FileOpContext * ctx, const char *s)
|
|||||||
|
|
||||||
ui = ctx->ui;
|
ui = ctx->ui;
|
||||||
label_set_text (ui->file_label[0], _("Deleting"));
|
label_set_text (ui->file_label[0], _("Deleting"));
|
||||||
label_set_text (ui->file_label[0], truncFileStringSecure (ui, s));
|
label_set_text (ui->file_label[0], truncFileStringSecure (ui->op_dlg, s));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------- */
|
/* --------------------------------------------------------------------------------------------- */
|
||||||
|
Загрузка…
x
Ссылка в новой задаче
Block a user