mirror of
https://gitlab.com/asus-linux/asusctl.git
synced 2026-02-06 00:15:04 +01:00
gex: rename gnome-44, add gnome-45
This commit is contained in:
@@ -0,0 +1,169 @@
|
||||
import { AnimeDbus } from "../dbus/animatrix";
|
||||
import { Supported } from "../dbus/supported";
|
||||
import { Platform } from "../dbus/platform";
|
||||
|
||||
import { addQuickSettingsItems } from "../helpers";
|
||||
import { MenuToggleAnimeBuiltins, MenuToggleAnimePower } from "../menu_toggles/anime";
|
||||
import { MenuTogglePanelOd } from "../menu_toggles/panel_od";
|
||||
import { MenuToggleMiniLed } from "../menu_toggles/mini_led";
|
||||
|
||||
import GObject from 'gi://GObject';
|
||||
|
||||
import * as AsusExtension from "../../extension";
|
||||
// import {PopupMenu, PopupMenuSection} from 'resource:///org/gnome/shell/ui/popupMenu.js';
|
||||
import * as PopupMenu from 'resource:///org/gnome/shell/ui/popupMenu.js';
|
||||
import {QuickMenuToggle} from 'resource:///org/gnome/shell/ui/quickSettings.js';
|
||||
|
||||
export const FeatureMenuToggle = GObject.registerClass(
|
||||
class FeatureMenuToggle extends QuickMenuToggle {
|
||||
private _dbus_supported: Supported;
|
||||
private _dbus_platform: Platform;
|
||||
private _dbus_anime: AnimeDbus;
|
||||
|
||||
public miniLed: typeof MenuToggleMiniLed;
|
||||
public panelOd: typeof MenuTogglePanelOd;
|
||||
public animeDisplayPower: typeof MenuToggleAnimePower;
|
||||
public animePowersaveAnim: typeof MenuToggleAnimeBuiltins;
|
||||
private primary = "mini-led";
|
||||
|
||||
constructor(dbus_supported: Supported, dbus_platform: Platform, dbus_anime: AnimeDbus) {
|
||||
super({
|
||||
title: "Laptop",
|
||||
iconName: "selection-mode-symbolic",
|
||||
toggleMode: true,
|
||||
});
|
||||
this._dbus_supported = dbus_supported;
|
||||
this._dbus_platform = dbus_platform;
|
||||
this._dbus_anime = dbus_anime;
|
||||
|
||||
this.menu.setHeader("selection-mode-symbolic", "Laptop features");
|
||||
|
||||
this.primary = AsusExtension.extension._settings.get_string("primary-quickmenu-toggle");
|
||||
|
||||
// TODO: temporary block
|
||||
if (this.primary == "mini-led" && !this._dbus_supported.supported.rog_bios_ctrl.mini_led_mode) {
|
||||
this.primary = "panel-od";
|
||||
} else if (this.primary == "panel-od" && !this._dbus_supported.supported.rog_bios_ctrl.panel_overdrive) {
|
||||
this.primary = "anime-power";
|
||||
} else if (this.primary == "anime-power" && !this._dbus_supported.supported.anime_ctrl) {
|
||||
this.primary = "mini-led";
|
||||
} else if (this.primary.length == 0) {
|
||||
this.primary = "panel-od";
|
||||
}
|
||||
|
||||
// AsusExtension.extension._settings.connect('changed::primary-quickmenu-toggle', this.sync);
|
||||
AsusExtension.extension._settings.set_string("primary-quickmenu-toggle", this.primary);
|
||||
|
||||
this._itemsSection = new PopupMenu.PopupMenuSection();
|
||||
if (this._dbus_supported.supported.rog_bios_ctrl.mini_led_mode) {
|
||||
if (this.miniLed == null) {
|
||||
this.miniLed = new MenuToggleMiniLed(this._dbus_platform);
|
||||
this._dbus_platform.notifyMiniLedSubscribers.push(this.miniLed);
|
||||
this._itemsSection.addMenuItem(this.miniLed, 0);
|
||||
this._dbus_platform.notifyMiniLedSubscribers.push(this);
|
||||
this.miniLed.toggle_callback = () => {
|
||||
this.primary = "mini-led";
|
||||
this.sync();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (this._dbus_supported.supported.rog_bios_ctrl.panel_overdrive) {
|
||||
if (this.panelOd == null) {
|
||||
this.panelOd = new MenuTogglePanelOd(this._dbus_platform);
|
||||
this._dbus_platform.notifyPanelOdSubscribers.push(this.panelOd);
|
||||
this._itemsSection.addMenuItem(this.panelOd, 1);
|
||||
this._dbus_platform.notifyPanelOdSubscribers.push(this);
|
||||
this.panelOd.toggle_callback = () => {
|
||||
this.primary = "panel-od";
|
||||
this.sync();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (this._dbus_supported.supported.anime_ctrl) {
|
||||
if (this.animeDisplayPower == null) {
|
||||
this.animeDisplayPower = new MenuToggleAnimePower(this._dbus_anime);
|
||||
this._dbus_anime.notifyAnimeStateSubscribers.push(this.animeDisplayPower);
|
||||
this._itemsSection.addMenuItem(this.animeDisplayPower, 2);
|
||||
this._dbus_anime.notifyAnimeStateSubscribers.push(this);
|
||||
this.animeDisplayPower.toggle_callback = () => {
|
||||
this.primary = "anime-power";
|
||||
this.sync();
|
||||
}
|
||||
}
|
||||
|
||||
if (this.animePowersaveAnim == null) {
|
||||
this.animePowersaveAnim = new MenuToggleAnimeBuiltins(this._dbus_anime);
|
||||
this._dbus_anime.notifyAnimeStateSubscribers.push(this.animePowersaveAnim);
|
||||
this._itemsSection.addMenuItem(this.animePowersaveAnim, 3);
|
||||
}
|
||||
}
|
||||
|
||||
this.connectObject(
|
||||
"clicked", () => {
|
||||
this._toggle();
|
||||
},
|
||||
this);
|
||||
|
||||
this.menu.addMenuItem(this._itemsSection, 0);
|
||||
|
||||
// // Add an entry-point for more extension._settings
|
||||
// this.menu.addMenuItem(new PopupMenu.PopupSeparatorMenuItem());
|
||||
// const settingsItem = this.menu.addAction("More Settings",
|
||||
// () => ExtensionUtils.openPrefs());
|
||||
// // Ensure the extension._settings are unavailable when the screen is locked
|
||||
// settingsItem.visible = Main.sessionMode.allowSettings;
|
||||
// this.menu._settingsActions[Me.uuid] = settingsItem;
|
||||
|
||||
this.sync();
|
||||
addQuickSettingsItems([this]);
|
||||
}
|
||||
|
||||
_toggle() {
|
||||
if (this.primary == "mini-led" && this.miniLed != null) {
|
||||
this._dbus_platform.getMiniLedMode();
|
||||
const checked = this._dbus_platform.bios.mini_led_mode;
|
||||
if (this.checked !== checked)
|
||||
this._dbus_platform.setMiniLedMode(this.checked);
|
||||
}
|
||||
|
||||
if (this.primary == "panel-od" && this.panelOd != null) {
|
||||
this._dbus_platform.getPanelOd();
|
||||
const checked = this._dbus_platform.bios.panel_overdrive;
|
||||
if (this.checked !== checked)
|
||||
this._dbus_platform.setPanelOd(this.checked);
|
||||
}
|
||||
|
||||
if (this.primary == "anime-power" && this.animeDisplayPower != null) {
|
||||
this._dbus_anime.getDeviceState();
|
||||
const checked = this._dbus_anime.deviceState.display_enabled;
|
||||
if (this.checked !== checked)
|
||||
this._dbus_anime.setEnableDisplay(this.checked);
|
||||
}
|
||||
}
|
||||
|
||||
sync() {
|
||||
let checked = false;
|
||||
if (this.primary == "mini-led" && this.miniLed != null) {
|
||||
this.title = this.miniLed.label;
|
||||
checked = this._dbus_platform.bios.mini_led_mode;
|
||||
}
|
||||
|
||||
if (this.primary == "panel-od" && this.panelOd != null) {
|
||||
this.title = this.panelOd.label;
|
||||
checked = this._dbus_platform.bios.panel_overdrive;
|
||||
}
|
||||
|
||||
if (this.primary == "anime-power" && this.animeDisplayPower != null) {
|
||||
this.title = this.animeDisplayPower.label;
|
||||
checked = this._dbus_anime.deviceState.display_enabled;
|
||||
}
|
||||
|
||||
// if (this.animePowersaveAnim != null) {
|
||||
// }
|
||||
|
||||
if (this.checked !== checked)
|
||||
this.set({ checked });
|
||||
}
|
||||
});
|
||||
Reference in New Issue
Block a user