Update libcosmic/iced
This commit is contained in:
parent
1ed1f418cb
commit
8d4bfb992e
5 changed files with 741 additions and 781 deletions
1307
Cargo.lock
generated
1307
Cargo.lock
generated
File diff suppressed because it is too large
Load diff
|
|
@ -37,7 +37,6 @@ url = "2.5"
|
|||
[dependencies.cosmic-files]
|
||||
git = "https://github.com/pop-os/cosmic-files.git"
|
||||
default-features = false
|
||||
features = ["winit"]
|
||||
|
||||
[dependencies.cosmic-text]
|
||||
git = "https://github.com/pop-os/cosmic-text.git"
|
||||
|
|
@ -63,14 +62,7 @@ wgpu = ["libcosmic/wgpu", "cosmic-files/wgpu"]
|
|||
inherits = "release"
|
||||
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']
|
||||
# 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" }
|
||||
# cosmic-config = { path = "../libcosmic/cosmic-config" }
|
||||
# cosmic-theme = { path = "../libcosmic/cosmic-theme" }
|
||||
|
|
|
|||
177
src/main.rs
177
src/main.rs
|
|
@ -8,7 +8,7 @@ use cosmic::widget::menu::key_bind::KeyBind;
|
|||
use cosmic::widget::DndDestination;
|
||||
use cosmic::Apply;
|
||||
use cosmic::{
|
||||
app::{command, message, Command, Core, Settings},
|
||||
app::{command, message, Core, Settings, Task},
|
||||
cosmic_config::{self, ConfigSet, CosmicConfigEntry},
|
||||
cosmic_theme, executor,
|
||||
iced::{
|
||||
|
|
@ -18,8 +18,7 @@ use cosmic::{
|
|||
futures::SinkExt,
|
||||
keyboard::{Event as KeyEvent, Key, Modifiers},
|
||||
mouse::{Button as MouseButton, Event as MouseEvent},
|
||||
subscription::{self, Subscription},
|
||||
window, Alignment, Color, Event, Length, Limits, Padding, Point,
|
||||
stream, window, Alignment, Color, Event, Length, Limits, Padding, Point, Subscription,
|
||||
},
|
||||
style,
|
||||
widget::{self, button, pane_grid, segmented_button, PaneGrid},
|
||||
|
|
@ -33,6 +32,7 @@ use std::{
|
|||
cmp,
|
||||
collections::{BTreeMap, BTreeSet, HashMap},
|
||||
env, fs, process,
|
||||
rc::Rc,
|
||||
sync::{atomic::Ordering, Mutex},
|
||||
};
|
||||
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();
|
||||
|
||||
// Update color schemes
|
||||
|
|
@ -524,7 +524,7 @@ impl App {
|
|||
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
|
||||
// recalculate the pane due to the changes of zoom_adj value
|
||||
// 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
|
||||
if let Some(ref config_handler) = self.config_handler {
|
||||
if let Err(err) = config_handler.set(
|
||||
|
|
@ -565,10 +565,10 @@ impl App {
|
|||
}
|
||||
}
|
||||
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
|
||||
if let Some(ref config_handler) = self.config_handler {
|
||||
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 {
|
||||
widget::text_input::focus(self.find_search_id.clone())
|
||||
} else if let Some(terminal_id) = self.terminal_ids.get(&self.pane_model.focus).cloned() {
|
||||
widget::text_input::focus(terminal_id)
|
||||
} else {
|
||||
Command::none()
|
||||
Task::none()
|
||||
}
|
||||
}
|
||||
|
||||
// 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);
|
||||
if let Some(tab_model) = self.pane_model.panes.get(pane) {
|
||||
let (header_title, window_title) = match tab_model.text(tab_model.active()) {
|
||||
|
|
@ -603,14 +603,22 @@ impl App {
|
|||
None => (String::new(), fl!("cosmic-terminal")),
|
||||
};
|
||||
self.set_header_title(header_title);
|
||||
Command::batch([
|
||||
self.set_window_title(window_title, window::Id::MAIN),
|
||||
Task::batch([
|
||||
if let Some(window_id) = self.core.main_window_id() {
|
||||
self.set_window_title(window_title, window_id)
|
||||
} else {
|
||||
Task::none()
|
||||
},
|
||||
self.update_focus(),
|
||||
])
|
||||
} else {
|
||||
log::error!("Failed to get the specific pane");
|
||||
Command::batch([
|
||||
self.set_window_title(fl!("cosmic-terminal"), window::Id::MAIN),
|
||||
Task::batch([
|
||||
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(),
|
||||
])
|
||||
}
|
||||
|
|
@ -720,7 +728,7 @@ impl App {
|
|||
.padding(0)
|
||||
.into(),
|
||||
])
|
||||
.align_items(Alignment::Center)
|
||||
.align_x(Alignment::Center)
|
||||
.spacing(space_xxs)
|
||||
.into()
|
||||
}
|
||||
|
|
@ -736,7 +744,7 @@ impl App {
|
|||
.into(),
|
||||
);
|
||||
|
||||
let mut section = widget::settings::view_section("");
|
||||
let mut section = widget::settings::section();
|
||||
let builtin_name = format!("COSMIC {:?}", 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(
|
||||
|
|
@ -763,7 +771,7 @@ impl App {
|
|||
Message::ColorSchemeExpand(color_scheme_kind, color_scheme_id_opt),
|
||||
)
|
||||
}
|
||||
.style(style::Button::Icon);
|
||||
.class(style::Button::Icon);
|
||||
|
||||
let mut popover = widget::popover(button);
|
||||
if expanded {
|
||||
|
|
@ -800,7 +808,7 @@ impl App {
|
|||
|
||||
sections.push(
|
||||
widget::row::with_children(vec![
|
||||
widget::horizontal_space(Length::Fill).into(),
|
||||
widget::horizontal_space().into(),
|
||||
widget::button::standard(fl!("import"))
|
||||
.on_press(Message::ColorSchemeImport(color_scheme_kind))
|
||||
.into(),
|
||||
|
|
@ -812,18 +820,18 @@ impl App {
|
|||
sections.push(
|
||||
widget::row::with_children(vec![
|
||||
icon_cache_get("dialog-error-symbolic", 16)
|
||||
.style(style::Svg::custom(|theme| {
|
||||
.class(style::Svg::Custom(Rc::new(|theme| {
|
||||
let cosmic = theme.cosmic();
|
||||
widget::svg::Appearance {
|
||||
widget::svg::Style {
|
||||
color: Some(cosmic.destructive_text_color().into()),
|
||||
}
|
||||
}))
|
||||
})))
|
||||
.into(),
|
||||
widget::text(error)
|
||||
.style(style::Text::Custom(|theme| {
|
||||
widget::text::body(error)
|
||||
.class(style::Text::Custom(|theme| {
|
||||
let cosmic = theme.cosmic();
|
||||
//TODO: re-export in libcosmic
|
||||
iced::widget::text::Appearance {
|
||||
iced::widget::text::Style {
|
||||
color: Some(cosmic.destructive_text_color().into()),
|
||||
}
|
||||
}))
|
||||
|
|
@ -849,7 +857,7 @@ impl App {
|
|||
let mut sections = Vec::with_capacity(2);
|
||||
|
||||
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() {
|
||||
let Some(profile) = self.config.profiles.get(&profile_id) else {
|
||||
continue;
|
||||
|
|
@ -862,7 +870,7 @@ impl App {
|
|||
widget::row::with_children(vec![
|
||||
widget::button::custom(icon_cache_get("edit-delete-symbolic", 16))
|
||||
.on_press(Message::ProfileRemove(profile_id))
|
||||
.style(style::Button::Icon)
|
||||
.class(style::Button::Icon)
|
||||
.into(),
|
||||
if expanded {
|
||||
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))
|
||||
.on_press(Message::ProfileExpand(profile_id))
|
||||
}
|
||||
.style(style::Button::Icon)
|
||||
.class(style::Button::Icon)
|
||||
.into(),
|
||||
])
|
||||
.align_items(Alignment::Center)
|
||||
.align_y(Alignment::Center)
|
||||
.spacing(space_xxs),
|
||||
),
|
||||
);
|
||||
|
|
@ -889,7 +897,7 @@ impl App {
|
|||
.iter()
|
||||
.position(|theme_name| theme_name == &profile.syntax_theme_light);
|
||||
|
||||
let expanded_section = widget::settings::view_section("")
|
||||
let expanded_section = widget::settings::section()
|
||||
.add(
|
||||
widget::column::with_children(vec![
|
||||
widget::column::with_children(vec![
|
||||
|
|
@ -972,10 +980,9 @@ impl App {
|
|||
.add(
|
||||
widget::settings::item::builder(fl!("make-default")).control(
|
||||
widget::toggler(
|
||||
None,
|
||||
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(
|
||||
|
|
@ -986,13 +993,12 @@ impl App {
|
|||
])
|
||||
.spacing(space_xxxs)
|
||||
.into(),
|
||||
widget::horizontal_space(Length::Fill).into(),
|
||||
widget::toggler(None, profile.hold, move |t| {
|
||||
Message::ProfileHold(profile_id, t)
|
||||
})
|
||||
.into(),
|
||||
widget::horizontal_space().into(),
|
||||
widget::toggler(profile.hold)
|
||||
.on_toggle(move |t| Message::ProfileHold(profile_id, t))
|
||||
.into(),
|
||||
])
|
||||
.align_items(Alignment::Center)
|
||||
.align_y(Alignment::Center)
|
||||
.padding([0, space_s]),
|
||||
);
|
||||
|
||||
|
|
@ -1010,7 +1016,7 @@ impl App {
|
|||
}
|
||||
|
||||
let add_profile = widget::row::with_children(vec![
|
||||
widget::horizontal_space(Length::Fill).into(),
|
||||
widget::horizontal_space().into(),
|
||||
widget::button::standard(fl!("add-profile"))
|
||||
.on_press(Message::ProfileNew)
|
||||
.into(),
|
||||
|
|
@ -1066,7 +1072,8 @@ impl App {
|
|||
.iter()
|
||||
.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(
|
||||
widget::settings::item::builder(fl!("theme")).control(widget::dropdown(
|
||||
&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(
|
||||
widget::settings::item::builder(fl!("default-font")).control(widget::dropdown(
|
||||
&self.font_names,
|
||||
|
|
@ -1135,12 +1143,12 @@ impl App {
|
|||
widget::button::custom(icon_cache_get("go-down-symbolic", 16))
|
||||
.on_press(Message::ShowAdvancedFontSettings(true))
|
||||
}
|
||||
.style(style::Button::Icon),
|
||||
.class(style::Button::Icon),
|
||||
),
|
||||
);
|
||||
|
||||
let advanced_font_settings = || {
|
||||
let section = widget::settings::view_section("")
|
||||
let section = widget::settings::section()
|
||||
.add(
|
||||
widget::settings::item::builder(fl!("default-font-stretch")).control(
|
||||
widget::dropdown(
|
||||
|
|
@ -1194,12 +1202,12 @@ impl App {
|
|||
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"))
|
||||
.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"))
|
||||
.description(fl!("show-header-description"))
|
||||
.toggler(self.config.show_headerbar, Message::ShowHeaderBar),
|
||||
|
|
@ -1221,7 +1229,7 @@ impl App {
|
|||
&mut self,
|
||||
pane: pane_grid::Pane,
|
||||
profile_id_opt: Option<ProfileId>,
|
||||
) -> Command<Message> {
|
||||
) -> Task<Message> {
|
||||
self.pane_model.focus = pane;
|
||||
match &self.term_event_tx_opt {
|
||||
Some(term_event_tx) => {
|
||||
|
|
@ -1369,7 +1377,7 @@ impl Application for App {
|
|||
}
|
||||
|
||||
/// 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.show_headerbar = flags.config.show_headerbar;
|
||||
|
||||
|
|
@ -1523,13 +1531,13 @@ impl Application for App {
|
|||
};
|
||||
|
||||
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)
|
||||
}
|
||||
|
||||
//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 {
|
||||
// Close context drawer if open
|
||||
self.core.window.show_context = false;
|
||||
|
|
@ -1543,16 +1551,16 @@ impl Application for App {
|
|||
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 {
|
||||
Command::none()
|
||||
Task::none()
|
||||
} else {
|
||||
self.update_focus()
|
||||
}
|
||||
}
|
||||
|
||||
/// 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
|
||||
macro_rules! config_set {
|
||||
($name: ident, $value: expr) => {
|
||||
|
|
@ -1805,7 +1813,7 @@ impl Application for App {
|
|||
let terminal = terminal.lock().unwrap();
|
||||
let term = terminal.term.lock();
|
||||
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 {
|
||||
|
|
@ -1820,7 +1828,7 @@ impl Application for App {
|
|||
let terminal = terminal.lock().unwrap();
|
||||
let term = terminal.term.lock();
|
||||
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 {
|
||||
// Drop the lock for term so that input_scroll doesn't block forever
|
||||
drop(term);
|
||||
|
|
@ -1840,7 +1848,7 @@ impl Application for App {
|
|||
let terminal = terminal.lock().unwrap();
|
||||
let term = terminal.term.lock();
|
||||
if let Some(text) = term.selection_to_string() {
|
||||
return Command::batch([
|
||||
return Task::batch([
|
||||
clipboard::write_primary(text),
|
||||
self.update_focus(),
|
||||
]);
|
||||
|
|
@ -1948,7 +1956,7 @@ impl Application for App {
|
|||
Message::Drop(Some((pane, entity, data))) => {
|
||||
self.pane_model.focus = pane;
|
||||
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(),
|
||||
command::message::app(Message::PasteValue(Some(entity), value)),
|
||||
]);
|
||||
|
|
@ -2010,9 +2018,9 @@ impl Application for App {
|
|||
}
|
||||
Message::MiddleClick(pane, entity_opt) => {
|
||||
self.pane_model.focus = pane;
|
||||
return Command::batch([
|
||||
return Task::batch([
|
||||
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)),
|
||||
None => message::none(),
|
||||
}),
|
||||
|
|
@ -2087,13 +2095,13 @@ impl Application for App {
|
|||
}
|
||||
Message::PaneDragged(_) => {}
|
||||
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)),
|
||||
None => message::none(),
|
||||
});
|
||||
}
|
||||
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)),
|
||||
None => message::none(),
|
||||
});
|
||||
|
|
@ -2295,7 +2303,9 @@ impl Application for App {
|
|||
self.pane_model.focus = sibling;
|
||||
} else {
|
||||
//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 {
|
||||
term::ClipboardType::Clipboard => {
|
||||
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?
|
||||
callback(&data_opt.unwrap_or_default());
|
||||
// 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));
|
||||
}
|
||||
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() {
|
||||
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>> {
|
||||
|
|
@ -2605,7 +2617,7 @@ impl Application for App {
|
|||
widget::button::custom(icon_cache_get("list-add-symbolic", 16))
|
||||
.on_press(Message::TabNew)
|
||||
.padding(8)
|
||||
.style(style::Button::Icon)
|
||||
.class(style::Button::Icon)
|
||||
.into(),
|
||||
]
|
||||
}
|
||||
|
|
@ -2633,7 +2645,7 @@ impl Application for App {
|
|||
.on_activate(Message::TabActivate)
|
||||
.on_close(|entity| Message::TabClose(Some(entity))),
|
||||
)
|
||||
.style(style::Container::Background)
|
||||
.class(style::Container::Background)
|
||||
.width(Length::Fill),
|
||||
);
|
||||
}
|
||||
|
|
@ -2693,7 +2705,7 @@ impl Application for App {
|
|||
.trailing_icon(
|
||||
button::custom(icon_cache_get("edit-clear-symbolic", 16))
|
||||
.on_press(Message::FindSearchValueChanged(String::new()))
|
||||
.style(style::Button::Icon)
|
||||
.class(style::Button::Icon)
|
||||
.into(),
|
||||
);
|
||||
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))
|
||||
.on_press(Message::FindPrevious)
|
||||
.padding(space_xxs)
|
||||
.style(style::Button::Icon),
|
||||
fl!("find-previous"),
|
||||
.class(style::Button::Icon),
|
||||
widget::text::body(fl!("find-previous")),
|
||||
widget::tooltip::Position::Top,
|
||||
)
|
||||
.into(),
|
||||
|
|
@ -2711,19 +2723,19 @@ impl Application for App {
|
|||
button::custom(icon_cache_get("go-down-symbolic", 16))
|
||||
.on_press(Message::FindNext)
|
||||
.padding(space_xxs)
|
||||
.style(style::Button::Icon),
|
||||
fl!("find-next"),
|
||||
.class(style::Button::Icon),
|
||||
widget::text::body(fl!("find-next")),
|
||||
widget::tooltip::Position::Top,
|
||||
)
|
||||
.into(),
|
||||
widget::horizontal_space(Length::Fill).into(),
|
||||
widget::horizontal_space().into(),
|
||||
button::custom(icon_cache_get("window-close-symbolic", 16))
|
||||
.on_press(Message::Find(false))
|
||||
.padding(space_xxs)
|
||||
.style(style::Button::Icon)
|
||||
.class(style::Button::Icon)
|
||||
.into(),
|
||||
])
|
||||
.align_items(Alignment::Center)
|
||||
.align_y(Alignment::Center)
|
||||
.padding(space_xxs)
|
||||
.spacing(space_xxs);
|
||||
|
||||
|
|
@ -2764,7 +2776,7 @@ impl Application for App {
|
|||
struct ThemeModeSubscription;
|
||||
|
||||
Subscription::batch([
|
||||
event::listen_with(|event, _status| match event {
|
||||
event::listen_with(|event, _status, _window_id| match event {
|
||||
Event::Keyboard(KeyEvent::KeyPressed { key, modifiers, .. }) => {
|
||||
Some(Message::Key(modifiers, key))
|
||||
}
|
||||
|
|
@ -2776,10 +2788,9 @@ impl Application for App {
|
|||
}
|
||||
_ => None,
|
||||
}),
|
||||
subscription::channel(
|
||||
Subscription::run_with_id(
|
||||
TypeId::of::<TerminalEventSubscription>(),
|
||||
100,
|
||||
|mut output| async move {
|
||||
stream::channel(100, |mut output| async move {
|
||||
let (event_tx, mut event_rx) = mpsc::channel(100);
|
||||
output.send(Message::TermEventTx(event_tx)).await.unwrap();
|
||||
|
||||
|
|
@ -2791,7 +2802,7 @@ impl Application for App {
|
|||
}
|
||||
|
||||
panic!("terminal event channel closed");
|
||||
},
|
||||
}),
|
||||
),
|
||||
cosmic_config::config_subscription(
|
||||
TypeId::of::<ConfigSubscription>(),
|
||||
|
|
@ -2827,7 +2838,7 @@ impl Application for App {
|
|||
.map(|_update| Message::SystemThemeChange),
|
||||
match &self.dialog_opt {
|
||||
Some(dialog) => dialog.subscription(),
|
||||
None => subscription::Subscription::none(),
|
||||
None => Subscription::none(),
|
||||
},
|
||||
])
|
||||
}
|
||||
|
|
|
|||
26
src/menu.rs
26
src/menu.rs
|
|
@ -8,7 +8,6 @@ use cosmic::{
|
|||
Background, Length,
|
||||
},
|
||||
iced_core::Border,
|
||||
theme,
|
||||
widget::{
|
||||
self,
|
||||
menu::{ItemHeight, ItemWidth, MenuBar, Tree as MenuTree},
|
||||
|
|
@ -38,7 +37,7 @@ pub fn context_menu<'a>(
|
|||
let key = find_key(&action);
|
||||
menu_button(vec![
|
||||
widget::text(label).into(),
|
||||
horizontal_space(Length::Fill).into(),
|
||||
horizontal_space().into(),
|
||||
widget::text(key).into(),
|
||||
])
|
||||
.on_press(Message::TabContextAction(entity, action))
|
||||
|
|
@ -47,12 +46,11 @@ pub fn context_menu<'a>(
|
|||
let menu_checkbox = |label, value, action| {
|
||||
menu_button(vec![
|
||||
widget::text(label).into(),
|
||||
widget::horizontal_space(Length::Fill).into(),
|
||||
widget::toggler(None, value, move |_| {
|
||||
Message::TabContextAction(entity, action)
|
||||
})
|
||||
.size(16.0)
|
||||
.into(),
|
||||
widget::horizontal_space().into(),
|
||||
widget::toggler(value)
|
||||
.on_toggle(move |_| Message::TabContextAction(entity, action))
|
||||
.size(16.0)
|
||||
.into(),
|
||||
])
|
||||
.on_press(Message::TabContextAction(entity, action))
|
||||
};
|
||||
|
|
@ -78,10 +76,10 @@ pub fn context_menu<'a>(
|
|||
))
|
||||
.padding(1)
|
||||
//TODO: move style to libcosmic
|
||||
.style(theme::Container::custom(|theme| {
|
||||
.style(|theme| {
|
||||
let cosmic = theme.cosmic();
|
||||
let component = &cosmic.background.component;
|
||||
widget::container::Appearance {
|
||||
widget::container::Style {
|
||||
icon_color: Some(component.on.into()),
|
||||
text_color: Some(component.on.into()),
|
||||
background: Some(Background::Color(component.base.into())),
|
||||
|
|
@ -92,7 +90,7 @@ pub fn context_menu<'a>(
|
|||
},
|
||||
..Default::default()
|
||||
}
|
||||
}))
|
||||
})
|
||||
.width(Length::Fixed(240.0))
|
||||
.into()
|
||||
}
|
||||
|
|
@ -126,10 +124,10 @@ pub fn color_scheme_menu<'a>(
|
|||
widget::container(column)
|
||||
.padding(1)
|
||||
//TODO: move style to libcosmic
|
||||
.style(theme::Container::custom(|theme| {
|
||||
.style(|theme| {
|
||||
let cosmic = theme.cosmic();
|
||||
let component = &cosmic.background.component;
|
||||
widget::container::Appearance {
|
||||
widget::container::Style {
|
||||
icon_color: Some(component.on.into()),
|
||||
text_color: Some(component.on.into()),
|
||||
background: Some(Background::Color(component.base.into())),
|
||||
|
|
@ -140,7 +138,7 @@ pub fn color_scheme_menu<'a>(
|
|||
},
|
||||
..Default::default()
|
||||
}
|
||||
}))
|
||||
})
|
||||
.width(Length::Fixed(120.0))
|
||||
.into()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ use cosmic::{
|
|||
text::Renderer as _,
|
||||
widget::{
|
||||
self,
|
||||
operation::{self, Operation, OperationOutputWrapper},
|
||||
operation::{self, Operation},
|
||||
tree, Id, Widget,
|
||||
},
|
||||
Border, Shell,
|
||||
|
|
@ -192,7 +192,7 @@ where
|
|||
tree: &mut widget::Tree,
|
||||
_layout: Layout<'_>,
|
||||
_renderer: &Renderer,
|
||||
operation: &mut dyn Operation<OperationOutputWrapper<Message>>,
|
||||
operation: &mut dyn Operation,
|
||||
) {
|
||||
let state = tree.state.downcast_mut::<State>();
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue