Timer: Fix Unknown Location notification
This commit is contained in:
+1
-1
@@ -23,7 +23,7 @@ export default class NightThemeSwitcher extends Extension {
|
|||||||
const timer = new Timer({
|
const timer = new Timer({
|
||||||
settings: this.getSettings(`${this.metadata['settings-schema']}.time`),
|
settings: this.getSettings(`${this.metadata['settings-schema']}.time`),
|
||||||
colorSchemeSettings: this.getSettings(`${this.metadata['settings-schema']}.color-scheme`),
|
colorSchemeSettings: this.getSettings(`${this.metadata['settings-schema']}.color-scheme`),
|
||||||
openPrefs: this.openPrefs,
|
openPreferences: this.openPreferences,
|
||||||
});
|
});
|
||||||
this.#modules.push(timer);
|
this.#modules.push(timer);
|
||||||
|
|
||||||
|
|||||||
+15
-16
@@ -32,7 +32,7 @@ export class Timer extends GObject.Object {
|
|||||||
#colorSchemeSettings;
|
#colorSchemeSettings;
|
||||||
#interfaceSettings;
|
#interfaceSettings;
|
||||||
#locationSettings;
|
#locationSettings;
|
||||||
#openPrefs;
|
#openPreferences;
|
||||||
#time;
|
#time;
|
||||||
|
|
||||||
#cancellable = null;
|
#cancellable = null;
|
||||||
@@ -57,15 +57,15 @@ export class Timer extends GObject.Object {
|
|||||||
* @param {object} params Params object.
|
* @param {object} params Params object.
|
||||||
* @param {Gio.Settings} params.settings Timer settings.
|
* @param {Gio.Settings} params.settings Timer settings.
|
||||||
* @param {Gio.Settings} params.colorSchemeSettings Color Scheme settings.
|
* @param {Gio.Settings} params.colorSchemeSettings Color Scheme settings.
|
||||||
* @param {Function} params.openPrefs Function opening the extension preferences.
|
* @param {Function} params.openPreferences Function opening the extension preferences.
|
||||||
*/
|
*/
|
||||||
constructor({ settings, colorSchemeSettings, openPrefs }) {
|
constructor({ settings, colorSchemeSettings, openPreferences }) {
|
||||||
super();
|
super();
|
||||||
this.#settings = settings;
|
this.#settings = settings;
|
||||||
this.#colorSchemeSettings = colorSchemeSettings;
|
this.#colorSchemeSettings = colorSchemeSettings;
|
||||||
this.#interfaceSettings = new Gio.Settings({ schema: 'org.gnome.desktop.interface' });
|
this.#interfaceSettings = new Gio.Settings({ schema: 'org.gnome.desktop.interface' });
|
||||||
this.#locationSettings = new Gio.Settings({ schema: 'org.gnome.system.location' });
|
this.#locationSettings = new Gio.Settings({ schema: 'org.gnome.system.location' });
|
||||||
this.#openPrefs = openPrefs;
|
this.#openPreferences = openPreferences;
|
||||||
}
|
}
|
||||||
|
|
||||||
enable() {
|
enable() {
|
||||||
@@ -281,26 +281,25 @@ export class Timer extends GObject.Object {
|
|||||||
} else {
|
} else {
|
||||||
console.error(`[${NTSMetadata.name}] Unable to retrieve the location, using the manual schedule times instead.\n${e}`);
|
console.error(`[${NTSMetadata.name}] Unable to retrieve the location, using the manual schedule times instead.\n${e}`);
|
||||||
|
|
||||||
const source = new MessageTray.Source(NTSMetadata.name, 'dialog-information-symbolic');
|
const source = new MessageTray.Source({
|
||||||
|
title: NTSMetadata.name,
|
||||||
|
icon: Gio.icon_new_for_string(GLib.build_filenamev([NTSMetadata.path, 'icons', 'nightthemeswitcher-symbolic.svg'])),
|
||||||
|
});
|
||||||
messageTray.add(source);
|
messageTray.add(source);
|
||||||
|
|
||||||
const notification = new MessageTray.Notification(
|
const notification = new MessageTray.Notification(
|
||||||
source,
|
|
||||||
_('Unknown Location'),
|
|
||||||
_('A manual schedule will be used to switch the dark mode.'),
|
|
||||||
{
|
{
|
||||||
gicon: Gio.icon_new_for_string(GLib.build_filenamev([NTSMetadata.path, 'icons', 'nightthemeswitcher-symbolic.svg'])),
|
source,
|
||||||
|
title: _('Unknown Location'),
|
||||||
|
body: _('A manual schedule will be used to switch the dark mode.'),
|
||||||
|
'icon-name': 'location-services-disabled-symbolic',
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
notification.addAction(_('Edit Manual Schedule'), () => this.#openPrefs());
|
notification.addAction(_('Edit Manual Schedule'), () => this.#openPreferences());
|
||||||
|
|
||||||
const locationSettingsApp = Shell.AppSystem.get_default().lookup_app('gnome-location-panel.desktop');
|
notification.connect('activated', () => this.#openPreferences());
|
||||||
if (locationSettingsApp)
|
|
||||||
notification.addAction(_('Open Location Settings'), () => locationSettingsApp.activate());
|
|
||||||
|
|
||||||
notification.connect('activated', () => this.#openPrefs());
|
source.addNotification(notification);
|
||||||
|
|
||||||
source.showNotification(notification);
|
|
||||||
|
|
||||||
this.#settings.set_boolean('manual-schedule', true);
|
this.#settings.set_boolean('manual-schedule', true);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user