@@ -85,46 +85,62 @@ impl SettingsWindowView {
8585 & mut self . config . show_layout_button ,
8686 "Show layout button" ,
8787 ) ) ;
88+
89+ ui. add ( egui:: Checkbox :: new (
90+ & mut self . config . hide_empty_workspaces ,
91+ "Hide empty workspaces" ,
92+ ) ) ;
8893 }
8994
90- fn layout_button_ui ( & mut self , ui : & mut egui:: Ui , monitor_id : & str ) {
95+ fn show_layout_button_ui ( & mut self , ui : & mut egui:: Ui , monitor_id : & str ) {
9196 let monitor_config = self . config . get_monitor_or_default ( monitor_id) ;
9297
9398 ui. label ( "Show layout button" ) ;
9499
95- #[ derive( Copy , Clone , PartialEq , strum:: Display ) ]
96- enum ShowLayoutButton {
97- Inherit ,
98- Show ,
99- Hide ,
100+ let mut selected: ActivationOption = monitor_config. show_layout_button . into ( ) ;
101+
102+ let before = selected;
103+
104+ egui:: ComboBox :: new ( "show_layout_button" , "" )
105+ . selected_text ( format ! ( "{}" , selected) )
106+ . show_ui ( ui, |ui| {
107+ for option in [
108+ ActivationOption :: Inherit ,
109+ ActivationOption :: Enable ,
110+ ActivationOption :: Disable ,
111+ ] {
112+ ui. selectable_value ( & mut selected, option, format ! ( "{}" , option) ) ;
113+ }
114+ } ) ;
115+
116+ if before != selected {
117+ monitor_config. show_layout_button = selected. into ( ) ;
100118 }
119+ }
101120
102- let mut selected = match monitor_config. show_layout_button {
103- None => ShowLayoutButton :: Inherit ,
104- Some ( true ) => ShowLayoutButton :: Show ,
105- Some ( false ) => ShowLayoutButton :: Hide ,
106- } ;
121+ fn hide_empty_workspaces_ui ( & mut self , ui : & mut egui:: Ui , monitor_id : & str ) {
122+ let monitor_config = self . config . get_monitor_or_default ( monitor_id) ;
123+
124+ ui. label ( "Hide empty workspaces" ) ;
125+
126+ let mut selected: ActivationOption = monitor_config. hide_empty_workspaces . into ( ) ;
107127
108128 let before = selected;
109129
110- egui:: ComboBox :: from_label ( "" )
130+ egui:: ComboBox :: new ( "hide_empty_workspaces" , "" )
111131 . selected_text ( format ! ( "{}" , selected) )
112132 . show_ui ( ui, |ui| {
113133 for option in [
114- ShowLayoutButton :: Inherit ,
115- ShowLayoutButton :: Show ,
116- ShowLayoutButton :: Hide ,
134+ ActivationOption :: Inherit ,
135+ ActivationOption :: Enable ,
136+ ActivationOption :: Disable ,
117137 ] {
118138 ui. selectable_value ( & mut selected, option, format ! ( "{}" , option) ) ;
119139 }
120140 } ) ;
121141
122142 if before != selected {
123- monitor_config. show_layout_button = match selected {
124- ShowLayoutButton :: Inherit => None ,
125- ShowLayoutButton :: Show => Some ( true ) ,
126- ShowLayoutButton :: Hide => Some ( false ) ,
127- } ;
143+ monitor_config. hide_empty_workspaces = selected. into ( ) ;
128144 }
129145 }
130146
@@ -159,7 +175,10 @@ impl SettingsWindowView {
159175 } ) ;
160176 ui. end_row ( ) ;
161177
162- self . layout_button_ui ( ui, monitor_id) ;
178+ self . show_layout_button_ui ( ui, monitor_id) ;
179+ ui. end_row ( ) ;
180+
181+ self . hide_empty_workspaces_ui ( ui, monitor_id) ;
163182 ui. end_row ( ) ;
164183 }
165184
@@ -227,3 +246,31 @@ impl EguiView for SettingsWindowView {
227246 egui:: CentralPanel :: default ( ) . show ( ctx, |ui| self . ui ( ui) ) ;
228247 }
229248}
249+
250+ /// Represents an activation option for a setting: Inherit, Enable, or Disable.
251+ #[ derive( Copy , Clone , PartialEq , strum:: Display ) ]
252+ enum ActivationOption {
253+ Inherit ,
254+ Enable ,
255+ Disable ,
256+ }
257+
258+ impl From < ActivationOption > for Option < bool > {
259+ fn from ( option : ActivationOption ) -> Self {
260+ match option {
261+ ActivationOption :: Inherit => None ,
262+ ActivationOption :: Enable => Some ( false ) ,
263+ ActivationOption :: Disable => Some ( true ) ,
264+ }
265+ }
266+ }
267+
268+ impl From < Option < bool > > for ActivationOption {
269+ fn from ( option : Option < bool > ) -> Self {
270+ match option {
271+ None => ActivationOption :: Inherit ,
272+ Some ( true ) => ActivationOption :: Disable ,
273+ Some ( false ) => ActivationOption :: Enable ,
274+ }
275+ }
276+ }
0 commit comments