Re: [Vala] Access the "klass" parameter of a class_init() function in vala with "static construct"
- From: Evan Nemerson <evan coeus-group com>
- To: Sébastien Wilmet <sebastien wilmet gmail com>
- Cc: vala-list gnome org
- Subject: Re: [Vala] Access the "klass" parameter of a class_init() function in vala with "static construct"
- Date: Sat, 31 Jul 2010 11:30:19 -0700
On Sat, 2010-07-31 at 17:59 +0200, Sébastien Wilmet wrote:
Hello!
What I want to do is to implement a GtkAction derived class which sets
GtkActionClass:toolbar_item_type to GTK_TYPE_MENU_TOOL_BUTTON in its
class_init function.
Vala doesn't currently expose *Class structs in the bindings, so AFAIK
what you're talking about can't be done easily. I'm not exactly an
expert on GObject, but I think you should be able to hack something
together by going creating bindings for GtkActionClass then getting
access to it with GLib.Object.get_class. This is untested, but you
should get the idea:
/* In a vapi */
[Compact, CCode (cname = "GtkActionClass")]
public class GtkActionClass {
public GLib.Type menu_item_type;
public GLib.Type toolbar_item_type;
}
/* Your code */
unowned GtkActionClass ac = (GtkActionClass) this.get_class ();
ac.toolbar_item_type = typeof (MenuToolButton);
This type of thing seems to be pretty uncommon... the only other example
I'm aware of is GtkAction (see bug #611498) so I'm not sure if support
for this should be added to Vala or not. If so, I'm thinking the syntax
could just be "public virtual GLib.Type toolbar_item_type;" (currently
emits an error about virtual not working with fields), which means we
still don't need to expose the whole *Class struct in the bindings.
Jürg, what do you think?
-Evan
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]