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