当我尝试从肉桂小程序打开 GtkWindow 时,整个桌面冻结。
文件中没有错误~/.cinnamon/glass.log
。
const Gtk = imports.gi.Gtk;
function MyApplet(orientation)
{
this._init(orientation);
}
MyApplet.prototype =
{
__proto__: Applet.IconApplet.prototype,
_init: function(orientation)
{
Applet.IconApplet.prototype._init.call(this, orientation);
try {
this.set_applet_icon_name("dialog-question");
this.set_applet_tooltip("test");
}
catch (e) {
global.logError(e);
};
},
on_applet_clicked: function(event)
{
Gtk.init(null, 0);
let mwindow = new Gtk.Window ({type : Gtk.WindowType.TOPLEVEL});
mwindow.title = "Hello World!";
mwindow.connect ("destroy", function(){Gtk.main_quit()});
mwindow.show();
Gtk.main();
}
};
function main(metadata, orientation)
{
let myApplet = new MyApplet(orientation);
return myApplet;
}
代码一直执行,直到Gtk.main()
没有窗口显示并且桌面被冻结。
任何人都知道如何使它正常工作?