Re: [Vala] Genie, subclassing and some help!



On 24/06/10 21:39, Abderrahim Kitouni wrote:
Hi,

2010/6/24, Andrew <rugby471 gmail com>:
Hi guys,

 I am a programmer coming form python and I am trying to get to grips
 with Genie. One problem I am having is as follows:

 Say I have a class called Gerrard and to create a new version of this
 class, I use the following:

 var g = new Gerrard(arg1, arg2, arg3)

 Now I wish to subclass Gerrard, into the class Terry. However I wish to
 be able to create a new version of Terry as follows:

 var t = new Terry(arg1, arg2, arg3)

 How do I do this in Genie?
it's as simple as
construct (arg1: type1, arg2: type2, arg3: type3)
    super(arg1, arg2, arg3)

BUT this won't work if the base class isn't defined in vala, in which
case you'll need to find the properties initialized by the creation
method (usually the same as the arg name) and chain up to GLib.Object
directly, something like (untested) :

construct (arg1: type1, arg2: type2, arg3: type3)
    Object(arg1: arg1, arg2: arg2, arg3: arg3)

HTH,
Abderrahim

Thankyou for your help.

I tried the first method but it didn't work (it is a Gtk object and so I
doubted it would due to what you said above). I then tried to do the
second method but I didn't really understand what to do.

Could you do an example with this
http://people.canonical.com/~ted/libappindicator/current/AppIndicator.html#app-indicator-new
?

Again thankyou for you help

-- 
Andrew



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