Load icons using mime type

This commit is contained in:
Jeremy Soller 2023-11-13 10:33:26 -07:00
parent 1151c64323
commit f76f83565c
No known key found for this signature in database
GPG key ID: DCFCA852D3906975
6 changed files with 72 additions and 15 deletions

View file

@ -1,9 +1,10 @@
// SPDX-License-Identifier: GPL-3.0-only
use cosmic::widget::{icon, Icon};
use cosmic_text::{Attrs, Buffer, Edit, Shaping, SyntaxEditor, ViEditor, Wrap};
use std::{fs, path::PathBuf, sync::Mutex};
use crate::{fl, Config, FONT_SYSTEM, SYNTAX_SYSTEM};
use crate::{fl, mime_icon, Config, FALLBACK_MIME_ICON, FONT_SYSTEM, SYNTAX_SYSTEM};
pub struct Tab {
pub path_opt: Option<PathBuf>,
@ -95,6 +96,13 @@ impl Tab {
}
}
pub fn icon(&self, size: u16) -> Icon {
match &self.path_opt {
Some(path) => mime_icon(path, size),
None => icon::from_name(FALLBACK_MIME_ICON).size(size).icon(),
}
}
pub fn title(&self) -> String {
//TODO: show full title when there is a conflict
if let Some(path) = &self.path_opt {