From 84c29b48616aaf04e61440622876ff068e173d6d Mon Sep 17 00:00:00 2001 From: Michael Natterer Date: Mon, 12 Jul 2004 14:32:31 +0000 Subject: [PATCH] Made the gimp-console binary compile. Finishes core/GUI separation and 2004-07-12 Michael Natterer Made the gimp-console binary compile. Finishes core/GUI separation and fixes bug #71514: * configure.in: removed the crazy-hacker warning for --enable-gimp-console. * app/Makefile.am: for gimp-console, copy app_procs.c to app_procs_console.c and compile it instead of app_procs.c with -DGIMP_CONSOLE_COMPILATION * app/app_procs.[ch]: added some #ifndef GIMP_CONSOLE_COMPILATION to skip GUI stuff for the gimp-console case. Renamed app_gui_libs_init() to app_libs_init(), renamed app_gui_abort() to app_abort() and added app_exit() so everything that needs #ifdefs lives here now. * app/main.c: changed accordingly. * app/gui/gui.c (gui_abort): really abort (call exit()). --- ChangeLog | 22 +++++++++++++ app/.cvsignore | 1 + app/Makefile.am | 22 +++++++++++-- app/app_procs.c | 83 +++++++++++++++++++++++++++++++++++++++++++++---- app/app_procs.h | 43 +++++++++++++------------ app/gui/gui.c | 6 ++-- app/main.c | 66 +++++++-------------------------------- configure.in | 8 ----- 8 files changed, 155 insertions(+), 96 deletions(-) diff --git a/ChangeLog b/ChangeLog index 712d503443..ee8b23dc11 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,25 @@ +2004-07-12 Michael Natterer + + Made the gimp-console binary compile. + Finishes core/GUI separation and fixes bug #71514: + + * configure.in: removed the crazy-hacker warning for + --enable-gimp-console. + + * app/Makefile.am: for gimp-console, copy app_procs.c to + app_procs_console.c and compile it instead of app_procs.c with + -DGIMP_CONSOLE_COMPILATION + + * app/app_procs.[ch]: added some #ifndef GIMP_CONSOLE_COMPILATION + to skip GUI stuff for the gimp-console case. + Renamed app_gui_libs_init() to app_libs_init(), renamed + app_gui_abort() to app_abort() and added app_exit() so everything + that needs #ifdefs lives here now. + + * app/main.c: changed accordingly. + + * app/gui/gui.c (gui_abort): really abort (call exit()). + 2004-07-12 Sven Neumann * INSTALL: made the suggestion to use binary packages more diff --git a/app/.cvsignore b/app/.cvsignore index f71dbd9d2f..a3895e9cbe 100644 --- a/app/.cvsignore +++ b/app/.cvsignore @@ -4,3 +4,4 @@ makefile.mingw .deps .libs gimp-2.1 +app_procs_console.c diff --git a/app/Makefile.am b/app/Makefile.am index 9b3468bc11..38cabae1a4 100644 --- a/app/Makefile.am +++ b/app/Makefile.am @@ -35,8 +35,7 @@ else bin_PROGRAMS = gimp-2.1 endif -gimp_2_1_SOURCES = \ - app_procs.c \ +COMMON_SOURCES = \ app_procs.h \ main.c \ batch.c \ @@ -49,11 +48,18 @@ gimp_2_1_SOURCES = \ units.h \ gimp-intl.h +gimp_2_1_SOURCES = \ + $(COMMON_SOURCES) \ + app_procs.c + EXTRA_DIST = \ makefile.msc \ gimp.rc \ wilber.ico +CLEANFILES = \ + app_procs_console.c + if HAVE_GLIBC_REGEX REGEXREPL = else @@ -133,7 +139,17 @@ gimp_2_1_LDADD = \ $(REGEXREPL) if ENABLE_GIMP_CONSOLE -gimp_console_2_1_SOURCES = $(gimp_2_1_SOURCES) +app_procs_console.c: $(srcdir)/app_procs.c + cp -f $(srcdir)/app_procs.c app_procs_console.c + +gimp_console_2_1_SOURCES = \ + $(COMMON_SOURCES) \ + app_procs_console.c + +gimp_console_2_1_CPPFLAGS = \ + $(AM_CPPFLAGS) \ + -DGIMP_CONSOLE_COMPILATION + gimp_console_2_1_LDFLAGS = $(gimp_2_1_LDFLAGS) gimp_console_2_1_LDADD = \ diff --git a/app/app_procs.c b/app/app_procs.c index 9afccf722d..d166a030bc 100644 --- a/app/app_procs.c +++ b/app/app_procs.c @@ -47,8 +47,10 @@ #include "tools/gimp-tools.h" +#ifndef GIMP_CONSOLE_COMPILATION #include "gui/gui.h" #include "gui/user-install-dialog.h" +#endif #include "app_procs.h" #include "batch.h" @@ -71,16 +73,77 @@ static gboolean app_exit_after_callback (Gimp *gimp, /* public functions */ gboolean -app_gui_libs_init (gint *argc, - gchar ***argv) +app_libs_init (gboolean *no_interface, + gint *argc, + gchar ***argv) { - return gui_libs_init (argc, argv); +#ifdef GIMP_CONSOLE_COMPILATION + *no_interface = TRUE; +#endif + + if (*no_interface) + { + gchar *basename; + + basename = g_path_get_basename ((*argv)[0]); + g_set_prgname (basename); + g_free (basename); + + g_type_init (); + + return TRUE; + } +#ifndef GIMP_CONSOLE_COMPILATION + else + { + return gui_libs_init (argc, argv); + } +#endif + + return FALSE; } void -app_gui_abort (const gchar *abort_message) +app_abort (gboolean no_interface, + const gchar *abort_message) { - gui_abort (abort_message); +#ifndef GIMP_CONSOLE_COMPILATION + if (no_interface) +#endif + { + g_print ("%s\n\n", abort_message); + } +#ifndef GIMP_CONSOLE_COMPILATION + else + { + gui_abort (abort_message); + } +#endif + + app_exit (EXIT_FAILURE); +} + +void +app_exit (gint status) +{ +#ifdef G_OS_WIN32 + /* Give them time to read the message if it was printed in a + * separate console window. I would really love to have + * some way of asking for confirmation to close the console + * window. + */ + HANDLE console; + DWORD mode; + + console = GetStdHandle (STD_OUTPUT_HANDLE); + if (GetConsoleMode (console, &mode) != 0) + { + g_print (_("(This console window will close in ten seconds)\n")); + Sleep(10000); + } +#endif + + exit (status); } void @@ -182,7 +245,9 @@ app_run (const gchar *full_prog_name, { /* not properly installed */ +#ifndef GIMP_CONSOLE_COMPILATION if (no_interface) +#endif { const gchar *msg; @@ -190,14 +255,16 @@ app_run (const gchar *full_prog_name, "User installation was skipped because the '--no-interface' flag was used.\n" "To perform user installation, run the GIMP without the '--no-interface' flag."); - g_print ("%s\n\n", msg); + g_printerr ("%s\n\n", msg); } +#ifndef GIMP_CONSOLE_COMPILATION else { user_install_dialog_run (alternate_system_gimprc, alternate_gimprc, be_verbose); } +#endif } gimp_load_config (gimp, alternate_system_gimprc, alternate_gimprc); @@ -205,8 +272,10 @@ app_run (const gchar *full_prog_name, /* initialize lowlevel stuff */ swap_is_ok = base_init (GIMP_BASE_CONFIG (gimp->config), use_cpu_accel); +#ifndef GIMP_CONSOLE_COMPILATION if (! no_interface) update_status_func = gui_init (gimp, no_splash); +#endif if (! update_status_func) update_status_func = app_init_update_none; @@ -293,8 +362,10 @@ app_run (const gchar *full_prog_name, } } +#ifndef GIMP_CONSOLE_COMPILATION if (! no_interface) gui_post_init (gimp); +#endif batch_run (gimp, batch_cmds); diff --git a/app/app_procs.h b/app/app_procs.h index 829803a6e0..06516cb7f3 100644 --- a/app/app_procs.h +++ b/app/app_procs.h @@ -25,27 +25,30 @@ #endif -gboolean app_gui_libs_init (gint *gimp_argc, - gchar ***gimp_argv); -void app_gui_abort (const gchar *abort_message); +gboolean app_libs_init (gboolean *no_interface, + gint *gimp_argc, + gchar ***gimp_argv); +void app_abort (gboolean no_interface, + const gchar *abort_message) G_GNUC_NORETURN; +void app_exit (gint status) G_GNUC_NORETURN; -void app_run (const gchar *full_prog_name, - gint gimp_argc, - gchar **gimp_argv, - const gchar *alternate_system_gimprc, - const gchar *alternate_gimprc, - const gchar *session_name, - const gchar **batch_cmds, - gboolean no_interface, - gboolean no_data, - gboolean no_fonts, - gboolean no_splash, - gboolean be_verbose, - gboolean use_shm, - gboolean use_cpu_accel, - gboolean console_messages, - GimpStackTraceMode stack_trace_mode, - GimpPDBCompatMode pdb_compat_mode); +void app_run (const gchar *full_prog_name, + gint gimp_argc, + gchar **gimp_argv, + const gchar *alternate_system_gimprc, + const gchar *alternate_gimprc, + const gchar *session_name, + const gchar **batch_cmds, + gboolean no_interface, + gboolean no_data, + gboolean no_fonts, + gboolean no_splash, + gboolean be_verbose, + gboolean use_shm, + gboolean use_cpu_accel, + gboolean console_messages, + GimpStackTraceMode stack_trace_mode, + GimpPDBCompatMode pdb_compat_mode); #endif /* __APP_PROCS_H__ */ diff --git a/app/gui/gui.c b/app/gui/gui.c index c8bb57beb5..26966ebe0f 100644 --- a/app/gui/gui.c +++ b/app/gui/gui.c @@ -133,10 +133,7 @@ gui_libs_init (gint *argc, abort_message = gui_sanity_check (); if (abort_message) - { - gui_abort (abort_message); - exit (EXIT_FAILURE); - } + gui_abort (abort_message); gimp_widgets_init (gui_help_func, gui_get_foreground_func, @@ -156,6 +153,7 @@ gui_abort (const gchar *abort_message) gimp_message_box (GIMP_STOCK_WILBER_EEK, NULL, abort_message, (GtkCallback) gtk_main_quit, NULL); gtk_main (); + exit (EXIT_FAILURE); } GimpInitStatusFunc diff --git a/app/main.c b/app/main.c index a3cde648d5..6d64f489f6 100644 --- a/app/main.c +++ b/app/main.c @@ -62,14 +62,12 @@ #ifdef G_OS_WIN32 #include #else -static void gimp_sigfatal_handler (gint sig_num) G_GNUC_NORETURN; -static void gimp_sigchld_handler (gint sig_num); +static void gimp_sigfatal_handler (gint sig_num) G_GNUC_NORETURN; +static void gimp_sigchld_handler (gint sig_num); #endif - -static void gimp_show_version (void); -static void gimp_show_help (const gchar *progname); -static void gimp_text_console_exit (gint status) G_GNUC_NORETURN; +static void gimp_show_version (void); +static void gimp_show_help (const gchar *progname); /* @@ -166,13 +164,13 @@ main (int argc, (strcmp (arg, "-v") == 0)) { gimp_show_version (); - gimp_text_console_exit (EXIT_SUCCESS); + app_exit (EXIT_SUCCESS); } else if ((strcmp (arg, "--help") == 0) || (strcmp (arg, "-h") == 0)) { gimp_show_help (full_prog_name); - gimp_text_console_exit (EXIT_SUCCESS); + app_exit (EXIT_SUCCESS); } else if (strncmp (arg, "--dump-gimprc", 13) == 0) { @@ -200,22 +198,12 @@ main (int argc, g_object_unref (gimp); - gimp_text_console_exit (success ? EXIT_SUCCESS : EXIT_FAILURE); + app_exit (success ? EXIT_SUCCESS : EXIT_FAILURE); } } } - if (no_interface) - { - gchar *basename; - - basename = g_path_get_basename (argv[0]); - g_set_prgname (basename); - g_free (basename); - - g_type_init (); - } - else if (! app_gui_libs_init (&argc, &argv)) + if (! app_libs_init (&no_interface, &argc, &argv)) { const gchar *msg; @@ -223,20 +211,12 @@ main (int argc, "Make sure a proper setup for your display environment exists."); g_print ("%s\n\n", msg); - gimp_text_console_exit (EXIT_FAILURE); + app_exit (EXIT_FAILURE); } abort_message = sanity_check (); - if (abort_message) - { - if (no_interface) - g_print ("%s\n\n", abort_message); - else - app_gui_abort (abort_message); - - exit (EXIT_FAILURE); - } + app_abort (no_interface, abort_message); g_set_application_name (_("The GIMP")); @@ -442,7 +422,7 @@ main (int argc, if (show_help) { gimp_show_help (full_prog_name); - gimp_text_console_exit (EXIT_FAILURE); + app_exit (EXIT_FAILURE); } #ifndef G_OS_WIN32 @@ -548,30 +528,6 @@ gimp_show_help (const gchar *progname) }; -static void -gimp_text_console_exit (gint status) -{ -#ifdef G_OS_WIN32 - /* Give them time to read the message if it was printed in a - * separate console window. I would really love to have - * some way of asking for confirmation to close the console - * window. - */ - HANDLE console; - DWORD mode; - - console = GetStdHandle (STD_OUTPUT_HANDLE); - if (GetConsoleMode (console, &mode) != 0) - { - g_print (_("(This console window will close in ten seconds)\n")); - Sleep(10000); - } -#endif - - exit (status); -} - - #ifdef G_OS_WIN32 /* In case we build this as a windowed application */ diff --git a/configure.in b/configure.in index c68e0d8d21..4ce792decd 100644 --- a/configure.in +++ b/configure.in @@ -1427,14 +1427,6 @@ AC_ARG_ENABLE(gimp-console, [ --enable-gimp-console build a console-only bina AM_CONDITIONAL(ENABLE_GIMP_CONSOLE, test x$enable_gimp_console = xyes) -if test x$enable_gimp_console = xyes ; then - AC_MSG_WARN([--enable-gimp-console... are you nuts? -*** -*** --enable-gimp-console is for crazy hackers only! -*** The build will fail badly in the app/ directory. -*** You have been warned ;) -***]) -fi dnl Possibly change default gimpdir from .gimp-major.minor gimpdir=.gimp-gimp_user_version