mirror of
https://github.com/YGGverse/Yoda.git
synced 2025-01-15 09:10:08 +00:00
draft focus out action
This commit is contained in:
parent
44c669389a
commit
e606ef5fa9
@ -156,6 +156,14 @@ impl App {
|
|||||||
),
|
),
|
||||||
&["<Primary>u"],
|
&["<Primary>u"],
|
||||||
),
|
),
|
||||||
|
(
|
||||||
|
format!(
|
||||||
|
"{}.{}",
|
||||||
|
browser.action.id,
|
||||||
|
browser.action.focus.gobject.name()
|
||||||
|
),
|
||||||
|
&["Escape"],
|
||||||
|
),
|
||||||
// Tab actions
|
// Tab actions
|
||||||
(
|
(
|
||||||
format!(
|
format!(
|
||||||
|
@ -69,6 +69,13 @@ impl Browser {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
action.focus.connect_activate({
|
||||||
|
let widget = widget.clone();
|
||||||
|
move || {
|
||||||
|
widget.application_window.set_focus(gtk::Window::NONE);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
action.profile.connect_activate({
|
action.profile.connect_activate({
|
||||||
let profile = profile.clone();
|
let profile = profile.clone();
|
||||||
move || {
|
move || {
|
||||||
|
@ -1,12 +1,14 @@
|
|||||||
mod about;
|
mod about;
|
||||||
mod close;
|
mod close;
|
||||||
mod debug;
|
mod debug;
|
||||||
|
mod focus;
|
||||||
mod profile;
|
mod profile;
|
||||||
mod update;
|
mod update;
|
||||||
|
|
||||||
use about::About;
|
use about::About;
|
||||||
use close::Close;
|
use close::Close;
|
||||||
use debug::Debug;
|
use debug::Debug;
|
||||||
|
use focus::Focus;
|
||||||
use profile::Profile;
|
use profile::Profile;
|
||||||
use update::Update;
|
use update::Update;
|
||||||
|
|
||||||
@ -23,6 +25,7 @@ pub struct Action {
|
|||||||
pub about: Rc<About>,
|
pub about: Rc<About>,
|
||||||
pub close: Rc<Close>,
|
pub close: Rc<Close>,
|
||||||
pub debug: Rc<Debug>,
|
pub debug: Rc<Debug>,
|
||||||
|
pub focus: Rc<Focus>,
|
||||||
pub profile: Rc<Profile>,
|
pub profile: Rc<Profile>,
|
||||||
pub update: Rc<Update>,
|
pub update: Rc<Update>,
|
||||||
// Group
|
// Group
|
||||||
@ -39,6 +42,7 @@ impl Action {
|
|||||||
let about = Rc::new(About::new());
|
let about = Rc::new(About::new());
|
||||||
let close = Rc::new(Close::new());
|
let close = Rc::new(Close::new());
|
||||||
let debug = Rc::new(Debug::new());
|
let debug = Rc::new(Debug::new());
|
||||||
|
let focus = Rc::new(Focus::new());
|
||||||
let profile = Rc::new(Profile::new());
|
let profile = Rc::new(Profile::new());
|
||||||
let update = Rc::new(Update::new());
|
let update = Rc::new(Update::new());
|
||||||
|
|
||||||
@ -52,6 +56,7 @@ impl Action {
|
|||||||
gobject.add_action(&about.gobject);
|
gobject.add_action(&about.gobject);
|
||||||
gobject.add_action(&close.gobject);
|
gobject.add_action(&close.gobject);
|
||||||
gobject.add_action(&debug.gobject);
|
gobject.add_action(&debug.gobject);
|
||||||
|
gobject.add_action(&focus.gobject);
|
||||||
gobject.add_action(&profile.gobject);
|
gobject.add_action(&profile.gobject);
|
||||||
gobject.add_action(&update.gobject);
|
gobject.add_action(&update.gobject);
|
||||||
|
|
||||||
@ -60,6 +65,7 @@ impl Action {
|
|||||||
about,
|
about,
|
||||||
close,
|
close,
|
||||||
debug,
|
debug,
|
||||||
|
focus,
|
||||||
profile,
|
profile,
|
||||||
update,
|
update,
|
||||||
id,
|
id,
|
||||||
|
25
src/app/browser/action/focus.rs
Normal file
25
src/app/browser/action/focus.rs
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
use gtk::{gio::SimpleAction, glib::uuid_string_random};
|
||||||
|
|
||||||
|
/// [SimpleAction](https://docs.gtk.org/gio/class.SimpleAction.html) wrapper for `Focus` action of `Browser` group
|
||||||
|
pub struct Focus {
|
||||||
|
pub gobject: SimpleAction,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Focus {
|
||||||
|
// Constructors
|
||||||
|
|
||||||
|
/// Create new `Self`
|
||||||
|
pub fn new() -> Self {
|
||||||
|
Self {
|
||||||
|
gobject: SimpleAction::new(&uuid_string_random(), None),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Events
|
||||||
|
|
||||||
|
/// Define callback function for
|
||||||
|
/// [SimpleAction::activate](https://docs.gtk.org/gio/signal.SimpleAction.activate.html) signal
|
||||||
|
pub fn connect_activate(&self, callback: impl Fn() + 'static) {
|
||||||
|
self.gobject.connect_activate(move |_, _| callback());
|
||||||
|
}
|
||||||
|
}
|
@ -27,7 +27,7 @@ use gtk::{
|
|||||||
gdk_pixbuf::Pixbuf,
|
gdk_pixbuf::Pixbuf,
|
||||||
gio::SocketClientEvent,
|
gio::SocketClientEvent,
|
||||||
glib::{gformat, GString, Priority, Uri, UriFlags, UriHideFlags},
|
glib::{gformat, GString, Priority, Uri, UriFlags, UriHideFlags},
|
||||||
prelude::{EditableExt, FileExt, SocketClientExt, WidgetExt},
|
prelude::{EditableExt, FileExt, SocketClientExt},
|
||||||
};
|
};
|
||||||
use sqlite::Transaction;
|
use sqlite::Transaction;
|
||||||
use std::{rc::Rc, time::Duration};
|
use std::{rc::Rc, time::Duration};
|
||||||
@ -149,7 +149,7 @@ impl Page {
|
|||||||
const DEFAULT_MAX_REDIRECT_COUNT: usize = 10;
|
const DEFAULT_MAX_REDIRECT_COUNT: usize = 10;
|
||||||
|
|
||||||
// Move focus out from navigation entry
|
// Move focus out from navigation entry
|
||||||
self.navigation.reload.widget.gobject.grab_focus();
|
// self.navigation.reload.widget.gobject.grab_focus();
|
||||||
|
|
||||||
// Reset widgets
|
// Reset widgets
|
||||||
self.input.unset();
|
self.input.unset();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user