[Glade-users] Making my own Classes
Xavier Claessens
xclaesse at gmail.com
Sun Oct 14 17:57:42 EDT 2007
Thanks for answering that fast;
On your blog I see the "parent" attribute, seems exactly what I need.
It's not documented [1]? If I understand the patch for the "parent"
attribute, I write a catalog with my EmpathyFoo widget and say the
parent class is GtkHBox. When someone wants to embed my widget in the
glade UI, glade will create a GtkHBox object, pack everything in it so
it looks like a EmpathyFoo but it's not really one?
Xavier Claessens.
[1] http://glade.gnome.org/docs/index.html
Le dimanche 14 octobre 2007 à 16:20 -0400, Tristan Van Berkom a écrit :
> 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/
>
>
More information about the Glade-users
mailing list