| Author |
Message |
jemimah

Joined: 26 Aug 2009 Posts: 4309 Location: Tampa, FL
|
Posted: Tue 26 Jan 2010, 13:22 Post subject:
How do you cast a Double to an an Int in Vala? |
|
I'm working on Vattery, a battery meter for the systray, which is written in Vala. It seems that the Double class in Vala lacks a to_int() method, so to cast a double to an int I've been using Double.to_string().to_int(). Surely there's a better way? The Vala reference manual is woefully incomplete.
|
|
Back to top
|
|
 |
BarryK
Puppy Master

Joined: 09 May 2005 Posts: 6866 Location: Perth, Western Australia
|
Posted: Tue 26 Jan 2010, 18:40 Post subject:
|
|
Perhaps this is a dumb suggestion, but won't a caste do it?
a = (int) b;
...or, doesn't casting extend to this type of conversion?
_________________ http://bkhome.org/blog2/
|
|
Back to top
|
|
 |
jemimah

Joined: 26 Aug 2009 Posts: 4309 Location: Tampa, FL
|
Posted: Tue 26 Jan 2010, 20:32 Post subject:
|
|
Yep, that works. Thanks.
|
|
Back to top
|
|
 |
jemimah

Joined: 26 Aug 2009 Posts: 4309 Location: Tampa, FL
|
Posted: Tue 26 Jan 2010, 20:43 Post subject:
|
|
Maybe you can help me with another Vala problem.
When I compile with Vala I get this error:
| Code: |
/root/vattery/vattery-retro-jemimah-patches/main.vala:309: undefined reference to `gtk_status_icon_set_tooltip_text' |
The correct code for our version of Gtk is 'gtk_status_icon_set_tooltip'. I've been killing the build script halfway though so I can fix the generated C code, and then finishing the build by hand.
Is there a permanent way to fix this?
|
|
Back to top
|
|
 |
BarryK
Puppy Master

Joined: 09 May 2005 Posts: 6866 Location: Perth, Western Australia
|
Posted: Wed 27 Jan 2010, 02:30 Post subject:
|
|
| jemimah wrote: | | Maybe you can help me with another Vala problem. |
Heh heh, no that was just a lucky stab at it the last time. I wouldn't have a clue how to fix that gtk problem!
_________________ http://bkhome.org/blog2/
|
|
Back to top
|
|
 |
Lobster
Official Crustacean

Joined: 04 May 2005 Posts: 15109 Location: Paradox Realm
|
Posted: Wed 27 Jan 2010, 06:40 Post subject:
|
|
. . . for those wondering with valour 'bout Vala
http://puppylinux.org/wikka/ValaGenieintro
_________________ Puppy WIKI
|
|
Back to top
|
|
 |
|