Timer: Send a notification when falling back to the manual schedule

This commit is contained in:
Romain Vigier
2022-10-30 14:33:54 +01:00
parent 51e9d92f4e
commit b50764a280
3 changed files with 56 additions and 7 deletions
+4
View File
@@ -22,6 +22,9 @@ main = [
enums = [
'enums/Time.js',
]
icons = [
'data/icons/nightthemeswitcher-symbolic.svg',
]
modules = [
'modules/Switcher.js',
'modules/SwitcherCommands.js',
@@ -43,6 +46,7 @@ preferences = [
install_data(main, install_dir: INSTALL_DIR)
install_data(enums, install_dir: INSTALL_DIR / 'enums')
install_data(icons, install_dir: INSTALL_DIR / 'icons')
install_data(modules, install_dir: INSTALL_DIR / 'modules')
install_data(preferences, install_dir: INSTALL_DIR / 'preferences')
+27 -2
View File
@@ -4,10 +4,12 @@
const { Geoclue, Gio, GLib, GObject, Meta, Shell } = imports.gi;
const { extensionUtils } = imports.misc;
const { main } = imports.ui;
const { main, messageTray } = imports.ui;
const Me = extensionUtils.getCurrentExtension();
const _ = extensionUtils.gettext;
const debug = Me.imports.debug;
const { Time } = Me.imports.enums.Time;
@@ -244,7 +246,7 @@ var Timer = class extends GObject.Object {
this.#changeTime(time, true);
}
#onGeoclueReady(_, result) {
#onGeoclueReady(_geoclue, result) {
try {
this.#geoclue = Geoclue.Simple.new_finish(result);
this.#geoclueLocationConnectionId = this.#geoclue.connect('notify::location', this.#onLocationChanged.bind(this));
@@ -257,6 +259,29 @@ var Timer = class extends GObject.Object {
this.#updateSuntimes();
} else {
console.error(`[${Me.metadata.name}] Unable to retrieve the location, using the manual schedule times instead.\n${e}`);
const source = new messageTray.Source(Me.metadata.name, 'dialog-information-symbolic');
main.messageTray.add(source);
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([Me.path, 'icons', 'nightthemeswitcher-symbolic.svg'])),
}
);
notification.addAction(_('Edit Manual Schedule'), () => extensionUtils.openPrefs());
const locationSettingsApp = Shell.AppSystem.get_default().lookup_app('gnome-location-panel.desktop');
if (locationSettingsApp)
notification.addAction(_('Open Location Settings'), () => locationSettingsApp.activate());
notification.connect('activated', () => extensionUtils.openPrefs());
source.showNotification(notification);
this.#settings.set_boolean('manual-schedule', true);
}
}
}
+25 -5
View File
@@ -8,7 +8,11 @@ msgid ""
msgstr ""
"Project-Id-Version: nightthemeswitcher@romainvigier.fr\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2022-08-17 14:13+0200\n"
<<<<<<< HEAD
"POT-Creation-Date: 2022-10-30 14:28+0100\n"
=======
"POT-Creation-Date: 2022-10-30 14:03+0100\n"
>>>>>>> d754bee (Timer: Send a notification when falling back to the manual schedule)
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
@@ -21,7 +25,7 @@ msgstr ""
msgid "Change background"
msgstr ""
#: src/data/ui/BackgroundButton.ui:31
#: src/data/ui/BackgroundButton.ui:24
msgid "Select your background image"
msgstr ""
@@ -64,7 +68,7 @@ msgstr ""
msgid "notify-send \"Hello sunshine!\""
msgstr ""
#: src/data/ui/CommandsPage.ui:35 src/data/ui/SchedulePage.ui:39
#: src/data/ui/CommandsPage.ui:35 src/data/ui/SchedulePage.ui:40
msgid "Sunset"
msgstr ""
@@ -104,7 +108,7 @@ msgstr ""
msgid "Manual schedule"
msgstr ""
#: src/data/ui/SchedulePage.ui:55
#: src/data/ui/SchedulePage.ui:57
msgid "Keyboard shortcut"
msgstr ""
@@ -167,7 +171,23 @@ msgstr ""
msgid ":"
msgstr ""
#: src/preferences/BackgroundButton.js:69
#: src/modules/Timer.js:268
msgid "Unknown Location"
msgstr ""
#: src/modules/Timer.js:269
msgid "A manual schedule will be used to switch the dark mode."
msgstr ""
#: src/modules/Timer.js:274
msgid "Edit Manual Schedule"
msgstr ""
#: src/modules/Timer.js:278
msgid "Open Location Settings"
msgstr ""
#: src/preferences/BackgroundButton.js:86
msgid "This image format is not supported."
msgstr ""