diff --git a/extension.js b/extension.js index 0bed3e4..5ce2cbf 100644 --- a/extension.js +++ b/extension.js @@ -24,13 +24,18 @@ import Meta from 'gi://Meta'; import Shell from 'gi://Shell'; import St from 'gi://St'; -import {Extension} from 'resource:///org/gnome/shell/extensions/extension.js'; +import { Extension } from 'resource:///org/gnome/shell/extensions/extension.js'; import * as Main from 'resource:///org/gnome/shell/ui/main.js'; -import MessageTray from 'resource:///org/gnome/shell/ui/messageTray.js'; +import { MessageTray } from 'resource:///org/gnome/shell/ui/messageTray.js'; import * as Utils from './utils.js'; const BannerBin = Main.messageTray._bannerBin; -import {NOTIFICATION_TIMEOUT, HIDE_TIMEOUT, LONGER_HIDE_TIMEOUT, IDLE_TIME, State, Urgency } from 'resource:///org/gnome/shell/ui/messageTray.js'; +import { State, Urgency } from 'resource:///org/gnome/shell/ui/messageTray.js'; + +const NOTIFICATION_TIMEOUT = 4000; +const HIDE_TIMEOUT = 200; +const LONGER_HIDE_TIMEOUT = 600; +const IDLE_TIME = 1000; let ANIMATION_TIME = 200; let ANIMATION_DIRECTION = 2; @@ -47,7 +52,11 @@ function patcher(obj, live, method, original, patch) { eval(`${live}.${method} = ${newBody}`); } -const getMessageTraySize = () => ({ width, height } = Main.layoutManager.getWorkAreaForMonitor(global.display.get_primary_monitor())); +const getMessageTraySize = () => { + var width, height; + var { width, height } = Main.layoutManager.getWorkAreaForMonitor(global.display.get_primary_monitor()); + return {width, height}; +} const originalShow = MessageTray.prototype._showNotification; const originalHide = MessageTray.prototype._hideNotification; @@ -160,7 +169,8 @@ const always_minimize_patch = { }; export default class NotificationExtension extends Extension { - constructor() { + constructor(metadata) { + super(metadata); this._previous_y_align = BannerBin.get_y_align(); this._previous_x_align = BannerBin.get_x_align(); } diff --git a/metadata.json b/metadata.json index 7df3e57..65be373 100644 --- a/metadata.json +++ b/metadata.json @@ -5,7 +5,7 @@ "description": "Configure notification banner position and animation to your liking", "uuid": "notification-banner-reloaded@marcinjakubowski.github.com", "shell-version": [ - "45", + "45" ], "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 d991a45..3ae9a15 100644 --- a/prefs.js +++ b/prefs.js @@ -46,7 +46,23 @@ function init() { } export default class NotificationExtensionPreferences extends ExtensionPreferences { - constructor() { + constructor(metadata) { + super(metadata); + } + + getPreferencesWidget() { + let frame = new Gtk.Box(); + let widget = new Preferences(this.getSettings()); + addBox(frame, widget.main); + if (frame.show_all) + frame.show_all(); + return frame; + } +} + +class Preferences{ + constructor(settings) { + this.settings = settings this.main = new Gtk.Grid({ margin_top: 10, margin_bottom: 10, @@ -164,7 +180,6 @@ export default class NotificationExtensionPreferences extends ExtensionPreferenc addRow(animationTimeLabel, this.animationTime); addRow(alwaysMinimizeLabel, this.alwaysMinimize); - const settings = this.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.PADDING_HORIZONTAL, this.paddingHorizontal, 'value', Gio.SettingsBindFlags.DEFAULT); @@ -186,13 +201,3 @@ export default class NotificationExtensionPreferences extends ExtensionPreferenc return liststore; } }; - -function buildPrefsWidget() { - let frame = new Gtk.Box(); - let widget = new Preferences(); - addBox(frame, widget.main); - if (frame.show_all) - frame.show_all(); - return frame; -} - diff --git a/utils.js b/utils.js index f96c1a9..3771286 100644 --- a/utils.js +++ b/utils.js @@ -1,4 +1,4 @@ -var PrefFields = { +export const PrefFields = { ANCHOR_VERTICAL : 'anchor-vertical', ANCHOR_HORIZONTAL : 'anchor-horizontal', PADDING_VERTICAL : 'padding-vertical',