[fractal] Drop Data also when exiting media viewer via esc
- From: Daniel Garcia Moreno <danigm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [fractal] Drop Data also when exiting media viewer via esc
- Date: Fri, 27 Mar 2020 17:05:01 +0000 (UTC)
commit dedea9494e1ecddb287204b8ecd8d52a046223d8
Author: Sonja Heinze <sonjaleaheinze gmail com>
Date: Fri Mar 6 00:57:30 2020 +0100
Drop Data also when exiting media viewer via esc
Before, the structs MediaViewer and Data were only dropped when exiting
the media viewer by clicking the back button. Therefore, the callback
responsible for entering full screen mode through double click also only
in that case got disconnected.
Now, both things happen when the media viewer back action is activated.
That includes exiting the media viewer by clicking the esc button.
fractal-gtk/src/actions/global.rs | 10 ++++++++--
fractal-gtk/src/appop/media_viewer.rs | 14 --------------
2 files changed, 8 insertions(+), 16 deletions(-)
---
diff --git a/fractal-gtk/src/actions/global.rs b/fractal-gtk/src/actions/global.rs
index 06187cfc..afec9d03 100644
--- a/fractal-gtk/src/actions/global.rs
+++ b/fractal-gtk/src/actions/global.rs
@@ -255,10 +255,16 @@ pub fn new(app: >k::Application, op: &Arc<Mutex<AppOp>>) {
back.borrow_mut().push(AppState::MediaViewer);
});
+ let mv_weak = Rc::downgrade(&op.lock().unwrap().media_viewer);
let back_weak = Rc::downgrade(&back_history);
back.connect_activate(move |_, _| {
+ let mv = upgrade_weak!(mv_weak);
+ if let Some(mut mv) = mv.borrow_mut().take() {
+ mv.disconnect_signal_id();
+ }
+
+ // Remove the current state from the store
back_weak.upgrade().map(|back| {
- // Remove the current state form the store
back.borrow_mut().pop();
if let Some(state) = back.borrow().last() {
debug!("Go back to state {:?}", state);
@@ -267,7 +273,7 @@ pub fn new(app: >k::Application, op: &Arc<Mutex<AppOp>>) {
op.set_state(state.clone());
}
} else {
- // Falback when there is no back history
+ // Fallback when there is no back history
debug!("There is no state to go back to. Go back to state NoRoom");
if let Some(op) = App::get_op() {
let mut op = op.lock().unwrap();
diff --git a/fractal-gtk/src/appop/media_viewer.rs b/fractal-gtk/src/appop/media_viewer.rs
index 2db26d5a..8e2ed0e0 100644
--- a/fractal-gtk/src/appop/media_viewer.rs
+++ b/fractal-gtk/src/appop/media_viewer.rs
@@ -2,8 +2,6 @@ use gtk;
use gtk::prelude::*;
use log::error;
-use std::cell::RefCell;
-use std::rc::Rc;
use crate::actions;
@@ -75,18 +73,6 @@ impl AppOp {
stack.add_named(&body, "media-viewer");
stack_header.add_named(&header, "media-viewer");
-
- let media_viewer_back_button = panel
- .builder
- .get_object::<gtk::Button>("media_viewer_back_button")
- .expect("Can't find media_viewer_back_button in ui file.");
- self.media_viewer = Rc::new(RefCell::new(Some(panel)));
- let mv = self.media_viewer.clone();
- media_viewer_back_button.connect_clicked(move |_| {
- if let Some(mut mv) = mv.borrow_mut().take() {
- mv.disconnect_signal_id();
- }
- });
}
self.set_state(AppState::MediaViewer);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]