Added modal flag to the dialog structure.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
This commit is contained in:
Andrew Borodin 2009-11-19 11:34:20 +03:00
parent 5c9826a897
commit 74651f2e9f
24 changed files with 51 additions and 39 deletions

View File

@ -264,7 +264,7 @@ do_enter_key (Dlg_head * h, int f_pos)
chl_end = 0;
chl_dlg =
create_dlg (lyy, lxx, 13, 17, dialog_colors, chl_callback,
create_dlg (TRUE, lyy, lxx, 13, 17, dialog_colors, chl_callback,
"[Advanced Chown]", title, DLG_COMPACT | DLG_REVERSE);
/* get new listboxes */
@ -581,7 +581,7 @@ init_chown_advanced (void)
x_toggle = 070;
ch_dlg =
create_dlg (0, 0, dlg_h, dlg_w, dialog_colors, advanced_chown_callback,
create_dlg (TRUE, 0, 0, dlg_h, dlg_w, dialog_colors, advanced_chown_callback,
"[Advanced Chown]", _("Chown advanced command"),
DLG_CENTER | DLG_REVERSE);

View File

@ -202,7 +202,7 @@ display_init (int radio_sel, char *init_text, int _check_status, char **_status)
displays_status = _status;
dd = create_dlg (0, 0, dlg_height, dlg_width, dialog_colors,
dd = create_dlg (TRUE, 0, 0, dlg_height, dlg_width, dialog_colors,
display_callback, "[Listing Mode...]", display_title,
DLG_CENTER | DLG_REVERSE);
@ -597,7 +597,7 @@ init_disp_bits_box (void)
do_refresh ();
dbits_dlg =
create_dlg (0, 0, DISPY, DISPX, dialog_colors, NULL,
create_dlg (TRUE, 0, 0, DISPY, DISPX, dialog_colors, NULL,
"[Display bits]", _("Display bits"), DLG_CENTER | DLG_REVERSE);
add_widget (dbits_dlg, label_new (3, 4, _("Input / display codepage:")));
@ -691,7 +691,7 @@ tree_box (const char *current_dir)
(void) current_dir;
/* Create the components */
dlg = create_dlg (0, 0, LINES - 9, COLS - 20, dialog_colors,
dlg = create_dlg (TRUE, 0, 0, LINES - 9, COLS - 20, dialog_colors,
tree_callback, "[Directory Tree]",
_("Directory tree"), DLG_CENTER | DLG_REVERSE);
@ -983,7 +983,7 @@ jobs_cmd (void)
}
#endif /* ENABLE_NLS */
jobs_dlg = create_dlg (0, 0, JOBS_Y, JOBS_X, dialog_colors, NULL,
jobs_dlg = create_dlg (TRUE, 0, 0, JOBS_Y, JOBS_X, dialog_colors, NULL,
"[Background jobs]", _("Background Jobs"), DLG_CENTER | DLG_REVERSE);
bg_list = listbox_new (2, 3, JOBS_Y - 9, JOBS_X - 7, FALSE, NULL);
@ -1074,7 +1074,7 @@ vfs_smb_get_authinfo (const char *host, const char *share, const char *domain, c
title = g_strdup_printf (_("Password for \\\\%s\\%s"), host, share);
auth_dlg = create_dlg (0, 0, dialog_y, dialog_x, dialog_colors, NULL,
auth_dlg = create_dlg (TRUE, 0, 0, dialog_y, dialog_x, dialog_colors, NULL,
"[Smb Authinfo]", title, DLG_CENTER | DLG_REVERSE);
g_free (title);

View File

@ -207,7 +207,7 @@ init_chmod (void)
single_set = (current_panel->marked < 2) ? 2 : 0;
ch_dlg =
create_dlg (0, 0, 22 - single_set, 70, dialog_colors,
create_dlg (TRUE, 0, 0, 22 - single_set, 70, dialog_colors,
chmod_callback, "[Chmod]", _("Chmod command"), DLG_CENTER | DLG_REVERSE);
for (i = 0; i < BUTTONS; i++)

View File

@ -154,7 +154,7 @@ init_chown (void)
single_set = (current_panel->marked < 2) ? 3 : 0;
ch_dlg =
create_dlg (0, 0, 18, 74, dialog_colors, chown_callback, "[Chown]",
create_dlg (TRUE, 0, 0, 18, 74, dialog_colors, chown_callback, "[Chown]",
_("Chown command"), DLG_CENTER | DLG_REVERSE);
for (i = 0; i < BUTTONS - single_set; i++)

View File

@ -1236,7 +1236,7 @@ complete_engine (WInput * in, int what_to_do)
min_end = end;
query_height = h;
query_width = w;
query_dlg = create_dlg (y, x, query_height, query_width,
query_dlg = create_dlg (TRUE, y, x, query_height, query_width,
dialog_colors, query_callback,
"[Completion]", NULL, DLG_COMPACT);
query_list = listbox_new (1, 1, h - 2, w - 2, FALSE, NULL);

View File

@ -258,12 +258,14 @@ default_dlg_callback (Dlg_head * h, Widget * sender, dlg_msg_t msg, int parm, vo
}
Dlg_head *
create_dlg (int y1, int x1, int lines, int cols, const int *colors,
dlg_cb_fn callback, const char *help_ctx, const char *title, dlg_flags_t flags)
create_dlg (gboolean modal, int y1, int x1, int lines, int cols,
const int *colors, dlg_cb_fn callback, const char *help_ctx,
const char *title, dlg_flags_t flags)
{
Dlg_head *new_d;
new_d = g_new0 (Dlg_head, 1);
new_d->modal = modal;
if (colors != NULL)
{
new_d->color = g_new (int, DLG_COLOR_NUM);
@ -880,6 +882,9 @@ dlg_key_event (Dlg_head * h, int d_key)
void
init_dlg (Dlg_head * h)
{
if ((top_dlg != NULL) && ((Dlg_head *) top_dlg->data)->modal)
h->modal = TRUE;
/* add dialog to the stack */
current_dlg = g_list_prepend (current_dlg, h);

View File

@ -25,7 +25,7 @@
#include "lib/global.h"
#include "lib/tty/mouse.h"
#include "lib/util.h" /* Hook */
#include "lib/util.h" /* Hook */
/* Common return values */
#define B_EXIT 0
@ -127,6 +127,7 @@ typedef char *(*dlg_shortcut_str) (unsigned long command);
struct Dlg_head
{
/* Set by the user */
gboolean modal; /* type of dialog: modal or not */
dlg_flags_t flags; /* User flags */
const char *help_ctx; /* Name of the help entry */
int *color; /* Color set. Unused in viewer and editor */
@ -199,7 +200,7 @@ struct Widget
void draw_box (Dlg_head * h, int y, int x, int ys, int xs, gboolean single);
/* Creates a dialog head */
Dlg_head *create_dlg (int y1, int x1, int lines, int cols,
Dlg_head *create_dlg (gboolean modal, int y1, int x1, int lines, int cols,
const int *colors, dlg_cb_fn callback,
const char *help_ctx, const char *title, dlg_flags_t flags);

View File

@ -2748,6 +2748,8 @@ dview_redo (WDiff * dview)
static void
dview_edit (WDiff * dview, int ord)
{
Dlg_head *h;
gboolean h_modal;
int linenum, lineofs;
if (dview->dsrc == DATA_SRC_TMP)
@ -2756,8 +2758,13 @@ dview_edit (WDiff * dview, int ord)
return;
}
h = ((Widget *) dview)->owner;
h_modal = h->modal;
get_line_numbers (dview->a[ord], dview->skip_rows, &linenum, &lineofs);
h->modal = TRUE; /* not allow edit file in several editors */
do_edit_at_line (dview->file[ord], linenum);
h->modal = h_modal;
dview_redo (dview);
dview_update (dview);
}
@ -3229,7 +3236,7 @@ diff_view (const char *file1, const char *file2, const char *label1, const char
/* Create dialog and widgets, put them on the dialog */
dview_dlg =
create_dlg (0, 0, LINES, COLS, NULL, dview_dialog_callback,
create_dlg (FALSE, 0, 0, LINES, COLS, NULL, dview_dialog_callback,
"[Diff Viewer]", NULL, DLG_WANT_TAB);
dview = g_new0 (WDiff, 1);

View File

@ -320,7 +320,7 @@ editcmd_dialog_raw_key_query (const char *heading, const char *query, int cancel
};
struct Dlg_head *raw_dlg =
create_dlg (0, 0, 7, w, dialog_colors, editcmd_dialog_raw_key_query_cb,
create_dlg (TRUE, 0, 0, 7, w, dialog_colors, editcmd_dialog_raw_key_query_cb,
NULL, heading, DLG_CENTER | DLG_TRYUP | DLG_WANT_TAB);
add_widget (raw_dlg, input_new (3 - cancel, w - 5, (int *) input_colors,
2, "", 0, INPUT_COMPLETE_DEFAULT));
@ -376,7 +376,7 @@ editcmd_dialog_completion_show (WEdit * edit, int max_len, int word_len,
/* create the dialog */
compl_dlg =
create_dlg (start_y, start_x, compl_dlg_h, compl_dlg_w,
create_dlg (TRUE, start_y, start_x, compl_dlg_h, compl_dlg_w,
dialog_colors, NULL, "[Completion]", NULL, DLG_COMPACT);
/* create the listbox */
@ -464,7 +464,7 @@ editcmd_dialog_select_definition_show (WEdit * edit, char *match_expr, int max_l
start_y -= (offset + 1);
/* create the dialog */
def_dlg = create_dlg (start_y, start_x, def_dlg_h, def_dlg_w,
def_dlg = create_dlg (TRUE, start_y, start_x, def_dlg_h, def_dlg_w,
dialog_colors, NULL, "[Definitions]", match_expr, DLG_COMPACT);
/* create the listbox */

View File

@ -263,7 +263,7 @@ edit_file (const char *_file, int line)
/* Create a new dialog and add it widgets to it */
edit_dlg =
create_dlg (0, 0, LINES, COLS, NULL, edit_dialog_callback,
create_dlg (FALSE, 0, 0, LINES, COLS, NULL, edit_dialog_callback,
"[Internal File Editor]", NULL, DLG_WANT_TAB);
edit_dlg->get_shortcut = edit_get_shortcut;

View File

@ -1570,7 +1570,7 @@ compute_dir_size_create_ui (void)
ui = g_new (ComputeDirSizeUI, 1);
ui->dlg = create_dlg (0, 0, 8, COLS / 2, dialog_colors, NULL,
ui->dlg = create_dlg (TRUE, 0, 0, 8, COLS / 2, dialog_colors, NULL,
NULL, _("Directory scanning"), DLG_CENTER);
ui->dirname = label_new (3, 3, "");
add_widget (ui->dlg, ui->dirname);

View File

@ -298,7 +298,7 @@ file_op_context_create_ui_without_init (FileOpContext * ctx, gboolean with_eta,
ui->showing_bps = with_eta;
ui->op_dlg =
create_dlg (0, 0, WY - minus + 1 + total_reserve, dlg_width,
create_dlg (TRUE, 0, 0, WY - minus + 1 + total_reserve, dlg_width,
dialog_colors, NULL, NULL, op_names[ctx->operation], DLG_CENTER | DLG_REVERSE);
last_hint_line = the_hint->widget.y;
@ -777,7 +777,7 @@ overwrite_query_dialog (FileOpContext * ctx, enum OperationMode mode)
/* FIXME - missing help node */
ui->replace_dlg =
create_dlg (0, 0, rd_ylen, rd_xlen, alarm_colors, NULL, "[Replace]",
create_dlg (TRUE, 0, 0, rd_ylen, rd_xlen, alarm_colors, NULL, "[Replace]",
title, DLG_CENTER | DLG_REVERSE);
/* prompt -- centered */

View File

@ -425,7 +425,7 @@ find_parameters (char **start_dir, char **pattern, char **content)
find_par_start:
find_dlg =
create_dlg (0, 0, FIND_Y, FIND_X, dialog_colors,
create_dlg (TRUE, 0, 0, FIND_Y, FIND_X, dialog_colors,
find_parm_callback, "[Find File]", _("Find File"), DLG_CENTER | DLG_REVERSE);
add_widget (find_dlg,
@ -1226,7 +1226,7 @@ setup_gui (void)
}
find_dlg =
create_dlg (0, 0, FIND2_Y, FIND2_X, dialog_colors, find_callback,
create_dlg (TRUE, 0, 0, FIND2_Y, FIND2_X, dialog_colors, find_callback,
"[Find File]", _("Find File"), DLG_CENTER | DLG_REVERSE);
add_widget (find_dlg,

View File

@ -1027,7 +1027,7 @@ interactive_display (const char *filename, const char *node)
help_lines = min (LINES - 4, max (2 * LINES / 3, 18));
whelp =
create_dlg (0, 0, help_lines + 4, HELP_WINDOW_WIDTH + 4,
create_dlg (TRUE, 0, 0, help_lines + 4, HELP_WINDOW_WIDTH + 4,
help_colors, help_callback, "[Help]", _("Help"),
DLG_TRYUP | DLG_CENTER | DLG_WANT_TAB);

View File

@ -699,7 +699,7 @@ init_hotlist (int list_type)
}
hotlist_dlg =
create_dlg (0, 0, LINES - 2, hotlist_cols, dialog_colors,
create_dlg (TRUE, 0, 0, LINES - 2, hotlist_cols, dialog_colors,
hotlist_callback, help_node, title, DLG_CENTER | DLG_REVERSE);
for (i = 0; i < BUTTONS; i++)
@ -761,7 +761,7 @@ init_movelist (int list_type, struct hotlist *item)
do_refresh ();
movelist_dlg =
create_dlg (0, 0, LINES - 6, movelist_cols, dialog_colors,
create_dlg (TRUE, 0, 0, LINES - 6, movelist_cols, dialog_colors,
hotlist_callback, "[Hotlist]", hdr, DLG_CENTER | DLG_REVERSE);
g_free (hdr);

View File

@ -456,7 +456,7 @@ init_layout (void)
}
layout_dlg =
create_dlg (0, 0, 14, first_width * 2 + 9,
create_dlg (TRUE, 0, 0, 14, first_width * 2 + 9,
dialog_colors, layout_callback, "[Layout]",
_("Layout"), DLG_CENTER | DLG_REVERSE);

View File

@ -252,7 +252,7 @@ init_learn (void)
do_refresh ();
learn_dlg =
create_dlg (0, 0, 23, 78, dialog_colors, learn_callback,
create_dlg (TRUE, 0, 0, 23, 78, dialog_colors, learn_callback,
"[Learn keys]", learn_title, DLG_CENTER | DLG_REVERSE);
for (i = 0; i < BUTTONS; i++)

View File

@ -171,7 +171,7 @@ init_listmode (char *oldlistformat)
do_refresh ();
listmode_dlg =
create_dlg (0, 0, 22, 74, dialog_colors, NULL, listmode_section,
create_dlg (TRUE, 0, 0, 22, 74, dialog_colors, NULL, listmode_section,
"Listing format edit", DLG_CENTER | DLG_REVERSE);
add_widget (listmode_dlg,

View File

@ -1898,7 +1898,7 @@ do_nc (void)
panel_init ();
midnight_dlg = create_dlg (0, 0, LINES, COLS, midnight_colors, midnight_callback,
midnight_dlg = create_dlg (FALSE, 0, 0, LINES, COLS, midnight_colors, midnight_callback,
"[main]", NULL, DLG_WANT_IDLE);
if (mc_run_mode == MC_RUN_FULL)

View File

@ -46,7 +46,6 @@
#include "option.h"
void
configure_box (void)
{

View File

@ -171,7 +171,7 @@ init_panelize (void)
do_refresh ();
panelize_dlg =
create_dlg (0, 0, 22, panelize_cols, dialog_colors,
create_dlg (TRUE, 0, 0, 22, panelize_cols, dialog_colors,
panelize_callback, "[External panelize]",
_("External panelize"), DLG_CENTER | DLG_REVERSE);

View File

@ -245,7 +245,7 @@ mcview_viewer (const char *command, const char *file, int *move_dir_p, int start
Dlg_head *view_dlg;
/* Create dialog and widgets, put them on the dialog */
view_dlg = create_dlg (0, 0, LINES, COLS, NULL, mcview_dialog_callback,
view_dlg = create_dlg (FALSE, 0, 0, LINES, COLS, NULL, mcview_dialog_callback,
"[Internal File Viewer]", NULL, DLG_WANT_TAB);
lc_mcview = mcview_new (0, 0, LINES - 1, COLS, FALSE);

View File

@ -1419,7 +1419,7 @@ show_hist (GList ** history, Widget * widget)
hist_data.maxlen = maxlen;
query_dlg =
create_dlg (0, 0, 4, 4, dialog_colors, dlg_hist_callback,
create_dlg (TRUE, 0, 0, 4, 4, dialog_colors, dlg_hist_callback,
"[History-query]", i18n_htitle (), DLG_COMPACT);
query_dlg->data = &hist_data;

View File

@ -97,7 +97,7 @@ create_listbox_window_centered (int center_y, int center_x, int lines, int cols,
listbox = g_new (Listbox, 1);
listbox->dlg =
create_dlg (ypos, xpos, lines + space, cols + space,
create_dlg (TRUE, ypos, xpos, lines + space, cols + space,
listbox_colors, NULL,
help, title, DLG_REVERSE | DLG_TRYUP);
@ -188,7 +188,7 @@ query_dialog (const char *header, const char *text, int flags, int count, ...)
/* prepare dialog */
query_dlg =
create_dlg (0, 0, lines, cols, query_colors, default_query_callback,
create_dlg (TRUE, 0, 0, lines, cols, query_colors, default_query_callback,
"[QueryBox]", header, DLG_NONE);
if (count > 0) {
@ -377,11 +377,11 @@ quick_dialog_skip (QuickDialog *qd, int nskip)
I18N (qd->title);
if ((qd->xpos == -1) || (qd->ypos == -1))
dd = create_dlg (0, 0, qd->ylen, qd->xlen,
dd = create_dlg (TRUE, 0, 0, qd->ylen, qd->xlen,
dialog_colors, NULL, qd->help, qd->title,
DLG_CENTER | DLG_TRYUP | DLG_REVERSE);
else
dd = create_dlg (qd->ypos, qd->xpos, qd->ylen, qd->xlen,
dd = create_dlg (TRUE, qd->ypos, qd->xpos, qd->ylen, qd->xlen,
dialog_colors, NULL, qd->help, qd->title,
DLG_REVERSE);