insert new tab after current on middle click

This commit is contained in:
yggverse 2024-10-15 15:55:14 +03:00
parent 29588c0d0b
commit 18d0da99f2
5 changed files with 18 additions and 6 deletions

View File

@ -120,7 +120,7 @@ impl Browser {
action_tab_append.connect_activate({
let window = window.clone();
move |_, _| {
window.tab_append();
window.tab_append(None);
}
});

View File

@ -74,8 +74,8 @@ impl Window {
}
// Actions
pub fn tab_append(&self) {
self.tab.append();
pub fn tab_append(&self, position: Option<i32>) {
self.tab.append(position);
}
pub fn tab_page_navigation_base(&self) {

View File

@ -98,6 +98,10 @@ impl Tab {
action_tab_page_navigation_reload.clone(),
action_update.clone(),
// Options
match gobject.selected_page() {
Some(page) => Some(gobject.page_position(&page) + 1),
None => None,
},
false,
false,
);
@ -133,7 +137,7 @@ impl Tab {
}
// Actions
pub fn append(&self) -> Arc<Item> {
pub fn append(&self, position: Option<i32>) -> Arc<Item> {
// Init new tab item
let item = Item::new_arc(
self.gobject(),
@ -146,6 +150,7 @@ impl Tab {
self.action_tab_page_navigation_reload.clone(),
self.action_update.clone(),
// Options
position,
false,
true,
);
@ -328,7 +333,7 @@ impl Tab {
pub fn init(&self) {
// Append just one blank page if no tabs available after last session restore
if self.index.borrow().is_empty() {
self.append();
self.append(None);
}
// @TODO other/child features..

View File

@ -35,6 +35,7 @@ impl Item {
action_tab_page_navigation_reload: Arc<SimpleAction>,
action_update: Arc<SimpleAction>,
// Options
position: Option<i32>,
is_pinned: bool,
is_selected: bool,
) -> Arc<Self> {
@ -58,6 +59,7 @@ impl Item {
tab_view,
page.gobject(),
None,
position,
is_pinned,
is_selected,
); // @TODO
@ -149,6 +151,7 @@ impl Item {
action_tab_page_navigation_reload.clone(),
action_update.clone(),
// Options
None,
record.is_pinned,
record.is_selected,
);

View File

@ -20,10 +20,14 @@ impl Widget {
tab_view: &TabView,
page: &Box,
title: Option<&str>,
position: Option<i32>,
is_pinned: bool,
is_selected: bool,
) -> Arc<Self> {
let gobject = tab_view.append(page);
let gobject = match position {
Some(number) => tab_view.insert(page, number),
None => tab_view.append(page),
};
gobject.set_keyword(keyword);