summaryrefslogtreecommitdiff
path: root/ext/tk/sample
diff options
context:
space:
mode:
Diffstat (limited to 'ext/tk/sample')
-rw-r--r--ext/tk/sample/tkbiff.rb12
-rw-r--r--ext/tk/sample/tkdialog.rb1
-rw-r--r--ext/tk/sample/tkfrom.rb8
3 files changed, 13 insertions, 8 deletions
diff --git a/ext/tk/sample/tkbiff.rb b/ext/tk/sample/tkbiff.rb
index ac27184437..5fe367fd97 100644
--- a/ext/tk/sample/tkbiff.rb
+++ b/ext/tk/sample/tkbiff.rb
@@ -12,7 +12,7 @@ if ARGV.length == 0
if ENV['MAIL']
$spool = ENV['MAIL']
else
- $spool = '/usr/spool/mail/' + ENV['USER']
+ $spool = '/var/spool/mail/' + ENV['USER']
end
else
$spool = ARGV[0]
@@ -70,7 +70,13 @@ end
require "tkscrollbox"
+my_appname = Tk.appname('tkbiff')
$top = TkRoot.new
+if ((TkWinfo.interps($top) - [my_appname]).find{|ip| ip =~ /^tkbiff/})
+ STDERR.print("Probably other 'tkbiff's are running. Bye.\n")
+ exit
+end
+
$top.withdraw
$list = TkScrollbox.new($top) {
relief 'raised'
@@ -136,12 +142,12 @@ def pop_up
$list.see 'end'
end
$top.deiconify
- Tk.after 2000, proc{$top.withdraw}
+ Tk.after 2000, proc{$top.iconify}
end
$list.insert 'end', "You have no mail."
check
-Tk.after 2000, proc{$top.withdraw}
+Tk.after 2000, proc{$top.iconify}
begin
Tk.mainloop
rescue
diff --git a/ext/tk/sample/tkdialog.rb b/ext/tk/sample/tkdialog.rb
index e83e16d0a8..73708945fb 100644
--- a/ext/tk/sample/tkdialog.rb
+++ b/ext/tk/sample/tkdialog.rb
@@ -54,7 +54,6 @@ bot.pack
root.pack('side'=>'top', 'fill'=>'both', 'expand'=>'yes')
def quit(button)
- print "aaa\n"
print "You pressed the \"#{button}\" button; bye-bye!\n"
exit
end
diff --git a/ext/tk/sample/tkfrom.rb b/ext/tk/sample/tkfrom.rb
index 8c3efb8137..e0e7f4810f 100644
--- a/ext/tk/sample/tkfrom.rb
+++ b/ext/tk/sample/tkfrom.rb
@@ -54,9 +54,9 @@ if ARGV.length == 0
if ENV['MAIL']
ARGV[0] = ENV['MAIL']
elsif ENV['USER']
- ARGV[0] = '/usr/spool/mail/' + ENV['USER']
+ ARGV[0] = '/var/spool/mail/' + ENV['USER']
elsif ENV['LOGNAME']
- ARGV[0] = '/usr/spool/mail/' + ENV['LOGNAME']
+ ARGV[0] = '/var/spool/mail/' + ENV['LOGNAME']
end
end
@@ -64,7 +64,7 @@ require "tk"
list = scroll = nil
TkFrame.new{|f|
list = TkListbox.new(f) {
- yscroll proc{|idx|
+ yscroll proc{|*idx|
scroll.set *idx
}
relief 'raised'
@@ -94,7 +94,7 @@ root.bind "space", proc{exit}
$outcount = 0;
for file in ARGV
- next if File.exist?(file)
+ next unless File.exist?(file)
atime = File.atime(file)
mtime = File.mtime(file)
f = open(file, "r")