mirror of
https://github.com/YGGverse/Yoda.git
synced 2025-09-11 22:42:00 +00:00
remove private level for the entry with extra methods
This commit is contained in:
parent
6e4eec54f0
commit
e7e216aaea
@ -8,7 +8,12 @@ use crate::Profile;
|
||||
use action::Action;
|
||||
use adw::{TabPage, TabView};
|
||||
use anyhow::Result;
|
||||
use gtk::{Box, Orientation, gio::Icon, glib::Propagation, prelude::ActionExt};
|
||||
use gtk::{
|
||||
Box, Orientation,
|
||||
gio::Icon,
|
||||
glib::Propagation,
|
||||
prelude::{ActionExt, EditableExt, EntryExt, WidgetExt},
|
||||
};
|
||||
pub use item::Item;
|
||||
use menu::Menu;
|
||||
use sourceview::prelude::IsA;
|
||||
@ -76,8 +81,10 @@ impl Tab {
|
||||
if let Some(item) = index.borrow_mut().remove(tab_page) {
|
||||
// keep removed `Item` reference in the memory (to reopen from the main menu)
|
||||
// * skip item with blank request
|
||||
if !item.page.navigation.request.is_empty() {
|
||||
profile.history.close(&item.page.navigation.request.text());
|
||||
if !item.page.navigation.request.entry.text_length() > 0 {
|
||||
profile
|
||||
.history
|
||||
.close(&item.page.navigation.request.entry.text());
|
||||
}
|
||||
}
|
||||
// reassign global actions to active tab
|
||||
@ -160,7 +167,7 @@ impl Tab {
|
||||
// Expect user input on tab appended has empty request entry
|
||||
// * this action initiated here because should be applied on tab appending event only
|
||||
if request.is_none() || request.is_some_and(|value| value.is_empty()) {
|
||||
item.page.navigation.request.grab_focus();
|
||||
item.page.navigation.request.entry.grab_focus();
|
||||
}
|
||||
|
||||
// Relate with GTK `TabPage` with app `Item`
|
||||
@ -273,7 +280,7 @@ impl Tab {
|
||||
pub fn reload(&self, page_position: Option<i32>) {
|
||||
if let Some(item) = self.item(page_position) {
|
||||
item.client
|
||||
.handle(&item.page.navigation.request.text(), true, false);
|
||||
.handle(&item.page.navigation.request.entry.text(), true, false);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -11,7 +11,7 @@ use anyhow::Result;
|
||||
use client::Client;
|
||||
use gtk::{
|
||||
Box,
|
||||
prelude::{ActionExt, ActionMapExt, BoxExt},
|
||||
prelude::{ActionExt, ActionMapExt, BoxExt, EditableExt},
|
||||
};
|
||||
use page::Page;
|
||||
use sqlite::Transaction;
|
||||
@ -85,7 +85,7 @@ impl Item {
|
||||
this.set_enabled(false);
|
||||
if let Some(uri) = page.navigation.request.home() {
|
||||
let request = uri.to_string();
|
||||
page.navigation.request.set_text(&request);
|
||||
page.navigation.request.entry.set_text(&request);
|
||||
client.handle(&request, true, false);
|
||||
}
|
||||
}
|
||||
@ -96,7 +96,7 @@ impl Item {
|
||||
let client = client.clone();
|
||||
move |request, is_snap_history, is_redirect| {
|
||||
if let Some(request) = request {
|
||||
page.navigation.request.set_text(&request);
|
||||
page.navigation.request.entry.set_text(&request);
|
||||
client.handle(&request, is_snap_history, is_redirect);
|
||||
}
|
||||
}
|
||||
@ -110,7 +110,7 @@ impl Item {
|
||||
action.reload.connect_activate({
|
||||
let page = page.clone();
|
||||
let client = client.clone();
|
||||
move |_, _| client.handle(&page.navigation.request.text(), true, false)
|
||||
move |_, _| client.handle(&page.navigation.request.entry.text(), true, false)
|
||||
});
|
||||
|
||||
action.reload.connect_enabled_notify({
|
||||
@ -145,7 +145,7 @@ impl Item {
|
||||
|
||||
// Handle immediately on request
|
||||
if let Some(request) = request {
|
||||
page.navigation.request.set_text(request);
|
||||
page.navigation.request.entry.set_text(request);
|
||||
if is_load {
|
||||
client.handle(request, true, false)
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ use ggemini::{
|
||||
client::{Client, Request, Response},
|
||||
gio::{file_output_stream, memory_input_stream},
|
||||
};
|
||||
use gtk::prelude::EditableExt;
|
||||
use gtk::{
|
||||
gdk::Texture,
|
||||
gdk_pixbuf::Pixbuf,
|
||||
@ -569,7 +570,7 @@ fn handle(
|
||||
} else {
|
||||
let t = target.to_string();
|
||||
if matches!(redirect, Redirect::Permanent { .. }) {
|
||||
page.navigation.request.set_text(&t);
|
||||
page.navigation.request.entry.set_text(&t);
|
||||
}
|
||||
redirects.replace(total);
|
||||
{
|
||||
|
@ -4,7 +4,7 @@ use super::{Feature, Page};
|
||||
use crate::tool::{Format, uri_to_title};
|
||||
use gtk::gio::{MemoryInputStream, SocketConnection};
|
||||
use gtk::prelude::{
|
||||
Cast, IOStreamExt, InputStreamExtManual, OutputStreamExtManual, SocketClientExt,
|
||||
Cast, EditableExt, IOStreamExt, InputStreamExtManual, OutputStreamExtManual, SocketClientExt,
|
||||
};
|
||||
use gtk::{
|
||||
gdk::Texture,
|
||||
@ -59,7 +59,7 @@ impl Nex {
|
||||
.request
|
||||
.info
|
||||
.replace(i.into_permanent_redirect());
|
||||
self.page.navigation.request.set_text(&r);
|
||||
self.page.navigation.request.entry.set_text(&r);
|
||||
self.page.item_action.load.activate(Some(&r), false, true);
|
||||
return; // prevents operation cancelled message on redirect
|
||||
}
|
||||
|
@ -8,7 +8,7 @@ use super::{Action as ItemAction, Profile, TabAction, WindowAction};
|
||||
use adw::TabPage;
|
||||
use anyhow::Result;
|
||||
use content::Content;
|
||||
use gtk::prelude::WidgetExt;
|
||||
use gtk::prelude::{EditableExt, EntryExt, WidgetExt};
|
||||
use input::Input;
|
||||
use navigation::Navigation;
|
||||
use search::Search;
|
||||
@ -98,10 +98,10 @@ impl Page {
|
||||
pub fn snap_history(&self) {
|
||||
self.item_action
|
||||
.history
|
||||
.add(self.navigation.request.text(), true);
|
||||
.add(self.navigation.request.entry.text(), true);
|
||||
self.profile
|
||||
.history
|
||||
.open(self.navigation.request.text(), Some(self.title()))
|
||||
.open(self.navigation.request.entry.text(), Some(self.title()))
|
||||
}
|
||||
|
||||
/// Cleanup session for `Self`
|
||||
@ -136,7 +136,7 @@ impl Page {
|
||||
// Make initial page history snap
|
||||
self.profile
|
||||
.history
|
||||
.open(self.navigation.request.text(), Some(self.title()));
|
||||
.open(self.navigation.request.entry.text(), Some(self.title()));
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
@ -178,6 +178,7 @@ impl Page {
|
||||
pub fn set_progress(&self, progress_fraction: f64) {
|
||||
self.navigation
|
||||
.request
|
||||
.entry
|
||||
.set_progress_fraction(progress_fraction);
|
||||
self.tab_page.set_loading(progress_fraction > 0.0)
|
||||
}
|
||||
|
@ -53,7 +53,7 @@ impl Navigation {
|
||||
g_box.append(&home);
|
||||
g_box.append(&history);
|
||||
g_box.append(&reload);
|
||||
request.append_to(&g_box); // private member
|
||||
g_box.append(&request.entry);
|
||||
g_box.append(&bookmark.button);
|
||||
|
||||
Self {
|
||||
|
@ -1,7 +1,7 @@
|
||||
use super::{Profile, Request, WindowAction};
|
||||
use gtk::{
|
||||
Button,
|
||||
prelude::{ActionExt, ButtonExt, WidgetExt},
|
||||
prelude::{ActionExt, ButtonExt, EditableExt, WidgetExt},
|
||||
};
|
||||
use std::rc::Rc;
|
||||
|
||||
@ -23,12 +23,11 @@ impl Bookmark {
|
||||
action.bookmark.simple_action.name()
|
||||
))
|
||||
.build();
|
||||
update(profile, &button, &request.text());
|
||||
request.on_change({
|
||||
update(profile, &button, &request.entry.text());
|
||||
request.entry.connect_changed({
|
||||
let b = button.clone();
|
||||
let p = profile.clone();
|
||||
let r = request.clone();
|
||||
move || update(&p, &b, &r.text())
|
||||
move |e| update(&p, &b, &e.text())
|
||||
});
|
||||
Self {
|
||||
profile: profile.clone(),
|
||||
@ -40,7 +39,7 @@ impl Bookmark {
|
||||
pub fn toggle(&self, title: Option<&str>) {
|
||||
let button = self.button.clone();
|
||||
let profile = self.profile.clone();
|
||||
let query = self.request.text();
|
||||
let query = self.request.entry.text();
|
||||
let title = title.map(|t| t.to_string());
|
||||
button.set_sensitive(false); // lock
|
||||
let has_bookmark = profile.bookmark.toggle(&query, title.as_deref()).unwrap();
|
||||
|
@ -27,8 +27,7 @@ const PREFIX_DOWNLOAD: &str = "download:";
|
||||
const PREFIX_SOURCE: &str = "source:";
|
||||
|
||||
pub struct Request {
|
||||
/// * keep it private to properly update some local dependencies on change (e.g. proxy resolver)
|
||||
entry: Entry,
|
||||
pub entry: Entry,
|
||||
pub info: Rc<RefCell<Info>>,
|
||||
profile: Rc<Profile>,
|
||||
proxy_resolver: Rc<RefCell<Option<ProxyResolver>>>,
|
||||
@ -179,7 +178,7 @@ impl Request {
|
||||
&& state.contains(StateFlags::ACTIVE | StateFlags::FOCUS_WITHIN)
|
||||
&& this.selection_bounds().is_none()
|
||||
{
|
||||
this.select_region(0, -1);
|
||||
this.select_region(0, -1)
|
||||
}
|
||||
// Update last focus state
|
||||
has_focus.replace(state.contains(StateFlags::FOCUS_WITHIN));
|
||||
@ -291,27 +290,6 @@ impl Request {
|
||||
self.entry.text().starts_with("file://")
|
||||
}
|
||||
|
||||
pub fn is_empty(&self) -> bool {
|
||||
self.entry.text_length() > 0
|
||||
}
|
||||
|
||||
pub fn grab_focus(&self) -> bool {
|
||||
self.entry.grab_focus()
|
||||
}
|
||||
|
||||
pub fn set_progress_fraction(&self, value: f64) {
|
||||
self.entry.set_progress_fraction(value);
|
||||
}
|
||||
|
||||
pub fn set_text(&self, value: &str) {
|
||||
self.entry.set_text(value);
|
||||
self.refresh()
|
||||
}
|
||||
|
||||
pub fn text(&self) -> GString {
|
||||
self.entry.text()
|
||||
}
|
||||
|
||||
/// Get [ProxyResolver](https://docs.gtk.org/gio/iface.ProxyResolver.html)
|
||||
/// which is constructed for every `Request` entry change
|
||||
/// * useful on build new [SocketClient](https://docs.gtk.org/gio/class.SocketClient.html)
|
||||
@ -320,15 +298,6 @@ impl Request {
|
||||
self.proxy_resolver.borrow().clone()
|
||||
}
|
||||
|
||||
pub fn append_to(&self, parent: >k::Box) {
|
||||
use gtk::prelude::BoxExt;
|
||||
parent.append(&self.entry)
|
||||
}
|
||||
|
||||
pub fn on_change(&self, callback: impl Fn() + 'static) {
|
||||
self.entry.connect_changed(move |_| callback());
|
||||
}
|
||||
|
||||
// Tools
|
||||
|
||||
/// Get request value with formatted `download` prefix
|
||||
|
Loading…
x
Reference in New Issue
Block a user