Add extension update notification

This commit is contained in:
Charles Gagnon
2025-02-19 16:09:29 -05:00
parent 8378946aad
commit 55ccb19a8d
8 changed files with 165 additions and 129 deletions

View File

@@ -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

View File

@@ -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 <charlesg99@outlook.com>\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"

View File

@@ -1331,5 +1331,9 @@
<default>''</default>
<summary>Unix time when the donate icon was hidden</summary>
</key>
<key type="i" name="extension-version">
<default>65</default>
<summary>Installed extension version</summary>
</key>
</schema>
</schemalist>

View File

@@ -1826,7 +1826,7 @@ export function resetRecentlyClickedApp() {
recentlyClickedAppIndex = 0
recentlyClickedAppMonitorIndex = null
return false
return GLib.SOURCE_REMOVE
}
export function closeAllWindows(app, monitor) {

View File

@@ -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()

View File

@@ -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
},
)
})
}

View File

@@ -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)
}
/*

View File

@@ -1,99 +1,86 @@
<?xml version="1.0" encoding="UTF-8"?>
<?xml version='1.0' encoding='UTF-8'?>
<interface>
<!-- interface-name SettingsAbout.ui -->
<requires lib="gtk" version="4.0"/>
<requires lib="libadwaita" version="1.6"/>
<object class="AdwPreferencesPage" id="about">
<property name="icon-name">help-about-symbolic</property>
<property name="title" translatable="yes">About</property>
<property name="icon_name">help-about-symbolic</property>
<!-- group info -->
<child>
<object class="AdwPreferencesGroup" id="about_group_info">
<property name="title" translatable="yes">Info</property>
<child>
<object class="AdwActionRow">
<property name="title" translatable="yes">Version</property>
<child>
<object class="GtkLabel" id="extension_version">
<property name="label">...</property>
</object>
</child>
</object>
</child>
<child>
<object class="AdwActionRow">
<property name="title" translatable="yes">Source</property>
<child>
<object class="GtkLinkButton" id="homepage_link">
<property name="label" translatable="yes">GitHub</property>
<property name="receives_default">True</property>
<property name="halign">center</property>
<property name="uri">https://github.com/home-sweet-gnome/dash-to-panel</property>
</object>
</child>
</object>
</child>
</object>
</child>
<!-- group export import -->
<child>
<object class="AdwPreferencesGroup" id="about_group_export_and_import">
<property name="title" translatable="yes">Export and Import</property>
<child>
<object class="AdwActionRow">
<property name="title" translatable="yes">Export and import settings</property>
<property name="subtitle" translatable="yes">Use the buttons below to create a settings file from your current preferences that can be imported on a different machine.</property>
</object>
</child>
<child>
<object class="AdwPreferencesRow">
<child>
<object class="GtkBox">
<property name="margin_start">8</property>
<property name="margin_end">8</property>
<property name="margin_top">4</property>
<property name="margin_bottom">4</property>
<property name="spacing">8</property>
<property name="halign">end</property>
<child>
<object class="GtkButton" id="importexport_export_button">
<property name="label" translatable="yes">Export to file</property>
<property name="receives_default">True</property>
</object>
</child>
<child>
<object class="GtkButton" id="importexport_import_button">
<property name="label" translatable="yes">Import from file</property>
<property name="receives_default">True</property>
</object>
</child>
</object>
</child>
</object>
</child>
</object>
</child>
<!-- group disclaimer -->
<child>
<object class="AdwPreferencesGroup" id="about_group_disclaimer">
<child>
<object class="GtkLabel" id="label1">
<property name="label" translatable="yes">&lt;span size="small"&gt;This program comes with ABSOLUTELY NO WARRANTY.&#10;See the &lt;a href="https://www.gnu.org/licenses/old-licenses/gpl-2.0.html"&gt;GNU General Public License, version 2 or later&lt;/a&gt; for details.&lt;/span&gt;</property>
<property name="use_markup">True</property>
<property name="justify">center</property>
<property name="wrap">True</property>
</object>
</child>
</object>
</child>
<child>
<object class="AdwPreferencesGroup" id="about_group_info">
<property name="title" translatable="yes">Info</property>
<child>
<object class="AdwActionRow">
<property name="title" translatable="yes">Version</property>
<child>
<object class="GtkLinkButton" id="extension_version"/>
</child>
</object>
</child>
<child>
<object class="AdwActionRow">
<property name="title" translatable="yes">Source</property>
<child>
<object class="GtkLinkButton" id="homepage_link">
<property name="halign">center</property>
<property name="label" translatable="yes">GitHub</property>
<property name="receives-default">True</property>
<property name="uri">https://github.com/home-sweet-gnome/dash-to-panel</property>
</object>
</child>
</object>
</child>
</object>
</child>
<child>
<object class="AdwPreferencesGroup" id="about_group_export_and_import">
<property name="title" translatable="yes">Export and Import</property>
<child>
<object class="AdwActionRow">
<property name="subtitle" translatable="yes">Use the buttons below to create a settings file from your current preferences that can be imported on a different machine.</property>
<property name="title" translatable="yes">Export and import settings</property>
</object>
</child>
<child>
<object class="AdwPreferencesRow">
<child>
<object class="GtkBox">
<property name="halign">end</property>
<property name="margin-bottom">4</property>
<property name="margin-end">8</property>
<property name="margin-start">8</property>
<property name="margin-top">4</property>
<property name="spacing">8</property>
<child>
<object class="GtkButton" id="importexport_export_button">
<property name="label" translatable="yes">Export to file</property>
<property name="receives-default">True</property>
</object>
</child>
<child>
<object class="GtkButton" id="importexport_import_button">
<property name="label" translatable="yes">Import from file</property>
<property name="receives-default">True</property>
</object>
</child>
</object>
</child>
</object>
</child>
</object>
</child>
<child>
<object class="AdwPreferencesGroup" id="about_group_disclaimer">
<child>
<object class="GtkLabel" id="label1">
<property name="justify">center</property>
<property name="label" translatable="yes">&lt;span size="small"&gt;This program comes with ABSOLUTELY NO WARRANTY.
See the &lt;a href="https://www.gnu.org/licenses/old-licenses/gpl-2.0.html"&gt;GNU General Public License, version 2 or later&lt;/a&gt; for details.&lt;/span&gt;</property>
<property name="use-markup">True</property>
<property name="wrap">True</property>
</object>
</child>
</object>
</child>
</object>
</interface>