diff --git a/extension.js b/extension.js index 0167aff..d51ce7c 100644 --- a/extension.js +++ b/extension.js @@ -30,6 +30,8 @@ let ANIMATION_TIME = 200; let ANIMATION_DIRECTION = 2; let ANCHOR_VERTICAL = 0; let ANCHOR_HORIZONTAL = 2; +let PADDING_VERTICAL = 0; +let PADDING_HORIZONTAL = 0; function patcher(obj, method, original, patch) { const body = eval(`${obj}.prototype.${method}.toString()`); @@ -47,10 +49,10 @@ function calcTarget(self) { let x = 0, y = 0; switch (ANCHOR_HORIZONTAL) { case 0: // left - x = 0; + x = 0 + PADDING_HORIZONTAL; break; case 1: // right - x = getMessageTraySize().width - self._banner.width; + x = getMessageTraySize().width - self._banner.width - PADDING_HORIZONTAL; break; case 2: // center x = (getMessageTraySize().width - self._banner.width) / 2.0; @@ -58,10 +60,10 @@ function calcTarget(self) { } switch (ANCHOR_VERTICAL) { case 0: // top - y = 0; + y = 0 + PADDING_VERTICAL; break; case 1: // bottom - y = getMessageTraySize().height - self._banner.height; + y = getMessageTraySize().height - self._banner.height - PADDING_VERTICAL; break; case 2: // center y = (getMessageTraySize().height - self._banner.height) / 2.0; @@ -154,6 +156,8 @@ class Extension { _fetchSettings() { ANCHOR_VERTICAL = this._settings.get_int(Utils.PrefFields.ANCHOR_VERTICAL); ANCHOR_HORIZONTAL = this._settings.get_int(Utils.PrefFields.ANCHOR_HORIZONTAL); + PADDING_VERTICAL = this._settings.get_int(Utils.PrefFields.PADDING_VERTICAL); + PADDING_HORIZONTAL = this._settings.get_int(Utils.PrefFields.PADDING_HORIZONTAL); ANIMATION_DIRECTION = this._settings.get_int(Utils.PrefFields.ANIMATION_DIRECTION); ANIMATION_TIME = this._settings.get_int(Utils.PrefFields.ANIMATION_TIME); } diff --git a/metadata.json b/metadata.json index cfca28e..00cbee6 100644 --- a/metadata.json +++ b/metadata.json @@ -1,6 +1,7 @@ { "name": "Notification Banner Reloaded", - "version": 4, + "version": 5, + "_generated": "Generated by SweetTooth, do not edit", "description": "Configure notification banner position and animation to your liking", "uuid": "notification-banner-reloaded@marcinjakubowski.github.com", "shell-version": [ diff --git a/prefs.js b/prefs.js index bf0df77..2e20b8d 100644 --- a/prefs.js +++ b/prefs.js @@ -51,6 +51,20 @@ class Preferences { row_homogeneous: false }); + this.paddingHorizontal = new Gtk.SpinButton({ + adjustment: new Gtk.Adjustment({ + lower: 0, + upper: 1000, + step_increment: 1 + }) + }); + this.paddingVertical = new Gtk.SpinButton({ + adjustment: new Gtk.Adjustment({ + lower: 0, + upper: 1000, + step_increment: 1 + }) + }); this.animationTime = new Gtk.SpinButton({ adjustment: new Gtk.Adjustment({ lower: 100, @@ -84,6 +98,16 @@ class Preferences { hexpand: true, halign: Gtk.Align.START }); + let paddingHorizontalLabel = new Gtk.Label({ + label: _("Horizontal Padding"), + hexpand: true, + halign: Gtk.Align.START + }); + let paddingVerticalLabel = new Gtk.Label({ + label: _("Vertial Padding"), + hexpand: true, + halign: Gtk.Align.START + }); let animationDirectionLabel = new Gtk.Label({ label: _("Animation Direction"), hexpand: true, @@ -119,12 +143,16 @@ class Preferences { addRow(anchorHorizontalLabel, this.anchorHorizontal); addRow(anchorVerticalLabel, this.anchorVertical); + addRow(paddingHorizontalLabel, this.paddingHorizontal); + addRow(paddingVerticalLabel, this.paddingVertical); addRow(animationDirectionLabel, this.animationDirection); addRow(animationTimeLabel, this.animationTime); - + 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.PADDING_HORIZONTAL, this.paddingHorizontal, 'value', Gio.SettingsBindFlags.DEFAULT); + settings.bind(Utils.PrefFields.PADDING_VERTICAL, this.paddingVertical, 'value', 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); } diff --git a/schemas/gschemas.compiled b/schemas/gschemas.compiled index e023309..03cbd83 100644 Binary files a/schemas/gschemas.compiled and b/schemas/gschemas.compiled differ diff --git a/schemas/org.gnome.shell.extensions.notification-banner-reloaded.gschema.xml b/schemas/org.gnome.shell.extensions.notification-banner-reloaded.gschema.xml index ced7e4d..d7e50e0 100644 --- a/schemas/org.gnome.shell.extensions.notification-banner-reloaded.gschema.xml +++ b/schemas/org.gnome.shell.extensions.notification-banner-reloaded.gschema.xml @@ -23,6 +23,20 @@ + + 0 + Vertical padding of the banner + + + + + + 0 + Horizontal padding of the banner + + + + 2 Animation direction diff --git a/utils.js b/utils.js index 55d3755..fc788c6 100644 --- a/utils.js +++ b/utils.js @@ -1,6 +1,8 @@ var PrefFields = { ANCHOR_VERTICAL : 'anchor-vertical', ANCHOR_HORIZONTAL : 'anchor-horizontal', + PADDING_VERTICAL : 'padding-vertical', + PADDING_HORIZONTAL : 'padding-horizontal', ANIMATION_TIME : 'animation-time', ANIMATION_DIRECTION : 'animation-direction', -}; \ No newline at end of file +};