commit hamster-time-tracker for openSUSE:Factory
Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package hamster-time-tracker for openSUSE:Factory checked in at 2023-09-29 21:13:53 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/hamster-time-tracker (Old) and /work/SRC/openSUSE:Factory/.hamster-time-tracker.new.28202 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Package is "hamster-time-tracker" Fri Sep 29 21:13:53 2023 rev:9 rq:1114055 version:unknown Changes: -------- --- /work/SRC/openSUSE:Factory/hamster-time-tracker/hamster-time-tracker.changes 2023-06-20 16:48:51.567542112 +0200 +++ /work/SRC/openSUSE:Factory/.hamster-time-tracker.new.28202/hamster-time-tracker.changes 2023-09-29 21:15:06.525071387 +0200 @@ -1,0 +2,19 @@ +Wed Sep 27 21:07:24 UTC 2023 - Martin Wilck <mwilck@suse.com> + +- Update GNOME extension for GNOME shell 45 support + (older GNOME shell is not supported any more) + * add 0162-README.rst-add-info-about-restarting-the-extension.patch + * add 0163-TotalTimeWidget-port-to-JS6-classes.patch + * add 0164-prefs.js-Remove-display-of-extension-version.patch + * add 0165-settings-schema-fix-description-for-panel-placement-.patch + * add 0166-README.rst-simplify-installation-instructions.patch + * add 0167-panelWidget-add-button-to-open-extension-settings.patch + * add 0168-Use-ECMAScript-import-export-statements.patch + * add 0169-extension.js-adapt-to-GNOME-45.patch + * add 0170-prefs.js-re-implement-for-GNOME-45.patch + * add 0171-metadata.json.in-GNOME-45-support.patch + * add 0172-README.rst-fixup-GNOME-shell-compatiblility.patch + * add 0173-Replace-global.log-by-console.log.patch + * del 0133-Bump-latest-validated-gnome-shell-version-1.patch (empty) + +------------------------------------------------------------------- Old: ---- 0133-Bump-latest-validated-gnome-shell-version-1.patch New: ---- 0162-README.rst-add-info-about-restarting-the-extension.patch 0163-TotalTimeWidget-port-to-JS6-classes.patch 0164-prefs.js-Remove-display-of-extension-version.patch 0165-settings-schema-fix-description-for-panel-placement-.patch 0166-README.rst-simplify-installation-instructions.patch 0167-panelWidget-add-button-to-open-extension-settings.patch 0168-Use-ECMAScript-import-export-statements.patch 0169-extension.js-adapt-to-GNOME-45.patch 0170-prefs.js-re-implement-for-GNOME-45.patch 0171-metadata.json.in-GNOME-45-support.patch 0172-README.rst-fixup-GNOME-shell-compatiblility.patch 0173-Replace-global.log-by-console.log.patch ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ hamster-time-tracker.spec ++++++ --- /var/tmp/diff_new_pack.5nDRYV/_old 2023-09-29 21:15:11.753260020 +0200 +++ /var/tmp/diff_new_pack.5nDRYV/_new 2023-09-29 21:15:11.757260164 +0200 @@ -21,8 +21,8 @@ # ext_gnome_version: latest GNOME shell version supported # min_gnome_version: earliest GNOME shell version supported %if 0%{?suse_version} >= 1550 -%global ext_gnome_version 44 -%global min_gnome_version 3.34 +%global ext_gnome_version 45 +%global min_gnome_version 45 %else %if 0%{?sle_version} >= 150400 %global ext_gnome_version 41 @@ -93,7 +93,6 @@ Patch130: 0130-README.rst-Add-a-section-about-UUID-changing.patch Patch131: 0131-metadata.json.in-fix-json-syntax-error.patch Patch132: 0132-Update-README.st.patch -Patch133: 0133-Bump-latest-validated-gnome-shell-version-1.patch Patch134: 0134-README-mention-GNOME-shell-compatibility-of-this-ver.patch Patch135: 0135-README.rst-document-GNOME-shell-compatibility.patch Patch136: 0136-ongoingFactEntry-stop-using-deprecated-Clutter-key-s.patch @@ -125,6 +124,19 @@ Patch159: 0159-Report-errors-in-DBUS-calls.patch Patch160: 0160-Report-errors-on-initial-DBUS-connection.patch Patch161: 0161-Gracefully-handle-hamster-DBUS-disappearing.patch +# GNOME 45 +Patch162: 0162-README.rst-add-info-about-restarting-the-extension.patch +Patch163: 0163-TotalTimeWidget-port-to-JS6-classes.patch +Patch164: 0164-prefs.js-Remove-display-of-extension-version.patch +Patch165: 0165-settings-schema-fix-description-for-panel-placement-.patch +Patch166: 0166-README.rst-simplify-installation-instructions.patch +Patch167: 0167-panelWidget-add-button-to-open-extension-settings.patch +Patch168: 0168-Use-ECMAScript-import-export-statements.patch +Patch169: 0169-extension.js-adapt-to-GNOME-45.patch +Patch170: 0170-prefs.js-re-implement-for-GNOME-45.patch +Patch171: 0171-metadata.json.in-GNOME-45-support.patch +Patch172: 0172-README.rst-fixup-GNOME-shell-compatiblility.patch +Patch173: 0173-Replace-global.log-by-console.log.patch BuildRequires: fdupes BuildRequires: intltool @@ -222,7 +234,6 @@ %patch130 -p1 %patch131 -p1 %patch132 -p1 -%patch133 -p1 %patch134 -p1 %patch135 -p1 %patch136 -p1 @@ -252,6 +263,21 @@ %patch160 -p1 %patch161 -p1 %endif +%if 0%{?suse_version} >= 1600 +# TW: GNOME 45 support +%patch162 -p1 +%patch163 -p1 +%patch164 -p1 +%patch165 -p1 +%patch166 -p1 +%patch167 -p1 +%patch168 -p1 +%patch169 -p1 +%patch170 -p1 +%patch171 -p1 +%patch172 -p1 +%patch173 -p1 +%endif %endif mkdir build ++++++ 0162-README.rst-add-info-about-restarting-the-extension.patch ++++++ From 470ef00f9378d6960f53ed0dd2f228bb31d1f676 Mon Sep 17 00:00:00 2001 From: Martin Wilck <mwilck@suse.com> Date: Thu, 10 Aug 2023 18:04:46 +0200 Subject: [PATCH 162/173] README.rst: add info about restarting the extension --- README.rst | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/README.rst b/README.rst index 1e5b305..fe4e920 100644 --- a/README.rst +++ b/README.rst @@ -93,6 +93,17 @@ Afterwards, enable the extension and change the preferences using Tweak Tool, or on ``https://extensions.gnome.org/local/``. On GNOME 3.36 and later, you can also use the GNOME "Extensions" tool. +Reloading the Extension +~~~~~~~~~~~~~~~~~~~~~~~ + +If the Hamster GNOME shell extension is already loaded and you change some code, +the GNOME shell needs to be restarted in order to update and restart the extension. +The easiest way to do this is to run GNOME under X11 and use the key combination +``Alt-F2`` followed by ``r``. If you run GNOME under Wayland, either re-login, or +start a `nested session <https://wiki.gnome.org/Initiatives/Wayland/GnomeShell/Testing>`_:: + + dbus-run-session -- gnome-shell --nested --wayland + Changing the extension UUID ~~~~~~~~~~~~~~~~~~~~~~~~~~~ -- 2.42.0 ++++++ 0163-TotalTimeWidget-port-to-JS6-classes.patch ++++++ From 8c4857f9902810b4c369c0317ea90ebabe15caba Mon Sep 17 00:00:00 2001 From: Martin Wilck <mwilck@suse.com> Date: Fri, 22 Sep 2023 17:28:06 +0200 Subject: [PATCH 163/173] TotalTimeWidget: port to JS6 classes See 9c0b672 ("Port GObject classes to JS6 classes") Signed-off-by: Martin Wilck <mwilck@suse.com> --- extension/widgets/totalTimeWidget.js | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/extension/widgets/totalTimeWidget.js b/extension/widgets/totalTimeWidget.js index a956c36..9a6d64b 100644 --- a/extension/widgets/totalTimeWidget.js +++ b/extension/widgets/totalTimeWidget.js @@ -21,12 +21,10 @@ Copyright (c) 2016 - 2018 Eric Goller / projecthamster <elbenfreund@projecthamst Copyright (c) 2018 Thibaut Madelaine <madtibo_git@tribu-ml.fr> */ - -const Lang = imports.lang; const St = imports.gi.St; const Clutter = imports.gi.Clutter; const GLib = imports.gi.GLib; - +const GObject = imports.gi.GObject; const Me = imports.misc.extensionUtils.getCurrentExtension(); const Stuff = Me.imports.stuff; @@ -34,19 +32,16 @@ const Stuff = Me.imports.stuff; /** * Custom Label widget that displays total time. */ -var TotalTimeWidget = new Lang.Class({ - Name: 'TotalTime', - Extends: St.Label, - - _init: function() { - this.parent({style_class: 'summary-label'}); - - }, +var TotalTimeWidget = GObject.registerClass( + class TotalTime extends St.Label { + _init() { + super._init({style_class: 'summary-label'}); + } /** * Recompute values and replace old string with new one based on passed facts. */ - refresh: function(facts) { + refresh(facts) { /** * Construct a string representing today total. */ @@ -61,5 +56,5 @@ var TotalTimeWidget = new Lang.Class({ } this.set_text(getString(facts)); - }, + } }); -- 2.42.0 ++++++ 0164-prefs.js-Remove-display-of-extension-version.patch ++++++ From 0da6e64b06dd55fbf80438dfa62157a64e73eca9 Mon Sep 17 00:00:00 2001 From: Martin Wilck <mwilck@suse.com> Date: Fri, 22 Sep 2023 20:04:12 +0200 Subject: [PATCH 164/173] prefs.js: Remove display of extension version The meta data object in recent versions of GNOME shell doesn't contain a 'version' field. We have removed it from metadata.json with 4b9687b ("metadata.json: remove "version" field"). The prefs dialog will just show "undefined", which is not helpful. Remove the widget displaying the version. Signed-off-by: Martin Wilck <mwilck@suse.com> --- extension/prefs.js | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/extension/prefs.js b/extension/prefs.js index 86b2f5e..23e9ab0 100644 --- a/extension/prefs.js +++ b/extension/prefs.js @@ -25,10 +25,7 @@ const Gdk = imports.gi.Gdk; const Gio = imports.gi.Gio; const Gtk = imports.gi.Gtk; const GObject = imports.gi.GObject; - - const ExtensionUtils = imports.misc.extensionUtils; -const Me = ExtensionUtils.getCurrentExtension(); const HamsterSettingsWidget = GObject.registerClass( class HamsterSettingsWidget extends Gtk.Grid { @@ -124,14 +121,6 @@ class HamsterSettingsWidget extends Gtk.Grid { }); this.attach(label, 0, 3, 2, 1); - let version_text = Me.metadata.version; - label = new Gtk.Label({ - label: "You are running hamster-shell-extension version " + version_text, - halign: Gtk.Align.CENTER, - visible: true, - margin_top: 10 - }); - this.attach(label, 0, 4, 2, 1); } _onPlacementChange(widget) { -- 2.42.0 ++++++ 0165-settings-schema-fix-description-for-panel-placement-.patch ++++++ From 4b11f19f9b3777cd0022719871f08386fd9e516f Mon Sep 17 00:00:00 2001 From: Martin Wilck <mwilck@suse.com> Date: Fri, 22 Sep 2023 23:11:22 +0200 Subject: [PATCH 165/173] settings schema: fix description for panel-placement, add gettext domain --- .../org.gnome.shell.extensions.project-hamster.gschema.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/data/schemas/org.gnome.shell.extensions.project-hamster.gschema.xml b/data/schemas/org.gnome.shell.extensions.project-hamster.gschema.xml index 8a35b28..5122c39 100644 --- a/data/schemas/org.gnome.shell.extensions.project-hamster.gschema.xml +++ b/data/schemas/org.gnome.shell.extensions.project-hamster.gschema.xml @@ -1,10 +1,10 @@ <?xml version="1.0" encoding="UTF-8"?> -<schemalist> +<schemalist gettext-domain="hamster-shell-extension"> <schema id="org.gnome.shell.extensions.project-hamster" path="/org/gnome/shell/extensions/project-hamster/"> <key name="panel-placement" type="i"> <default>0</default> <summary>Placement in the panel.</summary> - <description>Position to place extension at. 0 - default, 1 - replace calendar, 2 - replace activities.</description> + <description>Position to place extension at. 0 - default, 1 - replace calendar, 2 - replace activities, 3 - Center, next to calendar.</description> </key> <key name="panel-appearance" type="i"> -- 2.42.0 ++++++ 0166-README.rst-simplify-installation-instructions.patch ++++++ From 222aa30dcb64ba5388ca645b7bdab87ada4009a2 Mon Sep 17 00:00:00 2001 From: Martin Wilck <mwilck@suse.com> Date: Mon, 25 Sep 2023 18:06:16 +0200 Subject: [PATCH 166/173] README.rst: simplify installation instructions Signed-off-by: Martin Wilck <mwilck@suse.com> --- README.rst | 63 ++++++++++++++++-------------------------------------- 1 file changed, 19 insertions(+), 44 deletions(-) diff --git a/README.rst b/README.rst index fe4e920..41a4a52 100644 --- a/README.rst +++ b/README.rst @@ -31,68 +31,43 @@ hamster`` which should bring up ``hamster-service`` and Install For Production ~~~~~~~~~~~~~~~~~~~~~~ -The extension is available on `the central extension repository <https://extensions.gnome.org/extension/425/project-hamster-extension>`_. -Current compatible Gnome shell versions: 3.34, 3.36. *This version is not compatible -with Gnome shell 3.32 and earlier.* -For previous shell versions check `releases <https://github.com/projecthamster/hamster-shell-extension/tags>`_. +Please follow the instructions under +`Manual Installation For Testing and Development`_ below to install from git. +The code in this branch (``develop``) is compatible with GNOME shell 3.34 +up to GNOME shell 44. See also `metadata.json.in`_. -Creating a development environment -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -As ``hamster-shell-extension`` is mainly simple JS there is not much of a development -setup needed if you just want to get hacking right away. We do however provide -a few convenience functionalities that make documenting and releasing the extension -easier. For those purposes some additional python packages are required. -The easiest and cleanest way to go about this is to create a new virtual environment and activate -it:: +*Important:* The "Hamster Time Tracker" extension on +`extensions.gnome.org https://extensions.gnome.org/extension/425/project-hamster-extension/`_ +is *severely outdated*; it supports GNOME shell up to 3.20 only. There are +some other versions of this extension on extensions.gnome.org, but none of +them is supported by the current maintainers of the extension. - python3 -m venv .venv - source .venv/bin/activate - -Now you are all setup to run ``make develop`` and related make targets without -changing you main environment. +.. _metadata.json.in: data/metadata.json.in Manual Installation For Testing and Development ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + Clone the repository:: git clone https://github.com/projecthamster/hamster-shell-extension.git Make sure you are on the development branch:: - git checkout develop + git switch -c develop origin/develop -Build a fresh distribution package:: +To make this build available locally under your user account:: + + make install-user + +To build a fresh distribution package (this will create a distributable archive located in the ``dist/`` folder):: make dist -This will create a distributable archive located in the ``dist/`` folder. +Afterwards, enable the extension and change the preferences using the +*gnome-extensions* tool (on GNOME 3.34 and earlier, you need to use *gnome-tweak-tool*). -**Shortcut on** ``develop`` - -If you are using the ``develop`` branch since May 2020, you can run ``make -install-user`` to install your current working branch in your user environment -or ``make install`` for a system-wide installation. The ``DESTDIR`` variable -can be provided to ``make install`` to adjust the base installation path (it -defaults to ``DESTDIR=/usr/local``). - -Otherwise, on other branches, follow the steps below to manually install the -distribution archive:: - - # Build - make dist - # Remove any old installation - rm -rf ~/.local/share/gnome-shell/extensions/contact@projecthamster.org - # Create directory - mkdir -p ~/.local/share/gnome-shell/extensions/contact@projecthamster.org - # Unpack build - tar xfz dist/contact@projecthamster.org.tar.gz -C ~/.local/share/gnome-shell/extensions/contact@projecthamster.org - -Afterwards, enable the extension and change the preferences using Tweak Tool, -or on ``https://extensions.gnome.org/local/``. On GNOME 3.36 and later, you -can also use the GNOME "Extensions" tool. - Reloading the Extension ~~~~~~~~~~~~~~~~~~~~~~~ -- 2.42.0 ++++++ 0167-panelWidget-add-button-to-open-extension-settings.patch ++++++ From 2b3257b3c9530c7ef12c1ada9be53afc2cc088d2 Mon Sep 17 00:00:00 2001 From: Martin Wilck <mwilck@suse.com> Date: Mon, 25 Sep 2023 17:02:48 +0200 Subject: [PATCH 167/173] panelWidget: add button to open extension settings Signed-off-by: Martin Wilck <mwilck@suse.com> --- extension/widgets/panelWidget.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/extension/widgets/panelWidget.js b/extension/widgets/panelWidget.js index 0d9e870..4a15dd6 100644 --- a/extension/widgets/panelWidget.js +++ b/extension/widgets/panelWidget.js @@ -125,6 +125,11 @@ class PanelWidget extends PanelMenu.Button { SettingMenuItem.connect('activate', this._onOpenSettings.bind(this)); this.menu.addMenuItem(SettingMenuItem); + let ExtSettingMenuItem = new PopupMenu.PopupMenuItem(_("Extension Settings")); + ExtSettingMenuItem.connect('activate', + () => this._controller.openPreferences()); + this.menu.addMenuItem(ExtSettingMenuItem); + // focus menu upon display this.menu.connect('open-state-changed', function(menu, open) { -- 2.42.0 ++++++ 0168-Use-ECMAScript-import-export-statements.patch ++++++ From 96bfe69e7f9f6e0f175a4c501a96054cb537850e Mon Sep 17 00:00:00 2001 From: Martin Wilck <mwilck@suse.com> Date: Fri, 22 Sep 2023 18:53:26 +0200 Subject: [PATCH 168/173] Use ECMAScript import/export statements https://gjs.guide/extensions/upgrading/gnome-shell-45.html Signed-off-by: Martin Wilck <mwilck@suse.com> --- extension/extension.js | 18 +++++-------- extension/prefs.js | 9 +++---- extension/stuff.js | 10 +++---- extension/widgets/categoryTotalsWidget.js | 14 +++++----- extension/widgets/factsBox.js | 32 ++++++++++------------- extension/widgets/ongoingFactEntry.js | 14 +++++----- extension/widgets/panelWidget.js | 25 +++++++++--------- extension/widgets/todaysFactsWidget.js | 18 ++++++------- extension/widgets/totalTimeWidget.js | 14 +++++----- 9 files changed, 70 insertions(+), 84 deletions(-) diff --git a/extension/extension.js b/extension/extension.js index 8ece31e..31068ef 100644 --- a/extension/extension.js +++ b/extension/extension.js @@ -21,18 +21,14 @@ Copyright (c) 2016 - 2018 Eric Goller / projecthamster <elbenfreund@projecthamst */ -const GLib = imports.gi.GLib; -const Shell = imports.gi.Shell; -const Meta = imports.gi.Meta; -const Main = imports.ui.main; -const Gio = imports.gi.Gio; +import GLib from 'gi://GLib'; +import Shell from 'gi://Shell'; +import Meta from 'gi://Meta'; +import Gio from 'gi://Gio'; +import * as Main from 'resource:///org/gnome/shell/ui/main.js'; -const Gettext = imports.gettext.domain('hamster-shell-extension'); -const _ = Gettext.gettext; - -const ExtensionUtils = imports.misc.extensionUtils; -const Me = ExtensionUtils.getCurrentExtension(); -const PanelWidget = Me.imports.widgets.panelWidget.PanelWidget; +import {Extension, gettext as _} from 'resource:///org/gnome/shell/extensions/extension.js'; +import PanelWidget from './widgets/panelWidget.js'; // dbus-send --session --type=method_call --print-reply --dest=org.gnome.Hamster /org/gnome/Hamster org.freedesktop.DBus.Introspectable.Introspect const ApiProxyIface = ['', diff --git a/extension/prefs.js b/extension/prefs.js index 23e9ab0..c7ae150 100644 --- a/extension/prefs.js +++ b/extension/prefs.js @@ -21,11 +21,10 @@ Copyright (c) 2016 - 2018 Eric Goller / projecthamster <elbenfreund@projecthamst */ -const Gdk = imports.gi.Gdk; -const Gio = imports.gi.Gio; -const Gtk = imports.gi.Gtk; -const GObject = imports.gi.GObject; -const ExtensionUtils = imports.misc.extensionUtils; +import Gdk from 'gi://Gdk'; +import Gio from 'gi://Gio'; +import Gtk from 'gi://Gtk'; +import GObject from 'gi://GObject'; const HamsterSettingsWidget = GObject.registerClass( class HamsterSettingsWidget extends Gtk.Grid { diff --git a/extension/stuff.js b/extension/stuff.js index 56c7054..4cd8a12 100644 --- a/extension/stuff.js +++ b/extension/stuff.js @@ -29,7 +29,7 @@ Copyright (c) 2016 - 2018 Eric Goller / projecthamster <elbenfreund@projecthamst * * @param {int} - Total amount of seconds to represent. */ -function formatDuration(total_seconds) { +export function formatDuration(total_seconds) { let hours = total_seconds / 3600; let remaining_seconds = total_seconds % 3600; // We only care for "full minutes". @@ -45,7 +45,7 @@ function formatDuration(total_seconds) { * * @param {int} - Total amount of seconds to represent. */ -function formatDurationHuman(total_seconds) { +export function formatDurationHuman(total_seconds) { let hours = total_seconds / 3600; let remaining_seconds = total_seconds % 3600; // We only care for "full minutes". @@ -75,7 +75,7 @@ function formatDurationHuman(total_seconds) { * * @param {int} - Total amount of seconds to represent. */ -function formatDurationHours(seconds) { +export function formatDurationHours(seconds) { // We shift by one decimal place to the left in order to round properly. let hours = Math.round((seconds/3600)*10); // Shift right after rounding. @@ -85,7 +85,7 @@ function formatDurationHours(seconds) { // Other helper functions -function fromDbusFact(fact) { +export function fromDbusFact(fact) { // converts a fact coming from dbus into a usable object function UTCToLocal(timestamp) { // TODO - is this really the way?! @@ -108,7 +108,7 @@ function fromDbusFact(fact) { return result; } -function fromDbusFacts(facts) { +export function fromDbusFacts(facts) { let res = []; for (var fact of facts) { res.push(fromDbusFact(fact)); diff --git a/extension/widgets/categoryTotalsWidget.js b/extension/widgets/categoryTotalsWidget.js index 88f9b96..9b36b7e 100644 --- a/extension/widgets/categoryTotalsWidget.js +++ b/extension/widgets/categoryTotalsWidget.js @@ -21,13 +21,11 @@ Copyright (c) 2016 - 2018 Eric Goller / projecthamster <elbenfreund@projecthamst */ -const St = imports.gi.St; -const Clutter = imports.gi.Clutter; -const GLib = imports.gi.GLib; -const GObject = imports.gi.GObject; - -const Me = imports.misc.extensionUtils.getCurrentExtension(); -const Stuff = Me.imports.stuff; +import St from 'gi://St'; +import Clutter from 'gi://Clutter'; +import GLib from 'gi://GLib'; +import GObject from 'gi://GObject'; +import * as Stuff from '../stuff.js' /** @@ -66,3 +64,5 @@ class CategoryTotals extends St.Label { this.set_text(getString(facts)); } }); + +export default CategoryTotalsWidget; diff --git a/extension/widgets/factsBox.js b/extension/widgets/factsBox.js index a033602..ab745de 100644 --- a/extension/widgets/factsBox.js +++ b/extension/widgets/factsBox.js @@ -21,23 +21,18 @@ Copyright (c) 2016 - 2018 Eric Goller / projecthamster <elbenfreund@projecthamst */ -const St = imports.gi.St; -const PopupMenu = imports.ui.popupMenu; -const Clutter = imports.gi.Clutter; -const Mainloop = imports.mainloop; -const GLib = imports.gi.GLib; -const GObject = imports.gi.GObject; - -const Gettext = imports.gettext.domain('hamster-shell-extension'); -const _ = Gettext.gettext; - -const Me = imports.misc.extensionUtils.getCurrentExtension(); -const Stuff = Me.imports.stuff; -const OngoingFactEntry = Me.imports.widgets.ongoingFactEntry.OngoingFactEntry; -const CategoryTotalsWidget = Me.imports.widgets.categoryTotalsWidget.CategoryTotalsWidget; -const TotalTimeWidget = Me.imports.widgets.totalTimeWidget.TotalTimeWidget; -const TodaysFactsWidget = Me.imports.widgets.todaysFactsWidget.TodaysFactsWidget; +import St from 'gi://St'; +import Clutter from 'gi://Clutter'; +import GLib from 'gi://GLib'; +import GObject from 'gi://GObject'; +import { gettext as _ } from 'resource:///org/gnome/shell/extensions/extension.js'; +import * as PopupMenu from 'resource:///org/gnome/shell/ui/popupMenu.js'; +import * as Stuff from '../stuff.js'; +import OngoingFactEntry from './ongoingFactEntry.js'; +import CategoryTotalsWidget from './categoryTotalsWidget.js'; +import TotalTimeWidget from './totalTimeWidget.js'; +import TodaysFactsWidget from './todaysFactsWidget.js'; /** * Create the widget that ``PanelWidget`` will use to dispay the *raw fact entry* as @@ -79,7 +74,6 @@ class FactsBox extends PopupMenu.PopupBaseMenuItem { // Setup category summery this.summaryLabel = new CategoryTotalsWidget(); main_box.add(this.summaryLabel); - // Setup total time this.totalTimeLabel = new TotalTimeWidget(); main_box.add(this.totalTimeLabel); @@ -100,7 +94,7 @@ class FactsBox extends PopupMenu.PopupBaseMenuItem { * Focus the fact entry and make sure todaysFactsWidget are scrolled to the bottom. */ focus() { - Mainloop.timeout_add(20, function() { + GLib.timeout_add(GLib.PRIORITY_DEFAULT, 20, function() { this._scrollAdjustment.value = this._scrollAdjustment.upper; global.stage.set_key_focus(this.ongoingFactEntry); }.bind(this)); @@ -113,3 +107,5 @@ class FactsBox extends PopupMenu.PopupBaseMenuItem { global.stage.set_key_focus(null); } }); + +export default FactsBox; diff --git a/extension/widgets/ongoingFactEntry.js b/extension/widgets/ongoingFactEntry.js index cce4929..cd63ae3 100644 --- a/extension/widgets/ongoingFactEntry.js +++ b/extension/widgets/ongoingFactEntry.js @@ -21,15 +21,11 @@ Copyright (c) 2016 - 2018 Eric Goller / projecthamster <elbenfreund@projecthamst */ -const GObject = imports.gi.GObject; -const St = imports.gi.St; -const Clutter = imports.gi.Clutter; - -const Gettext = imports.gettext.domain('hamster-shell-extension'); -const _ = Gettext.gettext; - -const Me = imports.misc.extensionUtils.getCurrentExtension(); +import GObject from 'gi://GObject'; +import St from 'gi://St'; +import Clutter from 'gi://Clutter'; +import { gettext as _ } from 'resource:///org/gnome/shell/extensions/extension.js'; /** * Custom Entry widget that allows entering a *raw fact* string for a new ongoing fact. @@ -186,3 +182,5 @@ class OngoingFactEntry extends St.Entry { } } }); + +export default OngoingFactEntry; diff --git a/extension/widgets/panelWidget.js b/extension/widgets/panelWidget.js index 4a15dd6..b02d37b 100644 --- a/extension/widgets/panelWidget.js +++ b/extension/widgets/panelWidget.js @@ -21,20 +21,17 @@ Copyright (c) 2016 - 2018 Eric Goller / projecthamster <elbenfreund@projecthamst */ -const Gio = imports.gi.Gio; -const GObject = imports.gi.GObject; -const Clutter = imports.gi.Clutter; -const PanelMenu = imports.ui.panelMenu; -const St = imports.gi.St; -const PopupMenu = imports.ui.popupMenu; -const GLib = imports.gi.GLib; +import Gio from 'gi://Gio'; +import GObject from 'gi://GObject'; +import Clutter from 'gi://Clutter'; +import St from 'gi://St'; +import GLib from 'gi://GLib'; +import * as PanelMenu from 'resource:///org/gnome/shell/ui/panelMenu.js'; +import * as PopupMenu from 'resource:///org/gnome/shell/ui/popupMenu.js'; -const Gettext = imports.gettext.domain('hamster-shell-extension'); -const _ = Gettext.gettext; - -const Me = imports.misc.extensionUtils.getCurrentExtension(); -const FactsBox = Me.imports.widgets.factsBox.FactsBox; -const Stuff = Me.imports.stuff; +import { gettext as _ } from 'resource:///org/gnome/shell/extensions/extension.js'; +import FactsBox from './factsBox.js'; +import * as Stuff from '../stuff.js'; /** * Class that defines the actual extension widget to be shown in the panel. @@ -341,3 +338,5 @@ class PanelWidget extends PanelMenu.Button { } } }); + +export default PanelWidget; diff --git a/extension/widgets/todaysFactsWidget.js b/extension/widgets/todaysFactsWidget.js index 778f964..29c2370 100644 --- a/extension/widgets/todaysFactsWidget.js +++ b/extension/widgets/todaysFactsWidget.js @@ -21,17 +21,13 @@ Copyright (c) 2016 - 2018 Eric Goller / projecthamster <elbenfreund@projecthamst */ -const St = imports.gi.St; -const Clutter = imports.gi.Clutter; -const GLib = imports.gi.GLib; -const GObject = imports.gi.GObject; - -const Gettext = imports.gettext.domain('hamster-shell-extension'); -const _ = Gettext.gettext; - -const Me = imports.misc.extensionUtils.getCurrentExtension(); -const Stuff = Me.imports.stuff; +import St from 'gi://St'; +import Clutter from 'gi://Clutter'; +import GLib from 'gi://GLib'; +import GObject from 'gi://GObject'; +import { gettext as _ } from 'resource:///org/gnome/shell/extensions/extension.js'; +import * as Stuff from '../stuff.js'; /** * A widget that lists all facts for *today*. @@ -195,3 +191,5 @@ class TodaysFactsWidget extends St.ScrollView { this.populateFactsWidget(facts, ongoingFact); } }); + +export default TodaysFactsWidget; diff --git a/extension/widgets/totalTimeWidget.js b/extension/widgets/totalTimeWidget.js index 9a6d64b..d11be30 100644 --- a/extension/widgets/totalTimeWidget.js +++ b/extension/widgets/totalTimeWidget.js @@ -21,13 +21,11 @@ Copyright (c) 2016 - 2018 Eric Goller / projecthamster <elbenfreund@projecthamst Copyright (c) 2018 Thibaut Madelaine <madtibo_git@tribu-ml.fr> */ -const St = imports.gi.St; -const Clutter = imports.gi.Clutter; -const GLib = imports.gi.GLib; -const GObject = imports.gi.GObject; -const Me = imports.misc.extensionUtils.getCurrentExtension(); -const Stuff = Me.imports.stuff; - +import St from 'gi://St'; +import Clutter from 'gi://Clutter'; +import GLib from 'gi://GLib'; +import GObject from 'gi://GObject'; +import * as Stuff from '../stuff.js'; /** * Custom Label widget that displays total time. @@ -58,3 +56,5 @@ var TotalTimeWidget = GObject.registerClass( this.set_text(getString(facts)); } }); + +export default TotalTimeWidget; -- 2.42.0 ++++++ 0169-extension.js-adapt-to-GNOME-45.patch ++++++ From 3ce1d776309872c543594934ee03b13112812213 Mon Sep 17 00:00:00 2001 From: Martin Wilck <mwilck@suse.com> Date: Fri, 22 Sep 2023 21:18:08 +0200 Subject: [PATCH 169/173] extension.js: adapt to GNOME 45 https://gjs.guide/extensions/upgrading/gnome-shell-45.html#extension-js Signed-off-by: Martin Wilck <mwilck@suse.com> --- extension/extension.js | 11 +++-------- extension/widgets/panelWidget.js | 2 +- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/extension/extension.js b/extension/extension.js index 31068ef..7873763 100644 --- a/extension/extension.js +++ b/extension/extension.js @@ -88,11 +88,11 @@ let WindowsProxy = Gio.DBusProxy.makeProxyWrapper(WindowsProxyIface); * * @class */ -class Controller { +export default class Controller extends Extension { constructor(extensionMeta) { let dateMenu = Main.panel.statusArea.dateMenu; - this.extensionMeta = extensionMeta; + super(extensionMeta); this.panelWidget = null; this.settings = null; this.placement = 0; @@ -136,7 +136,7 @@ class Controller { if (!this.shouldEnable || !this.apiProxy || !this.windowsProxy) return; - this.settings = ExtensionUtils.getSettings(); + this.settings = this.getSettings(); this.panelWidget = new PanelWidget(this); this.placement = this.settings.get_int("panel-placement"); @@ -281,8 +281,3 @@ class Controller { } } - -function init(extensionMeta) { - ExtensionUtils.initTranslations(); - return new Controller(extensionMeta); -} diff --git a/extension/widgets/panelWidget.js b/extension/widgets/panelWidget.js index b02d37b..bfdc41b 100644 --- a/extension/widgets/panelWidget.js +++ b/extension/widgets/panelWidget.js @@ -62,7 +62,7 @@ class PanelWidget extends PanelMenu.Button { this._controller = controller; // [FIXME] // Still needed? - this._extensionMeta = controller.extensionMeta; + this._extensionMeta = controller.metadata; this._settings = controller.settings; this._windowsProxy = controller.windowsProxy; -- 2.42.0 ++++++ 0170-prefs.js-re-implement-for-GNOME-45.patch ++++++ From 56a49e059d6ba187086df9690303352e27ed1702 Mon Sep 17 00:00:00 2001 From: Martin Wilck <mwilck@suse.com> Date: Fri, 22 Sep 2023 23:12:35 +0200 Subject: [PATCH 170/173] prefs.js: re-implement for GNOME 45 I used check buttons for the settings. Adw.ComboRow might have been more suitable, but I couldn't find an example how to set it up. The code here was copied from GNOME's window-list extension and adapted to hamster. Signed-off-by: Martin Wilck <mwilck@suse.com> --- extension/prefs.js | 251 ++++++++++++++++++++------------------------- 1 file changed, 114 insertions(+), 137 deletions(-) diff --git a/extension/prefs.js b/extension/prefs.js index c7ae150..0b565e6 100644 --- a/extension/prefs.js +++ b/extension/prefs.js @@ -21,155 +21,132 @@ Copyright (c) 2016 - 2018 Eric Goller / projecthamster <elbenfreund@projecthamst */ +import Adw from 'gi://Adw'; import Gdk from 'gi://Gdk'; import Gio from 'gi://Gio'; import Gtk from 'gi://Gtk'; import GObject from 'gi://GObject'; +import GLib from 'gi://GLib'; -const HamsterSettingsWidget = GObject.registerClass( -class HamsterSettingsWidget extends Gtk.Grid { - _init(params) { - super._init(params); +import {ExtensionPreferences, gettext as _} from 'resource:///org/gnome/Shell/Extensions/js/extensions/prefs.js'; - this.name = 'ProjectHamster.Prefs.HamsterSettingsWidget'; - this.set_margin_bottom(18); - this.set_margin_end(18); - this.set_margin_start(18); - this.set_margin_top(18); - this.set_column_spacing(12); - this.set_row_spacing(12); - this.visible = true; +class HotkeyRow extends Adw.EntryRow { + static { + GObject.registerClass(this); + } - this._settings = ExtensionUtils.getSettings(); + constructor({ title, settings, bind }) { + super({ + title: title, + }); - let label = new Gtk.Label({ - label: "Positioning:", - halign: Gtk.Align.START, - visible: true - }); - this.attach(label, 0, 0, 1, 1); + this.connect("apply", () => { + const hotkeys = this.get_text(); - let placementOptions = new Gtk.ListStore(); - placementOptions.set_column_types([GObject.TYPE_STRING, GObject.TYPE_INT]); + const mappings = hotkeys.split(",").map((x) => { + const [, key, mods] = Gtk.accelerator_parse(x); + return Gtk.accelerator_valid(key, mods) && Gtk.accelerator_name(key, mods); + }); - placementOptions.set(placementOptions.append(), [0, 1], ["Default", 0]); - placementOptions.set(placementOptions.append(), [0, 1], ["Replace calendar", 1]); - placementOptions.set(placementOptions.append(), [0, 1], ["Replace activities", 2]); - placementOptions.set(placementOptions.append(), [0, 1], ["Center, next to calendar", 3]); + if (mappings.every((x) => !!x)) { + console.log("HotkeyRow: good hotkey value ", hotkeys); + this.current = mappings; + settings.set_strv(bind, this.current); + } else { + console.log("invalid hotkey value ", hotkeys); + this.set_text(this.current.join(",")); + } + }); - let placementCombo = new Gtk.ComboBox({ - model: placementOptions, - visible: true - }); - - let placementComboRenderer = new Gtk.CellRendererText(); - placementCombo.pack_start(placementComboRenderer, true); - placementCombo.add_attribute(placementComboRenderer, 'text', 0); - placementCombo.connect('changed', this._onPlacementChange.bind(this)); - placementCombo.set_active(this._settings.get_int("panel-placement")); - this.attach(placementCombo, 1, 0, 1, 1); - - label = new Gtk.Label({ - label: "Appearance in panel:", - halign: Gtk.Align.START, - visible: true - }); - this.attach(label, 0, 1, 1, 1); - - let appearanceOptions = new Gtk.ListStore(); - appearanceOptions.set_column_types([GObject.TYPE_STRING, GObject.TYPE_INT]); - - appearanceOptions.set(appearanceOptions.append(), [0, 1], ["Label", 0]); - appearanceOptions.set(appearanceOptions.append(), [0, 1], ["Icon", 1]); - appearanceOptions.set(appearanceOptions.append(), [0, 1], ["Label and icon", 2]); - - let appearanceCombo = new Gtk.ComboBox({ - model: appearanceOptions, - visible: true - }); - - let appearanceComboRenderer = new Gtk.CellRendererText(); - appearanceCombo.pack_start(appearanceComboRenderer, true); - appearanceCombo.add_attribute(appearanceComboRenderer, 'text', 0); - appearanceCombo.connect('changed', this._onAppearanceChange.bind(this)); - appearanceCombo.set_active(this._settings.get_int("panel-appearance")); - this.attach(appearanceCombo, 1, 1, 1, 1); - - label = new Gtk.Label({ - label: "Global hotkey:", - halign: Gtk.Align.START, - visible: true - }); - this.attach(label, 0, 2, 1, 1); - - let entry = new Gtk.Entry({ - margin_bottom: 10, - margin_top: 5, - text: this._settings.get_strv("show-hamster-dropdown")[0], - visible: true - }); - entry.connect('changed', this._onHotkeyChange.bind(this)); - this.attach(entry, 1, 2, 1, 1); - - label = new Gtk.Label({ - label: "Reload gnome shell after updating prefs (alt+f2 > r)", - halign: Gtk.Align.CENTER, - visible: true, - margin_top: 70 - }); - this.attach(label, 0, 3, 2, 1); - - } - - _onPlacementChange(widget) { - let [success, iter] = widget.get_active_iter(); - if (!success) - return; - - let newPlacement = widget.get_model().get_value(iter, 1); - - if (this._settings.get_int("panel-placement") == newPlacement) - return; - - this._settings.set_int("panel-placement", newPlacement); - } - - _onAppearanceChange(widget) { - let [success, iter] = widget.get_active_iter(); - if (!success) - return; - - let newAppearance = widget.get_model().get_value(iter, 1); - - if (this._settings.get_int("panel-appearance") == newAppearance) - return; - - this._settings.set_int("panel-appearance", newAppearance); - } - - _onHotkeyChange(widget, bananas) { - let hotkey = widget.get_text(); - let [key, mods] = [null, null]; - - if (Gtk.MAJOR_VERSION >= 4) { - let _r = null; - [_r, key, mods] = Gtk.accelerator_parse(hotkey); - } else { - [key, mods] = Gtk.accelerator_parse(hotkey); - } - - if (key != 0) { - let parsedName = Gtk.accelerator_name(key, mods); - this._settings.set_strv("show-hamster-dropdown", [parsedName]); - } - - } -}); - -function init() { + this.show_apply_button = true, + this.current = settings.get_strv(bind); + console.log("HotkeyRow current: ", bind, this.current); + this.set_text(this.current.join(",")); + } } -function buildPrefsWidget() { - return new HamsterSettingsWidget(); +class HamsterPrefsWidget extends Adw.PreferencesPage { + + static { + GObject.registerClass(this); + } + + constructor(settings) { + super(); + this._settings = settings; + + this._actionGroup = new Gio.SimpleActionGroup(); + this.insert_action_group('hamster', this._actionGroup); + this._actionGroup.add_action( + this._settings.create_action('panel-placement')); + this._actionGroup.add_action( + this._settings.create_action('panel-appearance')); + + const placementGroup = new Adw.PreferencesGroup({ + title: _('Panel Placement'), + }); + this.add(placementGroup); + + const placements = [ + { p: 0, title: _("Default") }, + { p: 1, title: _("Replace calendar") }, + { p: 2, title: _("Replace activities") }, + { p: 3, title: _("Center, next to calendar") }, + ]; + + for (const {p, title} of placements) { + const btn = new Gtk.CheckButton({ + action_name: 'hamster.panel-placement', + action_target: new GLib.Variant('i', p), + }); + const row = new Adw.ActionRow({ + activatable_widget: btn, + title, + }); + row.add_prefix(btn); + placementGroup.add(row); + } + + const appearanceGroup = new Adw.PreferencesGroup({ + title: _('Panel Appearance'), + }); + this.add(appearanceGroup); + + const appearances = [ + { a: 0, title: _("Label") }, + { a: 1, title: _("Icon") }, + { a: 2, title: _("Label and icon") }, + ]; + + for (const {a, title} of appearances) { + const btn = new Gtk.CheckButton({ + action_name: 'hamster.panel-appearance', + action_target: new GLib.Variant('i', a), + }); + const row = new Adw.ActionRow({ + activatable_widget: btn, + title, + }); + row.add_prefix(btn); + appearanceGroup.add(row); + } + + const miscGroup = new Adw.PreferencesGroup(); + this.add(miscGroup); + + let row = new HotkeyRow({ + title: _("Global hotkey"), + settings: this._settings, + bind: "show-hamster-dropdown", + }); + + miscGroup.add(row); + } +} + +export default class HamsterPrefs extends ExtensionPreferences { + getPreferencesWidget() { + return new HamsterPrefsWidget(this.getSettings()); + } } -- 2.42.0 ++++++ 0171-metadata.json.in-GNOME-45-support.patch ++++++ From 289d6b16a436fd51c807cea7ba3f05863dae039a Mon Sep 17 00:00:00 2001 From: Martin Wilck <mwilck@suse.com> Date: Fri, 22 Sep 2023 23:16:04 +0200 Subject: [PATCH 171/173] metadata.json.in: GNOME 45 support This implies that support for all previous GNOME versions is dropped. (https://gjs.guide/extensions/upgrading/gnome-shell-45.html#shell-version) Signed-off-by: Martin Wilck <mwilck@suse.com> --- data/metadata.json.in | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/data/metadata.json.in b/data/metadata.json.in index 162a7cf..ddbd0a5 100644 --- a/data/metadata.json.in +++ b/data/metadata.json.in @@ -10,14 +10,7 @@ "gettext-domain": "hamster-shell-extension", "settings-schema": "org.gnome.shell.extensions.project-hamster", "shell-version": [ - "3.34", - "3.36", - "3.38", - "40", - "41", - "42", - "43", - "44" + "45" ], "url": "https://github.com/projecthamster/hamster-shell-extension.git", "uuid": @UUID@ -- 2.42.0 ++++++ 0172-README.rst-fixup-GNOME-shell-compatiblility.patch ++++++ From 36efbfe623faf94da1ea86686864f95e62c81192 Mon Sep 17 00:00:00 2001 From: Martin Wilck <mwilck@suse.com> Date: Mon, 25 Sep 2023 18:46:45 +0200 Subject: [PATCH 172/173] README.rst: fixup GNOME shell compatiblility Signed-off-by: Martin Wilck <mwilck@suse.com> --- README.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.rst b/README.rst index 41a4a52..5263bf7 100644 --- a/README.rst +++ b/README.rst @@ -34,8 +34,8 @@ Install For Production Please follow the instructions under `Manual Installation For Testing and Development`_ below to install from git. -The code in this branch (``develop``) is compatible with GNOME shell 3.34 -up to GNOME shell 44. See also `metadata.json.in`_. +The code in this branch is compatible with *GNOME shell 45 and newer* only. +See also `metadata.json.in`_. *Important:* The "Hamster Time Tracker" extension on `extensions.gnome.org https://extensions.gnome.org/extension/425/project-hamster-extension/`_ -- 2.42.0 ++++++ 0173-Replace-global.log-by-console.log.patch ++++++ From bdda7f12190654c0cc9663912473476eafcf64ef Mon Sep 17 00:00:00 2001 From: Martin Wilck <mwilck@suse.com> Date: Wed, 27 Sep 2023 10:58:14 +0200 Subject: [PATCH 173/173] Replace "global.log" by "console.log" "global" isn't generally available any more. Signed-off-by: Martin Wilck <mwilck@suse.com> --- extension/extension.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/extension/extension.js b/extension/extension.js index 7873763..05e75cb 100644 --- a/extension/extension.js +++ b/extension/extension.js @@ -187,7 +187,7 @@ export default class Controller extends Extension { this.shouldEnable = false; Main.wm.removeKeybinding("show-hamster-dropdown"); - global.log('Shutting down hamster-shell-extension.'); + console.log('Shutting down hamster-shell-extension.'); this._removeWidget(this.placement); Main.panel.menuManager.removeMenu(this.panelWidget.menu); this.panelWidget.destroy(); @@ -209,7 +209,6 @@ export default class Controller extends Extension { this.reportIfError(_("Failed to get activities"), err); this.runningActivitiesQuery = false; this.activities = response; - // global.log('ACTIVITIES HAMSTER: ', this.activities); }.bind(this)); } @@ -220,7 +219,7 @@ export default class Controller extends Extension { reportIfError(msg, error) { if (error) { // Use toString, error can be a string, exception, etc. - global.log("error: Hamster: " + msg + ": " + error.toString()); + console.log("error: Hamster: " + msg + ": " + error.toString()); // Prefix msg to details (second argument), since the // details are word-wrapped and the title is not. Main.notify("Hamster: " + msg, msg + "\n" + error.toString()); -- 2.42.0
participants (1)
-
Source-Sync