[gnome-shell] popupMenu: Implement Switch as actor
- From: Florian Müllner <fmuellner src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell] popupMenu: Implement Switch as actor
- Date: Wed, 15 May 2019 17:35:13 +0000 (UTC)
commit 6ecb0a4546f643076f7bf51deb686be73a88aa88
Author: Marco Trevisan (Treviño) <mail 3v1n0 net>
Date: Fri Apr 12 16:04:16 2019 -0500
popupMenu: Implement Switch as actor
Switch is used only by menu items, and implement it extending St.Bin
https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/499
js/ui/popupMenu.js | 24 ++++++++++++------------
1 file changed, 12 insertions(+), 12 deletions(-)
---
diff --git a/js/ui/popupMenu.js b/js/ui/popupMenu.js
index 83a1d1ced..90319accc 100644
--- a/js/ui/popupMenu.js
+++ b/js/ui/popupMenu.js
@@ -291,26 +291,27 @@ class PopupSeparatorMenuItem extends PopupBaseMenuItem {
}
});
-var Switch = class {
- constructor(state) {
- this.actor = new St.Bin({ style_class: 'toggle-switch',
- accessible_role: Atk.Role.CHECK_BOX,
- can_focus: true });
+var Switch = GObject.registerClass(
+class Switch extends St.Bin {
+ _init(state) {
+ super._init({ style_class: 'toggle-switch',
+ accessible_role: Atk.Role.CHECK_BOX,
+ can_focus: true });
this.setToggleState(state);
}
setToggleState(state) {
if (state)
- this.actor.add_style_pseudo_class('checked');
+ this.add_style_pseudo_class('checked');
else
- this.actor.remove_style_pseudo_class('checked');
+ this.remove_style_pseudo_class('checked');
this.state = state;
}
toggle() {
this.setToggleState(!this.state);
}
-};
+});
var PopupSwitchMenuItem = GObject.registerClass({
Signals: { 'toggled': { param_types: [GObject.TYPE_BOOLEAN] }, },
@@ -334,7 +335,7 @@ class PopupSwitchMenuItem extends PopupBaseMenuItem {
this._statusLabel = new St.Label({ text: '',
style_class: 'popup-status-menu-item'
});
- this._statusBin.child = this._switch.actor;
+ this._statusBin.child = this._switch;
}
setStatus(text) {
@@ -344,7 +345,7 @@ class PopupSwitchMenuItem extends PopupBaseMenuItem {
this.reactive = false;
this.accessible_role = Atk.Role.MENU_ITEM;
} else {
- this._statusBin.child = this._switch.actor;
+ this._statusBin.child = this._switch;
this.reactive = true;
this.accessible_role = Atk.Role.CHECK_MENU_ITEM;
}
@@ -352,9 +353,8 @@ class PopupSwitchMenuItem extends PopupBaseMenuItem {
}
activate(event) {
- if (this._switch.actor.mapped) {
+ if (this._switch.mapped)
this.toggle();
- }
// we allow pressing space to toggle the switch
// without closing the menu
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]