Skip to content

Commit

Permalink
Port preferences to GNOME 45
Browse files Browse the repository at this point in the history
  • Loading branch information
stuarthayhurst committed Aug 13, 2023
1 parent dc2f55b commit 403bf7d
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 34 deletions.
2 changes: 1 addition & 1 deletion extension/extension.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import * as PopupMenu from 'resource:///org/gnome/shell/ui/popupMenu.js';
import * as QuickSettings from 'resource:///org/gnome/shell/ui/quickSettings.js';
const QuickSettingsMenu = Main.panel.statusArea.quickSettings;

//Use _() for translations
//Extension system imports
import {Extension, gettext as _} from 'resource:///org/gnome/shell/extensions/extension.js';

//Custom PopupMenuItem with an icon, label and switch
Expand Down
61 changes: 28 additions & 33 deletions extension/prefs.js
Original file line number Diff line number Diff line change
@@ -1,23 +1,20 @@
/* exported init fillPreferencesWindow buildPrefsWidget */

//Local extension imports
const ExtensionUtils = imports.misc.extensionUtils;
const Me = ExtensionUtils.getCurrentExtension();
const ShellVersion = parseFloat(imports.misc.config.PACKAGE_VERSION);
/* exported PrivacyPreferences */

//Main imports
const { Gtk, Gio } = imports.gi;
const Adw = imports.gi.Adw;
import Gtk from 'gi://Gtk';
import Gio from 'gi://Gio';
import Adw from 'gi://Adw';

//Use _() for translations
const _ = imports.gettext.domain(Me.metadata.uuid).gettext;
//Extension system imports
import {ExtensionPreferences, gettext as _} from 'resource:///org/gnome/Shell/Extensions/js/extensions/prefs.js';

var PrefsPages = class PrefsPages {
constructor() {
this._settings = ExtensionUtils.getSettings('org.gnome.shell.extensions.privacy-menu');
constructor(path, uuid, settings) {
this._settings = settings;
this._path = path;

this._builder = new Gtk.Builder();
this._builder.set_translation_domain(Me.metadata.uuid);
this._builder.set_translation_domain(uuid);

this.preferencesWidget = null;
this._createPreferences();
Expand Down Expand Up @@ -50,7 +47,7 @@ var PrefsPages = class PrefsPages {
}

_createPreferences() {
this._builder.add_from_file(Me.path + '/gtk4/prefs.ui');
this._builder.add_from_file(this._.path + '/gtk4/prefs.ui');

//Get the settings container widget
this.preferencesWidget = this._builder.get_object('main-prefs');
Expand Down Expand Up @@ -92,23 +89,21 @@ var PrefsPages = class PrefsPages {
}
}

function init() {
ExtensionUtils.initTranslations();
}

//Create preferences window with libadwaita
function fillPreferencesWindow(window) {
//Create pages and widgets
let prefsPages = new PrefsPages();
let settingsPage = new Adw.PreferencesPage();
let settingsGroup = new Adw.PreferencesGroup();

//Build the settings page
settingsPage.set_title(_('Settings'));
settingsPage.set_icon_name('preferences-system-symbolic');
settingsGroup.add(prefsPages.preferencesWidget);
settingsPage.add(settingsGroup);

//Add the pages to the window
window.add(settingsPage);
export default class PrivacyPreferences extends ExtensionPreferences {
//Create preferences window with libadwaita
fillPreferencesWindow(window) {
//Create pages and widgets
let prefsPages = new PrefsPages(this.path, this.uuid, this.getSettings());
let settingsPage = new Adw.PreferencesPage();
let settingsGroup = new Adw.PreferencesGroup();

//Build the settings page
settingsPage.set_title(_('Settings'));
settingsPage.set_icon_name('preferences-system-symbolic');
settingsGroup.add(prefsPages.preferencesWidget);
settingsPage.add(settingsGroup);

//Add the pages to the window
window.add(settingsPage);
}
}

0 comments on commit 403bf7d

Please sign in to comment.