Commit 30861d48 authored by Marco Trevisan's avatar Marco Trevisan 🎺 Committed by Florian Müllner

popupMenu: Make sensitive a Menu and MenuItem property

Use 'sensitive' as native gobject property for PopupBaseMenuItem, while simulate
it for PopupMenuBase.

GNOME/gnome-shell!499
parent a23391ea
......@@ -57,10 +57,13 @@ var PopupBaseMenuItem = GObject.registerClass({
GObject.ParamFlags.READWRITE,
GObject.TYPE_BOOLEAN,
false),
'sensitive': GObject.ParamSpec.boolean('sensitive', 'sensitive', 'sensitive',
GObject.ParamFlags.READWRITE,
GObject.TYPE_BOOLEAN,
true),
},
Signals: {
'activate': { param_types: [Clutter.Event.$gtype] },
'sensitive-changed': {},
}
}, class PopupBaseMenuItem extends St.BoxLayout {
_init(params) {
......@@ -204,15 +207,15 @@ var PopupBaseMenuItem = GObject.registerClass({
}
syncSensitive() {
let sensitive = this.getSensitive();
let sensitive = this.sensitive;
this.reactive = sensitive;
this.can_focus = sensitive;
this.emit('sensitive-changed');
this.notify('sensitive');
return sensitive;
}
getSensitive() {
let parentSensitive = this._parent ? this._parent.getSensitive() : true;
let parentSensitive = this._parent ? this._parent.sensitive : true;
return this._activatable && this._sensitive && parentSensitive;
}
......@@ -224,6 +227,14 @@ var PopupBaseMenuItem = GObject.registerClass({
this.syncSensitive();
}
get sensitive() {
return this.getSensitive();
}
set sensitive(sensitive) {
this.setSensitive(sensitive);
}
setOrnament(ornament) {
if (ornament == this._ornament)
return;
......@@ -449,13 +460,21 @@ var PopupMenuBase = class {
}
getSensitive() {
let parentSensitive = this._parent ? this._parent.getSensitive() : true;
let parentSensitive = this._parent ? this._parent.sensitive : true;
return this._sensitive && parentSensitive;
}
setSensitive(sensitive) {
this._sensitive = sensitive;
this.emit('sensitive-changed');
this.emit('notify::sensitive');
}
get sensitive() {
return this.getSensitive();
}
set sensitive(sensitive) {
this.setSensitive(sensitive);
}
_sessionUpdated() {
......@@ -541,8 +560,8 @@ var PopupMenuBase = class {
this.emit('active-changed', null);
}
});
menuItem._sensitiveChangeId = menuItem.connect('sensitive-changed', () => {
let sensitive = menuItem.getSensitive();
menuItem._sensitiveChangeId = menuItem.connect('notify::sensitive', () => {
let sensitive = menuItem.sensitive;
if (!sensitive && this._activeMenuItem == menuItem) {
if (!this.actor.navigate_focus(menuItem.actor,
St.DirectionType.TAB_FORWARD,
......@@ -558,7 +577,7 @@ var PopupMenuBase = class {
this.itemActivated(BoxPointer.PopupAnimation.FULL);
});
menuItem._parentSensitiveChangeId = this.connect('sensitive-changed', () => {
menuItem._parentSensitiveChangeId = this.connect('notify::sensitive', () => {
menuItem.syncSensitive();
});
......@@ -657,8 +676,8 @@ var PopupMenuBase = class {
let parentClosingId = this.connect('menu-closed', () => {
menuItem.emit('menu-closed');
});
let subMenuSensitiveChangedId = this.connect('sensitive-changed', () => {
menuItem.emit('sensitive-changed');
let subMenuSensitiveChangedId = this.connect('notify::sensitive', () => {
menuItem.emit('notify::sensitive');
});
menuItem.connect('destroy', () => {
......@@ -897,6 +916,10 @@ var PopupDummyMenu = class {
return true;
}
get sensitive() {
return this.getSensitive();
}
open() { this.emit('open-state-changed', true); }
close() { this.emit('open-state-changed', false); }
toggle() {}
......@@ -936,7 +959,11 @@ var PopupSubMenu = class extends PopupMenuBase {
}
getSensitive() {
return this._sensitive && this.sourceActor._delegate.getSensitive();
return this._sensitive && this.sourceActor.sensitive;
}
get sensitive() {
return this.getSensitive();
}
open(animate) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment