Load icons using mime type
This commit is contained in:
parent
1151c64323
commit
f76f83565c
6 changed files with 72 additions and 15 deletions
10
src/tab.rs
10
src/tab.rs
|
|
@ -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 {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue