@@ -23,12 +23,13 @@ use key_bind::key_binds;
23
23
use pages:: color_schemes:: providers:: cosmic_themes:: CosmicTheme ;
24
24
25
25
use crate :: {
26
- core:: nav:: NavPage ,
26
+ core:: nav:: Page ,
27
27
fl,
28
28
pages:: {
29
29
self ,
30
30
color_schemes:: { config:: ColorScheme , preview, ColorSchemeProvider , ColorSchemes } ,
31
31
layouts:: Layouts ,
32
+ snapshots:: Snapshots ,
32
33
} ,
33
34
settings:: { AppTheme , TweaksSettings , CONFIG_VERSION } ,
34
35
} ;
@@ -45,6 +46,7 @@ pub struct TweakTool {
45
46
modifiers : Modifiers ,
46
47
color_schemes : ColorSchemes ,
47
48
layouts : Layouts ,
49
+ snapshots : Snapshots ,
48
50
context_page : ContextPage ,
49
51
app_themes : Vec < String > ,
50
52
config_handler : Option < cosmic_config:: Config > ,
@@ -65,6 +67,7 @@ pub enum Status {
65
67
pub enum DialogPage {
66
68
SaveCurrentColorScheme ( String ) ,
67
69
SaveCurrentLayout ( String ) ,
70
+ CreateSnapshot ,
68
71
AvailableColorSchemes ,
69
72
}
70
73
@@ -73,6 +76,7 @@ pub enum Message {
73
76
Dock ( pages:: dock:: Message ) ,
74
77
Panel ( pages:: panel:: Message ) ,
75
78
Layouts ( pages:: layouts:: Message ) ,
79
+ Snapshots ( pages:: snapshots:: Message ) ,
76
80
ColorSchemes ( Box < pages:: color_schemes:: Message > ) ,
77
81
DialogUpdate ( DialogPage ) ,
78
82
DialogComplete ,
@@ -177,7 +181,7 @@ impl Application for TweakTool {
177
181
return Task :: none ( ) ;
178
182
} ;
179
183
180
- let title = if let Some ( page) = self . nav_model . data :: < NavPage > ( id) {
184
+ let title = if let Some ( page) = self . nav_model . data :: < Page > ( id) {
181
185
format ! ( "{} - {}" , page. title( ) , fl!( "app-title" ) )
182
186
} else {
183
187
fl ! ( "app-title" )
@@ -228,7 +232,7 @@ impl Application for TweakTool {
228
232
. spacing ( spacing. space_xxs ) ,
229
233
)
230
234
}
231
- DialogPage :: SaveCurrentLayout ( name) => widget:: dialog ( fl ! ( "save-current-color-scheme " ) )
235
+ DialogPage :: SaveCurrentLayout ( name) => widget:: dialog ( fl ! ( "save-current-layout " ) )
232
236
. primary_action (
233
237
widget:: button:: suggested ( fl ! ( "save" ) )
234
238
. on_press_maybe ( Some ( Message :: DialogComplete ) ) ,
@@ -248,6 +252,15 @@ impl Application for TweakTool {
248
252
] )
249
253
. spacing ( spacing. space_xxs ) ,
250
254
) ,
255
+ DialogPage :: CreateSnapshot => widget:: dialog ( fl ! ( "create-snapshot" ) )
256
+ . body ( fl ! ( "create-snapshot-description" ) )
257
+ . primary_action (
258
+ widget:: button:: suggested ( fl ! ( "create" ) )
259
+ . on_press_maybe ( Some ( Message :: DialogComplete ) ) ,
260
+ )
261
+ . secondary_action (
262
+ widget:: button:: standard ( fl ! ( "cancel" ) ) . on_press ( Message :: DialogCancel ) ,
263
+ ) ,
251
264
DialogPage :: AvailableColorSchemes => {
252
265
let show_more_button: Option < Element < Message > > = match self . status {
253
266
Status :: Idle => Some (
@@ -289,15 +302,15 @@ impl Application for TweakTool {
289
302
log:: info!( "Starting Cosmic Tweak Tool..." ) ;
290
303
291
304
let mut nav_model = segmented_button:: SingleSelectModel :: default ( ) ;
292
- for & nav_page in NavPage :: all ( ) {
305
+ for & nav_page in Page :: all ( ) {
293
306
let id = nav_model
294
307
. insert ( )
295
308
. icon ( nav_page. icon ( ) )
296
309
. text ( nav_page. title ( ) )
297
- . data :: < NavPage > ( nav_page)
310
+ . data :: < Page > ( nav_page)
298
311
. id ( ) ;
299
312
300
- if nav_page == NavPage :: default ( ) {
313
+ if nav_page == Page :: default ( ) {
301
314
nav_model. activate ( id) ;
302
315
}
303
316
}
@@ -311,6 +324,7 @@ impl Application for TweakTool {
311
324
modifiers : Modifiers :: empty ( ) ,
312
325
color_schemes : ColorSchemes :: default ( ) ,
313
326
layouts : Layouts :: default ( ) ,
327
+ snapshots : Snapshots :: default ( ) ,
314
328
context_page : ContextPage :: About ,
315
329
app_themes : vec ! [ fl!( "match-desktop" ) , fl!( "dark" ) , fl!( "light" ) ] ,
316
330
config_handler : flags. config_handler ,
@@ -336,17 +350,18 @@ impl Application for TweakTool {
336
350
fn view ( & self ) -> Element < Self :: Message > {
337
351
let spacing = cosmic:: theme:: active ( ) . cosmic ( ) . spacing ;
338
352
let entity = self . nav_model . active ( ) ;
339
- let nav_page = self . nav_model . data :: < NavPage > ( entity) . unwrap_or_default ( ) ;
353
+ let nav_page = self . nav_model . data :: < Page > ( entity) . unwrap_or_default ( ) ;
340
354
341
355
let view = match nav_page {
342
- NavPage :: ColorSchemes => self
356
+ Page :: ColorSchemes => self
343
357
. color_schemes
344
358
. view ( )
345
359
. map ( Box :: new)
346
360
. map ( Message :: ColorSchemes ) ,
347
- NavPage :: Dock => pages:: dock:: Dock :: default ( ) . view ( ) . map ( Message :: Dock ) ,
348
- NavPage :: Panel => pages:: panel:: Panel :: default ( ) . view ( ) . map ( Message :: Panel ) ,
349
- NavPage :: Layouts => self . layouts . view ( ) . map ( Message :: Layouts ) ,
361
+ Page :: Dock => pages:: dock:: Dock :: default ( ) . view ( ) . map ( Message :: Dock ) ,
362
+ Page :: Panel => pages:: panel:: Panel :: default ( ) . view ( ) . map ( Message :: Panel ) ,
363
+ Page :: Layouts => self . layouts . view ( ) . map ( Message :: Layouts ) ,
364
+ Page :: Snapshots => self . snapshots . view ( ) . map ( Message :: Snapshots ) ,
350
365
} ;
351
366
352
367
widget:: column:: with_children ( vec ! [ view] )
@@ -466,6 +481,15 @@ impl Application for TweakTool {
466
481
) ) ,
467
482
_ => commands. push ( self . layouts . update ( message) . map ( cosmic:: app:: Message :: App ) ) ,
468
483
} ,
484
+ Message :: Snapshots ( message) => match message {
485
+ pages:: snapshots:: Message :: OpenSaveDialog => commands
486
+ . push ( self . update ( Message :: ToggleDialogPage ( DialogPage :: CreateSnapshot ) ) ) ,
487
+ _ => commands. push (
488
+ self . snapshots
489
+ . update ( message)
490
+ . map ( cosmic:: app:: Message :: App ) ,
491
+ ) ,
492
+ } ,
469
493
Message :: ColorSchemes ( message) => match * message {
470
494
pages:: color_schemes:: Message :: SaveCurrentColorScheme ( None ) => {
471
495
commands. push ( self . update ( Message :: ToggleDialogPage (
@@ -507,6 +531,9 @@ impl Application for TweakTool {
507
531
DialogPage :: SaveCurrentLayout ( name) => {
508
532
commands. push ( self . update ( Message :: SaveNewLayout ( name) ) )
509
533
}
534
+ DialogPage :: CreateSnapshot => commands. push ( self . update (
535
+ Message :: Snapshots ( pages:: snapshots:: Message :: CreateSnapshot ) ,
536
+ ) ) ,
510
537
DialogPage :: AvailableColorSchemes => ( ) ,
511
538
}
512
539
}
0 commit comments