feat: app list is displayed and updated
This commit is contained in:
parent
ceff811072
commit
8223c76361
17 changed files with 4317 additions and 1256 deletions
|
|
@ -1,12 +1,15 @@
|
|||
use crate::ID;
|
||||
use anyhow::anyhow;
|
||||
use serde::Deserialize;
|
||||
use std::fmt::Debug;
|
||||
use std::fs::File;
|
||||
use xdg::BaseDirectories;
|
||||
|
||||
#[derive(Debug, Clone, Deserialize)]
|
||||
pub const APP_ID: &str = "com.system76.CosmicAppList";
|
||||
pub const VERSION: &str = "0.1.0";
|
||||
|
||||
#[derive(Debug, Clone, Deserialize, Default)]
|
||||
pub enum TopLevelFilter {
|
||||
#[default]
|
||||
ActiveWorkspace,
|
||||
ConfiguredOutput,
|
||||
}
|
||||
|
|
@ -14,6 +17,7 @@ pub enum TopLevelFilter {
|
|||
#[derive(Debug, Clone, Default, Deserialize)]
|
||||
pub struct AppListConfig {
|
||||
pub filter_top_levels: Option<TopLevelFilter>,
|
||||
pub favorites: Vec<String>,
|
||||
}
|
||||
|
||||
impl AppListConfig {
|
||||
|
|
@ -21,7 +25,7 @@ impl AppListConfig {
|
|||
pub fn load() -> anyhow::Result<AppListConfig> {
|
||||
let file = match BaseDirectories::new()
|
||||
.ok()
|
||||
.and_then(|dirs| dirs.find_config_file(format!("{ID}/config.ron")))
|
||||
.and_then(|dirs| dirs.find_config_file(format!("{APP_ID}/config.ron")))
|
||||
.and_then(|p| File::open(p).ok())
|
||||
{
|
||||
Some(path) => path,
|
||||
|
|
@ -33,4 +37,20 @@ impl AppListConfig {
|
|||
ron::de::from_reader::<_, AppListConfig>(file)
|
||||
.map_err(|err| anyhow!("Failed to parse config file: {}", err))
|
||||
}
|
||||
|
||||
pub fn add_favorite(&mut self, id: String) -> anyhow::Result<()> {
|
||||
if !self.favorites.contains(&id) {
|
||||
self.favorites.push(id);
|
||||
}
|
||||
todo!()
|
||||
}
|
||||
|
||||
pub fn remove_favorite(&mut self, id: String) -> anyhow::Result<()> {
|
||||
self.favorites.retain(|e| e != &id);
|
||||
todo!()
|
||||
}
|
||||
|
||||
pub fn save() -> anyhow::Result<()> {
|
||||
todo!()
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue