----Next_Part(Wed_Jun_25_01:59:03_2003_920)--
Content-Type: Text/Plain; charset=iso-2022-jp
Content-Transfer-Encoding: 7bit

永井@知九工大です.

長らく中途半端な状態となっていた Ruby/Tk の
resource database (option databese) サポートですが,
ようやく少しは使えな程度になりました.
先ほど commit しましたので,もし良かったら 
CVS から入手して試してみてください.

入手前に雰囲気がつかめるように,ext/tk/samples に追加した
サンプルスクリプトを添えておきます.
-- 
                                         永井  (九工大 知報)
                                             nagai / ai.kyutech.ac.jp

----Next_Part(Wed_Jun_25_01:59:03_2003_920)--
Content-Type: Text/Plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Content-Disposition: inline; filename="tkoptdb.rb"

#!/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 ENV['LANG'] /^ja/
  # read Japanese resource
  TkOptionDB.readfile(File.expand_path('resource.ja', File.dirname(__FILE__)))
else
  # read English resource
  TkOptionDB.readfile(File.expand_path('resource.en', File.dirname(__FILE__)))
end

# 'show_msg' and 'bye_msg' procedures can be defined on BTN_CMD resource.
# Those procedures are called under $SAFE
cmd  kOptionDB.new_proc_class(:BTN_CMD, [:show_msg, :bye_msg], 2) {
  # 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?} : "
      str
    end
  end
}

TkFrame.new(:classBtnFrame'){|f|
  pack(:padx, :pady)
  TkButton.new(:parent, :widgetnamehello'){ 
    command proc{
      print "($SAFE$SAFE}) : "
      cmd.show_msg(TkOptionDB.inspect)
    } 
    pack(:fillx, :padx0, :pady0)
  }
  TkButton.new(:commandroc{print "($SAFE$SAFE}) : "; cmd.bye_msg; exit}, 
	       :parent, :widgetnamequit'){
    pack(:fillx, :padx0, :pady0)
  }
}

Tk.mainloop

----Next_Part(Wed_Jun_25_01:59:03_2003_920)--
Content-Type: Text/Plain; charset=iso-2022-jp
Content-Transfer-Encoding: 7bit
Content-Disposition: inline; filename="resource.ja"

#
#  see Tcl/Tk's "options" manual for "Database Name" and "Database Class"
#
*BtnFrame.borderWidth: 5
*BtnFrame.relief: ridge
*BtnFrame.Button.background: wheat
*BtnFrame.Button.foreground: red
*hello.text: こんにちは
*quit.text: 
待累値町鼈阯熏鼇 癇苜 頏蜴※び粗び粗統∋                          頏蜴ぢこんにちは!! #{arg} のサンプルです.\n"}
*BTN_CMD.bye_msg:  {print "($SAFE$SAFE}) さようなら.\n"}

----Next_Part(Wed_Jun_25_01:59:03_2003_920)--
Content-Type: Text/Plain; charset=iso-2022-jp
Content-Transfer-Encoding: 7bit
Content-Disposition: inline; filename="resource.en"

#
#  see Tcl/Tk's "options" manual for "Database Name" and "Database Class"
#
*BtnFrame.borderWidth: 5
*BtnFrame.relief: ridge
*BtnFrame.Button.background: wheat
*BtnFrame.Button.foreground: red
*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"}

----Next_Part(Wed_Jun_25_01:59:03_2003_920)----