feat: config changes
This commit is contained in:
parent
e24ef3fbbd
commit
e87d101217
12 changed files with 129 additions and 159 deletions
|
|
@ -29,9 +29,7 @@ impl AppsContainer {
|
|||
// ..add_css_class("dock_container");
|
||||
};
|
||||
|
||||
let config = CosmicPanelConfig::load_from_env().unwrap_or_default();
|
||||
|
||||
let saved_app_list_view = DockList::new(DockListType::Saved, config.clone());
|
||||
let saved_app_list_view = DockList::new(DockListType::Saved);
|
||||
self_.append(&saved_app_list_view);
|
||||
|
||||
let separator_container = cascade! {
|
||||
|
|
@ -49,21 +47,15 @@ impl AppsContainer {
|
|||
..add_css_class("dock_separator");
|
||||
};
|
||||
separator_container.append(&separator);
|
||||
let active_app_list_view = DockList::new(DockListType::Active, config.clone());
|
||||
let active_app_list_view = DockList::new(DockListType::Active);
|
||||
self_.append(&active_app_list_view);
|
||||
// self_.connect_orientation_notify(glib::clone!(@weak separator => move |c| {
|
||||
// dbg!(c.orientation());
|
||||
// separator.set_orientation(match c.orientation() {
|
||||
// Orientation::Horizontal => Orientation::Vertical,
|
||||
// _ => Orientation::Horizontal,
|
||||
// });
|
||||
// }));
|
||||
|
||||
imp.saved_list.set(saved_app_list_view).unwrap();
|
||||
imp.active_list.set(active_app_list_view).unwrap();
|
||||
// Setup
|
||||
self_.setup_callbacks();
|
||||
self_.set_position(config.anchor);
|
||||
let anchor = std::env::var("COSMIC_PANEL_ANCHOR").ok().and_then(|anchor| anchor.parse::<PanelAnchor>().ok()).unwrap_or_default();
|
||||
self_.set_position(anchor);
|
||||
|
||||
Self::setup_callbacks(&self_);
|
||||
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ use crate::{
|
|||
{TX, WAYLAND_TX},
|
||||
};
|
||||
use cascade::cascade;
|
||||
use cosmic_panel_config::{CosmicPanelConfig, PanelAnchor};
|
||||
use cosmic_panel_config::{CosmicPanelConfig, PanelAnchor, PanelSize};
|
||||
|
||||
use gio::traits::AppLaunchContextExt;
|
||||
use gtk4::{
|
||||
|
|
@ -44,11 +44,10 @@ impl Default for DockListType {
|
|||
}
|
||||
|
||||
impl DockList {
|
||||
pub fn new(type_: DockListType, config: CosmicPanelConfig) -> Self {
|
||||
pub fn new(type_: DockListType) -> Self {
|
||||
let self_: DockList = glib::Object::new(&[]).expect("Failed to create DockList");
|
||||
let imp = imp::DockList::from_instance(&self_);
|
||||
imp.type_.set(type_).unwrap();
|
||||
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();
|
||||
|
|
@ -500,7 +499,16 @@ impl DockList {
|
|||
let popover_menu_index = &imp.popover_menu_index;
|
||||
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();
|
||||
|
||||
let icon_size = std::env::var("COSMIC_PANEL_SIZE").ok().and_then(|size| match size.parse::<PanelSize>() {
|
||||
Ok(PanelSize::XL) => Some(64),
|
||||
Ok(PanelSize::L) => Some(48),
|
||||
Ok(PanelSize::M) => Some(36),
|
||||
Ok(PanelSize::S) => Some(24),
|
||||
Ok(PanelSize::XS) => Some(18),
|
||||
Err(_) => Some(36),
|
||||
}).unwrap_or(36);
|
||||
|
||||
factory.connect_setup(
|
||||
glib::clone!(@weak popover_menu_index, @weak model => move |_, list_item| {
|
||||
let dock_item = DockItem::new(icon_size);
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ use gtk4::gdk::pango::EllipsizeMode;
|
|||
use gtk4::subclass::prelude::*;
|
||||
use gtk4::{gdk, gio, glib};
|
||||
use gtk4::{prelude::*, Label};
|
||||
use gtk4::{Box, Button, Image, ListBox, Orientation};
|
||||
use gtk4::{Box, Button, ListBox, Orientation};
|
||||
|
||||
use crate::dock_object::DockObject;
|
||||
use crate::utils::AppListEvent;
|
||||
|
|
@ -25,7 +25,6 @@ glib::wrapper! {
|
|||
impl DockPopover {
|
||||
pub fn new() -> Self {
|
||||
let self_: DockPopover = glib::Object::new(&[]).expect("Failed to create DockList");
|
||||
let imp = imp::DockPopover::from_instance(&self_);
|
||||
self_.layout();
|
||||
//dnd behavior is different for each type, as well as the data in the model
|
||||
self_
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ use gtk4::gdk::Display;
|
|||
use gtk4::{glib, prelude::*, CssProvider, StyleContext};
|
||||
use once_cell::sync::OnceCell;
|
||||
use std::collections::BTreeMap;
|
||||
use utils::{block_on, AppListEvent, BoxedWindowList, DEST, PATH};
|
||||
use utils::{AppListEvent, BoxedWindowList};
|
||||
use wayland::{Toplevel, ToplevelEvent};
|
||||
|
||||
mod apps_container;
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
use crate::config::AppListConfig;
|
||||
use crate::{config::TopLevelFilter, utils::AppListEvent, wayland_source::WaylandSource, TX};
|
||||
use calloop::channel::*;
|
||||
use cosmic_panel_config::CosmicPanelConfig;
|
||||
use cosmic_panel_config::{CosmicPanelOuput};
|
||||
use cosmic_protocols::{
|
||||
toplevel_info::v1::client::{
|
||||
zcosmic_toplevel_handle_v1::{self, ZcosmicToplevelHandleV1},
|
||||
|
|
@ -52,12 +52,12 @@ pub fn spawn_toplevels() -> SyncSender<ToplevelEvent> {
|
|||
.and_then(|s| s.map(|s| Connection::from_socket(s).map_err(anyhow::Error::msg)))
|
||||
{
|
||||
std::thread::spawn(move || {
|
||||
let output = match config.filter_top_levels {
|
||||
Some(TopLevelFilter::ConfiguredOutput) => {
|
||||
CosmicPanelConfig::load_from_env().ok().map(|c| c.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
|
||||
_ => None,
|
||||
};
|
||||
});
|
||||
|
||||
let mut event_loop = calloop::EventLoop::<State>::try_new().unwrap();
|
||||
let loop_handle = event_loop.handle();
|
||||
let event_queue = conn.new_event_queue::<State>();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue