How can I disable editting for GtkTextView in C?

Deadly 提交于 2019-12-13 03:24:14

问题


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:


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.



来源:https://stackoverflow.com/questions/2738897/how-can-i-disable-editting-for-gtktextview-in-c

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!