我正在尝试使用 glade/gtk/vala 制作一个简单的应用程序。到目前为止,我有这个:
using Gtk;
class HelloWorldApp : GLib.Object {
const string UI = "test.glade";
public Window main_window;
[CCode (instance_pos = -1)]
public void on_btn_hello_clicked(Button source) {
stdout.printf("Hello, world");
}
construct {
Builder builder = new Builder();
builder.add_from_file(UI);
main_window = builder.get_object("window1") as Window;
main_window.destroy.connect(Gtk.main_quit);
builder.connect_signals(this);
}
}
class HelloWorld : GLib.Object {
public static int main(string[] args) {
Gtk.init (ref args);
HelloWorldApp h = new HelloWorldApp();
h.main_window.show_all();
Gtk.main();
return 0;
}
}
当我运行它时,它输出:(helloworld:22641):Gtk-WARNING **:找不到信号处理程序'on_btn_hello_clicked',但除了未调用处理程序之外运行良好
我究竟做错了什么?