[Glade-users] Making my own Classes

Xavier Claessens xclaesse at gmail.com
Mon Oct 15 04:14:36 EDT 2007


Ok, with some concrete screenshots it's easier:

[1] That's a EmpathyContactWidget, it's a vbox with lots of things in
it. Atm EmpathyContactWidget is not a subclass of GtkVBox because I
don't know how to do that using glade. You can see the code [2],
especially empathy_contact_widget_new(). What I want is
EmpathyContactWidget to be a subclass of GtkVBox and containing all
internal widgets like in the screenshot. It's easy if all those widgets
are packed in my C code without using a glade file, but I want to use
glade to construct my widgets because it's far easier to make better
looking widgets.

Of course EmpathyContactWidget can't work without its internal widgets,
the code assumes they exists.

Thank you very much,
Xavier Claessens.

[1]http://users.skynet.be/Zdra/vbox.png
[2]
http://svn.gnome.org/viewvc/empathy/trunk/libempathy-gtk/empathy-contact-widget.c?revision=370&view=markup


Le dimanche 14 octobre 2007 à 22:43 -0400, Tristan Van Berkom a écrit :
> On Mon, 2007-10-15 at 00:44 +0200, Xavier Claessens wrote:
> > Hum, I'm not sure it can solve my problem... Here is what I want to
> > do:
> > 
> > 1) I create a foo.glade file, the root widget is a GtkVBox, I pack in
> > it logs of GTK widgets.
> > 2) Manually I rename the root widget class from GtkVBox to EmpathyFoo,
> > EmpathyFoo is a class inheriting from GtkVBox implemented in
> > libempathy-gtk. 
> > 3) Using gtk-builder-convert I convert foo.glade to foo.ui
> > 4) I make a method empathy_foo_new(){return
> > gtk_builder_get_object(foo.ui, root);} With that function I think
> > GtkBuilder will do a g_object_new(empathy_foo_get_type(), NULL); and
> > then it will pack all widgets in it as described in the .ui file. If
> > that works, glade will introspect my widget, see all packed widgets
> > and display me their properties but won't allow me to removed them
> > since they are internal childs? 
> 
> sigh.
> 
> let me try to explain. your widget EmpathyFoo must be a _widget_,
> just an object, no glade file, no builder file, just a widget.
> 
> Integrating the widget into glade will allow you to add an EmpathyFoo
> widget into your project, at that point the user can add children
> to it at their leasure (a widget does not load a sub hierarchy
> using glade, an application loads a glade hierarchy that contains
> your widget at some point in the hierarchy).
> 
> Also, your widgets will always be easier to integrate into
> glade/builder/bindings if you make sure that normal generic object 
> methods work properly; i.e. there is no reason why a widget
> must be created with my_foo_new(), an object that responds well
> to the gobject api should be able to create itself using construct
> properties and a normal constructor.
> 
> After you've written a simple catalog for glade, there is no 
> bussiness of "s/GtkHBox/EmpathyFoo/" in the glade file... children
> of the hbox (i.e. the EmpathyFoo) are specified by the user
> and treated like as if the EmpathyFoo were any other hbox.
> 
> If the EmpathyFoo widget has internal children, then those
> children are created _by EmpathyFoo_ (not specified in a glade
> file) however; we can allow users to modify properties on
> children that are internal to composite widgets, granted that
> the glade catalog plugin module marks those internally created 
> widgets as such (and yes, we can even let the user add their
> own children to children that are internal to EmpathyFoo).
> 
> I have to admit that I am somewhat alarmed by our failure to
> understand eachother, please assume that I have no idea what
> an EmpathyFoo is supposed to do or look like (so far all I know
> is that its some kind of hbox), I wonder if you still have 
> problems understanding if you could just try to outline exactly
> what you want to accomplish then I can try to tell you how its done.
> 
> Cheers,
>                        -Tristan
> 
> 



More information about the Glade-users mailing list