Skip to content

Commit 82b3162

Browse files
committed
Hide application icon when run under flatpak since it blocks access to those.
1 parent ee774bb commit 82b3162

File tree

5 files changed

+33
-2
lines changed

5 files changed

+33
-2
lines changed

Cargo.toml

+3
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ name = "pwvucontrol"
33
version = "0.4.3"
44
edition = "2021"
55

6+
[features]
7+
sandboxed = []
8+
69
[dependencies]
710
gettext-rs = { version = "0.7", features = ["gettext-system"] }
811
gtk = { version = "0.8.2", package = "gtk4", features = ["v4_12"]}

build-aux/com.saivert.pwvucontrol.json

+13-1
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,22 @@
6767
"name": "pwvucontrol",
6868
"builddir": true,
6969
"buildsystem": "meson",
70+
"config-opts": [
71+
"-Dsandboxed=true"
72+
],
7073
"sources": [
7174
{
7275
"type": "dir",
73-
"path": ".."
76+
"path": "..",
77+
"skip": [
78+
".flatpak-builder",
79+
".git",
80+
"builddir",
81+
".github",
82+
"flatpak-build",
83+
"myrepo",
84+
"target"
85+
]
7486
}
7587
]
7688
}

meson_options.txt

+7
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,10 @@ option(
88
value: 'default',
99
description: 'The build profile for pwvucontrol. One of "default" or "development".'
1010
)
11+
12+
option(
13+
'sandboxed',
14+
type: 'boolean',
15+
value: false,
16+
description: 'If this is built to be run in a sandbox.'
17+
)

src/meson.build

+4
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ else
2525
message('Building in debug mode')
2626
endif
2727

28+
if get_option('sandboxed')
29+
cargo_options += ['-Fsandboxed']
30+
endif
31+
2832
cargo_env = [
2933
'CARGO_HOME=' + meson.project_build_root() / 'cargo-home',
3034
'CODEGEN_BUILD_DIR=' + meson.current_build_dir()

src/ui/volumebox.rs

+6-1
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,12 @@ mod imp {
8080
let item = self.node_object.borrow();
8181
let item = item.as_ref().cloned().unwrap();
8282

83-
self.icon.set_icon_name(Some(&item.iconname()));
83+
// Flatpak blocks access to application icons, so hide the icon when run in the sandbox.
84+
if cfg!(not(feature = "sandboxed")) {
85+
self.icon.set_icon_name(Some(&item.iconname()));
86+
} else {
87+
self.icon.set_visible(false);
88+
}
8489

8590
item.bind_property("name", &self.title_label.get(), "label").sync_create().build();
8691

0 commit comments

Comments
 (0)