diff options
author | yugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-08-25 15:13:14 +0000 |
---|---|---|
committer | yugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-08-25 15:13:14 +0000 |
commit | d0233291bc8a5068e52c69c210e5979e5324b5bc (patch) | |
tree | 7d9459449c33792c63eeb7baa071e76352e0baab /trunk/ext/tk/sample/tkoptdb.rb | |
parent | 0dc342de848a642ecce8db697b8fecd83a63e117 (diff) | |
parent | 72eaacaa15256ab95c3b52ea386f88586fb9da40 (diff) |
re-adding tag v1_9_0_4 as an alias of trunk@18848v1_9_0_4
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/tags/v1_9_0_4@18849 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'trunk/ext/tk/sample/tkoptdb.rb')
-rw-r--r-- | trunk/ext/tk/sample/tkoptdb.rb | 106 |
1 files changed, 0 insertions, 106 deletions
diff --git a/trunk/ext/tk/sample/tkoptdb.rb b/trunk/ext/tk/sample/tkoptdb.rb deleted file mode 100644 index 47784ea238..0000000000 --- a/trunk/ext/tk/sample/tkoptdb.rb +++ /dev/null @@ -1,106 +0,0 @@ -#!/usr/bin/env ruby -# -# sample script of TkOptionDB -# -# If 'LANG' environment variable's value is started by 'ja', -# then read Japanese resource data and display Japanese button text. -# In other case, read English resource data and display English text. -# -require "tk" - -if __FILE__ == $0 || !TkCore::INTERP.safe? - if ENV['LANG'] =~ /^ja/ - # read Japanese resource - TkOptionDB.read_with_encoding(File.expand_path('resource.ja', - File.dirname(__FILE__)), - 'euc-jp') - else - # read English resource - TkOptionDB.readfile(File.expand_path('resource.en', - File.dirname(__FILE__))) - end -end - -# 'show_msg' and 'bye_msg' procedures can be defined on BTN_CMD resource. -# Those procedures are called under $SAFE==2 -cmd = TkOptionDB.new_proc_class(:BTN_CMD, [:show_msg, :bye_msg], 3) { - # If you want to check resource string (str), - # please define __check_proc_string__(str) like this. - class << self - def __check_proc_string__(str) - print "($SAFE=#{$SAFE} >>>) check!! str.tainted?::#{str.tainted?}" - str.untaint - print "==>#{str.tainted?} (<<< $SAFE=#{$SAFE}): " - str - end - private :__check_proc_string__ - end -} - -# following two frame widgets use same database entry -TkFrame.new(:class=>'BtnFrame'){|f| - pack(:padx=>5, :pady=>5) - TkButton.new(:parent=>f, :widgetname=>'hello'){ - command proc{ - 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 - print "(<<< $SAFE=#{$SAFE} ) : " - exit - }, - :parent=>f, :widgetname=>'quit'){ - pack(:fill=>:x, :padx=>10, :pady=>10) - } -} - -class BtnFrame < TkFrame; end -BtnFrame.new{|f| - pack(:padx=>5, :pady=>5) - TkButton.new(:parent=>f, :widgetname=>'hello'){ - command proc{ - 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 - print "(<<< $SAFE=#{$SAFE})" - exit - }, - :parent=>f, :widgetname=>'quit'){ - pack(:fill=>:x, :padx=>10, :pady=>10) - } -} - -# if unknown class, use default option values -TkFrame.new(:class=>'BtnFrame2'){|f| - pack(:padx=>5, :pady=>5) - TkButton.new(:parent=>f, :widgetname=>'hello'){ - command proc{ - 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 - print "(<<< $SAFE=#{$SAFE})" - exit - }, - :parent=>f, :widgetname=>'quit'){ - pack(:fill=>:x, :padx=>10, :pady=>10) - } -} - -Tk.mainloop |