mirror of
https://github.com/MidnightCommander/mc
synced 2024-12-23 04:46:55 +03:00
Merge branch '3632_widget_flags'
* 3632_widget_flags: Reorganize WDialog flags. (dlg_set_position): minor refactoring. Rename DLG_WANT_TAB to WOP_WANT_TAB and move it to widget_options_t. By default, WOP_WANT_HOTKEY option is off. If widget wants cursor, define that explicitly. Add WST_MODAL state. WOP_TOP_SELECT: new widget option Join widget_state_t and dlg_state_t. Move WOP_WANT_IDLE option to widget_state_t flags Move WOP_DISABLED option to widget_state_t flags widget_state_t: new type. (widget_get_options): new widget API. Change prefix of widget options: W_ -> WOP_. Ticket #3632: refactoring of widget flags.
This commit is contained in:
commit
61c379b964
@ -213,6 +213,7 @@ button_new (int y, int x, int action, button_flags_t flags, const char *text, bc
|
||||
widget_init (w, y, x, 1, button_get_len (b), button_callback, button_mouse_callback);
|
||||
b->selected = FALSE;
|
||||
b->callback = callback;
|
||||
widget_want_cursor (w, TRUE);
|
||||
widget_want_hotkey (w, TRUE);
|
||||
b->hotpos = (b->text.hotkey != NULL) ? str_term_width1 (b->text.start) : -1;
|
||||
|
||||
|
@ -253,7 +253,6 @@ buttonbar_new (gboolean visible)
|
||||
w->pos_flags = WPOS_KEEP_HORZ | WPOS_KEEP_BOTTOM;
|
||||
bb->visible = visible;
|
||||
widget_want_hotkey (w, TRUE);
|
||||
widget_want_cursor (w, FALSE);
|
||||
|
||||
return bb;
|
||||
}
|
||||
|
@ -140,6 +140,7 @@ check_new (int y, int x, int state, const char *text)
|
||||
/* 4 is width of "[X] " */
|
||||
widget_init (w, y, x, 1, 4 + hotkey_width (c->text), check_callback, check_mouse_callback);
|
||||
c->state = state ? C_BOOL : 0;
|
||||
widget_want_cursor (w, TRUE);
|
||||
widget_want_hotkey (w, TRUE);
|
||||
|
||||
return c;
|
||||
|
@ -72,7 +72,7 @@ dialog_switch_suspend (void *data, void *user_data)
|
||||
(void) user_data;
|
||||
|
||||
if (data != mc_current->data)
|
||||
DIALOG (data)->state = DLG_SUSPENDED;
|
||||
widget_set_state (WIDGET (data), WST_SUSPENDED, TRUE);
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
@ -95,7 +95,7 @@ dialog_switch_goto (GList * dlg)
|
||||
else
|
||||
{
|
||||
/* switch from editor, viewer, etc to another dialog */
|
||||
old->state = DLG_SUSPENDED;
|
||||
widget_set_state (WIDGET (old), WST_SUSPENDED, TRUE);
|
||||
|
||||
if (DIALOG (dlg->data) != midnight_dlg)
|
||||
/* switch to another editor, viewer, etc */
|
||||
@ -104,7 +104,7 @@ dialog_switch_goto (GList * dlg)
|
||||
else
|
||||
{
|
||||
/* switch to panels */
|
||||
midnight_dlg->state = DLG_ACTIVE;
|
||||
widget_set_state (WIDGET (midnight_dlg), WST_ACTIVE, TRUE);
|
||||
do_refresh ();
|
||||
}
|
||||
}
|
||||
@ -119,7 +119,8 @@ dlg_resize_cb (void *data, void *user_data)
|
||||
WDialog *d = data;
|
||||
|
||||
(void) user_data;
|
||||
if (d->state == DLG_ACTIVE)
|
||||
|
||||
if (widget_get_state (WIDGET (d), WST_ACTIVE))
|
||||
send_message (d, NULL, MSG_RESIZE, 0, NULL);
|
||||
else
|
||||
d->winch_pending = TRUE;
|
||||
@ -170,7 +171,7 @@ dialog_switch_remove (WDialog * h)
|
||||
|
||||
/* resume forced the current screen */
|
||||
if (mc_current != NULL)
|
||||
DIALOG (mc_current->data)->state = DLG_ACTIVE;
|
||||
widget_set_state (WIDGET (mc_current->data), WST_ACTIVE, TRUE);
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
@ -273,11 +274,12 @@ dialog_switch_process_pending (void)
|
||||
while (dialog_switch_pending)
|
||||
{
|
||||
WDialog *h = DIALOG (mc_current->data);
|
||||
Widget *wh = WIDGET (h);
|
||||
|
||||
dialog_switch_pending = FALSE;
|
||||
h->state = DLG_SUSPENDED;
|
||||
widget_set_state (wh, WST_SUSPENDED, TRUE);
|
||||
ret = dlg_run (h);
|
||||
if (h->state == DLG_CLOSED)
|
||||
if (widget_get_state (wh, WST_CLOSED))
|
||||
{
|
||||
dlg_destroy (h);
|
||||
|
||||
|
@ -119,7 +119,7 @@ dlg_widget_prev (WDialog * h, GList * l)
|
||||
*/
|
||||
|
||||
static void
|
||||
dlg_broadcast_msg_to (WDialog * h, widget_msg_t msg, gboolean reverse, int flags)
|
||||
dlg_broadcast_msg_to (WDialog * h, widget_msg_t msg, gboolean reverse, widget_options_t flags)
|
||||
{
|
||||
GList *p, *first;
|
||||
|
||||
@ -182,14 +182,20 @@ static gboolean
|
||||
dlg_unfocus (WDialog * h)
|
||||
{
|
||||
/* we can unfocus disabled widget */
|
||||
if ((h->current != NULL) && (h->state == DLG_CONSTRUCT || h->state == DLG_ACTIVE))
|
||||
if (h->current != NULL)
|
||||
{
|
||||
Widget *current = WIDGET (h->current->data);
|
||||
Widget *wh = WIDGET (h);
|
||||
|
||||
if (send_message (current, NULL, MSG_UNFOCUS, 0, NULL) == MSG_HANDLED)
|
||||
if (widget_get_state (wh, WST_CONSTRUCT) || widget_get_state (wh, WST_ACTIVE))
|
||||
{
|
||||
send_message (h, current, MSG_UNFOCUS, 0, NULL);
|
||||
return TRUE;
|
||||
Widget *current = WIDGET (h->current->data);
|
||||
|
||||
if (send_message (current, NULL, MSG_UNFOCUS, 0, NULL) == MSG_HANDLED)
|
||||
{
|
||||
send_message (h, current, MSG_UNFOCUS, 0, NULL);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -247,7 +253,7 @@ do_select_widget (WDialog * h, GList * w, select_dir_t dir)
|
||||
break;
|
||||
}
|
||||
}
|
||||
while (h->current != w /* && (WIDGET (h->current->data)->options & W_DISABLED) == 0 */ );
|
||||
while (h->current != w);
|
||||
|
||||
if (widget_overlapped (w0, WIDGET (h->current->data)))
|
||||
{
|
||||
@ -313,19 +319,19 @@ dlg_execute_cmd (WDialog * h, long command)
|
||||
break;
|
||||
|
||||
case CK_ScreenList:
|
||||
if (!h->modal)
|
||||
if (!widget_get_state (WIDGET (h), WST_MODAL))
|
||||
dialog_switch_list ();
|
||||
else
|
||||
ret = MSG_NOT_HANDLED;
|
||||
break;
|
||||
case CK_ScreenNext:
|
||||
if (!h->modal)
|
||||
if (!widget_get_state (WIDGET (h), WST_MODAL))
|
||||
dialog_switch_next ();
|
||||
else
|
||||
ret = MSG_NOT_HANDLED;
|
||||
break;
|
||||
case CK_ScreenPrev:
|
||||
if (!h->modal)
|
||||
if (!widget_get_state (WIDGET (h), WST_MODAL))
|
||||
dialog_switch_prev ();
|
||||
else
|
||||
ret = MSG_NOT_HANDLED;
|
||||
@ -382,8 +388,9 @@ dlg_mouse_event (WDialog * h, Gpm_Event * event)
|
||||
GList *p;
|
||||
|
||||
/* close the dialog by mouse left click out of dialog area */
|
||||
if (mouse_close_dialog && !h->fullscreen && ((event->buttons & GPM_B_LEFT) != 0)
|
||||
&& ((event->type & GPM_DOWN) != 0) && !mouse_global_in_widget (event, wh))
|
||||
if (mouse_close_dialog && (wh->pos_flags & WPOS_FULLSCREEN) == 0
|
||||
&& ((event->buttons & GPM_B_LEFT) != 0) && ((event->type & GPM_DOWN) != 0)
|
||||
&& !mouse_global_in_widget (event, wh))
|
||||
{
|
||||
h->ret_value = B_CANCEL;
|
||||
dlg_stop (h);
|
||||
@ -405,7 +412,7 @@ dlg_mouse_event (WDialog * h, Gpm_Event * event)
|
||||
{
|
||||
Widget *w = WIDGET (p->data);
|
||||
|
||||
if ((w->options & W_DISABLED) == 0 && w->mouse_callback != NULL)
|
||||
if (!widget_get_state (w, WST_DISABLED) && w->mouse_callback != NULL)
|
||||
{
|
||||
/* put global cursor position to the widget */
|
||||
int ret;
|
||||
@ -445,10 +452,10 @@ dlg_try_hotkey (WDialog * h, int d_key)
|
||||
|
||||
current = WIDGET (h->current->data);
|
||||
|
||||
if ((current->options & W_DISABLED) != 0)
|
||||
if (widget_get_state (current, WST_DISABLED))
|
||||
return MSG_NOT_HANDLED;
|
||||
|
||||
if (current->options & W_IS_INPUT)
|
||||
if (widget_get_options (current, WOP_IS_INPUT))
|
||||
{
|
||||
/* skip ascii control characters, anything else can valid character in
|
||||
* some encoding */
|
||||
@ -462,7 +469,7 @@ dlg_try_hotkey (WDialog * h, int d_key)
|
||||
d_key = g_ascii_tolower (c);
|
||||
|
||||
handled = MSG_NOT_HANDLED;
|
||||
if ((current->options & W_WANT_HOTKEY) != 0)
|
||||
if (widget_get_options (current, WOP_WANT_HOTKEY))
|
||||
handled = send_message (current, NULL, MSG_HOTKEY, d_key, NULL);
|
||||
|
||||
/* If not used, send hotkey to other widgets */
|
||||
@ -476,7 +483,8 @@ dlg_try_hotkey (WDialog * h, int d_key)
|
||||
{
|
||||
current = WIDGET (hot_cur->data);
|
||||
|
||||
if ((current->options & W_WANT_HOTKEY) != 0 && (current->options & W_DISABLED) == 0)
|
||||
if (widget_get_options (current, WOP_WANT_HOTKEY)
|
||||
&& !widget_get_state (current, WST_DISABLED))
|
||||
handled = send_message (current, NULL, MSG_HOTKEY, d_key, NULL);
|
||||
|
||||
if (handled == MSG_NOT_HANDLED)
|
||||
@ -503,7 +511,7 @@ dlg_key_event (WDialog * h, int d_key)
|
||||
h->current = h->widgets;
|
||||
|
||||
/* TAB used to cycle */
|
||||
if ((h->flags & DLG_WANT_TAB) == 0)
|
||||
if (!widget_get_options (WIDGET (h), WOP_WANT_TAB))
|
||||
{
|
||||
if (d_key == '\t')
|
||||
{
|
||||
@ -546,18 +554,19 @@ dlg_key_event (WDialog * h, int d_key)
|
||||
static void
|
||||
frontend_dlg_run (WDialog * h)
|
||||
{
|
||||
Widget *wh = WIDGET (h);
|
||||
Gpm_Event event;
|
||||
|
||||
event.x = -1;
|
||||
|
||||
/* close opened editors, viewers, etc */
|
||||
if (!h->modal && mc_global.midnight_shutdown)
|
||||
if (!widget_get_state (wh, WST_MODAL) && mc_global.midnight_shutdown)
|
||||
{
|
||||
send_message (h, NULL, MSG_VALIDATE, 0, NULL);
|
||||
return;
|
||||
}
|
||||
|
||||
while (h->state == DLG_ACTIVE)
|
||||
while (widget_get_state (wh, WST_ACTIVE))
|
||||
{
|
||||
int d_key;
|
||||
|
||||
@ -569,11 +578,11 @@ frontend_dlg_run (WDialog * h)
|
||||
if (idle_hook)
|
||||
execute_hooks (idle_hook);
|
||||
|
||||
while ((WIDGET (h)->options & W_WANT_IDLE) != 0 && is_idle ())
|
||||
send_message (h, NULL, MSG_IDLE, 0, NULL);
|
||||
while (widget_get_state (wh, WST_IDLE) && is_idle ())
|
||||
send_message (wh, NULL, MSG_IDLE, 0, NULL);
|
||||
|
||||
/* Allow terminating the dialog from the idle handler */
|
||||
if (h->state != DLG_ACTIVE)
|
||||
if (!widget_get_state (wh, WST_ACTIVE))
|
||||
break;
|
||||
}
|
||||
|
||||
@ -585,7 +594,7 @@ frontend_dlg_run (WDialog * h)
|
||||
|
||||
dlg_process_event (h, d_key, &event);
|
||||
|
||||
if (h->state == DLG_CLOSED)
|
||||
if (widget_get_state (wh, WST_CLOSED))
|
||||
send_message (h, NULL, MSG_VALIDATE, 0, NULL);
|
||||
}
|
||||
}
|
||||
@ -615,7 +624,7 @@ dlg_set_top_or_bottom_widget (void *w, gboolean set_top)
|
||||
abort (); /* widget is not in dialog, this should not happen */
|
||||
|
||||
/* unfocus prevoius widget and focus current one before widget reordering */
|
||||
if (set_top && h->state == DLG_ACTIVE)
|
||||
if (set_top && widget_get_state (WIDGET (h), WST_ACTIVE))
|
||||
do_select_widget (h, l, SELECT_EXACT);
|
||||
|
||||
/* widget reordering */
|
||||
@ -638,10 +647,10 @@ dlg_default_repaint (WDialog * h)
|
||||
|
||||
int space;
|
||||
|
||||
if (h->state != DLG_ACTIVE)
|
||||
if (!widget_get_state (wh, WST_ACTIVE))
|
||||
return;
|
||||
|
||||
space = (h->flags & DLG_COMPACT) ? 0 : 1;
|
||||
space = h->compact ? 0 : 1;
|
||||
|
||||
tty_setcolor (h->color[DLG_COLOR_NORMAL]);
|
||||
dlg_erase (h);
|
||||
@ -659,7 +668,7 @@ dlg_default_repaint (WDialog * h)
|
||||
/** this function allows to set dialog position */
|
||||
|
||||
void
|
||||
dlg_set_position (WDialog * h, int y1, int x1, int y2, int x2)
|
||||
dlg_set_position (WDialog * h, int y, int x, int lines, int cols)
|
||||
{
|
||||
Widget *wh = WIDGET (h);
|
||||
|
||||
@ -673,10 +682,10 @@ dlg_set_position (WDialog * h, int y1, int x1, int y2, int x2)
|
||||
oc = wh->cols;
|
||||
ol = wh->lines;
|
||||
|
||||
wh->x = x1;
|
||||
wh->y = y1;
|
||||
wh->lines = y2 - y1;
|
||||
wh->cols = x2 - x1;
|
||||
wh->x = x;
|
||||
wh->y = y;
|
||||
wh->lines = lines;
|
||||
wh->cols = cols;
|
||||
|
||||
/* dialog is empty */
|
||||
if (h->widgets == NULL)
|
||||
@ -707,36 +716,36 @@ dlg_set_position (WDialog * h, int y1, int x1, int y2, int x2)
|
||||
one direction - it should be sized */
|
||||
|
||||
Widget *c = WIDGET (w->data);
|
||||
int x = c->x;
|
||||
int y = c->y;
|
||||
int cols = c->cols;
|
||||
int lines = c->lines;
|
||||
int cx = c->x;
|
||||
int cy = c->y;
|
||||
int ccols = c->cols;
|
||||
int clines = c->lines;
|
||||
|
||||
if ((c->pos_flags & WPOS_CENTER_HORZ) != 0)
|
||||
x = wh->x + (wh->cols - c->cols) / 2;
|
||||
cx = wh->x + (wh->cols - c->cols) / 2;
|
||||
else if ((c->pos_flags & WPOS_KEEP_LEFT) != 0 && (c->pos_flags & WPOS_KEEP_RIGHT) != 0)
|
||||
{
|
||||
x += shift_x;
|
||||
cols += scale_x;
|
||||
cx += shift_x;
|
||||
ccols += scale_x;
|
||||
}
|
||||
else if ((c->pos_flags & WPOS_KEEP_LEFT) != 0)
|
||||
x += shift_x;
|
||||
cx += shift_x;
|
||||
else if ((c->pos_flags & WPOS_KEEP_RIGHT) != 0)
|
||||
x += shift_x + scale_x;
|
||||
cx += shift_x + scale_x;
|
||||
|
||||
if ((c->pos_flags & WPOS_CENTER_VERT) != 0)
|
||||
y = wh->y + (wh->lines - c->lines) / 2;
|
||||
cy = wh->y + (wh->lines - c->lines) / 2;
|
||||
else if ((c->pos_flags & WPOS_KEEP_TOP) != 0 && (c->pos_flags & WPOS_KEEP_BOTTOM) != 0)
|
||||
{
|
||||
y += shift_y;
|
||||
lines += scale_y;
|
||||
cy += shift_y;
|
||||
clines += scale_y;
|
||||
}
|
||||
else if ((c->pos_flags & WPOS_KEEP_TOP) != 0)
|
||||
y += shift_y;
|
||||
cy += shift_y;
|
||||
else if ((c->pos_flags & WPOS_KEEP_BOTTOM) != 0)
|
||||
y += shift_y + scale_y;
|
||||
cy += shift_y + scale_y;
|
||||
|
||||
widget_set_size (c, y, x, lines, cols);
|
||||
widget_set_size (c, cy, cx, clines, ccols);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -747,24 +756,38 @@ dlg_set_position (WDialog * h, int y1, int x1, int y2, int x2)
|
||||
void
|
||||
dlg_set_size (WDialog * h, int lines, int cols)
|
||||
{
|
||||
int x = WIDGET (h)->x;
|
||||
int y = WIDGET (h)->y;
|
||||
Widget *w = WIDGET (h);
|
||||
int x, y;
|
||||
|
||||
if ((h->flags & DLG_CENTER) != 0)
|
||||
if ((w->pos_flags & WPOS_FULLSCREEN) != 0)
|
||||
{
|
||||
y = (LINES - lines) / 2;
|
||||
x = (COLS - cols) / 2;
|
||||
y = 0;
|
||||
x = 0;
|
||||
lines = LINES;
|
||||
cols = COLS;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((w->pos_flags & WPOS_CENTER_HORZ) != 0)
|
||||
x = (COLS - cols) / 2;
|
||||
else
|
||||
x = w->x;
|
||||
|
||||
if ((w->pos_flags & WPOS_CENTER_VERT) != 0)
|
||||
y = (LINES - lines) / 2;
|
||||
else
|
||||
y = w->y;
|
||||
|
||||
if ((w->pos_flags & WPOS_TRYUP) != 0)
|
||||
{
|
||||
if (y > 3)
|
||||
y -= 2;
|
||||
else if (y == 3)
|
||||
y = 2;
|
||||
}
|
||||
}
|
||||
|
||||
if ((h->flags & DLG_TRYUP) != 0)
|
||||
{
|
||||
if (y > 3)
|
||||
y -= 2;
|
||||
else if (y == 3)
|
||||
y = 2;
|
||||
}
|
||||
|
||||
dlg_set_position (h, y, x, y + lines, x + cols);
|
||||
dlg_set_position (h, y, x, lines, cols);
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
@ -790,14 +813,15 @@ dlg_default_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm, v
|
||||
return MSG_NOT_HANDLED;
|
||||
|
||||
case MSG_IDLE:
|
||||
dlg_broadcast_msg_to (h, MSG_IDLE, FALSE, W_WANT_IDLE);
|
||||
/* we don't want endless loop */
|
||||
widget_idle (w, FALSE);
|
||||
return MSG_HANDLED;
|
||||
|
||||
case MSG_RESIZE:
|
||||
/* this is default resizing mechanism */
|
||||
/* the main idea of this code is to resize dialog
|
||||
according to flags (if any of flags require automatic
|
||||
resizing, like DLG_CENTER, end after that reposition
|
||||
resizing, like WPOS_CENTER, end after that reposition
|
||||
controls in dialog according to flags of widget) */
|
||||
dlg_set_size (h, w->lines, w->cols);
|
||||
return MSG_HANDLED;
|
||||
@ -812,28 +836,38 @@ dlg_default_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm, v
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
WDialog *
|
||||
dlg_create (gboolean modal, int y1, int x1, int lines, int cols,
|
||||
const int *colors, widget_cb_fn callback, widget_mouse_cb_fn mouse_callback,
|
||||
const char *help_ctx, const char *title, dlg_flags_t flags)
|
||||
dlg_create (gboolean modal, int y1, int x1, int lines, int cols, widget_pos_flags_t pos_flags,
|
||||
gboolean compact, const int *colors, widget_cb_fn callback,
|
||||
widget_mouse_cb_fn mouse_callback, const char *help_ctx, const char *title)
|
||||
{
|
||||
WDialog *new_d;
|
||||
Widget *w;
|
||||
|
||||
if ((pos_flags & WPOS_FULLSCREEN) != 0)
|
||||
{
|
||||
y1 = 0;
|
||||
x1 = 0;
|
||||
lines = LINES;
|
||||
cols = COLS;
|
||||
}
|
||||
|
||||
new_d = g_new0 (WDialog, 1);
|
||||
w = WIDGET (new_d);
|
||||
widget_init (w, y1, x1, lines, cols, (callback != NULL) ? callback : dlg_default_callback,
|
||||
mouse_callback);
|
||||
widget_want_cursor (w, FALSE);
|
||||
w->pos_flags = pos_flags;
|
||||
w->options |= WOP_TOP_SELECT;
|
||||
|
||||
w->state |= WST_CONSTRUCT;
|
||||
if (modal)
|
||||
w->state |= WST_MODAL;
|
||||
|
||||
new_d->state = DLG_CONSTRUCT;
|
||||
new_d->modal = modal;
|
||||
new_d->color = colors;
|
||||
new_d->help_ctx = help_ctx;
|
||||
new_d->flags = flags;
|
||||
new_d->compact = compact;
|
||||
new_d->data = NULL;
|
||||
|
||||
dlg_set_size (new_d, lines, cols);
|
||||
new_d->fullscreen = (w->x == 0 && w->y == 0 && w->cols == COLS && w->lines == LINES);
|
||||
|
||||
new_d->mouse_status = MOU_UNHANDLED;
|
||||
|
||||
@ -883,12 +917,10 @@ dlg_set_default_colors (void)
|
||||
void
|
||||
dlg_erase (WDialog * h)
|
||||
{
|
||||
if ((h != NULL) && (h->state == DLG_ACTIVE))
|
||||
{
|
||||
Widget *wh = WIDGET (h);
|
||||
Widget *wh = WIDGET (h);
|
||||
|
||||
if (wh != NULL && widget_get_state (wh, WST_ACTIVE))
|
||||
tty_fill_region (wh->y, wh->x, wh->lines, wh->cols, ' ');
|
||||
}
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
@ -944,7 +976,7 @@ add_widget_autopos (WDialog * h, void *w, widget_pos_flags_t pos_flags, const vo
|
||||
}
|
||||
|
||||
/* widget has been added in runtime */
|
||||
if (h->state == DLG_ACTIVE)
|
||||
if (widget_get_state (wh, WST_ACTIVE))
|
||||
{
|
||||
send_message (widget, NULL, MSG_INIT, 0, NULL);
|
||||
send_message (widget, NULL, MSG_DRAW, 0, NULL);
|
||||
@ -997,7 +1029,7 @@ del_widget (void *w)
|
||||
g_list_free_1 (d);
|
||||
|
||||
/* widget has been deleted in runtime */
|
||||
if (h->state == DLG_ACTIVE)
|
||||
if (widget_get_state (WIDGET (h), WST_ACTIVE))
|
||||
{
|
||||
dlg_redraw (h);
|
||||
dlg_focus (h);
|
||||
@ -1020,7 +1052,7 @@ do_refresh (void)
|
||||
{
|
||||
/* Search first fullscreen dialog */
|
||||
for (; d != NULL; d = g_list_next (d))
|
||||
if (d->data != NULL && DIALOG (d->data)->fullscreen)
|
||||
if (d->data != NULL && (WIDGET (d->data)->pos_flags & WPOS_FULLSCREEN) != 0)
|
||||
break;
|
||||
/* back to top dialog */
|
||||
for (; d != NULL; d = g_list_previous (d))
|
||||
@ -1044,15 +1076,20 @@ gboolean
|
||||
dlg_focus (WDialog * h)
|
||||
{
|
||||
/* cannot focus disabled widget */
|
||||
if ((h->current != NULL) && (h->state == DLG_CONSTRUCT || h->state == DLG_ACTIVE))
|
||||
if (h->current != NULL)
|
||||
{
|
||||
Widget *current = WIDGET (h->current->data);
|
||||
Widget *wh = WIDGET (h);
|
||||
|
||||
if (((current->options & W_DISABLED) == 0)
|
||||
&& (send_message (current, NULL, MSG_FOCUS, 0, NULL) == MSG_HANDLED))
|
||||
if (widget_get_state (wh, WST_CONSTRUCT) || widget_get_state (wh, WST_ACTIVE))
|
||||
{
|
||||
send_message (h, current, MSG_FOCUS, 0, NULL);
|
||||
return TRUE;
|
||||
Widget *current = WIDGET (h->current->data);
|
||||
|
||||
if (!widget_get_state (current, WST_DISABLED)
|
||||
&& (send_message (current, NULL, MSG_FOCUS, 0, NULL) == MSG_HANDLED))
|
||||
{
|
||||
send_message (h, current, MSG_FOCUS, 0, NULL);
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1108,18 +1145,10 @@ dlg_select_widget (void *w)
|
||||
Widget *widget = WIDGET (w);
|
||||
WDialog *h = widget->owner;
|
||||
|
||||
do_select_widget (h, g_list_find (h->widgets, widget), SELECT_EXACT);
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
/**
|
||||
* Set widget at top of widget list and make it current.
|
||||
*/
|
||||
|
||||
void
|
||||
dlg_set_top_widget (void *w)
|
||||
{
|
||||
dlg_set_top_or_bottom_widget (w, TRUE);
|
||||
if (widget_get_options (widget, WOP_TOP_SELECT))
|
||||
dlg_set_top_or_bottom_widget (w, TRUE);
|
||||
else
|
||||
do_select_widget (h, g_list_find (h->widgets, widget), SELECT_EXACT);
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
@ -1160,13 +1189,13 @@ update_cursor (WDialog * h)
|
||||
{
|
||||
GList *p = h->current;
|
||||
|
||||
if ((p != NULL) && (h->state == DLG_ACTIVE))
|
||||
if (p != NULL && widget_get_state (WIDGET (h), WST_ACTIVE))
|
||||
{
|
||||
Widget *w;
|
||||
|
||||
w = WIDGET (p->data);
|
||||
|
||||
if (((w->options & W_DISABLED) == 0) && ((w->options & W_WANT_CURSOR) != 0))
|
||||
if (!widget_get_state (w, WST_DISABLED) && widget_get_options (w, WOP_WANT_CURSOR))
|
||||
send_message (w, NULL, MSG_CURSOR, 0, NULL);
|
||||
else
|
||||
do
|
||||
@ -1177,9 +1206,9 @@ update_cursor (WDialog * h)
|
||||
|
||||
w = WIDGET (p->data);
|
||||
|
||||
if (((w->options & W_DISABLED) == 0) && ((w->options & W_WANT_CURSOR) != 0))
|
||||
if (send_message (w, NULL, MSG_CURSOR, 0, NULL) == MSG_HANDLED)
|
||||
break;
|
||||
if (!widget_get_state (w, WST_DISABLED) && widget_get_options (w, WOP_WANT_CURSOR)
|
||||
&& send_message (w, NULL, MSG_CURSOR, 0, NULL) == MSG_HANDLED)
|
||||
break;
|
||||
}
|
||||
while (TRUE);
|
||||
}
|
||||
@ -1194,7 +1223,7 @@ update_cursor (WDialog * h)
|
||||
void
|
||||
dlg_redraw (WDialog * h)
|
||||
{
|
||||
if (h->state != DLG_ACTIVE)
|
||||
if (!widget_get_state (WIDGET (h), WST_ACTIVE))
|
||||
return;
|
||||
|
||||
if (h->winch_pending)
|
||||
@ -1213,7 +1242,7 @@ dlg_redraw (WDialog * h)
|
||||
void
|
||||
dlg_stop (WDialog * h)
|
||||
{
|
||||
h->state = DLG_CLOSED;
|
||||
widget_set_state (WIDGET (h), WST_CLOSED, TRUE);
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
@ -1222,16 +1251,18 @@ dlg_stop (WDialog * h)
|
||||
void
|
||||
dlg_init (WDialog * h)
|
||||
{
|
||||
if (top_dlg != NULL && DIALOG (top_dlg->data)->modal)
|
||||
h->modal = TRUE;
|
||||
Widget *wh = WIDGET (h);
|
||||
|
||||
if (top_dlg != NULL && widget_get_state (WIDGET (top_dlg->data), WST_MODAL))
|
||||
widget_set_state (wh, WST_MODAL, TRUE);
|
||||
|
||||
/* add dialog to the stack */
|
||||
top_dlg = g_list_prepend (top_dlg, h);
|
||||
|
||||
/* Initialize dialog manager and widgets */
|
||||
if (h->state == DLG_CONSTRUCT)
|
||||
if (widget_get_state (wh, WST_CONSTRUCT))
|
||||
{
|
||||
if (!h->modal)
|
||||
if (!widget_get_state (wh, WST_MODAL))
|
||||
dialog_switch_add (h);
|
||||
|
||||
send_message (h, NULL, MSG_INIT, 0, NULL);
|
||||
@ -1239,7 +1270,7 @@ dlg_init (WDialog * h)
|
||||
dlg_read_history (h);
|
||||
}
|
||||
|
||||
h->state = DLG_ACTIVE;
|
||||
widget_set_state (wh, WST_ACTIVE, TRUE);
|
||||
|
||||
/* first send MSG_DRAW to dialog itself and all widgets... */
|
||||
dlg_redraw (h);
|
||||
@ -1277,10 +1308,10 @@ dlg_run_done (WDialog * h)
|
||||
{
|
||||
top_dlg = g_list_remove (top_dlg, h);
|
||||
|
||||
if (h->state == DLG_CLOSED)
|
||||
if (widget_get_state (WIDGET (h), WST_CLOSED))
|
||||
{
|
||||
send_message (h, h->current->data, MSG_END, 0, NULL);
|
||||
if (!h->modal)
|
||||
if (!widget_get_state (WIDGET (h), WST_MODAL))
|
||||
dialog_switch_remove (h);
|
||||
}
|
||||
}
|
||||
|
@ -29,25 +29,6 @@
|
||||
|
||||
/*** enums ***************************************************************************************/
|
||||
|
||||
/* Flags for dlg_create */
|
||||
typedef enum
|
||||
{
|
||||
DLG_NONE = 0, /* No options */
|
||||
DLG_CENTER = (1 << 0), /* Center the dialog */
|
||||
DLG_TRYUP = (1 << 1), /* Try to move two lines up the dialog */
|
||||
DLG_COMPACT = (1 << 2), /* Suppress spaces around the frame */
|
||||
DLG_WANT_TAB = (1 << 3) /* Should the tab key be sent to the dialog? */
|
||||
} dlg_flags_t;
|
||||
|
||||
/* Dialog state */
|
||||
typedef enum
|
||||
{
|
||||
DLG_CONSTRUCT = 0, /* Dialog has been constructed but not run yet */
|
||||
DLG_ACTIVE = 1, /* Dialog is visible and active */
|
||||
DLG_SUSPENDED = 2, /* Dialog is suspended */
|
||||
DLG_CLOSED = 3 /* Dialog is closed */
|
||||
} dlg_state_t;
|
||||
|
||||
/* Dialog color constants */
|
||||
typedef enum
|
||||
{
|
||||
@ -80,8 +61,7 @@ struct WDialog
|
||||
Widget widget;
|
||||
|
||||
/* Set by the user */
|
||||
gboolean modal; /* type of dialog: modal or not */
|
||||
dlg_flags_t flags; /* User flags */
|
||||
gboolean compact; /* Suppress spaces around the frame */
|
||||
const char *help_ctx; /* Name of the help entry */
|
||||
const int *color; /* Color set. Unused in viewer and editor */
|
||||
char *title; /* Title of the dialog */
|
||||
@ -90,8 +70,6 @@ struct WDialog
|
||||
int ret_value; /* Result of dlg_run() */
|
||||
|
||||
/* Internal flags */
|
||||
dlg_state_t state;
|
||||
gboolean fullscreen; /* Parents dialogs don't need refresh */
|
||||
gboolean winch_pending; /* SIGWINCH signal has been got. Resize dialog after rise */
|
||||
int mouse_status; /* For the autorepeat status of the mouse */
|
||||
|
||||
@ -127,8 +105,9 @@ extern const global_keymap_t *dialog_map;
|
||||
|
||||
/* Creates a dialog head */
|
||||
WDialog *dlg_create (gboolean modal, int y1, int x1, int lines, int cols,
|
||||
widget_pos_flags_t pos_flags, gboolean compact,
|
||||
const int *colors, widget_cb_fn callback, widget_mouse_cb_fn mouse_callback,
|
||||
const char *help_ctx, const char *title, dlg_flags_t flags);
|
||||
const char *help_ctx, const char *title);
|
||||
|
||||
void dlg_set_default_colors (void);
|
||||
|
||||
@ -142,7 +121,7 @@ void del_widget (void *w);
|
||||
according to dialog flags */
|
||||
void dlg_set_size (WDialog * h, int lines, int cols);
|
||||
/* this function allows to set dialog position */
|
||||
void dlg_set_position (WDialog * h, int y1, int x1, int y2, int x2);
|
||||
void dlg_set_position (WDialog * h, int y, int x, int lines, int cols);
|
||||
|
||||
void dlg_init (WDialog * h);
|
||||
int dlg_run (WDialog * d);
|
||||
@ -169,7 +148,6 @@ void dlg_stop (WDialog * h);
|
||||
|
||||
/* Widget selection */
|
||||
void dlg_select_widget (void *w);
|
||||
void dlg_set_top_widget (void *w);
|
||||
void dlg_set_bottom_widget (void *w);
|
||||
void dlg_one_up (WDialog * h);
|
||||
void dlg_one_down (WDialog * h);
|
||||
|
@ -138,8 +138,6 @@ gauge_new (int y, int x, int cols, gboolean shown, int max, int current)
|
||||
g = g_new (WGauge, 1);
|
||||
w = WIDGET (g);
|
||||
widget_init (w, y, x, 1, cols, gauge_callback, NULL);
|
||||
widget_want_cursor (w, FALSE);
|
||||
widget_want_hotkey (w, FALSE);
|
||||
|
||||
g->shown = shown;
|
||||
if (max == 0)
|
||||
|
@ -71,7 +71,7 @@ groupbox_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm, void
|
||||
|
||||
gboolean disabled;
|
||||
|
||||
disabled = (w->options & W_DISABLED) != 0;
|
||||
disabled = widget_get_state (w, WST_DISABLED);
|
||||
tty_setcolor (disabled ? DISABLED_COLOR : h->color[DLG_COLOR_NORMAL]);
|
||||
tty_draw_box (w->y, w->x, w->lines, w->cols, TRUE);
|
||||
|
||||
@ -107,9 +107,6 @@ groupbox_new (int y, int x, int height, int width, const char *title)
|
||||
w = WIDGET (g);
|
||||
widget_init (w, y, x, height, width, groupbox_callback, NULL);
|
||||
|
||||
widget_want_cursor (w, FALSE);
|
||||
widget_want_hotkey (w, FALSE);
|
||||
|
||||
g->title = NULL;
|
||||
groupbox_set_title (g, title);
|
||||
|
||||
|
@ -107,7 +107,7 @@ history_dlg_reposition (WDialog * dlg_head)
|
||||
x = COLS - wi;
|
||||
}
|
||||
|
||||
dlg_set_position (dlg_head, y, x, y + he, x + wi);
|
||||
dlg_set_position (dlg_head, y, x, he, wi);
|
||||
|
||||
return MSG_HANDLED;
|
||||
}
|
||||
@ -319,8 +319,8 @@ history_show (GList ** history, Widget * widget, int current)
|
||||
hist_data.maxlen = maxlen;
|
||||
|
||||
query_dlg =
|
||||
dlg_create (TRUE, 0, 0, 4, 4, dialog_colors, history_dlg_callback, NULL,
|
||||
"[History-query]", _("History"), DLG_COMPACT);
|
||||
dlg_create (TRUE, 0, 0, 4, 4, WPOS_KEEP_DEFAULT, TRUE, dialog_colors, history_dlg_callback,
|
||||
NULL, "[History-query]", _("History"));
|
||||
query_dlg->data = &hist_data;
|
||||
|
||||
query_list = listbox_new (1, 1, 2, 2, TRUE, NULL);
|
||||
|
@ -67,7 +67,7 @@ hline_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm, void *d
|
||||
{
|
||||
Widget *wo = WIDGET (h);
|
||||
|
||||
if (((h->flags & DLG_COMPACT) != 0))
|
||||
if (h->compact)
|
||||
{
|
||||
w->x = wo->x;
|
||||
w->cols = wo->cols;
|
||||
@ -136,8 +136,6 @@ hline_new (int y, int x, int width)
|
||||
l->text = NULL;
|
||||
l->auto_adjust_cols = (width < 0);
|
||||
l->transparent = FALSE;
|
||||
widget_want_cursor (w, FALSE);
|
||||
widget_want_hotkey (w, FALSE);
|
||||
|
||||
return l;
|
||||
}
|
||||
|
@ -103,7 +103,7 @@ static void
|
||||
draw_history_button (WInput * in)
|
||||
{
|
||||
char c;
|
||||
gboolean disabled = (WIDGET (in)->options & W_DISABLED) != 0;
|
||||
gboolean disabled;
|
||||
|
||||
if (g_list_next (in->history.current) == NULL)
|
||||
c = '^';
|
||||
@ -113,6 +113,7 @@ draw_history_button (WInput * in)
|
||||
c = '|';
|
||||
|
||||
widget_move (in, 0, WIDGET (in)->cols - HISTORY_BUTTON_WIDTH);
|
||||
disabled = widget_get_state (WIDGET (in), WST_DISABLED);
|
||||
tty_setcolor (disabled ? DISABLED_COLOR : in->color[WINPUTC_HISTORY]);
|
||||
|
||||
#ifdef LARGE_HISTORY_BUTTON
|
||||
@ -967,25 +968,6 @@ input_mouse_callback (Widget * w, mouse_msg_t msg, mouse_event_t * event)
|
||||
}
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* Callback for applying new options to input widget.
|
||||
*
|
||||
* @param w widget
|
||||
* @param options options set
|
||||
* @param enable TRUE if specified options should be added, FALSE if options should be removed
|
||||
*/
|
||||
static void
|
||||
input_set_options_callback (Widget * w, widget_options_t options, gboolean enable)
|
||||
{
|
||||
WInput *in = INPUT (w);
|
||||
|
||||
widget_default_set_options_callback (w, options, enable);
|
||||
if (in->label != NULL)
|
||||
widget_set_options (WIDGET (in->label), options, enable);
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
/*** public functions ****************************************************************************/
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
@ -1010,8 +992,7 @@ input_new (int y, int x, const int *colors, int width, const char *def_text,
|
||||
in = g_new (WInput, 1);
|
||||
w = WIDGET (in);
|
||||
widget_init (w, y, x, 1, width, input_callback, input_mouse_callback);
|
||||
w->options |= W_IS_INPUT;
|
||||
w->set_options = input_set_options_callback;
|
||||
w->options |= WOP_IS_INPUT | WOP_WANT_CURSOR;
|
||||
|
||||
in->color = colors;
|
||||
in->first = TRUE;
|
||||
@ -1065,6 +1046,8 @@ input_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm, void *d
|
||||
mc_event_add (w->owner->event_group, MCEVENT_HISTORY_LOAD, input_load_history, w, NULL);
|
||||
/* subscribe to "history_save" event */
|
||||
mc_event_add (w->owner->event_group, MCEVENT_HISTORY_SAVE, input_save_history, w, NULL);
|
||||
if (in->label != NULL)
|
||||
widget_set_state (WIDGET (in->label), WST_DISABLED, widget_get_state (w, WST_DISABLED));
|
||||
return MSG_HANDLED;
|
||||
|
||||
case MSG_KEY:
|
||||
@ -1102,6 +1085,12 @@ input_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm, void *d
|
||||
input_update (in, FALSE);
|
||||
return MSG_HANDLED;
|
||||
|
||||
case MSG_ENABLE:
|
||||
case MSG_DISABLE:
|
||||
if (in->label != NULL)
|
||||
widget_set_state (WIDGET (in->label), WST_DISABLED, msg == MSG_DISABLE);
|
||||
return MSG_HANDLED;
|
||||
|
||||
case MSG_CURSOR:
|
||||
widget_move (in, 0, str_term_width2 (in->buffer, in->point) - in->term_first_shown);
|
||||
return MSG_HANDLED;
|
||||
@ -1271,7 +1260,7 @@ input_update (WInput * in, gboolean clear_first)
|
||||
return;
|
||||
|
||||
/* don't draw widget not put into dialog */
|
||||
if (w->owner == NULL || w->owner->state != DLG_ACTIVE)
|
||||
if (w->owner == NULL || !widget_get_state (WIDGET (w->owner), WST_ACTIVE))
|
||||
return;
|
||||
|
||||
if (should_show_history_button (in))
|
||||
@ -1295,7 +1284,7 @@ input_update (WInput * in, gboolean clear_first)
|
||||
if (has_history != 0)
|
||||
draw_history_button (in);
|
||||
|
||||
if ((w->options & W_DISABLED) != 0)
|
||||
if (widget_get_state (w, WST_DISABLED))
|
||||
tty_setcolor (DISABLED_COLOR);
|
||||
else if (in->first)
|
||||
tty_setcolor (in->color[WINPUTC_UNCHANGED]);
|
||||
|
@ -1271,9 +1271,8 @@ complete_engine (WInput * in, int what_to_do)
|
||||
query_height = h;
|
||||
query_width = w;
|
||||
|
||||
query_dlg = dlg_create (TRUE, y, x, query_height, query_width,
|
||||
dialog_colors, query_callback, NULL,
|
||||
"[Completion]", NULL, DLG_COMPACT);
|
||||
query_dlg = dlg_create (TRUE, y, x, query_height, query_width, WPOS_KEEP_DEFAULT, TRUE,
|
||||
dialog_colors, query_callback, NULL, "[Completion]", NULL);
|
||||
query_list = listbox_new (1, 1, h - 2, w - 2, FALSE, NULL);
|
||||
add_widget (query_dlg, query_list);
|
||||
|
||||
|
@ -81,7 +81,7 @@ label_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm, void *d
|
||||
if (l->text == NULL)
|
||||
return MSG_HANDLED;
|
||||
|
||||
disabled = (w->options & W_DISABLED) != 0;
|
||||
disabled = widget_get_state (w, WST_DISABLED);
|
||||
|
||||
if (l->transparent)
|
||||
tty_setcolor (disabled ? DISABLED_COLOR : DEFAULT_COLOR);
|
||||
@ -147,8 +147,6 @@ label_new (int y, int x, const char *text)
|
||||
l->text = g_strdup (text);
|
||||
l->auto_adjust_cols = TRUE;
|
||||
l->transparent = FALSE;
|
||||
widget_want_cursor (w, FALSE);
|
||||
widget_want_hotkey (w, FALSE);
|
||||
|
||||
return l;
|
||||
}
|
||||
|
@ -63,7 +63,7 @@ create_listbox_window_centered (int center_y, int center_x, int lines, int cols,
|
||||
|
||||
int xpos = 0, ypos = 0;
|
||||
Listbox *listbox;
|
||||
dlg_flags_t dlg_flags = DLG_TRYUP;
|
||||
widget_pos_flags_t pos_flags = WPOS_TRYUP;
|
||||
|
||||
/* Adjust sizes */
|
||||
lines = MIN (lines, LINES - 6);
|
||||
@ -80,7 +80,7 @@ create_listbox_window_centered (int center_y, int center_x, int lines, int cols,
|
||||
|
||||
/* adjust position */
|
||||
if ((center_y < 0) || (center_x < 0))
|
||||
dlg_flags |= DLG_CENTER;
|
||||
pos_flags |= WPOS_CENTER;
|
||||
else
|
||||
{
|
||||
/* Actually, this this is not used in MC. */
|
||||
@ -105,8 +105,8 @@ create_listbox_window_centered (int center_y, int center_x, int lines, int cols,
|
||||
listbox = g_new (Listbox, 1);
|
||||
|
||||
listbox->dlg =
|
||||
dlg_create (TRUE, ypos, xpos, lines + space, cols + space,
|
||||
listbox_colors, NULL, NULL, help, title, dlg_flags);
|
||||
dlg_create (TRUE, ypos, xpos, lines + space, cols + space, pos_flags, FALSE, listbox_colors,
|
||||
NULL, NULL, help, title);
|
||||
|
||||
listbox->list = listbox_new (2, 2, lines, cols, FALSE, NULL);
|
||||
add_widget (listbox->dlg, listbox->list);
|
||||
|
@ -132,22 +132,24 @@ listbox_draw (WListbox * l, gboolean focused)
|
||||
{
|
||||
Widget *w = WIDGET (l);
|
||||
const WDialog *h = w->owner;
|
||||
const gboolean disabled = (w->options & W_DISABLED) != 0;
|
||||
const int normalc = disabled ? DISABLED_COLOR : h->color[DLG_COLOR_NORMAL];
|
||||
/* *INDENT-OFF* */
|
||||
int selc = disabled
|
||||
? DISABLED_COLOR
|
||||
: focused
|
||||
? h->color[DLG_COLOR_HOT_FOCUS]
|
||||
: h->color[DLG_COLOR_FOCUS];
|
||||
/* *INDENT-ON* */
|
||||
|
||||
gboolean disabled;
|
||||
int normalc, selc;
|
||||
int length = 0;
|
||||
GList *le = NULL;
|
||||
int pos;
|
||||
int i;
|
||||
int sel_line = -1;
|
||||
|
||||
disabled = widget_get_state (w, WST_DISABLED);
|
||||
normalc = disabled ? DISABLED_COLOR : h->color[DLG_COLOR_NORMAL];
|
||||
/* *INDENT-OFF* */
|
||||
selc = disabled
|
||||
? DISABLED_COLOR
|
||||
: focused
|
||||
? h->color[DLG_COLOR_HOT_FOCUS]
|
||||
: h->color[DLG_COLOR_FOCUS];
|
||||
/* *INDENT-ON* */
|
||||
|
||||
if (l->list != NULL)
|
||||
{
|
||||
length = g_queue_get_length (l->list);
|
||||
@ -561,7 +563,6 @@ listbox_new (int y, int x, int height, int width, gboolean deletable, lcback_fn
|
||||
l->scrollbar = !mc_global.tty.slow_terminal;
|
||||
l->focused = FALSE;
|
||||
widget_want_hotkey (w, TRUE);
|
||||
widget_want_cursor (w, FALSE);
|
||||
|
||||
return l;
|
||||
}
|
||||
|
@ -307,7 +307,7 @@ menubar_finish (WMenuBar * menubar)
|
||||
menubar->is_dropped = FALSE;
|
||||
menubar->is_active = FALSE;
|
||||
w->lines = 1;
|
||||
widget_want_hotkey (w, 0);
|
||||
widget_want_hotkey (w, FALSE);
|
||||
|
||||
/* Move the menubar to the bottom so that widgets displayed on top of
|
||||
* an "invisible" menubar get the first chance to respond to mouse events. */
|
||||
@ -588,7 +588,7 @@ menubar_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm, void
|
||||
w->lines = LINES;
|
||||
|
||||
/* Trick to get all of the hotkeys */
|
||||
widget_want_hotkey (w, 1);
|
||||
widget_want_hotkey (w, TRUE);
|
||||
menubar_draw (menubar);
|
||||
return MSG_HANDLED;
|
||||
|
||||
@ -892,9 +892,9 @@ menubar_new (int y, int x, int cols, GList * menu, gboolean visible)
|
||||
menubar = g_new0 (WMenuBar, 1);
|
||||
w = WIDGET (menubar);
|
||||
widget_init (w, y, x, 1, cols, menubar_callback, menubar_mouse_callback);
|
||||
w->options |= WOP_TOP_SELECT;
|
||||
|
||||
menubar->is_visible = visible;
|
||||
widget_want_cursor (w, FALSE);
|
||||
menubar_set_menu (menubar, menu);
|
||||
|
||||
return menubar;
|
||||
@ -1017,7 +1017,7 @@ menubar_activate (WMenuBar * menubar, gboolean dropped, int which)
|
||||
|
||||
/* Bring it to the top so it receives all mouse events before any other widget.
|
||||
* See also comment in menubar_finish(). */
|
||||
dlg_set_top_widget (w);
|
||||
dlg_select_widget (w);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -90,6 +90,7 @@ quick_create_labeled_input (GArray * widgets, int *y, int x, quick_widget_t * qu
|
||||
label.quick_widget = g_new0 (quick_widget_t, 1);
|
||||
label.quick_widget->widget_type = quick_label;
|
||||
label.quick_widget->options = quick_widget->options;
|
||||
label.quick_widget->state = quick_widget->state;
|
||||
/* FIXME: this should be turned in depend of label_location */
|
||||
label.quick_widget->pos_flags = quick_widget->pos_flags;
|
||||
|
||||
@ -405,13 +406,13 @@ quick_dialog_skip (quick_dialog_t * quick_dlg, int nskip)
|
||||
width2 = (quick_dlg->cols - 7) / 2;
|
||||
|
||||
if (quick_dlg->x == -1 || quick_dlg->y == -1)
|
||||
dd = dlg_create (TRUE, 0, 0, y + 3, quick_dlg->cols,
|
||||
dd = dlg_create (TRUE, 0, 0, y + 3, quick_dlg->cols, WPOS_CENTER | WPOS_TRYUP, FALSE,
|
||||
dialog_colors, quick_dlg->callback, quick_dlg->mouse_callback,
|
||||
quick_dlg->help, quick_dlg->title, DLG_CENTER | DLG_TRYUP);
|
||||
quick_dlg->help, quick_dlg->title);
|
||||
else
|
||||
dd = dlg_create (TRUE, quick_dlg->y, quick_dlg->x, y + 3, quick_dlg->cols,
|
||||
dialog_colors, quick_dlg->callback, quick_dlg->mouse_callback,
|
||||
quick_dlg->help, quick_dlg->title, DLG_NONE);
|
||||
WPOS_KEEP_DEFAULT, FALSE, dialog_colors, quick_dlg->callback,
|
||||
quick_dlg->mouse_callback, quick_dlg->help, quick_dlg->title);
|
||||
|
||||
/* add widgets into the dialog */
|
||||
x2 = x1 + width2 + 1;
|
||||
@ -562,6 +563,7 @@ quick_dialog_skip (quick_dialog_t * quick_dlg, int nskip)
|
||||
|
||||
/* add widget into dialog */
|
||||
item->widget->options |= item->quick_widget->options; /* FIXME: cannot reset flags, setup only */
|
||||
item->widget->state |= item->quick_widget->state; /* FIXME: cannot reset flags, setup only */
|
||||
id = add_widget_autopos (dd, item->widget, item->quick_widget->pos_flags, NULL);
|
||||
if (item->quick_widget->id != NULL)
|
||||
*item->quick_widget->id = id;
|
||||
|
@ -12,7 +12,7 @@
|
||||
#define QUICK_CHECKBOX(txt, st, id_) \
|
||||
{ \
|
||||
.widget_type = quick_checkbox, \
|
||||
.options = W_DEFAULT, \
|
||||
.options = WOP_DEFAULT, \
|
||||
.pos_flags = WPOS_KEEP_DEFAULT, \
|
||||
.id = id_, \
|
||||
.u = { \
|
||||
@ -26,7 +26,7 @@
|
||||
#define QUICK_BUTTON(txt, act, cb, id_) \
|
||||
{ \
|
||||
.widget_type = quick_button, \
|
||||
.options = W_DEFAULT, \
|
||||
.options = WOP_DEFAULT, \
|
||||
.pos_flags = WPOS_KEEP_DEFAULT, \
|
||||
.id = id_, \
|
||||
.u = { \
|
||||
@ -41,7 +41,7 @@
|
||||
#define QUICK_INPUT(txt, hname, res, id_, is_passwd_, strip_passwd_, completion_flags_) \
|
||||
{ \
|
||||
.widget_type = quick_input, \
|
||||
.options = W_DEFAULT, \
|
||||
.options = WOP_DEFAULT, \
|
||||
.pos_flags = WPOS_KEEP_DEFAULT, \
|
||||
.id = id_, \
|
||||
.u = { \
|
||||
@ -62,7 +62,7 @@
|
||||
#define QUICK_LABELED_INPUT(label_, label_loc, txt, hname, res, id_, is_passwd_, strip_passwd_, completion_flags_) \
|
||||
{ \
|
||||
.widget_type = quick_input, \
|
||||
.options = W_DEFAULT, \
|
||||
.options = WOP_DEFAULT, \
|
||||
.pos_flags = WPOS_KEEP_DEFAULT, \
|
||||
.id = id_, \
|
||||
.u = { \
|
||||
@ -83,7 +83,7 @@
|
||||
#define QUICK_LABEL(txt, id_) \
|
||||
{ \
|
||||
.widget_type = quick_label, \
|
||||
.options = W_DEFAULT, \
|
||||
.options = WOP_DEFAULT, \
|
||||
.pos_flags = WPOS_KEEP_DEFAULT, \
|
||||
.id = id_, \
|
||||
.u = { \
|
||||
@ -97,7 +97,7 @@
|
||||
#define QUICK_RADIO(cnt, items_, val, id_) \
|
||||
{ \
|
||||
.widget_type = quick_radio, \
|
||||
.options = W_DEFAULT, \
|
||||
.options = WOP_DEFAULT, \
|
||||
.pos_flags = WPOS_KEEP_DEFAULT, \
|
||||
.id = id_, \
|
||||
.u = { \
|
||||
@ -112,7 +112,7 @@
|
||||
#define QUICK_START_GROUPBOX(t) \
|
||||
{ \
|
||||
.widget_type = quick_start_groupbox, \
|
||||
.options = W_DEFAULT, \
|
||||
.options = WOP_DEFAULT, \
|
||||
.pos_flags = WPOS_KEEP_DEFAULT, \
|
||||
.id = NULL, \
|
||||
.u = { \
|
||||
@ -125,7 +125,7 @@
|
||||
#define QUICK_STOP_GROUPBOX \
|
||||
{ \
|
||||
.widget_type = quick_stop_groupbox, \
|
||||
.options = W_DEFAULT, \
|
||||
.options = WOP_DEFAULT, \
|
||||
.pos_flags = WPOS_KEEP_DEFAULT, \
|
||||
.id = NULL, \
|
||||
.u = { \
|
||||
@ -140,7 +140,7 @@
|
||||
#define QUICK_SEPARATOR(line_) \
|
||||
{ \
|
||||
.widget_type = quick_separator, \
|
||||
.options = W_DEFAULT, \
|
||||
.options = WOP_DEFAULT, \
|
||||
.pos_flags = WPOS_KEEP_DEFAULT, \
|
||||
.id = NULL, \
|
||||
.u = { \
|
||||
@ -154,7 +154,7 @@
|
||||
#define QUICK_START_COLUMNS \
|
||||
{ \
|
||||
.widget_type = quick_start_columns, \
|
||||
.options = W_DEFAULT, \
|
||||
.options = WOP_DEFAULT, \
|
||||
.pos_flags = WPOS_KEEP_DEFAULT, \
|
||||
.id = NULL, \
|
||||
.u = { \
|
||||
@ -169,7 +169,7 @@
|
||||
#define QUICK_NEXT_COLUMN \
|
||||
{ \
|
||||
.widget_type = quick_next_column, \
|
||||
.options = W_DEFAULT, \
|
||||
.options = WOP_DEFAULT, \
|
||||
.pos_flags = WPOS_KEEP_DEFAULT, \
|
||||
.id = NULL, \
|
||||
.u = { \
|
||||
@ -184,7 +184,7 @@
|
||||
#define QUICK_STOP_COLUMNS \
|
||||
{ \
|
||||
.widget_type = quick_stop_columns, \
|
||||
.options = W_DEFAULT, \
|
||||
.options = WOP_DEFAULT, \
|
||||
.pos_flags = WPOS_KEEP_DEFAULT, \
|
||||
.id = NULL, \
|
||||
.u = { \
|
||||
@ -199,7 +199,7 @@
|
||||
#define QUICK_START_BUTTONS(space_, line_) \
|
||||
{ \
|
||||
.widget_type = quick_buttons, \
|
||||
.options = W_DEFAULT, \
|
||||
.options = WOP_DEFAULT, \
|
||||
.pos_flags = WPOS_KEEP_DEFAULT, \
|
||||
.id = NULL, \
|
||||
.u = { \
|
||||
@ -218,7 +218,7 @@
|
||||
#define QUICK_END \
|
||||
{ \
|
||||
.widget_type = quick_end, \
|
||||
.options = W_DEFAULT, \
|
||||
.options = WOP_DEFAULT, \
|
||||
.pos_flags = WPOS_KEEP_DEFAULT, \
|
||||
.id = NULL, \
|
||||
.u = { \
|
||||
@ -269,6 +269,7 @@ struct quick_widget_t
|
||||
quick_t widget_type;
|
||||
|
||||
widget_options_t options;
|
||||
widget_state_t state;
|
||||
widget_pos_flags_t pos_flags;
|
||||
unsigned long *id;
|
||||
|
||||
|
@ -195,6 +195,7 @@ radio_new (int y, int x, int count, const char **texts)
|
||||
r->pos = 0;
|
||||
r->sel = 0;
|
||||
r->count = count;
|
||||
widget_want_cursor (w, TRUE);
|
||||
widget_want_hotkey (w, TRUE);
|
||||
|
||||
return r;
|
||||
|
@ -147,15 +147,14 @@ widget_init (Widget * w, int y, int x, int lines, int cols,
|
||||
w->pos_flags = WPOS_KEEP_DEFAULT;
|
||||
w->callback = callback;
|
||||
w->mouse_callback = mouse_callback;
|
||||
w->set_options = widget_default_set_options_callback;
|
||||
w->owner = NULL;
|
||||
w->mouse.forced_capture = FALSE;
|
||||
w->mouse.capture = FALSE;
|
||||
w->mouse.last_msg = MSG_MOUSE_NONE;
|
||||
w->mouse.last_buttons_down = 0;
|
||||
|
||||
/* Almost all widgets want to put the cursor in a suitable place */
|
||||
w->options = W_WANT_CURSOR;
|
||||
w->options = WOP_DEFAULT;
|
||||
w->state = WST_DEFAULT;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
@ -174,6 +173,8 @@ widget_default_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm
|
||||
case MSG_INIT:
|
||||
case MSG_FOCUS:
|
||||
case MSG_UNFOCUS:
|
||||
case MSG_ENABLE:
|
||||
case MSG_DISABLE:
|
||||
case MSG_DRAW:
|
||||
case MSG_DESTROY:
|
||||
case MSG_CURSOR:
|
||||
@ -187,38 +188,73 @@ widget_default_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* Callback for applying new options to widget.
|
||||
*
|
||||
* @param w widget
|
||||
* @param options options set
|
||||
* @param enable TRUE if specified options should be added, FALSE if options should be removed
|
||||
*/
|
||||
void
|
||||
widget_default_set_options_callback (Widget * w, widget_options_t options, gboolean enable)
|
||||
{
|
||||
if (enable)
|
||||
w->options |= options;
|
||||
else
|
||||
w->options &= ~options;
|
||||
|
||||
if (w->owner != NULL && (options & W_DISABLED) != 0)
|
||||
send_message (w, NULL, MSG_DRAW, 0, NULL);
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* Apply new options to widget.
|
||||
*
|
||||
* @param w widget
|
||||
* @param options options set
|
||||
* @param options widget option flags to modify. Several flags per call can be modified.
|
||||
* @param enable TRUE if specified options should be added, FALSE if options should be removed
|
||||
*/
|
||||
void
|
||||
widget_set_options (Widget * w, widget_options_t options, gboolean enable)
|
||||
{
|
||||
w->set_options (w, options, enable);
|
||||
if (enable)
|
||||
w->options |= options;
|
||||
else
|
||||
w->options &= ~options;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* Modify state of widget.
|
||||
*
|
||||
* @param w widget
|
||||
* @param state widget state flag to modify
|
||||
* @param enable specifies whether to turn the flag on (TRUE) or off (FALSE).
|
||||
* Only one flag per call can be modified.
|
||||
* @return TRUE if set was handled successfully, FALSE otherwise
|
||||
*/
|
||||
gboolean
|
||||
widget_set_state (Widget * w, widget_state_t state, gboolean enable)
|
||||
{
|
||||
gboolean ret = TRUE;
|
||||
|
||||
if (enable)
|
||||
w->state |= state;
|
||||
else
|
||||
w->state &= ~state;
|
||||
|
||||
if (enable)
|
||||
{
|
||||
/* exclusive bits */
|
||||
if ((state & WST_CONSTRUCT) != 0)
|
||||
w->state &= ~(WST_ACTIVE | WST_SUSPENDED | WST_CLOSED);
|
||||
else if ((state & WST_ACTIVE) != 0)
|
||||
w->state &= ~(WST_CONSTRUCT | WST_SUSPENDED | WST_CLOSED);
|
||||
else if ((state & WST_SUSPENDED) != 0)
|
||||
w->state &= ~(WST_CONSTRUCT | WST_ACTIVE | WST_CLOSED);
|
||||
else if ((state & WST_CLOSED) != 0)
|
||||
w->state &= ~(WST_CONSTRUCT | WST_ACTIVE | WST_SUSPENDED);
|
||||
}
|
||||
|
||||
if (w->owner == NULL)
|
||||
return FALSE;
|
||||
|
||||
switch (state)
|
||||
{
|
||||
case WST_DISABLED:
|
||||
if (send_message (w, NULL, enable ? MSG_DISABLE : MSG_ENABLE, 0, NULL) != MSG_HANDLED)
|
||||
ret = FALSE;
|
||||
if (ret)
|
||||
send_message (w, NULL, MSG_DRAW, 0, NULL);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
@ -241,7 +277,7 @@ widget_selectcolor (Widget * w, gboolean focused, gboolean hotkey)
|
||||
WDialog *h = w->owner;
|
||||
int color;
|
||||
|
||||
if ((w->options & W_DISABLED) != 0)
|
||||
if (widget_get_state (w, WST_DISABLED))
|
||||
color = DISABLED_COLOR;
|
||||
else if (hotkey)
|
||||
{
|
||||
@ -293,7 +329,7 @@ widget_redraw (Widget * w)
|
||||
{
|
||||
WDialog *h = w->owner;
|
||||
|
||||
if (h != NULL && h->state == DLG_ACTIVE)
|
||||
if (h != NULL && widget_get_state (WIDGET (h), WST_ACTIVE))
|
||||
w->callback (w, NULL, MSG_DRAW, 0, NULL);
|
||||
}
|
||||
}
|
||||
|
@ -16,10 +16,11 @@
|
||||
|
||||
#define widget_move(w, _y, _x) tty_gotoyx (CONST_WIDGET(w)->y + (_y), CONST_WIDGET(w)->x + (_x))
|
||||
/* Sets/clear the specified flag in the options field */
|
||||
#define widget_want_cursor(w,i) widget_set_options(w, W_WANT_CURSOR, i)
|
||||
#define widget_want_hotkey(w,i) widget_set_options(w, W_WANT_HOTKEY, i)
|
||||
#define widget_want_idle(w,i) widget_set_options(w, W_WANT_IDLE, i)
|
||||
#define widget_disable(w,i) widget_set_options(w, W_DISABLED, i)
|
||||
#define widget_want_cursor(w,i) widget_set_options(w, WOP_WANT_CURSOR, i)
|
||||
#define widget_want_hotkey(w,i) widget_set_options(w, WOP_WANT_HOTKEY, i)
|
||||
#define widget_want_tab(w,i) widget_set_options(w, WOP_WANT_TAB, i)
|
||||
#define widget_idle(w,i) widget_set_state(w, WST_IDLE, i)
|
||||
#define widget_disable(w,i) widget_set_state(w, WST_DISABLED, i)
|
||||
|
||||
/*** enums ***************************************************************************************/
|
||||
|
||||
@ -29,6 +30,8 @@ typedef enum
|
||||
MSG_INIT = 0, /* Initialize widget */
|
||||
MSG_FOCUS, /* Draw widget in focused state or widget has got focus */
|
||||
MSG_UNFOCUS, /* Draw widget in unfocused state or widget has been unfocused */
|
||||
MSG_ENABLE, /* Change state to enabled */
|
||||
MSG_DISABLE, /* Change state to disabled */
|
||||
MSG_DRAW, /* Draw widget on screen */
|
||||
MSG_KEY, /* Sent to widgets on key press */
|
||||
MSG_HOTKEY, /* Sent to widget to catch preprocess key */
|
||||
@ -62,32 +65,51 @@ typedef enum
|
||||
/* Widget options */
|
||||
typedef enum
|
||||
{
|
||||
W_DEFAULT = (0 << 0),
|
||||
W_WANT_HOTKEY = (1 << 1),
|
||||
W_WANT_CURSOR = (1 << 2),
|
||||
W_WANT_IDLE = (1 << 3),
|
||||
W_IS_INPUT = (1 << 4),
|
||||
W_DISABLED = (1 << 5) /* Widget cannot be selected */
|
||||
WOP_DEFAULT = (0 << 0),
|
||||
WOP_WANT_HOTKEY = (1 << 1),
|
||||
WOP_WANT_CURSOR = (1 << 2),
|
||||
WOP_WANT_TAB = (1 << 3), /* Should the tab key be sent to the dialog? */
|
||||
WOP_IS_INPUT = (1 << 4),
|
||||
WOP_TOP_SELECT = (1 << 5)
|
||||
} widget_options_t;
|
||||
|
||||
/* Widget state */
|
||||
typedef enum
|
||||
{
|
||||
WST_DEFAULT = (0 << 0),
|
||||
WST_DISABLED = (1 << 0), /* Widget cannot be selected */
|
||||
WST_IDLE = (1 << 1),
|
||||
WST_MODAL = (1 << 2), /* Widget (dialog) is modal */
|
||||
|
||||
WST_CONSTRUCT = (1 << 15), /* Dialog has been constructed but not run yet */
|
||||
WST_ACTIVE = (1 << 16), /* Dialog is visible and active */
|
||||
WST_SUSPENDED = (1 << 17), /* Dialog is suspended */
|
||||
WST_CLOSED = (1 << 18) /* Dialog is closed */
|
||||
} widget_state_t;
|
||||
|
||||
/* Flags for widget repositioning on dialog resize */
|
||||
typedef enum
|
||||
{
|
||||
WPOS_CENTER_HORZ = (1 << 0), /* center widget in horizontal */
|
||||
WPOS_CENTER_VERT = (1 << 1), /* center widget in vertical */
|
||||
WPOS_KEEP_LEFT = (1 << 2), /* keep widget distance to left border of dialog */
|
||||
WPOS_KEEP_RIGHT = (1 << 3), /* keep widget distance to right border of dialog */
|
||||
WPOS_KEEP_TOP = (1 << 4), /* keep widget distance to top border of dialog */
|
||||
WPOS_KEEP_BOTTOM = (1 << 5), /* keep widget distance to bottom border of dialog */
|
||||
WPOS_FULLSCREEN = (1 << 0), /* widget occupies the whole screen */
|
||||
WPOS_CENTER_HORZ = (1 << 1), /* center widget in horizontal */
|
||||
WPOS_CENTER_VERT = (1 << 2), /* center widget in vertical */
|
||||
WPOS_CENTER = WPOS_CENTER_HORZ | WPOS_CENTER_VERT, /* center widget */
|
||||
WPOS_TRYUP = (1 << 3), /* try to move two lines up the widget */
|
||||
WPOS_KEEP_LEFT = (1 << 4), /* keep widget distance to left border of dialog */
|
||||
WPOS_KEEP_RIGHT = (1 << 5), /* keep widget distance to right border of dialog */
|
||||
WPOS_KEEP_TOP = (1 << 6), /* keep widget distance to top border of dialog */
|
||||
WPOS_KEEP_BOTTOM = (1 << 7), /* keep widget distance to bottom border of dialog */
|
||||
WPOS_KEEP_HORZ = WPOS_KEEP_LEFT | WPOS_KEEP_RIGHT,
|
||||
WPOS_KEEP_VERT = WPOS_KEEP_TOP | WPOS_KEEP_BOTTOM,
|
||||
WPOS_KEEP_ALL = WPOS_KEEP_HORZ | WPOS_KEEP_VERT,
|
||||
WPOS_KEEP_DEFAULT = WPOS_KEEP_LEFT | WPOS_KEEP_TOP
|
||||
} widget_pos_flags_t;
|
||||
/* NOTE: if WPOS_CENTER_HORZ flag is used, other horizontal flags (WPOS_KEEP_LEFT, WPOS_KEEP_RIGHT,
|
||||
* and WPOS_KEEP_HORZ are ignored).
|
||||
/* NOTES:
|
||||
* If WPOS_FULLSCREEN is set then all other position flags are ignored.
|
||||
* If WPOS_CENTER_HORZ flag is used, other horizontal flags (WPOS_KEEP_LEFT, WPOS_KEEP_RIGHT,
|
||||
* and WPOS_KEEP_HORZ) are ignored.
|
||||
* If WPOS_CENTER_VERT flag is used, other horizontal flags (WPOS_KEEP_TOP, WPOS_KEEP_BOTTOM,
|
||||
* and WPOS_KEEP_VERT are ignored).
|
||||
* and WPOS_KEEP_VERT) are ignored.
|
||||
*/
|
||||
|
||||
/*** structures declarations (and typedefs of structures)*****************************************/
|
||||
@ -103,12 +125,12 @@ struct Widget
|
||||
{
|
||||
int x, y;
|
||||
int cols, lines;
|
||||
widget_options_t options;
|
||||
widget_pos_flags_t pos_flags; /* repositioning flags */
|
||||
widget_options_t options;
|
||||
widget_state_t state;
|
||||
unsigned int id; /* Number of the widget, starting with 0 */
|
||||
widget_cb_fn callback;
|
||||
widget_mouse_cb_fn mouse_callback;
|
||||
void (*set_options) (Widget * w, widget_options_t options, gboolean enable);
|
||||
WDialog *owner;
|
||||
/* Mouse-related fields. */
|
||||
struct
|
||||
@ -153,8 +175,8 @@ void widget_init (Widget * w, int y, int x, int lines, int cols,
|
||||
/* Default callback for widgets */
|
||||
cb_ret_t widget_default_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm,
|
||||
void *data);
|
||||
void widget_default_set_options_callback (Widget * w, widget_options_t options, gboolean enable);
|
||||
void widget_set_options (Widget * w, widget_options_t options, gboolean enable);
|
||||
gboolean widget_set_state (Widget * w, widget_state_t state, gboolean enable);
|
||||
void widget_set_size (Widget * widget, int y, int x, int lines, int cols);
|
||||
/* select color for widget in dependance of state */
|
||||
void widget_selectcolor (Widget * w, gboolean focused, gboolean hotkey);
|
||||
@ -185,6 +207,37 @@ send_message (void *w, void *sender, widget_msg_t msg, int parm, void *data)
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
/**
|
||||
* Check whether one or several option flags are set or not.
|
||||
* @param w widget
|
||||
* @param options widget option flags
|
||||
*
|
||||
* @return TRUE if all requested option flags are set, FALSE otherwise.
|
||||
*/
|
||||
|
||||
static inline gboolean
|
||||
widget_get_options (const Widget * w, widget_options_t options)
|
||||
{
|
||||
return ((w->options & options) == options);
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* Check whether one or several state flags are set or not.
|
||||
* @param w widget
|
||||
* @param state widget state flags
|
||||
*
|
||||
* @return TRUE if all requested state flags are set, FALSE otherwise.
|
||||
*/
|
||||
|
||||
static inline gboolean
|
||||
widget_get_state (const Widget * w, widget_state_t state)
|
||||
{
|
||||
return ((w->state & state) == state);
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
#endif /* MC__WIDGET_INTERNAL_H */
|
||||
|
@ -70,7 +70,7 @@ query_default_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm,
|
||||
switch (msg)
|
||||
{
|
||||
case MSG_RESIZE:
|
||||
if ((h->flags & DLG_CENTER) == 0)
|
||||
if ((w->pos_flags & WPOS_CENTER) == 0)
|
||||
{
|
||||
WDialog *prev_dlg = NULL;
|
||||
int ypos, xpos;
|
||||
@ -93,7 +93,7 @@ query_default_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm,
|
||||
}
|
||||
|
||||
/* if previous dialog is not fullscreen'd -- overlap it */
|
||||
if (prev_dlg == NULL || prev_dlg->fullscreen)
|
||||
if (prev_dlg == NULL || (WIDGET (prev_dlg)->pos_flags & WPOS_FULLSCREEN) != 0)
|
||||
ypos = LINES / 3 - (w->lines - 3) / 2;
|
||||
else
|
||||
ypos = WIDGET (prev_dlg)->y + 2;
|
||||
@ -101,7 +101,7 @@ query_default_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm,
|
||||
xpos = COLS / 2 - w->cols / 2;
|
||||
|
||||
/* set position */
|
||||
dlg_set_position (h, ypos, xpos, ypos + w->lines, xpos + w->cols);
|
||||
dlg_set_position (h, ypos, xpos, w->lines, w->cols);
|
||||
|
||||
return MSG_HANDLED;
|
||||
}
|
||||
@ -279,7 +279,8 @@ query_dialog (const char *header, const char *text, int flags, int count, ...)
|
||||
int result = -1;
|
||||
int cols, lines;
|
||||
const int *query_colors = (flags & D_ERROR) != 0 ? alarm_colors : dialog_colors;
|
||||
dlg_flags_t dlg_flags = (flags & D_CENTER) != 0 ? (DLG_CENTER | DLG_TRYUP) : DLG_NONE;
|
||||
widget_pos_flags_t pos_flags =
|
||||
(flags & D_CENTER) != 0 ? (WPOS_CENTER | WPOS_TRYUP) : WPOS_KEEP_DEFAULT;
|
||||
|
||||
if (header == MSG_ERROR)
|
||||
header = _("Error");
|
||||
@ -304,8 +305,8 @@ query_dialog (const char *header, const char *text, int flags, int count, ...)
|
||||
|
||||
/* prepare dialog */
|
||||
query_dlg =
|
||||
dlg_create (TRUE, 0, 0, lines, cols, query_colors, query_default_callback, NULL,
|
||||
"[QueryBox]", header, dlg_flags);
|
||||
dlg_create (TRUE, 0, 0, lines, cols, pos_flags, FALSE, query_colors, query_default_callback,
|
||||
NULL, "[QueryBox]", header);
|
||||
|
||||
if (count > 0)
|
||||
{
|
||||
@ -585,8 +586,8 @@ status_msg_init (status_msg_t * sm, const char *title, double delay, status_msg_
|
||||
|
||||
start = mc_timer_elapsed (mc_global.timer);
|
||||
|
||||
sm->dlg = dlg_create (TRUE, 0, 0, 7, MIN (MAX (40, COLS / 2), COLS), dialog_colors,
|
||||
NULL, NULL, NULL, title, DLG_CENTER);
|
||||
sm->dlg = dlg_create (TRUE, 0, 0, 7, MIN (MAX (40, COLS / 2), COLS), WPOS_CENTER, FALSE,
|
||||
dialog_colors, NULL, NULL, NULL, title);
|
||||
sm->start = start;
|
||||
sm->delay = (guint64) (delay * G_USEC_PER_SEC);
|
||||
sm->block = FALSE;
|
||||
@ -648,7 +649,7 @@ status_msg_common_update (status_msg_t * sm)
|
||||
if (sm->dlg == NULL)
|
||||
return B_ENTER;
|
||||
|
||||
if (sm->dlg->state != DLG_ACTIVE)
|
||||
if (widget_get_state (WIDGET (sm->dlg), WST_CONSTRUCT))
|
||||
{
|
||||
/* dialog is not shown yet */
|
||||
|
||||
|
@ -1,4 +1,6 @@
|
||||
/*
|
||||
File difference viewer
|
||||
|
||||
Copyright (C) 2007-2016
|
||||
Free Software Foundation, Inc.
|
||||
|
||||
@ -2888,10 +2890,13 @@ dview_edit (WDiff * dview, diff_place_t ord)
|
||||
}
|
||||
|
||||
h = WIDGET (dview)->owner;
|
||||
h_modal = h->modal;
|
||||
h_modal = widget_get_state (WIDGET (h), WST_MODAL);
|
||||
|
||||
get_line_numbers (dview->a[ord], dview->skip_rows, &linenum, &lineofs);
|
||||
h->modal = TRUE; /* not allow edit file in several editors */
|
||||
|
||||
/* disallow edit file in several editors */
|
||||
widget_set_state (WIDGET (h), WST_MODAL, TRUE);
|
||||
|
||||
{
|
||||
vfs_path_t *tmp_vpath;
|
||||
|
||||
@ -2899,7 +2904,8 @@ dview_edit (WDiff * dview, diff_place_t ord)
|
||||
edit_file_at_line (tmp_vpath, use_internal_edit != 0, linenum);
|
||||
vfs_path_free (tmp_vpath);
|
||||
}
|
||||
h->modal = h_modal;
|
||||
|
||||
widget_set_state (WIDGET (h), WST_MODAL, h_modal);
|
||||
dview_redo (dview);
|
||||
dview_update (dview);
|
||||
}
|
||||
@ -3388,7 +3394,7 @@ dview_adjust_size (WDialog * h)
|
||||
static cb_ret_t
|
||||
dview_dialog_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm, void *data)
|
||||
{
|
||||
WDiff *dview = (WDiff *) data;
|
||||
WDiff *dview;
|
||||
WDialog *h = DIALOG (w);
|
||||
|
||||
switch (msg)
|
||||
@ -3406,9 +3412,10 @@ dview_dialog_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm,
|
||||
|
||||
case MSG_VALIDATE:
|
||||
dview = (WDiff *) find_widget_type (h, dview_callback);
|
||||
h->state = DLG_ACTIVE; /* don't stop the dialog before final decision */
|
||||
/* don't stop the dialog before final decision */
|
||||
widget_set_state (w, WST_ACTIVE, TRUE);
|
||||
if (dview_ok_to_exit (dview))
|
||||
h->state = DLG_CLOSED;
|
||||
dlg_stop (h);
|
||||
return MSG_HANDLED;
|
||||
|
||||
default:
|
||||
@ -3453,13 +3460,13 @@ diff_view (const char *file1, const char *file2, const char *label1, const char
|
||||
|
||||
/* Create dialog and widgets, put them on the dialog */
|
||||
dview_dlg =
|
||||
dlg_create (FALSE, 0, 0, LINES, COLS, NULL, dview_dialog_callback, NULL,
|
||||
"[Diff Viewer]", NULL, DLG_WANT_TAB);
|
||||
dlg_create (FALSE, 0, 0, 1, 1, WPOS_FULLSCREEN, FALSE, NULL, dview_dialog_callback, NULL,
|
||||
"[Diff Viewer]", NULL);
|
||||
widget_want_tab (WIDGET (dview_dlg), TRUE);
|
||||
|
||||
dview = g_new0 (WDiff, 1);
|
||||
w = WIDGET (dview);
|
||||
widget_init (w, 0, 0, LINES - 1, COLS, dview_callback, dview_mouse_callback);
|
||||
widget_want_cursor (w, FALSE);
|
||||
|
||||
add_widget (dview_dlg, dview);
|
||||
add_widget (dview_dlg, buttonbar_new (TRUE));
|
||||
@ -3475,7 +3482,7 @@ diff_view (const char *file1, const char *file2, const char *label1, const char
|
||||
if (error == 0)
|
||||
dlg_run (dview_dlg);
|
||||
|
||||
if ((error != 0) || (dview_dlg->state == DLG_CLOSED))
|
||||
if (error != 0 || widget_get_state (WIDGET (dview_dlg), WST_CLOSED))
|
||||
dlg_destroy (dview_dlg);
|
||||
|
||||
return error == 0 ? 1 : 0;
|
||||
|
@ -2097,6 +2097,8 @@ edit_init (WEdit * edit, int y, int x, int lines, int cols, const vfs_path_t * f
|
||||
to_free = TRUE;
|
||||
|
||||
widget_init (WIDGET (edit), y, x, lines, cols, NULL, NULL);
|
||||
widget_want_cursor (WIDGET (edit), TRUE);
|
||||
widget_set_options (WIDGET (edit), WOP_TOP_SELECT, TRUE);
|
||||
edit->fullscreen = TRUE;
|
||||
edit_save_size (edit);
|
||||
}
|
||||
|
@ -2262,7 +2262,7 @@ edit_close_cmd (WEdit * edit)
|
||||
{
|
||||
edit = find_editor (h);
|
||||
if (edit != NULL)
|
||||
dlg_set_top_widget (edit);
|
||||
dlg_select_widget (edit);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -320,8 +320,9 @@ editcmd_dialog_raw_key_query (const char *heading, const char *query, gboolean c
|
||||
w = MAX (w, wq + 3 * 2 + 1 + 2);
|
||||
|
||||
raw_dlg =
|
||||
dlg_create (TRUE, 0, 0, cancel ? 7 : 5, w, dialog_colors, editcmd_dialog_raw_key_query_cb,
|
||||
NULL, NULL, heading, DLG_CENTER | DLG_TRYUP | DLG_WANT_TAB);
|
||||
dlg_create (TRUE, 0, 0, cancel ? 7 : 5, w, WPOS_CENTER | WPOS_TRYUP, FALSE, dialog_colors,
|
||||
editcmd_dialog_raw_key_query_cb, NULL, NULL, heading);
|
||||
widget_want_tab (WIDGET (raw_dlg), TRUE);
|
||||
|
||||
add_widget (raw_dlg, label_new (y, 3, query));
|
||||
add_widget (raw_dlg, input_new (y++, 3 + wq + 1, input_colors,
|
||||
@ -379,8 +380,8 @@ editcmd_dialog_completion_show (const WEdit * edit, int max_len, GString ** comp
|
||||
|
||||
/* create the dialog */
|
||||
compl_dlg =
|
||||
dlg_create (TRUE, start_y, start_x, compl_dlg_h, compl_dlg_w,
|
||||
dialog_colors, NULL, NULL, "[Completion]", NULL, DLG_COMPACT);
|
||||
dlg_create (TRUE, start_y, start_x, compl_dlg_h, compl_dlg_w, WPOS_KEEP_DEFAULT, TRUE,
|
||||
dialog_colors, NULL, NULL, "[Completion]", NULL);
|
||||
|
||||
/* create the listbox */
|
||||
compl_list = listbox_new (1, 1, compl_dlg_h - 2, compl_dlg_w - 2, FALSE, NULL);
|
||||
@ -445,8 +446,8 @@ editcmd_dialog_select_definition_show (WEdit * edit, char *match_expr, int max_l
|
||||
start_y -= (offset + 1);
|
||||
|
||||
/* create the dialog */
|
||||
def_dlg = dlg_create (TRUE, start_y, start_x, def_dlg_h, def_dlg_w,
|
||||
dialog_colors, NULL, NULL, "[Definitions]", match_expr, DLG_COMPACT);
|
||||
def_dlg = dlg_create (TRUE, start_y, start_x, def_dlg_h, def_dlg_w, WPOS_KEEP_DEFAULT, TRUE,
|
||||
dialog_colors, NULL, NULL, "[Definitions]", match_expr);
|
||||
|
||||
/* create the listbox */
|
||||
def_list = listbox_new (1, 1, def_dlg_h - 2, def_dlg_w - 2, FALSE, NULL);
|
||||
|
@ -356,7 +356,7 @@ edit_window_list (const WDialog * h)
|
||||
if (rv >= 0)
|
||||
{
|
||||
w = g_list_nth (h->widgets, rv + offset);
|
||||
dlg_set_top_widget (w->data);
|
||||
dlg_select_widget (w->data);
|
||||
}
|
||||
}
|
||||
|
||||
@ -485,11 +485,11 @@ edit_dialog_command_execute (WDialog * h, long command)
|
||||
break;
|
||||
case CK_WindowNext:
|
||||
dlg_one_down (h);
|
||||
dlg_set_top_widget (h->current->data);
|
||||
dlg_select_widget (h->current->data);
|
||||
break;
|
||||
case CK_WindowPrev:
|
||||
dlg_one_up (h);
|
||||
dlg_set_top_widget (h->current->data);
|
||||
dlg_select_widget (h->current->data);
|
||||
break;
|
||||
case CK_Options:
|
||||
edit_options_dialog (h);
|
||||
@ -641,7 +641,8 @@ edit_quit (WDialog * h)
|
||||
GList *l;
|
||||
WEdit *e = NULL;
|
||||
|
||||
h->state = DLG_ACTIVE; /* don't stop the dialog before final decision */
|
||||
/* don't stop the dialog before final decision */
|
||||
widget_set_state (WIDGET (h), WST_ACTIVE, TRUE);
|
||||
|
||||
for (l = h->widgets; l != NULL; l = g_list_next (l))
|
||||
if (edit_widget_is_editor (CONST_WIDGET (l->data)))
|
||||
@ -665,7 +666,7 @@ edit_quit (WDialog * h)
|
||||
|
||||
/* no editors in dialog at all or no any file required to be saved */
|
||||
if (e == NULL || l == NULL)
|
||||
h->state = DLG_CLOSED;
|
||||
dlg_stop (h);
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
@ -835,7 +836,7 @@ edit_dialog_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm, v
|
||||
* So let's trigger an IDLE signal.
|
||||
*/
|
||||
if (!is_idle ())
|
||||
widget_want_idle (w, TRUE);
|
||||
widget_idle (w, TRUE);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -852,7 +853,7 @@ edit_dialog_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm, v
|
||||
return MSG_HANDLED;
|
||||
|
||||
case MSG_IDLE:
|
||||
widget_want_idle (w, FALSE);
|
||||
widget_idle (w, FALSE);
|
||||
return send_message (h->current->data, NULL, MSG_IDLE, 0, NULL);
|
||||
|
||||
default:
|
||||
@ -905,7 +906,7 @@ edit_dialog_mouse_callback (Widget * w, mouse_msg_t msg, mouse_event_t * event)
|
||||
if (top != h->current)
|
||||
{
|
||||
/* Window is not active. Activate it */
|
||||
dlg_set_top_widget (e);
|
||||
dlg_select_widget (e);
|
||||
}
|
||||
|
||||
/* Handle buttons */
|
||||
@ -1086,7 +1087,7 @@ edit_mouse_callback (Widget * w, mouse_msg_t msg, mouse_event_t * event)
|
||||
switch (msg)
|
||||
{
|
||||
case MSG_MOUSE_DOWN:
|
||||
dlg_set_top_widget (w);
|
||||
dlg_select_widget (w);
|
||||
edit_update_curs_row (edit);
|
||||
edit_update_curs_col (edit);
|
||||
|
||||
@ -1222,8 +1223,9 @@ edit_files (const GList * files)
|
||||
|
||||
/* Create a new dialog and add it widgets to it */
|
||||
edit_dlg =
|
||||
dlg_create (FALSE, 0, 0, LINES, COLS, NULL, edit_dialog_callback,
|
||||
edit_dialog_mouse_callback, "[Internal File Editor]", NULL, DLG_WANT_TAB);
|
||||
dlg_create (FALSE, 0, 0, 1, 1, WPOS_FULLSCREEN, FALSE, NULL, edit_dialog_callback,
|
||||
edit_dialog_mouse_callback, "[Internal File Editor]", NULL);
|
||||
widget_want_tab (WIDGET (edit_dlg), TRUE);
|
||||
|
||||
edit_dlg->get_shortcut = edit_get_shortcut;
|
||||
edit_dlg->get_title = edit_get_title;
|
||||
@ -1249,7 +1251,7 @@ edit_files (const GList * files)
|
||||
if (ok)
|
||||
dlg_run (edit_dlg);
|
||||
|
||||
if (!ok || edit_dlg->state == DLG_CLOSED)
|
||||
if (!ok || widget_get_state (WIDGET (edit_dlg), WST_CLOSED))
|
||||
dlg_destroy (edit_dlg);
|
||||
|
||||
return ok;
|
||||
|
@ -109,8 +109,8 @@ spell_dialog_spell_suggest_show (WEdit * edit, const char *word, char **new_word
|
||||
sug_dlg_w += max_btn_len;
|
||||
sug_dlg_w = MAX (sug_dlg_w, word_label_len) + 1;
|
||||
|
||||
sug_dlg = dlg_create (TRUE, ypos, xpos, sug_dlg_h, sug_dlg_w,
|
||||
dialog_colors, NULL, NULL, "[ASpell]", _("Check word"), DLG_COMPACT);
|
||||
sug_dlg = dlg_create (TRUE, ypos, xpos, sug_dlg_h, sug_dlg_w, WPOS_KEEP_DEFAULT, TRUE,
|
||||
dialog_colors, NULL, NULL, "[ASpell]", _("Check word"));
|
||||
|
||||
add_widget (sug_dlg, label_new (1, 2, lang_label));
|
||||
add_widget (sug_dlg, label_new (3, 2, word_label));
|
||||
|
@ -340,8 +340,8 @@ do_enter_key (WDialog * h, int f_pos)
|
||||
chl_end = FALSE;
|
||||
|
||||
chl_dlg =
|
||||
dlg_create (TRUE, lyy, lxx, 13, 17, dialog_colors, chl_callback, NULL,
|
||||
"[Advanced Chown]", title, DLG_COMPACT);
|
||||
dlg_create (TRUE, lyy, lxx, 13, 17, WPOS_KEEP_DEFAULT, TRUE, dialog_colors,
|
||||
chl_callback, NULL, "[Advanced Chown]", title);
|
||||
|
||||
/* get new listboxes */
|
||||
chl_list = listbox_new (1, 1, 11, 15, FALSE, NULL);
|
||||
@ -674,8 +674,8 @@ init_chown_advanced (void)
|
||||
dlg_h += 2;
|
||||
|
||||
ch_dlg =
|
||||
dlg_create (TRUE, 0, 0, dlg_h, dlg_w, dialog_colors, advanced_chown_callback, NULL,
|
||||
"[Advanced Chown]", _("Chown advanced command"), DLG_CENTER);
|
||||
dlg_create (TRUE, 0, 0, dlg_h, dlg_w, WPOS_CENTER, FALSE, dialog_colors,
|
||||
advanced_chown_callback, NULL, "[Advanced Chown]", _("Chown advanced command"));
|
||||
|
||||
|
||||
l_filename = label_new (2, 3, "");
|
||||
|
@ -198,8 +198,8 @@ sel_skin_button (WButton * button, int action)
|
||||
lxx = COLS / 2;
|
||||
lyy = (LINES - 13) / 2;
|
||||
skin_dlg =
|
||||
dlg_create (TRUE, lyy, lxx, 13, 24, dialog_colors, NULL, NULL, "[Appearance]", _("Skins"),
|
||||
DLG_COMPACT);
|
||||
dlg_create (TRUE, lyy, lxx, 13, 24, WPOS_KEEP_DEFAULT, TRUE, dialog_colors, NULL, NULL,
|
||||
"[Appearance]", _("Skins"));
|
||||
|
||||
skin_list = listbox_new (1, 1, 11, 22, FALSE, NULL);
|
||||
skin_name = "default";
|
||||
@ -538,15 +538,15 @@ configure_box (void)
|
||||
g_snprintf (time_out, sizeof (time_out), "%d", old_esc_mode_timeout);
|
||||
|
||||
#ifndef USE_INTERNAL_EDIT
|
||||
quick_widgets[17].options = W_DISABLED;
|
||||
quick_widgets[17].state = WST_DISABLED;
|
||||
#endif
|
||||
|
||||
if (!old_esc_mode)
|
||||
quick_widgets[10].options = quick_widgets[11].options = W_DISABLED;
|
||||
quick_widgets[10].state = quick_widgets[11].state = WST_DISABLED;
|
||||
|
||||
#ifndef HAVE_POSIX_FALLOCATE
|
||||
mc_global.vfs.preallocate_space = FALSE;
|
||||
quick_widgets[7].options = W_DISABLED;
|
||||
quick_widgets[7].state = WST_DISABLED;
|
||||
#endif
|
||||
|
||||
if (quick_dialog (&qdlg) == B_ENTER)
|
||||
@ -761,13 +761,13 @@ panel_listing_box (WPanel * panel, int num, char **userp, char **minip, int *use
|
||||
g_snprintf (panel_brief_cols_in, sizeof (panel_brief_cols_in), "%d", panel->brief_cols);
|
||||
|
||||
if ((int) panel->list_type != panel_listing_brief_idx)
|
||||
quick_widgets[4].options = W_DISABLED;
|
||||
quick_widgets[4].state = WST_DISABLED;
|
||||
|
||||
if ((int) panel->list_type != panel_listing_user_idx)
|
||||
quick_widgets[6].options = W_DISABLED;
|
||||
quick_widgets[6].state = WST_DISABLED;
|
||||
|
||||
if (!mini_user_status)
|
||||
quick_widgets[9].options = W_DISABLED;
|
||||
quick_widgets[9].state = WST_DISABLED;
|
||||
|
||||
if (quick_dialog (&qdlg) == B_CANCEL)
|
||||
result = -1;
|
||||
@ -1020,8 +1020,8 @@ tree_box (const char *current_dir)
|
||||
(void) current_dir;
|
||||
|
||||
/* Create the components */
|
||||
dlg = dlg_create (TRUE, 0, 0, LINES - 9, COLS - 20, dialog_colors, tree_callback, NULL,
|
||||
"[Directory Tree]", _("Directory tree"), DLG_CENTER);
|
||||
dlg = dlg_create (TRUE, 0, 0, LINES - 9, COLS - 20, WPOS_CENTER, FALSE, dialog_colors,
|
||||
tree_callback, NULL, "[Directory Tree]", _("Directory tree"));
|
||||
wd = WIDGET (dlg);
|
||||
|
||||
mytree = tree_new (2, 2, wd->lines - 6, wd->cols - 5, FALSE);
|
||||
@ -1109,7 +1109,7 @@ configure_vfs (void)
|
||||
|
||||
#ifdef ENABLE_VFS_FTP
|
||||
if (!ftpfs_always_use_proxy)
|
||||
quick_widgets[5].options = W_DISABLED;
|
||||
quick_widgets[5].state = WST_DISABLED;
|
||||
#endif
|
||||
|
||||
if (quick_dialog (&qdlg) != B_CANCEL)
|
||||
@ -1240,8 +1240,8 @@ jobs_cmd (void)
|
||||
x += (int) n_but - 1;
|
||||
cols = MAX (cols, x + 6);
|
||||
|
||||
jobs_dlg = dlg_create (TRUE, 0, 0, lines, cols, dialog_colors, NULL, NULL,
|
||||
"[Background jobs]", _("Background jobs"), DLG_CENTER);
|
||||
jobs_dlg = dlg_create (TRUE, 0, 0, lines, cols, WPOS_CENTER, FALSE, dialog_colors, NULL, NULL,
|
||||
"[Background jobs]", _("Background jobs"));
|
||||
|
||||
bg_list = listbox_new (2, 2, lines - 6, cols - 6, FALSE, NULL);
|
||||
jobs_fill_listbox (bg_list);
|
||||
|
@ -305,8 +305,8 @@ init_chmod (const char *fname, const struct stat *sf_stat)
|
||||
}
|
||||
|
||||
ch_dlg =
|
||||
dlg_create (TRUE, 0, 0, lines, cols, dialog_colors,
|
||||
chmod_callback, NULL, "[Chmod]", _("Chmod command"), DLG_CENTER);
|
||||
dlg_create (TRUE, 0, 0, lines, cols, WPOS_CENTER, FALSE, dialog_colors,
|
||||
chmod_callback, NULL, "[Chmod]", _("Chmod command"));
|
||||
|
||||
add_widget (ch_dlg, groupbox_new (PY, PX, check_perm_num + 2, perm_gb_len, _("Permission")));
|
||||
|
||||
|
@ -213,8 +213,8 @@ init_chown (void)
|
||||
lines = GH + 4 + (single_set ? 2 : 4);
|
||||
|
||||
ch_dlg =
|
||||
dlg_create (TRUE, 0, 0, lines, cols, dialog_colors, chown_callback, NULL, "[Chown]",
|
||||
_("Chown command"), DLG_CENTER);
|
||||
dlg_create (TRUE, 0, 0, lines, cols, WPOS_CENTER, FALSE, dialog_colors, chown_callback,
|
||||
NULL, "[Chown]", _("Chown command"));
|
||||
|
||||
add_widget (ch_dlg, groupbox_new (2, 3, GH, GW, _("User name")));
|
||||
l_user = listbox_new (3, 4, GH - 2, GW - 2, FALSE, NULL);
|
||||
|
@ -542,8 +542,8 @@ overwrite_query_dialog (file_op_context_t * ctx, enum OperationMode mode)
|
||||
|
||||
/* FIXME - missing help node */
|
||||
ui->replace_dlg =
|
||||
dlg_create (TRUE, 0, 0, rd_ylen, rd_xlen, alarm_colors, NULL, NULL, "[Replace]", title,
|
||||
DLG_CENTER);
|
||||
dlg_create (TRUE, 0, 0, rd_ylen, rd_xlen, WPOS_CENTER, FALSE, alarm_colors, NULL, NULL,
|
||||
"[Replace]", title);
|
||||
|
||||
/* prompt */
|
||||
ADD_RD_LABEL (0, "", "", y++);
|
||||
@ -746,8 +746,8 @@ file_op_context_create_ui (file_op_context_t * ctx, gboolean with_eta,
|
||||
ui->replace_result = REPLACE_YES;
|
||||
|
||||
ui->op_dlg =
|
||||
dlg_create (TRUE, 0, 0, dlg_height, dlg_width, dialog_colors, NULL, NULL, NULL,
|
||||
op_names[ctx->operation], DLG_CENTER);
|
||||
dlg_create (TRUE, 0, 0, dlg_height, dlg_width, WPOS_CENTER, FALSE, dialog_colors, NULL,
|
||||
NULL, NULL, op_names[ctx->operation]);
|
||||
|
||||
if (dialog_type != FILEGUI_DIALOG_DELETE_ITEM)
|
||||
{
|
||||
|
@ -353,7 +353,7 @@ add_to_list (const char *text, void *data)
|
||||
static inline void
|
||||
stop_idle (void *data)
|
||||
{
|
||||
widget_want_idle (WIDGET (data), FALSE);
|
||||
widget_idle (WIDGET (data), FALSE);
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
@ -498,7 +498,8 @@ find_parm_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm, voi
|
||||
if (!(file_pattern_cbox->state & C_BOOL)
|
||||
&& (in_name->buffer[0] != '\0') && !find_check_regexp (in_name->buffer))
|
||||
{
|
||||
h->state = DLG_ACTIVE; /* Don't stop the dialog */
|
||||
/* Don't stop the dialog */
|
||||
widget_set_state (WIDGET (h), WST_ACTIVE, TRUE);
|
||||
message (D_ERROR, MSG_ERROR, _("Malformed regular expression"));
|
||||
dlg_select_widget (in_name);
|
||||
return MSG_HANDLED;
|
||||
@ -508,7 +509,8 @@ find_parm_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm, voi
|
||||
if ((content_regexp_cbox->state & C_BOOL) && (in_with->buffer[0] != '\0')
|
||||
&& !find_check_regexp (in_with->buffer))
|
||||
{
|
||||
h->state = DLG_ACTIVE; /* Don't stop the dialog */
|
||||
/* Don't stop the dialog */
|
||||
widget_set_state (WIDGET (h), WST_ACTIVE, TRUE);
|
||||
message (D_ERROR, MSG_ERROR, _("Malformed regular expression"));
|
||||
dlg_select_widget (in_with);
|
||||
return MSG_HANDLED;
|
||||
@ -659,8 +661,8 @@ find_parameters (char **start_dir, ssize_t * start_dir_len,
|
||||
in_start_dir = g_strdup (".");
|
||||
|
||||
find_dlg =
|
||||
dlg_create (TRUE, 0, 0, lines, cols, dialog_colors, find_parm_callback, NULL, "[Find File]",
|
||||
_("Find File"), DLG_CENTER);
|
||||
dlg_create (TRUE, 0, 0, lines, cols, WPOS_CENTER, FALSE, dialog_colors, find_parm_callback,
|
||||
NULL, "[Find File]", _("Find File"));
|
||||
|
||||
x1 = 3;
|
||||
x2 = cols / 2 + 1;
|
||||
@ -955,7 +957,7 @@ check_find_events (WDialog * h)
|
||||
/* dialog terminated */
|
||||
return FIND_ABORT;
|
||||
}
|
||||
if ((WIDGET (h)->options & W_WANT_IDLE) == 0)
|
||||
if (!widget_get_state (WIDGET (h), WST_IDLE))
|
||||
{
|
||||
/* searching suspended */
|
||||
return FIND_SUSPEND;
|
||||
@ -1545,7 +1547,7 @@ start_stop (WButton * button, int action)
|
||||
(void) action;
|
||||
|
||||
running = is_start;
|
||||
widget_want_idle (WIDGET (find_dlg), running);
|
||||
widget_idle (WIDGET (find_dlg), running);
|
||||
is_start = !is_start;
|
||||
|
||||
status_update (is_start ? _("Stopped") : _("Searching"));
|
||||
@ -1613,8 +1615,8 @@ setup_gui (void)
|
||||
cols = COLS - 16;
|
||||
|
||||
find_dlg =
|
||||
dlg_create (TRUE, 0, 0, lines, cols, dialog_colors, find_callback, NULL, "[Find File]",
|
||||
_("Find File"), DLG_CENTER);
|
||||
dlg_create (TRUE, 0, 0, lines, cols, WPOS_CENTER, FALSE, dialog_colors, find_callback, NULL,
|
||||
"[Find File]", _("Find File"));
|
||||
|
||||
find_calc_button_locations (find_dlg, TRUE);
|
||||
|
||||
@ -1681,7 +1683,7 @@ run_process (void)
|
||||
|
||||
resuming = FALSE;
|
||||
|
||||
widget_want_idle (WIDGET (find_dlg), TRUE);
|
||||
widget_idle (WIDGET (find_dlg), TRUE);
|
||||
ret = dlg_run (find_dlg);
|
||||
|
||||
mc_search_free (search_file_handle);
|
||||
@ -1697,7 +1699,7 @@ run_process (void)
|
||||
static void
|
||||
kill_gui (void)
|
||||
{
|
||||
widget_want_idle (WIDGET (find_dlg), FALSE);
|
||||
widget_idle (WIDGET (find_dlg), FALSE);
|
||||
dlg_destroy (find_dlg);
|
||||
}
|
||||
|
||||
|
@ -759,8 +759,8 @@ init_hotlist (hotlist_t list_type)
|
||||
}
|
||||
|
||||
hotlist_dlg =
|
||||
dlg_create (TRUE, 0, 0, lines, cols, dialog_colors, hotlist_callback, NULL, help_node,
|
||||
title, DLG_CENTER);
|
||||
dlg_create (TRUE, 0, 0, lines, cols, WPOS_CENTER, FALSE, dialog_colors, hotlist_callback,
|
||||
NULL, help_node, title);
|
||||
|
||||
y = UY;
|
||||
hotlist_group = groupbox_new (y, UX, lines - 10 + dh, cols - 2 * UX, _("Top level group"));
|
||||
@ -827,8 +827,8 @@ init_movelist (struct hotlist *item)
|
||||
hdr = g_strdup_printf (_("Moving %s"), item->label);
|
||||
|
||||
movelist_dlg =
|
||||
dlg_create (TRUE, 0, 0, lines, cols, dialog_colors, hotlist_callback, NULL, "[Hotlist]",
|
||||
hdr, DLG_CENTER);
|
||||
dlg_create (TRUE, 0, 0, lines, cols, WPOS_CENTER, FALSE, dialog_colors, hotlist_callback,
|
||||
NULL, "[Hotlist]", hdr);
|
||||
|
||||
g_free (hdr);
|
||||
|
||||
|
@ -339,8 +339,6 @@ info_new (int y, int x, int lines, int cols)
|
||||
info = g_new (struct WInfo, 1);
|
||||
w = WIDGET (info);
|
||||
widget_init (w, y, x, lines, cols, info_callback, NULL);
|
||||
/* We do not want the cursor */
|
||||
widget_want_cursor (w, FALSE);
|
||||
|
||||
return info;
|
||||
}
|
||||
|
@ -510,8 +510,8 @@ init_layout (void)
|
||||
width = max (l1 * 2 + 7, b);
|
||||
|
||||
layout_dlg =
|
||||
dlg_create (TRUE, 0, 0, 15, width, dialog_colors, layout_callback, NULL, "[Layout]",
|
||||
_("Layout"), DLG_CENTER);
|
||||
dlg_create (TRUE, 0, 0, 15, width, WPOS_CENTER, FALSE, dialog_colors, layout_callback, NULL,
|
||||
"[Layout]", _("Layout"));
|
||||
|
||||
#define XTRACT(i) *check_options[i].variable, check_options[i].text
|
||||
|
||||
@ -538,21 +538,23 @@ init_layout (void)
|
||||
|
||||
/* "Console output" groupbox */
|
||||
{
|
||||
const int disabled = mc_global.tty.console_flag != '\0' ? 0 : W_DISABLED;
|
||||
widget_state_t disabled;
|
||||
Widget *w;
|
||||
|
||||
disabled = mc_global.tty.console_flag != '\0' ? 0 : WST_DISABLED;
|
||||
|
||||
w = WIDGET (groupbox_new (8, 3, 3, l1, title2));
|
||||
w->options |= disabled;
|
||||
w->state |= disabled;
|
||||
add_widget (layout_dlg, w);
|
||||
|
||||
w = WIDGET (button_new (9, output_lines_label_len + 5, B_PLUS,
|
||||
NARROW_BUTTON, "&+", bplus_cback));
|
||||
w->options |= disabled;
|
||||
w->state |= disabled;
|
||||
add_widget (layout_dlg, w);
|
||||
|
||||
w = WIDGET (button_new (9, output_lines_label_len + 5 + 5, B_MINUS,
|
||||
NARROW_BUTTON, "&-", bminus_cback));
|
||||
w->options |= disabled;
|
||||
w->state |= disabled;
|
||||
add_widget (layout_dlg, w);
|
||||
}
|
||||
|
||||
|
@ -198,8 +198,8 @@ init_listmode (char *oldlistformat)
|
||||
do_refresh ();
|
||||
|
||||
listmode_dlg =
|
||||
dlg_create (TRUE, 0, 0, 22, 74, dialog_colors, NULL, NULL, listmode_section,
|
||||
"Listing format edit", DLG_CENTER | DLG_REVERSE);
|
||||
dlg_create (TRUE, 0, 0, 22, 74, WPOS_CENTER, FALSE, dialog_colors, NULL, NULL,
|
||||
listmode_section, "Listing format edit");
|
||||
|
||||
add_widget (listmode_dlg, groupbox_new (UY, UX, 4, 63, "General options"));
|
||||
add_widget (listmode_dlg, groupbox_new (UY + 4, UX, 11, 18, "Items"));
|
||||
|
@ -138,10 +138,10 @@ static gboolean ctl_x_map_enabled = FALSE;
|
||||
static void
|
||||
stop_dialogs (void)
|
||||
{
|
||||
midnight_dlg->state = DLG_CLOSED;
|
||||
dlg_stop (midnight_dlg);
|
||||
|
||||
if ((top_dlg != NULL) && (top_dlg->data != NULL))
|
||||
DIALOG (top_dlg->data)->state = DLG_CLOSED;
|
||||
dlg_stop (DIALOG (top_dlg->data));
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
@ -1421,7 +1421,7 @@ midnight_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm, void
|
||||
|
||||
case MSG_IDLE:
|
||||
/* We only need the first idle event to show user menu after start */
|
||||
widget_want_idle (w, FALSE);
|
||||
widget_idle (w, FALSE);
|
||||
|
||||
if (boot_current_is_left)
|
||||
dlg_select_widget (get_panel_widget (0));
|
||||
@ -1757,8 +1757,8 @@ do_nc (void)
|
||||
edit_stack_init ();
|
||||
#endif
|
||||
|
||||
midnight_dlg = dlg_create (FALSE, 0, 0, LINES, COLS, dialog_colors, midnight_callback, NULL,
|
||||
"[main]", NULL, DLG_NONE);
|
||||
midnight_dlg = dlg_create (FALSE, 0, 0, 1, 1, WPOS_FULLSCREEN, FALSE, dialog_colors,
|
||||
midnight_callback, NULL, "[main]", NULL);
|
||||
|
||||
/* Check if we were invoked as an editor or file viewer */
|
||||
if (mc_global.mc_run_mode != MC_RUN_FULL)
|
||||
@ -1769,7 +1769,7 @@ do_nc (void)
|
||||
else
|
||||
{
|
||||
/* We only need the first idle event to show user menu after start */
|
||||
widget_want_idle (WIDGET (midnight_dlg), TRUE);
|
||||
widget_idle (WIDGET (midnight_dlg), TRUE);
|
||||
|
||||
setup_mc ();
|
||||
mc_filehighlight = mc_fhl_new (TRUE);
|
||||
|
@ -4292,8 +4292,6 @@ panel_new_with_dir (const char *panel_name, const vfs_path_t * vpath)
|
||||
w = WIDGET (panel);
|
||||
/* No know sizes of the panel at startup */
|
||||
widget_init (w, 0, 0, 0, 0, panel_callback, panel_mouse_callback);
|
||||
/* We do not want the cursor */
|
||||
widget_want_cursor (w, FALSE);
|
||||
|
||||
if (vpath != NULL)
|
||||
{
|
||||
|
@ -168,8 +168,8 @@ init_panelize (void)
|
||||
panelize_cols = MAX (panelize_cols, blen + 4);
|
||||
|
||||
panelize_dlg =
|
||||
dlg_create (TRUE, 0, 0, 20, panelize_cols, dialog_colors, panelize_callback, NULL,
|
||||
"[External panelize]", _("External panelize"), DLG_CENTER);
|
||||
dlg_create (TRUE, 0, 0, 20, panelize_cols, WPOS_CENTER, FALSE, dialog_colors,
|
||||
panelize_callback, NULL, "[External panelize]", _("External panelize"));
|
||||
|
||||
/* add listbox to the dialogs */
|
||||
y = UY;
|
||||
|
@ -1291,8 +1291,6 @@ tree_new (int y, int x, int lines, int cols, gboolean is_panel)
|
||||
tree->searching = 0;
|
||||
tree->active = 0;
|
||||
|
||||
/* We do not want to keep the cursor */
|
||||
widget_want_cursor (w, FALSE);
|
||||
load_tree (tree);
|
||||
return tree;
|
||||
}
|
||||
|
@ -1023,6 +1023,7 @@ mousedispatch_new (int y, int x, int yl, int xl)
|
||||
|
||||
w = g_new0 (Widget, 1);
|
||||
widget_init (w, y, x, yl, xl, md_callback, help_mouse_callback);
|
||||
widget_want_cursor (w, TRUE);
|
||||
|
||||
return w;
|
||||
}
|
||||
@ -1096,9 +1097,9 @@ help_interactive_display (const gchar * event_group_name, const gchar * event_na
|
||||
help_lines = MIN (LINES - 4, MAX (2 * LINES / 3, 18));
|
||||
|
||||
whelp =
|
||||
dlg_create (TRUE, 0, 0, help_lines + 4, HELP_WINDOW_WIDTH + 4,
|
||||
help_colors, help_callback, NULL, "[Help]", _("Help"),
|
||||
DLG_TRYUP | DLG_CENTER | DLG_WANT_TAB);
|
||||
dlg_create (TRUE, 0, 0, help_lines + 4, WPOS_CENTER | WPOS_TRYUP, FALSE,
|
||||
HELP_WINDOW_WIDTH + 4, help_colors, help_callback, NULL, "[Help]", _("Help"));
|
||||
widget_want_tab (WIDGET (whelp), TRUE);
|
||||
|
||||
selected_item = search_string_node (main_node, STRING_LINK_START) - 1;
|
||||
currentpoint = main_node + 1; /* Skip the newline following the start of the node */
|
||||
|
@ -274,8 +274,8 @@ init_learn (void)
|
||||
do_refresh ();
|
||||
|
||||
learn_dlg =
|
||||
dlg_create (TRUE, 0, 0, dlg_height, dlg_width, dialog_colors, learn_callback, NULL,
|
||||
"[Learn keys]", learn_title, DLG_CENTER);
|
||||
dlg_create (TRUE, 0, 0, dlg_height, dlg_width, WPOS_CENTER, FALSE, dialog_colors,
|
||||
learn_callback, NULL, "[Learn keys]", learn_title);
|
||||
|
||||
/* find first unshown button */
|
||||
for (key = key_name_conv_tab, learn_total = 0;
|
||||
|
@ -732,9 +732,10 @@ mcview_dialog_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm,
|
||||
|
||||
case MSG_VALIDATE:
|
||||
view = (WView *) find_widget_type (h, mcview_callback);
|
||||
h->state = DLG_ACTIVE; /* don't stop the dialog before final decision */
|
||||
/* don't stop the dialog before final decision */
|
||||
widget_set_state (WIDGET (h), WST_ACTIVE, TRUE);
|
||||
if (mcview_ok_to_quit (view))
|
||||
h->state = DLG_CLOSED;
|
||||
dlg_stop (h);
|
||||
else
|
||||
mcview_update (view);
|
||||
return MSG_HANDLED;
|
||||
|
@ -232,8 +232,9 @@ mcview_viewer (const char *command, const vfs_path_t * file_vpath, int start_lin
|
||||
WDialog *view_dlg;
|
||||
|
||||
/* Create dialog and widgets, put them on the dialog */
|
||||
view_dlg = dlg_create (FALSE, 0, 0, LINES, COLS, NULL, mcview_dialog_callback, NULL,
|
||||
"[Internal File Viewer]", NULL, DLG_WANT_TAB);
|
||||
view_dlg = dlg_create (FALSE, 0, 0, 1, 1, WPOS_FULLSCREEN, FALSE, NULL, mcview_dialog_callback,
|
||||
NULL, "[Internal File Viewer]", NULL);
|
||||
widget_want_tab (WIDGET (view_dlg), TRUE);
|
||||
|
||||
lc_mcview = mcview_new (0, 0, LINES - 1, COLS, FALSE);
|
||||
add_widget (view_dlg, lc_mcview);
|
||||
@ -249,9 +250,9 @@ mcview_viewer (const char *command, const vfs_path_t * file_vpath, int start_lin
|
||||
if (succeeded)
|
||||
dlg_run (view_dlg);
|
||||
else
|
||||
view_dlg->state = DLG_CLOSED;
|
||||
dlg_stop (view_dlg);
|
||||
|
||||
if (view_dlg->state == DLG_CLOSED)
|
||||
if (widget_get_state (WIDGET (view_dlg), WST_CLOSED))
|
||||
dlg_destroy (view_dlg);
|
||||
|
||||
return succeeded;
|
||||
|
Loading…
Reference in New Issue
Block a user