|
|
80b029 |
From ff01583cb7eb00cbe012011b3de34298243787bc Mon Sep 17 00:00:00 2001
|
|
|
80b029 |
From: =?UTF-8?q?Florian=20M=C3=BCllner?= <fmuellner@gnome.org>
|
|
|
80b029 |
Date: Tue, 8 Feb 2022 13:41:18 +0100
|
|
|
80b029 |
Subject: [PATCH] Support positioning at the top
|
|
|
80b029 |
|
|
|
80b029 |
Fedora has always placed the logo at the bottom, but for RHEL the
|
|
|
80b029 |
placement will likely be at the top.
|
|
|
80b029 |
---
|
|
|
80b029 |
extension.js | 30 ++++++++-----------
|
|
|
80b029 |
prefs.js | 30 +++++++++----------
|
|
|
80b029 |
...sted.background-logo-extension.gschema.xml | 6 +++-
|
|
|
80b029 |
3 files changed, 33 insertions(+), 33 deletions(-)
|
|
|
80b029 |
|
|
|
80b029 |
diff --git a/extension.js b/extension.js
|
|
|
80b029 |
index d1bf35b..8255617 100644
|
|
|
80b029 |
--- a/extension.js
|
|
|
80b029 |
+++ b/extension.js
|
|
|
80b029 |
@@ -166,26 +166,22 @@ class BackgroundLogo extends St.Widget {
|
|
|
80b029 |
|
|
|
80b029 |
_updatePosition() {
|
|
|
80b029 |
let xAlign, yAlign;
|
|
|
80b029 |
- switch (this._settings.get_string('logo-position')) {
|
|
|
80b029 |
- case 'center':
|
|
|
80b029 |
- xAlign = Clutter.ActorAlign.CENTER;
|
|
|
80b029 |
- yAlign = Clutter.ActorAlign.CENTER;
|
|
|
80b029 |
- break;
|
|
|
80b029 |
- case 'bottom-left':
|
|
|
80b029 |
+ const position = this._settings.get_string('logo-position');
|
|
|
80b029 |
+ if (position.endsWith('left'))
|
|
|
80b029 |
xAlign = Clutter.ActorAlign.START;
|
|
|
80b029 |
- yAlign = Clutter.ActorAlign.END;
|
|
|
80b029 |
- break;
|
|
|
80b029 |
- case 'bottom-center':
|
|
|
80b029 |
- xAlign = Clutter.ActorAlign.CENTER;
|
|
|
80b029 |
- yAlign = Clutter.ActorAlign.END;
|
|
|
80b029 |
- break;
|
|
|
80b029 |
- case 'bottom-right':
|
|
|
80b029 |
+ else if (position.endsWith('right'))
|
|
|
80b029 |
xAlign = Clutter.ActorAlign.END;
|
|
|
80b029 |
+ else
|
|
|
80b029 |
+ xAlign = Clutter.ActorAlign.CENTER;
|
|
|
80b029 |
+
|
|
|
80b029 |
+ if (position.startsWith('top'))
|
|
|
80b029 |
+ yAlign = Clutter.ActorAlign.START;
|
|
|
80b029 |
+ else if (position.startsWith('bottom'))
|
|
|
80b029 |
yAlign = Clutter.ActorAlign.END;
|
|
|
80b029 |
- break;
|
|
|
80b029 |
- }
|
|
|
80b029 |
- this._bin.x_align = xAlign;
|
|
|
80b029 |
- this._bin.y_align = yAlign;
|
|
|
80b029 |
+ else
|
|
|
80b029 |
+ yAlign = Clutter.ActorAlign.CENTER;
|
|
|
80b029 |
+
|
|
|
80b029 |
+ this._bin.set({ xAlign, yAlign });
|
|
|
80b029 |
}
|
|
|
80b029 |
|
|
|
80b029 |
_updateBorder() {
|
|
|
80b029 |
diff --git a/prefs.js b/prefs.js
|
|
|
80b029 |
index a2ce27a..c8d5903 100644
|
|
|
80b029 |
--- a/prefs.js
|
|
|
80b029 |
+++ b/prefs.js
|
|
|
80b029 |
@@ -76,6 +76,9 @@ class BackgroundLogoPrefsWidget extends Gtk.Grid {
|
|
|
80b029 |
comboBox.append('bottom-left', 'Bottom left');
|
|
|
80b029 |
comboBox.append('bottom-center', 'Bottom center');
|
|
|
80b029 |
comboBox.append('bottom-right', 'Bottom right');
|
|
|
80b029 |
+ comboBox.append('top-left', 'Top left');
|
|
|
80b029 |
+ comboBox.append('top-center', 'Top center');
|
|
|
80b029 |
+ comboBox.append('top-right', 'Top right');
|
|
|
80b029 |
this._settings.bind('logo-position',
|
|
|
80b029 |
comboBox, 'active-id',
|
|
|
80b029 |
Gio.SettingsBindFlags.DEFAULT);
|
|
|
80b029 |
@@ -196,24 +199,21 @@ class BackgroundLogoPrefsWidget extends Gtk.Grid {
|
|
|
80b029 |
_getLogoPosition(width, height) {
|
|
|
80b029 |
let scaledBorder = this._settings.get_uint('logo-border');
|
|
|
80b029 |
let x, y;
|
|
|
80b029 |
- switch (this._settings.get_string('logo-position')) {
|
|
|
80b029 |
- case 'center':
|
|
|
80b029 |
- x = (width - this._logo.get_width()) / 2;
|
|
|
80b029 |
- y = (height - this._logo.get_height()) / 2;
|
|
|
80b029 |
- break;
|
|
|
80b029 |
- case 'bottom-left':
|
|
|
80b029 |
+ const position = this._settings.get_string('logo-position');
|
|
|
80b029 |
+ if (position.endsWith('left'))
|
|
|
80b029 |
x = scaledBorder;
|
|
|
80b029 |
- y = height - this._logo.get_height() - scaledBorder;
|
|
|
80b029 |
- break;
|
|
|
80b029 |
- case 'bottom-center':
|
|
|
80b029 |
+ else if (position.endsWith('right'))
|
|
|
80b029 |
+ x = (width - this._logo.get_width() - scaledBorder);
|
|
|
80b029 |
+ else
|
|
|
80b029 |
x = (width - this._logo.get_width()) / 2;
|
|
|
80b029 |
+
|
|
|
80b029 |
+ if (position.startsWith('top'))
|
|
|
80b029 |
+ y = scaledBorder;
|
|
|
80b029 |
+ else if (position.startsWith('bottom'))
|
|
|
80b029 |
y = height - this._logo.get_height() - scaledBorder;
|
|
|
80b029 |
- break;
|
|
|
80b029 |
- case 'bottom-right':
|
|
|
80b029 |
- x = width - this._logo.get_width() - scaledBorder;
|
|
|
80b029 |
- y = height - this._logo.get_height() - scaledBorder;
|
|
|
80b029 |
- break;
|
|
|
80b029 |
- }
|
|
|
80b029 |
+ else
|
|
|
80b029 |
+ y = (height - this._logo.get_height()) / 2;
|
|
|
80b029 |
+
|
|
|
80b029 |
return [x, y];
|
|
|
80b029 |
}
|
|
|
80b029 |
|
|
|
80b029 |
diff --git a/schemas/org.fedorahosted.background-logo-extension.gschema.xml b/schemas/org.fedorahosted.background-logo-extension.gschema.xml
|
|
|
80b029 |
index abacefb..74bc3a8 100644
|
|
|
80b029 |
--- a/schemas/org.fedorahosted.background-logo-extension.gschema.xml
|
|
|
80b029 |
+++ b/schemas/org.fedorahosted.background-logo-extension.gschema.xml
|
|
|
80b029 |
@@ -5,6 +5,9 @@
|
|
|
80b029 |
<value nick="bottom-left" value="1"/>
|
|
|
80b029 |
<value nick="bottom-center" value="2"/>
|
|
|
80b029 |
<value nick="bottom-right" value="3" />
|
|
|
80b029 |
+ <value nick="top-left" value="4"/>
|
|
|
80b029 |
+ <value nick="top-center" value="5"/>
|
|
|
80b029 |
+ <value nick="top-right" value="6" />
|
|
|
80b029 |
</enum>
|
|
|
80b029 |
|
|
|
80b029 |
|
|
|
80b029 |
@@ -20,7 +23,8 @@
|
|
|
80b029 |
<summary>Logo position</summary>
|
|
|
80b029 |
<description>
|
|
|
80b029 |
The position logo of the logo; valid values are 'center',
|
|
|
80b029 |
- 'bottom-left', 'bottom-center' and 'bottom-right'
|
|
|
80b029 |
+ 'bottom-left', 'bottom-center', 'bottom-right',
|
|
|
80b029 |
+ 'top-left', 'top-center' and 'top-right'
|
|
|
80b029 |
</description>
|
|
|
80b029 |
</key>
|
|
|
80b029 |
<key type="d" name="logo-size">
|
|
|
80b029 |
--
|
|
|
80b029 |
2.33.1
|
|
|
80b029 |
|