From 57cdc4cee95028fb652c1c643f85171cf06764ba Mon Sep 17 00:00:00 2001 From: yggverse Date: Mon, 11 Nov 2024 16:53:06 +0200 Subject: [PATCH] save is_attention session state --- src/app/browser/window/tab.rs | 4 +--- src/app/browser/window/tab/item.rs | 9 +++++---- src/app/browser/window/tab/item/database.rs | 15 +++++++++++---- src/app/browser/window/tab/item/widget.rs | 6 ++++-- 4 files changed, 21 insertions(+), 13 deletions(-) diff --git a/src/app/browser/window/tab.rs b/src/app/browser/window/tab.rs index c3e8e069..40f1715f 100644 --- a/src/app/browser/window/tab.rs +++ b/src/app/browser/window/tab.rs @@ -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 self.index .borrow_mut() @@ -311,6 +308,7 @@ impl Tab { &self.widget.gobject().page_position(item.widget().gobject()), &item.widget().gobject().is_pinned(), &item.widget().gobject().is_selected(), + &item.widget().gobject().needs_attention(), )?; } } diff --git a/src/app/browser/window/tab/item.rs b/src/app/browser/window/tab/item.rs index 5fc1f745..2e707224 100644 --- a/src/app/browser/window/tab/item.rs +++ b/src/app/browser/window/tab/item.rs @@ -37,7 +37,7 @@ impl Item { options: (Option, Option, bool, bool, bool, bool), ) -> Self { // 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 let id = uuid_string_random(); @@ -59,8 +59,7 @@ impl Item { page.widget().gobject(), None, position, - is_pinned, - is_selected, + (is_pinned, is_selected, is_attention), )); // Init events @@ -155,7 +154,7 @@ impl Item { None, record.is_pinned, record.is_selected, - false, + record.is_attention, false, ), )); @@ -181,6 +180,7 @@ impl Item { page_position: &i32, is_pinned: &bool, is_selected: &bool, + is_attention: &bool, ) -> Result<(), String> { match Database::add( transaction, @@ -188,6 +188,7 @@ impl Item { page_position, is_pinned, is_selected, + is_attention, ) { Ok(_) => { let id = Database::last_insert_id(transaction); diff --git a/src/app/browser/window/tab/item/database.rs b/src/app/browser/window/tab/item/database.rs index b4519fed..c67fdf8b 100644 --- a/src/app/browser/window/tab/item/database.rs +++ b/src/app/browser/window/tab/item/database.rs @@ -5,6 +5,7 @@ pub struct Table { // pub app_browser_window_tab_id: i64, not in use pub is_pinned: bool, pub is_selected: bool, + pub is_attention: bool, } pub struct Database { @@ -20,7 +21,8 @@ impl Database { `app_browser_window_tab_id` INTEGER NOT NULL, `page_position` 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, is_pinned: &bool, is_selected: &bool, + is_attention: &bool, ) -> Result { tx.execute( "INSERT INTO `app_browser_window_tab_item` ( `app_browser_window_tab_id`, `page_position`, `is_pinned`, - `is_selected` - ) VALUES (?, ?, ?, ?)", + `is_selected`, + `is_attention` + ) VALUES (?, ?, ?, ?, ?)", [ app_browser_window_tab_id, &(*page_position as i64), &(*is_pinned as i64), &(*is_selected as i64), + &(*is_attention as i64), ], ) } @@ -54,7 +59,8 @@ impl Database { "SELECT `id`, `app_browser_window_tab_id`, `is_pinned`, - `is_selected` + `is_selected`, + `is_attention` FROM `app_browser_window_tab_item` WHERE `app_browser_window_tab_id` = ? 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 is_pinned: row.get(2)?, is_selected: row.get(3)?, + is_attention: row.get(4)?, }) })?; diff --git a/src/app/browser/window/tab/item/widget.rs b/src/app/browser/window/tab/item/widget.rs index 52253be7..72489358 100644 --- a/src/app/browser/window/tab/item/widget.rs +++ b/src/app/browser/window/tab/item/widget.rs @@ -20,8 +20,7 @@ impl Widget { child: &impl IsA, title: Option<&str>, position: Option, - is_pinned: bool, - is_selected: bool, + state: (bool, bool, bool), ) -> Self { let gobject = match position { Some(value) => { @@ -37,6 +36,9 @@ impl Widget { 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_title(match title {