[gnome] Update gnome extensions
This commit is contained in:
@ -238,6 +238,13 @@ export const ThresholdIndicator = GObject.registerClass({
|
||||
|
||||
this._updateIndicator();
|
||||
|
||||
this._notificationSource = new MessageTray.Source({
|
||||
'title': this._name,
|
||||
'icon': getIcon('threshold-app', false)
|
||||
});
|
||||
|
||||
Main.messageTray.add(this._notificationSource);
|
||||
|
||||
// Driver signals
|
||||
this._driver.connectObject(
|
||||
'notify', () => this._updateIndicator(),
|
||||
@ -314,6 +321,8 @@ export const ThresholdIndicator = GObject.registerClass({
|
||||
);
|
||||
|
||||
this.connect('destroy', () => {
|
||||
this._notificationSource.destroy();
|
||||
this._notificationSource = null;
|
||||
this.quickSettingsItems.forEach(item => item.destroy());
|
||||
this._settings.disconnectObject(this);
|
||||
this._settings = null;
|
||||
@ -324,13 +333,7 @@ export const ThresholdIndicator = GObject.registerClass({
|
||||
});
|
||||
|
||||
// Pending changes alert
|
||||
this._driver.batteries.every(battery => {
|
||||
if (battery.pendingChanges && battery.isActive) {
|
||||
this._notify(_('Battery Threshold'), _('The currently set thresholds do not match the configured ones'), 'threshold-active-warning', false);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
});
|
||||
this._pendingChangesAlert();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -375,36 +378,20 @@ export const ThresholdIndicator = GObject.registerClass({
|
||||
/**
|
||||
* Show notification.
|
||||
*
|
||||
* @param {string} msg Title
|
||||
* @param {string} details Message
|
||||
* @param {string} iconName Icon name
|
||||
* @param {boolean} [transient=true] Transient notification
|
||||
*/
|
||||
_notify(msg, details, iconName, transient = true) {
|
||||
_notify(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) }
|
||||
);
|
||||
notification.setTransient(transient);
|
||||
source.showNotification(notification);
|
||||
} else {
|
||||
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,
|
||||
gicon: getIcon(iconName, true)
|
||||
});
|
||||
source.addNotification(notification);
|
||||
}
|
||||
const notification = new MessageTray.Notification({
|
||||
source: this._notificationSource,
|
||||
title: _('Battery Threshold'),
|
||||
body: details,
|
||||
isTransient: transient,
|
||||
gicon: getIcon(iconName, true)
|
||||
});
|
||||
this._notificationSource.addNotification(notification);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -413,7 +400,7 @@ export const ThresholdIndicator = GObject.registerClass({
|
||||
* @param {string} message Message
|
||||
*/
|
||||
_notifyError(message) {
|
||||
this._notify(_('Battery Threshold'), message, 'threshold-error', false);
|
||||
this._notify(message, 'threshold-error', false)
|
||||
}
|
||||
|
||||
/**
|
||||
@ -422,7 +409,7 @@ export const ThresholdIndicator = GObject.registerClass({
|
||||
* @param {string} message Message
|
||||
*/
|
||||
_notifyEnabled(message) {
|
||||
this._notify(_('Battery Threshold'), message, 'threshold-active');
|
||||
this._notify(message, 'threshold-active')
|
||||
}
|
||||
|
||||
/**
|
||||
@ -431,6 +418,54 @@ export const ThresholdIndicator = GObject.registerClass({
|
||||
* @param {string} message Message
|
||||
*/
|
||||
_notifyDisabled(message) {
|
||||
this._notify(_('Battery Threshold'), message, 'threshold-inactive');
|
||||
this._notify(message, 'threshold-inactive')
|
||||
}
|
||||
|
||||
/**
|
||||
* Show alert when are pending values changes
|
||||
*/
|
||||
_pendingChangesAlert() {
|
||||
let notify = false;
|
||||
this._driver.batteries.every(battery => {
|
||||
if (battery.pendingChanges && battery.isActive) {
|
||||
notify = true;
|
||||
}
|
||||
return true;
|
||||
});
|
||||
|
||||
if (notify) {
|
||||
let message = _(`The currently configured thresholds don't match those set on the system.`);
|
||||
if (SHELL_VERSION >= 48) {
|
||||
// TRANSLATORS: The strings "<b>" and "</b>" are part of the markup language and indicate that the text between the tags will be rendered in "bold"
|
||||
// TRANSLATORS: This chain joins another so it is a good idea to leave a space in front of it.
|
||||
// TRANSLATORS: "Preserve battery health" is an option in Gnome settings.
|
||||
message += _(` Is the <b>Preserve battery health</b> option enabled in Gnome settings? This mode restores its own values.`);
|
||||
}
|
||||
|
||||
const notification = new MessageTray.Notification({
|
||||
source: this._notificationSource,
|
||||
title: _('Battery Threshold'),
|
||||
body: message,
|
||||
gicon: getIcon('threshold-active-warning', true),
|
||||
resident: true,
|
||||
urgency: MessageTray.Urgency.CRITICAL,
|
||||
'use-body-markup': true
|
||||
});
|
||||
notification.addAction(_('Keep detected'), () => {
|
||||
this._driver.batteries.every(battery => {
|
||||
if (battery.pendingChanges && battery.isActive) {
|
||||
this._settings.set_int(`start-${battery.name.toLowerCase()}`, battery.startValue);
|
||||
this._settings.set_int(`end-${battery.name.toLowerCase()}`, battery.endValue);
|
||||
}
|
||||
return true;
|
||||
});
|
||||
notification.destroy();
|
||||
});
|
||||
notification.addAction(_('Set configured'), () => {
|
||||
this._driver.enableAll();
|
||||
notification.destroy();
|
||||
});
|
||||
this._notificationSource.addNotification(notification);
|
||||
}
|
||||
}
|
||||
});
|
||||
Reference in New Issue
Block a user