panel config fixes
This commit is contained in:
parent
df6c2e5f02
commit
2001c960ad
11 changed files with 265 additions and 125 deletions
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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>,
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ pub mod graphics;
|
|||
pub mod mode_box;
|
||||
|
||||
use self::{dbus::PowerDaemonProxy, graphics::Graphics, mode_box::ModeSelection};
|
||||
use cosmic_panel_config::config::{CosmicPanelConfig, XdgWrapperConfig};
|
||||
use cosmic_panel_config::config::{CosmicPanelConfig};
|
||||
use gtk4::{
|
||||
gdk::Display,
|
||||
gio::ApplicationFlags,
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ extern crate relm4_macros;
|
|||
pub mod session_manager;
|
||||
pub mod ui;
|
||||
|
||||
use cosmic_panel_config::config::{CosmicPanelConfig, XdgWrapperConfig};
|
||||
use cosmic_panel_config::config::{CosmicPanelConfig};
|
||||
use gtk4::{gio::ApplicationFlags, glib, prelude::*, Align, Button, Label, Orientation, Separator};
|
||||
use once_cell::sync::Lazy;
|
||||
use std::process::Command;
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ impl CosmicWorkspacesWindow {
|
|||
..set_title(Some(&fl!("cosmic-applet-workspaces")));
|
||||
..add_css_class("transparent");
|
||||
};
|
||||
let config = CosmicPanelConfig::load_from_env().unwrap_or_default();
|
||||
let config = CosmicPanelConfig::load_from_env().unwrap();
|
||||
|
||||
let app_list = WorkspaceList::new(config);
|
||||
self_.set_child(Some(&app_list));
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ use crate::wayland::State;
|
|||
use crate::workspace_button::WorkspaceButton;
|
||||
use crate::workspace_object::WorkspaceObject;
|
||||
use cascade::cascade;
|
||||
use cosmic_panel_config::config::{CosmicPanelConfig, XdgWrapperConfig};
|
||||
use cosmic_panel_config::config::{CosmicPanelConfig};
|
||||
use gtk4::ListView;
|
||||
use gtk4::Orientation;
|
||||
use gtk4::SignalListItemFactory;
|
||||
|
|
@ -40,9 +40,11 @@ impl WorkspaceList {
|
|||
|
||||
fn layout(&self) {
|
||||
let imp = imp::WorkspaceList::from_instance(self);
|
||||
let anchor = imp.config.get().unwrap().anchor;
|
||||
|
||||
let list_view = cascade! {
|
||||
ListView::default();
|
||||
..set_orientation(Orientation::Horizontal);
|
||||
..set_orientation(anchor.into());
|
||||
..add_css_class("transparent");
|
||||
};
|
||||
self.append(&list_view);
|
||||
|
|
@ -86,7 +88,7 @@ impl WorkspaceList {
|
|||
.item()
|
||||
.expect("The item has to exist.")
|
||||
.downcast::<WorkspaceObject>()
|
||||
.expect("The item has to be a `DockObject`");
|
||||
.expect("The item has to be a `WorkspaceObject`");
|
||||
let workspace_button = list_item
|
||||
.child()
|
||||
.expect("The list item child needs to exist.")
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
use crate::fl;
|
||||
use cascade::cascade;
|
||||
use cosmic_panel_config::config::{CosmicPanelConfig, XdgWrapperConfig};
|
||||
use cosmic_panel_config::config::{CosmicPanelConfig};
|
||||
use gtk4::{
|
||||
gio::{self, DesktopAppInfo, Icon},
|
||||
glib::{self, Object},
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue