Vala error: The name `set_revealed' does not exist in the context of `Gtk.InfoBar'
Vala error: The name `set_revealed' does not exist in the context of `Gtk.InfoBar'
我在 ui 中添加了一个 Gtk.InfoBar,一切看起来都很好。在 Glade 中,我可以将信息栏切换为显示,反之亦然。
在 valadoc.org 文档中 set_revealed
列出了允许的方法。
public void set_revealed (bool revealed)
Sets the GtkInfoBar:revealed property to revealed.
但是当我开始ui我的项目时,我收到了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
找到完整代码
您似乎正在导入旧版本的 Gtk+。您的 window.ui
表示 <requires lib="gtk+" version="3.16"/>
.
set_revealed
可从 [ Version ( since = "3.22.29" ) ]
购买。
看来你必须更新了。
我在 ui 中添加了一个 Gtk.InfoBar,一切看起来都很好。在 Glade 中,我可以将信息栏切换为显示,反之亦然。
在 valadoc.org 文档中 set_revealed
列出了允许的方法。
public void set_revealed (bool revealed)
Sets the GtkInfoBar:revealed property to revealed.
但是当我开始ui我的项目时,我收到了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
找到完整代码您似乎正在导入旧版本的 Gtk+。您的 window.ui
表示 <requires lib="gtk+" version="3.16"/>
.
set_revealed
可从 [ Version ( since = "3.22.29" ) ]
购买。
看来你必须更新了。