drop options not in use

This commit is contained in:
yggverse 2024-10-11 02:40:08 +03:00
parent 6684b09ae2
commit 4370d1d971
8 changed files with 14 additions and 69 deletions

View File

@ -55,8 +55,6 @@ impl Browser {
action_tab_pin.clone(), action_tab_pin.clone(),
)); ));
//window.gobject().append(header.gobject());
// Init widget // Init widget
let widget = Arc::new(Widget::new(window.gobject())); let widget = Arc::new(Widget::new(window.gobject()));
@ -119,7 +117,7 @@ impl Browser {
action_tab_append.connect_activate({ action_tab_append.connect_activate({
let window = window.clone(); let window = window.clone();
move |_, _| { move |_, _| {
window.tab_append(None); window.tab_append();
} }
}); });

View File

@ -83,8 +83,8 @@ impl Window {
} }
// Actions // Actions
pub fn tab_append(&self, tab_page_navigation_request_text: Option<GString>) { pub fn tab_append(&self) {
self.tab.append(tab_page_navigation_request_text, true); self.tab.append();
} }
pub fn tab_page_navigation_base(&self) { pub fn tab_page_navigation_base(&self) {

View File

@ -76,16 +76,9 @@ impl Tab {
} }
// Actions // Actions
pub fn append( pub fn append(&self) -> Arc<Item> {
&self,
page_navigation_request_text: Option<GString>,
is_initially_current: bool,
) -> Arc<Item> {
// Init new tab item // Init new tab item
let item = Item::new_arc( let item = Item::new_arc(
page_navigation_request_text.clone(),
is_initially_current,
// Actions
self.action_tab_page_navigation_base.clone(), self.action_tab_page_navigation_base.clone(),
self.action_tab_page_navigation_history_back.clone(), self.action_tab_page_navigation_history_back.clone(),
self.action_tab_page_navigation_history_forward.clone(), self.action_tab_page_navigation_history_forward.clone(),
@ -99,9 +92,7 @@ impl Tab {
// Append new page // Append new page
self.widget.gobject().add_page(item.gobject(), None); self.widget.gobject().add_page(item.gobject(), None);
if page_navigation_request_text.is_none() { item.page_navigation_request_grab_focus(); // @TODO
item.page_navigation_request_grab_focus(); // @TODO
}
item item
} }
@ -215,9 +206,7 @@ impl Tab {
// Append new Notebook page // Append new Notebook page
/* @TODO /* @TODO
self.widget.append( self.widget.append(
item.label(),
item.page(), item.page(),
item.is_initially_current(),
); */ ); */
} }
} }

View File

@ -20,16 +20,11 @@ pub struct Item {
id: GString, id: GString,
// Components // Components
page: Arc<Page>, page: Arc<Page>,
// Extras, useful for session restore
is_initially_current: bool,
} }
impl Item { impl Item {
// Construct // Construct
pub fn new_arc( pub fn new_arc(
page_navigation_request_text: Option<GString>,
is_initially_current: bool,
// Actions
action_tab_page_navigation_base: Arc<SimpleAction>, action_tab_page_navigation_base: Arc<SimpleAction>,
action_tab_page_navigation_history_back: Arc<SimpleAction>, action_tab_page_navigation_history_back: Arc<SimpleAction>,
action_tab_page_navigation_history_forward: Arc<SimpleAction>, action_tab_page_navigation_history_forward: Arc<SimpleAction>,
@ -42,7 +37,6 @@ impl Item {
// Init components // Init components
let page = Page::new_arc( let page = Page::new_arc(
id.clone(), id.clone(),
page_navigation_request_text.clone(),
action_tab_page_navigation_base.clone(), action_tab_page_navigation_base.clone(),
action_tab_page_navigation_history_back.clone(), action_tab_page_navigation_history_back.clone(),
action_tab_page_navigation_history_forward.clone(), action_tab_page_navigation_history_forward.clone(),
@ -51,11 +45,7 @@ impl Item {
); );
// Return struct // Return struct
Arc::new(Self { Arc::new(Self { id, page })
id,
is_initially_current,
page,
})
} }
// Actions // Actions
@ -131,9 +121,6 @@ impl Item {
for record in records { for record in records {
// Construct new item object // Construct new item object
let item = Item::new_arc( let item = Item::new_arc(
None,
record.is_initially_current,
// Actions
action_tab_page_navigation_base.clone(), action_tab_page_navigation_base.clone(),
action_tab_page_navigation_history_back.clone(), action_tab_page_navigation_history_back.clone(),
action_tab_page_navigation_history_forward.clone(), action_tab_page_navigation_history_forward.clone(),
@ -161,14 +148,8 @@ impl Item {
transaction: &Transaction, transaction: &Transaction,
app_browser_window_tab_id: &i64, app_browser_window_tab_id: &i64,
page_number: &u32, page_number: &u32,
is_initially_current: &bool,
) -> Result<(), String> { ) -> Result<(), String> {
match Database::add( match Database::add(transaction, app_browser_window_tab_id, page_number) {
transaction,
app_browser_window_tab_id,
page_number,
is_initially_current,
) {
Ok(_) => { Ok(_) => {
let id = Database::last_insert_id(transaction); let id = Database::last_insert_id(transaction);
@ -188,10 +169,6 @@ impl Item {
self.id.clone() self.id.clone()
} }
pub fn is_initially_current(&self) -> bool {
self.is_initially_current
}
pub fn gobject(&self) -> &Box { pub fn gobject(&self) -> &Box {
&self.page.gobject() &self.page.gobject()
} }

View File

@ -3,7 +3,6 @@ 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_initially_current: bool,
} }
pub struct Database { pub struct Database {
@ -17,8 +16,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_number` INTEGER NOT NULL, `page_number` INTEGER NOT NULL
`is_initially_current` INTEGER NOT NULL
)", )",
[], [],
) )
@ -28,36 +26,28 @@ impl Database {
tx: &Transaction, tx: &Transaction,
app_browser_window_tab_id: &i64, app_browser_window_tab_id: &i64,
page_number: &u32, page_number: &u32,
is_initially_current: &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_number`, `page_number`
`is_initially_current` ) VALUES (?, ?)",
) VALUES (?, ?, ?)", [app_browser_window_tab_id, &(*page_number as i64)],
[
app_browser_window_tab_id,
&(*page_number as i64),
&(*is_initially_current as i64),
],
) )
} }
pub fn records(tx: &Transaction, app_browser_window_tab_id: &i64) -> Result<Vec<Table>, Error> { pub fn records(tx: &Transaction, app_browser_window_tab_id: &i64) -> Result<Vec<Table>, Error> {
let mut stmt = tx.prepare( let mut stmt = tx.prepare(
"SELECT `id`, "SELECT `id`,
`app_browser_window_tab_id`, `app_browser_window_tab_id` FROM `app_browser_window_tab_item`
`is_initially_current` FROM `app_browser_window_tab_item` WHERE `app_browser_window_tab_id` = ?
WHERE `app_browser_window_tab_id` = ? ORDER BY `page_number` ASC", // just order by, no store in struct wanted
ORDER BY `page_number` ASC", // just order by, no store in struct wanted
)?; )?;
let result = stmt.query_map([app_browser_window_tab_id], |row| { let result = stmt.query_map([app_browser_window_tab_id], |row| {
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_initially_current: row.get(2)?,
}) })
})?; })?;

View File

@ -40,7 +40,6 @@ impl Page {
// Construct // Construct
pub fn new_arc( pub fn new_arc(
name: GString, name: GString,
navigation_request_text: Option<GString>,
action_tab_page_navigation_base: Arc<SimpleAction>, action_tab_page_navigation_base: Arc<SimpleAction>,
action_tab_page_navigation_history_back: Arc<SimpleAction>, action_tab_page_navigation_history_back: Arc<SimpleAction>,
action_tab_page_navigation_history_forward: Arc<SimpleAction>, action_tab_page_navigation_history_forward: Arc<SimpleAction>,
@ -56,7 +55,6 @@ impl Page {
// Init components // Init components
let content = Arc::new(Content::new(action_page_open.clone())); let content = Arc::new(Content::new(action_page_open.clone()));
let navigation = Arc::new(Navigation::new( let navigation = Arc::new(Navigation::new(
navigation_request_text,
action_tab_page_navigation_base.clone(), action_tab_page_navigation_base.clone(),
action_tab_page_navigation_history_back.clone(), action_tab_page_navigation_history_back.clone(),
action_tab_page_navigation_history_forward.clone(), action_tab_page_navigation_history_forward.clone(),

View File

@ -32,7 +32,6 @@ pub struct Navigation {
impl Navigation { impl Navigation {
pub fn new( pub fn new(
request_text: Option<GString>,
action_tab_page_navigation_base: Arc<SimpleAction>, action_tab_page_navigation_base: Arc<SimpleAction>,
action_tab_page_navigation_history_back: Arc<SimpleAction>, action_tab_page_navigation_history_back: Arc<SimpleAction>,
action_tab_page_navigation_history_forward: Arc<SimpleAction>, action_tab_page_navigation_history_forward: Arc<SimpleAction>,
@ -47,7 +46,6 @@ impl Navigation {
); );
let reload = Reload::new(action_tab_page_navigation_reload.clone()); let reload = Reload::new(action_tab_page_navigation_reload.clone());
let request = Request::new( let request = Request::new(
request_text,
action_update.clone(), action_update.clone(),
action_tab_page_navigation_reload.clone(), action_tab_page_navigation_reload.clone(),
); );

View File

@ -25,7 +25,6 @@ pub struct Request {
impl Request { impl Request {
// Construct // Construct
pub fn new( pub fn new(
text: Option<GString>,
// Actions // Actions
action_update: Arc<SimpleAction>, action_update: Arc<SimpleAction>,
action_tab_page_navigation_reload: Arc<SimpleAction>, // @TODO local `action_page_open`? action_tab_page_navigation_reload: Arc<SimpleAction>, // @TODO local `action_page_open`?
@ -34,10 +33,6 @@ impl Request {
let widget = Entry::builder() let widget = Entry::builder()
.placeholder_text("URL or search term...") .placeholder_text("URL or search term...")
.hexpand(true) .hexpand(true)
.text(match text {
Some(text) => text,
None => GString::new(),
})
.build(); .build();
// Connect events // Connect events