From 1ec190b8e324eb5ae3a1895520299f8da5bb13b5 Mon Sep 17 00:00:00 2001 From: Nathaniel Russell <46272571+nater1983@users.noreply.github.com> Date: Sat, 6 Apr 2024 19:05:11 -0500 Subject: [PATCH 1/6] Update extension.js ReferenceError: assignment to undeclared variable currentDateTime changed to currDateTime --- eortologio@danchris.github.io/extension.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eortologio@danchris.github.io/extension.js b/eortologio@danchris.github.io/extension.js index 08f87d0..2be9865 100644 --- a/eortologio@danchris.github.io/extension.js +++ b/eortologio@danchris.github.io/extension.js @@ -70,7 +70,7 @@ export default class EortologioPopupExtension extends Extension { } disable() { - currentDateTime = null + currDateTime = null this._EortologioPopup.destroy(); this._EortologioPopup = null; } From 4df80254165428afdebc0b25a5ae45d41058dae7 Mon Sep 17 00:00:00 2001 From: Nathaniel Russell <46272571+nater1983@users.noreply.github.com> Date: Sat, 6 Apr 2024 19:14:43 -0500 Subject: [PATCH 2/6] Update helpers.js ReferenceError: assignment to undeclared variable currentDateTime updated helpers.js to use currDateTime --- eortologio@danchris.github.io/helpers.js | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/eortologio@danchris.github.io/helpers.js b/eortologio@danchris.github.io/helpers.js index aa223e0..0a5ca01 100644 --- a/eortologio@danchris.github.io/helpers.js +++ b/eortologio@danchris.github.io/helpers.js @@ -1,13 +1,13 @@ import GLib from 'gi://GLib'; import Gio from 'gi://Gio'; -export function getNameDays(currentDateTime){ +export function getNameDays(currDateTime){ let nameDays = []; - let date = getCurrentDate(currentDateTime); - let [easterDay, easterMonth, easterYear] = calcOrthEaster(currentDateTime.get_year()); + let date = getCurrentDate(currDateTime); + let [easterDay, easterMonth, easterYear] = calcOrthEaster(currDateTime.get_year()); - return nameDays.concat(getRecurringNameDays(date), getRelativeToEasterNameDays(easterDay, easterMonth, easterYear, currentDateTime)); + return nameDays.concat(getRecurringNameDays(date), getRelativeToEasterNameDays(easterDay, easterMonth, easterYear, currDateTime)); } @@ -29,7 +29,7 @@ export function getRecurringNameDays(date, subdir){ return recurringNameDays; } -export function getRelativeToEasterNameDays(easterDay, easterMonth, easterYear, currentDateTime, subdir){ +export function getRelativeToEasterNameDays(easterDay, easterMonth, easterYear, currDateTime, subdir){ let easterDateTime = GLib.DateTime.new(GLib.TimeZone.new_local(),easterYear, easterMonth, easterDay, 0,0,0); const file = Gio.File.new_for_uri(import.meta.url).get_parent().get_child('relative_to_easter.json'); @@ -43,14 +43,14 @@ export function getRelativeToEasterNameDays(easterDay, easterMonth, easterYear, const namedaysFile = decoder.decode(contents); const jsonData = JSON.parse(namedaysFile); - // Assuming easterDateTime and currentDateTime are properly defined + // Assuming easterDateTime and currDateTime are properly defined jsonData.special.forEach(function (element) { tmpDateTime = easterDateTime.add_days(parseInt(element.toEaster)); if ( - tmpDateTime.get_day_of_month() === currentDateTime.get_day_of_month() && - tmpDateTime.get_month() === currentDateTime.get_month() && - tmpDateTime.get_year() === currentDateTime.get_year() + tmpDateTime.get_day_of_month() === currDateTime.get_day_of_month() && + tmpDateTime.get_month() === currDateTime.get_month() && + tmpDateTime.get_year() === currDateTime.get_year() ) { relativeNameDays = relativeNameDays.concat(element.main, element.variations); } @@ -60,13 +60,13 @@ export function getRelativeToEasterNameDays(easterDay, easterMonth, easterYear, } -export function getCurrentDate(currentDateTime){ +export function getCurrentDate(currDateTime){ - let currentDay = currentDateTime.get_day_of_month(); + let currentDay = currDateTime.get_day_of_month(); if (currentDay < 10) currentDay ="0".concat(currentDay.toString()); - let currentMonth = currentDateTime.get_month(); + let currentMonth = currDateTime.get_month(); if (currentMonth < 10 ) currentMonth = "0".concat(currentMonth.toString()); From f57d510a60ac9d4a05683f2ee0452ed639967ce7 Mon Sep 17 00:00:00 2001 From: Nathaniel Russell <46272571+nater1983@users.noreply.github.com> Date: Sat, 6 Apr 2024 20:40:50 -0500 Subject: [PATCH 3/6] Update extension.js --- eortologio@danchris.github.io/extension.js | 45 ++++++++++++++-------- 1 file changed, 28 insertions(+), 17 deletions(-) diff --git a/eortologio@danchris.github.io/extension.js b/eortologio@danchris.github.io/extension.js index 2be9865..6504d80 100644 --- a/eortologio@danchris.github.io/extension.js +++ b/eortologio@danchris.github.io/extension.js @@ -15,20 +15,20 @@ * * SPDX-License-Identifier: GPL-2.0-or-later */ - + import GObject from 'gi://GObject'; import GLib from 'gi://GLib'; import St from 'gi://St'; import Clutter from 'gi://Clutter'; - + import {Extension, gettext as _} from 'resource:///org/gnome/shell/extensions/extension.js'; import * as PanelMenu from 'resource:///org/gnome/shell/ui/panelMenu.js'; import * as PopupMenu from 'resource:///org/gnome/shell/ui/popupMenu.js'; import * as Helpers from './helpers.js'; - + import * as Main from 'resource:///org/gnome/shell/ui/main.js'; - - + + const EortologioPopup = GObject.registerClass( class EortologioPopup extends PanelMenu.Button { _init() { @@ -37,51 +37,62 @@ const EortologioPopup = GObject.registerClass( text: "Eortologio", y_align: Clutter.ActorAlign.CENTER, }); - + this.add_child(label); - + + // set the label that describes the button for screenreader users + this.set_label_actor(label); + + // This is the time at construction, which is the same as the time + // when `enable()` is called. this.dateTime = GLib.DateTime.new_now_local(); - let currentNamedays = Helpers.getNameDays(this.dateTime); - - updateMenu(this.menu, currentNamedays); + let initialNamedays = Helpers.getNameDays(this.dateTime); + updateMenu(this.menu, initialNamedays); + this._timeoutId = GLib.timeout_add_seconds(GLib.PRIORITY_DEFAULT, 60 * 60, () => { - + + // This is current time when the callback is invoked we are now inside let currDateTime = GLib.DateTime.new_now_local(); if (this.dateTime.get_day_of_month() != currDateTime.get_day_of_month() || this.dateTime.get_month() != currDateTime.get_month() || this.dateTime.get_year() != currDateTime.get_year() ) { + // The day has changed, so we update the reference time and menu this.dateTime = currDateTime; let currentNamedays = Helpers.getNameDays(this.dateTime); updateMenu(this.menu, currentNamedays); } return GLib.SOURCE_CONTINUE; }); + + this.connect('destroy', () => { + GLib.Source.remove(this._timeoutId); + this._timeoutId = null; + }); } } ); - + export default class EortologioPopupExtension extends Extension { enable() { this._EortologioPopup = new EortologioPopup(); Main.panel.addToStatusArea(this.uuid, this._EortologioPopup); } - + disable() { - currDateTime = null this._EortologioPopup.destroy(); this._EortologioPopup = null; } } - + function updateMenu(menu, names) { - + if (!menu.isEmpty()) { menu.removeAll() } - + if (names.length === 0){ menu.addMenuItem(new PopupMenu.PopupMenuItem('No Celebrations today...')); } From 3a3c5983fe758ac489c576617d3874458c161269 Mon Sep 17 00:00:00 2001 From: Nathaniel Russell <46272571+nater1983@users.noreply.github.com> Date: Sun, 7 Apr 2024 10:40:04 -0500 Subject: [PATCH 4/6] Update extension.js Cleanup white space --- eortologio@danchris.github.io/extension.js | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/eortologio@danchris.github.io/extension.js b/eortologio@danchris.github.io/extension.js index 6504d80..0e7da36 100644 --- a/eortologio@danchris.github.io/extension.js +++ b/eortologio@danchris.github.io/extension.js @@ -15,7 +15,7 @@ * * SPDX-License-Identifier: GPL-2.0-or-later */ - + import GObject from 'gi://GObject'; import GLib from 'gi://GLib'; import St from 'gi://St'; @@ -25,10 +25,10 @@ import {Extension, gettext as _} from 'resource:///org/gnome/shell/extensions/ex import * as PanelMenu from 'resource:///org/gnome/shell/ui/panelMenu.js'; import * as PopupMenu from 'resource:///org/gnome/shell/ui/popupMenu.js'; import * as Helpers from './helpers.js'; - + import * as Main from 'resource:///org/gnome/shell/ui/main.js'; - - + + const EortologioPopup = GObject.registerClass( class EortologioPopup extends PanelMenu.Button { _init() { @@ -37,9 +37,9 @@ const EortologioPopup = GObject.registerClass( text: "Eortologio", y_align: Clutter.ActorAlign.CENTER, }); - + this.add_child(label); - + // set the label that describes the button for screenreader users this.set_label_actor(label); @@ -74,19 +74,19 @@ const EortologioPopup = GObject.registerClass( } } ); - + export default class EortologioPopupExtension extends Extension { enable() { this._EortologioPopup = new EortologioPopup(); Main.panel.addToStatusArea(this.uuid, this._EortologioPopup); } - + disable() { this._EortologioPopup.destroy(); this._EortologioPopup = null; } } - + function updateMenu(menu, names) { if (!menu.isEmpty()) { From bd906d04a1f84db6ba94e26b9bb6c046d1c567d2 Mon Sep 17 00:00:00 2001 From: Nathaniel Russell <46272571+nater1983@users.noreply.github.com> Date: Sun, 7 Apr 2024 10:42:02 -0500 Subject: [PATCH 5/6] Update extension.js Remove the last bit of white space --- eortologio@danchris.github.io/extension.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/eortologio@danchris.github.io/extension.js b/eortologio@danchris.github.io/extension.js index 0e7da36..0e499aa 100644 --- a/eortologio@danchris.github.io/extension.js +++ b/eortologio@danchris.github.io/extension.js @@ -20,7 +20,7 @@ import GObject from 'gi://GObject'; import GLib from 'gi://GLib'; import St from 'gi://St'; import Clutter from 'gi://Clutter'; - + import {Extension, gettext as _} from 'resource:///org/gnome/shell/extensions/extension.js'; import * as PanelMenu from 'resource:///org/gnome/shell/ui/panelMenu.js'; import * as PopupMenu from 'resource:///org/gnome/shell/ui/popupMenu.js'; @@ -88,11 +88,11 @@ export default class EortologioPopupExtension extends Extension { } function updateMenu(menu, names) { - + if (!menu.isEmpty()) { menu.removeAll() } - + if (names.length === 0){ menu.addMenuItem(new PopupMenu.PopupMenuItem('No Celebrations today...')); } From 5635df54800579e8da3a54d70dc99db1e81f4c7f Mon Sep 17 00:00:00 2001 From: Nathaniel Russell <46272571+nater1983@users.noreply.github.com> Date: Sun, 11 Aug 2024 21:50:48 -0500 Subject: [PATCH 6/6] Add Gnome Shell 47 Add 47 and updated the version number --- eortologio@danchris.github.io/metadata.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/eortologio@danchris.github.io/metadata.json b/eortologio@danchris.github.io/metadata.json index 1319ea1..f35487e 100644 --- a/eortologio@danchris.github.io/metadata.json +++ b/eortologio@danchris.github.io/metadata.json @@ -2,7 +2,7 @@ "name": "Eortologio", "description": "Simple gnome extension to display the greek namedays", "uuid": "eortologio@danchris.github.io", - "shell-version": ["45", "46"], + "shell-version": ["45", "46", "47"], "url": "https://github.com/danchris/eortologio-gnome-shell-extension", - "version": 8 + "version": 9 }