Merge branch '2257_disabled_widget'

* 2257_disabled_widget:
  Visual improvements of 'Virtual File System Setting' dialog.
  Visual improvements of 'Configiration' dialog.
  Reimplemented 'Layout' dialog engine.
  Some reimplementation of "Listing mode" dialog.
  Updated EN and RU man pages.
  Added color for disabled widget.
  Improvements of QuickDialog engine.
  Added parameter to Wbutton callback to get the message sender easy.
  Added dlg_find_by_id() function.
  Ticket #2257: added capability to interactive enable/disable widgets.
This commit is contained in:
Andrew Borodin 2010-07-17 15:37:18 +04:00
commit 09ad9d04a9
33 changed files with 492 additions and 276 deletions

View File

@ -3460,7 +3460,7 @@ The format for the color definition is:
<keyword>=<foregroundcolor>,<backgroundcolor>:<keyword>= ...
.fi
.PP
The colors are optional, and the keywords are: normal, selected, marked,
The colors are optional, and the keywords are: normal, selected, disabled, marked,
markselect, errors, input, inputmark, inputunchanged, commandlinemark,
reverse, gauge. Menu colors are: menunormal,
menusel, menuhot, menuhotsel, menuinactive. Dialog colors are: dnormal, dfocus,
@ -3476,6 +3476,9 @@ determines the color of the filled part of the progress bar (gauge),
which is used to show the user the progress of file operations, such as
copying.
.PP
.I disabled
determines the color of the widget that cannot be selected.
.PP
The dialog boxes use the following colors:
.I dnormal
is used for the normal text,

View File

@ -1,6 +1,6 @@
.\"TOPICS "Разделы помощи:"
.\" TODO: Перевести раздел EXTernal File System
.TH MC "15 Июня 2010" "MC Version 4.7.3" "GNU Midnight Commander"
.TH MC "29 Июня 2010" "MC Version 4.7.4" "GNU Midnight Commander"
.\"SKIP_SECTION"
.SH "НАИМЕНОВАНИЕ"
mc \- Визуальная оболочка для Unix\-подобных систем.
@ -3731,7 +3731,7 @@ xterm=menu=magenta:marked=,magenta:markselect=,red
.PP
Цвета не являются обязательными, а в качестве ключевых слов (keywords)
могут использоваться: для задания цветовой палитры в панелях: normal,
selected, marked, markselect, errors, input, inputmark, inputunchanged,
selected, disabled, marked, markselect, errors, input, inputmark, inputunchanged,
commandlinemark, reverse, gauge. Цвета пунктов меню: menunormal, menusel,
menuhot, menuhotsel, menuinactive. Цвета в окне диалога: dnormal, dfocus,
dhotnormal, dhotfocus. Цвета в окне подсказки: helpnormal, helpitalic,
@ -3759,6 +3759,9 @@ special, core. Цвета в редакторе: editnormal, editbold, editmarke
определяет цвет заполненной части полоски (progress bar), при
графическом отображении хода выполнения файловых операций (копирование и
др.).
.I disabled
определяет цвет элемента диалога, который не может по каким-то причинам быть выбран
для работы с ним.
.PP
Диалоговые окна используют следующие цвета:
.I dnormal

View File

@ -1,5 +1,5 @@
#ifndef MC__SKIN_H
#define MC__SKIN_H
#ifndef MC_SKIN_H
#define MC_SKIN_H
#include "lib/global.h"
@ -18,72 +18,73 @@
#define MARKED_COLOR mc_skin_color__cache[2]
#define SELECTED_COLOR mc_skin_color__cache[3]
#define MARKED_SELECTED_COLOR mc_skin_color__cache[4]
#define REVERSE_COLOR mc_skin_color__cache[5]
#define COMMAND_MARK_COLOR mc_skin_color__cache[6]
#define DISABLED_COLOR mc_skin_color__cache[5]
#define REVERSE_COLOR mc_skin_color__cache[6]
#define COMMAND_MARK_COLOR mc_skin_color__cache[7]
/* Dialog colors */
#define COLOR_NORMAL mc_skin_color__cache[7]
#define COLOR_FOCUS mc_skin_color__cache[8]
#define COLOR_HOT_NORMAL mc_skin_color__cache[9]
#define COLOR_HOT_FOCUS mc_skin_color__cache[10]
#define COLOR_NORMAL mc_skin_color__cache[8]
#define COLOR_FOCUS mc_skin_color__cache[9]
#define COLOR_HOT_NORMAL mc_skin_color__cache[10]
#define COLOR_HOT_FOCUS mc_skin_color__cache[11]
/* Error dialog colors */
#define ERROR_COLOR mc_skin_color__cache[11]
#define ERROR_HOT_NORMAL mc_skin_color__cache[12]
#define ERROR_HOT_FOCUS mc_skin_color__cache[13]
#define ERROR_COLOR mc_skin_color__cache[12]
#define ERROR_HOT_NORMAL mc_skin_color__cache[13]
#define ERROR_HOT_FOCUS mc_skin_color__cache[14]
/* Menu colors */
#define MENU_ENTRY_COLOR mc_skin_color__cache[14]
#define MENU_SELECTED_COLOR mc_skin_color__cache[15]
#define MENU_HOT_COLOR mc_skin_color__cache[16]
#define MENU_HOTSEL_COLOR mc_skin_color__cache[17]
#define MENU_INACTIVE_COLOR mc_skin_color__cache[18]
#define MENU_ENTRY_COLOR mc_skin_color__cache[15]
#define MENU_SELECTED_COLOR mc_skin_color__cache[16]
#define MENU_HOT_COLOR mc_skin_color__cache[17]
#define MENU_HOTSEL_COLOR mc_skin_color__cache[18]
#define MENU_INACTIVE_COLOR mc_skin_color__cache[19]
/*
* This should be selectable independently. Default has to be black background
* foreground does not matter at all.
*/
#define GAUGE_COLOR mc_skin_color__cache[19]
#define INPUT_COLOR mc_skin_color__cache[20]
#define INPUT_UNCHANGED_COLOR mc_skin_color__cache[21]
#define INPUT_MARK_COLOR mc_skin_color__cache[22]
#define GAUGE_COLOR mc_skin_color__cache[20]
#define INPUT_COLOR mc_skin_color__cache[21]
#define INPUT_UNCHANGED_COLOR mc_skin_color__cache[22]
#define INPUT_MARK_COLOR mc_skin_color__cache[23]
#define HELP_NORMAL_COLOR mc_skin_color__cache[23]
#define HELP_ITALIC_COLOR mc_skin_color__cache[24]
#define HELP_BOLD_COLOR mc_skin_color__cache[25]
#define HELP_LINK_COLOR mc_skin_color__cache[26]
#define HELP_SLINK_COLOR mc_skin_color__cache[27]
#define HELP_NORMAL_COLOR mc_skin_color__cache[24]
#define HELP_ITALIC_COLOR mc_skin_color__cache[25]
#define HELP_BOLD_COLOR mc_skin_color__cache[26]
#define HELP_LINK_COLOR mc_skin_color__cache[27]
#define HELP_SLINK_COLOR mc_skin_color__cache[28]
#define VIEW_UNDERLINED_COLOR mc_skin_color__cache[28]
#define VIEW_UNDERLINED_COLOR mc_skin_color__cache[29]
/*
* editor colors - only 4 for normal, search->found, select, and whitespace
* respectively
* Last is defined to view color.
*/
#define EDITOR_NORMAL_COLOR mc_skin_color__cache[29]
#define EDITOR_BOLD_COLOR mc_skin_color__cache[30]
#define EDITOR_MARKED_COLOR mc_skin_color__cache[31]
#define EDITOR_WHITESPACE_COLOR mc_skin_color__cache[32]
#define EDITOR_RIGHT_MARGIN_COLOR mc_skin_color__cache[33]
#define EDITOR_NORMAL_COLOR mc_skin_color__cache[30]
#define EDITOR_BOLD_COLOR mc_skin_color__cache[31]
#define EDITOR_MARKED_COLOR mc_skin_color__cache[32]
#define EDITOR_WHITESPACE_COLOR mc_skin_color__cache[33]
#define EDITOR_RIGHT_MARGIN_COLOR mc_skin_color__cache[34]
/* color of left 8 char status per line */
#define LINE_STATE_COLOR mc_skin_color__cache[34]
#define BOOK_MARK_COLOR mc_skin_color__cache[35]
#define BOOK_MARK_FOUND_COLOR mc_skin_color__cache[36]
#define LINE_STATE_COLOR mc_skin_color__cache[35]
#define BOOK_MARK_COLOR mc_skin_color__cache[36]
#define BOOK_MARK_FOUND_COLOR mc_skin_color__cache[37]
#define BUTTONBAR_HOTKEY_COLOR mc_skin_color__cache[37]
#define BUTTONBAR_BUTTON_COLOR mc_skin_color__cache[38]
#define BUTTONBAR_HOTKEY_COLOR mc_skin_color__cache[38]
#define BUTTONBAR_BUTTON_COLOR mc_skin_color__cache[39]
/* Diff colors */
#define DFF_ADD_COLOR mc_skin_color__cache[39]
#define DFF_CHG_COLOR mc_skin_color__cache[40]
#define DFF_CHH_COLOR mc_skin_color__cache[41]
#define DFF_CHD_COLOR mc_skin_color__cache[42]
#define DFF_DEL_COLOR mc_skin_color__cache[43]
#define DFF_FOLDER_COLOR mc_skin_color__cache[44]
#define DFF_ERROR_COLOR mc_skin_color__cache[45]
#define DFF_ADD_COLOR mc_skin_color__cache[40]
#define DFF_CHG_COLOR mc_skin_color__cache[41]
#define DFF_CHH_COLOR mc_skin_color__cache[42]
#define DFF_CHD_COLOR mc_skin_color__cache[43]
#define DFF_DEL_COLOR mc_skin_color__cache[44]
#define DFF_FOLDER_COLOR mc_skin_color__cache[45]
#define DFF_ERROR_COLOR mc_skin_color__cache[46]
#define MC_SKIN_COLOR_CACHE_COUNT 46
#define MC_SKIN_COLOR_CACHE_COUNT 47
/*** enums ***************************************************************************************/
@ -112,5 +113,4 @@ void mc_skin_lines_parse_ini_file (mc_skin_t *);
gchar *mc_skin_get(const gchar *, const gchar *, const gchar *);
#endif
#endif /* MC_SKIN_H */

View File

@ -55,6 +55,7 @@ static const mc_skin_colors_old_t old_colors[] = {
{"marked", "core", "marked"},
{"selected", "core", "selected"},
{"markselect", "core", "markselect"},
{"disabled", "core", "disabled"},
{"reverse", "core", "reverse"},
{"dnormal", "dialog", "_default_"},
{"dfocus", "dialog", "dfocus"},

View File

@ -201,6 +201,7 @@ mc_skin_color_cache_init (void)
MARKED_COLOR = mc_skin_color_get ("core", "marked");
SELECTED_COLOR = mc_skin_color_get ("core", "selected");
MARKED_SELECTED_COLOR = mc_skin_color_get ("core", "markselect");
DISABLED_COLOR = mc_skin_color_get ("core", "disabled");
REVERSE_COLOR = mc_skin_color_get ("core", "reverse");
COMMAND_MARK_COLOR = mc_skin_color_get ("core", "commandlinemark");

View File

@ -54,6 +54,7 @@ mc_skin_hardcoded_blackwhite_colors (mc_skin_t * mc_skin)
mc_config_set_string (mc_skin->config, "core", "selected", "A_REVERSE");
mc_config_set_string (mc_skin->config, "core", "marked", "A_BOLD");
mc_config_set_string (mc_skin->config, "core", "markselect", "A_BOLD_REVERSE");
mc_config_set_string (mc_skin->config, "core", "disabled", "default");
mc_config_set_string (mc_skin->config, "core", "reverse", "A_REVERSE");
mc_config_set_string (mc_skin->config, "dialog", "_default_", "A_REVERSE");
mc_config_set_string (mc_skin->config, "dialog", "dfocus", "A_BOLD");

View File

@ -33,6 +33,7 @@
input=black;cyan
inputunchanged=gray;cyan
inputmark=cyan;black
disabled=gray;blue
reverse=black;lightgray
commandlinemark=black;lightgray

View File

@ -33,6 +33,7 @@
input=black;cyan
inputunchanged=gray;cyan
inputmark=cyan;black
disabled=gray;lightgray
reverse=black;lightgray
commandlinemark=black;lightgray

View File

@ -31,10 +31,11 @@
markselect=yellow;cyan
gauge=white;black
input=black;cyan
reverse=black;lightgray
inputunchanged=gray;cyan
inputmark=cyan;black
commandlinemark=black;lightgray
disabled=gray;lightgray
reverse=black;lightgray
[dialog]
_default_=black;lightgray

View File

@ -35,6 +35,7 @@
input=black;cyan
inputunchanged=gray;cyan
inputmark=cyan;black
disabled=gray;lightgray
reverse=black;lightgray
commandlinemark=black;lightgray

View File

@ -31,6 +31,7 @@
markselect=yellow;
gauge=;yellow
input=brightgreen;
disabled=gray;blue
reverse=brightgreen;blue
[dialog]

View File

@ -31,6 +31,7 @@
markselect=brown;blue
gauge=black;lightgray
input=lightgray;black
disabled=gray;darkgray
reverse=blue;black
[dialog]

View File

@ -325,7 +325,7 @@ mc_args_new_color_group (void)
_("--colors KEYWORD={FORE},{BACK}\n\n"
"{FORE} and {BACK} can be omitted, and the default will be used\n"
"\n" "Keywords:\n"
" Global: errors, reverse, gauge, viewunderline\n"
" Global: errors, disabled, reverse, gauge, viewunderline\n"
" input, inputmark, inputunchanged, commandlinemark\n"
" File display: normal, selected, marked, markselect\n"
" Dialog boxes: dnormal, dfocus, dhotnormal, dhotfocus, errdhotnormal,\n"

View File

@ -82,14 +82,6 @@ display_callback (Dlg_head * h, Widget * sender, dlg_msg_t msg, int parm, void *
{
switch (msg)
{
case DLG_UNFOCUS:
if (dlg_widget_active (display_radio))
{
assign_text (display_mini_status, displays_status[display_radio->sel]);
input_set_point (display_mini_status, 0);
}
return MSG_HANDLED;
case DLG_KEY:
if (parm == '\n')
{
@ -115,16 +107,44 @@ display_callback (Dlg_head * h, Widget * sender, dlg_msg_t msg, int parm, void *
}
}
if (g_ascii_tolower (parm) == display_user_hotkey && dlg_widget_active (display_user_format)
&& dlg_widget_active (display_mini_status))
if (g_ascii_tolower (parm) == display_user_hotkey)
{
display_radio->sel = 3;
display_radio->pos = display_radio->sel = 3;
dlg_select_widget (display_radio); /* force redraw */
dlg_select_widget (display_user_format);
h->callback (h, (Widget *) display_radio, DLG_ACTION, 0, NULL);
return MSG_HANDLED;
}
return MSG_NOT_HANDLED;
case DLG_ACTION:
if (sender == (Widget *) display_radio)
{
if (!(display_check_status->state & C_BOOL))
assign_text (display_mini_status, displays_status[display_radio->sel]);
update_input (display_mini_status, 0);
update_input (display_user_format, 0);
widget_disable (display_user_format->widget, display_radio->sel != 3);
return MSG_HANDLED;
}
if (sender == (Widget *) display_check_status)
{
if (display_check_status->state & C_BOOL)
{
widget_disable (display_mini_status->widget, FALSE);
assign_text (display_mini_status, displays_status[3]);
}
else
{
widget_disable (display_mini_status->widget, TRUE);
assign_text (display_mini_status, displays_status[display_radio->sel]);
}
update_input (display_mini_status, 0);
return MSG_HANDLED;
}
return MSG_NOT_HANDLED;
default:
return default_dlg_callback (h, sender, msg, parm, data);
}
@ -164,7 +184,7 @@ display_init (int radio_sel, char *init_text, int _check_status, char **_status)
{
int i, maxlen = 0;
const char *cp;
int ok_len, cancel_len;
int ok_len, cancel_len, b_len, gap;
#ifdef ENABLE_NLS
display_title = _(display_title);
@ -186,6 +206,7 @@ display_init (int radio_sel, char *init_text, int _check_status, char **_status)
ok_len = button_get_len (ok_button);
cancel_button = button_new (dlg_height - 3, 0, B_CANCEL, NORMAL_BUTTON, cancel_name, 0);
cancel_len = button_get_len (cancel_button);
b_len = ok_len + cancel_len + 2;
dlg_width = max (dlg_width, str_term_width1 (display_title) + 10);
/* calculate max width of radiobutons */
@ -195,9 +216,10 @@ display_init (int radio_sel, char *init_text, int _check_status, char **_status)
dlg_width = max (dlg_width, str_term_width1 (user_mini_status) + 13);
/* buttons */
dlg_width = max (dlg_width, ok_len + cancel_len + 8);
ok_button->widget.x = dlg_width / 3 - ok_len / 2;
cancel_button->widget.x = dlg_width * 2 / 3 - cancel_len / 2;
dlg_width = max (dlg_width, b_len + 6);
gap = (dlg_width - 6 - b_len) / 3;
ok_button->widget.x = 3 + gap;
cancel_button->widget.x = ok_button->widget.x + ok_len + gap + 2;
}
displays_status = _status;
@ -212,7 +234,6 @@ display_init (int radio_sel, char *init_text, int _check_status, char **_status)
display_mini_status = input_new (10, 8, (int *) input_colors, dlg_width - 12, _status[radio_sel],
"mini-input", INPUT_COMPLETE_DEFAULT);
add_widget (dd, display_mini_status);
input_set_point (display_mini_status, 0);
display_check_status = check_new (9, 4, _check_status, user_mini_status);
add_widget (dd, display_check_status);
@ -220,7 +241,6 @@ display_init (int radio_sel, char *init_text, int _check_status, char **_status)
display_user_format = input_new (7, 8, (int *) input_colors, dlg_width - 12, init_text,
"user-fmt-input", INPUT_COMPLETE_DEFAULT);
add_widget (dd, display_user_format);
input_set_point (display_user_format, 0);
display_radio = radio_new (3, 4, LIST_TYPES, displays);
display_radio->sel = display_radio->pos = radio_sel;
@ -321,7 +341,7 @@ sort_box (const panel_field_t * sort_format, int *reverse, int *case_sensitive,
QuickDialog quick_dlg = {
dlg_width, dlg_height, -1, -1,
N_("Sort order"), "[Sort Order...]",
quick_widgets, TRUE
quick_widgets, NULL, TRUE
};
quick_widgets[5].u.radio.items = sort_orders_names;
@ -449,7 +469,7 @@ confirm_box (void)
{
QuickDialog confirmation = {
dlg_width, dlg_height, -1, -1, title,
"[Confirmation]", conf_widgets, 1
"[Confirmation]", conf_widgets, NULL, TRUE
};
(void) quick_dialog (&confirmation);
@ -485,7 +505,7 @@ display_bits_box (void) /* AB:FIXME: test dialog */
QuickDialog display_bits = {
DISPX, DISPY, -1, -1, _("Display bits"),
"[Display bits]", display_widgets, TRUE
"[Display bits]", display_widgets, NULL, TRUE
};
int i;
@ -558,10 +578,11 @@ static WLabel *cplabel;
static WCheck *inpcheck;
static int
sel_charset_button (int action)
sel_charset_button (WButton *button, int action)
{
int new_dcp;
(void) button;
(void) action;
new_dcp = select_charset (-1, -1, new_display_codepage, TRUE);
@ -719,6 +740,32 @@ static char *ret_timeout;
static char *ret_passwd;
static char *ret_directory_timeout;
static char *ret_ftp_proxy;
static cb_ret_t
confvfs_callback (Dlg_head * h, Widget * sender, dlg_msg_t msg, int parm, void *data)
{
switch (msg)
{
case DLG_ACTION:
if (sender->id == 6)
{
/* message from "Always use ftp proxy" checkbutton */
const gboolean not_use = !(((WCheck *) sender)->state & C_BOOL);
Widget *w;
/* input */
w = dlg_find_by_id (h, sender->id - 1);
widget_disable (*w, not_use);
send_message (w, WIDGET_DRAW, 0);
return MSG_HANDLED;
}
return MSG_NOT_HANDLED;
default:
return default_dlg_callback (h, sender, msg, parm, data);
}
}
#endif
void
@ -766,12 +813,22 @@ configure_vfs (void)
QuickDialog confvfs_dlg = {
VFSX, VFSY, -1, -1, N_("Virtual File System Setting"),
"[Virtual FS]", confvfs_widgets, FALSE
"[Virtual FS]", confvfs_widgets,
#ifdef USE_NETCODE
confvfs_callback,
#else
NULL,
#endif
FALSE
};
#ifdef USE_NETCODE
g_snprintf (buffer3, sizeof (buffer3), "%i", ftpfs_directory_timeout);
if (!ftpfs_always_use_proxy)
confvfs_widgets[5].options = W_DISABLED;
#endif
g_snprintf (buffer2, sizeof (buffer2), "%i", vfs_timeout);
if (quick_dialog (&confvfs_dlg) != B_CANCEL)
@ -823,7 +880,7 @@ cd_dialog (void)
QuickDialog Quick_input = {
xlen, ylen, 2, LINES - 2 - ylen, _("Quick cd"),
"[Quick cd]", quick_widgets, TRUE
"[Quick cd]", quick_widgets, NULL, TRUE
};
return (quick_dialog (&Quick_input) != B_CANCEL) ? my_str : NULL;
@ -846,7 +903,7 @@ symlink_dialog (const char *existing, const char *new, char **ret_existing, char
QuickDialog Quick_input = {
64, 12, -1, -1, N_("Symbolic link"),
"[File Menu]", quick_widgets, FALSE
"[File Menu]", quick_widgets, NULL, FALSE
};
if (quick_dialog (&Quick_input) == B_CANCEL)
@ -890,12 +947,14 @@ jobs_fill_listbox (void)
}
static int
task_cb (int action)
task_cb (WButton *button, int action)
{
TaskList *tl;
int sig = 0;
if (!bg_list->list)
(void) button;
if (bg_list->list == NULL)
return 0;
/* Get this instance information */
@ -937,18 +996,16 @@ static struct
const char *name;
int xpos;
int value;
int (*callback) (int);
bcback callback;
}
job_buttons[] =
{
{
N_("&Stop"), 3, B_STOP, task_cb},
{
N_("&Resume"), 12, B_RESUME, task_cb},
{
N_("&Kill"), 23, B_KILL, task_cb},
{
N_("&OK"), 35, B_CANCEL, NULL}
/* *INDENT-OFF* */
{ N_("&Stop"), 3, B_STOP, task_cb },
{ N_("&Resume"), 12, B_RESUME, task_cb },
{ N_("&Kill"), 23, B_KILL, task_cb },
{ N_("&OK"), 35, B_CANCEL, NULL }
/* *INDENT-ON* */
};
void

View File

@ -613,7 +613,7 @@ select_unselect_cmd (const char *title, const char *history_name, gboolean do_se
QuickDialog quick_dlg = {
DX, DY, -1, -1, title,
"[Select/Unselect Files]", quick_widgets, FALSE
"[Select/Unselect Files]", quick_widgets, NULL, FALSE
};
if (quick_dialog (&quick_dlg) == B_CANCEL)

View File

@ -456,24 +456,39 @@ dlg_broadcast_msg (Dlg_head * h, widget_msg_t message, gboolean reverse)
int
dlg_focus (Dlg_head * h)
{
if ((h->current != NULL)
&& (send_message ((Widget *) h->current->data, WIDGET_FOCUS, 0) == MSG_HANDLED))
/* cannot focus disabled widget ... */
if (h->current != NULL)
{
h->callback (h, (Widget *) h->current->data, DLG_FOCUS, 0, NULL);
return 1;
Widget *current = (Widget *) h->current->data;
if (((current->options & W_DISABLED) == 0)
&& (send_message (current, WIDGET_FOCUS, 0) == MSG_HANDLED))
{
h->callback (h, current, DLG_FOCUS, 0, NULL);
return 1;
}
}
return 0;
}
static int
dlg_unfocus (Dlg_head * h)
{
if ((h->current != NULL)
&& (send_message ((Widget *) h->current->data, WIDGET_UNFOCUS, 0) == MSG_HANDLED))
/* ... but can unfocus disabled widget */
if (h->current != NULL)
{
h->callback (h, (Widget *) h->current->data, DLG_UNFOCUS, 0, NULL);
return 1;
Widget *current = (Widget *) h->current->data;
if (send_message (current, WIDGET_UNFOCUS, 0) == MSG_HANDLED)
{
h->callback (h, current, DLG_UNFOCUS, 0, NULL);
return 1;
}
}
return 0;
}
@ -505,21 +520,32 @@ find_widget_type (const Dlg_head * h, callback_fn callback)
return (w == NULL) ? NULL : (Widget *) w->data;
}
/* Find the widget with the given dialog id in the dialog h and select it */
void
dlg_select_by_id (const Dlg_head * h, unsigned int id)
/* Find the widget with the given id */
Widget *
dlg_find_by_id (const Dlg_head * h, unsigned int id)
{
if (h->widgets != NULL)
{
Widget *w_found;
GList *w;
w_found = (Widget *) g_list_nth_data (h->widgets, id);
if (w_found != NULL)
dlg_select_widget (w_found);
for (w = h->widgets; w != NULL; w = g_list_next (w))
if (((Widget *) w->data)->id == id)
return (Widget *) w->data;
}
return NULL;
}
/* Find the widget with the given id in the dialog h and select it */
void
dlg_select_by_id (const Dlg_head * h, unsigned int id)
{
Widget *w;
w = dlg_find_by_id (h, id);
if (w != NULL)
dlg_select_widget (w);
}
/* What to do if the requested widget doesn't take focus */
typedef enum
@ -566,7 +592,7 @@ do_select_widget (Dlg_head * h, GList * w, select_dir_t dir)
return;
}
}
while (h->current != w);
while (h->current != w /* && (((Widget *) h->current->data)->options & W_DISABLED) == 0 */);
if (dlg_overlap (w0, (Widget *) h->current->data))
{
@ -625,8 +651,12 @@ update_cursor (Dlg_head * h)
if (p != NULL)
{
if (((Widget *) (p->data))->options & W_WANT_CURSOR)
send_message ((Widget *) p->data, WIDGET_CURSOR, 0);
Widget *w;
w = (Widget *) p->data;
if (((w->options & W_DISABLED) == 0) && ((w->options & W_WANT_CURSOR) != 0))
send_message (w, WIDGET_CURSOR, 0);
else
do
{
@ -637,8 +667,10 @@ update_cursor (Dlg_head * h)
if (p == h->current)
break;
if (((Widget *) (p->data))->options & W_WANT_CURSOR)
if (send_message ((Widget *) p->data, WIDGET_CURSOR, 0) == MSG_HANDLED)
w = (Widget *) p->data;
if (((w->options & W_DISABLED) == 0) && ((w->options & W_WANT_CURSOR) != 0))
if (send_message (w, WIDGET_CURSOR, 0) == MSG_HANDLED)
break;
}
while (TRUE);
@ -781,7 +813,8 @@ dlg_mouse_event (Dlg_head * h, Gpm_Event * event)
if (item == NULL)
item = h->widgets;
if ((x > widget->x) && (x <= widget->x + widget->cols)
if (((widget->options & W_DISABLED) == 0)
&& (x > widget->x) && (x <= widget->x + widget->cols)
&& (y > widget->y) && (y <= widget->y + widget->lines))
{
new_event = *event;
@ -801,6 +834,7 @@ static cb_ret_t
dlg_try_hotkey (Dlg_head * h, int d_key)
{
GList *hot_cur;
Widget *current;
cb_ret_t handled;
int c;
@ -815,7 +849,12 @@ dlg_try_hotkey (Dlg_head * h, int d_key)
* the currently selected widget is an input line
*/
if (((Widget *) h->current->data)->options & W_IS_INPUT)
current = (Widget *) h->current->data;
if ((current->options & W_DISABLED) != 0)
return MSG_NOT_HANDLED;
if (current->options & W_IS_INPUT)
{
/* skip ascii control characters, anything else can valid character in
* some encoding */
@ -829,8 +868,8 @@ dlg_try_hotkey (Dlg_head * h, int d_key)
d_key = g_ascii_tolower (c);
handled = MSG_NOT_HANDLED;
if (((Widget *) h->current->data)->options & W_WANT_HOTKEY)
handled = send_message ((Widget *) h->current->data, WIDGET_HOTKEY, d_key);
if ((current->options & W_WANT_HOTKEY) != 0)
handled = send_message (current, WIDGET_HOTKEY, d_key);
/* If not used, send hotkey to other widgets */
if (handled == MSG_HANDLED)
@ -843,8 +882,10 @@ dlg_try_hotkey (Dlg_head * h, int d_key)
/* send it to all widgets */
while (h->current != hot_cur && handled == MSG_NOT_HANDLED)
{
if (((Widget *) hot_cur->data)->options & W_WANT_HOTKEY)
handled = send_message ((Widget *) hot_cur->data, WIDGET_HOTKEY, d_key);
current = (Widget *) hot_cur->data;
if ((current->options & W_WANT_HOTKEY) != 0)
handled = send_message (current, WIDGET_HOTKEY, d_key);
if (handled == MSG_NOT_HANDLED)
{

View File

@ -180,7 +180,8 @@ typedef enum
W_WANT_HOTKEY = (1 << 1),
W_WANT_CURSOR = (1 << 2),
W_WANT_IDLE = (1 << 3),
W_IS_INPUT = (1 << 4)
W_IS_INPUT = (1 << 4),
W_DISABLED = (1 << 5) /* Widget cannot be selected */
} widget_options_t;
/* Flags for widget repositioning on dialog resize */
@ -294,6 +295,7 @@ void dlg_one_up (Dlg_head * h);
void dlg_one_down (Dlg_head * h);
int dlg_focus (Dlg_head * h);
Widget *find_widget_type (const Dlg_head * h, callback_fn callback);
Widget *dlg_find_by_id (const Dlg_head * h, unsigned int id);
void dlg_select_by_id (const Dlg_head * h, unsigned int id);
/* Redraw all dialogs */
@ -301,10 +303,11 @@ void do_refresh (void);
/* Sets/clear the specified flag in the options field */
#define widget_option(w,f,i) \
w.options = ((i) ? (w.options | (f)) : (w.options & (~(f))))
w.options = ((i) ? ((w).options | (f)) : ((w).options & (~(f))))
#define widget_want_cursor(w,i) widget_option(w, W_WANT_CURSOR, i)
#define widget_want_hotkey(w,i) widget_option(w, W_WANT_HOTKEY, i)
#define widget_want_cursor(w,i) widget_option((w), W_WANT_CURSOR, (i))
#define widget_want_hotkey(w,i) widget_option((w), W_WANT_HOTKEY, (i))
#define widget_disable(w,i) widget_option((w), W_DISABLED, (i))
/* Used in load_prompt() */
void update_cursor (Dlg_head * h);

View File

@ -135,9 +135,9 @@ mcdiffview_dialog_search (WDiff * dview)
};
QuickDialog search_input = {
SEARCH_DLG_WIDTH, SEARCH_DLG_HEIGHT, -1, 0,
SEARCH_DLG_WIDTH, SEARCH_DLG_HEIGHT, -1, -1,
N_("Search"), "[Input Line Keys]",
search_widgets, 0
search_widgets, NULL, FALSE
};
mcdiffview_dialog_fix_buttons_positions (&search_input);

View File

@ -2421,7 +2421,7 @@ dview_diff_options (WDiff * dview)
QuickDialog diffopt = {
OPTX, OPTY, -1, -1,
N_("Diff Options"), "[Diff Options]",
diffopt_widgets, 0
diffopt_widgets, NULL, FALSE
};
if (quick_dialog (&diffopt) != B_CANCEL)

View File

@ -457,7 +457,7 @@ menu_save_mode_cmd (void)
QuickDialog dialog = {
DLG_X, DLG_Y, -1, -1, N_("Edit Save Mode"),
"[Edit Save Mode]", widgets, FALSE
"[Edit Save Mode]", widgets, NULL, FALSE
};
size_t i;
@ -556,7 +556,7 @@ edit_get_save_file_as (WEdit * edit)
QuickDialog Quick_options = {
DLG_WIDTH, DLG_HEIGHT, -1, -1,
N_("Save As"), "[Save File As]",
quick_widgets, FALSE
quick_widgets, NULL, FALSE
};
if (quick_dialog (&Quick_options) != B_CANCEL)
@ -2671,7 +2671,7 @@ edit_mail_dialog (WEdit * edit)
QuickDialog Quick_input = {
50, MAIL_DLG_HEIGHT, -1, -1, N_("Mail"),
"[Input Line Keys]", quick_widgets, FALSE
"[Input Line Keys]", quick_widgets, NULL, FALSE
};
quick_widgets[2].u.input.text = mail_cc_last ? mail_cc_last : "";

View File

@ -138,7 +138,7 @@ editcmd_dialog_replace_show (WEdit * edit, const char *search_default, const cha
QuickDialog Quick_input = {
REPLACE_DLG_WIDTH, REPLACE_DLG_HEIGHT, -1, -1, N_("Replace"),
"[Input Line Keys]", quick_widgets, FALSE
"[Input Line Keys]", quick_widgets, NULL, FALSE
};
if (quick_dialog (&Quick_input) != B_CANCEL)
@ -218,7 +218,7 @@ editcmd_dialog_search_show (WEdit * edit, char **search_text)
QuickDialog Quick_input = {
SEARCH_DLG_WIDTH, SEARCH_DLG_HEIGHT, -1, -1, N_("Search"),
"[Input Line Keys]", quick_widgets, TRUE
"[Input Line Keys]", quick_widgets, NULL, TRUE
};
#ifdef ENABLE_NLS
@ -612,7 +612,7 @@ editcmd_dialog_replace_prompt_show (WEdit * edit, char *from_text, char *to_text
{
QuickDialog Quick_input = {
dlg_width, dlg_height, 0, 0, N_("Confirm replace"),
"[Input Line Keys]", quick_widgets, FALSE
"[Input Line Keys]", quick_widgets, NULL, FALSE
};
/* Sometimes menu can hide replaced text. I don't like it */

View File

@ -107,7 +107,7 @@ edit_options_dialog (WEdit * edit)
QuickDialog Quick_options = {
OPT_DLG_W, OPT_DLG_H, -1, -1, N_("Editor options"),
"[Editor options]", quick_widgets, FALSE
"[Editor options]", quick_widgets, NULL, FALSE
};
#ifdef ENABLE_NLS

View File

@ -1042,7 +1042,7 @@ file_mask_dialog (FileOpContext * ctx, FileOperation operation,
QuickDialog Quick_input = {
fmd_xlen, FMDY, -1, -1, op_names[operation],
"[Mask Copy/Rename]", fmd_widgets, TRUE
"[Mask Copy/Rename]", fmd_widgets, NULL, TRUE
};
ask_file_mask:

View File

@ -1142,9 +1142,10 @@ find_callback (struct Dlg_head *h, Widget * sender, dlg_msg_t msg, int parm, voi
/* Handles the Stop/Start button in the find window */
static int
start_stop (int button)
start_stop (WButton *button, int action)
{
(void) button;
(void) action;
running = is_start;
set_idle_proc (find_dlg, running);
@ -1158,9 +1159,10 @@ start_stop (int button)
/* Handle view command, when invoked as a button */
static int
find_do_view_file (int button)
find_do_view_file (WButton *button, int action)
{
(void) button;
(void) action;
view_edit_currently_selected_file (0, 0);
return 0;
@ -1168,9 +1170,10 @@ find_do_view_file (int button)
/* Handle edit command, when invoked as a button */
static int
find_do_edit_file (int button)
find_do_edit_file (WButton *button, int action)
{
(void) button;
(void) action;
view_edit_currently_selected_file (0, 1);
return 0;
@ -1236,17 +1239,17 @@ setup_gui (void)
button_new (FIND2_Y - 3, fbuts[6].x, B_VIEW, NORMAL_BUTTON,
fbuts[6].text, find_do_view_file));
add_widget (find_dlg,
button_new (FIND2_Y - 3, fbuts[5].x, B_PANELIZE, NORMAL_BUTTON, fbuts[5].text, 0));
button_new (FIND2_Y - 3, fbuts[5].x, B_PANELIZE, NORMAL_BUTTON, fbuts[5].text, NULL));
add_widget (find_dlg,
button_new (FIND2_Y - 4, fbuts[4].x, B_CANCEL, NORMAL_BUTTON, fbuts[4].text, 0));
button_new (FIND2_Y - 4, fbuts[4].x, B_CANCEL, NORMAL_BUTTON, fbuts[4].text, NULL));
stop_button =
button_new (FIND2_Y - 4, fbuts[0].x, B_STOP, NORMAL_BUTTON, fbuts[0].text, start_stop);
add_widget (find_dlg, stop_button);
add_widget (find_dlg,
button_new (FIND2_Y - 4, fbuts[3].x, B_AGAIN, NORMAL_BUTTON, fbuts[3].text, 0));
button_new (FIND2_Y - 4, fbuts[3].x, B_AGAIN, NORMAL_BUTTON, fbuts[3].text, NULL));
add_widget (find_dlg,
button_new (FIND2_Y - 4, fbuts[2].x, B_ENTER, DEFPUSH_BUTTON, fbuts[2].text, 0));
button_new (FIND2_Y - 4, fbuts[2].x, B_ENTER, DEFPUSH_BUTTON, fbuts[2].text, NULL));
status_label = label_new (FIND2_Y - 7, 4, _("Searching"));
add_widget (find_dlg, status_label);

View File

@ -306,8 +306,10 @@ add_name_to_list (const char *path)
#endif /* !ENABLE_VFS */
static int
hotlist_button_callback (int action)
hotlist_button_callback (WButton *button, int action)
{
(void) button;
switch (action)
{
case B_MOVE:
@ -463,7 +465,7 @@ hotlist_handle_key (Dlg_head * h, int key)
case '\n':
case KEY_ENTER:
case KEY_RIGHT:
if (hotlist_button_callback (B_ENTER))
if (hotlist_button_callback (NULL, B_ENTER))
{
h->ret_value = B_ENTER;
dlg_stop (h);
@ -472,7 +474,7 @@ hotlist_handle_key (Dlg_head * h, int key)
case KEY_LEFT:
if (hotlist_state.type != LIST_VFSLIST)
return !hotlist_button_callback (B_UP_GROUP);
return !hotlist_button_callback (NULL, B_UP_GROUP);
else
return MSG_NOT_HANDLED;
@ -481,7 +483,7 @@ hotlist_handle_key (Dlg_head * h, int key)
return MSG_NOT_HANDLED;
else
{
hotlist_button_callback (B_REMOVE);
hotlist_button_callback (NULL, B_REMOVE);
return MSG_HANDLED;
}
@ -574,7 +576,7 @@ l_call (WListbox * list)
}
else
{
hotlist_button_callback (B_ENTER);
hotlist_button_callback (NULL, B_ENTER);
hotlist_callback (dlg, NULL, DLG_POST_KEY, '\n', NULL);
return LISTBOX_CONT;
}
@ -587,7 +589,7 @@ l_call (WListbox * list)
}
}
hotlist_button_callback (B_UP_GROUP);
hotlist_button_callback (NULL, B_UP_GROUP);
hotlist_callback (dlg, NULL, DLG_POST_KEY, 'u', NULL);
return LISTBOX_CONT;
}
@ -971,7 +973,7 @@ add_new_entry_input (const char *header, const char *text1, const char *text2,
{
QuickDialog Quick_input = {
len, lines1 + lines2 + 7, -1, -1, header,
help, quick_widgets, FALSE
help, quick_widgets, NULL, FALSE
};
for (i = 0; i < 7; i++)
@ -1058,7 +1060,7 @@ add_new_group_input (const char *header, const char *label, char **result)
{
QuickDialog Quick_input = {
len, lines + 6, -1, -1, header,
"[Hotlist]", quick_widgets, FALSE
"[Hotlist]", quick_widgets, NULL, FALSE
};
int relative_y[] = { 1, 1, 1, 0, 2 }; /* the relative_x component from the

View File

@ -158,8 +158,6 @@ static int height;
#define B_PLUS (B_USER + 2)
#define B_MINUS (B_USER + 3)
static Dlg_head *layout_dlg;
static const char *s_split_direction[2] = {
N_("&Vertical"),
N_("&Horizontal")
@ -190,12 +188,12 @@ static struct
#define OTHER_OPTIONS_COUNT (LAYOUT_OPTIONS_COUNT - 1)
static gsize first_width;
static const char *output_lines_label = 0;
static const char *output_lines_label = NULL;
static int output_lines_label_len;
static WButton *bleft_widget, *bright_widget;
static void
static inline void
_check_split (void)
{
if (_horizontal_split)
@ -216,69 +214,51 @@ _check_split (void)
else if (_first_panel_size > COLS - MINWIDTH)
_first_panel_size = COLS - MINWIDTH;
}
old_first_panel_size = _first_panel_size;
old_horizontal_split = _horizontal_split;
}
static void
update_split (void)
update_split (const Dlg_head *h)
{
/* Check split has to be done before testing if it changed, since
it can change due to calling _check_split() as well */
_check_split ();
/* To avoid setting the cursor to the wrong place */
if ((old_first_panel_size == _first_panel_size) && (old_horizontal_split == _horizontal_split))
return;
tty_setcolor (check_options[7].widget->state & C_BOOL ? DISABLED_COLOR : COLOR_NORMAL);
old_first_panel_size = _first_panel_size;
old_horizontal_split = _horizontal_split;
tty_setcolor (COLOR_NORMAL);
dlg_move (layout_dlg, 6, 6);
dlg_move (h, 6, 6);
tty_printf ("%03d", _first_panel_size);
dlg_move (layout_dlg, 6, 18);
dlg_move (h, 6, 18);
if (_horizontal_split)
tty_printf ("%03d", height - _first_panel_size);
else
tty_printf ("%03d", COLS - _first_panel_size);
dlg_move (h, 6, 13);
tty_print_char ('=');
}
static int
b2left_cback (int action)
b_left_right_cback (WButton *button, int action)
{
(void) action;
if (_equal_split)
{
/* Turn equal split off */
_equal_split = 0;
check_options[7].widget->state = check_options[7].widget->state & ~C_BOOL;
dlg_select_widget (check_options[7].widget);
dlg_select_widget (bleft_widget);
}
_first_panel_size++;
if (button == bleft_widget)
_first_panel_size++;
else
_first_panel_size--;
update_split (button->widget.owner);
return 0;
}
static int
b2right_cback (int action)
{
(void) action;
if (_equal_split)
{
/* Turn equal split off */
_equal_split = 0;
check_options[7].widget->state = check_options[7].widget->state & ~C_BOOL;
dlg_select_widget (check_options[7].widget);
dlg_select_widget (bright_widget);
}
_first_panel_size--;
return 0;
}
static int
bplus_cback (int action)
bplus_cback (WButton *button, int action)
{
(void) button;
(void) action;
if (_output_lines < 99)
@ -287,8 +267,9 @@ bplus_cback (int action)
}
static int
bminus_cback (int action)
bminus_cback (WButton *button, int action)
{
(void) button;
(void) action;
if (_output_lines > 0)
@ -310,32 +291,27 @@ layout_callback (Dlg_head * h, Widget * sender, dlg_msg_t msg, int parm, void *d
old_horizontal_split = -1;
old_output_lines = -1;
tty_setcolor (COLOR_HOT_NORMAL);
update_split ();
dlg_move (h, 6, 13);
tty_print_char ('=');
if (console_flag)
update_split (h);
if (old_output_lines != _output_lines)
{
if (old_output_lines != _output_lines)
{
old_output_lines = _output_lines;
tty_setcolor (COLOR_NORMAL);
dlg_move (h, 9, 6);
tty_print_string (output_lines_label);
dlg_move (h, 9, 6 + 3 + output_lines_label_len);
tty_printf ("%02d", _output_lines);
}
old_output_lines = _output_lines;
tty_setcolor (console_flag ? COLOR_NORMAL : DISABLED_COLOR);
dlg_move (h, 9, 6);
tty_print_string (output_lines_label);
dlg_move (h, 9, 6 + 3 + output_lines_label_len);
tty_printf ("%02d", _output_lines);
}
return MSG_HANDLED;
case DLG_POST_KEY:
_equal_split = check_options[7].widget->state & C_BOOL;
_menubar_visible = check_options[6].widget->state & C_BOOL;
_command_prompt = check_options[5].widget->state & C_BOOL;
_keybar_visible = check_options[3].widget->state & C_BOOL;
_message_visible = check_options[2].widget->state & C_BOOL;
_xterm_title = check_options[1].widget->state & C_BOOL;
_free_space = check_options[0].widget->state & C_BOOL;
if (console_flag)
{
int minimum;
@ -351,40 +327,63 @@ layout_callback (Dlg_head * h, Widget * sender, dlg_msg_t msg, int parm, void *d
}
}
else
{
height = LINES - _keybar_visible - _command_prompt -
_menubar_visible - _output_lines - _message_visible;
}
if (_horizontal_split != radio_widget->sel)
if (old_output_lines != _output_lines)
{
_horizontal_split = radio_widget->sel;
if (_horizontal_split)
_first_panel_size = height / 2;
else
_first_panel_size = COLS / 2;
}
update_split ();
if (console_flag)
{
if (old_output_lines != _output_lines)
{
old_output_lines = _output_lines;
tty_setcolor (COLOR_NORMAL);
dlg_move (h, 9, 6 + 3 + output_lines_label_len);
tty_printf ("%02d", _output_lines);
}
old_output_lines = _output_lines;
tty_setcolor (console_flag ? COLOR_NORMAL : DISABLED_COLOR);
dlg_move (h, 9, 6 + 3 + output_lines_label_len);
tty_printf ("%02d", _output_lines);
}
return MSG_HANDLED;
case DLG_ACTION:
if (sender == (Widget *) radio_widget)
{
if (_horizontal_split != radio_widget->sel)
{
_horizontal_split = radio_widget->sel;
if (_equal_split)
{
if (_horizontal_split)
_first_panel_size = height / 2;
else
_first_panel_size = COLS / 2;
}
}
update_split (h);
return MSG_HANDLED;
}
if (sender == (Widget *) check_options[7].widget)
{
_equal_split = check_options[7].widget->state & C_BOOL;
widget_disable (bleft_widget->widget, _equal_split);
send_message ((Widget *) bleft_widget, WIDGET_DRAW, 0);
widget_disable (bright_widget->widget, _equal_split);
send_message ((Widget *) bright_widget, WIDGET_DRAW, 0);
update_split (h);
return MSG_HANDLED;
}
return MSG_NOT_HANDLED;
default:
return default_dlg_callback (h, sender, msg, parm, data);
}
}
static void
static Dlg_head *
init_layout (void)
{
static int i18n_layt_flag = 0;
static gboolean i18n_layt_flag = FALSE;
static int b1, b2, b3;
size_t i = sizeof (s_split_direction) / sizeof (char *);
const char *ok_button = _("&OK");
@ -392,6 +391,8 @@ init_layout (void)
const char *save_button = _("&Save");
static const char *title1, *title2, *title3;
Dlg_head *layout_dlg;
if (!i18n_layt_flag)
{
gsize l1;
@ -427,13 +428,10 @@ init_layout (void)
if (l1 > first_width)
first_width = l1;
if (console_flag)
{
output_lines_label_len = str_term_width1 (output_lines_label);
l1 = output_lines_label_len + 12;
if (l1 > first_width)
first_width = l1;
}
output_lines_label_len = str_term_width1 (output_lines_label);
l1 = output_lines_label_len + 12;
if (l1 > first_width)
first_width = l1;
/*
* alex@bcs.zp.ua:
@ -453,7 +451,7 @@ init_layout (void)
b2 = b1 + str_term_width1 (ok_button) + i + 6;
b3 = b2 + str_term_width1 (save_button) + i + 4;
i18n_layt_flag = 1;
i18n_layt_flag = TRUE;
}
layout_dlg =
@ -485,21 +483,30 @@ init_layout (void)
_xterm_title = xterm_title;
_free_space = free_space;
if (console_flag)
{
add_widget (layout_dlg, groupbox_new (8, 4, 3, first_width, title2));
const int disabled = console_flag ? 0 : W_DISABLED;
Widget *w;
add_widget (layout_dlg,
button_new (9, output_lines_label_len + 6 + 5, B_MINUS,
NARROW_BUTTON, "&-", bminus_cback));
add_widget (layout_dlg,
button_new (9, output_lines_label_len + 6, B_PLUS,
NARROW_BUTTON, "&+", bplus_cback));
w = (Widget *) groupbox_new (8, 4, 3, first_width, title2);
w->options |= disabled;
add_widget (layout_dlg, w);
w = (Widget *) button_new (9, output_lines_label_len + 6 + 5, B_MINUS,
NARROW_BUTTON, "&-", bminus_cback);
w->options |= disabled;
add_widget (layout_dlg, w);
w = (Widget *) button_new (9, output_lines_label_len + 6, B_PLUS,
NARROW_BUTTON, "&+", bplus_cback);
w->options |= disabled;
add_widget (layout_dlg, w);
}
bright_widget = button_new (6, 15, B_2RIGHT, NARROW_BUTTON, "&>", b2right_cback);
bright_widget = button_new (6, 15, B_2RIGHT, NARROW_BUTTON, "&>", b_left_right_cback);
widget_disable (bright_widget->widget, _equal_split);
add_widget (layout_dlg, bright_widget);
bleft_widget = button_new (6, 9, B_2LEFT, NARROW_BUTTON, "&<", b2left_cback);
bleft_widget = button_new (6, 9, B_2LEFT, NARROW_BUTTON, "&<", b_left_right_cback);
widget_disable (bleft_widget->widget, _equal_split);
add_widget (layout_dlg, bleft_widget);
check_options[7].widget = check_new (5, 6, XTRACT (7));
@ -514,6 +521,8 @@ init_layout (void)
radio_widget = radio_new (3, 6, 2, s_split_direction);
add_widget (layout_dlg, radio_widget);
radio_widget->sel = horizontal_split;
return layout_dlg;
}
void
@ -531,23 +540,23 @@ layout_change (void)
void
layout_box (void)
{
Dlg_head *layout_dlg;
int result;
size_t i;
int layout_do_change = 0;
gboolean layout_do_change = FALSE;
init_layout ();
run_dlg (layout_dlg);
result = layout_dlg->ret_value;
layout_dlg = init_layout ();
result = run_dlg (layout_dlg);
if (result == B_ENTER || result == B_EXIT)
{
size_t i;
for (i = 0; i < (size_t) LAYOUT_OPTIONS_COUNT; i++)
if (check_options[i].widget != NULL)
*check_options[i].variable = check_options[i].widget->state & C_BOOL;
horizontal_split = radio_widget->sel;
first_panel_size = _first_panel_size;
output_lines = _output_lines;
layout_do_change = 1;
layout_do_change = TRUE;
}
if (result == B_EXIT)
{

View File

@ -63,8 +63,10 @@ static struct {
int ret_cmd, flags, y, x;
const char *text;
} learn_but[BUTTONS] = {
/* *INDENT-OFF */
{ B_CANCEL, NORMAL_BUTTON, 0, 39, N_("&Cancel") },
{ B_ENTER, DEFPUSH_BUTTON, 0, 25, N_("&Save") }
/* *INDENT-ON */
};
static Dlg_head *learn_dlg;
@ -81,10 +83,14 @@ static int learnchanged;
static const char* learn_title = N_("Learn keys");
static int learn_button (int action)
static int learn_button (WButton *button, int action)
{
Dlg_head *d;
char *seq;
Dlg_head *d = create_message (D_ERROR, _("Teach me a key"),
(void) button;
d = create_message (D_ERROR, _("Teach me a key"),
_("Please press the %s\n"
"and then wait until this message disappears.\n\n"
"Then, press it again to see if OK appears\n"

View File

@ -37,6 +37,7 @@
#include "lib/tty/key.h" /* old_esc_mode_timeout */
#include "dialog.h" /* B_ constants */
#include "widget.h" /* WCheck */
#include "setup.h" /* panels_options */
#include "main.h"
#include "file.h" /* file_op_compute_totals */
@ -46,6 +47,36 @@
#include "option.h"
static cb_ret_t
configure_callback (Dlg_head * h, Widget * sender, dlg_msg_t msg, int parm, void *data)
{
switch (msg)
{
case DLG_ACTION:
if (sender->id == 18)
{
/* message from "Single press" checkbutton */
const gboolean not_single = !(((WCheck *) sender)->state & C_BOOL);
Widget *w;
/* label */
w = dlg_find_by_id (h, sender->id - 1);
widget_disable (*w, not_single);
send_message (w, WIDGET_DRAW, 0);
/* input */
w = dlg_find_by_id (h, sender->id - 2);
widget_disable (*w, not_single);
send_message (w, WIDGET_DRAW, 0);
return MSG_HANDLED;
}
return MSG_NOT_HANDLED;
default:
return default_dlg_callback (h, sender, msg, parm, data);
}
}
void
configure_box (void)
{
@ -118,7 +149,7 @@ configure_box (void)
QuickDialog Quick_input = {
dlg_width, dlg_height, -1, -1,
N_("Configure options"), "[Configuration]",
quick_widgets, TRUE
quick_widgets, configure_callback, TRUE
};
int qd_result;
@ -211,6 +242,9 @@ configure_box (void)
g_snprintf (time_out, sizeof (time_out), "%d", old_esc_mode_timeout);
if (!old_esc_mode)
quick_widgets[16].options = quick_widgets[17].options = W_DISABLED;
qd_result = quick_dialog (&Quick_input);
if ((qd_result == B_ENTER) || (qd_result == B_EXIT))
@ -290,7 +324,7 @@ panel_options_box (void)
QuickDialog Quick_input = {
dlg_width, dlg_height, -1, -1,
N_("Panel options"), "[Panel options]",
quick_widgets, TRUE
quick_widgets, NULL, TRUE
};
int qd_result;

View File

@ -112,7 +112,7 @@ mcview_dialog_search (mcview_t * view)
QuickDialog Quick_input = {
SEARCH_DLG_WIDTH, SEARCH_DLG_HEIGHT, -1, -1,
N_("Search"), "[Input Line Keys]",
quick_widgets, FALSE
quick_widgets, NULL, FALSE
};
qd_result = quick_dialog (&Quick_input);
@ -201,7 +201,7 @@ mcview_dialog_goto (mcview_t * view, off_t * offset)
QuickDialog Quick_input = {
goto_dlg_width, goto_dlg_height, -1, -1,
N_("Goto"), "[Input Line Keys]",
quick_widgets, FALSE
quick_widgets, NULL, FALSE
};
#ifdef ENABLE_NLS

View File

@ -67,11 +67,26 @@ static void
widget_selectcolor (Widget * w, gboolean focused, gboolean hotkey)
{
Dlg_head *h = w->owner;
int color;
tty_setcolor (hotkey
? (focused
? DLG_HOT_FOCUSC (h)
: DLG_HOT_NORMALC (h)) : (focused ? DLG_FOCUSC (h) : DLG_NORMALC (h)));
if ((w->options & W_DISABLED) != 0)
color = DISABLED_COLOR;
else if (hotkey)
{
if (focused)
color = DLG_HOT_FOCUSC (h);
else
color = DLG_HOT_NORMALC (h);
}
else
{
if (focused)
color = DLG_FOCUSC (h);
else
color = DLG_NORMALC (h);
}
tty_setcolor (color);
}
struct hotkey_t
@ -211,7 +226,7 @@ button_callback (Widget * w, widget_msg_t msg, int parm)
return MSG_NOT_HANDLED;
if (b->callback)
stop = (*b->callback) (b->action);
stop = (*b->callback) (b, b->action);
if (!b->callback || stop)
{
h->ret_value = b->action;
@ -741,14 +756,15 @@ label_callback (Widget * w, widget_msg_t msg, int parm)
{
char *p = l->text, *q, c = 0;
int y = 0;
gboolean disabled = (w->options & W_DISABLED) != 0;
if (!l->text)
return MSG_HANDLED;
if (l->transparent)
tty_setcolor (DEFAULT_COLOR);
tty_setcolor (disabled ? DISABLED_COLOR : DEFAULT_COLOR);
else
tty_setcolor (DLG_NORMALC (h));
tty_setcolor (disabled ? DISABLED_COLOR : DLG_NORMALC (h));
for (;;)
{
@ -1022,20 +1038,22 @@ static void
draw_history_button (WInput * in)
{
char c;
gboolean disabled = (((Widget *) in)->options & W_DISABLED) != 0;
c = in->history->next ? (in->history->prev ? '|' : 'v') : '^';
widget_move (&in->widget, 0, in->field_width - HISTORY_BUTTON_WIDTH);
#ifdef LARGE_HISTORY_BUTTON
{
Dlg_head *h;
h = in->widget.owner;
tty_setcolor (NORMAL_COLOR);
tty_setcolor (disabled ? DISABLED_COLOR : NORMAL_COLOR);
tty_print_string ("[ ]");
/* Too distracting: tty_setcolor (MARKED_COLOR); */
widget_move (&in->widget, 0, in->field_width - HISTORY_BUTTON_WIDTH + 1);
tty_print_char (c);
}
#else
tty_setcolor (MARKED_COLOR);
tty_setcolor (disabled ? DISABLED_COLOR : MARKED_COLOR);
tty_print_char (c);
#endif
}
@ -1134,7 +1152,9 @@ update_input (WInput * in, int clear_first)
if (has_history)
draw_history_button (in);
if (in->first)
if ((((Widget *) in)->options & W_DISABLED) != 0)
tty_setcolor (DISABLED_COLOR);
else if (in->first)
tty_setcolor (in->unchanged_color);
else
tty_setcolor (in->color);
@ -2440,8 +2460,9 @@ static void
listbox_draw (WListbox * l, gboolean focused)
{
const Dlg_head *h = l->widget.owner;
const int normalc = DLG_NORMALC (h);
int selc = focused ? DLG_HOT_FOCUSC (h) : DLG_FOCUSC (h);
const gboolean disabled = (((Widget *) l)->options & W_DISABLED) != 0;
const int normalc = disabled ? DISABLED_COLOR : DLG_NORMALC (h);
int selc = disabled ? DISABLED_COLOR : focused ? DLG_HOT_FOCUSC (h) : DLG_FOCUSC (h);
GList *le;
int pos;
@ -3121,7 +3142,12 @@ buttonbar_callback (Widget * w, widget_msg_t msg, int parm)
break;
tty_setcolor (BUTTONBAR_HOTKEY_COLOR);
tty_printf ("%2d", i + 1);
/* don't show num of undefined button */
if ((bb->labels[i].text == NULL) || (bb->labels[i].text[0] == '\0'))
tty_print_string (" ");
else
tty_printf ("%2d", i + 1);
tty_setcolor (BUTTONBAR_BUTTON_COLOR);
text = (bb->labels[i].text != NULL) ? bb->labels[i].text : "";
tty_print_string (str_fit_to_term (text, width - 2, J_LEFT_FIT));
@ -3233,15 +3259,18 @@ groupbox_callback (Widget * w, widget_msg_t msg, int parm)
return MSG_NOT_HANDLED;
case WIDGET_DRAW:
tty_setcolor (COLOR_NORMAL);
{
gboolean disabled = (w->options & W_DISABLED) != 0;
tty_setcolor (disabled ? DISABLED_COLOR : COLOR_NORMAL);
draw_box (g->widget.owner, g->widget.y - g->widget.owner->y,
g->widget.x - g->widget.owner->x, g->widget.lines, g->widget.cols, TRUE);
tty_setcolor (COLOR_HOT_NORMAL);
tty_setcolor (disabled ? DISABLED_COLOR : COLOR_HOT_NORMAL);
dlg_move (g->widget.owner, g->widget.y - g->widget.owner->y,
g->widget.x - g->widget.owner->x + 1);
tty_print_string (g->title);
return MSG_HANDLED;
}
case WIDGET_DESTROY:
g_free (g->title);

View File

@ -30,7 +30,8 @@ typedef enum {
/* widget variable of type Widget. We abuse this fact everywhere */
/* button callback */
typedef int (*bcback) (int);
struct WButton;
typedef int (*bcback) (struct WButton *button, int action);
/* structure for label (caption) with hotkey, if original text does not contain
* hotkey, only start is valid and is equal to original text

View File

@ -385,11 +385,11 @@ quick_dialog_skip (QuickDialog * qd, int nskip)
if ((qd->xpos == -1) || (qd->ypos == -1))
dd = create_dlg (TRUE, 0, 0, qd->ylen, qd->xlen,
dialog_colors, NULL, qd->help, qd->title,
dialog_colors, qd->callback, qd->help, qd->title,
DLG_CENTER | DLG_TRYUP | DLG_REVERSE);
else
dd = create_dlg (TRUE, qd->ypos, qd->xpos, qd->ylen, qd->xlen,
dialog_colors, NULL, qd->help, qd->title, DLG_REVERSE);
dialog_colors, qd->callback, qd->help, qd->title, DLG_REVERSE);
for (qw = qd->widgets; qw->widget_type != quick_end; qw++)
{
@ -464,11 +464,19 @@ quick_dialog_skip (QuickDialog * qd, int nskip)
break;
}
add_widget (dd, qw->widget);
if (qw->widget != NULL)
{
qw->widget->options |= qw->options; /* FIXME: cannot reset flags, setup only */
add_widget (dd, qw->widget);
}
}
while (nskip-- != 0)
dd->current = dd->current->next;
{
dd->current = g_list_next (dd->current);
if (dd->current == NULL)
dd->current = dd->widgets;
}
return_val = run_dlg (dd);
@ -592,7 +600,7 @@ fg_input_dialog_help (const char *header, const char *text, const char *help,
{
QuickDialog Quick_input = {
len, lines + 6, -1, -1, header,
help, quick_widgets, TRUE
help, quick_widgets, NULL, TRUE
};
for (i = 0; i < 4; i++)

View File

@ -48,6 +48,7 @@ typedef struct
int y_divisions;
Widget *widget;
widget_options_t options;
/* widget parameters */
union
@ -103,6 +104,7 @@ typedef struct
.relative_y = y, \
.y_divisions = ydiv, \
.widget = NULL, \
.options = 0, \
.u = { \
.checkbox = { \
.text = txt, \
@ -119,6 +121,7 @@ typedef struct
.relative_y = y, \
.y_divisions = ydiv, \
.widget = NULL, \
.options = 0, \
.u = { \
.button = { \
.text = txt, \
@ -136,6 +139,7 @@ typedef struct
.relative_y = y, \
.y_divisions = ydiv, \
.widget = NULL, \
.options = 0, \
.u = { \
.input = { \
.text = txt, \
@ -155,6 +159,7 @@ typedef struct
.relative_y = y, \
.y_divisions = ydiv, \
.widget = NULL, \
.options = 0, \
.u = { \
.label = { \
.text = txt \
@ -170,6 +175,7 @@ typedef struct
.relative_y = y, \
.y_divisions = ydiv, \
.widget = NULL, \
.options = 0, \
.u = { \
.radio = { \
.count = cnt, \
@ -187,6 +193,7 @@ typedef struct
.relative_y = y, \
.y_divisions = ydiv, \
.widget = NULL, \
.options = 0, \
.u = { \
.groupbox = { \
.width = w, \
@ -196,7 +203,6 @@ typedef struct
} \
}
#define QUICK_END \
{ \
.widget_type = quick_end, \
@ -205,6 +211,7 @@ typedef struct
.relative_y = 0, \
.y_divisions = 0, \
.widget = NULL, \
.options = 0, \
.u = { \
.input = { \
.text = NULL, \
@ -223,6 +230,7 @@ typedef struct
const char *title;
const char *help;
QuickWidget *widgets;
dlg_cb_fn callback;
gboolean i18n; /* If true, internationalization has happened */
} QuickDialog;