From 500967db9a4520ba568cd42c8122559869983d2b Mon Sep 17 00:00:00 2001 From: Florian Müllner Date: Feb 15 2022 14:37:13 +0000 Subject: Support positioning at the top Fedora has always placed the logo at the bottom, but for RHEL the placement will likely be at the top. --- diff --git a/extension.js b/extension.js index 1f34b2e..403cc5a 100644 --- a/extension.js +++ b/extension.js @@ -166,26 +166,22 @@ class BackgroundLogo extends St.Widget { _updatePosition() { let xAlign, yAlign; - switch (this._settings.get_string('logo-position')) { - case 'center': - xAlign = Clutter.ActorAlign.CENTER; - yAlign = Clutter.ActorAlign.CENTER; - break; - case 'bottom-left': + const position = this._settings.get_string('logo-position'); + if (position.endsWith('left')) xAlign = Clutter.ActorAlign.START; - yAlign = Clutter.ActorAlign.END; - break; - case 'bottom-center': - xAlign = Clutter.ActorAlign.CENTER; - yAlign = Clutter.ActorAlign.END; - break; - case 'bottom-right': + else if (position.endsWith('right')) xAlign = Clutter.ActorAlign.END; + else + xAlign = Clutter.ActorAlign.CENTER; + + if (position.startsWith('top')) + yAlign = Clutter.ActorAlign.START; + else if (position.startsWith('bottom')) yAlign = Clutter.ActorAlign.END; - break; - } - this._bin.x_align = xAlign; - this._bin.y_align = yAlign; + else + yAlign = Clutter.ActorAlign.CENTER; + + this._bin.set({ xAlign, yAlign }); } _updateBorder() { diff --git a/prefs.js b/prefs.js index c40338f..d910719 100644 --- a/prefs.js +++ b/prefs.js @@ -101,24 +101,21 @@ class PreviewGroup extends Adw.PreferencesGroup { _getLogoPosition(width, height) { let scaledBorder = this._settings.get_uint('logo-border'); let x, y; - switch (this._settings.get_string('logo-position')) { - case 'center': - x = (width - this._logo.get_width()) / 2; - y = (height - this._logo.get_height()) / 2; - break; - case 'bottom-left': + const position = this._settings.get_string('logo-position'); + if (position.endsWith('left')) x = scaledBorder; - y = height - this._logo.get_height() - scaledBorder; - break; - case 'bottom-center': + else if (position.endsWith('right')) + x = (width - this._logo.get_width() - scaledBorder); + else x = (width - this._logo.get_width()) / 2; + + if (position.startsWith('top')) + y = scaledBorder; + else if (position.startsWith('bottom')) y = height - this._logo.get_height() - scaledBorder; - break; - case 'bottom-right': - x = width - this._logo.get_width() - scaledBorder; - y = height - this._logo.get_height() - scaledBorder; - break; - } + else + y = (height - this._logo.get_height()) / 2; + return [x, y]; } }); @@ -182,6 +179,9 @@ class LogoGroup extends Adw.PreferencesGroup { positionModel.append(new LogoPosition('Bottom left', 'bottom-left')); positionModel.append(new LogoPosition('Bottom center', 'bottom-center')); positionModel.append(new LogoPosition('Bottom right', 'bottom-right')); + positionModel.append(new LogoPosition('Top left', 'top-left')); + positionModel.append(new LogoPosition('Top center', 'top-center')); + positionModel.append(new LogoPosition('Top right', 'top-right')); this._positionRow = new Adw.ComboRow({ title: 'Position', model: positionModel, diff --git a/schemas/org.fedorahosted.background-logo-extension.gschema.xml b/schemas/org.fedorahosted.background-logo-extension.gschema.xml index abacefb..74bc3a8 100644 --- a/schemas/org.fedorahosted.background-logo-extension.gschema.xml +++ b/schemas/org.fedorahosted.background-logo-extension.gschema.xml @@ -5,6 +5,9 @@ + + + Logo position The position logo of the logo; valid values are 'center', - 'bottom-left', 'bottom-center' and 'bottom-right' + 'bottom-left', 'bottom-center', 'bottom-right', + 'top-left', 'top-center' and 'top-right'