TextView height incorrect when inserted in already show()n parent

If you insert a TextView with some long line of text and word wrapping
enabled, it seems that its initial height request remains the same as
it would if hexpand were set to false. But, this only happens when
inserting into a parent that has already had show() called on it. A
test case is below. If someone could tell me some workaround I'd
appreciate it.

Its worth noting that if you click on the textview, it will fix
itself. It seems similar to bug 540909, but this doesn't involve any
notebooks. Just a Window, Grid, and TextView.
A line-wrapping GtkLabel does not exhibit this behavior (it always
renders as if TRIGGER_BUG == FALSE).

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


int main(int argc, char** argv) {
	gtk_init(&argc, &argv);
	GtkWidget *window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
	GtkWidget *grid = gtk_grid_new();
	GtkWidget *label = gtk_label_new("----------------------");
	GtkTextView *tv = GTK_TEXT_VIEW(gtk_text_view_new());
	GtkTextBuffer *tb = gtk_text_view_get_buffer(tv);

	gtk_window_set_default_size(GTK_WINDOW(window), 500, 800);
	gtk_orientable_set_orientation(GTK_ORIENTABLE(grid), GTK_ORIENTATION_VERTICAL);

	gchar *text = "The quick brown fox jumps over the lazy dog. Pack my
box with five dozen liquor jugs. A quick movement of the enemy will
jepordize six gunboats. The quick brown fox jumps over the lazy dog.";
	gtk_widget_set_hexpand(GTK_WIDGET(tv), TRUE);
	gtk_text_view_set_wrap_mode(tv, GTK_WRAP_WORD);
	gtk_text_buffer_set_text(tb, text, strlen(text));

	gtk_container_add(GTK_CONTAINER(grid), GTK_WIDGET(tv));
	gtk_container_add(GTK_CONTAINER(grid), label);

		gtk_widget_show_all (window);

	gtk_container_add(GTK_CONTAINER(window), grid);

	gtk_widget_show_all (window);
	return 0;

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