[gimp/goat-invasion: 322/418] app: add parent_type parameter to gimp_gegl_get_config_proxy()



commit a806c235590db5ba32f787763261c433151a037b
Author: Michael Natterer <mitch gimp org>
Date:   Fri Mar 30 00:51:24 2012 +0200

    app: add parent_type parameter to gimp_gegl_get_config_proxy()
    
    and derive from that type. Use GimpImageMapConfig as base class for
    GimpOperationTool's config.

 app/gegl/gimp-gegl-config-proxy.c |   81 +++++++++++++++++++++----------------
 app/gegl/gimp-gegl-config-proxy.h |    3 +-
 app/tools/gimpoperationtool.c     |    4 +-
 3 files changed, 51 insertions(+), 37 deletions(-)
---
diff --git a/app/gegl/gimp-gegl-config-proxy.c b/app/gegl/gimp-gegl-config-proxy.c
index 349680a..86040d4 100644
--- a/app/gegl/gimp-gegl-config-proxy.c
+++ b/app/gegl/gimp-gegl-config-proxy.c
@@ -144,11 +144,15 @@ gimp_gegl_config_class_init (GObjectClass *klass,
 }
 
 GimpObject *
-gimp_gegl_get_config_proxy (const gchar *operation)
+gimp_gegl_get_config_proxy (const gchar *operation,
+                            GType        parent_type)
 {
   static GHashTable *config_types = NULL;
   GType              config_type;
 
+  g_return_val_if_fail (operation != NULL, NULL);
+  g_return_val_if_fail (g_type_is_a (parent_type, GIMP_TYPE_OBJECT), NULL);
+
   if (! config_types)
     config_types = g_hash_table_new_full (g_str_hash,
                                           g_str_equal,
@@ -159,42 +163,49 @@ gimp_gegl_get_config_proxy (const gchar *operation)
 
   if (! config_type)
     {
-      GTypeInfo info =
-      {
-        sizeof (GimpObjectClass),
-        (GBaseInitFunc) NULL,
-        (GBaseFinalizeFunc) NULL,
-        (GClassInitFunc) gimp_gegl_config_class_init,
-        NULL,           /* class_finalize */
-        operation,
-        sizeof (GimpObject),
-        0,              /* n_preallocs */
-        (GInstanceInitFunc) NULL,
-      };
-
-      const GInterfaceInfo config_info =
-      {
-        NULL, /* interface_init     */
-        NULL, /* interface_finalize */
-        NULL  /* interface_data     */
-      };
-
-      gchar *type_name = g_strdup_printf ("GimpGegl-%s-config",
-                                          operation);
+      GTypeQuery query;
 
-      g_strcanon (type_name, G_CSET_DIGITS "-" G_CSET_a_2_z G_CSET_A_2_Z, '-');
+      g_type_query (parent_type, &query);
 
-      config_type = g_type_register_static (GIMP_TYPE_OBJECT, type_name,
-                                            &info, 0);
-
-      g_free (type_name);
-
-      g_type_add_interface_static (config_type, GIMP_TYPE_CONFIG,
-                                   &config_info);
-
-      g_hash_table_insert (config_types,
-                           g_strdup (operation),
-                           (gpointer) config_type);
+      {
+        GTypeInfo info =
+          {
+            query.class_size,
+            (GBaseInitFunc) NULL,
+            (GBaseFinalizeFunc) NULL,
+            (GClassInitFunc) gimp_gegl_config_class_init,
+            NULL,           /* class_finalize */
+            operation,
+            query.instance_size,
+            0,              /* n_preallocs */
+            (GInstanceInitFunc) NULL,
+          };
+
+        const GInterfaceInfo config_info =
+          {
+            NULL, /* interface_init     */
+            NULL, /* interface_finalize */
+            NULL  /* interface_data     */
+          };
+
+        gchar *type_name = g_strdup_printf ("GimpGegl-%s-config",
+                                            operation);
+
+        g_strcanon (type_name,
+                    G_CSET_DIGITS "-" G_CSET_a_2_z G_CSET_A_2_Z, '-');
+
+        config_type = g_type_register_static (GIMP_TYPE_OBJECT, type_name,
+                                              &info, 0);
+
+        g_free (type_name);
+
+        g_type_add_interface_static (config_type, GIMP_TYPE_CONFIG,
+                                     &config_info);
+
+        g_hash_table_insert (config_types,
+                             g_strdup (operation),
+                             (gpointer) config_type);
+      }
     }
 
   return g_object_new (config_type, NULL);
diff --git a/app/gegl/gimp-gegl-config-proxy.h b/app/gegl/gimp-gegl-config-proxy.h
index 741f7fe..f6a6794 100644
--- a/app/gegl/gimp-gegl-config-proxy.h
+++ b/app/gegl/gimp-gegl-config-proxy.h
@@ -19,7 +19,8 @@
 #define __GIMP_GEGL_CONFIG_PROXY_H__
 
 
-GimpObject * gimp_gegl_get_config_proxy  (const gchar *operation);
+GimpObject * gimp_gegl_get_config_proxy  (const gchar *operation,
+                                          GType        parent_type);
 
 void         gimp_gegl_config_proxy_sync (GimpObject  *proxy,
                                           GeglNode    *node);
diff --git a/app/tools/gimpoperationtool.c b/app/tools/gimpoperationtool.c
index 7fbc5a7..65fb156 100644
--- a/app/tools/gimpoperationtool.c
+++ b/app/tools/gimpoperationtool.c
@@ -35,6 +35,7 @@
 #include "core/gimperror.h"
 #include "core/gimpimage.h"
 #include "core/gimpimagemap.h"
+#include "core/gimpimagemapconfig.h"
 #include "core/gimpparamspecs-duplicate.h"
 
 #include "widgets/gimphelp-ids.h"
@@ -246,7 +247,8 @@ gimp_operation_tool_set_operation (GimpOperationTool *tool,
 
   gimp_image_map_tool_create_map (GIMP_IMAGE_MAP_TOOL (tool));
 
-  tool->config = gimp_gegl_get_config_proxy (tool->operation);
+  tool->config = gimp_gegl_get_config_proxy (tool->operation,
+                                             GIMP_TYPE_IMAGE_MAP_CONFIG);
 
   if (tool->options_table)
     {



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]