diff --git a/src/icons/hicolor/scalable/status/nightthemeswitcher-ondemand-off-symbolic.svg b/src/icons/hicolor/scalable/status/nightthemeswitcher-ondemand-off-symbolic.svg
new file mode 100644
index 0000000..d858964
--- /dev/null
+++ b/src/icons/hicolor/scalable/status/nightthemeswitcher-ondemand-off-symbolic.svg
@@ -0,0 +1 @@
+
diff --git a/src/icons/hicolor/scalable/status/nightthemeswitcher-ondemand-on-symbolic.svg b/src/icons/hicolor/scalable/status/nightthemeswitcher-ondemand-on-symbolic.svg
new file mode 100644
index 0000000..bd2d2cb
--- /dev/null
+++ b/src/icons/hicolor/scalable/status/nightthemeswitcher-ondemand-on-symbolic.svg
@@ -0,0 +1 @@
+
diff --git a/src/modules/TimerOndemand.js b/src/modules/TimerOndemand.js
index 96a5c72..e50e318 100644
--- a/src/modules/TimerOndemand.js
+++ b/src/modules/TimerOndemand.js
@@ -16,11 +16,14 @@ You should have received a copy of the GNU General Public License along with
this program. If not, see .
*/
-const { Shell, St } = imports.gi;
+const { Gio, GLib, Shell, St } = imports.gi;
const { extensionUtils } = imports.misc;
const Signals = imports.signals;
-const { main, panelMenu: PanelMenu, popupMenu: PopupMenu } = imports.ui;
+const { main } = imports.ui;
+
+const { Button: PanelMenuButton } = imports.ui.panelMenu;
+const { PopupImageMenuItem } = imports.ui.popupMenu;
const Me = extensionUtils.getCurrentExtension();
@@ -144,17 +147,16 @@ var TimerOndemand = class {
_addButtonToPanel() {
logDebug('Adding On-demand Timer button to the panel...');
- const getIconNameForCurrentTime = () => e.timer.time === 'day' ? 'weather-clear-symbolic' : 'weather-clear-night-symbolic';
const icon = new St.Icon({
- icon_name: getIconNameForCurrentTime(),
+ gicon: this._getIconForTime(e.timer.time),
style_class: 'system-status-icon',
});
- this._button = new PanelMenu.Button(0.0);
+ this._button = new PanelMenuButton(0.0);
const buttonActor = getActor(this._button);
buttonActor.add_actor(icon);
buttonActor.connect('button-press-event', () => {
this._toggleTime();
- icon.icon_name = getIconNameForCurrentTime();
+ icon.gicon = this._getIconForTime(e.timer.time);
});
main.panel.addToStatusArea('NightThemeSwitcherButton', this._button);
logDebug('Added On-demand Timer button to the panel.');
@@ -164,18 +166,25 @@ var TimerOndemand = class {
logDebug('Adding On-demand Timer button to the menu...');
const aggregateMenu = main.panel.statusArea.aggregateMenu;
const position = findShellAggregateMenuItemPosition(aggregateMenu._system.menu) - 1;
- const getLabelForCurrentTime = () => e.timer.time === 'day' ? _('Switch to night theme') : _('Switch to day theme');
- const getIconNameForCurrentTime = () => e.timer.time === 'day' ? 'weather-clear-night-symbolic' : 'weather-clear-symbolic';
- this._button = new PopupMenu.PopupImageMenuItem(getLabelForCurrentTime(), getIconNameForCurrentTime());
+ this._button = new PopupImageMenuItem(this._getLabelForTime(e.timer.time), this._getIconForTime(e.timer.time));
this._button.connect('activate', () => {
this._toggleTime();
- this._button.label.text = getLabelForCurrentTime();
- this._button.setIcon(getIconNameForCurrentTime());
+ this._button.label.text = this._getLabelForTime(e.timer.time);
+ this._button.setIcon(this._getIconForTime(e.timer.time));
});
aggregateMenu.menu.addMenuItem(this._button, position);
logDebug('Added On-demand Timer button to the menu.');
}
+ _getIconForTime(time) {
+ const name = time === 'day' ? 'nightthemeswitcher-ondemand-off-symbolic' : 'nightthemeswitcher-ondemand-on-symbolic';
+ return Gio.icon_new_for_string(GLib.build_filenamev([Me.path, 'icons', 'hicolor', 'scalable', 'status', `${name}.svg`]));
+ }
+
+ _getLabelForTime(time) {
+ return time === 'day' ? _('Switch to night theme') : _('Switch to day theme');
+ }
+
_toggleTime() {
e.settings.time.ondemandTime = e.timer.time === 'day' ? 'night' : 'day';
this.emit('time-changed', this.time);