[gimp] app: font loading output a GError.
- From: Jehan Pagès <jehanp src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] app: font loading output a GError.
- Date: Sun, 29 Apr 2018 17:48:01 +0000 (UTC)
commit 3de1f337023ced06cb4e3fff7a21f5c468ece191
Author: Jehan <jehan girinstud io>
Date: Sun Apr 29 19:07:04 2018 +0200
app: font loading output a GError.
This GError will either specify the font which failed to load (if
unique) or a vague message about fonts which fail to load.
Unfortunately right now, this message also goes to terminal because the
GUI is not ready yet.
app/text/gimp-fonts.c | 81 ++++++++++++++++++++++++++++++++++++++----------
1 files changed, 64 insertions(+), 17 deletions(-)
---
diff --git a/app/text/gimp-fonts.c b/app/text/gimp-fonts.c
index 450321b..9e4ecbd 100644
--- a/app/text/gimp-fonts.c
+++ b/app/text/gimp-fonts.c
@@ -36,16 +36,19 @@
#include "gimp-fonts.h"
#include "gimpfontlist.h"
+#include "gimp-intl.h"
#define CONF_FNAME "fonts.conf"
-static gboolean gimp_fonts_load_fonts_conf (FcConfig *config,
- GFile *fonts_conf);
-static void gimp_fonts_add_directories (FcConfig *config,
- GList *path);
-static void gimp_fonts_recursive_add_font (FcConfig *config,
- const gchar *path);
+static gboolean gimp_fonts_load_fonts_conf (FcConfig *config,
+ GFile *fonts_conf);
+static void gimp_fonts_add_directories (Gimp *gimp,
+ FcConfig *config,
+ GList *path);
+static void gimp_fonts_recursive_add_font (FcConfig *config,
+ const gchar *path,
+ GError **error);
void
@@ -146,7 +149,7 @@ gimp_fonts_load (Gimp *gimp,
goto cleanup;
path = gimp_config_path_expand_to_files (gimp->config->font_path, FALSE);
- gimp_fonts_add_directories (config, path);
+ gimp_fonts_add_directories (gimp, config, path);
g_list_free_full (path, (GDestroyNotify) g_object_unref);
if (status_callback)
@@ -230,10 +233,12 @@ gimp_fonts_load_fonts_conf (FcConfig *config,
}
static void
-gimp_fonts_add_directories (FcConfig *config,
- GList *path)
+gimp_fonts_add_directories (Gimp *gimp,
+ FcConfig *config,
+ GList *path)
{
- GList *list;
+ GList *list;
+ GError *error = NULL;
g_return_if_fail (config != NULL);
@@ -248,20 +253,29 @@ gimp_fonts_add_directories (FcConfig *config,
* the list, but are unusable and output many errors.
* See bug 748553.
*/
- gimp_fonts_recursive_add_font (config, dir);
+ gimp_fonts_recursive_add_font (config, dir, &error);
g_free (dir);
}
+ if (error)
+ {
+ gimp_message_literal (gimp, NULL,
+ GIMP_MESSAGE_INFO,
+ error->message);
+ g_error_free (error);
+ }
}
static void
-gimp_fonts_recursive_add_font (FcConfig *config,
- const gchar *path)
+gimp_fonts_recursive_add_font (FcConfig *config,
+ const gchar *path,
+ GError **error)
{
g_return_if_fail (config != NULL);
if (g_file_test (path, G_FILE_TEST_IS_DIR))
{
- GDir *gdir = g_dir_open (path, 0, NULL);
+ GError *dir_error = NULL;
+ GDir *gdir = g_dir_open (path, 0, &dir_error);
if (gdir)
{
@@ -272,7 +286,7 @@ gimp_fonts_recursive_add_font (FcConfig *config,
gchar *filename;
filename = g_build_filename (path, basename, NULL);
- gimp_fonts_recursive_add_font (config, filename);
+ gimp_fonts_recursive_add_font (config, filename, error);
g_free (filename);
}
g_dir_close (gdir);
@@ -281,6 +295,22 @@ gimp_fonts_recursive_add_font (FcConfig *config,
{
g_printerr ("%s: opening font directory '%s' failed.\n",
G_STRFUNC, path);
+ if (error)
+ {
+ if (*error)
+ {
+ g_clear_error (error);
+ g_set_error_literal (error, G_FILE_ERROR, G_FILE_ERROR_FAILED,
+ _("Some fonts failed to load."));
+ }
+ else
+ {
+ g_set_error (error, dir_error->domain, dir_error->code,
+ _("Opening font directory '%s' failed: %s"),
+ path, dir_error->message);
+ }
+ g_error_free (dir_error);
+ }
}
}
else
@@ -292,8 +322,25 @@ gimp_fonts_recursive_add_font (FcConfig *config,
#endif
if (FcFalse == FcConfigAppFontAddFile (config, (const FcChar8 *) filename))
- g_printerr ("%s: adding font file '%s' failed.\n",
- G_STRFUNC, filename);
+ {
+ g_printerr ("%s: adding font file '%s' failed.\n",
+ G_STRFUNC, filename);
+ if (error)
+ {
+ if (*error)
+ {
+ g_clear_error (error);
+ g_set_error_literal (error, G_FILE_ERROR, G_FILE_ERROR_FAILED,
+ _("Some fonts failed to load."));
+ }
+ else
+ {
+ g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_FAILED,
+ _("Loading font file '%s' failed."),
+ filename);
+ }
+ }
+ }
g_free (filename);
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]