mirror of
https://github.com/MidnightCommander/mc
synced 2025-01-24 20:22:11 +03:00
* wtools.c (common_dialog_callback): Fold into ...
* dlg.c (default_dlg_callback): ... this. Don't redraw dialogs that don't have colors. Adjust all dependencies. (std_callback): Elimitate.
This commit is contained in:
parent
47f1a6a51b
commit
e000c69683
@ -1,5 +1,10 @@
|
||||
2002-09-02 Pavel Roskin <proski@gnu.org>
|
||||
|
||||
* wtools.c (common_dialog_callback): Fold into ...
|
||||
* dlg.c (default_dlg_callback): ... this. Don't redraw dialogs
|
||||
that don't have colors. Adjust all dependencies.
|
||||
(std_callback): Elimitate.
|
||||
|
||||
* panelize.c (panelize_refresh): Eliminate in favor of
|
||||
common_dialog_callback().
|
||||
|
||||
|
15
src/boxes.c
15
src/boxes.c
@ -325,7 +325,7 @@ sort_box (sortfn *sort_fn, int *reverse, int *case_sensitive)
|
||||
break;
|
||||
}
|
||||
|
||||
dd = create_dlg (0, 0, SORT_Y, SORT_X, dialog_colors, common_dialog_callback,
|
||||
dd = create_dlg (0, 0, SORT_Y, SORT_X, dialog_colors, NULL,
|
||||
"[Sort Order...]", "sort", DLG_CENTER);
|
||||
|
||||
x_set_dialog_title (dd, sort_title);
|
||||
@ -570,8 +570,7 @@ init_disp_bits_box (void)
|
||||
do_refresh();
|
||||
|
||||
dbits_dlg = create_dlg( 0, 0, DISPY, DISPX, dialog_colors,
|
||||
common_dialog_callback, "[Display bits]", "Display bits",
|
||||
DLG_CENTER );
|
||||
NULL, "[Display bits]", "Display bits", DLG_CENTER );
|
||||
x_set_dialog_title( dbits_dlg, _(" Display bits "));
|
||||
|
||||
add_widget( dbits_dlg,
|
||||
@ -975,9 +974,8 @@ jobs_cmd (void)
|
||||
}
|
||||
#endif /* ENABLE_NLS */
|
||||
|
||||
jobs_dlg = create_dlg (0, 0, JOBS_Y, JOBS_X, dialog_colors,
|
||||
common_dialog_callback, "[Background jobs]", "jobs",
|
||||
DLG_CENTER);
|
||||
jobs_dlg = create_dlg (0, 0, JOBS_Y, JOBS_X, dialog_colors, NULL,
|
||||
"[Background jobs]", "jobs", DLG_CENTER);
|
||||
x_set_dialog_title (jobs_dlg, _("Background Jobs"));
|
||||
|
||||
bg_list = listbox_new (2, 3, JOBS_X-7, JOBS_Y-9, listbox_nothing, 0, "listbox");
|
||||
@ -1060,9 +1058,8 @@ vfs_smb_get_authinfo (const char *host, const char *share, const char *domain,
|
||||
if (!user)
|
||||
user = "";
|
||||
|
||||
auth_dlg = create_dlg (0, 0, dialog_y, dialog_x, dialog_colors,
|
||||
common_dialog_callback, "[Smb Authinfo]", "smbauthinfo",
|
||||
DLG_CENTER);
|
||||
auth_dlg = create_dlg (0, 0, dialog_y, dialog_x, dialog_colors, NULL,
|
||||
"[Smb Authinfo]", "smbauthinfo", DLG_CENTER);
|
||||
|
||||
title = g_strdup_printf (_("Password for \\\\%s\\%s"), host, share);
|
||||
x_set_dialog_title (auth_dlg, title);
|
||||
|
32
src/dlg.c
32
src/dlg.c
@ -141,6 +141,7 @@ void init_widget (Widget *w, int y, int x, int lines, int cols,
|
||||
w->options = W_WANT_CURSOR;
|
||||
}
|
||||
|
||||
/* Default callback for widgets */
|
||||
int default_proc (Dlg_head *h, int Msg, int Par)
|
||||
{
|
||||
switch (Msg){
|
||||
@ -177,12 +178,36 @@ int default_proc (Dlg_head *h, int Msg, int Par)
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Clean the dialog area, draw the frame and the title */
|
||||
void
|
||||
common_dialog_repaint (struct Dlg_head *h)
|
||||
{
|
||||
int space;
|
||||
|
||||
space = (h->flags & DLG_COMPACT) ? 0 : 1;
|
||||
|
||||
attrset (NORMALC);
|
||||
dlg_erase (h);
|
||||
draw_box (h, space, space, h->lines - 2 * space, h->cols - 2 * space);
|
||||
attrset (HOT_NORMALC);
|
||||
if (h->title) {
|
||||
dlg_move (h, space, (h->cols - strlen (h->title)) / 2);
|
||||
addstr (h->title);
|
||||
}
|
||||
}
|
||||
|
||||
/* Default dialog callback */
|
||||
int default_dlg_callback (Dlg_head *h, int id, int msg)
|
||||
{
|
||||
if (msg == DLG_DRAW && h->color) {
|
||||
common_dialog_repaint (h);
|
||||
return MSG_HANDLED;
|
||||
}
|
||||
if (msg == DLG_IDLE){
|
||||
dlg_broadcast_msg_to (h, WIDGET_IDLE, 0, W_WANT_IDLE);
|
||||
return MSG_HANDLED;
|
||||
}
|
||||
return 0;
|
||||
return MSG_NOT_HANDLED;
|
||||
}
|
||||
|
||||
Dlg_head *create_dlg (int y1, int x1, int lines, int cols,
|
||||
@ -883,11 +908,6 @@ destroy_dlg (Dlg_head *h)
|
||||
do_refresh ();
|
||||
}
|
||||
|
||||
int std_callback (Dlg_head *h, int Msg, int Par)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
void widget_set_size (Widget *widget, int y, int x, int lines, int cols)
|
||||
{
|
||||
widget->x = x;
|
||||
|
@ -172,11 +172,15 @@ void init_widget (Widget *w, int y, int x, int lines, int cols,
|
||||
callback_fn callback, destroy_fn destroy,
|
||||
mouse_h mouse_handler, char *tkname);
|
||||
|
||||
/* Various default service provision */
|
||||
/* Default callback for dialogs */
|
||||
int default_dlg_callback (Dlg_head *h, int id, int msg);
|
||||
int std_callback (Dlg_head *h, int Msg, int Par);
|
||||
|
||||
/* Default callback for widgets */
|
||||
int default_proc (Dlg_head *h, int Msg, int Par);
|
||||
|
||||
/* Default paint routine for dialogs */
|
||||
void common_dialog_repaint (struct Dlg_head *h);
|
||||
|
||||
#define real_widget_move(w, _y, _x) move((w)->y + _y, (w)->x + _x)
|
||||
#define dlg_move(h, _y, _x) move(((Dlg_head *) h)->y + _y, \
|
||||
((Dlg_head *) h)->x + _x)
|
||||
|
@ -218,7 +218,7 @@ file_op_context_create_ui (FileOpContext *ctx, FileOperation op, int with_eta)
|
||||
x_size = (WX + 4) + ui->eta_extra;
|
||||
|
||||
ui->op_dlg = create_dlg (0, 0, WY-minus+4, x_size, dialog_colors,
|
||||
common_dialog_callback, "", "opwin", DLG_CENTER);
|
||||
NULL, "", "opwin", DLG_CENTER);
|
||||
|
||||
last_hint_line = the_hint->widget.y;
|
||||
if ((ui->op_dlg->y + ui->op_dlg->lines) > last_hint_line)
|
||||
@ -610,8 +610,7 @@ init_replace (FileOpContext *ctx, enum OperationMode mode)
|
||||
|
||||
ui = ctx->ui;
|
||||
|
||||
ui->replace_dlg = create_dlg (0, 0, 16, rd_xlen, alarm_colors,
|
||||
common_dialog_callback,
|
||||
ui->replace_dlg = create_dlg (0, 0, 16, rd_xlen, alarm_colors, NULL,
|
||||
"[ Replace ]", "replace", DLG_CENTER);
|
||||
|
||||
x_set_dialog_title (ui->replace_dlg,
|
||||
|
@ -195,9 +195,8 @@ find_par_start:
|
||||
if (!in_contents)
|
||||
in_contents = g_strdup ("");
|
||||
|
||||
find_dlg = create_dlg (0, 0, FIND_Y, FIND_X, dialog_colors,
|
||||
common_dialog_callback, "[Find File]", "findfile",
|
||||
DLG_CENTER);
|
||||
find_dlg = create_dlg (0, 0, FIND_Y, FIND_X, dialog_colors, NULL,
|
||||
"[Find File]", "findfile", DLG_CENTER);
|
||||
|
||||
x_set_dialog_title (find_dlg, _("Find File"));
|
||||
|
||||
|
@ -945,8 +945,8 @@ show_hist (Hist * history, int widget_x, int widget_y)
|
||||
}
|
||||
|
||||
query_dlg =
|
||||
create_dlg (y, x, h, w, dialog_colors, common_dialog_callback,
|
||||
"[History-query]", "history", DLG_COMPACT);
|
||||
create_dlg (y, x, h, w, dialog_colors, NULL, "[History-query]",
|
||||
"history", DLG_COMPACT);
|
||||
x_set_dialog_title (query_dlg, i18n_htitle ());
|
||||
query_list = listbox_new (1, 1, w - 2, h - 2, listbox_finish, 0, NULL);
|
||||
add_widget (query_dlg, query_list);
|
||||
|
40
src/wtools.c
40
src/wtools.c
@ -50,36 +50,6 @@
|
||||
|
||||
/* }}} */
|
||||
|
||||
/* {{{ Common dialog callback */
|
||||
|
||||
void
|
||||
common_dialog_repaint (struct Dlg_head *h)
|
||||
{
|
||||
int space;
|
||||
|
||||
space = (h->flags & DLG_COMPACT) ? 0 : 1;
|
||||
|
||||
attrset (NORMALC);
|
||||
dlg_erase (h);
|
||||
draw_box (h, space, space, h->lines - 2 * space, h->cols - 2 * space);
|
||||
attrset (HOT_NORMALC);
|
||||
if (h->title) {
|
||||
dlg_move (h, space, (h->cols - strlen (h->title)) / 2);
|
||||
addstr (h->title);
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
common_dialog_callback (struct Dlg_head *h, int id, int msg)
|
||||
{
|
||||
if (msg == DLG_DRAW) {
|
||||
common_dialog_repaint (h);
|
||||
return MSG_HANDLED;
|
||||
}
|
||||
return MSG_NOT_HANDLED;
|
||||
}
|
||||
|
||||
/* }}} */
|
||||
/* {{{ Listbox utility functions */
|
||||
|
||||
Listbox *create_listbox_window (int cols, int lines, char *title, char *help)
|
||||
@ -106,8 +76,7 @@ Listbox *create_listbox_window (int cols, int lines, char *title, char *help)
|
||||
|
||||
/* Create components */
|
||||
listbox->dlg = create_dlg (ypos, xpos, lines+6, cols+4, dialog_colors,
|
||||
common_dialog_callback, help, "listbox",
|
||||
DLG_CENTER);
|
||||
NULL, help, "listbox", DLG_CENTER);
|
||||
x_set_dialog_title (listbox->dlg, title);
|
||||
|
||||
listbox->list = listbox_new (2, 2, cols, lines, listbox_finish, 0, "li");
|
||||
@ -184,9 +153,8 @@ int query_dialog (char *header, char *text, int flags, int count, ...)
|
||||
ypos = LINES/3 - (lines-3)/2;
|
||||
|
||||
/* prepare dialog */
|
||||
query_dlg = create_dlg (ypos, xpos, lines, cols, query_colors,
|
||||
common_dialog_callback, "[QueryBox]",
|
||||
"query", DLG_BACKWARD);
|
||||
query_dlg = create_dlg (ypos, xpos, lines, cols, query_colors, NULL,
|
||||
"[QueryBox]", "query", DLG_BACKWARD);
|
||||
x_set_dialog_title (query_dlg, header);
|
||||
|
||||
if (count > 0){
|
||||
@ -287,7 +255,7 @@ Chooser *new_chooser (int lines, int cols, char *help, int flags)
|
||||
int button_lines;
|
||||
|
||||
c =g_new (Chooser, 1);
|
||||
c->dialog = create_dlg (0, 0, lines, cols, dialog_colors, common_dialog_callback,
|
||||
c->dialog = create_dlg (0, 0, lines, cols, dialog_colors, NULL,
|
||||
help, "chooser", DLG_CENTER);
|
||||
|
||||
c->dialog->lines = lines;
|
||||
|
@ -1,12 +1,6 @@
|
||||
#ifndef __WTOOLS_H
|
||||
#define __WTOOLS_H
|
||||
|
||||
/* Repaint the area, the frame and the title */
|
||||
void common_dialog_repaint (struct Dlg_head *h);
|
||||
|
||||
/* For common dialogs, just repaint */
|
||||
int common_dialog_callback (struct Dlg_head *h, int id, int msg);
|
||||
|
||||
/* Listbox utility functions */
|
||||
typedef struct {
|
||||
Dlg_head *dlg;
|
||||
|
Loading…
Reference in New Issue
Block a user