2006-12-10 05:33:38 +08:00
|
|
|
/* GIMP - The GNU Image Manipulation Program
|
1997-11-25 06:05:25 +08:00
|
|
|
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
|
|
|
*
|
2009-01-18 06:28:01 +08:00
|
|
|
* This program is free software: you can redistribute it and/or modify
|
1997-11-25 06:05:25 +08:00
|
|
|
* it under the terms of the GNU General Public License as published by
|
2009-01-18 06:28:01 +08:00
|
|
|
* the Free Software Foundation; either version 3 of the License, or
|
1997-11-25 06:05:25 +08:00
|
|
|
* (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
|
2018-07-12 05:27:07 +08:00
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
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>
|
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>
|
|
|
|
|
2013-10-15 07:58:39 +08:00
|
|
|
#include <gio/gio.h>
|
2000-02-11 09:04:23 +08:00
|
|
|
|
2007-08-27 02:59:34 +08:00
|
|
|
#ifdef G_OS_WIN32
|
|
|
|
#include <io.h> /* get_osfhandle */
|
2015-08-31 21:26:51 +08:00
|
|
|
|
|
|
|
#endif /* G_OS_WIN32 */
|
|
|
|
|
2019-11-03 22:07:46 +08:00
|
|
|
#if defined(ENABLE_RELOCATABLE_RESOURCES) && defined(__APPLE__)
|
|
|
|
#include <libgen.h> /* dirname */
|
|
|
|
#include <sys/stat.h>
|
|
|
|
#endif /* __APPLE__ */
|
|
|
|
|
2008-07-11 17:16:23 +08:00
|
|
|
#ifndef GIMP_CONSOLE_COMPILATION
|
2021-08-14 18:29:17 +08:00
|
|
|
#include <gtk/gtk.h>
|
2016-01-02 02:37:10 +08:00
|
|
|
#else
|
|
|
|
#include <gdk-pixbuf/gdk-pixbuf.h>
|
2008-07-11 17:16:23 +08:00
|
|
|
#endif
|
|
|
|
|
2012-11-20 15:21:33 +08:00
|
|
|
#include <babl/babl.h>
|
|
|
|
|
2001-05-22 04:30:16 +08:00
|
|
|
#include "libgimpbase/gimpbase.h"
|
1998-07-15 10:28:31 +08:00
|
|
|
|
2011-05-05 06:33:19 +08:00
|
|
|
#include "pdb/pdb-types.h"
|
2005-02-15 19:19:23 +08:00
|
|
|
|
2021-08-14 18:29:17 +08:00
|
|
|
#include "config/gimpearlyrc.h"
|
2003-10-14 06:55:25 +08:00
|
|
|
#include "config/gimpconfig-dump.h"
|
|
|
|
|
|
|
|
#include "core/gimp.h"
|
2019-05-19 22:46:52 +08:00
|
|
|
#include "core/gimpbacktrace.h"
|
2000-12-17 05:37:03 +08:00
|
|
|
|
2011-05-05 06:33:19 +08:00
|
|
|
#include "pdb/gimppdb.h"
|
|
|
|
#include "pdb/gimpprocedure.h"
|
|
|
|
#include "pdb/internal-procs.h"
|
|
|
|
|
2005-12-29 04:45:52 +08:00
|
|
|
#include "about.h"
|
2007-02-02 22:27:16 +08:00
|
|
|
#include "app.h"
|
2021-08-14 18:29:17 +08:00
|
|
|
#include "language.h"
|
2004-03-30 19:32:21 +08:00
|
|
|
#include "sanity.h"
|
2008-10-14 03:32:33 +08:00
|
|
|
#include "signals.h"
|
2008-07-11 17:08:07 +08:00
|
|
|
#include "unique.h"
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2005-02-03 06:08:35 +08:00
|
|
|
#ifdef G_OS_WIN32
|
2010-09-02 23:38:06 +08:00
|
|
|
/* To get PROCESS_DEP_* defined we need _WIN32_WINNT at 0x0601. We still
|
|
|
|
* use the API optionally only if present, though.
|
|
|
|
*/
|
2016-05-29 08:26:04 +08:00
|
|
|
#ifdef _WIN32_WINNT
|
|
|
|
#undef _WIN32_WINNT
|
|
|
|
#endif
|
2010-09-02 23:38:06 +08:00
|
|
|
#define _WIN32_WINNT 0x0601
|
2005-02-03 06:08:35 +08:00
|
|
|
#include <windows.h>
|
Make the handling of console output make more sense Win32. Should mostly
2007-01-26 Tor Lillqvist <tml@novell.com>
Make the handling of console output make more sense Win32. Should
mostly fix #400927.
* app/app_procs.c (app_exit): Drop the Win32 "This console window
will close in ten seconds" message from here.
(app_run): Drop the call to FreeConsole() from here. GIMP is built
as a GUI executable on Windows, and in case we do open a fresh
console window in main() (see below), we shouldn't then
immediately close it here.
* app/errors.c (errors_init): Drop printing the "You can mimize
this window, but don't close it" message on Win32 from here.
* app/main.c (gimp_open_console_window): New Win32-only
function. If either stdout or stderr are unconnected, open a new
console window and connect stdout and/or stderr to it as
needed. Set the console title to "GIMP output. You can minimize
this window, but don't close it." Register an atexit function that
waits for the user to close the console window.
(wait_console_window): New Win32-only function. Registered as an
atexit function when GIMP has opened a new console window. Prompts
the user to type any character to close the window.
(main, gimp_show_version): Always call gimp_open_console_window()
in the unstable version. As the "This is a development version of
GIMP. Debug messages may appear here" message says, one point of
the unstable version is that debug messages should be visible, so
I think it makes sense to always see them in an unstable
version. In stable versions, call gimp_open_console_window() only
if options that cause output that the user wants to see were
given, like --help and --version.
svn path=/trunk/; revision=21781
2007-01-27 04:47:36 +08:00
|
|
|
#include <conio.h>
|
2005-02-03 06:08:35 +08:00
|
|
|
#endif
|
|
|
|
|
2007-11-15 18:57:53 +08:00
|
|
|
#include "gimp-log.h"
|
2003-03-26 00:38:19 +08:00
|
|
|
#include "gimp-intl.h"
|
2018-01-29 07:58:01 +08:00
|
|
|
#include "gimp-version.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);
|
2011-05-05 06:33:19 +08:00
|
|
|
static gboolean gimp_option_dump_pdb_procedures_deprecated
|
|
|
|
(const gchar *option_name,
|
|
|
|
const gchar *value,
|
|
|
|
gpointer data,
|
|
|
|
GError **error);
|
2005-02-09 06:57:24 +08:00
|
|
|
|
2005-12-30 02:39:03 +08:00
|
|
|
static void gimp_show_version_and_exit (void) G_GNUC_NORETURN;
|
|
|
|
static void gimp_show_license_and_exit (void) G_GNUC_NORETURN;
|
2005-02-09 06:57:24 +08:00
|
|
|
|
|
|
|
static void gimp_init_i18n (void);
|
|
|
|
static void gimp_init_malloc (void);
|
2003-01-09 07:43:31 +08:00
|
|
|
|
Make the handling of console output make more sense Win32. Should mostly
2007-01-26 Tor Lillqvist <tml@novell.com>
Make the handling of console output make more sense Win32. Should
mostly fix #400927.
* app/app_procs.c (app_exit): Drop the Win32 "This console window
will close in ten seconds" message from here.
(app_run): Drop the call to FreeConsole() from here. GIMP is built
as a GUI executable on Windows, and in case we do open a fresh
console window in main() (see below), we shouldn't then
immediately close it here.
* app/errors.c (errors_init): Drop printing the "You can mimize
this window, but don't close it" message on Win32 from here.
* app/main.c (gimp_open_console_window): New Win32-only
function. If either stdout or stderr are unconnected, open a new
console window and connect stdout and/or stderr to it as
needed. Set the console title to "GIMP output. You can minimize
this window, but don't close it." Register an atexit function that
waits for the user to close the console window.
(wait_console_window): New Win32-only function. Registered as an
atexit function when GIMP has opened a new console window. Prompts
the user to type any character to close the window.
(main, gimp_show_version): Always call gimp_open_console_window()
in the unstable version. As the "This is a development version of
GIMP. Debug messages may appear here" message says, one point of
the unstable version is that debug messages should be visible, so
I think it makes sense to always see them in an unstable
version. In stable versions, call gimp_open_console_window() only
if options that cause output that the user wants to see were
given, like --help and --version.
svn path=/trunk/; revision=21781
2007-01-27 04:47:36 +08:00
|
|
|
#if defined (G_OS_WIN32) && !defined (GIMP_CONSOLE_COMPILATION)
|
|
|
|
static void gimp_open_console_window (void);
|
|
|
|
#else
|
|
|
|
#define gimp_open_console_window() /* as nothing */
|
|
|
|
#endif
|
2005-02-03 23:21:20 +08:00
|
|
|
|
2005-09-26 07:04:25 +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;
|
2007-04-17 23:54:01 +08:00
|
|
|
static gboolean as_new = FALSE;
|
2005-09-26 07:04:25 +08:00
|
|
|
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;
|
2007-01-19 22:50:13 +08:00
|
|
|
static gboolean new_instance = FALSE;
|
2005-02-03 07:04:24 +08:00
|
|
|
#if defined (USE_SYSV_SHM) || defined (USE_POSIX_SHM) || defined (G_OS_WIN32)
|
2005-09-26 07:04:25 +08:00
|
|
|
static gboolean use_shm = TRUE;
|
2005-02-03 07:04:24 +08:00
|
|
|
#else
|
2005-09-26 07:04:25 +08:00
|
|
|
static gboolean use_shm = FALSE;
|
2005-02-03 07:04:24 +08:00
|
|
|
#endif
|
2005-09-26 07:04:25 +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
|
2014-09-14 07:08:25 +08:00
|
|
|
static gboolean show_playground = TRUE;
|
2018-03-29 17:20:20 +08:00
|
|
|
static gboolean show_debug_menu = TRUE;
|
2005-09-26 07:04:25 +08:00
|
|
|
static GimpStackTraceMode stack_trace_mode = GIMP_STACK_TRACE_QUERY;
|
|
|
|
static GimpPDBCompatMode pdb_compat_mode = GIMP_PDB_COMPAT_WARN;
|
2005-02-03 23:21:20 +08:00
|
|
|
#else
|
2014-09-14 07:08:25 +08:00
|
|
|
static gboolean show_playground = FALSE;
|
2018-03-29 17:20:20 +08:00
|
|
|
static gboolean show_debug_menu = FALSE;
|
2005-09-26 07:04:25 +08:00
|
|
|
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[] =
|
|
|
|
{
|
2005-09-26 07:04:25 +08:00
|
|
|
{ "version", 'v', G_OPTION_FLAG_NO_ARG,
|
2005-12-30 02:39:03 +08:00
|
|
|
G_OPTION_ARG_CALLBACK, (GOptionArgFunc) gimp_show_version_and_exit,
|
2005-02-03 23:21:20 +08:00
|
|
|
N_("Show version information and exit"), NULL
|
|
|
|
},
|
2005-12-30 02:39:03 +08:00
|
|
|
{
|
|
|
|
"license", 0, G_OPTION_FLAG_NO_ARG,
|
|
|
|
G_OPTION_ARG_CALLBACK, (GOptionArgFunc) gimp_show_license_and_exit,
|
|
|
|
N_("Show license information and exit"), NULL
|
|
|
|
},
|
2005-02-03 23:21:20 +08:00
|
|
|
{
|
|
|
|
"verbose", 0, 0,
|
|
|
|
G_OPTION_ARG_NONE, &be_verbose,
|
|
|
|
N_("Be more verbose"), NULL
|
|
|
|
},
|
2007-01-19 22:50:13 +08:00
|
|
|
{
|
|
|
|
"new-instance", 'n', 0,
|
|
|
|
G_OPTION_ARG_NONE, &new_instance,
|
|
|
|
N_("Start a new GIMP instance"), NULL
|
|
|
|
},
|
2007-04-17 23:54:01 +08:00
|
|
|
{
|
|
|
|
"as-new", 'a', 0,
|
|
|
|
G_OPTION_ARG_NONE, &as_new,
|
|
|
|
N_("Open images as new"), NULL
|
|
|
|
},
|
2005-02-03 23:21:20 +08:00
|
|
|
{
|
|
|
|
"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,
|
2010-08-18 00:24:53 +08:00
|
|
|
N_("Do not show a splash screen"), NULL
|
2005-02-03 23:21:20 +08:00
|
|
|
},
|
|
|
|
{
|
|
|
|
"no-shm", 0, G_OPTION_FLAG_REVERSE,
|
|
|
|
G_OPTION_ARG_NONE, &use_shm,
|
2017-03-22 00:45:50 +08:00
|
|
|
N_("Do not use shared memory between GIMP and plug-ins"), NULL
|
2005-02-03 23:21:20 +08:00
|
|
|
},
|
|
|
|
{
|
|
|
|
"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>"
|
|
|
|
},
|
|
|
|
{
|
2007-10-18 01:25:07 +08:00
|
|
|
"gimprc", 'g', 0,
|
2005-02-03 23:21:20 +08:00
|
|
|
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
|
|
|
},
|
|
|
|
{
|
2007-10-18 02:43:23 +08:00
|
|
|
"console-messages", 'c', 0,
|
2005-02-03 23:21:20 +08:00
|
|
|
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
|
|
|
},
|
|
|
|
{
|
2011-03-09 22:35:52 +08:00
|
|
|
"debug-handlers", 0, 0,
|
2005-02-03 23:21:20 +08:00
|
|
|
G_OPTION_ARG_NONE, &use_debug_handler,
|
|
|
|
N_("Enable non-fatal debugging signal handlers"), NULL
|
|
|
|
},
|
|
|
|
{
|
2005-09-26 07:04:25 +08:00
|
|
|
"g-fatal-warnings", 0, G_OPTION_FLAG_NO_ARG,
|
2005-02-09 06:57:24 +08:00
|
|
|
G_OPTION_ARG_CALLBACK, gimp_option_fatal_warnings,
|
|
|
|
N_("Make all warnings fatal"), NULL
|
2005-02-03 23:21:20 +08:00
|
|
|
},
|
|
|
|
{
|
2005-09-26 07:04:25 +08:00
|
|
|
"dump-gimprc", 0, G_OPTION_FLAG_NO_ARG,
|
2005-02-03 23:21:20 +08:00
|
|
|
G_OPTION_ARG_CALLBACK, gimp_option_dump_gimprc,
|
|
|
|
N_("Output a gimprc file with default settings"), NULL
|
|
|
|
},
|
|
|
|
{
|
2005-09-26 07:04:25 +08:00
|
|
|
"dump-gimprc-system", 0, G_OPTION_FLAG_NO_ARG | G_OPTION_FLAG_HIDDEN,
|
2005-02-03 23:21:20 +08:00
|
|
|
G_OPTION_ARG_CALLBACK, gimp_option_dump_gimprc,
|
|
|
|
NULL, NULL
|
|
|
|
},
|
|
|
|
{
|
2005-09-26 07:04:25 +08:00
|
|
|
"dump-gimprc-manpage", 0, G_OPTION_FLAG_NO_ARG | G_OPTION_FLAG_HIDDEN,
|
2005-02-03 23:21:20 +08:00
|
|
|
G_OPTION_ARG_CALLBACK, gimp_option_dump_gimprc,
|
|
|
|
NULL, NULL
|
|
|
|
},
|
2011-05-05 06:33:19 +08:00
|
|
|
{
|
|
|
|
"dump-pdb-procedures-deprecated", 0,
|
|
|
|
G_OPTION_FLAG_NO_ARG | G_OPTION_FLAG_HIDDEN,
|
|
|
|
G_OPTION_ARG_CALLBACK, gimp_option_dump_pdb_procedures_deprecated,
|
2011-05-06 13:29:01 +08:00
|
|
|
N_("Output a sorted list of deprecated procedures in the PDB"), NULL
|
2011-05-05 06:33:19 +08:00
|
|
|
},
|
2014-09-14 07:08:25 +08:00
|
|
|
{
|
2018-04-21 21:48:22 +08:00
|
|
|
"show-playground", 0, 0,
|
2014-09-14 07:08:25 +08:00
|
|
|
G_OPTION_ARG_NONE, &show_playground,
|
|
|
|
N_("Show a preferences page with experimental features"), NULL
|
|
|
|
},
|
2018-03-29 17:20:20 +08:00
|
|
|
{
|
|
|
|
"show-debug-menu", 0, G_OPTION_FLAG_HIDDEN,
|
|
|
|
G_OPTION_ARG_NONE, &show_debug_menu,
|
|
|
|
N_("Show an image submenu with debug actions"), NULL
|
|
|
|
},
|
2005-02-03 23:21:20 +08:00
|
|
|
{
|
|
|
|
G_OPTION_REMAINING, 0, 0,
|
|
|
|
G_OPTION_ARG_FILENAME_ARRAY, &filenames,
|
|
|
|
NULL, NULL
|
|
|
|
},
|
|
|
|
{ NULL }
|
|
|
|
};
|
|
|
|
|
2019-11-03 22:07:46 +08:00
|
|
|
#if defined(ENABLE_RELOCATABLE_RESOURCES) && defined(__APPLE__)
|
|
|
|
static void
|
|
|
|
gimp_macos_setenv (const char * progname)
|
|
|
|
{
|
|
|
|
/* helper to set environment variables for GIMP to be relocatable.
|
|
|
|
* Due to the latest changes it is not recommended to set it in the shell
|
|
|
|
* wrapper anymore.
|
|
|
|
*/
|
2021-03-23 05:28:05 +08:00
|
|
|
gchar *resolved_path;
|
2019-11-03 22:07:46 +08:00
|
|
|
/* on some OSX installations open file limit is 256 and GIMP needs more */
|
2021-03-23 05:28:05 +08:00
|
|
|
struct rlimit limit;
|
|
|
|
|
2019-11-03 22:07:46 +08:00
|
|
|
limit.rlim_cur = 10000;
|
|
|
|
limit.rlim_max = 10000;
|
|
|
|
setrlimit (RLIMIT_NOFILE, &limit);
|
2021-03-23 05:28:05 +08:00
|
|
|
resolved_path = g_canonicalize_filename (progname, NULL);
|
|
|
|
if (resolved_path && ! g_getenv ("GIMP_NO_WRAPPER"))
|
2019-11-03 22:07:46 +08:00
|
|
|
{
|
|
|
|
/* set path to the app folder to make sure that our python is called
|
|
|
|
* instead of system one
|
|
|
|
*/
|
|
|
|
static gboolean show_playground = TRUE;
|
|
|
|
|
|
|
|
gchar *path;
|
2021-03-23 05:28:05 +08:00
|
|
|
gchar *tmp;
|
2019-11-03 22:07:46 +08:00
|
|
|
gchar *app_dir;
|
2021-03-23 05:28:05 +08:00
|
|
|
gchar *res_dir;
|
2019-11-03 22:07:46 +08:00
|
|
|
size_t path_len;
|
|
|
|
struct stat sb;
|
|
|
|
|
|
|
|
app_dir = g_path_get_dirname (resolved_path);
|
2021-03-23 05:28:05 +08:00
|
|
|
tmp = g_strdup_printf ("%s/../Resources", app_dir);
|
|
|
|
res_dir = g_canonicalize_filename (tmp, NULL);
|
|
|
|
g_free (tmp);
|
|
|
|
if (res_dir && !stat (res_dir, &sb) && S_ISDIR (sb.st_mode))
|
|
|
|
{
|
|
|
|
g_print ("GIMP is started as MacOS application\n");
|
|
|
|
}
|
2019-11-03 22:07:46 +08:00
|
|
|
else
|
2021-03-23 05:28:05 +08:00
|
|
|
{
|
2021-12-22 09:33:04 +08:00
|
|
|
tmp = g_strdup_printf ("%s/../share", app_dir);
|
|
|
|
res_dir = g_canonicalize_filename (tmp, NULL);
|
2021-12-22 20:59:06 +08:00
|
|
|
g_free (tmp);
|
2021-12-22 09:33:04 +08:00
|
|
|
if (res_dir && !stat (res_dir, &sb) && S_ISDIR (sb.st_mode))
|
|
|
|
{
|
|
|
|
g_free (res_dir);
|
|
|
|
|
|
|
|
g_print ("GIMP is started in the build directory\n");
|
|
|
|
|
|
|
|
tmp = g_strdup_printf ("%s/..", app_dir); /* running in build dir */
|
|
|
|
res_dir = g_canonicalize_filename (tmp, NULL);
|
2021-12-22 20:59:06 +08:00
|
|
|
g_free (tmp);
|
2021-12-22 09:33:04 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
g_free (res_dir);
|
|
|
|
return;
|
|
|
|
}
|
2021-03-23 05:28:05 +08:00
|
|
|
}
|
2019-11-03 22:07:46 +08:00
|
|
|
|
|
|
|
path_len = strlen (g_getenv ("PATH") ? g_getenv ("PATH") : "") + strlen (app_dir) + 2;
|
|
|
|
path = g_try_malloc (path_len);
|
|
|
|
if (path == NULL)
|
|
|
|
{
|
|
|
|
g_warning ("Failed to allocate memory");
|
|
|
|
app_exit (EXIT_FAILURE);
|
|
|
|
}
|
|
|
|
if (g_getenv ("PATH"))
|
|
|
|
g_snprintf (path, path_len, "%s:%s", app_dir, g_getenv ("PATH"));
|
|
|
|
else
|
|
|
|
g_snprintf (path, path_len, "%s", app_dir);
|
|
|
|
g_free (app_dir);
|
|
|
|
g_setenv ("PATH", path, TRUE);
|
|
|
|
g_free (path);
|
2021-03-23 05:28:05 +08:00
|
|
|
tmp = g_strdup_printf ("%s/lib/gtk-3.0/3.0.0", res_dir);
|
2019-11-03 22:07:46 +08:00
|
|
|
g_setenv ("GTK_PATH", tmp, TRUE);
|
2021-03-23 05:28:05 +08:00
|
|
|
g_free (tmp);
|
|
|
|
tmp = g_strdup_printf ("%s/lib/gegl-0.4", res_dir);
|
2019-11-03 22:07:46 +08:00
|
|
|
g_setenv ("GEGL_PATH", tmp, TRUE);
|
2021-03-23 05:28:05 +08:00
|
|
|
g_free (tmp);
|
|
|
|
tmp = g_strdup_printf ("%s/lib/babl-0.1", res_dir);
|
2019-11-03 22:07:46 +08:00
|
|
|
g_setenv ("BABL_PATH", tmp, TRUE);
|
2021-03-23 05:28:05 +08:00
|
|
|
g_free (tmp);
|
|
|
|
tmp = g_strdup_printf ("%s/lib/gdk-pixbuf-2.0/2.10.0/loaders.cache", res_dir);
|
2019-11-03 22:07:46 +08:00
|
|
|
g_setenv ("GDK_PIXBUF_MODULE_FILE", tmp, TRUE);
|
2021-03-23 05:28:05 +08:00
|
|
|
g_free (tmp);
|
|
|
|
tmp = g_strdup_printf ("%s/etc/fonts", res_dir);
|
2019-11-03 22:07:46 +08:00
|
|
|
g_setenv ("FONTCONFIG_PATH", tmp, TRUE);
|
2021-03-23 05:28:05 +08:00
|
|
|
g_free (tmp);
|
|
|
|
tmp = g_strdup_printf ("%s", res_dir);
|
2019-11-03 22:07:46 +08:00
|
|
|
g_setenv ("PYTHONHOME", tmp, TRUE);
|
2021-03-23 05:28:05 +08:00
|
|
|
g_free (tmp);
|
2021-11-30 06:08:23 +08:00
|
|
|
tmp = g_strdup_printf ("%s/lib/python3.9", res_dir);
|
2019-11-03 22:07:46 +08:00
|
|
|
g_setenv ("PYTHONPATH", tmp, TRUE);
|
2021-03-23 05:28:05 +08:00
|
|
|
g_free (tmp);
|
|
|
|
tmp = g_strdup_printf ("%s/lib/gio/modules", res_dir);
|
2019-11-03 22:07:46 +08:00
|
|
|
g_setenv ("GIO_MODULE_DIR", tmp, TRUE);
|
2021-03-23 05:28:05 +08:00
|
|
|
g_free (tmp);
|
|
|
|
tmp = g_strdup_printf ("%s/share/libwmf/fonts", res_dir);
|
2019-11-03 22:07:46 +08:00
|
|
|
g_setenv ("WMF_FONTDIR", tmp, TRUE);
|
2021-03-23 05:28:05 +08:00
|
|
|
g_free (tmp);
|
2022-01-24 10:08:11 +08:00
|
|
|
if (g_getenv ("DYLD_LIBRARY_PATH"))
|
|
|
|
tmp = g_strdup_printf ("%s/lib:%s", res_dir, g_getenv ("DYLD_LIBRARY_PATH"));
|
|
|
|
else
|
|
|
|
tmp = g_strdup_printf ("%s/lib", res_dir);
|
|
|
|
g_setenv ("DYLD_LIBRARY_PATH", tmp, TRUE);
|
|
|
|
g_free (tmp);
|
2021-12-02 07:12:44 +08:00
|
|
|
if (g_getenv ("XDG_DATA_DIRS"))
|
|
|
|
tmp = g_strdup_printf ("%s/share:%s", res_dir, g_getenv ("XDG_DATA_DIRS"));
|
|
|
|
else
|
|
|
|
tmp = g_strdup_printf ("%s/share", res_dir);
|
|
|
|
g_setenv ("XDG_DATA_DIRS", tmp, TRUE);
|
|
|
|
g_free (tmp);
|
2021-12-03 18:14:35 +08:00
|
|
|
tmp = g_strdup_printf ("%s/lib/girepository-1.0", res_dir);
|
|
|
|
g_setenv ("GI_TYPELIB_PATH", tmp, TRUE);
|
|
|
|
g_free (tmp);
|
2021-03-23 05:28:05 +08:00
|
|
|
if (g_getenv ("HOME") != NULL)
|
2019-11-03 22:07:46 +08:00
|
|
|
{
|
2021-03-23 05:28:05 +08:00
|
|
|
tmp = g_strdup_printf ("%s/Library/Application Support/GIMP/3.00/cache",
|
|
|
|
g_getenv ("HOME"));
|
2019-11-03 22:07:46 +08:00
|
|
|
g_setenv ("XDG_CACHE_HOME", tmp, TRUE);
|
2021-03-23 05:28:05 +08:00
|
|
|
g_free (tmp);
|
2019-11-03 22:07:46 +08:00
|
|
|
}
|
2021-03-23 05:28:05 +08:00
|
|
|
g_free (res_dir);
|
2019-11-03 22:07:46 +08:00
|
|
|
}
|
2021-03-23 05:28:05 +08:00
|
|
|
g_free (resolved_path);
|
2019-11-03 22:07:46 +08:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2021-08-14 18:29:17 +08:00
|
|
|
/* gimp_early_configuration () is executed as soon as we can read
|
|
|
|
* the "gimprc" files, but before any library initialization takes
|
|
|
|
* place
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
gimp_early_configuration (void)
|
|
|
|
{
|
|
|
|
GFile *system_gimprc_file = NULL;
|
|
|
|
GFile *user_gimprc_file = NULL;
|
|
|
|
GimpEarlyRc *earlyrc;
|
|
|
|
gchar *language;
|
|
|
|
|
|
|
|
if (system_gimprc)
|
|
|
|
system_gimprc_file = g_file_new_for_commandline_arg (system_gimprc);
|
|
|
|
|
|
|
|
if (user_gimprc)
|
|
|
|
user_gimprc_file = g_file_new_for_commandline_arg (user_gimprc);
|
|
|
|
|
|
|
|
/* GimpEarlyRc is reponsible for reading "gimprc" files for the
|
|
|
|
* sole purpose of getting some configuration data that is needed
|
|
|
|
* in the early initialization phase
|
|
|
|
*/
|
|
|
|
earlyrc = gimp_early_rc_new (system_gimprc_file,
|
|
|
|
user_gimprc_file,
|
|
|
|
be_verbose);
|
|
|
|
|
|
|
|
/* Language needs to be determined first, before any GimpContext is
|
|
|
|
* instantiated (which happens when the Gimp object is created)
|
|
|
|
* because its properties need to be properly localized in the
|
|
|
|
* settings language (if different from system language). Otherwise we
|
|
|
|
* end up with pieces of GUI always using the system language (cf. bug
|
|
|
|
* 787457)
|
|
|
|
*/
|
|
|
|
language = gimp_early_rc_get_language (earlyrc);
|
|
|
|
|
|
|
|
/* change the locale if a language if specified */
|
|
|
|
language_init (language);
|
|
|
|
if (language)
|
|
|
|
g_free (language);
|
|
|
|
|
|
|
|
#if defined (G_OS_WIN32) && !defined (GIMP_CONSOLE_COMPILATION)
|
|
|
|
|
|
|
|
#if GTK_MAJOR_VERSION > 3
|
|
|
|
#warning For GTK4 and above use the proper backend-specific API instead of the GDK_WIN32_TABLET_INPUT_API environment variable
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* Set a GdkWin32-specific environment variable to specify
|
|
|
|
* the desired pen / touch input API to use on Windows
|
|
|
|
*/
|
|
|
|
if (gtk_get_major_version () == 3 &&
|
|
|
|
(gtk_get_minor_version () > 24 ||
|
|
|
|
(gtk_get_minor_version () == 24 &&
|
|
|
|
gtk_get_micro_version () >= 30)))
|
|
|
|
{
|
|
|
|
GimpWin32PointerInputAPI api = gimp_early_rc_get_win32_pointer_input_api (earlyrc);
|
|
|
|
|
|
|
|
switch (api)
|
|
|
|
{
|
|
|
|
case GIMP_WIN32_POINTER_INPUT_API_WINTAB:
|
|
|
|
g_setenv ("GDK_WIN32_TABLET_INPUT_API", "wintab", TRUE);
|
|
|
|
break;
|
|
|
|
case GIMP_WIN32_POINTER_INPUT_API_WINDOWS_INK:
|
|
|
|
g_setenv ("GDK_WIN32_TABLET_INPUT_API", "winpointer", TRUE);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
g_object_unref (earlyrc);
|
|
|
|
|
2021-12-17 16:49:05 +08:00
|
|
|
g_clear_object (&system_gimprc_file);
|
|
|
|
g_clear_object (&user_gimprc_file);
|
2021-08-14 18:29:17 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
gimp_options_group_parse_hook (GOptionContext *context,
|
|
|
|
GOptionGroup *group,
|
|
|
|
gpointer data,
|
|
|
|
GError **error)
|
|
|
|
{
|
|
|
|
/* early initialization from data stored in "gimprc" files */
|
|
|
|
gimp_early_configuration ();
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
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;
|
2014-07-28 21:03:06 +08:00
|
|
|
GFile *system_gimprc_file = NULL;
|
|
|
|
GFile *user_gimprc_file = NULL;
|
2021-08-14 18:29:17 +08:00
|
|
|
GOptionGroup *gimp_group = NULL;
|
2018-01-27 04:20:52 +08:00
|
|
|
gchar *backtrace_file = NULL;
|
2005-02-03 23:58:00 +08:00
|
|
|
gint i;
|
2002-02-19 01:42:17 +08:00
|
|
|
|
2018-08-15 20:24:15 +08:00
|
|
|
#ifdef ENABLE_WIN32_DEBUG_CONSOLE
|
|
|
|
gimp_open_console_window ();
|
|
|
|
#endif
|
2019-11-03 22:07:46 +08:00
|
|
|
#if defined(ENABLE_RELOCATABLE_RESOURCES) && defined(__APPLE__)
|
|
|
|
/* remove MacOS session identifier from the command line args */
|
|
|
|
gint newargc = 0;
|
|
|
|
for (gint i = 0; i < argc; i++)
|
|
|
|
{
|
|
|
|
if (!g_str_has_prefix (argv[i], "-psn_"))
|
|
|
|
{
|
|
|
|
argv[newargc] = argv[i];
|
|
|
|
newargc++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (argc > newargc)
|
|
|
|
{
|
|
|
|
argv[newargc] = NULL; /* glib expects NULL terminated array */
|
|
|
|
argc = newargc;
|
|
|
|
}
|
|
|
|
|
|
|
|
gimp_macos_setenv (argv[0]);
|
|
|
|
#endif
|
2018-08-15 20:24:15 +08:00
|
|
|
|
2008-08-07 23:45:33 +08:00
|
|
|
#if defined (__GNUC__) && defined (_WIN64)
|
|
|
|
/* mingw-w64, at least the unstable build from late July 2008,
|
|
|
|
* starts subsystem:windows programs in main(), but passes them
|
|
|
|
* bogus argc and argv. __argc and __argv are OK, though, so just
|
|
|
|
* use them.
|
|
|
|
*/
|
|
|
|
argc = __argc;
|
|
|
|
argv = __argv;
|
|
|
|
#endif
|
|
|
|
|
2019-05-19 22:46:52 +08:00
|
|
|
/* Initialize GimpBacktrace early on. In particular, we want the
|
|
|
|
* Windows backend to catch the SET_THREAD_NAME exceptions of newly
|
|
|
|
* created threads.
|
|
|
|
*/
|
|
|
|
gimp_backtrace_init ();
|
|
|
|
|
2018-01-27 23:43:43 +08:00
|
|
|
/* Start signal handlers early. */
|
|
|
|
gimp_init_signal_handlers (&backtrace_file);
|
|
|
|
|
2010-09-02 23:38:06 +08:00
|
|
|
#ifdef G_OS_WIN32
|
|
|
|
/* Reduce risks */
|
|
|
|
{
|
|
|
|
typedef BOOL (WINAPI *t_SetDllDirectoryA) (LPCSTR lpPathName);
|
|
|
|
t_SetDllDirectoryA p_SetDllDirectoryA;
|
|
|
|
|
2016-05-30 00:24:06 +08:00
|
|
|
p_SetDllDirectoryA =
|
|
|
|
(t_SetDllDirectoryA) GetProcAddress (GetModuleHandle ("kernel32.dll"),
|
|
|
|
"SetDllDirectoryA");
|
2010-09-02 23:38:06 +08:00
|
|
|
if (p_SetDllDirectoryA)
|
|
|
|
(*p_SetDllDirectoryA) ("");
|
|
|
|
}
|
2015-04-13 02:47:06 +08:00
|
|
|
|
|
|
|
/* On Windows, set DLL search path to $INSTALLDIR/bin so that .exe
|
|
|
|
plug-ins in the plug-ins directory can find libgimp and file
|
|
|
|
library DLLs without needing to set external PATH. */
|
|
|
|
{
|
|
|
|
const gchar *install_dir;
|
|
|
|
gchar *bin_dir;
|
|
|
|
LPWSTR w_bin_dir;
|
|
|
|
int n;
|
|
|
|
|
|
|
|
w_bin_dir = NULL;
|
|
|
|
install_dir = gimp_installation_directory ();
|
|
|
|
bin_dir = g_build_filename (install_dir, "bin", NULL);
|
|
|
|
|
|
|
|
n = MultiByteToWideChar (CP_UTF8, MB_ERR_INVALID_CHARS,
|
|
|
|
bin_dir, -1, NULL, 0);
|
|
|
|
if (n == 0)
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
w_bin_dir = g_malloc_n (n + 1, sizeof (wchar_t));
|
|
|
|
n = MultiByteToWideChar (CP_UTF8, MB_ERR_INVALID_CHARS,
|
|
|
|
bin_dir, -1,
|
|
|
|
w_bin_dir, (n + 1) * sizeof (wchar_t));
|
|
|
|
if (n == 0)
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
SetDllDirectoryW (w_bin_dir);
|
|
|
|
|
|
|
|
out:
|
|
|
|
if (w_bin_dir)
|
|
|
|
g_free (w_bin_dir);
|
|
|
|
g_free (bin_dir);
|
|
|
|
}
|
|
|
|
|
2010-09-02 23:38:06 +08:00
|
|
|
#ifndef _WIN64
|
|
|
|
{
|
|
|
|
typedef BOOL (WINAPI *t_SetProcessDEPPolicy) (DWORD dwFlags);
|
|
|
|
t_SetProcessDEPPolicy p_SetProcessDEPPolicy;
|
|
|
|
|
2016-05-30 00:24:06 +08:00
|
|
|
p_SetProcessDEPPolicy =
|
|
|
|
(t_SetProcessDEPPolicy) GetProcAddress (GetModuleHandle ("kernel32.dll"),
|
|
|
|
"SetProcessDEPPolicy");
|
2010-09-02 23:38:06 +08:00
|
|
|
if (p_SetProcessDEPPolicy)
|
|
|
|
(*p_SetProcessDEPPolicy) (PROCESS_DEP_ENABLE|PROCESS_DEP_DISABLE_ATL_THUNK_EMULATION);
|
|
|
|
}
|
|
|
|
#endif
|
2015-08-11 10:27:45 +08:00
|
|
|
|
|
|
|
/* Group all our windows together on the taskbar */
|
|
|
|
{
|
|
|
|
typedef HRESULT (WINAPI *t_SetCurrentProcessExplicitAppUserModelID) (PCWSTR lpPathName);
|
|
|
|
t_SetCurrentProcessExplicitAppUserModelID p_SetCurrentProcessExplicitAppUserModelID;
|
|
|
|
|
2016-05-30 00:24:06 +08:00
|
|
|
p_SetCurrentProcessExplicitAppUserModelID =
|
|
|
|
(t_SetCurrentProcessExplicitAppUserModelID) GetProcAddress (GetModuleHandle ("shell32.dll"),
|
|
|
|
"SetCurrentProcessExplicitAppUserModelID");
|
2015-08-11 10:27:45 +08:00
|
|
|
if (p_SetCurrentProcessExplicitAppUserModelID)
|
|
|
|
(*p_SetCurrentProcessExplicitAppUserModelID) (L"gimp.GimpApplication");
|
|
|
|
}
|
2010-09-02 23:38:06 +08:00
|
|
|
#endif
|
|
|
|
|
2005-02-03 23:21:20 +08:00
|
|
|
gimp_init_malloc ();
|
2002-02-19 01:42:17 +08:00
|
|
|
|
2005-11-06 09:06:41 +08:00
|
|
|
gimp_env_init (FALSE);
|
|
|
|
|
2007-11-15 18:57:53 +08:00
|
|
|
gimp_log_init ();
|
|
|
|
|
2005-02-03 23:21:20 +08:00
|
|
|
gimp_init_i18n ();
|
1999-09-04 09:43:50 +08:00
|
|
|
|
2005-12-29 04:45:52 +08:00
|
|
|
g_set_application_name (GIMP_NAME);
|
2005-02-03 07:04:24 +08:00
|
|
|
|
2014-03-09 05:38:27 +08:00
|
|
|
#ifdef G_OS_WIN32
|
|
|
|
argv = g_win32_get_command_line ();
|
|
|
|
#else
|
|
|
|
argv = g_strdupv (argv);
|
|
|
|
#endif
|
|
|
|
|
2005-02-09 06:57:24 +08:00
|
|
|
basename = g_path_get_basename (argv[0]);
|
|
|
|
g_set_prgname (basename);
|
|
|
|
g_free (basename);
|
|
|
|
|
2008-02-26 22:02:44 +08:00
|
|
|
/* Check argv[] for "--verbose" first */
|
|
|
|
for (i = 1; i < argc; i++)
|
|
|
|
{
|
|
|
|
const gchar *arg = argv[i];
|
|
|
|
|
|
|
|
if (arg[0] != '-')
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if ((strcmp (arg, "--verbose") == 0) || (strcmp (arg, "-v") == 0))
|
|
|
|
{
|
|
|
|
be_verbose = TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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))
|
2006-04-12 20:49:29 +08:00
|
|
|
{
|
|
|
|
no_interface = TRUE;
|
|
|
|
}
|
2005-02-03 23:58:00 +08:00
|
|
|
else if ((strcmp (arg, "--version") == 0) || (strcmp (arg, "-v") == 0))
|
2006-04-12 20:49:29 +08:00
|
|
|
{
|
|
|
|
gimp_show_version_and_exit ();
|
|
|
|
}
|
Make the handling of console output make more sense Win32. Should mostly
2007-01-26 Tor Lillqvist <tml@novell.com>
Make the handling of console output make more sense Win32. Should
mostly fix #400927.
* app/app_procs.c (app_exit): Drop the Win32 "This console window
will close in ten seconds" message from here.
(app_run): Drop the call to FreeConsole() from here. GIMP is built
as a GUI executable on Windows, and in case we do open a fresh
console window in main() (see below), we shouldn't then
immediately close it here.
* app/errors.c (errors_init): Drop printing the "You can mimize
this window, but don't close it" message on Win32 from here.
* app/main.c (gimp_open_console_window): New Win32-only
function. If either stdout or stderr are unconnected, open a new
console window and connect stdout and/or stderr to it as
needed. Set the console title to "GIMP output. You can minimize
this window, but don't close it." Register an atexit function that
waits for the user to close the console window.
(wait_console_window): New Win32-only function. Registered as an
atexit function when GIMP has opened a new console window. Prompts
the user to type any character to close the window.
(main, gimp_show_version): Always call gimp_open_console_window()
in the unstable version. As the "This is a development version of
GIMP. Debug messages may appear here" message says, one point of
the unstable version is that debug messages should be visible, so
I think it makes sense to always see them in an unstable
version. In stable versions, call gimp_open_console_window() only
if options that cause output that the user wants to see were
given, like --help and --version.
svn path=/trunk/; revision=21781
2007-01-27 04:47:36 +08:00
|
|
|
#if defined (G_OS_WIN32) && !defined (GIMP_CONSOLE_COMPILATION)
|
|
|
|
else if ((strcmp (arg, "--help") == 0) ||
|
|
|
|
(strcmp (arg, "-?") == 0) ||
|
|
|
|
(strncmp (arg, "--help-", 7) == 0))
|
|
|
|
{
|
|
|
|
gimp_open_console_window ();
|
|
|
|
}
|
|
|
|
#endif
|
2005-02-03 23:58:00 +08:00
|
|
|
}
|
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
|
|
|
|
2006-06-27 15:49:14 +08:00
|
|
|
context = g_option_context_new (_("[FILE|URI...]"));
|
2007-01-12 22:46:30 +08:00
|
|
|
g_option_context_set_summary (context, GIMP_NAME);
|
|
|
|
|
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
|
|
|
|
2021-08-14 18:29:17 +08:00
|
|
|
/* The GIMP option group is just an empty option group, created for the sole
|
|
|
|
* purpose of running a post-parse hook before any other of dependant libraries
|
|
|
|
* are run. This makes it possible to apply options from configuration data
|
|
|
|
* obtained from "gimprc" files, before other libraries have a chance to run
|
|
|
|
* some of their intialization code.
|
|
|
|
*/
|
|
|
|
gimp_group = g_option_group_new ("gimp", "", "", NULL, NULL);
|
|
|
|
g_option_group_set_parse_hooks (gimp_group, NULL, gimp_options_group_parse_hook);
|
|
|
|
g_option_context_add_group (context, gimp_group);
|
|
|
|
|
2005-02-09 06:57:24 +08:00
|
|
|
app_libs_init (context, no_interface);
|
2005-02-03 06:08:35 +08:00
|
|
|
|
2014-03-09 05:38:27 +08:00
|
|
|
if (! g_option_context_parse_strv (context, &argv, &error))
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2005-02-09 06:57:24 +08:00
|
|
|
if (error)
|
|
|
|
{
|
2007-05-11 15:12:05 +08:00
|
|
|
gimp_open_console_window ();
|
2005-02-09 06:57:24 +08:00
|
|
|
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
|
|
|
}
|
|
|
|
|
Make the handling of console output make more sense Win32. Should mostly
2007-01-26 Tor Lillqvist <tml@novell.com>
Make the handling of console output make more sense Win32. Should
mostly fix #400927.
* app/app_procs.c (app_exit): Drop the Win32 "This console window
will close in ten seconds" message from here.
(app_run): Drop the call to FreeConsole() from here. GIMP is built
as a GUI executable on Windows, and in case we do open a fresh
console window in main() (see below), we shouldn't then
immediately close it here.
* app/errors.c (errors_init): Drop printing the "You can mimize
this window, but don't close it" message on Win32 from here.
* app/main.c (gimp_open_console_window): New Win32-only
function. If either stdout or stderr are unconnected, open a new
console window and connect stdout and/or stderr to it as
needed. Set the console title to "GIMP output. You can minimize
this window, but don't close it." Register an atexit function that
waits for the user to close the console window.
(wait_console_window): New Win32-only function. Registered as an
atexit function when GIMP has opened a new console window. Prompts
the user to type any character to close the window.
(main, gimp_show_version): Always call gimp_open_console_window()
in the unstable version. As the "This is a development version of
GIMP. Debug messages may appear here" message says, one point of
the unstable version is that debug messages should be visible, so
I think it makes sense to always see them in an unstable
version. In stable versions, call gimp_open_console_window() only
if options that cause output that the user wants to see were
given, like --help and --version.
svn path=/trunk/; revision=21781
2007-01-27 04:47:36 +08:00
|
|
|
if (no_interface || be_verbose || console_messages || batch_commands != NULL)
|
|
|
|
gimp_open_console_window ();
|
|
|
|
|
2007-01-19 22:50:13 +08:00
|
|
|
if (no_interface)
|
|
|
|
new_instance = TRUE;
|
|
|
|
|
2008-07-11 17:16:23 +08:00
|
|
|
#ifndef GIMP_CONSOLE_COMPILATION
|
|
|
|
if (! new_instance && gimp_unique_open (filenames, as_new))
|
2007-01-19 22:50:13 +08:00
|
|
|
{
|
2008-07-11 17:16:23 +08:00
|
|
|
if (be_verbose)
|
2016-05-29 08:37:32 +08:00
|
|
|
g_print ("%s\n",
|
|
|
|
_("Another GIMP instance is already running."));
|
2008-07-11 17:16:23 +08:00
|
|
|
|
2015-07-11 20:56:13 +08:00
|
|
|
if (batch_commands)
|
|
|
|
gimp_unique_batch_run (batch_interpreter, batch_commands);
|
|
|
|
|
2008-07-11 17:16:23 +08:00
|
|
|
gdk_notify_startup_complete ();
|
|
|
|
|
|
|
|
return EXIT_SUCCESS;
|
2007-01-19 22:50:13 +08:00
|
|
|
}
|
2008-07-11 17:16:23 +08:00
|
|
|
#endif
|
2007-01-19 22:50:13 +08:00
|
|
|
|
2017-06-15 21:30:45 +08:00
|
|
|
abort_message = sanity_check_early ();
|
2005-02-09 06:57:24 +08:00
|
|
|
if (abort_message)
|
|
|
|
app_abort (no_interface, abort_message);
|
2005-02-03 23:21:20 +08:00
|
|
|
|
2014-07-28 21:03:06 +08:00
|
|
|
if (system_gimprc)
|
|
|
|
system_gimprc_file = g_file_new_for_commandline_arg (system_gimprc);
|
|
|
|
|
|
|
|
if (user_gimprc)
|
|
|
|
user_gimprc_file = g_file_new_for_commandline_arg (user_gimprc);
|
|
|
|
|
2005-02-03 23:21:20 +08:00
|
|
|
app_run (argv[0],
|
|
|
|
filenames,
|
2014-07-28 21:03:06 +08:00
|
|
|
system_gimprc_file,
|
|
|
|
user_gimprc_file,
|
2005-02-03 23:21:20 +08:00
|
|
|
session_name,
|
|
|
|
batch_interpreter,
|
|
|
|
batch_commands,
|
2007-04-17 23:54:01 +08:00
|
|
|
as_new,
|
2005-02-03 23:21:20 +08:00
|
|
|
no_interface,
|
|
|
|
no_data,
|
|
|
|
no_fonts,
|
|
|
|
no_splash,
|
|
|
|
be_verbose,
|
|
|
|
use_shm,
|
|
|
|
use_cpu_accel,
|
|
|
|
console_messages,
|
2006-09-10 00:36:15 +08:00
|
|
|
use_debug_handler,
|
2014-09-14 07:08:25 +08:00
|
|
|
show_playground,
|
2018-03-29 17:20:20 +08:00
|
|
|
show_debug_menu,
|
2005-02-03 23:21:20 +08:00
|
|
|
stack_trace_mode,
|
2018-01-27 04:20:52 +08:00
|
|
|
pdb_compat_mode,
|
|
|
|
backtrace_file);
|
|
|
|
|
2021-12-17 16:49:05 +08:00
|
|
|
g_free (backtrace_file);
|
2014-07-28 21:03:06 +08:00
|
|
|
|
2021-12-17 16:49:05 +08:00
|
|
|
g_clear_object (&system_gimprc_file);
|
|
|
|
g_clear_object (&user_gimprc_file);
|
2014-07-28 21:03:06 +08:00
|
|
|
|
2014-03-09 05:38:27 +08:00
|
|
|
g_strfreev (argv);
|
|
|
|
|
2005-02-03 23:21:20 +08:00
|
|
|
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
|
|
|
|
2008-08-07 23:45:33 +08:00
|
|
|
/* Provide WinMain in case we build GIMP as a subsystem:windows
|
|
|
|
* application. Well, we do. When built with mingw, though, user code
|
|
|
|
* execution still starts in main() in that case. So WinMain() gets
|
|
|
|
* used on MSVC builds only.
|
|
|
|
*/
|
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,
|
2006-04-12 20:49:29 +08:00
|
|
|
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
|
|
|
|
Make the handling of console output make more sense Win32. Should mostly
2007-01-26 Tor Lillqvist <tml@novell.com>
Make the handling of console output make more sense Win32. Should
mostly fix #400927.
* app/app_procs.c (app_exit): Drop the Win32 "This console window
will close in ten seconds" message from here.
(app_run): Drop the call to FreeConsole() from here. GIMP is built
as a GUI executable on Windows, and in case we do open a fresh
console window in main() (see below), we shouldn't then
immediately close it here.
* app/errors.c (errors_init): Drop printing the "You can mimize
this window, but don't close it" message on Win32 from here.
* app/main.c (gimp_open_console_window): New Win32-only
function. If either stdout or stderr are unconnected, open a new
console window and connect stdout and/or stderr to it as
needed. Set the console title to "GIMP output. You can minimize
this window, but don't close it." Register an atexit function that
waits for the user to close the console window.
(wait_console_window): New Win32-only function. Registered as an
atexit function when GIMP has opened a new console window. Prompts
the user to type any character to close the window.
(main, gimp_show_version): Always call gimp_open_console_window()
in the unstable version. As the "This is a development version of
GIMP. Debug messages may appear here" message says, one point of
the unstable version is that debug messages should be visible, so
I think it makes sense to always see them in an unstable
version. In stable versions, call gimp_open_console_window() only
if options that cause output that the user wants to see were
given, like --help and --version.
svn path=/trunk/; revision=21781
2007-01-27 04:47:36 +08:00
|
|
|
#ifndef GIMP_CONSOLE_COMPILATION
|
|
|
|
|
|
|
|
static void
|
|
|
|
wait_console_window (void)
|
|
|
|
{
|
|
|
|
FILE *console = fopen ("CONOUT$", "w");
|
|
|
|
|
2007-01-27 05:22:07 +08:00
|
|
|
SetConsoleTitleW (g_utf8_to_utf16 (_("GIMP output. Type any character to close this window."), -1, NULL, NULL, NULL));
|
Make the handling of console output make more sense Win32. Should mostly
2007-01-26 Tor Lillqvist <tml@novell.com>
Make the handling of console output make more sense Win32. Should
mostly fix #400927.
* app/app_procs.c (app_exit): Drop the Win32 "This console window
will close in ten seconds" message from here.
(app_run): Drop the call to FreeConsole() from here. GIMP is built
as a GUI executable on Windows, and in case we do open a fresh
console window in main() (see below), we shouldn't then
immediately close it here.
* app/errors.c (errors_init): Drop printing the "You can mimize
this window, but don't close it" message on Win32 from here.
* app/main.c (gimp_open_console_window): New Win32-only
function. If either stdout or stderr are unconnected, open a new
console window and connect stdout and/or stderr to it as
needed. Set the console title to "GIMP output. You can minimize
this window, but don't close it." Register an atexit function that
waits for the user to close the console window.
(wait_console_window): New Win32-only function. Registered as an
atexit function when GIMP has opened a new console window. Prompts
the user to type any character to close the window.
(main, gimp_show_version): Always call gimp_open_console_window()
in the unstable version. As the "This is a development version of
GIMP. Debug messages may appear here" message says, one point of
the unstable version is that debug messages should be visible, so
I think it makes sense to always see them in an unstable
version. In stable versions, call gimp_open_console_window() only
if options that cause output that the user wants to see were
given, like --help and --version.
svn path=/trunk/; revision=21781
2007-01-27 04:47:36 +08:00
|
|
|
fprintf (console, _("(Type any character to close this window)\n"));
|
|
|
|
fflush (console);
|
|
|
|
_getch ();
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_open_console_window (void)
|
|
|
|
{
|
|
|
|
if (((HANDLE) _get_osfhandle (fileno (stdout)) == INVALID_HANDLE_VALUE ||
|
|
|
|
(HANDLE) _get_osfhandle (fileno (stderr)) == INVALID_HANDLE_VALUE) && AllocConsole ())
|
|
|
|
{
|
|
|
|
if ((HANDLE) _get_osfhandle (fileno (stdout)) == INVALID_HANDLE_VALUE)
|
|
|
|
freopen ("CONOUT$", "w", stdout);
|
|
|
|
|
|
|
|
if ((HANDLE) _get_osfhandle (fileno (stderr)) == INVALID_HANDLE_VALUE)
|
|
|
|
freopen ("CONOUT$", "w", stderr);
|
|
|
|
|
2007-01-27 05:22:07 +08:00
|
|
|
SetConsoleTitleW (g_utf8_to_utf16 (_("GIMP output. You can minimize this window, but don't close it."), -1, NULL, NULL, NULL));
|
Make the handling of console output make more sense Win32. Should mostly
2007-01-26 Tor Lillqvist <tml@novell.com>
Make the handling of console output make more sense Win32. Should
mostly fix #400927.
* app/app_procs.c (app_exit): Drop the Win32 "This console window
will close in ten seconds" message from here.
(app_run): Drop the call to FreeConsole() from here. GIMP is built
as a GUI executable on Windows, and in case we do open a fresh
console window in main() (see below), we shouldn't then
immediately close it here.
* app/errors.c (errors_init): Drop printing the "You can mimize
this window, but don't close it" message on Win32 from here.
* app/main.c (gimp_open_console_window): New Win32-only
function. If either stdout or stderr are unconnected, open a new
console window and connect stdout and/or stderr to it as
needed. Set the console title to "GIMP output. You can minimize
this window, but don't close it." Register an atexit function that
waits for the user to close the console window.
(wait_console_window): New Win32-only function. Registered as an
atexit function when GIMP has opened a new console window. Prompts
the user to type any character to close the window.
(main, gimp_show_version): Always call gimp_open_console_window()
in the unstable version. As the "This is a development version of
GIMP. Debug messages may appear here" message says, one point of
the unstable version is that debug messages should be visible, so
I think it makes sense to always see them in an unstable
version. In stable versions, call gimp_open_console_window() only
if options that cause output that the user wants to see were
given, like --help and --version.
svn path=/trunk/; revision=21781
2007-01-27 04:47:36 +08:00
|
|
|
|
|
|
|
atexit (wait_console_window);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
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;
|
|
|
|
|
Make the handling of console output make more sense Win32. Should mostly
2007-01-26 Tor Lillqvist <tml@novell.com>
Make the handling of console output make more sense Win32. Should
mostly fix #400927.
* app/app_procs.c (app_exit): Drop the Win32 "This console window
will close in ten seconds" message from here.
(app_run): Drop the call to FreeConsole() from here. GIMP is built
as a GUI executable on Windows, and in case we do open a fresh
console window in main() (see below), we shouldn't then
immediately close it here.
* app/errors.c (errors_init): Drop printing the "You can mimize
this window, but don't close it" message on Win32 from here.
* app/main.c (gimp_open_console_window): New Win32-only
function. If either stdout or stderr are unconnected, open a new
console window and connect stdout and/or stderr to it as
needed. Set the console title to "GIMP output. You can minimize
this window, but don't close it." Register an atexit function that
waits for the user to close the console window.
(wait_console_window): New Win32-only function. Registered as an
atexit function when GIMP has opened a new console window. Prompts
the user to type any character to close the window.
(main, gimp_show_version): Always call gimp_open_console_window()
in the unstable version. As the "This is a development version of
GIMP. Debug messages may appear here" message says, one point of
the unstable version is that debug messages should be visible, so
I think it makes sense to always see them in an unstable
version. In stable versions, call gimp_open_console_window() only
if options that cause output that the user wants to see were
given, like --help and --version.
svn path=/trunk/; revision=21781
2007-01-27 04:47:36 +08:00
|
|
|
gimp_open_console_window ();
|
|
|
|
|
2005-02-03 07:04:24 +08:00
|
|
|
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;
|
|
|
|
|
2012-11-20 15:21:33 +08:00
|
|
|
babl_init ();
|
2016-09-13 05:51:29 +08:00
|
|
|
gimp = g_object_new (GIMP_TYPE_GIMP, NULL);
|
2016-09-13 18:55:17 +08:00
|
|
|
gimp_load_config (gimp, NULL, NULL);
|
2005-02-03 07:04:24 +08:00
|
|
|
|
2016-09-14 07:27:42 +08:00
|
|
|
success = gimp_config_dump (G_OBJECT (gimp), format);
|
2005-02-03 07:04:24 +08:00
|
|
|
|
|
|
|
g_object_unref (gimp);
|
|
|
|
|
|
|
|
app_exit (success ? EXIT_SUCCESS : EXIT_FAILURE);
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
2003-01-09 07:43:31 +08:00
|
|
|
}
|
|
|
|
|
2011-05-05 06:33:19 +08:00
|
|
|
static gboolean
|
|
|
|
gimp_option_dump_pdb_procedures_deprecated (const gchar *option_name,
|
|
|
|
const gchar *value,
|
|
|
|
gpointer data,
|
|
|
|
GError **error)
|
|
|
|
{
|
|
|
|
Gimp *gimp;
|
|
|
|
GList *deprecated_procs;
|
|
|
|
GList *iter;
|
|
|
|
|
2016-05-28 01:30:49 +08:00
|
|
|
babl_init ();
|
2011-05-05 06:33:19 +08:00
|
|
|
gimp = g_object_new (GIMP_TYPE_GIMP, NULL);
|
2016-09-13 18:55:17 +08:00
|
|
|
gimp_load_config (gimp, NULL, NULL);
|
2011-05-05 06:33:19 +08:00
|
|
|
|
2011-05-06 13:29:01 +08:00
|
|
|
/* Make sure to turn on compatibility mode so deprecated procedures
|
|
|
|
* are included
|
2011-05-05 06:33:19 +08:00
|
|
|
*/
|
|
|
|
gimp->pdb_compat_mode = GIMP_PDB_COMPAT_ON;
|
|
|
|
|
2011-05-06 13:29:01 +08:00
|
|
|
/* Initialize the list of procedures */
|
2011-05-05 06:33:19 +08:00
|
|
|
internal_procs_init (gimp->pdb);
|
|
|
|
|
2011-05-06 13:29:01 +08:00
|
|
|
/* Get deprecated procedures */
|
2011-05-05 06:33:19 +08:00
|
|
|
deprecated_procs = gimp_pdb_get_deprecated_procedures (gimp->pdb);
|
|
|
|
|
|
|
|
for (iter = deprecated_procs; iter; iter = g_list_next (iter))
|
|
|
|
{
|
|
|
|
GimpProcedure *procedure = GIMP_PROCEDURE (iter->data);
|
|
|
|
|
2019-08-18 07:55:47 +08:00
|
|
|
g_print ("%s\n", gimp_object_get_name (procedure));
|
2011-05-05 06:33:19 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
g_list_free (deprecated_procs);
|
|
|
|
|
|
|
|
g_object_unref (gimp);
|
|
|
|
|
|
|
|
app_exit (EXIT_SUCCESS);
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2005-12-30 02:39:03 +08:00
|
|
|
static void
|
|
|
|
gimp_show_version_and_exit (void)
|
|
|
|
{
|
2008-02-26 22:02:44 +08:00
|
|
|
gimp_open_console_window ();
|
|
|
|
gimp_version_show (be_verbose);
|
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
|
|
|
|
2005-12-30 02:39:03 +08:00
|
|
|
static void
|
|
|
|
gimp_show_license_and_exit (void)
|
|
|
|
{
|
2008-02-26 22:02:44 +08:00
|
|
|
gimp_open_console_window ();
|
|
|
|
gimp_version_show (be_verbose);
|
2005-12-30 02:39:03 +08:00
|
|
|
|
|
|
|
g_print ("\n");
|
|
|
|
g_print (GIMP_LICENSE);
|
|
|
|
g_print ("\n\n");
|
|
|
|
|
|
|
|
app_exit (EXIT_SUCCESS);
|
|
|
|
}
|
2003-01-09 07:43:31 +08:00
|
|
|
|
2005-02-09 06:57:24 +08:00
|
|
|
static void
|
|
|
|
gimp_init_malloc (void)
|
|
|
|
{
|
2005-12-30 02:39:03 +08:00
|
|
|
#ifdef GIMP_GLIB_MEM_PROFILER
|
2005-02-09 06:57:24 +08:00
|
|
|
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
|
|
|
*/
|
2012-06-21 03:44:09 +08:00
|
|
|
#if 0
|
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
|
2012-06-21 03:44:09 +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
|
|
|
{
|
2009-12-30 07:38:31 +08:00
|
|
|
/* We may change the locale later if the user specifies a language
|
|
|
|
* in the gimprc file. Here we are just initializing the locale
|
|
|
|
* according to the environment variables and set up the paths to
|
|
|
|
* the message catalogs.
|
|
|
|
*/
|
|
|
|
|
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
|
|
|
}
|