* filegui.c: Eliminate x_set_dialog_title().

* hotlist.c: Likewise.
* help.c: Likewise.
(interactive_display): Default to node "[main]" if the given
node is empty.
This commit is contained in:
Pavel Roskin 2002-09-03 06:53:11 +00:00
parent 2d93d274b5
commit 52caab36b8
4 changed files with 155 additions and 115 deletions

View File

@ -1,3 +1,11 @@
2002-09-03 Pavel Roskin <proski@gnu.org>
* filegui.c: Eliminate x_set_dialog_title().
* hotlist.c: Likewise.
* help.c: Likewise.
(interactive_display): Default to node "[main]" if the given
node is empty.
2002-09-02 Pavel Roskin <proski@gnu.org> 2002-09-02 Pavel Roskin <proski@gnu.org>
* dlg.c (create_dlg): Take title instead of unused name as the * dlg.c (create_dlg): Take title instead of unused name as the

View File

@ -218,14 +218,12 @@ 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,
NULL, "", "opwin", DLG_CENTER); NULL, NULL, op_names[op], 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)
the_hint->widget.y = ui->op_dlg->y + ui->op_dlg->lines+1; the_hint->widget.y = ui->op_dlg->y + ui->op_dlg->lines+1;
x_set_dialog_title (ui->op_dlg, op_names[op]);
add_widget (ui->op_dlg, button_new (BY-minus, WX - 19 + eta_offset, FILE_ABORT, add_widget (ui->op_dlg, button_new (BY-minus, WX - 19 + eta_offset, FILE_ABORT,
NORMAL_BUTTON, _("&Abort"), 0, 0, "abort")); NORMAL_BUTTON, _("&Abort"), 0, 0, "abort"));
add_widget (ui->op_dlg, button_new (BY-minus, 14 + eta_offset, FILE_SKIP, add_widget (ui->op_dlg, button_new (BY-minus, 14 + eta_offset, FILE_SKIP,
@ -553,95 +551,104 @@ rd_widgets [] =
label_new (rd_widgets [i].ypos, rd_widgets [i].xpos, buffer, rd_widgets [i].tkname)) label_new (rd_widgets [i].ypos, rd_widgets [i].xpos, buffer, rd_widgets [i].tkname))
static void static void
init_replace (FileOpContext *ctx, enum OperationMode mode) init_replace (FileOpContext * ctx, enum OperationMode mode)
{ {
FileOpContextUI *ui; FileOpContextUI *ui;
char buffer [BUF_SMALL]; char buffer[BUF_SMALL];
char *title;
static int rd_xlen = 60, rd_trunc = X_TRUNC; static int rd_xlen = 60, rd_trunc = X_TRUNC;
#ifdef ENABLE_NLS #ifdef ENABLE_NLS
static int i18n_flag; static int i18n_flag;
if (!i18n_flag) { if (!i18n_flag) {
int l1, l2, l, row; int l1, l2, l, row;
register int i = sizeof (rd_widgets) / sizeof (rd_widgets [0]); register int i = sizeof (rd_widgets) / sizeof (rd_widgets[0]);
while (i--) while (i--)
rd_widgets [i].text = _(rd_widgets [i].text); rd_widgets[i].text = _(rd_widgets[i].text);
/* /*
*longest of "Overwrite..." labels * longest of "Overwrite..." labels
* (assume "Target date..." are short enough) * (assume "Target date..." are short enough)
*/ */
l1 = max (strlen (rd_widgets [6].text), strlen (rd_widgets [11].text)); l1 = max (strlen (rd_widgets[6].text),
strlen (rd_widgets[11].text));
/* longest of button rows */ /* longest of button rows */
i = sizeof (rd_widgets) / sizeof (rd_widgets [0]); i = sizeof (rd_widgets) / sizeof (rd_widgets[0]);
for (row = l = l2 = 0; i--;) { for (row = l = l2 = 0; i--;) {
if (rd_widgets [i].value != 0) { if (rd_widgets[i].value != 0) {
if (row != rd_widgets [i].ypos) { if (row != rd_widgets[i].ypos) {
row = rd_widgets [i].ypos; row = rd_widgets[i].ypos;
l2 = max (l2, l); l2 = max (l2, l);
l = 0; l = 0;
} }
l += strlen (rd_widgets [i].text) + 4; l += strlen (rd_widgets[i].text) + 4;
} }
} }
l2 = max (l2, l); /* last row */ l2 = max (l2, l); /* last row */
rd_xlen = max (rd_xlen, l1 + l2 + 8); rd_xlen = max (rd_xlen, l1 + l2 + 8);
rd_trunc = rd_xlen - 6; rd_trunc = rd_xlen - 6;
/* Now place buttons */ /* Now place buttons */
l1 += 5; /* start of first button in the row */ l1 += 5; /* start of first button in the row */
i = sizeof (rd_widgets) / sizeof (rd_widgets [0]); i = sizeof (rd_widgets) / sizeof (rd_widgets[0]);
for (l = l1, row = 0; --i > 1;) { for (l = l1, row = 0; --i > 1;) {
if (rd_widgets [i].value != 0) { if (rd_widgets[i].value != 0) {
if (row != rd_widgets [i].ypos) { if (row != rd_widgets[i].ypos) {
row = rd_widgets [i].ypos; row = rd_widgets[i].ypos;
l = l1; l = l1;
} }
rd_widgets [i].xpos = l; rd_widgets[i].xpos = l;
l += strlen (rd_widgets [i].text) + 4; l += strlen (rd_widgets[i].text) + 4;
} }
} }
/* Abort button is centered */ /* Abort button is centered */
rd_widgets [1].xpos = (rd_xlen - strlen (rd_widgets [1].text) - 3) / 2; rd_widgets[1].xpos =
(rd_xlen - strlen (rd_widgets[1].text) - 3) / 2;
} }
#endif /* ENABLE_NLS */ #endif /* ENABLE_NLS */
ui = ctx->ui; ui = ctx->ui;
ui->replace_dlg = create_dlg (0, 0, 16, rd_xlen, alarm_colors, NULL, if (mode == Foreground)
"[ Replace ]", "replace", DLG_CENTER); title = _(" File exists ");
else
x_set_dialog_title (ui->replace_dlg, title = _(" Background process: File exists ");
(mode == Foreground
? _(" File exists ") /* FIXME - missing help node */
: _(" Background process: File exists "))); ui->replace_dlg =
create_dlg (0, 0, 16, rd_xlen, alarm_colors, NULL, "[Replace]",
title, DLG_CENTER);
ADD_RD_LABEL(ui, 0, ADD_RD_LABEL (ui, 0,
name_trunc (ui->replace_filename, rd_trunc - strlen (rd_widgets [0].text)), 0); name_trunc (ui->replace_filename,
ADD_RD_BUTTON(1); rd_trunc - strlen (rd_widgets[0].text)), 0);
ADD_RD_BUTTON (1);
ADD_RD_BUTTON(2); ADD_RD_BUTTON (2);
ADD_RD_BUTTON(3); ADD_RD_BUTTON (3);
ADD_RD_BUTTON(4); ADD_RD_BUTTON (4);
ADD_RD_BUTTON(5); ADD_RD_BUTTON (5);
ADD_RD_LABEL(ui, 6, 0, 0); ADD_RD_LABEL (ui, 6, 0, 0);
/* "this target..." widgets */ /* "this target..." widgets */
if (!S_ISDIR (ui->d_stat->st_mode)){ if (!S_ISDIR (ui->d_stat->st_mode)) {
if ((ui->d_stat->st_size && ui->s_stat->st_size > ui->d_stat->st_size)) if ((ui->d_stat->st_size
ADD_RD_BUTTON(7); && ui->s_stat->st_size > ui->d_stat->st_size))
ADD_RD_BUTTON (7);
ADD_RD_BUTTON(8); ADD_RD_BUTTON (8);
} }
ADD_RD_BUTTON(9); ADD_RD_BUTTON (9);
ADD_RD_BUTTON(10); ADD_RD_BUTTON (10);
ADD_RD_LABEL(ui, 11,0,0); ADD_RD_LABEL (ui, 11, 0, 0);
ADD_RD_LABEL(ui, 12, file_date (ui->d_stat->st_mtime), (int) ui->d_stat->st_size); ADD_RD_LABEL (ui, 12, file_date (ui->d_stat->st_mtime),
ADD_RD_LABEL(ui, 13, file_date (ui->s_stat->st_mtime), (int) ui->s_stat->st_size); (int) ui->d_stat->st_size);
ADD_RD_LABEL (ui, 13, file_date (ui->s_stat->st_mtime),
(int) ui->s_stat->st_size);
} }
void void

View File

@ -750,18 +750,18 @@ interactive_display_finish (void)
void void
interactive_display (char *filename, char *node) interactive_display (char *filename, char *node)
{ {
WButtonBar *help_bar; WButtonBar *help_bar;
Widget *md; Widget *md;
char *hlpfile = filename; char *hlpfile = filename;
if (filename) if (filename)
data = load_file (filename); data = load_file (filename);
else else
data = load_mc_home_file ("mc.hlp", &hlpfile); data = load_mc_home_file ("mc.hlp", &hlpfile);
if (data == NULL){ if (data == NULL) {
message (1, MSG_ERROR, _(" Cannot open file %s \n %s "), message (1, MSG_ERROR, _(" Cannot open file %s \n %s "), hlpfile,
hlpfile, unix_error_string (errno)); unix_error_string (errno));
} }
if (!filename) if (!filename)
@ -770,42 +770,46 @@ interactive_display (char *filename, char *node)
if (!data) if (!data)
return; return;
if (!(main_node = search_string (data, node))){ if (!node || !*node)
message (1, MSG_ERROR, _(" Cannot find node %s in help file "), node); node = "[main]";
if (!(main_node = search_string (data, node))) {
message (1, MSG_ERROR, _(" Cannot find node %s in help file "),
node);
interactive_display_finish (); interactive_display_finish ();
return; return;
} }
help_lines = min (LINES - 4, max (2 * LINES / 3, 18)); help_lines = min (LINES - 4, max (2 * LINES / 3, 18));
whelp = create_dlg (0, 0, help_lines+4, HELP_WINDOW_WIDTH+4, dialog_colors, whelp =
help_callback, "[Help]", "help", create_dlg (0, 0, help_lines + 4, HELP_WINDOW_WIDTH + 4,
DLG_TRYUP | DLG_CENTER | DLG_WANT_TAB); dialog_colors, help_callback, "[Help]", _("Help"),
x_set_dialog_title(whelp, _("Help")); DLG_TRYUP | DLG_CENTER | DLG_WANT_TAB);
selected_item = search_string_node (main_node, STRING_LINK_START) - 1; selected_item = search_string_node (main_node, STRING_LINK_START) - 1;
currentpoint = startpoint = main_node + 1; currentpoint = startpoint = main_node + 1;
for (history_ptr = HISTORY_SIZE; history_ptr;){ for (history_ptr = HISTORY_SIZE; history_ptr;) {
history_ptr--; history_ptr--;
history [history_ptr].page = currentpoint; history[history_ptr].page = currentpoint;
history [history_ptr].link = selected_item; history[history_ptr].link = selected_item;
} }
help_bar = buttonbar_new (1); help_bar = buttonbar_new (1);
help_bar->widget.y -= whelp->y; help_bar->widget.y -= whelp->y;
help_bar->widget.x -= whelp->x; help_bar->widget.x -= whelp->x;
md = mousedispatch_new (1, 1, help_lines, HELP_WINDOW_WIDTH-2); md = mousedispatch_new (1, 1, help_lines, HELP_WINDOW_WIDTH - 2);
add_widget (whelp, help_bar); add_widget (whelp, help_bar);
add_widget (whelp, md); add_widget (whelp, md);
define_label_data (whelp, (Widget *)NULL, 1, _("Help"), define_label_data (whelp, (Widget *) NULL, 1, _("Help"),
(buttonbarfn) help_help_cmd, whelp); (buttonbarfn) help_help_cmd, whelp);
define_label_data (whelp, (Widget *)NULL, 2, _("Index"), define_label_data (whelp, (Widget *) NULL, 2, _("Index"),
(buttonbarfn) help_index_cmd,whelp); (buttonbarfn) help_index_cmd, whelp);
define_label_data (whelp, (Widget *)NULL, 3, _("Prev"), define_label_data (whelp, (Widget *) NULL, 3, _("Prev"),
(buttonbarfn) prev_node_cmd, whelp); (buttonbarfn) prev_node_cmd, whelp);
define_label (whelp, (Widget *) NULL, 4, "", 0); define_label (whelp, (Widget *) NULL, 4, "", 0);
define_label (whelp, (Widget *) NULL, 5, "", 0); define_label (whelp, (Widget *) NULL, 5, "", 0);
@ -813,7 +817,8 @@ interactive_display (char *filename, char *node)
define_label (whelp, (Widget *) NULL, 7, "", 0); define_label (whelp, (Widget *) NULL, 7, "", 0);
define_label (whelp, (Widget *) NULL, 8, "", 0); define_label (whelp, (Widget *) NULL, 8, "", 0);
define_label (whelp, (Widget *) NULL, 9, "", 0); define_label (whelp, (Widget *) NULL, 9, "", 0);
define_label_data (whelp, (Widget *) NULL, 10, _("Quit"), quit_cmd, whelp); define_label_data (whelp, (Widget *) NULL, 10, _("Quit"), quit_cmd,
whelp);
run_dlg (whelp); run_dlg (whelp);
interactive_display_finish (); interactive_display_finish ();

View File

@ -568,62 +568,80 @@ init_i18n_stuff(int list_type, int cols)
return cols; return cols;
} }
static void init_hotlist (int list_type) static void
init_hotlist (int list_type)
{ {
int i; int i;
int hotlist_cols = init_i18n_stuff (list_type, COLS - 6); char *title, *help_node;
int hotlist_cols;
hotlist_cols = init_i18n_stuff (list_type, COLS - 6);
do_refresh (); do_refresh ();
hotlist_state.expanded = GetPrivateProfileInt ("HotlistConfig", hotlist_state.expanded =
"expanded_view_of_groups", 0, profile_name); GetPrivateProfileInt ("HotlistConfig", "expanded_view_of_groups",
0, profile_name);
hotlist_dlg = create_dlg (0, 0, LINES-2, hotlist_cols, dialog_colors, if (list_type == LIST_VFSLIST) {
hotlist_callback, title = _("Active VFS directories");
list_type == LIST_VFSLIST ? "[vfshot]" : "[Hotlist]", help_node = "[vfshot]"; /* FIXME - no such node */
list_type == LIST_VFSLIST ? "vfshot" : "hotlist", } else {
DLG_CENTER); title = _("Directory hotlist");
x_set_dialog_title (hotlist_dlg, help_node = "[Hotlist]";
list_type == LIST_VFSLIST ? _("Active VFS directories") : _("Directory hotlist")); }
#define XTRACT(i) BY+hotlist_but[i].y, BX+hotlist_but[i].x, hotlist_but[i].ret_cmd, hotlist_but[i].flags, hotlist_but[i].text, hotlist_button_callback, 0, hotlist_but[i].tkname hotlist_dlg =
create_dlg (0, 0, LINES - 2, hotlist_cols, dialog_colors,
for (i = 0; i < BUTTONS; i++){ hotlist_callback, help_node, title, DLG_CENTER);
if (hotlist_but[i].type & list_type)
add_widget (hotlist_dlg, button_new (XTRACT (i))); for (i = 0; i < BUTTONS; i++) {
if (hotlist_but[i].type & list_type)
add_widget (hotlist_dlg,
button_new (BY + hotlist_but[i].y,
BX + hotlist_but[i].x,
hotlist_but[i].ret_cmd,
hotlist_but[i].flags,
hotlist_but[i].text,
hotlist_button_callback, 0,
hotlist_but[i].tkname));
} }
#undef XTRACT
/* We add the labels. /* We add the labels.
* pname will hold entry's pathname; * pname will hold entry's pathname;
* pname_group will hold name of current group * pname_group will hold name of current group
*/ */
pname = label_new (UY-11+LINES, UX+2, "", "the-lab"); pname = label_new (UY - 11 + LINES, UX + 2, "", "the-lab");
add_widget (hotlist_dlg, pname); add_widget (hotlist_dlg, pname);
if (!hotlist_state.moving) { if (!hotlist_state.moving) {
add_widget (hotlist_dlg, label_new (UY-12+LINES, UX+1, _(" Directory path "), NULL)); add_widget (hotlist_dlg,
label_new (UY - 12 + LINES, UX + 1,
_(" Directory path "), NULL));
/* This one holds the displayed pathname */ /* This one holds the displayed pathname */
pname_group = label_new (UY, UX+1, _(" Directory label "), NULL); pname_group = label_new (UY, UX + 1, _(" Directory label "), NULL);
add_widget (hotlist_dlg, pname_group); add_widget (hotlist_dlg, pname_group);
} }
/* get new listbox */ /* get new listbox */
l_hotlist = listbox_new (UY + 1, UX + 1, COLS-2*UX-8, LINES-14, listbox_cback, l_call, "listbox"); l_hotlist =
listbox_new (UY + 1, UX + 1, COLS - 2 * UX - 8, LINES - 14,
listbox_cback, l_call, "listbox");
/* Fill the hotlist with the active VFS or the hotlist */ /* Fill the hotlist with the active VFS or the hotlist */
#ifdef USE_VFS #ifdef USE_VFS
if (list_type == LIST_VFSLIST){ if (list_type == LIST_VFSLIST) {
listbox_add_item (l_hotlist, 0, 0, home_dir, 0); listbox_add_item (l_hotlist, 0, 0, home_dir, 0);
vfs_fill_names (add_name_to_list); vfs_fill_names (add_name_to_list);
} else } else
#endif /* !USE_VFS */ #endif /* !USE_VFS */
fill_listbox (); fill_listbox ();
add_widget (hotlist_dlg, l_hotlist); add_widget (hotlist_dlg, l_hotlist);
/* add listbox to the dialogs */ /* add listbox to the dialogs */
} }
static void init_movelist (int list_type, struct hotlist *item) static void
init_movelist (int list_type, struct hotlist *item)
{ {
int i; int i;
char *hdr = g_strdup_printf (_("Moving %s"), item->label); char *hdr = g_strdup_printf (_("Moving %s"), item->label);
@ -631,35 +649,37 @@ static void init_movelist (int list_type, struct hotlist *item)
do_refresh (); do_refresh ();
movelist_dlg = create_dlg (0, 0, LINES-6, movelist_cols, dialog_colors, movelist_dlg =
hotlist_callback, "[Hotlist]", create_dlg (0, 0, LINES - 6, movelist_cols, dialog_colors,
"movelist", hotlist_callback, "[Hotlist]", hdr, DLG_CENTER);
DLG_CENTER);
x_set_dialog_title (movelist_dlg, hdr);
g_free (hdr); g_free (hdr);
#define XTRACT(i) BY-4+hotlist_but[i].y, BX+hotlist_but[i].x, hotlist_but[i].ret_cmd, hotlist_but[i].flags, hotlist_but[i].text, hotlist_button_callback, 0, hotlist_but[i].tkname for (i = 0; i < BUTTONS; i++) {
for (i = 0; i < BUTTONS; i++){
if (hotlist_but[i].type & list_type) if (hotlist_but[i].type & list_type)
add_widget (movelist_dlg, button_new (XTRACT (i))); add_widget (movelist_dlg,
button_new (BY - 4 + hotlist_but[i].y,
BX + hotlist_but[i].x,
hotlist_but[i].ret_cmd,
hotlist_but[i].flags,
hotlist_but[i].text,
hotlist_button_callback, 0,
hotlist_but[i].tkname));
} }
#undef XTRACT
/* We add the labels. We are interested in the last one, /* We add the labels. We are interested in the last one,
* that one will hold the path name label * that one will hold the path name label
*/ */
movelist_group = label_new (UY, UX+1, _(" Directory label "), NULL); movelist_group = label_new (UY, UX + 1, _(" Directory label "), NULL);
add_widget (movelist_dlg, movelist_group); add_widget (movelist_dlg, movelist_group);
/* get new listbox */ /* get new listbox */
l_movelist = listbox_new (UY + 1, UX + 1, l_movelist =
movelist_dlg->cols - 2*UX - 2, movelist_dlg->lines - 8, listbox_new (UY + 1, UX + 1, movelist_dlg->cols - 2 * UX - 2,
listbox_cback, l_call, "listbox"); movelist_dlg->lines - 8, listbox_cback, l_call,
"listbox");
fill_listbox (); fill_listbox ();
add_widget (movelist_dlg, l_movelist); add_widget (movelist_dlg, l_movelist);
/* add listbox to the dialogs */ /* add listbox to the dialogs */
} }