mirror of
https://github.com/MidnightCommander/mc
synced 2025-03-30 11:42:54 +03:00
Added dialog state (active, suspended, closed).
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
This commit is contained in:
parent
5ab573263a
commit
0e0f9c8ccd
34
src/dialog.c
34
src/dialog.c
@ -141,15 +141,16 @@ dlg_set_position (Dlg_head * h, int y1, int x1, int y2, int x2)
|
||||
h->lines = y2 - y1;
|
||||
h->cols = x2 - x1;
|
||||
|
||||
/* dialog is empty */
|
||||
if (h->current == NULL)
|
||||
return;
|
||||
|
||||
/* values by which controls should be moved */
|
||||
shift_x = h->x - ox;
|
||||
shift_y = h->y - oy;
|
||||
scale_x = h->cols - oc;
|
||||
scale_y = h->lines - ol;
|
||||
|
||||
if (h->current == NULL)
|
||||
return;
|
||||
|
||||
if ((shift_x != 0) || (shift_y != 0) || (scale_x != 0) || (scale_y != 0))
|
||||
{
|
||||
Widget *c = h->current;
|
||||
@ -275,9 +276,13 @@ create_dlg (int y1, int x1, int lines, int cols, const int *colors,
|
||||
new_d->data = NULL;
|
||||
|
||||
dlg_set_size (new_d, lines, cols);
|
||||
new_d->fullscreen = (new_d->x == 0 && new_d->y == 0
|
||||
&& new_d->cols == COLS && new_d->lines == LINES);
|
||||
|
||||
new_d->mouse_status = MOU_NORMAL;
|
||||
|
||||
/* Strip existing spaces, add one space before and after the title */
|
||||
if (title)
|
||||
if (title != NULL)
|
||||
{
|
||||
char *t;
|
||||
|
||||
@ -329,8 +334,8 @@ add_widget_autopos (Dlg_head * h, void *w, widget_pos_flags_t pos_flags)
|
||||
{
|
||||
Widget *widget = (Widget *) w;
|
||||
|
||||
/* Don't accept 0 widgets, and running dialogs */
|
||||
if (!widget || h->running)
|
||||
/* Don't accept 0 widgets */
|
||||
if (widget == NULL)
|
||||
abort ();
|
||||
|
||||
widget->x += h->x;
|
||||
@ -610,7 +615,7 @@ dlg_redraw (Dlg_head * h)
|
||||
void
|
||||
dlg_stop (Dlg_head * h)
|
||||
{
|
||||
h->running = 0;
|
||||
h->state = DLG_CLOSED;
|
||||
}
|
||||
|
||||
static void
|
||||
@ -821,15 +826,10 @@ dlg_key_event (Dlg_head * h, int d_key)
|
||||
void
|
||||
init_dlg (Dlg_head * h)
|
||||
{
|
||||
|
||||
/* add dialog to the stack */
|
||||
current_dlg = g_list_prepend (current_dlg, h);
|
||||
|
||||
if (h->x == 0 && h->y == 0 && h->cols == COLS && h->lines == LINES)
|
||||
h->fullscreen = 1;
|
||||
|
||||
/* Initialize the mouse status */
|
||||
h->mouse_status = MOU_NORMAL;
|
||||
|
||||
/* Initialize dialog manager and widgets */
|
||||
h->callback (h, NULL, DLG_INIT, 0, NULL);
|
||||
dlg_broadcast_msg (h, WIDGET_INIT, 0);
|
||||
@ -841,7 +841,7 @@ init_dlg (Dlg_head * h)
|
||||
h->current = h->current->next;
|
||||
|
||||
h->ret_value = 0;
|
||||
h->running = 1;
|
||||
h->state = DLG_ACTIVE;
|
||||
}
|
||||
|
||||
void
|
||||
@ -868,7 +868,7 @@ frontend_run_dlg (Dlg_head * h)
|
||||
Gpm_Event event;
|
||||
|
||||
event.x = -1;
|
||||
while (h->running)
|
||||
while (h->state == DLG_ACTIVE)
|
||||
{
|
||||
if (winch_flag)
|
||||
change_screen_size ();
|
||||
@ -882,7 +882,7 @@ frontend_run_dlg (Dlg_head * h)
|
||||
h->callback (h, NULL, DLG_IDLE, 0, NULL);
|
||||
|
||||
/* Allow terminating the dialog from the idle handler */
|
||||
if (!h->running)
|
||||
if (h->state != DLG_ACTIVE)
|
||||
break;
|
||||
}
|
||||
|
||||
@ -894,7 +894,7 @@ frontend_run_dlg (Dlg_head * h)
|
||||
|
||||
dlg_process_event (h, d_key, &event);
|
||||
|
||||
if (!h->running)
|
||||
if (h->state == DLG_CLOSED)
|
||||
h->callback (h, NULL, DLG_VALIDATE, 0, NULL);
|
||||
}
|
||||
}
|
||||
|
12
src/dialog.h
12
src/dialog.h
@ -97,6 +97,14 @@ typedef enum
|
||||
DLG_NONE = 0 /* No options */
|
||||
} dlg_flags_t;
|
||||
|
||||
/* Dialog state */
|
||||
typedef enum
|
||||
{
|
||||
DLG_ACTIVE = 0, /* Dialog is visible and active */
|
||||
DLG_SUSPENDED = 1, /* Dialog is suspended */
|
||||
DLG_CLOSED = 2 /* Dialog is closed */
|
||||
} dlg_state_t;
|
||||
|
||||
/* Dialog callback */
|
||||
typedef struct Dlg_head Dlg_head;
|
||||
typedef cb_ret_t (*dlg_cb_fn) (struct Dlg_head * h, Widget * sender,
|
||||
@ -132,8 +140,8 @@ struct Dlg_head
|
||||
int cols, lines; /* Width and height of the window */
|
||||
|
||||
/* Internal flags */
|
||||
unsigned int running:1; /* The dialog is currently active */
|
||||
unsigned int fullscreen:1; /* Parents dialogs don't need refresh */
|
||||
dlg_state_t state;
|
||||
gboolean fullscreen; /* Parents dialogs don't need refresh */
|
||||
int mouse_status; /* For the autorepeat status of the mouse */
|
||||
|
||||
/* Internal variables */
|
||||
|
@ -3205,7 +3205,10 @@ dview_dialog_callback (Dlg_head * h, Widget * sender, dlg_msg_t msg, int parm, v
|
||||
case DLG_VALIDATE:
|
||||
dview = (WDiff *) find_widget_type (h, dview_callback);
|
||||
if (!dview_ok_to_exit (dview))
|
||||
h->running = 1;
|
||||
h->state = DLG_ACTIVE;
|
||||
else
|
||||
h->state = DLG_CLOSED;
|
||||
|
||||
return MSG_HANDLED;
|
||||
|
||||
default:
|
||||
|
@ -231,7 +231,9 @@ edit_dialog_callback (Dlg_head * h, Widget * sender, dlg_msg_t msg, int parm, vo
|
||||
|
||||
case DLG_VALIDATE:
|
||||
if (!edit_ok_to_exit (edit))
|
||||
h->running = 1;
|
||||
h->state = DLG_ACTIVE;
|
||||
else
|
||||
h->state = DLG_CLOSED;
|
||||
return MSG_HANDLED;
|
||||
|
||||
default:
|
||||
|
@ -325,7 +325,7 @@ find_parm_callback (Dlg_head * h, Widget * sender, dlg_msg_t msg, int parm, void
|
||||
{
|
||||
message (D_ERROR, MSG_ERROR, _("Malformed regular expression"));
|
||||
dlg_select_widget (in_name);
|
||||
h->running = 1; /* Don't stop the dialog */
|
||||
h->state = DLG_ACTIVE; /* Don't stop the dialog */
|
||||
return MSG_HANDLED;
|
||||
}
|
||||
|
||||
@ -335,7 +335,7 @@ find_parm_callback (Dlg_head * h, Widget * sender, dlg_msg_t msg, int parm, void
|
||||
{
|
||||
message (D_ERROR, MSG_ERROR, _("Malformed regular expression"));
|
||||
dlg_select_widget (in_with);
|
||||
h->running = 1; /* Don't stop the dialog */
|
||||
h->state = DLG_ACTIVE; /* Don't stop the dialog */
|
||||
return MSG_HANDLED;
|
||||
}
|
||||
|
||||
|
@ -324,10 +324,10 @@ change_panel (void)
|
||||
static void
|
||||
stop_dialogs (void)
|
||||
{
|
||||
midnight_dlg->running = 0;
|
||||
midnight_dlg->state = DLG_CLOSED;
|
||||
|
||||
if ((current_dlg != NULL) && (current_dlg->data != NULL))
|
||||
((Dlg_head *) current_dlg->data)->running = 0;
|
||||
((Dlg_head *) current_dlg->data)->state = DLG_CLOSED;
|
||||
}
|
||||
|
||||
static int
|
||||
|
Loading…
x
Reference in New Issue
Block a user