|
| 1 | +use crate::files_panel; |
1 | 2 | use crate::state::FmState; |
2 | 3 | use gtk4::gio::{Menu, SimpleAction}; |
| 4 | +use gtk4::glib; |
3 | 5 | use gtk4::prelude::*; |
4 | | -use gtk4::{Box as GtkBox, MenuButton, ApplicationWindow, Application}; |
| 6 | +use gtk4::{Application, ApplicationWindow, Box as GtkBox, MenuButton}; |
5 | 7 | use std::cell::RefCell; |
6 | 8 | use std::rc::Rc; |
7 | | -use gtk4::{glib, gio}; |
8 | | -use crate::files_panel; |
9 | 9 |
|
10 | 10 | pub fn build_headerbar() -> GtkBox { |
11 | 11 | let headerbar = GtkBox::new(gtk4::Orientation::Horizontal, 6); |
@@ -38,38 +38,57 @@ pub fn build_headerbar() -> GtkBox { |
38 | 38 | headerbar |
39 | 39 | } |
40 | 40 |
|
41 | | -pub fn implement_actions(window: &ApplicationWindow, app: &Application, fmstate: Rc<RefCell<FmState>>, files_list: >k4::StringList) { |
| 41 | +pub fn implement_actions( |
| 42 | + window: &ApplicationWindow, |
| 43 | + app: &Application, |
| 44 | + fmstate: Rc<RefCell<FmState>>, |
| 45 | + files_list: >k4::StringList, |
| 46 | +) { |
42 | 47 | // Show Hidden Files action |
43 | 48 | let show_hidden_initial = fmstate.borrow().settings.show_hidden; |
44 | 49 | let show_hidden_action = |
45 | 50 | SimpleAction::new_stateful("show_hidden", None, &show_hidden_initial.into()); |
46 | 51 |
|
47 | | - show_hidden_action.connect_activate(glib::clone!(#[strong] fmstate, #[weak] files_list, move |action, _| { |
48 | | - let current: bool = action.state().unwrap().get().unwrap(); |
49 | | - action.set_state(&(!current).into()); |
50 | | - |
51 | | - let mut fmstate_mut = fmstate.borrow_mut(); |
52 | | - fmstate_mut.settings.show_hidden = !current; |
53 | | - |
54 | | - files_panel::populate_files_list( |
55 | | - &files_list, |
56 | | - &fmstate_mut.current_path, |
57 | | - &fmstate_mut.settings.show_hidden, |
58 | | - ); |
59 | | - })); |
| 52 | + show_hidden_action.connect_activate(glib::clone!( |
| 53 | + #[strong] |
| 54 | + fmstate, |
| 55 | + #[weak] |
| 56 | + files_list, |
| 57 | + move |action, _| { |
| 58 | + let current: bool = action.state().unwrap().get().unwrap(); |
| 59 | + action.set_state(&(!current).into()); |
| 60 | + |
| 61 | + let mut fmstate_mut = fmstate.borrow_mut(); |
| 62 | + fmstate_mut.settings.show_hidden = !current; |
| 63 | + |
| 64 | + files_panel::populate_files_list( |
| 65 | + &files_list, |
| 66 | + &fmstate_mut.current_path, |
| 67 | + &fmstate_mut.settings.show_hidden, |
| 68 | + ); |
| 69 | + } |
| 70 | + )); |
60 | 71 |
|
61 | 72 | window.add_action(&show_hidden_action); |
62 | 73 |
|
63 | 74 | let new_window_action = SimpleAction::new("open_new_window", None); |
64 | | - new_window_action.connect_activate(glib::clone!(#[weak] app, move |_, _| { |
65 | | - crate::build_fm(&app); |
66 | | - })); |
| 75 | + new_window_action.connect_activate(glib::clone!( |
| 76 | + #[weak] |
| 77 | + app, |
| 78 | + move |_, _| { |
| 79 | + crate::build_fm(&app); |
| 80 | + } |
| 81 | + )); |
67 | 82 | window.add_action(&new_window_action); |
68 | 83 |
|
69 | 84 | let close_window_action = SimpleAction::new("close_window", None); |
70 | | - close_window_action.connect_activate(glib::clone!(#[weak] window, move |_, _| { |
71 | | - window.close(); |
72 | | - })); |
| 85 | + close_window_action.connect_activate(glib::clone!( |
| 86 | + #[weak] |
| 87 | + window, |
| 88 | + move |_, _| { |
| 89 | + window.close(); |
| 90 | + } |
| 91 | + )); |
73 | 92 | window.add_action(&close_window_action); |
74 | 93 |
|
75 | 94 | let undo_action = SimpleAction::new("undo_history", None); |
|
0 commit comments