Commit aef7ac64 authored by Tristan Van Berkom's avatar Tristan Van Berkom

New "construct-object-function" used to construct object instances by way


	* gladeui/glade-widget.c, gladeui/glade-widget-adaptor.[ch],
	gladeui/glade-xml-utils.c: New "construct-object-function" used to construct
	object instances by way of the plugin (glade_widget_adaptor_construct_object ()).


svn path=/trunk/; revision=1949
parent 1baaef3b
......@@ -13,6 +13,10 @@
* gladeui/glade-property.[ch]: Now property states can be flagged and
also include format_disabled state.
* gladeui/glade-widget.c, gladeui/glade-widget-adaptor.[ch],
gladeui/glade-xml-utils.c: New "construct-object-function" used to construct
object instances by way of the plugin (glade_widget_adaptor_construct_object ()).
2008-09-20 Tristan Van Berkom <tvb@gnome.org>
* TODO: Updated.
......
......@@ -797,6 +797,15 @@ glade_widget_adaptor_real_get_property (GObject *object,
/*******************************************************************************
GladeWidgetAdaptor base class implementations
*******************************************************************************/
static GObject *
glade_widget_adaptor_object_construct_object (GladeWidgetAdaptor *adaptor,
guint n_parameters,
GParameter *parameters)
{
return g_object_newv (adaptor->type, n_parameters, parameters);
}
static void
glade_widget_adaptor_object_set_property (GladeWidgetAdaptor *adaptor,
GObject *object,
......@@ -1162,6 +1171,7 @@ glade_widget_adaptor_class_init (GladeWidgetAdaptorClass *adaptor_class)
object_class->get_property = glade_widget_adaptor_real_get_property;
/* Class methods */
adaptor_class->construct_object = glade_widget_adaptor_object_construct_object;
adaptor_class->deep_post_create = NULL;
adaptor_class->post_create = NULL;
adaptor_class->get_internal_child = NULL;
......@@ -1351,6 +1361,11 @@ gwa_extend_with_node_load_sym (GladeWidgetAdaptorClass *klass,
&symbol))
object_class->constructor = symbol;
if (glade_xml_load_sym_from_node (node, module,
GLADE_TAG_CONSTRUCT_OBJECT_FUNCTION,
&symbol))
klass->construct_object = symbol;
if (glade_xml_load_sym_from_node (node, module,
GLADE_TAG_DEEP_POST_CREATE_FUNCTION,
&symbol))
......@@ -2495,6 +2510,28 @@ glade_widget_adaptor_default_params (GladeWidgetAdaptor *adaptor,
return (GParameter *)g_array_free (params, FALSE);
}
/**
* glade_widget_adaptor_construct_object:
* @adaptor: A #GladeWidgetAdaptor
* @n_parameters: amount of construct parameters
* @parameters: array of construct #GParameter args to create
* the new object with.
*
* This function is called to construct a GObject instance for
* a #GladeWidget of the said @adaptor. (provided for language
* bindings that may need to construct a wrapper object).
*
* Returns: A newly created #GObject
*/
GObject *
glade_widget_adaptor_construct_object (GladeWidgetAdaptor *adaptor,
guint n_parameters,
GParameter *parameters)
{
g_return_val_if_fail (GLADE_IS_WIDGET_ADAPTOR (adaptor), NULL);
return GLADE_WIDGET_ADAPTOR_GET_CLASS (adaptor)->construct_object (adaptor, n_parameters, parameters);
}
/**
* glade_widget_adaptor_post_create:
......
......@@ -327,6 +327,26 @@ typedef void (* GladeReplaceChildFunc) (GladeWidgetAdaptor *adaptor,
GObject *old_obj,
GObject *new_obj);
/**
* GladeConstructObjectFunc:
* @adaptor: A #GladeWidgetAdaptor
* @n_parameters: amount of construct parameters
* @parameters: array of construct #GParameter args to create
* the new object with.
*
* This function is called to construct a GObject instance.
* (for language bindings that may need to construct a wrapper
* object).
*
* Returns: A newly created #GObject
*/
typedef GObject *(* GladeConstructObjectFunc) (GladeWidgetAdaptor *adaptor,
guint n_parameters,
GParameter *parameters);
/**
* GladePostCreateFunc:
* @object: a #GObject
......@@ -563,6 +583,9 @@ struct _GladeWidgetAdaptorClass
gint default_width; /* Default width in GladeDesignLayout */
gint default_height; /* Default height in GladeDesignLayout */
GladeConstructObjectFunc construct_object; /* Object constructor
*/
GladePostCreateFunc deep_post_create; /* Executed after widget creation:
* plugins use this to setup various
* support codes (adaptors must always
......@@ -689,6 +712,10 @@ GParameter *glade_widget_adaptor_default_params (GladeWidgetAdaptor
gboolean construct,
guint *n_params);
GObject *glade_widget_adaptor_construct_object (GladeWidgetAdaptor *adaptor,
guint n_parameters,
GParameter *parameters);
void glade_widget_adaptor_post_create (GladeWidgetAdaptor *adaptor,
GObject *object,
GladeCreateReason reason);
......
......@@ -511,7 +511,7 @@ glade_widget_build_object (GladeWidgetAdaptor *adaptor,
guint n_params, i;
if (reason == GLADE_CREATE_LOAD)
return g_object_new (adaptor->type, NULL);
return glade_widget_adaptor_construct_object (adaptor, 0, NULL);
if (widget)
params = glade_widget_template_params (widget, TRUE, &n_params);
......@@ -520,7 +520,7 @@ glade_widget_build_object (GladeWidgetAdaptor *adaptor,
/* Create the new object with the correct parameters.
*/
object = g_object_newv (adaptor->type, n_params, params);
object = glade_widget_adaptor_construct_object (adaptor, n_params, params);
free_params (params, n_params);
......
......@@ -110,6 +110,7 @@ typedef enum
#define GLADE_TAG_DEFAULT_PALETTE_STATE "default-palette-state"
#define GLADE_TAG_PROJECT_CONVERT_FUNCTION "project-convert-function"
#define GLADE_TAG_REPLACE_CHILD_FUNCTION "replace-child-function"
#define GLADE_TAG_CONSTRUCT_OBJECT_FUNCTION "construct-object-function"
#define GLADE_TAG_DEEP_POST_CREATE_FUNCTION "deep-post-create-function"
#define GLADE_TAG_POST_CREATE_FUNCTION "post-create-function"
#define GLADE_TAG_GET_INTERNAL_CHILD_FUNCTION "get-internal-child-function"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment