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.
This commit is contained in:
Michael Natterer 2012-03-30 00:51:24 +02:00
parent e8cc9d1bf5
commit 8bc6f1ee09
3 changed files with 45 additions and 31 deletions

View File

@ -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 =
GTypeQuery query;
g_type_query (parent_type, &query);
{
sizeof (GimpObjectClass),
(GBaseInitFunc) NULL,
(GBaseFinalizeFunc) NULL,
(GClassInitFunc) gimp_gegl_config_class_init,
NULL, /* class_finalize */
operation,
sizeof (GimpObject),
0, /* n_preallocs */
(GInstanceInitFunc) NULL,
};
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 */
};
const GInterfaceInfo config_info =
{
NULL, /* interface_init */
NULL, /* interface_finalize */
NULL /* interface_data */
};
gchar *type_name = g_strdup_printf ("GimpGegl-%s-config",
operation);
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, '-');
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);
config_type = g_type_register_static (GIMP_TYPE_OBJECT, type_name,
&info, 0);
g_free (type_name);
g_free (type_name);
g_type_add_interface_static (config_type, GIMP_TYPE_CONFIG,
&config_info);
g_type_add_interface_static (config_type, GIMP_TYPE_CONFIG,
&config_info);
g_hash_table_insert (config_types,
g_strdup (operation),
(gpointer) config_type);
g_hash_table_insert (config_types,
g_strdup (operation),
(gpointer) config_type);
}
}
return g_object_new (config_type, NULL);

View File

@ -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);

View File

@ -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)
{