Textview/scrollbar problem when maximising window

[To the moderators of this list: sorry about the duplicate - posted the
previous from the wrong account :-( ] 

I was about to raise a bug here, but a couple of existing bugs vaguely
look like they might be in the same general area - #1165, #71052 (maybe
:-), perhaps someone can enlighten me).

Anyway here is the problem I see - I'll raise a bug report if this is
not a known problem. Compile the test case below (this is with
gtk+-2.2). Running the program, when the window appears, manually scroll
the right-hand vertical scroll bar to the bottom so that the last line
of text is visible (the 100th line). Now maximise the window. The last
line of text is now some way up within the textview. This may be working
as designed, however it's not what I'd expect. More importantly, the
vertical scrollbar thumb appears to have overshot the trough - a single
left mouse-click rectifies the situation with the scrollbar thumb
springing to its correct position and size. Am I missing something here?

The test code:

#include <gtk/gtk.h>
#include <stdio.h>
#include <string.h>

static GtkWidget* create_text_view (void)
        GtkWidget *text_view;
        GtkTextBuffer *tb;
        int i;
        gchar line[1024];

        text_view = gtk_text_view_new ();
        tb = gtk_text_view_get_buffer (GTK_TEXT_VIEW (text_view));

        for (i = 1; i < 101; ++i) {
                sprintf(line, "This is a line of text on line number
%d\n", i);
                gtk_text_buffer_insert_at_cursor(tb, line,

        gtk_text_view_set_editable(GTK_TEXT_VIEW(text_view), FALSE);

        return text_view;

void destroy(GtkWidget *widget, gpointer data)

int main (int argc, char *argv[])
        GtkWidget *text_view;
        GtkWidget *window;
        GtkWidget *scrolled_window;
        gtk_init(&argc, &argv);

        window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
        gtk_signal_connect (GTK_OBJECT (window), "destroy",
                            (GtkSignalFunc) destroy, NULL);
        scrolled_window = gtk_scrolled_window_new (NULL, NULL);
        gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW
        text_view = create_text_view ();
        gtk_container_add (GTK_CONTAINER (scrolled_window), text_view);
        gtk_container_add (GTK_CONTAINER (window), scrolled_window);
        gtk_window_set_default_size (GTK_WINDOW (window), 400, 400);
        gtk_widget_show_all (window);


        return 0;

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