2023-07-10 09:53:00 +00:00
|
|
|
import Gio from 'gi://Gio';
|
|
|
|
import GObject from 'gi://GObject';
|
2023-06-08 04:52:46 +00:00
|
|
|
|
2023-07-10 09:53:00 +00:00
|
|
|
import * as SystemActions from '../../misc/systemActions.js';
|
2022-07-27 01:46:43 +00:00
|
|
|
|
2023-07-10 09:53:00 +00:00
|
|
|
import {QuickToggle, SystemIndicator} from '../quickSettings.js';
|
2022-07-27 01:46:43 +00:00
|
|
|
|
|
|
|
const RotationToggle = GObject.registerClass(
|
|
|
|
class RotationToggle extends QuickToggle {
|
|
|
|
_init() {
|
|
|
|
this._systemActions = new SystemActions.getDefault();
|
|
|
|
|
|
|
|
super._init({
|
2023-01-30 20:32:39 +00:00
|
|
|
title: _('Auto Rotate'),
|
2022-07-27 01:46:43 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
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());
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2023-07-10 09:53:00 +00:00
|
|
|
export const Indicator = GObject.registerClass(
|
2022-07-27 01:46:43 +00:00
|
|
|
class Indicator extends SystemIndicator {
|
|
|
|
_init() {
|
|
|
|
super._init();
|
|
|
|
|
|
|
|
this.quickSettingsItems.push(new RotationToggle());
|
|
|
|
}
|
|
|
|
});
|