remove extra title member

This commit is contained in:
yggverse 2025-01-23 16:11:19 +02:00
parent 176d24da4f
commit 054c30b238
4 changed files with 26 additions and 43 deletions

View File

@ -61,7 +61,7 @@ impl Client {
// Reset widgets
self.subject.page.search.unset();
self.subject.page.input.unset();
self.subject.page.title.replace("Loading..".into());
self.subject.tab_page.set_title("Loading..");
self.subject
.page
.navigation
@ -91,7 +91,7 @@ impl Client {
status.set_description(Some(&format!(
"Scheme `{scheme}` yet not supported"
)));
subject.page.title.replace(status.title());
subject.tab_page.set_title(&status.title());
subject
.page
.navigation

View File

@ -129,8 +129,7 @@ impl Gemini {
todo!()*/
}
});
self.subject.page.title.replace("Titan input".into());
self.subject.tab_page.set_title("Titan input");
self.subject
.page
.navigation
@ -199,7 +198,7 @@ fn handle(
Some(1024),
);
}
subject.page.title.replace(title.into());
subject.tab_page.set_title(&title);
subject.page.navigation.request.widget.entry.set_progress_fraction(0.0);
subject.tab_page.set_loading(false);
redirects.replace(0); // reset
@ -271,7 +270,7 @@ fn handle(
}
},
);
subject.page.title.replace(status.title());
subject.tab_page.set_title(&status.title());
subject.page.navigation.request.widget.entry.set_progress_fraction(0.0);
subject.tab_page.set_loading(false);
redirects.replace(0); // reset
@ -294,7 +293,7 @@ fn handle(
subject.page.search.set(Some(widget.text_view));
// Update page meta
subject.page.title.replace(match widget.meta.title {
subject.tab_page.set_title(&match widget.meta.title {
Some(title) => title.into(), // @TODO
None => uri_to_title(&uri),
});
@ -313,7 +312,7 @@ fn handle(
Err(e) => {
let status = subject.page.content.to_status_failure();
status.set_description(Some(&e.to_string()));
subject.page.title.replace(status.title());
subject.tab_page.set_title(&status.title());
subject.page.navigation.request.widget.entry.set_progress_fraction(0.0);
subject.tab_page.set_loading(false);
redirects.replace(0); // reset
@ -348,13 +347,13 @@ fn handle(
move |result| {
match result {
Ok(buffer) => {
subject.page.title.replace(uri_to_title(&uri));
subject.tab_page.set_title(&uri_to_title(&uri));
subject.page.content.to_image(&Texture::for_pixbuf(&buffer));
}
Err(e) => {
let status = subject.page.content.to_status_failure();
status.set_description(Some(e.message()));
subject.page.title.replace(status.title());
subject.tab_page.set_title(&status.title());
}
}
subject.page.navigation.request.widget.entry.set_progress_fraction(0.0);
@ -367,7 +366,7 @@ fn handle(
let status = subject.page.content.to_status_failure();
status.set_description(Some(&e.to_string()));
subject.page.title.replace(status.title());
subject.tab_page.set_title(&status.title());
subject.page.navigation.request.widget.entry.set_progress_fraction(0.0);
subject.tab_page.set_loading(false);
redirects.replace(0); // reset
@ -381,7 +380,7 @@ fn handle(
.content
.to_status_mime(mime, Some((&subject.page.tab_action, &uri)));
status.set_description(Some(&format!("Content type `{mime}` yet not supported")));
subject.page.title.replace(status.title());
subject.tab_page.set_title(&status.title());
subject.page.navigation.request.widget.entry.set_progress_fraction(0.0);
subject.tab_page.set_loading(false);
redirects.replace(0); // reset
@ -390,7 +389,7 @@ fn handle(
None => {
let status = subject.page.content.to_status_failure();
status.set_description(Some("MIME type not found"));
subject.page.title.replace(status.title());
subject.tab_page.set_title(&status.title());
subject.page.navigation.request.widget.entry.set_progress_fraction(0.0);
subject.tab_page.set_loading(false);
redirects.replace(0); // reset
@ -428,7 +427,7 @@ fn handle(
if total > 5 {
let status = subject.page.content.to_status_failure();
status.set_description(Some("Redirection limit reached"));
subject.page.title.replace(status.title());
subject.tab_page.set_title(&status.title());
subject.page.navigation.request.widget.entry.set_progress_fraction(0.0);
subject.tab_page.set_loading(false);
redirects.replace(0); // reset
@ -439,7 +438,7 @@ fn handle(
|| uri.host() != target.host() {
let status = subject.page.content.to_status_failure();
status.set_description(Some("External redirects not allowed by protocol specification"));
subject.page.title.replace(status.title());
subject.tab_page.set_title(&status.title());
subject.page.navigation.request.widget.entry.set_progress_fraction(0.0);
subject.tab_page.set_loading(false);
redirects.replace(0); // reset
@ -459,7 +458,7 @@ fn handle(
Err(e) => {
let status = subject.page.content.to_status_failure();
status.set_description(Some(&e.to_string()));
subject.page.title.replace(status.title());
subject.tab_page.set_title(&status.title());
subject.page.navigation.request.widget.entry.set_progress_fraction(0.0);
subject.tab_page.set_loading(false);
redirects.replace(0); // reset
@ -468,7 +467,7 @@ fn handle(
None => {
let status = subject.page.content.to_status_failure();
status.set_description(Some("Redirection target not found"));
subject.page.title.replace(status.title());
subject.tab_page.set_title(&status.title());
subject.page.navigation.request.widget.entry.set_progress_fraction(0.0);
subject.tab_page.set_loading(false);
redirects.replace(0); // reset
@ -487,7 +486,7 @@ fn handle(
None => response.meta.status.to_string(),
}));
subject.page.title.replace(status.title());
subject.tab_page.set_title(&status.title());
subject.page.navigation.request.widget.entry.set_progress_fraction(0.0);
subject.tab_page.set_loading(false);
redirects.replace(0); // reset
@ -495,7 +494,7 @@ fn handle(
status => {
let _status = subject.page.content.to_status_failure();
_status.set_description(Some(&format!("Undefined status code `{status}`")));
subject.page.title.replace(_status.title());
subject.tab_page.set_title(&_status.title());
subject.page.navigation.request.widget.entry.set_progress_fraction(0.0);
subject.tab_page.set_loading(false);
redirects.replace(0); // reset
@ -505,7 +504,7 @@ fn handle(
Err(e) => {
let status = subject.page.content.to_status_failure();
status.set_description(Some(&e.to_string()));
subject.page.title.replace(status.title());
subject.tab_page.set_title(&status.title());
subject.page.navigation.request.widget.entry.set_progress_fraction(0.0);
subject.tab_page.set_loading(false);
redirects.replace(0); // reset

View File

@ -17,12 +17,11 @@ use super::{Action as TabAction, BrowserAction, Profile, WindowAction};
use gtk::{glib::GString, prelude::EditableExt};
use sqlite::Transaction;
use std::{cell::RefCell, rc::Rc};
use std::rc::Rc;
pub struct Page {
pub id: Rc<GString>,
pub profile: Rc<Profile>,
pub title: Rc<RefCell<GString>>,
// Actions
pub browser_action: Rc<BrowserAction>,
pub tab_action: Rc<TabAction>,
@ -71,7 +70,6 @@ impl Page {
Self {
id: id.clone(),
profile: profile.clone(),
title: Rc::new(RefCell::new("New page".into())),
// Actions
browser_action: browser_action.clone(),
tab_action: tab_action.clone(),
@ -152,7 +150,6 @@ impl Page {
Ok(records) => {
for record in records {
// Restore self by last record
self.title.replace(record.title.into());
// Delegate restore action to the item childs
self.navigation.restore(transaction, &record.id)?;
// Make initial page history snap using `navigation` values restored
@ -173,11 +170,7 @@ impl Page {
transaction: &Transaction,
app_browser_window_tab_item_id: i64,
) -> Result<(), String> {
match database::insert(
transaction,
app_browser_window_tab_item_id,
self.title.borrow().as_str(),
) {
match database::insert(transaction, app_browser_window_tab_item_id) {
Ok(_) => {
let id = database::last_insert_id(transaction);

View File

@ -3,7 +3,6 @@ use sqlite::{Error, Transaction};
pub struct Table {
pub id: i64,
// pub app_browser_window_tab_item_id: i64, not in use,
pub title: String,
}
pub fn init(tx: &Transaction) -> Result<usize, Error> {
@ -12,7 +11,6 @@ pub fn init(tx: &Transaction) -> Result<usize, Error> {
(
`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
`app_browser_window_tab_item_id` INTEGER NOT NULL,
`title` VARCHAR(1024),
FOREIGN KEY (`app_browser_window_tab_item_id`) REFERENCES `app_browser_window_tab_item`(`id`)
)",
@ -20,25 +18,19 @@ pub fn init(tx: &Transaction) -> Result<usize, Error> {
)
}
pub fn insert(
tx: &Transaction,
app_browser_window_tab_item_id: i64,
title: &str,
) -> Result<usize, Error> {
pub fn insert(tx: &Transaction, app_browser_window_tab_item_id: i64) -> Result<usize, Error> {
tx.execute(
"INSERT INTO `app_browser_window_tab_item_page` (
`app_browser_window_tab_item_id`,
`title`
) VALUES (?, ?)",
(app_browser_window_tab_item_id, title),
`app_browser_window_tab_item_id`
) VALUES (?)",
[app_browser_window_tab_item_id],
)
}
pub fn select(tx: &Transaction, app_browser_window_tab_item_id: i64) -> Result<Vec<Table>, Error> {
let mut stmt = tx.prepare(
"SELECT `id`,
`app_browser_window_tab_item_id`,
`title`
`app_browser_window_tab_item_id`
FROM `app_browser_window_tab_item_page`
WHERE `app_browser_window_tab_item_id` = ?",
)?;
@ -47,7 +39,6 @@ pub fn select(tx: &Transaction, app_browser_window_tab_item_id: i64) -> Result<V
Ok(Table {
id: row.get(0)?,
// app_browser_window_tab_item_id: row.get(1)?, not in use
title: row.get(2)?,
})
})?;