1997-11-25 06:05:25 +08:00
|
|
|
/* The GIMP -- an image manipulation program
|
|
|
|
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
|
|
|
*
|
|
|
|
* 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
|
1998-04-13 13:44:11 +08:00
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
1997-11-25 06:05:25 +08:00
|
|
|
*/
|
2000-12-17 05:37:03 +08:00
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
#include "config.h"
|
Check for mmap.
* configure.in: Check for mmap.
* app/makefile.msc: Depend on gimpi.lib.
* app/app_procs.c (app_init): Fix gccism: Allocate filenames (an
array with non-constant size) dynamically.
* app/{datafiles,fileops,general,install,module_db,temp_buf}.c:
Include glib.h before standard headers, because of certain obscure
details related to compiling with gcc on Win32.
(If you really want to know: glib.h defines he names of POSIXish
(but non-ANSI) functions as prefixed with underscore, because
that's how they are named in the msvcrt runtime C library we want
to use. However, defining stat as _stat causes some problems if
done after including the mingw32 <sys/stat.h>. So, it's easiest to
include <glib.h> early.)
* app/main.c: Use _stdcall and __argc, __argv with MSC, but
__attribute__((stdcall)) and _argc, _argv with gcc. Don't print
the "Passed serialization test" message on Win32. (It would open
up an otherwise unnecessary console window.)
* app/paint_funcs.c (gaussian_blur_region): Don't use variable sum
until initialized.
* app/{bezier_select,paths_dialog}.c: Include config.h and define
rint() if necessary.
* app/plug_in.c: Use _spawnv, not spawnv, on Win32 and OS/2.
1999-05-29 01:47:17 +08:00
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
2005-02-09 06:57:24 +08:00
|
|
|
#include <signal.h>
|
2000-02-11 09:04:23 +08:00
|
|
|
|
1999-02-21 07:20:54 +08:00
|
|
|
#ifdef HAVE_UNISTD_H
|
1997-11-25 06:05:25 +08:00
|
|
|
#include <unistd.h>
|
1999-02-21 07:20:54 +08:00
|
|
|
#endif
|
|
|
|
|
2004-04-30 03:47:24 +08:00
|
|
|
#ifdef __GLIBC__
|
|
|
|
#include <malloc.h>
|
|
|
|
#endif
|
|
|
|
|
2003-03-26 00:38:19 +08:00
|
|
|
#include <locale.h>
|
|
|
|
|
2001-11-18 00:32:34 +08:00
|
|
|
#include <glib-object.h>
|
2000-02-11 09:04:23 +08:00
|
|
|
|
2001-05-22 04:30:16 +08:00
|
|
|
#include "libgimpbase/gimpbase.h"
|
1998-07-15 10:28:31 +08:00
|
|
|
|
2005-02-15 19:19:23 +08:00
|
|
|
#include "core/core-types.h"
|
|
|
|
|
|
|
|
#include "base/tile.h"
|
|
|
|
|
2003-10-14 06:55:25 +08:00
|
|
|
#include "config/gimpconfig-dump.h"
|
|
|
|
|
|
|
|
#include "core/gimp.h"
|
2000-12-17 05:37:03 +08:00
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
#include "app_procs.h"
|
|
|
|
#include "errors.h"
|
2004-03-30 19:32:21 +08:00
|
|
|
#include "sanity.h"
|
2003-11-17 06:46:40 +08:00
|
|
|
#include "units.h"
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2005-02-03 06:08:35 +08:00
|
|
|
#ifdef G_OS_WIN32
|
|
|
|
#include <windows.h>
|
|
|
|
#endif
|
|
|
|
|
2003-03-26 00:38:19 +08:00
|
|
|
#include "gimp-intl.h"
|
1998-08-06 07:46:04 +08:00
|
|
|
|
2001-07-14 03:25:34 +08:00
|
|
|
|
2005-02-09 06:57:24 +08:00
|
|
|
static gboolean gimp_option_fatal_warnings (const gchar *option_name,
|
|
|
|
const gchar *value,
|
|
|
|
gpointer data,
|
|
|
|
GError **error);
|
|
|
|
static gboolean gimp_option_stack_trace_mode (const gchar *option_name,
|
|
|
|
const gchar *value,
|
|
|
|
gpointer data,
|
|
|
|
GError **error);
|
|
|
|
static gboolean gimp_option_pdb_compat_mode (const gchar *option_name,
|
|
|
|
const gchar *value,
|
|
|
|
gpointer data,
|
|
|
|
GError **error);
|
|
|
|
static gboolean gimp_option_dump_gimprc (const gchar *option_name,
|
|
|
|
const gchar *value,
|
|
|
|
gpointer data,
|
|
|
|
GError **error);
|
|
|
|
|
|
|
|
static void gimp_show_version (void) G_GNUC_NORETURN;
|
|
|
|
|
|
|
|
static void gimp_init_i18n (void);
|
|
|
|
static void gimp_init_malloc (void);
|
|
|
|
static void gimp_init_signal_handlers (void);
|
2003-01-09 07:43:31 +08:00
|
|
|
|
2005-02-03 23:21:20 +08:00
|
|
|
#ifndef G_OS_WIN32
|
2005-02-09 06:57:24 +08:00
|
|
|
static void gimp_sigfatal_handler (gint sig_num) G_GNUC_NORETURN;
|
2005-02-03 23:21:20 +08:00
|
|
|
#endif
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2005-02-03 23:21:20 +08:00
|
|
|
|
|
|
|
static const gchar *system_gimprc = NULL;
|
|
|
|
static const gchar *user_gimprc = NULL;
|
|
|
|
static const gchar *session_name = NULL;
|
|
|
|
static const gchar *batch_interpreter = NULL;
|
|
|
|
static const gchar **batch_commands = NULL;
|
|
|
|
static const gchar **filenames = NULL;
|
|
|
|
static gboolean no_interface = FALSE;
|
|
|
|
static gboolean no_data = FALSE;
|
|
|
|
static gboolean no_fonts = FALSE;
|
|
|
|
static gboolean no_splash = FALSE;
|
|
|
|
static gboolean be_verbose = FALSE;
|
2005-02-03 07:04:24 +08:00
|
|
|
#if defined (USE_SYSV_SHM) || defined (USE_POSIX_SHM) || defined (G_OS_WIN32)
|
2005-02-03 23:21:20 +08:00
|
|
|
static gboolean use_shm = TRUE;
|
2005-02-03 07:04:24 +08:00
|
|
|
#else
|
2005-02-03 23:21:20 +08:00
|
|
|
static gboolean use_shm = FALSE;
|
2005-02-03 07:04:24 +08:00
|
|
|
#endif
|
2005-02-03 23:21:20 +08:00
|
|
|
static gboolean use_cpu_accel = TRUE;
|
|
|
|
static gboolean console_messages = FALSE;
|
|
|
|
static gboolean use_debug_handler = FALSE;
|
2005-02-03 06:08:35 +08:00
|
|
|
|
2005-02-03 23:21:20 +08:00
|
|
|
#ifdef GIMP_UNSTABLE
|
|
|
|
static GimpStackTraceMode stack_trace_mode = GIMP_STACK_TRACE_QUERY;
|
|
|
|
static GimpPDBCompatMode pdb_compat_mode = GIMP_PDB_COMPAT_WARN;
|
|
|
|
#else
|
|
|
|
static GimpStackTraceMode stack_trace_mode = GIMP_STACK_TRACE_NEVER;
|
|
|
|
static GimpPDBCompatMode pdb_compat_mode = GIMP_PDB_COMPAT_ON;
|
2001-08-04 03:43:19 +08:00
|
|
|
#endif
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2005-02-03 23:21:20 +08:00
|
|
|
|
|
|
|
static const GOptionEntry main_entries[] =
|
|
|
|
{
|
|
|
|
{ "version", 'v', 0,
|
|
|
|
G_OPTION_ARG_CALLBACK, (GOptionArgFunc) gimp_show_version,
|
|
|
|
N_("Show version information and exit"), NULL
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"verbose", 0, 0,
|
|
|
|
G_OPTION_ARG_NONE, &be_verbose,
|
|
|
|
N_("Be more verbose"), NULL
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"no-interface", 'i', 0,
|
|
|
|
G_OPTION_ARG_NONE, &no_interface,
|
|
|
|
N_("Run without a user interface"), NULL
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"no-data", 'd', 0,
|
|
|
|
G_OPTION_ARG_NONE, &no_data,
|
2005-04-06 21:15:38 +08:00
|
|
|
N_("Do not load brushes, gradients, patterns, ..."), NULL
|
2005-02-03 23:21:20 +08:00
|
|
|
},
|
|
|
|
{
|
|
|
|
"no-fonts", 'f', 0,
|
|
|
|
G_OPTION_ARG_NONE, &no_fonts,
|
|
|
|
N_("Do not load any fonts"), NULL
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"no-splash", 's', 0,
|
|
|
|
G_OPTION_ARG_NONE, &no_splash,
|
|
|
|
N_("Do not show a startup window"), NULL
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"no-shm", 0, G_OPTION_FLAG_REVERSE,
|
|
|
|
G_OPTION_ARG_NONE, &use_shm,
|
|
|
|
N_("Do not use shared memory between GIMP and plugins"), NULL
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"no-cpu-accel", 0, G_OPTION_FLAG_REVERSE,
|
|
|
|
G_OPTION_ARG_NONE, &use_cpu_accel,
|
|
|
|
N_("Do not use special CPU acceleration functions"), NULL
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"session", 0, 0,
|
|
|
|
G_OPTION_ARG_FILENAME, &session_name,
|
|
|
|
N_("Use an alternate sessionrc file"), "<name>"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"gimprc", 0, 0,
|
|
|
|
G_OPTION_ARG_FILENAME, &user_gimprc,
|
|
|
|
N_("Use an alternate user gimprc file"), "<filename>"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"system-gimprc", 0, 0,
|
|
|
|
G_OPTION_ARG_FILENAME, &system_gimprc,
|
|
|
|
N_("Use an alternate system gimprc file"), "<filename>"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"batch", 'b', 0,
|
|
|
|
G_OPTION_ARG_STRING_ARRAY, &batch_commands,
|
|
|
|
N_("Batch command to run (can be used multiple times)"), "<command>"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"batch-interpreter", 0, 0,
|
|
|
|
G_OPTION_ARG_STRING, &batch_interpreter,
|
2005-04-06 21:15:38 +08:00
|
|
|
N_("The procedure to process batch commands with"), "<proc>"
|
2005-02-03 23:21:20 +08:00
|
|
|
},
|
|
|
|
{
|
|
|
|
"console-messages", 0, 0,
|
|
|
|
G_OPTION_ARG_NONE, &console_messages,
|
2005-02-09 06:57:24 +08:00
|
|
|
N_("Send messages to console instead of using a dialog"), NULL
|
2005-02-03 23:21:20 +08:00
|
|
|
},
|
|
|
|
{
|
|
|
|
"pdb-compat-mode", 0, 0,
|
|
|
|
G_OPTION_ARG_CALLBACK, gimp_option_pdb_compat_mode,
|
2005-04-06 21:15:38 +08:00
|
|
|
/* don't translate the mode names (off|on|warn) */
|
|
|
|
N_("PDB compatibility mode (off|on|warn)"), "<mode>"
|
2005-02-03 23:21:20 +08:00
|
|
|
},
|
|
|
|
{
|
|
|
|
"stack-trace-mode", 0, 0,
|
|
|
|
G_OPTION_ARG_CALLBACK, gimp_option_stack_trace_mode,
|
2005-04-06 21:15:38 +08:00
|
|
|
/* don't translate the mode names (never|query|always) */
|
|
|
|
N_("Debug in case of a crash (never|query|always)"), "<mode>"
|
2005-02-03 23:21:20 +08:00
|
|
|
},
|
|
|
|
{
|
|
|
|
"debug-handlers", 0, 0,
|
|
|
|
G_OPTION_ARG_NONE, &use_debug_handler,
|
|
|
|
N_("Enable non-fatal debugging signal handlers"), NULL
|
|
|
|
},
|
|
|
|
{
|
2005-02-09 06:57:24 +08:00
|
|
|
"g-fatal-warnings", 0, 0,
|
|
|
|
G_OPTION_ARG_CALLBACK, gimp_option_fatal_warnings,
|
|
|
|
N_("Make all warnings fatal"), NULL
|
2005-02-03 23:21:20 +08:00
|
|
|
},
|
|
|
|
{
|
|
|
|
"dump-gimprc", 0, 0,
|
|
|
|
G_OPTION_ARG_CALLBACK, gimp_option_dump_gimprc,
|
|
|
|
N_("Output a gimprc file with default settings"), NULL
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"dump-gimprc-system", 0, G_OPTION_FLAG_HIDDEN,
|
|
|
|
G_OPTION_ARG_CALLBACK, gimp_option_dump_gimprc,
|
|
|
|
NULL, NULL
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"dump-gimprc-manpage", 0, G_OPTION_FLAG_HIDDEN,
|
|
|
|
G_OPTION_ARG_CALLBACK, gimp_option_dump_gimprc,
|
|
|
|
NULL, NULL
|
|
|
|
},
|
|
|
|
{
|
|
|
|
G_OPTION_REMAINING, 0, 0,
|
|
|
|
G_OPTION_ARG_FILENAME_ARRAY, &filenames,
|
|
|
|
NULL, NULL
|
|
|
|
},
|
|
|
|
{ NULL }
|
|
|
|
};
|
|
|
|
|
2002-02-19 01:42:17 +08:00
|
|
|
|
2005-02-03 23:21:20 +08:00
|
|
|
int
|
|
|
|
main (int argc,
|
|
|
|
char **argv)
|
|
|
|
{
|
|
|
|
GOptionContext *context;
|
|
|
|
GError *error = NULL;
|
|
|
|
const gchar *abort_message;
|
2005-02-09 06:57:24 +08:00
|
|
|
gchar *basename;
|
2005-02-03 23:58:00 +08:00
|
|
|
gint i;
|
2002-02-19 01:42:17 +08:00
|
|
|
|
2005-02-03 23:21:20 +08:00
|
|
|
gimp_init_malloc ();
|
2002-02-19 01:42:17 +08:00
|
|
|
|
2005-02-03 23:21:20 +08:00
|
|
|
gimp_init_i18n ();
|
1999-09-04 09:43:50 +08:00
|
|
|
|
2005-09-19 21:15:31 +08:00
|
|
|
g_set_application_name (_("GNU Image Manipulation Program"));
|
2005-02-03 07:04:24 +08:00
|
|
|
|
2005-02-09 06:57:24 +08:00
|
|
|
basename = g_path_get_basename (argv[0]);
|
|
|
|
g_set_prgname (basename);
|
|
|
|
g_free (basename);
|
|
|
|
|
2005-02-03 07:04:24 +08:00
|
|
|
/* Check argv[] for "--no-interface" before trying to initialize gtk+. */
|
2005-02-03 23:58:00 +08:00
|
|
|
for (i = 1; i < argc; i++)
|
|
|
|
{
|
|
|
|
const gchar *arg = argv[i];
|
|
|
|
|
|
|
|
if (arg[0] != '-')
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if ((strcmp (arg, "--no-interface") == 0) || (strcmp (arg, "-i") == 0))
|
|
|
|
{
|
|
|
|
no_interface = TRUE;
|
|
|
|
}
|
|
|
|
else if ((strcmp (arg, "--version") == 0) || (strcmp (arg, "-v") == 0))
|
|
|
|
{
|
|
|
|
gimp_show_version ();
|
|
|
|
app_exit (EXIT_SUCCESS);
|
|
|
|
}
|
|
|
|
}
|
1999-09-28 06:12:44 +08:00
|
|
|
|
2005-02-09 06:57:24 +08:00
|
|
|
#ifdef GIMP_CONSOLE_COMPILATION
|
|
|
|
no_interface = TRUE;
|
|
|
|
#endif
|
2005-02-06 23:47:03 +08:00
|
|
|
|
2005-02-03 23:58:00 +08:00
|
|
|
context = g_option_context_new ("[FILE|URI...]");
|
2005-02-03 07:04:24 +08:00
|
|
|
g_option_context_add_main_entries (context, main_entries, GETTEXT_PACKAGE);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2005-02-09 06:57:24 +08:00
|
|
|
app_libs_init (context, no_interface);
|
2005-02-03 06:08:35 +08:00
|
|
|
|
|
|
|
if (! g_option_context_parse (context, &argc, &argv, &error))
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2005-02-09 06:57:24 +08:00
|
|
|
if (error)
|
|
|
|
{
|
|
|
|
g_print ("%s\n", error->message);
|
|
|
|
g_error_free (error);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
g_print ("%s\n",
|
|
|
|
_("GIMP could not initialize the graphical user interface.\n"
|
|
|
|
"Make sure a proper setup for your display environment "
|
|
|
|
"exists."));
|
|
|
|
}
|
2001-11-18 00:32:34 +08:00
|
|
|
|
2005-02-03 06:08:35 +08:00
|
|
|
app_exit (EXIT_FAILURE);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
2005-02-09 06:57:24 +08:00
|
|
|
abort_message = sanity_check ();
|
|
|
|
if (abort_message)
|
|
|
|
app_abort (no_interface, abort_message);
|
2005-02-03 23:21:20 +08:00
|
|
|
|
2005-02-09 06:57:24 +08:00
|
|
|
gimp_init_signal_handlers ();
|
2005-02-03 23:21:20 +08:00
|
|
|
|
|
|
|
gimp_errors_init (argv[0], use_debug_handler, stack_trace_mode);
|
|
|
|
|
|
|
|
app_run (argv[0],
|
|
|
|
filenames,
|
|
|
|
system_gimprc,
|
|
|
|
user_gimprc,
|
|
|
|
session_name,
|
|
|
|
batch_interpreter,
|
|
|
|
batch_commands,
|
|
|
|
no_interface,
|
|
|
|
no_data,
|
|
|
|
no_fonts,
|
|
|
|
no_splash,
|
|
|
|
be_verbose,
|
|
|
|
use_shm,
|
|
|
|
use_cpu_accel,
|
|
|
|
console_messages,
|
|
|
|
stack_trace_mode,
|
|
|
|
pdb_compat_mode);
|
|
|
|
|
|
|
|
g_option_context_free (context);
|
|
|
|
|
|
|
|
return EXIT_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-02-09 06:57:24 +08:00
|
|
|
#ifdef G_OS_WIN32
|
2005-02-03 23:21:20 +08:00
|
|
|
|
2005-02-09 06:57:24 +08:00
|
|
|
/* In case we build this as a windowed application */
|
2000-04-22 00:42:11 +08:00
|
|
|
|
2005-02-09 06:57:24 +08:00
|
|
|
#ifdef __GNUC__
|
|
|
|
# ifndef _stdcall
|
|
|
|
# define _stdcall __attribute__((stdcall))
|
|
|
|
# endif
|
2005-02-03 23:21:20 +08:00
|
|
|
#endif
|
|
|
|
|
2005-02-09 06:57:24 +08:00
|
|
|
int _stdcall
|
|
|
|
WinMain (struct HINSTANCE__ *hInstance,
|
|
|
|
struct HINSTANCE__ *hPrevInstance,
|
|
|
|
char *lpszCmdLine,
|
|
|
|
int nCmdShow)
|
2005-02-03 23:21:20 +08:00
|
|
|
{
|
2005-02-09 06:57:24 +08:00
|
|
|
return main (__argc, __argv);
|
|
|
|
}
|
2002-12-18 00:26:34 +08:00
|
|
|
|
2005-02-09 06:57:24 +08:00
|
|
|
#endif /* G_OS_WIN32 */
|
2000-04-22 00:42:11 +08:00
|
|
|
|
app/appenv.h New file. Includes <math.h>. Move G_PI, RINT(), ROUND() etc
1999-09-01 Tor Lillqvist <tml@iki.fi>
* app/appenv.h
* libgimp/gimpmath.h: New file. Includes <math.h>. Move G_PI,
RINT(), ROUND() etc from app/appenv.h here, so plug-ins can
use them, too. Remove some commented-out old stuff in appenv.h.
* libgimp/gimp.h: Include gimpmath.h.
* libgimp/gimp.c (gimp_main): Win32: Don't install signal
handlers, we can't do anything useful in the handler ourselves
anyway (it would be nice to print out a backtrace, but that seems
pretty hard to do, even if not impossible). Let Windows inform the
user about the crash. If the plug-in was compiled with MSVC, and
the user also has it, she is offered a chance to start the
debugger automatically anyway.
* app/*several*.c: Include gimpmath.h for G_PI etc. Don't include
<math.h>, as gimpmath.h includes it.
* plug-ins/*/*many*.c: Include config.h. Don't include <math.h>.
Remove all the duplicated definitions of G_PI and rint(). Use
RINT() instead of rint().
* app/app_procs.[ch]: app_exit() takes a gboolean.
* app/batch.c
* app/commands.c
* app/interface.c: Call app_exit() with FALSE or TRUE.
* app/main.c (on_error): Call gimp_fatal_error. (main): Don't
install any signal handler on Win32 here, either.
* app/errors.c (gimp_fatal_error, gimp_terminate): Win32: Format
the message and call MessageBox with it. g_on_error_query doesn't
do anything useful on Win32, and printf'ing a message to stdout or
stderr doesn't do anything, either, in a windowing application.
1999-09-02 04:30:56 +08:00
|
|
|
|
2005-02-09 06:57:24 +08:00
|
|
|
static gboolean
|
|
|
|
gimp_option_fatal_warnings (const gchar *option_name,
|
|
|
|
const gchar *value,
|
|
|
|
gpointer data,
|
|
|
|
GError **error)
|
|
|
|
{
|
|
|
|
GLogLevelFlags fatal_mask;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2005-02-09 06:57:24 +08:00
|
|
|
fatal_mask = g_log_set_always_fatal (G_LOG_FATAL_MASK);
|
|
|
|
fatal_mask |= G_LOG_LEVEL_WARNING | G_LOG_LEVEL_CRITICAL;
|
2000-05-11 05:21:23 +08:00
|
|
|
|
2005-02-09 06:57:24 +08:00
|
|
|
g_log_set_always_fatal (fatal_mask);
|
2005-02-03 07:04:24 +08:00
|
|
|
|
2005-02-09 06:57:24 +08:00
|
|
|
return TRUE;
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
2005-02-03 06:08:35 +08:00
|
|
|
static gboolean
|
|
|
|
gimp_option_stack_trace_mode (const gchar *option_name,
|
|
|
|
const gchar *value,
|
|
|
|
gpointer data,
|
|
|
|
GError **error)
|
|
|
|
{
|
|
|
|
if (strcmp (value, "never") == 0)
|
|
|
|
stack_trace_mode = GIMP_STACK_TRACE_NEVER;
|
|
|
|
else if (strcmp (value, "query") == 0)
|
|
|
|
stack_trace_mode = GIMP_STACK_TRACE_QUERY;
|
|
|
|
else if (strcmp (value, "always") == 0)
|
|
|
|
stack_trace_mode = GIMP_STACK_TRACE_ALWAYS;
|
|
|
|
else
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
gimp_option_pdb_compat_mode (const gchar *option_name,
|
|
|
|
const gchar *value,
|
|
|
|
gpointer data,
|
|
|
|
GError **error)
|
|
|
|
{
|
|
|
|
if (! strcmp (value, "off"))
|
|
|
|
pdb_compat_mode = GIMP_PDB_COMPAT_OFF;
|
|
|
|
else if (! strcmp (value, "on"))
|
|
|
|
pdb_compat_mode = GIMP_PDB_COMPAT_ON;
|
|
|
|
else if (! strcmp (value, "warn"))
|
|
|
|
pdb_compat_mode = GIMP_PDB_COMPAT_WARN;
|
|
|
|
else
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
removed the gimp_busy boolean, check whether user_installation is needed
2001-07-10 Michael Natterer <mitch@gimp.org>
* app/app_procs.[ch]: removed the gimp_busy boolean, check whether
user_installation is needed here, not in user_install.c, parse
gtkrc an friends only if(!no_interface), create the Gimp object
before parsing gimp's rc files an pas it to the parse functions,
many other cleanups.
* app/appenums.h: added MessageHandlerType and StackTraceMode.
* app/appenv.h: removed MessageHandlerType, declare all global
variables from main.c (no more hidden global stuff please).
* app/errors.[ch]: added the fatal message func here (from main.c),
removed the StackTraceMode enum.
* app/gimprc.[ch]: renamed functions to gimprc_*(), pass a Gimp
pointer to some functions.
* app/gimpunit.c
* app/unitrc.h: ok, this is ugly: renamed all functions to
_gimp_unit_*() and made them public. The unit list is part
of the Gimp object now, so pass a Gimp* to all functions.
* app/libgimp_glue.[ch]: added EEKy wrappers for all gimp_unit_*()
functions which are used by widgets.
* app/main.c: cleaned up the global variables, removed the fatal
message handler, call app_init() directly, not via the
user_install stuff, misc. cleanups.
* app/user_install.[ch]: removed the check if user_installation is
needed (done by app_procs.c now).
* app/core/gimp.[ch]: added the user_unit list and the "busy"
boolean. Moved gimp_[set|unset]_busy() here. Added
gimp_initialize() which is called after unitrc and gimprc are
parsed.
* app/batch.c
* app/colormaps.c
* app/devices.c
* app/disp_callbacks.c
* app/gdisplay_ops.c
* app/gimphelp.c
* app/module_db.c
* app/nav_window.c
* app/plug_in.c
* app/core/gimpcontext.c
* app/core/gimpdatafiles.c
* app/core/gimpimage-convert.c
* app/core/gimpimage-duplicate.c
* app/core/gimpimage.c
* app/core/gimpparasite.c
* app/core/gimpparasitelist.h
* app/gui/file-open-dialog.c
* app/gui/gui.[ch]
* app/gui/info-dialog.c
* app/gui/info-window.c
* app/gui/preferences-dialog.c
* app/gui/session.c
* app/gui/tips-dialog.c
* app/gui/toolbox.c
* app/tools/gimpblendtool.c
* app/tools/gimpbucketfilltool.c
* app/tools/gimpcolorpickertool.c
* app/tools/gimpfuzzyselecttool.c
* app/tools/gimptransformtool.c
* app/tools/tool_manager.c
* app/widgets/gimpcolorpanel.c
* app/widgets/gimpcursor.c
* app/xcf/xcf-load.c
* app/xcf/xcf-save.c
* app/xcf/xcf.c
* tools/pdbgen/Makefile.am
* tools/pdbgen/app.pl
* tools/pdbgen/enums.pl
* tools/pdbgen/pdb/image.pdb
* tools/pdbgen/pdb/message.pdb
* tools/pdbgen/pdb/unit.pdb
* app/pdb/image_cmds.c
* app/pdb/message_cmds.c
* app/pdb/unit_cmds.c: changed accordingly, minor cleanups.
2001-07-11 03:16:16 +08:00
|
|
|
|
2005-02-03 07:04:24 +08:00
|
|
|
static gboolean
|
|
|
|
gimp_option_dump_gimprc (const gchar *option_name,
|
|
|
|
const gchar *value,
|
|
|
|
gpointer data,
|
|
|
|
GError **error)
|
2003-01-09 07:43:31 +08:00
|
|
|
{
|
2005-02-03 07:04:24 +08:00
|
|
|
GimpConfigDumpFormat format = GIMP_CONFIG_DUMP_NONE;
|
|
|
|
|
|
|
|
if (strcmp (option_name, "--dump-gimprc") == 0)
|
|
|
|
format = GIMP_CONFIG_DUMP_GIMPRC;
|
|
|
|
if (strcmp (option_name, "--dump-gimprc-system") == 0)
|
|
|
|
format = GIMP_CONFIG_DUMP_GIMPRC_SYSTEM;
|
|
|
|
else if (strcmp (option_name, "--dump-gimprc-manpage") == 0)
|
|
|
|
format = GIMP_CONFIG_DUMP_GIMPRC_MANPAGE;
|
|
|
|
|
|
|
|
if (format)
|
|
|
|
{
|
|
|
|
Gimp *gimp;
|
|
|
|
gboolean success;
|
|
|
|
|
|
|
|
gimp = g_object_new (GIMP_TYPE_GIMP, NULL);
|
|
|
|
|
|
|
|
units_init (gimp);
|
|
|
|
|
|
|
|
success = gimp_config_dump (format);
|
|
|
|
|
|
|
|
g_object_unref (gimp);
|
|
|
|
|
|
|
|
app_exit (success ? EXIT_SUCCESS : EXIT_FAILURE);
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
2003-01-09 07:43:31 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2005-02-03 07:04:24 +08:00
|
|
|
gimp_show_version (void)
|
2003-01-09 07:43:31 +08:00
|
|
|
{
|
2005-02-04 04:23:51 +08:00
|
|
|
g_print (_("%s version %s"), "GIMP", GIMP_VERSION);
|
2003-10-26 04:05:41 +08:00
|
|
|
g_print ("\n");
|
2005-02-03 07:04:24 +08:00
|
|
|
|
|
|
|
app_exit (EXIT_SUCCESS);
|
2004-11-27 20:09:13 +08:00
|
|
|
}
|
2003-10-26 04:05:41 +08:00
|
|
|
|
2003-01-09 07:43:31 +08:00
|
|
|
|
2005-02-09 06:57:24 +08:00
|
|
|
static void
|
|
|
|
gimp_init_malloc (void)
|
|
|
|
{
|
|
|
|
#if 0
|
|
|
|
g_mem_set_vtable (glib_mem_profiler_table);
|
|
|
|
g_atexit (g_mem_profile);
|
|
|
|
#endif
|
1999-02-21 07:20:54 +08:00
|
|
|
|
2005-02-09 06:57:24 +08:00
|
|
|
#ifdef __GLIBC__
|
|
|
|
/* Tweak memory allocation so that memory allocated in chunks >= 4k
|
2005-02-15 19:11:02 +08:00
|
|
|
* (64x64 pixel 1bpp tile) gets returned to the system when free()'d.
|
|
|
|
*
|
|
|
|
* The default value for M_MMAP_THRESHOLD in glibc-2.3 is 128k.
|
|
|
|
* This is said to be an empirically derived value that works well
|
|
|
|
* in most systems. Lowering it to 4k is thus probably not the ideal
|
|
|
|
* solution.
|
|
|
|
*
|
|
|
|
* An alternative to tuning this parameter would be to use
|
|
|
|
* malloc_trim(), for example after releasing a large tile-manager.
|
2005-02-09 06:57:24 +08:00
|
|
|
*/
|
2005-02-15 19:19:23 +08:00
|
|
|
mallopt (M_MMAP_THRESHOLD, TILE_WIDTH * TILE_HEIGHT);
|
Check for mmap.
* configure.in: Check for mmap.
* app/makefile.msc: Depend on gimpi.lib.
* app/app_procs.c (app_init): Fix gccism: Allocate filenames (an
array with non-constant size) dynamically.
* app/{datafiles,fileops,general,install,module_db,temp_buf}.c:
Include glib.h before standard headers, because of certain obscure
details related to compiling with gcc on Win32.
(If you really want to know: glib.h defines he names of POSIXish
(but non-ANSI) functions as prefixed with underscore, because
that's how they are named in the msvcrt runtime C library we want
to use. However, defining stat as _stat causes some problems if
done after including the mingw32 <sys/stat.h>. So, it's easiest to
include <glib.h> early.)
* app/main.c: Use _stdcall and __argc, __argv with MSC, but
__attribute__((stdcall)) and _argc, _argv with gcc. Don't print
the "Passed serialization test" message on Win32. (It would open
up an otherwise unnecessary console window.)
* app/paint_funcs.c (gaussian_blur_region): Don't use variable sum
until initialized.
* app/{bezier_select,paths_dialog}.c: Include config.h and define
rint() if necessary.
* app/plug_in.c: Use _spawnv, not spawnv, on Win32 and OS/2.
1999-05-29 01:47:17 +08:00
|
|
|
#endif
|
2005-02-09 06:57:24 +08:00
|
|
|
}
|
Check for mmap.
* configure.in: Check for mmap.
* app/makefile.msc: Depend on gimpi.lib.
* app/app_procs.c (app_init): Fix gccism: Allocate filenames (an
array with non-constant size) dynamically.
* app/{datafiles,fileops,general,install,module_db,temp_buf}.c:
Include glib.h before standard headers, because of certain obscure
details related to compiling with gcc on Win32.
(If you really want to know: glib.h defines he names of POSIXish
(but non-ANSI) functions as prefixed with underscore, because
that's how they are named in the msvcrt runtime C library we want
to use. However, defining stat as _stat causes some problems if
done after including the mingw32 <sys/stat.h>. So, it's easiest to
include <glib.h> early.)
* app/main.c: Use _stdcall and __argc, __argv with MSC, but
__attribute__((stdcall)) and _argc, _argv with gcc. Don't print
the "Passed serialization test" message on Win32. (It would open
up an otherwise unnecessary console window.)
* app/paint_funcs.c (gaussian_blur_region): Don't use variable sum
until initialized.
* app/{bezier_select,paths_dialog}.c: Include config.h and define
rint() if necessary.
* app/plug_in.c: Use _spawnv, not spawnv, on Win32 and OS/2.
1999-05-29 01:47:17 +08:00
|
|
|
|
2005-02-09 06:57:24 +08:00
|
|
|
static void
|
|
|
|
gimp_init_i18n (void)
|
1999-02-21 07:20:54 +08:00
|
|
|
{
|
2005-02-09 06:57:24 +08:00
|
|
|
setlocale (LC_ALL, "");
|
|
|
|
|
|
|
|
bindtextdomain (GETTEXT_PACKAGE"-libgimp", gimp_locale_directory ());
|
|
|
|
#ifdef HAVE_BIND_TEXTDOMAIN_CODESET
|
|
|
|
bind_textdomain_codeset (GETTEXT_PACKAGE"-libgimp", "UTF-8");
|
|
|
|
#endif
|
|
|
|
|
|
|
|
bindtextdomain (GETTEXT_PACKAGE, gimp_locale_directory ());
|
|
|
|
#ifdef HAVE_BIND_TEXTDOMAIN_CODESET
|
|
|
|
bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
|
|
|
|
#endif
|
|
|
|
|
|
|
|
textdomain (GETTEXT_PACKAGE);
|
1999-02-21 07:20:54 +08:00
|
|
|
}
|
|
|
|
|
2005-02-09 06:57:24 +08:00
|
|
|
static void
|
|
|
|
gimp_init_signal_handlers (void)
|
|
|
|
{
|
|
|
|
#ifndef G_OS_WIN32
|
|
|
|
/* 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
|
|
|
|
* install itself as a handler for program errors).
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* Handle fatal signals */
|
|
|
|
|
|
|
|
/* these are handled by gimp_terminate() */
|
|
|
|
gimp_signal_private (SIGHUP, gimp_sigfatal_handler, 0);
|
|
|
|
gimp_signal_private (SIGINT, gimp_sigfatal_handler, 0);
|
|
|
|
gimp_signal_private (SIGQUIT, gimp_sigfatal_handler, 0);
|
|
|
|
gimp_signal_private (SIGABRT, gimp_sigfatal_handler, 0);
|
|
|
|
gimp_signal_private (SIGTERM, gimp_sigfatal_handler, 0);
|
|
|
|
|
|
|
|
if (stack_trace_mode != GIMP_STACK_TRACE_NEVER)
|
|
|
|
{
|
|
|
|
/* these are handled by gimp_fatal_error() */
|
|
|
|
gimp_signal_private (SIGBUS, gimp_sigfatal_handler, 0);
|
|
|
|
gimp_signal_private (SIGSEGV, gimp_sigfatal_handler, 0);
|
|
|
|
gimp_signal_private (SIGFPE, gimp_sigfatal_handler, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Ignore SIGPIPE because plug_in.c handles broken pipes */
|
|
|
|
gimp_signal_private (SIGPIPE, SIG_IGN, 0);
|
|
|
|
|
|
|
|
/* Restart syscalls on SIGCHLD */
|
|
|
|
gimp_signal_private (SIGCHLD, SIG_DFL, SA_RESTART);
|
|
|
|
|
removed the gimp_busy boolean, check whether user_installation is needed
2001-07-10 Michael Natterer <mitch@gimp.org>
* app/app_procs.[ch]: removed the gimp_busy boolean, check whether
user_installation is needed here, not in user_install.c, parse
gtkrc an friends only if(!no_interface), create the Gimp object
before parsing gimp's rc files an pas it to the parse functions,
many other cleanups.
* app/appenums.h: added MessageHandlerType and StackTraceMode.
* app/appenv.h: removed MessageHandlerType, declare all global
variables from main.c (no more hidden global stuff please).
* app/errors.[ch]: added the fatal message func here (from main.c),
removed the StackTraceMode enum.
* app/gimprc.[ch]: renamed functions to gimprc_*(), pass a Gimp
pointer to some functions.
* app/gimpunit.c
* app/unitrc.h: ok, this is ugly: renamed all functions to
_gimp_unit_*() and made them public. The unit list is part
of the Gimp object now, so pass a Gimp* to all functions.
* app/libgimp_glue.[ch]: added EEKy wrappers for all gimp_unit_*()
functions which are used by widgets.
* app/main.c: cleaned up the global variables, removed the fatal
message handler, call app_init() directly, not via the
user_install stuff, misc. cleanups.
* app/user_install.[ch]: removed the check if user_installation is
needed (done by app_procs.c now).
* app/core/gimp.[ch]: added the user_unit list and the "busy"
boolean. Moved gimp_[set|unset]_busy() here. Added
gimp_initialize() which is called after unitrc and gimprc are
parsed.
* app/batch.c
* app/colormaps.c
* app/devices.c
* app/disp_callbacks.c
* app/gdisplay_ops.c
* app/gimphelp.c
* app/module_db.c
* app/nav_window.c
* app/plug_in.c
* app/core/gimpcontext.c
* app/core/gimpdatafiles.c
* app/core/gimpimage-convert.c
* app/core/gimpimage-duplicate.c
* app/core/gimpimage.c
* app/core/gimpparasite.c
* app/core/gimpparasitelist.h
* app/gui/file-open-dialog.c
* app/gui/gui.[ch]
* app/gui/info-dialog.c
* app/gui/info-window.c
* app/gui/preferences-dialog.c
* app/gui/session.c
* app/gui/tips-dialog.c
* app/gui/toolbox.c
* app/tools/gimpblendtool.c
* app/tools/gimpbucketfilltool.c
* app/tools/gimpcolorpickertool.c
* app/tools/gimpfuzzyselecttool.c
* app/tools/gimptransformtool.c
* app/tools/tool_manager.c
* app/widgets/gimpcolorpanel.c
* app/widgets/gimpcursor.c
* app/xcf/xcf-load.c
* app/xcf/xcf-save.c
* app/xcf/xcf.c
* tools/pdbgen/Makefile.am
* tools/pdbgen/app.pl
* tools/pdbgen/enums.pl
* tools/pdbgen/pdb/image.pdb
* tools/pdbgen/pdb/message.pdb
* tools/pdbgen/pdb/unit.pdb
* app/pdb/image_cmds.c
* app/pdb/message_cmds.c
* app/pdb/unit_cmds.c: changed accordingly, minor cleanups.
2001-07-11 03:16:16 +08:00
|
|
|
#endif /* G_OS_WIN32 */
|
2005-02-09 06:57:24 +08:00
|
|
|
}
|
1999-01-08 03:53:05 +08:00
|
|
|
|
|
|
|
|
1999-10-05 03:26:07 +08:00
|
|
|
#ifndef G_OS_WIN32
|
app/appenv.h New file. Includes <math.h>. Move G_PI, RINT(), ROUND() etc
1999-09-01 Tor Lillqvist <tml@iki.fi>
* app/appenv.h
* libgimp/gimpmath.h: New file. Includes <math.h>. Move G_PI,
RINT(), ROUND() etc from app/appenv.h here, so plug-ins can
use them, too. Remove some commented-out old stuff in appenv.h.
* libgimp/gimp.h: Include gimpmath.h.
* libgimp/gimp.c (gimp_main): Win32: Don't install signal
handlers, we can't do anything useful in the handler ourselves
anyway (it would be nice to print out a backtrace, but that seems
pretty hard to do, even if not impossible). Let Windows inform the
user about the crash. If the plug-in was compiled with MSVC, and
the user also has it, she is offered a chance to start the
debugger automatically anyway.
* app/*several*.c: Include gimpmath.h for G_PI etc. Don't include
<math.h>, as gimpmath.h includes it.
* plug-ins/*/*many*.c: Include config.h. Don't include <math.h>.
Remove all the duplicated definitions of G_PI and rint(). Use
RINT() instead of rint().
* app/app_procs.[ch]: app_exit() takes a gboolean.
* app/batch.c
* app/commands.c
* app/interface.c: Call app_exit() with FALSE or TRUE.
* app/main.c (on_error): Call gimp_fatal_error. (main): Don't
install any signal handler on Win32 here, either.
* app/errors.c (gimp_fatal_error, gimp_terminate): Win32: Format
the message and call MessageBox with it. g_on_error_query doesn't
do anything useful on Win32, and printf'ing a message to stdout or
stderr doesn't do anything, either, in a windowing application.
1999-09-02 04:30:56 +08:00
|
|
|
|
2000-04-22 00:42:11 +08:00
|
|
|
/* gimp core signal handler for fatal signals */
|
|
|
|
|
|
|
|
static void
|
2000-05-11 05:21:23 +08:00
|
|
|
gimp_sigfatal_handler (gint sig_num)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
|
|
|
switch (sig_num)
|
|
|
|
{
|
|
|
|
case SIGHUP:
|
|
|
|
case SIGINT:
|
|
|
|
case SIGQUIT:
|
|
|
|
case SIGABRT:
|
2000-05-11 05:21:23 +08:00
|
|
|
case SIGTERM:
|
|
|
|
gimp_terminate (g_strsignal (sig_num));
|
1997-11-25 06:05:25 +08:00
|
|
|
break;
|
2000-04-22 00:42:11 +08:00
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
case SIGBUS:
|
|
|
|
case SIGSEGV:
|
2000-05-11 05:21:23 +08:00
|
|
|
case SIGFPE:
|
|
|
|
default:
|
|
|
|
gimp_fatal_error (g_strsignal (sig_num));
|
1997-11-25 06:05:25 +08:00
|
|
|
break;
|
2000-05-11 05:21:23 +08:00
|
|
|
}
|
|
|
|
}
|
2000-04-22 00:42:11 +08:00
|
|
|
|
removed the gimp_busy boolean, check whether user_installation is needed
2001-07-10 Michael Natterer <mitch@gimp.org>
* app/app_procs.[ch]: removed the gimp_busy boolean, check whether
user_installation is needed here, not in user_install.c, parse
gtkrc an friends only if(!no_interface), create the Gimp object
before parsing gimp's rc files an pas it to the parse functions,
many other cleanups.
* app/appenums.h: added MessageHandlerType and StackTraceMode.
* app/appenv.h: removed MessageHandlerType, declare all global
variables from main.c (no more hidden global stuff please).
* app/errors.[ch]: added the fatal message func here (from main.c),
removed the StackTraceMode enum.
* app/gimprc.[ch]: renamed functions to gimprc_*(), pass a Gimp
pointer to some functions.
* app/gimpunit.c
* app/unitrc.h: ok, this is ugly: renamed all functions to
_gimp_unit_*() and made them public. The unit list is part
of the Gimp object now, so pass a Gimp* to all functions.
* app/libgimp_glue.[ch]: added EEKy wrappers for all gimp_unit_*()
functions which are used by widgets.
* app/main.c: cleaned up the global variables, removed the fatal
message handler, call app_init() directly, not via the
user_install stuff, misc. cleanups.
* app/user_install.[ch]: removed the check if user_installation is
needed (done by app_procs.c now).
* app/core/gimp.[ch]: added the user_unit list and the "busy"
boolean. Moved gimp_[set|unset]_busy() here. Added
gimp_initialize() which is called after unitrc and gimprc are
parsed.
* app/batch.c
* app/colormaps.c
* app/devices.c
* app/disp_callbacks.c
* app/gdisplay_ops.c
* app/gimphelp.c
* app/module_db.c
* app/nav_window.c
* app/plug_in.c
* app/core/gimpcontext.c
* app/core/gimpdatafiles.c
* app/core/gimpimage-convert.c
* app/core/gimpimage-duplicate.c
* app/core/gimpimage.c
* app/core/gimpparasite.c
* app/core/gimpparasitelist.h
* app/gui/file-open-dialog.c
* app/gui/gui.[ch]
* app/gui/info-dialog.c
* app/gui/info-window.c
* app/gui/preferences-dialog.c
* app/gui/session.c
* app/gui/tips-dialog.c
* app/gui/toolbox.c
* app/tools/gimpblendtool.c
* app/tools/gimpbucketfilltool.c
* app/tools/gimpcolorpickertool.c
* app/tools/gimpfuzzyselecttool.c
* app/tools/gimptransformtool.c
* app/tools/tool_manager.c
* app/widgets/gimpcolorpanel.c
* app/widgets/gimpcursor.c
* app/xcf/xcf-load.c
* app/xcf/xcf-save.c
* app/xcf/xcf.c
* tools/pdbgen/Makefile.am
* tools/pdbgen/app.pl
* tools/pdbgen/enums.pl
* tools/pdbgen/pdb/image.pdb
* tools/pdbgen/pdb/message.pdb
* tools/pdbgen/pdb/unit.pdb
* app/pdb/image_cmds.c
* app/pdb/message_cmds.c
* app/pdb/unit_cmds.c: changed accordingly, minor cleanups.
2001-07-11 03:16:16 +08:00
|
|
|
#endif /* ! G_OS_WIN32 */
|