[gtk+/composite-templates: 13/15] Added return value to gtk_builder_expose_object() and made it ignore if the object id is in use.
- From: Juan Pablo Ugarte <jpu src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/composite-templates: 13/15] Added return value to gtk_builder_expose_object() and made it ignore if the object id is in use.
- Date: Wed, 28 Nov 2012 16:45:34 +0000 (UTC)
commit edcbb7af2b24c04c39ed7301096c126e27fc0cc6
Author: Juan Pablo Ugarte <juanpablougarte gmail com>
Date: Thu Nov 15 16:18:51 2012 -0300
Added return value to gtk_builder_expose_object() and made it ignore if the object id is in use.
gtk/gtkbuilder.c | 21 ++++++++++++++-------
gtk/gtkbuilder.h | 2 +-
2 files changed, 15 insertions(+), 8 deletions(-)
---
diff --git a/gtk/gtkbuilder.c b/gtk/gtkbuilder.c
index 8e52bc9..bcd2c09 100644
--- a/gtk/gtkbuilder.c
+++ b/gtk/gtkbuilder.c
@@ -1295,8 +1295,8 @@ gtk_builder_get_translation_domain (GtkBuilder *builder)
* @name: the name of the object exposed to the builder
* @object: the object to expose
*
- * Add @object to the @builder object pool so it can be references just like any
- * other object buiolt by builder.
+ * Add @object to the @builder object pool so it can be referenced just like any
+ * other object built by builder.
*
* To make this function even more useful a new special entry point element
* <template> is defined. It is similar to <object> with the only difference
@@ -1305,23 +1305,30 @@ gtk_builder_get_translation_domain (GtkBuilder *builder)
* function. This way you can change properties and even add children to an
* external object using builder, not just reference it.
*
+ * Returns: True if object was exposed.
+ *
* Since: 3.8
**/
-void
+gboolean
gtk_builder_expose_object (GtkBuilder *builder,
const gchar *name,
GObject *object)
{
GtkBuilderPrivate *priv;
- g_return_if_fail (GTK_IS_BUILDER (builder));
- g_return_if_fail (name && name[0]);
- g_return_if_fail (G_IS_OBJECT (object));
+ g_return_val_if_fail (GTK_IS_BUILDER (builder), FALSE);
+ g_return_val_if_fail (name && name[0], FALSE);
+ g_return_val_if_fail (G_IS_OBJECT (object), FALSE);
priv = builder->priv;
-
+
+ if (g_hash_table_contains (priv->objects, name))
+ return FALSE;
+
object_set_name (object, name);
g_hash_table_insert (priv->objects, g_strdup (name), g_object_ref (object));
+
+ return TRUE;
}
diff --git a/gtk/gtkbuilder.h b/gtk/gtkbuilder.h
index 3338162..c44dbd4 100644
--- a/gtk/gtkbuilder.h
+++ b/gtk/gtkbuilder.h
@@ -143,7 +143,7 @@ guint gtk_builder_add_objects_from_string (GtkBuilder *builder,
GObject* gtk_builder_get_object (GtkBuilder *builder,
const gchar *name);
GSList* gtk_builder_get_objects (GtkBuilder *builder);
-void gtk_builder_expose_object (GtkBuilder *builder,
+gboolean gtk_builder_expose_object (GtkBuilder *builder,
const gchar *name,
GObject *object);
void gtk_builder_connect_signals (GtkBuilder *builder,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]