[Glade-users] Making my own Classes



On Sun, 2007-10-14 at 17:55 +0200, Xavier Claessens wrote:
[...]
But how will glade-3 react if I want to edit my glade file? It will see
a unknown widget type... Is there a way to tell glade that EmpathyFoo is
just like GtkHBox but when a client wants to instantiate it should use
g_object_new(Empathy_foo_get_type(), NULL);

And if I write a catalog xml file to describe properties of my
EmpathyFoo widget, then other programs will be able to embed a
EmpathyFoo widget in their UI, but will they be able to modify widgets
packed in it?

Yes.

So I have a foo.glade describing my EmpathyFoo widget, if I edit that
file I want to be able to modify widgets packed in my EmpathyFoo widget.
If a create a new bar.glade and pack (using catalog) an EmpathyFoo
widget into a GtkWindow I don't want to be able to edit widgets
contained in EmpathyFoo widget.

Is that possible? Thanks for explanations!

Ok you'll have to look at glade3/plugins/gtk+/glade-gtk.c,gtk+.xml.in .

That will give you a good idea of how the class adapter works
(i.e. we use an object class implemented by your plugin to interact
with your runtime widgets).

A plugin is not always nescisary, but you might need to override
some of the behaviour from the GtkHBox adaptor if your widget
behaves differently than a normal hbox (especially if you have
implicit internal child widgets, you might need to special case
them a bit). this blog post[1] you might have found explains the
simplest way to make a pluginless catalog, it should get you 
started at least.

Note that from the libglade pov, you'll have to write a plugin
that calls glade_register_widget() for your types and does any
special casing on the libglade side of things (it will be loaded
as the "name" specified in your glade catalog), there are easier
ways to get your widgets working without writing libglade plugins
but if you want it available for everyone then you need libglade
plugins (those plugins will not be needed in a GtkBuilder situation).

Cheers,
                -Tristan

[1] http://blogs.gnome.org/tvb/2007/07/25/some-popular-features/






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