add padding options for notification banner (#1)
Co-authored-by: synonym24 <itsa-me@synonym24.at>
This commit is contained in:
+8
-4
@@ -30,6 +30,8 @@ let ANIMATION_TIME = 200;
|
|||||||
let ANIMATION_DIRECTION = 2;
|
let ANIMATION_DIRECTION = 2;
|
||||||
let ANCHOR_VERTICAL = 0;
|
let ANCHOR_VERTICAL = 0;
|
||||||
let ANCHOR_HORIZONTAL = 2;
|
let ANCHOR_HORIZONTAL = 2;
|
||||||
|
let PADDING_VERTICAL = 0;
|
||||||
|
let PADDING_HORIZONTAL = 0;
|
||||||
|
|
||||||
function patcher(obj, method, original, patch) {
|
function patcher(obj, method, original, patch) {
|
||||||
const body = eval(`${obj}.prototype.${method}.toString()`);
|
const body = eval(`${obj}.prototype.${method}.toString()`);
|
||||||
@@ -47,10 +49,10 @@ function calcTarget(self) {
|
|||||||
let x = 0, y = 0;
|
let x = 0, y = 0;
|
||||||
switch (ANCHOR_HORIZONTAL) {
|
switch (ANCHOR_HORIZONTAL) {
|
||||||
case 0: // left
|
case 0: // left
|
||||||
x = 0;
|
x = 0 + PADDING_HORIZONTAL;
|
||||||
break;
|
break;
|
||||||
case 1: // right
|
case 1: // right
|
||||||
x = getMessageTraySize().width - self._banner.width;
|
x = getMessageTraySize().width - self._banner.width - PADDING_HORIZONTAL;
|
||||||
break;
|
break;
|
||||||
case 2: // center
|
case 2: // center
|
||||||
x = (getMessageTraySize().width - self._banner.width) / 2.0;
|
x = (getMessageTraySize().width - self._banner.width) / 2.0;
|
||||||
@@ -58,10 +60,10 @@ function calcTarget(self) {
|
|||||||
}
|
}
|
||||||
switch (ANCHOR_VERTICAL) {
|
switch (ANCHOR_VERTICAL) {
|
||||||
case 0: // top
|
case 0: // top
|
||||||
y = 0;
|
y = 0 + PADDING_VERTICAL;
|
||||||
break;
|
break;
|
||||||
case 1: // bottom
|
case 1: // bottom
|
||||||
y = getMessageTraySize().height - self._banner.height;
|
y = getMessageTraySize().height - self._banner.height - PADDING_VERTICAL;
|
||||||
break;
|
break;
|
||||||
case 2: // center
|
case 2: // center
|
||||||
y = (getMessageTraySize().height - self._banner.height) / 2.0;
|
y = (getMessageTraySize().height - self._banner.height) / 2.0;
|
||||||
@@ -154,6 +156,8 @@ class Extension {
|
|||||||
_fetchSettings() {
|
_fetchSettings() {
|
||||||
ANCHOR_VERTICAL = this._settings.get_int(Utils.PrefFields.ANCHOR_VERTICAL);
|
ANCHOR_VERTICAL = this._settings.get_int(Utils.PrefFields.ANCHOR_VERTICAL);
|
||||||
ANCHOR_HORIZONTAL = this._settings.get_int(Utils.PrefFields.ANCHOR_HORIZONTAL);
|
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_DIRECTION = this._settings.get_int(Utils.PrefFields.ANIMATION_DIRECTION);
|
||||||
ANIMATION_TIME = this._settings.get_int(Utils.PrefFields.ANIMATION_TIME);
|
ANIMATION_TIME = this._settings.get_int(Utils.PrefFields.ANIMATION_TIME);
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-1
@@ -1,6 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "Notification Banner Reloaded",
|
"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",
|
"description": "Configure notification banner position and animation to your liking",
|
||||||
"uuid": "notification-banner-reloaded@marcinjakubowski.github.com",
|
"uuid": "notification-banner-reloaded@marcinjakubowski.github.com",
|
||||||
"shell-version": [
|
"shell-version": [
|
||||||
|
|||||||
@@ -51,6 +51,20 @@ class Preferences {
|
|||||||
row_homogeneous: false
|
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({
|
this.animationTime = new Gtk.SpinButton({
|
||||||
adjustment: new Gtk.Adjustment({
|
adjustment: new Gtk.Adjustment({
|
||||||
lower: 100,
|
lower: 100,
|
||||||
@@ -84,6 +98,16 @@ class Preferences {
|
|||||||
hexpand: true,
|
hexpand: true,
|
||||||
halign: Gtk.Align.START
|
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({
|
let animationDirectionLabel = new Gtk.Label({
|
||||||
label: _("Animation Direction"),
|
label: _("Animation Direction"),
|
||||||
hexpand: true,
|
hexpand: true,
|
||||||
@@ -119,12 +143,16 @@ class Preferences {
|
|||||||
|
|
||||||
addRow(anchorHorizontalLabel, this.anchorHorizontal);
|
addRow(anchorHorizontalLabel, this.anchorHorizontal);
|
||||||
addRow(anchorVerticalLabel, this.anchorVertical);
|
addRow(anchorVerticalLabel, this.anchorVertical);
|
||||||
|
addRow(paddingHorizontalLabel, this.paddingHorizontal);
|
||||||
|
addRow(paddingVerticalLabel, this.paddingVertical);
|
||||||
addRow(animationDirectionLabel, this.animationDirection);
|
addRow(animationDirectionLabel, this.animationDirection);
|
||||||
addRow(animationTimeLabel, this.animationTime);
|
addRow(animationTimeLabel, this.animationTime);
|
||||||
|
|
||||||
const settings = ExtensionUtils.getSettings();
|
const settings = ExtensionUtils.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_VERTICAL, this.paddingVertical, 'value', Gio.SettingsBindFlags.DEFAULT);
|
||||||
settings.bind(Utils.PrefFields.ANIMATION_DIRECTION, this.animationDirection, '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);
|
settings.bind(Utils.PrefFields.ANIMATION_TIME, this.animationTime, 'value', Gio.SettingsBindFlags.DEFAULT);
|
||||||
}
|
}
|
||||||
|
|||||||
Binary file not shown.
@@ -23,6 +23,20 @@
|
|||||||
<range min="0" max="2"/>
|
<range min="0" max="2"/>
|
||||||
</key>
|
</key>
|
||||||
|
|
||||||
|
<key type="i" name="padding-vertical">
|
||||||
|
<default>0</default>
|
||||||
|
<summary>Vertical padding of the banner</summary>
|
||||||
|
<description></description>
|
||||||
|
<range min="0" max="1000"/>
|
||||||
|
</key>
|
||||||
|
|
||||||
|
<key type="i" name="padding-horizontal">
|
||||||
|
<default>0</default>
|
||||||
|
<summary>Horizontal padding of the banner</summary>
|
||||||
|
<description></description>
|
||||||
|
<range min="0" max="1000"/>
|
||||||
|
</key>
|
||||||
|
|
||||||
<key type="i" name="animation-direction">
|
<key type="i" name="animation-direction">
|
||||||
<default>2</default>
|
<default>2</default>
|
||||||
<summary>Animation direction</summary>
|
<summary>Animation direction</summary>
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
var PrefFields = {
|
var PrefFields = {
|
||||||
ANCHOR_VERTICAL : 'anchor-vertical',
|
ANCHOR_VERTICAL : 'anchor-vertical',
|
||||||
ANCHOR_HORIZONTAL : 'anchor-horizontal',
|
ANCHOR_HORIZONTAL : 'anchor-horizontal',
|
||||||
|
PADDING_VERTICAL : 'padding-vertical',
|
||||||
|
PADDING_HORIZONTAL : 'padding-horizontal',
|
||||||
ANIMATION_TIME : 'animation-time',
|
ANIMATION_TIME : 'animation-time',
|
||||||
ANIMATION_DIRECTION : 'animation-direction',
|
ANIMATION_DIRECTION : 'animation-direction',
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user