~ubuntu-branches/ubuntu/jaunty/gimp/jaunty-security

« back to all changes in this revision

Viewing changes to app/main.c

  • Committer: Bazaar Package Importer
  • Author(s): Daniel Holbach
  • Date: 2007-05-02 16:33:03 UTC
  • mfrom: (1.1.4 upstream)
  • Revision ID: james.westby@ubuntu.com-20070502163303-bvzhjzbpw8qglc4y
Tags: 2.3.16-1ubuntu1
* Resynchronized with Debian, remaining Ubuntu changes:
  - debian/rules: i18n magic.
* debian/control.in:
  - Maintainer: Ubuntu Core Developers <ubuntu-devel@lists.ubuntu.com>
* debian/patches/02_help-message.patch,
  debian/patches/03_gimp.desktop.in.in.patch,
  debian/patches/10_dont_show_wizard.patch: updated.
* debian/patches/04_composite-signedness.patch,
  debian/patches/05_add-letter-spacing.patch: dropped, used upstream.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* The GIMP -- an image manipulation program
 
1
/* GIMP - The GNU Image Manipulation Program
2
2
 * Copyright (C) 1995 Spencer Kimball and Peter Mattis
3
3
 *
4
4
 * This program is free software; you can redistribute it and/or modify
18
18
 
19
19
#include "config.h"
20
20
 
 
21
#define _GNU_SOURCE  /* for the sigaction stuff */
 
22
 
21
23
#include <stdio.h>
22
24
#include <stdlib.h>
 
25
#include <string.h>
23
26
#include <signal.h>
24
 
#include <string.h>
25
 
#include <sys/types.h>
26
 
 
27
 
#ifdef HAVE_SYS_WAIT_H
28
 
#include <sys/wait.h>
29
 
#endif
30
27
 
31
28
#ifdef HAVE_UNISTD_H
32
29
#include <unistd.h>
36
33
#include <malloc.h>
37
34
#endif
38
35
 
39
 
#ifndef  WAIT_ANY
40
 
#define  WAIT_ANY -1
41
 
#endif
42
 
 
43
36
#include <locale.h>
44
37
 
45
38
#include <glib-object.h>
46
39
 
 
40
#if HAVE_DBUS_GLIB
 
41
#include <dbus/dbus-glib.h>
 
42
#endif
 
43
 
 
44
#ifndef GIMP_CONSOLE_COMPILATION
 
45
#include <gdk/gdk.h>
 
46
#endif
 
47
 
47
48
#include "libgimpbase/gimpbase.h"
48
49
 
 
50
#include "core/core-types.h"
 
51
 
 
52
#include "base/tile.h"
 
53
 
49
54
#include "config/gimpconfig-dump.h"
50
55
 
51
 
#include "core/core-types.h"
52
56
#include "core/gimp.h"
53
57
 
54
 
#include "app_procs.h"
 
58
#include "widgets/gimpdbusservice.h"
 
59
 
 
60
#include "about.h"
 
61
#include "app.h"
55
62
#include "errors.h"
56
63
#include "sanity.h"
57
64
#include "units.h"
58
65
 
 
66
#ifdef G_OS_WIN32
 
67
#include <windows.h>
 
68
#include <conio.h>
 
69
#endif
 
70
 
59
71
#include "gimp-intl.h"
60
72
 
61
73
 
62
 
#ifdef G_OS_WIN32
63
 
#include <windows.h>
64
 
#else
65
 
static void  gimp_sigfatal_handler (gint         sig_num) G_GNUC_NORETURN;
66
 
static void  gimp_sigchld_handler  (gint         sig_num);
67
 
#endif
68
 
 
69
 
static void  gimp_show_version     (void);
70
 
static void  gimp_show_help        (const gchar *progname);
71
 
 
72
 
 
73
 
/*
74
 
 *  argv processing:
75
 
 *      Arguments are either switches, their associated
76
 
 *      values, or image files.  As switches and their
77
 
 *      associated values are processed, those slots in
78
 
 *      the argv[] array are NULLed. We do this because
79
 
 *      unparsed args are treated as images to load on
80
 
 *      startup.
81
 
 *
82
 
 *      The GTK switches are processed first (X switches are
83
 
 *      processed here, not by any X routines).  Then the
84
 
 *      general GIMP switches are processed.  Any args
85
 
 *      left are assumed to be image files the GIMP should
86
 
 *      display.
87
 
 *
88
 
 *      The exception is the batch switch.  When this is
89
 
 *      encountered, all remaining args are treated as batch
90
 
 *      commands.
91
 
 */
 
74
static gboolean  gimp_option_fatal_warnings   (const gchar  *option_name,
 
75
                                               const gchar  *value,
 
76
                                               gpointer      data,
 
77
                                               GError      **error);
 
78
static gboolean  gimp_option_stack_trace_mode (const gchar  *option_name,
 
79
                                               const gchar  *value,
 
80
                                               gpointer      data,
 
81
                                               GError      **error);
 
82
static gboolean  gimp_option_pdb_compat_mode  (const gchar  *option_name,
 
83
                                               const gchar  *value,
 
84
                                               gpointer      data,
 
85
                                               GError      **error);
 
86
static gboolean  gimp_option_dump_gimprc      (const gchar  *option_name,
 
87
                                               const gchar  *value,
 
88
                                               gpointer      data,
 
89
                                               GError      **error);
 
90
 
 
91
static void      gimp_show_version_and_exit   (void) G_GNUC_NORETURN;
 
92
static void      gimp_show_license_and_exit   (void) G_GNUC_NORETURN;
 
93
 
 
94
static void      gimp_init_i18n               (void);
 
95
static void      gimp_init_malloc             (void);
 
96
static void      gimp_init_signal_handlers    (void);
 
97
 
 
98
#ifndef G_OS_WIN32
 
99
static void      gimp_sigfatal_handler        (gint sig_num) G_GNUC_NORETURN;
 
100
#endif
 
101
 
 
102
#if defined (G_OS_WIN32) && !defined (GIMP_CONSOLE_COMPILATION)
 
103
static void      gimp_open_console_window     (void);
 
104
#else
 
105
#define gimp_open_console_window() /* as nothing */
 
106
#endif
 
107
 
 
108
static gboolean  gimp_dbus_open               (const gchar **filenames,
 
109
                                               gboolean      as_new,
 
110
                                               gboolean      be_verbose);
 
111
 
 
112
 
 
113
static const gchar        *system_gimprc     = NULL;
 
114
static const gchar        *user_gimprc       = NULL;
 
115
static const gchar        *session_name      = NULL;
 
116
static const gchar        *batch_interpreter = NULL;
 
117
static const gchar       **batch_commands    = NULL;
 
118
static const gchar       **filenames         = NULL;
 
119
static gboolean            as_new            = FALSE;
 
120
static gboolean            no_interface      = FALSE;
 
121
static gboolean            no_data           = FALSE;
 
122
static gboolean            no_fonts          = FALSE;
 
123
static gboolean            no_splash         = FALSE;
 
124
static gboolean            be_verbose        = FALSE;
 
125
static gboolean            new_instance      = FALSE;
 
126
#if defined (USE_SYSV_SHM) || defined (USE_POSIX_SHM) || defined (G_OS_WIN32)
 
127
static gboolean            use_shm           = TRUE;
 
128
#else
 
129
static gboolean            use_shm           = FALSE;
 
130
#endif
 
131
static gboolean            use_cpu_accel     = TRUE;
 
132
static gboolean            console_messages  = FALSE;
 
133
static gboolean            use_debug_handler = FALSE;
 
134
 
 
135
#ifdef GIMP_UNSTABLE
 
136
static GimpStackTraceMode  stack_trace_mode  = GIMP_STACK_TRACE_QUERY;
 
137
static GimpPDBCompatMode   pdb_compat_mode   = GIMP_PDB_COMPAT_WARN;
 
138
#else
 
139
static GimpStackTraceMode  stack_trace_mode  = GIMP_STACK_TRACE_NEVER;
 
140
static GimpPDBCompatMode   pdb_compat_mode   = GIMP_PDB_COMPAT_ON;
 
141
#endif
 
142
 
 
143
 
 
144
static const GOptionEntry main_entries[] =
 
145
{
 
146
  { "version", 'v', G_OPTION_FLAG_NO_ARG,
 
147
    G_OPTION_ARG_CALLBACK, (GOptionArgFunc) gimp_show_version_and_exit,
 
148
    N_("Show version information and exit"), NULL
 
149
  },
 
150
  {
 
151
    "license", 0, G_OPTION_FLAG_NO_ARG,
 
152
    G_OPTION_ARG_CALLBACK, (GOptionArgFunc) gimp_show_license_and_exit,
 
153
    N_("Show license information and exit"), NULL
 
154
  },
 
155
  {
 
156
    "verbose", 0, 0,
 
157
    G_OPTION_ARG_NONE, &be_verbose,
 
158
    N_("Be more verbose"), NULL
 
159
  },
 
160
  {
 
161
    "new-instance", 'n', 0,
 
162
    G_OPTION_ARG_NONE, &new_instance,
 
163
    N_("Start a new GIMP instance"), NULL
 
164
  },
 
165
  {
 
166
    "as-new", 'a', 0,
 
167
    G_OPTION_ARG_NONE, &as_new,
 
168
    N_("Open images as new"), NULL
 
169
  },
 
170
  {
 
171
    "no-interface", 'i', 0,
 
172
    G_OPTION_ARG_NONE, &no_interface,
 
173
    N_("Run without a user interface"), NULL
 
174
  },
 
175
  {
 
176
    "no-data", 'd', 0,
 
177
    G_OPTION_ARG_NONE, &no_data,
 
178
    N_("Do not load brushes, gradients, patterns, ..."), NULL
 
179
  },
 
180
  {
 
181
    "no-fonts", 'f', 0,
 
182
    G_OPTION_ARG_NONE, &no_fonts,
 
183
    N_("Do not load any fonts"), NULL
 
184
  },
 
185
  {
 
186
    "no-splash", 's', 0,
 
187
    G_OPTION_ARG_NONE, &no_splash,
 
188
    N_("Do not show a startup window"), NULL
 
189
  },
 
190
  {
 
191
    "no-shm", 0, G_OPTION_FLAG_REVERSE,
 
192
    G_OPTION_ARG_NONE, &use_shm,
 
193
    N_("Do not use shared memory between GIMP and plugins"), NULL
 
194
  },
 
195
  {
 
196
    "no-cpu-accel", 0, G_OPTION_FLAG_REVERSE,
 
197
    G_OPTION_ARG_NONE, &use_cpu_accel,
 
198
    N_("Do not use special CPU acceleration functions"), NULL
 
199
  },
 
200
  {
 
201
    "session", 0, 0,
 
202
    G_OPTION_ARG_FILENAME, &session_name,
 
203
    N_("Use an alternate sessionrc file"), "<name>"
 
204
  },
 
205
  {
 
206
    "gimprc", 0, 0,
 
207
    G_OPTION_ARG_FILENAME, &user_gimprc,
 
208
    N_("Use an alternate user gimprc file"), "<filename>"
 
209
  },
 
210
  {
 
211
    "system-gimprc", 0, 0,
 
212
    G_OPTION_ARG_FILENAME, &system_gimprc,
 
213
    N_("Use an alternate system gimprc file"), "<filename>"
 
214
  },
 
215
  {
 
216
    "batch", 'b', 0,
 
217
    G_OPTION_ARG_STRING_ARRAY, &batch_commands,
 
218
    N_("Batch command to run (can be used multiple times)"), "<command>"
 
219
  },
 
220
  {
 
221
    "batch-interpreter", 0, 0,
 
222
    G_OPTION_ARG_STRING, &batch_interpreter,
 
223
    N_("The procedure to process batch commands with"), "<proc>"
 
224
  },
 
225
  {
 
226
    "console-messages", 0, 0,
 
227
    G_OPTION_ARG_NONE, &console_messages,
 
228
    N_("Send messages to console instead of using a dialog"), NULL
 
229
  },
 
230
  {
 
231
    "pdb-compat-mode", 0, 0,
 
232
    G_OPTION_ARG_CALLBACK, gimp_option_pdb_compat_mode,
 
233
    /*  don't translate the mode names (off|on|warn)  */
 
234
    N_("PDB compatibility mode (off|on|warn)"), "<mode>"
 
235
  },
 
236
  {
 
237
    "stack-trace-mode", 0, 0,
 
238
    G_OPTION_ARG_CALLBACK, gimp_option_stack_trace_mode,
 
239
    /*  don't translate the mode names (never|query|always)  */
 
240
    N_("Debug in case of a crash (never|query|always)"), "<mode>"
 
241
  },
 
242
  {
 
243
    "debug-handlers", 0, G_OPTION_FLAG_NO_ARG,
 
244
    G_OPTION_ARG_NONE, &use_debug_handler,
 
245
    N_("Enable non-fatal debugging signal handlers"), NULL
 
246
  },
 
247
  {
 
248
    "g-fatal-warnings", 0, G_OPTION_FLAG_NO_ARG,
 
249
    G_OPTION_ARG_CALLBACK, gimp_option_fatal_warnings,
 
250
    N_("Make all warnings fatal"), NULL
 
251
  },
 
252
  {
 
253
    "dump-gimprc", 0, G_OPTION_FLAG_NO_ARG,
 
254
    G_OPTION_ARG_CALLBACK, gimp_option_dump_gimprc,
 
255
    N_("Output a gimprc file with default settings"), NULL
 
256
  },
 
257
  {
 
258
    "dump-gimprc-system", 0, G_OPTION_FLAG_NO_ARG | G_OPTION_FLAG_HIDDEN,
 
259
    G_OPTION_ARG_CALLBACK, gimp_option_dump_gimprc,
 
260
    NULL, NULL
 
261
  },
 
262
  {
 
263
    "dump-gimprc-manpage", 0, G_OPTION_FLAG_NO_ARG | G_OPTION_FLAG_HIDDEN,
 
264
    G_OPTION_ARG_CALLBACK, gimp_option_dump_gimprc,
 
265
    NULL, NULL
 
266
  },
 
267
  {
 
268
    G_OPTION_REMAINING, 0, 0,
 
269
    G_OPTION_ARG_FILENAME_ARRAY, &filenames,
 
270
    NULL, NULL
 
271
  },
 
272
  { NULL }
 
273
};
 
274
 
92
275
 
93
276
int
94
277
main (int    argc,
95
278
      char **argv)
96
279
{
97
 
  const gchar        *abort_message           = NULL;
98
 
  const gchar        *full_prog_name          = NULL;
99
 
  const gchar        *alternate_system_gimprc = NULL;
100
 
  const gchar        *alternate_gimprc        = NULL;
101
 
  const gchar        *session_name            = NULL;
102
 
  const gchar        *batch_interpreter       = NULL;
103
 
  const gchar       **batch_commands          = NULL;
104
 
  gboolean            show_help               = FALSE;
105
 
  gboolean            no_interface            = FALSE;
106
 
  gboolean            no_data                 = FALSE;
107
 
  gboolean            no_fonts                = FALSE;
108
 
  gboolean            no_splash               = FALSE;
109
 
  gboolean            be_verbose              = FALSE;
110
 
  gboolean            use_shm                 = FALSE;
111
 
  gboolean            use_cpu_accel           = TRUE;
112
 
  gboolean            console_messages        = FALSE;
113
 
  gboolean            use_debug_handler       = FALSE;
 
280
  GOptionContext *context;
 
281
  GError         *error = NULL;
 
282
  const gchar    *abort_message;
 
283
  gchar          *basename;
 
284
  gint            i;
 
285
 
 
286
#ifdef ENABLE_MP
 
287
  if (! g_thread_supported ())
 
288
    g_thread_init (NULL);
 
289
#endif
 
290
 
114
291
#ifdef GIMP_UNSTABLE
115
 
  GimpStackTraceMode  stack_trace_mode        = GIMP_STACK_TRACE_QUERY;
116
 
  GimpPDBCompatMode   pdb_compat_mode         = GIMP_PDB_COMPAT_WARN;
117
 
#else
118
 
  GimpStackTraceMode  stack_trace_mode        = GIMP_STACK_TRACE_NEVER;
119
 
  GimpPDBCompatMode   pdb_compat_mode         = GIMP_PDB_COMPAT_ON;
120
 
#endif
121
 
  gint                i, j;
122
 
 
123
 
#if 0
124
 
  g_mem_set_vtable (glib_mem_profiler_table);
125
 
  g_atexit (g_mem_profile);
126
 
#endif
127
 
 
128
 
  /* Initialize variables */
129
 
 
130
 
  full_prog_name = argv[0];
131
 
 
132
 
  /* Initialize i18n support */
133
 
 
134
 
  setlocale (LC_ALL, "");
135
 
 
136
 
  bindtextdomain (GETTEXT_PACKAGE"-libgimp", gimp_locale_directory ());
137
 
#ifdef HAVE_BIND_TEXTDOMAIN_CODESET
138
 
  bind_textdomain_codeset (GETTEXT_PACKAGE"-libgimp", "UTF-8");
139
 
#endif
140
 
 
141
 
  bindtextdomain (GETTEXT_PACKAGE, gimp_locale_directory ());
142
 
#ifdef HAVE_BIND_TEXTDOMAIN_CODESET
143
 
  bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
144
 
#endif
145
 
 
146
 
  textdomain (GETTEXT_PACKAGE);
147
 
 
148
 
  /* Check argv[] for "--no-interface" before trying to initialize gtk+.
149
 
   * We also check for "--help" or "--version" here since those shouldn't
150
 
   * require gui libs either.
151
 
   */
 
292
  gimp_open_console_window ();
 
293
#endif
 
294
 
 
295
  gimp_init_malloc ();
 
296
 
 
297
  gimp_env_init (FALSE);
 
298
 
 
299
  gimp_init_i18n ();
 
300
 
 
301
  g_set_application_name (GIMP_NAME);
 
302
 
 
303
  basename = g_path_get_basename (argv[0]);
 
304
  g_set_prgname (basename);
 
305
  g_free (basename);
 
306
 
 
307
  /* Check argv[] for "--no-interface" before trying to initialize gtk+. */
152
308
  for (i = 1; i < argc; i++)
153
309
    {
154
310
      const gchar *arg = argv[i];
156
312
      if (arg[0] != '-')
157
313
        continue;
158
314
 
159
 
      if ((strcmp (arg, "--no-interface") == 0) ||
160
 
          (strcmp (arg, "-i") == 0))
161
 
        {
162
 
          no_interface = TRUE;
163
 
        }
164
 
      else if ((strcmp (arg, "--version") == 0) ||
165
 
               (strcmp (arg, "-v") == 0))
166
 
        {
167
 
          gimp_show_version ();
168
 
          app_exit (EXIT_SUCCESS);
169
 
        }
 
315
      if ((strcmp (arg, "--no-interface") == 0) || (strcmp (arg, "-i") == 0))
 
316
        {
 
317
          no_interface = TRUE;
 
318
        }
 
319
      else if ((strcmp (arg, "--version") == 0) || (strcmp (arg, "-v") == 0))
 
320
        {
 
321
          gimp_open_console_window ();
 
322
          gimp_show_version_and_exit ();
 
323
        }
 
324
#if defined (G_OS_WIN32) && !defined (GIMP_CONSOLE_COMPILATION)
170
325
      else if ((strcmp (arg, "--help") == 0) ||
171
 
               (strcmp (arg, "-h") == 0))
172
 
        {
173
 
          gimp_show_help (full_prog_name);
174
 
          app_exit (EXIT_SUCCESS);
175
 
        }
176
 
      else if (strncmp (arg, "--dump-gimprc", 13) == 0)
 
326
               (strcmp (arg, "-?") == 0) ||
 
327
               (strncmp (arg, "--help-", 7) == 0))
177
328
        {
178
 
          GimpConfigDumpFormat format = GIMP_CONFIG_DUMP_NONE;
179
 
 
180
 
          if (strcmp (arg, "--dump-gimprc") == 0)
181
 
            format = GIMP_CONFIG_DUMP_GIMPRC;
182
 
          if (strcmp (arg, "--dump-gimprc-system") == 0)
183
 
            format = GIMP_CONFIG_DUMP_GIMPRC_SYSTEM;
184
 
          else if (strcmp (arg, "--dump-gimprc-manpage") == 0)
185
 
            format = GIMP_CONFIG_DUMP_GIMPRC_MANPAGE;
186
 
 
187
 
          if (format)
188
 
            {
189
 
              Gimp     *gimp;
190
 
              gboolean  success;
191
 
 
192
 
              g_type_init ();
193
 
 
194
 
              gimp = g_object_new (GIMP_TYPE_GIMP, NULL);
195
 
 
196
 
              units_init (gimp);
197
 
 
198
 
              success = gimp_config_dump (format);
199
 
 
200
 
              g_object_unref (gimp);
201
 
 
202
 
              app_exit (success ? EXIT_SUCCESS : EXIT_FAILURE);
203
 
            }
 
329
          gimp_open_console_window ();
204
330
        }
 
331
#endif
205
332
    }
206
333
 
207
 
  if (! app_libs_init (&no_interface, &argc, &argv))
 
334
#ifdef GIMP_CONSOLE_COMPILATION
 
335
  no_interface = TRUE;
 
336
#endif
 
337
 
 
338
  context = g_option_context_new (_("[FILE|URI...]"));
 
339
  g_option_context_set_summary (context, GIMP_NAME);
 
340
 
 
341
  g_option_context_add_main_entries (context, main_entries, GETTEXT_PACKAGE);
 
342
 
 
343
  app_libs_init (context, no_interface);
 
344
 
 
345
  if (! g_option_context_parse (context, &argc, &argv, &error))
208
346
    {
209
 
      const gchar *msg;
210
 
 
211
 
      msg = _("GIMP could not initialize the graphical user interface.\n"
212
 
              "Make sure a proper setup for your display environment exists.");
213
 
      g_print ("%s\n\n", msg);
 
347
      if (error)
 
348
        {
 
349
          gimp_open_console_window ();
 
350
          g_print ("%s\n", error->message);
 
351
          g_error_free (error);
 
352
        }
 
353
      else
 
354
        {
 
355
          g_print ("%s\n",
 
356
                   _("GIMP could not initialize the graphical user interface.\n"
 
357
                     "Make sure a proper setup for your display environment "
 
358
                     "exists."));
 
359
        }
214
360
 
215
361
      app_exit (EXIT_FAILURE);
216
362
    }
217
363
 
 
364
  if (no_interface || be_verbose || console_messages || batch_commands != NULL)
 
365
    gimp_open_console_window ();
 
366
 
 
367
  if (no_interface)
 
368
    new_instance = TRUE;
 
369
 
 
370
  if (! new_instance)
 
371
    {
 
372
      if (gimp_dbus_open (filenames, as_new, be_verbose))
 
373
        return EXIT_SUCCESS;
 
374
    }
 
375
 
218
376
  abort_message = sanity_check ();
219
377
  if (abort_message)
220
378
    app_abort (no_interface, abort_message);
221
379
 
222
 
  g_set_application_name (_("The GIMP"));
223
 
 
224
 
#if defined (USE_SYSV_SHM) || defined (USE_POSIX_SHM) || defined (G_OS_WIN32)
225
 
  use_shm = TRUE;
226
 
#endif
227
 
 
228
 
#ifdef __GLIBC__
229
 
  /* Tweak memory allocation so that memory allocated in chunks >= 4k
230
 
   * (64x64 pixel 1bpp tile) gets returned to the system when free'd ().
231
 
   */
232
 
  mallopt (M_MMAP_THRESHOLD, 64 * 64 - 1);
233
 
#endif
234
 
 
235
 
  batch_commands    = g_new (const gchar *, argc);
236
 
  batch_commands[0] = NULL;
237
 
 
238
 
  for (i = 1; i < argc; i++)
239
 
    {
240
 
      if (strcmp (argv[i], "--g-fatal-warnings") == 0)
241
 
        {
242
 
          GLogLevelFlags fatal_mask;
243
 
 
244
 
          fatal_mask = g_log_set_always_fatal (G_LOG_FATAL_MASK);
245
 
          fatal_mask |= G_LOG_LEVEL_WARNING | G_LOG_LEVEL_CRITICAL;
246
 
          g_log_set_always_fatal (fatal_mask);
247
 
          argv[i] = NULL;
248
 
        }
249
 
      else if ((strcmp (argv[i], "--no-interface") == 0) ||
250
 
               (strcmp (argv[i], "-i") == 0))
251
 
        {
252
 
          no_interface = TRUE;
253
 
          argv[i] = NULL;
254
 
        }
255
 
      else if (strcmp (argv[i], "--batch-interpreter") == 0)
256
 
        {
257
 
          argv[i] = NULL;
258
 
          if (argc <= ++i)
259
 
            {
260
 
              show_help = TRUE;
261
 
            }
262
 
          else
263
 
            {
264
 
              batch_interpreter = argv[i];
265
 
              argv[i] = NULL;
266
 
            }
267
 
        }
268
 
      else if ((strcmp (argv[i], "--batch") == 0) ||
269
 
               (strcmp (argv[i], "-b") == 0))
270
 
        {
271
 
          argv[i] = NULL;
272
 
          for (j = 0, i++ ; i < argc; j++, i++)
273
 
            {
274
 
              batch_commands[j] = argv[i];
275
 
              argv[i] = NULL;
276
 
            }
277
 
          batch_commands[j] = NULL;
278
 
 
279
 
          /* We need at least one batch command */
280
 
          if (batch_commands[0] == NULL)
281
 
            show_help = TRUE;
282
 
        }
283
 
      else if (strcmp (argv[i], "--system-gimprc") == 0)
284
 
        {
285
 
          argv[i] = NULL;
286
 
          if (argc <= ++i)
287
 
            {
288
 
              show_help = TRUE;
289
 
            }
290
 
          else
291
 
            {
292
 
              alternate_system_gimprc = argv[i];
293
 
              argv[i] = NULL;
294
 
            }
295
 
        }
296
 
      else if ((strcmp (argv[i], "--gimprc") == 0) ||
297
 
               (strcmp (argv[i], "-g") == 0))
298
 
        {
299
 
          argv[i] = NULL;
300
 
          if (argc <= ++i)
301
 
            {
302
 
              show_help = TRUE;
303
 
            }
304
 
          else
305
 
            {
306
 
              alternate_gimprc = argv[i];
307
 
              argv[i] = NULL;
308
 
            }
309
 
        }
310
 
      else if ((strcmp (argv[i], "--no-data") == 0) ||
311
 
               (strcmp (argv[i], "-d") == 0))
312
 
        {
313
 
          no_data = TRUE;
314
 
          argv[i] = NULL;
315
 
        }
316
 
      else if ((strcmp (argv[i], "--no-fonts") == 0) ||
317
 
               (strcmp (argv[i], "-f") == 0))
318
 
        {
319
 
          no_fonts = TRUE;
320
 
          argv[i] = NULL;
321
 
        }
322
 
      else if ((strcmp (argv[i], "--no-splash") == 0) ||
323
 
               (strcmp (argv[i], "-s") == 0))
324
 
        {
325
 
          no_splash = TRUE;
326
 
          argv[i] = NULL;
327
 
        }
328
 
      else if (strcmp (argv[i], "--verbose") == 0)
329
 
        {
330
 
          be_verbose = TRUE;
331
 
          argv[i] = NULL;
332
 
        }
333
 
      else if (strcmp (argv[i], "--no-shm") == 0)
334
 
        {
335
 
          use_shm = FALSE;
336
 
          argv[i] = NULL;
337
 
        }
338
 
      else if (strcmp (argv[i], "--no-cpu-accel") == 0)
339
 
        {
340
 
          use_cpu_accel = FALSE;
341
 
          argv[i] = NULL;
342
 
        }
343
 
      else if (strcmp (argv[i], "--debug-handlers") == 0)
344
 
        {
345
 
          use_debug_handler = TRUE;
346
 
          argv[i] = NULL;
347
 
        }
348
 
      else if ((strcmp (argv[i], "--console-messages") == 0) ||
349
 
               (strcmp (argv[i], "-c") == 0))
350
 
        {
351
 
          console_messages = TRUE;
352
 
          argv[i] = NULL;
353
 
        }
354
 
      else if (strcmp (argv[i], "--session") == 0)
355
 
        {
356
 
          argv[i] = NULL;
357
 
          if (argc <= ++i)
358
 
            {
359
 
              show_help = TRUE;
360
 
            }
361
 
          else
362
 
            {
363
 
              session_name = argv[i];
364
 
              argv[i] = NULL;
365
 
            }
366
 
        }
367
 
      else if (strcmp (argv[i], "--stack-trace-mode") == 0)
368
 
        {
369
 
          argv[i] = NULL;
370
 
          if (argc <= ++i)
371
 
            {
372
 
              show_help = TRUE;
373
 
            }
374
 
          else
375
 
            {
376
 
              if (! strcmp (argv[i], "never"))
377
 
                stack_trace_mode = GIMP_STACK_TRACE_NEVER;
378
 
              else if (! strcmp (argv[i], "query"))
379
 
                stack_trace_mode = GIMP_STACK_TRACE_QUERY;
380
 
              else if (! strcmp (argv[i], "always"))
381
 
                stack_trace_mode = GIMP_STACK_TRACE_ALWAYS;
382
 
              else
383
 
                show_help = TRUE;
384
 
 
385
 
              argv[i] = NULL;
386
 
            }
387
 
        }
388
 
      else if (strcmp (argv[i], "--pdb-compat-mode") == 0)
389
 
        {
390
 
          argv[i] = NULL;
391
 
          if (argc <= ++i)
392
 
            {
393
 
              show_help = TRUE;
394
 
            }
395
 
          else
396
 
            {
397
 
              if (! strcmp (argv[i], "off"))
398
 
                pdb_compat_mode = GIMP_PDB_COMPAT_OFF;
399
 
              else if (! strcmp (argv[i], "on"))
400
 
                pdb_compat_mode = GIMP_PDB_COMPAT_ON;
401
 
              else if (! strcmp (argv[i], "warn"))
402
 
                pdb_compat_mode = GIMP_PDB_COMPAT_WARN;
403
 
              else
404
 
                show_help = TRUE;
405
 
 
406
 
              argv[i] = NULL;
407
 
            }
408
 
        }
409
 
      else if (strcmp (argv[i], "--") == 0)
410
 
        {
411
 
          /*
412
 
           *  everything after "--" is a parameter (i.e. image to load)
413
 
           */
414
 
          argv[i] = NULL;
415
 
          break;
416
 
        }
417
 
      else if (argv[i][0] == '-')
418
 
        {
419
 
          /*
420
 
           *  anything else starting with a '-' is an error.
421
 
           */
422
 
          g_print (_("\nInvalid option \"%s\"\n"), argv[i]);
423
 
          show_help = TRUE;
424
 
        }
425
 
    }
426
 
 
427
 
  if (show_help)
428
 
    {
429
 
      gimp_show_help (full_prog_name);
430
 
      app_exit (EXIT_FAILURE);
431
 
    }
432
 
 
433
 
#ifndef G_OS_WIN32
434
 
 
435
 
  /* No use catching these on Win32, the user won't get any
436
 
   * stack trace from glib anyhow. It's better to let Windows inform
437
 
   * about the program error, and offer debugging (if the user
438
 
   * has installed MSVC or some other compiler that knows how to
439
 
   * install itself as a handler for program errors).
440
 
   */
441
 
 
442
 
  /* Handle fatal signals */
443
 
 
444
 
  /* these are handled by gimp_terminate() */
445
 
  gimp_signal_private (SIGHUP,  gimp_sigfatal_handler, 0);
446
 
  gimp_signal_private (SIGINT,  gimp_sigfatal_handler, 0);
447
 
  gimp_signal_private (SIGQUIT, gimp_sigfatal_handler, 0);
448
 
  gimp_signal_private (SIGABRT, gimp_sigfatal_handler, 0);
449
 
  gimp_signal_private (SIGTERM, gimp_sigfatal_handler, 0);
450
 
 
451
 
  if (stack_trace_mode != GIMP_STACK_TRACE_NEVER)
452
 
    {
453
 
      /* these are handled by gimp_fatal_error() */
454
 
      gimp_signal_private (SIGBUS,  gimp_sigfatal_handler, 0);
455
 
      gimp_signal_private (SIGSEGV, gimp_sigfatal_handler, 0);
456
 
      gimp_signal_private (SIGFPE,  gimp_sigfatal_handler, 0);
457
 
    }
458
 
 
459
 
  /* Ignore SIGPIPE because plug_in.c handles broken pipes */
460
 
 
461
 
  gimp_signal_private (SIGPIPE, SIG_IGN, 0);
462
 
 
463
 
  /* Collect dead children */
464
 
 
465
 
  gimp_signal_private (SIGCHLD, gimp_sigchld_handler, SA_RESTART);
466
 
 
467
 
#endif /* G_OS_WIN32 */
468
 
 
469
 
  gimp_errors_init (full_prog_name,
470
 
                    use_debug_handler,
471
 
                    stack_trace_mode);
472
 
 
473
 
  app_run (full_prog_name,
474
 
           argc - 1,
475
 
           argv + 1,
476
 
           alternate_system_gimprc,
477
 
           alternate_gimprc,
 
380
  gimp_init_signal_handlers ();
 
381
 
 
382
  app_run (argv[0],
 
383
           filenames,
 
384
           system_gimprc,
 
385
           user_gimprc,
478
386
           session_name,
479
387
           batch_interpreter,
480
388
           batch_commands,
 
389
           as_new,
481
390
           no_interface,
482
391
           no_data,
483
392
           no_fonts,
486
395
           use_shm,
487
396
           use_cpu_accel,
488
397
           console_messages,
 
398
           use_debug_handler,
489
399
           stack_trace_mode,
490
400
           pdb_compat_mode);
491
401
 
492
 
  g_free (batch_commands);
 
402
  g_option_context_free (context);
493
403
 
494
404
  return EXIT_SUCCESS;
495
405
}
496
406
 
497
407
 
498
 
static void
499
 
gimp_show_version (void)
500
 
{
501
 
  g_print ("%s %s\n", _("GIMP version"), GIMP_VERSION);
502
 
}
503
 
 
504
 
static void
505
 
gimp_show_help (const gchar *progname)
506
 
{
507
 
  gimp_show_version ();
508
 
 
509
 
  g_print (_("\nUsage: %s [option ... ] [file ... ]\n\n"),
510
 
           gimp_filename_to_utf8 (progname));
511
 
  g_print (_("Options:\n"));
512
 
  g_print (_("  -h, --help               Output this help.\n"));
513
 
  g_print (_("  -v, --version            Output version information.\n"));
514
 
  g_print (_("  --verbose                Show startup messages.\n"));
515
 
  g_print (_("  --no-shm                 Do not use shared memory between GIMP and plugins.\n"));
516
 
  g_print (_("  --no-cpu-accel           Do not use special CPU accelerations.\n"));
517
 
  g_print (_("  -d, --no-data            Do not load brushes, gradients, palettes, patterns.\n"));
518
 
  g_print (_("  -f, --no-fonts           Do not load any fonts.\n"));
519
 
  g_print (_("  -i, --no-interface       Run without a user interface.\n"));
520
 
  g_print (_("  --display <display>      Use the designated X display.\n"));
521
 
  g_print (_("  -s, --no-splash          Do not show the startup window.\n"));
522
 
  g_print (_("  --session <name>         Use an alternate sessionrc file.\n"));
523
 
  g_print (_("  -g, --gimprc <gimprc>    Use an alternate gimprc file.\n"));
524
 
  g_print (_("  --system-gimprc <gimprc> Use an alternate system gimprc file.\n"));
525
 
  g_print (_("  --dump-gimprc            Output a gimprc file with default settings.\n"));
526
 
  g_print (_("  -c, --console-messages   Display warnings to console instead of a dialog box.\n"));
527
 
  g_print (_("  --debug-handlers         Enable non-fatal debugging signal handlers.\n"));
528
 
  g_print (_("  --stack-trace-mode <never | query | always>\n"
529
 
             "                           Debugging mode for fatal signals.\n"));
530
 
  g_print (_("  --pdb-compat-mode <off | on | warn>\n"
531
 
             "                           Procedural Database compatibility mode.\n"));
532
 
  g_print (_("  --batch-interpreter <procedure>\n"
533
 
             "                           The procedure to process batch commands with.\n"));
534
 
  g_print (_("  -b, --batch <commands>   Process commands in batch mode.\n"));
535
 
  g_print ("\n");
536
 
}
537
 
 
538
 
 
539
408
#ifdef G_OS_WIN32
540
409
 
541
 
/* In case we build this as a windowed application */
 
410
/* In case we build this as a windowed application. Well, we do. */
542
411
 
543
412
#ifdef __GNUC__
544
413
#  ifndef _stdcall
548
417
 
549
418
int _stdcall
550
419
WinMain (struct HINSTANCE__ *hInstance,
551
 
         struct HINSTANCE__ *hPrevInstance,
552
 
         char               *lpszCmdLine,
553
 
         int                 nCmdShow)
 
420
         struct HINSTANCE__ *hPrevInstance,
 
421
         char               *lpszCmdLine,
 
422
         int                 nCmdShow)
554
423
{
555
424
  return main (__argc, __argv);
556
425
}
557
426
 
558
 
#endif /* G_OS_WIN32 */
 
427
#ifndef GIMP_CONSOLE_COMPILATION
 
428
 
 
429
static void
 
430
wait_console_window (void)
 
431
{
 
432
  FILE *console = fopen ("CONOUT$", "w");
 
433
 
 
434
  SetConsoleTitleW (g_utf8_to_utf16 (_("GIMP output. Type any character to close this window."), -1, NULL, NULL, NULL));
 
435
  fprintf (console, _("(Type any character to close this window)\n"));
 
436
  fflush (console);
 
437
  _getch ();
 
438
}
 
439
 
 
440
static void
 
441
gimp_open_console_window (void)
 
442
{
 
443
  if (((HANDLE) _get_osfhandle (fileno (stdout)) == INVALID_HANDLE_VALUE ||
 
444
       (HANDLE) _get_osfhandle (fileno (stderr)) == INVALID_HANDLE_VALUE) && AllocConsole ())
 
445
    {
 
446
      if ((HANDLE) _get_osfhandle (fileno (stdout)) == INVALID_HANDLE_VALUE)
 
447
        freopen ("CONOUT$", "w", stdout);
 
448
 
 
449
      if ((HANDLE) _get_osfhandle (fileno (stderr)) == INVALID_HANDLE_VALUE)
 
450
        freopen ("CONOUT$", "w", stderr);
 
451
 
 
452
      SetConsoleTitleW (g_utf8_to_utf16 (_("GIMP output. You can minimize this window, but don't close it."), -1, NULL, NULL, NULL));
 
453
 
 
454
      atexit (wait_console_window);
 
455
    }
 
456
}
 
457
#endif
 
458
 
 
459
#endif /* G_OS_WIN32 */
 
460
 
 
461
 
 
462
static gboolean
 
463
gimp_option_fatal_warnings (const gchar  *option_name,
 
464
                            const gchar  *value,
 
465
                            gpointer      data,
 
466
                            GError      **error)
 
467
{
 
468
  GLogLevelFlags fatal_mask;
 
469
 
 
470
  fatal_mask = g_log_set_always_fatal (G_LOG_FATAL_MASK);
 
471
  fatal_mask |= G_LOG_LEVEL_WARNING | G_LOG_LEVEL_CRITICAL;
 
472
 
 
473
  g_log_set_always_fatal (fatal_mask);
 
474
 
 
475
  return TRUE;
 
476
}
 
477
 
 
478
static gboolean
 
479
gimp_option_stack_trace_mode (const gchar  *option_name,
 
480
                              const gchar  *value,
 
481
                              gpointer      data,
 
482
                              GError      **error)
 
483
{
 
484
  if (strcmp (value, "never") == 0)
 
485
    stack_trace_mode = GIMP_STACK_TRACE_NEVER;
 
486
  else if (strcmp (value, "query") == 0)
 
487
    stack_trace_mode = GIMP_STACK_TRACE_QUERY;
 
488
  else if (strcmp (value, "always") == 0)
 
489
    stack_trace_mode = GIMP_STACK_TRACE_ALWAYS;
 
490
  else
 
491
    return FALSE;
 
492
 
 
493
  return TRUE;
 
494
}
 
495
 
 
496
static gboolean
 
497
gimp_option_pdb_compat_mode (const gchar  *option_name,
 
498
                             const gchar  *value,
 
499
                             gpointer      data,
 
500
                             GError      **error)
 
501
{
 
502
  if (! strcmp (value, "off"))
 
503
    pdb_compat_mode = GIMP_PDB_COMPAT_OFF;
 
504
  else if (! strcmp (value, "on"))
 
505
    pdb_compat_mode = GIMP_PDB_COMPAT_ON;
 
506
  else if (! strcmp (value, "warn"))
 
507
    pdb_compat_mode = GIMP_PDB_COMPAT_WARN;
 
508
  else
 
509
    return FALSE;
 
510
 
 
511
  return TRUE;
 
512
}
 
513
 
 
514
static gboolean
 
515
gimp_option_dump_gimprc (const gchar  *option_name,
 
516
                         const gchar  *value,
 
517
                         gpointer      data,
 
518
                         GError      **error)
 
519
{
 
520
  GimpConfigDumpFormat format = GIMP_CONFIG_DUMP_NONE;
 
521
 
 
522
  gimp_open_console_window ();
 
523
 
 
524
  if (strcmp (option_name, "--dump-gimprc") == 0)
 
525
    format = GIMP_CONFIG_DUMP_GIMPRC;
 
526
  if (strcmp (option_name, "--dump-gimprc-system") == 0)
 
527
    format = GIMP_CONFIG_DUMP_GIMPRC_SYSTEM;
 
528
  else if (strcmp (option_name, "--dump-gimprc-manpage") == 0)
 
529
    format = GIMP_CONFIG_DUMP_GIMPRC_MANPAGE;
 
530
 
 
531
  if (format)
 
532
    {
 
533
      Gimp     *gimp;
 
534
      gboolean  success;
 
535
 
 
536
      gimp = g_object_new (GIMP_TYPE_GIMP, NULL);
 
537
 
 
538
      units_init (gimp);
 
539
 
 
540
      success = gimp_config_dump (format);
 
541
 
 
542
      g_object_unref (gimp);
 
543
 
 
544
      app_exit (success ? EXIT_SUCCESS : EXIT_FAILURE);
 
545
    }
 
546
 
 
547
  return FALSE;
 
548
}
 
549
 
 
550
static void
 
551
gimp_show_version (void)
 
552
{
 
553
  gimp_open_console_window ();
 
554
  g_print (_("%s version %s"), GIMP_NAME, GIMP_VERSION);
 
555
  g_print ("\n");
 
556
}
 
557
 
 
558
static void
 
559
gimp_show_version_and_exit (void)
 
560
{
 
561
  gimp_show_version ();
 
562
 
 
563
  app_exit (EXIT_SUCCESS);
 
564
}
 
565
 
 
566
static void
 
567
gimp_show_license_and_exit (void)
 
568
{
 
569
  gimp_show_version ();
 
570
 
 
571
  g_print ("\n");
 
572
  g_print (GIMP_LICENSE);
 
573
  g_print ("\n\n");
 
574
 
 
575
  app_exit (EXIT_SUCCESS);
 
576
}
 
577
 
 
578
static void
 
579
gimp_init_malloc (void)
 
580
{
 
581
#ifdef GIMP_GLIB_MEM_PROFILER
 
582
  g_mem_set_vtable (glib_mem_profiler_table);
 
583
  g_atexit (g_mem_profile);
 
584
#endif
 
585
 
 
586
#ifdef __GLIBC__
 
587
  /* Tweak memory allocation so that memory allocated in chunks >= 4k
 
588
   * (64x64 pixel 1bpp tile) gets returned to the system when free()'d.
 
589
   *
 
590
   * The default value for M_MMAP_THRESHOLD in glibc-2.3 is 128k.
 
591
   * This is said to be an empirically derived value that works well
 
592
   * in most systems. Lowering it to 4k is thus probably not the ideal
 
593
   * solution.
 
594
   *
 
595
   * An alternative to tuning this parameter would be to use
 
596
   * malloc_trim(), for example after releasing a large tile-manager.
 
597
   *
 
598
   * Another possibility is to switch to using GSlice as soon as this
 
599
   * API is available in a stable GLib release.
 
600
   */
 
601
  mallopt (M_MMAP_THRESHOLD, TILE_WIDTH * TILE_HEIGHT);
 
602
#endif
 
603
}
 
604
 
 
605
static void
 
606
gimp_init_i18n (void)
 
607
{
 
608
  setlocale (LC_ALL, "");
 
609
 
 
610
  bindtextdomain (GETTEXT_PACKAGE"-libgimp", gimp_locale_directory ());
 
611
#ifdef HAVE_BIND_TEXTDOMAIN_CODESET
 
612
  bind_textdomain_codeset (GETTEXT_PACKAGE"-libgimp", "UTF-8");
 
613
#endif
 
614
 
 
615
  bindtextdomain (GETTEXT_PACKAGE, gimp_locale_directory ());
 
616
#ifdef HAVE_BIND_TEXTDOMAIN_CODESET
 
617
  bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
 
618
#endif
 
619
 
 
620
  textdomain (GETTEXT_PACKAGE);
 
621
}
 
622
 
 
623
static void
 
624
gimp_init_signal_handlers (void)
 
625
{
 
626
#ifndef G_OS_WIN32
 
627
  /* No use catching these on Win32, the user won't get any
 
628
   * stack trace from glib anyhow. It's better to let Windows inform
 
629
   * about the program error, and offer debugging (if the user
 
630
   * has installed MSVC or some other compiler that knows how to
 
631
   * install itself as a handler for program errors).
 
632
   */
 
633
 
 
634
  /* Handle fatal signals */
 
635
 
 
636
  /* these are handled by gimp_terminate() */
 
637
  gimp_signal_private (SIGHUP,  gimp_sigfatal_handler, 0);
 
638
  gimp_signal_private (SIGINT,  gimp_sigfatal_handler, 0);
 
639
  gimp_signal_private (SIGQUIT, gimp_sigfatal_handler, 0);
 
640
  gimp_signal_private (SIGABRT, gimp_sigfatal_handler, 0);
 
641
  gimp_signal_private (SIGTERM, gimp_sigfatal_handler, 0);
 
642
 
 
643
  if (stack_trace_mode != GIMP_STACK_TRACE_NEVER)
 
644
    {
 
645
      /* these are handled by gimp_fatal_error() */
 
646
      gimp_signal_private (SIGBUS,  gimp_sigfatal_handler, 0);
 
647
      gimp_signal_private (SIGSEGV, gimp_sigfatal_handler, 0);
 
648
      gimp_signal_private (SIGFPE,  gimp_sigfatal_handler, 0);
 
649
    }
 
650
 
 
651
  /* Ignore SIGPIPE because plug_in.c handles broken pipes */
 
652
  gimp_signal_private (SIGPIPE, SIG_IGN, 0);
 
653
 
 
654
  /* Restart syscalls on SIGCHLD */
 
655
  gimp_signal_private (SIGCHLD, SIG_DFL, SA_RESTART);
 
656
 
 
657
#endif /* G_OS_WIN32 */
 
658
}
559
659
 
560
660
 
561
661
#ifndef G_OS_WIN32
584
684
    }
585
685
}
586
686
 
587
 
/* gimp core signal handler for death-of-child signals */
588
 
 
589
 
static void
590
 
gimp_sigchld_handler (gint sig_num)
591
 
{
592
 
  gint pid;
593
 
  gint status;
594
 
 
595
 
  while (TRUE)
596
 
    {
597
 
      pid = waitpid (WAIT_ANY, &status, WNOHANG);
598
 
 
599
 
      if (pid <= 0)
600
 
        break;
601
 
    }
602
 
}
603
 
 
604
687
#endif /* ! G_OS_WIN32 */
 
688
 
 
689
 
 
690
static gboolean
 
691
gimp_dbus_open (const gchar **filenames,
 
692
                gboolean      as_new,
 
693
                gboolean      be_verbose)
 
694
{
 
695
#ifndef GIMP_CONSOLE_COMPILATION
 
696
#if HAVE_DBUS_GLIB
 
697
  DBusGConnection *connection = dbus_g_bus_get (DBUS_BUS_SESSION, NULL);
 
698
 
 
699
  if (connection)
 
700
    {
 
701
      DBusGProxy *proxy;
 
702
      gboolean    success;
 
703
      GError     *error = NULL;
 
704
 
 
705
      proxy = dbus_g_proxy_new_for_name (connection,
 
706
                                         GIMP_DBUS_SERVICE_NAME,
 
707
                                         GIMP_DBUS_SERVICE_PATH,
 
708
                                         GIMP_DBUS_SERVICE_INTERFACE);
 
709
 
 
710
      if (filenames)
 
711
        {
 
712
          const gchar *method = as_new ? "OpenAsNew" : "Open";
 
713
          gint         i;
 
714
 
 
715
          for (i = 0, success = TRUE; filenames[i] && success; i++)
 
716
            {
 
717
              gboolean retval;  /* ignored */
 
718
 
 
719
              success = dbus_g_proxy_call (proxy, method, &error,
 
720
                                           G_TYPE_STRING, filenames[i],
 
721
                                           G_TYPE_INVALID,
 
722
                                           G_TYPE_BOOLEAN, &retval,
 
723
                                           G_TYPE_INVALID);
 
724
            }
 
725
        }
 
726
      else
 
727
        {
 
728
          success = dbus_g_proxy_call (proxy, "Activate", &error,
 
729
                                       G_TYPE_INVALID, G_TYPE_INVALID);
 
730
        }
 
731
 
 
732
      g_object_unref (proxy);
 
733
      dbus_g_connection_unref (connection);
 
734
 
 
735
      if (success)
 
736
        {
 
737
          if (be_verbose)
 
738
            g_print ("%s\n",
 
739
                     _("Another GIMP instance is already running."));
 
740
 
 
741
          gdk_notify_startup_complete ();
 
742
 
 
743
          return TRUE;
 
744
        }
 
745
      else if (! (error->domain == DBUS_GERROR &&
 
746
                  error->code == DBUS_GERROR_SERVICE_UNKNOWN))
 
747
        {
 
748
          g_print ("%s\n", error->message);
 
749
        }
 
750
 
 
751
      g_clear_error (&error);
 
752
    }
 
753
#endif
 
754
#endif
 
755
 
 
756
  return FALSE;
 
757
}