Issue #1211: Load fonts in background after startup.
Fonts should not be blocking startup as this provides a very bad
experience when people have a lot of fonts. This was experienced even
more on Windows where loading time are often excessively long.
We were already running font loading in a thread, yet were still
blocking startup (thread was only so that the loading status GUI could
get updated as a feedback). Now we will only start loading and proceed
directly to next steps.
While fonts are not loaded, the text tool will not be usable, yet all
other activities can be performed.
(cherry picked from commit 2484dec7d5
)
This commit is contained in:
@ -39,5 +39,5 @@ fonts_refresh_cmd_callback (GtkAction *action,
|
|||||||
GimpContext *context = action_data_get_context (data);
|
GimpContext *context = action_data_get_context (data);
|
||||||
|
|
||||||
if (context)
|
if (context)
|
||||||
gimp_fonts_load (context->gimp, NULL, NULL);
|
gimp_fonts_load (context->gimp, NULL);
|
||||||
}
|
}
|
||||||
|
@ -799,8 +799,8 @@ gimp_restore (Gimp *gimp,
|
|||||||
/* initialize the list of fonts */
|
/* initialize the list of fonts */
|
||||||
if (! gimp->no_fonts)
|
if (! gimp->no_fonts)
|
||||||
{
|
{
|
||||||
status_callback (NULL, _("Fonts (this may take a while)"), 0.7);
|
status_callback (NULL, _("Fonts"), 0.7);
|
||||||
gimp_fonts_load (gimp, status_callback, error);
|
gimp_fonts_load (gimp, error);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* initialize the template list */
|
/* initialize the template list */
|
||||||
|
@ -46,7 +46,7 @@ fonts_refresh_invoker (GimpProcedure *procedure,
|
|||||||
const GimpValueArray *args,
|
const GimpValueArray *args,
|
||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
gimp_fonts_load (gimp, NULL, error);
|
gimp_fonts_load (gimp, error);
|
||||||
|
|
||||||
return gimp_procedure_get_return_values (procedure, TRUE, NULL);
|
return gimp_procedure_get_return_values (procedure, TRUE, NULL);
|
||||||
}
|
}
|
||||||
|
@ -110,14 +110,22 @@ gimp_fonts_load_async (GimpAsync *async,
|
|||||||
gimp_async_finish (async, NULL);
|
gimp_async_finish (async, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
static void
|
||||||
gimp_fonts_load (Gimp *gimp,
|
gimp_fonts_load_async_callback (GimpAsync *async,
|
||||||
GimpInitStatusFunc status_callback,
|
GimpFontList *fonts)
|
||||||
GError **error)
|
|
||||||
{
|
{
|
||||||
FcConfig *config;
|
if (gimp_async_is_finished (async))
|
||||||
GFile *fonts_conf;
|
gimp_font_list_restore (fonts);
|
||||||
GList *path;
|
}
|
||||||
|
|
||||||
|
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_FONT_LIST (gimp->fonts));
|
||||||
|
|
||||||
@ -147,36 +155,16 @@ gimp_fonts_load (Gimp *gimp,
|
|||||||
gimp_fonts_add_directories (gimp, config, path, error);
|
gimp_fonts_add_directories (gimp, config, path, error);
|
||||||
g_list_free_full (path, (GDestroyNotify) g_object_unref);
|
g_list_free_full (path, (GDestroyNotify) g_object_unref);
|
||||||
|
|
||||||
if (status_callback)
|
/* We perform font cache initialization in a separate thread, so
|
||||||
{
|
* in the case a cache rebuild is to be done it will not block
|
||||||
GimpAsync *async;
|
* the UI.
|
||||||
gint64 end_time;
|
*/
|
||||||
|
async = gimp_parallel_run_async ((GimpParallelRunAsyncFunc) gimp_fonts_load_async,
|
||||||
/* We perform font cache initialization in a separate thread, so
|
config);
|
||||||
* in the case a cache rebuild is to be done it will not block
|
gimp_async_add_callback (async,
|
||||||
* the UI.
|
(GimpAsyncCallback) gimp_fonts_load_async_callback,
|
||||||
*/
|
gimp->fonts);
|
||||||
|
g_object_unref (async);
|
||||||
async = gimp_parallel_run_async (
|
|
||||||
(GimpParallelRunAsyncFunc) gimp_fonts_load_async,
|
|
||||||
config);
|
|
||||||
|
|
||||||
do
|
|
||||||
{
|
|
||||||
status_callback (NULL, NULL, 0.6);
|
|
||||||
|
|
||||||
end_time = g_get_monotonic_time () + 0.1 * G_TIME_SPAN_SECOND;
|
|
||||||
}
|
|
||||||
while (! gimp_async_wait_until (async, end_time));
|
|
||||||
|
|
||||||
g_object_unref (async);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
gimp_fonts_load_func (config);
|
|
||||||
}
|
|
||||||
|
|
||||||
gimp_font_list_restore (GIMP_FONT_LIST (gimp->fonts));
|
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
gimp_container_thaw (GIMP_CONTAINER (gimp->fonts));
|
gimp_container_thaw (GIMP_CONTAINER (gimp->fonts));
|
||||||
@ -364,7 +352,7 @@ gimp_fonts_notify_font_path (GObject *gobject,
|
|||||||
{
|
{
|
||||||
GError *error = NULL;
|
GError *error = NULL;
|
||||||
|
|
||||||
gimp_fonts_load (gimp, NULL, &error);
|
gimp_fonts_load (gimp, &error);
|
||||||
|
|
||||||
if (error)
|
if (error)
|
||||||
{
|
{
|
||||||
|
@ -24,7 +24,6 @@ void gimp_fonts_set_config (Gimp *gimp);
|
|||||||
void gimp_fonts_exit (Gimp *gimp);
|
void gimp_fonts_exit (Gimp *gimp);
|
||||||
|
|
||||||
void gimp_fonts_load (Gimp *gimp,
|
void gimp_fonts_load (Gimp *gimp,
|
||||||
GimpInitStatusFunc status_callback,
|
|
||||||
GError **error);
|
GError **error);
|
||||||
void gimp_fonts_reset (Gimp *gimp);
|
void gimp_fonts_reset (Gimp *gimp);
|
||||||
|
|
||||||
|
@ -30,7 +30,7 @@ HELP
|
|||||||
%invoke = (
|
%invoke = (
|
||||||
code => <<'CODE'
|
code => <<'CODE'
|
||||||
{
|
{
|
||||||
gimp_fonts_load (gimp, NULL, error);
|
gimp_fonts_load (gimp, error);
|
||||||
}
|
}
|
||||||
CODE
|
CODE
|
||||||
);
|
);
|
||||||
|
Reference in New Issue
Block a user