diff options
| author | nagai <nagai@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2003-07-01 22:08:19 +0000 |
|---|---|---|
| committer | nagai <nagai@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2003-07-01 22:08:19 +0000 |
| commit | abe26307ca356ff31192d8e9434970b2fdf51123 (patch) | |
| tree | 267471cf841b06e6fb0b3d779f32440235ac3761 | |
| parent | f309a270ba0d00b520689858945ac35f23f4d216 (diff) | |
| download | ruby-abe26307ca356ff31192d8e9434970b2fdf51123.tar.gz ruby-abe26307ca356ff31192d8e9434970b2fdf51123.tar.xz ruby-abe26307ca356ff31192d8e9434970b2fdf51123.zip | |
tk.rb :
* TkWindow include TkWinfo
* treat unknown widget classes as subclasses of TkWindow
git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@4024 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
| -rw-r--r-- | ext/tcltklib/tcltklib.c | 2 | ||||
| -rw-r--r-- | ext/tk/lib/tk.rb | 32 |
2 files changed, 24 insertions, 10 deletions
diff --git a/ext/tcltklib/tcltklib.c b/ext/tcltklib/tcltklib.c index b99b4e94a..72ca93342 100644 --- a/ext/tcltklib/tcltklib.c +++ b/ext/tcltklib/tcltklib.c @@ -607,7 +607,7 @@ ip_init(self) } DUMP1("Tk_Init"); if (Tk_Init(ptr->ip) == TCL_ERROR) { - rb_raise(rb_eRuntimeError, "%s", ptr->ip->result); + rb_raise(rb_eRuntimeError, "%s", ptr->ip->result); } DUMP1("Tcl_StaticPackage(\"Tk\")"); #if TCL_MAJOR_VERSION >= 8 diff --git a/ext/tk/lib/tk.rb b/ext/tk/lib/tk.rb index 74821f41c..3c399a24a 100644 --- a/ext/tk/lib/tk.rb +++ b/ext/tk/lib/tk.rb @@ -62,19 +62,32 @@ module TkComm return path end - ruby_class = WidgetClassNames[tk_class] - gen_class_name = ruby_class.name + 'GeneratedOnTk' + if ruby_class = WidgetClassNames[tk_class] + ruby_class_name = ruby_class.name + gen_class_name = ruby_class_name + 'GeneratedOnTk' + classname_def = '' + elsif Object.const_defined?('Tk' + tk_class) + ruby_class_name = 'Tk' + tk_class + gen_class_name = ruby_class_name + 'GeneratedOnTk' + classname_def = '' + else + ruby_class_name = 'TkWindow' + gen_class_name = ruby_class_name + tk_class + 'GeneratedOnTk' + classname_def = "WidgetClassName = '#{tk_class}'.freeze" + end unless Object.const_defined? gen_class_name - eval "class #{gen_class_name}<#{ruby_class.name} - def initialize(path) - @path=path - Tk_WINDOWS[@path] = self - end - end" + Object.class_eval "class #{gen_class_name}<#{ruby_class_name} + #{classname_def} + def initialize(path) + @path=path + Tk_WINDOWS[@path] = self + end + end" end - eval "#{gen_class_name}.new('#{path}')" + Object.class_eval "#{gen_class_name}.new('#{path}')" end private :_genobj_for_tkwidget + module_function :_genobj_for_tkwidget def tk_tcl2ruby(val) if val =~ /^rb_out (c\d+)/ @@ -3224,6 +3237,7 @@ class TkObject<TkKernel end class TkWindow<TkObject + include TkWinfo extend TkBindCore WidgetClassName = ''.freeze |
