mirror of
https://gitlab.com/asus-linux/asusctl.git
synced 2026-02-06 00:15:04 +01:00
gex: itemize the quicks and indicators
This commit is contained in:
39
desktop-extensions/gnome/src/modules/indicators/mini_led.ts
Normal file
39
desktop-extensions/gnome/src/modules/indicators/mini_led.ts
Normal file
@@ -0,0 +1,39 @@
|
||||
declare const imports: any;
|
||||
// REF: https://gjs.guide/extensions/development/creating.html
|
||||
|
||||
const { GObject, Gio } = imports.gi;
|
||||
const ExtensionUtils = imports.misc.extensionUtils;
|
||||
|
||||
const { SystemIndicator } = imports.ui.quickSettings;
|
||||
const QuickSettingsMenu = imports.ui.main.panel.statusArea.quickSettings;
|
||||
|
||||
import { Platform } from '../dbus/platform';
|
||||
import { QuickMiniLed } from '../quick_toggles/mini_led';
|
||||
|
||||
export const IndicateMiniLed = GObject.registerClass(
|
||||
class IndicateMiniLed extends SystemIndicator {
|
||||
constructor(dbus_platform: Platform) {
|
||||
super();
|
||||
|
||||
// Create the icon for the indicator
|
||||
this._indicator = this._addIndicator();
|
||||
this._indicator.icon_name = 'selection-mode-symbolic';
|
||||
|
||||
// Showing the indicator when the feature is enabled
|
||||
this._settings = ExtensionUtils.getSettings();
|
||||
this._settings.bind('mini-led-enabled',
|
||||
this._indicator, 'visible',
|
||||
Gio.SettingsBindFlags.DEFAULT);
|
||||
|
||||
// // Create the toggle and associate it with the indicator, being sure to
|
||||
// // destroy it along with the indicator
|
||||
// this.quickSettingsItems.push(new QuickMiniLed(dbus_platform));
|
||||
|
||||
// this.connect('destroy', () => {
|
||||
// this.quickSettingsItems.forEach((item: { destroy: () => any; }) => item.destroy());
|
||||
// });
|
||||
|
||||
// Add the indicator to the panel and the toggle to the menu
|
||||
QuickSettingsMenu._indicators.add_child(this);
|
||||
}
|
||||
});
|
||||
@@ -0,0 +1,50 @@
|
||||
declare const imports: any;
|
||||
|
||||
import { Platform } from "../dbus/platform";
|
||||
|
||||
const { GObject, Gio } = imports.gi;
|
||||
const ExtensionUtils = imports.misc.extensionUtils;
|
||||
|
||||
const { QuickToggle } = imports.ui.quickSettings;
|
||||
|
||||
export const QuickMiniLed = GObject.registerClass(
|
||||
class QuickMiniLed extends QuickToggle {
|
||||
private _dbus_platform: Platform;
|
||||
|
||||
constructor(dbus_platform: Platform) {
|
||||
super({
|
||||
title: 'MiniLED',
|
||||
iconName: 'selection-mode-symbolic',
|
||||
toggleMode: true,
|
||||
});
|
||||
this._dbus_platform = dbus_platform;
|
||||
this.label = 'MiniLED';
|
||||
this._settings = ExtensionUtils.getSettings();
|
||||
|
||||
this.connectObject(
|
||||
'destroy', () => this._settings.run_dispose(),
|
||||
'clicked', () => this._toggleMode(),
|
||||
this);
|
||||
|
||||
this.connect('destroy', () => {
|
||||
this.destroy();
|
||||
});
|
||||
|
||||
this._settings.bind('mini-led-enabled',
|
||||
this, 'checked',
|
||||
Gio.SettingsBindFlags.DEFAULT);
|
||||
|
||||
this._sync();
|
||||
}
|
||||
|
||||
_toggleMode() {
|
||||
this._dbus_platform.setMiniLedMode(this.checked);
|
||||
this._sync();
|
||||
}
|
||||
|
||||
_sync() {
|
||||
const checked = this._dbus_platform.getMiniLedMode();
|
||||
if (this.checked !== checked)
|
||||
this.set({ checked });
|
||||
}
|
||||
});
|
||||
@@ -0,0 +1,50 @@
|
||||
declare const imports: any;
|
||||
|
||||
import { Platform } from "../dbus/platform";
|
||||
|
||||
const { GObject, Gio } = imports.gi;
|
||||
const ExtensionUtils = imports.misc.extensionUtils;
|
||||
|
||||
const { QuickToggle } = imports.ui.quickSettings;
|
||||
|
||||
export const QuickPanelOd = GObject.registerClass(
|
||||
class QuickPanelOd extends QuickToggle {
|
||||
private _dbus_platform: Platform;
|
||||
|
||||
constructor(dbus_platform: Platform) {
|
||||
super({
|
||||
title: 'Panel Overdrive',
|
||||
iconName: 'selection-mode-symbolic',
|
||||
toggleMode: true,
|
||||
});
|
||||
this._dbus_platform = dbus_platform;
|
||||
this.label = 'Panel Overdrive';
|
||||
this._settings = ExtensionUtils.getSettings();
|
||||
|
||||
this.connectObject(
|
||||
'destroy', () => this._settings.run_dispose(),
|
||||
'clicked', () => this._toggleMode(),
|
||||
this);
|
||||
|
||||
this.connect('destroy', () => {
|
||||
this.destroy();
|
||||
});
|
||||
|
||||
this._settings.bind('panel-od-enabled',
|
||||
this, 'checked',
|
||||
Gio.SettingsBindFlags.DEFAULT);
|
||||
|
||||
this._sync();
|
||||
}
|
||||
|
||||
_toggleMode() {
|
||||
this._dbus_platform.setPanelOd(this.checked);
|
||||
this._sync();
|
||||
}
|
||||
|
||||
_sync() {
|
||||
const checked = this._dbus_platform.getPanelOd();
|
||||
if (this.checked !== checked)
|
||||
this.set({ checked });
|
||||
}
|
||||
});
|
||||
Reference in New Issue
Block a user