Commit d37fb8aa authored by Ell's avatar Ell

app: split sanity check into early/late stages, to fix gegl translation

The GEGL ops sanity check causes all ops to be initialized.  The
strings used by their properties will pick the translation selected
at the time of the check.  It must therefore run after language
intiailization, otherwise the selected translation would correspond
to the system locale, even if the user selected a different language
in the preferences.

Split the sanity check into early and late stages.  The early stage
is run before the call to app_run(), as it did before, while the
late stage is run during app_run(), after the configuration has been
loaded.  Currently, the GEGL ops check is the only late-stage check;
all other checks are performed during the early stage.
parent 7bf04966
......@@ -64,6 +64,7 @@
#include "app.h"
#include "errors.h"
#include "language.h"
#include "sanity.h"
#include "gimp-debug.h"
#include "gimp-intl.h"
......@@ -179,6 +180,7 @@ app_run (const gchar *full_prog_name,
GMainLoop *run_loop;
GFile *default_folder = NULL;
GFile *gimpdir;
const gchar *abort_message;
if (filenames && filenames[0] && ! filenames[1] &&
g_file_test (filenames[0], G_FILE_TEST_IS_DIR))
......@@ -253,6 +255,13 @@ app_run (const gchar *full_prog_name,
/* change the locale if a language if specified */
language_init (gimp->config->language);
/* run the late-stage sanity check. it's important that this check is run
* after the call to language_init() (see comment in sanity_check_late().)
*/
abort_message = sanity_check_late ();
if (abort_message)
app_abort (no_interface, abort_message);
/* initialize lowlevel stuff */
gimp_gegl_init (gimp);
......
......@@ -536,7 +536,7 @@ main (int argc,
}
#endif
abort_message = sanity_check ();
abort_message = sanity_check_early ();
if (abort_message)
app_abort (no_interface, abort_message);
......
......@@ -33,6 +33,7 @@
#include "gimp-intl.h"
/* early-stage tests */
static gchar * sanity_check_gimp (void);
static gchar * sanity_check_glib (void);
static gchar * sanity_check_cairo (void);
......@@ -44,16 +45,22 @@ static gchar * sanity_check_lcms (void);
static gchar * sanity_check_gexiv2 (void);
static gchar * sanity_check_babl (void);
static gchar * sanity_check_gegl (void);
static gchar * sanity_check_gegl_ops (void);
static gchar * sanity_check_filename_encoding (void);
/* late-stage tests */
static gchar * sanity_check_gegl_ops (void);
/* public functions */
/* early-stage sanity check, performed before the call to app_run(). */
const gchar *
sanity_check (void)
sanity_check_early (void)
{
gchar *abort_message = sanity_check_gimp ();
gchar *abort_message = NULL;
if (! abort_message)
abort_message = sanity_check_gimp ();
if (! abort_message)
abort_message = sanity_check_glib ();
......@@ -86,10 +93,27 @@ sanity_check (void)
abort_message = sanity_check_gegl ();
if (! abort_message)
abort_message = sanity_check_gegl_ops ();
abort_message = sanity_check_filename_encoding ();
return abort_message;
}
/* late-stage sanity check, performed during app_run(), after the user
* configuration has been loaded.
*/
const gchar *
sanity_check_late (void)
{
gchar *abort_message = NULL;
/* the gegl ops test initializes all gegl ops; in particular, it initializes
* all the strings used by their properties, which appear in the ui. it
* must be run after we've called language_init(), potentially overriding
* LANGUAGE according to the user config, or else all affected strings would
* use the translation corresponding to the system locale, regardless.
*/
if (! abort_message)
abort_message = sanity_check_filename_encoding ();
abort_message = sanity_check_gegl_ops ();
return abort_message;
}
......@@ -97,6 +121,9 @@ sanity_check (void)
/* private functions */
/* early-stage tests */
static gboolean
sanity_check_version (guint major_version, guint required_major,
guint minor_version, guint required_minor,
......@@ -520,6 +547,58 @@ sanity_check_gegl (void)
return NULL;
}
static gchar *
sanity_check_filename_encoding (void)
{
gchar *result;
GError *error = NULL;
result = g_filename_to_utf8 ("", -1, NULL, NULL, &error);
if (! result)
{
gchar *msg =
g_strdup_printf
(_("The configured filename encoding cannot be converted to UTF-8: "
"%s\n\n"
"Please check the value of the environment variable "
"G_FILENAME_ENCODING."),
error->message);
g_error_free (error);
return msg;
}
g_free (result);
result = g_filename_to_utf8 (gimp_directory (), -1, NULL, NULL, &error);
if (! result)
{
gchar *msg =
g_strdup_printf
(_("The name of the directory holding the GIMP user configuration "
"cannot be converted to UTF-8: "
"%s\n\n"
"Your filesystem probably stores files in an encoding "
"other than UTF-8 and you didn't tell GLib about this. "
"Please set the environment variable G_FILENAME_ENCODING."),
error->message);
g_error_free (error);
return msg;
}
g_free (result);
return NULL;
}
/* late-stage tests */
static gchar *
sanity_check_gegl_ops (void)
{
......@@ -658,52 +737,3 @@ sanity_check_gegl_ops (void)
return NULL;
}
static gchar *
sanity_check_filename_encoding (void)
{
gchar *result;
GError *error = NULL;
result = g_filename_to_utf8 ("", -1, NULL, NULL, &error);
if (! result)
{
gchar *msg =
g_strdup_printf
(_("The configured filename encoding cannot be converted to UTF-8: "
"%s\n\n"
"Please check the value of the environment variable "
"G_FILENAME_ENCODING."),
error->message);
g_error_free (error);
return msg;
}
g_free (result);
result = g_filename_to_utf8 (gimp_directory (), -1, NULL, NULL, &error);
if (! result)
{
gchar *msg =
g_strdup_printf
(_("The name of the directory holding the GIMP user configuration "
"cannot be converted to UTF-8: "
"%s\n\n"
"Your filesystem probably stores files in an encoding "
"other than UTF-8 and you didn't tell GLib about this. "
"Please set the environment variable G_FILENAME_ENCODING."),
error->message);
g_error_free (error);
return msg;
}
g_free (result);
return NULL;
}
......@@ -23,7 +23,8 @@
#endif
const gchar * sanity_check (void);
const gchar * sanity_check_early (void);
const gchar * sanity_check_late (void);
#endif /* __SANITY_H__ */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment