2016-08-02 54 views
0

如何編寫代碼on_applet_clicked功能,顯示GtkPopover與示例內容? gtk_popover_new()和接下來是什麼?GtkPopover和小程序

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); 
} 

回答

1

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

GTK +是客戶端應用程序工具包;它不能在窗口管理器中使用。

如果你想使用菜單的小程序,你必須導入它作爲使用PopupMenu實例:

const PopupMenu = imports.ui.popupMenu; 

PopupMenuItem實例及其子類來填充它。