diff options
author | nagai <nagai@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-04-14 15:17:52 +0000 |
---|---|---|
committer | nagai <nagai@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-04-14 15:17:52 +0000 |
commit | 9126130c4a6225e8f9dd50252acbe5cdfa9129b7 (patch) | |
tree | b883671eefc3bdc0726484fd14b9ccc3e4cba1ea /ext/tk/lib/tk | |
parent | 15b2474e19b5c0f4482ff9322c60bb8a79101e2a (diff) |
* ext/tk/lib/tk/text.rb: typo. call a wrong method.
* ext/tk/lib/tk/itemconfig.rb: ditto.
* ext/tk/sample/ttk_wrapper.rb: bug fix.
* ext/tk/sample/tktextio.rb: add binding for 'Ctrl-u' at console mode.
* ext/tk/lib/tk.rb, ext/tk/lib/tk/itemfont.rb, ext/tk/lib/font.rb:
support __IGNORE_UNKNOWN_CONFIGURE_OPTION__ about font options.
* ext/tk/lib/tkextlib/iwidgets/scrolledcanvas.rb,
ext/tk/lib/tkextlib/iwidgets/scrolledlistbox.rb,
ext/tk/lib/tkextlib/iwidgets/scrolledtext.rb: bug fix.
* ext/tk/lib/tkextlib/tile/tpaned.rb: improve TPaned#add.
* ext/tk/lib/tk/timer.rb: add TkTimer#at_end(proc) to register the
procedure which called at end of the timer.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@16020 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/tk/lib/tk')
-rw-r--r-- | ext/tk/lib/tk/font.rb | 8 | ||||
-rw-r--r-- | ext/tk/lib/tk/itemconfig.rb | 16 | ||||
-rw-r--r-- | ext/tk/lib/tk/itemfont.rb | 24 | ||||
-rw-r--r-- | ext/tk/lib/tk/text.rb | 8 | ||||
-rw-r--r-- | ext/tk/lib/tk/timer.rb | 38 | ||||
-rw-r--r-- | ext/tk/lib/tk/toplevel.rb | 2 |
6 files changed, 78 insertions, 18 deletions
diff --git a/ext/tk/lib/tk/font.rb b/ext/tk/lib/tk/font.rb index 4641d8a640..62d628c132 100644 --- a/ext/tk/lib/tk/font.rb +++ b/ext/tk/lib/tk/font.rb @@ -1056,7 +1056,13 @@ class TkFont keys = _symbolkey2str(args.pop).update(fontslot) args.concat(hash_kv(keys)) - tk_call(*args) + begin + tk_call(*args) + rescue => e + unless TkConfigMethod.__IGNORE_UNKNOWN_CONFIGURE_OPTION__ + fail e + end + end Tk_FontUseTBL.mutex.synchronize{ Tk_FontUseTBL[[win, tag, optkey].join(';')] = self } diff --git a/ext/tk/lib/tk/itemconfig.rb b/ext/tk/lib/tk/itemconfig.rb index dbc45a9e7c..abff676d78 100644 --- a/ext/tk/lib/tk/itemconfig.rb +++ b/ext/tk/lib/tk/itemconfig.rb @@ -242,7 +242,7 @@ module TkItemConfigMethod __itemcget_core(tagOrId, option) rescue => e begin - __itemconfiginfo_core(tagOrId) + __itemcget_core(tagOrId) # not tag error -> option is unknown nil rescue @@ -319,7 +319,8 @@ module TkItemConfigMethod def __check_available_itemconfigure_options(tagOrId, keys) id = tagid(tagOrId) - availables = self.current_itemconfiginfo(id).keys + + availables = self.__current_itemconfiginfo(id).keys # add non-standard keys availables |= __font_optkeys.map{|k| @@ -329,6 +330,7 @@ module TkItemConfigMethod availables |= __item_keyonly_optkeys(id).keys.map{|k| k.to_s} keys = _symbolkey2str(keys) + keys.delete_if{|k, v| !(availables.include?(k))} end @@ -340,7 +342,7 @@ module TkItemConfigMethod begin __itemconfigure_core(tagOrId, slot) rescue - slot = __check_available_configure_options(tagOrId, slot) + slot = __check_available_itemconfigure_options(tagOrId, slot) __itemconfigure_core(tagOrId, slot) unless slot.empty? end else @@ -349,6 +351,7 @@ module TkItemConfigMethod rescue => e begin __itemconfiginfo_core(tagOrId) + # not tag error -> option is unknown rescue fail e # tag error end @@ -1125,7 +1128,7 @@ module TkItemConfigMethod end end - def current_itemconfiginfo(tagOrId, slot = nil) + def __current_itemconfiginfo(tagOrId, slot = nil) if TkComm::GET_CONFIGINFO_AS_ARRAY if slot org_slot = slot @@ -1147,6 +1150,7 @@ module TkItemConfigMethod ret[conf[0]] = conf[-1] end } + ret end else # ! TkComm::GET_CONFIGINFO_AS_ARRAY @@ -1157,4 +1161,8 @@ module TkItemConfigMethod ret end end + + def current_itemconfiginfo(tagOrId, slot = nil) + __current_itemconfiginfo(tagOrId, slot) + end end diff --git a/ext/tk/lib/tk/itemfont.rb b/ext/tk/lib/tk/itemfont.rb index ab9e3ff6c9..11d443b597 100644 --- a/ext/tk/lib/tk/itemfont.rb +++ b/ext/tk/lib/tk/itemfont.rb @@ -94,7 +94,13 @@ module TkTreatItemFont *(__item_config_cmd(tagid(tagOrId)) << {})) next else - tk_call(*(__item_config_cmd(tagid(tagOrId)) << "-#{optkey}" << fnt)) + begin + tk_call(*(__item_config_cmd(tagid(tagOrId)) << "-#{optkey}" << fnt)) + rescue => e + unless TkConfigMethod.__IGNORE_UNKNOWN_CONFIGURE_OPTION__ + fail e + end + end end end next @@ -147,7 +153,13 @@ module TkTreatItemFont elsif Tk::JAPANIZED_TK fobj = fontobj # create a new TkFont object else - tk_call(*(__item_config_cmd(tagid(tagOrId)) << "-#{optkey}" << ltn)) + begin + tk_call(*(__item_config_cmd(tagid(tagOrId)) << "-#{optkey}" << ltn)) + rescue => e + unless TkConfigMethod.__IGNORE_UNKNOWN_CONFIGURE_OPTION__ + fail e + end + end next end @@ -198,7 +210,13 @@ module TkTreatItemFont elsif Tk::JAPANIZED_TK fobj = fontobj # create a new TkFont object else - tk_call(*(__item_config_cmd(tagid(tagOrId)) << "-#{optkey}" << knj)) + begin + tk_call(*(__item_config_cmd(tagid(tagOrId)) << "-#{optkey}" << knj)) + rescue => e + unless TkConfigMethod.__IGNORE_UNKNOWN_CONFIGURE_OPTION__ + fail e + end + end next end diff --git a/ext/tk/lib/tk/text.rb b/ext/tk/lib/tk/text.rb index 14b9be23f0..a4c63c70a3 100644 --- a/ext/tk/lib/tk/text.rb +++ b/ext/tk/lib/tk/text.rb @@ -36,10 +36,10 @@ module TkTextTagConfig itemconfigure(['tag', tagOrId], slot, value) end def tag_configinfo(tagOrId, slot=nil) - itemconfigure(['tag', tagOrId], slot) + itemconfiginfo(['tag', tagOrId], slot) end def current_tag_configinfo(tagOrId, slot=nil) - itemconfigure(['tag', tagOrId], slot) + current_itemconfiginfo(['tag', tagOrId], slot) end def window_cget(tagOrId, option) @@ -49,10 +49,10 @@ module TkTextTagConfig itemconfigure(['window', tagOrId], slot, value) end def window_configinfo(tagOrId, slot=nil) - itemconfigure(['window', tagOrId], slot) + itemconfiginfo(['window', tagOrId], slot) end def current_window_configinfo(tagOrId, slot=nil) - itemconfigure(['window', tagOrId], slot) + current_itemconfiginfo(['window', tagOrId], slot) end private :itemcget, :itemconfigure diff --git a/ext/tk/lib/tk/timer.rb b/ext/tk/lib/tk/timer.rb index 3588f0c480..91840d0575 100644 --- a/ext/tk/lib/tk/timer.rb +++ b/ext/tk/lib/tk/timer.rb @@ -111,7 +111,8 @@ class TkTimer if @running == false || @proc_max == 0 || @do_loop == 0 Tk_CBTBL.delete(@id) ;# for GC @running = false - @wait_var.value = 0 + # @wait_var.value = 0 + __at_end__ return end if @current_pos >= @proc_max @@ -120,7 +121,8 @@ class TkTimer else Tk_CBTBL.delete(@id) ;# for GC @running = false - @wait_var.value = 0 + # @wait_var.value = 0 + __at_end__ return end end @@ -151,6 +153,8 @@ class TkTimer @wait_var = TkVariable.new(0) + @at_end_proc = nil + @cb_cmd = TkCore::INTERP.get_cb_entry(self.method(:do_callback)) @set_next = true @@ -210,6 +214,12 @@ class TkTimer attr_accessor :loop_exec + def __at_end__ + @at_end_proc.call(self) if @at_end_proc + @wait_var.value = 0 # for wait + end + private :__at_end__ + def cb_call @cb_cmd.call end @@ -427,7 +437,8 @@ class TkTimer def cancel @running = false - @wait_var.value = 0 + # @wait_var.value = 0 + __at_end__ tk_call 'after', 'cancel', @after_id if @after_id @after_id = nil @@ -471,6 +482,21 @@ class TkTimer end end + def at_end(*arg, &b) + if arg.empty? + if b + @at_end_proc = b + else + # no proc + return @at_end_proc + end + else + fail ArgumentError, "wrong number of arguments" if arg.length != 1 || b + @at_end_proc = arg[0] + end + self + end + def wait(on_thread = true, check_root = false) if $SAFE >= 4 fail SecurityError, "can't wait timer at $SAFE >= 4" @@ -569,7 +595,8 @@ class TkRTTimer < TkTimer if @running == false || @proc_max == 0 || @do_loop == 0 Tk_CBTBL.delete(@id) ;# for GC @running = false - @wait_var.value = 0 + # @wait_var.value = 0 + __at_end__ return end if @current_pos >= @proc_max @@ -578,7 +605,8 @@ class TkRTTimer < TkTimer else Tk_CBTBL.delete(@id) ;# for GC @running = false - @wait_var.value = 0 + # @wait_var.value = 0 + __at_end__ return end end diff --git a/ext/tk/lib/tk/toplevel.rb b/ext/tk/lib/tk/toplevel.rb index 2d99eda44c..bd6e8307f5 100644 --- a/ext/tk/lib/tk/toplevel.rb +++ b/ext/tk/lib/tk/toplevel.rb @@ -72,7 +72,7 @@ class Tk::Toplevel<TkWindow conf_methods = _symbolkey2str(__methodcall_optkeys()) - keys.each{|k,v| + keys.each{|k,v| # k is a String if conf_methods.key?(k) wm_cmds[conf_methods[k]] = v elsif Wm.method_defined?(k) |