popupMenu: Make sensitive a Menu and MenuItem property
Use 'sensitive' as native gobject property for PopupBaseMenuItem, while simulate it for PopupMenuBase. https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/499
This commit is contained in:
parent
a23391ea28
commit
30861d4800
@ -57,10 +57,13 @@ var PopupBaseMenuItem = GObject.registerClass({
|
|||||||
GObject.ParamFlags.READWRITE,
|
GObject.ParamFlags.READWRITE,
|
||||||
GObject.TYPE_BOOLEAN,
|
GObject.TYPE_BOOLEAN,
|
||||||
false),
|
false),
|
||||||
|
'sensitive': GObject.ParamSpec.boolean('sensitive', 'sensitive', 'sensitive',
|
||||||
|
GObject.ParamFlags.READWRITE,
|
||||||
|
GObject.TYPE_BOOLEAN,
|
||||||
|
true),
|
||||||
},
|
},
|
||||||
Signals: {
|
Signals: {
|
||||||
'activate': { param_types: [Clutter.Event.$gtype] },
|
'activate': { param_types: [Clutter.Event.$gtype] },
|
||||||
'sensitive-changed': {},
|
|
||||||
}
|
}
|
||||||
}, class PopupBaseMenuItem extends St.BoxLayout {
|
}, class PopupBaseMenuItem extends St.BoxLayout {
|
||||||
_init(params) {
|
_init(params) {
|
||||||
@ -204,15 +207,15 @@ var PopupBaseMenuItem = GObject.registerClass({
|
|||||||
}
|
}
|
||||||
|
|
||||||
syncSensitive() {
|
syncSensitive() {
|
||||||
let sensitive = this.getSensitive();
|
let sensitive = this.sensitive;
|
||||||
this.reactive = sensitive;
|
this.reactive = sensitive;
|
||||||
this.can_focus = sensitive;
|
this.can_focus = sensitive;
|
||||||
this.emit('sensitive-changed');
|
this.notify('sensitive');
|
||||||
return sensitive;
|
return sensitive;
|
||||||
}
|
}
|
||||||
|
|
||||||
getSensitive() {
|
getSensitive() {
|
||||||
let parentSensitive = this._parent ? this._parent.getSensitive() : true;
|
let parentSensitive = this._parent ? this._parent.sensitive : true;
|
||||||
return this._activatable && this._sensitive && parentSensitive;
|
return this._activatable && this._sensitive && parentSensitive;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -224,6 +227,14 @@ var PopupBaseMenuItem = GObject.registerClass({
|
|||||||
this.syncSensitive();
|
this.syncSensitive();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get sensitive() {
|
||||||
|
return this.getSensitive();
|
||||||
|
}
|
||||||
|
|
||||||
|
set sensitive(sensitive) {
|
||||||
|
this.setSensitive(sensitive);
|
||||||
|
}
|
||||||
|
|
||||||
setOrnament(ornament) {
|
setOrnament(ornament) {
|
||||||
if (ornament == this._ornament)
|
if (ornament == this._ornament)
|
||||||
return;
|
return;
|
||||||
@ -449,13 +460,21 @@ var PopupMenuBase = class {
|
|||||||
}
|
}
|
||||||
|
|
||||||
getSensitive() {
|
getSensitive() {
|
||||||
let parentSensitive = this._parent ? this._parent.getSensitive() : true;
|
let parentSensitive = this._parent ? this._parent.sensitive : true;
|
||||||
return this._sensitive && parentSensitive;
|
return this._sensitive && parentSensitive;
|
||||||
}
|
}
|
||||||
|
|
||||||
setSensitive(sensitive) {
|
setSensitive(sensitive) {
|
||||||
this._sensitive = sensitive;
|
this._sensitive = sensitive;
|
||||||
this.emit('sensitive-changed');
|
this.emit('notify::sensitive');
|
||||||
|
}
|
||||||
|
|
||||||
|
get sensitive() {
|
||||||
|
return this.getSensitive();
|
||||||
|
}
|
||||||
|
|
||||||
|
set sensitive(sensitive) {
|
||||||
|
this.setSensitive(sensitive);
|
||||||
}
|
}
|
||||||
|
|
||||||
_sessionUpdated() {
|
_sessionUpdated() {
|
||||||
@ -541,8 +560,8 @@ var PopupMenuBase = class {
|
|||||||
this.emit('active-changed', null);
|
this.emit('active-changed', null);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
menuItem._sensitiveChangeId = menuItem.connect('sensitive-changed', () => {
|
menuItem._sensitiveChangeId = menuItem.connect('notify::sensitive', () => {
|
||||||
let sensitive = menuItem.getSensitive();
|
let sensitive = menuItem.sensitive;
|
||||||
if (!sensitive && this._activeMenuItem == menuItem) {
|
if (!sensitive && this._activeMenuItem == menuItem) {
|
||||||
if (!this.actor.navigate_focus(menuItem.actor,
|
if (!this.actor.navigate_focus(menuItem.actor,
|
||||||
St.DirectionType.TAB_FORWARD,
|
St.DirectionType.TAB_FORWARD,
|
||||||
@ -558,7 +577,7 @@ var PopupMenuBase = class {
|
|||||||
this.itemActivated(BoxPointer.PopupAnimation.FULL);
|
this.itemActivated(BoxPointer.PopupAnimation.FULL);
|
||||||
});
|
});
|
||||||
|
|
||||||
menuItem._parentSensitiveChangeId = this.connect('sensitive-changed', () => {
|
menuItem._parentSensitiveChangeId = this.connect('notify::sensitive', () => {
|
||||||
menuItem.syncSensitive();
|
menuItem.syncSensitive();
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -657,8 +676,8 @@ var PopupMenuBase = class {
|
|||||||
let parentClosingId = this.connect('menu-closed', () => {
|
let parentClosingId = this.connect('menu-closed', () => {
|
||||||
menuItem.emit('menu-closed');
|
menuItem.emit('menu-closed');
|
||||||
});
|
});
|
||||||
let subMenuSensitiveChangedId = this.connect('sensitive-changed', () => {
|
let subMenuSensitiveChangedId = this.connect('notify::sensitive', () => {
|
||||||
menuItem.emit('sensitive-changed');
|
menuItem.emit('notify::sensitive');
|
||||||
});
|
});
|
||||||
|
|
||||||
menuItem.connect('destroy', () => {
|
menuItem.connect('destroy', () => {
|
||||||
@ -897,6 +916,10 @@ var PopupDummyMenu = class {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get sensitive() {
|
||||||
|
return this.getSensitive();
|
||||||
|
}
|
||||||
|
|
||||||
open() { this.emit('open-state-changed', true); }
|
open() { this.emit('open-state-changed', true); }
|
||||||
close() { this.emit('open-state-changed', false); }
|
close() { this.emit('open-state-changed', false); }
|
||||||
toggle() {}
|
toggle() {}
|
||||||
@ -936,7 +959,11 @@ var PopupSubMenu = class extends PopupMenuBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
getSensitive() {
|
getSensitive() {
|
||||||
return this._sensitive && this.sourceActor._delegate.getSensitive();
|
return this._sensitive && this.sourceActor.sensitive;
|
||||||
|
}
|
||||||
|
|
||||||
|
get sensitive() {
|
||||||
|
return this.getSensitive();
|
||||||
}
|
}
|
||||||
|
|
||||||
open(animate) {
|
open(animate) {
|
||||||
|
Loading…
Reference in New Issue
Block a user