1
1

* 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.
Этот коммит содержится в:
Pavel Roskin 2002-09-02 16:31:33 +00:00
родитель 47f1a6a51b
Коммит e000c69683
9 изменённых файлов: 53 добавлений и 67 удалений

Просмотреть файл

@ -1,5 +1,10 @@
2002-09-02 Pavel Roskin <proski@gnu.org> 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 * panelize.c (panelize_refresh): Eliminate in favor of
common_dialog_callback(). common_dialog_callback().

Просмотреть файл

@ -325,7 +325,7 @@ sort_box (sortfn *sort_fn, int *reverse, int *case_sensitive)
break; 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); "[Sort Order...]", "sort", DLG_CENTER);
x_set_dialog_title (dd, sort_title); x_set_dialog_title (dd, sort_title);
@ -570,8 +570,7 @@ init_disp_bits_box (void)
do_refresh(); do_refresh();
dbits_dlg = create_dlg( 0, 0, DISPY, DISPX, dialog_colors, dbits_dlg = create_dlg( 0, 0, DISPY, DISPX, dialog_colors,
common_dialog_callback, "[Display bits]", "Display bits", NULL, "[Display bits]", "Display bits", DLG_CENTER );
DLG_CENTER );
x_set_dialog_title( dbits_dlg, _(" Display bits ")); x_set_dialog_title( dbits_dlg, _(" Display bits "));
add_widget( dbits_dlg, add_widget( dbits_dlg,
@ -975,9 +974,8 @@ jobs_cmd (void)
} }
#endif /* ENABLE_NLS */ #endif /* ENABLE_NLS */
jobs_dlg = create_dlg (0, 0, JOBS_Y, JOBS_X, dialog_colors, jobs_dlg = create_dlg (0, 0, JOBS_Y, JOBS_X, dialog_colors, NULL,
common_dialog_callback, "[Background jobs]", "jobs", "[Background jobs]", "jobs", DLG_CENTER);
DLG_CENTER);
x_set_dialog_title (jobs_dlg, _("Background Jobs")); x_set_dialog_title (jobs_dlg, _("Background Jobs"));
bg_list = listbox_new (2, 3, JOBS_X-7, JOBS_Y-9, listbox_nothing, 0, "listbox"); 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) if (!user)
user = ""; user = "";
auth_dlg = create_dlg (0, 0, dialog_y, dialog_x, dialog_colors, auth_dlg = create_dlg (0, 0, dialog_y, dialog_x, dialog_colors, NULL,
common_dialog_callback, "[Smb Authinfo]", "smbauthinfo", "[Smb Authinfo]", "smbauthinfo", DLG_CENTER);
DLG_CENTER);
title = g_strdup_printf (_("Password for \\\\%s\\%s"), host, share); title = g_strdup_printf (_("Password for \\\\%s\\%s"), host, share);
x_set_dialog_title (auth_dlg, title); x_set_dialog_title (auth_dlg, title);

Просмотреть файл

@ -141,6 +141,7 @@ void init_widget (Widget *w, int y, int x, int lines, int cols,
w->options = W_WANT_CURSOR; w->options = W_WANT_CURSOR;
} }
/* Default callback for widgets */
int default_proc (Dlg_head *h, int Msg, int Par) int default_proc (Dlg_head *h, int Msg, int Par)
{ {
switch (Msg){ switch (Msg){
@ -177,12 +178,36 @@ int default_proc (Dlg_head *h, int Msg, int Par)
return 1; 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) 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){ if (msg == DLG_IDLE){
dlg_broadcast_msg_to (h, WIDGET_IDLE, 0, W_WANT_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, Dlg_head *create_dlg (int y1, int x1, int lines, int cols,
@ -883,11 +908,6 @@ destroy_dlg (Dlg_head *h)
do_refresh (); 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) void widget_set_size (Widget *widget, int y, int x, int lines, int cols)
{ {
widget->x = x; 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, callback_fn callback, destroy_fn destroy,
mouse_h mouse_handler, char *tkname); 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 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); 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 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, \ #define dlg_move(h, _y, _x) move(((Dlg_head *) h)->y + _y, \
((Dlg_head *) h)->x + _x) ((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; x_size = (WX + 4) + ui->eta_extra;
ui->op_dlg = create_dlg (0, 0, WY-minus+4, x_size, dialog_colors, 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; last_hint_line = the_hint->widget.y;
if ((ui->op_dlg->y + ui->op_dlg->lines) > last_hint_line) 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 = ctx->ui;
ui->replace_dlg = create_dlg (0, 0, 16, rd_xlen, alarm_colors, ui->replace_dlg = create_dlg (0, 0, 16, rd_xlen, alarm_colors, NULL,
common_dialog_callback,
"[ Replace ]", "replace", DLG_CENTER); "[ Replace ]", "replace", DLG_CENTER);
x_set_dialog_title (ui->replace_dlg, x_set_dialog_title (ui->replace_dlg,

Просмотреть файл

@ -195,9 +195,8 @@ find_par_start:
if (!in_contents) if (!in_contents)
in_contents = g_strdup (""); in_contents = g_strdup ("");
find_dlg = create_dlg (0, 0, FIND_Y, FIND_X, dialog_colors, find_dlg = create_dlg (0, 0, FIND_Y, FIND_X, dialog_colors, NULL,
common_dialog_callback, "[Find File]", "findfile", "[Find File]", "findfile", DLG_CENTER);
DLG_CENTER);
x_set_dialog_title (find_dlg, _("Find File")); x_set_dialog_title (find_dlg, _("Find File"));

Просмотреть файл

@ -945,8 +945,8 @@ show_hist (Hist * history, int widget_x, int widget_y)
} }
query_dlg = query_dlg =
create_dlg (y, x, h, w, dialog_colors, common_dialog_callback, create_dlg (y, x, h, w, dialog_colors, NULL, "[History-query]",
"[History-query]", "history", DLG_COMPACT); "history", DLG_COMPACT);
x_set_dialog_title (query_dlg, i18n_htitle ()); x_set_dialog_title (query_dlg, i18n_htitle ());
query_list = listbox_new (1, 1, w - 2, h - 2, listbox_finish, 0, NULL); query_list = listbox_new (1, 1, w - 2, h - 2, listbox_finish, 0, NULL);
add_widget (query_dlg, query_list); add_widget (query_dlg, query_list);

Просмотреть файл

@ -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 utility functions */
Listbox *create_listbox_window (int cols, int lines, char *title, char *help) 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 */ /* Create components */
listbox->dlg = create_dlg (ypos, xpos, lines+6, cols+4, dialog_colors, listbox->dlg = create_dlg (ypos, xpos, lines+6, cols+4, dialog_colors,
common_dialog_callback, help, "listbox", NULL, help, "listbox", DLG_CENTER);
DLG_CENTER);
x_set_dialog_title (listbox->dlg, title); x_set_dialog_title (listbox->dlg, title);
listbox->list = listbox_new (2, 2, cols, lines, listbox_finish, 0, "li"); 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; ypos = LINES/3 - (lines-3)/2;
/* prepare dialog */ /* prepare dialog */
query_dlg = create_dlg (ypos, xpos, lines, cols, query_colors, query_dlg = create_dlg (ypos, xpos, lines, cols, query_colors, NULL,
common_dialog_callback, "[QueryBox]", "[QueryBox]", "query", DLG_BACKWARD);
"query", DLG_BACKWARD);
x_set_dialog_title (query_dlg, header); x_set_dialog_title (query_dlg, header);
if (count > 0){ if (count > 0){
@ -287,7 +255,7 @@ Chooser *new_chooser (int lines, int cols, char *help, int flags)
int button_lines; int button_lines;
c =g_new (Chooser, 1); 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); help, "chooser", DLG_CENTER);
c->dialog->lines = lines; c->dialog->lines = lines;

Просмотреть файл

@ -1,12 +1,6 @@
#ifndef __WTOOLS_H #ifndef __WTOOLS_H
#define __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 */ /* Listbox utility functions */
typedef struct { typedef struct {
Dlg_head *dlg; Dlg_head *dlg;