Puppy Linux Discussion Forum Forum Index Puppy Linux Discussion Forum
Puppy HOME page : puppylinux.com
"THE" alternative forum : puppylinux.info
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

The time now is Tue 29 Jul 2014, 07:15
All times are UTC - 4
 Forum index » Off-Topic Area » Programming
How do you cast a Double to an an Int in Vala?
Post new topic   Reply to topic View previous topic :: View next topic
Page 1 of 1 [6 Posts]  
Author Message
jemimah


Joined: 26 Aug 2009
Posts: 4309
Location: Tampa, FL

PostPosted: 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
View user's profile Send private message Visit poster's website 
BarryK
Puppy Master


Joined: 09 May 2005
Posts: 7047
Location: Perth, Western Australia

PostPosted: 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/news/
Back to top
View user's profile Send private message Visit poster's website 
jemimah


Joined: 26 Aug 2009
Posts: 4309
Location: Tampa, FL

PostPosted: Tue 26 Jan 2010, 20:32    Post subject:  

Yep, that works. Thanks.
Back to top
View user's profile Send private message Visit poster's website 
jemimah


Joined: 26 Aug 2009
Posts: 4309
Location: Tampa, FL

PostPosted: 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
View user's profile Send private message Visit poster's website 
BarryK
Puppy Master


Joined: 09 May 2005
Posts: 7047
Location: Perth, Western Australia

PostPosted: 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/news/
Back to top
View user's profile Send private message Visit poster's website 
Lobster
Official Crustacean


Joined: 04 May 2005
Posts: 15117
Location: Paradox Realm

PostPosted: 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
View user's profile Send private message Visit poster's website 
Display posts from previous:   Sort by:   
Page 1 of 1 [6 Posts]  
Post new topic   Reply to topic View previous topic :: View next topic
 Forum index » Off-Topic Area » Programming
Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.0449s ][ Queries: 11 (0.0024s) ][ GZIP on ]