mirror of
https://github.com/YGGverse/Yoda.git
synced 2026-04-01 17:15:28 +00:00
remove Escape accels from window actions as blocking dialog windows, replace it with local EventControllerKey implementation, that depends of active focus
This commit is contained in:
parent
4a81297ef1
commit
d469499d46
10 changed files with 37 additions and 68 deletions
|
|
@ -7,7 +7,7 @@ use feature::Feature;
|
|||
use gtk::{
|
||||
gio::Cancellable,
|
||||
glib::{Uri, UriFlags},
|
||||
prelude::{ActionExt, CancellableExt},
|
||||
prelude::CancellableExt,
|
||||
};
|
||||
use std::{cell::Cell, rc::Rc, sync::Arc};
|
||||
|
||||
|
|
@ -37,12 +37,11 @@ impl Client {
|
|||
/// Route tab item `request` to protocol driver
|
||||
/// * or `navigation` entry if the value not provided
|
||||
pub fn handle(&self, request: &str, is_snap_history: bool) {
|
||||
self.page.escape();
|
||||
|
||||
// Deprecate page info but keep it data as is
|
||||
self.page.info.borrow_mut().deprecate();
|
||||
|
||||
// Move focus out from navigation entry @TODO
|
||||
self.page.browser_action.escape.activate(None);
|
||||
|
||||
// Initially disable find action
|
||||
self.page
|
||||
.window_action
|
||||
|
|
|
|||
|
|
@ -5,10 +5,11 @@ mod input;
|
|||
mod navigation;
|
||||
mod search;
|
||||
|
||||
use super::{Action as ItemAction, BrowserAction, Profile, TabAction, WindowAction};
|
||||
use super::{Action as ItemAction, Profile, TabAction, WindowAction};
|
||||
use adw::TabPage;
|
||||
use anyhow::Result;
|
||||
use content::Content;
|
||||
use gtk::prelude::WidgetExt;
|
||||
use info::Info;
|
||||
use input::Input;
|
||||
use navigation::Navigation;
|
||||
|
|
@ -19,7 +20,6 @@ use std::{cell::RefCell, rc::Rc, sync::Arc};
|
|||
pub struct Page {
|
||||
pub profile: Arc<Profile>,
|
||||
// Actions
|
||||
pub browser_action: Rc<BrowserAction>,
|
||||
pub item_action: Rc<ItemAction>,
|
||||
pub window_action: Rc<WindowAction>,
|
||||
// Components
|
||||
|
|
@ -42,8 +42,7 @@ impl Page {
|
|||
|
||||
pub fn build(
|
||||
profile: &Arc<Profile>,
|
||||
(browser_action, window_action, tab_action, item_action): (
|
||||
&Rc<BrowserAction>,
|
||||
(window_action, tab_action, item_action): (
|
||||
&Rc<WindowAction>,
|
||||
&Rc<TabAction>,
|
||||
&Rc<ItemAction>,
|
||||
|
|
@ -65,7 +64,6 @@ impl Page {
|
|||
profile: profile.clone(),
|
||||
tab_page: tab_page.clone(),
|
||||
// Actions
|
||||
browser_action: browser_action.clone(),
|
||||
item_action: item_action.clone(),
|
||||
window_action: window_action.clone(),
|
||||
// Components
|
||||
|
|
@ -86,8 +84,14 @@ impl Page {
|
|||
|
||||
/// Request `Escape` action for all page components
|
||||
pub fn escape(&self) {
|
||||
use gtk::prelude::RootExt;
|
||||
self.search.hide();
|
||||
self.navigation.escape();
|
||||
self.content
|
||||
.g_box
|
||||
.root()
|
||||
.unwrap()
|
||||
.set_focus(gtk::Window::NONE);
|
||||
}
|
||||
|
||||
/// Toggle `Find` widget
|
||||
|
|
|
|||
|
|
@ -49,6 +49,22 @@ impl Search {
|
|||
g_box.append(&placeholder.label);
|
||||
g_box.append(&close);
|
||||
|
||||
// Hide widget on `Escape` key pressed
|
||||
g_box.add_controller({
|
||||
use gtk::{gdk::Key, glib::Propagation};
|
||||
let c = gtk::EventControllerKey::new();
|
||||
c.connect_key_pressed({
|
||||
let g_box = g_box.clone();
|
||||
move |_, k, _, _| {
|
||||
if k == Key::Escape {
|
||||
g_box.set_visible(false)
|
||||
}
|
||||
Propagation::Stop
|
||||
}
|
||||
});
|
||||
c
|
||||
});
|
||||
|
||||
// Connect events
|
||||
close.connect_clicked({
|
||||
let form = form.clone();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue