0

如何在on_applet_clicked显示GtkPopover示例内容的函数中编写代码?gtk_popover_new ()接下来呢?

const Applet = imports.ui.applet;
const Util = imports.misc.util;

function MyApplet(orientation, panel_height, instance_id) {
    this._init(orientation, panel_height, instance_id);
}

MyApplet.prototype = {
    __proto__: Applet.IconApplet.prototype,

    _init: function(orientation, panel_height, instance_id) {
        Applet.IconApplet.prototype._init.call(this, orientation, panel_height, instance_id);

        this.set_applet_icon_name("folder-system");
        this.set_applet_tooltip(_("Click here to kill a window"));
    },

    on_applet_clicked: function() {
        // here
    }
};

function main(metadata, orientation, panel_height, instance_id) {
    return new MyApplet(orientation, panel_height, instance_id);
}
4

1 回答 1

1

您不能在 Cinnamon 窗口管理器 UI 元素中使用 GTK+。

GTK+ 是一个客户端应用工具包;它不能在窗口管理器中使用。

如果您想为小程序使用菜单,则必须PopupMenu通过将其导入来使用实例:

const PopupMenu = imports.ui.popupMenu;

PopupMenuItem并用实例及其子类填充它。

于 2016-08-02T21:34:19.523 回答