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 {
|
) -> Self {
|
||||||
// Init components
|
// 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(
|
let navigation = Rc::new(Navigation::new(
|
||||||
profile.clone(),
|
profile.clone(),
|
||||||
|
@ -5,7 +5,7 @@ mod text;
|
|||||||
use image::Image;
|
use image::Image;
|
||||||
use text::Text;
|
use text::Text;
|
||||||
|
|
||||||
use super::{TabAction, WindowAction};
|
use super::{BrowserAction, TabAction, WindowAction};
|
||||||
use adw::StatusPage;
|
use adw::StatusPage;
|
||||||
use gtk::{
|
use gtk::{
|
||||||
gdk::Paintable,
|
gdk::Paintable,
|
||||||
@ -17,6 +17,7 @@ use gtk::{
|
|||||||
use std::{rc::Rc, time::Duration};
|
use std::{rc::Rc, time::Duration};
|
||||||
|
|
||||||
pub struct Content {
|
pub struct Content {
|
||||||
|
browser_action: Rc<BrowserAction>,
|
||||||
window_action: Rc<WindowAction>,
|
window_action: Rc<WindowAction>,
|
||||||
tab_action: Rc<TabAction>,
|
tab_action: Rc<TabAction>,
|
||||||
pub g_box: Box,
|
pub g_box: Box,
|
||||||
@ -26,11 +27,18 @@ impl Content {
|
|||||||
// Construct
|
// Construct
|
||||||
|
|
||||||
/// Create new container for different components
|
/// 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 {
|
Self {
|
||||||
g_box: Box::builder().orientation(Orientation::Vertical).build(),
|
g_box: Box::builder().orientation(Orientation::Vertical).build(),
|
||||||
window_action: action.0,
|
browser_action,
|
||||||
tab_action: action.1,
|
window_action,
|
||||||
|
tab_action,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -125,7 +133,7 @@ impl Content {
|
|||||||
let text = Text::new_gemini(
|
let text = Text::new_gemini(
|
||||||
data,
|
data,
|
||||||
base,
|
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);
|
self.g_box.append(&text.g_box);
|
||||||
text
|
text
|
||||||
|
@ -6,7 +6,7 @@ use gemini::Gemini;
|
|||||||
use search::Search;
|
use search::Search;
|
||||||
use source::Source;
|
use source::Source;
|
||||||
|
|
||||||
use super::{TabAction, WindowAction};
|
use super::{BrowserAction, TabAction, WindowAction};
|
||||||
use adw::Clamp;
|
use adw::Clamp;
|
||||||
use gtk::{
|
use gtk::{
|
||||||
glib::Uri,
|
glib::Uri,
|
||||||
@ -31,10 +31,14 @@ impl Text {
|
|||||||
pub fn new_gemini(
|
pub fn new_gemini(
|
||||||
gemtext: &str,
|
gemtext: &str,
|
||||||
base: &Uri,
|
base: &Uri,
|
||||||
(window_action, tab_action): (Rc<WindowAction>, Rc<TabAction>),
|
(browser_action, window_action, tab_action): (
|
||||||
|
&Rc<BrowserAction>,
|
||||||
|
&Rc<WindowAction>,
|
||||||
|
&Rc<TabAction>,
|
||||||
|
),
|
||||||
) -> Self {
|
) -> Self {
|
||||||
// Init components
|
// 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));
|
let search = Rc::new(Search::new(&gemini.reader.buffer));
|
||||||
|
|
||||||
// Init main widget
|
// Init main widget
|
||||||
@ -55,6 +59,13 @@ impl Text {
|
|||||||
);
|
);
|
||||||
|
|
||||||
// Connect events
|
// Connect events
|
||||||
|
browser_action.escape.connect_activate({
|
||||||
|
let close = search.close.clone();
|
||||||
|
move || {
|
||||||
|
close.activate();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
window_action.find.connect_activate({
|
window_action.find.connect_activate({
|
||||||
let search = search.clone();
|
let search = search.clone();
|
||||||
move |_| {
|
move |_| {
|
||||||
|
@ -15,9 +15,15 @@ pub struct Gemini {
|
|||||||
|
|
||||||
impl Gemini {
|
impl Gemini {
|
||||||
// Construct
|
// 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
|
// 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));
|
let widget = Rc::new(Widget::new(&reader.widget.text_view));
|
||||||
|
|
||||||
// Result
|
// Result
|
||||||
|
Loading…
x
Reference in New Issue
Block a user