summaryrefslogtreecommitdiffstats
path: root/ext/tcltklib
diff options
context:
space:
mode:
authornagai <nagai@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2005-07-21 22:04:43 +0000
committernagai <nagai@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2005-07-21 22:04:43 +0000
commita428c6e7cf97db93d09b374adf17783c03546f5a (patch)
tree41fe7f1a4b159b15c3171247c70c1f5f03d75d9b /ext/tcltklib
parent2f3f45da2319fe189e264877742b63f2d13a76d6 (diff)
downloadruby-a428c6e7cf97db93d09b374adf17783c03546f5a.tar.gz
ruby-a428c6e7cf97db93d09b374adf17783c03546f5a.tar.xz
ruby-a428c6e7cf97db93d09b374adf17783c03546f5a.zip
* ext/tk/tkutil.c (tk_conv_args): forget to revert thread_critical
and gc_disable when raise ArgumentError. * ext/tk/lib/remote-tk.rb: RemoteTkIp doesn't need to include TkUtil. * ext/tcltklib/tcltklib.c: add TclTkIp#has_mainwindow? method. * ext/tk/lib/tk.rb: add Tk.has_mainwindow? method. * ext/tk/lib/multi-tk.rb: add MultiTkIp#has_mainwindow? method. * ext/tk/lib/remote-tk.rb: add RemoteTkIp#has_mainwindow? method. * ext/tk/lib/multi-tk.rb: slave IP fail to exit itself when $SAFE==4. * ext/tk/lib/multi-tk.rb: remove constants from MultiTkIp module to avoid access from external. * ext/tk/lib/multi-tk.rb: check_root flag is ignored on slave IPs' mainloop. * ext/tk/lib/multi-tk.rb: hang-up Tk.mainloop called on a slave IP with $SAFE==4. * ext/tk/lib/multi-tk.rb: MultiTkIp#bg_eval_proc doesn't work properly. * ext/tk/lib/multi-tk.rb: add MultiTkIp#set_cb_error(proc) and cb_error(exc) to log errors at callbacks on safe slave IPs. * ext/tk/lib/multi-tk.rb: fail to get an available slave IP object when call Tk.mainloop in the block which is given to new_* method, because cannot finish initialize while the root widget is alive. * ext/tk/lib/multi-tk.rb: fail to control a slave IP when Tk.mainloop runs on the IP. git-svn-id: http://svn.ruby-lang.org/repos/ruby/branches/ruby_1_8@8817 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/tcltklib')
-rw-r--r--ext/tcltklib/MANUAL.eng5
-rw-r--r--ext/tcltklib/MANUAL.euc5
-rw-r--r--ext/tcltklib/tcltklib.c20
3 files changed, 29 insertions, 1 deletions
diff --git a/ext/tcltklib/MANUAL.eng b/ext/tcltklib/MANUAL.eng
index 9e7bd20d3..1db61f228 100644
--- a/ext/tcltklib/MANUAL.eng
+++ b/ext/tcltklib/MANUAL.eng
@@ -310,6 +310,11 @@ class TclTkIp
: Check whether the interpreter is already deleted.
: If deleted, returns true.
+ has_mainwindow?
+ : Check whether the interpreter has a MainWindow (root widget).
+ : If has, returns true. If doesn't, returns false.
+ : If IP is already deleted, returns nil.
+
restart
: Restart Tk part of the interpreter.
: Use this when you need Tk functions after destroying the
diff --git a/ext/tcltklib/MANUAL.euc b/ext/tcltklib/MANUAL.euc
index f90dcff3e..5dd36726b 100644
--- a/ext/tcltklib/MANUAL.euc
+++ b/ext/tcltklib/MANUAL.euc
@@ -422,6 +422,11 @@ require "tcltklib" すると, 以下のモジュール, クラスが利用可能です.
: delete 済みでコマンドを受け付けない状態になっているならば
: true を返す.
+ has_mainwindow?
+ : Tcl/Tk インタープリタにメインウィンドウ (root widget) が
+ : 存在すれば true を,存在しなければ false を返す.
+ : インタープリタが既に delete 済みであれば nil を返す.
+
restart
: Tcl/Tk インタープリタの Tk 部分の初期化,再起動を行う.
: 一旦 root widget を破壊した後に再度 Tk の機能が必要と
diff --git a/ext/tcltklib/tcltklib.c b/ext/tcltklib/tcltklib.c
index b088ef7cf..d1e5f9d0d 100644
--- a/ext/tcltklib/tcltklib.c
+++ b/ext/tcltklib/tcltklib.c
@@ -4,7 +4,7 @@
* Oct. 24, 1997 Y. Matsumoto
*/
-#define TCLTKLIB_RELEASE_DATE "2005-07-19"
+#define TCLTKLIB_RELEASE_DATE "2005-07-22"
#include "ruby.h"
#include "rubysig.h"
@@ -511,6 +511,7 @@ get_ip(self)
}
if (ptr->ip == (Tcl_Interp*)NULL) {
/* rb_raise(rb_eRuntimeError, "deleted IP"); */
+ return((struct tcltkip *)NULL);
}
return ptr;
}
@@ -5293,6 +5294,22 @@ ip_is_deleted_p(self)
}
}
+static VALUE
+ip_has_mainwindow_p(self)
+ VALUE self;
+{
+ struct tcltkip *ptr = get_ip(self);
+
+ if (ptr == (struct tcltkip *)NULL || ptr->ip == (Tcl_Interp *)NULL
+ || Tcl_InterpDeleted(ptr->ip)) {
+ return Qnil;
+ } else if (Tk_MainWindow(ptr->ip) == (Tk_Window)NULL) {
+ return Qfalse;
+ } else {
+ return Qtrue;
+ }
+}
+
static VALUE
#ifdef HAVE_STDARG_PROTOTYPES
@@ -8557,6 +8574,7 @@ Init_tcltklib()
rb_define_method(ip, "allow_ruby_exit=", ip_allow_ruby_exit_set, 1);
rb_define_method(ip, "delete", ip_delete, 0);
rb_define_method(ip, "deleted?", ip_is_deleted_p, 0);
+ rb_define_method(ip, "has_mainwindow?", ip_has_mainwindow_p, 0);
rb_define_method(ip, "invalid_namespace?", ip_has_invalid_namespace_p, 0);
rb_define_method(ip, "_eval", ip_eval, 1);
rb_define_method(ip, "_toUTF8", ip_toUTF8, -1);