summaryrefslogtreecommitdiff
path: root/ext/tcltklib
diff options
context:
space:
mode:
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 9e7bd20d37..1db61f228e 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 f90dcff3e4..5dd36726ba 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 b088ef7cf7..d1e5f9d0d0 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);