aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Gabriel <mike.gabriel@das-netzwerkteam.de>2025-05-15 10:19:05 +0200
committerMike Gabriel <mike.gabriel@das-netzwerkteam.de>2025-05-15 10:19:05 +0200
commit800eaa1c02c8d61d25a94561136760912d5e1bcd (patch)
tree9702c4a56a38493c878597cfefa09db11e24a6be
parentd1d8d80ed9665d66874c100165600d36207f2967 (diff)
parent508631878e53106dfe0ffbe5cec4a3d62856fac0 (diff)
downloadarctica-greeter-800eaa1c02c8d61d25a94561136760912d5e1bcd.tar.gz
arctica-greeter-800eaa1c02c8d61d25a94561136760912d5e1bcd.tar.bz2
arctica-greeter-800eaa1c02c8d61d25a94561136760912d5e1bcd.zip
Merge branch 'tari01-pr/add-background-position'
Attributes GH PR #120: https://github.com/ArcticaProject/arctica-greeter/pull/120
-rw-r--r--data/org.ArcticaProject.arctica-greeter.gschema.xml11
-rw-r--r--src/background.vala30
-rw-r--r--src/settings.vala1
3 files changed, 40 insertions, 2 deletions
diff --git a/data/org.ArcticaProject.arctica-greeter.gschema.xml b/data/org.ArcticaProject.arctica-greeter.gschema.xml
index b5c2cab..540d87f 100644
--- a/data/org.ArcticaProject.arctica-greeter.gschema.xml
+++ b/data/org.ArcticaProject.arctica-greeter.gschema.xml
@@ -347,5 +347,16 @@
<default>'#000000'</default>
<summary>The background color of the menubar in #RRGGBB format.</summary>
</key>
+ <key name="background-position" type="s">
+ <choices>
+ <choice value='center'/>
+ <choice value='top-left'/>
+ <choice value='top-right'/>
+ <choice value='bottom-left'/>
+ <choice value='bottom-right'/>
+ </choices>
+ <default>'center'</default>
+ <summary>The position of the background image.</summary>
+ </key>
</schema>
</schemalist>
diff --git a/src/background.vala b/src/background.vala
index bf1ca6f..07dce7e 100644
--- a/src/background.vala
+++ b/src/background.vala
@@ -173,17 +173,43 @@ class BackgroundLoader : Object
var target_aspect = (double) width / height;
var aspect = (double) image.width / image.height;
double scale, offset_x = 0, offset_y = 0;
+ string sPosition = AGSettings.get_string (AGSettings.KEY_BACKGROUND_POSITION);
+
if (aspect > target_aspect)
{
/* Fit height and trim sides */
scale = (double) height / image.height;
- offset_x = (image.width * scale - width) / 2;
+
+ if (sPosition == "center")
+ {
+ offset_x = (image.width * scale - width) / 2;
+ }
+ else if (sPosition == "top-left" || sPosition == "bottom-left")
+ {
+ offset_x = 0;
+ }
+ else if (sPosition == "top-right" || sPosition == "bottom-right")
+ {
+ offset_x = (image.width * scale - width);
+ }
}
else
{
/* Fit width and trim top and bottom */
scale = (double) width / image.width;
- offset_y = (image.height * scale - height) / 2;
+
+ if (sPosition == "center")
+ {
+ offset_y = (image.height * scale - height) / 2;
+ }
+ else if (sPosition == "top-left" || sPosition == "top-right")
+ {
+ offset_y = 0;
+ }
+ else if (sPosition == "bottom-left" || sPosition == "bottom-right")
+ {
+ offset_y = (image.height * scale - height);
+ }
}
var scaled_image = new Gdk.Pixbuf (image.colorspace, image.has_alpha, image.bits_per_sample, width, height);
diff --git a/src/settings.vala b/src/settings.vala
index 865fe4a..d479aa6 100644
--- a/src/settings.vala
+++ b/src/settings.vala
@@ -101,6 +101,7 @@ public class AGSettings : Object
public const string KEY_LOGO_OFFSET_VERTICAL = "logo-offset-vertical";
public const string KEY_ERROR_BELOW_ENTRY = "error-below-entry";
public const string KEY_MENUBAR_BGCOLOR = "menubar-bgcolor";
+ public const string KEY_BACKGROUND_POSITION = "background-position";
public static bool get_boolean (string key)
{