Bug in GtkTextView?



Hello,

I have following problem with GtkTextView: when I add more than 9 lines
(I determined this value using trial and error method) only bottom part
of the text is visible. The widget however is big enough for all the
text to fit in and there is empty space at the bottom. When window
containing the widget is resized the text is 'scrolled' down and all of
it becomes visible. Do I miss something? What Can I do to make the whole
text visible?

Attached is simple program that creates GtkTextView and adds 20 lines of
random ;) text into it. I use GTK+ 2.0.5

-- 
[Krzysztof Luks]
[kluks<at>iq.pl]
#include <gtk/gtk.h>

int main(int argc, char *argv[])
{
	GtkWidget *win;
	GtkWidget *textview;
	GtkTextBuffer *buff;
	GtkTextIter iter;
	gchar *txt;
	int i, j;

	gtk_init(&argc, &argv);

	win = gtk_window_new(GTK_WINDOW_TOPLEVEL);
	textview = gtk_text_view_new();

	buff = gtk_text_view_get_buffer(GTK_TEXT_VIEW(textview));
	gtk_text_buffer_get_iter_at_offset(GTK_TEXT_BUFFER(buff), &iter, 0);
	
	/* create 20 lines of text, each line contains 78 characters and
	 * newline */
	for(i = 0; i < 20; i++) {
		txt = (gchar *) g_malloc0(80);
		for(j = 0; j < 79; j++)
			txt[j] = 'a'+i;
		txt[79] = '\n';
		gtk_text_buffer_insert(GTK_TEXT_BUFFER(buff), &iter, txt, -1);
	}

	gtk_container_add(GTK_CONTAINER(win), textview);
	gtk_widget_show_all(win);
	gtk_main();
	
	return 0;
}



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