Merge pull request #698 from pop-os/feat/tab-dnd

feat: tab dnd
This commit is contained in:
Jeremy Soller 2026-02-12 14:38:02 -07:00 committed by GitHub
commit 7c59e94308
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -7,6 +7,8 @@ use cosmic::iced::clipboard::dnd::DndAction;
use cosmic::iced_core::keyboard::key::Named;
use cosmic::widget::menu::action::MenuAction;
use cosmic::widget::menu::key_bind::KeyBind;
use cosmic::widget::pane_grid::Pane;
use cosmic::widget::segmented_button::ReorderEvent;
use cosmic::{
Application, ApplicationExt, Element, action,
app::{Core, Settings, Task, context_drawer},
@ -407,6 +409,7 @@ pub enum Message {
ProfileRemove(ProfileId),
ProfileSyntaxTheme(ProfileId, ColorSchemeKind, usize),
ProfileTabTitle(ProfileId, String),
ReorderTab(Pane, ReorderEvent),
Surface(surface::Action),
SelectAll(Option<segmented_button::Entity>),
ShowAdvancedFontSettings(bool),
@ -3093,6 +3096,20 @@ impl Application for App {
cosmic::app::Action::Surface(a),
));
}
Message::ReorderTab(
pane,
ReorderEvent {
dragged,
target,
position,
},
) => {
let Some(p) = self.pane_model.panes.get_mut(pane) else {
log::error!("Failed to find reordered tab model.");
return Task::none();
};
_ = p.reorder(dragged, target, position);
}
}
Task::none()
@ -3198,6 +3215,9 @@ impl Application for App {
tab_column = tab_column.push(
widget::container(
widget::tab_bar::horizontal(tab_model)
.enable_tab_drag(String::from("x-cosmic-term/tab"))
.on_reorder(move |event| Message::ReorderTab(pane, event))
.tab_drag_threshold(25.)
.button_height(32)
.button_spacing(space_xxs)
.on_activate(Message::TabActivate)