From 5334df6fffb9a0aa94e7c72db32ce4bfed484cd6 Mon Sep 17 00:00:00 2001 From: Ashley Wulber Date: Thu, 2 May 2024 11:49:32 -0400 Subject: [PATCH] fix: allow DnD back to the home group --- src/app.rs | 20 +++++++------------- src/app_group.rs | 20 ++++++++++++++++++++ src/widgets/group.rs | 1 - 3 files changed, 27 insertions(+), 14 deletions(-) diff --git a/src/app.rs b/src/app.rs index 90db2ba..b6bba3d 100644 --- a/src/app.rs +++ b/src/app.rs @@ -544,10 +544,6 @@ impl cosmic::Application for CosmicAppLibrary { Message::FinishDndOffer(i, entry) => { self.offer_group = None; - if self.cur_group == i { - return Command::none(); - } - self.config.add_entry(i, &entry.id); if let Some(helper) = self.helper.as_ref() { if let Err(err) = self.config.write_entry(helper) { @@ -1062,15 +1058,13 @@ impl cosmic::Application for CosmicAppLibrary { group_height, spacing, ); - if i != 0 { - group_button = group_button - .on_finish(move |entry| Message::FinishDndOffer(i, entry)) - .on_cancel(Message::LeaveDndOffer) - .on_offer(Message::StartDndOffer(i)) - .on_dnd_command_produced(|c| { - Message::DndCommandProduced(DndCommand(Arc::new(c))) - }); - } + group_button = group_button + .on_finish(move |entry| Message::FinishDndOffer(i, entry)) + .on_cancel(Message::LeaveDndOffer) + .on_offer(Message::StartDndOffer(i)) + .on_dnd_command_produced(|c| { + Message::DndCommandProduced(DndCommand(Arc::new(c))) + }); group_row = group_row.push(group_button); } diff --git a/src/app_group.rs b/src/app_group.rs index 1b76a8b..cda985d 100644 --- a/src/app_group.rs +++ b/src/app_group.rs @@ -180,6 +180,26 @@ impl AppLibraryConfig { exclude.retain(|conf_id| conf_id != id); include.push(id.to_string()); } + } else { + // add to filter of all groups, forcing it to the Home group + for group in &mut self.groups { + match &mut group.filter { + FilterType::AppIds(ids) => { + ids.retain(|conf_id| conf_id != id); + } + FilterType::Categories { + categories: _, + exclude, + include, + } => { + include.retain(|conf_id| conf_id != id); + if exclude.iter().all(|conf_id| conf_id != id) { + exclude.push(id.to_string()); + } + } + FilterType::None => {} + } + } } } diff --git a/src/widgets/group.rs b/src/widgets/group.rs index 4b8f248..f9074fe 100644 --- a/src/widgets/group.rs +++ b/src/widgets/group.rs @@ -28,7 +28,6 @@ use cosmic::{ use super::application::MIME_TYPE; -/// A widget that can be dragged and dropped. #[allow(missing_debug_implementations)] pub struct GroupButton<'a, Message> { content: Element<'a, Message, cosmic::Theme, cosmic::Renderer>,