status/autoRotate: Port to quick settings

On devices where auto-rotation is supported, (un)locking the
orientation is a common enough action to not bury it in a menu.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2392>
This commit is contained in:
Florian Müllner 2022-07-27 03:46:43 +02:00 committed by Marge Bot
parent 80d1f68c77
commit 4d931c2c41
5 changed files with 50 additions and 21 deletions

View File

@ -133,6 +133,7 @@
<file>ui/components/keyring.js</file>
<file>ui/status/accessibility.js</file>
<file>ui/status/autoRotate.js</file>
<file>ui/status/brightness.js</file>
<file>ui/status/dwellClick.js</file>
<file>ui/status/location.js</file>

View File

@ -425,6 +425,7 @@ class QuickSettings extends PanelMenu.Button {
this._thunderbolt = new imports.ui.status.thunderbolt.Indicator();
this._nightLight = new imports.ui.status.nightLight.Indicator();
this._rfkill = new imports.ui.status.rfkill.Indicator();
this._autoRotate = new imports.ui.status.autoRotate.Indicator();
this._unsafeMode = new UnsafeModeIndicator();
this._power = new imports.ui.status.power.Indicator();
@ -435,6 +436,7 @@ class QuickSettings extends PanelMenu.Button {
if (this._bluetooth)
this._indicators.add_child(this._bluetooth);
this._indicators.add_child(this._rfkill);
this._indicators.add_child(this._autoRotate);
this._indicators.add_child(this._unsafeMode);
this._indicators.add_child(this._power);
@ -445,6 +447,7 @@ class QuickSettings extends PanelMenu.Button {
this._addItems(this._bluetooth.quickSettingsItems);
this._addItems(this._nightLight.quickSettingsItems);
this._addItems(this._rfkill.quickSettingsItems);
this._addItems(this._autoRotate.quickSettingsItems);
this._addItems(this._unsafeMode.quickSettingsItems);
this._addItems(this._power.quickSettingsItems);
}

View File

@ -0,0 +1,45 @@
/* exported Indicator */
const {Gio, GObject} = imports.gi;
const SystemActions = imports.misc.systemActions;
const {QuickToggle, SystemIndicator} = imports.ui.quickSettings;
const RotationToggle = GObject.registerClass(
class RotationToggle extends QuickToggle {
_init() {
this._systemActions = new SystemActions.getDefault();
super._init({
label: _('Auto Rotate'),
});
this._systemActions.bind_property('can-lock-orientation',
this, 'visible',
GObject.BindingFlags.DEFAULT |
GObject.BindingFlags.SYNC_CREATE);
this._systemActions.bind_property('orientation-lock-icon',
this, 'icon-name',
GObject.BindingFlags.DEFAULT |
GObject.BindingFlags.SYNC_CREATE);
this._settings = new Gio.Settings({
schema_id: 'org.gnome.settings-daemon.peripherals.touchscreen',
});
this._settings.bind('orientation-lock',
this, 'checked',
Gio.SettingsBindFlags.INVERT_BOOLEAN);
this.connect('clicked',
() => this._systemActions.activateLockOrientation());
}
});
var Indicator = GObject.registerClass(
class Indicator extends SystemIndicator {
_init() {
super._init();
this.quickSettingsItems.push(new RotationToggle());
}
});

View File

@ -62,27 +62,6 @@ class Indicator extends PanelMenu.SystemIndicator {
let bindFlags = GObject.BindingFlags.DEFAULT | GObject.BindingFlags.SYNC_CREATE;
let item;
item = new PopupMenu.PopupImageMenuItem(
this._systemActions.getName('lock-orientation'),
this._systemActions.orientation_lock_icon);
item.connect('activate', () => {
this.menu.itemActivated(BoxPointer.PopupAnimation.NONE);
this._systemActions.activateLockOrientation();
});
this.menu.addMenuItem(item);
this._orientationLockItem = item;
this._systemActions.bind_property('can-lock-orientation',
this._orientationLockItem, 'visible',
bindFlags);
this._systemActions.connect('notify::orientation-lock-icon', () => {
let iconName = this._systemActions.orientation_lock_icon;
let labelText = this._systemActions.getName("lock-orientation");
this._orientationLockItem.setIcon(iconName);
this._orientationLockItem.label.text = labelText;
});
let app = this._settingsApp = Shell.AppSystem.get_default().lookup_app(
'org.gnome.Settings.desktop');
if (app) {

View File

@ -56,6 +56,7 @@ js/ui/searchController.js
js/ui/shellEntry.js
js/ui/shellMountOperation.js
js/ui/status/accessibility.js
js/ui/status/autoRotate.js
js/ui/status/bluetooth.js
js/ui/status/brightness.js
js/ui/status/dwellClick.js