chore: update libcosmic
This commit is contained in:
parent
c71420ccf9
commit
0ab6f724fb
9 changed files with 613 additions and 575 deletions
842
Cargo.lock
generated
842
Cargo.lock
generated
File diff suppressed because it is too large
Load diff
11
Cargo.toml
11
Cargo.toml
|
|
@ -44,10 +44,13 @@ tracing-log = "0.2.0"
|
|||
lto = "thin"
|
||||
# lto = "fat"
|
||||
|
||||
# [patch."https://github.com/pop-os/cosmic-time"]
|
||||
[patch."https://github.com/pop-os/cosmic-time"]
|
||||
cosmic-time = { git = "https://github.com/pop-os/cosmic-time//", branch = "wip-iced-update" }
|
||||
# cosmic-time = { path = "../cosmic-time" }
|
||||
# [patch."https://github.com/pop-os/libcosmic"]
|
||||
# libcosmic = { git = "https://github.com/pop-os/libcosmic//", branch = "refactor-config-watch" }
|
||||
# cosmic-config = { git = "https://github.com/pop-os/libcosmic//", branch = "refactor-config-watch" }
|
||||
[patch."https://github.com/pop-os/libcosmic"]
|
||||
libcosmic = { git = "https://github.com/pop-os/libcosmic//", branch = "update-iced-latest" }
|
||||
cosmic-config = { git = "https://github.com/pop-os/libcosmic//", branch = "update-iced-latest" }
|
||||
# libcosmic = { path = "../libcosmic"}
|
||||
# cosmic-config = { path = "../libcosmic/cosmic-config"}
|
||||
[patch."https://github.com/Smithay/client-toolkit"]
|
||||
sctk = { git = "https://github.com/smithay/client-toolkit//", package = "smithay-client-toolkit", rev = "e63ab5f" }
|
||||
|
|
|
|||
|
|
@ -25,7 +25,10 @@ use cosmic::iced::widget::vertical_space;
|
|||
use cosmic::iced::widget::{column, dnd_source, mouse_area, row, Column, Row};
|
||||
use cosmic::iced::Color;
|
||||
use cosmic::iced::{window, Subscription};
|
||||
use cosmic::iced_core::window::Icon;
|
||||
use cosmic::iced_core::Border;
|
||||
use cosmic::iced_core::Padding;
|
||||
use cosmic::iced_core::Shadow;
|
||||
use cosmic::iced_runtime::core::alignment::Horizontal;
|
||||
use cosmic::iced_runtime::core::event;
|
||||
use cosmic::iced_sctk::commands::data_device::accept_mime_type;
|
||||
|
|
@ -132,9 +135,12 @@ impl DockItem {
|
|||
background: Some(Background::Color(
|
||||
theme.cosmic().on_bg_color().into(),
|
||||
)),
|
||||
border_radius: 4.0.into(),
|
||||
border_width: 0.0,
|
||||
border_color: Color::TRANSPARENT,
|
||||
border: Border {
|
||||
radius: 4.0.into(),
|
||||
width: 0.0,
|
||||
color: Color::TRANSPARENT,
|
||||
},
|
||||
shadow: Shadow::default(),
|
||||
icon_color: Some(Color::TRANSPARENT),
|
||||
},
|
||||
)))
|
||||
|
|
|
|||
|
|
@ -778,7 +778,7 @@ fn revealer(
|
|||
options: Vec<(String, String)>,
|
||||
toggle: Message,
|
||||
mut change: impl FnMut(String) -> Message + 'static,
|
||||
) -> widget::Column<'static, Message, Renderer> {
|
||||
) -> widget::Column<'static, Message, crate::Theme, Renderer> {
|
||||
if open {
|
||||
options.iter().fold(
|
||||
column![revealer_head(open, title, selected, toggle)].width(Length::Fill),
|
||||
|
|
|
|||
|
|
@ -353,7 +353,7 @@ impl cosmic::Application for Window {
|
|||
fn button_icon<'a>(
|
||||
cur_mode: Option<GraphicsMode>,
|
||||
button_mode: Graphics,
|
||||
) -> Container<'a, Message, cosmic::Renderer> {
|
||||
) -> Container<'a, Message, cosmic::Theme, cosmic::Renderer> {
|
||||
match cur_mode {
|
||||
Some(GraphicsMode::Selected { prev: _, new }) if new == button_mode => {
|
||||
cosmic::widget::container(
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ use cosmic::iced::event::{listen_with, PlatformSpecific};
|
|||
use cosmic::iced::time;
|
||||
use cosmic::iced::wayland::actions::layer_surface::SctkLayerSurfaceSettings;
|
||||
use cosmic::iced::wayland::popup::{destroy_popup, get_popup};
|
||||
use cosmic::iced_core::{Border, Shadow};
|
||||
use cosmic::iced_runtime::core::layout::Limits;
|
||||
use cosmic::iced_sctk::commands::layer_surface::{
|
||||
destroy_layer_surface, get_layer_surface, Anchor, KeyboardInteractivity,
|
||||
|
|
@ -323,9 +324,12 @@ impl cosmic::Application for Power {
|
|||
background: Some(
|
||||
Color::from(theme.cosmic().background.base).into(),
|
||||
),
|
||||
border_radius: 12.0.into(),
|
||||
border_width: 2.0,
|
||||
border_color: theme.cosmic().bg_divider().into(),
|
||||
border: Border {
|
||||
radius: 12.0.into(),
|
||||
width: 2.0,
|
||||
color: theme.cosmic().bg_divider().into(),
|
||||
},
|
||||
shadow: Shadow::default(),
|
||||
}
|
||||
}))
|
||||
.width(Length::Shrink)
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ use cosmic::{
|
|||
},
|
||||
window, Subscription,
|
||||
},
|
||||
iced_style::application,
|
||||
iced_style::{application, menu},
|
||||
Theme,
|
||||
};
|
||||
use std::collections::BTreeMap;
|
||||
|
|
@ -173,18 +173,13 @@ impl cosmic::Application for App {
|
|||
|
||||
fn view(&self) -> cosmic::Element<'_, Msg> {
|
||||
// XXX connect open event
|
||||
iced::widget::row(
|
||||
self.menus
|
||||
.iter()
|
||||
.map(|(id, menu)| {
|
||||
self.core
|
||||
.applet
|
||||
.icon_button(menu.icon_name())
|
||||
.on_press(Msg::TogglePopup(*id))
|
||||
.into()
|
||||
})
|
||||
.collect(),
|
||||
)
|
||||
iced::widget::row(self.menus.iter().map(|(id, menu)| {
|
||||
self.core
|
||||
.applet
|
||||
.icon_button(menu.icon_name())
|
||||
.on_press(Msg::TogglePopup(*id))
|
||||
.into()
|
||||
}))
|
||||
.into()
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -79,84 +79,76 @@ impl State {
|
|||
}
|
||||
|
||||
fn layout_view(layout: &Layout, expanded: Option<i32>) -> cosmic::Element<Msg> {
|
||||
iced::widget::column(
|
||||
layout
|
||||
.children()
|
||||
.iter()
|
||||
.filter_map(|i| {
|
||||
if !i.visible() {
|
||||
None
|
||||
} else if i.type_() == Some("separator") {
|
||||
Some(iced::widget::horizontal_rule(2).into())
|
||||
} else if let Some(label) = i.label() {
|
||||
// Strip _ when not doubled
|
||||
// TODO: interpret as "access key"? And label with underline.
|
||||
let mut is_underscore = false;
|
||||
let label = label
|
||||
.chars()
|
||||
.filter(|c| {
|
||||
let prev_is_underscore = is_underscore;
|
||||
is_underscore = !is_underscore && *c == '_';
|
||||
*c != '_' || prev_is_underscore
|
||||
})
|
||||
.collect::<String>();
|
||||
iced::widget::column(layout.children().iter().filter_map(|i| {
|
||||
if !i.visible() {
|
||||
None
|
||||
} else if i.type_() == Some("separator") {
|
||||
Some(iced::widget::horizontal_rule(2).into())
|
||||
} else if let Some(label) = i.label() {
|
||||
// Strip _ when not doubled
|
||||
// TODO: interpret as "access key"? And label with underline.
|
||||
let mut is_underscore = false;
|
||||
let label = label
|
||||
.chars()
|
||||
.filter(|c| {
|
||||
let prev_is_underscore = is_underscore;
|
||||
is_underscore = !is_underscore && *c == '_';
|
||||
*c != '_' || prev_is_underscore
|
||||
})
|
||||
.collect::<String>();
|
||||
|
||||
let is_submenu = i.children_display() == Some("submenu");
|
||||
let is_expanded = expanded == Some(i.id());
|
||||
let is_submenu = i.children_display() == Some("submenu");
|
||||
let is_expanded = expanded == Some(i.id());
|
||||
|
||||
let text = iced::widget::text(label).width(iced::Length::Fill);
|
||||
let text = iced::widget::text(label).width(iced::Length::Fill);
|
||||
|
||||
let mut children: Vec<cosmic::Element<_>> = vec![text.into()];
|
||||
if is_submenu {
|
||||
let icon = cosmic::widget::icon::from_name(if is_expanded {
|
||||
"go-down-symbolic"
|
||||
} else {
|
||||
"go-next-symbolic"
|
||||
})
|
||||
.size(14)
|
||||
.symbolic(true);
|
||||
children.push(icon.into());
|
||||
}
|
||||
if let Some(icon_data) = i.icon_data() {
|
||||
let handle = iced::widget::image::Handle::from_memory(icon_data.to_vec());
|
||||
children.insert(0, iced::widget::Image::new(handle).into());
|
||||
} else if let Some(icon_name) = i.icon_name() {
|
||||
let icon = cosmic::widget::icon::from_name(icon_name)
|
||||
.size(14)
|
||||
.symbolic(true);
|
||||
children.insert(0, icon.into());
|
||||
}
|
||||
if i.toggle_state() == Some(1) {
|
||||
let icon = cosmic::widget::icon::from_name("emblem-ok-symbolic")
|
||||
.size(14)
|
||||
.symbolic(true);
|
||||
children.push(icon.into());
|
||||
}
|
||||
let button = row_button(children).on_press(Msg::Click(i.id(), is_submenu));
|
||||
|
||||
if is_submenu && is_expanded {
|
||||
Some(
|
||||
iced::widget::column![
|
||||
button,
|
||||
// XXX nested
|
||||
iced::widget::container(layout_view(i, None)).padding(
|
||||
iced::Padding {
|
||||
left: 12.,
|
||||
..iced::Padding::ZERO
|
||||
}
|
||||
)
|
||||
]
|
||||
.into(),
|
||||
)
|
||||
} else {
|
||||
Some(button.into())
|
||||
}
|
||||
let mut children: Vec<cosmic::Element<_>> = vec![text.into()];
|
||||
if is_submenu {
|
||||
let icon = cosmic::widget::icon::from_name(if is_expanded {
|
||||
"go-down-symbolic"
|
||||
} else {
|
||||
None
|
||||
}
|
||||
})
|
||||
.collect(),
|
||||
)
|
||||
"go-next-symbolic"
|
||||
})
|
||||
.size(14)
|
||||
.symbolic(true);
|
||||
children.push(icon.into());
|
||||
}
|
||||
if let Some(icon_data) = i.icon_data() {
|
||||
let handle = iced::widget::image::Handle::from_memory(icon_data.to_vec());
|
||||
children.insert(0, iced::widget::Image::new(handle).into());
|
||||
} else if let Some(icon_name) = i.icon_name() {
|
||||
let icon = cosmic::widget::icon::from_name(icon_name)
|
||||
.size(14)
|
||||
.symbolic(true);
|
||||
children.insert(0, icon.into());
|
||||
}
|
||||
if i.toggle_state() == Some(1) {
|
||||
let icon = cosmic::widget::icon::from_name("emblem-ok-symbolic")
|
||||
.size(14)
|
||||
.symbolic(true);
|
||||
children.push(icon.into());
|
||||
}
|
||||
let button = row_button(children).on_press(Msg::Click(i.id(), is_submenu));
|
||||
|
||||
if is_submenu && is_expanded {
|
||||
Some(
|
||||
iced::widget::column![
|
||||
button,
|
||||
// XXX nested
|
||||
iced::widget::container(layout_view(i, None)).padding(iced::Padding {
|
||||
left: 12.,
|
||||
..iced::Padding::ZERO
|
||||
})
|
||||
]
|
||||
.into(),
|
||||
)
|
||||
} else {
|
||||
Some(button.into())
|
||||
}
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}))
|
||||
.into()
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ use cosmic::iced::event;
|
|||
use cosmic::iced::mouse::{self, ScrollDelta};
|
||||
use cosmic::iced::widget::{button, column, container, row, text};
|
||||
use cosmic::iced::{Event::Mouse, Length, Subscription};
|
||||
use cosmic::iced_core::Background;
|
||||
use cosmic::iced_core::{Background, Border};
|
||||
use cosmic::iced_style::application;
|
||||
use cosmic::{applet::cosmic_panel_config::PanelAnchor, font::FONT_BOLD, Command};
|
||||
use cosmic::{Element, Theme};
|
||||
|
|
@ -121,83 +121,101 @@ impl cosmic::Application for IcedWorkspacesApplet {
|
|||
if self.workspaces.is_empty() {
|
||||
return row![].padding(8).into();
|
||||
}
|
||||
let buttons = self
|
||||
.workspaces
|
||||
.iter()
|
||||
.filter_map(|w| {
|
||||
let btn = button(
|
||||
text(w.0.clone())
|
||||
.font(FONT_BOLD)
|
||||
.size(16)
|
||||
.horizontal_alignment(Horizontal::Center)
|
||||
.vertical_alignment(Vertical::Center)
|
||||
.width(Length::Fill)
|
||||
.height(Length::Fill),
|
||||
)
|
||||
.width(Length::Fixed(
|
||||
self.core.applet.suggested_size().0 as f32
|
||||
+ match self.layout {
|
||||
Layout::Row => 20.0,
|
||||
Layout::Column => 16.0,
|
||||
},
|
||||
))
|
||||
.height(Length::Fixed(
|
||||
self.core.applet.suggested_size().0 as f32
|
||||
+ match self.layout {
|
||||
Layout::Row => 16.0,
|
||||
Layout::Column => 20.0,
|
||||
},
|
||||
))
|
||||
.on_press(Message::WorkspacePressed(w.2.clone()))
|
||||
.padding(0);
|
||||
let buttons = self.workspaces.iter().filter_map(|w| {
|
||||
let btn = button(
|
||||
text(w.0.clone())
|
||||
.font(FONT_BOLD)
|
||||
.size(16)
|
||||
.horizontal_alignment(Horizontal::Center)
|
||||
.vertical_alignment(Vertical::Center)
|
||||
.width(Length::Fill)
|
||||
.height(Length::Fill),
|
||||
)
|
||||
.width(Length::Fixed(
|
||||
self.core.applet.suggested_size().0 as f32
|
||||
+ match self.layout {
|
||||
Layout::Row => 20.0,
|
||||
Layout::Column => 16.0,
|
||||
},
|
||||
))
|
||||
.height(Length::Fixed(
|
||||
self.core.applet.suggested_size().0 as f32
|
||||
+ match self.layout {
|
||||
Layout::Row => 16.0,
|
||||
Layout::Column => 20.0,
|
||||
},
|
||||
))
|
||||
.on_press(Message::WorkspacePressed(w.2.clone()))
|
||||
.padding(0);
|
||||
|
||||
Some(
|
||||
btn.style(match w.1 {
|
||||
Some(zcosmic_workspace_handle_v1::State::Active) => {
|
||||
cosmic::theme::iced::Button::Primary
|
||||
}
|
||||
Some(zcosmic_workspace_handle_v1::State::Urgent) => {
|
||||
let appearance = |theme: &Theme| button::Appearance {
|
||||
Some(
|
||||
btn.style(match w.1 {
|
||||
Some(zcosmic_workspace_handle_v1::State::Active) => {
|
||||
cosmic::theme::iced::Button::Primary
|
||||
}
|
||||
Some(zcosmic_workspace_handle_v1::State::Urgent) => {
|
||||
let appearance = |theme: &Theme| {
|
||||
let cosmic = theme.cosmic();
|
||||
button::Appearance {
|
||||
background: Some(Background::Color(
|
||||
theme.cosmic().palette.neutral_3.into(),
|
||||
cosmic.palette.neutral_3.into(),
|
||||
)),
|
||||
border: Border {
|
||||
radius: cosmic.radius_xl().into(),
|
||||
..Default::default()
|
||||
},
|
||||
border_radius: theme.cosmic().radius_xl().into(),
|
||||
text_color: theme.cosmic().destructive_button.base.into(),
|
||||
..button::Appearance::default()
|
||||
};
|
||||
cosmic::theme::iced::Button::Custom {
|
||||
active: Box::new(appearance),
|
||||
hover: Box::new(move |theme| button::Appearance {
|
||||
background: Some(Background::Color(
|
||||
theme.current_container().component.hover.into(),
|
||||
)),
|
||||
..appearance(theme)
|
||||
}),
|
||||
}
|
||||
};
|
||||
cosmic::theme::iced::Button::Custom {
|
||||
active: Box::new(appearance),
|
||||
hover: Box::new(move |theme| button::Appearance {
|
||||
background: Some(Background::Color(
|
||||
theme.current_container().component.hover.into(),
|
||||
)),
|
||||
border: Border {
|
||||
radius: theme.cosmic().radius_xl().into(),
|
||||
..Default::default()
|
||||
},
|
||||
..appearance(theme)
|
||||
}),
|
||||
}
|
||||
None => {
|
||||
let appearance = |theme: &Theme| button::Appearance {
|
||||
}
|
||||
None => {
|
||||
let appearance = |theme: &Theme| {
|
||||
let cosmic = theme.cosmic();
|
||||
button::Appearance {
|
||||
background: None,
|
||||
border_radius: theme.cosmic().radius_xl().into(),
|
||||
border: Border {
|
||||
radius: cosmic.radius_xl().into(),
|
||||
..Default::default()
|
||||
},
|
||||
border_radius: cosmic.radius_xl().into(),
|
||||
text_color: theme.current_container().component.on.into(),
|
||||
..button::Appearance::default()
|
||||
};
|
||||
cosmic::theme::iced::Button::Custom {
|
||||
active: Box::new(appearance),
|
||||
hover: Box::new(move |theme| button::Appearance {
|
||||
background: Some(Background::Color(
|
||||
theme.current_container().component.hover.into(),
|
||||
)),
|
||||
..appearance(theme)
|
||||
}),
|
||||
}
|
||||
};
|
||||
cosmic::theme::iced::Button::Custom {
|
||||
active: Box::new(appearance),
|
||||
hover: Box::new(move |theme| button::Appearance {
|
||||
background: Some(Background::Color(
|
||||
theme.current_container().component.hover.into(),
|
||||
)),
|
||||
border: Border {
|
||||
radius: theme.cosmic().radius_xl().into(),
|
||||
..Default::default()
|
||||
},
|
||||
..appearance(theme)
|
||||
}),
|
||||
}
|
||||
_ => return None,
|
||||
})
|
||||
.into(),
|
||||
)
|
||||
})
|
||||
.collect();
|
||||
}
|
||||
_ => return None,
|
||||
})
|
||||
.into(),
|
||||
)
|
||||
});
|
||||
let layout_section: Element<_> = match self.layout {
|
||||
Layout::Row => row(buttons)
|
||||
.width(Length::Shrink)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue