1998-02-27 07:54:42 +03:00
|
|
|
/* Dialog managing.
|
|
|
|
Copyright (C) 1994 Miguel de Icaza.
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation; either version 2 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to the Free Software
|
2000-08-23 02:50:00 +04:00
|
|
|
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
1998-02-27 07:54:42 +03:00
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdarg.h>
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include "global.h"
|
|
|
|
#include "dialog.h"
|
2002-08-23 02:53:02 +04:00
|
|
|
#include "key.h" /* we_are_background */
|
|
|
|
#include "main.h" /* fast_refresh */
|
1998-02-27 07:54:42 +03:00
|
|
|
|
|
|
|
|
2002-11-14 10:25:18 +03:00
|
|
|
/* The refresh stack */
|
|
|
|
typedef struct Refresh {
|
|
|
|
void (*refresh_fn)(void *);
|
|
|
|
void *parameter;
|
|
|
|
int flags;
|
|
|
|
struct Refresh *next;
|
|
|
|
} Refresh;
|
|
|
|
|
2002-11-14 09:41:04 +03:00
|
|
|
static Refresh *refresh_list;
|
1998-02-27 07:54:42 +03:00
|
|
|
|
2002-11-14 09:41:04 +03:00
|
|
|
void
|
|
|
|
push_refresh (refresh_fn new_refresh, void *parameter, int flags)
|
1998-02-27 07:54:42 +03:00
|
|
|
{
|
|
|
|
Refresh *new;
|
|
|
|
|
Glibing..... (2)
Wed Jan 27 03:17:44 1999 Timur Bakeyev <mc@bat.ru>
* Converted memory managment to Glib. Now we use g_new()/g_malloc()/
g_strdup()/g_free() routings. Also, copy_strings() replaced by
g_strconcat(), strcasecmp() -> g_strcasecmp(),and sprintf() by
g_snprintf().
* Some sequences of malloc()/sprintf() changed to g_strdup_printf().
* mad.[ch]: Modified, to work with new GLib's memory managment. Fixed
a missing #undef for tempnam, which caused dead loop. Add several new
functions to emulate GLib memory managment.
*main.c, mad.[ch]: Add a new switch "-M", which allows to redirect MAD
messages to the file.
* util.[ch], utilunix.c: Modified, deleted our variants of strcasecmp()
and strdup() - we have g_ equivalences. Remove get_full_name() - it is
similar to concat_dir_and_file(). Some other tricks with g_* functions.
* global.h: Modified, extended. Now it is main memory mangment include -
i.e. all inclusions of <stdlib.h>, <malloc.h>, <glib.h>, "fs.h", "mem.h",
"util.h" and "mad.h" done there. This elimanates problem with proper or-
der of #include's.
* All around the source - changed order of #include's, most of them gone
to global.h (see above), minor changes, like "0" -> NULL in string func-
tions.
1999-01-27 04:08:30 +03:00
|
|
|
new = g_new (Refresh, 1);
|
1998-02-27 07:54:42 +03:00
|
|
|
new->next = (struct Refresh *) refresh_list;
|
|
|
|
new->refresh_fn = new_refresh;
|
|
|
|
new->parameter = parameter;
|
2002-11-14 09:41:04 +03:00
|
|
|
new->flags = flags;
|
1998-02-27 07:54:42 +03:00
|
|
|
refresh_list = new;
|
|
|
|
}
|
|
|
|
|
2002-11-14 09:41:04 +03:00
|
|
|
void
|
|
|
|
pop_refresh (void)
|
1998-02-27 07:54:42 +03:00
|
|
|
{
|
|
|
|
Refresh *old;
|
2002-11-14 09:41:04 +03:00
|
|
|
|
1998-02-27 07:54:42 +03:00
|
|
|
if (!refresh_list)
|
|
|
|
fprintf (stderr, _("\n\n\nrefresh stack underflow!\n\n\n"));
|
|
|
|
else {
|
|
|
|
old = refresh_list;
|
|
|
|
refresh_list = refresh_list->next;
|
Glibing..... (2)
Wed Jan 27 03:17:44 1999 Timur Bakeyev <mc@bat.ru>
* Converted memory managment to Glib. Now we use g_new()/g_malloc()/
g_strdup()/g_free() routings. Also, copy_strings() replaced by
g_strconcat(), strcasecmp() -> g_strcasecmp(),and sprintf() by
g_snprintf().
* Some sequences of malloc()/sprintf() changed to g_strdup_printf().
* mad.[ch]: Modified, to work with new GLib's memory managment. Fixed
a missing #undef for tempnam, which caused dead loop. Add several new
functions to emulate GLib memory managment.
*main.c, mad.[ch]: Add a new switch "-M", which allows to redirect MAD
messages to the file.
* util.[ch], utilunix.c: Modified, deleted our variants of strcasecmp()
and strdup() - we have g_ equivalences. Remove get_full_name() - it is
similar to concat_dir_and_file(). Some other tricks with g_* functions.
* global.h: Modified, extended. Now it is main memory mangment include -
i.e. all inclusions of <stdlib.h>, <malloc.h>, <glib.h>, "fs.h", "mem.h",
"util.h" and "mad.h" done there. This elimanates problem with proper or-
der of #include's.
* All around the source - changed order of #include's, most of them gone
to global.h (see above), minor changes, like "0" -> NULL in string func-
tions.
1999-01-27 04:08:30 +03:00
|
|
|
g_free (old);
|
1998-02-27 07:54:42 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-11-14 09:41:04 +03:00
|
|
|
static void
|
|
|
|
do_complete_refresh (Refresh *refresh_list)
|
1998-02-27 07:54:42 +03:00
|
|
|
{
|
|
|
|
if (!refresh_list)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (refresh_list->flags != REFRESH_COVERS_ALL)
|
|
|
|
do_complete_refresh (refresh_list->next);
|
2002-11-14 09:41:04 +03:00
|
|
|
|
|
|
|
(*(refresh_list->refresh_fn)) (refresh_list->parameter);
|
1998-02-27 07:54:42 +03:00
|
|
|
}
|
|
|
|
|
2002-11-14 09:41:04 +03:00
|
|
|
void
|
|
|
|
do_refresh (void)
|
1998-02-27 07:54:42 +03:00
|
|
|
{
|
2002-11-14 09:41:04 +03:00
|
|
|
if (we_are_background || !refresh_list)
|
1998-02-27 07:54:42 +03:00
|
|
|
return;
|
1999-01-01 05:04:59 +03:00
|
|
|
|
2002-11-14 09:41:04 +03:00
|
|
|
if (fast_refresh)
|
|
|
|
(*(refresh_list->refresh_fn)) (refresh_list->parameter);
|
1998-02-27 07:54:42 +03:00
|
|
|
else {
|
2002-11-14 09:41:04 +03:00
|
|
|
do_complete_refresh (refresh_list);
|
1998-02-27 07:54:42 +03:00
|
|
|
}
|
|
|
|
}
|