You are not logged in.
Hi!
I'm trying to develop a gnome shell extension, more precisely, a modification of the globalmenu extension. I want the old gnome2-globalmenu style instead of what have been already ported to gnome 3. So I've got a problem with my PopupMenu :
I've got the menu but I can't click on it, the cursor doesn't have any effect on the menu, I can only click through all the menu items. The panel button code is shown below :
function MyButton(label, path, app) {
this._init(label, path, app);
}
MyButton.prototype = {
__proto__: PanelMenu.Button.prototype,
_init: function(label, path, app) {
PanelMenu.Button.prototype._init.call(this, 0.0);
this._metaDisplay = global.screen.get_display();
this._targetApp = app;
let bin = new St.Bin();
this.actor.add_actor(bin);
this.actor.reactive = true;
this._label = new St.Label({ style_class: 'panel-globalmenu-item',
text: label
});
bin.set_child(this._label);
/*this._visible = !Main.overview.visible;
if (!this._visible)
this.actor.hide();
Main.overview.connect('hiding', Lang.bind(this, function () {
this.show();
}));
Main.overview.connect('showing', Lang.bind(this, function () {
this.hide();
}));*/
this.menu.connect('open-state-changed', Lang.bind(this, this.refreshMenu, path, this.menu));
},
refreshMenu: function(obj, open, path, menu) {
if(!open) {
return false;
}
var xwindow = this._getTargetXWindow();
if(xwindow != 0) {
var manager = new Manager();
manager.GetUiRemote(xwindow, path,
Lang.bind(this, function(result, error, xwindow) {
this.rebuildMenu(menu, path, result, xwindow);
}, xwindow)
);
}
return false;
},
rebuildMenu: function(menu, path, ui, xwindow) {
var xml = XML('<menu>'+ui+'</menu>');
var i = 0;
menu.removeAll();
var current_group = new PopupMenu.PopupMenuSection();
for each (var item in xml.*) {
var visible = !(item.@visible.toString() == "false");
var sensitive = !(item.@sensitive.toString() == "false");
var menuitem = null;
switch(item.name().toString()) {
case "radio":
case "check":
var active = (item.@active.toString()=="true")
menuitem = new PopupMenu.PopupSwitchMenuItem(item.@label.toString(), active);
break;
case "item":
if(item.@submenu.toString() == "true") {
menuitem = new PopupMenu.PopupSubMenuMenuItem(item.@label.toString());
menuitem.menu = new PopupSubMenu(menuitem.actor, menuitem._triangle);
menuitem.menu.connect('open-state-changed', Lang.bind(menuitem, menuitem._subMenuOpenStateChanged));
menuitem.menu.connect('pre-open-state-changed',
Lang.bind(this, this.refreshMenu, path + i + '/', menuitem.menu));
} else {
menuitem = new PopupMenu.PopupMenuItem(item.@label.toString());
}
break;
case "separator":
//menuitem = new PopupMenu.PopupSeparatorMenuItem();
if(visible) {
menu.addMenuItem(current_group);
current_group = new PopupMenu.PopupMenuSection();
}
break;
case "empty":
case "tearoff":
default:
menuitem = new PopupMenu.PopupMenuItem(item.name().toString());
visible = false;
break;
}
if(menuitem) {
if(item.@tooltip.toString() != "") {
menuitem.actor.tooltip_text = item.@tooltip.toString();
menuitem.actor.has_tooltip = true;
}
menuitem.actor.visible = visible;
if(!sensitive) {
menuitem.actor.add_style_pseudo_class('insensitive');
}
menuitem.connect("activate", Lang.bind(this, function(menuitem, event, xwindow, path) {
var manager = new Manager();
manager.EmitRemote(xwindow, path);
}, xwindow, path + i));
current_group.addMenuItem(menuitem);
}
i++;
}
menu.addMenuItem(current_group);
if (path == "/" && i == 1) {
var quitMenu = new PopupMenu.PopupMenuItem("Close %s".format(this._targetApp.get_name()));
menu.addMenuItem(quitMenu);
quitMenu.connect('activate', Lang.bind(this, this._onQuit));
}
},
_getTargetXWindow: function() {
if (this._targetApp == null)
return 0;
var list = this._targetApp.get_windows();
var window = list[0];
return GlobalMenu.meta_window_get_xwindow(window);
}
};
I don't know how to solve this issue, maybe someone could help me.
Offline