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.
This commit is contained in:
parent
46696253e9
commit
dedea9494e
2 changed files with 8 additions and 16 deletions
|
@ -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();
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue