diff options
24 files changed, 187 insertions, 100 deletions
diff --git a/ext/tk/ChangeLog.tkextlib b/ext/tk/ChangeLog.tkextlib index dfe4385955..83989c1a8e 100644 --- a/ext/tk/ChangeLog.tkextlib +++ b/ext/tk/ChangeLog.tkextlib @@ -1,3 +1,27 @@ +2004-12-16 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp> + + * bwidget/labelentry.rb: use TkCore.callback_obj?() + + * bwidget/listbox.rb: ditto + + * bwidget/notebook.rb: ditto + + * bwidget/spinbox.rb: ditto + + * itk/incr_tk.rb: ditto + + * iwidgets/scrolledcanvas.rb: ditto + + * tkDND/tkdnd.rb: ditto + + * treectrl/tktreectrl.rb: ditto + + * winico/winico.rb: ditto + +2004-12-10 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp> + + * tile/style.rb: 'theme_use' method bug fix + 2004-12-08 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp> * bwidget/notebook.rb: raise method cannot return the raised page. diff --git a/ext/tk/lib/multi-tk.rb b/ext/tk/lib/multi-tk.rb index 38e4b28dec..49bb49da9d 100644 --- a/ext/tk/lib/multi-tk.rb +++ b/ext/tk/lib/multi-tk.rb @@ -1256,6 +1256,9 @@ end # for callback operation class MultiTkIp + def self.cb_entry_class + @@CB_ENTRY_CLASS + end def self.get_cb_entry(cmd) @@CB_ENTRY_CLASS.new(__getip, cmd).freeze end diff --git a/ext/tk/lib/tk.rb b/ext/tk/lib/tk.rb index 3a8690305f..3cb911147a 100644 --- a/ext/tk/lib/tk.rb +++ b/ext/tk/lib/tk.rb @@ -574,6 +574,12 @@ end private :_toUTF8, :_fromUTF8 module_function :_toUTF8, :_fromUTF8 + def _callback_entry?(obj) + obj.kind_of?(Proc) || obj.kind_of?(Method) || obj.kind_of?(TkCallbackEntry) + end + private :_callback_entry? + module_function :_callback_entry? + =begin ### --> definition is moved to TkUtil module def _get_eval_string(str, enc_mode = nil) @@ -906,7 +912,8 @@ module TkComm # tagOrClass #end def bind(tagOrClass, context, *args) - if args[0].kind_of?(Proc) || args[0].kind_of?(Method) + # if args[0].kind_of?(Proc) || args[0].kind_of?(Method) + if TkComm._callback_entry?(args[0]) cmd = args.shift else cmd = Proc.new @@ -920,7 +927,8 @@ module TkComm # tagOrClass #end def bind_append(tagOrClass, context, *args) - if args[0].kind_of?(Proc) || args[0].kind_of?(Method) + # if args[0].kind_of?(Proc) || args[0].kind_of?(Method) + if TkComm._callback_entry?(args[0]) cmd = args.shift else cmd = Proc.new @@ -943,7 +951,8 @@ module TkComm # TkBindTag::ALL #end def bind_all(context, *args) - if args[0].kind_of?(Proc) || args[0].kind_of?(Method) + # if args[0].kind_of?(Proc) || args[0].kind_of?(Method) + if TkComm._callback_entry?(args[0]) cmd = args.shift else cmd = Proc.new @@ -957,7 +966,8 @@ module TkComm # TkBindTag::ALL #end def bind_append_all(context, *args) - if args[0].kind_of?(Proc) || args[0].kind_of?(Method) + # if args[0].kind_of?(Proc) || args[0].kind_of?(Method) + if TkComm._callback_entry?(args[0]) cmd = args.shift else cmd = Proc.new @@ -2107,7 +2117,8 @@ module TkBindCore # Tk.bind(self, context, cmd, *args) #end def bind(context, *args) - if args[0].kind_of?(Proc) || args[0].kind_of?(Method) + # if args[0].kind_of?(Proc) || args[0].kind_of?(Method) + if TkComm._callback_entry?(args[0]) cmd = args.shift else cmd = Proc.new @@ -2119,7 +2130,8 @@ module TkBindCore # Tk.bind_append(self, context, cmd, *args) #end def bind_append(context, *args) - if args[0].kind_of?(Proc) || args[0].kind_of?(Method) + # if args[0].kind_of?(Proc) || args[0].kind_of?(Method) + if TkComm._callback_entry?(args[0]) cmd = args.shift else cmd = Proc.new diff --git a/ext/tk/lib/tk/bindtag.rb b/ext/tk/lib/tk/bindtag.rb index adf96b9e3d..737223e3df 100644 --- a/ext/tk/lib/tk/bindtag.rb +++ b/ext/tk/lib/tk/bindtag.rb @@ -18,10 +18,11 @@ class TkBindTag def TkBindTag.new_by_name(name, *args, &b) return BTagID_TBL[name] if BTagID_TBL[name] - self.new(*args, &b).instance_eval{ + self.new.instance_eval{ BTagID_TBL.delete @id @id = name BTagID_TBL[@id] = self + bind(*args, &b) if args != [] } end diff --git a/ext/tk/lib/tk/canvas.rb b/ext/tk/lib/tk/canvas.rb index 3bc08e94fc..a0543cc42d 100644 --- a/ext/tk/lib/tk/canvas.rb +++ b/ext/tk/lib/tk/canvas.rb @@ -99,7 +99,8 @@ class TkCanvas<TkWindow # self #end def itembind(tag, context, *args) - if args[0].kind_of?(Proc) || args[0].kind_of?(Method) + # if args[0].kind_of?(Proc) || args[0].kind_of?(Method) + if TkComm._callback_entry?(args[0]) cmd = args.shift else cmd = Proc.new @@ -113,7 +114,8 @@ class TkCanvas<TkWindow # self #end def itembind_append(tag, context, *args) - if args[0].kind_of?(Proc) || args[0].kind_of?(Method) + # if args[0].kind_of?(Proc) || args[0].kind_of?(Method) + if TkComm._callback_entry?(args[0]) cmd = args.shift else cmd = Proc.new diff --git a/ext/tk/lib/tk/canvastag.rb b/ext/tk/lib/tk/canvastag.rb index 5d1d5e92ab..2eec6e3ca1 100644 --- a/ext/tk/lib/tk/canvastag.rb +++ b/ext/tk/lib/tk/canvastag.rb @@ -26,7 +26,8 @@ module TkcTagAccess # self #end def bind(seq, *args) - if args[0].kind_of?(Proc) || args[0].kind_of?(Method) + # if args[0].kind_of?(Proc) || args[0].kind_of?(Method) + if TkComm._callback_entry?(args[0]) cmd = args.shift else cmd = Proc.new @@ -40,7 +41,8 @@ module TkcTagAccess # self #end def bind_append(seq, *args) - if args[0].kind_of?(Proc) || args[0].kind_of?(Method) + # if args[0].kind_of?(Proc) || args[0].kind_of?(Method) + if TkComm._callback_entry?(args[0]) cmd = args.shift else cmd = Proc.new diff --git a/ext/tk/lib/tk/dialog.rb b/ext/tk/lib/tk/dialog.rb index f7d17b5a96..5b627d7c03 100644 --- a/ext/tk/lib/tk/dialog.rb +++ b/ext/tk/lib/tk/dialog.rb @@ -30,21 +30,21 @@ class TkDialogObj < TkWindow case configs when Proc @buttons.each_index{|i| - if (c = configs.call(i)).kind_of? Hash + if (c = configs.call(i)).kind_of?(Hash) set_config.call(c,i) end } when Array @buttons.each_index{|i| - if (c = configs[i]).kind_of? Hash + if (c = configs[i]).kind_of?(Hash) set_config.call(c,i) end } when Hash @buttons.each_with_index{|s,i| - if (c = configs[s]).kind_of? Hash + if (c = configs[s]).kind_of?(Hash) set_config.call(c,i) end } @@ -78,7 +78,7 @@ class TkDialogObj < TkWindow @command = prev_command - if keys.kind_of? Hash + if keys.kind_of?(Hash) @title = keys['title'] if keys.key? 'title' @message = keys['message'] if keys.key? 'message' @bitmap = keys['bitmap'] if keys.key? 'bitmap' @@ -99,18 +99,18 @@ class TkDialogObj < TkWindow @title = '{' + @title + '}' end - if @buttons.kind_of? Array + if @buttons.kind_of?(Array) _set_button_config(@buttons.collect{|cfg| (cfg.kind_of? Array)? cfg[1]: nil}) @buttons = @buttons.collect{|cfg| (cfg.kind_of? Array)? cfg[0]: cfg} end - if @buttons.kind_of? Hash + if @buttons.kind_of?(Hash) _set_button_config(@buttons) @buttons = @buttons.keys end - @buttons = tk_split_simplelist(@buttons) if @buttons.kind_of? String + @buttons = tk_split_simplelist(@buttons) if @buttons.kind_of?(String) @buttons = @buttons.collect{|s| - if s.kind_of? Array + if s.kind_of?(Array) s = s.join(' ') end if s.include? ?\s @@ -120,7 +120,7 @@ class TkDialogObj < TkWindow end } - if @message_config.kind_of? Hash + if @message_config.kind_of?(Hash) # @config << Kernel.format("%s.msg configure %s;", # @path, hash_kv(@message_config).join(' ')) # @config << @path+'.msg configure '+hash_kv(@message_config).join(' ')+';' @@ -128,7 +128,7 @@ class TkDialogObj < TkWindow array2tk_list(hash_kv(@message_config))+';' end - if @msgframe_config.kind_of? Hash + if @msgframe_config.kind_of?(Hash) # @config << Kernel.format("%s.top configure %s;", # @path, hash_kv(@msgframe_config).join(' ')) # @config << @path+'.top configure '+hash_kv(@msgframe_config).join(' ')+';' @@ -136,7 +136,7 @@ class TkDialogObj < TkWindow array2tk_list(hash_kv(@msgframe_config))+';' end - if @btnframe_config.kind_of? Hash + if @btnframe_config.kind_of?(Hash) # @config << Kernel.format("%s.bot configure %s;", # @path, hash_kv(@btnframe_config).join(' ')) # @config << @path+'.bot configure '+hash_kv(@btnframe_config).join(' ')+';' @@ -144,7 +144,7 @@ class TkDialogObj < TkWindow array2tk_list(hash_kv(@btnframe_config))+';' end - if @bitmap_config.kind_of? Hash + if @bitmap_config.kind_of?(Hash) # @config << Kernel.format("%s.bitmap configure %s;", # @path, hash_kv(@bitmap_config).join(' ')) # @config << @path+'.bitmap configure '+hash_kv(@bitmap_config).join(' ')+';' @@ -157,11 +157,12 @@ class TkDialogObj < TkWindow private :create_self def show - if @command.kind_of? Proc + # if @command.kind_of?(Proc) + if TkComm._callback_entry?(@command) @command.call(self) end - if @default_button.kind_of? String + if @default_button.kind_of?(String) default_button = @buttons.index(@default_button) else default_button = @default_button @@ -265,7 +266,7 @@ end class TkWarningObj < TkDialogObj def initialize(parent = nil, mes = nil) if !mes - if parent.kind_of? TkWindow + if parent.kind_of?(TkWindow) mes = "" else mes = parent.to_s diff --git a/ext/tk/lib/tk/optiondb.rb b/ext/tk/lib/tk/optiondb.rb index 1484671920..fe79de123c 100644 --- a/ext/tk/lib/tk/optiondb.rb +++ b/ext/tk/lib/tk/optiondb.rb @@ -178,7 +178,8 @@ module TkOptionDB proc_source = TkOptionDB.get(self::CARRIER, id.id2name, '').strip res_proc = nil if proc_str != proc_source # resource is changed - unless res_proc.kind_of? Proc + # unless res_proc.kind_of?(Proc) + unless TkComm._callback_entry?(res_proc) #if id == :new || !(self::METHOD_TBL.has_key?(id) || self::ADD_METHOD) if id == :new || !(@method_tbl.has_key?(id) || @add_method) raise NoMethodError, @@ -253,7 +254,7 @@ module TkOptionDB CmdClassID[1].succ! parent = nil # ignore parent else - klass = klass.to_s if klass.kind_of? Symbol + klass = klass.to_s if klass.kind_of?(Symbol) unless (?A..?Z) === klass[0] fail ArgumentError, "bad string '#{klass}' for class name" end @@ -269,7 +270,7 @@ module TkOptionDB carrier = Tk.tk_call_without_enc('frame', @path, '-class', klass) end - unless func.kind_of? Array + unless func.kind_of?(Array) fail ArgumentError, "method-list must be Array" end func_str = func.join(' ') diff --git a/ext/tk/lib/tk/text.rb b/ext/tk/lib/tk/text.rb index 49b769403a..a79f50616a 100644 --- a/ext/tk/lib/tk/text.rb +++ b/ext/tk/lib/tk/text.rb @@ -215,7 +215,7 @@ class TkText<TkTextWin end def image_configure(index, slot, value=None) - if slot.kind_of? Hash + if slot.kind_of?(Hash) _fromUTF8(tk_send_without_enc('image', 'configure', _get_eval_enc_str(index), *hash_kv(slot, true))) @@ -347,7 +347,7 @@ class TkText<TkTextWin end def insert(index, chars, *tags) - if tags[0].kind_of? Array + if tags[0].kind_of?(Array) # multiple chars-taglist argument :: str, [tag,...], str, [tag,...], ... args = [chars] while tags.size > 0 @@ -507,7 +507,7 @@ class TkText<TkTextWin *(tags.collect{|tag| _get_eval_enc_str(tag)})) if TkTextTag::TTagID_TBL[@path] tags.each{|tag| - if tag.kind_of? TkTextTag + if tag.kind_of?(TkTextTag) TkTextTag::TTagID_TBL[@path].delete(tag.id) else TkTextTag::TTagID_TBL[@path].delete(tag) @@ -524,7 +524,8 @@ class TkText<TkTextWin # self #end def tag_bind(tag, seq, *args) - if args[0].kind_of?(Proc) || args[0].kind_of?(Method) + # if args[0].kind_of?(Proc) || args[0].kind_of?(Method) + if TkComm._callback_entry?(args[0]) cmd = args.shift else cmd = Proc.new @@ -538,7 +539,8 @@ class TkText<TkTextWin # self #end def tag_bind_append(tag, seq, *args) - if args[0].kind_of?(Proc) || args[0].kind_of?(Method) + # if args[0].kind_of?(Proc) || args[0].kind_of?(Method) + if TkComm._callback_entry?(args[0]) cmd = args.shift else cmd = Proc.new @@ -580,7 +582,7 @@ class TkText<TkTextWin end def tag_configure(tag, key, val=None) - if key.kind_of? Hash + if key.kind_of?(Hash) key = _symbolkey2str(key) if ( key['font'] || key['kanjifont'] \ || key['latinfont'] || key['asciifont'] ) @@ -798,17 +800,17 @@ class TkText<TkTextWin end def window_configure(index, slot, value=None) - if index.kind_of? TkTextWindow + if index.kind_of?(TkTextWindow) index.configure(slot, value) else - if slot.kind_of? Hash + if slot.kind_of?(Hash) slot = _symbolkey2str(slot) win = slot['window'] # slot['window'] = win.epath if win.kind_of?(TkWindow) slot['window'] = _epath(win) if win if slot['create'] p_create = slot['create'] - if p_create.kind_of? Proc + if p_create.kind_of?(Proc) #=begin slot['create'] = install_cmd(proc{ id = p_create.call @@ -833,7 +835,7 @@ class TkText<TkTextWin end if slot == 'create' || slot == :create p_create = value - if p_create.kind_of? Proc + if p_create.kind_of?(Proc) #=begin value = install_cmd(proc{ id = p_create.call @@ -1054,7 +1056,7 @@ class TkText<TkTextWin end def search_with_length(pat,start,stop=None) - pat = pat.chr if pat.kind_of? Integer + pat = pat.chr if pat.kind_of?(Integer) if stop != None return ["", 0] if compare(start,'>=',stop) txt = get(start,stop) @@ -1062,7 +1064,7 @@ class TkText<TkTextWin match = $& #pos = txt[0..(pos-1)].split('').length if pos > 0 pos = _ktext_length(txt[0..(pos-1)]) if pos > 0 - if pat.kind_of? String + if pat.kind_of?(String) #return [index(start + " + #{pos} chars"), pat.split('').length] return [index(start + " + #{pos} chars"), _ktext_length(pat), pat.dup] @@ -1080,7 +1082,7 @@ class TkText<TkTextWin match = $& #pos = txt[0..(pos-1)].split('').length if pos > 0 pos = _ktext_length(txt[0..(pos-1)]) if pos > 0 - if pat.kind_of? String + if pat.kind_of?(String) #return [index(start + " + #{pos} chars"), pat.split('').length] return [index(start + " + #{pos} chars"), _ktext_length(pat), pat.dup] @@ -1095,7 +1097,7 @@ class TkText<TkTextWin match = $& #pos = txt[0..(pos-1)].split('').length if pos > 0 pos = _ktext_length(txt[0..(pos-1)]) if pos > 0 - if pat.kind_of? String + if pat.kind_of?(String) #return [index("1.0 + #{pos} chars"), pat.split('').length] return [index("1.0 + #{pos} chars"), _ktext_length(pat), pat.dup] @@ -1115,7 +1117,7 @@ class TkText<TkTextWin end def rsearch_with_length(pat,start,stop=None) - pat = pat.chr if pat.kind_of? Integer + pat = pat.chr if pat.kind_of?(Integer) if stop != None return ["", 0] if compare(start,'<=',stop) txt = get(stop,start) @@ -1123,7 +1125,7 @@ class TkText<TkTextWin match = $& #pos = txt[0..(pos-1)].split('').length if pos > 0 pos = _ktext_length(txt[0..(pos-1)]) if pos > 0 - if pat.kind_of? String + if pat.kind_of?(String) #return [index(stop + " + #{pos} chars"), pat.split('').length] return [index(stop + " + #{pos} chars"), _ktext_length(pat), pat.dup] else @@ -1139,7 +1141,7 @@ class TkText<TkTextWin match = $& #pos = txt[0..(pos-1)].split('').length if pos > 0 pos = _ktext_length(txt[0..(pos-1)]) if pos > 0 - if pat.kind_of? String + if pat.kind_of?(String) #return [index("1.0 + #{pos} chars"), pat.split('').length] return [index("1.0 + #{pos} chars"), _ktext_length(pat), pat.dup] else @@ -1152,7 +1154,7 @@ class TkText<TkTextWin match = $& #pos = txt[0..(pos-1)].split('').length if pos > 0 pos = _ktext_length(txt[0..(pos-1)]) if pos > 0 - if pat.kind_of? String + if pat.kind_of?(String) #return [index("1.0 + #{pos} chars"), pat.split('').length] return [index("1.0 + #{pos} chars"), _ktext_length(pat), pat.dup] else diff --git a/ext/tk/lib/tk/texttag.rb b/ext/tk/lib/tk/texttag.rb index 37b83cc4aa..a80f4780c0 100644 --- a/ext/tk/lib/tk/texttag.rb +++ b/ext/tk/lib/tk/texttag.rb @@ -32,9 +32,9 @@ class TkTextTag<TkObject TTagID_TBL[@tpath][@id] = self Tk_TextTag_ID[1].succ! #tk_call @t.path, "tag", "configure", @id, *hash_kv(keys) - if args != [] then + if args != [] keys = args.pop - if keys.kind_of? Hash then + if keys.kind_of?(Hash) add(*args) if args != [] configure(keys) else @@ -139,7 +139,7 @@ class TkTextTag<TkObject @t.tag_configure @id, key, val end # def configure(key, val=None) -# if key.kind_of? Hash +# if key.kind_of?(Hash) # tk_call @t.path, 'tag', 'configure', @id, *hash_kv(key) # else # tk_call @t.path, 'tag', 'configure', @id, "-#{key}", val @@ -148,7 +148,7 @@ class TkTextTag<TkObject # def configure(key, value) # if value == FALSE # value = "0" -# elsif value.kind_of? Proc +# elsif value.kind_of?(Proc) # value = install_cmd(value) # end # tk_call @t.path, 'tag', 'configure', @id, "-#{key}", value @@ -167,7 +167,8 @@ class TkTextTag<TkObject # self #end def bind(seq, *args) - if args[0].kind_of?(Proc) || args[0].kind_of?(Method) + # if args[0].kind_of?(Proc) || args[0].kind_of?(Method) + if TkComm._callback_entry?(args[0]) cmd = args.shift else cmd = Proc.new @@ -181,7 +182,8 @@ class TkTextTag<TkObject # self #end def bind_append(seq, *args) - if args[0].kind_of?(Proc) || args[0].kind_of?(Method) + # if args[0].kind_of?(Proc) || args[0].kind_of?(Method) + if TkComm._callback_entry?(args[0]) cmd = args.shift else cmd = Proc.new @@ -222,9 +224,9 @@ class TkTextNamedTag<TkTextTag def self.new(parent, name, *args) if TTagID_TBL[parent.path] && TTagID_TBL[parent.path][name] tagobj = TTagID_TBL[parent.path][name] - if args != [] then + if args != [] keys = args.pop - if keys.kind_of? Hash then + if keys.kind_of?(Hash) tagobj.add(*args) if args != [] tagobj.configure(keys) else @@ -250,9 +252,9 @@ class TkTextNamedTag<TkTextTag #if mode # tk_call @t.path, "addtag", @id, *args #end - if args != [] then + if args != [] keys = args.pop - if keys.kind_of? Hash then + if keys.kind_of?(Hash) add(*args) if args != [] configure(keys) else diff --git a/ext/tk/lib/tk/textwindow.rb b/ext/tk/lib/tk/textwindow.rb index 59fafff181..c53cbe1a70 100644 --- a/ext/tk/lib/tk/textwindow.rb +++ b/ext/tk/lib/tk/textwindow.rb @@ -13,7 +13,7 @@ class TkTextWindow<TkObject if index == 'end' @path = TkTextMark.new(@t, tk_call_without_enc(@t.path, 'index', 'end - 1 chars')) - elsif index.kind_of? TkTextMark + elsif index.kind_of?(TkTextMark) if tk_call_without_enc(@t.path,'index',index.path) == tk_call_without_enc(@t.path,'index','end') @path = TkTextMark.new(@t, tk_call_without_enc(@t.path, 'index', 'end - 1 chars')) @@ -32,7 +32,8 @@ class TkTextWindow<TkObject keys['window'] = _epath(@id) if @id if keys['create'] @p_create = keys['create'] - if @p_create.kind_of? Proc + # if @p_create.kind_of?(Proc) + if TkComm._callback_entry?(@p_create) =begin keys['create'] = install_cmd(proc{ @id = @p_create.call @@ -63,7 +64,7 @@ class TkTextWindow<TkObject end def configure(slot, value=None) - if slot.kind_of? Hash + if slot.kind_of?(Hash) slot = _symbolkey2str(slot) if slot['window'] @id = slot['window'] @@ -120,7 +121,8 @@ class TkTextWindow<TkObject def create=(value) @p_create = value - if @p_create.kind_of? Proc + # if @p_create.kind_of?(Proc) + if TkComm._callback_entry?(@p_create) value = install_cmd(proc{ @id = @p_create.call if @id.kind_of?(TkWindow) diff --git a/ext/tk/lib/tk/timer.rb b/ext/tk/lib/tk/timer.rb index f3b6465f78..a1f43fa864 100644 --- a/ext/tk/lib/tk/timer.rb +++ b/ext/tk/lib/tk/timer.rb @@ -122,7 +122,8 @@ class TkTimer @current_args = args - if @sleep_time.kind_of? Proc + # if @sleep_time.kind_of?(Proc) + if TkComm._callback_entry?(@sleep_time) sleep = @sleep_time.call(self) else sleep = @sleep_time @@ -244,23 +245,28 @@ class TkTimer end def set_interval(interval) - if interval != 'idle' \ - && !interval.kind_of?(Integer) && !interval.kind_of?(Proc) + #if interval != 'idle' && interval != :idle \ + # && !interval.kind_of?(Integer) && !interval.kind_of?(Proc) + if interval != 'idle' && interval != :idle \ + && !interval.kind_of?(Integer) && !TkComm._callback_entry?(interval) fail ArguemntError, "expect Integer or Proc" end @sleep_time = interval end def set_procs(interval, loop_exec, *procs) - if interval != 'idle' \ - && !interval.kind_of?(Integer) && !interval.kind_of?(Proc) + #if interval != 'idle' && interval != :idle \ + # && !interval.kind_of?(Integer) && !interval.kind_of?(Proc) + if interval != 'idle' && interval != :idle \ + && !interval.kind_of?(Integer) && !TkComm._callback_entry?(interval) fail ArguemntError, "expect Integer or Proc for 1st argument" end @sleep_time = interval @loop_proc = [] procs.each{|e| - if e.kind_of? Proc + # if e.kind_of?(Proc) + if TkComm._callback_entry?(e) @loop_proc.push([e]) else @loop_proc.push(e) @@ -288,7 +294,8 @@ class TkTimer def add_procs(*procs) procs.each{|e| - if e.kind_of? Proc + # if e.kind_of?(Proc) + if TkComm._callback_entry?(e) @loop_proc.push([e]) else @loop_proc.push(e) @@ -301,7 +308,8 @@ class TkTimer def delete_procs(*procs) procs.each{|e| - if e.kind_of? Proc + # if e.kind_of?(Proc) + if TkComm._callback_entry?(e) @loop_proc.delete([e]) else @loop_proc.delete(e) @@ -325,7 +333,7 @@ class TkTimer # set parameters for 'restart' sleep = @init_sleep unless sleep - if !sleep == 'idle' && !sleep.kind_of?(Integer) + if sleep != 'idle' && sleep != :idle && !sleep.kind_of?(Integer) fail ArguemntError, "expect Integer or 'idle' for 1st argument" end @@ -354,7 +362,7 @@ class TkTimer argc = init_args.size if argc > 0 sleep = init_args.shift - if !sleep == 'idle' && !sleep.kind_of?(Integer) + if sleep != 'idle' && sleep != :idle && !sleep.kind_of?(Integer) fail ArguemntError, "expect Integer or 'idle' for 1st argument" end @init_sleep = sleep @@ -368,7 +376,8 @@ class TkTimer @current_sleep = @init_sleep @running = true if @init_proc - if not @init_proc.kind_of? Proc + # if not @init_proc.kind_of?(Proc) + if !TkComm._callback_entry?(@init_proc) fail ArgumentError, "Argument '#{@init_proc}' need to be Proc" end @current_proc = @init_proc @@ -421,7 +430,7 @@ class TkTimer sleep, cmd = @current_script fail RuntimeError, "no procedure to continue" unless cmd if wait - unless wait.kind_of? Integer + unless wait.kind_of?(Integer) fail ArguemntError, "expect Integer for 1st argument" end sleep = wait diff --git a/ext/tk/lib/tk/validation.rb b/ext/tk/lib/tk/validation.rb index 5a50de456d..eeb0163ee4 100644 --- a/ext/tk/lib/tk/validation.rb +++ b/ext/tk/lib/tk/validation.rb @@ -51,7 +51,8 @@ module Tk if keys[key].kind_of?(Array) cmd, *args = keys[key] keys[key] = klass.new(cmd, args.join(' ')) - elsif keys[key].kind_of?(Proc) || keys[key].kind_of?(Method) + # elsif keys[key].kind_of?(Proc) || keys[key].kind_of?(Method) + elsif TkComm._callback_entry?(keys[key]) keys[key] = klass.new(keys[key]) end } @@ -151,7 +152,8 @@ module Tk if keys[key].kind_of?(Array) cmd, *args = keys[key] keys[key] = klass.new(cmd, args.join(' ')) - elsif keys[key].kind_of?(Proc) || keys[key].kind_of?(Method) + # elsif keys[key].kind_of?(Proc) || keys[key].kind_of?(Method) + elsif TkComm._callback_entry?(keys[key]) keys[key] = klass.new(keys[key]) end } diff --git a/ext/tk/lib/tkextlib/bwidget/labelentry.rb b/ext/tk/lib/tkextlib/bwidget/labelentry.rb index 1425ef7730..19e92d7ae4 100644 --- a/ext/tk/lib/tkextlib/bwidget/labelentry.rb +++ b/ext/tk/lib/tkextlib/bwidget/labelentry.rb @@ -28,7 +28,8 @@ class Tk::BWidget::LabelEntry # self #end def entrybind(context, *args) - if args[0].kind_of?(Proc) || args[0].kind_of?(Method) + # if args[0].kind_of?(Proc) || args[0].kind_of?(Method) + if TkComm._callback_entry?(args[0]) cmd = args.shift else cmd = Proc.new @@ -42,7 +43,8 @@ class Tk::BWidget::LabelEntry # self #end def entrybind_append(context, *args) - if args[0].kind_of?(Proc) || args[0].kind_of?(Method) + #if args[0].kind_of?(Proc) || args[0].kind_of?(Method) + if TkComm._callback_entry?(args[0]) cmd = args.shift else cmd = Proc.new diff --git a/ext/tk/lib/tkextlib/bwidget/listbox.rb b/ext/tk/lib/tkextlib/bwidget/listbox.rb index 7f218c923c..178866f699 100644 --- a/ext/tk/lib/tkextlib/bwidget/listbox.rb +++ b/ext/tk/lib/tkextlib/bwidget/listbox.rb @@ -49,7 +49,8 @@ class Tk::BWidget::ListBox # self #end def imagebind(context, *args) - if args[0].kind_of?(Proc) || args[0].kind_of?(Method) + #if args[0].kind_of?(Proc) || args[0].kind_of?(Method) + if TkComm._callback_entry?(args[0]) cmd = args.shift else cmd = Proc.new @@ -64,7 +65,8 @@ class Tk::BWidget::ListBox # self #end def imagebind_append(context, *args) - if args[0].kind_of?(Proc) || args[0].kind_of?(Method) + #if args[0].kind_of?(Proc) || args[0].kind_of?(Method) + if TkComm._callback_entry?(args[0]) cmd = args.shift else cmd = Proc.new @@ -88,7 +90,8 @@ class Tk::BWidget::ListBox # self #end def textbind(context, *args) - if args[0].kind_of?(Proc) || args[0].kind_of?(Method) + #if args[0].kind_of?(Proc) || args[0].kind_of?(Method) + if TkComm._callback_entry?(args[0]) cmd = args.shift else cmd = Proc.new @@ -103,7 +106,8 @@ class Tk::BWidget::ListBox # self #end def textbind_append(context, *args) - if args[0].kind_of?(Proc) || args[0].kind_of?(Method) + #if args[0].kind_of?(Proc) || args[0].kind_of?(Method) + if TkComm._callback_entry?(args[0]) cmd = args.shift else cmd = Proc.new diff --git a/ext/tk/lib/tkextlib/bwidget/notebook.rb b/ext/tk/lib/tkextlib/bwidget/notebook.rb index 8888ab224b..01299d2de8 100644 --- a/ext/tk/lib/tkextlib/bwidget/notebook.rb +++ b/ext/tk/lib/tkextlib/bwidget/notebook.rb @@ -46,7 +46,8 @@ class Tk::BWidget::NoteBook # self #end def tabbind(context, *args) - if args[0].kind_of?(Proc) || args[0].kind_of?(Method) + #if args[0].kind_of?(Proc) || args[0].kind_of?(Method) + if TkComm._callback_entry?(args[0]) cmd = args.shift else cmd = Proc.new @@ -61,7 +62,8 @@ class Tk::BWidget::NoteBook # self #end def tabbind_append(context, *args) - if args[0].kind_of?(Proc) || args[0].kind_of?(Method) + #if args[0].kind_of?(Proc) || args[0].kind_of?(Method) + if TkComm._callback_entry?(args[0]) cmd = args.shift else cmd = Proc.new diff --git a/ext/tk/lib/tkextlib/bwidget/spinbox.rb b/ext/tk/lib/tkextlib/bwidget/spinbox.rb index 66501ed702..52dfa30abc 100644 --- a/ext/tk/lib/tkextlib/bwidget/spinbox.rb +++ b/ext/tk/lib/tkextlib/bwidget/spinbox.rb @@ -27,7 +27,8 @@ class Tk::BWidget::SpinBox # self #end def entrybind(context, *args) - if args[0].kind_of?(Proc) || args[0].kind_of?(Method) + #if args[0].kind_of?(Proc) || args[0].kind_of?(Method) + if TkComm._callback_entry?(args[0]) cmd = args.shift else cmd = Proc.new @@ -41,7 +42,8 @@ class Tk::BWidget::SpinBox # self #end def entrybind_append(context, *args) - if args[0].kind_of?(Proc) || args[0].kind_of?(Method) + #if args[0].kind_of?(Proc) || args[0].kind_of?(Method) + if TkComm._callback_entry?(args[0]) cmd = args.shift else cmd = Proc.new diff --git a/ext/tk/lib/tkextlib/bwidget/tree.rb b/ext/tk/lib/tkextlib/bwidget/tree.rb index 16ca8e8927..dadf3d5161 100644 --- a/ext/tk/lib/tkextlib/bwidget/tree.rb +++ b/ext/tk/lib/tkextlib/bwidget/tree.rb @@ -46,7 +46,8 @@ class Tk::BWidget::Tree # self #end def imagebind(context, *args) - if args[0].kind_of?(Proc) || args[0].kind_of?(Method) + #if args[0].kind_of?(Proc) || args[0].kind_of?(Method) + if TkComm._callback_entry?(args[0]) cmd = args.shift else cmd = Proc.new @@ -61,7 +62,8 @@ class Tk::BWidget::Tree # self #end def imagebind_append(context, *args) - if args[0].kind_of?(Proc) || args[0].kind_of?(Method) + #if args[0].kind_of?(Proc) || args[0].kind_of?(Method) + if TkComm._callback_entry?(args[0]) cmd = args.shift else cmd = Proc.new @@ -85,7 +87,8 @@ class Tk::BWidget::Tree # self #end def textbind(context, *args) - if args[0].kind_of?(Proc) || args[0].kind_of?(Method) + #if args[0].kind_of?(Proc) || args[0].kind_of?(Method) + if TkComm._callback_entry?(args[0]) cmd = args.shift else cmd = Proc.new @@ -100,7 +103,8 @@ class Tk::BWidget::Tree # self #end def textbind_append(context, *args) - if args[0].kind_of?(Proc) || args[0].kind_of?(Method) + #if args[0].kind_of?(Proc) || args[0].kind_of?(Method) + if TkComm._callback_entry?(args[0]) cmd = args.shift else cmd = Proc.new diff --git a/ext/tk/lib/tkextlib/itk/incr_tk.rb b/ext/tk/lib/tkextlib/itk/incr_tk.rb index 106ffa3519..1d80e1cd6b 100644 --- a/ext/tk/lib/tkextlib/itk/incr_tk.rb +++ b/ext/tk/lib/tkextlib/itk/incr_tk.rb @@ -350,7 +350,8 @@ module Tk fail RuntimeError, 'component is not assigned to a widget' end end - if args[0].kind_of?(Proc) || args[0].kind_of?(Method) + # if args[0].kind_of?(Proc) || args[0].kind_of?(Method) + if TkComm._callback_entry?(args[0]) cmd = args.shift else cmd = Proc.new @@ -378,7 +379,8 @@ module Tk fail RuntimeError, 'component is not assigned to a widget' end end - if args[0].kind_of?(Proc) || args[0].kind_of?(Method) + # if args[0].kind_of?(Proc) || args[0].kind_of?(Method) + if TkComm._callback_entry?(args[0]) cmd = args.shift else cmd = Proc.new diff --git a/ext/tk/lib/tkextlib/iwidgets/scrolledcanvas.rb b/ext/tk/lib/tkextlib/iwidgets/scrolledcanvas.rb index ba563ba589..939d97de67 100644 --- a/ext/tk/lib/tkextlib/iwidgets/scrolledcanvas.rb +++ b/ext/tk/lib/tkextlib/iwidgets/scrolledcanvas.rb @@ -102,7 +102,8 @@ class Tk::Iwidgets::Scrolledcanvas # self #end def itembind(tag, context, *args) - if args[0].kind_of?(Proc) || args[0].kind_of?(Method) + # if args[0].kind_of?(Proc) || args[0].kind_of?(Method) + if TkComm._callback_entry?(args[0]) cmd = args.shift else cmd = Proc.new @@ -116,7 +117,8 @@ class Tk::Iwidgets::Scrolledcanvas # self #end def itembind_append(tag, context, *args) - if args[0].kind_of?(Proc) || args[0].kind_of?(Method) + # if args[0].kind_of?(Proc) || args[0].kind_of?(Method) + if TkComm._callback_entry?(args[0]) cmd = args.shift else cmd = Proc.new diff --git a/ext/tk/lib/tkextlib/tile/style.rb b/ext/tk/lib/tkextlib/tile/style.rb index 3be8c1d580..c8c0a802df 100644 --- a/ext/tk/lib/tkextlib/tile/style.rb +++ b/ext/tk/lib/tkextlib/tile/style.rb @@ -67,6 +67,6 @@ class << Tk::Tile::Style end def theme_use(name) - tk_call('style', 'use', name) + tk_call('style', 'theme', 'use', name) end end diff --git a/ext/tk/lib/tkextlib/tkDND/tkdnd.rb b/ext/tk/lib/tkextlib/tkDND/tkdnd.rb index d40d60217a..375ac89518 100644 --- a/ext/tk/lib/tkextlib/tkDND/tkdnd.rb +++ b/ext/tk/lib/tkextlib/tkDND/tkdnd.rb @@ -88,7 +88,8 @@ module Tk # self #end def dnd_bindtarget(type, event, *args) - if args[0].kind_of?(Proc) || args[0].kind_of?(Method) + # if args[0].kind_of?(Proc) || args[0].kind_of?(Method) + if TkComm._callback_entry?(args[0]) cmd = args.shift else cmd = Proc.new @@ -127,7 +128,8 @@ module Tk # self #end def dnd_bindsource(type, *args) - if args[0].kind_of?(Proc) || args[0].kind_of?(Method) + # if args[0].kind_of?(Proc) || args[0].kind_of?(Method) + if TkComm._callback_entry?(args[0]) cmd = args.shift else cmd = Proc.new diff --git a/ext/tk/lib/tkextlib/treectrl/tktreectrl.rb b/ext/tk/lib/tkextlib/treectrl/tktreectrl.rb index 11f723a8ff..9c1e977d14 100644 --- a/ext/tk/lib/tkextlib/treectrl/tktreectrl.rb +++ b/ext/tk/lib/tkextlib/treectrl/tktreectrl.rb @@ -748,7 +748,8 @@ class Tk::TreeCtrl # self #end def notify_bind(obj, event, *args) - if args[0].kind_of?(Proc) || args[0].kind_of?(Method) + # if args[0].kind_of?(Proc) || args[0].kind_of?(Method) + if TkComm._callback_entry?(args[0]) cmd = args.shift else cmd = Proc.new @@ -762,7 +763,8 @@ class Tk::TreeCtrl # self #end def notify_bind_append(obj, event, *args) - if args[0].kind_of?(Proc) || args[0].kind_of?(Method) + # if args[0].kind_of?(Proc) || args[0].kind_of?(Method) + if TkComm._callback_entry?(args[0]) cmd = args.shift else cmd = Proc.new diff --git a/ext/tk/lib/tkextlib/winico/winico.rb b/ext/tk/lib/tkextlib/winico/winico.rb index 8a71cbb401..1e2f1c0062 100644 --- a/ext/tk/lib/tkextlib/winico/winico.rb +++ b/ext/tk/lib/tkextlib/winico/winico.rb @@ -149,7 +149,8 @@ class Tk::Winico if keys[k].kind_of?(Array) cmd, *args = keys[k] keys[k] = Winico_callback.new(cmd, args.join(' ')) - elsif keys[k].kind_of?(Proc) + # elsif keys[k].kind_of?(Proc) + elsif TkComm._callback_entry?(keys[k]) keys[k] = Winico_callback.new(keys[k]) end } @@ -164,7 +165,8 @@ class Tk::Winico if keys[k].kind_of?(Array) cmd, *args = keys[k] keys[k] = Winico_callback.new(cmd, args.join(' ')) - elsif keys[k].kind_of?(Proc) + # elsif keys[k].kind_of?(Proc) + elsif TkComm._callback_entry?(keys[k]) keys[k] = Winico_callback.new(keys[k]) end } |