mirror of
https://github.com/YGGverse/Yoda.git
synced 2026-03-31 16:45:27 +00:00
implement tab pin status on session save/restore
This commit is contained in:
parent
fb8ef48917
commit
50f56c68f4
4 changed files with 26 additions and 3 deletions
|
|
@ -91,6 +91,7 @@ impl Tab {
|
|||
self.action_tab_page_navigation_reload.clone(),
|
||||
self.action_update.clone(),
|
||||
// Options
|
||||
false,
|
||||
true,
|
||||
);
|
||||
|
||||
|
|
@ -246,6 +247,7 @@ impl Tab {
|
|||
transaction,
|
||||
&id,
|
||||
&self.widget.gobject().page_position(item.gobject()),
|
||||
&item.gobject().is_pinned(),
|
||||
&item.gobject().is_selected(),
|
||||
)?;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,6 +34,7 @@ impl Item {
|
|||
action_tab_page_navigation_reload: Arc<SimpleAction>,
|
||||
action_update: Arc<SimpleAction>,
|
||||
// Options
|
||||
is_pinned: bool,
|
||||
is_selected: bool,
|
||||
) -> Arc<Self> {
|
||||
// Generate unique ID for new page components
|
||||
|
|
@ -49,7 +50,14 @@ impl Item {
|
|||
action_update.clone(),
|
||||
);
|
||||
|
||||
let widget = Widget::new_arc(id.as_str(), tab_view, page.gobject(), None, is_selected); // @TODO
|
||||
let widget = Widget::new_arc(
|
||||
id.as_str(),
|
||||
tab_view,
|
||||
page.gobject(),
|
||||
None,
|
||||
is_pinned,
|
||||
is_selected,
|
||||
); // @TODO
|
||||
|
||||
// Return struct
|
||||
Arc::new(Self { id, page, widget })
|
||||
|
|
@ -133,6 +141,7 @@ impl Item {
|
|||
action_tab_page_navigation_reload.clone(),
|
||||
action_update.clone(),
|
||||
// Options
|
||||
record.is_pinned,
|
||||
record.is_selected,
|
||||
);
|
||||
|
||||
|
|
@ -156,12 +165,14 @@ impl Item {
|
|||
transaction: &Transaction,
|
||||
app_browser_window_tab_id: &i64,
|
||||
page_position: &i32,
|
||||
is_pinned: &bool,
|
||||
is_selected: &bool,
|
||||
) -> Result<(), String> {
|
||||
match Database::add(
|
||||
transaction,
|
||||
app_browser_window_tab_id,
|
||||
page_position,
|
||||
is_pinned,
|
||||
is_selected,
|
||||
) {
|
||||
Ok(_) => {
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ use sqlite::{Error, Transaction};
|
|||
pub struct Table {
|
||||
pub id: i64,
|
||||
// pub app_browser_window_tab_id: i64, not in use
|
||||
pub is_pinned: bool,
|
||||
pub is_selected: bool,
|
||||
}
|
||||
|
||||
|
|
@ -18,6 +19,7 @@ impl Database {
|
|||
`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
|
||||
`app_browser_window_tab_id` INTEGER NOT NULL,
|
||||
`page_position` INTEGER NOT NULL,
|
||||
`is_pinned` INTEGER NOT NULL,
|
||||
`is_selected` INTEGER NOT NULL
|
||||
)",
|
||||
[],
|
||||
|
|
@ -28,17 +30,20 @@ impl Database {
|
|||
tx: &Transaction,
|
||||
app_browser_window_tab_id: &i64,
|
||||
page_position: &i32,
|
||||
is_pinned: &bool,
|
||||
is_selected: &bool,
|
||||
) -> Result<usize, Error> {
|
||||
tx.execute(
|
||||
"INSERT INTO `app_browser_window_tab_item` (
|
||||
`app_browser_window_tab_id`,
|
||||
`page_position`,
|
||||
`is_pinned`,
|
||||
`is_selected`
|
||||
) VALUES (?, ?, ?)",
|
||||
) VALUES (?, ?, ?, ?)",
|
||||
[
|
||||
app_browser_window_tab_id,
|
||||
&(*page_position as i64),
|
||||
&(*is_pinned as i64),
|
||||
&(*is_selected as i64),
|
||||
],
|
||||
)
|
||||
|
|
@ -48,6 +53,7 @@ impl Database {
|
|||
let mut stmt = tx.prepare(
|
||||
"SELECT `id`,
|
||||
`app_browser_window_tab_id`,
|
||||
`is_pinned`,
|
||||
`is_selected`
|
||||
FROM `app_browser_window_tab_item`
|
||||
WHERE `app_browser_window_tab_id` = ?
|
||||
|
|
@ -58,7 +64,8 @@ impl Database {
|
|||
Ok(Table {
|
||||
id: row.get(0)?,
|
||||
// app_browser_window_tab_id: row.get(1)?, not in use
|
||||
is_selected: row.get(2)?,
|
||||
is_pinned: row.get(2)?,
|
||||
is_selected: row.get(3)?,
|
||||
})
|
||||
})?;
|
||||
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ impl Widget {
|
|||
tab_view: &TabView,
|
||||
page: &Box,
|
||||
title: Option<&str>,
|
||||
is_pinned: bool,
|
||||
is_selected: bool,
|
||||
) -> Arc<Self> {
|
||||
let gobject = tab_view.append(page);
|
||||
|
|
@ -26,6 +27,8 @@ impl Widget {
|
|||
None => DEFAULT_TITLE,
|
||||
});
|
||||
|
||||
tab_view.set_page_pinned(&gobject, is_pinned);
|
||||
|
||||
if is_selected {
|
||||
tab_view.set_selected_page(&gobject);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue