Skip to content

Commit

Permalink
fix: allow DnD back to the home group
Browse files Browse the repository at this point in the history
  • Loading branch information
wash2 committed May 2, 2024
1 parent 28d2429 commit 554f1e4
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 14 deletions.
20 changes: 7 additions & 13 deletions src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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);
}
Expand Down
20 changes: 20 additions & 0 deletions src/app_group.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 => {}
}
}
}
}

Expand Down
1 change: 0 additions & 1 deletion src/widgets/group.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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>,
Expand Down

0 comments on commit 554f1e4

Please sign in to comment.