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



Hi,

2010/6/25 Andrew <rugby471 gmail com>:
On 25/06/10 09:00, Abderrahim Kitouni wrote:
Hi,

2010/6/25 Andrew <rugby471 gmail com>:
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
?

Take a look at the properties section [1], the "construct only"
properties cannot be changed afterwards and so need to be passed to
Object(...) if you don't want the default value. The other is
icon-name (which becomes icon_name in Vala/Genie).

What we notice here is that the "usually" part in my past message
doesn't work : category is passed to the creation method as an enum
but is stored in the property as a string. I'm not sure how to do the
mapping, you may need to look at the source of app_indicator_new

HTH,
Abderrahim

[1] http://people.canonical.com/~ted/libappindicator/current/AppIndicator.html#AppIndicator.properties

Sorry maybe I didn't explain, I am using Genie for the VERY FIRST time
and so what you are saying doesn't really mean anything to me.

Could you give me an example that I could learn off of?

I assumed you knew a bit of C and GObject to look at the source [1],
you need to do something similar to this function in your construct

(be careful to reindent correctly when copy-pasting)

construct (id: string, icon: string, category: AppIndicatorCategory)
  Object(id: id, icon_name: icon, category: category_from_enum(category))

def category_from_enum (category: AppIndicatorCategory): string
  var categ_cls = (EnumClass) typeof(AppIndicatorCategory).class_ref()
  return categ_class.get_value(category).value_nick

I didn't test this code but it should work.
It's not always that difficult with Genie/Vala (Object(id: id,
icon_name: icon, category: category) should be enough), it's just that
this library is a bit weird (the value is an enum in the constructor
and internally, but is exposed as a string to gobject). I think you
should report this.

HTH,
Abderrahim

[1] 
http://bazaar.launchpad.net/~indicator-applet-developers/indicator-application/trunk/annotate/head:/src/app-indicator.c#L1009



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