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 Wed 22 Oct 2014, 02:40
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 Posts_count  
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_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_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_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_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_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_website 
Display_posts:   Sort by:   
Page 1 of 1 Posts_count  
Post_new_topic   Reply_to_topic View_previous_topic :: View_next_topic
 Forum index » Off-Topic Area » Programming
Jump to:  

Rules_post_cannot
Rules_reply_cannot
Rules_edit_cannot
Rules_delete_cannot
Rules_vote_cannot
You cannot attach files in this forum
You can download files in this forum


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