Implement add to sidebar, fixes #112
This commit is contained in:
parent
a61e587b1c
commit
99c378873a
3 changed files with 46 additions and 5 deletions
|
|
@ -48,6 +48,25 @@ pub enum Favorite {
|
|||
}
|
||||
|
||||
impl Favorite {
|
||||
pub fn from_path(path: PathBuf) -> Self {
|
||||
// Ensure that special folders are handled properly
|
||||
for favorite in &[
|
||||
Self::Home,
|
||||
Self::Documents,
|
||||
Self::Downloads,
|
||||
Self::Music,
|
||||
Self::Pictures,
|
||||
Self::Videos,
|
||||
] {
|
||||
if let Some(favorite_path) = favorite.path_opt() {
|
||||
if &favorite_path == &path {
|
||||
return favorite.clone();
|
||||
}
|
||||
}
|
||||
}
|
||||
Self::Path(path)
|
||||
}
|
||||
|
||||
pub fn path_opt(&self) -> Option<PathBuf> {
|
||||
match self {
|
||||
Self::Home => dirs::home_dir(),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue