Re: Question about scrollbars



Sebastian Geerken wrote:

Hi.

I'm using a GtkLayout in a GtkScrolledWindow, and the area size as
well as the adjustment values of the GtkLayout are changed quite
often by the program itself. However, I need to catch adjustment
changes by *the user* (by using the scrollbars), and distinguish them
from changes caused by my program.

Currently, I connect a callback to the "value_changed" signal of the
adjustments, and keep track where changes come from, by
increasing/decreasing a counter before/after my program may affect
the adjustments. A zero value of this counter should indicate an user
caused change. But this turned out to be quite tricky, and I did not
get it working in all cases. So I ask if there is a more direct way
to notice changes of the scrollbars.

Thanks in advance,
Sebastian

_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list gnome org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

I usually use a global flag when I change a value in the code, like
this:

program_change = TRUE;
gtk_adjustment_value_changed(adj);
program_change = FALSE;

and in the signal

if(program_change)
{
        /* do something */
}
else
{
        /* user changed the scrollbar */
}

---------------------------------------------------------------------
Paolo Costabel                Visit The Internet Comic Books Database 
Sony Imageworks                           http://www.comicsdb.com




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]