mirror of
https://github.com/YGGverse/Yoda.git
synced 2025-02-05 16:04:15 +00:00
remove deprecated features
This commit is contained in:
parent
e9e5c5ad22
commit
5ab51db946
@ -284,10 +284,7 @@ impl Tab {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn update(&self, item_id: Option<GString>) {
|
pub fn update(&self, item_id: Option<GString>) {
|
||||||
let key = match item_id {
|
let key = item_id.unwrap_or_default();
|
||||||
Some(value) => value,
|
|
||||||
None => GString::new(), // @TODO
|
|
||||||
};
|
|
||||||
|
|
||||||
match self.index.borrow().get(&key) {
|
match self.index.borrow().get(&key) {
|
||||||
Some(item) => {
|
Some(item) => {
|
||||||
@ -296,7 +293,7 @@ impl Tab {
|
|||||||
|
|
||||||
// Update tab title on loading indicator inactive
|
// Update tab title on loading indicator inactive
|
||||||
if !item.page.is_loading() {
|
if !item.page.is_loading() {
|
||||||
item.widget.tab_page.set_title(&item.page.title())
|
item.widget.tab_page.set_title(&item.page.title.borrow())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Update all tabs
|
// Update all tabs
|
||||||
@ -307,7 +304,7 @@ impl Tab {
|
|||||||
|
|
||||||
// Update tab title on loading indicator inactive
|
// Update tab title on loading indicator inactive
|
||||||
if !item.page.is_loading() {
|
if !item.page.is_loading() {
|
||||||
item.widget.tab_page.set_title(&item.page.title())
|
item.widget.tab_page.set_title(&item.page.title.borrow())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,3 @@
|
|||||||
use crate::tool::now;
|
|
||||||
|
|
||||||
use super::super::super::page::status::Status as PageStatus; // @TODO
|
|
||||||
|
|
||||||
use super::{Feature, Page};
|
use super::{Feature, Page};
|
||||||
use gtk::glib::{GString, UriFlags};
|
use gtk::glib::{GString, UriFlags};
|
||||||
use gtk::prelude::{EditableExt, FileExt};
|
use gtk::prelude::{EditableExt, FileExt};
|
||||||
@ -84,9 +80,6 @@ impl Gemini {
|
|||||||
// Reset widgets
|
// Reset widgets
|
||||||
self.page.search.unset();
|
self.page.search.unset();
|
||||||
self.page.input.unset();
|
self.page.input.unset();
|
||||||
self.page
|
|
||||||
.status
|
|
||||||
.replace(PageStatus::Loading { time: now() });
|
|
||||||
self.page.title.replace("Loading..".into());
|
self.page.title.replace("Loading..".into());
|
||||||
self.page
|
self.page
|
||||||
.browser_action
|
.browser_action
|
||||||
@ -136,7 +129,6 @@ impl Gemini {
|
|||||||
Some(1024),
|
Some(1024),
|
||||||
);
|
);
|
||||||
page.title.replace(title.into()); // @TODO
|
page.title.replace(title.into()); // @TODO
|
||||||
page.status.replace(PageStatus::Input { time: now() });
|
|
||||||
page.browser_action.update.activate(Some(&page.id));
|
page.browser_action.update.activate(Some(&page.id));
|
||||||
}
|
}
|
||||||
Status::SensitiveInput => {
|
Status::SensitiveInput => {
|
||||||
@ -151,7 +143,6 @@ impl Gemini {
|
|||||||
Some(1024),
|
Some(1024),
|
||||||
);
|
);
|
||||||
page.title.replace(title.into()); // @TODO
|
page.title.replace(title.into()); // @TODO
|
||||||
page.status.replace(PageStatus::Input { time: now() });
|
|
||||||
page.browser_action.update.activate(Some(&page.id));
|
page.browser_action.update.activate(Some(&page.id));
|
||||||
}
|
}
|
||||||
// https://geminiprotocol.net/docs/protocol-specification.gmi#status-20
|
// https://geminiprotocol.net/docs/protocol-specification.gmi#status-20
|
||||||
@ -221,7 +212,6 @@ impl Gemini {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
page.status.replace(PageStatus::Success { time: now() });
|
|
||||||
page.title.replace(status.title());
|
page.title.replace(status.title());
|
||||||
page.browser_action.update.activate(Some(&page.id));
|
page.browser_action.update.activate(Some(&page.id));
|
||||||
},
|
},
|
||||||
@ -248,8 +238,6 @@ impl Gemini {
|
|||||||
page.search.set(Some(widget.text_view));
|
page.search.set(Some(widget.text_view));
|
||||||
|
|
||||||
// Update page meta
|
// Update page meta
|
||||||
page.status
|
|
||||||
.replace(PageStatus::Success { time: now() });
|
|
||||||
page.title.replace(match widget.meta.title {
|
page.title.replace(match widget.meta.title {
|
||||||
Some(title) => title.into(), // @TODO
|
Some(title) => title.into(), // @TODO
|
||||||
None => uri_to_title(&uri),
|
None => uri_to_title(&uri),
|
||||||
@ -270,7 +258,6 @@ impl Gemini {
|
|||||||
let status = page.content.to_status_failure();
|
let status = page.content.to_status_failure();
|
||||||
status.set_description(Some(&e.to_string()));
|
status.set_description(Some(&e.to_string()));
|
||||||
|
|
||||||
page.status.replace(PageStatus::Failure { time: now() });
|
|
||||||
page.title.replace(status.title());
|
page.title.replace(status.title());
|
||||||
page.browser_action.update.activate(Some(&page.id));
|
page.browser_action.update.activate(Some(&page.id));
|
||||||
},
|
},
|
||||||
@ -307,8 +294,6 @@ impl Gemini {
|
|||||||
// Process buffer data
|
// Process buffer data
|
||||||
match result {
|
match result {
|
||||||
Ok(buffer) => {
|
Ok(buffer) => {
|
||||||
page.status
|
|
||||||
.replace(PageStatus::Success { time: now() });
|
|
||||||
page.title.replace(uri_to_title(&uri));
|
page.title.replace(uri_to_title(&uri));
|
||||||
page.content
|
page.content
|
||||||
.to_image(&Texture::for_pixbuf(&buffer));
|
.to_image(&Texture::for_pixbuf(&buffer));
|
||||||
@ -319,9 +304,6 @@ impl Gemini {
|
|||||||
Err(e) => {
|
Err(e) => {
|
||||||
let status = page.content.to_status_failure();
|
let status = page.content.to_status_failure();
|
||||||
status.set_description(Some(e.message()));
|
status.set_description(Some(e.message()));
|
||||||
|
|
||||||
page.status
|
|
||||||
.replace(PageStatus::Failure { time: now() });
|
|
||||||
page.title.replace(status.title());
|
page.title.replace(status.title());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -333,7 +315,6 @@ impl Gemini {
|
|||||||
let status = page.content.to_status_failure();
|
let status = page.content.to_status_failure();
|
||||||
status.set_description(Some(&e.to_string()));
|
status.set_description(Some(&e.to_string()));
|
||||||
|
|
||||||
page.status.replace(PageStatus::Failure { time: now() });
|
|
||||||
page.title.replace(status.title());
|
page.title.replace(status.title());
|
||||||
page.browser_action.update.activate(Some(&page.id));
|
page.browser_action.update.activate(Some(&page.id));
|
||||||
}
|
}
|
||||||
@ -347,7 +328,6 @@ impl Gemini {
|
|||||||
.to_status_mime(mime, Some((&page.tab_action, &uri)));
|
.to_status_mime(mime, Some((&page.tab_action, &uri)));
|
||||||
status.set_description(Some(&format!("Content type `{mime}` yet not supported")));
|
status.set_description(Some(&format!("Content type `{mime}` yet not supported")));
|
||||||
|
|
||||||
page.status.replace(PageStatus::Failure { time: now() });
|
|
||||||
page.title.replace(status.title());
|
page.title.replace(status.title());
|
||||||
page.browser_action.update.activate(Some(&page.id));
|
page.browser_action.update.activate(Some(&page.id));
|
||||||
},
|
},
|
||||||
@ -356,7 +336,6 @@ impl Gemini {
|
|||||||
let status = page.content.to_status_failure();
|
let status = page.content.to_status_failure();
|
||||||
status.set_description(Some("MIME type not found"));
|
status.set_description(Some("MIME type not found"));
|
||||||
|
|
||||||
page.status.replace(PageStatus::Failure { time: now() });
|
|
||||||
page.title.replace(status.title());
|
page.title.replace(status.title());
|
||||||
page.browser_action.update.activate(Some(&page.id));
|
page.browser_action.update.activate(Some(&page.id));
|
||||||
},
|
},
|
||||||
@ -377,7 +356,6 @@ impl Gemini {
|
|||||||
let status = page.content.to_status_failure();
|
let status = page.content.to_status_failure();
|
||||||
status.set_description(Some("Redirection limit reached"));
|
status.set_description(Some("Redirection limit reached"));
|
||||||
|
|
||||||
page.status.replace(PageStatus::Failure { time: now() });
|
|
||||||
page.title.replace(status.title());
|
page.title.replace(status.title());
|
||||||
page.browser_action.update.activate(Some(&page.id));
|
page.browser_action.update.activate(Some(&page.id));
|
||||||
|
|
||||||
@ -390,7 +368,6 @@ impl Gemini {
|
|||||||
let status = page.content.to_status_failure();
|
let status = page.content.to_status_failure();
|
||||||
status.set_description(Some("External redirects not allowed by protocol specification"));
|
status.set_description(Some("External redirects not allowed by protocol specification"));
|
||||||
|
|
||||||
page.status.replace(PageStatus::Failure { time: now() });
|
|
||||||
page.title.replace(status.title());
|
page.title.replace(status.title());
|
||||||
page.browser_action.update.activate(Some(&page.id));
|
page.browser_action.update.activate(Some(&page.id));
|
||||||
|
|
||||||
@ -412,7 +389,6 @@ impl Gemini {
|
|||||||
let status = page.content.to_status_failure();
|
let status = page.content.to_status_failure();
|
||||||
status.set_description(Some(&e.to_string()));
|
status.set_description(Some(&e.to_string()));
|
||||||
|
|
||||||
page.status.replace(PageStatus::Failure { time: now() });
|
|
||||||
page.title.replace(status.title());
|
page.title.replace(status.title());
|
||||||
page.browser_action.update.activate(Some(&page.id));
|
page.browser_action.update.activate(Some(&page.id));
|
||||||
}
|
}
|
||||||
@ -422,45 +398,23 @@ impl Gemini {
|
|||||||
let status = page.content.to_status_failure();
|
let status = page.content.to_status_failure();
|
||||||
status.set_description(Some("Redirection target not found"));
|
status.set_description(Some("Redirection target not found"));
|
||||||
|
|
||||||
page.status.replace(PageStatus::Failure { time: now() });
|
|
||||||
page.title.replace(status.title());
|
page.title.replace(status.title());
|
||||||
page.browser_action.update.activate(Some(&page.id));
|
page.browser_action.update.activate(Some(&page.id));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
// https://geminiprotocol.net/docs/protocol-specification.gmi#status-60
|
// https://geminiprotocol.net/docs/protocol-specification.gmi#status-60
|
||||||
Status::CertificateRequest => {
|
Status::CertificateRequest |
|
||||||
let status = page.content.to_status_identity();
|
|
||||||
status.set_description(Some(&match response.meta.data {
|
|
||||||
Some(data) => data.to_string(),
|
|
||||||
None => Status::CertificateRequest.to_string(),
|
|
||||||
}));
|
|
||||||
|
|
||||||
page.status.replace(PageStatus::Success { time: now() });
|
|
||||||
page.title.replace(status.title());
|
|
||||||
page.browser_action.update.activate(Some(&page.id));
|
|
||||||
}
|
|
||||||
// https://geminiprotocol.net/docs/protocol-specification.gmi#status-61-certificate-not-authorized
|
// https://geminiprotocol.net/docs/protocol-specification.gmi#status-61-certificate-not-authorized
|
||||||
Status::CertificateUnauthorized => {
|
Status::CertificateUnauthorized |
|
||||||
let status = page.content.to_status_identity();
|
|
||||||
status.set_description(Some(&match response.meta.data {
|
|
||||||
Some(data) => data.to_string(),
|
|
||||||
None => Status::CertificateUnauthorized.to_string(),
|
|
||||||
}));
|
|
||||||
|
|
||||||
page.status.replace(PageStatus::Success { time: now() });
|
|
||||||
page.title.replace(status.title());
|
|
||||||
page.browser_action.update.activate(Some(&page.id));
|
|
||||||
}
|
|
||||||
// https://geminiprotocol.net/docs/protocol-specification.gmi#status-62-certificate-not-valid
|
// https://geminiprotocol.net/docs/protocol-specification.gmi#status-62-certificate-not-valid
|
||||||
Status::CertificateInvalid => {
|
Status::CertificateInvalid => {
|
||||||
let status = page.content.to_status_identity();
|
let status = page.content.to_status_identity();
|
||||||
status.set_description(Some(&match response.meta.data {
|
status.set_description(Some(&match response.meta.data {
|
||||||
Some(data) => data.to_string(),
|
Some(data) => data.to_string(),
|
||||||
None => Status::CertificateInvalid.to_string(),
|
None => response.meta.status.to_string(),
|
||||||
}));
|
}));
|
||||||
|
|
||||||
page.status.replace(PageStatus::Success { time: now() });
|
|
||||||
page.title.replace(status.title());
|
page.title.replace(status.title());
|
||||||
page.browser_action.update.activate(Some(&page.id));
|
page.browser_action.update.activate(Some(&page.id));
|
||||||
}
|
}
|
||||||
@ -468,7 +422,6 @@ impl Gemini {
|
|||||||
let _status = page.content.to_status_failure();
|
let _status = page.content.to_status_failure();
|
||||||
_status.set_description(Some(&format!("Undefined status code `{status}`")));
|
_status.set_description(Some(&format!("Undefined status code `{status}`")));
|
||||||
|
|
||||||
page.status.replace(PageStatus::Failure { time: now() });
|
|
||||||
page.title.replace(_status.title());
|
page.title.replace(_status.title());
|
||||||
page.browser_action.update.activate(Some(&page.id));
|
page.browser_action.update.activate(Some(&page.id));
|
||||||
},
|
},
|
||||||
@ -478,7 +431,6 @@ impl Gemini {
|
|||||||
let status = page.content.to_status_failure();
|
let status = page.content.to_status_failure();
|
||||||
status.set_description(Some(&e.to_string()));
|
status.set_description(Some(&e.to_string()));
|
||||||
|
|
||||||
page.status.replace(PageStatus::Failure { time: now() });
|
|
||||||
page.title.replace(status.title());
|
page.title.replace(status.title());
|
||||||
page.browser_action.update.activate(Some(&page.id));
|
page.browser_action.update.activate(Some(&page.id));
|
||||||
},
|
},
|
||||||
|
@ -4,7 +4,6 @@ mod error;
|
|||||||
mod input;
|
mod input;
|
||||||
mod navigation;
|
mod navigation;
|
||||||
mod search;
|
mod search;
|
||||||
pub mod status;
|
|
||||||
mod widget;
|
mod widget;
|
||||||
|
|
||||||
use content::Content;
|
use content::Content;
|
||||||
@ -12,11 +11,9 @@ use error::Error;
|
|||||||
use input::Input;
|
use input::Input;
|
||||||
use navigation::Navigation;
|
use navigation::Navigation;
|
||||||
use search::Search;
|
use search::Search;
|
||||||
use status::Status;
|
|
||||||
use widget::Widget;
|
use widget::Widget;
|
||||||
|
|
||||||
use super::{Action as TabAction, BrowserAction, Profile, WindowAction};
|
use super::{Action as TabAction, BrowserAction, Profile, WindowAction};
|
||||||
use crate::tool::now;
|
|
||||||
|
|
||||||
use gtk::{
|
use gtk::{
|
||||||
glib::GString,
|
glib::GString,
|
||||||
@ -28,7 +25,6 @@ use std::{cell::RefCell, rc::Rc};
|
|||||||
pub struct Page {
|
pub struct Page {
|
||||||
pub id: Rc<GString>,
|
pub id: Rc<GString>,
|
||||||
pub profile: Rc<Profile>,
|
pub profile: Rc<Profile>,
|
||||||
pub status: Rc<RefCell<Status>>,
|
|
||||||
pub title: Rc<RefCell<GString>>,
|
pub title: Rc<RefCell<GString>>,
|
||||||
// Actions
|
// Actions
|
||||||
pub browser_action: Rc<BrowserAction>,
|
pub browser_action: Rc<BrowserAction>,
|
||||||
@ -74,8 +70,6 @@ impl Page {
|
|||||||
&input.widget.clamp,
|
&input.widget.clamp,
|
||||||
));
|
));
|
||||||
|
|
||||||
let status = Rc::new(RefCell::new(Status::New { time: now() }));
|
|
||||||
|
|
||||||
// Done
|
// Done
|
||||||
Self {
|
Self {
|
||||||
id: id.clone(),
|
id: id.clone(),
|
||||||
@ -86,7 +80,6 @@ impl Page {
|
|||||||
tab_action: tab_action.clone(),
|
tab_action: tab_action.clone(),
|
||||||
window_action: window_action.clone(),
|
window_action: window_action.clone(),
|
||||||
// Components
|
// Components
|
||||||
status,
|
|
||||||
content,
|
content,
|
||||||
search,
|
search,
|
||||||
input,
|
input,
|
||||||
@ -157,9 +150,6 @@ impl Page {
|
|||||||
transaction: &Transaction,
|
transaction: &Transaction,
|
||||||
app_browser_window_tab_item_id: i64,
|
app_browser_window_tab_item_id: i64,
|
||||||
) -> Result<(), String> {
|
) -> Result<(), String> {
|
||||||
// Update status
|
|
||||||
self.status.replace(Status::SessionRestore { time: now() });
|
|
||||||
|
|
||||||
// Begin page restore
|
// Begin page restore
|
||||||
match database::select(transaction, app_browser_window_tab_item_id) {
|
match database::select(transaction, app_browser_window_tab_item_id) {
|
||||||
Ok(records) => {
|
Ok(records) => {
|
||||||
@ -177,10 +167,6 @@ impl Page {
|
|||||||
}
|
}
|
||||||
Err(e) => return Err(e.to_string()),
|
Err(e) => return Err(e.to_string()),
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update status
|
|
||||||
self.status.replace(Status::SessionRestored { time: now() });
|
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -209,11 +195,6 @@ impl Page {
|
|||||||
|
|
||||||
// Getters
|
// Getters
|
||||||
|
|
||||||
/// Get `title` copy from `Self`
|
|
||||||
pub fn title(&self) -> GString {
|
|
||||||
self.title.borrow().clone()
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Get `Self` loading status
|
/// Get `Self` loading status
|
||||||
pub fn is_loading(&self) -> bool {
|
pub fn is_loading(&self) -> bool {
|
||||||
let progress_fraction = self.navigation.request.widget.entry.progress_fraction();
|
let progress_fraction = self.navigation.request.widget.entry.progress_fraction();
|
||||||
|
@ -1,43 +0,0 @@
|
|||||||
// Global dependencies
|
|
||||||
use crate::tool::format_time;
|
|
||||||
use gtk::glib::DateTime;
|
|
||||||
use std::fmt::{Display, Formatter, Result};
|
|
||||||
|
|
||||||
/// `Page` status
|
|
||||||
pub enum Status {
|
|
||||||
Failure { time: DateTime },
|
|
||||||
Input { time: DateTime },
|
|
||||||
Loading { time: DateTime },
|
|
||||||
New { time: DateTime },
|
|
||||||
SessionRestore { time: DateTime },
|
|
||||||
SessionRestored { time: DateTime },
|
|
||||||
Success { time: DateTime },
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Display for Status {
|
|
||||||
fn fmt(&self, f: &mut Formatter) -> Result {
|
|
||||||
match self {
|
|
||||||
Self::Failure { time } => {
|
|
||||||
write!(f, "[{}] Failure", format_time(time))
|
|
||||||
}
|
|
||||||
Self::Input { time } => {
|
|
||||||
write!(f, "[{}] Input issue", format_time(time))
|
|
||||||
}
|
|
||||||
Self::Loading { time } => {
|
|
||||||
write!(f, "[{}] Loading...", format_time(time))
|
|
||||||
}
|
|
||||||
Self::New { time } => {
|
|
||||||
write!(f, "[{}] New page", format_time(time))
|
|
||||||
}
|
|
||||||
Self::SessionRestore { time } => {
|
|
||||||
write!(f, "[{}] Session restore...", format_time(time))
|
|
||||||
}
|
|
||||||
Self::SessionRestored { time } => {
|
|
||||||
write!(f, "[{}] Session restored", format_time(time))
|
|
||||||
}
|
|
||||||
Self::Success { time } => {
|
|
||||||
write!(f, "[{}] Success", format_time(time))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
13
src/tool.rs
13
src/tool.rs
@ -1,8 +1,5 @@
|
|||||||
//! Some shared helpers collection
|
//! Some shared helpers collection
|
||||||
|
|
||||||
// Global dependencies
|
|
||||||
use gtk::glib::{DateTime, GString};
|
|
||||||
|
|
||||||
/// Format bytes to KB/MB/GB presentation
|
/// Format bytes to KB/MB/GB presentation
|
||||||
pub fn format_bytes(value: usize) -> String {
|
pub fn format_bytes(value: usize) -> String {
|
||||||
const KB: f32 = 1024.0;
|
const KB: f32 = 1024.0;
|
||||||
@ -24,13 +21,3 @@ pub fn format_bytes(value: usize) -> String {
|
|||||||
format!("{:.2} GB", f / GB)
|
format!("{:.2} GB", f / GB)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Format given [DateTime](https://docs.gtk.org/glib/struct.DateTime.html)
|
|
||||||
pub fn format_time(t: &DateTime) -> GString {
|
|
||||||
t.format_iso8601().unwrap() // @TODO handle?
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Get current [DateTime](https://docs.gtk.org/glib/struct.DateTime.html)
|
|
||||||
pub fn now() -> DateTime {
|
|
||||||
DateTime::now_local().unwrap() // @TODO handle?
|
|
||||||
}
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user