From 55ccb19a8d489db98ce4a42a125221a8020cdeae Mon Sep 17 00:00:00 2001 From: Charles Gagnon Date: Wed, 19 Feb 2025 16:09:29 -0500 Subject: [PATCH] Add extension update notification --- Makefile | 2 +- po/fr.po | 24 ++- ...shell.extensions.dash-to-panel.gschema.xml | 4 + src/appIcons.js | 2 +- src/extension.js | 34 +++- src/prefs.js | 31 ++-- src/utils.js | 24 +-- ui/SettingsAbout.ui | 173 ++++++++---------- 8 files changed, 165 insertions(+), 129 deletions(-) diff --git a/Makefile b/Makefile index ec51474..65a1929 100644 --- a/Makefile +++ b/Makefile @@ -5,7 +5,7 @@ MODULES = src/*.js src/stylesheet.css metadata.json COPYING README.md UI_MODULES = ui/*.ui IMAGES = ./* ../media/design/svg/dash-to-panel-logo-light.svg -TOLOCALIZE = src/prefs.js src/appIcons.js src/taskbar.js +TOLOCALIZE = src/extension.js src/prefs.js src/appIcons.js src/taskbar.js MSGSRC = $(wildcard po/*.po) ifeq ($(strip $(DESTDIR)),) INSTALLBASE = $(HOME)/.local/share/gnome-shell/extensions diff --git a/po/fr.po b/po/fr.po index a059d31..f6a3c9d 100644 --- a/po/fr.po +++ b/po/fr.po @@ -9,8 +9,8 @@ msgid "" msgstr "" "Project-Id-Version: Dash To Panel\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2025-02-19 08:28-0500\n" -"PO-Revision-Date: 2025-02-19 09:46-0500\n" +"POT-Creation-Date: 2025-02-19 16:00-0500\n" +"PO-Revision-Date: 2025-02-19 16:04-0500\n" "Last-Translator: Charles Gagnon \n" "Language-Team: French\n" "Language: fr\n" @@ -39,6 +39,14 @@ msgstr "" "X-Poedit-SearchPath-16: desktopIconsIntegration.js\n" "X-Poedit-SearchPath-17: appIcons.js\n" +#: src/extension.js:87 +msgid "Dash to panel has been updated!" +msgstr "Dash to panel a été mis à jour!" + +#: src/extension.js:91 +msgid "See what's new" +msgstr "Voir les nouveautés" + #: src/prefs.js:275 msgid "Show Desktop button height (px)" msgstr "Hauteur du bouton Afficher le Bureau (px)" @@ -268,11 +276,11 @@ msgstr "Options d'animation des icônes d'application" msgid "App icon highlight options" msgstr "Options d'animation du surlignement des icônes d'application" -#: src/prefs.js:3505 +#: src/prefs.js:3508 msgid "Export settings" msgstr "Exporter les paramètres" -#: src/prefs.js:3526 +#: src/prefs.js:3529 msgid "Import settings" msgstr "Importer des paramètres" @@ -1081,10 +1089,6 @@ msgid "Export and Import" msgstr "Import et export" #: ui/SettingsAbout.ui.h:7 -msgid "Export and import settings" -msgstr "Import et export de paramètres" - -#: ui/SettingsAbout.ui.h:8 msgid "" "Use the buttons below to create a settings file from your current " "preferences that can be imported on a different machine." @@ -1092,6 +1096,10 @@ msgstr "" "Utiliser les boutons ci-dessous pour créer un fichier de paramètres à partir " "de vos préférences actuelles qui pourra être importé sur une autre machine." +#: ui/SettingsAbout.ui.h:8 +msgid "Export and import settings" +msgstr "Import et export de paramètres" + #: ui/SettingsAbout.ui.h:9 msgid "Export to file" msgstr "Exporter vers un fichier" diff --git a/schemas/org.gnome.shell.extensions.dash-to-panel.gschema.xml b/schemas/org.gnome.shell.extensions.dash-to-panel.gschema.xml index ebeafaa..db38331 100644 --- a/schemas/org.gnome.shell.extensions.dash-to-panel.gschema.xml +++ b/schemas/org.gnome.shell.extensions.dash-to-panel.gschema.xml @@ -1331,5 +1331,9 @@ '' Unix time when the donate icon was hidden + + 65 + Installed extension version + diff --git a/src/appIcons.js b/src/appIcons.js index 9e9ba0a..9cf0be6 100644 --- a/src/appIcons.js +++ b/src/appIcons.js @@ -1826,7 +1826,7 @@ export function resetRecentlyClickedApp() { recentlyClickedAppIndex = 0 recentlyClickedAppMonitorIndex = null - return false + return GLib.SOURCE_REMOVE } export function closeAllWindows(app, monitor) { diff --git a/src/extension.js b/src/extension.js index 698e9a9..b1e3e71 100644 --- a/src/extension.js +++ b/src/extension.js @@ -18,10 +18,14 @@ */ import Gio from 'gi://Gio' +import GLib from 'gi://GLib' import * as Main from 'resource:///org/gnome/shell/ui/main.js' import { EventEmitter } from 'resource:///org/gnome/shell/misc/signals.js' -import { Extension } from 'resource:///org/gnome/shell/extensions/extension.js' +import { + Extension, + gettext as _, +} from 'resource:///org/gnome/shell/extensions/extension.js' import * as PanelSettings from './panelSettings.js' import * as PanelManager from './panelManager.js' @@ -78,6 +82,24 @@ export default class DashToPanelExtension extends Extension { if (donateIconUnixtime && donateIconUnixtime < Date.now() - 10368000000) SETTINGS.set_string('hide-donate-icon-unixtime', '') + if (this.metadata.version != SETTINGS.get_int('extension-version')) { + Utils.notify( + _('Dash to panel has been updated!'), + _(`You are now running version ${this.metadata.version}.`), + 'software-update-available-symbolic', + { + text: _(`See what's new`), + func: () => + Gio.app_info_launch_default_for_uri( + `${this.metadata.url}/releases/tag/v${this.metadata.version}`, + global.create_app_launch_context(0, -1), + ), + }, + ) + + SETTINGS.set_int('extension-version', this.metadata.version) + } + Main.layoutManager.startInOverview = !SETTINGS.get_boolean( 'hide-overview-on-startup', ) @@ -99,6 +121,8 @@ export default class DashToPanelExtension extends Extension { panelManager = new PanelManager.PanelManager() panelManager.enable() ubuntuDockDelayId = 0 + + return GLib.SOURCE_REMOVE } // disable ubuntu dock if present @@ -110,13 +134,17 @@ export default class DashToPanelExtension extends Extension { global.settings.set_strv('disabled-extensions', disabled) // wait a bit so ubuntu dock can disable itself and restore the showappsbutton - ubuntuDockDelayId = setTimeout(completeEnable, 200) + ubuntuDockDelayId = GLib.timeout_add( + GLib.PRIORITY_DEFAULT, + 200, + completeEnable, + ) } } else completeEnable() } disable() { - if (ubuntuDockDelayId) clearTimeout(ubuntuDockDelayId) + if (ubuntuDockDelayId) GLib.Source.remove(ubuntuDockDelayId) PanelSettings.disable(SETTINGS) panelManager.disable() diff --git a/src/prefs.js b/src/prefs.js index 7bda652..310a0f4 100644 --- a/src/prefs.js +++ b/src/prefs.js @@ -3491,12 +3491,15 @@ const Preferences = class { // About Panel - this._builder - .get_object('extension_version') - .set_label( - this._metadata.version.toString() + - (this._metadata.commit ? ' (' + this._metadata.commit + ')' : ''), - ) + let versionLinkButton = this._builder.get_object('extension_version') + + versionLinkButton.set_label( + this._metadata.version.toString() + + (this._metadata.commit ? ' (' + this._metadata.commit + ')' : ''), + ) + versionLinkButton.set_uri( + `${this._metadata.url}/${this._metadata.commit ? `commit/${this._metadata.commit}` : `releases/tag/v${this._metadata.version}`}`, + ) this._builder .get_object('importexport_export_button') @@ -3587,16 +3590,22 @@ const Preferences = class { ) this.notebook.connect('notify::visible-page', () => { - clearTimeout(revealDonateTimeout) + if (revealDonateTimeout) GLib.Source.remove(revealDonateTimeout) if ( this.notebook.visible_page_name == 'donation' && !donationRevealer.get_reveal_child() ) - revealDonateTimeout = setTimeout(() => { - donationRevealer.set_reveal_child(true) - donationSpinner.set_spinning(false) - }, 15000) + revealDonateTimeout = GLib.timeout_add( + GLib.PRIORITY_DEFAULT, + 15000, + () => { + donationRevealer.set_reveal_child(true) + donationSpinner.set_spinning(false) + + return GLib.SOURCE_REMOVE + }, + ) }) } diff --git a/src/utils.js b/src/utils.js index 7534d37..90c1dbc 100644 --- a/src/utils.js +++ b/src/utils.js @@ -528,16 +528,18 @@ export const getPoint = function (coords) { return new Graphene.Point(coords) } -export const notify = function (text, iconName, action, isTransient) { - let source = new MessageTray.SystemNotificationSource() - let notification = new MessageTray.Notification(source, 'Dash to Panel', text) - let notifyFunc = source.showNotification || source.notify +export const notify = function (title, body, iconName, action, isTransient) { + let source = new MessageTray.Source({ + title: 'Dash to Panel', + }) + let notification = new MessageTray.Notification({ + source, + title, + body, + isTransient: isTransient || false, + }) - if (iconName) { - source.createIcon = function () { - return new St.Icon({ icon_name: iconName }) - } - } + if (iconName) source.iconName = iconName if (action) { if (!(action instanceof Array)) { @@ -548,9 +550,7 @@ export const notify = function (text, iconName, action, isTransient) { } Main.messageTray.add(source) - - notification.setTransient(isTransient) - notifyFunc.call(source, notification) + source.addNotification(notification) } /* diff --git a/ui/SettingsAbout.ui b/ui/SettingsAbout.ui index 4ab0476..9c03b25 100644 --- a/ui/SettingsAbout.ui +++ b/ui/SettingsAbout.ui @@ -1,99 +1,86 @@ - + + - + + help-about-symbolic About - help-about-symbolic - - - - - Info - - - - Version - - - ... - - - - - - - - Source - - - GitHub - True - center - https://github.com/home-sweet-gnome/dash-to-panel - - - - - - - - - - - - Export and Import - - - - Export and import settings - Use the buttons below to create a settings file from your current preferences that can be imported on a different machine. - - - - - - - - 8 - 8 - 4 - 4 - 8 - end - - - Export to file - True - - - - - Import from file - True - - - - - - - - - - - - - - - - <span size="small">This program comes with ABSOLUTELY NO WARRANTY. See the <a href="https://www.gnu.org/licenses/old-licenses/gpl-2.0.html">GNU General Public License, version 2 or later</a> for details.</span> - True - center - True - - - - - + + + Info + + + Version + + + + + + + + Source + + + center + GitHub + True + https://github.com/home-sweet-gnome/dash-to-panel + + + + + + + + + Export and Import + + + Use the buttons below to create a settings file from your current preferences that can be imported on a different machine. + Export and import settings + + + + + + + end + 4 + 8 + 8 + 4 + 8 + + + Export to file + True + + + + + Import from file + True + + + + + + + + + + + + + center + <span size="small">This program comes with ABSOLUTELY NO WARRANTY. +See the <a href="https://www.gnu.org/licenses/old-licenses/gpl-2.0.html">GNU General Public License, version 2 or later</a> for details.</span> + True + True + + + +