* 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>
* 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;
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;
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;
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,
NORMAL_BUTTON, _("&Abort"), 0, 0, "abort"));
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))
static void
init_replace (FileOpContext *ctx, enum OperationMode mode)
init_replace (FileOpContext * ctx, enum OperationMode mode)
{
FileOpContextUI *ui;
char buffer [BUF_SMALL];
char buffer[BUF_SMALL];
char *title;
static int rd_xlen = 60, rd_trunc = X_TRUNC;
#ifdef ENABLE_NLS
static int i18n_flag;
if (!i18n_flag) {
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--)
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)
*/
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 */
i = sizeof (rd_widgets) / sizeof (rd_widgets [0]);
i = sizeof (rd_widgets) / sizeof (rd_widgets[0]);
for (row = l = l2 = 0; i--;) {
if (rd_widgets [i].value != 0) {
if (row != rd_widgets [i].ypos) {
row = rd_widgets [i].ypos;
if (rd_widgets[i].value != 0) {
if (row != rd_widgets[i].ypos) {
row = rd_widgets[i].ypos;
l2 = max (l2, l);
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_trunc = rd_xlen - 6;
/* Now place buttons */
l1 += 5; /* start of first button in the row */
i = sizeof (rd_widgets) / sizeof (rd_widgets [0]);
l1 += 5; /* start of first button in the row */
i = sizeof (rd_widgets) / sizeof (rd_widgets[0]);
for (l = l1, row = 0; --i > 1;) {
if (rd_widgets [i].value != 0) {
if (row != rd_widgets [i].ypos) {
row = rd_widgets [i].ypos;
if (rd_widgets[i].value != 0) {
if (row != rd_widgets[i].ypos) {
row = rd_widgets[i].ypos;
l = l1;
}
rd_widgets [i].xpos = l;
l += strlen (rd_widgets [i].text) + 4;
rd_widgets[i].xpos = l;
l += strlen (rd_widgets[i].text) + 4;
}
}
/* 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->replace_dlg = create_dlg (0, 0, 16, rd_xlen, alarm_colors, NULL,
"[ Replace ]", "replace", DLG_CENTER);
x_set_dialog_title (ui->replace_dlg,
(mode == Foreground
? _(" File exists ")
: _(" Background process: File exists ")));
if (mode == Foreground)
title = _(" File exists ");
else
title = _(" Background process: File exists ");
/* FIXME - missing help node */
ui->replace_dlg =
create_dlg (0, 0, 16, rd_xlen, alarm_colors, NULL, "[Replace]",
title, DLG_CENTER);
ADD_RD_LABEL(ui, 0,
name_trunc (ui->replace_filename, rd_trunc - strlen (rd_widgets [0].text)), 0);
ADD_RD_BUTTON(1);
ADD_RD_LABEL (ui, 0,
name_trunc (ui->replace_filename,
rd_trunc - strlen (rd_widgets[0].text)), 0);
ADD_RD_BUTTON (1);
ADD_RD_BUTTON(2);
ADD_RD_BUTTON(3);
ADD_RD_BUTTON(4);
ADD_RD_BUTTON(5);
ADD_RD_LABEL(ui, 6, 0, 0);
ADD_RD_BUTTON (2);
ADD_RD_BUTTON (3);
ADD_RD_BUTTON (4);
ADD_RD_BUTTON (5);
ADD_RD_LABEL (ui, 6, 0, 0);
/* "this target..." widgets */
if (!S_ISDIR (ui->d_stat->st_mode)){
if ((ui->d_stat->st_size && ui->s_stat->st_size > ui->d_stat->st_size))
ADD_RD_BUTTON(7);
if (!S_ISDIR (ui->d_stat->st_mode)) {
if ((ui->d_stat->st_size
&& 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(10);
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, 13, file_date (ui->s_stat->st_mtime), (int) ui->s_stat->st_size);
ADD_RD_BUTTON (9);
ADD_RD_BUTTON (10);
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, 13, file_date (ui->s_stat->st_mtime),
(int) ui->s_stat->st_size);
}
void

View File

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

View File

@ -568,62 +568,80 @@ init_i18n_stuff(int list_type, int cols)
return cols;
}
static void init_hotlist (int list_type)
static void
init_hotlist (int list_type)
{
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 ();
hotlist_state.expanded = GetPrivateProfileInt ("HotlistConfig",
"expanded_view_of_groups", 0, profile_name);
hotlist_state.expanded =
GetPrivateProfileInt ("HotlistConfig", "expanded_view_of_groups",
0, profile_name);
hotlist_dlg = create_dlg (0, 0, LINES-2, hotlist_cols, dialog_colors,
hotlist_callback,
list_type == LIST_VFSLIST ? "[vfshot]" : "[Hotlist]",
list_type == LIST_VFSLIST ? "vfshot" : "hotlist",
DLG_CENTER);
x_set_dialog_title (hotlist_dlg,
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
for (i = 0; i < BUTTONS; i++){
if (hotlist_but[i].type & list_type)
add_widget (hotlist_dlg, button_new (XTRACT (i)));
if (list_type == LIST_VFSLIST) {
title = _("Active VFS directories");
help_node = "[vfshot]"; /* FIXME - no such node */
} else {
title = _("Directory hotlist");
help_node = "[Hotlist]";
}
hotlist_dlg =
create_dlg (0, 0, LINES - 2, hotlist_cols, dialog_colors,
hotlist_callback, help_node, title, DLG_CENTER);
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.
* pname will hold entry's pathname;
* 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);
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 */
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);
}
/* 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 */
#ifdef USE_VFS
if (list_type == LIST_VFSLIST){
if (list_type == LIST_VFSLIST) {
listbox_add_item (l_hotlist, 0, 0, home_dir, 0);
vfs_fill_names (add_name_to_list);
} else
#endif /* !USE_VFS */
#endif /* !USE_VFS */
fill_listbox ();
add_widget (hotlist_dlg, l_hotlist);
add_widget (hotlist_dlg, l_hotlist);
/* 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;
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 ();
movelist_dlg = create_dlg (0, 0, LINES-6, movelist_cols, dialog_colors,
hotlist_callback, "[Hotlist]",
"movelist",
DLG_CENTER);
x_set_dialog_title (movelist_dlg, hdr);
movelist_dlg =
create_dlg (0, 0, LINES - 6, movelist_cols, dialog_colors,
hotlist_callback, "[Hotlist]", hdr, DLG_CENTER);
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)
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,
* 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);
/* get new listbox */
l_movelist = listbox_new (UY + 1, UX + 1,
movelist_dlg->cols - 2*UX - 2, movelist_dlg->lines - 8,
listbox_cback, l_call, "listbox");
l_movelist =
listbox_new (UY + 1, UX + 1, movelist_dlg->cols - 2 * UX - 2,
movelist_dlg->lines - 8, listbox_cback, l_call,
"listbox");
fill_listbox ();
add_widget (movelist_dlg, l_movelist);
add_widget (movelist_dlg, l_movelist);
/* add listbox to the dialogs */
}