[gnome-shell] js/status: Use menu items as actors
- From: Florian Müllner <fmuellner src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell] js/status: Use menu items as actors
- Date: Wed, 15 May 2019 17:34:53 +0000 (UTC)
commit 41dd744b7429358a4534e603570d4d1c8acc161b
Author: Marco Trevisan (Treviño) <mail 3v1n0 net>
Date: Fri Apr 12 16:00:49 2019 -0500
js/status: Use menu items as actors
All menu items are actors now, so remove all the actor property usages.
https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/499
js/ui/status/bluetooth.js | 4 ++--
js/ui/status/brightness.js | 10 +++++-----
js/ui/status/keyboard.js | 17 +++++++++--------
js/ui/status/location.js | 4 ++--
js/ui/status/network.js | 30 +++++++++++++++---------------
js/ui/status/nightLight.js | 2 +-
js/ui/status/power.js | 4 ++--
js/ui/status/remoteAccess.js | 4 ++--
js/ui/status/rfkill.js | 2 +-
js/ui/status/system.js | 30 +++++++++++++++---------------
js/ui/status/volume.js | 10 +++++-----
11 files changed, 59 insertions(+), 58 deletions(-)
---
diff --git a/js/ui/status/bluetooth.js b/js/ui/status/bluetooth.js
index 6282234ca..b1fda3356 100644
--- a/js/ui/status/bluetooth.js
+++ b/js/ui/status/bluetooth.js
@@ -118,9 +118,9 @@ var Indicator = class extends PanelMenu.SystemIndicator {
// Remember if there were setup devices and show the menu
// if we've seen setup devices and we're not hard blocked
if (nDevices > 0)
- this._item.actor.visible = !this._proxy.BluetoothHardwareAirplaneMode;
+ this._item.visible = !this._proxy.BluetoothHardwareAirplaneMode;
else
- this._item.actor.visible = this._proxy.BluetoothHasAirplaneMode &&
!this._proxy.BluetoothAirplaneMode;
+ this._item.visible = this._proxy.BluetoothHasAirplaneMode && !this._proxy.BluetoothAirplaneMode;
if (nConnectedDevices > 0)
/* Translators: this is the number of connected bluetooth devices */
diff --git a/js/ui/status/brightness.js b/js/ui/status/brightness.js
index 025f29908..7643274fb 100644
--- a/js/ui/status/brightness.js
+++ b/js/ui/status/brightness.js
@@ -37,12 +37,12 @@ var Indicator = class extends PanelMenu.SystemIndicator {
let icon = new St.Icon({ icon_name: 'display-brightness-symbolic',
style_class: 'popup-menu-icon' });
- this._item.actor.add(icon);
- this._item.actor.add(this._slider.actor, { expand: true });
- this._item.actor.connect('button-press-event', (actor, event) => {
+ this._item.add(icon);
+ this._item.add(this._slider.actor, { expand: true });
+ this._item.connect('button-press-event', (actor, event) => {
return this._slider.startDragging(event);
});
- this._item.actor.connect('key-press-event', (actor, event) => {
+ this._item.connect('key-press-event', (actor, event) => {
return this._slider.onKeyPressEvent(actor, event);
});
@@ -55,7 +55,7 @@ var Indicator = class extends PanelMenu.SystemIndicator {
_sync() {
let visible = this._proxy.Brightness >= 0;
- this._item.actor.visible = visible;
+ this._item.visible = visible;
if (visible)
this._slider.setValue(this._proxy.Brightness / 100.0);
}
diff --git a/js/ui/status/keyboard.js b/js/ui/status/keyboard.js
index 274147fe4..df8e9c2f1 100644
--- a/js/ui/status/keyboard.js
+++ b/js/ui/status/keyboard.js
@@ -15,17 +15,18 @@ const Util = imports.misc.util;
const INPUT_SOURCE_TYPE_XKB = 'xkb';
const INPUT_SOURCE_TYPE_IBUS = 'ibus';
-var LayoutMenuItem = class extends PopupMenu.PopupBaseMenuItem {
- constructor(displayName, shortName) {
- super();
+var LayoutMenuItem = GObject.registerClass(
+class LayoutMenuItem extends PopupMenu.PopupBaseMenuItem {
+ _init(displayName, shortName) {
+ super._init();
this.label = new St.Label({ text: displayName });
this.indicator = new St.Label({ text: shortName });
- this.actor.add(this.label, { expand: true });
- this.actor.add(this.indicator);
- this.actor.label_actor = this.label;
+ this.add(this.label, { expand: true });
+ this.add(this.indicator);
+ this.label_actor = this.label;
}
-};
+});
var InputSource = class {
constructor(type, id, displayName, shortName, index) {
@@ -857,7 +858,7 @@ class InputSourceIndicator extends PanelMenu.Button {
// but at least for now it is used as "allow popping up windows
// from shell menus"; we can always add a separate sessionMode
// option if need arises.
- this._showLayoutItem.actor.visible = Main.sessionMode.allowSettings;
+ this._showLayoutItem.visible = Main.sessionMode.allowSettings;
}
_sourcesChanged() {
diff --git a/js/ui/status/location.js b/js/ui/status/location.js
index f030ae81b..e565367bb 100644
--- a/js/ui/status/location.js
+++ b/js/ui/status/location.js
@@ -101,12 +101,12 @@ var Indicator = class extends PanelMenu.SystemIndicator {
_syncIndicator() {
if (this._managerProxy == null) {
this._indicator.visible = false;
- this._item.actor.visible = false;
+ this._item.visible = false;
return;
}
this._indicator.visible = this._managerProxy.InUse;
- this._item.actor.visible = this._indicator.visible;
+ this._item.visible = this._indicator.visible;
this._updateMenuLabels();
}
diff --git a/js/ui/status/network.js b/js/ui/status/network.js
index b24d608e4..8c5fb976b 100644
--- a/js/ui/status/network.js
+++ b/js/ui/status/network.js
@@ -389,8 +389,8 @@ var NMConnectionDevice = class NMConnectionDevice extends NMConnectionSection {
_sync() {
let nItems = this._connectionItems.size;
- this._autoConnectItem.actor.visible = (nItems == 0);
- this._deactivateItem.actor.visible = this._device.state > NM.DeviceState.DISCONNECTED;
+ this._autoConnectItem.visible = (nItems == 0);
+ this._deactivateItem.visible = this._device.state > NM.DeviceState.DISCONNECTED;
if (this._activeConnection == null) {
let activeConnection = this._device.active_connection;
@@ -477,7 +477,7 @@ var NMDeviceWired = class extends NMConnectionDevice {
}
_sync() {
- this.item.actor.visible = this._hasCarrier();
+ this.item.visible = this._hasCarrier();
super._sync();
}
@@ -1076,7 +1076,7 @@ var NMWirelessDialog = class extends ModalDialog.ModalDialog {
let newPos = Util.insertSorted(this._networks, network, this._networkSortFunction);
this._createNetworkItem(network);
- this._itemBox.insert_child_at_index(network.item.actor, newPos);
+ this._itemBox.insert_child_at_index(network.item, newPos);
}
this._syncView();
@@ -1094,7 +1094,7 @@ var NMWirelessDialog = class extends ModalDialog.ModalDialog {
network.accessPoints.splice(res.ap, 1);
if (network.accessPoints.length == 0) {
- network.item.actor.destroy();
+ network.item.destroy();
this._networks.splice(res.network, 1);
} else {
network.item.updateBestAP(network.accessPoints[0]);
@@ -1110,7 +1110,7 @@ var NMWirelessDialog = class extends ModalDialog.ModalDialog {
this._itemBox.remove_all_children();
this._networks.forEach(network => {
- this._itemBox.add_child(network.item.actor);
+ this._itemBox.add_child(network.item);
});
adjustment.value = scrollValue;
@@ -1118,25 +1118,25 @@ var NMWirelessDialog = class extends ModalDialog.ModalDialog {
_selectNetwork(network) {
if (this._selectedNetwork)
- this._selectedNetwork.item.actor.remove_style_pseudo_class('selected');
+ this._selectedNetwork.item.remove_style_pseudo_class('selected');
this._selectedNetwork = network;
this._updateSensitivity();
if (this._selectedNetwork)
- this._selectedNetwork.item.actor.add_style_pseudo_class('selected');
+ this._selectedNetwork.item.add_style_pseudo_class('selected');
}
_createNetworkItem(network) {
network.item = new NMWirelessDialogItem(network);
network.item.setActive(network == this._selectedNetwork);
network.item.connect('selected', () => {
- Util.ensureActorVisibleInScrollView(this._scrollView, network.item.actor);
+ Util.ensureActorVisibleInScrollView(this._scrollView, network.item);
this._selectNetwork(network);
});
- network.item.actor.connect('destroy', () => {
+ network.item.connect('destroy', () => {
let keyFocus = global.stage.key_focus;
- if (keyFocus && keyFocus.contains(network.item.actor))
+ if (keyFocus && keyFocus.contains(network.item))
this._itemBox.grab_key_focus();
});
}
@@ -1262,7 +1262,7 @@ var NMDeviceWireless = class {
_sync() {
this._toggleItem.label.text = this._client.wireless_enabled ? _("Turn Off") : _("Turn On");
- this._toggleItem.actor.visible = this._client.wireless_hardware_enabled;
+ this._toggleItem.visible = this._client.wireless_hardware_enabled;
this.item.icon.icon_name = this._getMenuIcon();
this.item.label.text = this._getStatus();
@@ -1452,7 +1452,7 @@ var NMVpnSection = class extends NMConnectionSection {
_sync() {
let nItems = this._connectionItems.size;
- this.item.actor.visible = (nItems > 0);
+ this.item.visible = (nItems > 0);
super._sync();
}
@@ -1535,7 +1535,7 @@ var DeviceCategory = class extends PopupMenu.PopupMenuSection {
this._summaryItem.menu.addSettingsAction(_('Network Settings'),
'gnome-network-panel.desktop');
- this._summaryItem.actor.hide();
+ this._summaryItem.hide();
}
@@ -1544,7 +1544,7 @@ var DeviceCategory = class extends PopupMenu.PopupMenuSection {
(prev, child) => prev + (child.visible ? 1 : 0), 0);
this._summaryItem.label.text = this._getSummaryLabel(nDevices);
let shouldSummarize = nDevices > MAX_DEVICE_ITEMS;
- this._summaryItem.actor.visible = shouldSummarize;
+ this._summaryItem.visible = shouldSummarize;
this.section.actor.visible = !shouldSummarize;
}
diff --git a/js/ui/status/nightLight.js b/js/ui/status/nightLight.js
index 353db92c3..089a5cdf2 100644
--- a/js/ui/status/nightLight.js
+++ b/js/ui/status/nightLight.js
@@ -61,6 +61,6 @@ var Indicator = class extends PanelMenu.SystemIndicator {
: _("Night Light On");
this._disableItem.label.text = disabled ? _("Resume")
: _("Disable Until Tomorrow");
- this._item.actor.visible = this._indicator.visible = visible;
+ this._item.visible = this._indicator.visible = visible;
}
};
diff --git a/js/ui/status/power.js b/js/ui/status/power.js
index 3279811da..252b0dc4e 100644
--- a/js/ui/status/power.js
+++ b/js/ui/status/power.js
@@ -96,11 +96,11 @@ var Indicator = class extends PanelMenu.SystemIndicator {
// Do we have batteries or a UPS?
let visible = this._proxy.IsPresent;
if (visible) {
- this._item.actor.show();
+ this._item.show();
this._percentageLabel.visible = this._desktopSettings.get_boolean(SHOW_BATTERY_PERCENTAGE);
} else {
// If there's no battery, then we use the power icon.
- this._item.actor.hide();
+ this._item.hide();
this._indicator.icon_name = 'system-shutdown-symbolic';
this._percentageLabel.hide();
return;
diff --git a/js/ui/status/remoteAccess.js b/js/ui/status/remoteAccess.js
index ab0b55f28..26851d219 100644
--- a/js/ui/status/remoteAccess.js
+++ b/js/ui/status/remoteAccess.js
@@ -53,10 +53,10 @@ var RemoteAccessApplet = class extends PanelMenu.SystemIndicator {
_sync() {
if (this._handles.size == 0) {
this._indicator.visible = false;
- this._item.actor.visible = false;
+ this._item.visible = false;
} else {
this._indicator.visible = true;
- this._item.actor.visible = true;
+ this._item.visible = true;
}
}
diff --git a/js/ui/status/rfkill.js b/js/ui/status/rfkill.js
index e818e8788..8cf4d157d 100644
--- a/js/ui/status/rfkill.js
+++ b/js/ui/status/rfkill.js
@@ -97,7 +97,7 @@ var Indicator = class extends PanelMenu.SystemIndicator {
let showAirplaneMode = this._manager.shouldShowAirplaneMode;
this._indicator.visible = (airplaneMode && showAirplaneMode);
- this._item.actor.visible = (airplaneMode && showAirplaneMode);
+ this._item.visible = (airplaneMode && showAirplaneMode);
this._offItem.setSensitive(!hwAirplaneMode);
if (hwAirplaneMode)
diff --git a/js/ui/status/system.js b/js/ui/status/system.js
index 1b0d10d8c..b7eaef72b 100644
--- a/js/ui/status/system.js
+++ b/js/ui/status/system.js
@@ -116,10 +116,10 @@ var Indicator = class extends PanelMenu.SystemIndicator {
this._createSubMenu();
- this._loginScreenItem.actor.connect('notify::visible',
- () => { this._updateMultiUser(); });
- this._logoutItem.actor.connect('notify::visible',
- () => { this._updateMultiUser(); });
+ this._loginScreenItem.connect('notify::visible',
+ () => { this._updateMultiUser(); });
+ this._logoutItem.connect('notify::visible',
+ () => { this._updateMultiUser(); });
// Whether shutdown is available or not depends on both lockdown
// settings (disable-log-out) and Polkit policy - the latter doesn't
// notify, so we update the menu item each time the menu opens or
@@ -142,7 +142,7 @@ var Indicator = class extends PanelMenu.SystemIndicator {
this._lockScreenAction.visible ||
this._altSwitcher.actor.visible);
- this._actionsItem.actor.visible = visible;
+ this._actionsItem.visible = visible;
}
_sessionUpdated() {
@@ -150,10 +150,10 @@ var Indicator = class extends PanelMenu.SystemIndicator {
}
_updateMultiUser() {
- let hasSwitchUser = this._loginScreenItem.actor.visible;
- let hasLogout = this._logoutItem.actor.visible;
+ let hasSwitchUser = this._loginScreenItem.visible;
+ let hasLogout = this._logoutItem.visible;
- this._switchUserSubMenu.actor.visible = hasSwitchUser || hasLogout;
+ this._switchUserSubMenu.visible = hasSwitchUser || hasLogout;
}
_updateSwitchUserSubMenu() {
@@ -208,7 +208,7 @@ var Indicator = class extends PanelMenu.SystemIndicator {
this._switchUserSubMenu.menu.addMenuItem(item);
this._loginScreenItem = item;
this._systemActions.bind_property('can-switch-user',
- this._loginScreenItem.actor,
+ this._loginScreenItem,
'visible',
bindFlags);
@@ -220,7 +220,7 @@ var Indicator = class extends PanelMenu.SystemIndicator {
this._switchUserSubMenu.menu.addMenuItem(item);
this._logoutItem = item;
this._systemActions.bind_property('can-logout',
- this._logoutItem.actor,
+ this._logoutItem,
'visible',
bindFlags);
@@ -236,7 +236,7 @@ var Indicator = class extends PanelMenu.SystemIndicator {
item = new PopupMenu.PopupBaseMenuItem({ reactive: false,
can_focus: false });
- this.buttonGroup = item.actor;
+ this.buttonGroup = item;
let app = this._settingsApp = Shell.AppSystem.get_default().lookup_app(
'gnome-control-center.desktop'
@@ -251,14 +251,14 @@ var Indicator = class extends PanelMenu.SystemIndicator {
log('Missing required core component Settings, expect trouble…');
this._settingsAction = new St.Widget();
}
- item.actor.add(this._settingsAction, { expand: true, x_fill: false });
+ item.add(this._settingsAction, { expand: true, x_fill: false });
this._orientationLockAction = this._createActionButton('', _("Orientation Lock"));
this._orientationLockAction.connect('clicked', () => {
this.menu.itemActivated(BoxPointer.PopupAnimation.NONE),
this._systemActions.activateLockOrientation();
});
- item.actor.add(this._orientationLockAction, { expand: true, x_fill: false });
+ item.add(this._orientationLockAction, { expand: true, x_fill: false });
this._systemActions.bind_property('can-lock-orientation',
this._orientationLockAction,
'visible',
@@ -273,7 +273,7 @@ var Indicator = class extends PanelMenu.SystemIndicator {
this.menu.itemActivated(BoxPointer.PopupAnimation.NONE);
this._systemActions.activateLockScreen();
});
- item.actor.add(this._lockScreenAction, { expand: true, x_fill: false });
+ item.add(this._lockScreenAction, { expand: true, x_fill: false });
this._systemActions.bind_property('can-lock-screen',
this._lockScreenAction,
'visible',
@@ -300,7 +300,7 @@ var Indicator = class extends PanelMenu.SystemIndicator {
bindFlags);
this._altSwitcher = new AltSwitcher(this._powerOffAction, this._suspendAction);
- item.actor.add(this._altSwitcher.actor, { expand: true, x_fill: false });
+ item.add(this._altSwitcher.actor, { expand: true, x_fill: false });
this._actionsItem = item;
this.menu.addMenuItem(item);
diff --git a/js/ui/status/volume.js b/js/ui/status/volume.js
index d555b426e..ae2497a93 100644
--- a/js/ui/status/volume.js
+++ b/js/ui/status/volume.js
@@ -41,12 +41,12 @@ var StreamSlider = class {
this._slider.connect('drag-end', this._notifyVolumeChange.bind(this));
this._icon = new St.Icon({ style_class: 'popup-menu-icon' });
- this.item.actor.add(this._icon);
- this.item.actor.add(this._slider.actor, { expand: true });
- this.item.actor.connect('button-press-event', (actor, event) => {
+ this.item.add(this._icon);
+ this.item.add(this._slider.actor, { expand: true });
+ this.item.connect('button-press-event', (actor, event) => {
return this._slider.startDragging(event);
});
- this.item.actor.connect('key-press-event', (actor, event) => {
+ this.item.connect('key-press-event', (actor, event) => {
return this._slider.onKeyPressEvent(actor, event);
});
@@ -93,7 +93,7 @@ var StreamSlider = class {
_updateVisibility() {
let visible = this._shouldBeVisible();
- this.item.actor.visible = visible;
+ this.item.visible = visible;
}
scroll(event) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]