我在自己的用户界面中添加了一个Gtk.InfoBar,一切看起来都很好。在Glade中,我可以将信息栏切换为“已显示”,反之亦然。
在valadoc.org文档set_revealed
上列出了允许的方法。
公共无效set_revealed(已显示布尔)
将GtkInfoBar:revealed属性设置为显示。
但是在构建项目时,我会复习error: The name 'set_revealed' does not exist in the context of'Gtk.InfoBar'
我在做什么错了?
这是我的代码:
namespace Zeiterfassunggtk {
[GtkTemplate (ui = "/org/gnome/Zeiterfassunggtk/window.ui")]
public class Window : Gtk.ApplicationWindow {
[GtkChild]
Gtk.TreeView treeview1 = new Gtk.TreeView ();
[GtkChild]
Gtk.Button refreshbutton;
[GtkChild]
Gtk.MenuButton menubutton;
[GtkChild]
Gtk.Button menubuttonrefresh;
[GtkChild]
Gtk.Button menubuttonsave;
[GtkChild]
Gtk.Button menubuttonquit;
[GtkChild]
Gtk.InfoBar infobar1;
[GtkChild]
Gtk.Label infobar1label;
Gtk.TreeIter iter;
Gtk.ListStore liststore1 = new Gtk.ListStore (3, typeof (string), typeof (string), typeof (string));
private void setup_treeview (Gtk.TreeView treeview1) {
treeview1.set_model (liststore1);
treeview1.insert_column_with_attributes (-1, "Name", new Gtk.CellRendererText (), "text", 0, null);
treeview1.insert_column_with_attributes (-1, "Job", new Gtk.CellRendererText (), "text", 1, null);
treeview1.insert_column_with_attributes (-1, "Time", new Gtk.CellRendererText (), "text", 2, null);
liststore1.append (out iter);
liststore1.set (iter, 0, "Gerald", 1, "Job1", 2, "2018-01-01 18:23", -1);
}
void refresh () {
liststore1.append (out iter);
liststore1.set (iter, 0, "Gerald", 1, "Job1", 2, "2018-01-01 18:23", -1);
//infobar1.set_revealed (true);
}
void save () {
liststore1.append (out iter);
liststore1.set (iter, 0, "Gerald", 1, "Job2", 2, "2018-01-01 24:00", -1);
}
public Window (Gtk.Application app) {
Object (application: app);
this.maximize ();
this.setup_treeview (treeview1);
infobar1.set_revealed (false);
refreshbutton.clicked.connect (this.refresh);
menubuttonrefresh.clicked.connect (this.refresh);
menubuttonsave.clicked.connect (this.save);
menubuttonquit.clicked.connect (app.quit);
this.show_all ();
}
}
}
您可以在github.com
中找到完整的代码答案 0 :(得分:2)
似乎您正在导入旧版的Gtk +。您的window.ui
状态为<requires lib="gtk+" version="3.16"/>
。
set_revealed
可从[ Version ( since = "3.22.29" ) ]
获得。
您似乎必须进行更新。