We really don't need that global variable overkill from appenv.h just to

2003-09-01  Michael Natterer  <mitch@gimp.org>

	We really don't need that global variable overkill from appenv.h
	just to pass these values from main() to app_init():

	* app/app_procs.[ch] (app_init): added tons of parameters that
	used to be global variables before.
	Replaced app_init_update_status() by two functions, one which
	actually updates the splash, and one which does nothing, so we
	don't need global variables in the status callback.

	* app/appenv.h: removed vraiable declarations here. Some are still
	left, will get rid of this entire file soon...

	* app/main.c: added them as local variables to main() and
	pass them to app_init().

	* app/batch.c: removed the global "batch_cmds", they are passed
	the same way as the stuff above now.
This commit is contained in:
Michael Natterer 2003-09-01 17:26:09 +00:00 committed by Michael Natterer
parent a6647f2d00
commit b8b7985bb0
6 changed files with 111 additions and 57 deletions

View File

@ -1,3 +1,23 @@
2003-09-01 Michael Natterer <mitch@gimp.org>
We really don't need that global variable overkill from appenv.h
just to pass these values from main() to app_init():
* app/app_procs.[ch] (app_init): added tons of parameters that
used to be global variables before.
Replaced app_init_update_status() by two functions, one which
actually updates the splash, and one which does nothing, so we
don't need global variables in the status callback.
* app/appenv.h: removed vraiable declarations here. Some are still
left, will get rid of this entire file soon...
* app/main.c: added them as local variables to main() and
pass them to app_init().
* app/batch.c: removed the global "batch_cmds", they are passed
the same way as the stuff above now.
2003-09-01 Simon Budig <simon@gimp.org> 2003-09-01 Simon Budig <simon@gimp.org>
* app/tools/gimpvectortool.c: added simplistic undo, needs polishing. * app/tools/gimpvectortool.c: added simplistic undo, needs polishing.

View File

@ -64,7 +64,10 @@
/* local prototypes */ /* local prototypes */
static void app_init_update_status (const gchar *text1, static void app_init_update_splash (const gchar *text1,
const gchar *text2,
gdouble percentage);
static void app_init_update_none (const gchar *text1,
const gchar *text2, const gchar *text2,
gdouble percentage); gdouble percentage);
static gboolean app_exit_callback (Gimp *gimp, static gboolean app_exit_callback (Gimp *gimp,
@ -79,19 +82,9 @@ Gimp *the_gimp = NULL;
/* command-line options */ /* command-line options */
gboolean no_interface = FALSE;
gboolean no_data = FALSE;
gboolean no_splash = FALSE;
gboolean no_splash_image = FALSE;
gboolean be_verbose = FALSE;
gboolean use_shm = FALSE;
gboolean use_debug_handler = FALSE; gboolean use_debug_handler = FALSE;
gboolean console_messages = FALSE; gboolean console_messages = FALSE;
gboolean restore_session = FALSE;
gboolean use_mmx = TRUE;
GimpStackTraceMode stack_trace_mode = GIMP_STACK_TRACE_QUERY; GimpStackTraceMode stack_trace_mode = GIMP_STACK_TRACE_QUERY;
gchar *alternate_gimprc = NULL;
gchar *alternate_system_gimprc = NULL;
/* other global variables */ /* other global variables */
gchar *prog_name = NULL; /* our executable name */ gchar *prog_name = NULL; /* our executable name */
@ -107,11 +100,28 @@ app_gui_libs_init (gint *argc,
} }
void void
app_init (gint gimp_argc, app_init (gint gimp_argc,
gchar **gimp_argv) gchar **gimp_argv,
const gchar *alternate_system_gimprc,
const gchar *alternate_gimprc,
const gchar **batch_cmds,
gboolean no_interface,
gboolean no_data,
gboolean no_splash,
gboolean no_splash_image,
gboolean be_verbose,
gboolean use_shm,
gboolean use_mmx,
gboolean restore_session)
{ {
const gchar *gimp_dir; GimpInitStatusFunc update_status_func;
GimpRc *gimprc; const gchar *gimp_dir;
GimpRc *gimprc;
if (no_interface || no_splash)
update_status_func = app_init_update_none;
else
update_status_func = app_init_update_splash;
/* Create an instance of the "Gimp" object which is the root of the /* Create an instance of the "Gimp" object which is the root of the
* core object system * core object system
@ -241,7 +251,7 @@ app_init (gint gimp_argc,
/* Create all members of the global Gimp instance which need an already /* Create all members of the global Gimp instance which need an already
* parsed gimprc, e.g. the data factories * parsed gimprc, e.g. the data factories
*/ */
gimp_initialize (the_gimp, app_init_update_status); gimp_initialize (the_gimp, update_status_func);
if (! no_interface) if (! no_interface)
{ {
@ -251,7 +261,7 @@ app_init (gint gimp_argc,
/* Load all data files /* Load all data files
*/ */
gimp_restore (the_gimp, app_init_update_status, no_data); gimp_restore (the_gimp, update_status_func, no_data);
if (! no_interface) if (! no_interface)
{ {
@ -261,7 +271,7 @@ app_init (gint gimp_argc,
/* Initialize the plug-in structures /* Initialize the plug-in structures
*/ */
plug_ins_init (the_gimp, app_init_update_status); plug_ins_init (the_gimp, update_status_func);
if (! no_interface) if (! no_interface)
{ {
@ -346,7 +356,7 @@ app_init (gint gimp_argc,
} }
} }
batch_init (the_gimp, (const gchar **) batch_cmds); batch_init (the_gimp, batch_cmds);
if (! no_interface) if (! no_interface)
{ {
@ -375,14 +385,18 @@ app_init (gint gimp_argc,
/* private functions */ /* private functions */
static void static void
app_init_update_status (const gchar *text1, app_init_update_splash (const gchar *text1,
const gchar *text2, const gchar *text2,
gdouble percentage) gdouble percentage)
{ {
if (! no_interface && ! no_splash) splash_update (text1, text2, percentage);
{ }
splash_update (text1, text2, percentage);
} static void
app_init_update_none (const gchar *text1,
const gchar *text2,
gdouble percentage)
{
} }
static gboolean static gboolean

View File

@ -34,11 +34,22 @@
extern Gimp *the_gimp; extern Gimp *the_gimp;
gboolean app_gui_libs_init (gint *gimp_argc, gboolean app_gui_libs_init (gint *gimp_argc,
gchar ***gimp_argv); gchar ***gimp_argv);
void app_init (gint gimp_argc, void app_init (gint gimp_argc,
gchar **gimp_argv); gchar **gimp_argv,
const gchar *alternate_system_gimprc,
const gchar *alternate_gimprc,
const gchar **batch_cmds,
gboolean no_interface,
gboolean no_data,
gboolean no_splash,
gboolean no_splash_image,
gboolean be_verbose,
gboolean use_shm,
gboolean use_mmx,
gboolean restore_session);
#endif /* __APP_PROCS_H__ */ #endif /* __APP_PROCS_H__ */

View File

@ -25,20 +25,9 @@
/* command line options */ /* command line options */
extern gboolean no_interface;
extern gboolean no_splash;
extern gboolean no_splash_image;
extern gboolean no_data;
extern gboolean be_verbose;
extern gboolean use_shm;
extern gboolean use_mmx;
extern gboolean use_debug_handler; extern gboolean use_debug_handler;
extern gboolean console_messages; extern gboolean console_messages;
extern gboolean restore_session;
extern GimpStackTraceMode stack_trace_mode; extern GimpStackTraceMode stack_trace_mode;
extern gchar *alternate_gimprc;
extern gchar *alternate_system_gimprc;
extern gchar **batch_cmds;
/* other global variables */ /* other global variables */
extern gchar *prog_name; extern gchar *prog_name;

View File

@ -45,8 +45,6 @@ static void batch_perl_server (Gimp *gimp,
gint extra); gint extra);
gchar **batch_cmds = NULL;
static ProcRecord *eval_proc = NULL; static ProcRecord *eval_proc = NULL;

View File

@ -65,7 +65,7 @@ static void gimp_text_console_exit (gboolean fail);
/* /*
* argv processing: * argv processing:
* Arguments are either switches, their associated * Arguments are either switches, their associated
* values, or image files. As switches and their * values, or image files. As switches and their
* associated values are processed, those slots in * associated values are processed, those slots in
@ -88,8 +88,19 @@ int
main (int argc, main (int argc,
char **argv) char **argv)
{ {
gboolean show_help = FALSE; gchar *alternate_system_gimprc = NULL;
gint i, j; gchar *alternate_gimprc = NULL;
gchar **batch_cmds = NULL;
gboolean show_help = FALSE;
gboolean no_interface = FALSE;
gboolean no_data = FALSE;
gboolean no_splash = FALSE;
gboolean no_splash_image = FALSE;
gboolean be_verbose = FALSE;
gboolean use_shm = FALSE;
gboolean use_mmx = TRUE;
gboolean restore_session = FALSE;
gint i, j;
#if 0 #if 0
g_mem_set_vtable (glib_mem_profiler_table); g_mem_set_vtable (glib_mem_profiler_table);
@ -197,24 +208,24 @@ main (int argc,
if (batch_cmds[0] == NULL) /* We need at least one batch command */ if (batch_cmds[0] == NULL) /* We need at least one batch command */
show_help = TRUE; show_help = TRUE;
} }
else if (strcmp (argv[i], "--system-gimprc") == 0) else if (strcmp (argv[i], "--system-gimprc") == 0)
{ {
argv[i] = NULL; argv[i] = NULL;
if (argc <= ++i) if (argc <= ++i)
{ {
show_help = TRUE; show_help = TRUE;
} }
else else
{ {
alternate_system_gimprc = argv[i]; alternate_system_gimprc = argv[i];
argv[i] = NULL; argv[i] = NULL;
} }
} }
else if ((strcmp (argv[i], "--gimprc") == 0) || else if ((strcmp (argv[i], "--gimprc") == 0) ||
(strcmp (argv[i], "-g") == 0)) (strcmp (argv[i], "-g") == 0))
{ {
argv[i] = NULL; argv[i] = NULL;
if (argc <= ++i) if (argc <= ++i)
{ {
show_help = TRUE; show_help = TRUE;
} }
@ -274,14 +285,14 @@ main (int argc,
restore_session = TRUE; restore_session = TRUE;
argv[i] = NULL; argv[i] = NULL;
} }
else if (strcmp (argv[i], "--enable-stack-trace") == 0) else if (strcmp (argv[i], "--enable-stack-trace") == 0)
{ {
argv[i] = NULL; argv[i] = NULL;
if (argc <= ++i) if (argc <= ++i)
{ {
show_help = TRUE; show_help = TRUE;
} }
else else
{ {
if (! strcmp (argv[i], "never")) if (! strcmp (argv[i], "never"))
stack_trace_mode = GIMP_STACK_TRACE_NEVER; stack_trace_mode = GIMP_STACK_TRACE_NEVER;
@ -314,7 +325,7 @@ main (int argc,
} }
#ifdef G_OS_WIN32 #ifdef G_OS_WIN32
/* Common windoze apps don't have a console at all. So does Gimp /* Common windoze apps don't have a console at all. So does Gimp
* - if appropiate. This allows to compile as console application * - if appropiate. This allows to compile as console application
* with all it's benefits (like inheriting the console) but hide * with all it's benefits (like inheriting the console) but hide
* it, if the user doesn't want it. * it, if the user doesn't want it.
@ -331,7 +342,7 @@ main (int argc,
#ifndef G_OS_WIN32 #ifndef G_OS_WIN32
/* No use catching these on Win32, the user won't get any /* No use catching these on Win32, the user won't get any
* stack trace from glib anyhow. It's better to let Windows inform * stack trace from glib anyhow. It's better to let Windows inform
* about the program error, and offer debugging (if the user * about the program error, and offer debugging (if the user
* has installed MSVC or some other compiler that knows how to * has installed MSVC or some other compiler that knows how to
@ -367,7 +378,18 @@ main (int argc,
/* Initialize the application */ /* Initialize the application */
app_init (argc - 1, app_init (argc - 1,
argv + 1); argv + 1,
alternate_system_gimprc,
alternate_gimprc,
(const gchar **) batch_cmds,
no_interface,
no_data,
no_splash,
no_splash_image,
be_verbose,
use_shm,
use_mmx,
restore_session);
return 0; return 0;
} }
@ -396,7 +418,7 @@ gimp_show_help (const gchar *progname)
g_print (_(" -s, --no-splash Do not show the startup window.\n")); g_print (_(" -s, --no-splash Do not show the startup window.\n"));
g_print (_(" -S, --no-splash-image Do not add an image to the startup window.\n")); g_print (_(" -S, --no-splash-image Do not add an image to the startup window.\n"));
g_print (_(" -v, --version Output version information.\n")); g_print (_(" -v, --version Output version information.\n"));
g_print (_(" --verbose Show startup messages.\n")); g_print (_(" --verbose Show startup messages.\n"));
g_print (_(" --no-shm Do not use shared memory between GIMP and plugins.\n")); g_print (_(" --no-shm Do not use shared memory between GIMP and plugins.\n"));
g_print (_(" --no-mmx Do not use MMX routines.\n")); g_print (_(" --no-mmx Do not use MMX routines.\n"));
g_print (_(" --debug-handlers Enable non-fatal debugging signal handlers.\n")); g_print (_(" --debug-handlers Enable non-fatal debugging signal handlers.\n"));