Merge pull request #847 from pop-os/update-libcosmic

update libcosmic
This commit is contained in:
Jeremy Soller 2025-03-19 15:51:22 +00:00 committed by GitHub
commit 8b5b3a0a3b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 515 additions and 517 deletions

785
Cargo.lock generated

File diff suppressed because it is too large Load diff

View file

@ -67,7 +67,15 @@ default-features = false
features = ["multi-window", "tokio", "winit"] features = ["multi-window", "tokio", "winit"]
[features] [features]
default = ["bzip2", "dbus-config", "desktop", "gvfs", "liblzma", "notify", "wgpu"] default = [
"bzip2",
"dbus-config",
"desktop",
"gvfs",
"liblzma",
"notify",
"wgpu",
]
dbus-config = ["libcosmic/dbus-config"] dbus-config = ["libcosmic/dbus-config"]
desktop = ["libcosmic/desktop", "dep:cosmic-mime-apps", "dep:xdg"] desktop = ["libcosmic/desktop", "dep:cosmic-mime-apps", "dep:xdg"]
gvfs = ["dep:gio", "dep:glib"] gvfs = ["dep:gio", "dep:glib"]
@ -106,6 +114,9 @@ xdg-mime = { git = "https://github.com/ellieplayswow/xdg-mime-rs", branch = "fea
# 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" }
# cosmic-config = { git = "https://github.com/pop-os/libcosmic//", branch = "drop-menu-tree-changes" }
# libcosmic = { git = "https://github.com/pop-os/libcosmic//", branch = "drop-menu-tree-changes" }
# cosmic-theme = { git = "https://github.com/pop-os/libcosmic//", branch = "drop-menu-tree-changes" }
# [patch.'https://github.com/pop-os/smithay-clipboard'] # [patch.'https://github.com/pop-os/smithay-clipboard']
# smithay-clipboard = { path = "../smithay-clipboard" } # smithay-clipboard = { path = "../smithay-clipboard" }

View file

@ -1,7 +1,6 @@
// Copyright 2023 System76 <info@system76.com> // Copyright 2023 System76 <info@system76.com>
// SPDX-License-Identifier: GPL-3.0-only // SPDX-License-Identifier: GPL-3.0-only
use cosmic::iced::mouse::Event::CursorMoved;
#[cfg(feature = "wayland")] #[cfg(feature = "wayland")]
use cosmic::iced::{ use cosmic::iced::{
event::wayland::{Event as WaylandEvent, OutputEvent, OverlapNotifyEvent}, event::wayland::{Event as WaylandEvent, OutputEvent, OverlapNotifyEvent},
@ -16,7 +15,8 @@ use cosmic::iced::{
#[cfg(feature = "wayland")] #[cfg(feature = "wayland")]
use cosmic::iced_winit::commands::overlap_notify::overlap_notify; use cosmic::iced_winit::commands::overlap_notify::overlap_notify;
use cosmic::{ use cosmic::{
app::{self, context_drawer, message, Core, Task}, action,
app::{self, context_drawer, Core, Task},
cosmic_config, cosmic_theme, executor, cosmic_config, cosmic_theme, executor,
iced::{ iced::{
self, self,
@ -41,6 +41,7 @@ use cosmic::{
}, },
Application, ApplicationExt, Element, Application, ApplicationExt, Element,
}; };
use cosmic::{iced::mouse::Event::CursorMoved, surface};
use mime_guess::Mime; use mime_guess::Mime;
use notify_debouncer_full::{ use notify_debouncer_full::{
new_debouncer, new_debouncer,
@ -265,10 +266,10 @@ pub enum NavMenuAction {
} }
impl MenuAction for NavMenuAction { impl MenuAction for NavMenuAction {
type Message = cosmic::app::Message<Message>; type Message = cosmic::Action<Message>;
fn message(&self) -> Self::Message { fn message(&self) -> Self::Message {
cosmic::app::Message::App(Message::NavMenuAction(*self)) cosmic::Action::App(Message::NavMenuAction(*self))
} }
} }
@ -382,8 +383,9 @@ pub enum Message {
Recents, Recents,
#[cfg(feature = "wayland")] #[cfg(feature = "wayland")]
OutputEvent(OutputEvent, WlOutput), OutputEvent(OutputEvent, WlOutput),
Cosmic(app::cosmic::Message), Cosmic(app::Action),
None, None,
Surface(surface::Action),
} }
#[derive(Clone, Debug, Eq, PartialEq)] #[derive(Clone, Debug, Eq, PartialEq)]
@ -904,7 +906,7 @@ impl App {
async move { async move {
let location2 = location.clone(); let location2 = location.clone();
match tokio::task::spawn_blocking(move || location2.scan(icon_sizes)).await { match tokio::task::spawn_blocking(move || location2.scan(icon_sizes)).await {
Ok((parent_item_opt, items)) => message::app(Message::TabRescan( Ok((parent_item_opt, items)) => cosmic::action::app(Message::TabRescan(
entity, entity,
location, location,
parent_item_opt, parent_item_opt,
@ -913,7 +915,7 @@ impl App {
)), )),
Err(err) => { Err(err) => {
log::warn!("failed to rescan: {}", err); log::warn!("failed to rescan: {}", err);
message::none() cosmic::action::none()
} }
} }
}, },
@ -1017,16 +1019,15 @@ impl App {
// Tabs are collected first to placate the borrowck // Tabs are collected first to placate the borrowck
let tabs: Vec<_> = self.tab_model.iter().collect(); let tabs: Vec<_> = self.tab_model.iter().collect();
// Update main conf and each tab with the new config // Update main conf and each tab with the new config
let commands: Vec<_> = std::iter::once(cosmic::app::command::set_theme( let commands: Vec<_> =
self.config.app_theme.theme(), std::iter::once(cosmic::command::set_theme(self.config.app_theme.theme()))
)) .chain(tabs.into_iter().map(|entity| {
.chain(tabs.into_iter().map(|entity| { self.update(Message::TabMessage(
self.update(Message::TabMessage( Some(entity),
Some(entity), tab::Message::Config(self.config.tab),
tab::Message::Config(self.config.tab), ))
)) }))
})) .collect();
.collect();
Task::batch(commands) Task::batch(commands)
} }
@ -1179,7 +1180,7 @@ impl App {
}) })
.await .await
.unwrap(); .unwrap();
message::app(Message::MaybeExit) cosmic::action::app(Message::MaybeExit)
}, },
|x| x, |x| x,
); );
@ -1801,7 +1802,7 @@ impl Application for App {
(app, Task::batch(commands)) (app, Task::batch(commands))
} }
fn nav_bar(&self) -> Option<Element<message::Message<Self::Message>>> { fn nav_bar(&self) -> Option<Element<cosmic::Action<Self::Message>>> {
if !self.core().nav_bar_active() { if !self.core().nav_bar_active() {
return None; return None;
} }
@ -1809,18 +1810,18 @@ impl Application for App {
let nav_model = self.nav_model()?; let nav_model = self.nav_model()?;
let mut nav = cosmic::widget::nav_bar(nav_model, |entity| { let mut nav = cosmic::widget::nav_bar(nav_model, |entity| {
cosmic::app::Message::Cosmic(cosmic::app::cosmic::Message::NavBar(entity)) cosmic::Action::Cosmic(cosmic::app::Action::NavBar(entity))
}) })
.drag_id(self.nav_drag_id) .drag_id(self.nav_drag_id)
.on_dnd_enter(|entity, _| cosmic::app::Message::App(Message::DndEnterNav(entity))) .on_dnd_enter(|entity, _| cosmic::Action::App(Message::DndEnterNav(entity)))
.on_dnd_leave(|_| cosmic::app::Message::App(Message::DndExitNav)) .on_dnd_leave(|_| cosmic::Action::App(Message::DndExitNav))
.on_dnd_drop(|entity, data, action| { .on_dnd_drop(|entity, data, action| {
cosmic::app::Message::App(Message::DndDropNav(entity, data, action)) cosmic::Action::App(Message::DndDropNav(entity, data, action))
}) })
.on_context(|entity| cosmic::app::Message::App(Message::NavBarContext(entity))) .on_context(|entity| cosmic::Action::App(Message::NavBarContext(entity)))
.on_close(|entity| cosmic::app::Message::App(Message::NavBarClose(entity))) .on_close(|entity| cosmic::Action::App(Message::NavBarClose(entity)))
.on_middle_press(|entity| { .on_middle_press(|entity| {
cosmic::app::Message::App(Message::NavMenuAction(NavMenuAction::OpenInNewTab(entity))) cosmic::Action::App(Message::NavMenuAction(NavMenuAction::OpenInNewTab(entity)))
}) })
.context_menu(self.nav_context_menu(self.nav_bar_context_id)) .context_menu(self.nav_context_menu(self.nav_bar_context_id))
.close_icon( .close_icon(
@ -1843,7 +1844,7 @@ impl Application for App {
fn nav_context_menu( fn nav_context_menu(
&self, &self,
entity: widget::nav_bar::Id, entity: widget::nav_bar::Id,
) -> Option<Vec<widget::menu::Tree<cosmic::app::Message<Self::Message>>>> { ) -> Option<Vec<widget::menu::Tree<cosmic::Action<Self::Message>>>> {
let favorite_index_opt = self.nav_model.data::<FavoriteIndex>(entity); let favorite_index_opt = self.nav_model.data::<FavoriteIndex>(entity);
let location_opt = self.nav_model.data::<Location>(entity); let location_opt = self.nav_model.data::<Location>(entity);
@ -1945,7 +1946,9 @@ impl Application for App {
if let Some(data) = self.nav_model.data::<MounterData>(entity) { if let Some(data) = self.nav_model.data::<MounterData>(entity) {
if let Some(mounter) = MOUNTERS.get(&data.0) { if let Some(mounter) = MOUNTERS.get(&data.0) {
return mounter.mount(data.1.clone()).map(|_| message::none()); return mounter
.mount(data.1.clone())
.map(|_| cosmic::action::none());
} }
} }
Task::none() Task::none()
@ -1991,7 +1994,7 @@ impl Application for App {
// of closing everything on one press // of closing everything on one press
if self.core.window.show_context { if self.core.window.show_context {
self.set_show_context(false); self.set_show_context(false);
return cosmic::task::message(app::Message::App(Message::SetShowDetails(false))); return cosmic::task::message(cosmic::action::app(Message::SetShowDetails(false)));
} }
if self.search_get().is_some() { if self.search_get().is_some() {
// Close search if open // Close search if open
@ -2183,7 +2186,7 @@ impl Application for App {
let (id, command) = window::open(settings); let (id, command) = window::open(settings);
self.windows.insert(id, WindowKind::DesktopViewOptions); self.windows.insert(id, WindowKind::DesktopViewOptions);
return command.map(|_id| message::none()); return command.map(|_id| cosmic::action::none());
} }
Message::DialogCancel => { Message::DialogCancel => {
self.dialog_pages.pop_front(); self.dialog_pages.pop_front();
@ -2232,7 +2235,7 @@ impl Application for App {
error: _, error: _,
} => { } => {
if let Some(mounter) = MOUNTERS.get(&mounter_key) { if let Some(mounter) = MOUNTERS.get(&mounter_key) {
return mounter.mount(item).map(|_| message::none()); return mounter.mount(item).map(|_| cosmic::action::none());
} }
} }
DialogPage::NetworkAuth { DialogPage::NetworkAuth {
@ -2244,7 +2247,7 @@ impl Application for App {
return Task::perform( return Task::perform(
async move { async move {
auth_tx.send(auth).await.unwrap(); auth_tx.send(auth).await.unwrap();
message::none() cosmic::action::none()
}, },
|x| x, |x| x,
); );
@ -2513,7 +2516,7 @@ impl Application for App {
Some((*mounter_key, self.network_drive_input.clone())); Some((*mounter_key, self.network_drive_input.clone()));
return mounter return mounter
.network_drive(self.network_drive_input.clone()) .network_drive(self.network_drive_input.clone())
.map(|_| message::none()); .map(|_| cosmic::action::none());
} }
log::warn!( log::warn!(
"no mounter found for connecting to {:?}", "no mounter found for connecting to {:?}",
@ -2778,10 +2781,11 @@ impl Application for App {
let to = path.clone(); let to = path.clone();
return clipboard::read_data::<ClipboardPaste>().map(move |contents_opt| { return clipboard::read_data::<ClipboardPaste>().map(move |contents_opt| {
match contents_opt { match contents_opt {
Some(contents) => { Some(contents) => cosmic::action::app(Message::PasteContents(
message::app(Message::PasteContents(to.clone(), contents)) to.clone(),
} contents,
None => message::none(), )),
None => cosmic::action::none(),
} }
}); });
} }
@ -2833,7 +2837,7 @@ impl Application for App {
Message::UndoTrash(tid, paths.clone()) Message::UndoTrash(tid, paths.clone())
}), }),
) )
.map(cosmic::app::Message::App), .map(cosmic::Action::App),
); );
} }
} }
@ -2958,7 +2962,7 @@ impl Application for App {
PreviewKind::Location(Location::Path(path)), PreviewKind::Location(Location::Path(path)),
), ),
); );
commands.push(command.map(|_id| message::none())); commands.push(command.map(|_id| cosmic::action::none()));
} }
return Task::batch(commands); return Task::batch(commands);
} }
@ -2979,7 +2983,6 @@ impl Application for App {
return Task::batch([self.rescan_trash(), self.update_desktop()]); return Task::batch([self.rescan_trash(), self.update_desktop()]);
} }
Message::Rename(entity_opt) => { Message::Rename(entity_opt) => {
let entity = entity_opt.unwrap_or_else(|| self.tab_model.active()); let entity = entity_opt.unwrap_or_else(|| self.tab_model.active());
if let Some(tab) = self.tab_model.data_mut::<Tab>(entity) { if let Some(tab) = self.tab_model.data_mut::<Tab>(entity) {
@ -3023,7 +3026,7 @@ impl Application for App {
return Task::perform( return Task::perform(
async move { async move {
let _ = tx.send(replace_result).await; let _ = tx.send(replace_result).await;
message::none() cosmic::action::none()
}, },
|x| x, |x| x,
); );
@ -3239,11 +3242,9 @@ impl Application for App {
App::exec_entry_action(entry, action); App::exec_entry_action(entry, action);
} }
tab::Command::Iced(iced_command) => { tab::Command::Iced(iced_command) => {
commands.push( commands.push(iced_command.0.map(move |x| {
iced_command.0.map(move |x| { cosmic::action::app(Message::TabMessage(Some(entity), x))
message::app(Message::TabMessage(Some(entity), x)) }));
}),
);
} }
tab::Command::OpenFile(path) => self.open_file(&path), tab::Command::OpenFile(path) => self.open_file(&path),
tab::Command::OpenInNewTab(path) => { tab::Command::OpenInNewTab(path) => {
@ -3333,7 +3334,7 @@ impl Application for App {
self.context_page = context_page; self.context_page = context_page;
// Preview status is preserved across restarts // Preview status is preserved across restarts
if matches!(self.context_page, ContextPage::Preview(_, _)) { if matches!(self.context_page, ContextPage::Preview(_, _)) {
return cosmic::task::message(app::Message::App(Message::SetShowDetails( return cosmic::task::message(cosmic::action::app(Message::SetShowDetails(
self.core.window.show_context, self.core.window.show_context,
))); )));
} }
@ -3378,7 +3379,10 @@ impl Application for App {
if let Some(window_id) = self.window_id_opt.take() { if let Some(window_id) = self.window_id_opt.take() {
return Task::batch([ return Task::batch([
window::close(window_id), window::close(window_id),
Task::perform(async move { message::app(Message::MaybeExit) }, |x| x), Task::perform(
async move { cosmic::action::app(Message::MaybeExit) },
|x| x,
),
]); ]);
} }
} }
@ -3466,7 +3470,7 @@ impl Application for App {
self.nav_dnd_hover = Some((location.clone(), Instant::now())); self.nav_dnd_hover = Some((location.clone(), Instant::now()));
let location = location.clone(); let location = location.clone();
return Task::perform(tokio::time::sleep(HOVER_DURATION), move |_| { return Task::perform(tokio::time::sleep(HOVER_DURATION), move |_| {
cosmic::app::Message::App(Message::DndHoverLocTimeout(location.clone())) cosmic::Action::App(Message::DndHoverLocTimeout(location.clone()))
}); });
} }
} }
@ -3528,7 +3532,7 @@ impl Application for App {
Message::DndEnterTab(entity) => { Message::DndEnterTab(entity) => {
self.tab_dnd_hover = Some((entity, Instant::now())); self.tab_dnd_hover = Some((entity, Instant::now()));
return Task::perform(tokio::time::sleep(HOVER_DURATION), move |_| { return Task::perform(tokio::time::sleep(HOVER_DURATION), move |_| {
cosmic::app::Message::App(Message::DndHoverTabTimeout(entity)) cosmic::Action::App(Message::DndHoverTabTimeout(entity))
}); });
} }
Message::DndExitTab => { Message::DndExitTab => {
@ -3571,16 +3575,15 @@ impl Application for App {
return self.update(Message::TabActivate(entity)); return self.update(Message::TabActivate(entity));
} }
} }
Message::NavBarClose(entity) => { Message::NavBarClose(entity) => {
if let Some(data) = self.nav_model.data::<MounterData>(entity) { if let Some(data) = self.nav_model.data::<MounterData>(entity) {
if let Some(mounter) = MOUNTERS.get(&data.0) { if let Some(mounter) = MOUNTERS.get(&data.0) {
return mounter.unmount(data.1.clone()).map(|_| message::none()); return mounter
.unmount(data.1.clone())
.map(|_| cosmic::action::none());
} }
} }
} }
// Tracks which nav bar item to show a context menu for.
Message::NavBarContext(entity) => { Message::NavBarContext(entity) => {
// Close location editing if enabled // Close location editing if enabled
let tab_entity = self.tab_model.active(); let tab_entity = self.tab_model.active();
@ -3590,8 +3593,6 @@ impl Application for App {
self.nav_bar_context_id = entity; self.nav_bar_context_id = entity;
} }
// Applies selected nav bar context menu operation.
Message::NavMenuAction(action) => match action { Message::NavMenuAction(action) => match action {
NavMenuAction::Open(entity) => { NavMenuAction::Open(entity) => {
if let Some(path) = self if let Some(path) = self
@ -3817,7 +3818,7 @@ impl Application for App {
} }
Message::Cosmic(cosmic) => { Message::Cosmic(cosmic) => {
// Forward cosmic messages // Forward cosmic messages
return Task::perform(async move { cosmic }, message::cosmic); return Task::perform(async move { cosmic }, cosmic::action::cosmic);
} }
Message::None => {} Message::None => {}
#[cfg(all(feature = "desktop", feature = "wayland"))] #[cfg(all(feature = "desktop", feature = "wayland"))]
@ -3853,6 +3854,11 @@ impl Application for App {
}; };
} }
} }
Message::Surface(a) => {
return cosmic::task::message(cosmic::Action::Cosmic(
cosmic::app::Action::Surface(a),
));
}
} }
Task::none() Task::none()
@ -3881,7 +3887,7 @@ impl Application for App {
} else { } else {
text_input = text_input text_input = text_input
.on_input(Message::NetworkDriveInput) .on_input(Message::NetworkDriveInput)
.on_submit(Message::NetworkDriveSubmit); .on_submit(|_| Message::NetworkDriveSubmit);
widget::button::standard(fl!("connect")).on_press(Message::NetworkDriveSubmit) widget::button::standard(fl!("connect")).on_press(Message::NetworkDriveSubmit)
}; };
context_drawer::context_drawer( context_drawer::context_drawer(
@ -3937,9 +3943,8 @@ impl Application for App {
} }
} }
let dialog_page = match self.dialog_pages.front() { let Some(dialog_page) = self.dialog_pages.front() else {
Some(some) => some, return None;
None => return None,
}; };
let cosmic_theme::Spacing { let cosmic_theme::Spacing {
@ -4008,9 +4013,16 @@ impl Application for App {
password: password.clone(), password: password.clone(),
}) })
}) })
.on_submit_maybe(complete_maybe.clone()) .on_submit_maybe(
complete_maybe.clone().map(|maybe| move |_| maybe.clone()),
)
.into(), .into(),
widget::dropdown(archive_types, selected, move |index| { Element::from(widget::dropdown(
archive_types,
selected,
move |index| index,
))
.map(|index| {
Message::DialogUpdate(DialogPage::Compress { Message::DialogUpdate(DialogPage::Compress {
paths: paths.clone(), paths: paths.clone(),
to: to.clone(), to: to.clone(),
@ -4043,7 +4055,9 @@ impl Application for App {
password: Some(password_unwrapped), password: Some(password_unwrapped),
}) })
}) })
.on_submit_maybe(complete_maybe) .on_submit_maybe(
complete_maybe.clone().map(|maybe| move |_| maybe.clone()),
)
.into(), .into(),
])); ]));
} }
@ -4128,7 +4142,7 @@ impl Application for App {
auth_tx: auth_tx.clone(), auth_tx: auth_tx.clone(),
}) })
}) })
.on_submit(Message::DialogComplete); .on_submit(|_| Message::DialogComplete);
if !id_assigned { if !id_assigned {
input = input.id(self.dialog_text_input.clone()); input = input.id(self.dialog_text_input.clone());
id_assigned = true; id_assigned = true;
@ -4150,7 +4164,7 @@ impl Application for App {
auth_tx: auth_tx.clone(), auth_tx: auth_tx.clone(),
}) })
}) })
.on_submit(Message::DialogComplete); .on_submit(|_| Message::DialogComplete);
if !id_assigned { if !id_assigned {
input = input.id(self.dialog_text_input.clone()); input = input.id(self.dialog_text_input.clone());
id_assigned = true; id_assigned = true;
@ -4173,7 +4187,7 @@ impl Application for App {
auth_tx: auth_tx.clone(), auth_tx: auth_tx.clone(),
}) })
}) })
.on_submit(Message::DialogComplete); .on_submit(|_| Message::DialogComplete);
if !id_assigned { if !id_assigned {
input = input.id(self.dialog_text_input.clone()); input = input.id(self.dialog_text_input.clone());
} }
@ -4309,7 +4323,9 @@ impl Application for App {
dir: *dir, dir: *dir,
}) })
}) })
.on_submit_maybe(complete_maybe) .on_submit_maybe(
complete_maybe.clone().map(|maybe| move |_| maybe.clone()),
)
.into(), .into(),
]) ])
.spacing(space_xxs), .spacing(space_xxs),
@ -4469,7 +4485,9 @@ impl Application for App {
dir: *dir, dir: *dir,
}) })
}) })
.on_submit_maybe(complete_maybe) .on_submit_maybe(
complete_maybe.clone().map(|maybe| move |_| maybe.clone()),
)
.into(), .into(),
]) ])
.spacing(space_xxs), .spacing(space_xxs),
@ -4569,7 +4587,6 @@ impl Application for App {
widget::button::standard(fl!("keep")).on_press(Message::DialogCancel), widget::button::standard(fl!("keep")).on_press(Message::DialogCancel),
), ),
}; };
Some(dialog.into()) Some(dialog.into())
} }
@ -4849,9 +4866,9 @@ impl Application for App {
None => { None => {
//TODO: distinct views per monitor in desktop mode //TODO: distinct views per monitor in desktop mode
return self.view_main().map(|message| match message { return self.view_main().map(|message| match message {
app::Message::App(app) => app, cosmic::Action::App(app) => app,
app::Message::Cosmic(cosmic) => Message::Cosmic(cosmic), cosmic::Action::Cosmic(cosmic) => Message::Cosmic(cosmic),
app::Message::None => Message::None, cosmic::Action::None => Message::None,
}); });
} }
}; };

View file

@ -2,7 +2,7 @@
// SPDX-License-Identifier: GPL-3.0-only // SPDX-License-Identifier: GPL-3.0-only
use cosmic::{ use cosmic::{
app::{self, context_drawer, cosmic::Cosmic, message, Core, Task}, app::{self, context_drawer, cosmic::Cosmic, Core, Task},
cosmic_config, cosmic_theme, executor, cosmic_config, cosmic_theme, executor,
iced::{ iced::{
event, event,
@ -46,7 +46,7 @@ use crate::{
}; };
#[derive(Clone, Debug)] #[derive(Clone, Debug)]
pub struct DialogMessage(app::Message<Message>); pub struct DialogMessage(cosmic::Action<Message>);
#[derive(Clone, Debug)] #[derive(Clone, Debug)]
pub enum DialogResult { pub enum DialogResult {
@ -200,10 +200,10 @@ impl<M: Send + 'static> Dialog<M> {
on_result: Box::new(on_result), on_result: Box::new(on_result),
}, },
Task::batch([ Task::batch([
window_command.map(|_id| message::none()), window_command.map(|_id| cosmic::action::none()),
cosmic_command cosmic_command
.map(DialogMessage) .map(DialogMessage)
.map(move |message| app::Message::App(mapper(message))), .map(move |message| cosmic::action::app(mapper(message))),
]), ]),
) )
} }
@ -215,7 +215,7 @@ impl<M: Send + 'static> Dialog<M> {
.app .app
.update_title() .update_title()
.map(DialogMessage) .map(DialogMessage)
.map(move |message| app::Message::App(mapper(message))) .map(move |message| cosmic::action::app(mapper(message)))
} }
pub fn set_accept_label(&mut self, accept_label: impl Into<String>) { pub fn set_accept_label(&mut self, accept_label: impl Into<String>) {
@ -246,7 +246,7 @@ impl<M: Send + 'static> Dialog<M> {
.app .app
.rescan_tab() .rescan_tab()
.map(DialogMessage) .map(DialogMessage)
.map(move |message| app::Message::App(mapper(message))) .map(move |message| cosmic::action::app(mapper(message)))
} }
pub fn subscription(&self) -> Subscription<M> { pub fn subscription(&self) -> Subscription<M> {
@ -263,12 +263,12 @@ impl<M: Send + 'static> Dialog<M> {
.cosmic .cosmic
.update(message.0) .update(message.0)
.map(DialogMessage) .map(DialogMessage)
.map(move |message| app::Message::App(mapper(message))); .map(move |message| cosmic::action::app(mapper(message)));
if let Some(result) = self.cosmic.app.result_opt.take() { if let Some(result) = self.cosmic.app.result_opt.take() {
let on_result_message = (self.on_result)(result); let on_result_message = (self.on_result)(result);
Task::batch([ Task::batch([
command, command,
Task::perform(async move { app::Message::App(on_result_message) }, |x| x), Task::perform(async move { cosmic::action::app(on_result_message) }, |x| x),
]) ])
} else { } else {
command command
@ -327,6 +327,7 @@ enum Message {
SearchActivate, SearchActivate,
SearchClear, SearchClear,
SearchInput(String), SearchInput(String),
Surface(cosmic::surface::Action),
#[allow(clippy::enum_variant_names)] #[allow(clippy::enum_variant_names)]
TabMessage(tab::Message), TabMessage(tab::Message),
TabRescan(Location, Option<tab::Item>, Vec<tab::Item>), TabRescan(Location, Option<tab::Item>, Vec<tab::Item>),
@ -419,7 +420,7 @@ impl App {
widget::text_input("", filename) widget::text_input("", filename)
.id(self.filename_id.clone()) .id(self.filename_id.clone())
.on_input(Message::Filename) .on_input(Message::Filename)
.on_submit(Message::Save(false)), .on_submit(|_| Message::Save(false)),
); );
} }
@ -531,11 +532,11 @@ impl App {
let location2 = location.clone(); let location2 = location.clone();
match tokio::task::spawn_blocking(move || location2.scan(icon_sizes)).await { match tokio::task::spawn_blocking(move || location2.scan(icon_sizes)).await {
Ok((parent_item_opt, items)) => { Ok((parent_item_opt, items)) => {
message::app(Message::TabRescan(location, parent_item_opt, items)) cosmic::action::app(Message::TabRescan(location, parent_item_opt, items))
} }
Err(err) => { Err(err) => {
log::warn!("failed to rescan: {}", err); log::warn!("failed to rescan: {}", err);
message::none() cosmic::action::none()
} }
} }
}, },
@ -921,7 +922,9 @@ impl Application for App {
name, name,
}) })
}) })
.on_submit_maybe(complete_maybe) .on_submit_maybe(
complete_maybe.clone().map(|maybe| move |_| maybe.clone()),
)
.into(), .into(),
]) ])
.spacing(space_xxs), .spacing(space_xxs),
@ -997,7 +1000,7 @@ impl Application for App {
elements elements
} }
fn nav_bar(&self) -> Option<Element<message::Message<Self::Message>>> { fn nav_bar(&self) -> Option<Element<cosmic::Action<Self::Message>>> {
if !self.core().nav_bar_active() { if !self.core().nav_bar_active() {
return None; return None;
} }
@ -1005,9 +1008,9 @@ impl Application for App {
let nav_model = self.nav_model()?; let nav_model = self.nav_model()?;
let mut nav = cosmic::widget::nav_bar(nav_model, |entity| { let mut nav = cosmic::widget::nav_bar(nav_model, |entity| {
cosmic::app::Message::Cosmic(cosmic::app::cosmic::Message::NavBar(entity)) cosmic::action::cosmic(cosmic::app::Action::NavBar(entity))
}) })
//TODO .on_close(|entity| cosmic::app::Message::App(Message::NavBarClose(entity))) //TODO .on_close(|entity| cosmic::cosmic::action::app(Message::NavBarClose(entity)))
.close_icon( .close_icon(
widget::icon::from_name("media-eject-symbolic") widget::icon::from_name("media-eject-symbolic")
.size(16) .size(16)
@ -1043,7 +1046,9 @@ impl Application for App {
if let Some(data) = self.nav_model.data::<MounterData>(entity) { if let Some(data) = self.nav_model.data::<MounterData>(entity) {
if let Some(mounter) = MOUNTERS.get(&data.0) { if let Some(mounter) = MOUNTERS.get(&data.0) {
return mounter.mount(data.1.clone()).map(|_| message::none()); return mounter
.mount(data.1.clone())
.map(|_| cosmic::action::none());
} }
} }
Task::none() Task::none()
@ -1416,11 +1421,9 @@ impl Application for App {
commands.push(Task::batch([self.update_watcher(), self.rescan_tab()])); commands.push(Task::batch([self.update_watcher(), self.rescan_tab()]));
} }
tab::Command::Iced(iced_command) => { tab::Command::Iced(iced_command) => {
commands.push( commands.push(iced_command.0.map(|tab_message| {
iced_command.0.map(|tab_message| { cosmic::action::app(Message::TabMessage(tab_message))
message::app(Message::TabMessage(tab_message)) }));
}),
);
} }
tab::Command::OpenFile(_item_path) => { tab::Command::OpenFile(_item_path) => {
if self.flags.kind.save() { if self.flags.kind.save() {
@ -1575,6 +1578,11 @@ impl Application for App {
tab::View::Grid => zoom_out(&mut self.tab.config.icon_sizes.grid, 50, 500), tab::View::Grid => zoom_out(&mut self.tab.config.icon_sizes.grid, 50, 500),
} }
} }
Message::Surface(a) => {
return cosmic::task::message(cosmic::Action::Cosmic(
cosmic::app::Action::Surface(a),
));
}
} }
Task::none() Task::none()

View file

@ -1560,15 +1560,18 @@ impl Item {
if !mime_apps.is_empty() { if !mime_apps.is_empty() {
settings.push( settings.push(
widget::settings::item::builder(fl!("open-with")).control( widget::settings::item::builder(fl!("open-with")).control(
widget::dropdown( Element::from(
mime_apps, widget::dropdown(
mime_apps.iter().position(|x| x.is_default), mime_apps,
|index| { mime_apps.iter().position(|x| x.is_default),
let mime_app = &mime_apps[index]; move |index| index,
Message::SetOpenWith(self.mime.clone(), mime_app.id.clone()) )
}, .icons(mime_app_cache.icons(&self.mime)),
) )
.icons(mime_app_cache.icons(&self.mime)), .map(|index| {
let mime_app = &mime_apps[index];
Message::SetOpenWith(self.mime.clone(), mime_app.id.clone())
}),
), ),
); );
} }
@ -3771,7 +3774,7 @@ impl Tab {
location.with_path(PathBuf::from(input)).into(), location.with_path(PathBuf::from(input)).into(),
)) ))
}) })
.on_submit(Message::EditLocationSubmit) .on_submit(|_| Message::EditLocationSubmit)
.line_height(1.0); .line_height(1.0);
let mut popover = let mut popover =
widget::popover(text_input).position(widget::popover::Position::Bottom); widget::popover(text_input).position(widget::popover::Position::Bottom);