From c1566b74903da07910103c143cb2a38f4a7c86ba Mon Sep 17 00:00:00 2001 From: nagai Date: Tue, 9 Aug 2005 06:16:29 +0000 Subject: * ext/tk/tcltklib.c: remove dangerous 'rb_jump_tag's. * ext/tk/lib/tk.rb: add __val2ruby_optkeys and __ruby2val_optkeys to help to convert option values between ruby and tcl. * ext/tk/lib/tk/itemconfig.rb: add __item_val2ruby_optkeys and __item_ruby2val_optkeys to help to convert option values between ruby and tcl. * ext/tk/lib/tk/radiobutton.rb: use __ruby2val_optkeys for 'variable' option (for the reason of backward compatibility). * ext/tk/lib/tk/composite.rb: clarify the arguments of super(). * ext/tk/lib/tk/spinbox.rb: ditto. * ext/tk/lib/tk/text.rb: ditto. * ext/tk/lib/tk/validation.rb: ditto. * ext/tk/lib/tkextlib/*: support to treat tkvariable-type configure options. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@8958 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ext/tk/lib/tk.rb | 145 +++++++++++++++++++++++- ext/tk/lib/tk/composite.rb | 12 +- ext/tk/lib/tk/itemconfig.rb | 144 ++++++++++++++++++++++- ext/tk/lib/tk/radiobutton.rb | 8 ++ ext/tk/lib/tk/spinbox.rb | 2 +- ext/tk/lib/tk/text.rb | 8 +- ext/tk/lib/tk/validation.rb | 2 +- ext/tk/lib/tkextlib/blt/barchart.rb | 5 + ext/tk/lib/tkextlib/blt/component.rb | 6 + ext/tk/lib/tkextlib/blt/dragdrop.rb | 2 +- ext/tk/lib/tkextlib/blt/treeview.rb | 2 +- ext/tk/lib/tkextlib/bwidget/button.rb | 5 + ext/tk/lib/tkextlib/bwidget/entry.rb | 5 + ext/tk/lib/tkextlib/bwidget/label.rb | 5 + ext/tk/lib/tkextlib/bwidget/labelentry.rb | 5 + ext/tk/lib/tkextlib/bwidget/labelframe.rb | 5 + ext/tk/lib/tkextlib/bwidget/mainframe.rb | 5 + ext/tk/lib/tkextlib/bwidget/passwddlg.rb | 6 + ext/tk/lib/tkextlib/bwidget/spinbox.rb | 5 + ext/tk/lib/tkextlib/bwidget/tree.rb | 5 + ext/tk/lib/tkextlib/iwidgets/calendar.rb | 2 +- ext/tk/lib/tkextlib/iwidgets/entryfield.rb | 2 +- ext/tk/lib/tkextlib/iwidgets/hierarchy.rb | 8 +- ext/tk/lib/tkextlib/iwidgets/labeledframe.rb | 5 + ext/tk/lib/tkextlib/iwidgets/labeledwidget.rb | 5 + ext/tk/lib/tkextlib/iwidgets/menubar.rb | 5 + ext/tk/lib/tkextlib/iwidgets/scrolledlistbox.rb | 5 + ext/tk/lib/tkextlib/iwidgets/spinner.rb | 2 +- ext/tk/lib/tkextlib/iwidgets/toolbar.rb | 5 + ext/tk/lib/tkextlib/tkimg/pixmap.rb | 2 +- ext/tk/lib/tkextlib/tktable/tktable.rb | 2 +- ext/tk/tcltklib.c | 78 +++++++++++-- 32 files changed, 465 insertions(+), 38 deletions(-) (limited to 'ext') diff --git a/ext/tk/lib/tk.rb b/ext/tk/lib/tk.rb index f0f0271047..bffb0d26ca 100644 --- a/ext/tk/lib/tk.rb +++ b/ext/tk/lib/tk.rb @@ -2720,7 +2720,24 @@ module TkConfigMethod end private :__tkvariable_optkeys + def __val2ruby_optkeys # { key=>proc, ... } + # The method is used to convert a opt-value to a ruby's object. + # When get the value of the option "key", "proc.call(value)" is called. + {} + end + private :__val2ruby_optkeys + + def __ruby2val_optkeys # { key=>proc, ... } + # The method is used to convert a ruby's object to a opt-value. + # When set the value of the option "key", "proc.call(value)" is called. + # That is, "-#{key} #{proc.call(value)}". + {} + end + private :__ruby2val_optkeys + def __methodcall_optkeys # { key=>method, ... } + # The method is used to both of get and set. + # Usually, the 'key' will not be a widget option. {} end private :__methodcall_optkeys @@ -2775,6 +2792,16 @@ module TkConfigMethod fail ArgumentError, "Invalid option `#{orig_slot.inspect}'" end + if ( method = _symbolkey2str(__val2ruby_optkeys())[slot] ) + optval = tk_call_without_enc(*(__cget_cmd << "-#{slot}")) + begin + return method.call(optval) + rescue => e + warn("Warning:: #{e.message} (when #{method}.call(#{optval.inspect})") if $DEBUG + return optval + end + end + if ( method = _symbolkey2str(__methodcall_optkeys)[slot] ) return self.__send__(method) end @@ -2843,6 +2870,12 @@ module TkConfigMethod self.__send__(method, value) if value } + __ruby2val_optkeys.each{|key, method| + key = key.to_s + value = slot[key] + slot[key] = method.call(value) if value + } + __keyonly_optkeys.each{|defkey, undefkey| conf = slot.find{|kk, vv| kk == defkey.to_s} if conf @@ -2876,6 +2909,8 @@ module TkConfigMethod elsif undefkey tk_call(*(__config_cmd << "-#{undefkey}")) end + elsif ( method = _symbolkey2str(__ruby2val_optkeys)[slot] ) + method.call(value) elsif ( method = _symbolkey2str(__methodcall_optkeys)[slot] ) self.__send__(method, value) elsif (slot =~ /^(|latin|ascii|kanji)(#{__font_optkeys.join('|')})$/) @@ -2918,6 +2953,31 @@ module TkConfigMethod if slot slot = slot.to_s case slot + when /^(#{__val2ruby_optkeys().keys.join('|')})$/ + method = _symbolkey2str(__val2ruby_optkeys())[slot] + conf = tk_split_simplelist(tk_call_without_enc(*(__confinfo_cmd() << "-#{slot}")), false, true) + if ( __configinfo_struct[:default_value] \ + && conf[__configinfo_struct[:default_value]] ) + optval = conf[__configinfo_struct[:default_value]] + begin + val = method.call(optval) + rescue => e + warn("Warning:: #{e.message} (when #{method}.call(#{optval.inspect})") if $DEBUG + val = optval + end + conf[__configinfo_struct[:default_value]] = val + end + if ( conf[__configinfo_struct[:current_value]] ) + optval = conf[__configinfo_struct[:current_value]] + begin + val = method.call(optval) + rescue => e + warn("Warning:: #{e.message} (when #{method}.call(#{optval.inspect})") if $DEBUG + val = optval + end + conf[__configinfo_struct[:current_value]] = val + end + when /^(#{__methodcall_optkeys.keys.join('|')})$/ method = _symbolkey2str(__methodcall_optkeys)[slot] return [slot, '', '', '', self.__send__(method)] @@ -3059,7 +3119,32 @@ module TkConfigMethod conf[__configinfo_struct[:key]] = conf[__configinfo_struct[:key]][1..-1] - case conf[__configinfo_struct[:key]] + optkey = conf[__configinfo_struct[:key]] + case optkey + when /^(#{__val2ruby_optkeys().keys.join('|')})$/ + method = _symbolkey2str(__val2ruby_optkeys())[optkey] + if ( __configinfo_struct[:default_value] \ + && conf[__configinfo_struct[:default_value]] ) + optval = conf[__configinfo_struct[:default_value]] + begin + val = method.call(optval) + rescue => e + warn("Warning:: #{e.message} (when #{method}.call(#{optval.inspect})") if $DEBUG + val = optval + end + conf[__configinfo_struct[:default_value]] = val + end + if ( conf[__configinfo_struct[:current_value]] ) + optval = conf[__configinfo_struct[:current_value]] + begin + val = method.call(optval) + rescue => e + warn("Warning:: #{e.message} (when #{method}.call(#{optval.inspect})") if $DEBUG + val = optval + end + conf[__configinfo_struct[:current_value]] = val + end + when /^(#{__strval_optkeys.join('|')})$/ # do nothing @@ -3232,6 +3317,31 @@ module TkConfigMethod if slot slot = slot.to_s case slot + when /^(#{__val2ruby_optkeys().keys.join('|')})$/ + method = _symbolkey2str(__val2ruby_optkeys())[slot] + conf = tk_split_simplelist(tk_call_without_enc(*(__confinfo_cmd << "-#{slot}")), false, true) + if ( __configinfo_struct[:default_value] \ + && conf[__configinfo_struct[:default_value]] ) + optval = conf[__configinfo_struct[:default_value]] + begin + val = method.call(optval) + rescue => e + warn("Warning:: #{e.message} (when #{method}.call(#{optval.inspect})") if $DEBUG + val = optval + end + conf[__configinfo_struct[:default_value]] = val + end + if ( conf[__configinfo_struct[:current_value]] ) + optval = conf[__configinfo_struct[:current_value]] + begin + val = method.call(optval) + rescue => e + warn("Warning:: #{e.message} (when #{method}.call(#{optval.inspect})") if $DEBUG + val = optval + end + conf[__configinfo_struct[:current_value]] = val + end + when /^(#{__methodcall_optkeys.keys.join('|')})$/ method = _symbolkey2str(__methodcall_optkeys)[slot] return {slot => ['', '', '', self.__send__(method)]} @@ -3375,7 +3485,32 @@ module TkConfigMethod conf[__configinfo_struct[:key]] = conf[__configinfo_struct[:key]][1..-1] - case conf[__configinfo_struct[:key]] + optkey = conf[__configinfo_struct[:key]] + case optkey + when /^(#{__val2ruby_optkeys().keys.join('|')})$/ + method = _symbolkey2str(__val2ruby_optkeys())[optkey] + if ( __configinfo_struct[:default_value] \ + && conf[__configinfo_struct[:default_value]] ) + optval = conf[__configinfo_struct[:default_value]] + begin + val = method.call(optval) + rescue => e + warn("Warning:: #{e.message} (when #{method}.call(#{optval.inspect})") if $DEBUG + val = optval + end + conf[__configinfo_struct[:default_value]] = val + end + if ( conf[__configinfo_struct[:current_value]] ) + optval = conf[__configinfo_struct[:current_value]] + begin + val = method.call(optval) + rescue => e + warn("Warning:: #{e.message} (when #{method}.call(#{optval.inspect})") if $DEBUG + val = optval + end + conf[__configinfo_struct[:current_value]] = val + end + when /^(#{__strval_optkeys.join('|')})$/ # do nothing @@ -3746,6 +3881,12 @@ class TkWindowmethod, ... } + # The method is used to convert a opt-value to a ruby's object. + # When get the value of the option "key", "method.call(id, val)" is called. + {} + end + private :__item_val2ruby_optkeys + + def __item_ruby2val_optkeys(id) # { key=>method, ... } + # The method is used to convert a ruby's object to a opt-value. + # When set the value of the option "key", "method.call(id, val)" is called. + # That is, "-#{key} #{method.call(id, value)}". + {} + end + private :__item_ruby2val_optkeys + def __item_methodcall_optkeys(id) # { key=>method, ... } + # Use the method for both of get and set. + # Usually, the 'key' will not be a widget option. + # # maybe need to override # {'coords'=>'coords'} {} @@ -133,6 +151,16 @@ module TkItemConfigMethod fail ArgumentError, "Invalid option `#{orig_opt.inspect}'" end + if ( method = _symbolkey2str(__item_val2ruby_optkeys(tagid(tagOrId)))[option] ) + optval = tk_call_without_enc(*(__item_cget_cmd(tagid(tagOrId)) << "-#{option}")) + begin + return method.call(tagOrId, optval) + rescue => e + warn("Warning:: #{e.message} (when #{method}.call(#{tagOrId.inspect}, #{optval.inspect})") if $DEBUG + return optval + end + end + if ( method = _symbolkey2str(__item_methodcall_optkeys(tagid(tagOrId)))[option] ) return self.__send__(method, tagOrId) end @@ -200,6 +228,12 @@ module TkItemConfigMethod self.__send__(method, tagOrId, value) if value } + __item_ruby2val_optkeys(tagid(tagOrId)).each{|key, method| + key = key.to_s + value = slot[key] + slot[key] = method.call(tagOrId, value) if value + } + __item_keyonly_optkeys(tagid(tagOrId)).each{|defkey, undefkey| conf = slot.find{|kk, vv| kk == defkey.to_s} if conf @@ -233,6 +267,8 @@ module TkItemConfigMethod elsif undefkey tk_call(*(__item_config_cmd(tagid(tagOrId)) << "-#{undefkey}")) end + elsif ( method = _symbolkey2str(__item_ruby2val_optkeys(tagid(tagOrId)))[slot] ) + method.call(tagOrId, value) elsif ( method = _symbolkey2str(__item_methodcall_optkeys(tagid(tagOrId)))[slot] ) self.__send__(method, tagOrId, value) elsif (slot =~ /^(|latin|ascii|kanji)(#{__item_font_optkeys(tagid(tagOrId)).join('|')})$/) @@ -270,6 +306,31 @@ module TkItemConfigMethod if slot slot = slot.to_s case slot + when /^(#{__item_val2ruby_optkeys(tagid(tagOrId)).keys.join('|')})$/ + method = _symbolkey2str(__item_val2ruby_optkeys(tagid(tagOrId)))[slot] + conf = tk_split_simplelist(tk_call_without_enc(*(__item_confinfo_cmd(tagid(tagOrId)) << "-#{slot}")), false, true) + if ( __item_configinfo_struct(tagid(tagOrId))[:default_value] \ + && conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] ) + optval = conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] + begin + val = method.call(tagOrId, optval) + rescue => e + warn("Warning:: #{e.message} (when #{method}.call(#{tagOrId.inspect}, #{optval.inspect})") if $DEBUG + val = optval + end + conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] = val + end + if ( conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] ) + optval = conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] + begin + val = method.call(tagOrId, optval) + rescue => e + warn("Warning:: #{e.message} (when #{method}lcall(#{tagOrId.inspect}, #{optval.inspect})") if $DEBUG + val = optval + end + conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] = val + end + when /^(#{__item_methodcall_optkeys(tagid(tagOrId)).keys.join('|')})$/ method = _symbolkey2str(__item_methodcall_optkeys(tagid(tagOrId)))[slot] return [slot, '', '', '', self.__send__(method, tagOrId)] @@ -411,7 +472,32 @@ module TkItemConfigMethod conf[__item_configinfo_struct(tagid(tagOrId))[:key]] = conf[__item_configinfo_struct(tagid(tagOrId))[:key]][1..-1] - case conf[__item_configinfo_struct(tagid(tagOrId))[:key]] + optkey = conf[__item_configinfo_struct(tagid(tagOrId))[:key]] + case optkey + when /^(#{__item_val2ruby_optkeys(tagid(tagOrId)).keys.join('|')})$/ + method = _symbolkey2str(__item_val2ruby_optkeys(tagid(tagOrId)))[optkey] + if ( __item_configinfo_struct(tagid(tagOrId))[:default_value] \ + && conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] ) + optval = conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] + begin + val = method(tagOrId, optval) + rescue => e + warn("Warning:: #{e.message} (when #{method}.call(#{tagOrId.inspect}, #{optval.inspect})") if $DEBUG + val = optval + end + conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] = val + end + if ( conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] ) + optval = conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] + begin + val = method.call(tagOrId, optval) + rescue => e + warn("Warning:: #{e.message} (when #{method}.call(#{tagOrId.inspect}, #{optval.inspect})") if $DEBUG + val = optval + end + conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] = val + end + when /^(#{__item_strval_optkeys(tagid(tagOrId)).join('|')})$/ # do nothing @@ -583,6 +669,31 @@ module TkItemConfigMethod if slot slot = slot.to_s case slot + when /^(#{__item_val2ruby_optkeys(tagid(tagOrId)).keys.join('|')})$/ + method = _symbolkey2str(__item_val2ruby_optkeys(tagid(tagOrId)))[slot] + conf = tk_split_simplelist(tk_call_without_enc(*(__item_confinfo_cmd(tagid(tagOrId)) << "-#{slot}")), false, true) + if ( __item_configinfo_struct(tagid(tagOrId))[:default_value] \ + && conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] ) + optval = conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] + begin + val = method.call(tagOrId, optval) + rescue => e + warn("Warning:: #{e.message} (when #{method}.call(#{tagOrId.inspect}, #{optval.inspect})") if $DEBUG + val = optval + end + conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] = val + end + if ( conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] ) + optval = conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] + begin + val = method.call(tagOrId, optval) + rescue => e + warn("Warning:: #{e.message} (when #{method}.call(#{tagOrId.inspect}, #{optval.inspect})") if $DEBUG + val = optval + end + conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] = val + end + when /^(#{__item_methodcall_optkeys(tagid(tagOrId)).keys.join('|')})$/ method = _symbolkey2str(__item_methodcall_optkeys(tagid(tagOrId)))[slot] return {slot => ['', '', '', self.__send__(method, tagOrId)]} @@ -727,7 +838,32 @@ module TkItemConfigMethod conf[__item_configinfo_struct(tagid(tagOrId))[:key]] = conf[__item_configinfo_struct(tagid(tagOrId))[:key]][1..-1] - case conf[__item_configinfo_struct(tagid(tagOrId))[:key]] + optkey = conf[__item_configinfo_struct(tagid(tagOrId))[:key]] + case optkey + when /^(#{__item_val2ruby_optkeys(tagid(tagOrId)).keys.join('|')})$/ + method = _symbolkey2str(__item_val2ruby_optkeys(tagid(tagOrId)))[optkey] + if ( __item_configinfo_struct(tagid(tagOrId))[:default_value] \ + && conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] ) + optval = conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] + begin + val = method.call(tagOrId, optval) + rescue => e + warn("Warning:: #{e.message} (when #{method}.call(#{tagOrId.inspect}, #{optval.inspect})") if $DEBUG + val = optval + end + conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] = val + end + if ( conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] ) + optval = conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] + begin + val = method.call(tagOrId, optval) + rescue => e + warn("Warning:: #{e.message} (when #{method}.call(#{tagOrId.inspect}, #{optval.inspect})") if $DEBUG + val = optval + end + conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] = val + end + when /^(#{__item_strval_optkeys(tagid(tagOrId)).join('|')})$/ # do nothing diff --git a/ext/tk/lib/tk/radiobutton.rb b/ext/tk/lib/tk/radiobutton.rb index 6f7a5f60a0..d82aa5d07d 100644 --- a/ext/tk/lib/tk/radiobutton.rb +++ b/ext/tk/lib/tk/radiobutton.rb @@ -17,6 +17,14 @@ class TkRadioButtonproc, ... } + { + 'variable'=>proc{|v| tk_trace_variable(v)} # for backward compatibility + } + end + private :__ruby2val_optkeys + + def deselect tk_send_without_enc('deselect') self diff --git a/ext/tk/lib/tk/spinbox.rb b/ext/tk/lib/tk/spinbox.rb index ac84e06cb3..8941510fed 100644 --- a/ext/tk/lib/tk/spinbox.rb +++ b/ext/tk/lib/tk/spinbox.rb @@ -51,7 +51,7 @@ class TkSpinbox 0 # chars end - super index, *args + super(index, *args) else # single chars-taglist argument :: str, tag, tag, ... if tags.size == 0 - super index, chars + super(index, chars) else - super index, chars, tags.collect{|x|_get_eval_string(x)}.join(' ') + super(index, chars, tags.collect{|x|_get_eval_string(x)}.join(' ')) end end end @@ -476,7 +476,7 @@ class TkText 0 # chars end - super index, *args + super(index, *args) else # single chars-taglist argument :: str, tag, tag, ... if tags.size == 0 - super index, chars + super(index, chars) else - super index, chars, tags.collect{|x|_get_eval_string(x)}.join(' ') + super(index, chars, tags.collect{|x|_get_eval_string(x)}.join(' ')) end end end diff --git a/ext/tk/lib/tkextlib/iwidgets/labeledframe.rb b/ext/tk/lib/tkextlib/iwidgets/labeledframe.rb index 89669ea815..363047018f 100644 --- a/ext/tk/lib/tkextlib/iwidgets/labeledframe.rb +++ b/ext/tk/lib/tkextlib/iwidgets/labeledframe.rb @@ -18,6 +18,11 @@ class Tk::Iwidgets::Labeledframe WidgetClassName = 'Labeledframe'.freeze WidgetClassNames[WidgetClassName] = self + def __tkvariable_optkeys + super() << 'labelvariable' + end + private :__tkvariable_optkeys + def child_site window(tk_call(@path, 'childsite')) end diff --git a/ext/tk/lib/tkextlib/iwidgets/labeledwidget.rb b/ext/tk/lib/tkextlib/iwidgets/labeledwidget.rb index f847922386..cbd5fa0957 100644 --- a/ext/tk/lib/tkextlib/iwidgets/labeledwidget.rb +++ b/ext/tk/lib/tkextlib/iwidgets/labeledwidget.rb @@ -20,6 +20,11 @@ class Tk::Iwidgets::Labeledwidget WidgetClassName = 'Labeledwidget'.freeze WidgetClassNames[WidgetClassName] = self + def __tkvariable_optkeys + super() << 'labelvariable' + end + private :__tkvariable_optkeys + def self.alignlabels(*wins) tk_call('::iwidgets::Labeledwidget::alignlabels', *wins) end diff --git a/ext/tk/lib/tkextlib/iwidgets/menubar.rb b/ext/tk/lib/tkextlib/iwidgets/menubar.rb index b60349be17..ba4bb5f40d 100644 --- a/ext/tk/lib/tkextlib/iwidgets/menubar.rb +++ b/ext/tk/lib/tkextlib/iwidgets/menubar.rb @@ -18,6 +18,11 @@ class Tk::Iwidgets::Menubar WidgetClassName = 'Menubar'.freeze WidgetClassNames[WidgetClassName] = self + def __tkvariable_optkeys + super() << 'helpvariable' + end + private :__tkvariable_optkeys + #################################### include TkItemConfigMethod diff --git a/ext/tk/lib/tkextlib/iwidgets/scrolledlistbox.rb b/ext/tk/lib/tkextlib/iwidgets/scrolledlistbox.rb index a60059f744..c933bf2985 100644 --- a/ext/tk/lib/tkextlib/iwidgets/scrolledlistbox.rb +++ b/ext/tk/lib/tkextlib/iwidgets/scrolledlistbox.rb @@ -19,6 +19,11 @@ class Tk::Iwidgets::Scrolledlistbox WidgetClassName = 'Scrolledlistbox'.freeze WidgetClassNames[WidgetClassName] = self + def __tkvariable_optkeys + super() << 'listvariable' + end + private :__tkvariable_optkeys + ################################ def initialize(*args) diff --git a/ext/tk/lib/tkextlib/iwidgets/spinner.rb b/ext/tk/lib/tkextlib/iwidgets/spinner.rb index 4dac4ed582..174b9bd506 100644 --- a/ext/tk/lib/tkextlib/iwidgets/spinner.rb +++ b/ext/tk/lib/tkextlib/iwidgets/spinner.rb @@ -46,7 +46,7 @@ class Tk::Iwidgets::Spinner end def __validation_class_list - super << EntryfieldValidate + super() << EntryfieldValidate end Tk::ValidateConfigure.__def_validcmd(binding, EntryfieldValidate) diff --git a/ext/tk/lib/tkextlib/iwidgets/toolbar.rb b/ext/tk/lib/tkextlib/iwidgets/toolbar.rb index a2a7f31627..74bb0cc96c 100644 --- a/ext/tk/lib/tkextlib/iwidgets/toolbar.rb +++ b/ext/tk/lib/tkextlib/iwidgets/toolbar.rb @@ -18,6 +18,11 @@ class Tk::Iwidgets::Toolbar WidgetClassName = 'Toolbar'.freeze WidgetClassNames[WidgetClassName] = self + def __tkvariable_optkeys + super() << 'helpvariable' + end + private :__tkvariable_optkeys + #################################### include TkItemConfigMethod diff --git a/ext/tk/lib/tkextlib/tkimg/pixmap.rb b/ext/tk/lib/tkextlib/tkimg/pixmap.rb index 707dcf9c74..bd1b870af7 100644 --- a/ext/tk/lib/tkextlib/tkimg/pixmap.rb +++ b/ext/tk/lib/tkextlib/tkimg/pixmap.rb @@ -39,6 +39,6 @@ class TkPixmapImagelen); #else /* TCL_VERSION >= 8.1 */ VALUE enc = rb_attr_get(str, ID_at_enc); - if (!NIL_P(enc) && strcmp(StringValuePtr(enc), "binary") == 0) { - /* binary string */ - return Tcl_NewByteArrayObj(s, RSTRING(str)->len); + + if (!NIL_P(enc)) { + StringValue(enc); + if (strcmp(RSTRING(enc)->ptr, "binary") == 0) { + /* binary string */ + return Tcl_NewByteArrayObj(s, RSTRING(str)->len); + } else { + /* text string */ + return Tcl_NewStringObj(s, RSTRING(str)->len); + } } else if (strlen(s) != RSTRING(str)->len) { /* probably binary string */ return Tcl_NewByteArrayObj(s, RSTRING(str)->len); @@ -6030,9 +6079,12 @@ lib_fromUTF8_core(ip_obj, src, encodename) if (TYPE(str) == T_STRING) { enc = rb_attr_get(str, ID_at_enc); - if (!NIL_P(enc) && strcmp(StringValuePtr(enc), "binary") == 0) { - rb_thread_critical = thr_crit_bup; - return str; + if (!NIL_P(enc)) { + StringValue(enc); + if (strcmp(RSTRING(enc)->ptr, "binary") == 0) { + rb_thread_critical = thr_crit_bup; + return str; + } } } @@ -7629,6 +7681,14 @@ Init_tcltklib() eLocalJumpError = rb_const_get(rb_cObject, rb_intern("LocalJumpError")); + eTkLocalJumpError = rb_define_class("TkLocalJumpError", eLocalJumpError); + + eTkCallbackRetry = rb_define_class("TkCallbackRetry", eTkLocalJumpError); + eTkCallbackRedo = rb_define_class("TkCallbackRedo", eTkLocalJumpError); + eTkCallbackThrow = rb_define_class("TkCallbackThrow", eTkLocalJumpError); + + /* --------------------------------------------------------------- */ + ID_at_enc = rb_intern("@encoding"); ID_at_interp = rb_intern("@interp"); -- cgit v1.2.3