popupMenu: Allow specifying an icon on PopupMenuBase.addAction()

This allows passing an optional icon parameter to addAction()
so that a PopupImageMenuItem instance is created instead of a
PopupMenuItem if an icon is specified.

https://bugzilla.gnome.org/show_bug.cgi?id=782166
This commit is contained in:
Mario Sanchez Prada 2017-05-08 11:38:16 +01:00
parent 28ca96064b
commit e38c26894b

View File

@ -467,8 +467,13 @@ const PopupMenuBase = new Lang.Class({
this._setSettingsVisibility(Main.sessionMode.allowSettings);
},
addAction: function(title, callback) {
let menuItem = new PopupMenuItem(title);
addAction: function(title, callback, icon) {
let menuItem;
if (icon != undefined)
menuItem = new PopupImageMenuItem(title, icon);
else
menuItem = new PopupMenuItem(title);
this.addMenuItem(menuItem);
menuItem.connect('activate', Lang.bind(this, function (menuItem, event) {
callback(event);