Commit b8b7985b authored by Michael Natterer's avatar Michael Natterer 😴 Committed by Michael Natterer

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.
parent a6647f2d
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>
* app/tools/gimpvectortool.c: added simplistic undo, needs polishing.
......@@ -64,7 +64,10 @@
/* 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,
gdouble percentage);
static gboolean app_exit_callback (Gimp *gimp,
......@@ -79,19 +82,9 @@ Gimp *the_gimp = NULL;
/* 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 console_messages = FALSE;
gboolean restore_session = FALSE;
gboolean use_mmx = TRUE;
GimpStackTraceMode stack_trace_mode = GIMP_STACK_TRACE_QUERY;
gchar *alternate_gimprc = NULL;
gchar *alternate_system_gimprc = NULL;
/* other global variables */
gchar *prog_name = NULL; /* our executable name */
......@@ -107,11 +100,28 @@ app_gui_libs_init (gint *argc,
}
void
app_init (gint gimp_argc,
gchar **gimp_argv)
app_init (gint gimp_argc,
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;
GimpRc *gimprc;
GimpInitStatusFunc update_status_func;
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
* core object system
......@@ -241,7 +251,7 @@ app_init (gint gimp_argc,
/* Create all members of the global Gimp instance which need an already
* 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)
{
......@@ -251,7 +261,7 @@ app_init (gint gimp_argc,
/* 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)
{
......@@ -261,7 +271,7 @@ app_init (gint gimp_argc,
/* 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)
{
......@@ -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)
{
......@@ -375,14 +385,18 @@ app_init (gint gimp_argc,
/* private functions */
static void
app_init_update_status (const gchar *text1,
app_init_update_splash (const gchar *text1,
const gchar *text2,
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
......
......@@ -34,11 +34,22 @@
extern Gimp *the_gimp;
gboolean app_gui_libs_init (gint *gimp_argc,
gchar ***gimp_argv);
void app_init (gint gimp_argc,
gchar **gimp_argv);
gboolean app_gui_libs_init (gint *gimp_argc,
gchar ***gimp_argv);
void app_init (gint gimp_argc,
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__ */
......@@ -25,20 +25,9 @@
/* 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 console_messages;
extern gboolean restore_session;
extern GimpStackTraceMode stack_trace_mode;
extern gchar *alternate_gimprc;
extern gchar *alternate_system_gimprc;
extern gchar **batch_cmds;
/* other global variables */
extern gchar *prog_name;
......
......@@ -45,8 +45,6 @@ static void batch_perl_server (Gimp *gimp,
gint extra);
gchar **batch_cmds = NULL;
static ProcRecord *eval_proc = NULL;
......
......@@ -65,7 +65,7 @@ static void gimp_text_console_exit (gboolean fail);
/*
* argv processing:
* argv processing:
* Arguments are either switches, their associated
* values, or image files. As switches and their
* associated values are processed, those slots in
......@@ -88,8 +88,19 @@ int
main (int argc,
char **argv)
{
gboolean show_help = FALSE;
gint i, j;
gchar *alternate_system_gimprc = NULL;
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
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 */
show_help = TRUE;
}
else if (strcmp (argv[i], "--system-gimprc") == 0)
else if (strcmp (argv[i], "--system-gimprc") == 0)
{
argv[i] = NULL;
if (argc <= ++i)
if (argc <= ++i)
{
show_help = TRUE;
}
else
else
{
alternate_system_gimprc = argv[i];
argv[i] = NULL;
}
}
else if ((strcmp (argv[i], "--gimprc") == 0) ||
}
else if ((strcmp (argv[i], "--gimprc") == 0) ||
(strcmp (argv[i], "-g") == 0))
{
argv[i] = NULL;
if (argc <= ++i)
if (argc <= ++i)
{
show_help = TRUE;
}
......@@ -274,14 +285,14 @@ main (int argc,
restore_session = TRUE;
argv[i] = NULL;
}
else if (strcmp (argv[i], "--enable-stack-trace") == 0)
else if (strcmp (argv[i], "--enable-stack-trace") == 0)
{
argv[i] = NULL;
if (argc <= ++i)
if (argc <= ++i)
{
show_help = TRUE;
}
else
else
{
if (! strcmp (argv[i], "never"))
stack_trace_mode = GIMP_STACK_TRACE_NEVER;
......@@ -314,7 +325,7 @@ main (int argc,
}
#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
* with all it's benefits (like inheriting the console) but hide
* it, if the user doesn't want it.
......@@ -331,7 +342,7 @@ main (int argc,
#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
* about the program error, and offer debugging (if the user
* has installed MSVC or some other compiler that knows how to
......@@ -367,7 +378,18 @@ main (int argc,
/* Initialize the application */
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;
}
......@@ -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-image Do not add an image to the startup window.\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-mmx Do not use MMX routines.\n"));
g_print (_(" --debug-handlers Enable non-fatal debugging signal handlers.\n"));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment