Skip to content

Commit

Permalink
Added links section to UI
Browse files Browse the repository at this point in the history
  • Loading branch information
stuarthayhurst committed Aug 20, 2023
1 parent dbd00d5 commit 81107b7
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions extension/prefs.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down Expand Up @@ -67,6 +68,37 @@ 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((linkInfo) => {
//Create a widget for the link
/*let linkButton = new Gtk.LinkButton({
uri: linkInfo[1],
visible: false
});*/

//Create a row for the link widget
let linkEntryRow = new Adw.ActionRow({
title: linkInfo[0],
activatable: true/*,
activatable_widget: linkButton,
child: linkButton*/
});

linkEntryRow.connect('activated', () => {
let uriLauncher = new Gtk.UriLauncher();
uriLauncher.set_uri(linkInfo[1]);
uriLauncher.launch(this, null, null);
});

linksGroup.add(linkEntryRow);
});
}

_updateEnabledSettings() {
/*
- If quick settings are enabled, disable 'move-icon-setting' option
Expand Down Expand Up @@ -117,6 +149,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);
Expand Down

0 comments on commit 81107b7

Please sign in to comment.