我如何禁用编辑C中的GtkTextView? [英] How can I disable editting for GtkTextView in C?

查看:288
本文介绍了我如何禁用编辑C中的GtkTextView?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试过这个,它会生成一个TextView窗口:

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



但我不希望它是可编辑的。

顺便说一句,如何在文本溢出时显示滚动条?

解决方案

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



有一个 gtk_text_view_set_editable 函数。



您可以通过将小工具添加到 GtkScrolledWindow 中来添加滚动条。例如:

  GtkWidget * scrolled = gtk_scrolled_window_new(NULL,NULL); 
gtk_container_add(GTK_CONTAINER(滚动),查看);

然后,不要使用视图调用pack_start,而应使用滚动来调用它。



为了居中, GtkScrolledWindow 不是顶层窗口,所以它的位置取决于父容器(a VBox 在示例中)。有 pack_start 等参数可以得到你想要的内容。


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?

解决方案

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.

这篇关于我如何禁用编辑C中的GtkTextView?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆