diff --git a/scripts/tkremind b/scripts/tkremind index ecd3e857..9c95b587 100755 --- a/scripts/tkremind +++ b/scripts/tkremind @@ -2110,12 +2110,14 @@ proc IssueBackgroundReminder { file time now tag } { label $w.l -text "Reminder for $time issued at $now" message $w.msg -width 6i -text $msg frame $w.b - button $w.ok -text "OK" -command "destroy $w" + + # Automatically shut down window after a minute if option says so + set after_token [after 60000 [list ClosePopup $w "" $Option(MailAddr) $Option(AutoClose) "" $tag $msg $time]] + + button $w.ok -text "OK" -command [list ClosePopup $w $after_token "" 1 "" $tag $msg $time] if {$tag != "*"} { - button $w.nomore -text "Don't remind me again today" -command \ - "destroy $w; set Ignore($tag) 1" - button $w.kill -text "Delete this reminder completely" -command \ - "destroy $w; InteractiveDeleteReminder $tag" + button $w.nomore -text "Don't remind me again today" -command [list ClosePopup $w $after_token "" 1 "ignore" $tag $msg $time] + button $w.kill -text "Delete this reminder completely" -command [list ClosePopup $w $after_token "" 1 "kill" $tag $msg $time] } pack $w.l -side top pack $w.msg -side top -expand 1 -fill both @@ -2127,11 +2129,6 @@ proc IssueBackgroundReminder { file time now tag } { CenterWindow $w - # Automatically shut down window after a minute if option says so - if {$Option(AutoClose)} { - after 60000 "catch { destroy $w }" - } - update if {$Option(RingBell)} { bell @@ -2750,7 +2747,7 @@ proc InteractiveDeleteReminder { tag } { } } -proc SendMail { sender recipient subject body } { +proc SendMail { recipient subject body } { global Option if {"$Option(MailAddr)" == ""} { @@ -2765,4 +2762,27 @@ proc SendMail { sender recipient subject body } { } } +proc ClosePopup { w after_token mail_addr close_win ignore_or_kill tag reminder rem_time } { + global Ignore + if {"$after_token" != ""} { + catch { after cancel $after_token } + } + + if {$close_win} { + catch { destroy $w } + } + + if {$mail_addr} { + catch { + SendMail $mail_addr "Reminder for $rem_time" $reminder + } + } + if {"$ignore_or_kill" == "ignore"} { + set Ignore($tag) 1 + } + if {"$ignore_or_kill" == "kill"} { + InteractiveDeleteReminder $tag + } +} + main