commit
7c59e94308
1 changed files with 20 additions and 0 deletions
20
src/main.rs
20
src/main.rs
|
|
@ -7,6 +7,8 @@ use cosmic::iced::clipboard::dnd::DndAction;
|
||||||
use cosmic::iced_core::keyboard::key::Named;
|
use cosmic::iced_core::keyboard::key::Named;
|
||||||
use cosmic::widget::menu::action::MenuAction;
|
use cosmic::widget::menu::action::MenuAction;
|
||||||
use cosmic::widget::menu::key_bind::KeyBind;
|
use cosmic::widget::menu::key_bind::KeyBind;
|
||||||
|
use cosmic::widget::pane_grid::Pane;
|
||||||
|
use cosmic::widget::segmented_button::ReorderEvent;
|
||||||
use cosmic::{
|
use cosmic::{
|
||||||
Application, ApplicationExt, Element, action,
|
Application, ApplicationExt, Element, action,
|
||||||
app::{Core, Settings, Task, context_drawer},
|
app::{Core, Settings, Task, context_drawer},
|
||||||
|
|
@ -407,6 +409,7 @@ pub enum Message {
|
||||||
ProfileRemove(ProfileId),
|
ProfileRemove(ProfileId),
|
||||||
ProfileSyntaxTheme(ProfileId, ColorSchemeKind, usize),
|
ProfileSyntaxTheme(ProfileId, ColorSchemeKind, usize),
|
||||||
ProfileTabTitle(ProfileId, String),
|
ProfileTabTitle(ProfileId, String),
|
||||||
|
ReorderTab(Pane, ReorderEvent),
|
||||||
Surface(surface::Action),
|
Surface(surface::Action),
|
||||||
SelectAll(Option<segmented_button::Entity>),
|
SelectAll(Option<segmented_button::Entity>),
|
||||||
ShowAdvancedFontSettings(bool),
|
ShowAdvancedFontSettings(bool),
|
||||||
|
|
@ -3093,6 +3096,20 @@ impl Application for App {
|
||||||
cosmic::app::Action::Surface(a),
|
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()
|
Task::none()
|
||||||
|
|
@ -3198,6 +3215,9 @@ impl Application for App {
|
||||||
tab_column = tab_column.push(
|
tab_column = tab_column.push(
|
||||||
widget::container(
|
widget::container(
|
||||||
widget::tab_bar::horizontal(tab_model)
|
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_height(32)
|
||||||
.button_spacing(space_xxs)
|
.button_spacing(space_xxs)
|
||||||
.on_activate(Message::TabActivate)
|
.on_activate(Message::TabActivate)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue