app: popup error at startup when some fonts fail to load.
As proposed on IRC. This will allow people to debug their fonts (for instance when there are permission issues or whatnot) by knowing the list of problematic fonts in an error dialog at startup (and not only on terminal).
This commit is contained in:
@ -39,5 +39,5 @@ fonts_refresh_cmd_callback (GtkAction *action,
|
||||
GimpContext *context = action_data_get_context (data);
|
||||
|
||||
if (context)
|
||||
gimp_fonts_load (context->gimp, NULL);
|
||||
gimp_fonts_load (context->gimp, NULL, NULL);
|
||||
}
|
||||
|
14
app/app.c
14
app/app.c
@ -190,6 +190,7 @@ app_run (const gchar *full_prog_name,
|
||||
const gchar *abort_message;
|
||||
GimpLangRc *temprc;
|
||||
gchar *language = NULL;
|
||||
GError *font_error = NULL;
|
||||
|
||||
if (filenames && filenames[0] && ! filenames[1] &&
|
||||
g_file_test (filenames[0], G_FILE_TEST_IS_DIR))
|
||||
@ -326,7 +327,7 @@ app_run (const gchar *full_prog_name,
|
||||
|
||||
/* Load all data files
|
||||
*/
|
||||
gimp_restore (gimp, update_status_func);
|
||||
gimp_restore (gimp, update_status_func, &font_error);
|
||||
|
||||
/* enable autosave late so we don't autosave when the
|
||||
* monitor resolution is set in gui_init()
|
||||
@ -379,6 +380,10 @@ app_run (const gchar *full_prog_name,
|
||||
*/
|
||||
gimp_image_dirty (image, GIMP_DIRTY_IMAGE);
|
||||
}
|
||||
else
|
||||
{
|
||||
g_error_free (error);
|
||||
}
|
||||
|
||||
g_object_unref (file);
|
||||
}
|
||||
@ -411,6 +416,13 @@ app_run (const gchar *full_prog_name,
|
||||
}
|
||||
}
|
||||
}
|
||||
if (font_error)
|
||||
{
|
||||
gimp_message_literal (gimp, NULL,
|
||||
GIMP_MESSAGE_INFO,
|
||||
font_error->message);
|
||||
g_error_free (font_error);
|
||||
}
|
||||
|
||||
if (run_loop)
|
||||
gimp_batch_run (gimp, batch_interpreter, batch_commands);
|
||||
|
@ -769,9 +769,19 @@ gimp_initialize (Gimp *gimp,
|
||||
g_signal_emit (gimp, gimp_signals[INITIALIZE], 0, status_callback);
|
||||
}
|
||||
|
||||
/**
|
||||
* gimp_restore:
|
||||
* @gimp: a #Gimp object
|
||||
* @error: a #GError for uncessful loading.
|
||||
*
|
||||
* This function always succeeds. If present, @error may be filled for
|
||||
* possible feedback on data which failed to load. It doesn't imply any
|
||||
* fatale error.
|
||||
**/
|
||||
void
|
||||
gimp_restore (Gimp *gimp,
|
||||
GimpInitStatusFunc status_callback)
|
||||
GimpInitStatusFunc status_callback,
|
||||
GError **error)
|
||||
{
|
||||
g_return_if_fail (GIMP_IS_GIMP (gimp));
|
||||
g_return_if_fail (status_callback != NULL);
|
||||
@ -790,7 +800,7 @@ gimp_restore (Gimp *gimp,
|
||||
if (! gimp->no_fonts)
|
||||
{
|
||||
status_callback (NULL, _("Fonts (this may take a while)"), 0.7);
|
||||
gimp_fonts_load (gimp, status_callback);
|
||||
gimp_fonts_load (gimp, status_callback, error);
|
||||
}
|
||||
|
||||
/* initialize the template list */
|
||||
|
@ -175,7 +175,8 @@ void gimp_load_config (Gimp *gimp,
|
||||
void gimp_initialize (Gimp *gimp,
|
||||
GimpInitStatusFunc status_callback);
|
||||
void gimp_restore (Gimp *gimp,
|
||||
GimpInitStatusFunc status_callback);
|
||||
GimpInitStatusFunc status_callback,
|
||||
GError **error);
|
||||
gboolean gimp_is_restored (Gimp *gimp);
|
||||
|
||||
void gimp_exit (Gimp *gimp,
|
||||
|
@ -46,7 +46,7 @@ fonts_refresh_invoker (GimpProcedure *procedure,
|
||||
const GimpValueArray *args,
|
||||
GError **error)
|
||||
{
|
||||
gimp_fonts_load (gimp, NULL);
|
||||
gimp_fonts_load (gimp, NULL, error);
|
||||
|
||||
return gimp_procedure_get_return_values (procedure, TRUE, NULL);
|
||||
}
|
||||
|
@ -72,7 +72,7 @@ gimp_init_for_testing (void)
|
||||
|
||||
gimp_gegl_init (gimp);
|
||||
gimp_initialize (gimp, gimp_status_func_dummy);
|
||||
gimp_restore (gimp, gimp_status_func_dummy);
|
||||
gimp_restore (gimp, gimp_status_func_dummy, NULL);
|
||||
|
||||
return gimp;
|
||||
}
|
||||
@ -128,7 +128,7 @@ gimp_init_for_gui_testing_internal (gboolean show_gui,
|
||||
gui_init (gimp, TRUE);
|
||||
gimp_init_icon_theme_for_testing ();
|
||||
gimp_initialize (gimp, gimp_status_func_dummy);
|
||||
gimp_restore (gimp, gimp_status_func_dummy);
|
||||
gimp_restore (gimp, gimp_status_func_dummy, NULL);
|
||||
|
||||
return gimp;
|
||||
}
|
||||
|
@ -45,10 +45,14 @@ static gboolean gimp_fonts_load_fonts_conf (FcConfig *config,
|
||||
GFile *fonts_conf);
|
||||
static void gimp_fonts_add_directories (Gimp *gimp,
|
||||
FcConfig *config,
|
||||
GList *path);
|
||||
GList *path,
|
||||
GError **error);
|
||||
static void gimp_fonts_recursive_add_fontdir (FcConfig *config,
|
||||
GFile *path,
|
||||
GError **error);
|
||||
static void gimp_fonts_notify_font_path (GObject *gobject,
|
||||
GParamSpec *pspec,
|
||||
Gimp *gimp);
|
||||
|
||||
|
||||
void
|
||||
@ -65,8 +69,8 @@ gimp_fonts_set_config (Gimp *gimp)
|
||||
{
|
||||
g_return_if_fail (GIMP_IS_GIMP (gimp));
|
||||
|
||||
g_signal_connect_swapped (gimp->config, "notify::font-path",
|
||||
G_CALLBACK (gimp_fonts_load),
|
||||
g_signal_connect (gimp->config, "notify::font-path",
|
||||
G_CALLBACK (gimp_fonts_notify_font_path),
|
||||
gimp);
|
||||
}
|
||||
|
||||
@ -79,7 +83,7 @@ gimp_fonts_exit (Gimp *gimp)
|
||||
{
|
||||
if (gimp->config)
|
||||
g_signal_handlers_disconnect_by_func (gimp->config,
|
||||
G_CALLBACK (gimp_fonts_load),
|
||||
G_CALLBACK (gimp_fonts_notify_font_path),
|
||||
gimp);
|
||||
|
||||
g_clear_object (&gimp->fonts);
|
||||
@ -118,7 +122,8 @@ gimp_fonts_load_thread (GimpFontsLoadFuncData *data)
|
||||
|
||||
void
|
||||
gimp_fonts_load (Gimp *gimp,
|
||||
GimpInitStatusFunc status_callback)
|
||||
GimpInitStatusFunc status_callback,
|
||||
GError **error)
|
||||
{
|
||||
FcConfig *config;
|
||||
GFile *fonts_conf;
|
||||
@ -149,7 +154,7 @@ gimp_fonts_load (Gimp *gimp,
|
||||
goto cleanup;
|
||||
|
||||
path = gimp_config_path_expand_to_files (gimp->config->font_path, FALSE);
|
||||
gimp_fonts_add_directories (gimp, config, path);
|
||||
gimp_fonts_add_directories (gimp, config, path, error);
|
||||
g_list_free_full (path, (GDestroyNotify) g_object_unref);
|
||||
|
||||
if (status_callback)
|
||||
@ -235,10 +240,10 @@ gimp_fonts_load_fonts_conf (FcConfig *config,
|
||||
static void
|
||||
gimp_fonts_add_directories (Gimp *gimp,
|
||||
FcConfig *config,
|
||||
GList *path)
|
||||
GList *path,
|
||||
GError **error)
|
||||
{
|
||||
GList *list;
|
||||
GError *error = NULL;
|
||||
|
||||
g_return_if_fail (config != NULL);
|
||||
|
||||
@ -251,14 +256,16 @@ gimp_fonts_add_directories (Gimp *gimp,
|
||||
* the list, but are unusable and output many errors.
|
||||
* See bug 748553.
|
||||
*/
|
||||
gimp_fonts_recursive_add_fontdir (config, list->data, &error);
|
||||
gimp_fonts_recursive_add_fontdir (config, list->data, error);
|
||||
}
|
||||
if (error)
|
||||
if (error && *error)
|
||||
{
|
||||
gimp_message_literal (gimp, NULL,
|
||||
GIMP_MESSAGE_INFO,
|
||||
error->message);
|
||||
g_error_free (error);
|
||||
gchar *font_list = g_strdup ((*error)->message);
|
||||
|
||||
g_clear_error (error);
|
||||
g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_FAILED,
|
||||
_("Some fonts failed to load:\n%s"), font_list);
|
||||
g_free (font_list);
|
||||
}
|
||||
}
|
||||
|
||||
@ -323,15 +330,17 @@ gimp_fonts_recursive_add_fontdir (FcConfig *config,
|
||||
{
|
||||
if (*error)
|
||||
{
|
||||
gchar *current_message = g_strdup ((*error)->message);
|
||||
|
||||
g_clear_error (error);
|
||||
g_set_error_literal (error, G_FILE_ERROR, G_FILE_ERROR_FAILED,
|
||||
_("Some fonts failed to load."));
|
||||
g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_FAILED,
|
||||
"%s\n- %s", current_message, path);
|
||||
g_free (current_message);
|
||||
}
|
||||
else
|
||||
{
|
||||
g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_FAILED,
|
||||
_("Loading font file '%s' failed."),
|
||||
path);
|
||||
"- %s", path);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -342,4 +351,46 @@ gimp_fonts_recursive_add_fontdir (FcConfig *config,
|
||||
g_object_unref (info);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (error)
|
||||
{
|
||||
gchar *path = g_file_get_path (file);
|
||||
|
||||
if (*error)
|
||||
{
|
||||
gchar *current_message = g_strdup ((*error)->message);
|
||||
|
||||
g_clear_error (error);
|
||||
g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_FAILED,
|
||||
"%s\n- %s%s", current_message, path,
|
||||
G_DIR_SEPARATOR_S);
|
||||
g_free (current_message);
|
||||
}
|
||||
else
|
||||
{
|
||||
g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_FAILED,
|
||||
"- %s%s", path, G_DIR_SEPARATOR_S);
|
||||
}
|
||||
g_free (path);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_fonts_notify_font_path (GObject *gobject,
|
||||
GParamSpec *pspec,
|
||||
Gimp *gimp)
|
||||
{
|
||||
GError *error = NULL;
|
||||
|
||||
gimp_fonts_load (gimp, NULL, &error);
|
||||
|
||||
if (error)
|
||||
{
|
||||
gimp_message_literal (gimp, NULL,
|
||||
GIMP_MESSAGE_INFO,
|
||||
error->message);
|
||||
g_error_free (error);
|
||||
}
|
||||
}
|
||||
|
@ -24,7 +24,8 @@ void gimp_fonts_set_config (Gimp *gimp);
|
||||
void gimp_fonts_exit (Gimp *gimp);
|
||||
|
||||
void gimp_fonts_load (Gimp *gimp,
|
||||
GimpInitStatusFunc status_callback);
|
||||
GimpInitStatusFunc status_callback,
|
||||
GError **error);
|
||||
void gimp_fonts_reset (Gimp *gimp);
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user