mirror of
https://github.com/YGGverse/Yoda.git
synced 2026-04-02 17:45:28 +00:00
move info component into navigation request level
This commit is contained in:
parent
d1623bda9e
commit
05a8647f28
7 changed files with 34 additions and 23 deletions
|
|
@ -40,7 +40,7 @@ impl Client {
|
||||||
self.page.escape();
|
self.page.escape();
|
||||||
|
|
||||||
// Deprecate page info but keep it data as is
|
// Deprecate page info but keep it data as is
|
||||||
self.page.info.borrow_mut().deprecate();
|
self.page.navigation.request.info.borrow_mut().deprecate();
|
||||||
|
|
||||||
// Initially disable find action
|
// Initially disable find action
|
||||||
self.page
|
self.page
|
||||||
|
|
|
||||||
|
|
@ -38,7 +38,7 @@ impl Gemini {
|
||||||
client.socket.connect_event({
|
client.socket.connect_event({
|
||||||
let p = page.clone();
|
let p = page.clone();
|
||||||
move |_, event, _, _| {
|
move |_, event, _, _| {
|
||||||
let mut i = p.info.borrow_mut();
|
let mut i = p.navigation.request.info.borrow_mut();
|
||||||
p.set_progress(match event {
|
p.set_progress(match event {
|
||||||
// 0.1 reserved for handle begin
|
// 0.1 reserved for handle begin
|
||||||
SocketClientEvent::Resolving => {
|
SocketClientEvent::Resolving => {
|
||||||
|
|
@ -293,7 +293,7 @@ fn handle(
|
||||||
move |result| match result {
|
move |result| match result {
|
||||||
Ok((buffer, _ ,_)) => match std::str::from_utf8(&buffer) {
|
Ok((buffer, _ ,_)) => match std::str::from_utf8(&buffer) {
|
||||||
Ok(data) => {
|
Ok(data) => {
|
||||||
let mut i = page.info.borrow_mut();
|
let mut i = page.navigation.request.info.borrow_mut();
|
||||||
i
|
i
|
||||||
.add_event("Parsing".to_string())
|
.add_event("Parsing".to_string())
|
||||||
.set_mime(Some(success.mime().to_string()))
|
.set_mime(Some(success.mime().to_string()))
|
||||||
|
|
@ -396,7 +396,7 @@ fn handle(
|
||||||
page.set_title(&crate::tool::uri_to_title(&uri));
|
page.set_title(&crate::tool::uri_to_title(&uri));
|
||||||
page.content.to_image(&Texture::for_pixbuf(&buffer));
|
page.content.to_image(&Texture::for_pixbuf(&buffer));
|
||||||
{
|
{
|
||||||
let mut i = page.info.borrow_mut();
|
let mut i = page.navigation.request.info.borrow_mut();
|
||||||
i
|
i
|
||||||
.add_event(EVENT_COMPLETED.to_string())
|
.add_event(EVENT_COMPLETED.to_string())
|
||||||
.set_mime(Some(success.mime().to_string()))
|
.set_mime(Some(success.mime().to_string()))
|
||||||
|
|
@ -409,7 +409,7 @@ fn handle(
|
||||||
s.set_description(Some(e.message()));
|
s.set_description(Some(e.message()));
|
||||||
page.set_title(&s.title());
|
page.set_title(&s.title());
|
||||||
{
|
{
|
||||||
let mut i = page.info.borrow_mut();
|
let mut i = page.navigation.request.info.borrow_mut();
|
||||||
i
|
i
|
||||||
.add_event(EVENT_COMPLETED.to_string())
|
.add_event(EVENT_COMPLETED.to_string())
|
||||||
.set_mime(Some(success.mime().to_string()))
|
.set_mime(Some(success.mime().to_string()))
|
||||||
|
|
@ -436,7 +436,7 @@ fn handle(
|
||||||
}
|
}
|
||||||
redirects.replace(0); // reset
|
redirects.replace(0); // reset
|
||||||
{
|
{
|
||||||
let mut i = page.info.borrow_mut();
|
let mut i = page.navigation.request.info.borrow_mut();
|
||||||
i
|
i
|
||||||
.add_event(EVENT_COMPLETED.to_string())
|
.add_event(EVENT_COMPLETED.to_string())
|
||||||
.set_mime(Some(success.mime().to_string()))
|
.set_mime(Some(success.mime().to_string()))
|
||||||
|
|
@ -461,7 +461,7 @@ fn handle(
|
||||||
}
|
}
|
||||||
redirects.replace(0); // reset
|
redirects.replace(0); // reset
|
||||||
{
|
{
|
||||||
let mut i = page.info.borrow_mut();
|
let mut i = page.navigation.request.info.borrow_mut();
|
||||||
i
|
i
|
||||||
.add_event(EVENT_COMPLETED.to_string())
|
.add_event(EVENT_COMPLETED.to_string())
|
||||||
.set_mime(Some(mime.to_string()))
|
.set_mime(Some(mime.to_string()))
|
||||||
|
|
@ -518,14 +518,14 @@ fn handle(
|
||||||
}
|
}
|
||||||
redirects.replace(total);
|
redirects.replace(total);
|
||||||
{
|
{
|
||||||
let mut i = page.info.take();
|
let mut i = page.navigation.request.info.take();
|
||||||
i
|
i
|
||||||
.add_event(EVENT_COMPLETED.to_string())
|
.add_event(EVENT_COMPLETED.to_string())
|
||||||
.set_mime(None)
|
.set_mime(None)
|
||||||
.set_request(Some(uri.to_string()))
|
.set_request(Some(uri.to_string()))
|
||||||
.set_size(None);
|
.set_size(None);
|
||||||
|
|
||||||
page.info.replace(i.into_redirect());
|
page.navigation.request.info.replace(i.into_redirect());
|
||||||
}
|
}
|
||||||
page.item_action.load.activate(Some(&t), false);
|
page.item_action.load.activate(Some(&t), false);
|
||||||
}
|
}
|
||||||
|
|
@ -618,7 +618,7 @@ fn handle(
|
||||||
|
|
||||||
/// Apply common page info pattern
|
/// Apply common page info pattern
|
||||||
fn update_page_info(page: &Page, uri: &Uri, event_name: &str) {
|
fn update_page_info(page: &Page, uri: &Uri, event_name: &str) {
|
||||||
let mut i = page.info.borrow_mut();
|
let mut i = page.navigation.request.info.borrow_mut();
|
||||||
i.add_event(event_name.to_string())
|
i.add_event(event_name.to_string())
|
||||||
.set_mime(None)
|
.set_mime(None)
|
||||||
.set_request(Some(uri.to_string()))
|
.set_request(Some(uri.to_string()))
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,5 @@
|
||||||
mod content;
|
mod content;
|
||||||
mod database;
|
mod database;
|
||||||
mod info;
|
|
||||||
mod input;
|
mod input;
|
||||||
mod navigation;
|
mod navigation;
|
||||||
mod search;
|
mod search;
|
||||||
|
|
@ -10,12 +9,11 @@ use adw::TabPage;
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use content::Content;
|
use content::Content;
|
||||||
use gtk::prelude::WidgetExt;
|
use gtk::prelude::WidgetExt;
|
||||||
use info::Info;
|
|
||||||
use input::Input;
|
use input::Input;
|
||||||
use navigation::Navigation;
|
use navigation::Navigation;
|
||||||
use search::Search;
|
use search::Search;
|
||||||
use sqlite::Transaction;
|
use sqlite::Transaction;
|
||||||
use std::{cell::RefCell, rc::Rc, sync::Arc};
|
use std::{rc::Rc, sync::Arc};
|
||||||
|
|
||||||
pub struct Page {
|
pub struct Page {
|
||||||
pub profile: Arc<Profile>,
|
pub profile: Arc<Profile>,
|
||||||
|
|
@ -23,7 +21,6 @@ pub struct Page {
|
||||||
pub item_action: Rc<ItemAction>,
|
pub item_action: Rc<ItemAction>,
|
||||||
pub window_action: Rc<WindowAction>,
|
pub window_action: Rc<WindowAction>,
|
||||||
// Components
|
// Components
|
||||||
pub info: Rc<RefCell<Info>>,
|
|
||||||
pub content: Rc<Content>,
|
pub content: Rc<Content>,
|
||||||
pub input: Rc<Input>,
|
pub input: Rc<Input>,
|
||||||
pub navigation: Rc<Navigation>,
|
pub navigation: Rc<Navigation>,
|
||||||
|
|
@ -57,7 +54,6 @@ impl Page {
|
||||||
(window_action, tab_action, item_action),
|
(window_action, tab_action, item_action),
|
||||||
));
|
));
|
||||||
let input = Rc::new(Input::new());
|
let input = Rc::new(Input::new());
|
||||||
let info = Rc::new(RefCell::new(Info::new()));
|
|
||||||
|
|
||||||
// Done
|
// Done
|
||||||
Self {
|
Self {
|
||||||
|
|
@ -67,7 +63,6 @@ impl Page {
|
||||||
item_action: item_action.clone(),
|
item_action: item_action.clone(),
|
||||||
window_action: window_action.clone(),
|
window_action: window_action.clone(),
|
||||||
// Components
|
// Components
|
||||||
info,
|
|
||||||
content,
|
content,
|
||||||
input,
|
input,
|
||||||
navigation,
|
navigation,
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@ const MARGIN: i32 = 6;
|
||||||
const SPACING: i32 = 6;
|
const SPACING: i32 = 6;
|
||||||
|
|
||||||
pub struct Navigation {
|
pub struct Navigation {
|
||||||
request: Rc<Request>,
|
pub request: Rc<Request>,
|
||||||
bookmark: Rc<Bookmark>,
|
bookmark: Rc<Bookmark>,
|
||||||
pub g_box: Box,
|
pub g_box: Box,
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
mod database;
|
mod database;
|
||||||
mod identity;
|
mod identity;
|
||||||
|
mod info;
|
||||||
mod primary_icon;
|
mod primary_icon;
|
||||||
mod search;
|
mod search;
|
||||||
mod suggestion;
|
mod suggestion;
|
||||||
|
|
@ -12,9 +13,14 @@ use gtk::{
|
||||||
glib::{GString, Uri, UriFlags, gformat},
|
glib::{GString, Uri, UriFlags, gformat},
|
||||||
prelude::{EditableExt, EntryExt, WidgetExt},
|
prelude::{EditableExt, EntryExt, WidgetExt},
|
||||||
};
|
};
|
||||||
|
use info::Info;
|
||||||
use primary_icon::PrimaryIcon;
|
use primary_icon::PrimaryIcon;
|
||||||
use sqlite::Transaction;
|
use sqlite::Transaction;
|
||||||
use std::{cell::Cell, rc::Rc, sync::Arc};
|
use std::{
|
||||||
|
cell::{Cell, RefCell},
|
||||||
|
rc::Rc,
|
||||||
|
sync::Arc,
|
||||||
|
};
|
||||||
use suggestion::Suggestion;
|
use suggestion::Suggestion;
|
||||||
|
|
||||||
const PREFIX_DOWNLOAD: &str = "download:";
|
const PREFIX_DOWNLOAD: &str = "download:";
|
||||||
|
|
@ -22,6 +28,7 @@ const PREFIX_SOURCE: &str = "source:";
|
||||||
|
|
||||||
pub struct Request {
|
pub struct Request {
|
||||||
pub entry: Entry,
|
pub entry: Entry,
|
||||||
|
pub info: Rc<RefCell<Info>>,
|
||||||
suggestion: Rc<Suggestion>,
|
suggestion: Rc<Suggestion>,
|
||||||
profile: Arc<Profile>,
|
profile: Arc<Profile>,
|
||||||
}
|
}
|
||||||
|
|
@ -31,6 +38,9 @@ impl Request {
|
||||||
|
|
||||||
/// Build new `Self`
|
/// Build new `Self`
|
||||||
pub fn build(item_action: &Rc<ItemAction>, profile: &Arc<Profile>) -> Self {
|
pub fn build(item_action: &Rc<ItemAction>, profile: &Arc<Profile>) -> Self {
|
||||||
|
// Init components
|
||||||
|
let info = Rc::new(RefCell::new(Info::new()));
|
||||||
|
|
||||||
// Init main widget
|
// Init main widget
|
||||||
let entry = Entry::builder()
|
let entry = Entry::builder()
|
||||||
.placeholder_text("URL or search term...")
|
.placeholder_text("URL or search term...")
|
||||||
|
|
@ -95,7 +105,7 @@ impl Request {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
entry.connect_has_focus_notify(update_secondary_icon);
|
entry.connect_has_focus_notify(|this| update_secondary_icon(this, false));
|
||||||
|
|
||||||
suggestion
|
suggestion
|
||||||
.signal_handler_id
|
.signal_handler_id
|
||||||
|
|
@ -111,7 +121,7 @@ impl Request {
|
||||||
|
|
||||||
// Update icons
|
// Update icons
|
||||||
update_primary_icon(this, &profile);
|
update_primary_icon(this, &profile);
|
||||||
update_secondary_icon(this);
|
update_secondary_icon(this, false);
|
||||||
|
|
||||||
// Show search suggestions
|
// Show search suggestions
|
||||||
if this.focus_child().is_some() {
|
if this.focus_child().is_some() {
|
||||||
|
|
@ -162,6 +172,7 @@ impl Request {
|
||||||
|
|
||||||
Self {
|
Self {
|
||||||
entry,
|
entry,
|
||||||
|
info,
|
||||||
suggestion,
|
suggestion,
|
||||||
profile: profile.clone(),
|
profile: profile.clone(),
|
||||||
}
|
}
|
||||||
|
|
@ -325,13 +336,18 @@ fn is_focused(entry: &Entry) -> bool {
|
||||||
/// Secondary icon has two modes:
|
/// Secondary icon has two modes:
|
||||||
/// * navigate to the location button (on the entry is focused / has edit mode)
|
/// * navigate to the location button (on the entry is focused / has edit mode)
|
||||||
/// * page info button with dialog window activation (on the entry is inactive)
|
/// * page info button with dialog window activation (on the entry is inactive)
|
||||||
fn update_secondary_icon(entry: &Entry) {
|
fn update_secondary_icon(entry: &Entry, has_info: bool) {
|
||||||
if is_focused(entry) {
|
if is_focused(entry) {
|
||||||
entry.set_secondary_icon_name(Some("pan-end-symbolic"));
|
entry.set_secondary_icon_name(Some("pan-end-symbolic"));
|
||||||
entry.set_secondary_icon_tooltip_text(Some("Go to the location"))
|
entry.set_secondary_icon_tooltip_text(Some("Go to the location"))
|
||||||
} else {
|
} else {
|
||||||
entry.set_secondary_icon_name(Some("help-about-symbolic"));
|
if has_info {
|
||||||
entry.set_secondary_icon_tooltip_text(Some("Page info"));
|
entry.set_secondary_icon_name(Some("help-about-symbolic"));
|
||||||
|
entry.set_secondary_icon_tooltip_text(Some("Page info"));
|
||||||
|
} else {
|
||||||
|
entry.set_secondary_icon_name(None);
|
||||||
|
entry.set_secondary_icon_tooltip_text(None);
|
||||||
|
}
|
||||||
entry.select_region(0, 0);
|
entry.select_region(0, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue