refactor: make app-tray config its own crate
This commit is contained in:
parent
8870851f81
commit
481573ec27
8 changed files with 24 additions and 4 deletions
|
|
@ -2,8 +2,6 @@
|
|||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
|
||||
use crate::{
|
||||
config,
|
||||
config::{AppListConfig, APP_ID},
|
||||
fl,
|
||||
wayland_subscription::{
|
||||
wayland_subscription, OutputUpdate, ToplevelRequest, ToplevelUpdate, WaylandImage,
|
||||
|
|
@ -53,6 +51,7 @@ use cosmic::{
|
|||
},
|
||||
Apply, Command, Element, Theme,
|
||||
};
|
||||
use cosmic_app_list_config::{AppListConfig, APP_ID};
|
||||
use cosmic_protocols::{
|
||||
toplevel_info::v1::client::zcosmic_toplevel_handle_v1::{State, ZcosmicToplevelHandleV1},
|
||||
workspace::v1::client::zcosmic_workspace_handle_v1::ZcosmicWorkspaceHandleV1,
|
||||
|
|
@ -621,7 +620,7 @@ impl cosmic::Application for CosmicAppList {
|
|||
type Message = Message;
|
||||
type Executor = cosmic::SingleThreadExecutor;
|
||||
type Flags = ();
|
||||
const APP_ID: &'static str = config::APP_ID;
|
||||
const APP_ID: &'static str = APP_ID;
|
||||
|
||||
fn init(
|
||||
core: cosmic::app::Core,
|
||||
|
|
|
|||
|
|
@ -1,4 +0,0 @@
|
|||
(
|
||||
filter_top_levels: None,
|
||||
favorites: [],
|
||||
)
|
||||
|
|
@ -1,55 +0,0 @@
|
|||
// Copyright 2023 System76 <info@system76.com>
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
|
||||
use cosmic::cosmic_config::{
|
||||
self, cosmic_config_derive::CosmicConfigEntry, Config, CosmicConfigEntry,
|
||||
};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::fmt::Debug;
|
||||
pub const APP_ID: &str = "com.system76.CosmicAppList";
|
||||
|
||||
#[derive(Debug, Clone, Deserialize, Serialize, Default, PartialEq, Eq)]
|
||||
pub enum TopLevelFilter {
|
||||
#[default]
|
||||
ActiveWorkspace,
|
||||
ConfiguredOutput,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Deserialize, Serialize, PartialEq, Eq, CosmicConfigEntry)]
|
||||
#[version = 1]
|
||||
pub struct AppListConfig {
|
||||
pub filter_top_levels: Option<TopLevelFilter>,
|
||||
pub favorites: Vec<String>,
|
||||
pub enable_drag_source: bool,
|
||||
}
|
||||
|
||||
impl Default for AppListConfig {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
filter_top_levels: None,
|
||||
favorites: Vec::new(),
|
||||
enable_drag_source: true,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl AppListConfig {
|
||||
pub fn add_pinned(&mut self, id: String, config: &Config) {
|
||||
if !self.favorites.contains(&id) {
|
||||
self.favorites.push(id);
|
||||
let _ = self.write_entry(config);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn remove_pinned(&mut self, id: &str, config: &Config) {
|
||||
if let Some(pos) = self.favorites.iter().position(|e| e == &id) {
|
||||
self.favorites.remove(pos);
|
||||
let _ = self.write_entry(config);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn update_pinned(&mut self, favorites: Vec<String>, config: &Config) {
|
||||
self.favorites = favorites;
|
||||
let _ = self.write_entry(config);
|
||||
}
|
||||
}
|
||||
|
|
@ -2,7 +2,6 @@
|
|||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
|
||||
mod app;
|
||||
mod config;
|
||||
mod localize;
|
||||
mod wayland_handler;
|
||||
mod wayland_subscription;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue