@@ -375,14 +375,21 @@ class PomodoroApplet extends Applet.TextIconApplet {
375375 this . _pomodoroFinishedDialog . open ( ) ;
376376 }
377377 }
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+ }
386393 }
387394 }
388395 } ) ;
@@ -415,14 +422,19 @@ class PomodoroApplet extends Applet.TextIconApplet {
415422 // connect the short break timer signals
416423
417424 shortBreakTimer . connect ( 'timer-tick' , this . _timerTickUpdate . bind ( this ) ) ;
418-
425+ shortBreakTimer . connect ( 'timer-tick' , this . _shortBreakdialog . setTimeRemaining . bind ( this . _shortBreakdialog ) ) ;
426+
419427 shortBreakTimer . connect ( 'timer-started' , ( ) => {
420428 this . _setCurrentState ( 'short-break' ) ;
421429 this . _playBreakSound ( ) ;
430+ if ( this . _opt_showDialogMessages ) {
431+ this . _shortBreakdialog . open ( ) ;
432+ } else {
433+ Main . notify ( _ ( "Take a short break" ) ) ;
434+ }
422435 this . _numPomodoriFinished ++ ;
423436 this . _appletMenu . updateCounts ( this . _numPomodoroSetFinished , this . _numPomodoriFinished ) ;
424437 this . _appletMenu . showPomodoroInProgress ( this . _opt_pomodoriNumber ) ;
425- Main . notify ( _ ( "Take a short break" ) ) ;
426438 if ( this . _opt_enableScripts && this . _opt_customShortBreakScript ) {
427439 this . _checkAndExecuteCustomScript ( this . _opt_customShortBreakScript ) ;
428440 }
@@ -645,14 +657,32 @@ class PomodoroApplet extends Applet.TextIconApplet {
645657
646658 _createShortBreakDialog ( ) {
647659 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 ( ) ;
650667 this . _shortBreakdialog . close ( ) ;
651668 this . _timerQueue . preventStart ( false ) ;
652669 this . _appletMenu . toggleTimerState ( true ) ;
653670 this . _timerQueue . start ( ) ;
654671 } ) ;
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+
656686 this . _shortBreakdialog . connect ( 'pause-pomodoro' , ( ) => {
657687 this . _timerQueue . stop ( ) ;
658688 this . _appletMenu . toggleTimerState ( false ) ;
@@ -915,11 +945,26 @@ class PomodoroShortBreakFinishedDialog extends ModalDialog.ModalDialog {
915945 this . _timeLabel = new St . Label ( ) ;
916946 this . contentLayout . add ( this . _timeLabel ) ;
917947
948+ this . reset ( ) ;
949+ }
950+
951+ close ( ) {
952+ super . close ( ) ;
953+ this . reset ( ) ;
954+ }
955+
956+ reset ( ) {
918957 this . setButtons ( [
919958 {
920- label : _ ( "Continue Current Pomodoro " ) ,
959+ label : _ ( "Take Break " ) ,
921960 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' ) ;
923968 }
924969 } ,
925970 {
@@ -930,13 +975,56 @@ class PomodoroShortBreakFinishedDialog extends ModalDialog.ModalDialog {
930975 }
931976 ] ) ;
932977
933- this . setDefaultLabels ( ) ;
978+ this . _subjectLabel . set_text ( _ ( "Pomodoro finished, take a short break?" ) + "\n" ) ;
979+ this . _timeLabel . text = '' ;
934980 }
935981
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+
937998 this . _subjectLabel . set_text ( _ ( "Short break finished, ready to continue?" ) + "\n" ) ;
938999 this . _timeLabel . text = '' ;
9391000 }
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+ }
9401028}
9411029
9421030class PomodoroFinishedDialog extends ModalDialog . ModalDialog {
0 commit comments