glade3 r1949 - in trunk: . gladeui



Author: tvb
Date: Sun Sep 21 15:55:59 2008
New Revision: 1949
URL: http://svn.gnome.org/viewvc/glade3?rev=1949&view=rev

Log:

	* 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 ()).



Modified:
   trunk/ChangeLog
   trunk/gladeui/glade-widget-adaptor.c
   trunk/gladeui/glade-widget-adaptor.h
   trunk/gladeui/glade-widget.c
   trunk/gladeui/glade-xml-utils.h

Modified: trunk/gladeui/glade-widget-adaptor.c
==============================================================================
--- trunk/gladeui/glade-widget-adaptor.c	(original)
+++ trunk/gladeui/glade-widget-adaptor.c	Sun Sep 21 15:55:59 2008
@@ -797,6 +797,15 @@
 /*******************************************************************************
                   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 @@
 	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;
@@ -1352,6 +1362,11 @@
 		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))
 		klass->deep_post_create = symbol;
@@ -2495,6 +2510,28 @@
 	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:

Modified: trunk/gladeui/glade-widget-adaptor.h
==============================================================================
--- trunk/gladeui/glade-widget-adaptor.h	(original)
+++ trunk/gladeui/glade-widget-adaptor.h	Sun Sep 21 15:55:59 2008
@@ -327,6 +327,26 @@
 						   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 @@
 	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 @@
 							      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);

Modified: trunk/gladeui/glade-widget.c
==============================================================================
--- trunk/gladeui/glade-widget.c	(original)
+++ trunk/gladeui/glade-widget.c	Sun Sep 21 15:55:59 2008
@@ -511,7 +511,7 @@
 	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 @@
 
 	/* 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);
 

Modified: trunk/gladeui/glade-xml-utils.h
==============================================================================
--- trunk/gladeui/glade-xml-utils.h	(original)
+++ trunk/gladeui/glade-xml-utils.h	Sun Sep 21 15:55:59 2008
@@ -110,6 +110,7 @@
 #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"



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