diff --git a/extension.js b/extension.js index 004d36a..0167aff 100644 --- a/extension.js +++ b/extension.js @@ -20,12 +20,10 @@ const { Clutter, Gio, GLib, GObject, Meta, Shell, St } = imports.gi; const ExtensionUtils = imports.misc.extensionUtils; const Me = ExtensionUtils.getCurrentExtension(); -const Prefs = Me.imports.prefs; const Main = imports.ui.main; const MessageTray = imports.ui.messageTray.MessageTray; - +const Utils = Me.imports.utils; const BannerBin = Main.messageTray._bannerBin; - const { NOTIFICATION_TIMEOUT, HIDE_TIMEOUT, LONGER_HIDE_TIMEOUT, IDLE_TIME, State, Urgency } = imports.ui.messageTray; let ANIMATION_TIME = 200; @@ -148,16 +146,16 @@ class Extension { } _loadSettings() { - this._settings = Prefs.SettingsSchema; + this._settings = ExtensionUtils.getSettings(); this._settingsChangedId = this._settings.connect('changed', this._onSettingsChange.bind(this)); this._fetchSettings(); } _fetchSettings() { - ANCHOR_VERTICAL = this._settings.get_int(Prefs.Fields.ANCHOR_VERTICAL); - ANCHOR_HORIZONTAL = this._settings.get_int(Prefs.Fields.ANCHOR_HORIZONTAL); - ANIMATION_DIRECTION = this._settings.get_int(Prefs.Fields.ANIMATION_DIRECTION); - ANIMATION_TIME = this._settings.get_int(Prefs.Fields.ANIMATION_TIME); + ANCHOR_VERTICAL = this._settings.get_int(Utils.PrefFields.ANCHOR_VERTICAL); + ANCHOR_HORIZONTAL = this._settings.get_int(Utils.PrefFields.ANCHOR_HORIZONTAL); + ANIMATION_DIRECTION = this._settings.get_int(Utils.PrefFields.ANIMATION_DIRECTION); + ANIMATION_TIME = this._settings.get_int(Utils.PrefFields.ANIMATION_TIME); } _onSettingsChange() { @@ -180,7 +178,6 @@ class Extension { for (const { obj, method, original, patch } of patches) { patcher(obj, method, original, patch) } - } disable() { diff --git a/metadata.json b/metadata.json index fb70b5c..cfca28e 100644 --- a/metadata.json +++ b/metadata.json @@ -1,11 +1,12 @@ { "name": "Notification Banner Reloaded", - "version": 3, + "version": 4, "description": "Configure notification banner position and animation to your liking", "uuid": "notification-banner-reloaded@marcinjakubowski.github.com", "shell-version": [ "41", "40" ], - "url": "https://github.com/marcinjakubowski/notification-position-reloaded" + "url": "https://github.com/marcinjakubowski/notification-position-reloaded", + "settings-schema": "org.gnome.shell.extensions.notification-banner-reloaded" } diff --git a/prefs.js b/prefs.js index 3cba37f..bf0df77 100644 --- a/prefs.js +++ b/prefs.js @@ -26,20 +26,11 @@ const Gtk = imports.gi.Gtk; const Gio = imports.gi.Gio; const ExtensionUtils = imports.misc.extensionUtils; const Me = ExtensionUtils.getCurrentExtension(); +const Utils = Me.imports.utils; const Gettext = imports.gettext; const _ = Gettext.domain('notification-banner-reloaded').gettext; -var Fields = { - ANCHOR_VERTICAL : 'anchor-vertical', - ANCHOR_HORIZONTAL : 'anchor-horizontal', - ANIMATION_TIME : 'animation-time', - ANIMATION_DIRECTION : 'animation-direction', -}; - -const SCHEMA_NAME = 'org.gnome.shell.extensions.notification-banner-reloaded'; - -var SettingsSchema = ExtensionUtils.getSettings(SCHEMA_NAME); function init() { let localeDir = Me.dir.get_child('locale'); @@ -130,11 +121,12 @@ class Preferences { addRow(anchorVerticalLabel, this.anchorVertical); addRow(animationDirectionLabel, this.animationDirection); addRow(animationTimeLabel, this.animationTime); - - SettingsSchema.bind(Fields.ANCHOR_HORIZONTAL, this.anchorHorizontal, 'active', Gio.SettingsBindFlags.DEFAULT); - SettingsSchema.bind(Fields.ANCHOR_VERTICAL, this.anchorVertical, 'active', Gio.SettingsBindFlags.DEFAULT); - SettingsSchema.bind(Fields.ANIMATION_DIRECTION, this.animationDirection, 'active', Gio.SettingsBindFlags.DEFAULT); - SettingsSchema.bind(Fields.ANIMATION_TIME, this.animationTime, 'value', Gio.SettingsBindFlags.DEFAULT); + + const settings = ExtensionUtils.getSettings(); + 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.ANIMATION_DIRECTION, this.animationDirection, 'active', Gio.SettingsBindFlags.DEFAULT); + settings.bind(Utils.PrefFields.ANIMATION_TIME, this.animationTime, 'value', Gio.SettingsBindFlags.DEFAULT); } _create_options(opts) { diff --git a/utils.js b/utils.js new file mode 100644 index 0000000..55d3755 --- /dev/null +++ b/utils.js @@ -0,0 +1,6 @@ +var PrefFields = { + ANCHOR_VERTICAL : 'anchor-vertical', + ANCHOR_HORIZONTAL : 'anchor-horizontal', + ANIMATION_TIME : 'animation-time', + ANIMATION_DIRECTION : 'animation-direction', +}; \ No newline at end of file