summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog22
-rw-r--r--ext/tk/lib/tk.rb26
-rw-r--r--ext/tk/lib/tk/font.rb8
-rw-r--r--ext/tk/lib/tk/itemconfig.rb16
-rw-r--r--ext/tk/lib/tk/itemfont.rb24
-rw-r--r--ext/tk/lib/tk/text.rb8
-rw-r--r--ext/tk/lib/tk/timer.rb38
-rw-r--r--ext/tk/lib/tk/toplevel.rb2
-rw-r--r--ext/tk/lib/tkextlib/iwidgets/scrolledcanvas.rb2
-rw-r--r--ext/tk/lib/tkextlib/iwidgets/scrolledlistbox.rb2
-rw-r--r--ext/tk/lib/tkextlib/iwidgets/scrolledtext.rb2
-rw-r--r--ext/tk/lib/tkextlib/tile/tpaned.rb18
-rw-r--r--ext/tk/lib/tkextlib/version.rb2
-rw-r--r--ext/tk/sample/tktextio.rb12
-rw-r--r--ext/tk/sample/ttk_wrapper.rb18
15 files changed, 161 insertions, 39 deletions
diff --git a/ChangeLog b/ChangeLog
index 248c9db2cc..29372eea84 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,25 @@
+Tue Apr 15 00:15:29 2008 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
+
+ * 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.
+
Mon Apr 14 19:54:21 2008 Akinori MUSHA <knu@iDaemons.org>
* array.c (rb_ary_flatten, rb_ary_flatten_bang): Take an optional
diff --git a/ext/tk/lib/tk.rb b/ext/tk/lib/tk.rb
index 81df3cbf43..5f6bb2dbc1 100644
--- a/ext/tk/lib/tk.rb
+++ b/ext/tk/lib/tk.rb
@@ -3217,7 +3217,13 @@ module TkTreatFont
next
else
fnt = hash_kv(fnt) if fnt.kind_of?(Hash)
- tk_call(*(__config_cmd << "-#{optkey}" << fnt))
+ begin
+ tk_call(*(__config_cmd << "-#{optkey}" << fnt))
+ rescue => e
+ unless TkConfigMethod.__IGNORE_UNKNOWN_CONFIGURE_OPTION__
+ fail e
+ end
+ end
end
end
next
@@ -3271,7 +3277,13 @@ module TkTreatFont
fobj = fontobj # create a new TkFont object
else
ltn = hash_kv(ltn) if ltn.kind_of?(Hash)
- tk_call(*(__config_cmd << "-#{optkey}" << ltn))
+ begin
+ tk_call(*(__config_cmd << "-#{optkey}" << ltn))
+ rescue => e
+ unless TkConfigMethod.__IGNORE_UNKNOWN_CONFIGURE_OPTION__
+ fail e
+ end
+ end
next
end
@@ -3323,7 +3335,13 @@ module TkTreatFont
fobj = fontobj # create a new TkFont object
else
knj = hash_kv(knj) if knj.kind_of?(Hash)
- tk_call(*(__config_cmd << "-#{optkey}" << knj))
+ begin
+ tk_call(*(__config_cmd << "-#{optkey}" << knj))
+ rescue => e
+ unless TkConfigMethod.__IGNORE_UNKNOWN_CONFIGURE_OPTION__
+ fail e
+ end
+ end
next
end
@@ -5323,7 +5341,7 @@ TkWidget = TkWindow
#Tk.freeze
module Tk
- RELEASE_DATE = '2008-04-02'.freeze
+ RELEASE_DATE = '2008-04-13'.freeze
autoload :AUTO_PATH, 'tk/variable'
autoload :TCL_PACKAGE_PATH, 'tk/variable'
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)
diff --git a/ext/tk/lib/tkextlib/iwidgets/scrolledcanvas.rb b/ext/tk/lib/tkextlib/iwidgets/scrolledcanvas.rb
index b07602e340..67ad67d07e 100644
--- a/ext/tk/lib/tkextlib/iwidgets/scrolledcanvas.rb
+++ b/ext/tk/lib/tkextlib/iwidgets/scrolledcanvas.rb
@@ -37,7 +37,7 @@ class Tk::Iwidgets::Scrolledcanvas
end
def method_missing(id, *args)
- if @canvas.methods.include?(id.id2name)
+ if @canvas.respond_to?(id)
@canvas.__send__(id, *args)
else
super(id, *args)
diff --git a/ext/tk/lib/tkextlib/iwidgets/scrolledlistbox.rb b/ext/tk/lib/tkextlib/iwidgets/scrolledlistbox.rb
index cd1f6f0f79..7543d557e3 100644
--- a/ext/tk/lib/tkextlib/iwidgets/scrolledlistbox.rb
+++ b/ext/tk/lib/tkextlib/iwidgets/scrolledlistbox.rb
@@ -42,7 +42,7 @@ class Tk::Iwidgets::Scrolledlistbox
end
def method_missing(id, *args)
- if @listbox.methods.include?(id.id2name)
+ if @listbox.respond_to?(id)
@listbox.__send__(id, *args)
else
super(id, *args)
diff --git a/ext/tk/lib/tkextlib/iwidgets/scrolledtext.rb b/ext/tk/lib/tkextlib/iwidgets/scrolledtext.rb
index 2887b60815..d85f232b37 100644
--- a/ext/tk/lib/tkextlib/iwidgets/scrolledtext.rb
+++ b/ext/tk/lib/tkextlib/iwidgets/scrolledtext.rb
@@ -37,7 +37,7 @@ class Tk::Iwidgets::Scrolledtext
end
def method_missing(id, *args)
- if @text.methods.include?(id.id2name)
+ if @text.respond_to?(id)
@text.__send__(id, *args)
else
super(id, *args)
diff --git a/ext/tk/lib/tkextlib/tile/tpaned.rb b/ext/tk/lib/tkextlib/tile/tpaned.rb
index 342b54d253..f24b12e92e 100644
--- a/ext/tk/lib/tkextlib/tile/tpaned.rb
+++ b/ext/tk/lib/tkextlib/tile/tpaned.rb
@@ -36,9 +36,21 @@ class Tk::Tile::TPaned < TkWindow
[self::WidgetClassName, *(args.map!{|a| _get_eval_string(a)})].join('.')
end
- def add(win, keys)
- win = _epath(win)
- tk_send_without_enc('add', win, *hash_kv(keys))
+ def add(*args)
+ keys = args.pop
+ fail ArgumentError, "no window in arguments" unless keys
+
+ if keys && keys.kind_of?(Hash)
+ fail ArgumentError, "no window in arguments" if args == []
+ opts = hash_kv(keys)
+ else
+ args.push(keys) if keys
+ opts = []
+ end
+
+ args.each{|win|
+ tk_send_without_enc('add', _epath(win), *opts)
+ }
self
end
diff --git a/ext/tk/lib/tkextlib/version.rb b/ext/tk/lib/tkextlib/version.rb
index 3542c79dbe..0fc1136e53 100644
--- a/ext/tk/lib/tkextlib/version.rb
+++ b/ext/tk/lib/tkextlib/version.rb
@@ -2,5 +2,5 @@
# release date of tkextlib
#
module Tk
- Tkextlib_RELEASE_DATE = '2008-03-29'.freeze
+ Tkextlib_RELEASE_DATE = '2008-04-14'.freeze
end
diff --git a/ext/tk/sample/tktextio.rb b/ext/tk/sample/tktextio.rb
index 4573bcebdf..9f012feada 100644
--- a/ext/tk/sample/tktextio.rb
+++ b/ext/tk/sample/tktextio.rb
@@ -254,7 +254,15 @@ class TkTextIO < TkText
Tk.callback_break
end
end
- private :_cb_up, :_cb_down, :_cb_left, :_cb_backspace, :_cb_ctrl_a
+ def _cb_ctrl_u
+ if @console_mode
+ mark_set('insert', @ins_head)
+ delete('insert', 'insert lineend')
+ Tk.callback_break
+ end
+ end
+ private :_cb_up, :_cb_down, :_cb_left, :_cb_backspace,
+ :_cb_ctrl_a, :_cb_ctrl_u
def _setup_console_bindings
@bindtag = TkBindTag.new
@@ -328,6 +336,8 @@ class TkTextIO < TkText
@bindtag.bind('Home'){ _cb_ctrl_a }
@bindtag.bind('Control-a'){ _cb_ctrl_a }
+
+ @bindtag.bind('Control-u'){ _cb_ctrl_u }
end
private :_setup_console_bindings
diff --git a/ext/tk/sample/ttk_wrapper.rb b/ext/tk/sample/ttk_wrapper.rb
index ddae24019f..4a4491b5bd 100644
--- a/ext/tk/sample/ttk_wrapper.rb
+++ b/ext/tk/sample/ttk_wrapper.rb
@@ -52,6 +52,15 @@ end
##########################################################################
+# define Tcl/Tk procedures for compatibility.
+# those are required when want to use themes included
+# in "sample/tkextlib/tile/demo.rb".
+##########################################################################
+Tk::Tile.__define_LoadImages_proc_for_compatibility__!
+Tk::Tile::Style.__define_wrapper_proc_for_compatibility__!
+
+
+##########################################################################
# use themes defined on the demo of Ttk (Tile) extension
##########################################################################
demodir = File.dirname(__FILE__)
@@ -92,15 +101,6 @@ themes_by_ruby.each{|f|
##########################################################################
-# define Tcl/Tk procedures for compatibility.
-# those are required when want to use themes included
-# in "sample/tkextlib/tile/demo.rb".
-##########################################################################
-Tk::Tile.__define_LoadImages_proc_for_compatibility__!
-Tk::Tile::Style.__define_wrapper_proc_for_compatibility__!
-
-
-##########################################################################
# ignore unsupported options of Ttk widgets
##########################################################################
TkConfigMethod.__set_IGNORE_UNKNOWN_CONFIGURE_OPTION__! true