fileChooser: Only list supported image formats

Closes #151

Part-of: <https://gitlab.gnome.org/GNOME/Incubator/loupe/-/merge_requests/238>
This commit is contained in:
Sophie Herold 2023-06-20 20:58:01 +02:00
parent cc1c8a3da5
commit eb94683d1f
2 changed files with 14 additions and 12 deletions

17
Cargo.lock generated
View file

@ -1081,19 +1081,18 @@ dependencies = [
[[package]]
name = "glycin"
version = "0.0.1"
source = "git+https://gitlab.gnome.org/sophie-h/glycin.git#2e3f9add120a4913e559729d361d6d7e5d010f2b"
version = "0.1.0-alpha.2"
source = "git+https://gitlab.gnome.org/sophie-h/glycin.git#c85bff97db98c311a278816fd0efbc28173a2419"
dependencies = [
"anyhow",
"async-std",
"futures",
"gdk4",
"gio",
"glib",
"glycin-utils",
"lcms2",
"memfd",
"memmap2 0.6.2",
"memmap2 0.7.0",
"nix",
"rgb",
"safe-transmute",
@ -1102,13 +1101,13 @@ dependencies = [
[[package]]
name = "glycin-utils"
version = "0.0.1"
source = "git+https://gitlab.gnome.org/sophie-h/glycin.git#2e3f9add120a4913e559729d361d6d7e5d010f2b"
version = "0.1.0-alpha.2"
source = "git+https://gitlab.gnome.org/sophie-h/glycin.git#c85bff97db98c311a278816fd0efbc28173a2419"
dependencies = [
"anyhow",
"async-std",
"gettext-rs",
"memmap2 0.6.2",
"memmap2 0.7.0",
"nix",
"serde",
"zbus",
@ -1688,9 +1687,9 @@ dependencies = [
[[package]]
name = "memmap2"
version = "0.6.2"
version = "0.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6d28bba84adfe6646737845bc5ebbfa2c08424eb1c37e94a1fd2a82adb56a872"
checksum = "180d4b35be83d33392d1d1bfbd2ae1eca7ff5de1a94d3fc87faaa99a069e7cbd"
dependencies = [
"libc",
]

View file

@ -466,9 +466,12 @@ impl LpWindow {
let filter_supported_formats = gtk::FileFilter::new();
filter_supported_formats.set_name(Some(&gettext("Supported image formats")));
filter_supported_formats.add_mime_type("image/*");
// Manual support for Farbfeld since it has no mime type
filter_supported_formats.add_suffix("ff");
for mime_type in glycin::image_formats().await {
filter_supported_formats.add_mime_type(&mime_type);
}
// TODO: Update when SVG moves to glycin as well
filter_supported_formats.add_mime_type("image/svg+xml");
filter_supported_formats.add_mime_type("image/svg+xml-compressed");
let filter_all_files = gtk::FileFilter::new();
filter_all_files.set_name(Some(&gettext("All files")));