[gnome] Update extensions

This commit is contained in:
2024-10-31 10:19:02 -04:00
parent 851ec4a772
commit 6d1e6d1132
238 changed files with 8705 additions and 4185 deletions

View File

@ -7,6 +7,14 @@ import Gio from 'gi://Gio';
import Gtk from 'gi://Gtk';
import Gdk from 'gi://Gdk';
// Links
const URLS = {
readme: 'https://gitlab.com/marcosdalvarez/thinkpad-battery-threshold-extension/',
bug_report: 'https://gitlab.com/marcosdalvarez/thinkpad-battery-threshold-extension/-/issues',
license: 'https://gitlab.com/marcosdalvarez/thinkpad-battery-threshold-extension/-/blob/main/LICENSE',
translate: 'https://hosted.weblate.org/engage/thinkpad-battery-threshold/',
};
export const About = GObject.registerClass({
GTypeName: 'AboutPrefs',
Template: GLib.Uri.resolve_relative(import.meta.url, '../ui/about.ui',GLib.UriFlags.NONE),
@ -14,6 +22,10 @@ export const About = GObject.registerClass({
'app_icon_image',
'app_name_label',
'version_label',
'open_readme',
'open_bug_report',
'open_license',
'open_translate',
]
}, class About extends Adw.PreferencesPage {
constructor(window) {
@ -21,25 +33,29 @@ export const About = GObject.registerClass({
this._app_icon_image.gicon = Gio.icon_new_for_string(`${GLib.Uri.resolve_relative(import.meta.url, '../icons/threshold-active.svg',GLib.UriFlags.NONE)}`);
this._app_name_label.label = window._metadata.name;
this._version_label.label = window._metadata.version.toString();
this._version_label.label = window._metadata.version ? window._metadata.version.toString() : "0";
// setup menu actions
// Setup actions
const actionGroup = new Gio.SimpleActionGroup();
window.insert_action_group('prefs', actionGroup);
// a list of actions with their associated link
// A list of actions with their associated link
const actions = [
{
name: 'open-bug-report',
link: 'https://gitlab.com/marcosdalvarez/thinkpad-battery-threshold-extension/-/issues'
link: URLS.bug_report
},
{
name: 'open-readme',
link: 'https://gitlab.com/marcosdalvarez/thinkpad-battery-threshold-extension/'
link: URLS.readme
},
{
name: 'open-license',
link: 'https://gitlab.com/marcosdalvarez/thinkpad-battery-threshold-extension/-/blob/main/LICENSE'
link: URLS.license
},
{
name: 'open-translate',
link: URLS.translate
},
];
@ -51,5 +67,11 @@ export const About = GObject.registerClass({
);
actionGroup.add_action(act);
});
// Set tooltips
this._open_readme.tooltip_text = URLS.readme;
this._open_license.tooltip_text = URLS.license;
this._open_bug_report.tooltip_text = URLS.bug_report;
this._open_translate.tooltip_text = URLS.translate;
}
});

View File

@ -16,7 +16,11 @@ export const Thinkpad = GObject.registerClass({
'reset',
'apply_bat0',
'apply_bat1',
'reset_thresholds_dialog'
'reset_thresholds_dialog',
'disabled_start_bat0',
'disabled_start_bat1',
'warn_bat0',
'warn_bat1'
],
}, class Thinkpad extends Adw.PreferencesPage {
constructor(window) {
@ -46,26 +50,48 @@ export const Thinkpad = GObject.registerClass({
'value',
Gio.SettingsBindFlags.DEFAULT
);
window._settings.bind(
'disabled-start-bat0-value',
this._disabled_start_bat0,
'value',
Gio.SettingsBindFlags.DEFAULT
);
window._settings.bind(
'disabled-start-bat1-value',
this._disabled_start_bat1,
'value',
Gio.SettingsBindFlags.DEFAULT
);
window._settings.connect('changed::start-bat0', () => {
if (this._start_bat0.value >= this._end_bat0.value) {
this._end_bat0.value = this._start_bat0.value + 1;
}
this._updateWarnings();
});
window._settings.connect('changed::end-bat0', () => {
if (this._start_bat0.value >= this._end_bat0.value) {
this._start_bat0.value = this._end_bat0.value - 1;
}
this._updateWarnings();
});
window._settings.connect('changed::start-bat1', () => {
if (this._start_bat1.value >= this._end_bat1.value) {
this._end_bat1.value = this._start_bat1.value + 1;
}
this._updateWarnings();
});
window._settings.connect('changed::end-bat1', () => {
if (this._start_bat1.value >= this._end_bat1.value) {
this._start_bat1.value = this._end_bat1.value - 1;
}
this._updateWarnings();
});
window._settings.connect('changed::disabled-start-bat0-value', () => {
this._updateWarnings();
});
window._settings.connect('changed::disabled-start-bat1-value', () => {
this._updateWarnings();
});
const bat0 = window._driver.batteries.find(battery => battery.name === 'BAT0');
@ -96,13 +122,17 @@ export const Thinkpad = GObject.registerClass({
this._apply_bat1.sensitive = bat1.pendingChanges;
});
this._updateWarnings();
this._reset_thresholds_dialog.connect('response', (obj, response, data) => {
if (response === 'reset') {
const keys = [
'start-bat0',
'end-bat0',
'start-bat1',
'end-bat1'
'end-bat1',
'disabled-start-bat0-value',
'disabled-start-bat1-value',
];
keys.forEach(key => {
window._settings.reset(key);
@ -116,4 +146,9 @@ export const Thinkpad = GObject.registerClass({
this._reset_thresholds_dialog.present();
});
}
_updateWarnings() {
this._warn_bat0.reveal_child = this._start_bat0.value === this._disabled_start_bat0.value && this._end_bat0.value === 100;
this._warn_bat1.reveal_child = this._start_bat1.value === this._disabled_start_bat1.value && this._end_bat1.value === 100;
}
});