@@ -375,14 +375,21 @@ class PomodoroApplet extends Applet.TextIconApplet {
375
375
this . _pomodoroFinishedDialog . open ( ) ;
376
376
}
377
377
}
378
- else if ( ! this . _opt_autoContinueAfterShortBreak && timer === pomodoroTimer ) {
379
- timerQueue . preventStart ( true ) ;
380
- timerQueue . stop ( ) ;
381
- this . _appletMenu . toggleTimerState ( false ) ;
382
- this . _setAppletTooltip ( 0 ) ;
383
- if ( this . _opt_showDialogMessages ) {
384
- this . _playStartSound ( ) ;
385
- this . _shortBreakdialog . open ( ) ;
378
+ else if ( timer === pomodoroTimer ) {
379
+ // Close any short break dialog if we auto-continue once
380
+ // the break is over.
381
+ if ( this . _opt_autoContinueAfterShortBreak ) {
382
+ if ( this . _shortBreakdialog . state == ModalDialog . State . OPENED )
383
+ this . _shortBreakdialog . close ( ) ;
384
+ } else {
385
+ timerQueue . preventStart ( true ) ;
386
+ timerQueue . stop ( ) ;
387
+ this . _appletMenu . toggleTimerState ( false ) ;
388
+ this . _setAppletTooltip ( 0 ) ;
389
+ if ( this . _opt_showDialogMessages ) {
390
+ this . _playStartSound ( ) ;
391
+ this . _shortBreakdialog . open ( ) ;
392
+ }
386
393
}
387
394
}
388
395
} ) ;
@@ -415,14 +422,19 @@ class PomodoroApplet extends Applet.TextIconApplet {
415
422
// connect the short break timer signals
416
423
417
424
shortBreakTimer . connect ( 'timer-tick' , this . _timerTickUpdate . bind ( this ) ) ;
418
-
425
+ shortBreakTimer . connect ( 'timer-tick' , this . _shortBreakdialog . setTimeRemaining . bind ( this . _shortBreakdialog ) ) ;
426
+
419
427
shortBreakTimer . connect ( 'timer-started' , ( ) => {
420
428
this . _setCurrentState ( 'short-break' ) ;
421
429
this . _playBreakSound ( ) ;
430
+ if ( this . _opt_showDialogMessages ) {
431
+ this . _shortBreakdialog . open ( ) ;
432
+ } else {
433
+ Main . notify ( _ ( "Take a short break" ) ) ;
434
+ }
422
435
this . _numPomodoriFinished ++ ;
423
436
this . _appletMenu . updateCounts ( this . _numPomodoroSetFinished , this . _numPomodoriFinished ) ;
424
437
this . _appletMenu . showPomodoroInProgress ( this . _opt_pomodoriNumber ) ;
425
- Main . notify ( _ ( "Take a short break" ) ) ;
426
438
if ( this . _opt_enableScripts && this . _opt_customShortBreakScript ) {
427
439
this . _checkAndExecuteCustomScript ( this . _opt_customShortBreakScript ) ;
428
440
}
@@ -645,14 +657,32 @@ class PomodoroApplet extends Applet.TextIconApplet {
645
657
646
658
_createShortBreakDialog ( ) {
647
659
this . _shortBreakdialog = new PomodoroShortBreakFinishedDialog ( ) ;
648
-
649
- this . _shortBreakdialog . connect ( 'continue-current-pomodoro' , ( ) => {
660
+
661
+ this . _shortBreakdialog . connect ( 'take-break' , ( ) => {
662
+ this . _shortBreakdialog . close ( ) ;
663
+ } ) ;
664
+
665
+ this . _shortBreakdialog . connect ( 'skip-break' , ( ) => {
666
+ this . _timerQueue . skip ( ) ;
650
667
this . _shortBreakdialog . close ( ) ;
651
668
this . _timerQueue . preventStart ( false ) ;
652
669
this . _appletMenu . toggleTimerState ( true ) ;
653
670
this . _timerQueue . start ( ) ;
654
671
} ) ;
655
-
672
+
673
+ this . _shortBreakdialog . connect ( 'pause-pomodoro' , ( ) => {
674
+ this . _timerQueue . stop ( ) ;
675
+ this . _appletMenu . toggleTimerState ( false ) ;
676
+ this . _shortBreakdialog . close ( ) ;
677
+ } ) ;
678
+
679
+ this . _shortBreakdialog . connect ( 'start-next-pomodoro' , ( ) => {
680
+ this . _shortBreakdialog . close ( ) ;
681
+ this . _timerQueue . preventStart ( false ) ;
682
+ this . _appletMenu . toggleTimerState ( true ) ;
683
+ this . _timerQueue . start ( ) ;
684
+ } ) ;
685
+
656
686
this . _shortBreakdialog . connect ( 'pause-pomodoro' , ( ) => {
657
687
this . _timerQueue . stop ( ) ;
658
688
this . _appletMenu . toggleTimerState ( false ) ;
@@ -915,11 +945,26 @@ class PomodoroShortBreakFinishedDialog extends ModalDialog.ModalDialog {
915
945
this . _timeLabel = new St . Label ( ) ;
916
946
this . contentLayout . add ( this . _timeLabel ) ;
917
947
948
+ this . reset ( ) ;
949
+ }
950
+
951
+ close ( ) {
952
+ super . close ( ) ;
953
+ this . reset ( ) ;
954
+ }
955
+
956
+ reset ( ) {
918
957
this . setButtons ( [
919
958
{
920
- label : _ ( "Continue Current Pomodoro " ) ,
959
+ label : _ ( "Take Break " ) ,
921
960
action : ( ) => {
922
- this . emit ( 'continue-current-pomodoro' ) ;
961
+ this . emit ( 'take-break' ) ;
962
+ }
963
+ } ,
964
+ {
965
+ label : _ ( "Skip Break" ) ,
966
+ action : ( ) => {
967
+ this . emit ( 'skip-break' ) ;
923
968
}
924
969
} ,
925
970
{
@@ -930,13 +975,56 @@ class PomodoroShortBreakFinishedDialog extends ModalDialog.ModalDialog {
930
975
}
931
976
] ) ;
932
977
933
- this . setDefaultLabels ( ) ;
978
+ this . _subjectLabel . set_text ( _ ( "Pomodoro finished, take a short break?" ) + "\n" ) ;
979
+ this . _timeLabel . text = '' ;
934
980
}
935
981
936
- setDefaultLabels ( ) {
982
+ finished ( ) {
983
+ this . setButtons ( [
984
+ {
985
+ label : _ ( "Start Next Pomodoro" ) ,
986
+ action : ( ) => {
987
+ this . emit ( 'start-next-pomodoro' ) ;
988
+ }
989
+ } ,
990
+ {
991
+ label : _ ( "Pause Pomodoro" ) ,
992
+ action : ( ) => {
993
+ this . emit ( 'pause-pomodoro' ) ;
994
+ }
995
+ }
996
+ ] ) ;
997
+
937
998
this . _subjectLabel . set_text ( _ ( "Short break finished, ready to continue?" ) + "\n" ) ;
938
999
this . _timeLabel . text = '' ;
939
1000
}
1001
+
1002
+ setTimeRemaining ( timer ) {
1003
+ let tickCount = timer . getTicksRemaining ( ) ;
1004
+
1005
+ if ( tickCount === 0 ) {
1006
+ this . finished ( ) ;
1007
+ return ;
1008
+ }
1009
+
1010
+ // Update the time label text based on the time remaining
1011
+ this . _setTimeLabelText ( _ ( "A new pomodoro begins in %s." ) . format ( this . _getTimeString ( tickCount ) ) ) ;
1012
+ }
1013
+
1014
+ _setTimeLabelText ( label ) {
1015
+ this . _timeLabel . set_text ( label + "\n" ) ;
1016
+ }
1017
+
1018
+ _getTimeString ( totalSeconds ) {
1019
+ // Convert total seconds to minutes and seconds
1020
+ let minutes = parseInt ( totalSeconds / 60 ) ;
1021
+ let seconds = parseInt ( totalSeconds % 60 ) ;
1022
+
1023
+ let min = Gettext . dngettext ( UUID , "%d minute" , "%d minutes" , minutes ) . format ( minutes ) ;
1024
+ let sec = Gettext . dngettext ( UUID , "%d second" , "%d seconds" , seconds ) . format ( seconds ) ;
1025
+
1026
+ return _ ( "%s and %s" ) . format ( min , sec ) ;
1027
+ }
940
1028
}
941
1029
942
1030
class PomodoroFinishedDialog extends ModalDialog . ModalDialog {
0 commit comments