fix: padding, spacing, context menu style, and settings buttons

This commit is contained in:
Vukašin Vojinović 2024-09-24 15:52:17 +02:00 committed by GitHub
parent 0a32d27c70
commit 941cbf546b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
38 changed files with 694 additions and 538 deletions

View file

@ -7,8 +7,9 @@ use crate::{
use cctk::sctk::reexports::calloop::channel::SyncSender;
use cosmic::{
app::Core,
applet::padded_control,
applet::{menu_button, padded_control},
cosmic_config::{Config, ConfigSet, CosmicConfigEntry},
cosmic_theme::Spacing,
iced::{
wayland::popup::{destroy_popup, get_popup},
window::Id,
@ -16,9 +17,10 @@ use cosmic::{
},
iced_style::application,
iced_widget::{column, row},
theme,
widget::{
container, divider, segmented_button,
segmented_button::{Entity, SingleSelectModel},
container, divider,
segmented_button::{self, Entity, SingleSelectModel},
segmented_control, spin_button, text,
},
Element, Theme,
@ -58,6 +60,7 @@ pub enum Message {
MyConfigUpdate(Box<CosmicCompConfig>),
WorkspaceUpdate(WorkspacesUpdate),
NewWorkspace(Entity),
OpenSettings,
}
impl cosmic::Application for Window {
@ -267,6 +270,11 @@ impl cosmic::Application for Window {
}
});
}
Message::OpenSettings => {
let mut cmd = std::process::Command::new("cosmic-settings");
cmd.arg("window-management");
tokio::spawn(cosmic::process::spawn(cmd));
}
}
Command::none()
}
@ -280,6 +288,13 @@ impl cosmic::Application for Window {
}
fn view_window(&self, _id: Id) -> Element<Self::Message> {
let Spacing {
space_xxxs,
space_xxs,
space_s,
..
} = theme::active().cosmic().spacing;
let new_workspace_behavior_button =
segmented_control::horizontal(&self.new_workspace_behavior_model)
.on_activate(Message::NewWorkspace);
@ -296,12 +311,15 @@ impl cosmic::Application for Window {
.width(Length::Fill),
))
.width(Length::Fill),
padded_control(divider::horizontal::default(),),
padded_control(column![
text::body(fl!("new-workspace")),
new_workspace_behavior_button,
]),
padded_control(divider::horizontal::default()),
padded_control(divider::horizontal::default()).padding([space_xxs, space_s]),
padded_control(
column![
text::body(fl!("new-workspace")),
new_workspace_behavior_button,
]
.spacing(space_xxxs)
),
padded_control(divider::horizontal::default()).padding([space_xxs, space_s]),
padded_control(row!(
text::body(fl!("navigate-windows")).width(Length::Fill),
text::body(format!("{} + {}", fl!("super"), fl!("arrow-keys"))),
@ -319,7 +337,7 @@ impl cosmic::Application for Window {
text::body(fl!("toggle-floating-window")).width(Length::Fill),
text::body(format!("{} + G", fl!("super"))),
)),
padded_control(divider::horizontal::default()),
padded_control(divider::horizontal::default()).padding([space_xxs, space_s]),
padded_control(
anim!(
self.active_hint,
@ -331,6 +349,9 @@ impl cosmic::Application for Window {
.text_size(14)
.width(Length::Fill),
),
padded_control(divider::horizontal::default()).padding([space_xxs, space_s]),
menu_button(text::body(fl!("window-management-settings")))
.on_press(Message::OpenSettings)
]
.padding([8, 0]);