1998-01-16 15:19:09 +03:00
|
|
|
/*
|
|
|
|
* tcltklib.c
|
|
|
|
* Aug. 27, 1997 Y. Shigehiro
|
|
|
|
* Oct. 24, 1997 Y. Matsumoto
|
|
|
|
*/
|
|
|
|
|
2000-07-06 11:21:26 +04:00
|
|
|
#include "ruby.h"
|
|
|
|
#include "rubysig.h"
|
|
|
|
#undef EXTERN /* avoid conflict with tcl.h of tcl8.2 or before */
|
1998-01-16 15:19:09 +03:00
|
|
|
#include <stdio.h>
|
2003-08-29 12:34:14 +04:00
|
|
|
#ifdef HAVE_STDARG_PROTOTYPES
|
|
|
|
#include <stdarg.h>
|
|
|
|
#define va_init_list(a,b) va_start(a,b)
|
|
|
|
#else
|
|
|
|
#include <varargs.h>
|
|
|
|
#define va_init_list(a,b) va_start(a)
|
|
|
|
#endif
|
1998-01-16 15:19:09 +03:00
|
|
|
#include <string.h>
|
|
|
|
#include <tcl.h>
|
|
|
|
#include <tk.h>
|
|
|
|
|
1999-01-20 07:59:39 +03:00
|
|
|
#ifdef __MACOS__
|
|
|
|
# include <tkMac.h>
|
|
|
|
# include <Quickdraw.h>
|
|
|
|
#endif
|
1998-01-16 15:19:09 +03:00
|
|
|
|
2003-10-29 14:03:54 +03:00
|
|
|
#if TCL_MAJOR_VERSION >= 8
|
|
|
|
# ifndef CONST84
|
|
|
|
# if TCL_MAJOR_VERSION == 8 && TCL_MINOR_VERSION <= 4 /* Tcl8.0.x -- 8.4b1 */
|
|
|
|
# define CONST84
|
|
|
|
# else /* unknown (maybe TCL_VERSION >= 8.5) */
|
|
|
|
# ifdef CONST
|
|
|
|
# define CONST84 CONST
|
|
|
|
# else
|
|
|
|
# define CONST84
|
|
|
|
# endif
|
|
|
|
# endif
|
|
|
|
# endif
|
|
|
|
#endif
|
|
|
|
|
1999-08-13 09:37:52 +04:00
|
|
|
/* for ruby_debug */
|
1999-01-20 07:59:39 +03:00
|
|
|
|
1999-08-13 09:37:52 +04:00
|
|
|
#define DUMP1(ARG1) if (ruby_debug) { fprintf(stderr, "tcltklib: %s\n", ARG1);}
|
|
|
|
#define DUMP2(ARG1, ARG2) if (ruby_debug) { fprintf(stderr, "tcltklib: ");\
|
1998-01-16 15:19:09 +03:00
|
|
|
fprintf(stderr, ARG1, ARG2); fprintf(stderr, "\n"); }
|
|
|
|
/*
|
|
|
|
#define DUMP1(ARG1)
|
|
|
|
#define DUMP2(ARG1, ARG2)
|
|
|
|
*/
|
|
|
|
|
1999-01-20 07:59:39 +03:00
|
|
|
/* for callback break & continue */
|
1999-08-13 09:37:52 +04:00
|
|
|
static VALUE eTkCallbackBreak;
|
|
|
|
static VALUE eTkCallbackContinue;
|
|
|
|
|
|
|
|
static VALUE ip_invoke_real _((int, VALUE*, VALUE));
|
2003-10-14 19:25:45 +04:00
|
|
|
static VALUE ip_invoke _((int, VALUE*, VALUE));
|
1999-01-20 07:59:39 +03:00
|
|
|
|
1998-01-16 15:19:09 +03:00
|
|
|
/* from tkAppInit.c */
|
|
|
|
|
2000-05-13 20:13:31 +04:00
|
|
|
#if !defined __MINGW32__
|
1998-01-16 15:19:09 +03:00
|
|
|
/*
|
|
|
|
* The following variable is a special hack that is needed in order for
|
|
|
|
* Sun shared libraries to be used for Tcl.
|
|
|
|
*/
|
|
|
|
|
|
|
|
extern int matherr();
|
|
|
|
int *tclDummyMathPtr = (int *) matherr;
|
2000-05-13 20:13:31 +04:00
|
|
|
#endif
|
1998-01-16 15:19:09 +03:00
|
|
|
|
|
|
|
/*---- module TclTkLib ----*/
|
|
|
|
|
1999-08-13 09:37:52 +04:00
|
|
|
struct invoke_queue {
|
* tkfont.rb: Fix bugs on TkFont.init_widget_font for Tk8.x.
* tkafter.rb: Add self to 1st argument of interval- and loop-proc
TkAfter#current_interval returns an interval (sleep) time value
TkAfter#current_args returns an array of arguments
TkAfter#return_value returns a return value of last loop-proc
e.g.
TkAfter.new(
proc{|obj| 500 - obj.current_interval}, 10,
[proc{|obj| p obj.current_args}, 'proc', 1],
proc{|obj| p obj.current_args; ['return', 2]},
[proc{|obj|
p obj.return_value
p ['proc', obj.current_args[0].call(obj.return_value[1],
obj.current_args[1])]},
proc{|*args| args[0] + args[1]}, 1],
proc{p ['proc', 4]} ).start(100)
* tk*.rb: Allow to use Symbols for parameters.
Allow new notation of constructor (also allow old notation).
e.g.
TkFrame.new('classname'=>'User'){|base|
pack
f = TkFrame.new(base, :classname=>'ButtonFrame').pack
TkButton.new(
:parent => f,
:text => 'Quit',
:command => proc{exit}
).pack(
:fill => :x,
:pady => 2
)
}
* tkcanvas.rb: (TkcItem) Add 'coords' parameter to the canvas item
constructor (for new notation of constructor).
e.g.
c = TkCanvas.new.pack
l = TkcLine.new(c, :coords=>[[0,0], [100,100]])
* tcltklib.c: New 'mainloop' and 'mainloop_watchdog'.
The priority of their event-loop can be controlled.
They accept an optional argument.
If it false, they don't exit although the root widget is destroyed.
This function is sometimes useful, if it is used with 'restart'.
'mainloop' can't treat Thread#join/value in a callback routine.
(e.g. TkButton.new(:command=>proc{p Thread.new{button.invoke}.value}) )
'mainloop_watchdog' can treat them, but watchdog thread is always running
(so, a little heavier than 'mainloop').
If the purpose of using Thread#join/value is to do something under some
safe-level, please use Proc object.
(e.g. :command=>proc{$SAFE=1;proc{$SAFE=2;button.invoke}.call;p $SAFE})
* tk.rb: Support functions of new 'mainloop' and 'mainloop_watchdog'.
* tk.rb: (Tk.restart) Add 'app-name' paramater and 'use' parameter.
'app-name' specifies the name and the resource class of the
application. If 'app-name' is specified to 'xxx', the application
class on the resource database is set to 'Xxx' and the application
name is changed by the same rule of Tk.appname method. 'use'
specifies the main window for embedding the root widget instead of
generating a new window.
* tk.rb: Add new parameter 'widgetname' to the widget constructor to
support effective use of Resource Database. For example, the
resource 'Xxx*quit.text: QUIT' can set the text of the button
generated by the following code.
e.g.
Tk.restart('Xxx')
TkButton.new(nil, 'widgetname'=>'quit', 'command'=>proc{exit}).pack
Tk.mainloop
* tk.rb: TkOption::get always returns a tainted string.
Add TkOption::new_proc_class.
It generates a class to import procedures defined on the resource
database. For example, there is a following resource file.
----< resource-test >------------
*CMD.foo: {|*args| p [$SAFE, :foo, args]}
*CMD.XXX.bar: {|*args| p [$SAFE, :bar, args]}
*Button.command: ruby {p self; p $SAFE; TkOption::CMD::XXX.bar(1,2,3)}
---------------------------------
The following code is a sample of use of the resource file.
e.g.
require 'tk'
TkOption.readfile 'resource-test'
p TkOption.new_proc_class(:CMD, [:foo], 1)
p TkOption.new_proc_class(:XXX, [:bar], 2, false, TkOption::CMD)
TkButton.new(:text=>'test').pack
Tk.mainloop
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2515 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2002-06-04 11:03:33 +04:00
|
|
|
Tcl_Event ev;
|
1999-08-13 09:37:52 +04:00
|
|
|
int argc;
|
|
|
|
VALUE *argv;
|
|
|
|
VALUE obj;
|
|
|
|
int done;
|
* tkfont.rb: Fix bugs on TkFont.init_widget_font for Tk8.x.
* tkafter.rb: Add self to 1st argument of interval- and loop-proc
TkAfter#current_interval returns an interval (sleep) time value
TkAfter#current_args returns an array of arguments
TkAfter#return_value returns a return value of last loop-proc
e.g.
TkAfter.new(
proc{|obj| 500 - obj.current_interval}, 10,
[proc{|obj| p obj.current_args}, 'proc', 1],
proc{|obj| p obj.current_args; ['return', 2]},
[proc{|obj|
p obj.return_value
p ['proc', obj.current_args[0].call(obj.return_value[1],
obj.current_args[1])]},
proc{|*args| args[0] + args[1]}, 1],
proc{p ['proc', 4]} ).start(100)
* tk*.rb: Allow to use Symbols for parameters.
Allow new notation of constructor (also allow old notation).
e.g.
TkFrame.new('classname'=>'User'){|base|
pack
f = TkFrame.new(base, :classname=>'ButtonFrame').pack
TkButton.new(
:parent => f,
:text => 'Quit',
:command => proc{exit}
).pack(
:fill => :x,
:pady => 2
)
}
* tkcanvas.rb: (TkcItem) Add 'coords' parameter to the canvas item
constructor (for new notation of constructor).
e.g.
c = TkCanvas.new.pack
l = TkcLine.new(c, :coords=>[[0,0], [100,100]])
* tcltklib.c: New 'mainloop' and 'mainloop_watchdog'.
The priority of their event-loop can be controlled.
They accept an optional argument.
If it false, they don't exit although the root widget is destroyed.
This function is sometimes useful, if it is used with 'restart'.
'mainloop' can't treat Thread#join/value in a callback routine.
(e.g. TkButton.new(:command=>proc{p Thread.new{button.invoke}.value}) )
'mainloop_watchdog' can treat them, but watchdog thread is always running
(so, a little heavier than 'mainloop').
If the purpose of using Thread#join/value is to do something under some
safe-level, please use Proc object.
(e.g. :command=>proc{$SAFE=1;proc{$SAFE=2;button.invoke}.call;p $SAFE})
* tk.rb: Support functions of new 'mainloop' and 'mainloop_watchdog'.
* tk.rb: (Tk.restart) Add 'app-name' paramater and 'use' parameter.
'app-name' specifies the name and the resource class of the
application. If 'app-name' is specified to 'xxx', the application
class on the resource database is set to 'Xxx' and the application
name is changed by the same rule of Tk.appname method. 'use'
specifies the main window for embedding the root widget instead of
generating a new window.
* tk.rb: Add new parameter 'widgetname' to the widget constructor to
support effective use of Resource Database. For example, the
resource 'Xxx*quit.text: QUIT' can set the text of the button
generated by the following code.
e.g.
Tk.restart('Xxx')
TkButton.new(nil, 'widgetname'=>'quit', 'command'=>proc{exit}).pack
Tk.mainloop
* tk.rb: TkOption::get always returns a tainted string.
Add TkOption::new_proc_class.
It generates a class to import procedures defined on the resource
database. For example, there is a following resource file.
----< resource-test >------------
*CMD.foo: {|*args| p [$SAFE, :foo, args]}
*CMD.XXX.bar: {|*args| p [$SAFE, :bar, args]}
*Button.command: ruby {p self; p $SAFE; TkOption::CMD::XXX.bar(1,2,3)}
---------------------------------
The following code is a sample of use of the resource file.
e.g.
require 'tk'
TkOption.readfile 'resource-test'
p TkOption.new_proc_class(:CMD, [:foo], 1)
p TkOption.new_proc_class(:XXX, [:bar], 2, false, TkOption::CMD)
TkButton.new(:text=>'test').pack
Tk.mainloop
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2515 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2002-06-04 11:03:33 +04:00
|
|
|
int safe_level;
|
|
|
|
VALUE *result;
|
1999-08-13 09:37:52 +04:00
|
|
|
VALUE thread;
|
|
|
|
};
|
2003-11-08 00:39:36 +03:00
|
|
|
|
|
|
|
struct eval_queue {
|
|
|
|
Tcl_Event ev;
|
|
|
|
VALUE str;
|
|
|
|
VALUE obj;
|
|
|
|
int done;
|
|
|
|
int safe_level;
|
|
|
|
VALUE *result;
|
|
|
|
VALUE thread;
|
|
|
|
};
|
1999-08-13 09:37:52 +04:00
|
|
|
|
* tkfont.rb: Fix bugs on TkFont.init_widget_font for Tk8.x.
* tkafter.rb: Add self to 1st argument of interval- and loop-proc
TkAfter#current_interval returns an interval (sleep) time value
TkAfter#current_args returns an array of arguments
TkAfter#return_value returns a return value of last loop-proc
e.g.
TkAfter.new(
proc{|obj| 500 - obj.current_interval}, 10,
[proc{|obj| p obj.current_args}, 'proc', 1],
proc{|obj| p obj.current_args; ['return', 2]},
[proc{|obj|
p obj.return_value
p ['proc', obj.current_args[0].call(obj.return_value[1],
obj.current_args[1])]},
proc{|*args| args[0] + args[1]}, 1],
proc{p ['proc', 4]} ).start(100)
* tk*.rb: Allow to use Symbols for parameters.
Allow new notation of constructor (also allow old notation).
e.g.
TkFrame.new('classname'=>'User'){|base|
pack
f = TkFrame.new(base, :classname=>'ButtonFrame').pack
TkButton.new(
:parent => f,
:text => 'Quit',
:command => proc{exit}
).pack(
:fill => :x,
:pady => 2
)
}
* tkcanvas.rb: (TkcItem) Add 'coords' parameter to the canvas item
constructor (for new notation of constructor).
e.g.
c = TkCanvas.new.pack
l = TkcLine.new(c, :coords=>[[0,0], [100,100]])
* tcltklib.c: New 'mainloop' and 'mainloop_watchdog'.
The priority of their event-loop can be controlled.
They accept an optional argument.
If it false, they don't exit although the root widget is destroyed.
This function is sometimes useful, if it is used with 'restart'.
'mainloop' can't treat Thread#join/value in a callback routine.
(e.g. TkButton.new(:command=>proc{p Thread.new{button.invoke}.value}) )
'mainloop_watchdog' can treat them, but watchdog thread is always running
(so, a little heavier than 'mainloop').
If the purpose of using Thread#join/value is to do something under some
safe-level, please use Proc object.
(e.g. :command=>proc{$SAFE=1;proc{$SAFE=2;button.invoke}.call;p $SAFE})
* tk.rb: Support functions of new 'mainloop' and 'mainloop_watchdog'.
* tk.rb: (Tk.restart) Add 'app-name' paramater and 'use' parameter.
'app-name' specifies the name and the resource class of the
application. If 'app-name' is specified to 'xxx', the application
class on the resource database is set to 'Xxx' and the application
name is changed by the same rule of Tk.appname method. 'use'
specifies the main window for embedding the root widget instead of
generating a new window.
* tk.rb: Add new parameter 'widgetname' to the widget constructor to
support effective use of Resource Database. For example, the
resource 'Xxx*quit.text: QUIT' can set the text of the button
generated by the following code.
e.g.
Tk.restart('Xxx')
TkButton.new(nil, 'widgetname'=>'quit', 'command'=>proc{exit}).pack
Tk.mainloop
* tk.rb: TkOption::get always returns a tainted string.
Add TkOption::new_proc_class.
It generates a class to import procedures defined on the resource
database. For example, there is a following resource file.
----< resource-test >------------
*CMD.foo: {|*args| p [$SAFE, :foo, args]}
*CMD.XXX.bar: {|*args| p [$SAFE, :bar, args]}
*Button.command: ruby {p self; p $SAFE; TkOption::CMD::XXX.bar(1,2,3)}
---------------------------------
The following code is a sample of use of the resource file.
e.g.
require 'tk'
TkOption.readfile 'resource-test'
p TkOption.new_proc_class(:CMD, [:foo], 1)
p TkOption.new_proc_class(:XXX, [:bar], 2, false, TkOption::CMD)
TkButton.new(:text=>'test').pack
Tk.mainloop
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2515 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2002-06-04 11:03:33 +04:00
|
|
|
static VALUE eventloop_thread;
|
|
|
|
static VALUE watchdog_thread;
|
|
|
|
Tcl_Interp *current_interp;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* 'event_loop_max' is a maximum events which the eventloop processes in one
|
|
|
|
* term of thread scheduling. 'no_event_tick' is the count-up value when
|
|
|
|
* there are no event for processing.
|
|
|
|
* 'timer_tick' is a limit of one term of thread scheduling.
|
|
|
|
* If 'timer_tick' == 0, then not use the timer for thread scheduling.
|
|
|
|
*/
|
2003-06-09 22:09:11 +04:00
|
|
|
#define DEFAULT_EVENT_LOOP_MAX 800/*counts*/
|
|
|
|
#define DEFAULT_NO_EVENT_TICK 10/*counts*/
|
|
|
|
#define DEFAULT_NO_EVENT_WAIT 20/*milliseconds ( 1 -- 999 ) */
|
|
|
|
#define WATCHDOG_INTERVAL 10/*milliseconds ( 1 -- 999 ) */
|
2003-07-29 05:24:32 +04:00
|
|
|
#define DEFAULT_TIMER_TICK 0/*milliseconds ( 0 -- 999 ) */
|
2003-10-14 19:25:45 +04:00
|
|
|
#define NO_THREAD_INTERRUPT_TIME 100/*milliseconds ( 1 -- 999 ) */
|
2003-06-09 22:09:11 +04:00
|
|
|
|
* tkfont.rb: Fix bugs on TkFont.init_widget_font for Tk8.x.
* tkafter.rb: Add self to 1st argument of interval- and loop-proc
TkAfter#current_interval returns an interval (sleep) time value
TkAfter#current_args returns an array of arguments
TkAfter#return_value returns a return value of last loop-proc
e.g.
TkAfter.new(
proc{|obj| 500 - obj.current_interval}, 10,
[proc{|obj| p obj.current_args}, 'proc', 1],
proc{|obj| p obj.current_args; ['return', 2]},
[proc{|obj|
p obj.return_value
p ['proc', obj.current_args[0].call(obj.return_value[1],
obj.current_args[1])]},
proc{|*args| args[0] + args[1]}, 1],
proc{p ['proc', 4]} ).start(100)
* tk*.rb: Allow to use Symbols for parameters.
Allow new notation of constructor (also allow old notation).
e.g.
TkFrame.new('classname'=>'User'){|base|
pack
f = TkFrame.new(base, :classname=>'ButtonFrame').pack
TkButton.new(
:parent => f,
:text => 'Quit',
:command => proc{exit}
).pack(
:fill => :x,
:pady => 2
)
}
* tkcanvas.rb: (TkcItem) Add 'coords' parameter to the canvas item
constructor (for new notation of constructor).
e.g.
c = TkCanvas.new.pack
l = TkcLine.new(c, :coords=>[[0,0], [100,100]])
* tcltklib.c: New 'mainloop' and 'mainloop_watchdog'.
The priority of their event-loop can be controlled.
They accept an optional argument.
If it false, they don't exit although the root widget is destroyed.
This function is sometimes useful, if it is used with 'restart'.
'mainloop' can't treat Thread#join/value in a callback routine.
(e.g. TkButton.new(:command=>proc{p Thread.new{button.invoke}.value}) )
'mainloop_watchdog' can treat them, but watchdog thread is always running
(so, a little heavier than 'mainloop').
If the purpose of using Thread#join/value is to do something under some
safe-level, please use Proc object.
(e.g. :command=>proc{$SAFE=1;proc{$SAFE=2;button.invoke}.call;p $SAFE})
* tk.rb: Support functions of new 'mainloop' and 'mainloop_watchdog'.
* tk.rb: (Tk.restart) Add 'app-name' paramater and 'use' parameter.
'app-name' specifies the name and the resource class of the
application. If 'app-name' is specified to 'xxx', the application
class on the resource database is set to 'Xxx' and the application
name is changed by the same rule of Tk.appname method. 'use'
specifies the main window for embedding the root widget instead of
generating a new window.
* tk.rb: Add new parameter 'widgetname' to the widget constructor to
support effective use of Resource Database. For example, the
resource 'Xxx*quit.text: QUIT' can set the text of the button
generated by the following code.
e.g.
Tk.restart('Xxx')
TkButton.new(nil, 'widgetname'=>'quit', 'command'=>proc{exit}).pack
Tk.mainloop
* tk.rb: TkOption::get always returns a tainted string.
Add TkOption::new_proc_class.
It generates a class to import procedures defined on the resource
database. For example, there is a following resource file.
----< resource-test >------------
*CMD.foo: {|*args| p [$SAFE, :foo, args]}
*CMD.XXX.bar: {|*args| p [$SAFE, :bar, args]}
*Button.command: ruby {p self; p $SAFE; TkOption::CMD::XXX.bar(1,2,3)}
---------------------------------
The following code is a sample of use of the resource file.
e.g.
require 'tk'
TkOption.readfile 'resource-test'
p TkOption.new_proc_class(:CMD, [:foo], 1)
p TkOption.new_proc_class(:XXX, [:bar], 2, false, TkOption::CMD)
TkButton.new(:text=>'test').pack
Tk.mainloop
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2515 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2002-06-04 11:03:33 +04:00
|
|
|
static int event_loop_max = DEFAULT_EVENT_LOOP_MAX;
|
|
|
|
static int no_event_tick = DEFAULT_NO_EVENT_TICK;
|
2003-06-09 22:09:11 +04:00
|
|
|
static int no_event_wait = DEFAULT_NO_EVENT_WAIT;
|
* tkfont.rb: Fix bugs on TkFont.init_widget_font for Tk8.x.
* tkafter.rb: Add self to 1st argument of interval- and loop-proc
TkAfter#current_interval returns an interval (sleep) time value
TkAfter#current_args returns an array of arguments
TkAfter#return_value returns a return value of last loop-proc
e.g.
TkAfter.new(
proc{|obj| 500 - obj.current_interval}, 10,
[proc{|obj| p obj.current_args}, 'proc', 1],
proc{|obj| p obj.current_args; ['return', 2]},
[proc{|obj|
p obj.return_value
p ['proc', obj.current_args[0].call(obj.return_value[1],
obj.current_args[1])]},
proc{|*args| args[0] + args[1]}, 1],
proc{p ['proc', 4]} ).start(100)
* tk*.rb: Allow to use Symbols for parameters.
Allow new notation of constructor (also allow old notation).
e.g.
TkFrame.new('classname'=>'User'){|base|
pack
f = TkFrame.new(base, :classname=>'ButtonFrame').pack
TkButton.new(
:parent => f,
:text => 'Quit',
:command => proc{exit}
).pack(
:fill => :x,
:pady => 2
)
}
* tkcanvas.rb: (TkcItem) Add 'coords' parameter to the canvas item
constructor (for new notation of constructor).
e.g.
c = TkCanvas.new.pack
l = TkcLine.new(c, :coords=>[[0,0], [100,100]])
* tcltklib.c: New 'mainloop' and 'mainloop_watchdog'.
The priority of their event-loop can be controlled.
They accept an optional argument.
If it false, they don't exit although the root widget is destroyed.
This function is sometimes useful, if it is used with 'restart'.
'mainloop' can't treat Thread#join/value in a callback routine.
(e.g. TkButton.new(:command=>proc{p Thread.new{button.invoke}.value}) )
'mainloop_watchdog' can treat them, but watchdog thread is always running
(so, a little heavier than 'mainloop').
If the purpose of using Thread#join/value is to do something under some
safe-level, please use Proc object.
(e.g. :command=>proc{$SAFE=1;proc{$SAFE=2;button.invoke}.call;p $SAFE})
* tk.rb: Support functions of new 'mainloop' and 'mainloop_watchdog'.
* tk.rb: (Tk.restart) Add 'app-name' paramater and 'use' parameter.
'app-name' specifies the name and the resource class of the
application. If 'app-name' is specified to 'xxx', the application
class on the resource database is set to 'Xxx' and the application
name is changed by the same rule of Tk.appname method. 'use'
specifies the main window for embedding the root widget instead of
generating a new window.
* tk.rb: Add new parameter 'widgetname' to the widget constructor to
support effective use of Resource Database. For example, the
resource 'Xxx*quit.text: QUIT' can set the text of the button
generated by the following code.
e.g.
Tk.restart('Xxx')
TkButton.new(nil, 'widgetname'=>'quit', 'command'=>proc{exit}).pack
Tk.mainloop
* tk.rb: TkOption::get always returns a tainted string.
Add TkOption::new_proc_class.
It generates a class to import procedures defined on the resource
database. For example, there is a following resource file.
----< resource-test >------------
*CMD.foo: {|*args| p [$SAFE, :foo, args]}
*CMD.XXX.bar: {|*args| p [$SAFE, :bar, args]}
*Button.command: ruby {p self; p $SAFE; TkOption::CMD::XXX.bar(1,2,3)}
---------------------------------
The following code is a sample of use of the resource file.
e.g.
require 'tk'
TkOption.readfile 'resource-test'
p TkOption.new_proc_class(:CMD, [:foo], 1)
p TkOption.new_proc_class(:XXX, [:bar], 2, false, TkOption::CMD)
TkButton.new(:text=>'test').pack
Tk.mainloop
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2515 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2002-06-04 11:03:33 +04:00
|
|
|
static int timer_tick = DEFAULT_TIMER_TICK;
|
2003-06-09 19:50:24 +04:00
|
|
|
static int req_timer_tick = DEFAULT_TIMER_TICK;
|
|
|
|
static int run_timer_flag = 0;
|
* tkfont.rb: Fix bugs on TkFont.init_widget_font for Tk8.x.
* tkafter.rb: Add self to 1st argument of interval- and loop-proc
TkAfter#current_interval returns an interval (sleep) time value
TkAfter#current_args returns an array of arguments
TkAfter#return_value returns a return value of last loop-proc
e.g.
TkAfter.new(
proc{|obj| 500 - obj.current_interval}, 10,
[proc{|obj| p obj.current_args}, 'proc', 1],
proc{|obj| p obj.current_args; ['return', 2]},
[proc{|obj|
p obj.return_value
p ['proc', obj.current_args[0].call(obj.return_value[1],
obj.current_args[1])]},
proc{|*args| args[0] + args[1]}, 1],
proc{p ['proc', 4]} ).start(100)
* tk*.rb: Allow to use Symbols for parameters.
Allow new notation of constructor (also allow old notation).
e.g.
TkFrame.new('classname'=>'User'){|base|
pack
f = TkFrame.new(base, :classname=>'ButtonFrame').pack
TkButton.new(
:parent => f,
:text => 'Quit',
:command => proc{exit}
).pack(
:fill => :x,
:pady => 2
)
}
* tkcanvas.rb: (TkcItem) Add 'coords' parameter to the canvas item
constructor (for new notation of constructor).
e.g.
c = TkCanvas.new.pack
l = TkcLine.new(c, :coords=>[[0,0], [100,100]])
* tcltklib.c: New 'mainloop' and 'mainloop_watchdog'.
The priority of their event-loop can be controlled.
They accept an optional argument.
If it false, they don't exit although the root widget is destroyed.
This function is sometimes useful, if it is used with 'restart'.
'mainloop' can't treat Thread#join/value in a callback routine.
(e.g. TkButton.new(:command=>proc{p Thread.new{button.invoke}.value}) )
'mainloop_watchdog' can treat them, but watchdog thread is always running
(so, a little heavier than 'mainloop').
If the purpose of using Thread#join/value is to do something under some
safe-level, please use Proc object.
(e.g. :command=>proc{$SAFE=1;proc{$SAFE=2;button.invoke}.call;p $SAFE})
* tk.rb: Support functions of new 'mainloop' and 'mainloop_watchdog'.
* tk.rb: (Tk.restart) Add 'app-name' paramater and 'use' parameter.
'app-name' specifies the name and the resource class of the
application. If 'app-name' is specified to 'xxx', the application
class on the resource database is set to 'Xxx' and the application
name is changed by the same rule of Tk.appname method. 'use'
specifies the main window for embedding the root widget instead of
generating a new window.
* tk.rb: Add new parameter 'widgetname' to the widget constructor to
support effective use of Resource Database. For example, the
resource 'Xxx*quit.text: QUIT' can set the text of the button
generated by the following code.
e.g.
Tk.restart('Xxx')
TkButton.new(nil, 'widgetname'=>'quit', 'command'=>proc{exit}).pack
Tk.mainloop
* tk.rb: TkOption::get always returns a tainted string.
Add TkOption::new_proc_class.
It generates a class to import procedures defined on the resource
database. For example, there is a following resource file.
----< resource-test >------------
*CMD.foo: {|*args| p [$SAFE, :foo, args]}
*CMD.XXX.bar: {|*args| p [$SAFE, :bar, args]}
*Button.command: ruby {p self; p $SAFE; TkOption::CMD::XXX.bar(1,2,3)}
---------------------------------
The following code is a sample of use of the resource file.
e.g.
require 'tk'
TkOption.readfile 'resource-test'
p TkOption.new_proc_class(:CMD, [:foo], 1)
p TkOption.new_proc_class(:XXX, [:bar], 2, false, TkOption::CMD)
TkButton.new(:text=>'test').pack
Tk.mainloop
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2515 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2002-06-04 11:03:33 +04:00
|
|
|
|
2003-07-29 05:24:32 +04:00
|
|
|
static int event_loop_wait_event = 0;
|
2003-07-29 19:39:59 +04:00
|
|
|
static int event_loop_abort_on_exc = 1;
|
2003-07-27 23:35:06 +04:00
|
|
|
static int loop_counter = 0;
|
2003-06-09 22:09:11 +04:00
|
|
|
|
2003-10-14 19:25:45 +04:00
|
|
|
static int check_rootwidget_flag = 0;
|
|
|
|
|
* tkfont.rb: Fix bugs on TkFont.init_widget_font for Tk8.x.
* tkafter.rb: Add self to 1st argument of interval- and loop-proc
TkAfter#current_interval returns an interval (sleep) time value
TkAfter#current_args returns an array of arguments
TkAfter#return_value returns a return value of last loop-proc
e.g.
TkAfter.new(
proc{|obj| 500 - obj.current_interval}, 10,
[proc{|obj| p obj.current_args}, 'proc', 1],
proc{|obj| p obj.current_args; ['return', 2]},
[proc{|obj|
p obj.return_value
p ['proc', obj.current_args[0].call(obj.return_value[1],
obj.current_args[1])]},
proc{|*args| args[0] + args[1]}, 1],
proc{p ['proc', 4]} ).start(100)
* tk*.rb: Allow to use Symbols for parameters.
Allow new notation of constructor (also allow old notation).
e.g.
TkFrame.new('classname'=>'User'){|base|
pack
f = TkFrame.new(base, :classname=>'ButtonFrame').pack
TkButton.new(
:parent => f,
:text => 'Quit',
:command => proc{exit}
).pack(
:fill => :x,
:pady => 2
)
}
* tkcanvas.rb: (TkcItem) Add 'coords' parameter to the canvas item
constructor (for new notation of constructor).
e.g.
c = TkCanvas.new.pack
l = TkcLine.new(c, :coords=>[[0,0], [100,100]])
* tcltklib.c: New 'mainloop' and 'mainloop_watchdog'.
The priority of their event-loop can be controlled.
They accept an optional argument.
If it false, they don't exit although the root widget is destroyed.
This function is sometimes useful, if it is used with 'restart'.
'mainloop' can't treat Thread#join/value in a callback routine.
(e.g. TkButton.new(:command=>proc{p Thread.new{button.invoke}.value}) )
'mainloop_watchdog' can treat them, but watchdog thread is always running
(so, a little heavier than 'mainloop').
If the purpose of using Thread#join/value is to do something under some
safe-level, please use Proc object.
(e.g. :command=>proc{$SAFE=1;proc{$SAFE=2;button.invoke}.call;p $SAFE})
* tk.rb: Support functions of new 'mainloop' and 'mainloop_watchdog'.
* tk.rb: (Tk.restart) Add 'app-name' paramater and 'use' parameter.
'app-name' specifies the name and the resource class of the
application. If 'app-name' is specified to 'xxx', the application
class on the resource database is set to 'Xxx' and the application
name is changed by the same rule of Tk.appname method. 'use'
specifies the main window for embedding the root widget instead of
generating a new window.
* tk.rb: Add new parameter 'widgetname' to the widget constructor to
support effective use of Resource Database. For example, the
resource 'Xxx*quit.text: QUIT' can set the text of the button
generated by the following code.
e.g.
Tk.restart('Xxx')
TkButton.new(nil, 'widgetname'=>'quit', 'command'=>proc{exit}).pack
Tk.mainloop
* tk.rb: TkOption::get always returns a tainted string.
Add TkOption::new_proc_class.
It generates a class to import procedures defined on the resource
database. For example, there is a following resource file.
----< resource-test >------------
*CMD.foo: {|*args| p [$SAFE, :foo, args]}
*CMD.XXX.bar: {|*args| p [$SAFE, :bar, args]}
*Button.command: ruby {p self; p $SAFE; TkOption::CMD::XXX.bar(1,2,3)}
---------------------------------
The following code is a sample of use of the resource file.
e.g.
require 'tk'
TkOption.readfile 'resource-test'
p TkOption.new_proc_class(:CMD, [:foo], 1)
p TkOption.new_proc_class(:XXX, [:bar], 2, false, TkOption::CMD)
TkButton.new(:text=>'test').pack
Tk.mainloop
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2515 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2002-06-04 11:03:33 +04:00
|
|
|
#if TCL_MAJOR_VERSION >= 8
|
|
|
|
static int ip_ruby _((ClientData, Tcl_Interp *, int, Tcl_Obj *CONST*));
|
|
|
|
#else
|
|
|
|
static int ip_ruby _((ClientData, Tcl_Interp *, int, char **));
|
|
|
|
#endif
|
1999-08-13 09:37:52 +04:00
|
|
|
|
2003-08-29 12:34:14 +04:00
|
|
|
/*---- class TclTkIp ----*/
|
|
|
|
struct tcltkip {
|
|
|
|
Tcl_Interp *ip; /* the interpreter */
|
|
|
|
int return_value; /* return value */
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct tcltkip *
|
|
|
|
get_ip(self)
|
|
|
|
VALUE self;
|
|
|
|
{
|
|
|
|
struct tcltkip *ptr;
|
|
|
|
|
|
|
|
Data_Get_Struct(self, struct tcltkip, ptr);
|
|
|
|
if (ptr == 0) {
|
|
|
|
rb_raise(rb_eTypeError, "uninitialized TclTkIp");
|
|
|
|
}
|
|
|
|
return ptr;
|
|
|
|
}
|
|
|
|
|
1999-01-20 07:59:39 +03:00
|
|
|
/* Tk_ThreadTimer */
|
* tkfont.rb: Fix bugs on TkFont.init_widget_font for Tk8.x.
* tkafter.rb: Add self to 1st argument of interval- and loop-proc
TkAfter#current_interval returns an interval (sleep) time value
TkAfter#current_args returns an array of arguments
TkAfter#return_value returns a return value of last loop-proc
e.g.
TkAfter.new(
proc{|obj| 500 - obj.current_interval}, 10,
[proc{|obj| p obj.current_args}, 'proc', 1],
proc{|obj| p obj.current_args; ['return', 2]},
[proc{|obj|
p obj.return_value
p ['proc', obj.current_args[0].call(obj.return_value[1],
obj.current_args[1])]},
proc{|*args| args[0] + args[1]}, 1],
proc{p ['proc', 4]} ).start(100)
* tk*.rb: Allow to use Symbols for parameters.
Allow new notation of constructor (also allow old notation).
e.g.
TkFrame.new('classname'=>'User'){|base|
pack
f = TkFrame.new(base, :classname=>'ButtonFrame').pack
TkButton.new(
:parent => f,
:text => 'Quit',
:command => proc{exit}
).pack(
:fill => :x,
:pady => 2
)
}
* tkcanvas.rb: (TkcItem) Add 'coords' parameter to the canvas item
constructor (for new notation of constructor).
e.g.
c = TkCanvas.new.pack
l = TkcLine.new(c, :coords=>[[0,0], [100,100]])
* tcltklib.c: New 'mainloop' and 'mainloop_watchdog'.
The priority of their event-loop can be controlled.
They accept an optional argument.
If it false, they don't exit although the root widget is destroyed.
This function is sometimes useful, if it is used with 'restart'.
'mainloop' can't treat Thread#join/value in a callback routine.
(e.g. TkButton.new(:command=>proc{p Thread.new{button.invoke}.value}) )
'mainloop_watchdog' can treat them, but watchdog thread is always running
(so, a little heavier than 'mainloop').
If the purpose of using Thread#join/value is to do something under some
safe-level, please use Proc object.
(e.g. :command=>proc{$SAFE=1;proc{$SAFE=2;button.invoke}.call;p $SAFE})
* tk.rb: Support functions of new 'mainloop' and 'mainloop_watchdog'.
* tk.rb: (Tk.restart) Add 'app-name' paramater and 'use' parameter.
'app-name' specifies the name and the resource class of the
application. If 'app-name' is specified to 'xxx', the application
class on the resource database is set to 'Xxx' and the application
name is changed by the same rule of Tk.appname method. 'use'
specifies the main window for embedding the root widget instead of
generating a new window.
* tk.rb: Add new parameter 'widgetname' to the widget constructor to
support effective use of Resource Database. For example, the
resource 'Xxx*quit.text: QUIT' can set the text of the button
generated by the following code.
e.g.
Tk.restart('Xxx')
TkButton.new(nil, 'widgetname'=>'quit', 'command'=>proc{exit}).pack
Tk.mainloop
* tk.rb: TkOption::get always returns a tainted string.
Add TkOption::new_proc_class.
It generates a class to import procedures defined on the resource
database. For example, there is a following resource file.
----< resource-test >------------
*CMD.foo: {|*args| p [$SAFE, :foo, args]}
*CMD.XXX.bar: {|*args| p [$SAFE, :bar, args]}
*Button.command: ruby {p self; p $SAFE; TkOption::CMD::XXX.bar(1,2,3)}
---------------------------------
The following code is a sample of use of the resource file.
e.g.
require 'tk'
TkOption.readfile 'resource-test'
p TkOption.new_proc_class(:CMD, [:foo], 1)
p TkOption.new_proc_class(:XXX, [:bar], 2, false, TkOption::CMD)
TkButton.new(:text=>'test').pack
Tk.mainloop
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2515 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2002-06-04 11:03:33 +04:00
|
|
|
static Tcl_TimerToken timer_token = (Tcl_TimerToken)NULL;
|
1999-01-20 07:59:39 +03:00
|
|
|
|
|
|
|
/* timer callback */
|
2002-04-01 10:21:24 +04:00
|
|
|
static void _timer_for_tcl _((ClientData));
|
1999-08-13 09:37:52 +04:00
|
|
|
static void
|
|
|
|
_timer_for_tcl(clientData)
|
|
|
|
ClientData clientData;
|
1999-01-20 07:59:39 +03:00
|
|
|
{
|
2003-07-29 05:24:32 +04:00
|
|
|
/* struct invoke_queue *q, *tmp; */
|
|
|
|
/* VALUE thread; */
|
1999-01-20 07:59:39 +03:00
|
|
|
|
2003-06-09 19:50:24 +04:00
|
|
|
DUMP1("called timer_for_tcl");
|
1999-08-13 09:37:52 +04:00
|
|
|
Tk_DeleteTimerHandler(timer_token);
|
2003-06-09 19:50:24 +04:00
|
|
|
|
|
|
|
run_timer_flag = 1;
|
|
|
|
|
* tkfont.rb: Fix bugs on TkFont.init_widget_font for Tk8.x.
* tkafter.rb: Add self to 1st argument of interval- and loop-proc
TkAfter#current_interval returns an interval (sleep) time value
TkAfter#current_args returns an array of arguments
TkAfter#return_value returns a return value of last loop-proc
e.g.
TkAfter.new(
proc{|obj| 500 - obj.current_interval}, 10,
[proc{|obj| p obj.current_args}, 'proc', 1],
proc{|obj| p obj.current_args; ['return', 2]},
[proc{|obj|
p obj.return_value
p ['proc', obj.current_args[0].call(obj.return_value[1],
obj.current_args[1])]},
proc{|*args| args[0] + args[1]}, 1],
proc{p ['proc', 4]} ).start(100)
* tk*.rb: Allow to use Symbols for parameters.
Allow new notation of constructor (also allow old notation).
e.g.
TkFrame.new('classname'=>'User'){|base|
pack
f = TkFrame.new(base, :classname=>'ButtonFrame').pack
TkButton.new(
:parent => f,
:text => 'Quit',
:command => proc{exit}
).pack(
:fill => :x,
:pady => 2
)
}
* tkcanvas.rb: (TkcItem) Add 'coords' parameter to the canvas item
constructor (for new notation of constructor).
e.g.
c = TkCanvas.new.pack
l = TkcLine.new(c, :coords=>[[0,0], [100,100]])
* tcltklib.c: New 'mainloop' and 'mainloop_watchdog'.
The priority of their event-loop can be controlled.
They accept an optional argument.
If it false, they don't exit although the root widget is destroyed.
This function is sometimes useful, if it is used with 'restart'.
'mainloop' can't treat Thread#join/value in a callback routine.
(e.g. TkButton.new(:command=>proc{p Thread.new{button.invoke}.value}) )
'mainloop_watchdog' can treat them, but watchdog thread is always running
(so, a little heavier than 'mainloop').
If the purpose of using Thread#join/value is to do something under some
safe-level, please use Proc object.
(e.g. :command=>proc{$SAFE=1;proc{$SAFE=2;button.invoke}.call;p $SAFE})
* tk.rb: Support functions of new 'mainloop' and 'mainloop_watchdog'.
* tk.rb: (Tk.restart) Add 'app-name' paramater and 'use' parameter.
'app-name' specifies the name and the resource class of the
application. If 'app-name' is specified to 'xxx', the application
class on the resource database is set to 'Xxx' and the application
name is changed by the same rule of Tk.appname method. 'use'
specifies the main window for embedding the root widget instead of
generating a new window.
* tk.rb: Add new parameter 'widgetname' to the widget constructor to
support effective use of Resource Database. For example, the
resource 'Xxx*quit.text: QUIT' can set the text of the button
generated by the following code.
e.g.
Tk.restart('Xxx')
TkButton.new(nil, 'widgetname'=>'quit', 'command'=>proc{exit}).pack
Tk.mainloop
* tk.rb: TkOption::get always returns a tainted string.
Add TkOption::new_proc_class.
It generates a class to import procedures defined on the resource
database. For example, there is a following resource file.
----< resource-test >------------
*CMD.foo: {|*args| p [$SAFE, :foo, args]}
*CMD.XXX.bar: {|*args| p [$SAFE, :bar, args]}
*Button.command: ruby {p self; p $SAFE; TkOption::CMD::XXX.bar(1,2,3)}
---------------------------------
The following code is a sample of use of the resource file.
e.g.
require 'tk'
TkOption.readfile 'resource-test'
p TkOption.new_proc_class(:CMD, [:foo], 1)
p TkOption.new_proc_class(:XXX, [:bar], 2, false, TkOption::CMD)
TkButton.new(:text=>'test').pack
Tk.mainloop
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2515 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2002-06-04 11:03:33 +04:00
|
|
|
if (timer_tick > 0) {
|
2003-07-27 23:35:06 +04:00
|
|
|
timer_token = Tk_CreateTimerHandler(timer_tick, _timer_for_tcl,
|
|
|
|
(ClientData)0);
|
* tkfont.rb: Fix bugs on TkFont.init_widget_font for Tk8.x.
* tkafter.rb: Add self to 1st argument of interval- and loop-proc
TkAfter#current_interval returns an interval (sleep) time value
TkAfter#current_args returns an array of arguments
TkAfter#return_value returns a return value of last loop-proc
e.g.
TkAfter.new(
proc{|obj| 500 - obj.current_interval}, 10,
[proc{|obj| p obj.current_args}, 'proc', 1],
proc{|obj| p obj.current_args; ['return', 2]},
[proc{|obj|
p obj.return_value
p ['proc', obj.current_args[0].call(obj.return_value[1],
obj.current_args[1])]},
proc{|*args| args[0] + args[1]}, 1],
proc{p ['proc', 4]} ).start(100)
* tk*.rb: Allow to use Symbols for parameters.
Allow new notation of constructor (also allow old notation).
e.g.
TkFrame.new('classname'=>'User'){|base|
pack
f = TkFrame.new(base, :classname=>'ButtonFrame').pack
TkButton.new(
:parent => f,
:text => 'Quit',
:command => proc{exit}
).pack(
:fill => :x,
:pady => 2
)
}
* tkcanvas.rb: (TkcItem) Add 'coords' parameter to the canvas item
constructor (for new notation of constructor).
e.g.
c = TkCanvas.new.pack
l = TkcLine.new(c, :coords=>[[0,0], [100,100]])
* tcltklib.c: New 'mainloop' and 'mainloop_watchdog'.
The priority of their event-loop can be controlled.
They accept an optional argument.
If it false, they don't exit although the root widget is destroyed.
This function is sometimes useful, if it is used with 'restart'.
'mainloop' can't treat Thread#join/value in a callback routine.
(e.g. TkButton.new(:command=>proc{p Thread.new{button.invoke}.value}) )
'mainloop_watchdog' can treat them, but watchdog thread is always running
(so, a little heavier than 'mainloop').
If the purpose of using Thread#join/value is to do something under some
safe-level, please use Proc object.
(e.g. :command=>proc{$SAFE=1;proc{$SAFE=2;button.invoke}.call;p $SAFE})
* tk.rb: Support functions of new 'mainloop' and 'mainloop_watchdog'.
* tk.rb: (Tk.restart) Add 'app-name' paramater and 'use' parameter.
'app-name' specifies the name and the resource class of the
application. If 'app-name' is specified to 'xxx', the application
class on the resource database is set to 'Xxx' and the application
name is changed by the same rule of Tk.appname method. 'use'
specifies the main window for embedding the root widget instead of
generating a new window.
* tk.rb: Add new parameter 'widgetname' to the widget constructor to
support effective use of Resource Database. For example, the
resource 'Xxx*quit.text: QUIT' can set the text of the button
generated by the following code.
e.g.
Tk.restart('Xxx')
TkButton.new(nil, 'widgetname'=>'quit', 'command'=>proc{exit}).pack
Tk.mainloop
* tk.rb: TkOption::get always returns a tainted string.
Add TkOption::new_proc_class.
It generates a class to import procedures defined on the resource
database. For example, there is a following resource file.
----< resource-test >------------
*CMD.foo: {|*args| p [$SAFE, :foo, args]}
*CMD.XXX.bar: {|*args| p [$SAFE, :bar, args]}
*Button.command: ruby {p self; p $SAFE; TkOption::CMD::XXX.bar(1,2,3)}
---------------------------------
The following code is a sample of use of the resource file.
e.g.
require 'tk'
TkOption.readfile 'resource-test'
p TkOption.new_proc_class(:CMD, [:foo], 1)
p TkOption.new_proc_class(:XXX, [:bar], 2, false, TkOption::CMD)
TkButton.new(:text=>'test').pack
Tk.mainloop
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2515 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2002-06-04 11:03:33 +04:00
|
|
|
} else {
|
2003-07-27 23:35:06 +04:00
|
|
|
timer_token = (Tcl_TimerToken)NULL;
|
* tkfont.rb: Fix bugs on TkFont.init_widget_font for Tk8.x.
* tkafter.rb: Add self to 1st argument of interval- and loop-proc
TkAfter#current_interval returns an interval (sleep) time value
TkAfter#current_args returns an array of arguments
TkAfter#return_value returns a return value of last loop-proc
e.g.
TkAfter.new(
proc{|obj| 500 - obj.current_interval}, 10,
[proc{|obj| p obj.current_args}, 'proc', 1],
proc{|obj| p obj.current_args; ['return', 2]},
[proc{|obj|
p obj.return_value
p ['proc', obj.current_args[0].call(obj.return_value[1],
obj.current_args[1])]},
proc{|*args| args[0] + args[1]}, 1],
proc{p ['proc', 4]} ).start(100)
* tk*.rb: Allow to use Symbols for parameters.
Allow new notation of constructor (also allow old notation).
e.g.
TkFrame.new('classname'=>'User'){|base|
pack
f = TkFrame.new(base, :classname=>'ButtonFrame').pack
TkButton.new(
:parent => f,
:text => 'Quit',
:command => proc{exit}
).pack(
:fill => :x,
:pady => 2
)
}
* tkcanvas.rb: (TkcItem) Add 'coords' parameter to the canvas item
constructor (for new notation of constructor).
e.g.
c = TkCanvas.new.pack
l = TkcLine.new(c, :coords=>[[0,0], [100,100]])
* tcltklib.c: New 'mainloop' and 'mainloop_watchdog'.
The priority of their event-loop can be controlled.
They accept an optional argument.
If it false, they don't exit although the root widget is destroyed.
This function is sometimes useful, if it is used with 'restart'.
'mainloop' can't treat Thread#join/value in a callback routine.
(e.g. TkButton.new(:command=>proc{p Thread.new{button.invoke}.value}) )
'mainloop_watchdog' can treat them, but watchdog thread is always running
(so, a little heavier than 'mainloop').
If the purpose of using Thread#join/value is to do something under some
safe-level, please use Proc object.
(e.g. :command=>proc{$SAFE=1;proc{$SAFE=2;button.invoke}.call;p $SAFE})
* tk.rb: Support functions of new 'mainloop' and 'mainloop_watchdog'.
* tk.rb: (Tk.restart) Add 'app-name' paramater and 'use' parameter.
'app-name' specifies the name and the resource class of the
application. If 'app-name' is specified to 'xxx', the application
class on the resource database is set to 'Xxx' and the application
name is changed by the same rule of Tk.appname method. 'use'
specifies the main window for embedding the root widget instead of
generating a new window.
* tk.rb: Add new parameter 'widgetname' to the widget constructor to
support effective use of Resource Database. For example, the
resource 'Xxx*quit.text: QUIT' can set the text of the button
generated by the following code.
e.g.
Tk.restart('Xxx')
TkButton.new(nil, 'widgetname'=>'quit', 'command'=>proc{exit}).pack
Tk.mainloop
* tk.rb: TkOption::get always returns a tainted string.
Add TkOption::new_proc_class.
It generates a class to import procedures defined on the resource
database. For example, there is a following resource file.
----< resource-test >------------
*CMD.foo: {|*args| p [$SAFE, :foo, args]}
*CMD.XXX.bar: {|*args| p [$SAFE, :bar, args]}
*Button.command: ruby {p self; p $SAFE; TkOption::CMD::XXX.bar(1,2,3)}
---------------------------------
The following code is a sample of use of the resource file.
e.g.
require 'tk'
TkOption.readfile 'resource-test'
p TkOption.new_proc_class(:CMD, [:foo], 1)
p TkOption.new_proc_class(:XXX, [:bar], 2, false, TkOption::CMD)
TkButton.new(:text=>'test').pack
Tk.mainloop
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2515 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2002-06-04 11:03:33 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/* rb_thread_schedule(); */
|
2003-06-09 19:50:24 +04:00
|
|
|
/* tick_counter += event_loop_max; */
|
* tkfont.rb: Fix bugs on TkFont.init_widget_font for Tk8.x.
* tkafter.rb: Add self to 1st argument of interval- and loop-proc
TkAfter#current_interval returns an interval (sleep) time value
TkAfter#current_args returns an array of arguments
TkAfter#return_value returns a return value of last loop-proc
e.g.
TkAfter.new(
proc{|obj| 500 - obj.current_interval}, 10,
[proc{|obj| p obj.current_args}, 'proc', 1],
proc{|obj| p obj.current_args; ['return', 2]},
[proc{|obj|
p obj.return_value
p ['proc', obj.current_args[0].call(obj.return_value[1],
obj.current_args[1])]},
proc{|*args| args[0] + args[1]}, 1],
proc{p ['proc', 4]} ).start(100)
* tk*.rb: Allow to use Symbols for parameters.
Allow new notation of constructor (also allow old notation).
e.g.
TkFrame.new('classname'=>'User'){|base|
pack
f = TkFrame.new(base, :classname=>'ButtonFrame').pack
TkButton.new(
:parent => f,
:text => 'Quit',
:command => proc{exit}
).pack(
:fill => :x,
:pady => 2
)
}
* tkcanvas.rb: (TkcItem) Add 'coords' parameter to the canvas item
constructor (for new notation of constructor).
e.g.
c = TkCanvas.new.pack
l = TkcLine.new(c, :coords=>[[0,0], [100,100]])
* tcltklib.c: New 'mainloop' and 'mainloop_watchdog'.
The priority of their event-loop can be controlled.
They accept an optional argument.
If it false, they don't exit although the root widget is destroyed.
This function is sometimes useful, if it is used with 'restart'.
'mainloop' can't treat Thread#join/value in a callback routine.
(e.g. TkButton.new(:command=>proc{p Thread.new{button.invoke}.value}) )
'mainloop_watchdog' can treat them, but watchdog thread is always running
(so, a little heavier than 'mainloop').
If the purpose of using Thread#join/value is to do something under some
safe-level, please use Proc object.
(e.g. :command=>proc{$SAFE=1;proc{$SAFE=2;button.invoke}.call;p $SAFE})
* tk.rb: Support functions of new 'mainloop' and 'mainloop_watchdog'.
* tk.rb: (Tk.restart) Add 'app-name' paramater and 'use' parameter.
'app-name' specifies the name and the resource class of the
application. If 'app-name' is specified to 'xxx', the application
class on the resource database is set to 'Xxx' and the application
name is changed by the same rule of Tk.appname method. 'use'
specifies the main window for embedding the root widget instead of
generating a new window.
* tk.rb: Add new parameter 'widgetname' to the widget constructor to
support effective use of Resource Database. For example, the
resource 'Xxx*quit.text: QUIT' can set the text of the button
generated by the following code.
e.g.
Tk.restart('Xxx')
TkButton.new(nil, 'widgetname'=>'quit', 'command'=>proc{exit}).pack
Tk.mainloop
* tk.rb: TkOption::get always returns a tainted string.
Add TkOption::new_proc_class.
It generates a class to import procedures defined on the resource
database. For example, there is a following resource file.
----< resource-test >------------
*CMD.foo: {|*args| p [$SAFE, :foo, args]}
*CMD.XXX.bar: {|*args| p [$SAFE, :bar, args]}
*Button.command: ruby {p self; p $SAFE; TkOption::CMD::XXX.bar(1,2,3)}
---------------------------------
The following code is a sample of use of the resource file.
e.g.
require 'tk'
TkOption.readfile 'resource-test'
p TkOption.new_proc_class(:CMD, [:foo], 1)
p TkOption.new_proc_class(:XXX, [:bar], 2, false, TkOption::CMD)
TkButton.new(:text=>'test').pack
Tk.mainloop
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2515 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2002-06-04 11:03:33 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
static VALUE
|
|
|
|
set_eventloop_tick(self, tick)
|
|
|
|
VALUE self;
|
|
|
|
VALUE tick;
|
|
|
|
{
|
|
|
|
int ttick = NUM2INT(tick);
|
|
|
|
|
2003-09-07 11:10:44 +04:00
|
|
|
rb_secure(4);
|
|
|
|
|
* tkfont.rb: Fix bugs on TkFont.init_widget_font for Tk8.x.
* tkafter.rb: Add self to 1st argument of interval- and loop-proc
TkAfter#current_interval returns an interval (sleep) time value
TkAfter#current_args returns an array of arguments
TkAfter#return_value returns a return value of last loop-proc
e.g.
TkAfter.new(
proc{|obj| 500 - obj.current_interval}, 10,
[proc{|obj| p obj.current_args}, 'proc', 1],
proc{|obj| p obj.current_args; ['return', 2]},
[proc{|obj|
p obj.return_value
p ['proc', obj.current_args[0].call(obj.return_value[1],
obj.current_args[1])]},
proc{|*args| args[0] + args[1]}, 1],
proc{p ['proc', 4]} ).start(100)
* tk*.rb: Allow to use Symbols for parameters.
Allow new notation of constructor (also allow old notation).
e.g.
TkFrame.new('classname'=>'User'){|base|
pack
f = TkFrame.new(base, :classname=>'ButtonFrame').pack
TkButton.new(
:parent => f,
:text => 'Quit',
:command => proc{exit}
).pack(
:fill => :x,
:pady => 2
)
}
* tkcanvas.rb: (TkcItem) Add 'coords' parameter to the canvas item
constructor (for new notation of constructor).
e.g.
c = TkCanvas.new.pack
l = TkcLine.new(c, :coords=>[[0,0], [100,100]])
* tcltklib.c: New 'mainloop' and 'mainloop_watchdog'.
The priority of their event-loop can be controlled.
They accept an optional argument.
If it false, they don't exit although the root widget is destroyed.
This function is sometimes useful, if it is used with 'restart'.
'mainloop' can't treat Thread#join/value in a callback routine.
(e.g. TkButton.new(:command=>proc{p Thread.new{button.invoke}.value}) )
'mainloop_watchdog' can treat them, but watchdog thread is always running
(so, a little heavier than 'mainloop').
If the purpose of using Thread#join/value is to do something under some
safe-level, please use Proc object.
(e.g. :command=>proc{$SAFE=1;proc{$SAFE=2;button.invoke}.call;p $SAFE})
* tk.rb: Support functions of new 'mainloop' and 'mainloop_watchdog'.
* tk.rb: (Tk.restart) Add 'app-name' paramater and 'use' parameter.
'app-name' specifies the name and the resource class of the
application. If 'app-name' is specified to 'xxx', the application
class on the resource database is set to 'Xxx' and the application
name is changed by the same rule of Tk.appname method. 'use'
specifies the main window for embedding the root widget instead of
generating a new window.
* tk.rb: Add new parameter 'widgetname' to the widget constructor to
support effective use of Resource Database. For example, the
resource 'Xxx*quit.text: QUIT' can set the text of the button
generated by the following code.
e.g.
Tk.restart('Xxx')
TkButton.new(nil, 'widgetname'=>'quit', 'command'=>proc{exit}).pack
Tk.mainloop
* tk.rb: TkOption::get always returns a tainted string.
Add TkOption::new_proc_class.
It generates a class to import procedures defined on the resource
database. For example, there is a following resource file.
----< resource-test >------------
*CMD.foo: {|*args| p [$SAFE, :foo, args]}
*CMD.XXX.bar: {|*args| p [$SAFE, :bar, args]}
*Button.command: ruby {p self; p $SAFE; TkOption::CMD::XXX.bar(1,2,3)}
---------------------------------
The following code is a sample of use of the resource file.
e.g.
require 'tk'
TkOption.readfile 'resource-test'
p TkOption.new_proc_class(:CMD, [:foo], 1)
p TkOption.new_proc_class(:XXX, [:bar], 2, false, TkOption::CMD)
TkButton.new(:text=>'test').pack
Tk.mainloop
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2515 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2002-06-04 11:03:33 +04:00
|
|
|
if (ttick < 0) {
|
2003-07-27 23:35:06 +04:00
|
|
|
rb_raise(rb_eArgError,
|
|
|
|
"timer-tick parameter must be 0 or positive number");
|
* tkfont.rb: Fix bugs on TkFont.init_widget_font for Tk8.x.
* tkafter.rb: Add self to 1st argument of interval- and loop-proc
TkAfter#current_interval returns an interval (sleep) time value
TkAfter#current_args returns an array of arguments
TkAfter#return_value returns a return value of last loop-proc
e.g.
TkAfter.new(
proc{|obj| 500 - obj.current_interval}, 10,
[proc{|obj| p obj.current_args}, 'proc', 1],
proc{|obj| p obj.current_args; ['return', 2]},
[proc{|obj|
p obj.return_value
p ['proc', obj.current_args[0].call(obj.return_value[1],
obj.current_args[1])]},
proc{|*args| args[0] + args[1]}, 1],
proc{p ['proc', 4]} ).start(100)
* tk*.rb: Allow to use Symbols for parameters.
Allow new notation of constructor (also allow old notation).
e.g.
TkFrame.new('classname'=>'User'){|base|
pack
f = TkFrame.new(base, :classname=>'ButtonFrame').pack
TkButton.new(
:parent => f,
:text => 'Quit',
:command => proc{exit}
).pack(
:fill => :x,
:pady => 2
)
}
* tkcanvas.rb: (TkcItem) Add 'coords' parameter to the canvas item
constructor (for new notation of constructor).
e.g.
c = TkCanvas.new.pack
l = TkcLine.new(c, :coords=>[[0,0], [100,100]])
* tcltklib.c: New 'mainloop' and 'mainloop_watchdog'.
The priority of their event-loop can be controlled.
They accept an optional argument.
If it false, they don't exit although the root widget is destroyed.
This function is sometimes useful, if it is used with 'restart'.
'mainloop' can't treat Thread#join/value in a callback routine.
(e.g. TkButton.new(:command=>proc{p Thread.new{button.invoke}.value}) )
'mainloop_watchdog' can treat them, but watchdog thread is always running
(so, a little heavier than 'mainloop').
If the purpose of using Thread#join/value is to do something under some
safe-level, please use Proc object.
(e.g. :command=>proc{$SAFE=1;proc{$SAFE=2;button.invoke}.call;p $SAFE})
* tk.rb: Support functions of new 'mainloop' and 'mainloop_watchdog'.
* tk.rb: (Tk.restart) Add 'app-name' paramater and 'use' parameter.
'app-name' specifies the name and the resource class of the
application. If 'app-name' is specified to 'xxx', the application
class on the resource database is set to 'Xxx' and the application
name is changed by the same rule of Tk.appname method. 'use'
specifies the main window for embedding the root widget instead of
generating a new window.
* tk.rb: Add new parameter 'widgetname' to the widget constructor to
support effective use of Resource Database. For example, the
resource 'Xxx*quit.text: QUIT' can set the text of the button
generated by the following code.
e.g.
Tk.restart('Xxx')
TkButton.new(nil, 'widgetname'=>'quit', 'command'=>proc{exit}).pack
Tk.mainloop
* tk.rb: TkOption::get always returns a tainted string.
Add TkOption::new_proc_class.
It generates a class to import procedures defined on the resource
database. For example, there is a following resource file.
----< resource-test >------------
*CMD.foo: {|*args| p [$SAFE, :foo, args]}
*CMD.XXX.bar: {|*args| p [$SAFE, :bar, args]}
*Button.command: ruby {p self; p $SAFE; TkOption::CMD::XXX.bar(1,2,3)}
---------------------------------
The following code is a sample of use of the resource file.
e.g.
require 'tk'
TkOption.readfile 'resource-test'
p TkOption.new_proc_class(:CMD, [:foo], 1)
p TkOption.new_proc_class(:XXX, [:bar], 2, false, TkOption::CMD)
TkButton.new(:text=>'test').pack
Tk.mainloop
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2515 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2002-06-04 11:03:33 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/* delete old timer callback */
|
|
|
|
Tk_DeleteTimerHandler(timer_token);
|
|
|
|
|
2003-06-09 19:50:24 +04:00
|
|
|
timer_tick = req_timer_tick = ttick;
|
* tkfont.rb: Fix bugs on TkFont.init_widget_font for Tk8.x.
* tkafter.rb: Add self to 1st argument of interval- and loop-proc
TkAfter#current_interval returns an interval (sleep) time value
TkAfter#current_args returns an array of arguments
TkAfter#return_value returns a return value of last loop-proc
e.g.
TkAfter.new(
proc{|obj| 500 - obj.current_interval}, 10,
[proc{|obj| p obj.current_args}, 'proc', 1],
proc{|obj| p obj.current_args; ['return', 2]},
[proc{|obj|
p obj.return_value
p ['proc', obj.current_args[0].call(obj.return_value[1],
obj.current_args[1])]},
proc{|*args| args[0] + args[1]}, 1],
proc{p ['proc', 4]} ).start(100)
* tk*.rb: Allow to use Symbols for parameters.
Allow new notation of constructor (also allow old notation).
e.g.
TkFrame.new('classname'=>'User'){|base|
pack
f = TkFrame.new(base, :classname=>'ButtonFrame').pack
TkButton.new(
:parent => f,
:text => 'Quit',
:command => proc{exit}
).pack(
:fill => :x,
:pady => 2
)
}
* tkcanvas.rb: (TkcItem) Add 'coords' parameter to the canvas item
constructor (for new notation of constructor).
e.g.
c = TkCanvas.new.pack
l = TkcLine.new(c, :coords=>[[0,0], [100,100]])
* tcltklib.c: New 'mainloop' and 'mainloop_watchdog'.
The priority of their event-loop can be controlled.
They accept an optional argument.
If it false, they don't exit although the root widget is destroyed.
This function is sometimes useful, if it is used with 'restart'.
'mainloop' can't treat Thread#join/value in a callback routine.
(e.g. TkButton.new(:command=>proc{p Thread.new{button.invoke}.value}) )
'mainloop_watchdog' can treat them, but watchdog thread is always running
(so, a little heavier than 'mainloop').
If the purpose of using Thread#join/value is to do something under some
safe-level, please use Proc object.
(e.g. :command=>proc{$SAFE=1;proc{$SAFE=2;button.invoke}.call;p $SAFE})
* tk.rb: Support functions of new 'mainloop' and 'mainloop_watchdog'.
* tk.rb: (Tk.restart) Add 'app-name' paramater and 'use' parameter.
'app-name' specifies the name and the resource class of the
application. If 'app-name' is specified to 'xxx', the application
class on the resource database is set to 'Xxx' and the application
name is changed by the same rule of Tk.appname method. 'use'
specifies the main window for embedding the root widget instead of
generating a new window.
* tk.rb: Add new parameter 'widgetname' to the widget constructor to
support effective use of Resource Database. For example, the
resource 'Xxx*quit.text: QUIT' can set the text of the button
generated by the following code.
e.g.
Tk.restart('Xxx')
TkButton.new(nil, 'widgetname'=>'quit', 'command'=>proc{exit}).pack
Tk.mainloop
* tk.rb: TkOption::get always returns a tainted string.
Add TkOption::new_proc_class.
It generates a class to import procedures defined on the resource
database. For example, there is a following resource file.
----< resource-test >------------
*CMD.foo: {|*args| p [$SAFE, :foo, args]}
*CMD.XXX.bar: {|*args| p [$SAFE, :bar, args]}
*Button.command: ruby {p self; p $SAFE; TkOption::CMD::XXX.bar(1,2,3)}
---------------------------------
The following code is a sample of use of the resource file.
e.g.
require 'tk'
TkOption.readfile 'resource-test'
p TkOption.new_proc_class(:CMD, [:foo], 1)
p TkOption.new_proc_class(:XXX, [:bar], 2, false, TkOption::CMD)
TkButton.new(:text=>'test').pack
Tk.mainloop
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2515 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2002-06-04 11:03:33 +04:00
|
|
|
if (timer_tick > 0) {
|
2003-07-27 23:35:06 +04:00
|
|
|
/* start timer callback */
|
|
|
|
timer_token = Tk_CreateTimerHandler(timer_tick, _timer_for_tcl,
|
|
|
|
(ClientData)0);
|
* tkfont.rb: Fix bugs on TkFont.init_widget_font for Tk8.x.
* tkafter.rb: Add self to 1st argument of interval- and loop-proc
TkAfter#current_interval returns an interval (sleep) time value
TkAfter#current_args returns an array of arguments
TkAfter#return_value returns a return value of last loop-proc
e.g.
TkAfter.new(
proc{|obj| 500 - obj.current_interval}, 10,
[proc{|obj| p obj.current_args}, 'proc', 1],
proc{|obj| p obj.current_args; ['return', 2]},
[proc{|obj|
p obj.return_value
p ['proc', obj.current_args[0].call(obj.return_value[1],
obj.current_args[1])]},
proc{|*args| args[0] + args[1]}, 1],
proc{p ['proc', 4]} ).start(100)
* tk*.rb: Allow to use Symbols for parameters.
Allow new notation of constructor (also allow old notation).
e.g.
TkFrame.new('classname'=>'User'){|base|
pack
f = TkFrame.new(base, :classname=>'ButtonFrame').pack
TkButton.new(
:parent => f,
:text => 'Quit',
:command => proc{exit}
).pack(
:fill => :x,
:pady => 2
)
}
* tkcanvas.rb: (TkcItem) Add 'coords' parameter to the canvas item
constructor (for new notation of constructor).
e.g.
c = TkCanvas.new.pack
l = TkcLine.new(c, :coords=>[[0,0], [100,100]])
* tcltklib.c: New 'mainloop' and 'mainloop_watchdog'.
The priority of their event-loop can be controlled.
They accept an optional argument.
If it false, they don't exit although the root widget is destroyed.
This function is sometimes useful, if it is used with 'restart'.
'mainloop' can't treat Thread#join/value in a callback routine.
(e.g. TkButton.new(:command=>proc{p Thread.new{button.invoke}.value}) )
'mainloop_watchdog' can treat them, but watchdog thread is always running
(so, a little heavier than 'mainloop').
If the purpose of using Thread#join/value is to do something under some
safe-level, please use Proc object.
(e.g. :command=>proc{$SAFE=1;proc{$SAFE=2;button.invoke}.call;p $SAFE})
* tk.rb: Support functions of new 'mainloop' and 'mainloop_watchdog'.
* tk.rb: (Tk.restart) Add 'app-name' paramater and 'use' parameter.
'app-name' specifies the name and the resource class of the
application. If 'app-name' is specified to 'xxx', the application
class on the resource database is set to 'Xxx' and the application
name is changed by the same rule of Tk.appname method. 'use'
specifies the main window for embedding the root widget instead of
generating a new window.
* tk.rb: Add new parameter 'widgetname' to the widget constructor to
support effective use of Resource Database. For example, the
resource 'Xxx*quit.text: QUIT' can set the text of the button
generated by the following code.
e.g.
Tk.restart('Xxx')
TkButton.new(nil, 'widgetname'=>'quit', 'command'=>proc{exit}).pack
Tk.mainloop
* tk.rb: TkOption::get always returns a tainted string.
Add TkOption::new_proc_class.
It generates a class to import procedures defined on the resource
database. For example, there is a following resource file.
----< resource-test >------------
*CMD.foo: {|*args| p [$SAFE, :foo, args]}
*CMD.XXX.bar: {|*args| p [$SAFE, :bar, args]}
*Button.command: ruby {p self; p $SAFE; TkOption::CMD::XXX.bar(1,2,3)}
---------------------------------
The following code is a sample of use of the resource file.
e.g.
require 'tk'
TkOption.readfile 'resource-test'
p TkOption.new_proc_class(:CMD, [:foo], 1)
p TkOption.new_proc_class(:XXX, [:bar], 2, false, TkOption::CMD)
TkButton.new(:text=>'test').pack
Tk.mainloop
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2515 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2002-06-04 11:03:33 +04:00
|
|
|
} else {
|
2003-07-27 23:35:06 +04:00
|
|
|
timer_token = (Tcl_TimerToken)NULL;
|
* tkfont.rb: Fix bugs on TkFont.init_widget_font for Tk8.x.
* tkafter.rb: Add self to 1st argument of interval- and loop-proc
TkAfter#current_interval returns an interval (sleep) time value
TkAfter#current_args returns an array of arguments
TkAfter#return_value returns a return value of last loop-proc
e.g.
TkAfter.new(
proc{|obj| 500 - obj.current_interval}, 10,
[proc{|obj| p obj.current_args}, 'proc', 1],
proc{|obj| p obj.current_args; ['return', 2]},
[proc{|obj|
p obj.return_value
p ['proc', obj.current_args[0].call(obj.return_value[1],
obj.current_args[1])]},
proc{|*args| args[0] + args[1]}, 1],
proc{p ['proc', 4]} ).start(100)
* tk*.rb: Allow to use Symbols for parameters.
Allow new notation of constructor (also allow old notation).
e.g.
TkFrame.new('classname'=>'User'){|base|
pack
f = TkFrame.new(base, :classname=>'ButtonFrame').pack
TkButton.new(
:parent => f,
:text => 'Quit',
:command => proc{exit}
).pack(
:fill => :x,
:pady => 2
)
}
* tkcanvas.rb: (TkcItem) Add 'coords' parameter to the canvas item
constructor (for new notation of constructor).
e.g.
c = TkCanvas.new.pack
l = TkcLine.new(c, :coords=>[[0,0], [100,100]])
* tcltklib.c: New 'mainloop' and 'mainloop_watchdog'.
The priority of their event-loop can be controlled.
They accept an optional argument.
If it false, they don't exit although the root widget is destroyed.
This function is sometimes useful, if it is used with 'restart'.
'mainloop' can't treat Thread#join/value in a callback routine.
(e.g. TkButton.new(:command=>proc{p Thread.new{button.invoke}.value}) )
'mainloop_watchdog' can treat them, but watchdog thread is always running
(so, a little heavier than 'mainloop').
If the purpose of using Thread#join/value is to do something under some
safe-level, please use Proc object.
(e.g. :command=>proc{$SAFE=1;proc{$SAFE=2;button.invoke}.call;p $SAFE})
* tk.rb: Support functions of new 'mainloop' and 'mainloop_watchdog'.
* tk.rb: (Tk.restart) Add 'app-name' paramater and 'use' parameter.
'app-name' specifies the name and the resource class of the
application. If 'app-name' is specified to 'xxx', the application
class on the resource database is set to 'Xxx' and the application
name is changed by the same rule of Tk.appname method. 'use'
specifies the main window for embedding the root widget instead of
generating a new window.
* tk.rb: Add new parameter 'widgetname' to the widget constructor to
support effective use of Resource Database. For example, the
resource 'Xxx*quit.text: QUIT' can set the text of the button
generated by the following code.
e.g.
Tk.restart('Xxx')
TkButton.new(nil, 'widgetname'=>'quit', 'command'=>proc{exit}).pack
Tk.mainloop
* tk.rb: TkOption::get always returns a tainted string.
Add TkOption::new_proc_class.
It generates a class to import procedures defined on the resource
database. For example, there is a following resource file.
----< resource-test >------------
*CMD.foo: {|*args| p [$SAFE, :foo, args]}
*CMD.XXX.bar: {|*args| p [$SAFE, :bar, args]}
*Button.command: ruby {p self; p $SAFE; TkOption::CMD::XXX.bar(1,2,3)}
---------------------------------
The following code is a sample of use of the resource file.
e.g.
require 'tk'
TkOption.readfile 'resource-test'
p TkOption.new_proc_class(:CMD, [:foo], 1)
p TkOption.new_proc_class(:XXX, [:bar], 2, false, TkOption::CMD)
TkButton.new(:text=>'test').pack
Tk.mainloop
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2515 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2002-06-04 11:03:33 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
return tick;
|
|
|
|
}
|
|
|
|
|
|
|
|
static VALUE
|
|
|
|
get_eventloop_tick(self)
|
|
|
|
VALUE self;
|
|
|
|
{
|
|
|
|
return INT2NUM(timer_tick);
|
|
|
|
}
|
|
|
|
|
2003-08-29 12:34:14 +04:00
|
|
|
static VALUE
|
|
|
|
ip_set_eventloop_tick(self, tick)
|
|
|
|
VALUE self;
|
|
|
|
VALUE tick;
|
|
|
|
{
|
|
|
|
struct tcltkip *ptr = get_ip(self);
|
|
|
|
|
|
|
|
if (Tcl_GetMaster(ptr->ip) != (Tcl_Interp*)NULL) {
|
|
|
|
/* slave IP */
|
|
|
|
return get_eventloop_tick(self);
|
|
|
|
}
|
|
|
|
return set_eventloop_tick(self, tick);
|
|
|
|
}
|
|
|
|
|
|
|
|
static VALUE
|
|
|
|
ip_get_eventloop_tick(self)
|
|
|
|
VALUE self;
|
|
|
|
{
|
|
|
|
return get_eventloop_tick(self);
|
|
|
|
}
|
|
|
|
|
2003-06-19 20:14:43 +04:00
|
|
|
static VALUE
|
|
|
|
set_no_event_wait(self, wait)
|
|
|
|
VALUE self;
|
|
|
|
VALUE wait;
|
|
|
|
{
|
|
|
|
int t_wait = NUM2INT(wait);
|
|
|
|
|
2003-09-07 11:10:44 +04:00
|
|
|
rb_secure(4);
|
|
|
|
|
2003-06-19 20:14:43 +04:00
|
|
|
if (t_wait <= 0) {
|
2003-07-27 23:35:06 +04:00
|
|
|
rb_raise(rb_eArgError,
|
|
|
|
"no_event_wait parameter must be positive number");
|
2003-06-19 20:14:43 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
no_event_wait = t_wait;
|
|
|
|
|
|
|
|
return wait;
|
|
|
|
}
|
|
|
|
|
|
|
|
static VALUE
|
|
|
|
get_no_event_wait(self)
|
|
|
|
VALUE self;
|
|
|
|
{
|
|
|
|
return INT2NUM(no_event_wait);
|
|
|
|
}
|
|
|
|
|
2003-08-29 12:34:14 +04:00
|
|
|
static VALUE
|
|
|
|
ip_set_no_event_wait(self, wait)
|
|
|
|
VALUE self;
|
|
|
|
VALUE wait;
|
|
|
|
{
|
|
|
|
struct tcltkip *ptr = get_ip(self);
|
|
|
|
|
|
|
|
if (Tcl_GetMaster(ptr->ip) != (Tcl_Interp*)NULL) {
|
|
|
|
/* slave IP */
|
|
|
|
return get_no_event_wait(self);
|
|
|
|
}
|
|
|
|
return set_no_event_wait(self, wait);
|
|
|
|
}
|
|
|
|
|
|
|
|
static VALUE
|
|
|
|
ip_get_no_event_wait(self)
|
|
|
|
VALUE self;
|
|
|
|
{
|
|
|
|
return get_no_event_wait(self);
|
|
|
|
}
|
|
|
|
|
* tkfont.rb: Fix bugs on TkFont.init_widget_font for Tk8.x.
* tkafter.rb: Add self to 1st argument of interval- and loop-proc
TkAfter#current_interval returns an interval (sleep) time value
TkAfter#current_args returns an array of arguments
TkAfter#return_value returns a return value of last loop-proc
e.g.
TkAfter.new(
proc{|obj| 500 - obj.current_interval}, 10,
[proc{|obj| p obj.current_args}, 'proc', 1],
proc{|obj| p obj.current_args; ['return', 2]},
[proc{|obj|
p obj.return_value
p ['proc', obj.current_args[0].call(obj.return_value[1],
obj.current_args[1])]},
proc{|*args| args[0] + args[1]}, 1],
proc{p ['proc', 4]} ).start(100)
* tk*.rb: Allow to use Symbols for parameters.
Allow new notation of constructor (also allow old notation).
e.g.
TkFrame.new('classname'=>'User'){|base|
pack
f = TkFrame.new(base, :classname=>'ButtonFrame').pack
TkButton.new(
:parent => f,
:text => 'Quit',
:command => proc{exit}
).pack(
:fill => :x,
:pady => 2
)
}
* tkcanvas.rb: (TkcItem) Add 'coords' parameter to the canvas item
constructor (for new notation of constructor).
e.g.
c = TkCanvas.new.pack
l = TkcLine.new(c, :coords=>[[0,0], [100,100]])
* tcltklib.c: New 'mainloop' and 'mainloop_watchdog'.
The priority of their event-loop can be controlled.
They accept an optional argument.
If it false, they don't exit although the root widget is destroyed.
This function is sometimes useful, if it is used with 'restart'.
'mainloop' can't treat Thread#join/value in a callback routine.
(e.g. TkButton.new(:command=>proc{p Thread.new{button.invoke}.value}) )
'mainloop_watchdog' can treat them, but watchdog thread is always running
(so, a little heavier than 'mainloop').
If the purpose of using Thread#join/value is to do something under some
safe-level, please use Proc object.
(e.g. :command=>proc{$SAFE=1;proc{$SAFE=2;button.invoke}.call;p $SAFE})
* tk.rb: Support functions of new 'mainloop' and 'mainloop_watchdog'.
* tk.rb: (Tk.restart) Add 'app-name' paramater and 'use' parameter.
'app-name' specifies the name and the resource class of the
application. If 'app-name' is specified to 'xxx', the application
class on the resource database is set to 'Xxx' and the application
name is changed by the same rule of Tk.appname method. 'use'
specifies the main window for embedding the root widget instead of
generating a new window.
* tk.rb: Add new parameter 'widgetname' to the widget constructor to
support effective use of Resource Database. For example, the
resource 'Xxx*quit.text: QUIT' can set the text of the button
generated by the following code.
e.g.
Tk.restart('Xxx')
TkButton.new(nil, 'widgetname'=>'quit', 'command'=>proc{exit}).pack
Tk.mainloop
* tk.rb: TkOption::get always returns a tainted string.
Add TkOption::new_proc_class.
It generates a class to import procedures defined on the resource
database. For example, there is a following resource file.
----< resource-test >------------
*CMD.foo: {|*args| p [$SAFE, :foo, args]}
*CMD.XXX.bar: {|*args| p [$SAFE, :bar, args]}
*Button.command: ruby {p self; p $SAFE; TkOption::CMD::XXX.bar(1,2,3)}
---------------------------------
The following code is a sample of use of the resource file.
e.g.
require 'tk'
TkOption.readfile 'resource-test'
p TkOption.new_proc_class(:CMD, [:foo], 1)
p TkOption.new_proc_class(:XXX, [:bar], 2, false, TkOption::CMD)
TkButton.new(:text=>'test').pack
Tk.mainloop
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2515 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2002-06-04 11:03:33 +04:00
|
|
|
static VALUE
|
|
|
|
set_eventloop_weight(self, loop_max, no_event)
|
|
|
|
VALUE self;
|
|
|
|
VALUE loop_max;
|
|
|
|
VALUE no_event;
|
|
|
|
{
|
|
|
|
int lpmax = NUM2INT(loop_max);
|
|
|
|
int no_ev = NUM2INT(no_event);
|
|
|
|
|
2003-09-07 11:10:44 +04:00
|
|
|
rb_secure(4);
|
|
|
|
|
* tkfont.rb: Fix bugs on TkFont.init_widget_font for Tk8.x.
* tkafter.rb: Add self to 1st argument of interval- and loop-proc
TkAfter#current_interval returns an interval (sleep) time value
TkAfter#current_args returns an array of arguments
TkAfter#return_value returns a return value of last loop-proc
e.g.
TkAfter.new(
proc{|obj| 500 - obj.current_interval}, 10,
[proc{|obj| p obj.current_args}, 'proc', 1],
proc{|obj| p obj.current_args; ['return', 2]},
[proc{|obj|
p obj.return_value
p ['proc', obj.current_args[0].call(obj.return_value[1],
obj.current_args[1])]},
proc{|*args| args[0] + args[1]}, 1],
proc{p ['proc', 4]} ).start(100)
* tk*.rb: Allow to use Symbols for parameters.
Allow new notation of constructor (also allow old notation).
e.g.
TkFrame.new('classname'=>'User'){|base|
pack
f = TkFrame.new(base, :classname=>'ButtonFrame').pack
TkButton.new(
:parent => f,
:text => 'Quit',
:command => proc{exit}
).pack(
:fill => :x,
:pady => 2
)
}
* tkcanvas.rb: (TkcItem) Add 'coords' parameter to the canvas item
constructor (for new notation of constructor).
e.g.
c = TkCanvas.new.pack
l = TkcLine.new(c, :coords=>[[0,0], [100,100]])
* tcltklib.c: New 'mainloop' and 'mainloop_watchdog'.
The priority of their event-loop can be controlled.
They accept an optional argument.
If it false, they don't exit although the root widget is destroyed.
This function is sometimes useful, if it is used with 'restart'.
'mainloop' can't treat Thread#join/value in a callback routine.
(e.g. TkButton.new(:command=>proc{p Thread.new{button.invoke}.value}) )
'mainloop_watchdog' can treat them, but watchdog thread is always running
(so, a little heavier than 'mainloop').
If the purpose of using Thread#join/value is to do something under some
safe-level, please use Proc object.
(e.g. :command=>proc{$SAFE=1;proc{$SAFE=2;button.invoke}.call;p $SAFE})
* tk.rb: Support functions of new 'mainloop' and 'mainloop_watchdog'.
* tk.rb: (Tk.restart) Add 'app-name' paramater and 'use' parameter.
'app-name' specifies the name and the resource class of the
application. If 'app-name' is specified to 'xxx', the application
class on the resource database is set to 'Xxx' and the application
name is changed by the same rule of Tk.appname method. 'use'
specifies the main window for embedding the root widget instead of
generating a new window.
* tk.rb: Add new parameter 'widgetname' to the widget constructor to
support effective use of Resource Database. For example, the
resource 'Xxx*quit.text: QUIT' can set the text of the button
generated by the following code.
e.g.
Tk.restart('Xxx')
TkButton.new(nil, 'widgetname'=>'quit', 'command'=>proc{exit}).pack
Tk.mainloop
* tk.rb: TkOption::get always returns a tainted string.
Add TkOption::new_proc_class.
It generates a class to import procedures defined on the resource
database. For example, there is a following resource file.
----< resource-test >------------
*CMD.foo: {|*args| p [$SAFE, :foo, args]}
*CMD.XXX.bar: {|*args| p [$SAFE, :bar, args]}
*Button.command: ruby {p self; p $SAFE; TkOption::CMD::XXX.bar(1,2,3)}
---------------------------------
The following code is a sample of use of the resource file.
e.g.
require 'tk'
TkOption.readfile 'resource-test'
p TkOption.new_proc_class(:CMD, [:foo], 1)
p TkOption.new_proc_class(:XXX, [:bar], 2, false, TkOption::CMD)
TkButton.new(:text=>'test').pack
Tk.mainloop
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2515 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2002-06-04 11:03:33 +04:00
|
|
|
if (lpmax <= 0 || no_ev <= 0) {
|
2003-07-27 23:35:06 +04:00
|
|
|
rb_raise(rb_eArgError, "weight parameters must be positive numbers");
|
* tkfont.rb: Fix bugs on TkFont.init_widget_font for Tk8.x.
* tkafter.rb: Add self to 1st argument of interval- and loop-proc
TkAfter#current_interval returns an interval (sleep) time value
TkAfter#current_args returns an array of arguments
TkAfter#return_value returns a return value of last loop-proc
e.g.
TkAfter.new(
proc{|obj| 500 - obj.current_interval}, 10,
[proc{|obj| p obj.current_args}, 'proc', 1],
proc{|obj| p obj.current_args; ['return', 2]},
[proc{|obj|
p obj.return_value
p ['proc', obj.current_args[0].call(obj.return_value[1],
obj.current_args[1])]},
proc{|*args| args[0] + args[1]}, 1],
proc{p ['proc', 4]} ).start(100)
* tk*.rb: Allow to use Symbols for parameters.
Allow new notation of constructor (also allow old notation).
e.g.
TkFrame.new('classname'=>'User'){|base|
pack
f = TkFrame.new(base, :classname=>'ButtonFrame').pack
TkButton.new(
:parent => f,
:text => 'Quit',
:command => proc{exit}
).pack(
:fill => :x,
:pady => 2
)
}
* tkcanvas.rb: (TkcItem) Add 'coords' parameter to the canvas item
constructor (for new notation of constructor).
e.g.
c = TkCanvas.new.pack
l = TkcLine.new(c, :coords=>[[0,0], [100,100]])
* tcltklib.c: New 'mainloop' and 'mainloop_watchdog'.
The priority of their event-loop can be controlled.
They accept an optional argument.
If it false, they don't exit although the root widget is destroyed.
This function is sometimes useful, if it is used with 'restart'.
'mainloop' can't treat Thread#join/value in a callback routine.
(e.g. TkButton.new(:command=>proc{p Thread.new{button.invoke}.value}) )
'mainloop_watchdog' can treat them, but watchdog thread is always running
(so, a little heavier than 'mainloop').
If the purpose of using Thread#join/value is to do something under some
safe-level, please use Proc object.
(e.g. :command=>proc{$SAFE=1;proc{$SAFE=2;button.invoke}.call;p $SAFE})
* tk.rb: Support functions of new 'mainloop' and 'mainloop_watchdog'.
* tk.rb: (Tk.restart) Add 'app-name' paramater and 'use' parameter.
'app-name' specifies the name and the resource class of the
application. If 'app-name' is specified to 'xxx', the application
class on the resource database is set to 'Xxx' and the application
name is changed by the same rule of Tk.appname method. 'use'
specifies the main window for embedding the root widget instead of
generating a new window.
* tk.rb: Add new parameter 'widgetname' to the widget constructor to
support effective use of Resource Database. For example, the
resource 'Xxx*quit.text: QUIT' can set the text of the button
generated by the following code.
e.g.
Tk.restart('Xxx')
TkButton.new(nil, 'widgetname'=>'quit', 'command'=>proc{exit}).pack
Tk.mainloop
* tk.rb: TkOption::get always returns a tainted string.
Add TkOption::new_proc_class.
It generates a class to import procedures defined on the resource
database. For example, there is a following resource file.
----< resource-test >------------
*CMD.foo: {|*args| p [$SAFE, :foo, args]}
*CMD.XXX.bar: {|*args| p [$SAFE, :bar, args]}
*Button.command: ruby {p self; p $SAFE; TkOption::CMD::XXX.bar(1,2,3)}
---------------------------------
The following code is a sample of use of the resource file.
e.g.
require 'tk'
TkOption.readfile 'resource-test'
p TkOption.new_proc_class(:CMD, [:foo], 1)
p TkOption.new_proc_class(:XXX, [:bar], 2, false, TkOption::CMD)
TkButton.new(:text=>'test').pack
Tk.mainloop
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2515 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2002-06-04 11:03:33 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
event_loop_max = lpmax;
|
|
|
|
no_event_tick = no_ev;
|
|
|
|
|
|
|
|
return rb_ary_new3(2, loop_max, no_event);
|
|
|
|
}
|
|
|
|
|
|
|
|
static VALUE
|
|
|
|
get_eventloop_weight(self)
|
|
|
|
VALUE self;
|
|
|
|
{
|
|
|
|
return rb_ary_new3(2, INT2NUM(event_loop_max), INT2NUM(no_event_tick));
|
|
|
|
}
|
|
|
|
|
2003-07-27 23:35:06 +04:00
|
|
|
static VALUE
|
2003-08-29 12:34:14 +04:00
|
|
|
ip_set_eventloop_weight(self, loop_max, no_event)
|
|
|
|
VALUE self;
|
|
|
|
VALUE loop_max;
|
|
|
|
VALUE no_event;
|
|
|
|
{
|
|
|
|
struct tcltkip *ptr = get_ip(self);
|
|
|
|
|
|
|
|
if (Tcl_GetMaster(ptr->ip) != (Tcl_Interp*)NULL) {
|
|
|
|
/* slave IP */
|
|
|
|
return get_eventloop_weight(self);
|
|
|
|
}
|
|
|
|
return set_eventloop_weight(self, loop_max, no_event);
|
|
|
|
}
|
|
|
|
|
|
|
|
static VALUE
|
|
|
|
ip_get_eventloop_weight(self)
|
|
|
|
VALUE self;
|
|
|
|
{
|
|
|
|
return get_eventloop_weight(self);
|
|
|
|
}
|
|
|
|
|
|
|
|
static VALUE
|
|
|
|
lib_evloop_abort_on_exc(self)
|
2003-07-27 23:35:06 +04:00
|
|
|
VALUE self;
|
|
|
|
{
|
2003-07-29 19:39:59 +04:00
|
|
|
if (event_loop_abort_on_exc > 0) {
|
|
|
|
return Qtrue;
|
|
|
|
} else if (event_loop_abort_on_exc == 0) {
|
|
|
|
return Qfalse;
|
|
|
|
} else {
|
|
|
|
return Qnil;
|
|
|
|
}
|
2003-07-27 23:35:06 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
static VALUE
|
2003-08-29 12:34:14 +04:00
|
|
|
ip_evloop_abort_on_exc(self)
|
|
|
|
VALUE self;
|
|
|
|
{
|
|
|
|
return lib_evloop_abort_on_exc(self);
|
|
|
|
}
|
|
|
|
|
|
|
|
static VALUE
|
|
|
|
lib_evloop_abort_on_exc_set(self, val)
|
2003-07-27 23:35:06 +04:00
|
|
|
VALUE self, val;
|
|
|
|
{
|
|
|
|
rb_secure(4);
|
2003-07-29 19:39:59 +04:00
|
|
|
if (RTEST(val)) {
|
|
|
|
event_loop_abort_on_exc = 1;
|
|
|
|
} else if (val == Qnil) {
|
|
|
|
event_loop_abort_on_exc = -1;
|
|
|
|
} else {
|
|
|
|
event_loop_abort_on_exc = 0;
|
|
|
|
}
|
2003-08-29 12:34:14 +04:00
|
|
|
return lib_evloop_abort_on_exc(self);
|
|
|
|
}
|
|
|
|
|
|
|
|
static VALUE
|
|
|
|
ip_evloop_abort_on_exc_set(self, val)
|
|
|
|
VALUE self, val;
|
|
|
|
{
|
|
|
|
struct tcltkip *ptr = get_ip(self);
|
|
|
|
|
2003-09-07 11:10:44 +04:00
|
|
|
rb_secure(4);
|
2003-08-29 12:34:14 +04:00
|
|
|
if (Tcl_GetMaster(ptr->ip) != (Tcl_Interp*)NULL) {
|
|
|
|
/* slave IP */
|
|
|
|
return lib_evloop_abort_on_exc(self);
|
|
|
|
}
|
|
|
|
return lib_evloop_abort_on_exc_set(self, val);
|
|
|
|
}
|
|
|
|
|
|
|
|
static VALUE
|
|
|
|
lib_num_of_mainwindows(self)
|
|
|
|
VALUE self;
|
|
|
|
{
|
|
|
|
return INT2FIX(Tk_GetNumMainWindows());
|
2003-07-27 23:35:06 +04:00
|
|
|
}
|
|
|
|
|
2003-10-14 19:25:45 +04:00
|
|
|
static int
|
|
|
|
lib_eventloop_core(check_root, check_var)
|
|
|
|
int check_root;
|
|
|
|
int *check_var;
|
* tkfont.rb: Fix bugs on TkFont.init_widget_font for Tk8.x.
* tkafter.rb: Add self to 1st argument of interval- and loop-proc
TkAfter#current_interval returns an interval (sleep) time value
TkAfter#current_args returns an array of arguments
TkAfter#return_value returns a return value of last loop-proc
e.g.
TkAfter.new(
proc{|obj| 500 - obj.current_interval}, 10,
[proc{|obj| p obj.current_args}, 'proc', 1],
proc{|obj| p obj.current_args; ['return', 2]},
[proc{|obj|
p obj.return_value
p ['proc', obj.current_args[0].call(obj.return_value[1],
obj.current_args[1])]},
proc{|*args| args[0] + args[1]}, 1],
proc{p ['proc', 4]} ).start(100)
* tk*.rb: Allow to use Symbols for parameters.
Allow new notation of constructor (also allow old notation).
e.g.
TkFrame.new('classname'=>'User'){|base|
pack
f = TkFrame.new(base, :classname=>'ButtonFrame').pack
TkButton.new(
:parent => f,
:text => 'Quit',
:command => proc{exit}
).pack(
:fill => :x,
:pady => 2
)
}
* tkcanvas.rb: (TkcItem) Add 'coords' parameter to the canvas item
constructor (for new notation of constructor).
e.g.
c = TkCanvas.new.pack
l = TkcLine.new(c, :coords=>[[0,0], [100,100]])
* tcltklib.c: New 'mainloop' and 'mainloop_watchdog'.
The priority of their event-loop can be controlled.
They accept an optional argument.
If it false, they don't exit although the root widget is destroyed.
This function is sometimes useful, if it is used with 'restart'.
'mainloop' can't treat Thread#join/value in a callback routine.
(e.g. TkButton.new(:command=>proc{p Thread.new{button.invoke}.value}) )
'mainloop_watchdog' can treat them, but watchdog thread is always running
(so, a little heavier than 'mainloop').
If the purpose of using Thread#join/value is to do something under some
safe-level, please use Proc object.
(e.g. :command=>proc{$SAFE=1;proc{$SAFE=2;button.invoke}.call;p $SAFE})
* tk.rb: Support functions of new 'mainloop' and 'mainloop_watchdog'.
* tk.rb: (Tk.restart) Add 'app-name' paramater and 'use' parameter.
'app-name' specifies the name and the resource class of the
application. If 'app-name' is specified to 'xxx', the application
class on the resource database is set to 'Xxx' and the application
name is changed by the same rule of Tk.appname method. 'use'
specifies the main window for embedding the root widget instead of
generating a new window.
* tk.rb: Add new parameter 'widgetname' to the widget constructor to
support effective use of Resource Database. For example, the
resource 'Xxx*quit.text: QUIT' can set the text of the button
generated by the following code.
e.g.
Tk.restart('Xxx')
TkButton.new(nil, 'widgetname'=>'quit', 'command'=>proc{exit}).pack
Tk.mainloop
* tk.rb: TkOption::get always returns a tainted string.
Add TkOption::new_proc_class.
It generates a class to import procedures defined on the resource
database. For example, there is a following resource file.
----< resource-test >------------
*CMD.foo: {|*args| p [$SAFE, :foo, args]}
*CMD.XXX.bar: {|*args| p [$SAFE, :bar, args]}
*Button.command: ruby {p self; p $SAFE; TkOption::CMD::XXX.bar(1,2,3)}
---------------------------------
The following code is a sample of use of the resource file.
e.g.
require 'tk'
TkOption.readfile 'resource-test'
p TkOption.new_proc_class(:CMD, [:foo], 1)
p TkOption.new_proc_class(:XXX, [:bar], 2, false, TkOption::CMD)
TkButton.new(:text=>'test').pack
Tk.mainloop
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2515 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2002-06-04 11:03:33 +04:00
|
|
|
{
|
2003-07-27 23:35:06 +04:00
|
|
|
VALUE current = eventloop_thread;
|
2003-10-14 19:25:45 +04:00
|
|
|
int found_event = 1;
|
2003-07-27 23:35:06 +04:00
|
|
|
struct timeval t;
|
2003-06-09 19:50:24 +04:00
|
|
|
|
2003-07-27 23:35:06 +04:00
|
|
|
t.tv_sec = (time_t)0;
|
|
|
|
t.tv_usec = (time_t)(no_event_wait*1000.0);
|
|
|
|
|
|
|
|
Tk_DeleteTimerHandler(timer_token);
|
|
|
|
run_timer_flag = 0;
|
|
|
|
if (timer_tick > 0) {
|
2003-06-09 19:50:24 +04:00
|
|
|
timer_token = Tk_CreateTimerHandler(timer_tick, _timer_for_tcl,
|
|
|
|
(ClientData)0);
|
|
|
|
} else {
|
2003-07-27 23:35:06 +04:00
|
|
|
timer_token = (Tcl_TimerToken)NULL;
|
|
|
|
}
|
2003-06-09 19:50:24 +04:00
|
|
|
|
2003-07-27 23:35:06 +04:00
|
|
|
for(;;) {
|
|
|
|
if (rb_thread_alone()) {
|
|
|
|
DUMP1("no other thread");
|
2003-07-29 05:24:32 +04:00
|
|
|
event_loop_wait_event = 0;
|
|
|
|
|
2003-07-27 23:35:06 +04:00
|
|
|
if (timer_tick == 0) {
|
|
|
|
timer_tick = NO_THREAD_INTERRUPT_TIME;
|
|
|
|
timer_token = Tk_CreateTimerHandler(timer_tick,
|
|
|
|
_timer_for_tcl,
|
|
|
|
(ClientData)0);
|
|
|
|
}
|
|
|
|
|
2003-10-14 19:25:45 +04:00
|
|
|
if (check_var != (int *)NULL) {
|
|
|
|
if (*check_var || !found_event) {
|
|
|
|
return found_event;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
found_event = Tcl_DoOneEvent(TCL_ALL_EVENTS);
|
2003-07-27 23:35:06 +04:00
|
|
|
|
|
|
|
if (loop_counter++ > 30000) {
|
|
|
|
loop_counter = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (run_timer_flag) {
|
2003-10-14 19:25:45 +04:00
|
|
|
/*
|
2003-07-27 23:35:06 +04:00
|
|
|
DUMP1("timer interrupt");
|
|
|
|
run_timer_flag = 0;
|
2003-09-07 11:10:44 +04:00
|
|
|
DUMP1("call rb_trap_exec()");
|
|
|
|
rb_trap_exec();
|
2003-10-14 19:25:45 +04:00
|
|
|
*/
|
2003-07-27 23:35:06 +04:00
|
|
|
DUMP1("check Root Widget");
|
2003-10-14 19:25:45 +04:00
|
|
|
if (check_root && Tk_GetNumMainWindows() == 0) {
|
|
|
|
run_timer_flag = 0;
|
|
|
|
rb_trap_exec();
|
|
|
|
return 1;
|
2003-07-27 23:35:06 +04:00
|
|
|
}
|
|
|
|
}
|
2003-06-09 19:50:24 +04:00
|
|
|
|
2003-07-27 23:35:06 +04:00
|
|
|
} else {
|
2003-10-14 19:25:45 +04:00
|
|
|
int tick_counter;
|
|
|
|
|
2003-07-27 23:35:06 +04:00
|
|
|
DUMP1("there are other threads");
|
2003-07-29 05:24:32 +04:00
|
|
|
event_loop_wait_event = 1;
|
|
|
|
|
2003-10-14 19:25:45 +04:00
|
|
|
found_event = 1;
|
|
|
|
|
2003-07-27 23:35:06 +04:00
|
|
|
timer_tick = req_timer_tick;
|
|
|
|
tick_counter = 0;
|
|
|
|
while(tick_counter < event_loop_max) {
|
2003-10-14 19:25:45 +04:00
|
|
|
if (check_var != (int *)NULL) {
|
|
|
|
if (*check_var || !found_event) {
|
|
|
|
return found_event;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-11-08 00:39:36 +03:00
|
|
|
found_event = Tcl_DoOneEvent(TCL_ALL_EVENTS | TCL_DONT_WAIT);
|
|
|
|
|
|
|
|
if (found_event) {
|
2003-07-27 23:35:06 +04:00
|
|
|
tick_counter++;
|
|
|
|
} else {
|
|
|
|
tick_counter += no_event_tick;
|
|
|
|
|
|
|
|
DUMP1("check Root Widget");
|
2003-10-14 19:25:45 +04:00
|
|
|
if (check_root && Tk_GetNumMainWindows() == 0) {
|
|
|
|
return 1;
|
2003-07-27 23:35:06 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
rb_thread_wait_for(t);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (loop_counter++ > 30000) {
|
|
|
|
loop_counter = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (watchdog_thread != 0 && eventloop_thread != current) {
|
2003-10-14 19:25:45 +04:00
|
|
|
return 1;
|
2003-07-27 23:35:06 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
if (run_timer_flag) {
|
2003-10-14 19:25:45 +04:00
|
|
|
/*
|
2003-07-27 23:35:06 +04:00
|
|
|
DUMP1("timer interrupt");
|
|
|
|
run_timer_flag = 0;
|
2003-10-14 19:25:45 +04:00
|
|
|
*/
|
2003-07-27 23:35:06 +04:00
|
|
|
break; /* switch to other thread */
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
DUMP1("check Root Widget");
|
2003-10-14 19:25:45 +04:00
|
|
|
if (check_root && Tk_GetNumMainWindows() == 0) {
|
|
|
|
return 1;
|
2003-07-27 23:35:06 +04:00
|
|
|
}
|
2003-06-09 19:50:24 +04:00
|
|
|
}
|
|
|
|
|
2003-10-14 19:25:45 +04:00
|
|
|
/* rb_thread_schedule(); */
|
|
|
|
if (run_timer_flag) {
|
|
|
|
run_timer_flag = 0;
|
|
|
|
rb_trap_exec();
|
|
|
|
} else {
|
|
|
|
DUMP1("thread scheduling");
|
|
|
|
rb_thread_schedule();
|
|
|
|
}
|
1999-08-13 09:37:52 +04:00
|
|
|
}
|
2003-10-14 19:25:45 +04:00
|
|
|
return 1;
|
1999-01-20 07:59:39 +03:00
|
|
|
}
|
1998-01-16 15:19:09 +03:00
|
|
|
|
* tkfont.rb: Fix bugs on TkFont.init_widget_font for Tk8.x.
* tkafter.rb: Add self to 1st argument of interval- and loop-proc
TkAfter#current_interval returns an interval (sleep) time value
TkAfter#current_args returns an array of arguments
TkAfter#return_value returns a return value of last loop-proc
e.g.
TkAfter.new(
proc{|obj| 500 - obj.current_interval}, 10,
[proc{|obj| p obj.current_args}, 'proc', 1],
proc{|obj| p obj.current_args; ['return', 2]},
[proc{|obj|
p obj.return_value
p ['proc', obj.current_args[0].call(obj.return_value[1],
obj.current_args[1])]},
proc{|*args| args[0] + args[1]}, 1],
proc{p ['proc', 4]} ).start(100)
* tk*.rb: Allow to use Symbols for parameters.
Allow new notation of constructor (also allow old notation).
e.g.
TkFrame.new('classname'=>'User'){|base|
pack
f = TkFrame.new(base, :classname=>'ButtonFrame').pack
TkButton.new(
:parent => f,
:text => 'Quit',
:command => proc{exit}
).pack(
:fill => :x,
:pady => 2
)
}
* tkcanvas.rb: (TkcItem) Add 'coords' parameter to the canvas item
constructor (for new notation of constructor).
e.g.
c = TkCanvas.new.pack
l = TkcLine.new(c, :coords=>[[0,0], [100,100]])
* tcltklib.c: New 'mainloop' and 'mainloop_watchdog'.
The priority of their event-loop can be controlled.
They accept an optional argument.
If it false, they don't exit although the root widget is destroyed.
This function is sometimes useful, if it is used with 'restart'.
'mainloop' can't treat Thread#join/value in a callback routine.
(e.g. TkButton.new(:command=>proc{p Thread.new{button.invoke}.value}) )
'mainloop_watchdog' can treat them, but watchdog thread is always running
(so, a little heavier than 'mainloop').
If the purpose of using Thread#join/value is to do something under some
safe-level, please use Proc object.
(e.g. :command=>proc{$SAFE=1;proc{$SAFE=2;button.invoke}.call;p $SAFE})
* tk.rb: Support functions of new 'mainloop' and 'mainloop_watchdog'.
* tk.rb: (Tk.restart) Add 'app-name' paramater and 'use' parameter.
'app-name' specifies the name and the resource class of the
application. If 'app-name' is specified to 'xxx', the application
class on the resource database is set to 'Xxx' and the application
name is changed by the same rule of Tk.appname method. 'use'
specifies the main window for embedding the root widget instead of
generating a new window.
* tk.rb: Add new parameter 'widgetname' to the widget constructor to
support effective use of Resource Database. For example, the
resource 'Xxx*quit.text: QUIT' can set the text of the button
generated by the following code.
e.g.
Tk.restart('Xxx')
TkButton.new(nil, 'widgetname'=>'quit', 'command'=>proc{exit}).pack
Tk.mainloop
* tk.rb: TkOption::get always returns a tainted string.
Add TkOption::new_proc_class.
It generates a class to import procedures defined on the resource
database. For example, there is a following resource file.
----< resource-test >------------
*CMD.foo: {|*args| p [$SAFE, :foo, args]}
*CMD.XXX.bar: {|*args| p [$SAFE, :bar, args]}
*Button.command: ruby {p self; p $SAFE; TkOption::CMD::XXX.bar(1,2,3)}
---------------------------------
The following code is a sample of use of the resource file.
e.g.
require 'tk'
TkOption.readfile 'resource-test'
p TkOption.new_proc_class(:CMD, [:foo], 1)
p TkOption.new_proc_class(:XXX, [:bar], 2, false, TkOption::CMD)
TkButton.new(:text=>'test').pack
Tk.mainloop
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2515 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2002-06-04 11:03:33 +04:00
|
|
|
VALUE
|
2003-10-14 19:25:45 +04:00
|
|
|
lib_eventloop_main(check_rootwidget)
|
|
|
|
VALUE check_rootwidget;
|
|
|
|
{
|
|
|
|
check_rootwidget_flag = RTEST(check_rootwidget);
|
|
|
|
|
|
|
|
if (lib_eventloop_core(check_rootwidget_flag, (int *)NULL)) {
|
|
|
|
return Qtrue;
|
|
|
|
} else {
|
|
|
|
return Qfalse;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
VALUE
|
|
|
|
lib_eventloop_ensure(parent_evloop)
|
* tkfont.rb: Fix bugs on TkFont.init_widget_font for Tk8.x.
* tkafter.rb: Add self to 1st argument of interval- and loop-proc
TkAfter#current_interval returns an interval (sleep) time value
TkAfter#current_args returns an array of arguments
TkAfter#return_value returns a return value of last loop-proc
e.g.
TkAfter.new(
proc{|obj| 500 - obj.current_interval}, 10,
[proc{|obj| p obj.current_args}, 'proc', 1],
proc{|obj| p obj.current_args; ['return', 2]},
[proc{|obj|
p obj.return_value
p ['proc', obj.current_args[0].call(obj.return_value[1],
obj.current_args[1])]},
proc{|*args| args[0] + args[1]}, 1],
proc{p ['proc', 4]} ).start(100)
* tk*.rb: Allow to use Symbols for parameters.
Allow new notation of constructor (also allow old notation).
e.g.
TkFrame.new('classname'=>'User'){|base|
pack
f = TkFrame.new(base, :classname=>'ButtonFrame').pack
TkButton.new(
:parent => f,
:text => 'Quit',
:command => proc{exit}
).pack(
:fill => :x,
:pady => 2
)
}
* tkcanvas.rb: (TkcItem) Add 'coords' parameter to the canvas item
constructor (for new notation of constructor).
e.g.
c = TkCanvas.new.pack
l = TkcLine.new(c, :coords=>[[0,0], [100,100]])
* tcltklib.c: New 'mainloop' and 'mainloop_watchdog'.
The priority of their event-loop can be controlled.
They accept an optional argument.
If it false, they don't exit although the root widget is destroyed.
This function is sometimes useful, if it is used with 'restart'.
'mainloop' can't treat Thread#join/value in a callback routine.
(e.g. TkButton.new(:command=>proc{p Thread.new{button.invoke}.value}) )
'mainloop_watchdog' can treat them, but watchdog thread is always running
(so, a little heavier than 'mainloop').
If the purpose of using Thread#join/value is to do something under some
safe-level, please use Proc object.
(e.g. :command=>proc{$SAFE=1;proc{$SAFE=2;button.invoke}.call;p $SAFE})
* tk.rb: Support functions of new 'mainloop' and 'mainloop_watchdog'.
* tk.rb: (Tk.restart) Add 'app-name' paramater and 'use' parameter.
'app-name' specifies the name and the resource class of the
application. If 'app-name' is specified to 'xxx', the application
class on the resource database is set to 'Xxx' and the application
name is changed by the same rule of Tk.appname method. 'use'
specifies the main window for embedding the root widget instead of
generating a new window.
* tk.rb: Add new parameter 'widgetname' to the widget constructor to
support effective use of Resource Database. For example, the
resource 'Xxx*quit.text: QUIT' can set the text of the button
generated by the following code.
e.g.
Tk.restart('Xxx')
TkButton.new(nil, 'widgetname'=>'quit', 'command'=>proc{exit}).pack
Tk.mainloop
* tk.rb: TkOption::get always returns a tainted string.
Add TkOption::new_proc_class.
It generates a class to import procedures defined on the resource
database. For example, there is a following resource file.
----< resource-test >------------
*CMD.foo: {|*args| p [$SAFE, :foo, args]}
*CMD.XXX.bar: {|*args| p [$SAFE, :bar, args]}
*Button.command: ruby {p self; p $SAFE; TkOption::CMD::XXX.bar(1,2,3)}
---------------------------------
The following code is a sample of use of the resource file.
e.g.
require 'tk'
TkOption.readfile 'resource-test'
p TkOption.new_proc_class(:CMD, [:foo], 1)
p TkOption.new_proc_class(:XXX, [:bar], 2, false, TkOption::CMD)
TkButton.new(:text=>'test').pack
Tk.mainloop
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2515 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2002-06-04 11:03:33 +04:00
|
|
|
VALUE parent_evloop;
|
|
|
|
{
|
|
|
|
Tk_DeleteTimerHandler(timer_token);
|
|
|
|
timer_token = (Tcl_TimerToken)NULL;
|
2003-10-14 19:25:45 +04:00
|
|
|
DUMP2("eventloop-ensure: current-thread : %lx\n", rb_thread_current());
|
|
|
|
DUMP2("eventloop-ensure: eventloop-thread : %lx\n", eventloop_thread);
|
2002-06-05 05:56:47 +04:00
|
|
|
if (eventloop_thread == rb_thread_current()) {
|
2003-07-29 19:39:59 +04:00
|
|
|
DUMP2("eventloop-thread -> %lx\n", parent_evloop);
|
2003-07-27 23:35:06 +04:00
|
|
|
eventloop_thread = parent_evloop;
|
2002-06-05 05:56:47 +04:00
|
|
|
}
|
* tkfont.rb: Fix bugs on TkFont.init_widget_font for Tk8.x.
* tkafter.rb: Add self to 1st argument of interval- and loop-proc
TkAfter#current_interval returns an interval (sleep) time value
TkAfter#current_args returns an array of arguments
TkAfter#return_value returns a return value of last loop-proc
e.g.
TkAfter.new(
proc{|obj| 500 - obj.current_interval}, 10,
[proc{|obj| p obj.current_args}, 'proc', 1],
proc{|obj| p obj.current_args; ['return', 2]},
[proc{|obj|
p obj.return_value
p ['proc', obj.current_args[0].call(obj.return_value[1],
obj.current_args[1])]},
proc{|*args| args[0] + args[1]}, 1],
proc{p ['proc', 4]} ).start(100)
* tk*.rb: Allow to use Symbols for parameters.
Allow new notation of constructor (also allow old notation).
e.g.
TkFrame.new('classname'=>'User'){|base|
pack
f = TkFrame.new(base, :classname=>'ButtonFrame').pack
TkButton.new(
:parent => f,
:text => 'Quit',
:command => proc{exit}
).pack(
:fill => :x,
:pady => 2
)
}
* tkcanvas.rb: (TkcItem) Add 'coords' parameter to the canvas item
constructor (for new notation of constructor).
e.g.
c = TkCanvas.new.pack
l = TkcLine.new(c, :coords=>[[0,0], [100,100]])
* tcltklib.c: New 'mainloop' and 'mainloop_watchdog'.
The priority of their event-loop can be controlled.
They accept an optional argument.
If it false, they don't exit although the root widget is destroyed.
This function is sometimes useful, if it is used with 'restart'.
'mainloop' can't treat Thread#join/value in a callback routine.
(e.g. TkButton.new(:command=>proc{p Thread.new{button.invoke}.value}) )
'mainloop_watchdog' can treat them, but watchdog thread is always running
(so, a little heavier than 'mainloop').
If the purpose of using Thread#join/value is to do something under some
safe-level, please use Proc object.
(e.g. :command=>proc{$SAFE=1;proc{$SAFE=2;button.invoke}.call;p $SAFE})
* tk.rb: Support functions of new 'mainloop' and 'mainloop_watchdog'.
* tk.rb: (Tk.restart) Add 'app-name' paramater and 'use' parameter.
'app-name' specifies the name and the resource class of the
application. If 'app-name' is specified to 'xxx', the application
class on the resource database is set to 'Xxx' and the application
name is changed by the same rule of Tk.appname method. 'use'
specifies the main window for embedding the root widget instead of
generating a new window.
* tk.rb: Add new parameter 'widgetname' to the widget constructor to
support effective use of Resource Database. For example, the
resource 'Xxx*quit.text: QUIT' can set the text of the button
generated by the following code.
e.g.
Tk.restart('Xxx')
TkButton.new(nil, 'widgetname'=>'quit', 'command'=>proc{exit}).pack
Tk.mainloop
* tk.rb: TkOption::get always returns a tainted string.
Add TkOption::new_proc_class.
It generates a class to import procedures defined on the resource
database. For example, there is a following resource file.
----< resource-test >------------
*CMD.foo: {|*args| p [$SAFE, :foo, args]}
*CMD.XXX.bar: {|*args| p [$SAFE, :bar, args]}
*Button.command: ruby {p self; p $SAFE; TkOption::CMD::XXX.bar(1,2,3)}
---------------------------------
The following code is a sample of use of the resource file.
e.g.
require 'tk'
TkOption.readfile 'resource-test'
p TkOption.new_proc_class(:CMD, [:foo], 1)
p TkOption.new_proc_class(:XXX, [:bar], 2, false, TkOption::CMD)
TkButton.new(:text=>'test').pack
Tk.mainloop
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2515 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2002-06-04 11:03:33 +04:00
|
|
|
return Qnil;
|
|
|
|
}
|
|
|
|
|
|
|
|
static VALUE
|
2003-10-14 19:25:45 +04:00
|
|
|
lib_eventloop_launcher(check_rootwidget)
|
* tkfont.rb: Fix bugs on TkFont.init_widget_font for Tk8.x.
* tkafter.rb: Add self to 1st argument of interval- and loop-proc
TkAfter#current_interval returns an interval (sleep) time value
TkAfter#current_args returns an array of arguments
TkAfter#return_value returns a return value of last loop-proc
e.g.
TkAfter.new(
proc{|obj| 500 - obj.current_interval}, 10,
[proc{|obj| p obj.current_args}, 'proc', 1],
proc{|obj| p obj.current_args; ['return', 2]},
[proc{|obj|
p obj.return_value
p ['proc', obj.current_args[0].call(obj.return_value[1],
obj.current_args[1])]},
proc{|*args| args[0] + args[1]}, 1],
proc{p ['proc', 4]} ).start(100)
* tk*.rb: Allow to use Symbols for parameters.
Allow new notation of constructor (also allow old notation).
e.g.
TkFrame.new('classname'=>'User'){|base|
pack
f = TkFrame.new(base, :classname=>'ButtonFrame').pack
TkButton.new(
:parent => f,
:text => 'Quit',
:command => proc{exit}
).pack(
:fill => :x,
:pady => 2
)
}
* tkcanvas.rb: (TkcItem) Add 'coords' parameter to the canvas item
constructor (for new notation of constructor).
e.g.
c = TkCanvas.new.pack
l = TkcLine.new(c, :coords=>[[0,0], [100,100]])
* tcltklib.c: New 'mainloop' and 'mainloop_watchdog'.
The priority of their event-loop can be controlled.
They accept an optional argument.
If it false, they don't exit although the root widget is destroyed.
This function is sometimes useful, if it is used with 'restart'.
'mainloop' can't treat Thread#join/value in a callback routine.
(e.g. TkButton.new(:command=>proc{p Thread.new{button.invoke}.value}) )
'mainloop_watchdog' can treat them, but watchdog thread is always running
(so, a little heavier than 'mainloop').
If the purpose of using Thread#join/value is to do something under some
safe-level, please use Proc object.
(e.g. :command=>proc{$SAFE=1;proc{$SAFE=2;button.invoke}.call;p $SAFE})
* tk.rb: Support functions of new 'mainloop' and 'mainloop_watchdog'.
* tk.rb: (Tk.restart) Add 'app-name' paramater and 'use' parameter.
'app-name' specifies the name and the resource class of the
application. If 'app-name' is specified to 'xxx', the application
class on the resource database is set to 'Xxx' and the application
name is changed by the same rule of Tk.appname method. 'use'
specifies the main window for embedding the root widget instead of
generating a new window.
* tk.rb: Add new parameter 'widgetname' to the widget constructor to
support effective use of Resource Database. For example, the
resource 'Xxx*quit.text: QUIT' can set the text of the button
generated by the following code.
e.g.
Tk.restart('Xxx')
TkButton.new(nil, 'widgetname'=>'quit', 'command'=>proc{exit}).pack
Tk.mainloop
* tk.rb: TkOption::get always returns a tainted string.
Add TkOption::new_proc_class.
It generates a class to import procedures defined on the resource
database. For example, there is a following resource file.
----< resource-test >------------
*CMD.foo: {|*args| p [$SAFE, :foo, args]}
*CMD.XXX.bar: {|*args| p [$SAFE, :bar, args]}
*Button.command: ruby {p self; p $SAFE; TkOption::CMD::XXX.bar(1,2,3)}
---------------------------------
The following code is a sample of use of the resource file.
e.g.
require 'tk'
TkOption.readfile 'resource-test'
p TkOption.new_proc_class(:CMD, [:foo], 1)
p TkOption.new_proc_class(:XXX, [:bar], 2, false, TkOption::CMD)
TkButton.new(:text=>'test').pack
Tk.mainloop
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2515 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2002-06-04 11:03:33 +04:00
|
|
|
VALUE check_rootwidget;
|
|
|
|
{
|
|
|
|
VALUE parent_evloop = eventloop_thread;
|
|
|
|
|
|
|
|
eventloop_thread = rb_thread_current();
|
|
|
|
|
|
|
|
if (ruby_debug) {
|
2003-07-27 23:35:06 +04:00
|
|
|
fprintf(stderr, "tcltklib: eventloop-thread : %lx -> %lx\n",
|
|
|
|
parent_evloop, eventloop_thread);
|
* tkfont.rb: Fix bugs on TkFont.init_widget_font for Tk8.x.
* tkafter.rb: Add self to 1st argument of interval- and loop-proc
TkAfter#current_interval returns an interval (sleep) time value
TkAfter#current_args returns an array of arguments
TkAfter#return_value returns a return value of last loop-proc
e.g.
TkAfter.new(
proc{|obj| 500 - obj.current_interval}, 10,
[proc{|obj| p obj.current_args}, 'proc', 1],
proc{|obj| p obj.current_args; ['return', 2]},
[proc{|obj|
p obj.return_value
p ['proc', obj.current_args[0].call(obj.return_value[1],
obj.current_args[1])]},
proc{|*args| args[0] + args[1]}, 1],
proc{p ['proc', 4]} ).start(100)
* tk*.rb: Allow to use Symbols for parameters.
Allow new notation of constructor (also allow old notation).
e.g.
TkFrame.new('classname'=>'User'){|base|
pack
f = TkFrame.new(base, :classname=>'ButtonFrame').pack
TkButton.new(
:parent => f,
:text => 'Quit',
:command => proc{exit}
).pack(
:fill => :x,
:pady => 2
)
}
* tkcanvas.rb: (TkcItem) Add 'coords' parameter to the canvas item
constructor (for new notation of constructor).
e.g.
c = TkCanvas.new.pack
l = TkcLine.new(c, :coords=>[[0,0], [100,100]])
* tcltklib.c: New 'mainloop' and 'mainloop_watchdog'.
The priority of their event-loop can be controlled.
They accept an optional argument.
If it false, they don't exit although the root widget is destroyed.
This function is sometimes useful, if it is used with 'restart'.
'mainloop' can't treat Thread#join/value in a callback routine.
(e.g. TkButton.new(:command=>proc{p Thread.new{button.invoke}.value}) )
'mainloop_watchdog' can treat them, but watchdog thread is always running
(so, a little heavier than 'mainloop').
If the purpose of using Thread#join/value is to do something under some
safe-level, please use Proc object.
(e.g. :command=>proc{$SAFE=1;proc{$SAFE=2;button.invoke}.call;p $SAFE})
* tk.rb: Support functions of new 'mainloop' and 'mainloop_watchdog'.
* tk.rb: (Tk.restart) Add 'app-name' paramater and 'use' parameter.
'app-name' specifies the name and the resource class of the
application. If 'app-name' is specified to 'xxx', the application
class on the resource database is set to 'Xxx' and the application
name is changed by the same rule of Tk.appname method. 'use'
specifies the main window for embedding the root widget instead of
generating a new window.
* tk.rb: Add new parameter 'widgetname' to the widget constructor to
support effective use of Resource Database. For example, the
resource 'Xxx*quit.text: QUIT' can set the text of the button
generated by the following code.
e.g.
Tk.restart('Xxx')
TkButton.new(nil, 'widgetname'=>'quit', 'command'=>proc{exit}).pack
Tk.mainloop
* tk.rb: TkOption::get always returns a tainted string.
Add TkOption::new_proc_class.
It generates a class to import procedures defined on the resource
database. For example, there is a following resource file.
----< resource-test >------------
*CMD.foo: {|*args| p [$SAFE, :foo, args]}
*CMD.XXX.bar: {|*args| p [$SAFE, :bar, args]}
*Button.command: ruby {p self; p $SAFE; TkOption::CMD::XXX.bar(1,2,3)}
---------------------------------
The following code is a sample of use of the resource file.
e.g.
require 'tk'
TkOption.readfile 'resource-test'
p TkOption.new_proc_class(:CMD, [:foo], 1)
p TkOption.new_proc_class(:XXX, [:bar], 2, false, TkOption::CMD)
TkButton.new(:text=>'test').pack
Tk.mainloop
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2515 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2002-06-04 11:03:33 +04:00
|
|
|
}
|
|
|
|
|
2003-10-14 19:25:45 +04:00
|
|
|
return rb_ensure(lib_eventloop_main, check_rootwidget,
|
|
|
|
lib_eventloop_ensure, parent_evloop);
|
* tkfont.rb: Fix bugs on TkFont.init_widget_font for Tk8.x.
* tkafter.rb: Add self to 1st argument of interval- and loop-proc
TkAfter#current_interval returns an interval (sleep) time value
TkAfter#current_args returns an array of arguments
TkAfter#return_value returns a return value of last loop-proc
e.g.
TkAfter.new(
proc{|obj| 500 - obj.current_interval}, 10,
[proc{|obj| p obj.current_args}, 'proc', 1],
proc{|obj| p obj.current_args; ['return', 2]},
[proc{|obj|
p obj.return_value
p ['proc', obj.current_args[0].call(obj.return_value[1],
obj.current_args[1])]},
proc{|*args| args[0] + args[1]}, 1],
proc{p ['proc', 4]} ).start(100)
* tk*.rb: Allow to use Symbols for parameters.
Allow new notation of constructor (also allow old notation).
e.g.
TkFrame.new('classname'=>'User'){|base|
pack
f = TkFrame.new(base, :classname=>'ButtonFrame').pack
TkButton.new(
:parent => f,
:text => 'Quit',
:command => proc{exit}
).pack(
:fill => :x,
:pady => 2
)
}
* tkcanvas.rb: (TkcItem) Add 'coords' parameter to the canvas item
constructor (for new notation of constructor).
e.g.
c = TkCanvas.new.pack
l = TkcLine.new(c, :coords=>[[0,0], [100,100]])
* tcltklib.c: New 'mainloop' and 'mainloop_watchdog'.
The priority of their event-loop can be controlled.
They accept an optional argument.
If it false, they don't exit although the root widget is destroyed.
This function is sometimes useful, if it is used with 'restart'.
'mainloop' can't treat Thread#join/value in a callback routine.
(e.g. TkButton.new(:command=>proc{p Thread.new{button.invoke}.value}) )
'mainloop_watchdog' can treat them, but watchdog thread is always running
(so, a little heavier than 'mainloop').
If the purpose of using Thread#join/value is to do something under some
safe-level, please use Proc object.
(e.g. :command=>proc{$SAFE=1;proc{$SAFE=2;button.invoke}.call;p $SAFE})
* tk.rb: Support functions of new 'mainloop' and 'mainloop_watchdog'.
* tk.rb: (Tk.restart) Add 'app-name' paramater and 'use' parameter.
'app-name' specifies the name and the resource class of the
application. If 'app-name' is specified to 'xxx', the application
class on the resource database is set to 'Xxx' and the application
name is changed by the same rule of Tk.appname method. 'use'
specifies the main window for embedding the root widget instead of
generating a new window.
* tk.rb: Add new parameter 'widgetname' to the widget constructor to
support effective use of Resource Database. For example, the
resource 'Xxx*quit.text: QUIT' can set the text of the button
generated by the following code.
e.g.
Tk.restart('Xxx')
TkButton.new(nil, 'widgetname'=>'quit', 'command'=>proc{exit}).pack
Tk.mainloop
* tk.rb: TkOption::get always returns a tainted string.
Add TkOption::new_proc_class.
It generates a class to import procedures defined on the resource
database. For example, there is a following resource file.
----< resource-test >------------
*CMD.foo: {|*args| p [$SAFE, :foo, args]}
*CMD.XXX.bar: {|*args| p [$SAFE, :bar, args]}
*Button.command: ruby {p self; p $SAFE; TkOption::CMD::XXX.bar(1,2,3)}
---------------------------------
The following code is a sample of use of the resource file.
e.g.
require 'tk'
TkOption.readfile 'resource-test'
p TkOption.new_proc_class(:CMD, [:foo], 1)
p TkOption.new_proc_class(:XXX, [:bar], 2, false, TkOption::CMD)
TkButton.new(:text=>'test').pack
Tk.mainloop
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2515 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2002-06-04 11:03:33 +04:00
|
|
|
}
|
2002-04-01 10:21:24 +04:00
|
|
|
|
1998-01-16 15:19:09 +03:00
|
|
|
/* execute Tk_MainLoop */
|
|
|
|
static VALUE
|
* tkfont.rb: Fix bugs on TkFont.init_widget_font for Tk8.x.
* tkafter.rb: Add self to 1st argument of interval- and loop-proc
TkAfter#current_interval returns an interval (sleep) time value
TkAfter#current_args returns an array of arguments
TkAfter#return_value returns a return value of last loop-proc
e.g.
TkAfter.new(
proc{|obj| 500 - obj.current_interval}, 10,
[proc{|obj| p obj.current_args}, 'proc', 1],
proc{|obj| p obj.current_args; ['return', 2]},
[proc{|obj|
p obj.return_value
p ['proc', obj.current_args[0].call(obj.return_value[1],
obj.current_args[1])]},
proc{|*args| args[0] + args[1]}, 1],
proc{p ['proc', 4]} ).start(100)
* tk*.rb: Allow to use Symbols for parameters.
Allow new notation of constructor (also allow old notation).
e.g.
TkFrame.new('classname'=>'User'){|base|
pack
f = TkFrame.new(base, :classname=>'ButtonFrame').pack
TkButton.new(
:parent => f,
:text => 'Quit',
:command => proc{exit}
).pack(
:fill => :x,
:pady => 2
)
}
* tkcanvas.rb: (TkcItem) Add 'coords' parameter to the canvas item
constructor (for new notation of constructor).
e.g.
c = TkCanvas.new.pack
l = TkcLine.new(c, :coords=>[[0,0], [100,100]])
* tcltklib.c: New 'mainloop' and 'mainloop_watchdog'.
The priority of their event-loop can be controlled.
They accept an optional argument.
If it false, they don't exit although the root widget is destroyed.
This function is sometimes useful, if it is used with 'restart'.
'mainloop' can't treat Thread#join/value in a callback routine.
(e.g. TkButton.new(:command=>proc{p Thread.new{button.invoke}.value}) )
'mainloop_watchdog' can treat them, but watchdog thread is always running
(so, a little heavier than 'mainloop').
If the purpose of using Thread#join/value is to do something under some
safe-level, please use Proc object.
(e.g. :command=>proc{$SAFE=1;proc{$SAFE=2;button.invoke}.call;p $SAFE})
* tk.rb: Support functions of new 'mainloop' and 'mainloop_watchdog'.
* tk.rb: (Tk.restart) Add 'app-name' paramater and 'use' parameter.
'app-name' specifies the name and the resource class of the
application. If 'app-name' is specified to 'xxx', the application
class on the resource database is set to 'Xxx' and the application
name is changed by the same rule of Tk.appname method. 'use'
specifies the main window for embedding the root widget instead of
generating a new window.
* tk.rb: Add new parameter 'widgetname' to the widget constructor to
support effective use of Resource Database. For example, the
resource 'Xxx*quit.text: QUIT' can set the text of the button
generated by the following code.
e.g.
Tk.restart('Xxx')
TkButton.new(nil, 'widgetname'=>'quit', 'command'=>proc{exit}).pack
Tk.mainloop
* tk.rb: TkOption::get always returns a tainted string.
Add TkOption::new_proc_class.
It generates a class to import procedures defined on the resource
database. For example, there is a following resource file.
----< resource-test >------------
*CMD.foo: {|*args| p [$SAFE, :foo, args]}
*CMD.XXX.bar: {|*args| p [$SAFE, :bar, args]}
*Button.command: ruby {p self; p $SAFE; TkOption::CMD::XXX.bar(1,2,3)}
---------------------------------
The following code is a sample of use of the resource file.
e.g.
require 'tk'
TkOption.readfile 'resource-test'
p TkOption.new_proc_class(:CMD, [:foo], 1)
p TkOption.new_proc_class(:XXX, [:bar], 2, false, TkOption::CMD)
TkButton.new(:text=>'test').pack
Tk.mainloop
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2515 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2002-06-04 11:03:33 +04:00
|
|
|
lib_mainloop(argc, argv, self)
|
|
|
|
int argc;
|
|
|
|
VALUE *argv;
|
1999-08-13 09:37:52 +04:00
|
|
|
VALUE self;
|
1998-01-16 15:19:09 +03:00
|
|
|
{
|
* tkfont.rb: Fix bugs on TkFont.init_widget_font for Tk8.x.
* tkafter.rb: Add self to 1st argument of interval- and loop-proc
TkAfter#current_interval returns an interval (sleep) time value
TkAfter#current_args returns an array of arguments
TkAfter#return_value returns a return value of last loop-proc
e.g.
TkAfter.new(
proc{|obj| 500 - obj.current_interval}, 10,
[proc{|obj| p obj.current_args}, 'proc', 1],
proc{|obj| p obj.current_args; ['return', 2]},
[proc{|obj|
p obj.return_value
p ['proc', obj.current_args[0].call(obj.return_value[1],
obj.current_args[1])]},
proc{|*args| args[0] + args[1]}, 1],
proc{p ['proc', 4]} ).start(100)
* tk*.rb: Allow to use Symbols for parameters.
Allow new notation of constructor (also allow old notation).
e.g.
TkFrame.new('classname'=>'User'){|base|
pack
f = TkFrame.new(base, :classname=>'ButtonFrame').pack
TkButton.new(
:parent => f,
:text => 'Quit',
:command => proc{exit}
).pack(
:fill => :x,
:pady => 2
)
}
* tkcanvas.rb: (TkcItem) Add 'coords' parameter to the canvas item
constructor (for new notation of constructor).
e.g.
c = TkCanvas.new.pack
l = TkcLine.new(c, :coords=>[[0,0], [100,100]])
* tcltklib.c: New 'mainloop' and 'mainloop_watchdog'.
The priority of their event-loop can be controlled.
They accept an optional argument.
If it false, they don't exit although the root widget is destroyed.
This function is sometimes useful, if it is used with 'restart'.
'mainloop' can't treat Thread#join/value in a callback routine.
(e.g. TkButton.new(:command=>proc{p Thread.new{button.invoke}.value}) )
'mainloop_watchdog' can treat them, but watchdog thread is always running
(so, a little heavier than 'mainloop').
If the purpose of using Thread#join/value is to do something under some
safe-level, please use Proc object.
(e.g. :command=>proc{$SAFE=1;proc{$SAFE=2;button.invoke}.call;p $SAFE})
* tk.rb: Support functions of new 'mainloop' and 'mainloop_watchdog'.
* tk.rb: (Tk.restart) Add 'app-name' paramater and 'use' parameter.
'app-name' specifies the name and the resource class of the
application. If 'app-name' is specified to 'xxx', the application
class on the resource database is set to 'Xxx' and the application
name is changed by the same rule of Tk.appname method. 'use'
specifies the main window for embedding the root widget instead of
generating a new window.
* tk.rb: Add new parameter 'widgetname' to the widget constructor to
support effective use of Resource Database. For example, the
resource 'Xxx*quit.text: QUIT' can set the text of the button
generated by the following code.
e.g.
Tk.restart('Xxx')
TkButton.new(nil, 'widgetname'=>'quit', 'command'=>proc{exit}).pack
Tk.mainloop
* tk.rb: TkOption::get always returns a tainted string.
Add TkOption::new_proc_class.
It generates a class to import procedures defined on the resource
database. For example, there is a following resource file.
----< resource-test >------------
*CMD.foo: {|*args| p [$SAFE, :foo, args]}
*CMD.XXX.bar: {|*args| p [$SAFE, :bar, args]}
*Button.command: ruby {p self; p $SAFE; TkOption::CMD::XXX.bar(1,2,3)}
---------------------------------
The following code is a sample of use of the resource file.
e.g.
require 'tk'
TkOption.readfile 'resource-test'
p TkOption.new_proc_class(:CMD, [:foo], 1)
p TkOption.new_proc_class(:XXX, [:bar], 2, false, TkOption::CMD)
TkButton.new(:text=>'test').pack
Tk.mainloop
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2515 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2002-06-04 11:03:33 +04:00
|
|
|
VALUE check_rootwidget;
|
|
|
|
|
|
|
|
if (rb_scan_args(argc, argv, "01", &check_rootwidget) == 0) {
|
2003-07-27 23:35:06 +04:00
|
|
|
check_rootwidget = Qtrue;
|
* tkfont.rb: Fix bugs on TkFont.init_widget_font for Tk8.x.
* tkafter.rb: Add self to 1st argument of interval- and loop-proc
TkAfter#current_interval returns an interval (sleep) time value
TkAfter#current_args returns an array of arguments
TkAfter#return_value returns a return value of last loop-proc
e.g.
TkAfter.new(
proc{|obj| 500 - obj.current_interval}, 10,
[proc{|obj| p obj.current_args}, 'proc', 1],
proc{|obj| p obj.current_args; ['return', 2]},
[proc{|obj|
p obj.return_value
p ['proc', obj.current_args[0].call(obj.return_value[1],
obj.current_args[1])]},
proc{|*args| args[0] + args[1]}, 1],
proc{p ['proc', 4]} ).start(100)
* tk*.rb: Allow to use Symbols for parameters.
Allow new notation of constructor (also allow old notation).
e.g.
TkFrame.new('classname'=>'User'){|base|
pack
f = TkFrame.new(base, :classname=>'ButtonFrame').pack
TkButton.new(
:parent => f,
:text => 'Quit',
:command => proc{exit}
).pack(
:fill => :x,
:pady => 2
)
}
* tkcanvas.rb: (TkcItem) Add 'coords' parameter to the canvas item
constructor (for new notation of constructor).
e.g.
c = TkCanvas.new.pack
l = TkcLine.new(c, :coords=>[[0,0], [100,100]])
* tcltklib.c: New 'mainloop' and 'mainloop_watchdog'.
The priority of their event-loop can be controlled.
They accept an optional argument.
If it false, they don't exit although the root widget is destroyed.
This function is sometimes useful, if it is used with 'restart'.
'mainloop' can't treat Thread#join/value in a callback routine.
(e.g. TkButton.new(:command=>proc{p Thread.new{button.invoke}.value}) )
'mainloop_watchdog' can treat them, but watchdog thread is always running
(so, a little heavier than 'mainloop').
If the purpose of using Thread#join/value is to do something under some
safe-level, please use Proc object.
(e.g. :command=>proc{$SAFE=1;proc{$SAFE=2;button.invoke}.call;p $SAFE})
* tk.rb: Support functions of new 'mainloop' and 'mainloop_watchdog'.
* tk.rb: (Tk.restart) Add 'app-name' paramater and 'use' parameter.
'app-name' specifies the name and the resource class of the
application. If 'app-name' is specified to 'xxx', the application
class on the resource database is set to 'Xxx' and the application
name is changed by the same rule of Tk.appname method. 'use'
specifies the main window for embedding the root widget instead of
generating a new window.
* tk.rb: Add new parameter 'widgetname' to the widget constructor to
support effective use of Resource Database. For example, the
resource 'Xxx*quit.text: QUIT' can set the text of the button
generated by the following code.
e.g.
Tk.restart('Xxx')
TkButton.new(nil, 'widgetname'=>'quit', 'command'=>proc{exit}).pack
Tk.mainloop
* tk.rb: TkOption::get always returns a tainted string.
Add TkOption::new_proc_class.
It generates a class to import procedures defined on the resource
database. For example, there is a following resource file.
----< resource-test >------------
*CMD.foo: {|*args| p [$SAFE, :foo, args]}
*CMD.XXX.bar: {|*args| p [$SAFE, :bar, args]}
*Button.command: ruby {p self; p $SAFE; TkOption::CMD::XXX.bar(1,2,3)}
---------------------------------
The following code is a sample of use of the resource file.
e.g.
require 'tk'
TkOption.readfile 'resource-test'
p TkOption.new_proc_class(:CMD, [:foo], 1)
p TkOption.new_proc_class(:XXX, [:bar], 2, false, TkOption::CMD)
TkButton.new(:text=>'test').pack
Tk.mainloop
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2515 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2002-06-04 11:03:33 +04:00
|
|
|
} else if (RTEST(check_rootwidget)) {
|
2003-07-27 23:35:06 +04:00
|
|
|
check_rootwidget = Qtrue;
|
* tkfont.rb: Fix bugs on TkFont.init_widget_font for Tk8.x.
* tkafter.rb: Add self to 1st argument of interval- and loop-proc
TkAfter#current_interval returns an interval (sleep) time value
TkAfter#current_args returns an array of arguments
TkAfter#return_value returns a return value of last loop-proc
e.g.
TkAfter.new(
proc{|obj| 500 - obj.current_interval}, 10,
[proc{|obj| p obj.current_args}, 'proc', 1],
proc{|obj| p obj.current_args; ['return', 2]},
[proc{|obj|
p obj.return_value
p ['proc', obj.current_args[0].call(obj.return_value[1],
obj.current_args[1])]},
proc{|*args| args[0] + args[1]}, 1],
proc{p ['proc', 4]} ).start(100)
* tk*.rb: Allow to use Symbols for parameters.
Allow new notation of constructor (also allow old notation).
e.g.
TkFrame.new('classname'=>'User'){|base|
pack
f = TkFrame.new(base, :classname=>'ButtonFrame').pack
TkButton.new(
:parent => f,
:text => 'Quit',
:command => proc{exit}
).pack(
:fill => :x,
:pady => 2
)
}
* tkcanvas.rb: (TkcItem) Add 'coords' parameter to the canvas item
constructor (for new notation of constructor).
e.g.
c = TkCanvas.new.pack
l = TkcLine.new(c, :coords=>[[0,0], [100,100]])
* tcltklib.c: New 'mainloop' and 'mainloop_watchdog'.
The priority of their event-loop can be controlled.
They accept an optional argument.
If it false, they don't exit although the root widget is destroyed.
This function is sometimes useful, if it is used with 'restart'.
'mainloop' can't treat Thread#join/value in a callback routine.
(e.g. TkButton.new(:command=>proc{p Thread.new{button.invoke}.value}) )
'mainloop_watchdog' can treat them, but watchdog thread is always running
(so, a little heavier than 'mainloop').
If the purpose of using Thread#join/value is to do something under some
safe-level, please use Proc object.
(e.g. :command=>proc{$SAFE=1;proc{$SAFE=2;button.invoke}.call;p $SAFE})
* tk.rb: Support functions of new 'mainloop' and 'mainloop_watchdog'.
* tk.rb: (Tk.restart) Add 'app-name' paramater and 'use' parameter.
'app-name' specifies the name and the resource class of the
application. If 'app-name' is specified to 'xxx', the application
class on the resource database is set to 'Xxx' and the application
name is changed by the same rule of Tk.appname method. 'use'
specifies the main window for embedding the root widget instead of
generating a new window.
* tk.rb: Add new parameter 'widgetname' to the widget constructor to
support effective use of Resource Database. For example, the
resource 'Xxx*quit.text: QUIT' can set the text of the button
generated by the following code.
e.g.
Tk.restart('Xxx')
TkButton.new(nil, 'widgetname'=>'quit', 'command'=>proc{exit}).pack
Tk.mainloop
* tk.rb: TkOption::get always returns a tainted string.
Add TkOption::new_proc_class.
It generates a class to import procedures defined on the resource
database. For example, there is a following resource file.
----< resource-test >------------
*CMD.foo: {|*args| p [$SAFE, :foo, args]}
*CMD.XXX.bar: {|*args| p [$SAFE, :bar, args]}
*Button.command: ruby {p self; p $SAFE; TkOption::CMD::XXX.bar(1,2,3)}
---------------------------------
The following code is a sample of use of the resource file.
e.g.
require 'tk'
TkOption.readfile 'resource-test'
p TkOption.new_proc_class(:CMD, [:foo], 1)
p TkOption.new_proc_class(:XXX, [:bar], 2, false, TkOption::CMD)
TkButton.new(:text=>'test').pack
Tk.mainloop
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2515 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2002-06-04 11:03:33 +04:00
|
|
|
} else {
|
2003-07-27 23:35:06 +04:00
|
|
|
check_rootwidget = Qfalse;
|
* tkfont.rb: Fix bugs on TkFont.init_widget_font for Tk8.x.
* tkafter.rb: Add self to 1st argument of interval- and loop-proc
TkAfter#current_interval returns an interval (sleep) time value
TkAfter#current_args returns an array of arguments
TkAfter#return_value returns a return value of last loop-proc
e.g.
TkAfter.new(
proc{|obj| 500 - obj.current_interval}, 10,
[proc{|obj| p obj.current_args}, 'proc', 1],
proc{|obj| p obj.current_args; ['return', 2]},
[proc{|obj|
p obj.return_value
p ['proc', obj.current_args[0].call(obj.return_value[1],
obj.current_args[1])]},
proc{|*args| args[0] + args[1]}, 1],
proc{p ['proc', 4]} ).start(100)
* tk*.rb: Allow to use Symbols for parameters.
Allow new notation of constructor (also allow old notation).
e.g.
TkFrame.new('classname'=>'User'){|base|
pack
f = TkFrame.new(base, :classname=>'ButtonFrame').pack
TkButton.new(
:parent => f,
:text => 'Quit',
:command => proc{exit}
).pack(
:fill => :x,
:pady => 2
)
}
* tkcanvas.rb: (TkcItem) Add 'coords' parameter to the canvas item
constructor (for new notation of constructor).
e.g.
c = TkCanvas.new.pack
l = TkcLine.new(c, :coords=>[[0,0], [100,100]])
* tcltklib.c: New 'mainloop' and 'mainloop_watchdog'.
The priority of their event-loop can be controlled.
They accept an optional argument.
If it false, they don't exit although the root widget is destroyed.
This function is sometimes useful, if it is used with 'restart'.
'mainloop' can't treat Thread#join/value in a callback routine.
(e.g. TkButton.new(:command=>proc{p Thread.new{button.invoke}.value}) )
'mainloop_watchdog' can treat them, but watchdog thread is always running
(so, a little heavier than 'mainloop').
If the purpose of using Thread#join/value is to do something under some
safe-level, please use Proc object.
(e.g. :command=>proc{$SAFE=1;proc{$SAFE=2;button.invoke}.call;p $SAFE})
* tk.rb: Support functions of new 'mainloop' and 'mainloop_watchdog'.
* tk.rb: (Tk.restart) Add 'app-name' paramater and 'use' parameter.
'app-name' specifies the name and the resource class of the
application. If 'app-name' is specified to 'xxx', the application
class on the resource database is set to 'Xxx' and the application
name is changed by the same rule of Tk.appname method. 'use'
specifies the main window for embedding the root widget instead of
generating a new window.
* tk.rb: Add new parameter 'widgetname' to the widget constructor to
support effective use of Resource Database. For example, the
resource 'Xxx*quit.text: QUIT' can set the text of the button
generated by the following code.
e.g.
Tk.restart('Xxx')
TkButton.new(nil, 'widgetname'=>'quit', 'command'=>proc{exit}).pack
Tk.mainloop
* tk.rb: TkOption::get always returns a tainted string.
Add TkOption::new_proc_class.
It generates a class to import procedures defined on the resource
database. For example, there is a following resource file.
----< resource-test >------------
*CMD.foo: {|*args| p [$SAFE, :foo, args]}
*CMD.XXX.bar: {|*args| p [$SAFE, :bar, args]}
*Button.command: ruby {p self; p $SAFE; TkOption::CMD::XXX.bar(1,2,3)}
---------------------------------
The following code is a sample of use of the resource file.
e.g.
require 'tk'
TkOption.readfile 'resource-test'
p TkOption.new_proc_class(:CMD, [:foo], 1)
p TkOption.new_proc_class(:XXX, [:bar], 2, false, TkOption::CMD)
TkButton.new(:text=>'test').pack
Tk.mainloop
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2515 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2002-06-04 11:03:33 +04:00
|
|
|
}
|
|
|
|
|
2003-10-14 19:25:45 +04:00
|
|
|
return lib_eventloop_launcher(check_rootwidget);
|
* tkfont.rb: Fix bugs on TkFont.init_widget_font for Tk8.x.
* tkafter.rb: Add self to 1st argument of interval- and loop-proc
TkAfter#current_interval returns an interval (sleep) time value
TkAfter#current_args returns an array of arguments
TkAfter#return_value returns a return value of last loop-proc
e.g.
TkAfter.new(
proc{|obj| 500 - obj.current_interval}, 10,
[proc{|obj| p obj.current_args}, 'proc', 1],
proc{|obj| p obj.current_args; ['return', 2]},
[proc{|obj|
p obj.return_value
p ['proc', obj.current_args[0].call(obj.return_value[1],
obj.current_args[1])]},
proc{|*args| args[0] + args[1]}, 1],
proc{p ['proc', 4]} ).start(100)
* tk*.rb: Allow to use Symbols for parameters.
Allow new notation of constructor (also allow old notation).
e.g.
TkFrame.new('classname'=>'User'){|base|
pack
f = TkFrame.new(base, :classname=>'ButtonFrame').pack
TkButton.new(
:parent => f,
:text => 'Quit',
:command => proc{exit}
).pack(
:fill => :x,
:pady => 2
)
}
* tkcanvas.rb: (TkcItem) Add 'coords' parameter to the canvas item
constructor (for new notation of constructor).
e.g.
c = TkCanvas.new.pack
l = TkcLine.new(c, :coords=>[[0,0], [100,100]])
* tcltklib.c: New 'mainloop' and 'mainloop_watchdog'.
The priority of their event-loop can be controlled.
They accept an optional argument.
If it false, they don't exit although the root widget is destroyed.
This function is sometimes useful, if it is used with 'restart'.
'mainloop' can't treat Thread#join/value in a callback routine.
(e.g. TkButton.new(:command=>proc{p Thread.new{button.invoke}.value}) )
'mainloop_watchdog' can treat them, but watchdog thread is always running
(so, a little heavier than 'mainloop').
If the purpose of using Thread#join/value is to do something under some
safe-level, please use Proc object.
(e.g. :command=>proc{$SAFE=1;proc{$SAFE=2;button.invoke}.call;p $SAFE})
* tk.rb: Support functions of new 'mainloop' and 'mainloop_watchdog'.
* tk.rb: (Tk.restart) Add 'app-name' paramater and 'use' parameter.
'app-name' specifies the name and the resource class of the
application. If 'app-name' is specified to 'xxx', the application
class on the resource database is set to 'Xxx' and the application
name is changed by the same rule of Tk.appname method. 'use'
specifies the main window for embedding the root widget instead of
generating a new window.
* tk.rb: Add new parameter 'widgetname' to the widget constructor to
support effective use of Resource Database. For example, the
resource 'Xxx*quit.text: QUIT' can set the text of the button
generated by the following code.
e.g.
Tk.restart('Xxx')
TkButton.new(nil, 'widgetname'=>'quit', 'command'=>proc{exit}).pack
Tk.mainloop
* tk.rb: TkOption::get always returns a tainted string.
Add TkOption::new_proc_class.
It generates a class to import procedures defined on the resource
database. For example, there is a following resource file.
----< resource-test >------------
*CMD.foo: {|*args| p [$SAFE, :foo, args]}
*CMD.XXX.bar: {|*args| p [$SAFE, :bar, args]}
*Button.command: ruby {p self; p $SAFE; TkOption::CMD::XXX.bar(1,2,3)}
---------------------------------
The following code is a sample of use of the resource file.
e.g.
require 'tk'
TkOption.readfile 'resource-test'
p TkOption.new_proc_class(:CMD, [:foo], 1)
p TkOption.new_proc_class(:XXX, [:bar], 2, false, TkOption::CMD)
TkButton.new(:text=>'test').pack
Tk.mainloop
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2515 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2002-06-04 11:03:33 +04:00
|
|
|
}
|
|
|
|
|
2003-08-29 12:34:14 +04:00
|
|
|
static VALUE
|
|
|
|
ip_mainloop(argc, argv, self)
|
|
|
|
int argc;
|
|
|
|
VALUE *argv;
|
|
|
|
VALUE self;
|
|
|
|
{
|
|
|
|
struct tcltkip *ptr = get_ip(self);
|
|
|
|
|
|
|
|
if (Tcl_GetMaster(ptr->ip) != (Tcl_Interp*)NULL) {
|
|
|
|
/* slave IP */
|
|
|
|
return Qnil;
|
|
|
|
}
|
|
|
|
return lib_mainloop(argc, argv, self);
|
|
|
|
}
|
|
|
|
|
2002-06-05 05:56:47 +04:00
|
|
|
VALUE
|
|
|
|
lib_watchdog_core(check_rootwidget)
|
* tkfont.rb: Fix bugs on TkFont.init_widget_font for Tk8.x.
* tkafter.rb: Add self to 1st argument of interval- and loop-proc
TkAfter#current_interval returns an interval (sleep) time value
TkAfter#current_args returns an array of arguments
TkAfter#return_value returns a return value of last loop-proc
e.g.
TkAfter.new(
proc{|obj| 500 - obj.current_interval}, 10,
[proc{|obj| p obj.current_args}, 'proc', 1],
proc{|obj| p obj.current_args; ['return', 2]},
[proc{|obj|
p obj.return_value
p ['proc', obj.current_args[0].call(obj.return_value[1],
obj.current_args[1])]},
proc{|*args| args[0] + args[1]}, 1],
proc{p ['proc', 4]} ).start(100)
* tk*.rb: Allow to use Symbols for parameters.
Allow new notation of constructor (also allow old notation).
e.g.
TkFrame.new('classname'=>'User'){|base|
pack
f = TkFrame.new(base, :classname=>'ButtonFrame').pack
TkButton.new(
:parent => f,
:text => 'Quit',
:command => proc{exit}
).pack(
:fill => :x,
:pady => 2
)
}
* tkcanvas.rb: (TkcItem) Add 'coords' parameter to the canvas item
constructor (for new notation of constructor).
e.g.
c = TkCanvas.new.pack
l = TkcLine.new(c, :coords=>[[0,0], [100,100]])
* tcltklib.c: New 'mainloop' and 'mainloop_watchdog'.
The priority of their event-loop can be controlled.
They accept an optional argument.
If it false, they don't exit although the root widget is destroyed.
This function is sometimes useful, if it is used with 'restart'.
'mainloop' can't treat Thread#join/value in a callback routine.
(e.g. TkButton.new(:command=>proc{p Thread.new{button.invoke}.value}) )
'mainloop_watchdog' can treat them, but watchdog thread is always running
(so, a little heavier than 'mainloop').
If the purpose of using Thread#join/value is to do something under some
safe-level, please use Proc object.
(e.g. :command=>proc{$SAFE=1;proc{$SAFE=2;button.invoke}.call;p $SAFE})
* tk.rb: Support functions of new 'mainloop' and 'mainloop_watchdog'.
* tk.rb: (Tk.restart) Add 'app-name' paramater and 'use' parameter.
'app-name' specifies the name and the resource class of the
application. If 'app-name' is specified to 'xxx', the application
class on the resource database is set to 'Xxx' and the application
name is changed by the same rule of Tk.appname method. 'use'
specifies the main window for embedding the root widget instead of
generating a new window.
* tk.rb: Add new parameter 'widgetname' to the widget constructor to
support effective use of Resource Database. For example, the
resource 'Xxx*quit.text: QUIT' can set the text of the button
generated by the following code.
e.g.
Tk.restart('Xxx')
TkButton.new(nil, 'widgetname'=>'quit', 'command'=>proc{exit}).pack
Tk.mainloop
* tk.rb: TkOption::get always returns a tainted string.
Add TkOption::new_proc_class.
It generates a class to import procedures defined on the resource
database. For example, there is a following resource file.
----< resource-test >------------
*CMD.foo: {|*args| p [$SAFE, :foo, args]}
*CMD.XXX.bar: {|*args| p [$SAFE, :bar, args]}
*Button.command: ruby {p self; p $SAFE; TkOption::CMD::XXX.bar(1,2,3)}
---------------------------------
The following code is a sample of use of the resource file.
e.g.
require 'tk'
TkOption.readfile 'resource-test'
p TkOption.new_proc_class(:CMD, [:foo], 1)
p TkOption.new_proc_class(:XXX, [:bar], 2, false, TkOption::CMD)
TkButton.new(:text=>'test').pack
Tk.mainloop
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2515 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2002-06-04 11:03:33 +04:00
|
|
|
VALUE check_rootwidget;
|
2002-06-05 05:56:47 +04:00
|
|
|
{
|
* tkfont.rb: Fix bugs on TkFont.init_widget_font for Tk8.x.
* tkafter.rb: Add self to 1st argument of interval- and loop-proc
TkAfter#current_interval returns an interval (sleep) time value
TkAfter#current_args returns an array of arguments
TkAfter#return_value returns a return value of last loop-proc
e.g.
TkAfter.new(
proc{|obj| 500 - obj.current_interval}, 10,
[proc{|obj| p obj.current_args}, 'proc', 1],
proc{|obj| p obj.current_args; ['return', 2]},
[proc{|obj|
p obj.return_value
p ['proc', obj.current_args[0].call(obj.return_value[1],
obj.current_args[1])]},
proc{|*args| args[0] + args[1]}, 1],
proc{p ['proc', 4]} ).start(100)
* tk*.rb: Allow to use Symbols for parameters.
Allow new notation of constructor (also allow old notation).
e.g.
TkFrame.new('classname'=>'User'){|base|
pack
f = TkFrame.new(base, :classname=>'ButtonFrame').pack
TkButton.new(
:parent => f,
:text => 'Quit',
:command => proc{exit}
).pack(
:fill => :x,
:pady => 2
)
}
* tkcanvas.rb: (TkcItem) Add 'coords' parameter to the canvas item
constructor (for new notation of constructor).
e.g.
c = TkCanvas.new.pack
l = TkcLine.new(c, :coords=>[[0,0], [100,100]])
* tcltklib.c: New 'mainloop' and 'mainloop_watchdog'.
The priority of their event-loop can be controlled.
They accept an optional argument.
If it false, they don't exit although the root widget is destroyed.
This function is sometimes useful, if it is used with 'restart'.
'mainloop' can't treat Thread#join/value in a callback routine.
(e.g. TkButton.new(:command=>proc{p Thread.new{button.invoke}.value}) )
'mainloop_watchdog' can treat them, but watchdog thread is always running
(so, a little heavier than 'mainloop').
If the purpose of using Thread#join/value is to do something under some
safe-level, please use Proc object.
(e.g. :command=>proc{$SAFE=1;proc{$SAFE=2;button.invoke}.call;p $SAFE})
* tk.rb: Support functions of new 'mainloop' and 'mainloop_watchdog'.
* tk.rb: (Tk.restart) Add 'app-name' paramater and 'use' parameter.
'app-name' specifies the name and the resource class of the
application. If 'app-name' is specified to 'xxx', the application
class on the resource database is set to 'Xxx' and the application
name is changed by the same rule of Tk.appname method. 'use'
specifies the main window for embedding the root widget instead of
generating a new window.
* tk.rb: Add new parameter 'widgetname' to the widget constructor to
support effective use of Resource Database. For example, the
resource 'Xxx*quit.text: QUIT' can set the text of the button
generated by the following code.
e.g.
Tk.restart('Xxx')
TkButton.new(nil, 'widgetname'=>'quit', 'command'=>proc{exit}).pack
Tk.mainloop
* tk.rb: TkOption::get always returns a tainted string.
Add TkOption::new_proc_class.
It generates a class to import procedures defined on the resource
database. For example, there is a following resource file.
----< resource-test >------------
*CMD.foo: {|*args| p [$SAFE, :foo, args]}
*CMD.XXX.bar: {|*args| p [$SAFE, :bar, args]}
*Button.command: ruby {p self; p $SAFE; TkOption::CMD::XXX.bar(1,2,3)}
---------------------------------
The following code is a sample of use of the resource file.
e.g.
require 'tk'
TkOption.readfile 'resource-test'
p TkOption.new_proc_class(:CMD, [:foo], 1)
p TkOption.new_proc_class(:XXX, [:bar], 2, false, TkOption::CMD)
TkButton.new(:text=>'test').pack
Tk.mainloop
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2515 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2002-06-04 11:03:33 +04:00
|
|
|
VALUE evloop;
|
2003-07-27 23:35:06 +04:00
|
|
|
int prev_val = -1;
|
2003-07-29 05:24:32 +04:00
|
|
|
int chance = 0;
|
2003-07-29 05:45:33 +04:00
|
|
|
int check = RTEST(check_rootwidget);
|
2003-07-29 05:24:32 +04:00
|
|
|
struct timeval t0, t1;
|
2003-06-09 22:09:11 +04:00
|
|
|
|
2003-07-29 05:24:32 +04:00
|
|
|
t0.tv_sec = (time_t)0;
|
|
|
|
t0.tv_usec = (time_t)((NO_THREAD_INTERRUPT_TIME)*1000.0);
|
|
|
|
t1.tv_sec = (time_t)0;
|
|
|
|
t1.tv_usec = (time_t)((WATCHDOG_INTERVAL)*1000.0);
|
* tkfont.rb: Fix bugs on TkFont.init_widget_font for Tk8.x.
* tkafter.rb: Add self to 1st argument of interval- and loop-proc
TkAfter#current_interval returns an interval (sleep) time value
TkAfter#current_args returns an array of arguments
TkAfter#return_value returns a return value of last loop-proc
e.g.
TkAfter.new(
proc{|obj| 500 - obj.current_interval}, 10,
[proc{|obj| p obj.current_args}, 'proc', 1],
proc{|obj| p obj.current_args; ['return', 2]},
[proc{|obj|
p obj.return_value
p ['proc', obj.current_args[0].call(obj.return_value[1],
obj.current_args[1])]},
proc{|*args| args[0] + args[1]}, 1],
proc{p ['proc', 4]} ).start(100)
* tk*.rb: Allow to use Symbols for parameters.
Allow new notation of constructor (also allow old notation).
e.g.
TkFrame.new('classname'=>'User'){|base|
pack
f = TkFrame.new(base, :classname=>'ButtonFrame').pack
TkButton.new(
:parent => f,
:text => 'Quit',
:command => proc{exit}
).pack(
:fill => :x,
:pady => 2
)
}
* tkcanvas.rb: (TkcItem) Add 'coords' parameter to the canvas item
constructor (for new notation of constructor).
e.g.
c = TkCanvas.new.pack
l = TkcLine.new(c, :coords=>[[0,0], [100,100]])
* tcltklib.c: New 'mainloop' and 'mainloop_watchdog'.
The priority of their event-loop can be controlled.
They accept an optional argument.
If it false, they don't exit although the root widget is destroyed.
This function is sometimes useful, if it is used with 'restart'.
'mainloop' can't treat Thread#join/value in a callback routine.
(e.g. TkButton.new(:command=>proc{p Thread.new{button.invoke}.value}) )
'mainloop_watchdog' can treat them, but watchdog thread is always running
(so, a little heavier than 'mainloop').
If the purpose of using Thread#join/value is to do something under some
safe-level, please use Proc object.
(e.g. :command=>proc{$SAFE=1;proc{$SAFE=2;button.invoke}.call;p $SAFE})
* tk.rb: Support functions of new 'mainloop' and 'mainloop_watchdog'.
* tk.rb: (Tk.restart) Add 'app-name' paramater and 'use' parameter.
'app-name' specifies the name and the resource class of the
application. If 'app-name' is specified to 'xxx', the application
class on the resource database is set to 'Xxx' and the application
name is changed by the same rule of Tk.appname method. 'use'
specifies the main window for embedding the root widget instead of
generating a new window.
* tk.rb: Add new parameter 'widgetname' to the widget constructor to
support effective use of Resource Database. For example, the
resource 'Xxx*quit.text: QUIT' can set the text of the button
generated by the following code.
e.g.
Tk.restart('Xxx')
TkButton.new(nil, 'widgetname'=>'quit', 'command'=>proc{exit}).pack
Tk.mainloop
* tk.rb: TkOption::get always returns a tainted string.
Add TkOption::new_proc_class.
It generates a class to import procedures defined on the resource
database. For example, there is a following resource file.
----< resource-test >------------
*CMD.foo: {|*args| p [$SAFE, :foo, args]}
*CMD.XXX.bar: {|*args| p [$SAFE, :bar, args]}
*Button.command: ruby {p self; p $SAFE; TkOption::CMD::XXX.bar(1,2,3)}
---------------------------------
The following code is a sample of use of the resource file.
e.g.
require 'tk'
TkOption.readfile 'resource-test'
p TkOption.new_proc_class(:CMD, [:foo], 1)
p TkOption.new_proc_class(:XXX, [:bar], 2, false, TkOption::CMD)
TkButton.new(:text=>'test').pack
Tk.mainloop
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2515 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2002-06-04 11:03:33 +04:00
|
|
|
|
|
|
|
/* check other watchdog thread */
|
|
|
|
if (watchdog_thread != 0) {
|
2003-07-29 05:45:33 +04:00
|
|
|
if (RTEST(rb_funcall(watchdog_thread, rb_intern("stop?"), 0))) {
|
2003-07-27 23:35:06 +04:00
|
|
|
rb_funcall(watchdog_thread, rb_intern("kill"), 0);
|
|
|
|
} else {
|
|
|
|
return Qnil;
|
|
|
|
}
|
* tkfont.rb: Fix bugs on TkFont.init_widget_font for Tk8.x.
* tkafter.rb: Add self to 1st argument of interval- and loop-proc
TkAfter#current_interval returns an interval (sleep) time value
TkAfter#current_args returns an array of arguments
TkAfter#return_value returns a return value of last loop-proc
e.g.
TkAfter.new(
proc{|obj| 500 - obj.current_interval}, 10,
[proc{|obj| p obj.current_args}, 'proc', 1],
proc{|obj| p obj.current_args; ['return', 2]},
[proc{|obj|
p obj.return_value
p ['proc', obj.current_args[0].call(obj.return_value[1],
obj.current_args[1])]},
proc{|*args| args[0] + args[1]}, 1],
proc{p ['proc', 4]} ).start(100)
* tk*.rb: Allow to use Symbols for parameters.
Allow new notation of constructor (also allow old notation).
e.g.
TkFrame.new('classname'=>'User'){|base|
pack
f = TkFrame.new(base, :classname=>'ButtonFrame').pack
TkButton.new(
:parent => f,
:text => 'Quit',
:command => proc{exit}
).pack(
:fill => :x,
:pady => 2
)
}
* tkcanvas.rb: (TkcItem) Add 'coords' parameter to the canvas item
constructor (for new notation of constructor).
e.g.
c = TkCanvas.new.pack
l = TkcLine.new(c, :coords=>[[0,0], [100,100]])
* tcltklib.c: New 'mainloop' and 'mainloop_watchdog'.
The priority of their event-loop can be controlled.
They accept an optional argument.
If it false, they don't exit although the root widget is destroyed.
This function is sometimes useful, if it is used with 'restart'.
'mainloop' can't treat Thread#join/value in a callback routine.
(e.g. TkButton.new(:command=>proc{p Thread.new{button.invoke}.value}) )
'mainloop_watchdog' can treat them, but watchdog thread is always running
(so, a little heavier than 'mainloop').
If the purpose of using Thread#join/value is to do something under some
safe-level, please use Proc object.
(e.g. :command=>proc{$SAFE=1;proc{$SAFE=2;button.invoke}.call;p $SAFE})
* tk.rb: Support functions of new 'mainloop' and 'mainloop_watchdog'.
* tk.rb: (Tk.restart) Add 'app-name' paramater and 'use' parameter.
'app-name' specifies the name and the resource class of the
application. If 'app-name' is specified to 'xxx', the application
class on the resource database is set to 'Xxx' and the application
name is changed by the same rule of Tk.appname method. 'use'
specifies the main window for embedding the root widget instead of
generating a new window.
* tk.rb: Add new parameter 'widgetname' to the widget constructor to
support effective use of Resource Database. For example, the
resource 'Xxx*quit.text: QUIT' can set the text of the button
generated by the following code.
e.g.
Tk.restart('Xxx')
TkButton.new(nil, 'widgetname'=>'quit', 'command'=>proc{exit}).pack
Tk.mainloop
* tk.rb: TkOption::get always returns a tainted string.
Add TkOption::new_proc_class.
It generates a class to import procedures defined on the resource
database. For example, there is a following resource file.
----< resource-test >------------
*CMD.foo: {|*args| p [$SAFE, :foo, args]}
*CMD.XXX.bar: {|*args| p [$SAFE, :bar, args]}
*Button.command: ruby {p self; p $SAFE; TkOption::CMD::XXX.bar(1,2,3)}
---------------------------------
The following code is a sample of use of the resource file.
e.g.
require 'tk'
TkOption.readfile 'resource-test'
p TkOption.new_proc_class(:CMD, [:foo], 1)
p TkOption.new_proc_class(:XXX, [:bar], 2, false, TkOption::CMD)
TkButton.new(:text=>'test').pack
Tk.mainloop
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2515 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2002-06-04 11:03:33 +04:00
|
|
|
}
|
|
|
|
watchdog_thread = rb_thread_current();
|
|
|
|
|
|
|
|
/* watchdog start */
|
|
|
|
do {
|
2003-07-29 19:39:59 +04:00
|
|
|
if (eventloop_thread == 0
|
|
|
|
|| (loop_counter == prev_val
|
|
|
|
&& RTEST(rb_funcall(eventloop_thread, rb_intern("stop?"), 0))
|
|
|
|
&& ++chance >= 3 )
|
|
|
|
) {
|
|
|
|
/* start new eventloop thread */
|
|
|
|
DUMP2("eventloop thread %lx is sleeping or dead",
|
|
|
|
eventloop_thread);
|
2003-10-14 19:25:45 +04:00
|
|
|
evloop = rb_thread_create(lib_eventloop_launcher,
|
2003-07-29 19:39:59 +04:00
|
|
|
(void*)&check_rootwidget);
|
|
|
|
DUMP2("create new eventloop thread %lx", evloop);
|
|
|
|
loop_counter = -1;
|
|
|
|
chance = 0;
|
|
|
|
rb_thread_run(evloop);
|
2003-07-27 23:35:06 +04:00
|
|
|
} else {
|
2003-07-29 05:24:32 +04:00
|
|
|
loop_counter = prev_val;
|
|
|
|
chance = 0;
|
|
|
|
if (event_loop_wait_event) {
|
|
|
|
rb_thread_wait_for(t0);
|
|
|
|
} else {
|
|
|
|
rb_thread_wait_for(t1);
|
|
|
|
}
|
2003-07-27 23:35:06 +04:00
|
|
|
/* rb_thread_schedule(); */
|
|
|
|
}
|
2003-07-29 05:45:33 +04:00
|
|
|
} while(!check || Tk_GetNumMainWindows() != 0);
|
1999-01-20 07:59:39 +03:00
|
|
|
|
1998-01-16 15:19:09 +03:00
|
|
|
return Qnil;
|
|
|
|
}
|
|
|
|
|
2002-06-05 05:56:47 +04:00
|
|
|
VALUE
|
|
|
|
lib_watchdog_ensure(arg)
|
|
|
|
VALUE arg;
|
|
|
|
{
|
|
|
|
eventloop_thread = 0; /* stop eventloops */
|
|
|
|
return Qnil;
|
|
|
|
}
|
|
|
|
|
|
|
|
static VALUE
|
|
|
|
lib_mainloop_watchdog(argc, argv, self)
|
|
|
|
int argc;
|
|
|
|
VALUE *argv;
|
|
|
|
VALUE self;
|
|
|
|
{
|
|
|
|
VALUE check_rootwidget;
|
|
|
|
|
|
|
|
if (rb_scan_args(argc, argv, "01", &check_rootwidget) == 0) {
|
2003-07-27 23:35:06 +04:00
|
|
|
check_rootwidget = Qtrue;
|
2002-06-05 05:56:47 +04:00
|
|
|
} else if (RTEST(check_rootwidget)) {
|
2003-07-27 23:35:06 +04:00
|
|
|
check_rootwidget = Qtrue;
|
2002-06-05 05:56:47 +04:00
|
|
|
} else {
|
2003-07-27 23:35:06 +04:00
|
|
|
check_rootwidget = Qfalse;
|
2002-06-05 05:56:47 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
return rb_ensure(lib_watchdog_core, check_rootwidget,
|
|
|
|
lib_watchdog_ensure, Qnil);
|
|
|
|
}
|
|
|
|
|
* tkfont.rb: Fix bugs on TkFont.init_widget_font for Tk8.x.
* tkafter.rb: Add self to 1st argument of interval- and loop-proc
TkAfter#current_interval returns an interval (sleep) time value
TkAfter#current_args returns an array of arguments
TkAfter#return_value returns a return value of last loop-proc
e.g.
TkAfter.new(
proc{|obj| 500 - obj.current_interval}, 10,
[proc{|obj| p obj.current_args}, 'proc', 1],
proc{|obj| p obj.current_args; ['return', 2]},
[proc{|obj|
p obj.return_value
p ['proc', obj.current_args[0].call(obj.return_value[1],
obj.current_args[1])]},
proc{|*args| args[0] + args[1]}, 1],
proc{p ['proc', 4]} ).start(100)
* tk*.rb: Allow to use Symbols for parameters.
Allow new notation of constructor (also allow old notation).
e.g.
TkFrame.new('classname'=>'User'){|base|
pack
f = TkFrame.new(base, :classname=>'ButtonFrame').pack
TkButton.new(
:parent => f,
:text => 'Quit',
:command => proc{exit}
).pack(
:fill => :x,
:pady => 2
)
}
* tkcanvas.rb: (TkcItem) Add 'coords' parameter to the canvas item
constructor (for new notation of constructor).
e.g.
c = TkCanvas.new.pack
l = TkcLine.new(c, :coords=>[[0,0], [100,100]])
* tcltklib.c: New 'mainloop' and 'mainloop_watchdog'.
The priority of their event-loop can be controlled.
They accept an optional argument.
If it false, they don't exit although the root widget is destroyed.
This function is sometimes useful, if it is used with 'restart'.
'mainloop' can't treat Thread#join/value in a callback routine.
(e.g. TkButton.new(:command=>proc{p Thread.new{button.invoke}.value}) )
'mainloop_watchdog' can treat them, but watchdog thread is always running
(so, a little heavier than 'mainloop').
If the purpose of using Thread#join/value is to do something under some
safe-level, please use Proc object.
(e.g. :command=>proc{$SAFE=1;proc{$SAFE=2;button.invoke}.call;p $SAFE})
* tk.rb: Support functions of new 'mainloop' and 'mainloop_watchdog'.
* tk.rb: (Tk.restart) Add 'app-name' paramater and 'use' parameter.
'app-name' specifies the name and the resource class of the
application. If 'app-name' is specified to 'xxx', the application
class on the resource database is set to 'Xxx' and the application
name is changed by the same rule of Tk.appname method. 'use'
specifies the main window for embedding the root widget instead of
generating a new window.
* tk.rb: Add new parameter 'widgetname' to the widget constructor to
support effective use of Resource Database. For example, the
resource 'Xxx*quit.text: QUIT' can set the text of the button
generated by the following code.
e.g.
Tk.restart('Xxx')
TkButton.new(nil, 'widgetname'=>'quit', 'command'=>proc{exit}).pack
Tk.mainloop
* tk.rb: TkOption::get always returns a tainted string.
Add TkOption::new_proc_class.
It generates a class to import procedures defined on the resource
database. For example, there is a following resource file.
----< resource-test >------------
*CMD.foo: {|*args| p [$SAFE, :foo, args]}
*CMD.XXX.bar: {|*args| p [$SAFE, :bar, args]}
*Button.command: ruby {p self; p $SAFE; TkOption::CMD::XXX.bar(1,2,3)}
---------------------------------
The following code is a sample of use of the resource file.
e.g.
require 'tk'
TkOption.readfile 'resource-test'
p TkOption.new_proc_class(:CMD, [:foo], 1)
p TkOption.new_proc_class(:XXX, [:bar], 2, false, TkOption::CMD)
TkButton.new(:text=>'test').pack
Tk.mainloop
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2515 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2002-06-04 11:03:33 +04:00
|
|
|
static VALUE
|
2003-08-29 12:34:14 +04:00
|
|
|
ip_mainloop_watchdog(argc, argv, self)
|
|
|
|
int argc;
|
|
|
|
VALUE *argv;
|
|
|
|
VALUE self;
|
|
|
|
{
|
|
|
|
struct tcltkip *ptr = get_ip(self);
|
|
|
|
|
|
|
|
if (Tcl_GetMaster(ptr->ip) != (Tcl_Interp*)NULL) {
|
|
|
|
/* slave IP */
|
|
|
|
return Qnil;
|
|
|
|
}
|
|
|
|
return lib_mainloop_watchdog(argc, argv, self);
|
|
|
|
}
|
|
|
|
|
|
|
|
static VALUE
|
|
|
|
lib_do_one_event_core(argc, argv, self, is_ip)
|
* tkfont.rb: Fix bugs on TkFont.init_widget_font for Tk8.x.
* tkafter.rb: Add self to 1st argument of interval- and loop-proc
TkAfter#current_interval returns an interval (sleep) time value
TkAfter#current_args returns an array of arguments
TkAfter#return_value returns a return value of last loop-proc
e.g.
TkAfter.new(
proc{|obj| 500 - obj.current_interval}, 10,
[proc{|obj| p obj.current_args}, 'proc', 1],
proc{|obj| p obj.current_args; ['return', 2]},
[proc{|obj|
p obj.return_value
p ['proc', obj.current_args[0].call(obj.return_value[1],
obj.current_args[1])]},
proc{|*args| args[0] + args[1]}, 1],
proc{p ['proc', 4]} ).start(100)
* tk*.rb: Allow to use Symbols for parameters.
Allow new notation of constructor (also allow old notation).
e.g.
TkFrame.new('classname'=>'User'){|base|
pack
f = TkFrame.new(base, :classname=>'ButtonFrame').pack
TkButton.new(
:parent => f,
:text => 'Quit',
:command => proc{exit}
).pack(
:fill => :x,
:pady => 2
)
}
* tkcanvas.rb: (TkcItem) Add 'coords' parameter to the canvas item
constructor (for new notation of constructor).
e.g.
c = TkCanvas.new.pack
l = TkcLine.new(c, :coords=>[[0,0], [100,100]])
* tcltklib.c: New 'mainloop' and 'mainloop_watchdog'.
The priority of their event-loop can be controlled.
They accept an optional argument.
If it false, they don't exit although the root widget is destroyed.
This function is sometimes useful, if it is used with 'restart'.
'mainloop' can't treat Thread#join/value in a callback routine.
(e.g. TkButton.new(:command=>proc{p Thread.new{button.invoke}.value}) )
'mainloop_watchdog' can treat them, but watchdog thread is always running
(so, a little heavier than 'mainloop').
If the purpose of using Thread#join/value is to do something under some
safe-level, please use Proc object.
(e.g. :command=>proc{$SAFE=1;proc{$SAFE=2;button.invoke}.call;p $SAFE})
* tk.rb: Support functions of new 'mainloop' and 'mainloop_watchdog'.
* tk.rb: (Tk.restart) Add 'app-name' paramater and 'use' parameter.
'app-name' specifies the name and the resource class of the
application. If 'app-name' is specified to 'xxx', the application
class on the resource database is set to 'Xxx' and the application
name is changed by the same rule of Tk.appname method. 'use'
specifies the main window for embedding the root widget instead of
generating a new window.
* tk.rb: Add new parameter 'widgetname' to the widget constructor to
support effective use of Resource Database. For example, the
resource 'Xxx*quit.text: QUIT' can set the text of the button
generated by the following code.
e.g.
Tk.restart('Xxx')
TkButton.new(nil, 'widgetname'=>'quit', 'command'=>proc{exit}).pack
Tk.mainloop
* tk.rb: TkOption::get always returns a tainted string.
Add TkOption::new_proc_class.
It generates a class to import procedures defined on the resource
database. For example, there is a following resource file.
----< resource-test >------------
*CMD.foo: {|*args| p [$SAFE, :foo, args]}
*CMD.XXX.bar: {|*args| p [$SAFE, :bar, args]}
*Button.command: ruby {p self; p $SAFE; TkOption::CMD::XXX.bar(1,2,3)}
---------------------------------
The following code is a sample of use of the resource file.
e.g.
require 'tk'
TkOption.readfile 'resource-test'
p TkOption.new_proc_class(:CMD, [:foo], 1)
p TkOption.new_proc_class(:XXX, [:bar], 2, false, TkOption::CMD)
TkButton.new(:text=>'test').pack
Tk.mainloop
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2515 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2002-06-04 11:03:33 +04:00
|
|
|
int argc;
|
|
|
|
VALUE *argv;
|
|
|
|
VALUE self;
|
2003-08-29 12:34:14 +04:00
|
|
|
int is_ip;
|
* tkfont.rb: Fix bugs on TkFont.init_widget_font for Tk8.x.
* tkafter.rb: Add self to 1st argument of interval- and loop-proc
TkAfter#current_interval returns an interval (sleep) time value
TkAfter#current_args returns an array of arguments
TkAfter#return_value returns a return value of last loop-proc
e.g.
TkAfter.new(
proc{|obj| 500 - obj.current_interval}, 10,
[proc{|obj| p obj.current_args}, 'proc', 1],
proc{|obj| p obj.current_args; ['return', 2]},
[proc{|obj|
p obj.return_value
p ['proc', obj.current_args[0].call(obj.return_value[1],
obj.current_args[1])]},
proc{|*args| args[0] + args[1]}, 1],
proc{p ['proc', 4]} ).start(100)
* tk*.rb: Allow to use Symbols for parameters.
Allow new notation of constructor (also allow old notation).
e.g.
TkFrame.new('classname'=>'User'){|base|
pack
f = TkFrame.new(base, :classname=>'ButtonFrame').pack
TkButton.new(
:parent => f,
:text => 'Quit',
:command => proc{exit}
).pack(
:fill => :x,
:pady => 2
)
}
* tkcanvas.rb: (TkcItem) Add 'coords' parameter to the canvas item
constructor (for new notation of constructor).
e.g.
c = TkCanvas.new.pack
l = TkcLine.new(c, :coords=>[[0,0], [100,100]])
* tcltklib.c: New 'mainloop' and 'mainloop_watchdog'.
The priority of their event-loop can be controlled.
They accept an optional argument.
If it false, they don't exit although the root widget is destroyed.
This function is sometimes useful, if it is used with 'restart'.
'mainloop' can't treat Thread#join/value in a callback routine.
(e.g. TkButton.new(:command=>proc{p Thread.new{button.invoke}.value}) )
'mainloop_watchdog' can treat them, but watchdog thread is always running
(so, a little heavier than 'mainloop').
If the purpose of using Thread#join/value is to do something under some
safe-level, please use Proc object.
(e.g. :command=>proc{$SAFE=1;proc{$SAFE=2;button.invoke}.call;p $SAFE})
* tk.rb: Support functions of new 'mainloop' and 'mainloop_watchdog'.
* tk.rb: (Tk.restart) Add 'app-name' paramater and 'use' parameter.
'app-name' specifies the name and the resource class of the
application. If 'app-name' is specified to 'xxx', the application
class on the resource database is set to 'Xxx' and the application
name is changed by the same rule of Tk.appname method. 'use'
specifies the main window for embedding the root widget instead of
generating a new window.
* tk.rb: Add new parameter 'widgetname' to the widget constructor to
support effective use of Resource Database. For example, the
resource 'Xxx*quit.text: QUIT' can set the text of the button
generated by the following code.
e.g.
Tk.restart('Xxx')
TkButton.new(nil, 'widgetname'=>'quit', 'command'=>proc{exit}).pack
Tk.mainloop
* tk.rb: TkOption::get always returns a tainted string.
Add TkOption::new_proc_class.
It generates a class to import procedures defined on the resource
database. For example, there is a following resource file.
----< resource-test >------------
*CMD.foo: {|*args| p [$SAFE, :foo, args]}
*CMD.XXX.bar: {|*args| p [$SAFE, :bar, args]}
*Button.command: ruby {p self; p $SAFE; TkOption::CMD::XXX.bar(1,2,3)}
---------------------------------
The following code is a sample of use of the resource file.
e.g.
require 'tk'
TkOption.readfile 'resource-test'
p TkOption.new_proc_class(:CMD, [:foo], 1)
p TkOption.new_proc_class(:XXX, [:bar], 2, false, TkOption::CMD)
TkButton.new(:text=>'test').pack
Tk.mainloop
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2515 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2002-06-04 11:03:33 +04:00
|
|
|
{
|
2003-07-29 05:24:32 +04:00
|
|
|
VALUE vflags;
|
* tkfont.rb: Fix bugs on TkFont.init_widget_font for Tk8.x.
* tkafter.rb: Add self to 1st argument of interval- and loop-proc
TkAfter#current_interval returns an interval (sleep) time value
TkAfter#current_args returns an array of arguments
TkAfter#return_value returns a return value of last loop-proc
e.g.
TkAfter.new(
proc{|obj| 500 - obj.current_interval}, 10,
[proc{|obj| p obj.current_args}, 'proc', 1],
proc{|obj| p obj.current_args; ['return', 2]},
[proc{|obj|
p obj.return_value
p ['proc', obj.current_args[0].call(obj.return_value[1],
obj.current_args[1])]},
proc{|*args| args[0] + args[1]}, 1],
proc{p ['proc', 4]} ).start(100)
* tk*.rb: Allow to use Symbols for parameters.
Allow new notation of constructor (also allow old notation).
e.g.
TkFrame.new('classname'=>'User'){|base|
pack
f = TkFrame.new(base, :classname=>'ButtonFrame').pack
TkButton.new(
:parent => f,
:text => 'Quit',
:command => proc{exit}
).pack(
:fill => :x,
:pady => 2
)
}
* tkcanvas.rb: (TkcItem) Add 'coords' parameter to the canvas item
constructor (for new notation of constructor).
e.g.
c = TkCanvas.new.pack
l = TkcLine.new(c, :coords=>[[0,0], [100,100]])
* tcltklib.c: New 'mainloop' and 'mainloop_watchdog'.
The priority of their event-loop can be controlled.
They accept an optional argument.
If it false, they don't exit although the root widget is destroyed.
This function is sometimes useful, if it is used with 'restart'.
'mainloop' can't treat Thread#join/value in a callback routine.
(e.g. TkButton.new(:command=>proc{p Thread.new{button.invoke}.value}) )
'mainloop_watchdog' can treat them, but watchdog thread is always running
(so, a little heavier than 'mainloop').
If the purpose of using Thread#join/value is to do something under some
safe-level, please use Proc object.
(e.g. :command=>proc{$SAFE=1;proc{$SAFE=2;button.invoke}.call;p $SAFE})
* tk.rb: Support functions of new 'mainloop' and 'mainloop_watchdog'.
* tk.rb: (Tk.restart) Add 'app-name' paramater and 'use' parameter.
'app-name' specifies the name and the resource class of the
application. If 'app-name' is specified to 'xxx', the application
class on the resource database is set to 'Xxx' and the application
name is changed by the same rule of Tk.appname method. 'use'
specifies the main window for embedding the root widget instead of
generating a new window.
* tk.rb: Add new parameter 'widgetname' to the widget constructor to
support effective use of Resource Database. For example, the
resource 'Xxx*quit.text: QUIT' can set the text of the button
generated by the following code.
e.g.
Tk.restart('Xxx')
TkButton.new(nil, 'widgetname'=>'quit', 'command'=>proc{exit}).pack
Tk.mainloop
* tk.rb: TkOption::get always returns a tainted string.
Add TkOption::new_proc_class.
It generates a class to import procedures defined on the resource
database. For example, there is a following resource file.
----< resource-test >------------
*CMD.foo: {|*args| p [$SAFE, :foo, args]}
*CMD.XXX.bar: {|*args| p [$SAFE, :bar, args]}
*Button.command: ruby {p self; p $SAFE; TkOption::CMD::XXX.bar(1,2,3)}
---------------------------------
The following code is a sample of use of the resource file.
e.g.
require 'tk'
TkOption.readfile 'resource-test'
p TkOption.new_proc_class(:CMD, [:foo], 1)
p TkOption.new_proc_class(:XXX, [:bar], 2, false, TkOption::CMD)
TkButton.new(:text=>'test').pack
Tk.mainloop
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2515 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2002-06-04 11:03:33 +04:00
|
|
|
int flags;
|
2003-11-08 00:39:36 +03:00
|
|
|
int found_event;
|
* tkfont.rb: Fix bugs on TkFont.init_widget_font for Tk8.x.
* tkafter.rb: Add self to 1st argument of interval- and loop-proc
TkAfter#current_interval returns an interval (sleep) time value
TkAfter#current_args returns an array of arguments
TkAfter#return_value returns a return value of last loop-proc
e.g.
TkAfter.new(
proc{|obj| 500 - obj.current_interval}, 10,
[proc{|obj| p obj.current_args}, 'proc', 1],
proc{|obj| p obj.current_args; ['return', 2]},
[proc{|obj|
p obj.return_value
p ['proc', obj.current_args[0].call(obj.return_value[1],
obj.current_args[1])]},
proc{|*args| args[0] + args[1]}, 1],
proc{p ['proc', 4]} ).start(100)
* tk*.rb: Allow to use Symbols for parameters.
Allow new notation of constructor (also allow old notation).
e.g.
TkFrame.new('classname'=>'User'){|base|
pack
f = TkFrame.new(base, :classname=>'ButtonFrame').pack
TkButton.new(
:parent => f,
:text => 'Quit',
:command => proc{exit}
).pack(
:fill => :x,
:pady => 2
)
}
* tkcanvas.rb: (TkcItem) Add 'coords' parameter to the canvas item
constructor (for new notation of constructor).
e.g.
c = TkCanvas.new.pack
l = TkcLine.new(c, :coords=>[[0,0], [100,100]])
* tcltklib.c: New 'mainloop' and 'mainloop_watchdog'.
The priority of their event-loop can be controlled.
They accept an optional argument.
If it false, they don't exit although the root widget is destroyed.
This function is sometimes useful, if it is used with 'restart'.
'mainloop' can't treat Thread#join/value in a callback routine.
(e.g. TkButton.new(:command=>proc{p Thread.new{button.invoke}.value}) )
'mainloop_watchdog' can treat them, but watchdog thread is always running
(so, a little heavier than 'mainloop').
If the purpose of using Thread#join/value is to do something under some
safe-level, please use Proc object.
(e.g. :command=>proc{$SAFE=1;proc{$SAFE=2;button.invoke}.call;p $SAFE})
* tk.rb: Support functions of new 'mainloop' and 'mainloop_watchdog'.
* tk.rb: (Tk.restart) Add 'app-name' paramater and 'use' parameter.
'app-name' specifies the name and the resource class of the
application. If 'app-name' is specified to 'xxx', the application
class on the resource database is set to 'Xxx' and the application
name is changed by the same rule of Tk.appname method. 'use'
specifies the main window for embedding the root widget instead of
generating a new window.
* tk.rb: Add new parameter 'widgetname' to the widget constructor to
support effective use of Resource Database. For example, the
resource 'Xxx*quit.text: QUIT' can set the text of the button
generated by the following code.
e.g.
Tk.restart('Xxx')
TkButton.new(nil, 'widgetname'=>'quit', 'command'=>proc{exit}).pack
Tk.mainloop
* tk.rb: TkOption::get always returns a tainted string.
Add TkOption::new_proc_class.
It generates a class to import procedures defined on the resource
database. For example, there is a following resource file.
----< resource-test >------------
*CMD.foo: {|*args| p [$SAFE, :foo, args]}
*CMD.XXX.bar: {|*args| p [$SAFE, :bar, args]}
*Button.command: ruby {p self; p $SAFE; TkOption::CMD::XXX.bar(1,2,3)}
---------------------------------
The following code is a sample of use of the resource file.
e.g.
require 'tk'
TkOption.readfile 'resource-test'
p TkOption.new_proc_class(:CMD, [:foo], 1)
p TkOption.new_proc_class(:XXX, [:bar], 2, false, TkOption::CMD)
TkButton.new(:text=>'test').pack
Tk.mainloop
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2515 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2002-06-04 11:03:33 +04:00
|
|
|
|
|
|
|
if (rb_scan_args(argc, argv, "01", &vflags) == 0) {
|
2003-09-07 11:10:44 +04:00
|
|
|
flags = TCL_ALL_EVENTS | TCL_DONT_WAIT;
|
* tkfont.rb: Fix bugs on TkFont.init_widget_font for Tk8.x.
* tkafter.rb: Add self to 1st argument of interval- and loop-proc
TkAfter#current_interval returns an interval (sleep) time value
TkAfter#current_args returns an array of arguments
TkAfter#return_value returns a return value of last loop-proc
e.g.
TkAfter.new(
proc{|obj| 500 - obj.current_interval}, 10,
[proc{|obj| p obj.current_args}, 'proc', 1],
proc{|obj| p obj.current_args; ['return', 2]},
[proc{|obj|
p obj.return_value
p ['proc', obj.current_args[0].call(obj.return_value[1],
obj.current_args[1])]},
proc{|*args| args[0] + args[1]}, 1],
proc{p ['proc', 4]} ).start(100)
* tk*.rb: Allow to use Symbols for parameters.
Allow new notation of constructor (also allow old notation).
e.g.
TkFrame.new('classname'=>'User'){|base|
pack
f = TkFrame.new(base, :classname=>'ButtonFrame').pack
TkButton.new(
:parent => f,
:text => 'Quit',
:command => proc{exit}
).pack(
:fill => :x,
:pady => 2
)
}
* tkcanvas.rb: (TkcItem) Add 'coords' parameter to the canvas item
constructor (for new notation of constructor).
e.g.
c = TkCanvas.new.pack
l = TkcLine.new(c, :coords=>[[0,0], [100,100]])
* tcltklib.c: New 'mainloop' and 'mainloop_watchdog'.
The priority of their event-loop can be controlled.
They accept an optional argument.
If it false, they don't exit although the root widget is destroyed.
This function is sometimes useful, if it is used with 'restart'.
'mainloop' can't treat Thread#join/value in a callback routine.
(e.g. TkButton.new(:command=>proc{p Thread.new{button.invoke}.value}) )
'mainloop_watchdog' can treat them, but watchdog thread is always running
(so, a little heavier than 'mainloop').
If the purpose of using Thread#join/value is to do something under some
safe-level, please use Proc object.
(e.g. :command=>proc{$SAFE=1;proc{$SAFE=2;button.invoke}.call;p $SAFE})
* tk.rb: Support functions of new 'mainloop' and 'mainloop_watchdog'.
* tk.rb: (Tk.restart) Add 'app-name' paramater and 'use' parameter.
'app-name' specifies the name and the resource class of the
application. If 'app-name' is specified to 'xxx', the application
class on the resource database is set to 'Xxx' and the application
name is changed by the same rule of Tk.appname method. 'use'
specifies the main window for embedding the root widget instead of
generating a new window.
* tk.rb: Add new parameter 'widgetname' to the widget constructor to
support effective use of Resource Database. For example, the
resource 'Xxx*quit.text: QUIT' can set the text of the button
generated by the following code.
e.g.
Tk.restart('Xxx')
TkButton.new(nil, 'widgetname'=>'quit', 'command'=>proc{exit}).pack
Tk.mainloop
* tk.rb: TkOption::get always returns a tainted string.
Add TkOption::new_proc_class.
It generates a class to import procedures defined on the resource
database. For example, there is a following resource file.
----< resource-test >------------
*CMD.foo: {|*args| p [$SAFE, :foo, args]}
*CMD.XXX.bar: {|*args| p [$SAFE, :bar, args]}
*Button.command: ruby {p self; p $SAFE; TkOption::CMD::XXX.bar(1,2,3)}
---------------------------------
The following code is a sample of use of the resource file.
e.g.
require 'tk'
TkOption.readfile 'resource-test'
p TkOption.new_proc_class(:CMD, [:foo], 1)
p TkOption.new_proc_class(:XXX, [:bar], 2, false, TkOption::CMD)
TkButton.new(:text=>'test').pack
Tk.mainloop
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2515 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2002-06-04 11:03:33 +04:00
|
|
|
} else {
|
2003-07-27 23:35:06 +04:00
|
|
|
Check_Type(vflags, T_FIXNUM);
|
|
|
|
flags = FIX2INT(vflags);
|
* tkfont.rb: Fix bugs on TkFont.init_widget_font for Tk8.x.
* tkafter.rb: Add self to 1st argument of interval- and loop-proc
TkAfter#current_interval returns an interval (sleep) time value
TkAfter#current_args returns an array of arguments
TkAfter#return_value returns a return value of last loop-proc
e.g.
TkAfter.new(
proc{|obj| 500 - obj.current_interval}, 10,
[proc{|obj| p obj.current_args}, 'proc', 1],
proc{|obj| p obj.current_args; ['return', 2]},
[proc{|obj|
p obj.return_value
p ['proc', obj.current_args[0].call(obj.return_value[1],
obj.current_args[1])]},
proc{|*args| args[0] + args[1]}, 1],
proc{p ['proc', 4]} ).start(100)
* tk*.rb: Allow to use Symbols for parameters.
Allow new notation of constructor (also allow old notation).
e.g.
TkFrame.new('classname'=>'User'){|base|
pack
f = TkFrame.new(base, :classname=>'ButtonFrame').pack
TkButton.new(
:parent => f,
:text => 'Quit',
:command => proc{exit}
).pack(
:fill => :x,
:pady => 2
)
}
* tkcanvas.rb: (TkcItem) Add 'coords' parameter to the canvas item
constructor (for new notation of constructor).
e.g.
c = TkCanvas.new.pack
l = TkcLine.new(c, :coords=>[[0,0], [100,100]])
* tcltklib.c: New 'mainloop' and 'mainloop_watchdog'.
The priority of their event-loop can be controlled.
They accept an optional argument.
If it false, they don't exit although the root widget is destroyed.
This function is sometimes useful, if it is used with 'restart'.
'mainloop' can't treat Thread#join/value in a callback routine.
(e.g. TkButton.new(:command=>proc{p Thread.new{button.invoke}.value}) )
'mainloop_watchdog' can treat them, but watchdog thread is always running
(so, a little heavier than 'mainloop').
If the purpose of using Thread#join/value is to do something under some
safe-level, please use Proc object.
(e.g. :command=>proc{$SAFE=1;proc{$SAFE=2;button.invoke}.call;p $SAFE})
* tk.rb: Support functions of new 'mainloop' and 'mainloop_watchdog'.
* tk.rb: (Tk.restart) Add 'app-name' paramater and 'use' parameter.
'app-name' specifies the name and the resource class of the
application. If 'app-name' is specified to 'xxx', the application
class on the resource database is set to 'Xxx' and the application
name is changed by the same rule of Tk.appname method. 'use'
specifies the main window for embedding the root widget instead of
generating a new window.
* tk.rb: Add new parameter 'widgetname' to the widget constructor to
support effective use of Resource Database. For example, the
resource 'Xxx*quit.text: QUIT' can set the text of the button
generated by the following code.
e.g.
Tk.restart('Xxx')
TkButton.new(nil, 'widgetname'=>'quit', 'command'=>proc{exit}).pack
Tk.mainloop
* tk.rb: TkOption::get always returns a tainted string.
Add TkOption::new_proc_class.
It generates a class to import procedures defined on the resource
database. For example, there is a following resource file.
----< resource-test >------------
*CMD.foo: {|*args| p [$SAFE, :foo, args]}
*CMD.XXX.bar: {|*args| p [$SAFE, :bar, args]}
*Button.command: ruby {p self; p $SAFE; TkOption::CMD::XXX.bar(1,2,3)}
---------------------------------
The following code is a sample of use of the resource file.
e.g.
require 'tk'
TkOption.readfile 'resource-test'
p TkOption.new_proc_class(:CMD, [:foo], 1)
p TkOption.new_proc_class(:XXX, [:bar], 2, false, TkOption::CMD)
TkButton.new(:text=>'test').pack
Tk.mainloop
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2515 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2002-06-04 11:03:33 +04:00
|
|
|
}
|
2003-09-07 11:10:44 +04:00
|
|
|
|
|
|
|
if (rb_safe_level() >= 4 || (rb_safe_level() >=1 && OBJ_TAINTED(vflags))) {
|
|
|
|
flags |= TCL_DONT_WAIT;
|
|
|
|
}
|
|
|
|
|
2003-08-29 12:34:14 +04:00
|
|
|
if (is_ip) {
|
|
|
|
/* check IP */
|
|
|
|
struct tcltkip *ptr = get_ip(self);
|
|
|
|
if (Tcl_GetMaster(ptr->ip) != (Tcl_Interp*)NULL) {
|
|
|
|
/* slave IP */
|
|
|
|
flags |= TCL_DONT_WAIT;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-11-08 00:39:36 +03:00
|
|
|
found_event = Tcl_DoOneEvent(TCL_ALL_EVENTS | TCL_DONT_WAIT);
|
|
|
|
|
|
|
|
if (found_event) {
|
2003-07-27 23:35:06 +04:00
|
|
|
return Qtrue;
|
2003-06-19 20:14:43 +04:00
|
|
|
} else {
|
2003-07-27 23:35:06 +04:00
|
|
|
return Qfalse;
|
2003-06-19 20:14:43 +04:00
|
|
|
}
|
* tkfont.rb: Fix bugs on TkFont.init_widget_font for Tk8.x.
* tkafter.rb: Add self to 1st argument of interval- and loop-proc
TkAfter#current_interval returns an interval (sleep) time value
TkAfter#current_args returns an array of arguments
TkAfter#return_value returns a return value of last loop-proc
e.g.
TkAfter.new(
proc{|obj| 500 - obj.current_interval}, 10,
[proc{|obj| p obj.current_args}, 'proc', 1],
proc{|obj| p obj.current_args; ['return', 2]},
[proc{|obj|
p obj.return_value
p ['proc', obj.current_args[0].call(obj.return_value[1],
obj.current_args[1])]},
proc{|*args| args[0] + args[1]}, 1],
proc{p ['proc', 4]} ).start(100)
* tk*.rb: Allow to use Symbols for parameters.
Allow new notation of constructor (also allow old notation).
e.g.
TkFrame.new('classname'=>'User'){|base|
pack
f = TkFrame.new(base, :classname=>'ButtonFrame').pack
TkButton.new(
:parent => f,
:text => 'Quit',
:command => proc{exit}
).pack(
:fill => :x,
:pady => 2
)
}
* tkcanvas.rb: (TkcItem) Add 'coords' parameter to the canvas item
constructor (for new notation of constructor).
e.g.
c = TkCanvas.new.pack
l = TkcLine.new(c, :coords=>[[0,0], [100,100]])
* tcltklib.c: New 'mainloop' and 'mainloop_watchdog'.
The priority of their event-loop can be controlled.
They accept an optional argument.
If it false, they don't exit although the root widget is destroyed.
This function is sometimes useful, if it is used with 'restart'.
'mainloop' can't treat Thread#join/value in a callback routine.
(e.g. TkButton.new(:command=>proc{p Thread.new{button.invoke}.value}) )
'mainloop_watchdog' can treat them, but watchdog thread is always running
(so, a little heavier than 'mainloop').
If the purpose of using Thread#join/value is to do something under some
safe-level, please use Proc object.
(e.g. :command=>proc{$SAFE=1;proc{$SAFE=2;button.invoke}.call;p $SAFE})
* tk.rb: Support functions of new 'mainloop' and 'mainloop_watchdog'.
* tk.rb: (Tk.restart) Add 'app-name' paramater and 'use' parameter.
'app-name' specifies the name and the resource class of the
application. If 'app-name' is specified to 'xxx', the application
class on the resource database is set to 'Xxx' and the application
name is changed by the same rule of Tk.appname method. 'use'
specifies the main window for embedding the root widget instead of
generating a new window.
* tk.rb: Add new parameter 'widgetname' to the widget constructor to
support effective use of Resource Database. For example, the
resource 'Xxx*quit.text: QUIT' can set the text of the button
generated by the following code.
e.g.
Tk.restart('Xxx')
TkButton.new(nil, 'widgetname'=>'quit', 'command'=>proc{exit}).pack
Tk.mainloop
* tk.rb: TkOption::get always returns a tainted string.
Add TkOption::new_proc_class.
It generates a class to import procedures defined on the resource
database. For example, there is a following resource file.
----< resource-test >------------
*CMD.foo: {|*args| p [$SAFE, :foo, args]}
*CMD.XXX.bar: {|*args| p [$SAFE, :bar, args]}
*Button.command: ruby {p self; p $SAFE; TkOption::CMD::XXX.bar(1,2,3)}
---------------------------------
The following code is a sample of use of the resource file.
e.g.
require 'tk'
TkOption.readfile 'resource-test'
p TkOption.new_proc_class(:CMD, [:foo], 1)
p TkOption.new_proc_class(:XXX, [:bar], 2, false, TkOption::CMD)
TkButton.new(:text=>'test').pack
Tk.mainloop
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2515 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2002-06-04 11:03:33 +04:00
|
|
|
}
|
|
|
|
|
2003-08-29 12:34:14 +04:00
|
|
|
static VALUE
|
|
|
|
lib_do_one_event(argc, argv, self)
|
|
|
|
int argc;
|
|
|
|
VALUE *argv;
|
2002-08-19 09:56:09 +04:00
|
|
|
VALUE self;
|
|
|
|
{
|
2003-08-29 12:34:14 +04:00
|
|
|
return lib_do_one_event_core(argc, argv, self, 0);
|
|
|
|
}
|
2002-08-19 09:56:09 +04:00
|
|
|
|
2003-08-29 12:34:14 +04:00
|
|
|
static VALUE
|
|
|
|
ip_do_one_event(argc, argv, self)
|
|
|
|
int argc;
|
|
|
|
VALUE *argv;
|
|
|
|
VALUE self;
|
|
|
|
{
|
|
|
|
return lib_do_one_event_core(argc, argv, self, 0);
|
2002-08-19 09:56:09 +04:00
|
|
|
}
|
|
|
|
|
2003-08-29 12:34:14 +04:00
|
|
|
|
1998-01-16 15:19:09 +03:00
|
|
|
/* Tcl command `ruby' */
|
|
|
|
static VALUE
|
2003-11-08 00:39:36 +03:00
|
|
|
ip_ruby_eval_rescue(failed, einfo)
|
1999-08-13 09:37:52 +04:00
|
|
|
VALUE *failed;
|
|
|
|
VALUE einfo;
|
1998-01-16 15:19:09 +03:00
|
|
|
{
|
|
|
|
*failed = einfo;
|
|
|
|
return Qnil;
|
|
|
|
}
|
|
|
|
|
2003-11-08 00:39:36 +03:00
|
|
|
struct eval_body_arg {
|
|
|
|
char *string;
|
|
|
|
VALUE failed;
|
|
|
|
};
|
|
|
|
|
2002-03-08 10:03:09 +03:00
|
|
|
static VALUE
|
2003-11-08 00:39:36 +03:00
|
|
|
ip_ruby_eval_body(arg)
|
|
|
|
struct eval_body_arg *arg;
|
2002-03-08 10:03:09 +03:00
|
|
|
{
|
2003-11-08 00:39:36 +03:00
|
|
|
rb_trap_immediate = 0;
|
|
|
|
return rb_rescue2(rb_eval_string, (VALUE)arg->string,
|
|
|
|
ip_ruby_eval_rescue, (VALUE)&(arg->failed),
|
|
|
|
rb_eStandardError, rb_eScriptError, rb_eSystemExit,
|
|
|
|
(VALUE)0);
|
2002-03-08 10:03:09 +03:00
|
|
|
}
|
|
|
|
|
2003-08-29 12:34:14 +04:00
|
|
|
static VALUE
|
2003-11-08 00:39:36 +03:00
|
|
|
ip_ruby_eval_ensure(trapflag)
|
|
|
|
VALUE trapflag;
|
2003-08-29 12:34:14 +04:00
|
|
|
{
|
2003-11-08 00:39:36 +03:00
|
|
|
rb_trap_immediate = NUM2INT(trapflag);
|
|
|
|
return Qnil;
|
2003-08-29 12:34:14 +04:00
|
|
|
}
|
|
|
|
|
1998-01-16 15:19:09 +03:00
|
|
|
static int
|
1999-01-20 07:59:39 +03:00
|
|
|
#if TCL_MAJOR_VERSION >= 8
|
1999-08-13 09:37:52 +04:00
|
|
|
ip_ruby(clientData, interp, argc, argv)
|
|
|
|
ClientData clientData;
|
|
|
|
Tcl_Interp *interp;
|
|
|
|
int argc;
|
|
|
|
Tcl_Obj *CONST argv[];
|
1999-01-20 07:59:39 +03:00
|
|
|
#else
|
1999-08-13 09:37:52 +04:00
|
|
|
ip_ruby(clientData, interp, argc, argv)
|
|
|
|
ClientData clientData;
|
|
|
|
Tcl_Interp *interp;
|
|
|
|
int argc;
|
|
|
|
char *argv[];
|
1999-01-20 07:59:39 +03:00
|
|
|
#endif
|
1998-01-16 15:19:09 +03:00
|
|
|
{
|
|
|
|
VALUE res;
|
2003-11-08 00:39:36 +03:00
|
|
|
int old_trapflag;
|
|
|
|
struct eval_body_arg arg;
|
1999-01-20 07:59:39 +03:00
|
|
|
int dummy;
|
1998-01-16 15:19:09 +03:00
|
|
|
|
|
|
|
/* ruby command has 1 arg. */
|
|
|
|
if (argc != 2) {
|
1999-01-20 07:59:39 +03:00
|
|
|
rb_raise(rb_eArgError, "wrong # of arguments (%d for 1)", argc);
|
1998-01-16 15:19:09 +03:00
|
|
|
}
|
|
|
|
|
1999-01-20 07:59:39 +03:00
|
|
|
/* get C string from Tcl object */
|
|
|
|
#if TCL_MAJOR_VERSION >= 8
|
2003-11-08 00:39:36 +03:00
|
|
|
arg.string = Tcl_GetStringFromObj(argv[1], &dummy);
|
1999-01-20 07:59:39 +03:00
|
|
|
#else
|
2003-11-08 00:39:36 +03:00
|
|
|
arg.string = argv[1];
|
1999-01-20 07:59:39 +03:00
|
|
|
#endif
|
2003-11-08 00:39:36 +03:00
|
|
|
arg.failed = 0;
|
1999-01-20 07:59:39 +03:00
|
|
|
|
1998-01-16 15:19:09 +03:00
|
|
|
/* evaluate the argument string by ruby */
|
1999-01-20 07:59:39 +03:00
|
|
|
DUMP2("rb_eval_string(%s)", arg);
|
2003-11-08 00:39:36 +03:00
|
|
|
old_trapflag = rb_trap_immediate;
|
|
|
|
res = rb_ensure(ip_ruby_eval_body, (VALUE)&arg,
|
|
|
|
ip_ruby_eval_ensure, INT2FIX(old_trapflag));
|
1998-01-16 15:19:09 +03:00
|
|
|
|
2003-10-14 19:25:45 +04:00
|
|
|
/* status check */
|
2003-11-08 00:39:36 +03:00
|
|
|
if (arg.failed) {
|
|
|
|
VALUE eclass = CLASS_OF(arg.failed);
|
2003-10-14 19:25:45 +04:00
|
|
|
DUMP1("(rb_eval_string result) failed");
|
|
|
|
Tcl_ResetResult(interp);
|
2003-11-08 00:39:36 +03:00
|
|
|
Tcl_AppendResult(interp, StringValuePtr(arg.failed), (char*)NULL);
|
1999-01-20 07:59:39 +03:00
|
|
|
if (eclass == eTkCallbackBreak) {
|
1999-08-13 09:37:52 +04:00
|
|
|
return TCL_BREAK;
|
1999-01-20 07:59:39 +03:00
|
|
|
} else if (eclass == eTkCallbackContinue) {
|
1999-08-13 09:37:52 +04:00
|
|
|
return TCL_CONTINUE;
|
2003-10-26 18:25:58 +03:00
|
|
|
} else if (eclass == rb_eSystemExit) {
|
|
|
|
Tcl_Eval(interp, "destroy .");
|
2003-11-08 00:39:36 +03:00
|
|
|
rb_raise(rb_eSystemExit, StringValuePtr(arg.failed));
|
1999-01-20 07:59:39 +03:00
|
|
|
} else {
|
1999-08-13 09:37:52 +04:00
|
|
|
return TCL_ERROR;
|
1999-01-20 07:59:39 +03:00
|
|
|
}
|
1998-01-16 15:19:09 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/* result must be string or nil */
|
|
|
|
if (NIL_P(res)) {
|
|
|
|
DUMP1("(rb_eval_string result) nil");
|
2003-10-14 19:25:45 +04:00
|
|
|
Tcl_ResetResult(interp);
|
1998-01-16 15:19:09 +03:00
|
|
|
return TCL_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* copy result to the tcl interpreter */
|
2001-05-06 19:06:00 +04:00
|
|
|
DUMP2("(rb_eval_string result) %s", StringValuePtr(res));
|
1998-01-16 15:19:09 +03:00
|
|
|
DUMP1("Tcl_AppendResult");
|
2003-10-14 19:25:45 +04:00
|
|
|
Tcl_ResetResult(interp);
|
2001-05-06 19:06:00 +04:00
|
|
|
Tcl_AppendResult(interp, StringValuePtr(res), (char *)NULL);
|
1998-01-16 15:19:09 +03:00
|
|
|
|
|
|
|
return TCL_OK;
|
|
|
|
}
|
|
|
|
|
2003-10-14 19:25:45 +04:00
|
|
|
|
|
|
|
/**************************/
|
|
|
|
/* based on tclEvent.c */
|
|
|
|
/**************************/
|
2003-10-29 14:03:54 +03:00
|
|
|
static char *VwaitVarProc _((ClientData, Tcl_Interp *, CONST84 char *,
|
|
|
|
CONST84 char *, int));
|
2003-10-14 19:25:45 +04:00
|
|
|
static char *
|
|
|
|
VwaitVarProc(clientData, interp, name1, name2, flags)
|
|
|
|
ClientData clientData; /* Pointer to integer to set to 1. */
|
|
|
|
Tcl_Interp *interp; /* Interpreter containing variable. */
|
2003-10-29 14:03:54 +03:00
|
|
|
CONST84 char *name1; /* Name of variable. */
|
|
|
|
CONST84 char *name2; /* Second part of variable name. */
|
2003-10-14 19:25:45 +04:00
|
|
|
int flags; /* Information about what happened. */
|
|
|
|
{
|
|
|
|
int *donePtr = (int *) clientData;
|
|
|
|
|
|
|
|
*donePtr = 1;
|
|
|
|
return (char *) NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
#if TCL_MAJOR_VERSION >= 8
|
* ext/tcltklib/tcltklib.c (VwaitVarProc, ip_rbVwaitObjCmd,
WaitVariableProc, WaitVisibilityProc, WaitWindowProc,
ip_rbTkWaitObjCmd, ip_rbTkWaitCommand, rb_threadVwaitProc,
rb_threadWaitVisibilityProc, rb_threadWaitWindowProc,
ip_rb_threadVwaitObjCmd, ip_rb_threadTkWaitObjCmd): prototype;
avoid VC++ warnings.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@4850 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2003-10-28 09:23:47 +03:00
|
|
|
static int ip_rbVwaitObjCmd _((ClientData, Tcl_Interp *, int,
|
|
|
|
Tcl_Obj *CONST []));
|
|
|
|
static int
|
2003-10-14 19:25:45 +04:00
|
|
|
ip_rbVwaitObjCmd(clientData, interp, objc, objv)
|
|
|
|
ClientData clientData;
|
|
|
|
Tcl_Interp *interp;
|
|
|
|
int objc;
|
|
|
|
Tcl_Obj *CONST objv[];
|
|
|
|
#else
|
* ext/tcltklib/tcltklib.c (VwaitVarProc, ip_rbVwaitObjCmd,
WaitVariableProc, WaitVisibilityProc, WaitWindowProc,
ip_rbTkWaitObjCmd, ip_rbTkWaitCommand, rb_threadVwaitProc,
rb_threadWaitVisibilityProc, rb_threadWaitWindowProc,
ip_rb_threadVwaitObjCmd, ip_rb_threadTkWaitObjCmd): prototype;
avoid VC++ warnings.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@4850 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2003-10-28 09:23:47 +03:00
|
|
|
static int ip_rbVwaitCommand _((ClientData, Tcl_Interp *, int, char *[]));
|
|
|
|
static int
|
2003-10-14 19:25:45 +04:00
|
|
|
ip_rbVwaitCommand(clientData, interp, objc, objv)
|
|
|
|
ClientData clientData;
|
|
|
|
Tcl_Interp *interp;
|
|
|
|
int objc;
|
|
|
|
char *objv[];
|
|
|
|
#endif
|
|
|
|
{
|
|
|
|
int done, foundEvent;
|
|
|
|
char *nameString;
|
|
|
|
int dummy;
|
|
|
|
|
|
|
|
DUMP1("Ruby's 'vwait' is called");
|
|
|
|
if (objc != 2) {
|
|
|
|
#ifdef Tcl_WrongNumArgs
|
|
|
|
Tcl_WrongNumArgs(interp, 1, objv, "name");
|
|
|
|
#else
|
|
|
|
#if TCL_MAJOR_VERSION >= 8
|
|
|
|
/* nameString = Tcl_GetString(objv[0]); */
|
|
|
|
nameString = Tcl_GetStringFromObj(objv[0], &dummy);
|
|
|
|
#else
|
|
|
|
nameString = objv[0];
|
|
|
|
#endif
|
|
|
|
Tcl_AppendResult(interp, "wrong # args: should be \"",
|
|
|
|
nameString, " name\"", (char *) NULL);
|
|
|
|
#endif
|
|
|
|
return TCL_ERROR;
|
|
|
|
}
|
|
|
|
#if TCL_MAJOR_VERSION >= 8
|
|
|
|
/* nameString = Tcl_GetString(objv[1]); */
|
|
|
|
nameString = Tcl_GetStringFromObj(objv[1], &dummy);
|
|
|
|
#else
|
|
|
|
nameString = objv[1];
|
|
|
|
#endif
|
|
|
|
|
|
|
|
if (Tcl_TraceVar(interp, nameString,
|
|
|
|
TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS,
|
|
|
|
VwaitVarProc, (ClientData) &done) != TCL_OK) {
|
|
|
|
return TCL_ERROR;
|
|
|
|
};
|
|
|
|
done = 0;
|
|
|
|
foundEvent = lib_eventloop_core(/* not check root-widget */0, &done);
|
|
|
|
Tcl_UntraceVar(interp, nameString,
|
|
|
|
TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS,
|
|
|
|
VwaitVarProc, (ClientData) &done);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Clear out the interpreter's result, since it may have been set
|
|
|
|
* by event handlers.
|
|
|
|
*/
|
|
|
|
|
|
|
|
Tcl_ResetResult(interp);
|
|
|
|
if (!foundEvent) {
|
|
|
|
Tcl_AppendResult(interp, "can't wait for variable \"", nameString,
|
|
|
|
"\": would wait forever", (char *) NULL);
|
|
|
|
return TCL_ERROR;
|
|
|
|
}
|
|
|
|
return TCL_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**************************/
|
|
|
|
/* based on tkCmd.c */
|
|
|
|
/**************************/
|
2003-10-29 14:03:54 +03:00
|
|
|
static char *WaitVariableProc _((ClientData, Tcl_Interp *, CONST84 char *,
|
|
|
|
CONST84 char *, int));
|
2003-10-14 19:25:45 +04:00
|
|
|
static char *
|
|
|
|
WaitVariableProc(clientData, interp, name1, name2, flags)
|
|
|
|
ClientData clientData; /* Pointer to integer to set to 1. */
|
|
|
|
Tcl_Interp *interp; /* Interpreter containing variable. */
|
2003-10-29 14:03:54 +03:00
|
|
|
CONST84 char *name1; /* Name of variable. */
|
|
|
|
CONST84 char *name2; /* Second part of variable name. */
|
2003-10-14 19:25:45 +04:00
|
|
|
int flags; /* Information about what happened. */
|
|
|
|
{
|
|
|
|
int *donePtr = (int *) clientData;
|
|
|
|
|
|
|
|
*donePtr = 1;
|
|
|
|
return (char *) NULL;
|
|
|
|
}
|
|
|
|
|
* ext/tcltklib/tcltklib.c (VwaitVarProc, ip_rbVwaitObjCmd,
WaitVariableProc, WaitVisibilityProc, WaitWindowProc,
ip_rbTkWaitObjCmd, ip_rbTkWaitCommand, rb_threadVwaitProc,
rb_threadWaitVisibilityProc, rb_threadWaitWindowProc,
ip_rb_threadVwaitObjCmd, ip_rb_threadTkWaitObjCmd): prototype;
avoid VC++ warnings.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@4850 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2003-10-28 09:23:47 +03:00
|
|
|
static void WaitVisibilityProc _((ClientData, XEvent *));
|
2003-10-14 19:25:45 +04:00
|
|
|
static void
|
|
|
|
WaitVisibilityProc(clientData, eventPtr)
|
|
|
|
ClientData clientData; /* Pointer to integer to set to 1. */
|
|
|
|
XEvent *eventPtr; /* Information about event (not used). */
|
|
|
|
{
|
|
|
|
int *donePtr = (int *) clientData;
|
|
|
|
|
|
|
|
if (eventPtr->type == VisibilityNotify) {
|
|
|
|
*donePtr = 1;
|
|
|
|
}
|
|
|
|
if (eventPtr->type == DestroyNotify) {
|
|
|
|
*donePtr = 2;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
* ext/tcltklib/tcltklib.c (VwaitVarProc, ip_rbVwaitObjCmd,
WaitVariableProc, WaitVisibilityProc, WaitWindowProc,
ip_rbTkWaitObjCmd, ip_rbTkWaitCommand, rb_threadVwaitProc,
rb_threadWaitVisibilityProc, rb_threadWaitWindowProc,
ip_rb_threadVwaitObjCmd, ip_rb_threadTkWaitObjCmd): prototype;
avoid VC++ warnings.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@4850 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2003-10-28 09:23:47 +03:00
|
|
|
static void WaitWindowProc _((ClientData, XEvent *));
|
2003-10-14 19:25:45 +04:00
|
|
|
static void
|
|
|
|
WaitWindowProc(clientData, eventPtr)
|
|
|
|
ClientData clientData; /* Pointer to integer to set to 1. */
|
|
|
|
XEvent *eventPtr; /* Information about event. */
|
|
|
|
{
|
|
|
|
int *donePtr = (int *) clientData;
|
|
|
|
|
|
|
|
if (eventPtr->type == DestroyNotify) {
|
|
|
|
*donePtr = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#if TCL_MAJOR_VERSION >= 8
|
* ext/tcltklib/tcltklib.c (VwaitVarProc, ip_rbVwaitObjCmd,
WaitVariableProc, WaitVisibilityProc, WaitWindowProc,
ip_rbTkWaitObjCmd, ip_rbTkWaitCommand, rb_threadVwaitProc,
rb_threadWaitVisibilityProc, rb_threadWaitWindowProc,
ip_rb_threadVwaitObjCmd, ip_rb_threadTkWaitObjCmd): prototype;
avoid VC++ warnings.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@4850 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2003-10-28 09:23:47 +03:00
|
|
|
static int ip_rbTkWaitObjCmd _((ClientData, Tcl_Interp *, int,
|
|
|
|
Tcl_Obj *CONST []));
|
|
|
|
static int
|
2003-10-14 19:25:45 +04:00
|
|
|
ip_rbTkWaitObjCmd(clientData, interp, objc, objv)
|
|
|
|
ClientData clientData;
|
|
|
|
Tcl_Interp *interp;
|
|
|
|
int objc;
|
|
|
|
Tcl_Obj *CONST objv[];
|
|
|
|
#else
|
* ext/tcltklib/tcltklib.c (VwaitVarProc, ip_rbVwaitObjCmd,
WaitVariableProc, WaitVisibilityProc, WaitWindowProc,
ip_rbTkWaitObjCmd, ip_rbTkWaitCommand, rb_threadVwaitProc,
rb_threadWaitVisibilityProc, rb_threadWaitWindowProc,
ip_rb_threadVwaitObjCmd, ip_rb_threadTkWaitObjCmd): prototype;
avoid VC++ warnings.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@4850 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2003-10-28 09:23:47 +03:00
|
|
|
static int ip_rbTkWaitCommand _((ClientData, Tcl_Interp *, int, char *[]));
|
|
|
|
static int
|
2003-10-14 19:25:45 +04:00
|
|
|
ip_rbTkWaitCommand(clientData, interp, objc, objv)
|
|
|
|
ClientData clientData;
|
|
|
|
Tcl_Interp *interp;
|
|
|
|
int objc;
|
|
|
|
char *objv[];
|
|
|
|
#endif
|
|
|
|
{
|
|
|
|
Tk_Window tkwin = (Tk_Window) clientData;
|
|
|
|
int done, index;
|
|
|
|
static CONST char *optionStrings[] = { "variable", "visibility", "window",
|
|
|
|
(char *) NULL };
|
|
|
|
enum options { TKWAIT_VARIABLE, TKWAIT_VISIBILITY, TKWAIT_WINDOW };
|
|
|
|
char *nameString;
|
|
|
|
int dummy;
|
|
|
|
|
|
|
|
DUMP1("Ruby's 'tkwait' is called");
|
|
|
|
|
|
|
|
if (objc != 3) {
|
|
|
|
#ifdef Tcl_WrongNumArgs
|
|
|
|
Tcl_WrongNumArgs(interp, 1, objv, "variable|visibility|window name");
|
|
|
|
#else
|
|
|
|
#if TCL_MAJOR_VERSION >= 8
|
|
|
|
Tcl_AppendResult(interp, "wrong # args: should be \"",
|
|
|
|
Tcl_GetStringFromObj(objv[0], &dummy),
|
|
|
|
" variable|visibility|window name\"",
|
|
|
|
(char *) NULL);
|
|
|
|
#else
|
|
|
|
Tcl_AppendResult(interp, "wrong # args: should be \"",
|
|
|
|
objv[0], " variable|visibility|window name\"",
|
|
|
|
(char *) NULL);
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
return TCL_ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
#if TCL_MAJOR_VERSION >= 8
|
|
|
|
if (Tcl_GetIndexFromObj(interp, objv[1],
|
|
|
|
(CONST84 char **)optionStrings,
|
|
|
|
"option", 0, &index) != TCL_OK) {
|
|
|
|
return TCL_ERROR;
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
{
|
|
|
|
int c = objv[1][0];
|
|
|
|
size_t length = strlen(objv[1]);
|
|
|
|
|
|
|
|
if ((c == 'v') && (strncmp(objv[1], "variable", length) == 0)
|
|
|
|
&& (length >= 2)) {
|
|
|
|
index = TKWAIT_VARIABLE;
|
|
|
|
} else if ((c == 'v') && (strncmp(objv[1], "visibility", length) == 0)
|
|
|
|
&& (length >= 2)) {
|
|
|
|
index = TKWAIT_VISIBILITY;
|
|
|
|
} else if ((c == 'w') && (strncmp(objv[1], "window", length) == 0)) {
|
|
|
|
index = TKWAIT_WINDOW;
|
|
|
|
} else {
|
|
|
|
Tcl_AppendResult(interp, "bad option \"", objv[1],
|
|
|
|
"\": must be variable, visibility, or window",
|
|
|
|
(char *) NULL);
|
|
|
|
return TCL_ERROR;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if TCL_MAJOR_VERSION >= 8
|
|
|
|
/* nameString = Tcl_GetString(objv[2]); */
|
|
|
|
nameString = Tcl_GetStringFromObj(objv[2], &dummy);
|
|
|
|
#else
|
|
|
|
nameString = objv[2];
|
|
|
|
#endif
|
|
|
|
|
|
|
|
switch ((enum options) index) {
|
|
|
|
case TKWAIT_VARIABLE: {
|
|
|
|
if (Tcl_TraceVar(interp, nameString,
|
|
|
|
TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS,
|
|
|
|
WaitVariableProc, (ClientData) &done) != TCL_OK) {
|
|
|
|
return TCL_ERROR;
|
|
|
|
}
|
|
|
|
done = 0;
|
|
|
|
lib_eventloop_core(check_rootwidget_flag, &done);
|
|
|
|
Tcl_UntraceVar(interp, nameString,
|
|
|
|
TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS,
|
|
|
|
WaitVariableProc, (ClientData) &done);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case TKWAIT_VISIBILITY: {
|
|
|
|
Tk_Window window;
|
|
|
|
|
|
|
|
window = Tk_NameToWindow(interp, nameString, tkwin);
|
|
|
|
if (window == NULL) {
|
|
|
|
return TCL_ERROR;
|
|
|
|
}
|
|
|
|
Tk_CreateEventHandler(window,
|
|
|
|
VisibilityChangeMask|StructureNotifyMask,
|
|
|
|
WaitVisibilityProc, (ClientData) &done);
|
|
|
|
done = 0;
|
|
|
|
lib_eventloop_core(check_rootwidget_flag, &done);
|
|
|
|
if (done != 1) {
|
|
|
|
/*
|
|
|
|
* Note that we do not delete the event handler because it
|
|
|
|
* was deleted automatically when the window was destroyed.
|
|
|
|
*/
|
|
|
|
|
|
|
|
Tcl_ResetResult(interp);
|
|
|
|
Tcl_AppendResult(interp, "window \"", nameString,
|
|
|
|
"\" was deleted before its visibility changed",
|
|
|
|
(char *) NULL);
|
|
|
|
return TCL_ERROR;
|
|
|
|
}
|
|
|
|
Tk_DeleteEventHandler(window,
|
|
|
|
VisibilityChangeMask|StructureNotifyMask,
|
|
|
|
WaitVisibilityProc, (ClientData) &done);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case TKWAIT_WINDOW: {
|
|
|
|
Tk_Window window;
|
|
|
|
|
|
|
|
window = Tk_NameToWindow(interp, nameString, tkwin);
|
|
|
|
if (window == NULL) {
|
|
|
|
return TCL_ERROR;
|
|
|
|
}
|
|
|
|
Tk_CreateEventHandler(window, StructureNotifyMask,
|
|
|
|
WaitWindowProc, (ClientData) &done);
|
|
|
|
done = 0;
|
|
|
|
lib_eventloop_core(check_rootwidget_flag, &done);
|
|
|
|
/*
|
|
|
|
* Note: there's no need to delete the event handler. It was
|
|
|
|
* deleted automatically when the window was destroyed.
|
|
|
|
*/
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Clear out the interpreter's result, since it may have been set
|
|
|
|
* by event handlers.
|
|
|
|
*/
|
|
|
|
|
|
|
|
Tcl_ResetResult(interp);
|
|
|
|
return TCL_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/****************************/
|
|
|
|
/* vwait/tkwait with thread */
|
|
|
|
/****************************/
|
|
|
|
struct th_vwait_param {
|
|
|
|
VALUE thread;
|
|
|
|
int done;
|
|
|
|
};
|
|
|
|
|
2003-10-29 14:03:54 +03:00
|
|
|
static char *rb_threadVwaitProc _((ClientData, Tcl_Interp *, CONST84 char *,
|
|
|
|
CONST84 char *, int));
|
2003-10-14 19:25:45 +04:00
|
|
|
static char *
|
|
|
|
rb_threadVwaitProc(clientData, interp, name1, name2, flags)
|
|
|
|
ClientData clientData; /* Pointer to integer to set to 1. */
|
|
|
|
Tcl_Interp *interp; /* Interpreter containing variable. */
|
2003-10-29 14:03:54 +03:00
|
|
|
CONST84 char *name1; /* Name of variable. */
|
|
|
|
CONST84 char *name2; /* Second part of variable name. */
|
2003-10-14 19:25:45 +04:00
|
|
|
int flags; /* Information about what happened. */
|
|
|
|
{
|
|
|
|
struct th_vwait_param *param = (struct th_vwait_param *) clientData;
|
|
|
|
|
|
|
|
param->done = 1;
|
|
|
|
rb_thread_run(param->thread);
|
|
|
|
|
|
|
|
return (char *)NULL;
|
|
|
|
}
|
|
|
|
|
* ext/tcltklib/tcltklib.c (VwaitVarProc, ip_rbVwaitObjCmd,
WaitVariableProc, WaitVisibilityProc, WaitWindowProc,
ip_rbTkWaitObjCmd, ip_rbTkWaitCommand, rb_threadVwaitProc,
rb_threadWaitVisibilityProc, rb_threadWaitWindowProc,
ip_rb_threadVwaitObjCmd, ip_rb_threadTkWaitObjCmd): prototype;
avoid VC++ warnings.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@4850 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2003-10-28 09:23:47 +03:00
|
|
|
static void rb_threadWaitVisibilityProc _((ClientData, XEvent *));
|
2003-10-14 19:25:45 +04:00
|
|
|
static void
|
|
|
|
rb_threadWaitVisibilityProc(clientData, eventPtr)
|
|
|
|
ClientData clientData; /* Pointer to integer to set to 1. */
|
|
|
|
XEvent *eventPtr; /* Information about event (not used). */
|
|
|
|
{
|
|
|
|
struct th_vwait_param *param = (struct th_vwait_param *) clientData;
|
|
|
|
|
|
|
|
if (eventPtr->type == VisibilityNotify) {
|
|
|
|
param->done = 1;
|
|
|
|
}
|
|
|
|
if (eventPtr->type == DestroyNotify) {
|
|
|
|
param->done = 2;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
* ext/tcltklib/tcltklib.c (VwaitVarProc, ip_rbVwaitObjCmd,
WaitVariableProc, WaitVisibilityProc, WaitWindowProc,
ip_rbTkWaitObjCmd, ip_rbTkWaitCommand, rb_threadVwaitProc,
rb_threadWaitVisibilityProc, rb_threadWaitWindowProc,
ip_rb_threadVwaitObjCmd, ip_rb_threadTkWaitObjCmd): prototype;
avoid VC++ warnings.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@4850 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2003-10-28 09:23:47 +03:00
|
|
|
static void rb_threadWaitWindowProc _((ClientData, XEvent *));
|
2003-10-14 19:25:45 +04:00
|
|
|
static void
|
|
|
|
rb_threadWaitWindowProc(clientData, eventPtr)
|
|
|
|
ClientData clientData; /* Pointer to integer to set to 1. */
|
|
|
|
XEvent *eventPtr; /* Information about event. */
|
|
|
|
{
|
|
|
|
struct th_vwait_param *param = (struct th_vwait_param *) clientData;
|
|
|
|
|
|
|
|
if (eventPtr->type == DestroyNotify) {
|
|
|
|
param->done = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#if TCL_MAJOR_VERSION >= 8
|
* ext/tcltklib/tcltklib.c (VwaitVarProc, ip_rbVwaitObjCmd,
WaitVariableProc, WaitVisibilityProc, WaitWindowProc,
ip_rbTkWaitObjCmd, ip_rbTkWaitCommand, rb_threadVwaitProc,
rb_threadWaitVisibilityProc, rb_threadWaitWindowProc,
ip_rb_threadVwaitObjCmd, ip_rb_threadTkWaitObjCmd): prototype;
avoid VC++ warnings.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@4850 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2003-10-28 09:23:47 +03:00
|
|
|
static int ip_rb_threadVwaitObjCmd _((ClientData, Tcl_Interp *, int,
|
|
|
|
Tcl_Obj *CONST []));
|
|
|
|
static int
|
2003-10-14 19:25:45 +04:00
|
|
|
ip_rb_threadVwaitObjCmd(clientData, interp, objc, objv)
|
|
|
|
ClientData clientData;
|
|
|
|
Tcl_Interp *interp;
|
|
|
|
int objc;
|
|
|
|
Tcl_Obj *CONST objv[];
|
|
|
|
#else
|
* ext/tcltklib/tcltklib.c (VwaitVarProc, ip_rbVwaitObjCmd,
WaitVariableProc, WaitVisibilityProc, WaitWindowProc,
ip_rbTkWaitObjCmd, ip_rbTkWaitCommand, rb_threadVwaitProc,
rb_threadWaitVisibilityProc, rb_threadWaitWindowProc,
ip_rb_threadVwaitObjCmd, ip_rb_threadTkWaitObjCmd): prototype;
avoid VC++ warnings.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@4850 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2003-10-28 09:23:47 +03:00
|
|
|
static int ip_rb_threadVwaitCommand _((ClientData, Tcl_Interp *, int,
|
|
|
|
char *[]));
|
|
|
|
static int
|
2003-10-14 19:25:45 +04:00
|
|
|
ip_rb_threadVwaitCommand(clientData, interp, objc, objv)
|
|
|
|
ClientData clientData;
|
|
|
|
Tcl_Interp *interp;
|
|
|
|
int objc;
|
|
|
|
char *objv[];
|
|
|
|
#endif
|
|
|
|
{
|
|
|
|
struct th_vwait_param *param;
|
|
|
|
char *nameString;
|
|
|
|
int dummy;
|
|
|
|
|
|
|
|
DUMP1("Ruby's 'thread_vwait' is called");
|
|
|
|
|
|
|
|
if (eventloop_thread == rb_thread_current()) {
|
|
|
|
#if TCL_MAJOR_VERSION >= 8
|
|
|
|
DUMP1("call ip_rbVwaitObjCmd");
|
|
|
|
return ip_rbVwaitObjCmd(clientData, interp, objc, objv);
|
|
|
|
#else
|
|
|
|
DUMP1("call ip_rbVwaitCommand");
|
|
|
|
return ip_rbVwaitCommand(clientData, interp, objc, objv);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
if (objc != 2) {
|
|
|
|
#ifdef Tcl_WrongNumArgs
|
|
|
|
Tcl_WrongNumArgs(interp, 1, objv, "name");
|
|
|
|
#else
|
|
|
|
#if TCL_MAJOR_VERSION >= 8
|
|
|
|
/* nameString = Tcl_GetString(objv[0]); */
|
|
|
|
nameString = Tcl_GetStringFromObj(objv[0], &dummy);
|
|
|
|
#else
|
|
|
|
nameString = objv[0];
|
|
|
|
#endif
|
|
|
|
Tcl_AppendResult(interp, "wrong # args: should be \"",
|
|
|
|
nameString, " name\"", (char *) NULL);
|
|
|
|
#endif
|
|
|
|
return TCL_ERROR;
|
|
|
|
}
|
|
|
|
#if TCL_MAJOR_VERSION >= 8
|
|
|
|
/* nameString = Tcl_GetString(objv[1]); */
|
|
|
|
nameString = Tcl_GetStringFromObj(objv[1], &dummy);
|
|
|
|
#else
|
|
|
|
nameString = objv[1];
|
|
|
|
#endif
|
|
|
|
|
|
|
|
param = (struct th_vwait_param *)Tcl_Alloc(sizeof(struct th_vwait_param));
|
|
|
|
param->thread = rb_thread_current();
|
|
|
|
param->done = 0;
|
|
|
|
|
|
|
|
if (Tcl_TraceVar(interp, nameString,
|
|
|
|
TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS,
|
|
|
|
rb_threadVwaitProc, (ClientData) param) != TCL_OK) {
|
|
|
|
return TCL_ERROR;
|
|
|
|
};
|
|
|
|
|
|
|
|
if (!param->done) {
|
|
|
|
rb_thread_stop();
|
|
|
|
}
|
|
|
|
|
|
|
|
Tcl_UntraceVar(interp, nameString,
|
|
|
|
TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS,
|
|
|
|
rb_threadVwaitProc, (ClientData) param);
|
|
|
|
|
|
|
|
Tcl_Free((char *)param);
|
|
|
|
|
|
|
|
return TCL_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
#if TCL_MAJOR_VERSION >= 8
|
* ext/tcltklib/tcltklib.c (VwaitVarProc, ip_rbVwaitObjCmd,
WaitVariableProc, WaitVisibilityProc, WaitWindowProc,
ip_rbTkWaitObjCmd, ip_rbTkWaitCommand, rb_threadVwaitProc,
rb_threadWaitVisibilityProc, rb_threadWaitWindowProc,
ip_rb_threadVwaitObjCmd, ip_rb_threadTkWaitObjCmd): prototype;
avoid VC++ warnings.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@4850 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2003-10-28 09:23:47 +03:00
|
|
|
static int ip_rb_threadTkWaitObjCmd _((ClientData, Tcl_Interp *, int,
|
|
|
|
Tcl_Obj *CONST []));
|
|
|
|
static int
|
2003-10-14 19:25:45 +04:00
|
|
|
ip_rb_threadTkWaitObjCmd(clientData, interp, objc, objv)
|
|
|
|
ClientData clientData;
|
|
|
|
Tcl_Interp *interp;
|
|
|
|
int objc;
|
|
|
|
Tcl_Obj *CONST objv[];
|
|
|
|
#else
|
* ext/tcltklib/tcltklib.c (VwaitVarProc, ip_rbVwaitObjCmd,
WaitVariableProc, WaitVisibilityProc, WaitWindowProc,
ip_rbTkWaitObjCmd, ip_rbTkWaitCommand, rb_threadVwaitProc,
rb_threadWaitVisibilityProc, rb_threadWaitWindowProc,
ip_rb_threadVwaitObjCmd, ip_rb_threadTkWaitObjCmd): prototype;
avoid VC++ warnings.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@4850 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2003-10-28 09:23:47 +03:00
|
|
|
static int ip_rb_threadTkWaitCommand _((ClientData, Tcl_Interp *, int,
|
|
|
|
char *[]));
|
|
|
|
static int
|
2003-10-14 19:25:45 +04:00
|
|
|
ip_rb_threadTkWaitCommand(clientData, interp, objc, objv)
|
|
|
|
ClientData clientData;
|
|
|
|
Tcl_Interp *interp;
|
|
|
|
int objc;
|
|
|
|
char *objv[];
|
|
|
|
#endif
|
|
|
|
{
|
|
|
|
struct th_vwait_param *param;
|
|
|
|
Tk_Window tkwin = (Tk_Window) clientData;
|
|
|
|
int index;
|
|
|
|
static CONST char *optionStrings[] = { "variable", "visibility", "window",
|
|
|
|
(char *) NULL };
|
|
|
|
enum options { TKWAIT_VARIABLE, TKWAIT_VISIBILITY, TKWAIT_WINDOW };
|
|
|
|
char *nameString;
|
|
|
|
int dummy;
|
|
|
|
|
|
|
|
DUMP1("Ruby's 'thread_tkwait' is called");
|
|
|
|
|
|
|
|
if (eventloop_thread == rb_thread_current()) {
|
|
|
|
#if TCL_MAJOR_VERSION >= 8
|
|
|
|
DUMP1("call ip_rbTkWaitObjCmd");
|
|
|
|
return ip_rbTkWaitObjCmd(clientData, interp, objc, objv);
|
|
|
|
#else
|
|
|
|
DUMP1("call rb_VwaitCommand");
|
|
|
|
return ip_rbTkWaitCommand(clientData, interp, objc, objv);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
if (objc != 3) {
|
|
|
|
#ifdef Tcl_WrongNumArgs
|
|
|
|
Tcl_WrongNumArgs(interp, 1, objv, "variable|visibility|window name");
|
|
|
|
#else
|
|
|
|
#if TCL_MAJOR_VERSION >= 8
|
|
|
|
Tcl_AppendResult(interp, "wrong # args: should be \"",
|
|
|
|
Tcl_GetStringFromObj(objv[0], &dummy),
|
|
|
|
" variable|visibility|window name\"",
|
|
|
|
(char *) NULL);
|
|
|
|
#else
|
|
|
|
Tcl_AppendResult(interp, "wrong # args: should be \"",
|
|
|
|
objv[0], " variable|visibility|window name\"",
|
|
|
|
(char *) NULL);
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
return TCL_ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
#if TCL_MAJOR_VERSION >= 8
|
|
|
|
if (Tcl_GetIndexFromObj(interp, objv[1],
|
|
|
|
(CONST84 char **)optionStrings,
|
|
|
|
"option", 0, &index) != TCL_OK) {
|
|
|
|
return TCL_ERROR;
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
{
|
|
|
|
int c = objv[1][0];
|
|
|
|
size_t length = strlen(objv[1]);
|
|
|
|
|
|
|
|
if ((c == 'v') && (strncmp(objv[1], "variable", length) == 0)
|
|
|
|
&& (length >= 2)) {
|
|
|
|
index = TKWAIT_VARIABLE;
|
|
|
|
} else if ((c == 'v') && (strncmp(objv[1], "visibility", length) == 0)
|
|
|
|
&& (length >= 2)) {
|
|
|
|
index = TKWAIT_VISIBILITY;
|
|
|
|
} else if ((c == 'w') && (strncmp(objv[1], "window", length) == 0)) {
|
|
|
|
index = TKWAIT_WINDOW;
|
|
|
|
} else {
|
|
|
|
Tcl_AppendResult(interp, "bad option \"", objv[1],
|
|
|
|
"\": must be variable, visibility, or window",
|
|
|
|
(char *) NULL);
|
|
|
|
return TCL_ERROR;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if TCL_MAJOR_VERSION >= 8
|
|
|
|
/* nameString = Tcl_GetString(objv[2]); */
|
|
|
|
nameString = Tcl_GetStringFromObj(objv[2], &dummy);
|
|
|
|
#else
|
|
|
|
nameString = objv[2];
|
|
|
|
#endif
|
|
|
|
|
|
|
|
param = (struct th_vwait_param *)Tcl_Alloc(sizeof(struct th_vwait_param));
|
|
|
|
param->thread = rb_thread_current();
|
|
|
|
param->done = 0;
|
|
|
|
|
|
|
|
switch ((enum options) index) {
|
|
|
|
case TKWAIT_VARIABLE: {
|
|
|
|
if (Tcl_TraceVar(interp, nameString,
|
|
|
|
TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS,
|
|
|
|
rb_threadVwaitProc, (ClientData) param) != TCL_OK) {
|
|
|
|
return TCL_ERROR;
|
|
|
|
};
|
|
|
|
|
|
|
|
if (!param->done) {
|
|
|
|
rb_thread_stop();
|
|
|
|
}
|
|
|
|
|
|
|
|
Tcl_UntraceVar(interp, nameString,
|
|
|
|
TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS,
|
|
|
|
rb_threadVwaitProc, (ClientData) param);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case TKWAIT_VISIBILITY: {
|
|
|
|
Tk_Window window;
|
|
|
|
|
|
|
|
window = Tk_NameToWindow(interp, nameString, tkwin);
|
|
|
|
if (window == NULL) {
|
|
|
|
return TCL_ERROR;
|
|
|
|
}
|
|
|
|
Tk_CreateEventHandler(window,
|
|
|
|
VisibilityChangeMask|StructureNotifyMask,
|
|
|
|
rb_threadWaitVisibilityProc, (ClientData) param);
|
|
|
|
if (!param->done) {
|
|
|
|
rb_thread_stop();
|
|
|
|
}
|
|
|
|
if (param->done != 1) {
|
|
|
|
/*
|
|
|
|
* Note that we do not delete the event handler because it
|
|
|
|
* was deleted automatically when the window was destroyed.
|
|
|
|
*/
|
|
|
|
|
|
|
|
Tcl_ResetResult(interp);
|
|
|
|
Tcl_AppendResult(interp, "window \"", nameString,
|
|
|
|
"\" was deleted before its visibility changed",
|
|
|
|
(char *) NULL);
|
|
|
|
return TCL_ERROR;
|
|
|
|
}
|
|
|
|
Tk_DeleteEventHandler(window,
|
|
|
|
VisibilityChangeMask|StructureNotifyMask,
|
|
|
|
rb_threadWaitVisibilityProc, (ClientData) param);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case TKWAIT_WINDOW: {
|
|
|
|
Tk_Window window;
|
|
|
|
|
|
|
|
window = Tk_NameToWindow(interp, nameString, tkwin);
|
|
|
|
if (window == NULL) {
|
|
|
|
return TCL_ERROR;
|
|
|
|
}
|
|
|
|
Tk_CreateEventHandler(window, StructureNotifyMask,
|
|
|
|
rb_threadWaitWindowProc, (ClientData) param);
|
|
|
|
if (!param->done) {
|
|
|
|
rb_thread_stop();
|
|
|
|
}
|
|
|
|
/*
|
|
|
|
* Note: there's no need to delete the event handler. It was
|
|
|
|
* deleted automatically when the window was destroyed.
|
|
|
|
*/
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Tcl_Free((char *)param);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Clear out the interpreter's result, since it may have been set
|
|
|
|
* by event handlers.
|
|
|
|
*/
|
|
|
|
|
|
|
|
Tcl_ResetResult(interp);
|
|
|
|
return TCL_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static VALUE
|
|
|
|
ip_thread_vwait(self, var)
|
|
|
|
VALUE self;
|
|
|
|
VALUE var;
|
|
|
|
{
|
|
|
|
VALUE argv[2];
|
|
|
|
|
|
|
|
argv[0] = rb_str_new2("thread_vwait");
|
|
|
|
argv[1] = var;
|
|
|
|
return ip_invoke_real(2, argv, self);
|
|
|
|
}
|
|
|
|
|
|
|
|
static VALUE
|
|
|
|
ip_thread_tkwait(self, mode, target)
|
|
|
|
VALUE self;
|
|
|
|
VALUE mode;
|
|
|
|
VALUE target;
|
|
|
|
{
|
|
|
|
VALUE argv[3];
|
|
|
|
|
|
|
|
argv[0] = rb_str_new2("thread_tkwait");
|
|
|
|
argv[1] = mode;
|
|
|
|
argv[2] = target;
|
|
|
|
return ip_invoke_real(3, argv, self);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1998-01-16 15:19:09 +03:00
|
|
|
/* destroy interpreter */
|
|
|
|
static void
|
1999-08-13 09:37:52 +04:00
|
|
|
ip_free(ptr)
|
|
|
|
struct tcltkip *ptr;
|
1998-01-16 15:19:09 +03:00
|
|
|
{
|
|
|
|
DUMP1("Tcl_DeleteInterp");
|
2002-08-19 09:56:09 +04:00
|
|
|
if (ptr) {
|
2003-07-27 23:35:06 +04:00
|
|
|
Tcl_Release((ClientData)ptr->ip);
|
2002-08-19 09:56:09 +04:00
|
|
|
Tcl_DeleteInterp(ptr->ip);
|
|
|
|
free(ptr);
|
|
|
|
}
|
1998-01-16 15:19:09 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/* create and initialize interpreter */
|
* array.c (ary_alloc), dir.c (dir_s_alloc), eval.c (thgroup_s_alloc),
file.c (rb_stat_s_alloc), hash.c (hash_alloc), io.c (io_alloc),
object.c (rb_module_s_alloc, rb_class_allocate_instance),
re.c (match_alloc, rb_reg_s_alloc), string.c (str_alloc),
time.c (time_s_alloc), ext/digest/digest.c (rb_digest_base_alloc),
ext/tcltklib/tcltklib.c (ip_alloc),
ext/win32ole/win32ole.c (fole_s_allocate, fev_s_allocate)
: add prototype to get rid of VC++ warnings.
* ext/sdbm/init.c (fsdbm_alloc): allocator takes only one argument.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@3197 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2002-12-21 21:02:01 +03:00
|
|
|
static VALUE ip_alloc _((VALUE));
|
1998-01-16 15:19:09 +03:00
|
|
|
static VALUE
|
2002-08-19 09:56:09 +04:00
|
|
|
ip_alloc(self)
|
|
|
|
VALUE self;
|
|
|
|
{
|
|
|
|
return Data_Wrap_Struct(self, 0, ip_free, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
static VALUE
|
2003-07-23 20:07:35 +04:00
|
|
|
ip_init(argc, argv, self)
|
|
|
|
int argc;
|
|
|
|
VALUE *argv;
|
1999-08-13 09:37:52 +04:00
|
|
|
VALUE self;
|
1998-01-16 15:19:09 +03:00
|
|
|
{
|
|
|
|
struct tcltkip *ptr; /* tcltkip data struct */
|
2003-07-29 05:24:32 +04:00
|
|
|
VALUE argv0, opts;
|
2003-07-23 20:07:35 +04:00
|
|
|
int cnt;
|
2003-08-29 12:34:14 +04:00
|
|
|
int with_tk = 1;
|
1998-01-16 15:19:09 +03:00
|
|
|
|
|
|
|
/* create object */
|
2002-08-19 09:56:09 +04:00
|
|
|
Data_Get_Struct(self, struct tcltkip, ptr);
|
|
|
|
ptr = ALLOC(struct tcltkip);
|
|
|
|
DATA_PTR(self) = ptr;
|
1998-01-16 15:19:09 +03:00
|
|
|
ptr->return_value = 0;
|
|
|
|
|
|
|
|
/* from Tk_Main() */
|
|
|
|
DUMP1("Tcl_CreateInterp");
|
|
|
|
ptr->ip = Tcl_CreateInterp();
|
2003-07-27 23:35:06 +04:00
|
|
|
Tcl_Preserve((ClientData)ptr->ip);
|
* tkfont.rb: Fix bugs on TkFont.init_widget_font for Tk8.x.
* tkafter.rb: Add self to 1st argument of interval- and loop-proc
TkAfter#current_interval returns an interval (sleep) time value
TkAfter#current_args returns an array of arguments
TkAfter#return_value returns a return value of last loop-proc
e.g.
TkAfter.new(
proc{|obj| 500 - obj.current_interval}, 10,
[proc{|obj| p obj.current_args}, 'proc', 1],
proc{|obj| p obj.current_args; ['return', 2]},
[proc{|obj|
p obj.return_value
p ['proc', obj.current_args[0].call(obj.return_value[1],
obj.current_args[1])]},
proc{|*args| args[0] + args[1]}, 1],
proc{p ['proc', 4]} ).start(100)
* tk*.rb: Allow to use Symbols for parameters.
Allow new notation of constructor (also allow old notation).
e.g.
TkFrame.new('classname'=>'User'){|base|
pack
f = TkFrame.new(base, :classname=>'ButtonFrame').pack
TkButton.new(
:parent => f,
:text => 'Quit',
:command => proc{exit}
).pack(
:fill => :x,
:pady => 2
)
}
* tkcanvas.rb: (TkcItem) Add 'coords' parameter to the canvas item
constructor (for new notation of constructor).
e.g.
c = TkCanvas.new.pack
l = TkcLine.new(c, :coords=>[[0,0], [100,100]])
* tcltklib.c: New 'mainloop' and 'mainloop_watchdog'.
The priority of their event-loop can be controlled.
They accept an optional argument.
If it false, they don't exit although the root widget is destroyed.
This function is sometimes useful, if it is used with 'restart'.
'mainloop' can't treat Thread#join/value in a callback routine.
(e.g. TkButton.new(:command=>proc{p Thread.new{button.invoke}.value}) )
'mainloop_watchdog' can treat them, but watchdog thread is always running
(so, a little heavier than 'mainloop').
If the purpose of using Thread#join/value is to do something under some
safe-level, please use Proc object.
(e.g. :command=>proc{$SAFE=1;proc{$SAFE=2;button.invoke}.call;p $SAFE})
* tk.rb: Support functions of new 'mainloop' and 'mainloop_watchdog'.
* tk.rb: (Tk.restart) Add 'app-name' paramater and 'use' parameter.
'app-name' specifies the name and the resource class of the
application. If 'app-name' is specified to 'xxx', the application
class on the resource database is set to 'Xxx' and the application
name is changed by the same rule of Tk.appname method. 'use'
specifies the main window for embedding the root widget instead of
generating a new window.
* tk.rb: Add new parameter 'widgetname' to the widget constructor to
support effective use of Resource Database. For example, the
resource 'Xxx*quit.text: QUIT' can set the text of the button
generated by the following code.
e.g.
Tk.restart('Xxx')
TkButton.new(nil, 'widgetname'=>'quit', 'command'=>proc{exit}).pack
Tk.mainloop
* tk.rb: TkOption::get always returns a tainted string.
Add TkOption::new_proc_class.
It generates a class to import procedures defined on the resource
database. For example, there is a following resource file.
----< resource-test >------------
*CMD.foo: {|*args| p [$SAFE, :foo, args]}
*CMD.XXX.bar: {|*args| p [$SAFE, :bar, args]}
*Button.command: ruby {p self; p $SAFE; TkOption::CMD::XXX.bar(1,2,3)}
---------------------------------
The following code is a sample of use of the resource file.
e.g.
require 'tk'
TkOption.readfile 'resource-test'
p TkOption.new_proc_class(:CMD, [:foo], 1)
p TkOption.new_proc_class(:XXX, [:bar], 2, false, TkOption::CMD)
TkButton.new(:text=>'test').pack
Tk.mainloop
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2515 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2002-06-04 11:03:33 +04:00
|
|
|
current_interp = ptr->ip;
|
1998-01-16 15:19:09 +03:00
|
|
|
|
|
|
|
/* from Tcl_AppInit() */
|
|
|
|
DUMP1("Tcl_Init");
|
|
|
|
if (Tcl_Init(ptr->ip) == TCL_ERROR) {
|
1999-08-13 09:37:52 +04:00
|
|
|
rb_raise(rb_eRuntimeError, "%s", ptr->ip->result);
|
1998-01-16 15:19:09 +03:00
|
|
|
}
|
2003-07-23 20:07:35 +04:00
|
|
|
|
|
|
|
/* set variables */
|
|
|
|
cnt = rb_scan_args(argc, argv, "02", &argv0, &opts);
|
|
|
|
switch(cnt) {
|
|
|
|
case 2:
|
2003-07-25 20:43:03 +04:00
|
|
|
/* options */
|
2003-08-29 12:34:14 +04:00
|
|
|
if (opts == Qnil || opts == Qfalse) {
|
|
|
|
/* without Tk */
|
|
|
|
with_tk = 0;
|
|
|
|
} else {
|
|
|
|
Tcl_SetVar(ptr->ip, "argv", StringValuePtr(opts), 0);
|
|
|
|
}
|
2003-07-23 20:07:35 +04:00
|
|
|
case 1:
|
2003-07-25 20:43:03 +04:00
|
|
|
/* argv0 */
|
|
|
|
if (argv0 != Qnil) {
|
|
|
|
Tcl_SetVar(ptr->ip, "argv0", StringValuePtr(argv0), 0);
|
|
|
|
}
|
2003-07-23 20:07:35 +04:00
|
|
|
case 0:
|
2003-07-25 20:43:03 +04:00
|
|
|
/* no args */
|
|
|
|
;
|
2003-07-23 20:07:35 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/* from Tcl_AppInit() */
|
2003-08-29 12:34:14 +04:00
|
|
|
if (with_tk) {
|
|
|
|
DUMP1("Tk_Init");
|
|
|
|
if (Tk_Init(ptr->ip) == TCL_ERROR) {
|
|
|
|
rb_raise(rb_eRuntimeError, "%s", ptr->ip->result);
|
|
|
|
}
|
|
|
|
DUMP1("Tcl_StaticPackage(\"Tk\")");
|
2003-06-21 12:47:22 +04:00
|
|
|
#if TCL_MAJOR_VERSION >= 8
|
2003-08-29 12:34:14 +04:00
|
|
|
Tcl_StaticPackage(ptr->ip, "Tk", Tk_Init, Tk_SafeInit);
|
2003-06-21 12:47:22 +04:00
|
|
|
#else
|
2003-08-29 12:34:14 +04:00
|
|
|
Tcl_StaticPackage(ptr->ip, "Tk", Tk_Init,
|
|
|
|
(Tcl_PackageInitProc *) NULL);
|
2003-06-21 12:47:22 +04:00
|
|
|
#endif
|
2003-08-29 12:34:14 +04:00
|
|
|
}
|
1998-01-16 15:19:09 +03:00
|
|
|
|
|
|
|
/* add ruby command to the interpreter */
|
1999-01-20 07:59:39 +03:00
|
|
|
#if TCL_MAJOR_VERSION >= 8
|
|
|
|
DUMP1("Tcl_CreateObjCommand(\"ruby\")");
|
2000-07-06 11:21:26 +04:00
|
|
|
Tcl_CreateObjCommand(ptr->ip, "ruby", ip_ruby, (ClientData)NULL,
|
1999-01-20 07:59:39 +03:00
|
|
|
(Tcl_CmdDeleteProc *)NULL);
|
|
|
|
#else
|
1998-01-16 15:19:09 +03:00
|
|
|
DUMP1("Tcl_CreateCommand(\"ruby\")");
|
2000-07-06 11:21:26 +04:00
|
|
|
Tcl_CreateCommand(ptr->ip, "ruby", ip_ruby, (ClientData)NULL,
|
1998-01-16 15:19:09 +03:00
|
|
|
(Tcl_CmdDeleteProc *)NULL);
|
1999-01-20 07:59:39 +03:00
|
|
|
#endif
|
1998-01-16 15:19:09 +03:00
|
|
|
|
2003-10-14 19:25:45 +04:00
|
|
|
/* replace 'vwait' command */
|
|
|
|
#if TCL_MAJOR_VERSION >= 8
|
|
|
|
DUMP1("Tcl_CreateObjCommand(\"vwait\")");
|
|
|
|
Tcl_CreateObjCommand(ptr->ip, "vwait", ip_rbVwaitObjCmd,
|
|
|
|
(ClientData)NULL, (Tcl_CmdDeleteProc *)NULL);
|
|
|
|
#else
|
|
|
|
DUMP1("Tcl_CreateCommand(\"vwait\")");
|
|
|
|
Tcl_CreateCommand(ptr->ip, "vwait", ip_rbVwaitCommand,
|
|
|
|
(ClientData)NULL, (Tcl_CmdDeleteProc *)NULL);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* replace 'tkwait' command */
|
|
|
|
#if TCL_MAJOR_VERSION >= 8
|
|
|
|
DUMP1("Tcl_CreateObjCommand(\"tkwait\")");
|
|
|
|
Tcl_CreateObjCommand(ptr->ip, "tkwait", ip_rbTkWaitObjCmd,
|
|
|
|
(ClientData)NULL, (Tcl_CmdDeleteProc *)NULL);
|
|
|
|
#else
|
|
|
|
DUMP1("Tcl_CreateCommand(\"tkwait\")");
|
|
|
|
Tcl_CreateCommand(ptr->ip, "tkwait", ip_rbTkWaitCommand,
|
|
|
|
(ClientData)NULL, (Tcl_CmdDeleteProc *)NULL);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* add 'thread_vwait' command */
|
|
|
|
#if TCL_MAJOR_VERSION >= 8
|
|
|
|
DUMP1("Tcl_CreateObjCommand(\"thread_vwait\")");
|
|
|
|
Tcl_CreateObjCommand(ptr->ip, "thread_vwait", ip_rb_threadVwaitObjCmd,
|
|
|
|
(ClientData)NULL, (Tcl_CmdDeleteProc *)NULL);
|
|
|
|
#else
|
|
|
|
DUMP1("Tcl_CreateCommand(\"thread_vwait\")");
|
|
|
|
Tcl_CreateCommand(ptr->ip, "thread_vwait", ip_rb_threadVwaitCommand,
|
|
|
|
(ClientData)NULL, (Tcl_CmdDeleteProc *)NULL);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* add 'thread_tkwait' command */
|
|
|
|
#if TCL_MAJOR_VERSION >= 8
|
|
|
|
DUMP1("Tcl_CreateObjCommand(\"thread_tkwait\")");
|
|
|
|
Tcl_CreateObjCommand(ptr->ip, "thread_tkwait", ip_rb_threadTkWaitObjCmd,
|
|
|
|
(ClientData)NULL, (Tcl_CmdDeleteProc *)NULL);
|
|
|
|
#else
|
|
|
|
DUMP1("Tcl_CreateCommand(\"thread_tkwait\")");
|
|
|
|
Tcl_CreateCommand(ptr->ip, "thread_tkwait", ip_rb_threadTkWaitCommand,
|
|
|
|
(ClientData)NULL, (Tcl_CmdDeleteProc *)NULL);
|
|
|
|
#endif
|
|
|
|
|
2002-08-19 09:56:09 +04:00
|
|
|
return self;
|
1998-01-16 15:19:09 +03:00
|
|
|
}
|
|
|
|
|
2003-07-25 20:43:03 +04:00
|
|
|
static VALUE
|
|
|
|
ip_create_slave(argc, argv, self)
|
|
|
|
int argc;
|
|
|
|
VALUE *argv;
|
|
|
|
VALUE self;
|
|
|
|
{
|
|
|
|
struct tcltkip *master = get_ip(self);
|
|
|
|
struct tcltkip *slave = ALLOC(struct tcltkip);
|
|
|
|
VALUE name;
|
|
|
|
VALUE safemode;
|
|
|
|
int safe;
|
|
|
|
|
|
|
|
/* safe-mode check */
|
|
|
|
if (rb_scan_args(argc, argv, "11", &name, &safemode) == 1) {
|
|
|
|
safemode = Qfalse;
|
|
|
|
}
|
|
|
|
if (Tcl_IsSafe(master->ip) == 1) {
|
|
|
|
safe = 1;
|
|
|
|
} else if (safemode == Qfalse || safemode == Qnil) {
|
|
|
|
safe = 0;
|
2003-09-07 11:10:44 +04:00
|
|
|
rb_secure(4);
|
2003-07-25 20:43:03 +04:00
|
|
|
} else {
|
|
|
|
safe = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* create slave-ip */
|
|
|
|
if ((slave->ip = Tcl_CreateSlave(master->ip, StringValuePtr(name), safe))
|
|
|
|
== NULL) {
|
2003-07-28 10:10:13 +04:00
|
|
|
rb_raise(rb_eRuntimeError, "fail to create the new slave interpreter");
|
2003-07-25 20:43:03 +04:00
|
|
|
}
|
2003-07-27 23:35:06 +04:00
|
|
|
Tcl_Preserve((ClientData)slave->ip);
|
2003-07-25 20:43:03 +04:00
|
|
|
slave->return_value = 0;
|
|
|
|
|
|
|
|
return Data_Wrap_Struct(CLASS_OF(self), 0, ip_free, slave);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* make ip "safe" */
|
|
|
|
static VALUE
|
|
|
|
ip_make_safe(self)
|
|
|
|
VALUE self;
|
|
|
|
{
|
|
|
|
struct tcltkip *ptr = get_ip(self);
|
|
|
|
|
|
|
|
if (Tcl_MakeSafe(ptr->ip) == TCL_ERROR) {
|
2003-07-28 10:10:13 +04:00
|
|
|
rb_raise(rb_eRuntimeError, "%s", ptr->ip->result);
|
2003-07-25 20:43:03 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* is safe? */
|
|
|
|
static VALUE
|
|
|
|
ip_is_safe_p(self)
|
|
|
|
VALUE self;
|
|
|
|
{
|
|
|
|
struct tcltkip *ptr = get_ip(self);
|
|
|
|
|
|
|
|
if (Tcl_IsSafe(ptr->ip)) {
|
|
|
|
return Qtrue;
|
|
|
|
} else {
|
|
|
|
return Qfalse;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-07-27 23:35:06 +04:00
|
|
|
/* delete interpreter */
|
|
|
|
static VALUE
|
|
|
|
ip_delete(self)
|
|
|
|
VALUE self;
|
|
|
|
{
|
|
|
|
struct tcltkip *ptr = get_ip(self);
|
2003-09-07 11:10:44 +04:00
|
|
|
|
2003-07-27 23:35:06 +04:00
|
|
|
Tcl_DeleteInterp(ptr->ip);
|
|
|
|
|
|
|
|
return Qnil;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* is deleted? */
|
|
|
|
static VALUE
|
|
|
|
ip_is_deleted_p(self)
|
|
|
|
VALUE self;
|
|
|
|
{
|
|
|
|
struct tcltkip *ptr = get_ip(self);
|
|
|
|
|
|
|
|
if (Tcl_InterpDeleted(ptr->ip)) {
|
|
|
|
return Qtrue;
|
|
|
|
} else {
|
|
|
|
return Qfalse;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-11-08 00:39:36 +03:00
|
|
|
|
1998-01-16 15:19:09 +03:00
|
|
|
/* eval string in tcl by Tcl_Eval() */
|
|
|
|
static VALUE
|
2003-11-08 00:39:36 +03:00
|
|
|
ip_eval_real(self, str)
|
1999-08-13 09:37:52 +04:00
|
|
|
VALUE self;
|
|
|
|
VALUE str;
|
1998-01-16 15:19:09 +03:00
|
|
|
{
|
1999-01-20 07:59:39 +03:00
|
|
|
char *s;
|
2003-07-27 23:35:06 +04:00
|
|
|
char *buf; /* Tcl_Eval requires re-writable string region */
|
2002-08-19 09:56:09 +04:00
|
|
|
struct tcltkip *ptr = get_ip(self);
|
1998-01-16 15:19:09 +03:00
|
|
|
|
|
|
|
/* call Tcl_Eval() */
|
2001-05-06 19:06:00 +04:00
|
|
|
s = StringValuePtr(str);
|
1999-01-20 07:59:39 +03:00
|
|
|
buf = ALLOCA_N(char, strlen(s)+1);
|
|
|
|
strcpy(buf, s);
|
1998-01-16 15:19:09 +03:00
|
|
|
DUMP2("Tcl_Eval(%s)", buf);
|
|
|
|
ptr->return_value = Tcl_Eval(ptr->ip, buf);
|
|
|
|
if (ptr->return_value == TCL_ERROR) {
|
1999-08-13 09:37:52 +04:00
|
|
|
rb_raise(rb_eRuntimeError, "%s", ptr->ip->result);
|
1998-01-16 15:19:09 +03:00
|
|
|
}
|
|
|
|
DUMP2("(TCL_Eval result) %d", ptr->return_value);
|
|
|
|
|
|
|
|
/* pass back the result (as string) */
|
2003-06-20 18:52:45 +04:00
|
|
|
/* return(rb_str_new2(ptr->ip->result)); */
|
|
|
|
return(rb_tainted_str_new2(ptr->ip->result));
|
1999-01-20 07:59:39 +03:00
|
|
|
}
|
|
|
|
|
2003-11-08 00:39:36 +03:00
|
|
|
static VALUE
|
|
|
|
evq_safelevel_handler(arg, evq)
|
|
|
|
VALUE arg;
|
|
|
|
VALUE evq;
|
|
|
|
{
|
|
|
|
struct eval_queue *q;
|
|
|
|
|
|
|
|
Data_Get_Struct(evq, struct eval_queue, q);
|
|
|
|
DUMP2("(safe-level handler) $SAFE = %d", q->safe_level);
|
|
|
|
rb_set_safe_level(q->safe_level);
|
|
|
|
return ip_eval_real(q->obj, q->str);
|
|
|
|
}
|
|
|
|
|
|
|
|
int eval_queue_handler _((Tcl_Event *, int));
|
|
|
|
int
|
|
|
|
eval_queue_handler(evPtr, flags)
|
|
|
|
Tcl_Event *evPtr;
|
|
|
|
int flags;
|
|
|
|
{
|
|
|
|
struct eval_queue *q = (struct eval_queue *)evPtr;
|
|
|
|
|
|
|
|
DUMP2("do_eval_queue_handler : evPtr = %lx", evPtr);
|
|
|
|
DUMP2("eval queue_thread : %lx", rb_thread_current());
|
|
|
|
DUMP2("added by thread : %lx", q->thread);
|
|
|
|
|
|
|
|
if (q->done) {
|
|
|
|
DUMP1("processed by another event-loop");
|
|
|
|
return 0;
|
|
|
|
} else {
|
|
|
|
DUMP1("process it on current event-loop");
|
|
|
|
}
|
|
|
|
|
|
|
|
/* process it */
|
|
|
|
q->done = 1;
|
|
|
|
|
|
|
|
/* check safe-level */
|
|
|
|
if (rb_safe_level() != q->safe_level) {
|
|
|
|
*(q->result)
|
|
|
|
= rb_funcall(rb_proc_new(evq_safelevel_handler,
|
|
|
|
Data_Wrap_Struct(rb_cData,0,0,q)),
|
|
|
|
rb_intern("call"), 0);
|
|
|
|
} else {
|
|
|
|
DUMP2("call eval_real (for caller thread:%lx)", q->thread);
|
|
|
|
DUMP2("call eval_real (current thread:%lx)", rb_thread_current());
|
|
|
|
*(q->result) = ip_eval_real(q->obj, q->str);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* back to caller */
|
|
|
|
DUMP2("back to caller (caller thread:%lx)", q->thread);
|
|
|
|
DUMP2(" (current thread:%lx)", rb_thread_current());
|
|
|
|
rb_thread_run(q->thread);
|
|
|
|
DUMP1("finish back to caller");
|
|
|
|
|
|
|
|
/* end of handler : remove it */
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static VALUE
|
|
|
|
ip_eval(self, str)
|
|
|
|
VALUE self;
|
|
|
|
VALUE str;
|
|
|
|
{
|
|
|
|
struct eval_queue *tmp;
|
|
|
|
VALUE current = rb_thread_current();
|
|
|
|
VALUE result;
|
|
|
|
VALUE *alloc_result;
|
|
|
|
Tcl_QueuePosition position;
|
|
|
|
|
|
|
|
if (eventloop_thread == 0 || current == eventloop_thread) {
|
|
|
|
if (eventloop_thread) {
|
|
|
|
DUMP2("eval from current eventloop %lx", current);
|
|
|
|
} else {
|
|
|
|
DUMP2("eval from thread:%lx but no eventloop", current);
|
|
|
|
}
|
|
|
|
result = ip_eval_real(self, str);
|
|
|
|
if (rb_obj_is_kind_of(result, rb_eException)) {
|
|
|
|
rb_exc_raise(result);
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
DUMP2("eval from thread %lx (NOT current eventloop)", current);
|
|
|
|
|
|
|
|
/* allocate memory (protected from Tcl_ServiceEvent) */
|
|
|
|
alloc_result = ALLOC(VALUE);
|
|
|
|
|
|
|
|
/* allocate memory (freed by Tcl_ServiceEvent) */
|
|
|
|
tmp = (struct eval_queue *)Tcl_Alloc(sizeof(struct eval_queue));
|
|
|
|
|
|
|
|
/* construct event data */
|
|
|
|
tmp->done = 0;
|
|
|
|
tmp->obj = self;
|
|
|
|
tmp->str = str;
|
|
|
|
tmp->result = alloc_result;
|
|
|
|
tmp->thread = current;
|
|
|
|
tmp->safe_level = rb_safe_level();
|
|
|
|
tmp->ev.proc = eval_queue_handler;
|
|
|
|
position = TCL_QUEUE_TAIL;
|
|
|
|
|
|
|
|
/* add the handler to Tcl event queue */
|
|
|
|
DUMP1("add handler");
|
|
|
|
Tcl_QueueEvent(&(tmp->ev), position);
|
|
|
|
|
|
|
|
/* wait for the handler to be processed */
|
|
|
|
DUMP2("wait for handler (current thread:%lx)", current);
|
|
|
|
rb_thread_stop();
|
|
|
|
DUMP2("back from handler (current thread:%lx)", current);
|
|
|
|
|
|
|
|
/* get result & free allocated memory */
|
|
|
|
result = *alloc_result;
|
|
|
|
free(alloc_result);
|
|
|
|
if (rb_obj_is_kind_of(result, rb_eException)) {
|
|
|
|
rb_exc_raise(result);
|
|
|
|
}
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* restart Tk */
|
|
|
|
static VALUE
|
|
|
|
lib_restart(self)
|
|
|
|
VALUE self;
|
|
|
|
{
|
|
|
|
struct tcltkip *ptr = get_ip(self);
|
|
|
|
|
|
|
|
rb_secure(4);
|
|
|
|
|
|
|
|
/* destroy the root wdiget */
|
|
|
|
/* ptr->return_value = Tcl_Eval(ptr->ip, "destroy ."); */
|
|
|
|
ptr->return_value = FIX2INT(ip_eval(self, "destroy ."));
|
|
|
|
/* ignore ERROR */
|
|
|
|
DUMP2("(TCL_Eval result) %d", ptr->return_value);
|
|
|
|
Tcl_ResetResult(ptr->ip);
|
|
|
|
|
|
|
|
/* execute Tk_Init of Tk_SafeInit */
|
|
|
|
#if TCL_MAJOR_VERSION >= 8
|
|
|
|
if (Tcl_IsSafe(ptr->ip)) {
|
|
|
|
DUMP1("Tk_SafeInit");
|
|
|
|
if (Tk_SafeInit(ptr->ip) == TCL_ERROR) {
|
|
|
|
rb_raise(rb_eRuntimeError, "%s", ptr->ip->result);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
DUMP1("Tk_Init");
|
|
|
|
if (Tk_Init(ptr->ip) == TCL_ERROR) {
|
|
|
|
rb_raise(rb_eRuntimeError, "%s", ptr->ip->result);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
DUMP1("Tk_Init");
|
|
|
|
if (Tk_Init(ptr->ip) == TCL_ERROR) {
|
|
|
|
rb_raise(rb_eRuntimeError, "%s", ptr->ip->result);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
return Qnil;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static VALUE
|
|
|
|
ip_restart(self)
|
|
|
|
VALUE self;
|
|
|
|
{
|
|
|
|
struct tcltkip *ptr = get_ip(self);
|
|
|
|
|
|
|
|
rb_secure(4);
|
|
|
|
if (Tcl_GetMaster(ptr->ip) != (Tcl_Interp*)NULL) {
|
|
|
|
/* slave IP */
|
|
|
|
return Qnil;
|
|
|
|
}
|
|
|
|
return lib_restart(self);
|
|
|
|
}
|
|
|
|
|
1999-01-20 07:59:39 +03:00
|
|
|
static VALUE
|
1999-08-13 09:37:52 +04:00
|
|
|
ip_toUTF8(self, str, encodename)
|
|
|
|
VALUE self;
|
|
|
|
VALUE str;
|
|
|
|
VALUE encodename;
|
1999-01-20 07:59:39 +03:00
|
|
|
{
|
1999-08-13 09:37:52 +04:00
|
|
|
#ifdef TCL_UTF_MAX
|
|
|
|
Tcl_Interp *interp;
|
|
|
|
Tcl_Encoding encoding;
|
|
|
|
Tcl_DString dstr;
|
|
|
|
struct tcltkip *ptr;
|
|
|
|
char *buf;
|
|
|
|
|
2002-08-19 09:56:09 +04:00
|
|
|
ptr = get_ip(self);
|
1999-08-13 09:37:52 +04:00
|
|
|
interp = ptr->ip;
|
|
|
|
|
2001-05-06 19:06:00 +04:00
|
|
|
StringValue(encodename);
|
|
|
|
StringValue(str);
|
|
|
|
encoding = Tcl_GetEncoding(interp, RSTRING(encodename)->ptr);
|
2002-08-30 14:42:09 +04:00
|
|
|
if (!RSTRING(str)->len) return str;
|
2001-05-06 19:06:00 +04:00
|
|
|
buf = ALLOCA_N(char,strlen(RSTRING(str)->ptr)+1);
|
|
|
|
strcpy(buf, RSTRING(str)->ptr);
|
1999-08-13 09:37:52 +04:00
|
|
|
|
|
|
|
Tcl_DStringInit(&dstr);
|
|
|
|
Tcl_DStringFree(&dstr);
|
|
|
|
Tcl_ExternalToUtfDString(encoding,buf,strlen(buf),&dstr);
|
2003-06-20 18:52:45 +04:00
|
|
|
/* str = rb_str_new2(Tcl_DStringValue(&dstr)); */
|
|
|
|
str = rb_tainted_str_new2(Tcl_DStringValue(&dstr));
|
1999-08-13 09:37:52 +04:00
|
|
|
|
|
|
|
Tcl_FreeEncoding(encoding);
|
|
|
|
Tcl_DStringFree(&dstr);
|
1999-01-20 07:59:39 +03:00
|
|
|
#endif
|
1999-08-13 09:37:52 +04:00
|
|
|
return str;
|
1999-01-20 07:59:39 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
static VALUE
|
1999-08-13 09:37:52 +04:00
|
|
|
ip_fromUTF8(self, str, encodename)
|
|
|
|
VALUE self;
|
|
|
|
VALUE str;
|
|
|
|
VALUE encodename;
|
1999-01-20 07:59:39 +03:00
|
|
|
{
|
1999-08-13 09:37:52 +04:00
|
|
|
#ifdef TCL_UTF_MAX
|
|
|
|
Tcl_Interp *interp;
|
|
|
|
Tcl_Encoding encoding;
|
|
|
|
Tcl_DString dstr;
|
|
|
|
struct tcltkip *ptr;
|
|
|
|
char *buf;
|
1999-01-20 07:59:39 +03:00
|
|
|
|
2002-08-19 09:56:09 +04:00
|
|
|
ptr = get_ip(self);
|
1999-08-13 09:37:52 +04:00
|
|
|
interp = ptr->ip;
|
1999-01-20 07:59:39 +03:00
|
|
|
|
2001-05-06 19:06:00 +04:00
|
|
|
StringValue(encodename);
|
|
|
|
StringValue(str);
|
|
|
|
encoding = Tcl_GetEncoding(interp,RSTRING(encodename)->ptr);
|
2002-08-30 14:42:09 +04:00
|
|
|
if (!RSTRING(str)->len) return str;
|
2001-05-06 19:06:00 +04:00
|
|
|
buf = ALLOCA_N(char,strlen(RSTRING(str)->ptr)+1);
|
|
|
|
strcpy(buf,RSTRING(str)->ptr);
|
1999-01-20 07:59:39 +03:00
|
|
|
|
1999-08-13 09:37:52 +04:00
|
|
|
Tcl_DStringInit(&dstr);
|
|
|
|
Tcl_DStringFree(&dstr);
|
|
|
|
Tcl_UtfToExternalDString(encoding,buf,strlen(buf),&dstr);
|
2003-06-20 18:52:45 +04:00
|
|
|
/* str = rb_str_new2(Tcl_DStringValue(&dstr)); */
|
|
|
|
str = rb_tainted_str_new2(Tcl_DStringValue(&dstr));
|
1999-01-20 07:59:39 +03:00
|
|
|
|
1999-08-13 09:37:52 +04:00
|
|
|
Tcl_FreeEncoding(encoding);
|
|
|
|
Tcl_DStringFree(&dstr);
|
1999-01-20 07:59:39 +03:00
|
|
|
|
|
|
|
#endif
|
1999-08-13 09:37:52 +04:00
|
|
|
return str;
|
1999-01-20 07:59:39 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-08-29 12:34:14 +04:00
|
|
|
static VALUE
|
|
|
|
#ifdef HAVE_STDARG_PROTOTYPES
|
|
|
|
create_ip_exc(VALUE interp, VALUE exc, const char *fmt, ...)
|
|
|
|
#else
|
|
|
|
create_ip_exc(interp, exc, fmt, va_alist)
|
|
|
|
VALUE interp:
|
|
|
|
VALUE exc;
|
|
|
|
const char *fmt;
|
|
|
|
va_dcl
|
|
|
|
#endif
|
|
|
|
{
|
|
|
|
va_list args;
|
|
|
|
char buf[BUFSIZ];
|
|
|
|
VALUE einfo;
|
|
|
|
|
|
|
|
va_init_list(args,fmt);
|
|
|
|
vsnprintf(buf, BUFSIZ, fmt, args);
|
|
|
|
buf[BUFSIZ - 1] = '\0';
|
|
|
|
va_end(args);
|
|
|
|
einfo = rb_exc_new2(exc, buf);
|
|
|
|
rb_iv_set(einfo, "interp", interp);
|
|
|
|
Tcl_ResetResult(get_ip(interp)->ip);
|
|
|
|
return einfo;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-01-20 07:59:39 +03:00
|
|
|
static VALUE
|
1999-08-13 09:37:52 +04:00
|
|
|
ip_invoke_real(argc, argv, obj)
|
|
|
|
int argc;
|
|
|
|
VALUE *argv;
|
|
|
|
VALUE obj;
|
1999-01-20 07:59:39 +03:00
|
|
|
{
|
2001-05-06 19:06:00 +04:00
|
|
|
VALUE v;
|
1999-01-20 07:59:39 +03:00
|
|
|
struct tcltkip *ptr; /* tcltkip data struct */
|
|
|
|
int i;
|
|
|
|
Tcl_CmdInfo info;
|
2001-05-06 19:06:00 +04:00
|
|
|
char *cmd, *s;
|
1999-01-20 07:59:39 +03:00
|
|
|
char **av = (char **)NULL;
|
|
|
|
#if TCL_MAJOR_VERSION >= 8
|
|
|
|
Tcl_Obj **ov = (Tcl_Obj **)NULL;
|
|
|
|
Tcl_Obj *resultPtr;
|
|
|
|
#endif
|
|
|
|
|
2003-10-14 19:25:45 +04:00
|
|
|
DUMP2("invoke_real called by thread:%lx", rb_thread_current());
|
1999-01-20 07:59:39 +03:00
|
|
|
/* get the command name string */
|
2001-05-06 19:06:00 +04:00
|
|
|
v = argv[0];
|
|
|
|
cmd = StringValuePtr(v);
|
1999-01-20 07:59:39 +03:00
|
|
|
|
2003-10-14 19:25:45 +04:00
|
|
|
/* get the data struct */
|
|
|
|
ptr = get_ip(obj);
|
|
|
|
|
2003-07-27 23:35:06 +04:00
|
|
|
/* ip is deleted? */
|
|
|
|
if (Tcl_InterpDeleted(ptr->ip)) {
|
|
|
|
return rb_tainted_str_new2("");
|
|
|
|
}
|
|
|
|
|
1999-01-20 07:59:39 +03:00
|
|
|
/* map from the command name to a C procedure */
|
2003-10-14 19:25:45 +04:00
|
|
|
DUMP2("call Tcl_GetCommandInfo, %s", cmd);
|
1999-01-20 07:59:39 +03:00
|
|
|
if (!Tcl_GetCommandInfo(ptr->ip, cmd, &info)) {
|
2003-10-14 19:25:45 +04:00
|
|
|
DUMP1("error Tcl_GetCommandInfo");
|
2003-07-29 19:39:59 +04:00
|
|
|
/* if (event_loop_abort_on_exc || cmd[0] != '.') { */
|
|
|
|
if (event_loop_abort_on_exc > 0) {
|
2003-09-07 11:10:44 +04:00
|
|
|
/*rb_ip_raise(obj,rb_eNameError,"invalid command name `%s'",cmd);*/
|
2003-08-29 12:34:14 +04:00
|
|
|
return create_ip_exc(obj, rb_eNameError,
|
|
|
|
"invalid command name `%s'", cmd);
|
2003-07-29 19:39:59 +04:00
|
|
|
} else {
|
|
|
|
if (event_loop_abort_on_exc < 0) {
|
|
|
|
rb_warning("invalid command name `%s' (ignore)", cmd);
|
|
|
|
} else {
|
|
|
|
rb_warn("invalid command name `%s' (ignore)", cmd);
|
|
|
|
}
|
2003-07-27 23:35:06 +04:00
|
|
|
Tcl_ResetResult(ptr->ip);
|
|
|
|
return rb_tainted_str_new2("");
|
|
|
|
}
|
1999-01-20 07:59:39 +03:00
|
|
|
}
|
2003-10-14 19:25:45 +04:00
|
|
|
DUMP1("end Tcl_GetCommandInfo");
|
1999-01-20 07:59:39 +03:00
|
|
|
|
|
|
|
/* memory allocation for arguments of this command */
|
|
|
|
#if TCL_MAJOR_VERSION >= 8
|
1999-08-13 09:37:52 +04:00
|
|
|
if (info.isNativeObjectProc) {
|
|
|
|
/* object interface */
|
|
|
|
ov = (Tcl_Obj **)ALLOCA_N(Tcl_Obj *, argc+1);
|
|
|
|
for (i = 0; i < argc; ++i) {
|
2001-05-11 09:24:59 +04:00
|
|
|
v = argv[i];
|
2001-05-06 19:06:00 +04:00
|
|
|
s = StringValuePtr(v);
|
2001-05-11 09:24:59 +04:00
|
|
|
ov[i] = Tcl_NewStringObj(s, RSTRING(v)->len);
|
1999-08-13 09:37:52 +04:00
|
|
|
Tcl_IncrRefCount(ov[i]);
|
|
|
|
}
|
|
|
|
ov[argc] = (Tcl_Obj *)NULL;
|
|
|
|
}
|
|
|
|
else
|
1999-01-20 07:59:39 +03:00
|
|
|
#endif
|
1999-08-13 09:37:52 +04:00
|
|
|
{
|
2003-07-27 23:35:06 +04:00
|
|
|
/* string interface */
|
1999-08-13 09:37:52 +04:00
|
|
|
av = (char **)ALLOCA_N(char *, argc+1);
|
|
|
|
for (i = 0; i < argc; ++i) {
|
2001-05-06 19:06:00 +04:00
|
|
|
v = argv[i];
|
|
|
|
s = StringValuePtr(v);
|
1999-08-13 09:37:52 +04:00
|
|
|
av[i] = ALLOCA_N(char, strlen(s)+1);
|
|
|
|
strcpy(av[i], s);
|
|
|
|
}
|
|
|
|
av[argc] = (char *)NULL;
|
1999-01-20 07:59:39 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
Tcl_ResetResult(ptr->ip);
|
|
|
|
|
|
|
|
/* Invoke the C procedure */
|
|
|
|
#if TCL_MAJOR_VERSION >= 8
|
1999-08-13 09:37:52 +04:00
|
|
|
if (info.isNativeObjectProc) {
|
|
|
|
int dummy;
|
|
|
|
ptr->return_value = (*info.objProc)(info.objClientData,
|
|
|
|
ptr->ip, argc, ov);
|
|
|
|
|
|
|
|
/* get the string value from the result object */
|
|
|
|
resultPtr = Tcl_GetObjResult(ptr->ip);
|
|
|
|
Tcl_SetResult(ptr->ip, Tcl_GetStringFromObj(resultPtr, &dummy),
|
|
|
|
TCL_VOLATILE);
|
|
|
|
|
|
|
|
for (i=0; i<argc; i++) {
|
|
|
|
Tcl_DecrRefCount(ov[i]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
1999-01-20 07:59:39 +03:00
|
|
|
#endif
|
1999-08-13 09:37:52 +04:00
|
|
|
{
|
2002-09-25 11:03:05 +04:00
|
|
|
TRAP_BEG;
|
2003-07-29 05:24:32 +04:00
|
|
|
#if TCL_MAJOR_VERSION >= 8
|
|
|
|
ptr->return_value = (*info.proc)(info.clientData, ptr->ip,
|
|
|
|
argc, (CONST84 char **)av);
|
|
|
|
#else /* TCL_MAJOR_VERSION < 8 */
|
2002-09-25 11:03:05 +04:00
|
|
|
ptr->return_value = (*info.proc)(info.clientData, ptr->ip, argc, av);
|
2003-07-29 05:24:32 +04:00
|
|
|
#endif
|
2002-09-25 11:03:05 +04:00
|
|
|
TRAP_END;
|
1999-01-20 07:59:39 +03:00
|
|
|
}
|
|
|
|
|
2003-07-29 19:39:59 +04:00
|
|
|
/* exception on mainloop */
|
1999-01-20 07:59:39 +03:00
|
|
|
if (ptr->return_value == TCL_ERROR) {
|
2003-07-30 08:36:29 +04:00
|
|
|
if (event_loop_abort_on_exc > 0 && !Tcl_InterpDeleted(ptr->ip)) {
|
2003-08-29 12:34:14 +04:00
|
|
|
/*rb_ip_raise(obj, rb_eRuntimeError, "%s", ptr->ip->result);*/
|
|
|
|
return create_ip_exc(obj, rb_eRuntimeError, "%s", ptr->ip->result);
|
2003-07-29 19:39:59 +04:00
|
|
|
} else {
|
|
|
|
if (event_loop_abort_on_exc < 0) {
|
|
|
|
rb_warning("%s (ignore)", ptr->ip->result);
|
|
|
|
} else {
|
|
|
|
rb_warn("%s (ignore)", ptr->ip->result);
|
|
|
|
}
|
|
|
|
Tcl_ResetResult(ptr->ip);
|
|
|
|
return rb_tainted_str_new2("");
|
|
|
|
}
|
1999-01-20 07:59:39 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/* pass back the result (as string) */
|
2003-06-20 18:52:45 +04:00
|
|
|
/* return rb_str_new2(ptr->ip->result); */
|
|
|
|
return rb_tainted_str_new2(ptr->ip->result);
|
1999-08-13 09:37:52 +04:00
|
|
|
}
|
|
|
|
|
* tkfont.rb: Fix bugs on TkFont.init_widget_font for Tk8.x.
* tkafter.rb: Add self to 1st argument of interval- and loop-proc
TkAfter#current_interval returns an interval (sleep) time value
TkAfter#current_args returns an array of arguments
TkAfter#return_value returns a return value of last loop-proc
e.g.
TkAfter.new(
proc{|obj| 500 - obj.current_interval}, 10,
[proc{|obj| p obj.current_args}, 'proc', 1],
proc{|obj| p obj.current_args; ['return', 2]},
[proc{|obj|
p obj.return_value
p ['proc', obj.current_args[0].call(obj.return_value[1],
obj.current_args[1])]},
proc{|*args| args[0] + args[1]}, 1],
proc{p ['proc', 4]} ).start(100)
* tk*.rb: Allow to use Symbols for parameters.
Allow new notation of constructor (also allow old notation).
e.g.
TkFrame.new('classname'=>'User'){|base|
pack
f = TkFrame.new(base, :classname=>'ButtonFrame').pack
TkButton.new(
:parent => f,
:text => 'Quit',
:command => proc{exit}
).pack(
:fill => :x,
:pady => 2
)
}
* tkcanvas.rb: (TkcItem) Add 'coords' parameter to the canvas item
constructor (for new notation of constructor).
e.g.
c = TkCanvas.new.pack
l = TkcLine.new(c, :coords=>[[0,0], [100,100]])
* tcltklib.c: New 'mainloop' and 'mainloop_watchdog'.
The priority of their event-loop can be controlled.
They accept an optional argument.
If it false, they don't exit although the root widget is destroyed.
This function is sometimes useful, if it is used with 'restart'.
'mainloop' can't treat Thread#join/value in a callback routine.
(e.g. TkButton.new(:command=>proc{p Thread.new{button.invoke}.value}) )
'mainloop_watchdog' can treat them, but watchdog thread is always running
(so, a little heavier than 'mainloop').
If the purpose of using Thread#join/value is to do something under some
safe-level, please use Proc object.
(e.g. :command=>proc{$SAFE=1;proc{$SAFE=2;button.invoke}.call;p $SAFE})
* tk.rb: Support functions of new 'mainloop' and 'mainloop_watchdog'.
* tk.rb: (Tk.restart) Add 'app-name' paramater and 'use' parameter.
'app-name' specifies the name and the resource class of the
application. If 'app-name' is specified to 'xxx', the application
class on the resource database is set to 'Xxx' and the application
name is changed by the same rule of Tk.appname method. 'use'
specifies the main window for embedding the root widget instead of
generating a new window.
* tk.rb: Add new parameter 'widgetname' to the widget constructor to
support effective use of Resource Database. For example, the
resource 'Xxx*quit.text: QUIT' can set the text of the button
generated by the following code.
e.g.
Tk.restart('Xxx')
TkButton.new(nil, 'widgetname'=>'quit', 'command'=>proc{exit}).pack
Tk.mainloop
* tk.rb: TkOption::get always returns a tainted string.
Add TkOption::new_proc_class.
It generates a class to import procedures defined on the resource
database. For example, there is a following resource file.
----< resource-test >------------
*CMD.foo: {|*args| p [$SAFE, :foo, args]}
*CMD.XXX.bar: {|*args| p [$SAFE, :bar, args]}
*Button.command: ruby {p self; p $SAFE; TkOption::CMD::XXX.bar(1,2,3)}
---------------------------------
The following code is a sample of use of the resource file.
e.g.
require 'tk'
TkOption.readfile 'resource-test'
p TkOption.new_proc_class(:CMD, [:foo], 1)
p TkOption.new_proc_class(:XXX, [:bar], 2, false, TkOption::CMD)
TkButton.new(:text=>'test').pack
Tk.mainloop
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2515 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2002-06-04 11:03:33 +04:00
|
|
|
VALUE
|
|
|
|
ivq_safelevel_handler(arg, ivq)
|
|
|
|
VALUE arg;
|
|
|
|
VALUE ivq;
|
|
|
|
{
|
|
|
|
struct invoke_queue *q;
|
|
|
|
|
|
|
|
Data_Get_Struct(ivq, struct invoke_queue, q);
|
|
|
|
DUMP2("(safe-level handler) $SAFE = %d", q->safe_level);
|
|
|
|
rb_set_safe_level(q->safe_level);
|
|
|
|
return ip_invoke_real(q->argc, q->argv, q->obj);
|
|
|
|
}
|
|
|
|
|
2002-09-08 14:33:12 +04:00
|
|
|
int invoke_queue_handler _((Tcl_Event *, int));
|
* tkfont.rb: Fix bugs on TkFont.init_widget_font for Tk8.x.
* tkafter.rb: Add self to 1st argument of interval- and loop-proc
TkAfter#current_interval returns an interval (sleep) time value
TkAfter#current_args returns an array of arguments
TkAfter#return_value returns a return value of last loop-proc
e.g.
TkAfter.new(
proc{|obj| 500 - obj.current_interval}, 10,
[proc{|obj| p obj.current_args}, 'proc', 1],
proc{|obj| p obj.current_args; ['return', 2]},
[proc{|obj|
p obj.return_value
p ['proc', obj.current_args[0].call(obj.return_value[1],
obj.current_args[1])]},
proc{|*args| args[0] + args[1]}, 1],
proc{p ['proc', 4]} ).start(100)
* tk*.rb: Allow to use Symbols for parameters.
Allow new notation of constructor (also allow old notation).
e.g.
TkFrame.new('classname'=>'User'){|base|
pack
f = TkFrame.new(base, :classname=>'ButtonFrame').pack
TkButton.new(
:parent => f,
:text => 'Quit',
:command => proc{exit}
).pack(
:fill => :x,
:pady => 2
)
}
* tkcanvas.rb: (TkcItem) Add 'coords' parameter to the canvas item
constructor (for new notation of constructor).
e.g.
c = TkCanvas.new.pack
l = TkcLine.new(c, :coords=>[[0,0], [100,100]])
* tcltklib.c: New 'mainloop' and 'mainloop_watchdog'.
The priority of their event-loop can be controlled.
They accept an optional argument.
If it false, they don't exit although the root widget is destroyed.
This function is sometimes useful, if it is used with 'restart'.
'mainloop' can't treat Thread#join/value in a callback routine.
(e.g. TkButton.new(:command=>proc{p Thread.new{button.invoke}.value}) )
'mainloop_watchdog' can treat them, but watchdog thread is always running
(so, a little heavier than 'mainloop').
If the purpose of using Thread#join/value is to do something under some
safe-level, please use Proc object.
(e.g. :command=>proc{$SAFE=1;proc{$SAFE=2;button.invoke}.call;p $SAFE})
* tk.rb: Support functions of new 'mainloop' and 'mainloop_watchdog'.
* tk.rb: (Tk.restart) Add 'app-name' paramater and 'use' parameter.
'app-name' specifies the name and the resource class of the
application. If 'app-name' is specified to 'xxx', the application
class on the resource database is set to 'Xxx' and the application
name is changed by the same rule of Tk.appname method. 'use'
specifies the main window for embedding the root widget instead of
generating a new window.
* tk.rb: Add new parameter 'widgetname' to the widget constructor to
support effective use of Resource Database. For example, the
resource 'Xxx*quit.text: QUIT' can set the text of the button
generated by the following code.
e.g.
Tk.restart('Xxx')
TkButton.new(nil, 'widgetname'=>'quit', 'command'=>proc{exit}).pack
Tk.mainloop
* tk.rb: TkOption::get always returns a tainted string.
Add TkOption::new_proc_class.
It generates a class to import procedures defined on the resource
database. For example, there is a following resource file.
----< resource-test >------------
*CMD.foo: {|*args| p [$SAFE, :foo, args]}
*CMD.XXX.bar: {|*args| p [$SAFE, :bar, args]}
*Button.command: ruby {p self; p $SAFE; TkOption::CMD::XXX.bar(1,2,3)}
---------------------------------
The following code is a sample of use of the resource file.
e.g.
require 'tk'
TkOption.readfile 'resource-test'
p TkOption.new_proc_class(:CMD, [:foo], 1)
p TkOption.new_proc_class(:XXX, [:bar], 2, false, TkOption::CMD)
TkButton.new(:text=>'test').pack
Tk.mainloop
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2515 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2002-06-04 11:03:33 +04:00
|
|
|
int
|
|
|
|
invoke_queue_handler(evPtr, flags)
|
|
|
|
Tcl_Event *evPtr;
|
|
|
|
int flags;
|
|
|
|
{
|
2003-07-29 05:24:32 +04:00
|
|
|
struct invoke_queue *q = (struct invoke_queue *)evPtr;
|
* tkfont.rb: Fix bugs on TkFont.init_widget_font for Tk8.x.
* tkafter.rb: Add self to 1st argument of interval- and loop-proc
TkAfter#current_interval returns an interval (sleep) time value
TkAfter#current_args returns an array of arguments
TkAfter#return_value returns a return value of last loop-proc
e.g.
TkAfter.new(
proc{|obj| 500 - obj.current_interval}, 10,
[proc{|obj| p obj.current_args}, 'proc', 1],
proc{|obj| p obj.current_args; ['return', 2]},
[proc{|obj|
p obj.return_value
p ['proc', obj.current_args[0].call(obj.return_value[1],
obj.current_args[1])]},
proc{|*args| args[0] + args[1]}, 1],
proc{p ['proc', 4]} ).start(100)
* tk*.rb: Allow to use Symbols for parameters.
Allow new notation of constructor (also allow old notation).
e.g.
TkFrame.new('classname'=>'User'){|base|
pack
f = TkFrame.new(base, :classname=>'ButtonFrame').pack
TkButton.new(
:parent => f,
:text => 'Quit',
:command => proc{exit}
).pack(
:fill => :x,
:pady => 2
)
}
* tkcanvas.rb: (TkcItem) Add 'coords' parameter to the canvas item
constructor (for new notation of constructor).
e.g.
c = TkCanvas.new.pack
l = TkcLine.new(c, :coords=>[[0,0], [100,100]])
* tcltklib.c: New 'mainloop' and 'mainloop_watchdog'.
The priority of their event-loop can be controlled.
They accept an optional argument.
If it false, they don't exit although the root widget is destroyed.
This function is sometimes useful, if it is used with 'restart'.
'mainloop' can't treat Thread#join/value in a callback routine.
(e.g. TkButton.new(:command=>proc{p Thread.new{button.invoke}.value}) )
'mainloop_watchdog' can treat them, but watchdog thread is always running
(so, a little heavier than 'mainloop').
If the purpose of using Thread#join/value is to do something under some
safe-level, please use Proc object.
(e.g. :command=>proc{$SAFE=1;proc{$SAFE=2;button.invoke}.call;p $SAFE})
* tk.rb: Support functions of new 'mainloop' and 'mainloop_watchdog'.
* tk.rb: (Tk.restart) Add 'app-name' paramater and 'use' parameter.
'app-name' specifies the name and the resource class of the
application. If 'app-name' is specified to 'xxx', the application
class on the resource database is set to 'Xxx' and the application
name is changed by the same rule of Tk.appname method. 'use'
specifies the main window for embedding the root widget instead of
generating a new window.
* tk.rb: Add new parameter 'widgetname' to the widget constructor to
support effective use of Resource Database. For example, the
resource 'Xxx*quit.text: QUIT' can set the text of the button
generated by the following code.
e.g.
Tk.restart('Xxx')
TkButton.new(nil, 'widgetname'=>'quit', 'command'=>proc{exit}).pack
Tk.mainloop
* tk.rb: TkOption::get always returns a tainted string.
Add TkOption::new_proc_class.
It generates a class to import procedures defined on the resource
database. For example, there is a following resource file.
----< resource-test >------------
*CMD.foo: {|*args| p [$SAFE, :foo, args]}
*CMD.XXX.bar: {|*args| p [$SAFE, :bar, args]}
*Button.command: ruby {p self; p $SAFE; TkOption::CMD::XXX.bar(1,2,3)}
---------------------------------
The following code is a sample of use of the resource file.
e.g.
require 'tk'
TkOption.readfile 'resource-test'
p TkOption.new_proc_class(:CMD, [:foo], 1)
p TkOption.new_proc_class(:XXX, [:bar], 2, false, TkOption::CMD)
TkButton.new(:text=>'test').pack
Tk.mainloop
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2515 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2002-06-04 11:03:33 +04:00
|
|
|
|
2003-10-14 19:25:45 +04:00
|
|
|
DUMP2("do_invoke_queue_handler : evPtr = %lx", evPtr);
|
* tkfont.rb: Fix bugs on TkFont.init_widget_font for Tk8.x.
* tkafter.rb: Add self to 1st argument of interval- and loop-proc
TkAfter#current_interval returns an interval (sleep) time value
TkAfter#current_args returns an array of arguments
TkAfter#return_value returns a return value of last loop-proc
e.g.
TkAfter.new(
proc{|obj| 500 - obj.current_interval}, 10,
[proc{|obj| p obj.current_args}, 'proc', 1],
proc{|obj| p obj.current_args; ['return', 2]},
[proc{|obj|
p obj.return_value
p ['proc', obj.current_args[0].call(obj.return_value[1],
obj.current_args[1])]},
proc{|*args| args[0] + args[1]}, 1],
proc{p ['proc', 4]} ).start(100)
* tk*.rb: Allow to use Symbols for parameters.
Allow new notation of constructor (also allow old notation).
e.g.
TkFrame.new('classname'=>'User'){|base|
pack
f = TkFrame.new(base, :classname=>'ButtonFrame').pack
TkButton.new(
:parent => f,
:text => 'Quit',
:command => proc{exit}
).pack(
:fill => :x,
:pady => 2
)
}
* tkcanvas.rb: (TkcItem) Add 'coords' parameter to the canvas item
constructor (for new notation of constructor).
e.g.
c = TkCanvas.new.pack
l = TkcLine.new(c, :coords=>[[0,0], [100,100]])
* tcltklib.c: New 'mainloop' and 'mainloop_watchdog'.
The priority of their event-loop can be controlled.
They accept an optional argument.
If it false, they don't exit although the root widget is destroyed.
This function is sometimes useful, if it is used with 'restart'.
'mainloop' can't treat Thread#join/value in a callback routine.
(e.g. TkButton.new(:command=>proc{p Thread.new{button.invoke}.value}) )
'mainloop_watchdog' can treat them, but watchdog thread is always running
(so, a little heavier than 'mainloop').
If the purpose of using Thread#join/value is to do something under some
safe-level, please use Proc object.
(e.g. :command=>proc{$SAFE=1;proc{$SAFE=2;button.invoke}.call;p $SAFE})
* tk.rb: Support functions of new 'mainloop' and 'mainloop_watchdog'.
* tk.rb: (Tk.restart) Add 'app-name' paramater and 'use' parameter.
'app-name' specifies the name and the resource class of the
application. If 'app-name' is specified to 'xxx', the application
class on the resource database is set to 'Xxx' and the application
name is changed by the same rule of Tk.appname method. 'use'
specifies the main window for embedding the root widget instead of
generating a new window.
* tk.rb: Add new parameter 'widgetname' to the widget constructor to
support effective use of Resource Database. For example, the
resource 'Xxx*quit.text: QUIT' can set the text of the button
generated by the following code.
e.g.
Tk.restart('Xxx')
TkButton.new(nil, 'widgetname'=>'quit', 'command'=>proc{exit}).pack
Tk.mainloop
* tk.rb: TkOption::get always returns a tainted string.
Add TkOption::new_proc_class.
It generates a class to import procedures defined on the resource
database. For example, there is a following resource file.
----< resource-test >------------
*CMD.foo: {|*args| p [$SAFE, :foo, args]}
*CMD.XXX.bar: {|*args| p [$SAFE, :bar, args]}
*Button.command: ruby {p self; p $SAFE; TkOption::CMD::XXX.bar(1,2,3)}
---------------------------------
The following code is a sample of use of the resource file.
e.g.
require 'tk'
TkOption.readfile 'resource-test'
p TkOption.new_proc_class(:CMD, [:foo], 1)
p TkOption.new_proc_class(:XXX, [:bar], 2, false, TkOption::CMD)
TkButton.new(:text=>'test').pack
Tk.mainloop
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2515 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2002-06-04 11:03:33 +04:00
|
|
|
DUMP2("invoke queue_thread : %lx", rb_thread_current());
|
|
|
|
DUMP2("added by thread : %lx", q->thread);
|
|
|
|
|
|
|
|
if (q->done) {
|
2003-10-14 19:25:45 +04:00
|
|
|
DUMP1("processed by another event-loop");
|
2003-07-27 23:35:06 +04:00
|
|
|
return 0;
|
2003-10-14 19:25:45 +04:00
|
|
|
} else {
|
|
|
|
DUMP1("process it on current event-loop");
|
* tkfont.rb: Fix bugs on TkFont.init_widget_font for Tk8.x.
* tkafter.rb: Add self to 1st argument of interval- and loop-proc
TkAfter#current_interval returns an interval (sleep) time value
TkAfter#current_args returns an array of arguments
TkAfter#return_value returns a return value of last loop-proc
e.g.
TkAfter.new(
proc{|obj| 500 - obj.current_interval}, 10,
[proc{|obj| p obj.current_args}, 'proc', 1],
proc{|obj| p obj.current_args; ['return', 2]},
[proc{|obj|
p obj.return_value
p ['proc', obj.current_args[0].call(obj.return_value[1],
obj.current_args[1])]},
proc{|*args| args[0] + args[1]}, 1],
proc{p ['proc', 4]} ).start(100)
* tk*.rb: Allow to use Symbols for parameters.
Allow new notation of constructor (also allow old notation).
e.g.
TkFrame.new('classname'=>'User'){|base|
pack
f = TkFrame.new(base, :classname=>'ButtonFrame').pack
TkButton.new(
:parent => f,
:text => 'Quit',
:command => proc{exit}
).pack(
:fill => :x,
:pady => 2
)
}
* tkcanvas.rb: (TkcItem) Add 'coords' parameter to the canvas item
constructor (for new notation of constructor).
e.g.
c = TkCanvas.new.pack
l = TkcLine.new(c, :coords=>[[0,0], [100,100]])
* tcltklib.c: New 'mainloop' and 'mainloop_watchdog'.
The priority of their event-loop can be controlled.
They accept an optional argument.
If it false, they don't exit although the root widget is destroyed.
This function is sometimes useful, if it is used with 'restart'.
'mainloop' can't treat Thread#join/value in a callback routine.
(e.g. TkButton.new(:command=>proc{p Thread.new{button.invoke}.value}) )
'mainloop_watchdog' can treat them, but watchdog thread is always running
(so, a little heavier than 'mainloop').
If the purpose of using Thread#join/value is to do something under some
safe-level, please use Proc object.
(e.g. :command=>proc{$SAFE=1;proc{$SAFE=2;button.invoke}.call;p $SAFE})
* tk.rb: Support functions of new 'mainloop' and 'mainloop_watchdog'.
* tk.rb: (Tk.restart) Add 'app-name' paramater and 'use' parameter.
'app-name' specifies the name and the resource class of the
application. If 'app-name' is specified to 'xxx', the application
class on the resource database is set to 'Xxx' and the application
name is changed by the same rule of Tk.appname method. 'use'
specifies the main window for embedding the root widget instead of
generating a new window.
* tk.rb: Add new parameter 'widgetname' to the widget constructor to
support effective use of Resource Database. For example, the
resource 'Xxx*quit.text: QUIT' can set the text of the button
generated by the following code.
e.g.
Tk.restart('Xxx')
TkButton.new(nil, 'widgetname'=>'quit', 'command'=>proc{exit}).pack
Tk.mainloop
* tk.rb: TkOption::get always returns a tainted string.
Add TkOption::new_proc_class.
It generates a class to import procedures defined on the resource
database. For example, there is a following resource file.
----< resource-test >------------
*CMD.foo: {|*args| p [$SAFE, :foo, args]}
*CMD.XXX.bar: {|*args| p [$SAFE, :bar, args]}
*Button.command: ruby {p self; p $SAFE; TkOption::CMD::XXX.bar(1,2,3)}
---------------------------------
The following code is a sample of use of the resource file.
e.g.
require 'tk'
TkOption.readfile 'resource-test'
p TkOption.new_proc_class(:CMD, [:foo], 1)
p TkOption.new_proc_class(:XXX, [:bar], 2, false, TkOption::CMD)
TkButton.new(:text=>'test').pack
Tk.mainloop
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2515 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2002-06-04 11:03:33 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/* process it */
|
|
|
|
q->done = 1;
|
|
|
|
|
|
|
|
/* check safe-level */
|
|
|
|
if (rb_safe_level() != q->safe_level) {
|
2003-07-27 23:35:06 +04:00
|
|
|
*(q->result)
|
|
|
|
= rb_funcall(rb_proc_new(ivq_safelevel_handler,
|
|
|
|
Data_Wrap_Struct(rb_cData,0,0,q)),
|
|
|
|
rb_intern("call"), 0);
|
* tkfont.rb: Fix bugs on TkFont.init_widget_font for Tk8.x.
* tkafter.rb: Add self to 1st argument of interval- and loop-proc
TkAfter#current_interval returns an interval (sleep) time value
TkAfter#current_args returns an array of arguments
TkAfter#return_value returns a return value of last loop-proc
e.g.
TkAfter.new(
proc{|obj| 500 - obj.current_interval}, 10,
[proc{|obj| p obj.current_args}, 'proc', 1],
proc{|obj| p obj.current_args; ['return', 2]},
[proc{|obj|
p obj.return_value
p ['proc', obj.current_args[0].call(obj.return_value[1],
obj.current_args[1])]},
proc{|*args| args[0] + args[1]}, 1],
proc{p ['proc', 4]} ).start(100)
* tk*.rb: Allow to use Symbols for parameters.
Allow new notation of constructor (also allow old notation).
e.g.
TkFrame.new('classname'=>'User'){|base|
pack
f = TkFrame.new(base, :classname=>'ButtonFrame').pack
TkButton.new(
:parent => f,
:text => 'Quit',
:command => proc{exit}
).pack(
:fill => :x,
:pady => 2
)
}
* tkcanvas.rb: (TkcItem) Add 'coords' parameter to the canvas item
constructor (for new notation of constructor).
e.g.
c = TkCanvas.new.pack
l = TkcLine.new(c, :coords=>[[0,0], [100,100]])
* tcltklib.c: New 'mainloop' and 'mainloop_watchdog'.
The priority of their event-loop can be controlled.
They accept an optional argument.
If it false, they don't exit although the root widget is destroyed.
This function is sometimes useful, if it is used with 'restart'.
'mainloop' can't treat Thread#join/value in a callback routine.
(e.g. TkButton.new(:command=>proc{p Thread.new{button.invoke}.value}) )
'mainloop_watchdog' can treat them, but watchdog thread is always running
(so, a little heavier than 'mainloop').
If the purpose of using Thread#join/value is to do something under some
safe-level, please use Proc object.
(e.g. :command=>proc{$SAFE=1;proc{$SAFE=2;button.invoke}.call;p $SAFE})
* tk.rb: Support functions of new 'mainloop' and 'mainloop_watchdog'.
* tk.rb: (Tk.restart) Add 'app-name' paramater and 'use' parameter.
'app-name' specifies the name and the resource class of the
application. If 'app-name' is specified to 'xxx', the application
class on the resource database is set to 'Xxx' and the application
name is changed by the same rule of Tk.appname method. 'use'
specifies the main window for embedding the root widget instead of
generating a new window.
* tk.rb: Add new parameter 'widgetname' to the widget constructor to
support effective use of Resource Database. For example, the
resource 'Xxx*quit.text: QUIT' can set the text of the button
generated by the following code.
e.g.
Tk.restart('Xxx')
TkButton.new(nil, 'widgetname'=>'quit', 'command'=>proc{exit}).pack
Tk.mainloop
* tk.rb: TkOption::get always returns a tainted string.
Add TkOption::new_proc_class.
It generates a class to import procedures defined on the resource
database. For example, there is a following resource file.
----< resource-test >------------
*CMD.foo: {|*args| p [$SAFE, :foo, args]}
*CMD.XXX.bar: {|*args| p [$SAFE, :bar, args]}
*Button.command: ruby {p self; p $SAFE; TkOption::CMD::XXX.bar(1,2,3)}
---------------------------------
The following code is a sample of use of the resource file.
e.g.
require 'tk'
TkOption.readfile 'resource-test'
p TkOption.new_proc_class(:CMD, [:foo], 1)
p TkOption.new_proc_class(:XXX, [:bar], 2, false, TkOption::CMD)
TkButton.new(:text=>'test').pack
Tk.mainloop
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2515 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2002-06-04 11:03:33 +04:00
|
|
|
} else {
|
2003-10-14 19:25:45 +04:00
|
|
|
DUMP2("call invoke_real (for caller thread:%lx)", q->thread);
|
|
|
|
DUMP2("call invoke_real (current thread:%lx)", rb_thread_current());
|
2003-07-27 23:35:06 +04:00
|
|
|
*(q->result) = ip_invoke_real(q->argc, q->argv, q->obj);
|
* tkfont.rb: Fix bugs on TkFont.init_widget_font for Tk8.x.
* tkafter.rb: Add self to 1st argument of interval- and loop-proc
TkAfter#current_interval returns an interval (sleep) time value
TkAfter#current_args returns an array of arguments
TkAfter#return_value returns a return value of last loop-proc
e.g.
TkAfter.new(
proc{|obj| 500 - obj.current_interval}, 10,
[proc{|obj| p obj.current_args}, 'proc', 1],
proc{|obj| p obj.current_args; ['return', 2]},
[proc{|obj|
p obj.return_value
p ['proc', obj.current_args[0].call(obj.return_value[1],
obj.current_args[1])]},
proc{|*args| args[0] + args[1]}, 1],
proc{p ['proc', 4]} ).start(100)
* tk*.rb: Allow to use Symbols for parameters.
Allow new notation of constructor (also allow old notation).
e.g.
TkFrame.new('classname'=>'User'){|base|
pack
f = TkFrame.new(base, :classname=>'ButtonFrame').pack
TkButton.new(
:parent => f,
:text => 'Quit',
:command => proc{exit}
).pack(
:fill => :x,
:pady => 2
)
}
* tkcanvas.rb: (TkcItem) Add 'coords' parameter to the canvas item
constructor (for new notation of constructor).
e.g.
c = TkCanvas.new.pack
l = TkcLine.new(c, :coords=>[[0,0], [100,100]])
* tcltklib.c: New 'mainloop' and 'mainloop_watchdog'.
The priority of their event-loop can be controlled.
They accept an optional argument.
If it false, they don't exit although the root widget is destroyed.
This function is sometimes useful, if it is used with 'restart'.
'mainloop' can't treat Thread#join/value in a callback routine.
(e.g. TkButton.new(:command=>proc{p Thread.new{button.invoke}.value}) )
'mainloop_watchdog' can treat them, but watchdog thread is always running
(so, a little heavier than 'mainloop').
If the purpose of using Thread#join/value is to do something under some
safe-level, please use Proc object.
(e.g. :command=>proc{$SAFE=1;proc{$SAFE=2;button.invoke}.call;p $SAFE})
* tk.rb: Support functions of new 'mainloop' and 'mainloop_watchdog'.
* tk.rb: (Tk.restart) Add 'app-name' paramater and 'use' parameter.
'app-name' specifies the name and the resource class of the
application. If 'app-name' is specified to 'xxx', the application
class on the resource database is set to 'Xxx' and the application
name is changed by the same rule of Tk.appname method. 'use'
specifies the main window for embedding the root widget instead of
generating a new window.
* tk.rb: Add new parameter 'widgetname' to the widget constructor to
support effective use of Resource Database. For example, the
resource 'Xxx*quit.text: QUIT' can set the text of the button
generated by the following code.
e.g.
Tk.restart('Xxx')
TkButton.new(nil, 'widgetname'=>'quit', 'command'=>proc{exit}).pack
Tk.mainloop
* tk.rb: TkOption::get always returns a tainted string.
Add TkOption::new_proc_class.
It generates a class to import procedures defined on the resource
database. For example, there is a following resource file.
----< resource-test >------------
*CMD.foo: {|*args| p [$SAFE, :foo, args]}
*CMD.XXX.bar: {|*args| p [$SAFE, :bar, args]}
*Button.command: ruby {p self; p $SAFE; TkOption::CMD::XXX.bar(1,2,3)}
---------------------------------
The following code is a sample of use of the resource file.
e.g.
require 'tk'
TkOption.readfile 'resource-test'
p TkOption.new_proc_class(:CMD, [:foo], 1)
p TkOption.new_proc_class(:XXX, [:bar], 2, false, TkOption::CMD)
TkButton.new(:text=>'test').pack
Tk.mainloop
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2515 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2002-06-04 11:03:33 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/* back to caller */
|
2003-10-14 19:25:45 +04:00
|
|
|
DUMP2("back to caller (caller thread:%lx)", q->thread);
|
|
|
|
DUMP2(" (current thread:%lx)", rb_thread_current());
|
* tkfont.rb: Fix bugs on TkFont.init_widget_font for Tk8.x.
* tkafter.rb: Add self to 1st argument of interval- and loop-proc
TkAfter#current_interval returns an interval (sleep) time value
TkAfter#current_args returns an array of arguments
TkAfter#return_value returns a return value of last loop-proc
e.g.
TkAfter.new(
proc{|obj| 500 - obj.current_interval}, 10,
[proc{|obj| p obj.current_args}, 'proc', 1],
proc{|obj| p obj.current_args; ['return', 2]},
[proc{|obj|
p obj.return_value
p ['proc', obj.current_args[0].call(obj.return_value[1],
obj.current_args[1])]},
proc{|*args| args[0] + args[1]}, 1],
proc{p ['proc', 4]} ).start(100)
* tk*.rb: Allow to use Symbols for parameters.
Allow new notation of constructor (also allow old notation).
e.g.
TkFrame.new('classname'=>'User'){|base|
pack
f = TkFrame.new(base, :classname=>'ButtonFrame').pack
TkButton.new(
:parent => f,
:text => 'Quit',
:command => proc{exit}
).pack(
:fill => :x,
:pady => 2
)
}
* tkcanvas.rb: (TkcItem) Add 'coords' parameter to the canvas item
constructor (for new notation of constructor).
e.g.
c = TkCanvas.new.pack
l = TkcLine.new(c, :coords=>[[0,0], [100,100]])
* tcltklib.c: New 'mainloop' and 'mainloop_watchdog'.
The priority of their event-loop can be controlled.
They accept an optional argument.
If it false, they don't exit although the root widget is destroyed.
This function is sometimes useful, if it is used with 'restart'.
'mainloop' can't treat Thread#join/value in a callback routine.
(e.g. TkButton.new(:command=>proc{p Thread.new{button.invoke}.value}) )
'mainloop_watchdog' can treat them, but watchdog thread is always running
(so, a little heavier than 'mainloop').
If the purpose of using Thread#join/value is to do something under some
safe-level, please use Proc object.
(e.g. :command=>proc{$SAFE=1;proc{$SAFE=2;button.invoke}.call;p $SAFE})
* tk.rb: Support functions of new 'mainloop' and 'mainloop_watchdog'.
* tk.rb: (Tk.restart) Add 'app-name' paramater and 'use' parameter.
'app-name' specifies the name and the resource class of the
application. If 'app-name' is specified to 'xxx', the application
class on the resource database is set to 'Xxx' and the application
name is changed by the same rule of Tk.appname method. 'use'
specifies the main window for embedding the root widget instead of
generating a new window.
* tk.rb: Add new parameter 'widgetname' to the widget constructor to
support effective use of Resource Database. For example, the
resource 'Xxx*quit.text: QUIT' can set the text of the button
generated by the following code.
e.g.
Tk.restart('Xxx')
TkButton.new(nil, 'widgetname'=>'quit', 'command'=>proc{exit}).pack
Tk.mainloop
* tk.rb: TkOption::get always returns a tainted string.
Add TkOption::new_proc_class.
It generates a class to import procedures defined on the resource
database. For example, there is a following resource file.
----< resource-test >------------
*CMD.foo: {|*args| p [$SAFE, :foo, args]}
*CMD.XXX.bar: {|*args| p [$SAFE, :bar, args]}
*Button.command: ruby {p self; p $SAFE; TkOption::CMD::XXX.bar(1,2,3)}
---------------------------------
The following code is a sample of use of the resource file.
e.g.
require 'tk'
TkOption.readfile 'resource-test'
p TkOption.new_proc_class(:CMD, [:foo], 1)
p TkOption.new_proc_class(:XXX, [:bar], 2, false, TkOption::CMD)
TkButton.new(:text=>'test').pack
Tk.mainloop
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2515 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2002-06-04 11:03:33 +04:00
|
|
|
rb_thread_run(q->thread);
|
2003-10-14 19:25:45 +04:00
|
|
|
DUMP1("finish back to caller");
|
* tkfont.rb: Fix bugs on TkFont.init_widget_font for Tk8.x.
* tkafter.rb: Add self to 1st argument of interval- and loop-proc
TkAfter#current_interval returns an interval (sleep) time value
TkAfter#current_args returns an array of arguments
TkAfter#return_value returns a return value of last loop-proc
e.g.
TkAfter.new(
proc{|obj| 500 - obj.current_interval}, 10,
[proc{|obj| p obj.current_args}, 'proc', 1],
proc{|obj| p obj.current_args; ['return', 2]},
[proc{|obj|
p obj.return_value
p ['proc', obj.current_args[0].call(obj.return_value[1],
obj.current_args[1])]},
proc{|*args| args[0] + args[1]}, 1],
proc{p ['proc', 4]} ).start(100)
* tk*.rb: Allow to use Symbols for parameters.
Allow new notation of constructor (also allow old notation).
e.g.
TkFrame.new('classname'=>'User'){|base|
pack
f = TkFrame.new(base, :classname=>'ButtonFrame').pack
TkButton.new(
:parent => f,
:text => 'Quit',
:command => proc{exit}
).pack(
:fill => :x,
:pady => 2
)
}
* tkcanvas.rb: (TkcItem) Add 'coords' parameter to the canvas item
constructor (for new notation of constructor).
e.g.
c = TkCanvas.new.pack
l = TkcLine.new(c, :coords=>[[0,0], [100,100]])
* tcltklib.c: New 'mainloop' and 'mainloop_watchdog'.
The priority of their event-loop can be controlled.
They accept an optional argument.
If it false, they don't exit although the root widget is destroyed.
This function is sometimes useful, if it is used with 'restart'.
'mainloop' can't treat Thread#join/value in a callback routine.
(e.g. TkButton.new(:command=>proc{p Thread.new{button.invoke}.value}) )
'mainloop_watchdog' can treat them, but watchdog thread is always running
(so, a little heavier than 'mainloop').
If the purpose of using Thread#join/value is to do something under some
safe-level, please use Proc object.
(e.g. :command=>proc{$SAFE=1;proc{$SAFE=2;button.invoke}.call;p $SAFE})
* tk.rb: Support functions of new 'mainloop' and 'mainloop_watchdog'.
* tk.rb: (Tk.restart) Add 'app-name' paramater and 'use' parameter.
'app-name' specifies the name and the resource class of the
application. If 'app-name' is specified to 'xxx', the application
class on the resource database is set to 'Xxx' and the application
name is changed by the same rule of Tk.appname method. 'use'
specifies the main window for embedding the root widget instead of
generating a new window.
* tk.rb: Add new parameter 'widgetname' to the widget constructor to
support effective use of Resource Database. For example, the
resource 'Xxx*quit.text: QUIT' can set the text of the button
generated by the following code.
e.g.
Tk.restart('Xxx')
TkButton.new(nil, 'widgetname'=>'quit', 'command'=>proc{exit}).pack
Tk.mainloop
* tk.rb: TkOption::get always returns a tainted string.
Add TkOption::new_proc_class.
It generates a class to import procedures defined on the resource
database. For example, there is a following resource file.
----< resource-test >------------
*CMD.foo: {|*args| p [$SAFE, :foo, args]}
*CMD.XXX.bar: {|*args| p [$SAFE, :bar, args]}
*Button.command: ruby {p self; p $SAFE; TkOption::CMD::XXX.bar(1,2,3)}
---------------------------------
The following code is a sample of use of the resource file.
e.g.
require 'tk'
TkOption.readfile 'resource-test'
p TkOption.new_proc_class(:CMD, [:foo], 1)
p TkOption.new_proc_class(:XXX, [:bar], 2, false, TkOption::CMD)
TkButton.new(:text=>'test').pack
Tk.mainloop
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2515 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2002-06-04 11:03:33 +04:00
|
|
|
|
|
|
|
/* end of handler : remove it */
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
1999-08-13 09:37:52 +04:00
|
|
|
static VALUE
|
|
|
|
ip_invoke(argc, argv, obj)
|
|
|
|
int argc;
|
|
|
|
VALUE *argv;
|
|
|
|
VALUE obj;
|
|
|
|
{
|
* tkfont.rb: Fix bugs on TkFont.init_widget_font for Tk8.x.
* tkafter.rb: Add self to 1st argument of interval- and loop-proc
TkAfter#current_interval returns an interval (sleep) time value
TkAfter#current_args returns an array of arguments
TkAfter#return_value returns a return value of last loop-proc
e.g.
TkAfter.new(
proc{|obj| 500 - obj.current_interval}, 10,
[proc{|obj| p obj.current_args}, 'proc', 1],
proc{|obj| p obj.current_args; ['return', 2]},
[proc{|obj|
p obj.return_value
p ['proc', obj.current_args[0].call(obj.return_value[1],
obj.current_args[1])]},
proc{|*args| args[0] + args[1]}, 1],
proc{p ['proc', 4]} ).start(100)
* tk*.rb: Allow to use Symbols for parameters.
Allow new notation of constructor (also allow old notation).
e.g.
TkFrame.new('classname'=>'User'){|base|
pack
f = TkFrame.new(base, :classname=>'ButtonFrame').pack
TkButton.new(
:parent => f,
:text => 'Quit',
:command => proc{exit}
).pack(
:fill => :x,
:pady => 2
)
}
* tkcanvas.rb: (TkcItem) Add 'coords' parameter to the canvas item
constructor (for new notation of constructor).
e.g.
c = TkCanvas.new.pack
l = TkcLine.new(c, :coords=>[[0,0], [100,100]])
* tcltklib.c: New 'mainloop' and 'mainloop_watchdog'.
The priority of their event-loop can be controlled.
They accept an optional argument.
If it false, they don't exit although the root widget is destroyed.
This function is sometimes useful, if it is used with 'restart'.
'mainloop' can't treat Thread#join/value in a callback routine.
(e.g. TkButton.new(:command=>proc{p Thread.new{button.invoke}.value}) )
'mainloop_watchdog' can treat them, but watchdog thread is always running
(so, a little heavier than 'mainloop').
If the purpose of using Thread#join/value is to do something under some
safe-level, please use Proc object.
(e.g. :command=>proc{$SAFE=1;proc{$SAFE=2;button.invoke}.call;p $SAFE})
* tk.rb: Support functions of new 'mainloop' and 'mainloop_watchdog'.
* tk.rb: (Tk.restart) Add 'app-name' paramater and 'use' parameter.
'app-name' specifies the name and the resource class of the
application. If 'app-name' is specified to 'xxx', the application
class on the resource database is set to 'Xxx' and the application
name is changed by the same rule of Tk.appname method. 'use'
specifies the main window for embedding the root widget instead of
generating a new window.
* tk.rb: Add new parameter 'widgetname' to the widget constructor to
support effective use of Resource Database. For example, the
resource 'Xxx*quit.text: QUIT' can set the text of the button
generated by the following code.
e.g.
Tk.restart('Xxx')
TkButton.new(nil, 'widgetname'=>'quit', 'command'=>proc{exit}).pack
Tk.mainloop
* tk.rb: TkOption::get always returns a tainted string.
Add TkOption::new_proc_class.
It generates a class to import procedures defined on the resource
database. For example, there is a following resource file.
----< resource-test >------------
*CMD.foo: {|*args| p [$SAFE, :foo, args]}
*CMD.XXX.bar: {|*args| p [$SAFE, :bar, args]}
*Button.command: ruby {p self; p $SAFE; TkOption::CMD::XXX.bar(1,2,3)}
---------------------------------
The following code is a sample of use of the resource file.
e.g.
require 'tk'
TkOption.readfile 'resource-test'
p TkOption.new_proc_class(:CMD, [:foo], 1)
p TkOption.new_proc_class(:XXX, [:bar], 2, false, TkOption::CMD)
TkButton.new(:text=>'test').pack
Tk.mainloop
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2515 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2002-06-04 11:03:33 +04:00
|
|
|
struct invoke_queue *tmp;
|
|
|
|
VALUE current = rb_thread_current();
|
|
|
|
VALUE result;
|
|
|
|
VALUE *alloc_argv, *alloc_result;
|
|
|
|
Tcl_QueuePosition position;
|
1999-08-13 09:37:52 +04:00
|
|
|
|
2002-10-03 15:20:31 +04:00
|
|
|
if (argc < 1) {
|
|
|
|
rb_raise(rb_eArgError, "command name missing");
|
|
|
|
}
|
* tkfont.rb: Fix bugs on TkFont.init_widget_font for Tk8.x.
* tkafter.rb: Add self to 1st argument of interval- and loop-proc
TkAfter#current_interval returns an interval (sleep) time value
TkAfter#current_args returns an array of arguments
TkAfter#return_value returns a return value of last loop-proc
e.g.
TkAfter.new(
proc{|obj| 500 - obj.current_interval}, 10,
[proc{|obj| p obj.current_args}, 'proc', 1],
proc{|obj| p obj.current_args; ['return', 2]},
[proc{|obj|
p obj.return_value
p ['proc', obj.current_args[0].call(obj.return_value[1],
obj.current_args[1])]},
proc{|*args| args[0] + args[1]}, 1],
proc{p ['proc', 4]} ).start(100)
* tk*.rb: Allow to use Symbols for parameters.
Allow new notation of constructor (also allow old notation).
e.g.
TkFrame.new('classname'=>'User'){|base|
pack
f = TkFrame.new(base, :classname=>'ButtonFrame').pack
TkButton.new(
:parent => f,
:text => 'Quit',
:command => proc{exit}
).pack(
:fill => :x,
:pady => 2
)
}
* tkcanvas.rb: (TkcItem) Add 'coords' parameter to the canvas item
constructor (for new notation of constructor).
e.g.
c = TkCanvas.new.pack
l = TkcLine.new(c, :coords=>[[0,0], [100,100]])
* tcltklib.c: New 'mainloop' and 'mainloop_watchdog'.
The priority of their event-loop can be controlled.
They accept an optional argument.
If it false, they don't exit although the root widget is destroyed.
This function is sometimes useful, if it is used with 'restart'.
'mainloop' can't treat Thread#join/value in a callback routine.
(e.g. TkButton.new(:command=>proc{p Thread.new{button.invoke}.value}) )
'mainloop_watchdog' can treat them, but watchdog thread is always running
(so, a little heavier than 'mainloop').
If the purpose of using Thread#join/value is to do something under some
safe-level, please use Proc object.
(e.g. :command=>proc{$SAFE=1;proc{$SAFE=2;button.invoke}.call;p $SAFE})
* tk.rb: Support functions of new 'mainloop' and 'mainloop_watchdog'.
* tk.rb: (Tk.restart) Add 'app-name' paramater and 'use' parameter.
'app-name' specifies the name and the resource class of the
application. If 'app-name' is specified to 'xxx', the application
class on the resource database is set to 'Xxx' and the application
name is changed by the same rule of Tk.appname method. 'use'
specifies the main window for embedding the root widget instead of
generating a new window.
* tk.rb: Add new parameter 'widgetname' to the widget constructor to
support effective use of Resource Database. For example, the
resource 'Xxx*quit.text: QUIT' can set the text of the button
generated by the following code.
e.g.
Tk.restart('Xxx')
TkButton.new(nil, 'widgetname'=>'quit', 'command'=>proc{exit}).pack
Tk.mainloop
* tk.rb: TkOption::get always returns a tainted string.
Add TkOption::new_proc_class.
It generates a class to import procedures defined on the resource
database. For example, there is a following resource file.
----< resource-test >------------
*CMD.foo: {|*args| p [$SAFE, :foo, args]}
*CMD.XXX.bar: {|*args| p [$SAFE, :bar, args]}
*Button.command: ruby {p self; p $SAFE; TkOption::CMD::XXX.bar(1,2,3)}
---------------------------------
The following code is a sample of use of the resource file.
e.g.
require 'tk'
TkOption.readfile 'resource-test'
p TkOption.new_proc_class(:CMD, [:foo], 1)
p TkOption.new_proc_class(:XXX, [:bar], 2, false, TkOption::CMD)
TkButton.new(:text=>'test').pack
Tk.mainloop
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2515 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2002-06-04 11:03:33 +04:00
|
|
|
if (eventloop_thread == 0 || current == eventloop_thread) {
|
2003-10-14 19:25:45 +04:00
|
|
|
if (eventloop_thread) {
|
|
|
|
DUMP2("invoke from current eventloop %lx", current);
|
|
|
|
} else {
|
|
|
|
DUMP2("invoke from thread:%lx but no eventloop", current);
|
|
|
|
}
|
2003-09-02 09:04:30 +04:00
|
|
|
result = ip_invoke_real(argc, argv, obj);
|
|
|
|
if (rb_obj_is_kind_of(result, rb_eException)) {
|
|
|
|
rb_exc_raise(result);
|
|
|
|
}
|
|
|
|
return result;
|
1999-08-13 09:37:52 +04:00
|
|
|
}
|
* tkfont.rb: Fix bugs on TkFont.init_widget_font for Tk8.x.
* tkafter.rb: Add self to 1st argument of interval- and loop-proc
TkAfter#current_interval returns an interval (sleep) time value
TkAfter#current_args returns an array of arguments
TkAfter#return_value returns a return value of last loop-proc
e.g.
TkAfter.new(
proc{|obj| 500 - obj.current_interval}, 10,
[proc{|obj| p obj.current_args}, 'proc', 1],
proc{|obj| p obj.current_args; ['return', 2]},
[proc{|obj|
p obj.return_value
p ['proc', obj.current_args[0].call(obj.return_value[1],
obj.current_args[1])]},
proc{|*args| args[0] + args[1]}, 1],
proc{p ['proc', 4]} ).start(100)
* tk*.rb: Allow to use Symbols for parameters.
Allow new notation of constructor (also allow old notation).
e.g.
TkFrame.new('classname'=>'User'){|base|
pack
f = TkFrame.new(base, :classname=>'ButtonFrame').pack
TkButton.new(
:parent => f,
:text => 'Quit',
:command => proc{exit}
).pack(
:fill => :x,
:pady => 2
)
}
* tkcanvas.rb: (TkcItem) Add 'coords' parameter to the canvas item
constructor (for new notation of constructor).
e.g.
c = TkCanvas.new.pack
l = TkcLine.new(c, :coords=>[[0,0], [100,100]])
* tcltklib.c: New 'mainloop' and 'mainloop_watchdog'.
The priority of their event-loop can be controlled.
They accept an optional argument.
If it false, they don't exit although the root widget is destroyed.
This function is sometimes useful, if it is used with 'restart'.
'mainloop' can't treat Thread#join/value in a callback routine.
(e.g. TkButton.new(:command=>proc{p Thread.new{button.invoke}.value}) )
'mainloop_watchdog' can treat them, but watchdog thread is always running
(so, a little heavier than 'mainloop').
If the purpose of using Thread#join/value is to do something under some
safe-level, please use Proc object.
(e.g. :command=>proc{$SAFE=1;proc{$SAFE=2;button.invoke}.call;p $SAFE})
* tk.rb: Support functions of new 'mainloop' and 'mainloop_watchdog'.
* tk.rb: (Tk.restart) Add 'app-name' paramater and 'use' parameter.
'app-name' specifies the name and the resource class of the
application. If 'app-name' is specified to 'xxx', the application
class on the resource database is set to 'Xxx' and the application
name is changed by the same rule of Tk.appname method. 'use'
specifies the main window for embedding the root widget instead of
generating a new window.
* tk.rb: Add new parameter 'widgetname' to the widget constructor to
support effective use of Resource Database. For example, the
resource 'Xxx*quit.text: QUIT' can set the text of the button
generated by the following code.
e.g.
Tk.restart('Xxx')
TkButton.new(nil, 'widgetname'=>'quit', 'command'=>proc{exit}).pack
Tk.mainloop
* tk.rb: TkOption::get always returns a tainted string.
Add TkOption::new_proc_class.
It generates a class to import procedures defined on the resource
database. For example, there is a following resource file.
----< resource-test >------------
*CMD.foo: {|*args| p [$SAFE, :foo, args]}
*CMD.XXX.bar: {|*args| p [$SAFE, :bar, args]}
*Button.command: ruby {p self; p $SAFE; TkOption::CMD::XXX.bar(1,2,3)}
---------------------------------
The following code is a sample of use of the resource file.
e.g.
require 'tk'
TkOption.readfile 'resource-test'
p TkOption.new_proc_class(:CMD, [:foo], 1)
p TkOption.new_proc_class(:XXX, [:bar], 2, false, TkOption::CMD)
TkButton.new(:text=>'test').pack
Tk.mainloop
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2515 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2002-06-04 11:03:33 +04:00
|
|
|
|
|
|
|
DUMP2("invoke from thread %lx (NOT current eventloop)", current);
|
|
|
|
|
|
|
|
/* allocate memory (protected from Tcl_ServiceEvent) */
|
|
|
|
alloc_argv = ALLOC_N(VALUE,argc);
|
|
|
|
MEMCPY(alloc_argv, argv, VALUE, argc);
|
|
|
|
alloc_result = ALLOC(VALUE);
|
|
|
|
|
2003-10-14 19:25:45 +04:00
|
|
|
/* allocate memory (freed by Tcl_ServiceEvent) */
|
* tkfont.rb: Fix bugs on TkFont.init_widget_font for Tk8.x.
* tkafter.rb: Add self to 1st argument of interval- and loop-proc
TkAfter#current_interval returns an interval (sleep) time value
TkAfter#current_args returns an array of arguments
TkAfter#return_value returns a return value of last loop-proc
e.g.
TkAfter.new(
proc{|obj| 500 - obj.current_interval}, 10,
[proc{|obj| p obj.current_args}, 'proc', 1],
proc{|obj| p obj.current_args; ['return', 2]},
[proc{|obj|
p obj.return_value
p ['proc', obj.current_args[0].call(obj.return_value[1],
obj.current_args[1])]},
proc{|*args| args[0] + args[1]}, 1],
proc{p ['proc', 4]} ).start(100)
* tk*.rb: Allow to use Symbols for parameters.
Allow new notation of constructor (also allow old notation).
e.g.
TkFrame.new('classname'=>'User'){|base|
pack
f = TkFrame.new(base, :classname=>'ButtonFrame').pack
TkButton.new(
:parent => f,
:text => 'Quit',
:command => proc{exit}
).pack(
:fill => :x,
:pady => 2
)
}
* tkcanvas.rb: (TkcItem) Add 'coords' parameter to the canvas item
constructor (for new notation of constructor).
e.g.
c = TkCanvas.new.pack
l = TkcLine.new(c, :coords=>[[0,0], [100,100]])
* tcltklib.c: New 'mainloop' and 'mainloop_watchdog'.
The priority of their event-loop can be controlled.
They accept an optional argument.
If it false, they don't exit although the root widget is destroyed.
This function is sometimes useful, if it is used with 'restart'.
'mainloop' can't treat Thread#join/value in a callback routine.
(e.g. TkButton.new(:command=>proc{p Thread.new{button.invoke}.value}) )
'mainloop_watchdog' can treat them, but watchdog thread is always running
(so, a little heavier than 'mainloop').
If the purpose of using Thread#join/value is to do something under some
safe-level, please use Proc object.
(e.g. :command=>proc{$SAFE=1;proc{$SAFE=2;button.invoke}.call;p $SAFE})
* tk.rb: Support functions of new 'mainloop' and 'mainloop_watchdog'.
* tk.rb: (Tk.restart) Add 'app-name' paramater and 'use' parameter.
'app-name' specifies the name and the resource class of the
application. If 'app-name' is specified to 'xxx', the application
class on the resource database is set to 'Xxx' and the application
name is changed by the same rule of Tk.appname method. 'use'
specifies the main window for embedding the root widget instead of
generating a new window.
* tk.rb: Add new parameter 'widgetname' to the widget constructor to
support effective use of Resource Database. For example, the
resource 'Xxx*quit.text: QUIT' can set the text of the button
generated by the following code.
e.g.
Tk.restart('Xxx')
TkButton.new(nil, 'widgetname'=>'quit', 'command'=>proc{exit}).pack
Tk.mainloop
* tk.rb: TkOption::get always returns a tainted string.
Add TkOption::new_proc_class.
It generates a class to import procedures defined on the resource
database. For example, there is a following resource file.
----< resource-test >------------
*CMD.foo: {|*args| p [$SAFE, :foo, args]}
*CMD.XXX.bar: {|*args| p [$SAFE, :bar, args]}
*Button.command: ruby {p self; p $SAFE; TkOption::CMD::XXX.bar(1,2,3)}
---------------------------------
The following code is a sample of use of the resource file.
e.g.
require 'tk'
TkOption.readfile 'resource-test'
p TkOption.new_proc_class(:CMD, [:foo], 1)
p TkOption.new_proc_class(:XXX, [:bar], 2, false, TkOption::CMD)
TkButton.new(:text=>'test').pack
Tk.mainloop
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2515 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2002-06-04 11:03:33 +04:00
|
|
|
tmp = (struct invoke_queue *)Tcl_Alloc(sizeof(struct invoke_queue));
|
|
|
|
|
|
|
|
/* construct event data */
|
|
|
|
tmp->done = 0;
|
1999-08-13 09:37:52 +04:00
|
|
|
tmp->obj = obj;
|
|
|
|
tmp->argc = argc;
|
* tkfont.rb: Fix bugs on TkFont.init_widget_font for Tk8.x.
* tkafter.rb: Add self to 1st argument of interval- and loop-proc
TkAfter#current_interval returns an interval (sleep) time value
TkAfter#current_args returns an array of arguments
TkAfter#return_value returns a return value of last loop-proc
e.g.
TkAfter.new(
proc{|obj| 500 - obj.current_interval}, 10,
[proc{|obj| p obj.current_args}, 'proc', 1],
proc{|obj| p obj.current_args; ['return', 2]},
[proc{|obj|
p obj.return_value
p ['proc', obj.current_args[0].call(obj.return_value[1],
obj.current_args[1])]},
proc{|*args| args[0] + args[1]}, 1],
proc{p ['proc', 4]} ).start(100)
* tk*.rb: Allow to use Symbols for parameters.
Allow new notation of constructor (also allow old notation).
e.g.
TkFrame.new('classname'=>'User'){|base|
pack
f = TkFrame.new(base, :classname=>'ButtonFrame').pack
TkButton.new(
:parent => f,
:text => 'Quit',
:command => proc{exit}
).pack(
:fill => :x,
:pady => 2
)
}
* tkcanvas.rb: (TkcItem) Add 'coords' parameter to the canvas item
constructor (for new notation of constructor).
e.g.
c = TkCanvas.new.pack
l = TkcLine.new(c, :coords=>[[0,0], [100,100]])
* tcltklib.c: New 'mainloop' and 'mainloop_watchdog'.
The priority of their event-loop can be controlled.
They accept an optional argument.
If it false, they don't exit although the root widget is destroyed.
This function is sometimes useful, if it is used with 'restart'.
'mainloop' can't treat Thread#join/value in a callback routine.
(e.g. TkButton.new(:command=>proc{p Thread.new{button.invoke}.value}) )
'mainloop_watchdog' can treat them, but watchdog thread is always running
(so, a little heavier than 'mainloop').
If the purpose of using Thread#join/value is to do something under some
safe-level, please use Proc object.
(e.g. :command=>proc{$SAFE=1;proc{$SAFE=2;button.invoke}.call;p $SAFE})
* tk.rb: Support functions of new 'mainloop' and 'mainloop_watchdog'.
* tk.rb: (Tk.restart) Add 'app-name' paramater and 'use' parameter.
'app-name' specifies the name and the resource class of the
application. If 'app-name' is specified to 'xxx', the application
class on the resource database is set to 'Xxx' and the application
name is changed by the same rule of Tk.appname method. 'use'
specifies the main window for embedding the root widget instead of
generating a new window.
* tk.rb: Add new parameter 'widgetname' to the widget constructor to
support effective use of Resource Database. For example, the
resource 'Xxx*quit.text: QUIT' can set the text of the button
generated by the following code.
e.g.
Tk.restart('Xxx')
TkButton.new(nil, 'widgetname'=>'quit', 'command'=>proc{exit}).pack
Tk.mainloop
* tk.rb: TkOption::get always returns a tainted string.
Add TkOption::new_proc_class.
It generates a class to import procedures defined on the resource
database. For example, there is a following resource file.
----< resource-test >------------
*CMD.foo: {|*args| p [$SAFE, :foo, args]}
*CMD.XXX.bar: {|*args| p [$SAFE, :bar, args]}
*Button.command: ruby {p self; p $SAFE; TkOption::CMD::XXX.bar(1,2,3)}
---------------------------------
The following code is a sample of use of the resource file.
e.g.
require 'tk'
TkOption.readfile 'resource-test'
p TkOption.new_proc_class(:CMD, [:foo], 1)
p TkOption.new_proc_class(:XXX, [:bar], 2, false, TkOption::CMD)
TkButton.new(:text=>'test').pack
Tk.mainloop
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2515 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2002-06-04 11:03:33 +04:00
|
|
|
tmp->argv = alloc_argv;
|
|
|
|
tmp->result = alloc_result;
|
|
|
|
tmp->thread = current;
|
|
|
|
tmp->safe_level = rb_safe_level();
|
|
|
|
tmp->ev.proc = invoke_queue_handler;
|
|
|
|
position = TCL_QUEUE_TAIL;
|
1999-08-13 09:37:52 +04:00
|
|
|
|
* tkfont.rb: Fix bugs on TkFont.init_widget_font for Tk8.x.
* tkafter.rb: Add self to 1st argument of interval- and loop-proc
TkAfter#current_interval returns an interval (sleep) time value
TkAfter#current_args returns an array of arguments
TkAfter#return_value returns a return value of last loop-proc
e.g.
TkAfter.new(
proc{|obj| 500 - obj.current_interval}, 10,
[proc{|obj| p obj.current_args}, 'proc', 1],
proc{|obj| p obj.current_args; ['return', 2]},
[proc{|obj|
p obj.return_value
p ['proc', obj.current_args[0].call(obj.return_value[1],
obj.current_args[1])]},
proc{|*args| args[0] + args[1]}, 1],
proc{p ['proc', 4]} ).start(100)
* tk*.rb: Allow to use Symbols for parameters.
Allow new notation of constructor (also allow old notation).
e.g.
TkFrame.new('classname'=>'User'){|base|
pack
f = TkFrame.new(base, :classname=>'ButtonFrame').pack
TkButton.new(
:parent => f,
:text => 'Quit',
:command => proc{exit}
).pack(
:fill => :x,
:pady => 2
)
}
* tkcanvas.rb: (TkcItem) Add 'coords' parameter to the canvas item
constructor (for new notation of constructor).
e.g.
c = TkCanvas.new.pack
l = TkcLine.new(c, :coords=>[[0,0], [100,100]])
* tcltklib.c: New 'mainloop' and 'mainloop_watchdog'.
The priority of their event-loop can be controlled.
They accept an optional argument.
If it false, they don't exit although the root widget is destroyed.
This function is sometimes useful, if it is used with 'restart'.
'mainloop' can't treat Thread#join/value in a callback routine.
(e.g. TkButton.new(:command=>proc{p Thread.new{button.invoke}.value}) )
'mainloop_watchdog' can treat them, but watchdog thread is always running
(so, a little heavier than 'mainloop').
If the purpose of using Thread#join/value is to do something under some
safe-level, please use Proc object.
(e.g. :command=>proc{$SAFE=1;proc{$SAFE=2;button.invoke}.call;p $SAFE})
* tk.rb: Support functions of new 'mainloop' and 'mainloop_watchdog'.
* tk.rb: (Tk.restart) Add 'app-name' paramater and 'use' parameter.
'app-name' specifies the name and the resource class of the
application. If 'app-name' is specified to 'xxx', the application
class on the resource database is set to 'Xxx' and the application
name is changed by the same rule of Tk.appname method. 'use'
specifies the main window for embedding the root widget instead of
generating a new window.
* tk.rb: Add new parameter 'widgetname' to the widget constructor to
support effective use of Resource Database. For example, the
resource 'Xxx*quit.text: QUIT' can set the text of the button
generated by the following code.
e.g.
Tk.restart('Xxx')
TkButton.new(nil, 'widgetname'=>'quit', 'command'=>proc{exit}).pack
Tk.mainloop
* tk.rb: TkOption::get always returns a tainted string.
Add TkOption::new_proc_class.
It generates a class to import procedures defined on the resource
database. For example, there is a following resource file.
----< resource-test >------------
*CMD.foo: {|*args| p [$SAFE, :foo, args]}
*CMD.XXX.bar: {|*args| p [$SAFE, :bar, args]}
*Button.command: ruby {p self; p $SAFE; TkOption::CMD::XXX.bar(1,2,3)}
---------------------------------
The following code is a sample of use of the resource file.
e.g.
require 'tk'
TkOption.readfile 'resource-test'
p TkOption.new_proc_class(:CMD, [:foo], 1)
p TkOption.new_proc_class(:XXX, [:bar], 2, false, TkOption::CMD)
TkButton.new(:text=>'test').pack
Tk.mainloop
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2515 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2002-06-04 11:03:33 +04:00
|
|
|
/* add the handler to Tcl event queue */
|
2003-10-14 19:25:45 +04:00
|
|
|
DUMP1("add handler");
|
|
|
|
Tcl_QueueEvent(&(tmp->ev), position);
|
1999-08-13 09:37:52 +04:00
|
|
|
|
* tkfont.rb: Fix bugs on TkFont.init_widget_font for Tk8.x.
* tkafter.rb: Add self to 1st argument of interval- and loop-proc
TkAfter#current_interval returns an interval (sleep) time value
TkAfter#current_args returns an array of arguments
TkAfter#return_value returns a return value of last loop-proc
e.g.
TkAfter.new(
proc{|obj| 500 - obj.current_interval}, 10,
[proc{|obj| p obj.current_args}, 'proc', 1],
proc{|obj| p obj.current_args; ['return', 2]},
[proc{|obj|
p obj.return_value
p ['proc', obj.current_args[0].call(obj.return_value[1],
obj.current_args[1])]},
proc{|*args| args[0] + args[1]}, 1],
proc{p ['proc', 4]} ).start(100)
* tk*.rb: Allow to use Symbols for parameters.
Allow new notation of constructor (also allow old notation).
e.g.
TkFrame.new('classname'=>'User'){|base|
pack
f = TkFrame.new(base, :classname=>'ButtonFrame').pack
TkButton.new(
:parent => f,
:text => 'Quit',
:command => proc{exit}
).pack(
:fill => :x,
:pady => 2
)
}
* tkcanvas.rb: (TkcItem) Add 'coords' parameter to the canvas item
constructor (for new notation of constructor).
e.g.
c = TkCanvas.new.pack
l = TkcLine.new(c, :coords=>[[0,0], [100,100]])
* tcltklib.c: New 'mainloop' and 'mainloop_watchdog'.
The priority of their event-loop can be controlled.
They accept an optional argument.
If it false, they don't exit although the root widget is destroyed.
This function is sometimes useful, if it is used with 'restart'.
'mainloop' can't treat Thread#join/value in a callback routine.
(e.g. TkButton.new(:command=>proc{p Thread.new{button.invoke}.value}) )
'mainloop_watchdog' can treat them, but watchdog thread is always running
(so, a little heavier than 'mainloop').
If the purpose of using Thread#join/value is to do something under some
safe-level, please use Proc object.
(e.g. :command=>proc{$SAFE=1;proc{$SAFE=2;button.invoke}.call;p $SAFE})
* tk.rb: Support functions of new 'mainloop' and 'mainloop_watchdog'.
* tk.rb: (Tk.restart) Add 'app-name' paramater and 'use' parameter.
'app-name' specifies the name and the resource class of the
application. If 'app-name' is specified to 'xxx', the application
class on the resource database is set to 'Xxx' and the application
name is changed by the same rule of Tk.appname method. 'use'
specifies the main window for embedding the root widget instead of
generating a new window.
* tk.rb: Add new parameter 'widgetname' to the widget constructor to
support effective use of Resource Database. For example, the
resource 'Xxx*quit.text: QUIT' can set the text of the button
generated by the following code.
e.g.
Tk.restart('Xxx')
TkButton.new(nil, 'widgetname'=>'quit', 'command'=>proc{exit}).pack
Tk.mainloop
* tk.rb: TkOption::get always returns a tainted string.
Add TkOption::new_proc_class.
It generates a class to import procedures defined on the resource
database. For example, there is a following resource file.
----< resource-test >------------
*CMD.foo: {|*args| p [$SAFE, :foo, args]}
*CMD.XXX.bar: {|*args| p [$SAFE, :bar, args]}
*Button.command: ruby {p self; p $SAFE; TkOption::CMD::XXX.bar(1,2,3)}
---------------------------------
The following code is a sample of use of the resource file.
e.g.
require 'tk'
TkOption.readfile 'resource-test'
p TkOption.new_proc_class(:CMD, [:foo], 1)
p TkOption.new_proc_class(:XXX, [:bar], 2, false, TkOption::CMD)
TkButton.new(:text=>'test').pack
Tk.mainloop
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2515 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2002-06-04 11:03:33 +04:00
|
|
|
/* wait for the handler to be processed */
|
2003-10-14 19:25:45 +04:00
|
|
|
DUMP2("wait for handler (current thread:%lx)", current);
|
1999-08-13 09:37:52 +04:00
|
|
|
rb_thread_stop();
|
2003-10-14 19:25:45 +04:00
|
|
|
DUMP2("back from handler (current thread:%lx)", current);
|
1999-08-13 09:37:52 +04:00
|
|
|
|
* tkfont.rb: Fix bugs on TkFont.init_widget_font for Tk8.x.
* tkafter.rb: Add self to 1st argument of interval- and loop-proc
TkAfter#current_interval returns an interval (sleep) time value
TkAfter#current_args returns an array of arguments
TkAfter#return_value returns a return value of last loop-proc
e.g.
TkAfter.new(
proc{|obj| 500 - obj.current_interval}, 10,
[proc{|obj| p obj.current_args}, 'proc', 1],
proc{|obj| p obj.current_args; ['return', 2]},
[proc{|obj|
p obj.return_value
p ['proc', obj.current_args[0].call(obj.return_value[1],
obj.current_args[1])]},
proc{|*args| args[0] + args[1]}, 1],
proc{p ['proc', 4]} ).start(100)
* tk*.rb: Allow to use Symbols for parameters.
Allow new notation of constructor (also allow old notation).
e.g.
TkFrame.new('classname'=>'User'){|base|
pack
f = TkFrame.new(base, :classname=>'ButtonFrame').pack
TkButton.new(
:parent => f,
:text => 'Quit',
:command => proc{exit}
).pack(
:fill => :x,
:pady => 2
)
}
* tkcanvas.rb: (TkcItem) Add 'coords' parameter to the canvas item
constructor (for new notation of constructor).
e.g.
c = TkCanvas.new.pack
l = TkcLine.new(c, :coords=>[[0,0], [100,100]])
* tcltklib.c: New 'mainloop' and 'mainloop_watchdog'.
The priority of their event-loop can be controlled.
They accept an optional argument.
If it false, they don't exit although the root widget is destroyed.
This function is sometimes useful, if it is used with 'restart'.
'mainloop' can't treat Thread#join/value in a callback routine.
(e.g. TkButton.new(:command=>proc{p Thread.new{button.invoke}.value}) )
'mainloop_watchdog' can treat them, but watchdog thread is always running
(so, a little heavier than 'mainloop').
If the purpose of using Thread#join/value is to do something under some
safe-level, please use Proc object.
(e.g. :command=>proc{$SAFE=1;proc{$SAFE=2;button.invoke}.call;p $SAFE})
* tk.rb: Support functions of new 'mainloop' and 'mainloop_watchdog'.
* tk.rb: (Tk.restart) Add 'app-name' paramater and 'use' parameter.
'app-name' specifies the name and the resource class of the
application. If 'app-name' is specified to 'xxx', the application
class on the resource database is set to 'Xxx' and the application
name is changed by the same rule of Tk.appname method. 'use'
specifies the main window for embedding the root widget instead of
generating a new window.
* tk.rb: Add new parameter 'widgetname' to the widget constructor to
support effective use of Resource Database. For example, the
resource 'Xxx*quit.text: QUIT' can set the text of the button
generated by the following code.
e.g.
Tk.restart('Xxx')
TkButton.new(nil, 'widgetname'=>'quit', 'command'=>proc{exit}).pack
Tk.mainloop
* tk.rb: TkOption::get always returns a tainted string.
Add TkOption::new_proc_class.
It generates a class to import procedures defined on the resource
database. For example, there is a following resource file.
----< resource-test >------------
*CMD.foo: {|*args| p [$SAFE, :foo, args]}
*CMD.XXX.bar: {|*args| p [$SAFE, :bar, args]}
*Button.command: ruby {p self; p $SAFE; TkOption::CMD::XXX.bar(1,2,3)}
---------------------------------
The following code is a sample of use of the resource file.
e.g.
require 'tk'
TkOption.readfile 'resource-test'
p TkOption.new_proc_class(:CMD, [:foo], 1)
p TkOption.new_proc_class(:XXX, [:bar], 2, false, TkOption::CMD)
TkButton.new(:text=>'test').pack
Tk.mainloop
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2515 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2002-06-04 11:03:33 +04:00
|
|
|
/* get result & free allocated memory */
|
|
|
|
result = *alloc_result;
|
|
|
|
free(alloc_argv);
|
|
|
|
free(alloc_result);
|
2003-09-07 11:10:44 +04:00
|
|
|
if (rb_obj_is_kind_of(result, rb_eException)) {
|
|
|
|
rb_exc_raise(result);
|
|
|
|
}
|
* tkfont.rb: Fix bugs on TkFont.init_widget_font for Tk8.x.
* tkafter.rb: Add self to 1st argument of interval- and loop-proc
TkAfter#current_interval returns an interval (sleep) time value
TkAfter#current_args returns an array of arguments
TkAfter#return_value returns a return value of last loop-proc
e.g.
TkAfter.new(
proc{|obj| 500 - obj.current_interval}, 10,
[proc{|obj| p obj.current_args}, 'proc', 1],
proc{|obj| p obj.current_args; ['return', 2]},
[proc{|obj|
p obj.return_value
p ['proc', obj.current_args[0].call(obj.return_value[1],
obj.current_args[1])]},
proc{|*args| args[0] + args[1]}, 1],
proc{p ['proc', 4]} ).start(100)
* tk*.rb: Allow to use Symbols for parameters.
Allow new notation of constructor (also allow old notation).
e.g.
TkFrame.new('classname'=>'User'){|base|
pack
f = TkFrame.new(base, :classname=>'ButtonFrame').pack
TkButton.new(
:parent => f,
:text => 'Quit',
:command => proc{exit}
).pack(
:fill => :x,
:pady => 2
)
}
* tkcanvas.rb: (TkcItem) Add 'coords' parameter to the canvas item
constructor (for new notation of constructor).
e.g.
c = TkCanvas.new.pack
l = TkcLine.new(c, :coords=>[[0,0], [100,100]])
* tcltklib.c: New 'mainloop' and 'mainloop_watchdog'.
The priority of their event-loop can be controlled.
They accept an optional argument.
If it false, they don't exit although the root widget is destroyed.
This function is sometimes useful, if it is used with 'restart'.
'mainloop' can't treat Thread#join/value in a callback routine.
(e.g. TkButton.new(:command=>proc{p Thread.new{button.invoke}.value}) )
'mainloop_watchdog' can treat them, but watchdog thread is always running
(so, a little heavier than 'mainloop').
If the purpose of using Thread#join/value is to do something under some
safe-level, please use Proc object.
(e.g. :command=>proc{$SAFE=1;proc{$SAFE=2;button.invoke}.call;p $SAFE})
* tk.rb: Support functions of new 'mainloop' and 'mainloop_watchdog'.
* tk.rb: (Tk.restart) Add 'app-name' paramater and 'use' parameter.
'app-name' specifies the name and the resource class of the
application. If 'app-name' is specified to 'xxx', the application
class on the resource database is set to 'Xxx' and the application
name is changed by the same rule of Tk.appname method. 'use'
specifies the main window for embedding the root widget instead of
generating a new window.
* tk.rb: Add new parameter 'widgetname' to the widget constructor to
support effective use of Resource Database. For example, the
resource 'Xxx*quit.text: QUIT' can set the text of the button
generated by the following code.
e.g.
Tk.restart('Xxx')
TkButton.new(nil, 'widgetname'=>'quit', 'command'=>proc{exit}).pack
Tk.mainloop
* tk.rb: TkOption::get always returns a tainted string.
Add TkOption::new_proc_class.
It generates a class to import procedures defined on the resource
database. For example, there is a following resource file.
----< resource-test >------------
*CMD.foo: {|*args| p [$SAFE, :foo, args]}
*CMD.XXX.bar: {|*args| p [$SAFE, :bar, args]}
*Button.command: ruby {p self; p $SAFE; TkOption::CMD::XXX.bar(1,2,3)}
---------------------------------
The following code is a sample of use of the resource file.
e.g.
require 'tk'
TkOption.readfile 'resource-test'
p TkOption.new_proc_class(:CMD, [:foo], 1)
p TkOption.new_proc_class(:XXX, [:bar], 2, false, TkOption::CMD)
TkButton.new(:text=>'test').pack
Tk.mainloop
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2515 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2002-06-04 11:03:33 +04:00
|
|
|
|
1999-08-13 09:37:52 +04:00
|
|
|
return result;
|
1998-01-16 15:19:09 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/* get return code from Tcl_Eval() */
|
|
|
|
static VALUE
|
1999-08-13 09:37:52 +04:00
|
|
|
ip_retval(self)
|
|
|
|
VALUE self;
|
1998-01-16 15:19:09 +03:00
|
|
|
{
|
|
|
|
struct tcltkip *ptr; /* tcltkip data struct */
|
|
|
|
|
|
|
|
/* get the data strcut */
|
2002-08-19 09:56:09 +04:00
|
|
|
ptr = get_ip(self);
|
1998-01-16 15:19:09 +03:00
|
|
|
|
|
|
|
return (INT2FIX(ptr->return_value));
|
|
|
|
}
|
|
|
|
|
1999-01-20 07:59:39 +03:00
|
|
|
#ifdef __MACOS__
|
|
|
|
static void
|
|
|
|
_macinit()
|
|
|
|
{
|
1999-08-13 09:37:52 +04:00
|
|
|
tcl_macQdPtr = &qd; /* setup QuickDraw globals */
|
|
|
|
Tcl_MacSetEventProc(TkMacConvertEvent); /* setup event handler */
|
1999-01-20 07:59:39 +03:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
1998-01-16 15:19:09 +03:00
|
|
|
/*---- initialization ----*/
|
1999-08-13 09:37:52 +04:00
|
|
|
void
|
|
|
|
Init_tcltklib()
|
1998-01-16 15:19:09 +03:00
|
|
|
{
|
|
|
|
VALUE lib = rb_define_module("TclTkLib");
|
1999-01-20 07:59:39 +03:00
|
|
|
VALUE ip = rb_define_class("TclTkIp", rb_cObject);
|
|
|
|
|
* tkfont.rb: Fix bugs on TkFont.init_widget_font for Tk8.x.
* tkafter.rb: Add self to 1st argument of interval- and loop-proc
TkAfter#current_interval returns an interval (sleep) time value
TkAfter#current_args returns an array of arguments
TkAfter#return_value returns a return value of last loop-proc
e.g.
TkAfter.new(
proc{|obj| 500 - obj.current_interval}, 10,
[proc{|obj| p obj.current_args}, 'proc', 1],
proc{|obj| p obj.current_args; ['return', 2]},
[proc{|obj|
p obj.return_value
p ['proc', obj.current_args[0].call(obj.return_value[1],
obj.current_args[1])]},
proc{|*args| args[0] + args[1]}, 1],
proc{p ['proc', 4]} ).start(100)
* tk*.rb: Allow to use Symbols for parameters.
Allow new notation of constructor (also allow old notation).
e.g.
TkFrame.new('classname'=>'User'){|base|
pack
f = TkFrame.new(base, :classname=>'ButtonFrame').pack
TkButton.new(
:parent => f,
:text => 'Quit',
:command => proc{exit}
).pack(
:fill => :x,
:pady => 2
)
}
* tkcanvas.rb: (TkcItem) Add 'coords' parameter to the canvas item
constructor (for new notation of constructor).
e.g.
c = TkCanvas.new.pack
l = TkcLine.new(c, :coords=>[[0,0], [100,100]])
* tcltklib.c: New 'mainloop' and 'mainloop_watchdog'.
The priority of their event-loop can be controlled.
They accept an optional argument.
If it false, they don't exit although the root widget is destroyed.
This function is sometimes useful, if it is used with 'restart'.
'mainloop' can't treat Thread#join/value in a callback routine.
(e.g. TkButton.new(:command=>proc{p Thread.new{button.invoke}.value}) )
'mainloop_watchdog' can treat them, but watchdog thread is always running
(so, a little heavier than 'mainloop').
If the purpose of using Thread#join/value is to do something under some
safe-level, please use Proc object.
(e.g. :command=>proc{$SAFE=1;proc{$SAFE=2;button.invoke}.call;p $SAFE})
* tk.rb: Support functions of new 'mainloop' and 'mainloop_watchdog'.
* tk.rb: (Tk.restart) Add 'app-name' paramater and 'use' parameter.
'app-name' specifies the name and the resource class of the
application. If 'app-name' is specified to 'xxx', the application
class on the resource database is set to 'Xxx' and the application
name is changed by the same rule of Tk.appname method. 'use'
specifies the main window for embedding the root widget instead of
generating a new window.
* tk.rb: Add new parameter 'widgetname' to the widget constructor to
support effective use of Resource Database. For example, the
resource 'Xxx*quit.text: QUIT' can set the text of the button
generated by the following code.
e.g.
Tk.restart('Xxx')
TkButton.new(nil, 'widgetname'=>'quit', 'command'=>proc{exit}).pack
Tk.mainloop
* tk.rb: TkOption::get always returns a tainted string.
Add TkOption::new_proc_class.
It generates a class to import procedures defined on the resource
database. For example, there is a following resource file.
----< resource-test >------------
*CMD.foo: {|*args| p [$SAFE, :foo, args]}
*CMD.XXX.bar: {|*args| p [$SAFE, :bar, args]}
*Button.command: ruby {p self; p $SAFE; TkOption::CMD::XXX.bar(1,2,3)}
---------------------------------
The following code is a sample of use of the resource file.
e.g.
require 'tk'
TkOption.readfile 'resource-test'
p TkOption.new_proc_class(:CMD, [:foo], 1)
p TkOption.new_proc_class(:XXX, [:bar], 2, false, TkOption::CMD)
TkButton.new(:text=>'test').pack
Tk.mainloop
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2515 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2002-06-04 11:03:33 +04:00
|
|
|
VALUE ev_flag = rb_define_module_under(lib, "EventFlag");
|
|
|
|
|
2000-08-08 09:06:24 +04:00
|
|
|
#if defined USE_TCL_STUBS && defined USE_TK_STUBS
|
|
|
|
extern int ruby_tcltk_stubs();
|
|
|
|
int ret = ruby_tcltk_stubs();
|
|
|
|
if (ret)
|
|
|
|
rb_raise(rb_eLoadError, "tcltklib: tcltk_stubs init error(%d)", ret);
|
|
|
|
#endif
|
|
|
|
|
2003-06-19 20:14:43 +04:00
|
|
|
rb_define_const(ev_flag, "NONE", INT2FIX(0));
|
2002-06-04 12:03:43 +04:00
|
|
|
rb_define_const(ev_flag, "WINDOW", INT2FIX(TCL_WINDOW_EVENTS));
|
|
|
|
rb_define_const(ev_flag, "FILE", INT2FIX(TCL_FILE_EVENTS));
|
|
|
|
rb_define_const(ev_flag, "TIMER", INT2FIX(TCL_TIMER_EVENTS));
|
|
|
|
rb_define_const(ev_flag, "IDLE", INT2FIX(TCL_IDLE_EVENTS));
|
|
|
|
rb_define_const(ev_flag, "ALL", INT2FIX(TCL_ALL_EVENTS));
|
|
|
|
rb_define_const(ev_flag, "DONT_WAIT", INT2FIX(TCL_DONT_WAIT));
|
|
|
|
|
1999-01-20 07:59:39 +03:00
|
|
|
eTkCallbackBreak = rb_define_class("TkCallbackBreak", rb_eStandardError);
|
2003-06-19 20:14:43 +04:00
|
|
|
eTkCallbackContinue = rb_define_class("TkCallbackContinue",
|
|
|
|
rb_eStandardError);
|
1998-01-16 15:19:09 +03:00
|
|
|
|
* tkfont.rb: Fix bugs on TkFont.init_widget_font for Tk8.x.
* tkafter.rb: Add self to 1st argument of interval- and loop-proc
TkAfter#current_interval returns an interval (sleep) time value
TkAfter#current_args returns an array of arguments
TkAfter#return_value returns a return value of last loop-proc
e.g.
TkAfter.new(
proc{|obj| 500 - obj.current_interval}, 10,
[proc{|obj| p obj.current_args}, 'proc', 1],
proc{|obj| p obj.current_args; ['return', 2]},
[proc{|obj|
p obj.return_value
p ['proc', obj.current_args[0].call(obj.return_value[1],
obj.current_args[1])]},
proc{|*args| args[0] + args[1]}, 1],
proc{p ['proc', 4]} ).start(100)
* tk*.rb: Allow to use Symbols for parameters.
Allow new notation of constructor (also allow old notation).
e.g.
TkFrame.new('classname'=>'User'){|base|
pack
f = TkFrame.new(base, :classname=>'ButtonFrame').pack
TkButton.new(
:parent => f,
:text => 'Quit',
:command => proc{exit}
).pack(
:fill => :x,
:pady => 2
)
}
* tkcanvas.rb: (TkcItem) Add 'coords' parameter to the canvas item
constructor (for new notation of constructor).
e.g.
c = TkCanvas.new.pack
l = TkcLine.new(c, :coords=>[[0,0], [100,100]])
* tcltklib.c: New 'mainloop' and 'mainloop_watchdog'.
The priority of their event-loop can be controlled.
They accept an optional argument.
If it false, they don't exit although the root widget is destroyed.
This function is sometimes useful, if it is used with 'restart'.
'mainloop' can't treat Thread#join/value in a callback routine.
(e.g. TkButton.new(:command=>proc{p Thread.new{button.invoke}.value}) )
'mainloop_watchdog' can treat them, but watchdog thread is always running
(so, a little heavier than 'mainloop').
If the purpose of using Thread#join/value is to do something under some
safe-level, please use Proc object.
(e.g. :command=>proc{$SAFE=1;proc{$SAFE=2;button.invoke}.call;p $SAFE})
* tk.rb: Support functions of new 'mainloop' and 'mainloop_watchdog'.
* tk.rb: (Tk.restart) Add 'app-name' paramater and 'use' parameter.
'app-name' specifies the name and the resource class of the
application. If 'app-name' is specified to 'xxx', the application
class on the resource database is set to 'Xxx' and the application
name is changed by the same rule of Tk.appname method. 'use'
specifies the main window for embedding the root widget instead of
generating a new window.
* tk.rb: Add new parameter 'widgetname' to the widget constructor to
support effective use of Resource Database. For example, the
resource 'Xxx*quit.text: QUIT' can set the text of the button
generated by the following code.
e.g.
Tk.restart('Xxx')
TkButton.new(nil, 'widgetname'=>'quit', 'command'=>proc{exit}).pack
Tk.mainloop
* tk.rb: TkOption::get always returns a tainted string.
Add TkOption::new_proc_class.
It generates a class to import procedures defined on the resource
database. For example, there is a following resource file.
----< resource-test >------------
*CMD.foo: {|*args| p [$SAFE, :foo, args]}
*CMD.XXX.bar: {|*args| p [$SAFE, :bar, args]}
*Button.command: ruby {p self; p $SAFE; TkOption::CMD::XXX.bar(1,2,3)}
---------------------------------
The following code is a sample of use of the resource file.
e.g.
require 'tk'
TkOption.readfile 'resource-test'
p TkOption.new_proc_class(:CMD, [:foo], 1)
p TkOption.new_proc_class(:XXX, [:bar], 2, false, TkOption::CMD)
TkButton.new(:text=>'test').pack
Tk.mainloop
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2515 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2002-06-04 11:03:33 +04:00
|
|
|
rb_define_module_function(lib, "mainloop", lib_mainloop, -1);
|
|
|
|
rb_define_module_function(lib, "mainloop_watchdog",
|
|
|
|
lib_mainloop_watchdog, -1);
|
|
|
|
rb_define_module_function(lib, "do_one_event", lib_do_one_event, -1);
|
2003-08-29 12:34:14 +04:00
|
|
|
rb_define_module_function(lib, "mainloop_abort_on_exception",
|
|
|
|
lib_evloop_abort_on_exc, 0);
|
|
|
|
rb_define_module_function(lib, "mainloop_abort_on_exception=",
|
|
|
|
lib_evloop_abort_on_exc_set, 1);
|
* tkfont.rb: Fix bugs on TkFont.init_widget_font for Tk8.x.
* tkafter.rb: Add self to 1st argument of interval- and loop-proc
TkAfter#current_interval returns an interval (sleep) time value
TkAfter#current_args returns an array of arguments
TkAfter#return_value returns a return value of last loop-proc
e.g.
TkAfter.new(
proc{|obj| 500 - obj.current_interval}, 10,
[proc{|obj| p obj.current_args}, 'proc', 1],
proc{|obj| p obj.current_args; ['return', 2]},
[proc{|obj|
p obj.return_value
p ['proc', obj.current_args[0].call(obj.return_value[1],
obj.current_args[1])]},
proc{|*args| args[0] + args[1]}, 1],
proc{p ['proc', 4]} ).start(100)
* tk*.rb: Allow to use Symbols for parameters.
Allow new notation of constructor (also allow old notation).
e.g.
TkFrame.new('classname'=>'User'){|base|
pack
f = TkFrame.new(base, :classname=>'ButtonFrame').pack
TkButton.new(
:parent => f,
:text => 'Quit',
:command => proc{exit}
).pack(
:fill => :x,
:pady => 2
)
}
* tkcanvas.rb: (TkcItem) Add 'coords' parameter to the canvas item
constructor (for new notation of constructor).
e.g.
c = TkCanvas.new.pack
l = TkcLine.new(c, :coords=>[[0,0], [100,100]])
* tcltklib.c: New 'mainloop' and 'mainloop_watchdog'.
The priority of their event-loop can be controlled.
They accept an optional argument.
If it false, they don't exit although the root widget is destroyed.
This function is sometimes useful, if it is used with 'restart'.
'mainloop' can't treat Thread#join/value in a callback routine.
(e.g. TkButton.new(:command=>proc{p Thread.new{button.invoke}.value}) )
'mainloop_watchdog' can treat them, but watchdog thread is always running
(so, a little heavier than 'mainloop').
If the purpose of using Thread#join/value is to do something under some
safe-level, please use Proc object.
(e.g. :command=>proc{$SAFE=1;proc{$SAFE=2;button.invoke}.call;p $SAFE})
* tk.rb: Support functions of new 'mainloop' and 'mainloop_watchdog'.
* tk.rb: (Tk.restart) Add 'app-name' paramater and 'use' parameter.
'app-name' specifies the name and the resource class of the
application. If 'app-name' is specified to 'xxx', the application
class on the resource database is set to 'Xxx' and the application
name is changed by the same rule of Tk.appname method. 'use'
specifies the main window for embedding the root widget instead of
generating a new window.
* tk.rb: Add new parameter 'widgetname' to the widget constructor to
support effective use of Resource Database. For example, the
resource 'Xxx*quit.text: QUIT' can set the text of the button
generated by the following code.
e.g.
Tk.restart('Xxx')
TkButton.new(nil, 'widgetname'=>'quit', 'command'=>proc{exit}).pack
Tk.mainloop
* tk.rb: TkOption::get always returns a tainted string.
Add TkOption::new_proc_class.
It generates a class to import procedures defined on the resource
database. For example, there is a following resource file.
----< resource-test >------------
*CMD.foo: {|*args| p [$SAFE, :foo, args]}
*CMD.XXX.bar: {|*args| p [$SAFE, :bar, args]}
*Button.command: ruby {p self; p $SAFE; TkOption::CMD::XXX.bar(1,2,3)}
---------------------------------
The following code is a sample of use of the resource file.
e.g.
require 'tk'
TkOption.readfile 'resource-test'
p TkOption.new_proc_class(:CMD, [:foo], 1)
p TkOption.new_proc_class(:XXX, [:bar], 2, false, TkOption::CMD)
TkButton.new(:text=>'test').pack
Tk.mainloop
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2515 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2002-06-04 11:03:33 +04:00
|
|
|
rb_define_module_function(lib, "set_eventloop_tick",set_eventloop_tick,1);
|
|
|
|
rb_define_module_function(lib, "get_eventloop_tick",get_eventloop_tick,0);
|
2003-06-19 20:14:43 +04:00
|
|
|
rb_define_module_function(lib, "set_no_event_wait", set_no_event_wait, 1);
|
|
|
|
rb_define_module_function(lib, "get_no_event_wait", get_no_event_wait, 0);
|
* tkfont.rb: Fix bugs on TkFont.init_widget_font for Tk8.x.
* tkafter.rb: Add self to 1st argument of interval- and loop-proc
TkAfter#current_interval returns an interval (sleep) time value
TkAfter#current_args returns an array of arguments
TkAfter#return_value returns a return value of last loop-proc
e.g.
TkAfter.new(
proc{|obj| 500 - obj.current_interval}, 10,
[proc{|obj| p obj.current_args}, 'proc', 1],
proc{|obj| p obj.current_args; ['return', 2]},
[proc{|obj|
p obj.return_value
p ['proc', obj.current_args[0].call(obj.return_value[1],
obj.current_args[1])]},
proc{|*args| args[0] + args[1]}, 1],
proc{p ['proc', 4]} ).start(100)
* tk*.rb: Allow to use Symbols for parameters.
Allow new notation of constructor (also allow old notation).
e.g.
TkFrame.new('classname'=>'User'){|base|
pack
f = TkFrame.new(base, :classname=>'ButtonFrame').pack
TkButton.new(
:parent => f,
:text => 'Quit',
:command => proc{exit}
).pack(
:fill => :x,
:pady => 2
)
}
* tkcanvas.rb: (TkcItem) Add 'coords' parameter to the canvas item
constructor (for new notation of constructor).
e.g.
c = TkCanvas.new.pack
l = TkcLine.new(c, :coords=>[[0,0], [100,100]])
* tcltklib.c: New 'mainloop' and 'mainloop_watchdog'.
The priority of their event-loop can be controlled.
They accept an optional argument.
If it false, they don't exit although the root widget is destroyed.
This function is sometimes useful, if it is used with 'restart'.
'mainloop' can't treat Thread#join/value in a callback routine.
(e.g. TkButton.new(:command=>proc{p Thread.new{button.invoke}.value}) )
'mainloop_watchdog' can treat them, but watchdog thread is always running
(so, a little heavier than 'mainloop').
If the purpose of using Thread#join/value is to do something under some
safe-level, please use Proc object.
(e.g. :command=>proc{$SAFE=1;proc{$SAFE=2;button.invoke}.call;p $SAFE})
* tk.rb: Support functions of new 'mainloop' and 'mainloop_watchdog'.
* tk.rb: (Tk.restart) Add 'app-name' paramater and 'use' parameter.
'app-name' specifies the name and the resource class of the
application. If 'app-name' is specified to 'xxx', the application
class on the resource database is set to 'Xxx' and the application
name is changed by the same rule of Tk.appname method. 'use'
specifies the main window for embedding the root widget instead of
generating a new window.
* tk.rb: Add new parameter 'widgetname' to the widget constructor to
support effective use of Resource Database. For example, the
resource 'Xxx*quit.text: QUIT' can set the text of the button
generated by the following code.
e.g.
Tk.restart('Xxx')
TkButton.new(nil, 'widgetname'=>'quit', 'command'=>proc{exit}).pack
Tk.mainloop
* tk.rb: TkOption::get always returns a tainted string.
Add TkOption::new_proc_class.
It generates a class to import procedures defined on the resource
database. For example, there is a following resource file.
----< resource-test >------------
*CMD.foo: {|*args| p [$SAFE, :foo, args]}
*CMD.XXX.bar: {|*args| p [$SAFE, :bar, args]}
*Button.command: ruby {p self; p $SAFE; TkOption::CMD::XXX.bar(1,2,3)}
---------------------------------
The following code is a sample of use of the resource file.
e.g.
require 'tk'
TkOption.readfile 'resource-test'
p TkOption.new_proc_class(:CMD, [:foo], 1)
p TkOption.new_proc_class(:XXX, [:bar], 2, false, TkOption::CMD)
TkButton.new(:text=>'test').pack
Tk.mainloop
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2515 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2002-06-04 11:03:33 +04:00
|
|
|
rb_define_module_function(lib, "set_eventloop_weight",
|
|
|
|
set_eventloop_weight, 2);
|
|
|
|
rb_define_module_function(lib, "get_eventloop_weight",
|
|
|
|
get_eventloop_weight, 0);
|
2003-08-29 12:34:14 +04:00
|
|
|
rb_define_module_function(lib, "num_of_mainwindows",
|
|
|
|
lib_num_of_mainwindows, 0);
|
1998-01-16 15:19:09 +03:00
|
|
|
|
* ext/curses/curses.c, ext/digest/digest.c, ext/dl/handle.c,
ext/dl/ptr.c, ext/dl/sym.c, ext/gdbm/gdbm.c, ext/iconv/iconv.c,
ext/stringio/stringio.c, ext/strscan/strscan.c,
ext/tcltklib/tcltklib.c, ext/win32ole/win32ole.c:
use rb_define_alloc_func().
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@3193 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2002-12-20 14:23:40 +03:00
|
|
|
rb_define_alloc_func(ip, ip_alloc);
|
2003-07-23 20:07:35 +04:00
|
|
|
rb_define_method(ip, "initialize", ip_init, -1);
|
2003-07-25 20:43:03 +04:00
|
|
|
rb_define_method(ip, "create_slave", ip_create_slave, -1);
|
|
|
|
rb_define_method(ip, "make_safe", ip_make_safe, 0);
|
|
|
|
rb_define_method(ip, "safe?", ip_is_safe_p, 0);
|
2003-07-27 23:35:06 +04:00
|
|
|
rb_define_method(ip, "delete", ip_delete, 0);
|
|
|
|
rb_define_method(ip, "deleted?", ip_is_deleted_p, 0);
|
1998-01-16 15:19:09 +03:00
|
|
|
rb_define_method(ip, "_eval", ip_eval, 1);
|
2003-10-14 19:25:45 +04:00
|
|
|
rb_define_method(ip, "_toUTF8",ip_toUTF8, 2);
|
|
|
|
rb_define_method(ip, "_fromUTF8",ip_fromUTF8, 2);
|
|
|
|
rb_define_method(ip, "_thread_vwait", ip_thread_vwait, 1);
|
|
|
|
rb_define_method(ip, "_thread_tkwait", ip_thread_tkwait, 2);
|
1999-01-20 07:59:39 +03:00
|
|
|
rb_define_method(ip, "_invoke", ip_invoke, -1);
|
1998-01-16 15:19:09 +03:00
|
|
|
rb_define_method(ip, "_return_value", ip_retval, 0);
|
2003-08-29 12:34:14 +04:00
|
|
|
|
|
|
|
rb_define_method(ip, "mainloop", ip_mainloop, -1);
|
|
|
|
rb_define_method(ip, "mainloop_watchdog", ip_mainloop_watchdog, -1);
|
|
|
|
rb_define_method(ip, "do_one_event", ip_do_one_event, -1);
|
2003-07-29 19:39:59 +04:00
|
|
|
rb_define_method(ip, "mainloop_abort_on_exception",
|
2003-08-29 12:34:14 +04:00
|
|
|
ip_evloop_abort_on_exc, 0);
|
2003-07-29 19:39:59 +04:00
|
|
|
rb_define_method(ip, "mainloop_abort_on_exception=",
|
2003-08-29 12:34:14 +04:00
|
|
|
ip_evloop_abort_on_exc_set, 1);
|
|
|
|
rb_define_method(ip, "set_eventloop_tick", ip_set_eventloop_tick, 1);
|
|
|
|
rb_define_method(ip, "get_eventloop_tick", ip_get_eventloop_tick, 0);
|
|
|
|
rb_define_method(ip, "set_no_event_wait", ip_set_no_event_wait, 1);
|
|
|
|
rb_define_method(ip, "get_no_event_wait", ip_get_no_event_wait, 0);
|
|
|
|
rb_define_method(ip, "set_eventloop_weight", ip_set_eventloop_weight, 2);
|
|
|
|
rb_define_method(ip, "get_eventloop_weight", ip_get_eventloop_weight, 0);
|
|
|
|
rb_define_method(ip, "restart", ip_restart, 0);
|
1998-01-16 15:19:09 +03:00
|
|
|
|
* tkfont.rb: Fix bugs on TkFont.init_widget_font for Tk8.x.
* tkafter.rb: Add self to 1st argument of interval- and loop-proc
TkAfter#current_interval returns an interval (sleep) time value
TkAfter#current_args returns an array of arguments
TkAfter#return_value returns a return value of last loop-proc
e.g.
TkAfter.new(
proc{|obj| 500 - obj.current_interval}, 10,
[proc{|obj| p obj.current_args}, 'proc', 1],
proc{|obj| p obj.current_args; ['return', 2]},
[proc{|obj|
p obj.return_value
p ['proc', obj.current_args[0].call(obj.return_value[1],
obj.current_args[1])]},
proc{|*args| args[0] + args[1]}, 1],
proc{p ['proc', 4]} ).start(100)
* tk*.rb: Allow to use Symbols for parameters.
Allow new notation of constructor (also allow old notation).
e.g.
TkFrame.new('classname'=>'User'){|base|
pack
f = TkFrame.new(base, :classname=>'ButtonFrame').pack
TkButton.new(
:parent => f,
:text => 'Quit',
:command => proc{exit}
).pack(
:fill => :x,
:pady => 2
)
}
* tkcanvas.rb: (TkcItem) Add 'coords' parameter to the canvas item
constructor (for new notation of constructor).
e.g.
c = TkCanvas.new.pack
l = TkcLine.new(c, :coords=>[[0,0], [100,100]])
* tcltklib.c: New 'mainloop' and 'mainloop_watchdog'.
The priority of their event-loop can be controlled.
They accept an optional argument.
If it false, they don't exit although the root widget is destroyed.
This function is sometimes useful, if it is used with 'restart'.
'mainloop' can't treat Thread#join/value in a callback routine.
(e.g. TkButton.new(:command=>proc{p Thread.new{button.invoke}.value}) )
'mainloop_watchdog' can treat them, but watchdog thread is always running
(so, a little heavier than 'mainloop').
If the purpose of using Thread#join/value is to do something under some
safe-level, please use Proc object.
(e.g. :command=>proc{$SAFE=1;proc{$SAFE=2;button.invoke}.call;p $SAFE})
* tk.rb: Support functions of new 'mainloop' and 'mainloop_watchdog'.
* tk.rb: (Tk.restart) Add 'app-name' paramater and 'use' parameter.
'app-name' specifies the name and the resource class of the
application. If 'app-name' is specified to 'xxx', the application
class on the resource database is set to 'Xxx' and the application
name is changed by the same rule of Tk.appname method. 'use'
specifies the main window for embedding the root widget instead of
generating a new window.
* tk.rb: Add new parameter 'widgetname' to the widget constructor to
support effective use of Resource Database. For example, the
resource 'Xxx*quit.text: QUIT' can set the text of the button
generated by the following code.
e.g.
Tk.restart('Xxx')
TkButton.new(nil, 'widgetname'=>'quit', 'command'=>proc{exit}).pack
Tk.mainloop
* tk.rb: TkOption::get always returns a tainted string.
Add TkOption::new_proc_class.
It generates a class to import procedures defined on the resource
database. For example, there is a following resource file.
----< resource-test >------------
*CMD.foo: {|*args| p [$SAFE, :foo, args]}
*CMD.XXX.bar: {|*args| p [$SAFE, :bar, args]}
*Button.command: ruby {p self; p $SAFE; TkOption::CMD::XXX.bar(1,2,3)}
---------------------------------
The following code is a sample of use of the resource file.
e.g.
require 'tk'
TkOption.readfile 'resource-test'
p TkOption.new_proc_class(:CMD, [:foo], 1)
p TkOption.new_proc_class(:XXX, [:bar], 2, false, TkOption::CMD)
TkButton.new(:text=>'test').pack
Tk.mainloop
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2515 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2002-06-04 11:03:33 +04:00
|
|
|
eventloop_thread = 0;
|
|
|
|
watchdog_thread = 0;
|
|
|
|
|
1999-01-20 07:59:39 +03:00
|
|
|
#ifdef __MACOS__
|
|
|
|
_macinit();
|
|
|
|
#endif
|
|
|
|
|
1998-01-16 15:19:09 +03:00
|
|
|
/*---- initialize tcl/tk libraries ----*/
|
|
|
|
/* from Tk_Main() */
|
|
|
|
DUMP1("Tcl_FindExecutable");
|
|
|
|
Tcl_FindExecutable(RSTRING(rb_argv0)->ptr);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* eof */
|