feat: support MIME subclasses in file chooser dialog
This commit is contained in:
parent
3ef7913abd
commit
43a4228ca4
2 changed files with 11 additions and 1 deletions
|
|
@ -40,7 +40,7 @@ use crate::localize::LANGUAGE_SORTER;
|
||||||
use crate::mounter::{MOUNTERS, MounterItem, MounterItems, MounterKey, MounterMessage};
|
use crate::mounter::{MOUNTERS, MounterItem, MounterItems, MounterKey, MounterMessage};
|
||||||
use crate::tab::{self, ItemMetadata, Location, SearchLocation, Tab};
|
use crate::tab::{self, ItemMetadata, Location, SearchLocation, Tab};
|
||||||
use crate::zoom::{zoom_in_view, zoom_out_view, zoom_to_default};
|
use crate::zoom::{zoom_in_view, zoom_out_view, zoom_to_default};
|
||||||
use crate::{fl, home_dir, menu};
|
use crate::{fl, home_dir, menu, mime_icon};
|
||||||
|
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
pub struct DialogMessage(cosmic::Action<Message>);
|
pub struct DialogMessage(cosmic::Action<Message>);
|
||||||
|
|
@ -1919,11 +1919,13 @@ impl Application for App {
|
||||||
items.retain(|item| {
|
items.retain(|item| {
|
||||||
// Directories are always shown
|
// Directories are always shown
|
||||||
item.metadata.is_dir()
|
item.metadata.is_dir()
|
||||||
|
// Check for mime type match (first because it is faster)
|
||||||
|| mimes.iter().any(|filter_mime| {
|
|| mimes.iter().any(|filter_mime| {
|
||||||
if filter_mime.subtype() == mime::STAR {
|
if filter_mime.subtype() == mime::STAR {
|
||||||
filter_mime.type_() == item.mime.type_()
|
filter_mime.type_() == item.mime.type_()
|
||||||
} else {
|
} else {
|
||||||
*filter_mime == item.mime
|
*filter_mime == item.mime
|
||||||
|
|| mime_icon::is_mime_subclass_of(&item.mime, filter_mime)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
// Check for glob match (last because it is slower)
|
// Check for glob match (last because it is slower)
|
||||||
|
|
|
||||||
|
|
@ -124,3 +124,11 @@ pub fn parent_mime_types(mime: &Mime) -> Option<Vec<Mime>> {
|
||||||
let mime_icon_cache = MIME_ICON_CACHE.lock().unwrap();
|
let mime_icon_cache = MIME_ICON_CACHE.lock().unwrap();
|
||||||
mime_icon_cache.shared_mime_info.get_parents_aliased(mime)
|
mime_icon_cache.shared_mime_info.get_parents_aliased(mime)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn is_mime_subclass_of(mime_type: &Mime, base: &Mime) -> bool {
|
||||||
|
let mime_icon_cache = MIME_ICON_CACHE.lock().unwrap();
|
||||||
|
|
||||||
|
mime_icon_cache
|
||||||
|
.shared_mime_info
|
||||||
|
.mime_type_subclass(mime_type, base)
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue