feat: config changes
This commit is contained in:
parent
e24ef3fbbd
commit
e87d101217
12 changed files with 129 additions and 159 deletions
|
|
@ -1,9 +1,9 @@
|
|||
use crate::{
|
||||
utils::{Activate, WorkspaceEvent},
|
||||
utils::WorkspaceEvent,
|
||||
wayland_source::WaylandSource,
|
||||
};
|
||||
use calloop::channel::*;
|
||||
use cosmic_panel_config::CosmicPanelConfig;
|
||||
use cosmic_panel_config::CosmicPanelOuput;
|
||||
use cosmic_protocols::workspace::v1::client::{
|
||||
zcosmic_workspace_group_handle_v1::{self, ZcosmicWorkspaceGroupHandleV1},
|
||||
zcosmic_workspace_handle_v1::{self, ZcosmicWorkspaceHandleV1},
|
||||
|
|
@ -11,18 +11,15 @@ use cosmic_protocols::workspace::v1::client::{
|
|||
};
|
||||
use gtk4::glib;
|
||||
use std::{
|
||||
collections::HashMap, env, hash::Hash, mem, os::unix::net::UnixStream, path::PathBuf,
|
||||
sync::Arc, time::Duration,
|
||||
env, os::unix::net::UnixStream, path::PathBuf, time::Duration,
|
||||
};
|
||||
use tokio::sync::mpsc;
|
||||
use wayland_backend::client::ObjectData;
|
||||
use wayland_client::{
|
||||
event_created_child,
|
||||
protocol::{
|
||||
wl_output::{self, WlOutput},
|
||||
wl_registry,
|
||||
},
|
||||
ConnectError, Proxy,
|
||||
ConnectError,
|
||||
};
|
||||
use wayland_client::{Connection, Dispatch, QueueHandle};
|
||||
|
||||
|
|
@ -42,9 +39,12 @@ pub fn spawn_workspaces(tx: glib::Sender<State>) -> SyncSender<WorkspaceEvent> {
|
|||
.and_then(|s| s.map(|s| Connection::from_socket(s).map_err(anyhow::Error::msg)))
|
||||
{
|
||||
std::thread::spawn(move || {
|
||||
let output = CosmicPanelConfig::load_from_env()
|
||||
.unwrap_or_default()
|
||||
.output;
|
||||
let output = std::env::var("COSMIC_PANEL_OUTPUT").ok().and_then(|size| match size.parse::<CosmicPanelOuput>() {
|
||||
Ok(CosmicPanelOuput::Name(n)) => Some(n),
|
||||
// TODO handle Active & panic if the space is still configured for All instead of being assigned a named output
|
||||
_ => Some("".to_string()),
|
||||
}).unwrap_or_default();
|
||||
|
||||
let mut event_loop = calloop::EventLoop::<State>::try_new().unwrap();
|
||||
let loop_handle = event_loop.handle();
|
||||
let event_queue = conn.new_event_queue::<State>();
|
||||
|
|
|
|||
|
|
@ -34,9 +34,8 @@ impl CosmicWorkspacesWindow {
|
|||
..set_title(Some(&fl!("cosmic-applet-workspaces")));
|
||||
..add_css_class("transparent");
|
||||
};
|
||||
let config = CosmicPanelConfig::load_from_env().unwrap_or_default();
|
||||
|
||||
let app_list = WorkspaceList::new(config);
|
||||
let app_list = WorkspaceList::new();
|
||||
self_.set_child(Some(&app_list));
|
||||
imp.inner.set(app_list).unwrap();
|
||||
|
||||
|
|
|
|||
|
|
@ -13,7 +13,6 @@ use crate::utils::Activate;
|
|||
pub struct WorkspaceList {
|
||||
pub list_view: OnceCell<ListView>,
|
||||
pub model: OnceCell<gio::ListStore>,
|
||||
pub config: OnceCell<CosmicPanelConfig>,
|
||||
}
|
||||
|
||||
#[glib::object_subclass]
|
||||
|
|
|
|||
|
|
@ -7,15 +7,14 @@ use crate::workspace_button::WorkspaceButton;
|
|||
use crate::workspace_object::WorkspaceObject;
|
||||
use crate::TX;
|
||||
use cascade::cascade;
|
||||
use cosmic_panel_config::CosmicPanelConfig;
|
||||
use cosmic_panel_config::PanelAnchor;
|
||||
use cosmic_panel_config::PanelSize;
|
||||
use gtk4::builders::EventControllerScrollBuilder;
|
||||
use gtk4::EventControllerScrollFlags;
|
||||
use gtk4::Inhibit;
|
||||
use gtk4::ListView;
|
||||
use gtk4::Orientation;
|
||||
use gtk4::SignalListItemFactory;
|
||||
use gtk4::{gio, glib, prelude::*, subclass::prelude::*};
|
||||
use tokio::sync::mpsc::Sender;
|
||||
|
||||
mod imp;
|
||||
|
||||
|
|
@ -26,10 +25,9 @@ glib::wrapper! {
|
|||
}
|
||||
|
||||
impl WorkspaceList {
|
||||
pub fn new(config: CosmicPanelConfig) -> Self {
|
||||
pub fn new() -> Self {
|
||||
let self_: WorkspaceList = glib::Object::new(&[]).expect("Failed to create WorkspaceList");
|
||||
let imp = imp::WorkspaceList::from_instance(&self_);
|
||||
imp.config.set(config).unwrap();
|
||||
self_.layout();
|
||||
//dnd behavior is different for each type, as well as the data in the model
|
||||
self_.setup_model();
|
||||
|
|
@ -45,7 +43,7 @@ impl WorkspaceList {
|
|||
|
||||
fn layout(&self) {
|
||||
let imp = imp::WorkspaceList::from_instance(self);
|
||||
let anchor = imp.config.get().unwrap().anchor;
|
||||
let anchor = std::env::var("COSMIC_PANEL_ANCHOR").ok().and_then(|anchor| anchor.parse::<PanelAnchor>().ok()).unwrap_or_default();
|
||||
|
||||
let list_view = cascade! {
|
||||
ListView::default();
|
||||
|
|
@ -105,7 +103,7 @@ impl WorkspaceList {
|
|||
let imp = imp::WorkspaceList::from_instance(self);
|
||||
let factory = SignalListItemFactory::new();
|
||||
let model = imp.model.get().expect("Failed to get saved app model.");
|
||||
let icon_size = imp.config.get().unwrap().get_applet_icon_size();
|
||||
|
||||
factory.connect_setup(glib::clone!(@weak model => move |_, list_item| {
|
||||
let workspace_button = WorkspaceButton::new();
|
||||
list_item.set_child(Some(&workspace_button));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue