Commit e88fb8e9 authored by Michael Natterer's avatar Michael Natterer 😴

app: remove all old font management code, switch to GimpFontFactory[View]

Biggest change in this commit is reordering stuff in GimpContext
because GimpFont is now a first class citizen.
parent d153c748
......@@ -98,8 +98,6 @@ libappactions_a_SOURCES = \
filters-commands.h \
fonts-actions.c \
fonts-actions.h \
fonts-commands.c \
fonts-commands.h \
gradient-editor-actions.c \
gradient-editor-actions.h \
gradient-editor-commands.c \
......
......@@ -482,7 +482,7 @@ context_font_select_cmd_callback (GtkAction *action,
return_if_no_context (context, data);
context_select_object ((GimpActionSelectType) value,
context, context->gimp->fonts);
context, gimp_data_factory_get_container (context->gimp->font_factory));
}
void
......
......@@ -32,8 +32,8 @@
#include "widgets/gimphelp-ids.h"
#include "actions.h"
#include "data-commands.h"
#include "fonts-actions.h"
#include "fonts-commands.h"
#include "gimp-intl.h"
......@@ -47,7 +47,7 @@ static const GimpActionEntry fonts_actions[] =
{ "fonts-refresh", GIMP_ICON_VIEW_REFRESH,
NC_("fonts-action", "_Rescan Font List"), NULL,
NC_("fonts-action", "Rescan the installed fonts"),
G_CALLBACK (fonts_refresh_cmd_callback),
G_CALLBACK (data_refresh_cmd_callback),
GIMP_HELP_FONT_REFRESH }
};
......
/* GIMP - The GNU 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 3 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, see <http://www.gnu.org/licenses/>.
*/
#include "config.h"
#include <gegl.h>
#include <gtk/gtk.h>
#include "actions-types.h"
#include "core/gimpcontext.h"
#include "text/gimp-fonts.h"
#include "actions.h"
#include "fonts-commands.h"
/* public functions */
void
fonts_refresh_cmd_callback (GtkAction *action,
gpointer data)
{
GimpContext *context = action_data_get_context (data);
if (context)
gimp_fonts_load (context->gimp, NULL);
}
/* GIMP - The GNU 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 3 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, see <http://www.gnu.org/licenses/>.
*/
#ifndef __FONTS_COMMANDS_H__
#define __FONTS_COMMANDS_H__
void fonts_refresh_cmd_callback (GtkAction *action,
gpointer data);
#endif /* __FONTS_COMMANDS_H__ */
......@@ -42,7 +42,6 @@
#include "widgets/gimpbufferview.h"
#include "widgets/gimpcontainerview.h"
#include "widgets/gimpdatafactoryview.h"
#include "widgets/gimpfontview.h"
#include "widgets/gimphelp-ids.h"
#include "widgets/gimpimageeditor.h"
#include "widgets/gimpitemtreeview.h"
......@@ -86,7 +85,6 @@ plug_in_run_cmd_callback (GtkAction *action,
case GIMP_PLUGIN:
case GIMP_TEMPORARY:
if (GIMP_IS_DATA_FACTORY_VIEW (data) ||
GIMP_IS_FONT_VIEW (data) ||
GIMP_IS_BUFFER_VIEW (data))
{
GimpContainerEditor *editor = GIMP_CONTAINER_EDITOR (data);
......
......@@ -584,8 +584,8 @@ typedef enum /*< pdb-skip, skip >*/
GIMP_CONTEXT_PROP_PATTERN = 13,
GIMP_CONTEXT_PROP_GRADIENT = 14,
GIMP_CONTEXT_PROP_PALETTE = 15,
GIMP_CONTEXT_PROP_TOOL_PRESET = 16,
GIMP_CONTEXT_PROP_FONT = 17,
GIMP_CONTEXT_PROP_FONT = 16,
GIMP_CONTEXT_PROP_TOOL_PRESET = 17,
GIMP_CONTEXT_PROP_BUFFER = 18,
GIMP_CONTEXT_PROP_IMAGEFILE = 19,
GIMP_CONTEXT_PROP_TEMPLATE = 20,
......@@ -610,8 +610,8 @@ typedef enum /*< pdb-skip, skip >*/
GIMP_CONTEXT_PROP_MASK_PATTERN = 1 << 13,
GIMP_CONTEXT_PROP_MASK_GRADIENT = 1 << 14,
GIMP_CONTEXT_PROP_MASK_PALETTE = 1 << 15,
GIMP_CONTEXT_PROP_MASK_TOOL_PRESET = 1 << 16,
GIMP_CONTEXT_PROP_MASK_FONT = 1 << 17,
GIMP_CONTEXT_PROP_MASK_FONT = 1 << 16,
GIMP_CONTEXT_PROP_MASK_TOOL_PRESET = 1 << 17,
GIMP_CONTEXT_PROP_MASK_BUFFER = 1 << 18,
GIMP_CONTEXT_PROP_MASK_IMAGEFILE = 1 << 19,
GIMP_CONTEXT_PROP_MASK_TEMPLATE = 1 << 20,
......
......@@ -54,6 +54,8 @@
#include "gimptoolpreset.h"
#include "gimptoolpreset-load.h"
#include "text/gimpfontfactory.h"
#include "gimp-intl.h"
......@@ -170,6 +172,12 @@ gimp_data_factories_init (Gimp *gimp)
gimp_object_set_static_name (GIMP_OBJECT (gimp->palette_factory),
"palette factory");
gimp->font_factory =
gimp_font_factory_new (gimp,
"font-path");
gimp_object_set_static_name (GIMP_OBJECT (gimp->font_factory),
"font factory");
gimp->tool_preset_factory =
gimp_data_factory_new (gimp,
GIMP_TYPE_TOOL_PRESET,
......@@ -241,6 +249,9 @@ gimp_data_factories_clear (Gimp *gimp)
if (gimp->palette_factory)
gimp_data_factory_data_free (gimp->palette_factory);
if (gimp->font_factory)
gimp_data_factory_data_free (gimp->font_factory);
if (gimp->tool_preset_factory)
gimp_data_factory_data_free (gimp->tool_preset_factory);
}
......@@ -256,6 +267,7 @@ gimp_data_factories_exit (Gimp *gimp)
g_clear_object (&gimp->pattern_factory);
g_clear_object (&gimp->gradient_factory);
g_clear_object (&gimp->palette_factory);
g_clear_object (&gimp->font_factory);
g_clear_object (&gimp->tool_preset_factory);
g_clear_object (&gimp->tag_cache);
}
......@@ -270,8 +282,6 @@ gimp_data_factories_get_memsize (Gimp *gimp,
memsize += gimp_object_get_memsize (GIMP_OBJECT (gimp->named_buffers),
gui_size);
memsize += gimp_object_get_memsize (GIMP_OBJECT (gimp->fonts),
gui_size);
memsize += gimp_object_get_memsize (GIMP_OBJECT (gimp->brush_factory),
gui_size);
memsize += gimp_object_get_memsize (GIMP_OBJECT (gimp->dynamics_factory),
......@@ -284,6 +294,8 @@ gimp_data_factories_get_memsize (Gimp *gimp,
gui_size);
memsize += gimp_object_get_memsize (GIMP_OBJECT (gimp->palette_factory),
gui_size);
memsize += gimp_object_get_memsize (GIMP_OBJECT (gimp->font_factory),
gui_size);
memsize += gimp_object_get_memsize (GIMP_OBJECT (gimp->tool_preset_factory),
gui_size);
......@@ -302,8 +314,9 @@ gimp_data_factories_data_clean (Gimp *gimp)
gimp_data_factory_data_clean (gimp->dynamics_factory);
gimp_data_factory_data_clean (gimp->mybrush_factory);
gimp_data_factory_data_clean (gimp->pattern_factory);
gimp_data_factory_data_clean (gimp->palette_factory);
gimp_data_factory_data_clean (gimp->gradient_factory);
gimp_data_factory_data_clean (gimp->palette_factory);
gimp_data_factory_data_clean (gimp->font_factory);
gimp_data_factory_data_clean (gimp->tool_preset_factory);
}
......@@ -347,16 +360,21 @@ gimp_data_factories_load (Gimp *gimp,
status_callback (NULL, _("Color History"), 0.55);
gimp_palettes_load (gimp);
/* initialize the list of gimp fonts */
status_callback (NULL, _("Fonts"), 0.6);
gimp_data_factory_data_init (gimp->font_factory, gimp->user_context,
gimp->no_fonts);
/* initialize the list of gimp tool presets if we have a GUI */
if (! gimp->no_interface)
{
status_callback (NULL, _("Tool Presets"), 0.6);
status_callback (NULL, _("Tool Presets"), 0.7);
gimp_data_factory_data_init (gimp->tool_preset_factory, gimp->user_context,
gimp->no_data);
}
/* update tag cache */
status_callback (NULL, _("Updating tag cache"), 0.65);
status_callback (NULL, _("Updating tag cache"), 0.75);
gimp_tag_cache_load (gimp->tag_cache);
gimp_tag_cache_add_container (gimp->tag_cache,
gimp_data_factory_get_container (gimp->brush_factory));
......@@ -370,6 +388,8 @@ gimp_data_factories_load (Gimp *gimp,
gimp_data_factory_get_container (gimp->gradient_factory));
gimp_tag_cache_add_container (gimp->tag_cache,
gimp_data_factory_get_container (gimp->palette_factory));
gimp_tag_cache_add_container (gimp->tag_cache,
gimp_data_factory_get_container (gimp->font_factory));
gimp_tag_cache_add_container (gimp->tag_cache,
gimp_data_factory_get_container (gimp->tool_preset_factory));
}
......@@ -387,6 +407,7 @@ gimp_data_factories_save (Gimp *gimp)
gimp_data_factory_data_save (gimp->pattern_factory);
gimp_data_factory_data_save (gimp->gradient_factory);
gimp_data_factory_data_save (gimp->palette_factory);
gimp_data_factory_data_save (gimp->font_factory);
gimp_data_factory_data_save (gimp->tool_preset_factory);
gimp_palettes_save (gimp);
......
......@@ -40,8 +40,6 @@
#include "paint/gimp-paint.h"
#include "text/gimp-fonts.h"
#include "xcf/xcf.h"
#include "gimp.h"
......@@ -254,8 +252,6 @@ gimp_init (Gimp *gimp)
gimp_object_set_static_name (GIMP_OBJECT (gimp->named_buffers),
"named buffers");
gimp_fonts_init (gimp);
gimp_data_factories_init (gimp);
gimp->tool_info_list = g_object_new (GIMP_TYPE_LIST,
......@@ -393,8 +389,6 @@ gimp_finalize (GObject *object)
gimp_data_factories_exit (gimp);
gimp_fonts_exit (gimp);
g_clear_object (&gimp->named_buffers);
g_clear_object (&gimp->clipboard_buffer);
g_clear_object (&gimp->clipboard_image);
......@@ -507,8 +501,6 @@ gimp_real_initialize (Gimp *gimp,
status_callback (_("Initialization"), NULL, 0.0);
gimp_fonts_set_config (gimp);
/* set the last values used to default values */
gimp->image_new_last_template =
gimp_config_duplicate (GIMP_CONFIG (gimp->config->default_image));
......@@ -555,8 +547,6 @@ gimp_real_exit (Gimp *gimp,
gimp_data_factories_save (gimp);
gimp_fonts_reset (gimp);
gimp_templates_save (gimp);
gimp_parasiterc_save (gimp);
gimp_unitrc_save (gimp);
......@@ -796,13 +786,6 @@ gimp_restore (Gimp *gimp,
/* initialize the lists of gimp brushes, dynamics, patterns etc. */
gimp_data_factories_load (gimp, status_callback);
/* initialize the list of fonts */
if (! gimp->no_fonts)
{
status_callback (NULL, _("Fonts"), 0.7);
gimp_fonts_load (gimp, error);
}
/* initialize the template list */
status_callback (NULL, _("Templates"), 0.8);
gimp_templates_load (gimp);
......
......@@ -94,15 +94,13 @@ struct _Gimp
GimpBuffer *clipboard_buffer;
GimpContainer *named_buffers;
GimpContainer *fonts;
GimpAsyncSet *fonts_async_set;
GimpDataFactory *brush_factory;
GimpDataFactory *dynamics_factory;
GimpDataFactory *mybrush_factory;
GimpDataFactory *pattern_factory;
GimpDataFactory *gradient_factory;
GimpDataFactory *palette_factory;
GimpDataFactory *font_factory;
GimpDataFactory *tool_preset_factory;
GimpTagCache *tag_cache;
......
This diff is collapsed.
......@@ -88,12 +88,12 @@ struct _GimpContext
GimpPalette *palette;
gchar *palette_name;
GimpToolPreset *tool_preset;
gchar *tool_preset_name;
GimpFont *font;
gchar *font_name;
GimpToolPreset *tool_preset;
gchar *tool_preset_name;
GimpBuffer *buffer;
gchar *buffer_name;
......@@ -138,10 +138,10 @@ struct _GimpContextClass
GimpGradient *gradient);
void (* palette_changed) (GimpContext *context,
GimpPalette *palette);
void (* tool_preset_changed)(GimpContext *context,
GimpToolPreset *tool_preset);
void (* font_changed) (GimpContext *context,
GimpFont *font);
void (* tool_preset_changed)(GimpContext *context,
GimpToolPreset *tool_preset);
void (* buffer_changed) (GimpContext *context,
GimpBuffer *buffer);
void (* imagefile_changed) (GimpContext *context,
......@@ -319,13 +319,6 @@ void gimp_context_set_palette (GimpContext *context,
void gimp_context_palette_changed (GimpContext *context);
/* tool_preset */
GimpToolPreset * gimp_context_get_tool_preset (GimpContext *context);
void gimp_context_set_tool_preset (GimpContext *context,
GimpToolPreset *tool_preset);
void gimp_context_tool_preset_changed (GimpContext *context);
/* font */
GimpFont * gimp_context_get_font (GimpContext *context);
void gimp_context_set_font (GimpContext *context,
......@@ -336,6 +329,13 @@ void gimp_context_set_font_name (GimpContext *context,
void gimp_context_font_changed (GimpContext *context);
/* tool_preset */
GimpToolPreset * gimp_context_get_tool_preset (GimpContext *context);
void gimp_context_set_tool_preset (GimpContext *context,
GimpToolPreset *tool_preset);
void gimp_context_tool_preset_changed (GimpContext *context);
/* buffer */
GimpBuffer * gimp_context_get_buffer (GimpContext *context);
void gimp_context_set_buffer (GimpContext *context,
......
......@@ -45,7 +45,7 @@
#include "widgets/gimpdynamicsfactoryview.h"
#include "widgets/gimperrorconsole.h"
#include "widgets/gimperrordialog.h"
#include "widgets/gimpfontview.h"
#include "widgets/gimpfontfactoryview.h"
#include "widgets/gimpgradienteditor.h"
#include "widgets/gimphistogrameditor.h"
#include "widgets/gimpimageview.h"
......@@ -475,11 +475,11 @@ dialogs_font_list_view_new (GimpDialogFactory *factory,
GimpUIManager *ui_manager,
gint view_size)
{
return gimp_font_view_new (GIMP_VIEW_TYPE_LIST,
context->gimp->fonts,
context,
view_size, 1,
gimp_dialog_factory_get_menu_factory (factory));
return gimp_font_factory_view_new (GIMP_VIEW_TYPE_LIST,
context->gimp->font_factory,
context,
view_size, 1,
gimp_dialog_factory_get_menu_factory (factory));
}
GtkWidget *
......@@ -644,11 +644,11 @@ dialogs_font_grid_view_new (GimpDialogFactory *factory,
GimpUIManager *ui_manager,
gint view_size)
{
return gimp_font_view_new (GIMP_VIEW_TYPE_GRID,
context->gimp->fonts,
context,
view_size, 1,
gimp_dialog_factory_get_menu_factory (factory));
return gimp_font_factory_view_new (GIMP_VIEW_TYPE_GRID,
context->gimp->font_factory,
context,
view_size, 1,
gimp_dialog_factory_get_menu_factory (factory));
}
GtkWidget *
......
......@@ -28,8 +28,8 @@
#include "pdb-types.h"
#include "core/gimp.h"
#include "core/gimpdatafactory.h"
#include "core/gimpparamspecs.h"
#include "text/gimp-fonts.h"
#include "gimppdb.h"
#include "gimpprocedure.h"
......@@ -57,8 +57,9 @@ fonts_popup_invoker (GimpProcedure *procedure,
{
if (gimp->no_interface ||
! gimp_pdb_lookup_procedure (gimp->pdb, font_callback) ||
! gimp_fonts_wait (gimp, error) ||
! gimp_pdb_dialog_new (gimp, context, progress, gimp->fonts,
! gimp_data_factory_data_wait (gimp->font_factory) ||
! gimp_pdb_dialog_new (gimp, context, progress,
gimp_data_factory_get_container (gimp->font_factory),
popup_title, font_callback, initial_font,
NULL))
success = FALSE;
......@@ -85,7 +86,9 @@ fonts_close_popup_invoker (GimpProcedure *procedure,
{
if (gimp->no_interface ||
! gimp_pdb_lookup_procedure (gimp->pdb, font_callback) ||
! gimp_pdb_dialog_close (gimp, gimp->fonts, font_callback))
! gimp_pdb_dialog_close (gimp,
gimp_data_factory_get_container (gimp->font_factory),
font_callback))
success = FALSE;
}
......@@ -112,8 +115,10 @@ fonts_set_popup_invoker (GimpProcedure *procedure,
{
if (gimp->no_interface ||
! gimp_pdb_lookup_procedure (gimp->pdb, font_callback) ||
! gimp_fonts_wait (gimp, error) ||
! gimp_pdb_dialog_set (gimp, gimp->fonts, font_callback, font_name,
! gimp_data_factory_data_wait (gimp->font_factory) ||
! gimp_pdb_dialog_set (gimp,
gimp_data_factory_get_container (gimp->font_factory),
font_callback, font_name,
NULL))
success = FALSE;
}
......
......@@ -30,8 +30,8 @@
#include "core/gimp.h"
#include "core/gimpcontainer-filter.h"
#include "core/gimpcontainer.h"
#include "core/gimpdatafactory.h"
#include "core/gimpparamspecs.h"
#include "text/gimp-fonts.h"
#include "gimppdb.h"
#include "gimpprocedure.h"
......@@ -46,8 +46,8 @@ fonts_refresh_invoker (GimpProcedure *procedure,
const GimpValueArray *args,
GError **error)
{
gimp_fonts_load (gimp, error);
gimp_fonts_wait (gimp, NULL);
gimp_data_factory_data_refresh (gimp->font_factory, context);
gimp_data_factory_data_wait (gimp->font_factory);
return gimp_procedure_get_return_values (procedure, TRUE, NULL);
}
......@@ -70,12 +70,12 @@ fonts_get_list_invoker (GimpProcedure *procedure,
if (success)
{
if (! gimp_fonts_wait (gimp, error))
if (! gimp_data_factory_data_wait (gimp->font_factory))
success = FALSE;
if (success)
{
font_list = gimp_container_get_filtered_name_array (gimp->fonts,
font_list = gimp_container_get_filtered_name_array (gimp_data_factory_get_container (gimp->font_factory),
filter, &num_fonts);
}
}
......
......@@ -346,8 +346,7 @@ gimp_pdb_get_font (Gimp *gimp,
return NULL;
}
font = (GimpFont *)
gimp_container_get_child_by_name (gimp->fonts, name);
font = (GimpFont *) gimp_pdb_get_data_factory_item (gimp->font_factory, name);
if (! font)
{
......
......@@ -17,14 +17,10 @@ noinst_LIBRARIES = libapptext.a
libapptext_a_sources = \
text-types.h \
text-enums.h \
gimp-fonts.c \
gimp-fonts.h \
gimpfont.c \
gimpfont.h \
gimpfontfactory.c \
gimpfontfactory.h \
gimpfontlist.c \
gimpfontlist.h \
gimptext.c \
gimptext.h \
gimptext-compat.c \
......
/* GIMP - The GNU Image Manipulation Program
* Copyright (C) 1995-2001 Spencer Kimball, Peter Mattis and others
*
* text.c
* Copyright (C) 2003 Manish Singh <yosh@gimp.org>
*
* 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 3 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, see <http://www.gnu.org/licenses/>.
*/
#include "config.h"
#include <gio/gio.h>
#include <fontconfig/fontconfig.h>
#include "libgimpbase/gimpbase.h"
#include "libgimpconfig/gimpconfig.h"
#include "text-types.h"
#include "config/gimpcoreconfig.h"
#include "core/gimp.h"
#include "core/gimp-gui.h"
#include "core/gimp-parallel.h"
#include "core/gimpasync.h"
#include "core/gimpasyncset.h"
#include "core/gimpcancelable.h"
#include "core/gimpuncancelablewaitable.h"
#include "core/gimpwaitable.h"
#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 (Gimp *gimp,
FcConfig *config,
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
gimp_fonts_init (Gimp *gimp)
{
g_return_if_fail (GIMP_IS_GIMP (gimp));
gimp->fonts = gimp_font_list_new (72.0, 72.0);
gimp_object_set_name (GIMP_OBJECT (gimp->fonts), "fonts");
gimp->fonts_async_set = gimp_async_set_new ();
}
void
gimp_fonts_set_config (Gimp *gimp)
{
g_return_if_fail (GIMP_IS_GIMP (gimp));
g_signal_connect (gimp->config, "notify::font-path",
G_CALLBACK (gimp_fonts_notify_font_path),
gimp);
}
void
gimp_fonts_exit (Gimp *gimp)
{
g_return_if_fail (GIMP_IS_GIMP (gimp));
if (gimp->fonts_async_set)
{
gimp_cancelable_cancel (GIMP_CANCELABLE (gimp->fonts_async_set));
g_clear_object (&gimp->fonts_async_set);
}
if (gimp->fonts)
{
if (gimp->config)
g_signal_handlers_disconnect_by_func (gimp->config,
G_CALLBACK (gimp_fonts_notify_font_path),
gimp);
g_clear_object (&gimp->fonts);
}
}
static void
gimp_fonts_load_async (GimpAsync *async,
FcConfig *config)
{
if (FcConfigBuildFonts (config))
{
gimp_async_finish (async, config);
}
else
{
FcConfigDestroy (config);
gimp_async_abort (async);
}
}
static void
gimp_fonts_load_async_callback (GimpAsync *async,
Gimp *gimp)
{
if (gimp_async_is_canceled (async))
return;
if (gimp_async_is_finished (async))
{
FcConfig *config = gimp_async_get_result (async);
FcConfigSetCurrent (config);
gimp_font_list_restore (GIMP_FONT_LIST (gimp->fonts));
}
}
void
gimp_fonts_load (Gimp *gimp,
GError **error)
{
FcConfig *config;
GFile *fonts_conf;
GList *path;
GimpAsync *async;
g_return_if_fail (GIMP_IS_FONT_LIST (gimp->fonts));
g_return_if_fail (GIMP_IS_ASYNC_SET (gimp->fonts_async_set));
if (! gimp_async_set_is_empty (gimp->fonts_async_set))
{
/* font loading is already in progress */
return;
}
gimp_set_busy (gimp);
if (gimp->be_verbose)
g_print ("Loading fonts\n");
gimp_container_freeze (GIMP_CONTAINER (gimp->fonts));
gimp_container_clear (GIMP_CONTAINER (gimp->fonts));
config = FcInitLoadConfig ();
if (! config)
goto cleanup;
fonts_conf = gimp_directory_file (CONF_FNAME, NULL);
if (! gimp_fonts_load_fonts_conf (config, fonts_conf))
goto cleanup;
fonts_conf = gimp_sysconf_directory_file (CONF_FNAME, NULL);
if (! gimp_fonts_load_fonts_conf (config, fonts_conf))
goto cleanup;
path = gimp_config_path_expand_to_files (gimp->config->font_path, FALSE);
gimp_fonts_add_directories (gimp, config, path, error);
g_list_free_full (path, (GDestroyNotify) g_object_unref);
/* We perform font cache initialization in a separate thread, so
* in the case a cache rebuild is to be done it will not block
* the UI.
*/
async = gimp_parallel_run_async (
TRUE,
(GimpParallelRunAsyncFunc) gimp_fonts_load_async,
config);
gimp_async_add_callback (async,
(GimpAsyncCallback) gimp_fonts_load_async_callback,
gimp);
gimp_async_set_add (gimp->fonts_async_set, async);
g_object_unref (async);
cleanup:
gimp_container_thaw (