@@ -2,7 +2,7 @@ use std::cell::RefCell;
22use std:: rc:: Rc ;
33
44use gtk:: glib:: clone;
5- use gtk:: { gio, glib, DropDown , Expression , ListItem , SignalListItemFactory } ;
5+ use gtk:: { gio, glib, CheckButton , DropDown , Expression , ListItem , SignalListItemFactory } ;
66use gtk:: { prelude:: * , Label , TextView } ;
77use gtk:: { Box , Entry } ;
88
@@ -18,6 +18,7 @@ pub struct DoorEdit {
1818 name_input : Entry ,
1919 notes_input : TextView ,
2020 leads_to_input : DropDown ,
21+ hidden_input : CheckButton ,
2122 chambers_model : gio:: ListStore ,
2223}
2324
@@ -29,6 +30,7 @@ impl DoorEdit {
2930 . left_margin ( 10 )
3031 . right_margin ( 10 )
3132 . build ( ) ;
33+ let hidden_i = CheckButton :: builder ( ) . label ( "Hidden" ) . build ( ) ;
3234
3335 let chamber_vec: Vec < ChamberObject > =
3436 vec ! [ ChamberObject :: new( None , "-- No Chamber --" . to_owned( ) ) ] ;
@@ -115,6 +117,15 @@ impl DoorEdit {
115117 }
116118 } ) ) ;
117119
120+ hidden_i. connect_toggled (
121+ clone ! ( @strong control => move |w| if let Ok ( mut control) = control. try_borrow_mut( ) {
122+ match control. state. active_door_id {
123+ None => ( ) ,
124+ Some ( door_id) => control. apply( StateCommand :: ChangeDoorHidden ( door_id, w. is_active( ) ) ) ,
125+ }
126+ } ) ,
127+ ) ;
128+
118129 let b = Box :: builder ( )
119130 . orientation ( gtk:: Orientation :: Vertical )
120131 . build ( ) ;
@@ -123,6 +134,7 @@ impl DoorEdit {
123134 b. append ( & part_of_label) ;
124135 b. append ( & Label :: new ( Some ( "Name" ) ) ) ;
125136 b. append ( & name_i) ;
137+ b. append ( & hidden_i) ;
126138 b. append ( & Label :: new ( Some ( "Notes" ) ) ) ;
127139 b. append ( & notes_i) ;
128140 b. append ( & Label :: new ( Some ( "Leads to Chamber:" ) ) ) ;
@@ -136,6 +148,7 @@ impl DoorEdit {
136148 name_input : name_i,
137149 notes_input : notes_i,
138150 leads_to_input : leads_to_i,
151+ hidden_input : hidden_i,
139152 chambers_model : model,
140153 } ) ) ;
141154
@@ -177,6 +190,7 @@ impl StateEventSubscriber for DoorEdit {
177190 self . notes_input . buffer ( ) . set_text ( & door. notes ) ;
178191 self . leads_to_input
179192 . set_selected ( self . chamber_object_pos ( door. leads_to ) ) ;
193+ self . hidden_input . set_active ( door. hidden ) ;
180194 self . widget . set_visible ( true ) ;
181195 }
182196 StateEvent :: Reset => self . widget . set_visible ( false ) ,
0 commit comments