diff --git a/ChangeLog b/ChangeLog index f3587913d8..46250180ed 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,23 @@ 2004-03-30 Michael Natterer - * configure.in (ALL_LINGUAS): revert addition on "pa" until + * app/Makefile.am + * app/sanity.[ch]: new files implementing sanity_check() for + run-time checking library versions. Added a check for FreeType but + disabled it until we figured if and how freetype causes some of + the DLL hell bugs. + + * app/main.c (main): call it and abort if it fails. + + * app/app_procs.[ch]: added app_gui_abort() so main.c doesn't + need to #include "gui/gui.h" + + * app/gui/gui.[ch] (gui_libs_init): removed library sanity checking. + + (gui_abort): new function which shows the abort message. + +2004-03-30 Michael Natterer + + * configure.in (ALL_LINGUAS): revert addition of "pa" until all .po files are there. 2004-03-20 Guntupalli Karunakar diff --git a/app/Makefile.am b/app/Makefile.am index dca79fcd73..98c8820d20 100644 --- a/app/Makefile.am +++ b/app/Makefile.am @@ -41,6 +41,8 @@ gimp_2_0_SOURCES = \ batch.h \ errors.c \ errors.h \ + sanity.c \ + sanity.h \ units.c \ units.h \ gimp-intl.h diff --git a/app/app_procs.c b/app/app_procs.c index 53607272f4..b9658f0c29 100644 --- a/app/app_procs.c +++ b/app/app_procs.c @@ -77,6 +77,12 @@ app_gui_libs_init (gint *argc, return gui_libs_init (argc, argv); } +void +app_gui_abort (const gchar *abort_message) +{ + gui_abort (abort_message); +} + void app_run (const gchar *full_prog_name, gint gimp_argc, diff --git a/app/app_procs.h b/app/app_procs.h index 64f5290843..829803a6e0 100644 --- a/app/app_procs.h +++ b/app/app_procs.h @@ -25,8 +25,9 @@ #endif -gboolean app_gui_libs_init (gint *gimp_argc, - gchar ***gimp_argv); +gboolean app_gui_libs_init (gint *gimp_argc, + gchar ***gimp_argv); +void app_gui_abort (const gchar *abort_message); void app_run (const gchar *full_prog_name, gint gimp_argc, diff --git a/app/gui/gui.c b/app/gui/gui.c index c5a74f5713..8571e7201b 100644 --- a/app/gui/gui.c +++ b/app/gui/gui.c @@ -21,7 +21,6 @@ #include #include -#include #include "libgimpbase/gimpbase.h" #include "libgimpwidgets/gimpwidgets.h" @@ -119,12 +118,10 @@ gboolean gui_libs_init (gint *argc, gchar ***argv) { - gchar *abort_message = NULL; - g_return_val_if_fail (argc != NULL, FALSE); g_return_val_if_fail (argv != NULL, FALSE); - if (!gtk_init_check (argc, argv)) + if (! gtk_init_check (argc, argv)) return FALSE; gimp_widgets_init (gui_help_func, @@ -134,86 +131,19 @@ gui_libs_init (gint *argc, g_type_class_ref (GIMP_TYPE_COLOR_SELECT); - if (! abort_message) - { - const gchar *mismatch; - -#define GTK_REQUIRED_MAJOR 2 -#define GTK_REQUIRED_MINOR 2 -#define GTK_REQUIRED_MICRO 2 - - mismatch = gtk_check_version (GTK_REQUIRED_MAJOR, - GTK_REQUIRED_MINOR, - GTK_REQUIRED_MICRO); - - if (mismatch) - { - abort_message = - g_strdup_printf - ("%s\n\n" - "The GIMP requires Gtk+ version %d.%d.%d or later.\n" - "Installed Gtk+ version is %d.%d.%d.\n\n" - "Somehow you or your software packager managed\n" - "to install The GIMP with an older Gtk+ version.\n\n" - "Please upgrade to Gtk+ version %d.%d.%d or later.", - mismatch, - GTK_REQUIRED_MAJOR, GTK_REQUIRED_MINOR, GTK_REQUIRED_MICRO, - gtk_major_version, gtk_minor_version, gtk_micro_version, - GTK_REQUIRED_MAJOR, GTK_REQUIRED_MINOR, GTK_REQUIRED_MICRO); - } - -#undef GTK_REQUIRED_MAJOR -#undef GTK_REQUIRED_MINOR -#undef GTK_REQUIRED_MICRO - } - - if (! abort_message) - { - gint fc_version = FcGetVersion (); - gint fc_major_version = fc_version / 100 / 100; - gint fc_minor_version = fc_version / 100 % 100; - gint fc_micro_version = fc_version % 100; - -#define FC_REQUIRED_MAJOR 2 -#define FC_REQUIRED_MINOR 2 -#define FC_REQUIRED_MICRO 0 - - if (fc_version < ((FC_REQUIRED_MAJOR * 10000) + - (FC_REQUIRED_MINOR * 100) + - (FC_REQUIRED_MICRO * 1))) - { - abort_message = - g_strdup_printf - ("Fontconfig version too old!\n\n" - "The GIMP requires fontconfig version %d.%d.%d or later.\n" - "Installed fontconfig version is %d.%d.%d.\n\n" - "Somehow you or your software packager managed\n" - "to install The GIMP with an older fontconfig version.\n\n" - "Please upgrade to fontconfig version %d.%d.%d or later.", - FC_REQUIRED_MAJOR, FC_REQUIRED_MINOR, FC_REQUIRED_MICRO, - fc_major_version, fc_minor_version, fc_micro_version, - FC_REQUIRED_MAJOR, FC_REQUIRED_MINOR, FC_REQUIRED_MICRO); - } - -#undef FC_REQUIRED_MAJOR -#undef FC_REQUIRED_MINOR -#undef FC_REQUIRED_MICRO - } - - if (abort_message) - { - gimp_message_box (GIMP_STOCK_WILBER_EEK, NULL, abort_message, - (GtkCallback) gtk_main_quit, NULL); - - g_free (abort_message); - - gtk_main (); - exit (EXIT_FAILURE); - } - return TRUE; } +void +gui_abort (const gchar *abort_message) +{ + g_return_if_fail (abort_message != NULL); + + gimp_message_box (GIMP_STOCK_WILBER_EEK, NULL, abort_message, + (GtkCallback) gtk_main_quit, NULL); + gtk_main (); +} + GimpInitStatusFunc gui_init (Gimp *gimp, gboolean no_splash) diff --git a/app/gui/gui.h b/app/gui/gui.h index c55af9dba2..a83e6090c4 100644 --- a/app/gui/gui.h +++ b/app/gui/gui.h @@ -20,12 +20,13 @@ #define __GUI_H__ -gboolean gui_libs_init (gint *argc, - gchar ***argv); +gboolean gui_libs_init (gint *argc, + gchar ***argv); +void gui_abort (const gchar *abort_message); -GimpInitStatusFunc gui_init (Gimp *gimp, - gboolean no_spash); -void gui_post_init (Gimp *gimp); +GimpInitStatusFunc gui_init (Gimp *gimp, + gboolean no_spash); +void gui_post_init (Gimp *gimp); #endif /* __GUI_H__ */ diff --git a/app/main.c b/app/main.c index 4bc8e8db67..78c66c8a40 100644 --- a/app/main.c +++ b/app/main.c @@ -49,6 +49,7 @@ #include "app_procs.h" #include "errors.h" +#include "sanity.h" #include "units.h" #include "gimp-intl.h" @@ -91,6 +92,7 @@ int main (int argc, char **argv) { + const gchar *abort_message = NULL; gchar *full_prog_name = NULL; gchar *alternate_system_gimprc = NULL; gchar *alternate_gimprc = NULL; @@ -220,6 +222,18 @@ main (int argc, gimp_text_console_exit (EXIT_FAILURE); } + abort_message = sanity_check (no_interface); + + if (abort_message) + { + if (no_interface) + g_print ("%s\n\n", abort_message); + else + app_gui_abort (abort_message); + + exit (EXIT_FAILURE); + } + g_set_application_name (_("The GIMP")); #if defined (USE_SYSV_SHM) || defined (USE_POSIX_SHM) || defined (G_OS_WIN32) diff --git a/app/sanity.c b/app/sanity.c new file mode 100644 index 0000000000..13e896fbb3 --- /dev/null +++ b/app/sanity.c @@ -0,0 +1,161 @@ +/* The GIMP -- an image manipulation program + * Copyright (C) 1995 Spencer Kimball and Peter Mattis + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +#include "config.h" + +#include +#include +#include + +#include "sanity.h" + + +const gchar * +sanity_check (gboolean no_interface) +{ + gchar *abort_message = NULL; + + if (! no_interface) + { + const gchar *mismatch; + +#define GTK_REQUIRED_MAJOR 2 +#define GTK_REQUIRED_MINOR 2 +#define GTK_REQUIRED_MICRO 2 + + mismatch = gtk_check_version (GTK_REQUIRED_MAJOR, + GTK_REQUIRED_MINOR, + GTK_REQUIRED_MICRO); + + if (mismatch) + { + abort_message = + g_strdup_printf + ("%s\n\n" + "The GIMP requires Gtk+ version %d.%d.%d or later.\n" + "Installed Gtk+ version is %d.%d.%d.\n\n" + "Somehow you or your software packager managed\n" + "to install The GIMP with an older Gtk+ version.\n\n" + "Please upgrade to Gtk+ version %d.%d.%d or later.", + mismatch, + GTK_REQUIRED_MAJOR, GTK_REQUIRED_MINOR, GTK_REQUIRED_MICRO, + gtk_major_version, gtk_minor_version, gtk_micro_version, + GTK_REQUIRED_MAJOR, GTK_REQUIRED_MINOR, GTK_REQUIRED_MICRO); + } + +#undef GTK_REQUIRED_MAJOR +#undef GTK_REQUIRED_MINOR +#undef GTK_REQUIRED_MICRO + } + + if (! abort_message) + { + gint fc_version = FcGetVersion (); + gint fc_major_version = fc_version / 100 / 100; + gint fc_minor_version = fc_version / 100 % 100; + gint fc_micro_version = fc_version % 100; + +#define FC_REQUIRED_MAJOR 2 +#define FC_REQUIRED_MINOR 2 +#define FC_REQUIRED_MICRO 0 + + if (fc_version < ((FC_REQUIRED_MAJOR * 10000) + + (FC_REQUIRED_MINOR * 100) + + (FC_REQUIRED_MICRO * 1))) + { + abort_message = + g_strdup_printf + ("Fontconfig version too old!\n\n" + "The GIMP requires fontconfig version %d.%d.%d or later.\n" + "Installed fontconfig version is %d.%d.%d.\n\n" + "Somehow you or your software packager managed\n" + "to install The GIMP with an older fontconfig version.\n\n" + "Please upgrade to fontconfig version %d.%d.%d or later.", + FC_REQUIRED_MAJOR, FC_REQUIRED_MINOR, FC_REQUIRED_MICRO, + fc_major_version, fc_minor_version, fc_micro_version, + FC_REQUIRED_MAJOR, FC_REQUIRED_MINOR, FC_REQUIRED_MICRO); + } + +#undef FC_REQUIRED_MAJOR +#undef FC_REQUIRED_MINOR +#undef FC_REQUIRED_MICRO + } + +#if 0 + /* disabled until we definitely figured if and how freetype causes + * some of these windows dll hell bugs + */ + if (! abort_message) + { + FT_Library ft_library; + FT_Int ft_major_version; + FT_Int ft_minor_version; + FT_Int ft_micro_version; + FT_Int ft_version; + +#ifdef G_OS_WIN32 +#define FT_REQUIRED_MAJOR 2 +#define FT_REQUIRED_MINOR 1 +#define FT_REQUIRED_MICRO 7 +#else +#define FT_REQUIRED_MAJOR 2 +#define FT_REQUIRED_MINOR 1 +#define FT_REQUIRED_MICRO 7 +#endif + + if (FT_Init_FreeType (&ft_library) != 0) + g_error ("FT_Init_FreeType() failed"); + + FT_Library_Version (ft_library, + &ft_major_version, + &ft_minor_version, + &ft_micro_version); + + if (FT_Done_FreeType (ft_library) != 0) + g_error ("FT_Done_FreeType() failed"); + + ft_version = (ft_major_version * 10000 + + ft_minor_version * 100 + + ft_micro_version * 1); + + if (ft_version < ((FT_REQUIRED_MAJOR * 10000) + + (FT_REQUIRED_MINOR * 100) + + (FT_REQUIRED_MICRO * 1))) + { + abort_message = + g_strdup_printf + ("FreeType version too old!\n\n" + "The GIMP requires FreeType version %d.%d.%d or later.\n" + "Installed FreeType version is %d.%d.%d.\n\n" + "Somehow you or your software packager managed\n" + "to install The GIMP with an older FreeType version.\n\n" + "Please upgrade to FreeType version %d.%d.%d or later.", + FT_REQUIRED_MAJOR, FT_REQUIRED_MINOR, FT_REQUIRED_MICRO, + ft_major_version, ft_minor_version, ft_micro_version, + FT_REQUIRED_MAJOR, FT_REQUIRED_MINOR, FT_REQUIRED_MICRO); + } + + +#undef FT_REQUIRED_MAJOR +#undef FT_REQUIRED_MINOR +#undef FT_REQUIRED_MICRO + } +#endif + + return abort_message; +} diff --git a/app/sanity.h b/app/sanity.h new file mode 100644 index 0000000000..6cacf5b402 --- /dev/null +++ b/app/sanity.h @@ -0,0 +1,30 @@ +/* The GIMP -- an image manipulation program + * Copyright (C) 1995 Spencer Kimball and Peter Mattis + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +#ifndef __SANITY_H__ +#define __SANITY_H__ + +#ifndef GIMP_APP_GLUE_COMPILATION +#error You must not #include "sanity.h" from an app/ subdir +#endif + + +const gchar * sanity_check (gboolean no_interface); + + +#endif /* __SANITY_H__ */