Discussion:
Add new element <template> and gtk_builder_expose_object() function to GtkBuilder
Juan Pablo Ugarte
2012-11-12 21:19:18 UTC
Permalink
Hello guys, as part of my ongoing effort of bringing composite widgets
to Gtk+ I finished implementing a new GtkBuilder API
gtk_builder_expose_object() and added a new element to builder xml
format <template>
From gtk_builder_expose_object() documentation
Adds object to a pool of objects external to the objects built by
builder. Objects exposed in this pool can be referred to by xml
fragments by specifying the "external-object" boolean attribute.

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 it can only be defined as a toplevel element (that is it has
to be a child of <interface>) and its id has to reference an external
object exposed with this function. This way you can change properties
and even add children to an external object using builder and not just
reference it.

BTW there is a bug [1] in bugzilla to track these new features in
builder and I there is also a blog post [2] showing a bit more of what
can be accomplished using these new thing.

Any comments?

[1]https://bugzilla.gnome.org/show_bug.cgi?id=688205
[2]http://blogs.gnome.org/xjuan/2012/11/12/gtkbuilder-and-external-objects/

_______________________________________________
Glade-devel maillist - Glade-***@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/glade-devel
Juan Pablo Ugarte
2012-11-14 17:59:44 UTC
Permalink
Hello guys

Question for Tristan and Marco

Is there any specific reason why we should keep external object in a
different name space (other table)
now that this is only for object and not any variable?

greets

Juan Pablo
_______________________________________________
Glade-devel maillist - Glade-***@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/glade-devel
Tristan Van Berkom
2012-11-15 08:05:23 UTC
Permalink
On Thu, Nov 15, 2012 at 2:59 AM, Juan Pablo Ugarte
Post by Juan Pablo Ugarte
Hello guys
Question for Tristan and Marco
Is there any specific reason why we should keep external object in a
different name space (other table)
now that this is only for object and not any variable?
They should ideally use the same hash (or namespace, as you put it).

However it calls to question some nastier implications, such as... what
happens when you expose an external object which has the same
name as a declared object... should the external object be used instead ?
(i.e. should it be able to override internally declared fragments ?)

I think at least for now, we want to keep things as simple as possible
so the answer is no, it should not be able to override anything, and
a warning should be issued if there are any collisions in the internal
hash.

Cheers,
-Tristan
Post by Juan Pablo Ugarte
greets
Juan Pablo
_______________________________________________
Glade-devel maillist - Glade-***@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/glade-devel
Juan Pablo Ugarte
2012-11-15 15:07:01 UTC
Permalink
Post by Tristan Van Berkom
On Thu, Nov 15, 2012 at 2:59 AM, Juan Pablo Ugarte
Post by Juan Pablo Ugarte
Hello guys
Question for Tristan and Marco
Is there any specific reason why we should keep external object in a
different name space (other table)
now that this is only for object and not any variable?
They should ideally use the same hash (or namespace, as you put it).
However it calls to question some nastier implications, such as... what
happens when you expose an external object which has the same
name as a declared object... should the external object be used instead ?
(i.e. should it be able to override internally declared fragments ?)
Right that would be a problem, in this case, if we expose the object
before calling gtk_builder_add_from_string() for example then the
external object will be overridden by the internal one.

now if you expose the object after builder has already created an object
then you can get a collision.

gtk_builder_new ()
gtk_builder_add_from_string ()
gtk_builder_expose_object ()
gtk_builder_add_from_string ()

unless we make sure in gtk_builder_expose_object() that the table does
not contain the same id we are trying to add
Post by Tristan Van Berkom
I think at least for now, we want to keep things as simple as possible
so the answer is no, it should not be able to override anything, and
a warning should be issued if there are any collisions in the internal
hash.
Of course, btw for what I have seen in builder code if you call
gtk_builder_add_from_string() more than once objects will get overridden
in the table and bad thing would happen since the id checking is done at
the parsing level.

so I think that by simply making gtk_builder_expose_object() return a
boolean value indication if the object was exposed or not would be ok.
At least it wont be worst than the current situation

greets

Juan Pablo


_______________________________________________
Glade-devel maillist - Glade-***@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/glade-devel

Loading...