Change imports to support gnome45 in prefs.js

This commit is contained in:
mannjani
2023-11-12 14:33:54 +01:00
committed by Marcin Jakubowski
parent 0cc14fd043
commit ec95cfc8ad
+9 -11
View File
@@ -21,15 +21,13 @@
https://github.com/Tudmotu/gnome-shell-extension-clipboard-indicator https://github.com/Tudmotu/gnome-shell-extension-clipboard-indicator
https://extensions.gnome.org/extension/779/clipboard-indicator/ https://extensions.gnome.org/extension/779/clipboard-indicator/
*/ */
const GObject = imports.gi.GObject; import GObject from 'gi://GObject';
const Gtk = imports.gi.Gtk; import Gtk from 'gi://Gtk';
const Gio = imports.gi.Gio; import Gio from 'gi://Gio';
const ExtensionUtils = imports.misc.extensionUtils; import * as Utils from './utils.js';
const Me = ExtensionUtils.getCurrentExtension();
const Utils = Me.imports.utils; import {ExtensionPreferences, gettext as _} from 'resource:///org/gnome/Shell/Extensions/js/extensions/prefs.js';
const Gettext = imports.gettext;
const _ = Gettext.domain('notification-banner-reloaded').gettext;
// API change 3 -> 4 // API change 3 -> 4
function addBox(box, child) { function addBox(box, child) {
@@ -42,12 +40,12 @@ function addBox(box, child) {
} }
function init() { function init() {
let localeDir = Me.dir.get_child('locale'); let localeDir = './locale';
if (localeDir.query_exists(null)) if (localeDir.query_exists(null))
Gettext.bindtextdomain('notification-banner-reloaded', localeDir.get_path()); Gettext.bindtextdomain('notification-banner-reloaded', localeDir.get_path());
} }
class Preferences { export default class NotificationExtensionPreferences extends ExtensionPreferences {
constructor() { constructor() {
this.main = new Gtk.Grid({ this.main = new Gtk.Grid({
margin_top: 10, margin_top: 10,
@@ -166,7 +164,7 @@ class Preferences {
addRow(animationTimeLabel, this.animationTime); addRow(animationTimeLabel, this.animationTime);
addRow(alwaysMinimizeLabel, this.alwaysMinimize); addRow(alwaysMinimizeLabel, this.alwaysMinimize);
const settings = ExtensionUtils.getSettings(); const settings = this.getSettings();
settings.bind(Utils.PrefFields.ANCHOR_HORIZONTAL, this.anchorHorizontal, 'active', Gio.SettingsBindFlags.DEFAULT); settings.bind(Utils.PrefFields.ANCHOR_HORIZONTAL, this.anchorHorizontal, 'active', Gio.SettingsBindFlags.DEFAULT);
settings.bind(Utils.PrefFields.ANCHOR_VERTICAL, this.anchorVertical, 'active', Gio.SettingsBindFlags.DEFAULT); settings.bind(Utils.PrefFields.ANCHOR_VERTICAL, this.anchorVertical, 'active', Gio.SettingsBindFlags.DEFAULT);
settings.bind(Utils.PrefFields.PADDING_HORIZONTAL, this.paddingHorizontal, 'value', Gio.SettingsBindFlags.DEFAULT); settings.bind(Utils.PrefFields.PADDING_HORIZONTAL, this.paddingHorizontal, 'value', Gio.SettingsBindFlags.DEFAULT);