GTK+ Forums

Discussion forum for GTK+ and Programming. Ask questions, troubleshoot problems, view and post example code, or express your opinions.
It is currently Sat Apr 19, 2014 7:19 am

All times are UTC




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: using GtkScale
PostPosted: Fri Mar 06, 2009 7:48 pm 
Offline
GTK+ Guru

Joined: Thu Aug 07, 2008 12:23 am
Posts: 103
Location: NYC
Pursuant to my last post about using a gtk interface to openGL, how can I use a GtkScale to control, eg. a global variable? The API and all the documentation seem to be about using it with "adjustments", which look to me like values internal to the GUI. Which I guess makes sense because usually there is just a GUI.

Is there not a way to use a gsignal_connect() or something so that I can link the slider to an arbitrary value?


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 06, 2009 8:06 pm 
Offline
GTK+ Guru

Joined: Thu Aug 07, 2008 12:23 am
Posts: 103
Location: NYC
Okay I found it, silly me. But I must be misunderstanding something
Code:
float vector[3]={0.8f,0.8f,0.8f};
GtkWidget *slider=gtk_hscale_new_with_range(0.0,1.0,0.05);
gtk_scale_button_set_value(GTK_SCALE_BUTTON(slider),(gdouble)vector[0]);

I was hoping the slider would start up set to 0.8, but it is 0.0.

What's the deal?


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 06, 2009 8:35 pm 
Offline
GTK+ Guru

Joined: Thu Aug 07, 2008 12:23 am
Posts: 103
Location: NYC
Whoops again! Should have been gtk_range_set_value!

Now I just have to be able to get, the value...

If anyone has like, a very short little example of how they've done something like this (I know you're out there), it would be much appreciated.

[edit] oh my goodness there's a get_value too? So why does the API repeatedly state you must use the "value-changed" signal??
[edit] because you can use g_signal_connect...

Sigh. It's working great except you can't issue openGL commands in a signal handler function (segfault, I guess because there's no syncronization). I don't know if that will become a problem or not.

Anyone who's used GtkGLExt have anything to say about it?


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 2 guests


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 post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group