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 Nov 01, 2014 4:36 am

All times are UTC




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: gtkscale - move slider back after googling 2 week
PostPosted: Fri Mar 23, 2012 11:06 am 
Offline

Joined: Wed Feb 29, 2012 5:56 pm
Posts: 2
Hi all

After being googling for 2 weeks, I decided it was time to post my trouble.

Using Gtk2.24 for windows and relatively new programming with Gtk.

I create it with:

hscale = gtk_hscale_new (GTK_ADJUSTMENT (gtk_adjustment_new (0, 0, 100, 0.1, 1, 1)));

And connect signals:
g_signal_connect ((gpointer) hscale, "value_changed",
G_CALLBACK (on_hscale_value_changed),
NULL);
g_signal_connect ((gpointer) hscale, "button_release_event",
G_CALLBACK (on_hscale_button_release_event),
NULL);
g_signal_connect( (gpointer) hscale, "change-value",
G_CALLBACK( on_hscale_change_value ), NULL );

I'm trying to reset the position of a gtkhscale to its initial point after the user release the slider.

I connect on_hscale_button_release_event and set the value of the range gtk_range_set_value ( widget, 0.00); but the slider doesnt move back and the value is not set to 0.00. Why?

If I use gtk_range_set_fill_level the slider does move back but after that doesnt receive any other user input, i can not move the slider with the mouse or keyboard.

In a post found a suggestion and tried:
GtkAdjustment *a = (GtkAdjustment *)gtk_adjustment_new(0, 0, 100, 0.1, 1, 1);
gtk_range_set_adjustment(GTK_RANGE( widget ), a);

The slider doesnt moved back.

I've tried to connect and disconnect signals, but nothing seems to move the slider back to its initial position.

How can I "moved back" the slider when the button_release_event is fired?


Top
 Profile  
 
 Post subject: Re: gtkscale - move slider back after googling 2 week
PostPosted: Sat Mar 24, 2012 7:02 am 
Offline
Never Seen the Sunlight

Joined: Mon Apr 28, 2008 5:52 am
Posts: 768
Location: UK
Hello,

GTK+ uses the slider to set the position using button clicks. So on the "button-release-event" signal it will set the position of the slider for you. Since you are also trying to set the slider position using the same system you a end up with this this event sequence :-

1 - You set the slider position
2 - GTK+ set the slider position

I you want to get the expected result you must have your signal connected after the GTK+ signal.

What you are trying to do would be non-intuitive to the user as they would be expecting to move the slider using button clicks and not for it to be reset. So my advise would be not to do this.

_________________
E.


Top
 Profile  
 
 Post subject: Re: gtkscale - move slider back after googling 2 week
PostPosted: Sun Mar 25, 2012 5:09 am 
Offline
Never Seen the Sunlight

Joined: Thu Mar 24, 2011 2:10 pm
Posts: 328
Location: Sydney, Australia
As errol says you want a g_signal_connect_after call for the button_release_event signal in order to not conflict with gtks processes. Similarly you may need to make sure that there's no conflict from your resetting leading to a call to value_changed.
Also I must agree with errol's statement that the behaviour you are causing can be confusing to the user who expects a slider to behave like a slider. You are also assuming that the user will be interacting with the slider solely with the mouse; what if the user interacts with it using the keyboard? If you have a really good reason for what you are trying to do maybe it would be best to set up a custom widget specifically designed for your functionality and not cause confusion with the expected behaviour of other widgets.


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 4 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:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group