window: i18n for filter name and add 'all files'
Part-of: <https://gitlab.gnome.org/Incubator/loupe/-/merge_requests/195>
This commit is contained in:
parent
8cbe670498
commit
9d5dfd8728
2 changed files with 19 additions and 15 deletions
|
|
@ -171,7 +171,7 @@ impl Decoder {
|
|||
gio::Cancellable::NONE,
|
||||
)
|
||||
.context("Could not read content type information")?;
|
||||
if let Some(content_type) = file_info
|
||||
if let Some(mime_type) = file_info
|
||||
.content_type()
|
||||
.as_ref()
|
||||
.and_then(|x| gio::content_type_get_mime_type(x))
|
||||
|
|
@ -179,19 +179,14 @@ impl Decoder {
|
|||
// Known things we want to match here are
|
||||
// - image/svg+xml
|
||||
// - image/svg+xml-compressed
|
||||
if content_type.split('+').next() == Some("image/svg") {
|
||||
if mime_type.split('+').next() == Some("image/svg") {
|
||||
update_sender.send(DecoderUpdate::Format(ImageFormat::Svg));
|
||||
return Ok(FormatDecoder::Svg(Svg::new(file, update_sender, tiles)));
|
||||
} else if ["image/avif", "image/heif", "image/heic"]
|
||||
.contains(&content_type.as_str())
|
||||
{
|
||||
} else if ["image/avif", "image/heif", "image/heic"].contains(&mime_type.as_str()) {
|
||||
update_sender.send(DecoderUpdate::Format(ImageFormat::Heif));
|
||||
return Ok(FormatDecoder::Heif(Heif::new(file, update_sender, tiles)));
|
||||
} else {
|
||||
bail!(gettext_f(
|
||||
"Unknown image format: {}",
|
||||
&[content_type.as_str()]
|
||||
));
|
||||
bail!(gettext_f("Unknown image format: {}", &[mime_type.as_str()]));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -415,16 +415,25 @@ impl LpWindow {
|
|||
}
|
||||
|
||||
async fn pick_file(&self) {
|
||||
let filter_store = gio::ListStore::new(gtk::FileFilter::static_type());
|
||||
let filter_list = gio::ListStore::new(gtk::FileFilter::static_type());
|
||||
|
||||
let filter = gtk::FileFilter::new();
|
||||
filter.set_property("name", &String::from("Supported image files"));
|
||||
filter.add_mime_type("image/*");
|
||||
filter_store.append(&filter);
|
||||
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");
|
||||
|
||||
let filter_all_files = gtk::FileFilter::new();
|
||||
filter_all_files.set_name(Some(&gettext("All files")));
|
||||
filter_all_files.add_pattern("*");
|
||||
|
||||
filter_list.append(&filter_supported_formats);
|
||||
filter_list.append(&filter_all_files);
|
||||
|
||||
let chooser = gtk::FileDialog::builder()
|
||||
.title(gettext("Open Image"))
|
||||
.filters(&filter_store)
|
||||
.filters(&filter_list)
|
||||
.default_filter(&filter_supported_formats)
|
||||
.modal(true)
|
||||
.build();
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue