From e6007f10ac1cce72f9c7c8a30c9cf7be6936c902 Mon Sep 17 00:00:00 2001 From: Juan Pablo Ugarte Date: Thu, 15 Nov 2012 16:22:59 -0300 Subject: [PATCH] Added template_id parameter to gtk_container_class_set_template_from_*() functions This way you can call your template "this" or "that" or as you wish. --- gtk/gtkcontainer.c | 37 +++++++++++++++++++++++++------------ gtk/gtkcontainer.h | 6 ++++-- 2 files changed, 29 insertions(+), 14 deletions(-) diff --git a/gtk/gtkcontainer.c b/gtk/gtkcontainer.c index 2cf5c5d2f2..7341f1975d 100644 --- a/gtk/gtkcontainer.c +++ b/gtk/gtkcontainer.c @@ -255,7 +255,8 @@ struct _GtkContainerClassPrivate { GSList *tmpl_classes; - const gchar *tmpl; + const gchar *tmpl, *tmpl_id; + glong tmpl_len; GtkContainerTemplateType tmpl_type; GtkBuilderConnectFunc connect_func; GList *internal_children; /* InternalChildData list */ @@ -442,6 +443,7 @@ gtk_container_base_class_init (GtkContainerClass *class) GtkContainerClassPrivate); priv->tmpl = NULL; + priv->tmpl_id = NULL; priv->tmpl_classes = NULL; priv->connect_func = NULL; priv->internal_children = NULL; @@ -1400,12 +1402,15 @@ gtk_container_class_list_child_properties (GObjectClass *cclass, static void gtk_container_class_set_template (GtkContainerClass *container_class, const gchar *tmpl, + const gchar *template_id, GtkContainerTemplateType tmpl_type) { GtkContainerClassPrivate *priv = container_class->priv; GObjectClass *oclass; priv->tmpl = tmpl; + priv->tmpl_len = g_utf8_strlen (tmpl, -1); + priv->tmpl_id = template_id; priv->tmpl_type = tmpl_type; if (priv->tmpl_classes) @@ -1430,26 +1435,31 @@ gtk_container_class_set_template (GtkContainerClass *container_class, * gtk_container_class_set_template_from_string: * @container_class: a #GtkContainerClass * @template_string: the #GtkBuilder xml string + * @template_id: the template id * * For type implementations it is recommended to use #gtk_container_class_set_template_from_resource * instead of this function. * - * Since: 3.6 + * Since: 3.8 */ void gtk_container_class_set_template_from_string (GtkContainerClass *container_class, - const gchar *template_string) + const gchar *template_string, + const gchar *template_id) { g_return_if_fail (GTK_IS_CONTAINER_CLASS (container_class)); g_return_if_fail (template_string && template_string[0]); + g_return_if_fail (template_id && template_id[0]); - gtk_container_class_set_template (container_class, template_string, TMPL_STRING); + gtk_container_class_set_template (container_class, template_string, + template_id, TMPL_STRING); } /** * gtk_container_class_set_template_from_resource: * @container_class: a #GtkContainerClass * @resource_path: the #GtkBuilder xml resource path + * @template_id: the template id * * This is used when implementing new composite widget types * to specify a UI template for instances of this type. @@ -1458,23 +1468,26 @@ gtk_container_class_set_template_from_string (GtkContainerClass *container_class * format and are used to implement composite widget types in * an automated way. * - * Instances with an assigned template will have thier children - * built at object construct time. + * Instances with an assigned template will have their children built at object + * construct time. * * The provided xml is expected to have a