tk 0.2.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (93) hide show
  1. checksums.yaml +5 -5
  2. data/.gitignore +2 -0
  3. data/MANUAL_tcltklib.eng +0 -2
  4. data/MANUAL_tcltklib.ja +0 -2
  5. data/README.ActiveTcl +1 -1
  6. data/README.md +43 -0
  7. data/ext/tk/extconf.rb +4 -2
  8. data/ext/tk/old-extconf.rb +0 -1
  9. data/ext/tk/tcltklib.c +46 -148
  10. data/ext/tk/tkutil/extconf.rb +0 -2
  11. data/ext/tk/tkutil/tkutil.c +6 -9
  12. data/lib/multi-tk.rb +95 -315
  13. data/lib/remote-tk.rb +6 -23
  14. data/lib/tk.rb +41 -122
  15. data/lib/tk/bgerror.rb +2 -2
  16. data/lib/tk/bindtag.rb +1 -1
  17. data/lib/tk/canvas.rb +6 -14
  18. data/lib/tk/canvastag.rb +8 -16
  19. data/lib/tk/font.rb +1 -1
  20. data/lib/tk/fontchooser.rb +1 -1
  21. data/lib/tk/image.rb +1 -1
  22. data/lib/tk/menu.rb +4 -4
  23. data/lib/tk/msgcat.rb +5 -5
  24. data/lib/tk/namespace.rb +12 -32
  25. data/lib/tk/optiondb.rb +3 -73
  26. data/lib/tk/scale.rb +2 -2
  27. data/lib/tk/scrollable.rb +4 -2
  28. data/lib/tk/selection.rb +5 -4
  29. data/lib/tk/text.rb +8 -16
  30. data/lib/tk/textmark.rb +1 -1
  31. data/lib/tk/texttag.rb +7 -15
  32. data/lib/tk/timer.rb +2 -2
  33. data/lib/tk/tk_mac.rb +18 -18
  34. data/lib/tk/validation.rb +4 -35
  35. data/lib/tk/variable.rb +7 -5
  36. data/lib/tk/virtevent.rb +1 -1
  37. data/lib/tkextlib/blt/barchart.rb +0 -17
  38. data/lib/tkextlib/blt/bitmap.rb +1 -1
  39. data/lib/tkextlib/blt/component.rb +34 -34
  40. data/lib/tkextlib/blt/dragdrop.rb +6 -6
  41. data/lib/tkextlib/blt/graph.rb +0 -17
  42. data/lib/tkextlib/blt/stripchart.rb +0 -17
  43. data/lib/tkextlib/blt/tabset.rb +16 -31
  44. data/lib/tkextlib/blt/tree.rb +5 -5
  45. data/lib/tkextlib/blt/treeview.rb +14 -14
  46. data/lib/tkextlib/blt/watch.rb +1 -1
  47. data/lib/tkextlib/bwidget/labelentry.rb +6 -14
  48. data/lib/tkextlib/bwidget/listbox.rb +13 -29
  49. data/lib/tkextlib/bwidget/notebook.rb +6 -14
  50. data/lib/tkextlib/bwidget/spinbox.rb +6 -14
  51. data/lib/tkextlib/bwidget/tree.rb +19 -35
  52. data/lib/tkextlib/itcl/incr_tcl.rb +2 -2
  53. data/lib/tkextlib/itk/incr_tk.rb +7 -29
  54. data/lib/tkextlib/iwidgets/calendar.rb +0 -15
  55. data/lib/tkextlib/iwidgets/entryfield.rb +0 -21
  56. data/lib/tkextlib/iwidgets/notebook.rb +2 -2
  57. data/lib/tkextlib/iwidgets/scrolledcanvas.rb +6 -14
  58. data/lib/tkextlib/iwidgets/tabnotebook.rb +2 -2
  59. data/lib/tkextlib/tcllib/ctext.rb +2 -2
  60. data/lib/tkextlib/tcllib/plotchart.rb +5 -5
  61. data/lib/tkextlib/tcllib/validator.rb +6 -6
  62. data/lib/tkextlib/tile.rb +1 -1
  63. data/lib/tkextlib/tile/style.rb +1 -1
  64. data/lib/tkextlib/tile/treeview.rb +13 -20
  65. data/lib/tkextlib/tkDND/tkdnd.rb +6 -22
  66. data/lib/tkextlib/tkHTML/htmlwidget.rb +1 -1
  67. data/lib/tkextlib/tktable/tktable.rb +1 -1
  68. data/lib/tkextlib/treectrl/tktreectrl.rb +12 -20
  69. data/lib/tkextlib/vu/pie.rb +1 -1
  70. data/sample/binding_sample.rb +2 -2
  71. data/sample/cmd_res_test.rb +1 -1
  72. data/sample/demos-en/widget +21 -21
  73. data/sample/demos-jp/widget +4 -4
  74. data/sample/multi-ip_sample.rb +0 -3
  75. data/sample/multi-ip_sample2.rb +1 -1
  76. data/sample/resource.en +3 -3
  77. data/sample/resource.ja +3 -3
  78. data/sample/tcltklib/sample1.rb +2 -2
  79. data/sample/tkballoonhelp.rb +2 -2
  80. data/sample/tkextlib/tkHTML/ss.rb +0 -6
  81. data/sample/tkmulticolumnlist.rb +2 -2
  82. data/sample/tkmultilistframe.rb +2 -2
  83. data/sample/tkoptdb.rb +14 -16
  84. data/tk.gemspec +4 -4
  85. metadata +6 -13
  86. data/ChangeLog.tkextlib +0 -949
  87. data/old-README.tcltklib.ja +0 -159
  88. data/sample/binstr_usage.rb +0 -46
  89. data/sample/remote-ip_sample2.rb +0 -57
  90. data/sample/safe-tk.rb +0 -132
  91. data/sample/tkoptdb-safeTk.rb +0 -74
  92. data/sample/tktree.rb +0 -104
  93. data/sample/tktree.tcl +0 -305
@@ -13,8 +13,8 @@ class MultiTkIp; end
13
13
  class RemoteTkIp < MultiTkIp; end
14
14
 
15
15
  class MultiTkIp
16
- @@IP_TABLE = TkUtil.untrust({}) unless defined?(@@IP_TABLE)
17
- @@TK_TABLE_LIST = TkUtil.untrust([]) unless defined?(@@TK_TABLE_LIST)
16
+ @@IP_TABLE = {} unless defined?(@@IP_TABLE)
17
+ @@TK_TABLE_LIST = [] unless defined?(@@TK_TABLE_LIST)
18
18
  def self._IP_TABLE; @@IP_TABLE; end
19
19
  def self._TK_TABLE_LIST; @@TK_TABLE_LIST; end
20
20
 
@@ -87,39 +87,25 @@ class RemoteTkIp
87
87
  @slave_ip_tbl = {}
88
88
  @slave_ip_top = {}
89
89
 
90
- @force_default_encoding ||= TkUtil.untrust([false])
91
- @encoding ||= TkUtil.untrust([nil])
90
+ @force_default_encoding ||= [false]
91
+ @encoding ||= [nil]
92
92
  def @encoding.to_s; self.join(nil); end
93
93
 
94
- TkUtil.untrust(@tk_windows) unless @tk_windows.tainted?
95
- TkUtil.untrust(@tk_table_list) unless @tk_table_list.tainted?
96
- TkUtil.untrust(@slave_ip_tbl) unless @slave_ip_tbl.tainted?
97
- TkUtil.untrust(@slave_ip_top) unless @slave_ip_top.tainted?
98
-
99
94
  @system = Object.new
100
95
 
101
96
  @threadgroup = ThreadGroup.new
102
97
 
103
- @safe_level = [$SAFE]
98
+ @safe_level = [0]
104
99
 
105
100
  @wait_on_mainloop = [true, 0]
106
101
 
107
102
  @cmd_queue = Queue.new
108
103
 
109
- =begin
110
- @cmd_receiver, @receiver_watchdog = _create_receiver_and_watchdog()
111
-
112
- @threadgroup.add @cmd_receiver
113
- @threadgroup.add @receiver_watchdog
114
-
115
- @threadgroup.enclose
116
- =end
117
104
  @@DEFAULT_MASTER.assign_receiver_and_watchdog(self)
118
105
 
119
106
  @@IP_TABLE[@threadgroup] = self
120
107
  @@TK_TABLE_LIST.size.times{
121
- (tbl = {}).tainted? || TkUtil.untrust(tbl)
122
- @tk_table_list << tbl
108
+ @tk_table_list << {}
123
109
  }
124
110
 
125
111
  @ret_val = TkVariable.new
@@ -198,9 +184,6 @@ class RemoteTkIp
198
184
  raise SecurityError, "no permission to manipulate" unless self.manipulable?
199
185
 
200
186
  p ['_appsend', [@remote, @displayof], enc_mode, async, cmds] if $DEBUG
201
- if $SAFE >= 1 && cmds.find{|obj| obj.tainted?}
202
- fail SecurityError, "cannot send tainted commands at level #{$SAFE}"
203
- end
204
187
 
205
188
  cmds = @interp._merge_tklist(*TkUtil::_conv_args([], enc_mode, *cmds))
206
189
  if @displayof
data/lib/tk.rb CHANGED
@@ -31,8 +31,8 @@ class TclTkIp
31
31
  def initialize(*args)
32
32
  __initialize__(*args)
33
33
 
34
- @force_default_encoding ||= TkUtil.untrust([false])
35
- @encoding ||= TkUtil.untrust([nil])
34
+ @force_default_encoding ||= [false]
35
+ @encoding ||= [nil]
36
36
  def @encoding.to_s; self.join(nil); end
37
37
  end
38
38
  end
@@ -42,8 +42,8 @@ module TkComm
42
42
  include TkUtil
43
43
  extend TkUtil
44
44
 
45
- WidgetClassNames = TkUtil.untrust({})
46
- TkExtlibAutoloadModule = TkUtil.untrust([])
45
+ WidgetClassNames = {}
46
+ TkExtlibAutoloadModule = []
47
47
 
48
48
  # None = Object.new ### --> definition is moved to TkUtil module
49
49
  # def None.to_s
@@ -54,8 +54,8 @@ module TkComm
54
54
  #Tk_CMDTBL = {}
55
55
  #Tk_WINDOWS = {}
56
56
  Tk_IDs = [
57
- TkUtil.untrust("00000"), # [0]-cmdid
58
- TkUtil.untrust("00000") # [1]-winid
57
+ "00000", # [0]-cmdid
58
+ "00000" # [1]-winid
59
59
  ]
60
60
  Tk_IDs.instance_eval{
61
61
  @mutex = Mutex.new
@@ -76,7 +76,7 @@ module TkComm
76
76
  Tk_WINDOWS.freeze
77
77
 
78
78
  self.instance_eval{
79
- @cmdtbl = TkUtil.untrust([])
79
+ @cmdtbl = []
80
80
  }
81
81
 
82
82
  unless const_defined?(:GET_CONFIGINFO_AS_ARRAY)
@@ -848,7 +848,6 @@ end
848
848
  TkCore::INTERP.tk_cmd_tbl[id] = TkCore::INTERP.get_cb_entry(cmd)
849
849
  end
850
850
  @cmdtbl = [] unless defined? @cmdtbl
851
- TkUtil.untrust(@cmdtbl) unless @cmdtbl.tainted?
852
851
  @cmdtbl.push id
853
852
 
854
853
  if local_cmdtbl && local_cmdtbl.kind_of?(Array)
@@ -1070,31 +1069,23 @@ module TkComm
1070
1069
  :_bind_append_for_event_class, :_bind_remove_for_event_class,
1071
1070
  :_bindinfo_for_event_class
1072
1071
 
1073
- #def bind(tagOrClass, context, cmd=Proc.new, *args)
1074
- # _bind(["bind", tagOrClass], context, cmd, *args)
1075
- # tagOrClass
1076
- #end
1077
- def bind(tagOrClass, context, *args)
1072
+ def bind(tagOrClass, context, *args, &block)
1078
1073
  # if args[0].kind_of?(Proc) || args[0].kind_of?(Method)
1079
- if TkComm._callback_entry?(args[0]) || !block_given?
1074
+ if TkComm._callback_entry?(args[0]) || !block
1080
1075
  cmd = args.shift
1081
1076
  else
1082
- cmd = Proc.new
1077
+ cmd = block
1083
1078
  end
1084
1079
  _bind(["bind", tagOrClass], context, cmd, *args)
1085
1080
  tagOrClass
1086
1081
  end
1087
1082
 
1088
- #def bind_append(tagOrClass, context, cmd=Proc.new, *args)
1089
- # _bind_append(["bind", tagOrClass], context, cmd, *args)
1090
- # tagOrClass
1091
- #end
1092
- def bind_append(tagOrClass, context, *args)
1083
+ def bind_append(tagOrClass, context, *args, &block)
1093
1084
  # if args[0].kind_of?(Proc) || args[0].kind_of?(Method)
1094
- if TkComm._callback_entry?(args[0]) || !block_given?
1085
+ if TkComm._callback_entry?(args[0]) || !block
1095
1086
  cmd = args.shift
1096
1087
  else
1097
- cmd = Proc.new
1088
+ cmd = block
1098
1089
  end
1099
1090
  _bind_append(["bind", tagOrClass], context, cmd, *args)
1100
1091
  tagOrClass
@@ -1109,31 +1100,23 @@ module TkComm
1109
1100
  _bindinfo(['bind', tagOrClass], context)
1110
1101
  end
1111
1102
 
1112
- #def bind_all(context, cmd=Proc.new, *args)
1113
- # _bind(['bind', 'all'], context, cmd, *args)
1114
- # TkBindTag::ALL
1115
- #end
1116
- def bind_all(context, *args)
1103
+ def bind_all(context, *args, &block)
1117
1104
  # if args[0].kind_of?(Proc) || args[0].kind_of?(Method)
1118
- if TkComm._callback_entry?(args[0]) || !block_given?
1105
+ if TkComm._callback_entry?(args[0]) || !block
1119
1106
  cmd = args.shift
1120
1107
  else
1121
- cmd = Proc.new
1108
+ cmd = block
1122
1109
  end
1123
1110
  _bind(['bind', 'all'], context, cmd, *args)
1124
1111
  TkBindTag::ALL
1125
1112
  end
1126
1113
 
1127
- #def bind_append_all(context, cmd=Proc.new, *args)
1128
- # _bind_append(['bind', 'all'], context, cmd, *args)
1129
- # TkBindTag::ALL
1130
- #end
1131
- def bind_append_all(context, *args)
1114
+ def bind_append_all(context, *args, &block)
1132
1115
  # if args[0].kind_of?(Proc) || args[0].kind_of?(Method)
1133
- if TkComm._callback_entry?(args[0]) || !block_given?
1116
+ if TkComm._callback_entry?(args[0]) || !block
1134
1117
  cmd = args.shift
1135
1118
  else
1136
- cmd = Proc.new
1119
+ cmd = block
1137
1120
  end
1138
1121
  _bind_append(['bind', 'all'], context, cmd, *args)
1139
1122
  TkBindTag::ALL
@@ -1363,11 +1346,10 @@ EOS
1363
1346
  end
1364
1347
 
1365
1348
  INTERP.instance_eval{
1366
- # @tk_cmd_tbl = TkUtil.untrust({})
1367
1349
  @tk_cmd_tbl =
1368
- TkUtil.untrust(Hash.new{|hash, key|
1350
+ Hash.new{|hash, key|
1369
1351
  fail IndexError, "unknown command ID '#{key}'"
1370
- })
1352
+ }
1371
1353
  def @tk_cmd_tbl.[]=(idx,val)
1372
1354
  if self.has_key?(idx) && Thread.current.group != ThreadGroup::Default
1373
1355
  fail SecurityError,"cannot change the entried command"
@@ -1375,15 +1357,15 @@ EOS
1375
1357
  super(idx,val)
1376
1358
  end
1377
1359
 
1378
- @tk_windows = TkUtil.untrust({})
1360
+ @tk_windows = {}
1379
1361
 
1380
- @tk_table_list = TkUtil.untrust([])
1362
+ @tk_table_list = []
1381
1363
 
1382
- @init_ip_env = TkUtil.untrust([]) # table of Procs
1383
- @add_tk_procs = TkUtil.untrust([]) # table of [name, args, body]
1364
+ @init_ip_env = [] # table of Procs
1365
+ @add_tk_procs = [] # table of [name, args, body]
1384
1366
 
1385
- @force_default_encoding ||= TkUtil.untrust([false])
1386
- @encoding ||= TkUtil.untrust([nil])
1367
+ @force_default_encoding ||= [false]
1368
+ @encoding ||= [nil]
1387
1369
  def @encoding.to_s; self.join(nil); end
1388
1370
 
1389
1371
  @cb_entry_class = Class.new(TkCallbackEntry){
@@ -1437,15 +1419,7 @@ EOS
1437
1419
  end
1438
1420
  def INTERP.create_table
1439
1421
  id = @tk_table_list.size
1440
- (tbl = {}).tainted? || TkUtil.untrust(tbl)
1441
- @tk_table_list << tbl
1442
- # obj = Object.new
1443
- # obj.instance_eval <<-EOD
1444
- # def self.method_missing(m, *args)
1445
- # TkCore::INTERP.tk_object_table(#{id}).send(m, *args)
1446
- # end
1447
- # EOD
1448
- # return obj
1422
+ @tk_table_list << {}
1449
1423
  Tk_OBJECT_TABLE.new(id)
1450
1424
  end
1451
1425
 
@@ -1456,7 +1430,8 @@ EOS
1456
1430
  TkUtil._get_eval_string(TkUtil.eval_cmd(cmd, *args))
1457
1431
  end
1458
1432
 
1459
- def INTERP.init_ip_env(script = Proc.new)
1433
+ def INTERP.init_ip_env(script = (use_block = true), &block)
1434
+ script = block if use_block
1460
1435
  @init_ip_env << script
1461
1436
  script.call(self)
1462
1437
  end
@@ -1684,57 +1659,21 @@ EOS
1684
1659
  bool(tk_call('auto_load', tk_cmd))
1685
1660
  end
1686
1661
 
1687
- def after(ms, cmd=Proc.new)
1662
+ def after(ms, cmd=nil, &block)
1663
+ cmd ||= block
1688
1664
  cmdid = install_cmd(proc{ret = cmd.call;uninstall_cmd(cmdid); ret})
1689
1665
  after_id = tk_call_without_enc("after",ms,cmdid)
1690
1666
  after_id.instance_variable_set('@cmdid', cmdid)
1691
1667
  after_id
1692
1668
  end
1693
- =begin
1694
- def after(ms, cmd=Proc.new)
1695
- crit_bup = Thread.critical
1696
- Thread.critical = true
1697
-
1698
- myid = _curr_cmd_id
1699
- cmdid = install_cmd(proc{ret = cmd.call;uninstall_cmd(myid); ret})
1700
-
1701
- Thread.critical = crit_bup
1702
-
1703
- tk_call_without_enc("after",ms,cmdid) # return id
1704
- # return
1705
- # if false #defined? Thread
1706
- # Thread.start do
1707
- # ms = Float(ms)/1000
1708
- # ms = 10 if ms == 0
1709
- # sleep ms/1000
1710
- # cmd.call
1711
- # end
1712
- # else
1713
- # cmdid = install_cmd(cmd)
1714
- # tk_call("after",ms,cmdid)
1715
- # end
1716
- end
1717
- =end
1718
1669
 
1719
- def after_idle(cmd=Proc.new)
1670
+ def after_idle(cmd=nil, &block)
1671
+ cmd ||= block
1720
1672
  cmdid = install_cmd(proc{ret = cmd.call;uninstall_cmd(cmdid); ret})
1721
1673
  after_id = tk_call_without_enc('after','idle',cmdid)
1722
1674
  after_id.instance_variable_set('@cmdid', cmdid)
1723
1675
  after_id
1724
1676
  end
1725
- =begin
1726
- def after_idle(cmd=Proc.new)
1727
- crit_bup = Thread.critical
1728
- Thread.critical = true
1729
-
1730
- myid = _curr_cmd_id
1731
- cmdid = install_cmd(proc{ret = cmd.call;uninstall_cmd(myid); ret})
1732
-
1733
- Thread.critical = crit_bup
1734
-
1735
- tk_call_without_enc('after','idle',cmdid)
1736
- end
1737
- =end
1738
1677
 
1739
1678
  def after_cancel(afterId)
1740
1679
  tk_call_without_enc('after','cancel',afterId)
@@ -1786,9 +1725,6 @@ EOS
1786
1725
  end
1787
1726
 
1788
1727
  def appsend(interp, async, *args)
1789
- if $SAFE >= 1 && args.find{|obj| obj.tainted?}
1790
- fail SecurityError, "cannot send tainted Tk commands at level #{$SAFE}"
1791
- end
1792
1728
  if async != true && async != false && async != nil
1793
1729
  args.unshift(async)
1794
1730
  async = false
@@ -1801,9 +1737,6 @@ EOS
1801
1737
  end
1802
1738
 
1803
1739
  def rb_appsend(interp, async, *args)
1804
- if $SAFE >= 1 && args.find{|obj| obj.tainted?}
1805
- fail SecurityError, "cannot send tainted Ruby commands at level #{$SAFE}"
1806
- end
1807
1740
  if async != true && async != false && async != nil
1808
1741
  args.unshift(async)
1809
1742
  async = false
@@ -1817,9 +1750,6 @@ EOS
1817
1750
  end
1818
1751
 
1819
1752
  def appsend_displayof(interp, win, async, *args)
1820
- if $SAFE >= 1 && args.find{|obj| obj.tainted?}
1821
- fail SecurityError, "cannot send tainted Tk commands at level #{$SAFE}"
1822
- end
1823
1753
  win = '.' if win == nil
1824
1754
  if async != true && async != false && async != nil
1825
1755
  args.unshift(async)
@@ -1833,9 +1763,6 @@ EOS
1833
1763
  end
1834
1764
 
1835
1765
  def rb_appsend_displayof(interp, win, async, *args)
1836
- if $SAFE >= 1 && args.find{|obj| obj.tainted?}
1837
- fail SecurityError, "cannot send tainted Ruby commands at level #{$SAFE}"
1838
- end
1839
1766
  win = '.' if win == nil
1840
1767
  if async != true && async != false && async != nil
1841
1768
  args.unshift(async)
@@ -2085,7 +2012,6 @@ EOS
2085
2012
  puts 'invoke args => ' + args.inspect if $DEBUG
2086
2013
  ### print "=> ", args.join(" ").inspect, "\n" if $DEBUG
2087
2014
  begin
2088
- # res = TkUtil.untrust(INTERP._invoke(*args))
2089
2015
  # res = INTERP._invoke(enc_mode, *args)
2090
2016
  res = _ip_invoke_core(enc_mode, *args)
2091
2017
  # >>>>> _invoke returns a TAINTED string <<<<<
@@ -2093,7 +2019,6 @@ EOS
2093
2019
  # err = $!
2094
2020
  begin
2095
2021
  args.unshift "unknown"
2096
- #res = TkUtil.untrust(INTERP._invoke(*args))
2097
2022
  #res = INTERP._invoke(enc_mode, *args)
2098
2023
  res = _ip_invoke_core(enc_mode, *args)
2099
2024
  # >>>>> _invoke returns a TAINTED string <<<<<
@@ -3383,28 +3308,22 @@ end
3383
3308
 
3384
3309
 
3385
3310
  module TkBindCore
3386
- #def bind(context, cmd=Proc.new, *args)
3387
- # Tk.bind(self, context, cmd, *args)
3388
- #end
3389
- def bind(context, *args)
3311
+ def bind(context, *args, &block)
3390
3312
  # if args[0].kind_of?(Proc) || args[0].kind_of?(Method)
3391
- if TkComm._callback_entry?(args[0]) || !block_given?
3313
+ if TkComm._callback_entry?(args[0]) || !block
3392
3314
  cmd = args.shift
3393
3315
  else
3394
- cmd = Proc.new
3316
+ cmd = block
3395
3317
  end
3396
3318
  Tk.bind(self, context, cmd, *args)
3397
3319
  end
3398
3320
 
3399
- #def bind_append(context, cmd=Proc.new, *args)
3400
- # Tk.bind_append(self, context, cmd, *args)
3401
- #end
3402
- def bind_append(context, *args)
3321
+ def bind_append(context, *args, &block)
3403
3322
  # if args[0].kind_of?(Proc) || args[0].kind_of?(Method)
3404
- if TkComm._callback_entry?(args[0]) || !block_given?
3323
+ if TkComm._callback_entry?(args[0]) || !block
3405
3324
  cmd = args.shift
3406
3325
  else
3407
- cmd = Proc.new
3326
+ cmd = block
3408
3327
  end
3409
3328
  Tk.bind_append(self, context, cmd, *args)
3410
3329
  end
@@ -5592,7 +5511,7 @@ class TkWindow<TkObject
5592
5511
  if cmd
5593
5512
  configure_cmd('command', cmd)
5594
5513
  elsif b
5595
- configure_cmd('command', Proc.new(&b))
5514
+ configure_cmd('command', b)
5596
5515
  else
5597
5516
  cget('command')
5598
5517
  end
@@ -17,8 +17,8 @@ module TkBgError
17
17
  alias show bgerror
18
18
  module_function :bgerror, :tkerror, :show
19
19
 
20
- def set_handler(hdlr = Proc.new) #==> handler :: proc{|msg| ...body... }
21
- tk_call('proc', 'bgerror', 'msg', install_cmd(hdlr) + ' $msg')
20
+ def set_handler(hdlr = nil, &block) #==> handler :: proc{|msg| ...body... }
21
+ tk_call('proc', 'bgerror', 'msg', install_cmd(hdlr || block) + ' $msg')
22
22
  end
23
23
  def set_default
24
24
  begin
@@ -10,7 +10,7 @@ class TkBindTag
10
10
  #BTagID_TBL = {}
11
11
  BTagID_TBL = TkCore::INTERP.create_table
12
12
 
13
- (Tk_BINDTAG_ID = ["btag".freeze, TkUtil.untrust("00000")]).instance_eval{
13
+ (Tk_BINDTAG_ID = ["btag".freeze, "00000"]).instance_eval{
14
14
  @mutex = Mutex.new
15
15
  def mutex; @mutex; end
16
16
  freeze
@@ -131,31 +131,23 @@ class Tk::Canvas<TkWindow
131
131
  *tags.collect{|t| tagid(t)}))
132
132
  end
133
133
 
134
- #def itembind(tag, context, cmd=Proc.new, *args)
135
- # _bind([path, "bind", tagid(tag)], context, cmd, *args)
136
- # self
137
- #end
138
- def itembind(tag, context, *args)
134
+ def itembind(tag, context, *args, &block)
139
135
  # if args[0].kind_of?(Proc) || args[0].kind_of?(Method)
140
- if TkComm._callback_entry?(args[0]) || !block_given?
136
+ if TkComm._callback_entry?(args[0]) || !block
141
137
  cmd = args.shift
142
138
  else
143
- cmd = Proc.new
139
+ cmd = block
144
140
  end
145
141
  _bind([path, "bind", tagid(tag)], context, cmd, *args)
146
142
  self
147
143
  end
148
144
 
149
- #def itembind_append(tag, context, cmd=Proc.new, *args)
150
- # _bind_append([path, "bind", tagid(tag)], context, cmd, *args)
151
- # self
152
- #end
153
- def itembind_append(tag, context, *args)
145
+ def itembind_append(tag, context, *args, &block)
154
146
  # if args[0].kind_of?(Proc) || args[0].kind_of?(Method)
155
- if TkComm._callback_entry?(args[0]) || !block_given?
147
+ if TkComm._callback_entry?(args[0]) || !block
156
148
  cmd = args.shift
157
149
  else
158
- cmd = Proc.new
150
+ cmd = block
159
151
  end
160
152
  _bind_append([path, "bind", tagid(tag)], context, cmd, *args)
161
153
  self