mirror of
https://github.com/MidnightCommander/mc
synced 2024-12-22 20:36:50 +03:00
* dialog.c: Remove duplication between two chains of dialogs.
* dialog.h (struct Dlg_head): Add "fullscreen" field, remove "refresh_pushed", rename "previous_dialog" to "parent".
This commit is contained in:
parent
52d81f57d7
commit
db8db1268c
@ -1,5 +1,9 @@
|
||||
2003-10-24 Pavel Roskin <proski@gnu.org>
|
||||
|
||||
* dialog.c: Remove duplication between two chains of dialogs.
|
||||
* dialog.h (struct Dlg_head): Add "fullscreen" field, remove
|
||||
"refresh_pushed", rename "previous_dialog" to "parent".
|
||||
|
||||
* tree.h: Fix unneeded dependency on dialog.h.
|
||||
* layout.h: Likewise.
|
||||
|
||||
|
78
src/dialog.c
78
src/dialog.c
@ -268,67 +268,25 @@ enum {
|
||||
REFRESH_COVERS_ALL /* If the refresh fn convers all the screen */
|
||||
};
|
||||
|
||||
typedef void (*refresh_fn) (void *);
|
||||
|
||||
/* The refresh stack */
|
||||
struct Refresh {
|
||||
void (*refresh_fn)(void *);
|
||||
void *parameter;
|
||||
int flags;
|
||||
struct Refresh *next;
|
||||
};
|
||||
|
||||
static struct Refresh *refresh_list;
|
||||
|
||||
static void
|
||||
push_refresh (refresh_fn new_refresh, void *parameter, int flags)
|
||||
do_complete_refresh (Dlg_head *dlg)
|
||||
{
|
||||
struct Refresh *new;
|
||||
if (!dlg->fullscreen && dlg->parent)
|
||||
do_complete_refresh (dlg->parent);
|
||||
|
||||
new = g_new (struct Refresh, 1);
|
||||
new->next = (struct Refresh *) refresh_list;
|
||||
new->refresh_fn = new_refresh;
|
||||
new->parameter = parameter;
|
||||
new->flags = flags;
|
||||
refresh_list = new;
|
||||
}
|
||||
|
||||
static void
|
||||
pop_refresh (void)
|
||||
{
|
||||
struct Refresh *old;
|
||||
|
||||
if (!refresh_list)
|
||||
fprintf (stderr, _("\n\n\nrefresh stack underflow!\n\n\n"));
|
||||
else {
|
||||
old = refresh_list;
|
||||
refresh_list = refresh_list->next;
|
||||
g_free (old);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
do_complete_refresh (struct Refresh *refresh_list)
|
||||
{
|
||||
if (!refresh_list)
|
||||
return;
|
||||
|
||||
if (refresh_list->flags != REFRESH_COVERS_ALL)
|
||||
do_complete_refresh (refresh_list->next);
|
||||
|
||||
(*(refresh_list->refresh_fn)) (refresh_list->parameter);
|
||||
dlg_redraw (dlg);
|
||||
}
|
||||
|
||||
void
|
||||
do_refresh (void)
|
||||
{
|
||||
if (we_are_background || !refresh_list)
|
||||
if (we_are_background || !current_dlg)
|
||||
return;
|
||||
|
||||
if (fast_refresh)
|
||||
(*(refresh_list->refresh_fn)) (refresh_list->parameter);
|
||||
dlg_redraw (current_dlg);
|
||||
else {
|
||||
do_complete_refresh (refresh_list);
|
||||
do_complete_refresh (current_dlg);
|
||||
}
|
||||
}
|
||||
|
||||
@ -551,12 +509,6 @@ void dlg_redraw (Dlg_head *h)
|
||||
update_cursor (h);
|
||||
}
|
||||
|
||||
static void
|
||||
dlg_refresh (void *parameter)
|
||||
{
|
||||
dlg_redraw ((Dlg_head *) parameter);
|
||||
}
|
||||
|
||||
void dlg_stop (Dlg_head *h)
|
||||
{
|
||||
h->running = 0;
|
||||
@ -753,21 +705,14 @@ dlg_mouse_event (Dlg_head * h, Gpm_Event * event)
|
||||
/* Init the process */
|
||||
void init_dlg (Dlg_head *h)
|
||||
{
|
||||
int refresh_mode;
|
||||
|
||||
/* Initialize dialog manager and widgets */
|
||||
(*h->callback) (h, DLG_INIT, 0);
|
||||
dlg_broadcast_msg (h, WIDGET_INIT, 0);
|
||||
|
||||
if (h->x == 0 && h->y == 0 && h->cols == COLS && h->lines == LINES)
|
||||
refresh_mode = REFRESH_COVERS_ALL;
|
||||
else
|
||||
refresh_mode = REFRESH_COVERS_PART;
|
||||
h->fullscreen = 1;
|
||||
|
||||
push_refresh (dlg_refresh, h, refresh_mode);
|
||||
h->refresh_pushed = 1;
|
||||
|
||||
h->previous_dialog = current_dlg;
|
||||
h->parent = current_dlg;
|
||||
current_dlg = h;
|
||||
|
||||
/* Initialize the mouse status */
|
||||
@ -790,7 +735,7 @@ void dlg_run_done (Dlg_head *h)
|
||||
if (h->current)
|
||||
(*h->callback) (h, DLG_END, 0);
|
||||
|
||||
current_dlg = (Dlg_head *) h->previous_dialog;
|
||||
current_dlg = h->parent;
|
||||
}
|
||||
|
||||
void dlg_process_event (Dlg_head *h, int key, Gpm_Event *event)
|
||||
@ -863,9 +808,6 @@ destroy_dlg (Dlg_head *h)
|
||||
int i;
|
||||
Widget *c;
|
||||
|
||||
if (h->refresh_pushed)
|
||||
pop_refresh ();
|
||||
|
||||
dlg_broadcast_msg (h, WIDGET_DESTROY, 0);
|
||||
c = h->current;
|
||||
for (i = 0; i < h->count; i++) {
|
||||
|
@ -97,15 +97,15 @@ typedef struct Dlg_head {
|
||||
int cols, lines; /* Width and height of the window */
|
||||
|
||||
/* Internal flags */
|
||||
int running;
|
||||
int running:1; /* The dialog is currently active */
|
||||
int fullscreen:1; /* Parents dialogs don't need refresh */
|
||||
int mouse_status; /* For the autorepeat status of the mouse */
|
||||
int refresh_pushed; /* Did the dialog actually run? */
|
||||
|
||||
/* Internal variables */
|
||||
int count; /* Number of widgets */
|
||||
struct Widget *current; /* Curently active widget */
|
||||
dlg_cb_fn callback;
|
||||
void *previous_dialog; /* Pointer to the previously running Dlg_head */
|
||||
struct Dlg_head *parent; /* Parent dialog */
|
||||
|
||||
} Dlg_head;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user