views:

75

answers:

1

I tried this one and it generates a textview window:

http://zetcode.com/tutorials/gtktutorial/gtktextview/

But I don't want it to be editable.

BTW,how can I show the scroll bar when the text overflows?

+1  A: 

Check http://library.gnome.org/devel/gtk/stable/GtkTextView.html:

There's a gtk_text_view_set_editable function.

You can add scrollbars to widgets by adding them to a GtkScrolledWindow. Eg:

GtkWidget* scrolled = gtk_scrolled_window_new(NULL, NULL);
gtk_container_add (GTK_CONTAINER (scrolled), view);

And then instead of calling pack_start with view, call it with scrolled.

For centering, a GtkScrolledWindow isn't a top-level window so its position depends on the parent container (a VBox in the example). There are parameters of pack_start for padding etc which might get what you want.

fgb
I used `gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER);` for a normal window,but seems it's not working for scrolled window?
Gtker