mirror of
https://github.com/YGGverse/Yoda.git
synced 2025-01-15 09:10:08 +00:00
close search on escape action
This commit is contained in:
parent
94b8227088
commit
4b357f8229
@ -61,7 +61,11 @@ impl Page {
|
||||
),
|
||||
) -> Self {
|
||||
// Init components
|
||||
let content = Rc::new(Content::new((window_action.clone(), tab_action.clone())));
|
||||
let content = Rc::new(Content::new((
|
||||
browser_action.clone(),
|
||||
window_action.clone(),
|
||||
tab_action.clone(),
|
||||
)));
|
||||
|
||||
let navigation = Rc::new(Navigation::new(
|
||||
profile.clone(),
|
||||
|
@ -5,7 +5,7 @@ mod text;
|
||||
use image::Image;
|
||||
use text::Text;
|
||||
|
||||
use super::{TabAction, WindowAction};
|
||||
use super::{BrowserAction, TabAction, WindowAction};
|
||||
use adw::StatusPage;
|
||||
use gtk::{
|
||||
gdk::Paintable,
|
||||
@ -17,6 +17,7 @@ use gtk::{
|
||||
use std::{rc::Rc, time::Duration};
|
||||
|
||||
pub struct Content {
|
||||
browser_action: Rc<BrowserAction>,
|
||||
window_action: Rc<WindowAction>,
|
||||
tab_action: Rc<TabAction>,
|
||||
pub g_box: Box,
|
||||
@ -26,11 +27,18 @@ impl Content {
|
||||
// Construct
|
||||
|
||||
/// Create new container for different components
|
||||
pub fn new(action: (Rc<WindowAction>, Rc<TabAction>)) -> Self {
|
||||
pub fn new(
|
||||
(browser_action, window_action, tab_action): (
|
||||
Rc<BrowserAction>,
|
||||
Rc<WindowAction>,
|
||||
Rc<TabAction>,
|
||||
),
|
||||
) -> Self {
|
||||
Self {
|
||||
g_box: Box::builder().orientation(Orientation::Vertical).build(),
|
||||
window_action: action.0,
|
||||
tab_action: action.1,
|
||||
browser_action,
|
||||
window_action,
|
||||
tab_action,
|
||||
}
|
||||
}
|
||||
|
||||
@ -125,7 +133,7 @@ impl Content {
|
||||
let text = Text::new_gemini(
|
||||
data,
|
||||
base,
|
||||
(self.window_action.clone(), self.tab_action.clone()),
|
||||
(&self.browser_action, &self.window_action, &self.tab_action),
|
||||
);
|
||||
self.g_box.append(&text.g_box);
|
||||
text
|
||||
|
@ -6,7 +6,7 @@ use gemini::Gemini;
|
||||
use search::Search;
|
||||
use source::Source;
|
||||
|
||||
use super::{TabAction, WindowAction};
|
||||
use super::{BrowserAction, TabAction, WindowAction};
|
||||
use adw::Clamp;
|
||||
use gtk::{
|
||||
glib::Uri,
|
||||
@ -31,10 +31,14 @@ impl Text {
|
||||
pub fn new_gemini(
|
||||
gemtext: &str,
|
||||
base: &Uri,
|
||||
(window_action, tab_action): (Rc<WindowAction>, Rc<TabAction>),
|
||||
(browser_action, window_action, tab_action): (
|
||||
&Rc<BrowserAction>,
|
||||
&Rc<WindowAction>,
|
||||
&Rc<TabAction>,
|
||||
),
|
||||
) -> Self {
|
||||
// Init components
|
||||
let gemini = Gemini::new(gemtext, base, (window_action.clone(), tab_action));
|
||||
let gemini = Gemini::new(gemtext, base, (window_action, tab_action));
|
||||
let search = Rc::new(Search::new(&gemini.reader.buffer));
|
||||
|
||||
// Init main widget
|
||||
@ -55,6 +59,13 @@ impl Text {
|
||||
);
|
||||
|
||||
// Connect events
|
||||
browser_action.escape.connect_activate({
|
||||
let close = search.close.clone();
|
||||
move || {
|
||||
close.activate();
|
||||
}
|
||||
});
|
||||
|
||||
window_action.find.connect_activate({
|
||||
let search = search.clone();
|
||||
move |_| {
|
||||
|
@ -15,9 +15,15 @@ pub struct Gemini {
|
||||
|
||||
impl Gemini {
|
||||
// Construct
|
||||
pub fn new(gemtext: &str, base: &Uri, actions: (Rc<WindowAction>, Rc<TabAction>)) -> Self {
|
||||
pub fn new(
|
||||
gemtext: &str,
|
||||
base: &Uri,
|
||||
(window_action, tab_action): (&Rc<WindowAction>, &Rc<TabAction>),
|
||||
) -> Self {
|
||||
// Init components
|
||||
let reader = Rc::new(Reader::new(gemtext, base, actions).unwrap()); // @TODO handle errors
|
||||
let reader = Rc::new(
|
||||
Reader::new(gemtext, base, (window_action.clone(), tab_action.clone())).unwrap(),
|
||||
); // @TODO handle errors
|
||||
let widget = Rc::new(Widget::new(&reader.widget.text_view));
|
||||
|
||||
// Result
|
||||
|
Loading…
x
Reference in New Issue
Block a user