我从文件中读取每一行。添加到菜单。想要执行那些命令。但是当我单击时,出现空命令错误。
GLib-CRITICAL **:g_spawn_command_line_async:断言“command_line!= NULL”失败
ImageMenuItem menuApp;
void create_menuSystem() {
menuSystem = new Menu();
var menuSep = new SeparatorMenuItem();
//read ~/.config/traytool/app
var file = File.new_for_path(GLib.Environment.get_variable("HOME") + "/.config/traytool/app");
if(file.query_exists()) {
try {
var dis = new DataInputStream(file.read());
string line;
while((line = dis.read_line(null)) != null) {
menuApp = new ImageMenuItem.with_label(line);
menuApp.activate.connect(() => {
spawn_command_line_async(line); // <----- here
stdout.printf("..%s\n", line);
});
menuSystem.append(menuApp);
}
} catch(Error e) {
error("%s", e.message);
}
menuSystem.append(menuSep);
}
}