[Tkabber-dev] r265 - in trunk/plugins/reminder: . sounds

tkabber-svn at jabber.ru tkabber-svn at jabber.ru
Sun Jan 3 01:35:41 MSK 2010


Author: bigote
Date: 2010-01-03 01:35:40 +0300 (Sun, 03 Jan 2010)
New Revision: 265

Added:
   trunk/plugins/reminder/sounds/
   trunk/plugins/reminder/sounds/reminder.wav
Modified:
   trunk/plugins/reminder/reminder.tcl
Log:
Added sound support. Default behaviour is to play sound when a reminder pops up.


Modified: trunk/plugins/reminder/reminder.tcl
===================================================================
--- trunk/plugins/reminder/reminder.tcl	2010-01-02 10:17:46 UTC (rev 264)
+++ trunk/plugins/reminder/reminder.tcl	2010-01-02 22:35:40 UTC (rev 265)
@@ -1,4 +1,4 @@
-# "Reminder" plugin for Tkabber. 2010-01-02 v. 0.8.1
+# "Reminder" plugin for Tkabber. 2010-01-02 v. 0.9
 # Written by Serge Yudin xmpp:bigote at jabber.ru
 # Its purpose is to remind about your contact birthdays automatically
 # and about some tasks that you assign by means of "/remind" command.
@@ -8,7 +8,6 @@
 # either take a look at reminder::help procedure here.
 #####################################
 #
-# TODO: Add some sound reminder notification.
 # TODO: Birthday reminding isn't ready yet, at all.
 #
 
@@ -36,12 +35,25 @@
         you would like to be reminded."] \
         -type string -group Reminder
 
+    custom::defvar options(play_sound) 1 \
+        [::msgcat::mc "Play sound when a remind pops up."] \
+        -type boolean -group Reminder
+
     custom::defvar stored_rem_list {} \
         "List of reminders to store" \
         -type string -group Hidden
 
 }
 
+namespace eval ::sound {
+# Taken from Alarm plugin.
+    custom::defvar options(plugin_reminder_sound) \
+        [file join [file dirname [info script]] sounds reminder.wav] \
+        [::msgcat::mc "Play this sound file"] \
+        -command [list [namespace current]::load_sound_file plugin_reminder] \
+        -type file -group Reminder
+}
+
 proc reminder::load {} {
     variable rem_list
     variable rem_list2save
@@ -54,16 +66,22 @@
     [namespace current]::reminder_compls
     hook::add chat_send_message_hook \
     [namespace current]::handle_commands 18
+    hook::add finload_hook \
+    [list ::sound::load_sound_file plugin_reminder] 100
 }
 
 proc reminder::unload {} {
     variable rem_list
     variable rem_list2save
     variable winid
+    hook::remove finload_hook \
+    [namespace current]::restore_reminders 71
     hook::remove generate_completions_hook \
     [namespace current]::reminder_compls
     hook::remove chat_send_message_hook \
     [namespace current]::handle_commands 18
+    hook::remove finload_hook \
+    [list ::sound::load_sound_file plugin_reminder] 100
     catch {unset winid}
     catch {unset rem_list}
     catch {unset rem_list2save}
@@ -159,12 +177,16 @@
 
 proc reminder::show_reminder {msg} {
     variable winid
+    variable options
     set w .reminder$winid
     incr winid
     if {[winfo exists $w]} {
         destroy $w
     }
-    set msg "Now: [clock format [clock seconds]]\n$msg"
+    if {$options(play_sound)} {
+        ::sound::play $::sound::options(plugin_reminder_sound)
+    }
+    set msg "Now is: [clock format [clock seconds]]\n$msg"
     Dialog $w -title [::msgcat::mc "Reminder"] \
         -modal none -separator 1 -anchor e -default 0 -parent .
         set f [$w getframe]

Added: trunk/plugins/reminder/sounds/reminder.wav
===================================================================
(Binary files differ)


Property changes on: trunk/plugins/reminder/sounds/reminder.wav
___________________________________________________________________
Added: svn:mime-type
   + application/octet-stream



More information about the Tkabber-dev mailing list