From 4d3a121e6eef0164f32a4042afca35caccef4c3b Mon Sep 17 00:00:00 2001 From: nagai Date: Sun, 7 Sep 2003 07:10:44 +0000 Subject: * tcltklib.c (lib_mainloop_core): fixed signal-trap bug * multi-tk.rb, tk.rb, tkafter.rb, tkcanvas.rb, tkfont.rb, tktext.rb, tkvirtevent.rb : Ruby/Tk works at $SAFE == 4 git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@4527 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ext/tk/sample/resource.en | 5 ++-- ext/tk/sample/resource.ja | 7 +++--- ext/tk/sample/safe-tk.rb | 7 ++++++ ext/tk/sample/tkhello.rb | 2 +- ext/tk/sample/tkmenubutton.rb | 1 - ext/tk/sample/tkoptdb-safeTk.rb | 21 ++++++++++++++-- ext/tk/sample/tkoptdb.rb | 55 ++++++++++++++++++++++++++++------------- 7 files changed, 72 insertions(+), 26 deletions(-) (limited to 'ext/tk/sample') diff --git a/ext/tk/sample/resource.en b/ext/tk/sample/resource.en index bfdc80927..39b401397 100644 --- a/ext/tk/sample/resource.en +++ b/ext/tk/sample/resource.en @@ -8,5 +8,6 @@ *hello.text: HELLO *quit.text: QUIT *BTN_CMD.show_msg: {|arg| print "($SAFE=#{$SAFE}) ";\ - print "Hello!! This is a sample of #{arg}.\n"} -*BTN_CMD.bye_msg: {print "($SAFE=#{$SAFE}) Good-bye.\n"} + print "Hello!! This is a sample of #{arg}.";\ + print "(<<< $SAFE=#{$SAFE})\n"} +*BTN_CMD.bye_msg: {print "($SAFE=#{$SAFE} >>>) Good-bye.(<<< $SAFE=#{$SAFE})\n"} diff --git a/ext/tk/sample/resource.ja b/ext/tk/sample/resource.ja index 8b715f36b..a61390f95 100644 --- a/ext/tk/sample/resource.ja +++ b/ext/tk/sample/resource.ja @@ -7,6 +7,7 @@ *BtnFrame.Button.foreground: red *hello.text: こんにちは *quit.text: 終了 -*BTN_CMD.show_msg: {|arg| print "($SAFE=#{$SAFE}) ";\ - print "こんにちは!! #{arg} のサンプルです.\n"} -*BTN_CMD.bye_msg: {print "($SAFE=#{$SAFE}) さようなら.\n"} +*BTN_CMD.show_msg: {|arg| print "($SAFE=#{$SAFE} >>>) ";\ + print "こんにちは!! #{arg} のサンプルです.";\ + print "(<<< $SAFE=#{$SAFE})\n"} +*BTN_CMD.bye_msg: {print "($SAFE=#{$SAFE} >>>) さようなら.(<<< $SAFE=#{$SAFE})\n"} diff --git a/ext/tk/sample/safe-tk.rb b/ext/tk/sample/safe-tk.rb index 8be13a32d..0a25c804f 100644 --- a/ext/tk/sample/safe-tk.rb +++ b/ext/tk/sample/safe-tk.rb @@ -86,6 +86,13 @@ TkTimer.new(2000, -1, proc{p ['safe1', safe_slave1.deleted?]}).start TkTimer.new(2000, -1, proc{p ['safe2', safe_slave2.deleted?]}).start TkTimer.new(2000, -1, proc{p ['trusted', trusted_slave.deleted?]}).start +TkTimer.new(7000, 1, + proc{ + safe_slave1.eval_proc{Tk.root.destroy} + safe_slave1.delete + print "*** The safe_slave1 is deleted by the timer.\n" + }).start + TkTimer.new(10000, 1, proc{ trusted_slave.eval_proc{Tk.root.destroy} diff --git a/ext/tk/sample/tkhello.rb b/ext/tk/sample/tkhello.rb index 5188fe1c8..ab236963e 100644 --- a/ext/tk/sample/tkhello.rb +++ b/ext/tk/sample/tkhello.rb @@ -5,6 +5,6 @@ TkButton.new(nil, 'command' => proc{print "hello\n"}).pack('fill'=>'x') TkButton.new(nil, 'text' => 'quit', - 'command' => 'exit').pack('fill'=>'x') + 'command' => proc{exit}).pack('fill'=>'x') Tk.mainloop diff --git a/ext/tk/sample/tkmenubutton.rb b/ext/tk/sample/tkmenubutton.rb index 02a903ebb..1c7f51000 100644 --- a/ext/tk/sample/tkmenubutton.rb +++ b/ext/tk/sample/tkmenubutton.rb @@ -113,7 +113,6 @@ TkFrame.new{|f| } } - ############################ TkFrame.new(:borderwidth=>2, :relief=>:sunken, :height=>5).pack(:side=>:top, :fill=>:x, :padx=>20) diff --git a/ext/tk/sample/tkoptdb-safeTk.rb b/ext/tk/sample/tkoptdb-safeTk.rb index 169cd3c17..a5e394b23 100644 --- a/ext/tk/sample/tkoptdb-safeTk.rb +++ b/ext/tk/sample/tkoptdb-safeTk.rb @@ -5,6 +5,9 @@ require 'multi-tk' TkMessage.new(:text => <>>) check!! str.tainted?::#{str.tainted?}" str.untaint - print "==>#{str.tainted?} : " + print "==>#{str.tainted?} (<<< $SAFE=#{$SAFE}): " str end end @@ -38,12 +41,18 @@ TkFrame.new(:class=>'BtnFrame'){|f| pack(:padx=>5, :pady=>5) TkButton.new(:parent=>f, :widgetname=>'hello'){ command proc{ - print "($SAFE=#{$SAFE}) : " + print "($SAFE=#{$SAFE} >>>) : " cmd.show_msg(TkOptionDB.inspect) + print "(<<< $SAFE=#{$SAFE})" } pack(:fill=>:x, :padx=>10, :pady=>10) } - TkButton.new(:command=>proc{print "($SAFE=#{$SAFE}) : "; cmd.bye_msg; exit}, + TkButton.new(:command=>proc{ + print "($SAFE=#{$SAFE} >>>) : " + cmd.bye_msg + print "(<<< $SAFE=#{$SAFE} ) : " + exit + }, :parent=>f, :widgetname=>'quit'){ pack(:fill=>:x, :padx=>10, :pady=>10) } @@ -54,12 +63,18 @@ BtnFrame.new{|f| pack(:padx=>5, :pady=>5) TkButton.new(:parent=>f, :widgetname=>'hello'){ command proc{ - print "($SAFE=#{$SAFE}) : " + print "($SAFE=#{$SAFE} >>>) : " cmd.show_msg(TkOptionDB.inspect) + print "(<<< $SAFE=#{$SAFE})" } pack(:fill=>:x, :padx=>10, :pady=>10) } - TkButton.new(:command=>proc{print "($SAFE=#{$SAFE}) : "; cmd.bye_msg; exit}, + TkButton.new(:command=>proc{ + print "($SAFE=#{$SAFE} >>>) : " + cmd.bye_msg + print "(<<< $SAFE=#{$SAFE})" + exit + }, :parent=>f, :widgetname=>'quit'){ pack(:fill=>:x, :padx=>10, :pady=>10) } @@ -70,12 +85,18 @@ TkFrame.new(:class=>'BtnFrame2'){|f| pack(:padx=>5, :pady=>5) TkButton.new(:parent=>f, :widgetname=>'hello'){ command proc{ - print "($SAFE=#{$SAFE}) : " + print "($SAFE=#{$SAFE} >>>) : " cmd.show_msg(TkOptionDB.inspect) + print "(<<< $SAFE=#{$SAFE})" } pack(:fill=>:x, :padx=>10, :pady=>10) } - TkButton.new(:command=>proc{print "($SAFE=#{$SAFE}) : "; cmd.bye_msg; exit}, + TkButton.new(:command=>proc{ + print "($SAFE=#{$SAFE} >>>) : " + cmd.bye_msg + print "(<<< $SAFE=#{$SAFE})" + exit + }, :parent=>f, :widgetname=>'quit'){ pack(:fill=>:x, :padx=>10, :pady=>10) } -- cgit