您能帮我理解为什么以下代码无法正常运行吗?右键单击时看不到托盘图标。
消息显然不是贬值的根本原因 我的错是什么?
我的来源是Vala gnome project in GTk2
在Gtk3中测试的代码是
using Gtk;
//valac --pkg=gtk+-3.0 tray.vala
public class Main {
class AppStatusIcon : Window {
private StatusIcon trayicon;
private Gtk.Menu menuSystem;
public AppStatusIcon() {
/* Create tray icon */
trayicon = new StatusIcon.from_stock(Stock.HOME);
trayicon.set_tooltip_text ("Tray");
trayicon.set_visible(true);
trayicon.activate.connect(about_clicked);
create_menuSystem();
trayicon.popup_menu.connect(menuSystem_popup);
}
/* Create menu for right button */
public void create_menuSystem() {
menuSystem = new Gtk.Menu();
var menuAbout = new ImageMenuItem.from_stock(Stock.ABOUT, null);
menuAbout.activate.connect(about_clicked);
menuSystem.append(menuAbout);
var menuQuit = new ImageMenuItem.from_stock(Stock.QUIT, null);
menuQuit.activate.connect(Gtk.main_quit);
menuSystem.append(menuQuit);
menuSystem.show_all();
}
/* Show popup menu on right button */
private void menuSystem_popup(uint button, uint time) {
menuSystem.popup(null, null, null, button, time);
}
private void about_clicked() {
var about = new AboutDialog();
about.set_version("0.0.0");
about.set_program_name("Tray");
about.set_comments("Tray utility");
about.set_copyright("vala");
about.run();
about.hide();
}
}
public static int main (string[] args) {
Gtk.init(ref args);
var App = new AppStatusIcon();
App.hide();
Gtk.main();
return 0;
}
}
最新消息:现在valac不接受 menuSystem = new Menu(); 这是歧义的Gtk.Menu或GLib.Menu 我选择了 menuSystem = new Gtk.Menu();
多谢