pantheon.switchboard-plug-about: introduces a wallpaper meson flag

After some thought, it doesn't make sense to just keep the wallpaper.
This commit is contained in:
Bobby Rong 2022-01-30 12:40:25 +08:00
parent 3fd6c227c6
commit 90964d30ba
No known key found for this signature in database
GPG key ID: ED07364437C91161
3 changed files with 91 additions and 19 deletions

View file

@ -0,0 +1,82 @@
From cc47fa33893e6840463ef8d59f9f4de4b7563726 Mon Sep 17 00:00:00 2001
From: Bobby Rong <rjl931189261@126.com>
Date: Sat, 4 Dec 2021 22:00:38 +0800
Subject: [PATCH] Add meson option for overlaying logo on wallpaper
---
meson.build | 8 ++++++++
meson_options.txt | 1 +
src/Views/OperatingSystemView.vala | 8 ++++++++
3 files changed, 17 insertions(+)
create mode 100644 meson_options.txt
diff --git a/meson.build b/meson.build
index 2125de6e..cbe3cadd 100644
--- a/meson.build
+++ b/meson.build
@@ -20,6 +20,14 @@ add_project_arguments(
vapi_dir = join_paths(meson.current_source_dir(), 'vapi')
add_project_arguments(['--vapidir', vapi_dir], language: 'vala')
+vala_flags = []
+
+if get_option('wallpaper')
+ vala_flags += ['--define', 'WALLPAPER']
+endif
+
+add_project_arguments(vala_flags, language: 'vala')
+
subdir('data')
subdir('src')
subdir('po')
diff --git a/meson_options.txt b/meson_options.txt
new file mode 100644
index 00000000..8cef0bb3
--- /dev/null
+++ b/meson_options.txt
@@ -0,0 +1 @@
+option('wallpaper', type : 'boolean', value : true, description : 'Overlay logo on default wallpaper')
diff --git a/src/Views/OperatingSystemView.vala b/src/Views/OperatingSystemView.vala
index fdb92e7e..6110d1aa 100644
--- a/src/Views/OperatingSystemView.vala
+++ b/src/Views/OperatingSystemView.vala
@@ -39,6 +39,7 @@ public class About.OperatingSystemView : Gtk.Grid {
logo_icon_name = "distributor-logo";
}
+#if WALLPAPER
var logo = new Hdy.Avatar (128, "", false) {
// In case the wallpaper can't be loaded, we don't want an icon or text
icon_name = "invalid-icon-name",
@@ -53,6 +54,7 @@ public class About.OperatingSystemView : Gtk.Grid {
}
});
logo.get_style_context ().add_provider (style_provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION);
+#endif
var icon = new Gtk.Image () {
icon_name = logo_icon_name + "-symbolic",
@@ -64,9 +66,11 @@ public class About.OperatingSystemView : Gtk.Grid {
icon_style_context.add_class ("logo");
icon_style_context.add_provider (style_provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION);
+#if WALLPAPER
var logo_overlay = new Gtk.Overlay ();
logo_overlay.add (logo);
logo_overlay.add_overlay (icon);
+#endif
// Intentionally not using GLib.OsInfoKey.PRETTY_NAME here because we
// want more granular control over text formatting
@@ -145,7 +149,11 @@ public class About.OperatingSystemView : Gtk.Grid {
valign = Gtk.Align.CENTER,
vexpand = true
};
+#if WALLPAPER
software_grid.attach (logo_overlay, 0, 0, 1, 4);
+#else
+ software_grid.attach (icon, 0, 0, 1, 4);
+#endif
software_grid.attach (title, 1, 0, 3);
software_grid.attach (kernel_version_label, 1, 2, 3);

View file

@ -2,7 +2,6 @@
, stdenv
, fetchFromGitHub
, nix-update-script
, substituteAll
, meson
, ninja
, pkg-config
@ -30,11 +29,10 @@ stdenv.mkDerivation rec {
};
patches = [
# Use NixOS's default wallpaper
(substituteAll {
src = ./fix-background-path.patch;
default_wallpaper = "${nixos-artwork.wallpapers.simple-dark-gray.gnomeFilePath}";
})
# Introduces a wallpaper meson flag.
# The wallpapaper path does not exist on NixOS, let's just remove the wallpaper.
# https://github.com/elementary/switchboard-plug-about/pull/236
./add-wallpaper-option.patch
];
nativeBuildInputs = [
@ -55,6 +53,11 @@ stdenv.mkDerivation rec {
switchboard
];
mesonFlags = [
# This option is introduced in add-wallpaper-option.patch
"-Dwallpaper=false"
];
passthru = {
updateScript = nix-update-script {
attrPath = "pantheon.${pname}";

View file

@ -1,13 +0,0 @@
diff --git a/src/Views/OperatingSystemView.vala b/src/Views/OperatingSystemView.vala
index fdb92e7e..4161538e 100644
--- a/src/Views/OperatingSystemView.vala
+++ b/src/Views/OperatingSystemView.vala
@@ -47,7 +47,7 @@ public class About.OperatingSystemView : Gtk.Grid {
};
logo.set_image_load_func ((size) => {
try {
- return new Gdk.Pixbuf.from_file_at_scale ("/usr/share/backgrounds/elementaryos-default", -1, size, true);
+ return new Gdk.Pixbuf.from_file_at_scale ("@default_wallpaper@", -1, size, true);
} catch (Error e) {
critical (e.message);
}