From dcbe57bbc8a2498f8b4534ec330624c92ad4d63e Mon Sep 17 00:00:00 2001 From: Stuart Hayhurst Date: Sun, 20 Aug 2023 18:08:31 +0100 Subject: [PATCH] Added links section to UI --- extension/prefs.js | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/extension/prefs.js b/extension/prefs.js index 77cc878..d2fdaca 100644 --- a/extension/prefs.js +++ b/extension/prefs.js @@ -2,6 +2,7 @@ //Main imports import Gio from 'gi://Gio'; +import Gtk from 'gi://Gtk'; import Adw from 'gi://Adw'; import GObject from 'gi://GObject'; @@ -67,6 +68,26 @@ class PrefsPage extends Adw.PreferencesPage { }); } + addLinks(groupName, linksInfo) { + //Setup and add links group to window + let linksGroup = new Adw.PreferencesGroup(); + linksGroup.set_title(groupName); + this.add(linksGroup); + + linksInfo.forEach(() => { + let linkButton = new Gtk.LinkButton({ + uri: linksInfo[1] + }); + + let linkEntryRow = new Adw.ActionRow({ + title: linksInfo[0], + activatable_widget: linkButton + }); + + linksGroup.add(linkEntryRow); + }); + } + _updateEnabledSettings() { /* - If quick settings are enabled, disable 'move-icon-setting' option @@ -117,6 +138,15 @@ export default class PrivacyPreferences extends ExtensionPreferences { //Create settings page from info let settingsPage = new PrefsPage(pageInfo, groupsInfo, settingsInfo, this.getSettings()); + //Define and add links + let linksInfo = [ + //Translated title, link + [_("Report an issue"), "https://github.com/stuarthayhurst/privacy-menu-extension/issues"], + [_("Donate via GitHub"), "https://github.com/sponsors/stuarthayhurst"], + [_("Donate via PayPal"), "https://www.paypal.me/stuartahayhurst"] + ]; + settingsPage.addLinks(_("Links"), linksInfo); + //Add the pages to the window, enable searching window.add(settingsPage); window.set_search_enabled(true);