Update libcosmic/iced

This commit is contained in:
Jeremy Soller 2024-10-22 12:31:02 -06:00
parent 1ed1f418cb
commit 8d4bfb992e
No known key found for this signature in database
GPG key ID: D02FD439211AF56F
5 changed files with 741 additions and 781 deletions

1307
Cargo.lock generated

File diff suppressed because it is too large Load diff

View file

@ -37,7 +37,6 @@ url = "2.5"
[dependencies.cosmic-files] [dependencies.cosmic-files]
git = "https://github.com/pop-os/cosmic-files.git" git = "https://github.com/pop-os/cosmic-files.git"
default-features = false default-features = false
features = ["winit"]
[dependencies.cosmic-text] [dependencies.cosmic-text]
git = "https://github.com/pop-os/cosmic-text.git" git = "https://github.com/pop-os/cosmic-text.git"
@ -63,14 +62,7 @@ wgpu = ["libcosmic/wgpu", "cosmic-files/wgpu"]
inherits = "release" inherits = "release"
debug = true debug = true
[patch.crates-io]
# https://github.com/alexcrichton/filetime/pull/104
filetime = { git = "https://github.com/jackpot51/filetime" }
# [patch.'https://github.com/pop-os/libcosmic'] # [patch.'https://github.com/pop-os/libcosmic']
# libcosmic = { git = "https://github.com/pop-os/libcosmic//", branch = "zbus-4" }
# cosmic-config = { git = "https://github.com/pop-os/libcosmic//", branch = "zbus-4" }
# cosmic-theme = { git = "https://github.com/pop-os/libcosmic//", branch = "zbus-4" }
# libcosmic = { path = "../libcosmic" } # libcosmic = { path = "../libcosmic" }
# cosmic-config = { path = "../libcosmic/cosmic-config" } # cosmic-config = { path = "../libcosmic/cosmic-config" }
# cosmic-theme = { path = "../libcosmic/cosmic-theme" } # cosmic-theme = { path = "../libcosmic/cosmic-theme" }

View file

@ -8,7 +8,7 @@ use cosmic::widget::menu::key_bind::KeyBind;
use cosmic::widget::DndDestination; use cosmic::widget::DndDestination;
use cosmic::Apply; use cosmic::Apply;
use cosmic::{ use cosmic::{
app::{command, message, Command, Core, Settings}, app::{command, message, Core, Settings, Task},
cosmic_config::{self, ConfigSet, CosmicConfigEntry}, cosmic_config::{self, ConfigSet, CosmicConfigEntry},
cosmic_theme, executor, cosmic_theme, executor,
iced::{ iced::{
@ -18,8 +18,7 @@ use cosmic::{
futures::SinkExt, futures::SinkExt,
keyboard::{Event as KeyEvent, Key, Modifiers}, keyboard::{Event as KeyEvent, Key, Modifiers},
mouse::{Button as MouseButton, Event as MouseEvent}, mouse::{Button as MouseButton, Event as MouseEvent},
subscription::{self, Subscription}, stream, window, Alignment, Color, Event, Length, Limits, Padding, Point, Subscription,
window, Alignment, Color, Event, Length, Limits, Padding, Point,
}, },
style, style,
widget::{self, button, pane_grid, segmented_button, PaneGrid}, widget::{self, button, pane_grid, segmented_button, PaneGrid},
@ -33,6 +32,7 @@ use std::{
cmp, cmp,
collections::{BTreeMap, BTreeSet, HashMap}, collections::{BTreeMap, BTreeSet, HashMap},
env, fs, process, env, fs, process,
rc::Rc,
sync::{atomic::Ordering, Mutex}, sync::{atomic::Ordering, Mutex},
}; };
use tokio::sync::mpsc; use tokio::sync::mpsc;
@ -490,7 +490,7 @@ impl App {
} }
} }
fn update_config(&mut self) -> Command<Message> { fn update_config(&mut self) -> Task<Message> {
let theme = self.config.app_theme.theme(); let theme = self.config.app_theme.theme();
// Update color schemes // Update color schemes
@ -524,7 +524,7 @@ impl App {
cosmic::app::command::set_theme(theme) cosmic::app::command::set_theme(theme)
} }
fn update_render_active_pane_zoom(&mut self, zoom_message: Message) -> Command<Message> { fn update_render_active_pane_zoom(&mut self, zoom_message: Message) -> Task<Message> {
// skip writing config to fs when zoom in/ out // skip writing config to fs when zoom in/ out
// recalculate the pane due to the changes of zoom_adj value // recalculate the pane due to the changes of zoom_adj value
// but only for the active pane/tab // but only for the active pane/tab
@ -548,10 +548,10 @@ impl App {
} }
} }
} }
Command::none() Task::none()
} }
fn save_color_schemes(&mut self, color_scheme_kind: ColorSchemeKind) -> Command<Message> { fn save_color_schemes(&mut self, color_scheme_kind: ColorSchemeKind) -> Task<Message> {
// Optimized for just saving color_schemes // Optimized for just saving color_schemes
if let Some(ref config_handler) = self.config_handler { if let Some(ref config_handler) = self.config_handler {
if let Err(err) = config_handler.set( if let Err(err) = config_handler.set(
@ -565,10 +565,10 @@ impl App {
} }
} }
self.update_color_schemes(); self.update_color_schemes();
Command::none() Task::none()
} }
fn save_profiles(&mut self) -> Command<Message> { fn save_profiles(&mut self) -> Task<Message> {
// Optimized for just saving profiles // Optimized for just saving profiles
if let Some(ref config_handler) = self.config_handler { if let Some(ref config_handler) = self.config_handler {
match config_handler.set("profiles", &self.config.profiles) { match config_handler.set("profiles", &self.config.profiles) {
@ -578,21 +578,21 @@ impl App {
} }
} }
} }
Command::none() Task::none()
} }
fn update_focus(&self) -> Command<Message> { fn update_focus(&self) -> Task<Message> {
if self.find { if self.find {
widget::text_input::focus(self.find_search_id.clone()) widget::text_input::focus(self.find_search_id.clone())
} else if let Some(terminal_id) = self.terminal_ids.get(&self.pane_model.focus).cloned() { } else if let Some(terminal_id) = self.terminal_ids.get(&self.pane_model.focus).cloned() {
widget::text_input::focus(terminal_id) widget::text_input::focus(terminal_id)
} else { } else {
Command::none() Task::none()
} }
} }
// Call this any time the tab changes // Call this any time the tab changes
fn update_title(&mut self, pane: Option<pane_grid::Pane>) -> Command<Message> { fn update_title(&mut self, pane: Option<pane_grid::Pane>) -> Task<Message> {
let pane = pane.unwrap_or(self.pane_model.focus); let pane = pane.unwrap_or(self.pane_model.focus);
if let Some(tab_model) = self.pane_model.panes.get(pane) { if let Some(tab_model) = self.pane_model.panes.get(pane) {
let (header_title, window_title) = match tab_model.text(tab_model.active()) { let (header_title, window_title) = match tab_model.text(tab_model.active()) {
@ -603,14 +603,22 @@ impl App {
None => (String::new(), fl!("cosmic-terminal")), None => (String::new(), fl!("cosmic-terminal")),
}; };
self.set_header_title(header_title); self.set_header_title(header_title);
Command::batch([ Task::batch([
self.set_window_title(window_title, window::Id::MAIN), if let Some(window_id) = self.core.main_window_id() {
self.set_window_title(window_title, window_id)
} else {
Task::none()
},
self.update_focus(), self.update_focus(),
]) ])
} else { } else {
log::error!("Failed to get the specific pane"); log::error!("Failed to get the specific pane");
Command::batch([ Task::batch([
self.set_window_title(fl!("cosmic-terminal"), window::Id::MAIN), if let Some(window_id) = self.core.main_window_id() {
self.set_window_title(fl!("cosmic-terminal"), window_id)
} else {
Task::none()
},
self.update_focus(), self.update_focus(),
]) ])
} }
@ -720,7 +728,7 @@ impl App {
.padding(0) .padding(0)
.into(), .into(),
]) ])
.align_items(Alignment::Center) .align_x(Alignment::Center)
.spacing(space_xxs) .spacing(space_xxs)
.into() .into()
} }
@ -736,7 +744,7 @@ impl App {
.into(), .into(),
); );
let mut section = widget::settings::view_section(""); let mut section = widget::settings::section();
let builtin_name = format!("COSMIC {:?}", color_scheme_kind); let builtin_name = format!("COSMIC {:?}", color_scheme_kind);
let color_scheme_names = self.config.color_scheme_names(color_scheme_kind); let color_scheme_names = self.config.color_scheme_names(color_scheme_kind);
for (color_scheme_name, color_scheme_id_opt) in std::iter::once((builtin_name, None)).chain( for (color_scheme_name, color_scheme_id_opt) in std::iter::once((builtin_name, None)).chain(
@ -763,7 +771,7 @@ impl App {
Message::ColorSchemeExpand(color_scheme_kind, color_scheme_id_opt), Message::ColorSchemeExpand(color_scheme_kind, color_scheme_id_opt),
) )
} }
.style(style::Button::Icon); .class(style::Button::Icon);
let mut popover = widget::popover(button); let mut popover = widget::popover(button);
if expanded { if expanded {
@ -800,7 +808,7 @@ impl App {
sections.push( sections.push(
widget::row::with_children(vec![ widget::row::with_children(vec![
widget::horizontal_space(Length::Fill).into(), widget::horizontal_space().into(),
widget::button::standard(fl!("import")) widget::button::standard(fl!("import"))
.on_press(Message::ColorSchemeImport(color_scheme_kind)) .on_press(Message::ColorSchemeImport(color_scheme_kind))
.into(), .into(),
@ -812,18 +820,18 @@ impl App {
sections.push( sections.push(
widget::row::with_children(vec![ widget::row::with_children(vec![
icon_cache_get("dialog-error-symbolic", 16) icon_cache_get("dialog-error-symbolic", 16)
.style(style::Svg::custom(|theme| { .class(style::Svg::Custom(Rc::new(|theme| {
let cosmic = theme.cosmic(); let cosmic = theme.cosmic();
widget::svg::Appearance { widget::svg::Style {
color: Some(cosmic.destructive_text_color().into()), color: Some(cosmic.destructive_text_color().into()),
} }
})) })))
.into(), .into(),
widget::text(error) widget::text::body(error)
.style(style::Text::Custom(|theme| { .class(style::Text::Custom(|theme| {
let cosmic = theme.cosmic(); let cosmic = theme.cosmic();
//TODO: re-export in libcosmic //TODO: re-export in libcosmic
iced::widget::text::Appearance { iced::widget::text::Style {
color: Some(cosmic.destructive_text_color().into()), color: Some(cosmic.destructive_text_color().into()),
} }
})) }))
@ -849,7 +857,7 @@ impl App {
let mut sections = Vec::with_capacity(2); let mut sections = Vec::with_capacity(2);
if !self.config.profiles.is_empty() { if !self.config.profiles.is_empty() {
let mut profiles_section = widget::settings::view_section(""); let mut profiles_section = widget::settings::section();
for (profile_name, profile_id) in self.config.profile_names() { for (profile_name, profile_id) in self.config.profile_names() {
let Some(profile) = self.config.profiles.get(&profile_id) else { let Some(profile) = self.config.profiles.get(&profile_id) else {
continue; continue;
@ -862,7 +870,7 @@ impl App {
widget::row::with_children(vec![ widget::row::with_children(vec![
widget::button::custom(icon_cache_get("edit-delete-symbolic", 16)) widget::button::custom(icon_cache_get("edit-delete-symbolic", 16))
.on_press(Message::ProfileRemove(profile_id)) .on_press(Message::ProfileRemove(profile_id))
.style(style::Button::Icon) .class(style::Button::Icon)
.into(), .into(),
if expanded { if expanded {
widget::button::custom(icon_cache_get("go-up-symbolic", 16)) widget::button::custom(icon_cache_get("go-up-symbolic", 16))
@ -871,10 +879,10 @@ impl App {
widget::button::custom(icon_cache_get("go-down-symbolic", 16)) widget::button::custom(icon_cache_get("go-down-symbolic", 16))
.on_press(Message::ProfileExpand(profile_id)) .on_press(Message::ProfileExpand(profile_id))
} }
.style(style::Button::Icon) .class(style::Button::Icon)
.into(), .into(),
]) ])
.align_items(Alignment::Center) .align_y(Alignment::Center)
.spacing(space_xxs), .spacing(space_xxs),
), ),
); );
@ -889,7 +897,7 @@ impl App {
.iter() .iter()
.position(|theme_name| theme_name == &profile.syntax_theme_light); .position(|theme_name| theme_name == &profile.syntax_theme_light);
let expanded_section = widget::settings::view_section("") let expanded_section = widget::settings::section()
.add( .add(
widget::column::with_children(vec![ widget::column::with_children(vec![
widget::column::with_children(vec![ widget::column::with_children(vec![
@ -972,10 +980,9 @@ impl App {
.add( .add(
widget::settings::item::builder(fl!("make-default")).control( widget::settings::item::builder(fl!("make-default")).control(
widget::toggler( widget::toggler(
None,
self.get_default_profile().is_some_and(|p| p == profile_id), self.get_default_profile().is_some_and(|p| p == profile_id),
move |t| Message::UpdateDefaultProfile((t, profile_id)), )
), .on_toggle(move |t| Message::UpdateDefaultProfile((t, profile_id))),
), ),
) )
.add( .add(
@ -986,13 +993,12 @@ impl App {
]) ])
.spacing(space_xxxs) .spacing(space_xxxs)
.into(), .into(),
widget::horizontal_space(Length::Fill).into(), widget::horizontal_space().into(),
widget::toggler(None, profile.hold, move |t| { widget::toggler(profile.hold)
Message::ProfileHold(profile_id, t) .on_toggle(move |t| Message::ProfileHold(profile_id, t))
}) .into(),
.into(),
]) ])
.align_items(Alignment::Center) .align_y(Alignment::Center)
.padding([0, space_s]), .padding([0, space_s]),
); );
@ -1010,7 +1016,7 @@ impl App {
} }
let add_profile = widget::row::with_children(vec![ let add_profile = widget::row::with_children(vec![
widget::horizontal_space(Length::Fill).into(), widget::horizontal_space().into(),
widget::button::standard(fl!("add-profile")) widget::button::standard(fl!("add-profile"))
.on_press(Message::ProfileNew) .on_press(Message::ProfileNew)
.into(), .into(),
@ -1066,7 +1072,8 @@ impl App {
.iter() .iter()
.position(|zoom_step| zoom_step == &self.config.font_size_zoom_step_mul_100); .position(|zoom_step| zoom_step == &self.config.font_size_zoom_step_mul_100);
let appearance_section = widget::settings::view_section(fl!("appearance")) let appearance_section = widget::settings::section()
.title(fl!("appearance"))
.add( .add(
widget::settings::item::builder(fl!("theme")).control(widget::dropdown( widget::settings::item::builder(fl!("theme")).control(widget::dropdown(
&self.app_themes, &self.app_themes,
@ -1111,7 +1118,8 @@ impl App {
})), })),
); );
let mut font_section = widget::settings::view_section(fl!("font")) let mut font_section = widget::settings::section()
.title(fl!("font"))
.add( .add(
widget::settings::item::builder(fl!("default-font")).control(widget::dropdown( widget::settings::item::builder(fl!("default-font")).control(widget::dropdown(
&self.font_names, &self.font_names,
@ -1135,12 +1143,12 @@ impl App {
widget::button::custom(icon_cache_get("go-down-symbolic", 16)) widget::button::custom(icon_cache_get("go-down-symbolic", 16))
.on_press(Message::ShowAdvancedFontSettings(true)) .on_press(Message::ShowAdvancedFontSettings(true))
} }
.style(style::Button::Icon), .class(style::Button::Icon),
), ),
); );
let advanced_font_settings = || { let advanced_font_settings = || {
let section = widget::settings::view_section("") let section = widget::settings::section()
.add( .add(
widget::settings::item::builder(fl!("default-font-stretch")).control( widget::settings::item::builder(fl!("default-font-stretch")).control(
widget::dropdown( widget::dropdown(
@ -1194,12 +1202,12 @@ impl App {
font_section = font_section.add(advanced_font_settings()); font_section = font_section.add(advanced_font_settings());
} }
let splits_section = widget::settings::view_section(fl!("splits")).add( let splits_section = widget::settings::section().title(fl!("splits")).add(
widget::settings::item::builder(fl!("focus-follow-mouse")) widget::settings::item::builder(fl!("focus-follow-mouse"))
.toggler(self.config.focus_follow_mouse, Message::FocusFollowMouse), .toggler(self.config.focus_follow_mouse, Message::FocusFollowMouse),
); );
let advanced_section = widget::settings::view_section(fl!("advanced")).add( let advanced_section = widget::settings::section().title(fl!("advanced")).add(
widget::settings::item::builder(fl!("show-headerbar")) widget::settings::item::builder(fl!("show-headerbar"))
.description(fl!("show-header-description")) .description(fl!("show-header-description"))
.toggler(self.config.show_headerbar, Message::ShowHeaderBar), .toggler(self.config.show_headerbar, Message::ShowHeaderBar),
@ -1221,7 +1229,7 @@ impl App {
&mut self, &mut self,
pane: pane_grid::Pane, pane: pane_grid::Pane,
profile_id_opt: Option<ProfileId>, profile_id_opt: Option<ProfileId>,
) -> Command<Message> { ) -> Task<Message> {
self.pane_model.focus = pane; self.pane_model.focus = pane;
match &self.term_event_tx_opt { match &self.term_event_tx_opt {
Some(term_event_tx) => { Some(term_event_tx) => {
@ -1369,7 +1377,7 @@ impl Application for App {
} }
/// Creates the application, and optionally emits command on initialize. /// Creates the application, and optionally emits command on initialize.
fn init(mut core: Core, flags: Self::Flags) -> (Self, Command<Self::Message>) { fn init(mut core: Core, flags: Self::Flags) -> (Self, Task<Self::Message>) {
core.window.content_container = false; core.window.content_container = false;
core.window.show_headerbar = flags.config.show_headerbar; core.window.show_headerbar = flags.config.show_headerbar;
@ -1523,13 +1531,13 @@ impl Application for App {
}; };
app.set_curr_font_weights_and_stretches(); app.set_curr_font_weights_and_stretches();
let command = Command::batch([app.update_config(), app.update_title(None)]); let command = Task::batch([app.update_config(), app.update_title(None)]);
(app, command) (app, command)
} }
//TODO: currently the first escape unfocuses, and the second calls this function //TODO: currently the first escape unfocuses, and the second calls this function
fn on_escape(&mut self) -> Command<Message> { fn on_escape(&mut self) -> Task<Message> {
if self.core.window.show_context { if self.core.window.show_context {
// Close context drawer if open // Close context drawer if open
self.core.window.show_context = false; self.core.window.show_context = false;
@ -1543,16 +1551,16 @@ impl Application for App {
self.update_focus() self.update_focus()
} }
fn on_context_drawer(&mut self) -> Command<Message> { fn on_context_drawer(&mut self) -> Task<Message> {
if self.core.window.show_context { if self.core.window.show_context {
Command::none() Task::none()
} else { } else {
self.update_focus() self.update_focus()
} }
} }
/// Handle application events here. /// Handle application events here.
fn update(&mut self, message: Self::Message) -> Command<Self::Message> { fn update(&mut self, message: Self::Message) -> Task<Self::Message> {
// Helper for updating config values efficiently // Helper for updating config values efficiently
macro_rules! config_set { macro_rules! config_set {
($name: ident, $value: expr) => { ($name: ident, $value: expr) => {
@ -1805,7 +1813,7 @@ impl Application for App {
let terminal = terminal.lock().unwrap(); let terminal = terminal.lock().unwrap();
let term = terminal.term.lock(); let term = terminal.term.lock();
if let Some(text) = term.selection_to_string() { if let Some(text) = term.selection_to_string() {
return Command::batch([clipboard::write(text), self.update_focus()]); return Task::batch([clipboard::write(text), self.update_focus()]);
} }
} }
} else { } else {
@ -1820,7 +1828,7 @@ impl Application for App {
let terminal = terminal.lock().unwrap(); let terminal = terminal.lock().unwrap();
let term = terminal.term.lock(); let term = terminal.term.lock();
if let Some(text) = term.selection_to_string() { if let Some(text) = term.selection_to_string() {
return Command::batch([clipboard::write(text), self.update_focus()]); return Task::batch([clipboard::write(text), self.update_focus()]);
} else { } else {
// Drop the lock for term so that input_scroll doesn't block forever // Drop the lock for term so that input_scroll doesn't block forever
drop(term); drop(term);
@ -1840,7 +1848,7 @@ impl Application for App {
let terminal = terminal.lock().unwrap(); let terminal = terminal.lock().unwrap();
let term = terminal.term.lock(); let term = terminal.term.lock();
if let Some(text) = term.selection_to_string() { if let Some(text) = term.selection_to_string() {
return Command::batch([ return Task::batch([
clipboard::write_primary(text), clipboard::write_primary(text),
self.update_focus(), self.update_focus(),
]); ]);
@ -1948,7 +1956,7 @@ impl Application for App {
Message::Drop(Some((pane, entity, data))) => { Message::Drop(Some((pane, entity, data))) => {
self.pane_model.focus = pane; self.pane_model.focus = pane;
if let Ok(value) = shlex::try_join(data.paths.iter().filter_map(|p| p.to_str())) { if let Ok(value) = shlex::try_join(data.paths.iter().filter_map(|p| p.to_str())) {
return Command::batch([ return Task::batch([
self.update_focus(), self.update_focus(),
command::message::app(Message::PasteValue(Some(entity), value)), command::message::app(Message::PasteValue(Some(entity), value)),
]); ]);
@ -2010,9 +2018,9 @@ impl Application for App {
} }
Message::MiddleClick(pane, entity_opt) => { Message::MiddleClick(pane, entity_opt) => {
self.pane_model.focus = pane; self.pane_model.focus = pane;
return Command::batch([ return Task::batch([
self.update_focus(), self.update_focus(),
clipboard::read_primary(move |value_opt| match value_opt { clipboard::read_primary().map(move |value_opt| match value_opt {
Some(value) => message::app(Message::PasteValue(entity_opt, value)), Some(value) => message::app(Message::PasteValue(entity_opt, value)),
None => message::none(), None => message::none(),
}), }),
@ -2087,13 +2095,13 @@ impl Application for App {
} }
Message::PaneDragged(_) => {} Message::PaneDragged(_) => {}
Message::Paste(entity_opt) => { Message::Paste(entity_opt) => {
return clipboard::read(move |value_opt| match value_opt { return clipboard::read().map(move |value_opt| match value_opt {
Some(value) => message::app(Message::PasteValue(entity_opt, value)), Some(value) => message::app(Message::PasteValue(entity_opt, value)),
None => message::none(), None => message::none(),
}); });
} }
Message::PastePrimary(entity_opt) => { Message::PastePrimary(entity_opt) => {
return clipboard::read_primary(move |value_opt| match value_opt { return clipboard::read_primary().map(move |value_opt| match value_opt {
Some(value) => message::app(Message::PasteValue(entity_opt, value)), Some(value) => message::app(Message::PasteValue(entity_opt, value)),
None => message::none(), None => message::none(),
}); });
@ -2295,7 +2303,9 @@ impl Application for App {
self.pane_model.focus = sibling; self.pane_model.focus = sibling;
} else { } else {
//Last pane, closing window //Last pane, closing window
return window::close(window::Id::MAIN); if let Some(window_id) = self.core.main_window_id() {
return window::close(window_id);
}
} }
} }
} }
@ -2389,7 +2399,7 @@ impl Application for App {
match kind { match kind {
term::ClipboardType::Clipboard => { term::ClipboardType::Clipboard => {
log::info!("clipboard load"); log::info!("clipboard load");
return clipboard::read(move |data_opt| { return clipboard::read().map(move |data_opt| {
//TODO: what to do when data_opt is None? //TODO: what to do when data_opt is None?
callback(&data_opt.unwrap_or_default()); callback(&data_opt.unwrap_or_default());
// We don't need to do anything else // We don't need to do anything else
@ -2555,7 +2565,9 @@ impl Application for App {
config_set!(default_profile, default.then_some(profile_id)); config_set!(default_profile, default.then_some(profile_id));
} }
Message::WindowClose => { Message::WindowClose => {
return window::close(window::Id::MAIN); if let Some(window_id) = self.core.main_window_id() {
return window::close(window_id);
}
} }
Message::WindowNew => match env::current_exe() { Message::WindowNew => match env::current_exe() {
Ok(exe) => match process::Command::new(&exe).spawn() { Ok(exe) => match process::Command::new(&exe).spawn() {
@ -2580,7 +2592,7 @@ impl Application for App {
} }
} }
Command::none() Task::none()
} }
fn context_drawer(&self) -> Option<Element<Message>> { fn context_drawer(&self) -> Option<Element<Message>> {
@ -2605,7 +2617,7 @@ impl Application for App {
widget::button::custom(icon_cache_get("list-add-symbolic", 16)) widget::button::custom(icon_cache_get("list-add-symbolic", 16))
.on_press(Message::TabNew) .on_press(Message::TabNew)
.padding(8) .padding(8)
.style(style::Button::Icon) .class(style::Button::Icon)
.into(), .into(),
] ]
} }
@ -2633,7 +2645,7 @@ impl Application for App {
.on_activate(Message::TabActivate) .on_activate(Message::TabActivate)
.on_close(|entity| Message::TabClose(Some(entity))), .on_close(|entity| Message::TabClose(Some(entity))),
) )
.style(style::Container::Background) .class(style::Container::Background)
.width(Length::Fill), .width(Length::Fill),
); );
} }
@ -2693,7 +2705,7 @@ impl Application for App {
.trailing_icon( .trailing_icon(
button::custom(icon_cache_get("edit-clear-symbolic", 16)) button::custom(icon_cache_get("edit-clear-symbolic", 16))
.on_press(Message::FindSearchValueChanged(String::new())) .on_press(Message::FindSearchValueChanged(String::new()))
.style(style::Button::Icon) .class(style::Button::Icon)
.into(), .into(),
); );
let find_widget = widget::row::with_children(vec![ let find_widget = widget::row::with_children(vec![
@ -2702,8 +2714,8 @@ impl Application for App {
button::custom(icon_cache_get("go-up-symbolic", 16)) button::custom(icon_cache_get("go-up-symbolic", 16))
.on_press(Message::FindPrevious) .on_press(Message::FindPrevious)
.padding(space_xxs) .padding(space_xxs)
.style(style::Button::Icon), .class(style::Button::Icon),
fl!("find-previous"), widget::text::body(fl!("find-previous")),
widget::tooltip::Position::Top, widget::tooltip::Position::Top,
) )
.into(), .into(),
@ -2711,19 +2723,19 @@ impl Application for App {
button::custom(icon_cache_get("go-down-symbolic", 16)) button::custom(icon_cache_get("go-down-symbolic", 16))
.on_press(Message::FindNext) .on_press(Message::FindNext)
.padding(space_xxs) .padding(space_xxs)
.style(style::Button::Icon), .class(style::Button::Icon),
fl!("find-next"), widget::text::body(fl!("find-next")),
widget::tooltip::Position::Top, widget::tooltip::Position::Top,
) )
.into(), .into(),
widget::horizontal_space(Length::Fill).into(), widget::horizontal_space().into(),
button::custom(icon_cache_get("window-close-symbolic", 16)) button::custom(icon_cache_get("window-close-symbolic", 16))
.on_press(Message::Find(false)) .on_press(Message::Find(false))
.padding(space_xxs) .padding(space_xxs)
.style(style::Button::Icon) .class(style::Button::Icon)
.into(), .into(),
]) ])
.align_items(Alignment::Center) .align_y(Alignment::Center)
.padding(space_xxs) .padding(space_xxs)
.spacing(space_xxs); .spacing(space_xxs);
@ -2764,7 +2776,7 @@ impl Application for App {
struct ThemeModeSubscription; struct ThemeModeSubscription;
Subscription::batch([ Subscription::batch([
event::listen_with(|event, _status| match event { event::listen_with(|event, _status, _window_id| match event {
Event::Keyboard(KeyEvent::KeyPressed { key, modifiers, .. }) => { Event::Keyboard(KeyEvent::KeyPressed { key, modifiers, .. }) => {
Some(Message::Key(modifiers, key)) Some(Message::Key(modifiers, key))
} }
@ -2776,10 +2788,9 @@ impl Application for App {
} }
_ => None, _ => None,
}), }),
subscription::channel( Subscription::run_with_id(
TypeId::of::<TerminalEventSubscription>(), TypeId::of::<TerminalEventSubscription>(),
100, stream::channel(100, |mut output| async move {
|mut output| async move {
let (event_tx, mut event_rx) = mpsc::channel(100); let (event_tx, mut event_rx) = mpsc::channel(100);
output.send(Message::TermEventTx(event_tx)).await.unwrap(); output.send(Message::TermEventTx(event_tx)).await.unwrap();
@ -2791,7 +2802,7 @@ impl Application for App {
} }
panic!("terminal event channel closed"); panic!("terminal event channel closed");
}, }),
), ),
cosmic_config::config_subscription( cosmic_config::config_subscription(
TypeId::of::<ConfigSubscription>(), TypeId::of::<ConfigSubscription>(),
@ -2827,7 +2838,7 @@ impl Application for App {
.map(|_update| Message::SystemThemeChange), .map(|_update| Message::SystemThemeChange),
match &self.dialog_opt { match &self.dialog_opt {
Some(dialog) => dialog.subscription(), Some(dialog) => dialog.subscription(),
None => subscription::Subscription::none(), None => Subscription::none(),
}, },
]) ])
} }

View file

@ -8,7 +8,6 @@ use cosmic::{
Background, Length, Background, Length,
}, },
iced_core::Border, iced_core::Border,
theme,
widget::{ widget::{
self, self,
menu::{ItemHeight, ItemWidth, MenuBar, Tree as MenuTree}, menu::{ItemHeight, ItemWidth, MenuBar, Tree as MenuTree},
@ -38,7 +37,7 @@ pub fn context_menu<'a>(
let key = find_key(&action); let key = find_key(&action);
menu_button(vec![ menu_button(vec![
widget::text(label).into(), widget::text(label).into(),
horizontal_space(Length::Fill).into(), horizontal_space().into(),
widget::text(key).into(), widget::text(key).into(),
]) ])
.on_press(Message::TabContextAction(entity, action)) .on_press(Message::TabContextAction(entity, action))
@ -47,12 +46,11 @@ pub fn context_menu<'a>(
let menu_checkbox = |label, value, action| { let menu_checkbox = |label, value, action| {
menu_button(vec![ menu_button(vec![
widget::text(label).into(), widget::text(label).into(),
widget::horizontal_space(Length::Fill).into(), widget::horizontal_space().into(),
widget::toggler(None, value, move |_| { widget::toggler(value)
Message::TabContextAction(entity, action) .on_toggle(move |_| Message::TabContextAction(entity, action))
}) .size(16.0)
.size(16.0) .into(),
.into(),
]) ])
.on_press(Message::TabContextAction(entity, action)) .on_press(Message::TabContextAction(entity, action))
}; };
@ -78,10 +76,10 @@ pub fn context_menu<'a>(
)) ))
.padding(1) .padding(1)
//TODO: move style to libcosmic //TODO: move style to libcosmic
.style(theme::Container::custom(|theme| { .style(|theme| {
let cosmic = theme.cosmic(); let cosmic = theme.cosmic();
let component = &cosmic.background.component; let component = &cosmic.background.component;
widget::container::Appearance { widget::container::Style {
icon_color: Some(component.on.into()), icon_color: Some(component.on.into()),
text_color: Some(component.on.into()), text_color: Some(component.on.into()),
background: Some(Background::Color(component.base.into())), background: Some(Background::Color(component.base.into())),
@ -92,7 +90,7 @@ pub fn context_menu<'a>(
}, },
..Default::default() ..Default::default()
} }
})) })
.width(Length::Fixed(240.0)) .width(Length::Fixed(240.0))
.into() .into()
} }
@ -126,10 +124,10 @@ pub fn color_scheme_menu<'a>(
widget::container(column) widget::container(column)
.padding(1) .padding(1)
//TODO: move style to libcosmic //TODO: move style to libcosmic
.style(theme::Container::custom(|theme| { .style(|theme| {
let cosmic = theme.cosmic(); let cosmic = theme.cosmic();
let component = &cosmic.background.component; let component = &cosmic.background.component;
widget::container::Appearance { widget::container::Style {
icon_color: Some(component.on.into()), icon_color: Some(component.on.into()),
text_color: Some(component.on.into()), text_color: Some(component.on.into()),
background: Some(Background::Color(component.base.into())), background: Some(Background::Color(component.base.into())),
@ -140,7 +138,7 @@ pub fn color_scheme_menu<'a>(
}, },
..Default::default() ..Default::default()
} }
})) })
.width(Length::Fixed(120.0)) .width(Length::Fixed(120.0))
.into() .into()
} }

View file

@ -24,7 +24,7 @@ use cosmic::{
text::Renderer as _, text::Renderer as _,
widget::{ widget::{
self, self,
operation::{self, Operation, OperationOutputWrapper}, operation::{self, Operation},
tree, Id, Widget, tree, Id, Widget,
}, },
Border, Shell, Border, Shell,
@ -192,7 +192,7 @@ where
tree: &mut widget::Tree, tree: &mut widget::Tree,
_layout: Layout<'_>, _layout: Layout<'_>,
_renderer: &Renderer, _renderer: &Renderer,
operation: &mut dyn Operation<OperationOutputWrapper<Message>>, operation: &mut dyn Operation,
) { ) {
let state = tree.state.downcast_mut::<State>(); let state = tree.state.downcast_mut::<State>();