[gimp] app: create members of the Gimp instance earlier
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] app: create members of the Gimp instance earlier
- Date: Tue, 13 Sep 2016 07:51:55 +0000 (UTC)
commit 314027f0c90a1376923c9c92bb16664a1e974570
Author: Michael Natterer <mitch gimp org>
Date: Tue Sep 13 09:47:27 2016 +0200
app: create members of the Gimp instance earlier
Move fonts, data factories, document list, paint methods and user
context creation to gimp_init() or gimp_constructed() so that most
members are created when gimp_new() is done. This does not load any
data earlier, it just makes sure that all containers exist when
gimp_load_config() is called. It's also cleaner and less fragile,
app/core/gimp.c | 27 ++++++++++++---------------
app/text/gimp-fonts.c | 22 ++++++++++++++++++++++
app/text/gimp-fonts.h | 11 +++++++----
3 files changed, 41 insertions(+), 19 deletions(-)
---
diff --git a/app/core/gimp.c b/app/core/gimp.c
index 817f9ad..3266c51 100644
--- a/app/core/gimp.c
+++ b/app/core/gimp.c
@@ -252,6 +252,10 @@ 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,
"children-type", GIMP_TYPE_TOOL_INFO,
"append", TRUE,
@@ -259,6 +263,8 @@ gimp_init (Gimp *gimp)
gimp_object_set_static_name (GIMP_OBJECT (gimp->tool_info_list),
"tool infos");
+ gimp->documents = gimp_document_list_new (gimp);
+
gimp->templates = gimp_list_new (GIMP_TYPE_TEMPLATE, TRUE);
gimp_object_set_static_name (GIMP_OBJECT (gimp->templates), "templates");
}
@@ -272,12 +278,15 @@ gimp_constructed (GObject *object)
gimp_modules_init (gimp);
+ gimp_paint_init (gimp);
+
gimp->plug_in_manager = gimp_plug_in_manager_new (gimp);
gimp->pdb = gimp_pdb_new (gimp);
xcf_init (gimp);
- gimp->documents = gimp_document_list_new (gimp);
+ /* create user and default context */
+ gimp_contexts_init (gimp);
}
static void
@@ -397,11 +406,7 @@ gimp_finalize (GObject *object)
gimp_data_factories_exit (gimp);
- if (gimp->fonts)
- {
- g_object_unref (gimp->fonts);
- gimp->fonts = NULL;
- }
+ gimp_fonts_exit (gimp);
if (gimp->named_buffers)
{
@@ -563,20 +568,12 @@ gimp_real_initialize (Gimp *gimp,
status_callback (_("Initialization"), NULL, 0.0);
- gimp_fonts_init (gimp);
-
- /* create the data factories & tag cache */
- gimp_data_factories_init (gimp);
-
- gimp_paint_init (gimp);
+ 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));
- /* create user and default context */
- gimp_contexts_init (gimp);
-
/* add data objects that need the user context */
gimp_data_factories_add_builtin (gimp);
diff --git a/app/text/gimp-fonts.c b/app/text/gimp-fonts.c
index 1ceb82d..c201848 100644
--- a/app/text/gimp-fonts.c
+++ b/app/text/gimp-fonts.c
@@ -53,11 +53,33 @@ gimp_fonts_init (Gimp *gimp)
gimp->fonts = gimp_font_list_new (72.0, 72.0);
gimp_object_set_name (GIMP_OBJECT (gimp->fonts), "fonts");
+}
+
+void
+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), gimp);
}
+void
+gimp_fonts_exit (Gimp *gimp)
+{
+ g_return_if_fail (GIMP_IS_GIMP (gimp));
+
+ if (gimp->fonts)
+ {
+ g_signal_handlers_disconnect_by_func (gimp->config,
+ G_CALLBACK (gimp_fonts_load),
+ gimp);
+
+ g_object_unref (gimp->fonts);
+ gimp->fonts = NULL;
+ }
+}
+
typedef struct
{
FcConfig *config;
diff --git a/app/text/gimp-fonts.h b/app/text/gimp-fonts.h
index 19cc154..efb2e55 100644
--- a/app/text/gimp-fonts.h
+++ b/app/text/gimp-fonts.h
@@ -19,10 +19,13 @@
#define __GIMP_FONTS_H__
-void gimp_fonts_init (Gimp *gimp);
-void gimp_fonts_load (Gimp *gimp,
- GimpInitStatusFunc status_callback);
-void gimp_fonts_reset (Gimp *gimp);
+void gimp_fonts_init (Gimp *gimp);
+void gimp_fonts_set_config (Gimp *gimp);
+void gimp_fonts_exit (Gimp *gimp);
+
+void gimp_fonts_load (Gimp *gimp,
+ GimpInitStatusFunc status_callback);
+void gimp_fonts_reset (Gimp *gimp);
#endif /* __GIMP_FONTS_H__ */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]