mirror of
https://github.com/ruby/ruby.git
synced 2025-09-17 09:33:59 +02:00
* ext/tk/tcltklib.c (ip_make_menu_embeddable): help to make a menu
widget embeddable (pack, grid, and so on) like as a general widget. However, an embeddable menu may require to be definied some event bindings for general use. * ext/tk/lib/tk/event.rb: [bug fix] Tk.callback_break and Tk.callback_continue don't work on MultiTkIp. * ext/tk/lib/multi-tk.rb: ditto. * ext/tk/lib/tk.rb: lack of Tk.callback_return. * ext/tk/lib/tk/menu.rb: improve creating clone menus. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@10461 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
c6956e0d72
commit
c47bf50af7
6 changed files with 317 additions and 11 deletions
|
@ -158,7 +158,9 @@ class MultiTkIp
|
|||
backup_ip = current['callback_ip']
|
||||
current['callback_ip'] = @ip
|
||||
begin
|
||||
@ip.cb_eval(@cmd, *args)
|
||||
ret = @ip.cb_eval(@cmd, *args)
|
||||
fail ret if ret.kind_of?(Exception)
|
||||
ret
|
||||
rescue TkCallbackBreak, TkCallbackContinue => e
|
||||
fail e
|
||||
rescue SecurityError => e
|
||||
|
@ -175,6 +177,8 @@ class MultiTkIp
|
|||
fail e
|
||||
end
|
||||
rescue Exception => e
|
||||
fail e if e.message =~ /^TkCallback/
|
||||
|
||||
if @ip.safe?
|
||||
if @ip.respond_to?(:cb_error)
|
||||
@ip.cb_error(e)
|
||||
|
@ -662,6 +666,8 @@ class MultiTkIp
|
|||
@interp = TclTkIp.new(name, _keys2opts(keys))
|
||||
@ip_name = nil
|
||||
|
||||
@callback_status = [].taint
|
||||
|
||||
@system = Object.new
|
||||
|
||||
@wait_on_mainloop = [true, 0].taint
|
||||
|
@ -1057,6 +1063,8 @@ class MultiTkIp
|
|||
@cb_error_proc.taint unless @cb_error_proc.tainted?
|
||||
@evloop_thread.taint unless @evloop_thread.tainted?
|
||||
|
||||
@callback_status = []
|
||||
|
||||
name, safe, safe_opts, tk_opts = _parse_slaveopts(keys)
|
||||
|
||||
safe = 4 if safe && !safe.kind_of?(Fixnum)
|
||||
|
@ -1487,6 +1495,7 @@ class MultiTkIp
|
|||
@@CB_ENTRY_CLASS.new(__getip, cmd).freeze
|
||||
end
|
||||
|
||||
=begin
|
||||
def cb_eval(cmd, *args)
|
||||
#self.eval_callback{ TkComm._get_eval_string(TkUtil.eval_cmd(cmd, *args)) }
|
||||
#ret = self.eval_callback{ TkComm._get_eval_string(TkUtil.eval_cmd(cmd, *args)) }
|
||||
|
@ -1499,8 +1508,62 @@ class MultiTkIp
|
|||
end
|
||||
ret
|
||||
end
|
||||
end
|
||||
=end
|
||||
def cb_eval(cmd, *args)
|
||||
self.eval_callback(*args){|safe, *params|
|
||||
$SAFE=safe if $SAFE < safe
|
||||
# TkUtil.eval_cmd(cmd, *params)
|
||||
TkComm._get_eval_string(TkUtil.eval_cmd(cmd, *params))
|
||||
}
|
||||
end
|
||||
=begin
|
||||
def cb_eval(cmd, *args)
|
||||
@callback_status[0] ||= TkVariable.new
|
||||
@callback_status[1] ||= TkVariable.new
|
||||
st, val = @callback_status
|
||||
th = Thread.new{
|
||||
self.eval_callback(*args){|safe, *params|
|
||||
#p [status, val, safe, *params]
|
||||
$SAFE=safe if $SAFE < safe
|
||||
begin
|
||||
TkComm._get_eval_string(TkUtil.eval_cmd(cmd, *params))
|
||||
rescue TkCallbackContinue
|
||||
st.value = 4
|
||||
rescue TkCallbackBreak
|
||||
st.value = 3
|
||||
rescue TkCallbackReturn
|
||||
st.value = 2
|
||||
rescue Exception => e
|
||||
val.value = e.message
|
||||
st.value = 1
|
||||
else
|
||||
st.value = 0
|
||||
end
|
||||
}
|
||||
}
|
||||
begin
|
||||
st.wait
|
||||
status = st.numeric
|
||||
retval = val.value
|
||||
rescue => e
|
||||
fail e
|
||||
end
|
||||
|
||||
if status == 1
|
||||
fail RuntimeError, retval
|
||||
elsif status == 2
|
||||
fail TkCallbackReturn, "Tk callback returns 'return' status"
|
||||
elsif status == 3
|
||||
fail TkCallbackBreak, "Tk callback returns 'break' status"
|
||||
elsif status == 4
|
||||
fail TkCallbackContinue, "Tk callback returns 'continue' status"
|
||||
else
|
||||
''
|
||||
end
|
||||
end
|
||||
=end
|
||||
|
||||
end
|
||||
|
||||
# evaluate a procedure on the proper interpreter
|
||||
class MultiTkIp
|
||||
|
@ -1969,6 +2032,10 @@ class << MultiTkIp
|
|||
__getip._unset_global_var2(var, idx)
|
||||
end
|
||||
|
||||
def _make_menu_embeddable(menu_path)
|
||||
__getip._make_menu_embeddable(menu_path)
|
||||
end
|
||||
|
||||
def _split_tklist(str)
|
||||
__getip._split_tklist(str)
|
||||
end
|
||||
|
@ -2410,6 +2477,11 @@ class MultiTkIp
|
|||
@interp._unset_global_var2(var, idx)
|
||||
end
|
||||
|
||||
def _make_menu_embeddable(menu_path)
|
||||
raise SecurityError, "no permission to manipulate" unless self.manipulable?
|
||||
@interp._make_menu_embeddable(menu_path)
|
||||
end
|
||||
|
||||
def _split_tklist(str)
|
||||
raise SecurityError, "no permission to manipulate" unless self.manipulable?
|
||||
@interp._split_tklist(str)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue