panel config fixes

This commit is contained in:
Ashley Wulber 2022-06-17 12:53:26 -04:00
parent df6c2e5f02
commit 2001c960ad
11 changed files with 265 additions and 125 deletions

View file

@ -3,8 +3,8 @@ use crate::dock_list::DockList;
use crate::dock_list::DockListType;
use crate::utils::Event;
use cascade::cascade;
use cosmic_panel_config::config::Anchor;
use cosmic_panel_config::config::CosmicPanelConfig;
use cosmic_panel_config::config::PanelAnchor;
use gtk4::prelude::*;
use gtk4::subclass::prelude::*;
use gtk4::Orientation;
@ -81,7 +81,7 @@ impl AppsContainer {
}
}
pub fn set_position(&self, position: Anchor) {
pub fn set_position(&self, position: PanelAnchor) {
self.set_orientation(position.into());
let imp = imp::AppsContainer::from_instance(self);
imp.saved_list.get().unwrap().set_position(position);

View file

@ -5,7 +5,7 @@ use crate::dock_popover::DockPopover;
use crate::utils::BoxedWindowList;
use crate::utils::Event;
use cascade::cascade;
use cosmic_panel_config::config::{Anchor, XdgWrapperConfig};
use cosmic_panel_config::config::{PanelAnchor};
use gtk4::glib;
use gtk4::prelude::*;
use gtk4::subclass::prelude::*;
@ -131,50 +131,48 @@ impl DockItem {
}
}
pub fn set_position(&self, position: Anchor) {
pub fn set_position(&self, position: PanelAnchor) {
let imp = imp::DockItem::from_instance(self);
let item_box = imp.item_box.borrow();
let dots = imp.dots.borrow();
if let Some(image) = imp.image.borrow().as_ref() {
match position {
Anchor::Left => {
PanelAnchor::Left => {
item_box.set_orientation(Orientation::Horizontal);
dots.set_orientation(Orientation::Vertical);
dots.set_margin_bottom(4);
dots.set_margin_top(4);
item_box.reorder_child_after(&image.clone(), Some(&dots.clone()));
}
Anchor::Right => {
PanelAnchor::Right => {
item_box.set_orientation(Orientation::Horizontal);
dots.set_orientation(Orientation::Vertical);
dots.set_margin_bottom(4);
dots.set_margin_top(4);
item_box.reorder_child_after(&dots.clone(), Some(&image.clone()));
}
Anchor::Top => {
PanelAnchor::Top => {
item_box.set_orientation(Orientation::Vertical);
dots.set_orientation(Orientation::Horizontal);
dots.set_margin_start(4);
dots.set_margin_end(4);
item_box.reorder_child_after(&image.clone(), Some(&dots.clone()));
}
Anchor::Bottom => {
PanelAnchor::Bottom => {
item_box.set_orientation(Orientation::Vertical);
dots.set_orientation(Orientation::Horizontal);
dots.set_margin_start(4);
dots.set_margin_end(4);
item_box.reorder_child_after(&dots.clone(), Some(&image.clone()));
}
Anchor::Center => unimplemented!(),
};
}
let popover = imp.popover.borrow();
popover.set_position(match position {
Anchor::Left => PositionType::Right,
Anchor::Right => PositionType::Left,
Anchor::Top => PositionType::Bottom,
Anchor::Bottom => PositionType::Top,
Anchor::Center => unimplemented!(),
PanelAnchor::Left => PositionType::Right,
PanelAnchor::Right => PositionType::Left,
PanelAnchor::Top => PositionType::Bottom,
PanelAnchor::Bottom => PositionType::Top,
});
}

View file

@ -1,6 +1,6 @@
// SPDX-License-Identifier: MPL-2.0-only
use cosmic_panel_config::config::{Anchor, CosmicPanelConfig};
use cosmic_panel_config::config::{PanelAnchor, CosmicPanelConfig};
use glib::SignalHandlerId;
use gtk4::subclass::prelude::*;
use gtk4::{gio, glib};
@ -23,7 +23,7 @@ pub struct DockList {
pub drag_end_signal: Rc<RefCell<Option<SignalHandlerId>>>,
pub drag_cancel_signal: Rc<RefCell<Option<SignalHandlerId>>>,
pub popover_menu_index: Rc<Cell<Option<u32>>>,
pub position: Rc<Cell<Anchor>>,
pub position: Rc<Cell<PanelAnchor>>,
pub tx: OnceCell<mpsc::Sender<Event>>,
pub config: OnceCell<CosmicPanelConfig>,
}

View file

@ -5,7 +5,7 @@ use crate::dock_object::DockObject;
use crate::utils::data_path;
use crate::utils::{BoxedWindowList, Event, Item};
use cascade::cascade;
use cosmic_panel_config::config::{Anchor, CosmicPanelConfig, XdgWrapperConfig};
use cosmic_panel_config::config::{CosmicPanelConfig, PanelAnchor};
use gio::DesktopAppInfo;
use gio::Icon;
use glib::Object;
@ -174,10 +174,10 @@ impl DockList {
imp.list_view.set(list_view).unwrap();
}
pub fn set_position(&self, position: Anchor) {
pub fn set_position(&self, position: PanelAnchor) {
let imp = imp::DockList::from_instance(self);
let model = imp.model.get().unwrap();
imp.position.replace(position);
model.items_changed(0, model.n_items(), model.n_items());
let imp = imp::DockList::from_instance(self);