[gnome] Update extensions for version 48
This commit is contained in:
@ -299,4 +299,15 @@ other: Other
|
||||
### Fixed
|
||||
- Issue [#24](https://gitlab.com/marcosdalvarez/thinkpad-battery-threshold-extension/-/issues/24): The "NEVER" indicator mode does not work properly
|
||||
### Changed
|
||||
- "Automatic threshold detection disabled" is not convenient (no way to know the status before it is disabled for the first time), we returns to "model detection mode" and keeps "manual mode" (user settings)
|
||||
- "Automatic threshold detection disabled" is not convenient (no way to know the status before it is disabled for the first time), we returns to "model detection mode" and keeps "manual mode" (user settings)
|
||||
|
||||
## [v50] - 2025-01-06
|
||||
### Other
|
||||
- Update translations (German)
|
||||
- Minor internal changes
|
||||
|
||||
## [v51] - 2025-02-02
|
||||
### Other
|
||||
- Update translations (Italian)
|
||||
### Added
|
||||
- Gnome 48 support
|
||||
@ -332,34 +332,9 @@ export const ThinkPadBattery = GObject.registerClass({
|
||||
logError(e, this.name);
|
||||
}
|
||||
|
||||
// Update flags on changes in threshold values
|
||||
this._startId = this.connect(
|
||||
'notify::start-value', () => {
|
||||
this._updateStatuses();
|
||||
}
|
||||
);
|
||||
this._endId = this.connect(
|
||||
'notify::end-value', () => {
|
||||
this._updateStatuses();
|
||||
}
|
||||
);
|
||||
this._notifyHandlerId = this.connect('notify', () => this._updateStatuses());
|
||||
|
||||
this._settingStartId = this.settings.connect(
|
||||
`changed::start-${this.name.toLowerCase()}`, () => {
|
||||
this._updateStatuses();
|
||||
}
|
||||
);
|
||||
this._settingEndId = this.settings.connect(
|
||||
`changed::end-${this.name.toLowerCase()}`, () => {
|
||||
this._updateStatuses();
|
||||
}
|
||||
);
|
||||
|
||||
this._settingDisabledValueId = this.settings.connect(
|
||||
`changed::disabled-start-${this.name.toLowerCase()}-value`, () => {
|
||||
this._updateStatuses();
|
||||
}
|
||||
);
|
||||
this._settingsHandlerId = this.settings.connect('changed', () => this._updateStatuses());
|
||||
|
||||
// Load initial values
|
||||
this.startValue = readFileInt(this._startFilePath);
|
||||
@ -618,23 +593,11 @@ export const ThinkPadBattery = GObject.registerClass({
|
||||
}
|
||||
|
||||
destroy() {
|
||||
if (this._startId) {
|
||||
this.disconnect(this._startId);
|
||||
if (this._notifyHandlerId) {
|
||||
this.disconnect(this._notifyHandlerId)
|
||||
}
|
||||
if (this._endId) {
|
||||
this.disconnect(this._endId);
|
||||
}
|
||||
if (this._settingStartId) {
|
||||
this.settings.disconnect(this._settingStartId);
|
||||
}
|
||||
if (this._settingEndId) {
|
||||
this.settings.disconnect(this._settingEndId);
|
||||
}
|
||||
if (this._settingDisabledValueId) {
|
||||
this.settings.disconnect(this._settingDisabledValueId);
|
||||
}
|
||||
if (this._monitorId) {
|
||||
this._baseMonitor.disconnect(this._monitorId);
|
||||
if (this._settingsHandlerId) {
|
||||
this.settings.disconnect(this._settingsHandlerId)
|
||||
}
|
||||
this._baseMonitor.cancel();
|
||||
this._baseMonitor = null;
|
||||
@ -731,21 +694,8 @@ export const ThinkPad = GObject.registerClass({
|
||||
|
||||
// Connect the signals from the batteries to update the flags and notify commands
|
||||
this.batteries.forEach(battery => {
|
||||
const isAvailableId = battery.connect(
|
||||
'notify::is-available', (bat) => {
|
||||
this.isAvailable = this._checkAvailable();
|
||||
}
|
||||
);
|
||||
const isActiveId = battery.connect(
|
||||
'notify::is-active', (bat) => {
|
||||
this.isActive = this._checkActive();
|
||||
}
|
||||
);
|
||||
const pendingChangesId = battery.connect(
|
||||
'notify::pending-changes', (bat) => {
|
||||
this.pendingChanges = this._checkPendingChanges();
|
||||
}
|
||||
);
|
||||
const notifyHandlerId = battery.connect('notify', () => this._updateStatuses());
|
||||
|
||||
const enableCompletedId = battery.connect(
|
||||
'enable-completed', (bat, error) => {
|
||||
this.emit('enable-battery-completed', bat, error);
|
||||
@ -756,13 +706,11 @@ export const ThinkPad = GObject.registerClass({
|
||||
this.emit('disable-battery-completed', bat, error);
|
||||
}
|
||||
);
|
||||
this._batteriesId[battery.name] = [isAvailableId, isActiveId, enableCompletedId, disableCompletedId];
|
||||
this._batteriesId[battery.name] = [notifyHandlerId, enableCompletedId, disableCompletedId];
|
||||
});
|
||||
|
||||
// Load initial values
|
||||
this.isAvailable = this._checkAvailable();
|
||||
this.isActive = this._checkActive();
|
||||
this.pendingChanges = this._checkPendingChanges();
|
||||
this._updateStatuses();
|
||||
}
|
||||
|
||||
get environment() {
|
||||
@ -806,35 +754,17 @@ export const ThinkPad = GObject.registerClass({
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if there are changes to the settings that need to be applied
|
||||
*
|
||||
* @returns {boolean} Returns true if there are changes to the settings that need to be applied
|
||||
* Update driver status
|
||||
*/
|
||||
_checkPendingChanges() {
|
||||
return this.batteries.some(bat => {
|
||||
return bat.pendingChanges;
|
||||
_updateStatuses() {
|
||||
this.isAvailable = this.batteries.some(bat => {
|
||||
return bat.isAvailable;
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if at least one battery has the thresholds active
|
||||
*
|
||||
* @returns {boolean} Returns true if at least one battery has the thresholds active
|
||||
*/
|
||||
_checkActive() {
|
||||
return this.batteries.some(bat => {
|
||||
this.isActive = this.batteries.some(bat => {
|
||||
return bat.isActive && bat.isAvailable;
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if at least one battery is available to apply the thresholds
|
||||
*
|
||||
* @returns {boolean} Returns true if at least one battery is available to apply the thresholds
|
||||
*/
|
||||
_checkAvailable() {
|
||||
return this.batteries.some(bat => {
|
||||
return bat.isAvailable;
|
||||
this.pendingChanges = this.batteries.some(bat => {
|
||||
return bat.pendingChanges;
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@ -6,7 +6,7 @@ import GObject from 'gi://GObject';
|
||||
import GLib from 'gi://GLib';
|
||||
import Gio from 'gi://Gio';
|
||||
|
||||
import {gettext as _, ngettext} from 'resource:///org/gnome/shell/extensions/extension.js';
|
||||
import { gettext as _, ngettext } from 'resource:///org/gnome/shell/extensions/extension.js';
|
||||
import * as Main from 'resource:///org/gnome/shell/ui/main.js';
|
||||
import * as MessageTray from 'resource:///org/gnome/shell/ui/messageTray.js';
|
||||
import * as PopupMenu from 'resource:///org/gnome/shell/ui/popupMenu.js';
|
||||
@ -37,7 +37,7 @@ const BatteryItem = GObject.registerClass({
|
||||
|
||||
this._settings = settings;
|
||||
this._battery = battery;
|
||||
|
||||
|
||||
const box = new St.BoxLayout({
|
||||
'opacity': 128,
|
||||
'x_expand': true,
|
||||
@ -133,7 +133,7 @@ const BatteryItem = GObject.registerClass({
|
||||
} else {
|
||||
// TRANSLATORS: %s is the name of the battery.
|
||||
this.label.text = _('Enable thresholds (%s)').format(this._battery.name);
|
||||
this.setIcon(getIcon('threshold-inactive', colorMode ));
|
||||
this.setIcon(getIcon('threshold-inactive', colorMode));
|
||||
this._valuesLabel.visible = false;
|
||||
}
|
||||
// Reload 'button'
|
||||
@ -166,11 +166,11 @@ const ThresholdToggle = GObject.registerClass({
|
||||
this.unavailableMenuItem.sensitive = false;
|
||||
this.unavailableMenuItem.visible = false;
|
||||
this.menu.addMenuItem(this.unavailableMenuItem);
|
||||
|
||||
|
||||
// Batteries
|
||||
driver.batteries.forEach(battery => {
|
||||
// Battery menu item
|
||||
const item = new BatteryItem(battery, extensionObject.getSettings());
|
||||
const item = new BatteryItem(battery, extensionObject.getSettings());
|
||||
this.menu.addMenuItem(item);
|
||||
});
|
||||
|
||||
@ -212,7 +212,7 @@ const ThresholdToggle = GObject.registerClass({
|
||||
this.menu.addMenuItem(new PopupMenu.PopupSeparatorMenuItem());
|
||||
const settingsItem = this.menu.addAction(_('Thresholds settings'),
|
||||
() => extensionObject.openPreferences());
|
||||
|
||||
|
||||
// Ensure the getSettings() are unavailable when the screen is locked
|
||||
settingsItem.visible = Main.sessionMode.allowSettings;
|
||||
this.menu._settingsActions[extensionObject.uuid] = settingsItem;
|
||||
@ -226,7 +226,7 @@ export const ThresholdIndicator = GObject.registerClass({
|
||||
super();
|
||||
|
||||
this._settings = extensionObject.getSettings();
|
||||
this._driver = new ThinkPad({'settings': this._settings})
|
||||
this._driver = new ThinkPad({ 'settings': this._settings })
|
||||
this._name = extensionObject.metadata.name;
|
||||
|
||||
this._indicator = this._addIndicator();
|
||||
@ -240,15 +240,7 @@ export const ThresholdIndicator = GObject.registerClass({
|
||||
|
||||
// Driver signals
|
||||
this._driver.connectObject(
|
||||
'notify::is-available', () => {
|
||||
this._updateIndicator();
|
||||
},
|
||||
'notify::is-active', () => {
|
||||
this._updateIndicator();
|
||||
},
|
||||
'notify::pending-changes', () => {
|
||||
this._updateIndicator();
|
||||
},
|
||||
'notify', () => this._updateIndicator(),
|
||||
'enable-battery-completed', (driver, battery, error) => {
|
||||
if (!error) {
|
||||
this._notifyEnabled(
|
||||
@ -388,27 +380,27 @@ export const ThresholdIndicator = GObject.registerClass({
|
||||
* @param {string} iconName Icon name
|
||||
* @param {boolean} [transient=true] Transient notification
|
||||
*/
|
||||
_notify(msg, details, iconName, transient=true) {
|
||||
_notify(msg, details, iconName, transient = true) {
|
||||
if (!this._settings.get_boolean('show-notifications')) return;
|
||||
if (SHELL_VERSION === 45) {
|
||||
const source = new MessageTray.Source(this._name);
|
||||
Main.messageTray.add(source);
|
||||
const notification = new MessageTray.Notification(
|
||||
source,
|
||||
msg,
|
||||
details,
|
||||
{gicon: getIcon(iconName, true)}
|
||||
source,
|
||||
msg,
|
||||
details,
|
||||
{ gicon: getIcon(iconName, true) }
|
||||
);
|
||||
notification.setTransient(transient);
|
||||
source.showNotification(notification);
|
||||
} else {
|
||||
const source = new MessageTray.Source({'title': this._name});
|
||||
const source = new MessageTray.Source({ 'title': this._name });
|
||||
Main.messageTray.add(source);
|
||||
const notification = new MessageTray.Notification({
|
||||
source: source,
|
||||
title: msg,
|
||||
body: details,
|
||||
isTransient: transient,
|
||||
source: source,
|
||||
title: msg,
|
||||
body: details,
|
||||
isTransient: transient,
|
||||
gicon: getIcon(iconName, true)
|
||||
});
|
||||
source.addNotification(notification);
|
||||
@ -424,20 +416,20 @@ export const ThresholdIndicator = GObject.registerClass({
|
||||
this._notify(_('Battery Threshold'), message, 'threshold-error', false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Show enabled notification
|
||||
*
|
||||
* @param {string} message Message
|
||||
*/
|
||||
/**
|
||||
* Show enabled notification
|
||||
*
|
||||
* @param {string} message Message
|
||||
*/
|
||||
_notifyEnabled(message) {
|
||||
this._notify(_('Battery Threshold'), message, 'threshold-active');
|
||||
}
|
||||
|
||||
/**
|
||||
* Show disabled notification
|
||||
*
|
||||
* @param {string} message Message
|
||||
*/
|
||||
/**
|
||||
* Show disabled notification
|
||||
*
|
||||
* @param {string} message Message
|
||||
*/
|
||||
_notifyDisabled(message) {
|
||||
this._notify(_('Battery Threshold'), message, 'threshold-inactive');
|
||||
}
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@ -7,9 +7,10 @@
|
||||
"shell-version": [
|
||||
"45",
|
||||
"46",
|
||||
"47"
|
||||
"47",
|
||||
"48"
|
||||
],
|
||||
"url": "https://gitlab.com/marcosdalvarez/thinkpad-battery-threshold-extension",
|
||||
"uuid": "thinkpad-battery-threshold@marcosdalvarez.org",
|
||||
"version": 49
|
||||
"version": 51
|
||||
}
|
||||
Reference in New Issue
Block a user