Blame SOURCES/0001-Support-positioning-at-the-top.patch

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