@@ -29,7 +29,7 @@ use crate::{
29
29
self ,
30
30
color_schemes:: { config:: ColorScheme , preview, ColorSchemeProvider , ColorSchemes } ,
31
31
layouts:: Layouts ,
32
- snapshots:: Snapshots ,
32
+ snapshots:: { config :: SnapshotKind , Snapshots } ,
33
33
} ,
34
34
settings:: { AppTheme , TweaksSettings , CONFIG_VERSION } ,
35
35
} ;
@@ -66,8 +66,7 @@ pub enum Status {
66
66
#[ derive( Clone , Debug , Eq , PartialEq ) ]
67
67
pub enum DialogPage {
68
68
SaveCurrentColorScheme ( String ) ,
69
- SaveCurrentLayout ( String ) ,
70
- CreateSnapshot ,
69
+ CreateSnapshot ( String ) ,
71
70
AvailableColorSchemes ,
72
71
}
73
72
@@ -91,7 +90,6 @@ pub enum Message {
91
90
Key ( Modifiers , Key ) ,
92
91
Modifiers ( Modifiers ) ,
93
92
SystemThemeModeChange ,
94
- SaveNewLayout ( String ) ,
95
93
}
96
94
97
95
#[ derive( Debug , Clone , Eq , PartialEq ) ]
@@ -227,39 +225,28 @@ impl Application for TweakTool {
227
225
. on_input( move |name| {
228
226
Message :: DialogUpdate ( DialogPage :: SaveCurrentColorScheme ( name) )
229
227
} )
228
+ . on_submit( Message :: DialogComplete )
230
229
. into( ) ,
231
230
] )
232
231
. spacing ( spacing. space_xxs ) ,
233
232
)
234
233
}
235
- DialogPage :: SaveCurrentLayout ( name) => widget:: dialog ( fl ! ( "save-current-layout" ) )
236
- . primary_action (
237
- widget:: button:: suggested ( fl ! ( "save" ) )
238
- . on_press_maybe ( Some ( Message :: DialogComplete ) ) ,
239
- )
240
- . secondary_action (
241
- widget:: button:: standard ( fl ! ( "cancel" ) ) . on_press ( Message :: DialogCancel ) ,
242
- )
243
- . control (
244
- widget:: column:: with_children ( vec ! [
245
- widget:: text:: body( fl!( "color-scheme-name" ) ) . into( ) ,
246
- widget:: text_input( "" , name. as_str( ) )
247
- . id( self . dialog_text_input. clone( ) )
248
- . on_input( move |name| {
249
- Message :: DialogUpdate ( DialogPage :: SaveCurrentLayout ( name) )
250
- } )
251
- . into( ) ,
252
- ] )
253
- . spacing ( spacing. space_xxs ) ,
254
- ) ,
255
- DialogPage :: CreateSnapshot => widget:: dialog ( fl ! ( "create-snapshot" ) )
234
+ DialogPage :: CreateSnapshot ( name) => widget:: dialog ( fl ! ( "create-snapshot" ) )
256
235
. body ( fl ! ( "create-snapshot-description" ) )
257
236
. primary_action (
258
237
widget:: button:: suggested ( fl ! ( "create" ) )
259
238
. on_press_maybe ( Some ( Message :: DialogComplete ) ) ,
260
239
)
261
240
. secondary_action (
262
241
widget:: button:: standard ( fl ! ( "cancel" ) ) . on_press ( Message :: DialogCancel ) ,
242
+ )
243
+ . control (
244
+ widget:: text_input ( fl ! ( "snapshot-name" ) , name. as_str ( ) )
245
+ . id ( self . dialog_text_input . clone ( ) )
246
+ . on_input ( move |name| {
247
+ Message :: DialogUpdate ( DialogPage :: CreateSnapshot ( name) )
248
+ } )
249
+ . on_submit ( Message :: DialogComplete ) ,
263
250
) ,
264
251
DialogPage :: AvailableColorSchemes => {
265
252
let show_more_button: Option < Element < Message > > = match self . status {
@@ -335,10 +322,18 @@ impl Application for TweakTool {
335
322
offset : 0 ,
336
323
} ;
337
324
338
- let mut tasks = vec ! [ app. update( Message :: FetchAvailableColorSchemes (
339
- ColorSchemeProvider :: CosmicThemes ,
340
- app. limit,
341
- ) ) ] ;
325
+ let mut tasks = vec ! [
326
+ app. update( Message :: FetchAvailableColorSchemes (
327
+ ColorSchemeProvider :: CosmicThemes ,
328
+ app. limit,
329
+ ) ) ,
330
+ app. update( Message :: Snapshots (
331
+ pages:: snapshots:: Message :: CreateSnapshot (
332
+ "Application opened" . into( ) ,
333
+ SnapshotKind :: System ,
334
+ ) ,
335
+ ) ) ,
336
+ ] ;
342
337
343
338
if let Some ( id) = app. core . main_window_id ( ) {
344
339
tasks. push ( app. set_window_title ( fl ! ( "app-title" ) , id) ) ;
@@ -476,14 +471,12 @@ impl Application for TweakTool {
476
471
. map ( cosmic:: app:: Message :: App ) ,
477
472
) ,
478
473
Message :: Layouts ( message) => match message {
479
- pages:: layouts:: Message :: OpenSaveDialog => commands. push ( self . update (
480
- Message :: ToggleDialogPage ( DialogPage :: SaveCurrentLayout ( String :: new ( ) ) ) ,
481
- ) ) ,
482
474
_ => commands. push ( self . layouts . update ( message) . map ( cosmic:: app:: Message :: App ) ) ,
483
475
} ,
484
476
Message :: Snapshots ( message) => match message {
485
- pages:: snapshots:: Message :: OpenSaveDialog => commands
486
- . push ( self . update ( Message :: ToggleDialogPage ( DialogPage :: CreateSnapshot ) ) ) ,
477
+ pages:: snapshots:: Message :: OpenSaveDialog => commands. push ( self . update (
478
+ Message :: ToggleDialogPage ( DialogPage :: CreateSnapshot ( String :: new ( ) ) ) ,
479
+ ) ) ,
487
480
_ => commands. push (
488
481
self . snapshots
489
482
. update ( message)
@@ -512,9 +505,6 @@ impl Application for TweakTool {
512
505
pages:: color_schemes:: Message :: SaveCurrentColorScheme ( Some ( name) ) ,
513
506
) ) ) )
514
507
}
515
- Message :: SaveNewLayout ( name) => commands. push ( self . update ( Message :: Layouts (
516
- pages:: layouts:: Message :: SaveCurrentLayout ( name) ,
517
- ) ) ) ,
518
508
Message :: ToggleDialogPage ( dialog_page) => {
519
509
self . dialog_pages . push_back ( dialog_page) ;
520
510
commands. push ( widget:: text_input:: focus ( self . dialog_text_input . clone ( ) ) ) ;
@@ -528,12 +518,11 @@ impl Application for TweakTool {
528
518
DialogPage :: SaveCurrentColorScheme ( name) => {
529
519
commands. push ( self . update ( Message :: SaveNewColorScheme ( name) ) )
530
520
}
531
- DialogPage :: SaveCurrentLayout ( name) => {
532
- commands. push ( self . update ( Message :: SaveNewLayout ( name) ) )
521
+ DialogPage :: CreateSnapshot ( name) => {
522
+ commands. push ( self . update ( Message :: Snapshots (
523
+ pages:: snapshots:: Message :: CreateSnapshot ( name, SnapshotKind :: User ) ,
524
+ ) ) )
533
525
}
534
- DialogPage :: CreateSnapshot => commands. push ( self . update (
535
- Message :: Snapshots ( pages:: snapshots:: Message :: CreateSnapshot ) ,
536
- ) ) ,
537
526
DialogPage :: AvailableColorSchemes => ( ) ,
538
527
}
539
528
}
0 commit comments