111
106
#define gimp_open_console_window() /* as nothing */
114
static gboolean gimp_dbus_open (const gchar **filenames,
116
gboolean be_verbose);
119
109
static const gchar *system_gimprc = NULL;
120
110
static const gchar *user_gimprc = NULL;
121
111
static const gchar *session_name = NULL;
281
#if defined (__GNUC__) && defined (_WIN64)
282
/* mingw-w64, at least the unstable build from late July 2008,
283
* starts subsystem:windows programs in main(), but passes them
284
* bogus argc and argv. __argc and __argv are OK, though, so just
292
291
g_thread_init (NULL);
294
293
#ifdef GIMP_UNSTABLE
307
308
g_set_prgname (basename);
308
309
g_free (basename);
311
/* Check argv[] for "--verbose" first */
312
for (i = 1; i < argc; i++)
314
const gchar *arg = argv[i];
319
if ((strcmp (arg, "--verbose") == 0) || (strcmp (arg, "-v") == 0))
310
325
/* Check argv[] for "--no-interface" before trying to initialize gtk+. */
311
326
for (i = 1; i < argc; i++)
322
337
else if ((strcmp (arg, "--version") == 0) || (strcmp (arg, "-v") == 0))
324
gimp_open_console_window ();
325
339
gimp_show_version_and_exit ();
327
341
#if defined (G_OS_WIN32) && !defined (GIMP_CONSOLE_COMPILATION)
370
384
if (no_interface)
371
385
new_instance = TRUE;
387
#ifndef GIMP_CONSOLE_COMPILATION
388
if (! new_instance && gimp_unique_open (filenames, as_new))
375
if (gimp_dbus_open (filenames, as_new, be_verbose))
392
_("Another GIMP instance is already running."));
394
gdk_notify_startup_complete ();
379
400
abort_message = sanity_check ();
380
401
if (abort_message)
411
432
#ifdef G_OS_WIN32
413
/* In case we build this as a windowed application. Well, we do. */
434
/* Provide WinMain in case we build GIMP as a subsystem:windows
435
* application. Well, we do. When built with mingw, though, user code
436
* execution still starts in main() in that case. So WinMain() gets
437
* used on MSVC builds only.
416
441
# ifndef _stdcall
554
gimp_show_version (void)
556
gimp_open_console_window ();
557
g_print (_("%s version %s"), GIMP_NAME, GIMP_VERSION);
562
579
gimp_show_version_and_exit (void)
564
gimp_show_version ();
581
gimp_open_console_window ();
582
gimp_version_show (be_verbose);
566
584
app_exit (EXIT_SUCCESS);
598
617
* An alternative to tuning this parameter would be to use
599
618
* malloc_trim(), for example after releasing a large tile-manager.
601
* Another possibility is to switch to using GSlice as soon as this
602
* API is available in a stable GLib release.
604
620
mallopt (M_MMAP_THRESHOLD, TILE_WIDTH * TILE_HEIGHT);
690
706
#endif /* ! G_OS_WIN32 */
694
gimp_dbus_open (const gchar **filenames,
698
#ifndef GIMP_CONSOLE_COMPILATION
700
DBusGConnection *connection = dbus_g_bus_get (DBUS_BUS_SESSION, NULL);
706
GError *error = NULL;
708
proxy = dbus_g_proxy_new_for_name (connection,
709
GIMP_DBUS_SERVICE_NAME,
710
GIMP_DBUS_SERVICE_PATH,
711
GIMP_DBUS_SERVICE_INTERFACE);
715
const gchar *method = as_new ? "OpenAsNew" : "Open";
719
for (i = 0, success = TRUE; filenames[i] && success; i++)
721
const gchar *filename = filenames[i];
724
if (file_utils_filename_is_uri (filename, &error))
726
uri = g_strdup (filename);
730
if (! g_path_is_absolute (filename))
735
cwd = g_get_current_dir ();
737
absolute = g_build_filename (cwd, filename, NULL);
739
uri = g_filename_to_uri (absolute, NULL, &error);
745
uri = g_filename_to_uri (filename, NULL, &error);
751
gboolean retval; /* ignored */
753
success = dbus_g_proxy_call (proxy, method, &error,
756
G_TYPE_BOOLEAN, &retval,
762
g_printerr ("conversion to uri failed: %s\n", error->message);
763
g_clear_error (&error);
771
success = dbus_g_proxy_call (proxy, "Activate", &error,
772
G_TYPE_INVALID, G_TYPE_INVALID);
775
g_object_unref (proxy);
776
dbus_g_connection_unref (connection);
782
_("Another GIMP instance is already running."));
784
gdk_notify_startup_complete ();
788
else if (! (error->domain == DBUS_GERROR &&
789
error->code == DBUS_GERROR_SERVICE_UNKNOWN))
791
g_print ("%s\n", error->message);
794
g_clear_error (&error);