Reputation: 67291
gtk_signal_connect(GTK_OBJECT(vscrollbar), "value_changed",G_CALLBACK(my_function),NULL);
My signal handler looks like below:
void my_function(GtkWidget *widget)
{
printf("Hi\n");
}
As seen above it prints a Hi
whenever the scrollbar is moved one step up or one step down.
But i want to print up
when its moved up or down
when its moved down.
void my_function(GtkWidget *widget)
{
if(/* movement is up, How to identify? */)
printf("UP\n");
if(/* movement is down, How to identify */)
printf("DOWN\n");
}
I am complete new person when it comes to gtk programming. Can anybody please suggest what do i need to do for this?
Upvotes: 0
Views: 358
Reputation: 14607
First, a suggestion: check the latest API reference, even if you have to use old libraries. That will help you not write code that is already obsolete (gtk_signal_connect and GTK_OBJECT look quite ... ancient to anyone working with current GTK+). And if you can actually use current GTK+, do so.
As to your problem, you are correct that the API does not tell you the direction or magnitude of the change. You could use a "static gdouble last_value" in your signal handler and compare that to the current value to find out the direction (and don't forget to set last_value after that :)).
Upvotes: 1