[fractal/fractal-next] content: Unselect room on ESC
- From: Julian Sparber <jsparber src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [fractal/fractal-next] content: Unselect room on ESC
- Date: Mon, 12 Jul 2021 10:31:07 +0000 (UTC)
commit 8a86bd2ad7409142417bd6b12469c1e00a9b4901
Author: Kai A. Hiller <V02460 gmail com>
Date: Fri Jul 9 19:03:22 2021 +0200
content: Unselect room on ESC
data/resources/ui/shortcuts.ui | 7 ++++++-
src/application.rs | 1 +
src/session/mod.rs | 2 +-
src/window.rs | 7 +++++++
4 files changed, 15 insertions(+), 2 deletions(-)
---
diff --git a/data/resources/ui/shortcuts.ui b/data/resources/ui/shortcuts.ui
index e1a75664..33a33378 100644
--- a/data/resources/ui/shortcuts.ui
+++ b/data/resources/ui/shortcuts.ui
@@ -27,10 +27,15 @@
<property name="action-name">win.toggle-room-search</property>
</object>
</child>
+ <child>
+ <object class="GtkShortcutsShortcut">
+ <property name="title" translatable="yes" context="shortcut window">Close Room</property>
+ <property name="action-name">win.close-room</property>
+ </object>
+ </child>
</object>
</child>
</object>
</child>
</object>
</interface>
-
diff --git a/src/application.rs b/src/application.rs
index f8775c62..d7039ccb 100644
--- a/src/application.rs
+++ b/src/application.rs
@@ -125,6 +125,7 @@ impl Application {
self.set_accels_for_action("app.quit", &["<Control>q"]);
self.set_accels_for_action("win.show-help-overlay", &["<Control>question"]);
self.set_accels_for_action("win.toggle-room-search", &["<Control>k"]);
+ self.set_accels_for_action("win.close-room", &["Escape"]);
}
fn setup_css(&self) {
diff --git a/src/session/mod.rs b/src/session/mod.rs
index cf0d36ef..92c7c87e 100644
--- a/src/session/mod.rs
+++ b/src/session/mod.rs
@@ -202,7 +202,7 @@ impl Session {
priv_.selected_room.borrow().clone()
}
- fn set_selected_room(&self, selected_room: Option<Room>) {
+ pub fn set_selected_room(&self, selected_room: Option<Room>) {
let priv_ = imp::Session::from_instance(self);
if self.selected_room() == selected_room {
diff --git a/src/window.rs b/src/window.rs
index 8ec431ae..266d0b07 100644
--- a/src/window.rs
+++ b/src/window.rs
@@ -1,4 +1,5 @@
use crate::config::{APP_ID, PROFILE};
+use crate::gio::SimpleAction;
use crate::secret;
use crate::Application;
use crate::Login;
@@ -115,6 +116,12 @@ impl Window {
"search-mode-enabled",
);
self.add_action(&room_search_toggle_action);
+
+ let close_room_action = SimpleAction::new("close-room", None);
+ close_room_action.connect_activate(clone!(@weak session => move |_, _| {
+ session.set_selected_room(None);
+ }));
+ self.add_action(&close_room_action);
}
fn restore_sessions(&self) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]