chiark / gitweb /
ypp-chatlog-alerter: initial UI
authorIan Jackson <ian@liberator.relativity.greenend.org.uk>
Thu, 30 Sep 2010 19:49:56 +0000 (20:49 +0100)
committerIan Jackson <ian@liberator.relativity.greenend.org.uk>
Thu, 30 Sep 2010 19:49:56 +0000 (20:49 +0100)
ypp-chatlog-alerter [new file with mode: 0755]

diff --git a/ypp-chatlog-alerter b/ypp-chatlog-alerter
new file mode 100755 (executable)
index 0000000..71a05bb
--- /dev/null
@@ -0,0 +1,58 @@
+#!/usr/bin/wish
+
+set progname ypp-chatlog-alerter
+
+menu .mbar -tearoff 0
+foreach w {file edit} l {File Edit} {
+    menu .mbar.$w -tearoff 0
+    .mbar add cascade -menu .mbar.$w -label $l
+}
+proc menuent {w l a x} {
+    set c [list .mbar.$w add command -label $l -command $x]
+    if {[string length $a]} { lappend c -accel Command-$a }
+    eval $c
+}
+foreach l {Open Quit} a {O Q} x {newfile exit} {
+    menuent file $l $a $x
+}
+foreach l {Cut Copy Paste Clear} a {X C V {}} {
+    menuent edit $l $a [list event generate {[focus]} <<$l>>]]
+}
+. configure -menu .mbar
+
+switch -exact [tk windowingsystem] {
+    aqua {
+       set defaultfile ~/Library/Preferences/$progname.prefs
+    }
+    x11 {
+       set defaultfile ~/.$progname.rc
+    }
+    default {
+       error ?
+    }
+}
+
+proc newfile {} {
+    global currentfile defaultfile
+    
+    set newfile [tk_getOpenFile -multiple 0 -title "Select YPP log to track"]
+    if {![string length $newfile]} return
+
+    set currentfile $newfile
+    set newdefaults [open $defaultfile.new w]
+    puts $newdefaults "[list set currentfile $currentfile]"
+    close $newdefaults
+    file rename -force $defaultfile.new $defaultfile
+    refresh
+}
+
+set currentfile {}
+
+proc refresh {} {
+}
+
+if {[file exists $defaultfile]} {
+    source $defaultfile
+}
+
+listbox .l