Re: GtkTextView : how many lines currently visible?



Erik de Castro Lopo wrote:

but I still can't figure out how
to get the number of currently visible lines. I supposed I need
the size of the visible part of the GtkTextView widget, but getting
that is not obvious.

Ok, figured it out for myself. For the archive:

    gdkwin = gtk_text_view_get_window (GTK_TEXT_VIEW (widget),
                       GTK_TEXT_WINDOW_TEXT) ;
    gdk_drawable_get_size (GDK_DRAWABLE (gdkwin), &x, &y) ;

    gtk_text_view_window_to_buffer_coords (GTK_TEXT_VIEW (widget),
                       GTK_TEXT_WINDOW_TEXT, 0, y, &x, &y) ;
    gtk_text_view_get_iter_at_position (GTK_TEXT_VIEW (widget), &iter, NULL, x, y) ;

    last_line = gtk_text_iter_get_line (&iter) ;

Cheers,
Erik
-- 
+-----------------------------------------------------------+
  Erik de Castro Lopo
+-----------------------------------------------------------+
"The phrase "object-oriented" means a lot of things. Half are obvious,
and the other half are mistakes." -- Paul Graham



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