Setting Adjustments



I'm currently trying to set a vertical adjustment (i.e. scrollbar) attached to a
gtktext.  The method I've been using is simple but for some reason does not
work.  The "value" of the adjustment is set as follows;

gtk_adjustment_set_value(GTK_ADJUSTMENT(GTK_TEXT(TEXT)->vadj),
        
GTK_ADJUSTMENT(GTK_TEXT(text)->vadj)->upper*(num_lines/total_num_lines));

where num_lines is the number of carriage returns up to some point, and
total_num_lines is the total number of carriage returns in the gtktext.

The problem I'm having is that for every successive move (this is being used in
a find text routine) a little bit of error is being introduced so that at some
point the highlighted text found falls offscreen.  The algorithm is based on the
assumption that GTK_ADJUSTMENT(GTK_TEXT(text)->vadj)->upper is set to the number
of pixels per line * number of lines.  Does anyone know if this assumption is
incorrect?  Better yet, has anyone already solved this problem?  What I'm trying
to do is snap/jump to a text location without having to wait for the application
to scroll to it.  Scrolling is just too slow.  Any and all suggestions would be
greatly appreciated!



                                -- Stupid Genius




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