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

View File

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

View File

@ -76,16 +76,9 @@ impl Tab {
}
// Actions
pub fn append(
&self,
page_navigation_request_text: Option<GString>,
is_initially_current: bool,
) -> Arc<Item> {
pub fn append(&self) -> Arc<Item> {
// Init new tab item
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_history_back.clone(),
self.action_tab_page_navigation_history_forward.clone(),
@ -99,9 +92,7 @@ impl Tab {
// Append new page
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
}
@ -215,9 +206,7 @@ impl Tab {
// Append new Notebook page
/* @TODO
self.widget.append(
item.label(),
item.page(),
item.is_initially_current(),
); */
}
}

View File

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

View File

@ -3,7 +3,6 @@ use sqlite::{Error, Transaction};
pub struct Table {
pub id: i64,
// pub app_browser_window_tab_id: i64, not in use
pub is_initially_current: bool,
}
pub struct Database {
@ -17,8 +16,7 @@ impl Database {
(
`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
`app_browser_window_tab_id` INTEGER NOT NULL,
`page_number` INTEGER NOT NULL,
`is_initially_current` INTEGER NOT NULL
`page_number` INTEGER NOT NULL
)",
[],
)
@ -28,36 +26,28 @@ impl Database {
tx: &Transaction,
app_browser_window_tab_id: &i64,
page_number: &u32,
is_initially_current: &bool,
) -> Result<usize, Error> {
tx.execute(
"INSERT INTO `app_browser_window_tab_item` (
`app_browser_window_tab_id`,
`page_number`,
`is_initially_current`
) VALUES (?, ?, ?)",
[
app_browser_window_tab_id,
&(*page_number as i64),
&(*is_initially_current as i64),
],
`page_number`
) VALUES (?, ?)",
[app_browser_window_tab_id, &(*page_number as i64)],
)
}
pub fn records(tx: &Transaction, app_browser_window_tab_id: &i64) -> Result<Vec<Table>, Error> {
let mut stmt = tx.prepare(
"SELECT `id`,
`app_browser_window_tab_id`,
`is_initially_current` FROM `app_browser_window_tab_item`
WHERE `app_browser_window_tab_id` = ?
ORDER BY `page_number` ASC", // just order by, no store in struct wanted
`app_browser_window_tab_id` FROM `app_browser_window_tab_item`
WHERE `app_browser_window_tab_id` = ?
ORDER BY `page_number` ASC", // just order by, no store in struct wanted
)?;
let result = stmt.query_map([app_browser_window_tab_id], |row| {
Ok(Table {
id: row.get(0)?,
// 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
pub fn new_arc(
name: GString,
navigation_request_text: Option<GString>,
action_tab_page_navigation_base: Arc<SimpleAction>,
action_tab_page_navigation_history_back: Arc<SimpleAction>,
action_tab_page_navigation_history_forward: Arc<SimpleAction>,
@ -56,7 +55,6 @@ impl Page {
// Init components
let content = Arc::new(Content::new(action_page_open.clone()));
let navigation = Arc::new(Navigation::new(
navigation_request_text,
action_tab_page_navigation_base.clone(),
action_tab_page_navigation_history_back.clone(),
action_tab_page_navigation_history_forward.clone(),

View File

@ -32,7 +32,6 @@ pub struct Navigation {
impl Navigation {
pub fn new(
request_text: Option<GString>,
action_tab_page_navigation_base: Arc<SimpleAction>,
action_tab_page_navigation_history_back: 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 request = Request::new(
request_text,
action_update.clone(),
action_tab_page_navigation_reload.clone(),
);

View File

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