[gnome-shell/T27795: 40/138] systemMenu: move orientation lock button to the system settings menu
- From: Georges Basile Stavracas Neto <gbsneto src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell/T27795: 40/138] systemMenu: move orientation lock button to the system settings menu
- Date: Tue, 1 Oct 2019 23:32:41 +0000 (UTC)
commit c918a14c5942bbb60fd9985be7dd2182a617245b
Author: Mario Sanchez Prada <mario endlessm com>
Date: Thu Sep 14 15:20:55 2017 +0100
systemMenu: move orientation lock button to the system settings menu
Instead of using a button in the user menu, move it to be a row in the
system settings.
https://phabricator.endlessm.com/T17488
js/js-resources.gresource.xml | 1 +
js/ui/panel.js | 3 ++
js/ui/status/orientation.js | 92 +++++++++++++++++++++++++++++++++++++++++++
js/ui/status/system.js | 16 --------
po/POTFILES.in | 1 +
5 files changed, 97 insertions(+), 16 deletions(-)
---
diff --git a/js/js-resources.gresource.xml b/js/js-resources.gresource.xml
index 36a909d497..215de58dcc 100644
--- a/js/js-resources.gresource.xml
+++ b/js/js-resources.gresource.xml
@@ -148,5 +148,6 @@
<file>ui/hotCorner.js</file>
<file>ui/monitor.js</file>
<file>ui/sideComponent.js</file>
+ <file>ui/status/orientation.js</file>
</gresource>
</gresources>
diff --git a/js/ui/panel.js b/js/ui/panel.js
index 7b0abdbc6f..de65a134a9 100644
--- a/js/ui/panel.js
+++ b/js/ui/panel.js
@@ -739,6 +739,7 @@ class AggregateMenu extends PanelMenu.Button {
this._screencast = new imports.ui.status.screencast.Indicator();
this._location = new imports.ui.status.location.Indicator();
this._nightLight = new imports.ui.status.nightLight.Indicator();
+ this._orientation = new imports.ui.status.orientation.Indicator();
this._thunderbolt = new imports.ui.status.thunderbolt.Indicator();
this._indicators.add_child(this._thunderbolt.indicators);
@@ -777,6 +778,7 @@ class AggregateMenu extends PanelMenu.Button {
}
this.menu.addMenuItem(this._remoteAccess.menu);
this.menu.addMenuItem(this._location.menu);
+ this.menu.addMenuItem(this._orientation.menu);
this.menu.addMenuItem(this._rfkill.menu);
this.menu.addMenuItem(this._power.menu);
this.menu.addMenuItem(this._nightLight.menu);
@@ -787,6 +789,7 @@ class AggregateMenu extends PanelMenu.Button {
this.menu.addMenuItem(this._brightness.menu);
menuLayout.addSizeChild(this._location.menu.actor);
+ menuLayout.addSizeChild(this._orientation.menu.actor);
menuLayout.addSizeChild(this._rfkill.menu.actor);
menuLayout.addSizeChild(this._power.menu.actor);
}
diff --git a/js/ui/status/orientation.js b/js/ui/status/orientation.js
new file mode 100644
index 0000000000..fe5309489c
--- /dev/null
+++ b/js/ui/status/orientation.js
@@ -0,0 +1,92 @@
+// -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*-
+
+const { Gio, Meta } = imports.gi;
+
+const Main = imports.ui.main;
+const PanelMenu = imports.ui.panelMenu;
+const PopupMenu = imports.ui.popupMenu;
+
+const SENSOR_BUS_NAME = 'net.hadess.SensorProxy';
+const SENSOR_OBJECT_PATH = '/net/hadess/SensorProxy';
+
+const SensorProxyInterface = '<node> \
+<interface name="net.hadess.SensorProxy"> \
+ <property name="HasAccelerometer" type="b" access="read"/> \
+</interface> \
+</node>';
+
+const SensorProxy = Gio.DBusProxy.makeProxyWrapper(SensorProxyInterface);
+
+const ORIENTATION_SCHEMA = 'org.gnome.settings-daemon.peripherals.touchscreen';
+const ORIENTATION_LOCK = 'orientation-lock';
+
+var Indicator = class extends PanelMenu.SystemIndicator {
+ constructor() {
+ super();
+
+ this._settings = new Gio.Settings({ schema_id: ORIENTATION_SCHEMA });
+ this._monitorManager = Meta.MonitorManager.get();
+
+ this._settings.connect(
+ 'changed::' + ORIENTATION_LOCK, this._updateOrientationLock.bind(this));
+ Main.layoutManager.connect(
+ 'monitors-changed', this._updateOrientationLock.bind(this));
+ Gio.DBus.system.watch_name(SENSOR_BUS_NAME,
+ Gio.BusNameWatcherFlags.NONE,
+ this._sensorProxyAppeared.bind(this),
+ () => {
+ this._sensorProxy = null;
+ this._updateOrientationLock();
+ });
+
+ this._item = new PopupMenu.PopupSubMenuMenuItem('', true);
+ this._item.icon.icon_name = 'find-location-symbolic';
+ this._item.label.text = _("Orientation Lock");
+ this.menu.addMenuItem(this._item);
+
+ this._onOffAction = this._item.menu.addAction(
+ _("Disable"), this._onOnOffAction.bind(this));
+
+ this._updateOrientationLock();
+ }
+
+ _sensorProxyAppeared() {
+ this._sensorProxy = new SensorProxy(
+ Gio.DBus.system,
+ SENSOR_BUS_NAME,
+ SENSOR_OBJECT_PATH,
+ (proxy, error) => {
+ if (error) {
+ log(error.message);
+ return;
+ }
+ this._sensorProxy.connect(
+ 'g-properties-changed',
+ this._updateOrientationLock.bind(this));
+ this._updateOrientationLock();
+ });
+ }
+
+ _updateOrientationLock() {
+ if (this._sensorProxy)
+ this._item.actor.visible = (this._sensorProxy.HasAccelerometer &&
+ this._monitorManager.get_is_builtin_display_on());
+ else
+ this._item.actor.visible = false;
+
+ let locked = this._settings.get_boolean('orientation-lock');
+ if (locked) {
+ this._item.icon.icon_name = 'rotation-locked-symbolic';
+ this._onOffAction.label.text = _("Disable");
+ } else {
+ this._item.icon.icon_name = 'rotation-allowed-symbolic';
+ this._onOffAction.label.text = _("Enable");
+ }
+ }
+
+ _onOnOffAction() {
+ let locked = this._settings.get_boolean('orientation-lock');
+ this._settings.set_boolean('orientation-lock', !locked);
+ this._updateOrientationLock();
+ }
+};
diff --git a/js/ui/status/system.js b/js/ui/status/system.js
index 8ca04481e0..41ddac13b3 100644
--- a/js/ui/status/system.js
+++ b/js/ui/status/system.js
@@ -242,21 +242,6 @@ var Indicator = class extends PanelMenu.SystemIndicator {
}
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.add(this._orientationLockAction, { expand: true, x_fill: false });
- this._systemActions.bind_property('can-lock-orientation',
- this._orientationLockAction,
- 'visible',
- bindFlags);
- this._systemActions.bind_property('orientation-lock-icon',
- this._orientationLockAction.child,
- 'icon-name',
- bindFlags);
-
this._lockScreenAction = this._createActionButton('changes-prevent', _("Lock"));
this._lockScreenAction.connect('clicked', () => {
this.menu.itemActivated(BoxPointer.PopupAnimation.NONE);
@@ -295,7 +280,6 @@ var Indicator = class extends PanelMenu.SystemIndicator {
let visibilityGroup = [
this._settingsAction,
- this._orientationLockAction,
this._lockScreenAction,
this._altSwitcher.actor,
];
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 907aa037f6..77aea9b8b2 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -97,3 +97,4 @@ js/ui/appIconBar.js
js/ui/endlessButton.js
js/ui/forceAppExitDialog.js
js/ui/hotCorner.js
+js/ui/status/orientation.js
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]