Re: [Vala] Access the "klass" parameter of a class_init() function in vala with "static construct"
- From: Sébastien Wilmet <sebastien wilmet gmail com>
- To: Evan Nemerson <evan coeus-group 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 22:08:36 +0200
2010/7/31 Evan Nemerson <evan coeus-group com>
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);
I have this error:
error: Access to instance member `GLib.Object.get_class' denied
Also, in C the cast can be made because the first field in a Class struct is
the parent class.
Sébastien
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]