save is_attention session state

This commit is contained in:
yggverse 2024-11-11 16:53:06 +02:00
parent 8917d14908
commit 57cdc4cee9
4 changed files with 21 additions and 13 deletions

View File

@ -126,9 +126,6 @@ impl Tab {
), ),
)); ));
// Apply tab attention request
item.widget().gobject().set_needs_attention(is_attention);
// Register dynamically created tab components in the HashMap index // Register dynamically created tab components in the HashMap index
self.index self.index
.borrow_mut() .borrow_mut()
@ -311,6 +308,7 @@ impl Tab {
&self.widget.gobject().page_position(item.widget().gobject()), &self.widget.gobject().page_position(item.widget().gobject()),
&item.widget().gobject().is_pinned(), &item.widget().gobject().is_pinned(),
&item.widget().gobject().is_selected(), &item.widget().gobject().is_selected(),
&item.widget().gobject().needs_attention(),
)?; )?;
} }
} }

View File

@ -37,7 +37,7 @@ impl Item {
options: (Option<i32>, Option<String>, bool, bool, bool, bool), options: (Option<i32>, Option<String>, bool, bool, bool, bool),
) -> Self { ) -> Self {
// Get item options from tuple // Get item options from tuple
let (position, request, is_pinned, is_selected, _is_attention, is_load) = options; let (position, request, is_pinned, is_selected, is_attention, is_load) = options;
// Generate unique ID for new page components // Generate unique ID for new page components
let id = uuid_string_random(); let id = uuid_string_random();
@ -59,8 +59,7 @@ impl Item {
page.widget().gobject(), page.widget().gobject(),
None, None,
position, position,
is_pinned, (is_pinned, is_selected, is_attention),
is_selected,
)); ));
// Init events // Init events
@ -155,7 +154,7 @@ impl Item {
None, None,
record.is_pinned, record.is_pinned,
record.is_selected, record.is_selected,
false, record.is_attention,
false, false,
), ),
)); ));
@ -181,6 +180,7 @@ impl Item {
page_position: &i32, page_position: &i32,
is_pinned: &bool, is_pinned: &bool,
is_selected: &bool, is_selected: &bool,
is_attention: &bool,
) -> Result<(), String> { ) -> Result<(), String> {
match Database::add( match Database::add(
transaction, transaction,
@ -188,6 +188,7 @@ impl Item {
page_position, page_position,
is_pinned, is_pinned,
is_selected, is_selected,
is_attention,
) { ) {
Ok(_) => { Ok(_) => {
let id = Database::last_insert_id(transaction); let id = Database::last_insert_id(transaction);

View File

@ -5,6 +5,7 @@ pub struct Table {
// 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_pinned: bool,
pub is_selected: bool, pub is_selected: bool,
pub is_attention: bool,
} }
pub struct Database { pub struct Database {
@ -20,7 +21,8 @@ impl Database {
`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_pinned` INTEGER NOT NULL,
`is_selected` INTEGER NOT NULL `is_selected` INTEGER NOT NULL,
`is_attention` INTEGER NOT NULL
)", )",
[], [],
) )
@ -32,19 +34,22 @@ impl Database {
page_position: &i32, page_position: &i32,
is_pinned: &bool, is_pinned: &bool,
is_selected: &bool, is_selected: &bool,
is_attention: &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_pinned`,
`is_selected` `is_selected`,
) VALUES (?, ?, ?, ?)", `is_attention`
) VALUES (?, ?, ?, ?, ?)",
[ [
app_browser_window_tab_id, app_browser_window_tab_id,
&(*page_position as i64), &(*page_position as i64),
&(*is_pinned as i64), &(*is_pinned as i64),
&(*is_selected as i64), &(*is_selected as i64),
&(*is_attention as i64),
], ],
) )
} }
@ -54,7 +59,8 @@ impl Database {
"SELECT `id`, "SELECT `id`,
`app_browser_window_tab_id`, `app_browser_window_tab_id`,
`is_pinned`, `is_pinned`,
`is_selected` `is_selected`,
`is_attention`
FROM `app_browser_window_tab_item` FROM `app_browser_window_tab_item`
WHERE `app_browser_window_tab_id` = ? WHERE `app_browser_window_tab_id` = ?
ORDER BY `page_position` ASC", // just order by, no store in struct wanted ORDER BY `page_position` ASC", // just order by, no store in struct wanted
@ -66,6 +72,7 @@ impl Database {
// app_browser_window_tab_id: row.get(1)?, not in use // app_browser_window_tab_id: row.get(1)?, not in use
is_pinned: row.get(2)?, is_pinned: row.get(2)?,
is_selected: row.get(3)?, is_selected: row.get(3)?,
is_attention: row.get(4)?,
}) })
})?; })?;

View File

@ -20,8 +20,7 @@ impl Widget {
child: &impl IsA<gtk::Widget>, child: &impl IsA<gtk::Widget>,
title: Option<&str>, title: Option<&str>,
position: Option<i32>, position: Option<i32>,
is_pinned: bool, state: (bool, bool, bool),
is_selected: bool,
) -> Self { ) -> Self {
let gobject = match position { let gobject = match position {
Some(value) => { Some(value) => {
@ -37,6 +36,9 @@ impl Widget {
None => tab_view.append(child), None => tab_view.append(child),
}; };
let (is_pinned, is_selected, is_attention) = state;
gobject.set_needs_attention(is_attention);
gobject.set_keyword(keyword); gobject.set_keyword(keyword);
gobject.set_title(match title { gobject.set_title(match title {