• R/O
  • HTTP
  • SSH
  • HTTPS

Molby: コミット

Molecular Modeling Software


コミットメタ情報

リビジョン8c15a036a640d4cb7985fc5e389fb08bca0b9b10 (tree)
日時2014-09-27 00:32:32
作者toshinagata1964 <toshinagata1964@a2be...>
コミッターtoshinagata1964

ログメッセージ

Ruby#listen is now obsolete, and the message mechanism of Ruby dialog is reworked.

git-svn-id: svn+ssh://svn.sourceforge.jp/svnroot/molby/trunk@574 a2be9bc6-48de-4e38-9406-05402d4bc13c

変更サマリ

差分

--- a/MolLib/MolAction.c
+++ b/MolLib/MolAction.c
@@ -548,7 +548,7 @@ s_MolActionPerformRubyScript(Molecule *mol, MolAction *action)
548548 MyAppCallback_endUndoGrouping();
549549 }
550550 if (result != 0) {
551- Molby_showError(result);
551+ Ruby_showError(result);
552552 }
553553 MyAppCallback_hideProgressPanel(); /* In case when the progress panel is still onscreen */
554554 return (result == 0 ? 0 : -1);
--- a/MolLib/Ruby_bind/Molby_extern.h
+++ b/MolLib/Ruby_bind/Molby_extern.h
@@ -33,14 +33,15 @@ typedef void *RubyValue;
3333 extern char *gRubyVersion;
3434 extern char *gRubyCopyright;
3535
36+extern void Ruby_showError(int status);
37+extern int Ruby_showValue(RubyValue value, char **outValueString);
38+extern int Ruby_UpdateUI(int index, Molecule *mol, int *outChecked, char **outTitle);
39+
3640 extern void Molby_startup(const char *script_path, const char *dir);
3741 extern char *Molby_getDescription(void);
38-extern void Molby_showError(int status);
3942 extern RubyValue Molby_evalRubyScriptOnMolecule(const char *script, Molecule *mol, const char *fname, int *status);
4043 /* extern RubyValue Molby_evalRubyScript(const char *script, int *status);
4144 extern RubyValue Molby_evalRubyScriptOnActiveMoleculeWithInterrupt(const char *script, int *status); */
42-extern int Molby_showRubyValue(RubyValue value, char **outValueString);
43-extern int Ruby_UpdateUI(int index, Molecule *mol, int *outChecked, char **outTitle);
4445 /*extern int Ruby_methodType(const char *className, const char *methodName);*/
4546 extern void Molby_buildARGV(int argc, const char **argv);
4647
--- a/MolLib/Ruby_bind/ruby_bind.c
+++ b/MolLib/Ruby_bind/ruby_bind.c
@@ -11878,7 +11878,7 @@ Molby_evalRubyScriptOnMolecule(const char *script, Molecule *mol, const char *fn
1187811878 }
1187911879
1188011880 int
11881-Molby_showRubyValue(RubyValue value, char **outValueString)
11881+Ruby_showValue(RubyValue value, char **outValueString)
1188211882 {
1188311883 VALUE val = (VALUE)value;
1188411884 if (gMolbyIsCheckingInterrupt) {
@@ -11905,7 +11905,7 @@ Molby_showRubyValue(RubyValue value, char **outValueString)
1190511905 }
1190611906
1190711907 void
11908-Molby_showError(int status)
11908+Ruby_showError(int status)
1190911909 {
1191011910 static const int tag_raise = 6;
1191111911 char *msg = NULL, *msg2;
@@ -12163,7 +12163,7 @@ Molby_startup(const char *script, const char *dir)
1216312163 rb_load_protect(rb_str_new2(script), 0, &status);
1216412164 gMolbyRunLevel--;
1216512165 if (status != 0)
12166- Molby_showError(status);
12166+ Ruby_showError(status);
1216712167 else
1216812168 MyAppCallback_showScriptMessage("Done.\n");
1216912169 }
--- a/MolLib/Ruby_bind/ruby_dialog.c
+++ b/MolLib/Ruby_bind/ruby_dialog.c
@@ -15,8 +15,9 @@
1515
1616 */
1717
18+#include <ruby.h>
1819 #include "ruby_dialog.h"
19-#include "Molby.h"
20+#include "IntGroup.h"
2021
2122 static VALUE
2223 sTextSymbol, sTextFieldSymbol, sRadioSymbol, sButtonSymbol,
@@ -61,6 +62,21 @@ const RDRect gZeroRect = {{0, 0}, {0, 0}};
6162 /* True if y-coordinate grows from bottom to top (like Cocoa) */
6263 int gRubyDialogIsFlipped = 0;
6364
65+#pragma mark ====== External utility functions and macros ======
66+
67+#define FileStringValuePtr(val) Ruby_FileStringValuePtr(&val)
68+extern char *Ruby_FileStringValuePtr(VALUE *valp);
69+extern VALUE Ruby_NewFileStringValue(const char *fstr);
70+
71+#define EncodedStringValuePtr(val) Ruby_EncodedStringValuePtr(&val)
72+extern char *Ruby_EncodedStringValuePtr(VALUE *valp);
73+extern VALUE Ruby_NewEncodedStringValue(const char *str, int len);
74+
75+extern VALUE Ruby_SetInterruptFlag(VALUE val);
76+extern VALUE Ruby_ObjectAtIndex(VALUE ary, int idx);
77+extern VALUE ValueFromIntGroup(IntGroup *ig);
78+extern IntGroup *IntGroupFromValue(VALUE val);
79+
6480 #pragma mark ====== Dialog alloc/init/release ======
6581
6682 typedef struct RubyDialogInfo {
@@ -102,7 +118,7 @@ s_RubyDialog_Forget(VALUE self)
102118 if (di != NULL) {
103119 if (di->dref != NULL) {
104120 /* Unregister all messages */
105- RubyDialogCallback_Listen(di->dref, NULL, NULL, NULL, NULL, NULL);
121+ /* RubyDialogCallback_Listen(di->dref, NULL, NULL, NULL, NULL, NULL); */
106122 }
107123 di->dref = NULL;
108124 }
@@ -142,7 +158,7 @@ s_RubyDialogItem_SetAttr(VALUE self, VALUE key, VALUE val)
142158 itag = NUM2INT(rb_ivar_get(self, SYM2ID(sIndexSymbol)));
143159 type = rb_ivar_get(self, SYM2ID(sTypeSymbol));
144160 if (dialog_val == Qnil || (dref = s_RubyDialog_GetController(dialog_val)) == NULL)
145- rb_raise(rb_eStandardError, "The dialog item does not belong to any dialog (internal error?)");
161+ rb_raise(rb_eDialogError, "The dialog item does not belong to any dialog (internal error?)");
146162 view = RubyDialogCallback_dialogItemAtIndex(dref, itag);
147163 key_id = SYM2ID(key);
148164 if (key == sRangeSymbol) {
@@ -260,7 +276,7 @@ s_RubyDialogItem_SetAttr(VALUE self, VALUE key, VALUE val)
260276 } else if (rb_obj_is_kind_of(val, rb_cNumeric)) {
261277 flex = NUM2INT(rb_Integer(val));
262278 } else {
263- rb_raise(rb_eMolbyError, "the 'flex' attribute should be either an integer or an array of 4 boolean/integers");
279+ rb_raise(rb_eDialogError, "the 'flex' attribute should be either an integer or an array of 4 boolean/integers");
264280 }
265281 rb_ivar_set(self, key_id, INT2NUM(flex));
266282 }
@@ -304,7 +320,7 @@ s_RubyDialogItem_SetAttr(VALUE self, VALUE key, VALUE val)
304320 weight = 3;
305321 } else if (vali != Qnil) {
306322 vali = rb_inspect(vali);
307- rb_raise(rb_eMolbyError, "unknown font specification (%s)", EncodedStringValuePtr(vali));
323+ rb_raise(rb_eDialogError, "unknown font specification (%s)", EncodedStringValuePtr(vali));
308324 }
309325 }
310326 RubyDialogCallback_setFontForItem(view, size, family, style, weight);
@@ -355,7 +371,7 @@ s_RubyDialogItem_SetAttr(VALUE self, VALUE key, VALUE val)
355371 }
356372 } else {
357373 if (key == sTagSymbol && rb_obj_is_kind_of(val, rb_cInteger))
358- rb_raise(rb_eMolbyError, "the dialog item tag must not be integers");
374+ rb_raise(rb_eDialogError, "the dialog item tag must not be integers");
359375 rb_ivar_set(self, key_id, val);
360376 }
361377 RubyDialogCallback_setNeedsDisplay(view, 1);
@@ -389,7 +405,7 @@ s_RubyDialogItem_Attr(VALUE self, VALUE key)
389405 if (key == sTypeSymbol)
390406 return type;
391407 if (dialog_val == Qnil || (dref = s_RubyDialog_GetController(dialog_val)) == NULL)
392- rb_raise(rb_eStandardError, "The dialog item does not belong to any dialog (internal error?)");
408+ rb_raise(rb_eDialogError, "The dialog item does not belong to any dialog (internal error?)");
393409 view = RubyDialogCallback_dialogItemAtIndex(dref, itag);
394410 key_id = SYM2ID(key);
395411
@@ -502,7 +518,7 @@ s_RubyDialogItem_Attr(VALUE self, VALUE key)
502518 int size, family, style, weight;
503519 VALUE fval, sval, wval;
504520 if (RubyDialogCallback_getFontForItem(view, &size, &family, &style, &weight) == 0)
505- rb_raise(rb_eMolbyError, "Cannot get font for dialog item");
521+ rb_raise(rb_eDialogError, "Cannot get font for dialog item");
506522 fval = (family == 1 ? sDefaultSymbol :
507523 (family == 2 ? sRomanSymbol :
508524 (family == 3 ? sSwissSymbol :
@@ -555,11 +571,11 @@ s_RubyDialogItem_AppendString(VALUE self, VALUE val)
555571 index_val = rb_ivar_get(self, SYM2ID(sIndexSymbol));
556572 itag = NUM2INT(index_val);
557573 if (dialog_val == Qnil || (dref = s_RubyDialog_GetController(dialog_val)) == NULL)
558- rb_raise(rb_eStandardError, "The dialog item does not belong to any dialog (internal error?)");
574+ rb_raise(rb_eDialogError, "The dialog item does not belong to any dialog (internal error?)");
559575 view = RubyDialogCallback_dialogItemAtIndex(dref, itag);
560576 val = rb_str_to_str(val);
561577 if (RubyDialogCallback_appendString(view, EncodedStringValuePtr(val)) == 0)
562- rb_raise(rb_eMolbyError, "Cannot append string to the dialog item");
578+ rb_raise(rb_eDialogError, "Cannot append string to the dialog item");
563579 return self;
564580 }
565581
@@ -584,7 +600,7 @@ s_RubyDialogItem_RefreshRect(int argc, VALUE *argv, VALUE self)
584600 index_val = rb_ivar_get(self, SYM2ID(sIndexSymbol));
585601 itag = NUM2INT(index_val);
586602 if (dialog_val == Qnil || (dref = s_RubyDialog_GetController(dialog_val)) == NULL)
587- rb_raise(rb_eStandardError, "The dialog item does not belong to any dialog (internal error?)");
603+ rb_raise(rb_eDialogError, "The dialog item does not belong to any dialog (internal error?)");
588604 view = RubyDialogCallback_dialogItemAtIndex(dref, itag);
589605 rb_scan_args(argc, argv, "11", &rval, &fval);
590606 if (argc == 1)
@@ -699,9 +715,9 @@ s_RubyDialog_ItemIndexForTag(VALUE self, VALUE tag)
699715 {
700716 int i = s_RubyDialog_ItemIndexForTagNoRaise(self, tag);
701717 if (i == -1)
702- rb_raise(rb_eStandardError, "item number (%d) out of range", i);
718+ rb_raise(rb_eDialogError, "item number (%d) out of range", i);
703719 else if (i == -2)
704- rb_raise(rb_eStandardError, "Dialog has no item with tag %s", EncodedStringValuePtr(tag));
720+ rb_raise(rb_eDialogError, "Dialog has no item with tag %s", EncodedStringValuePtr(tag));
705721 return i;
706722 }
707723
@@ -1160,7 +1176,7 @@ s_RubyDialog_Item(int argc, VALUE *argv, VALUE self)
11601176 if (NIL_P(hash))
11611177 hash = rb_hash_new();
11621178 else if (TYPE(hash) != T_HASH)
1163- rb_raise(rb_eMolbyError, "The second argument of Dialog#item must be a hash");
1179+ rb_raise(rb_eDialogError, "The second argument of Dialog#item must be a hash");
11641180 rect.size.width = rect.size.height = 1.0;
11651181 rect.origin.x = rect.origin.y = 0.0;
11661182
@@ -1218,7 +1234,7 @@ s_RubyDialog_Item(int argc, VALUE *argv, VALUE self)
12181234 }
12191235
12201236 if (RubyDialogCallback_createItem(dref, rb_id2name(SYM2ID(type)), title, rect) == NULL)
1221- rb_raise(rb_eStandardError, "item type :%s is not implemented", rb_id2name(SYM2ID(type)));
1237+ rb_raise(rb_eDialogError, "item type :%s is not implemented", rb_id2name(SYM2ID(type)));
12221238
12231239 /* Push to _items */
12241240 items = rb_iv_get(self, "_items");
@@ -1335,7 +1351,7 @@ s_RubyDialog_RadioGroup(VALUE self, VALUE aval)
13351351 rb_ary_push(gval, INT2NUM(j));
13361352 }
13371353 if (i < n)
1338- rb_raise(rb_eStandardError, "the item %d (at index %d) does not represent a radio button", j, i);
1354+ rb_raise(rb_eDialogError, "the item %d (at index %d) does not represent a radio button", j, i);
13391355
13401356 /* Set the radio group array to the specified items. If the item already belongs to a radio group,
13411357 then it is removed from that group. */
@@ -1473,7 +1489,7 @@ s_RubyDialog_StartTimer(int argc, VALUE *argv, VALUE self)
14731489 rb_iv_set(self, "_timer_action", actval);
14741490 dval = NUM2DBL(rb_Float(itval));
14751491 if (RubyDialogCallback_startIntervalTimer(dref, dval) == 0)
1476- rb_raise(rb_eStandardError, "Cannot start timer for dialog");
1492+ rb_raise(rb_eDialogError, "Cannot start timer for dialog");
14771493 return self;
14781494 }
14791495
@@ -1587,6 +1603,7 @@ s_RubyDialog_SetMinSize(int argc, VALUE *argv, VALUE self)
15871603 return self;
15881604 }
15891605
1606+#if 0
15901607 /*
15911608 * call-seq:
15921609 * listen(obj, str, pr)
@@ -1609,8 +1626,8 @@ s_RubyDialog_Listen(VALUE self, VALUE oval, VALUE sval, VALUE pval)
16091626 i = RubyDialogCallback_Listen(s_RubyDialog_GetController(self), mol, "Molecule", sptr, (RubyValue)oval, (RubyValue)pval);
16101627 if (i < 0) {
16111628 switch (i) {
1612- case -1: rb_raise(rb_eMolbyError, "This dialog cannot be listened to."); break;
1613- case -2: rb_raise(rb_eMolbyError, "This message is not supported"); break;
1629+ case -1: rb_raise(rb_eDialogError, "This dialog cannot be listened to."); break;
1630+ case -2: rb_raise(rb_eDialogError, "This message is not supported"); break;
16141631 }
16151632 } else {
16161633 /* Keep the objects in the internal array, to protect from GC */
@@ -1627,10 +1644,11 @@ s_RubyDialog_Listen(VALUE self, VALUE oval, VALUE sval, VALUE pval)
16271644 }
16281645 }
16291646 } else {
1630- rb_raise(rb_eMolbyError, "Dialog#listen is presently only available for Molecule object");
1647+ rb_raise(rb_eDialogError, "Dialog#listen is presently only available for Molecule object");
16311648 }
16321649 return self;
16331650 }
1651+#endif
16341652
16351653 /*
16361654 * call-seq:
@@ -1698,7 +1716,7 @@ s_RubyDialog_OpenPanel(int argc, VALUE *argv, VALUE klass)
16981716 if (mulval != Qnil && mulval != Qfalse) {
16991717 multiple_selection = 1;
17001718 if (for_directories && multiple_selection)
1701- rb_raise(rb_eStandardError, "open_panel for directories allows only single selection");
1719+ rb_raise(rb_eDialogError, "open_panel for directories allows only single selection");
17021720 }
17031721 iflag = Ruby_SetInterruptFlag(Qfalse);
17041722 n = RubyDialogCallback_openPanel(mp, dp, wp, &ary, for_directories, multiple_selection);
@@ -1844,7 +1862,7 @@ RubyDialog_GetTableItemCount(RubyValue self, RDItem *ip)
18441862 void *vp[4] = { (void *)self, (void *)ip, (void *)sOnCountSymbol, NULL };
18451863 VALUE val = rb_protect(s_RubyDialog_doTableAction, (VALUE)vp, &status);
18461864 if (status != 0) {
1847- Molby_showError(status);
1865+ Ruby_showError(status);
18481866 return 0;
18491867 } else if (val == Qnil)
18501868 return 0;
@@ -1884,7 +1902,7 @@ RubyDialog_DragTableSelectionToRow(RubyValue self, RDItem *ip, int row)
18841902 void *vp[5] = { (void *)self, (void *)ip, (void *)sOnDragSelectionToRowSymbol, (void *)row, NULL };
18851903 rb_protect(s_RubyDialog_doTableAction, (VALUE)vp, &status);
18861904 if (status != 0)
1887- Molby_showError(status);
1905+ Ruby_showError(status);
18881906 }
18891907
18901908 int
@@ -1916,7 +1934,7 @@ RubyDialog_OnTableSelectionChanged(RubyValue self, RDItem *ip)
19161934 void *vp[4] = { (void *)self, (void *)ip, (void *)sOnSelectionChangedSymbol, NULL };
19171935 rb_protect(s_RubyDialog_doTableAction, (VALUE)vp, &status);
19181936 if (status != 0)
1919- Molby_showError(status);
1937+ Ruby_showError(status);
19201938 }
19211939
19221940 int
@@ -1948,7 +1966,7 @@ RubyDialog_OnPopUpMenuSelected(RubyValue self, RDItem *ip, int row, int column,
19481966 void *vp[7] = { (void *)self, (void *)ip, (void *)sOnPopUpMenuSelectedSymbol, (void *)row, (void *)column, (void *)selected_index, NULL };
19491967 rb_protect(s_RubyDialog_doTableAction, (VALUE)vp, &status);
19501968 if (status != 0)
1951- Molby_showError(status);
1969+ Ruby_showError(status);
19521970 }
19531971
19541972 #pragma mark ====== Utility function ======
@@ -2001,7 +2019,7 @@ s_RubyDialog_doItemAction(VALUE val)
20012019 VALUE flag;
20022020 RDItem *ip = (RDItem *)vp[1];
20032021 RDItem *ip2;
2004- Int options = (Int)vp[2];
2022+ int options = (int)vp[2];
20052023 VALUE ival, itval, actval, tval, aval;
20062024 RubyDialog *dref = s_RubyDialog_GetController(self);
20072025 VALUE items = rb_iv_get(self, "_items");
@@ -2100,7 +2118,7 @@ s_RubyDialog_doItemAction(VALUE val)
21002118 the item number (integer) as the argument. The default "action" method is
21012119 defined as s_RubyDialog_action. */
21022120 void
2103-RubyDialog_doItemAction(RubyValue self, RDItem *ip, Int options)
2121+RubyDialog_doItemAction(RubyValue self, RDItem *ip, int options)
21042122 {
21052123 int status;
21062124 void *vp[3];
@@ -2109,7 +2127,7 @@ RubyDialog_doItemAction(RubyValue self, RDItem *ip, Int options)
21092127 vp[2] = (void *)options;
21102128 rb_protect(s_RubyDialog_doItemAction, (VALUE)vp, &status);
21112129 if (status != 0)
2112- Molby_showError(status);
2130+ Ruby_showError(status);
21132131 }
21142132
21152133 static VALUE
@@ -2145,7 +2163,7 @@ RubyDialog_doPaintAction(RubyValue self, RDItem *ip)
21452163 vp[1] = ip;
21462164 rb_protect(s_RubyDialog_doPaintAction, (VALUE)vp, &status);
21472165 if (status != 0)
2148- Molby_showError(status);
2166+ Ruby_showError(status);
21492167 }
21502168
21512169 static VALUE
@@ -2169,7 +2187,7 @@ RubyDialog_doTimerAction(RubyValue self)
21692187 if (status != 0) {
21702188 /* Stop timer before showing error dialog */
21712189 RubyDialogCallback_stopIntervalTimer(s_RubyDialog_GetController((VALUE)self));
2172- Molby_showError(status);
2190+ Ruby_showError(status);
21732191 }
21742192 }
21752193
@@ -2198,7 +2216,7 @@ RubyDialog_doKeyAction(RubyValue self, int keyCode)
21982216 values[1] = (void *)keyCode;
21992217 rb_protect(s_RubyDialog_doKeyAction, (VALUE)values, &status);
22002218 if (status != 0) {
2201- Molby_showError(status);
2219+ Ruby_showError(status);
22022220 }
22032221 }
22042222
@@ -2274,7 +2292,7 @@ RubyDialog_doCloseWindow(RubyValue self, int isModal)
22742292 void *args[2] = { (void *)self, (void *)isModal };
22752293 rval = rb_protect(s_RubyDialog_doCloseWindow, (VALUE)args, &status);
22762294 if (status != 0) {
2277- Molby_showError(status);
2295+ Ruby_showError(status);
22782296 }
22792297 }
22802298
@@ -2291,7 +2309,7 @@ s_RubyDialog_GetDeviceContext(VALUE self)
22912309 Data_Get_Struct(self, RDBitmap, bitmap);
22922310 return RubyDialogCallback_getDeviceContextForBitmap(bitmap);
22932311 } else {
2294- rb_raise(rb_eMolbyError, "No graphic device context is available");
2312+ rb_raise(rb_eDialogError, "No graphic device context is available");
22952313 return NULL; /* Not reached */
22962314 }
22972315 }
@@ -2350,24 +2368,24 @@ s_RubyDialog_DrawLine(int argc, VALUE *argv, VALUE self)
23502368 /* The second form */
23512369 ncoords = argc;
23522370 if (ncoords < 2)
2353- rb_raise(rb_eMolbyError, "Too few coordinates are given (requires at least two points)");
2371+ rb_raise(rb_eDialogError, "Too few coordinates are given (requires at least two points)");
23542372 coords = (float *)calloc(sizeof(float), ncoords * 2);
23552373 coords[0] = NUM2DBL(rb_Float(RARRAY_PTR(aval)[0]));
23562374 coords[1] = NUM2DBL(rb_Float(RARRAY_PTR(aval)[1]));
23572375 for (i = 1; i < ncoords; i++) {
23582376 aval = rb_ary_to_ary(argv[i]);
23592377 if (RARRAY_LEN(aval) < 2)
2360- rb_raise(rb_eMolbyError, "The coordinate should be an array of two numerics");
2378+ rb_raise(rb_eDialogError, "The coordinate should be an array of two numerics");
23612379 coords[i * 2] = NUM2DBL(rb_Float(RARRAY_PTR(aval)[0]));
23622380 coords[i * 2 + 1] = NUM2DBL(rb_Float(RARRAY_PTR(aval)[1]));
23632381 }
23642382 } else {
23652383 /* The third form */
23662384 if (RARRAY_LEN(aval) % 2 == 1)
2367- rb_raise(rb_eMolbyError, "An odd number of numerics are given; the coordinate values should be given in pairs");
2385+ rb_raise(rb_eDialogError, "An odd number of numerics are given; the coordinate values should be given in pairs");
23682386 ncoords = RARRAY_LEN(aval) / 2;
23692387 if (ncoords < 2)
2370- rb_raise(rb_eMolbyError, "Too few coordinates are given (requires at least two points)");
2388+ rb_raise(rb_eDialogError, "Too few coordinates are given (requires at least two points)");
23712389 coords = (float *)calloc(sizeof(float), ncoords * 2);
23722390 for (i = 0; i < ncoords * 2; i++) {
23732391 coords[i] = NUM2DBL(rb_Float(RARRAY_PTR(aval)[i]));
@@ -2377,9 +2395,9 @@ s_RubyDialog_DrawLine(int argc, VALUE *argv, VALUE self)
23772395 /* The first form */
23782396 ncoords = argc / 2;
23792397 if (ncoords < 2)
2380- rb_raise(rb_eMolbyError, "Too few coordinates are given (requires at least two points)");
2398+ rb_raise(rb_eDialogError, "Too few coordinates are given (requires at least two points)");
23812399 if (argc % 2 == 1)
2382- rb_raise(rb_eMolbyError, "An odd number of numerics are given; the coordinate values should be given in pairs");
2400+ rb_raise(rb_eDialogError, "An odd number of numerics are given; the coordinate values should be given in pairs");
23832401 coords = (float *)calloc(sizeof(float), ncoords * 2);
23842402 for (i = 0; i < ncoords * 2; i++) {
23852403 coords[i] = NUM2DBL(rb_Float(argv[i]));
@@ -2410,7 +2428,7 @@ s_RubyDialog_DrawRectangle(int argc, VALUE *argv, VALUE self)
24102428 rb_scan_args(argc, argv, "11", &xval, &rval);
24112429 xval = rb_ary_to_ary(xval);
24122430 if (RARRAY_LEN(xval) < 4)
2413- rb_raise(rb_eMolbyError, "The dimension of rectangle should be given as four numerics (x, y, width, height) or an array of four numerics.");
2431+ rb_raise(rb_eDialogError, "The dimension of rectangle should be given as four numerics (x, y, width, height) or an array of four numerics.");
24142432 hval = RARRAY_PTR(xval)[3];
24152433 wval = RARRAY_PTR(xval)[2];
24162434 yval = RARRAY_PTR(xval)[1];
@@ -2656,11 +2674,11 @@ s_Bitmap_Initialize(int argc, VALUE *argv, VALUE self)
26562674 width = NUM2INT(rb_Integer(wval));
26572675 height = NUM2INT(rb_Integer(hval));
26582676 if (width <= 0 || width >= 32768)
2659- rb_raise(rb_eMolbyError, "Bitmap width (%d) is out of range (1..32767)", width);
2677+ rb_raise(rb_eDialogError, "Bitmap width (%d) is out of range (1..32767)", width);
26602678 if (height <= 0 || height >= 32768)
2661- rb_raise(rb_eMolbyError, "Bitmap height (%d) is out of range (1..32767)", height);
2679+ rb_raise(rb_eDialogError, "Bitmap height (%d) is out of range (1..32767)", height);
26622680 if (depth != 32)
2663- rb_raise(rb_eMolbyError, "Only depth = 32 is supported currently");
2681+ rb_raise(rb_eDialogError, "Only depth = 32 is supported currently");
26642682 bitmap = RubyDialogCallback_createBitmap(width, height, depth);
26652683 DATA_PTR(self) = bitmap;
26662684 return self;
@@ -2714,7 +2732,7 @@ RubyDialogInitClass(void)
27142732 VALUE parent;
27152733 if (rb_cDialog != Qfalse)
27162734 return;
2717- parent = RubyDialogCallback_parentModule();
2735+ parent = (VALUE)RubyDialogCallback_parentModule();
27182736 if (parent != Qfalse)
27192737 rb_cDialog = rb_define_class_under(parent, "Dialog", rb_cObject);
27202738 else
@@ -2745,7 +2763,7 @@ RubyDialogInitClass(void)
27452763 rb_define_method(rb_cDialog, "size", s_RubyDialog_Size, 0);
27462764 rb_define_method(rb_cDialog, "set_min_size", s_RubyDialog_SetMinSize, -1);
27472765 rb_define_method(rb_cDialog, "min_size", s_RubyDialog_MinSize, 0);
2748- rb_define_method(rb_cDialog, "listen", s_RubyDialog_Listen, 3);
2766+/* rb_define_method(rb_cDialog, "listen", s_RubyDialog_Listen, 3); */
27492767 rb_define_singleton_method(rb_cDialog, "save_panel", s_RubyDialog_SavePanel, -1);
27502768 rb_define_singleton_method(rb_cDialog, "open_panel", s_RubyDialog_OpenPanel, -1);
27512769
--- a/MolLib/Ruby_bind/ruby_dialog.h
+++ b/MolLib/Ruby_bind/ruby_dialog.h
@@ -39,7 +39,9 @@ typedef void *RubyValue;
3939 #ifndef STUB
4040 #define STUB extern
4141 #endif
42-
42+
43+extern void Ruby_showError(int status);
44+
4345 /* True if y-coordinate grows from bottom to top (like Cocoa) */
4446 extern int gRubyDialogIsFlipped;
4547
@@ -106,9 +108,7 @@ STUB void RubyDialogCallback_setWindowSize(RubyDialog *dref, RDSize size);
106108 STUB void RubyDialogCallback_setAutoResizeEnabled(RubyDialog *dref, int flag);
107109 STUB int RubyDialogCallback_isAutoResizeEnabled(RubyDialog *dref);
108110
109-//STUB int RubyDialogCallback_GetEventHandlerFromValueAndMessage(RubyValue val, const char *msg, RDEventHandlerRecord **recp);
110-//STUB int RubyDialogCallback_Listen(RubyDialog *dref, RDEventHandlerRecord *rec, RubyValue oval, RubyValue pval);
111-STUB int RubyDialogCallback_Listen(RubyDialog *dref, void *obj, const char *objtype, const char *msg, RubyValue oval, RubyValue pval);
111+//STUB int RubyDialogCallback_Listen(RubyDialog *dref, void *obj, const char *objtype, const char *msg, RubyValue oval, RubyValue pval);
112112
113113 STUB void RubyDialogCallback_createStandardButtons(RubyDialog *dref, const char *oktitle, const char *canceltitle);
114114 STUB RDItem *RubyDialogCallback_createItem(RubyDialog *dref, const char *type, const char *title, RDRect frame);
--- a/Scripts/molecule.rb
+++ b/Scripts/molecule.rb
@@ -761,23 +761,36 @@ class Molecule
761761 end
762762 end
763763
764- def close_all_auxiliary_windows
765- if @aux_windows
764+# def close_all_auxiliary_windows
765+# if @aux_windows
766+# @aux_windows.values.each { |d|
767+# close_auxiliary_window(d)
768+# }
769+# return true
770+# else
771+# return false
772+# end
773+# end
774+
775+ def on_close
776+ mol = self
777+ @on_close.call(mol) if @on_close
778+ if @aux_windows
766779 @aux_windows.values.each { |d|
767780 close_auxiliary_window(d)
768- }
769- return true
770- else
771- return false
781+ }
772782 end
773783 end
774784
775- def call_modification_handler_in_all_auxiliary_windows
785+ def on_modified
776786 mol = self
777- if @aux_windows
778- @aux_windows.values.each { |d|
787+ # Call a handler if defined
788+ @on_document_modified.call(mol) if @on_document_modified
789+ if @aux_windows
790+ @aux_windows.each_value { |d|
791+ # For each auxiliary window, call a handler if defined
779792 d.instance_eval { @on_document_modified.call(mol) if @on_document_modified }
780- }
793+ }
781794 end
782795 end
783796
--- a/wxSources/ConsoleFrame.cpp
+++ b/wxSources/ConsoleFrame.cpp
@@ -361,12 +361,12 @@ ConsoleFrame::OnEnterPressed()
361361 char *valueString;
362362 MyAppCallback_setConsoleColor(1);
363363 if (status != 0) {
364- Molby_showError(status);
364+ Ruby_showError(status);
365365 } else {
366366 textCtrl->AppendText(wxT("-->"));
367- status = Molby_showRubyValue(val, &valueString);
367+ status = Ruby_showValue(val, &valueString);
368368 if (status != 0) {
369- Molby_showError(status);
369+ Ruby_showError(status);
370370 } else {
371371 AssignArray(&valueHistory, &nValueHistory, sizeof(char *), nValueHistory, &valueString);
372372 if (nValueHistory >= MAX_HISTORY_LINES)
--- a/wxSources/MyApp.cpp
+++ b/wxSources/MyApp.cpp
@@ -1139,7 +1139,7 @@ MyApp::OnExecuteScript(wxCommandEvent &event)
11391139 if (retval == (RubyValue)6 && status == -1)
11401140 MyAppCallback_errorMessageBox("Cannot open Ruby script %s", (const char *)path.mb_str(wxConvFile));
11411141 else if (status != 0)
1142- Molby_showError(status);
1142+ Ruby_showError(status);
11431143 }
11441144 dialog->Destroy();
11451145 }
@@ -1196,7 +1196,7 @@ MyApp::OnOpenFiles(const wxString &files)
11961196 if (retval == (RubyValue)6 && status == -1)
11971197 MyAppCallback_errorMessageBox("Cannot open Ruby script: %s", (const char *)file.mb_str(wxConvFile));
11981198 else
1199- Molby_showError(status);
1199+ Ruby_showError(status);
12001200 return false;
12011201 }
12021202 } else {
--- a/wxSources/MyDocument.cpp
+++ b/wxSources/MyDocument.cpp
@@ -75,7 +75,7 @@ BEGIN_EVENT_TABLE(MyDocument, wxDocument)
7575 EVT_MENU(wxID_PASTE, MyDocument::OnPaste)
7676 EVT_MENU(wxID_CUT, MyDocument::OnCut)
7777 EVT_MENU(wxID_DELETE, MyDocument::OnDelete)
78- EVT_MENU(wxID_CLOSE, MyDocument::OnCustomClose)
78+// EVT_MENU(wxID_CLOSE, MyDocument::OnCustomClose)
7979 EVT_MENU(myMenuID_CreateNewAtom, MyDocument::OnCreateNewAtom)
8080 EVT_MENU_RANGE(myMenuID_CreateNewVdwParameter, myMenuID_CreateNewVdwCutoffParameter, MyDocument::OnCreateNewParameter)
8181 EVT_MENU(myMenuID_CreatePiAnchor, MyDocument::OnCreatePiAnchor)
@@ -488,7 +488,7 @@ MyDocument::OnCustomClose(wxCommandEvent &event)
488488 // RubyValue val;
489489 // MolActionCreateAndPerform(mol, SCRIPT_ACTION(";r"), "close_all_auxiliary_windows", &val);
490490 // if (val == NULL || val == RubyNil)
491- event.Skip();
491+// event.Skip();
492492 }
493493
494494 bool
@@ -503,8 +503,8 @@ MyDocument::Close()
503503 return false;
504504 }
505505 if (wxDocument::Close()) {
506- /* Close all auxiliary windows */
507- MolActionCreateAndPerform(mol, SCRIPT_ACTION(""), "close_all_auxiliary_windows");
506+ /* Call close hander in the Ruby world */
507+ MolActionCreateAndPerform(mol, SCRIPT_ACTION(""), "on_close");
508508 /* Send a message that this document will close */
509509 wxCommandEvent myEvent(MyDocumentEvent, MyDocumentEvent_documentWillClose);
510510 myEvent.SetEventObject(this);
@@ -531,8 +531,8 @@ MyDocument::OnDocumentModified(wxCommandEvent& event)
531531 isModifyNotificationSent = false;
532532 MoleculeClearModifyCount(GetMainView()->mol);
533533
534- /* Send message to all auxiliary windows */
535- MolActionCreateAndPerform(mol, SCRIPT_ACTION(""), "call_modification_handler_in_all_auxiliary_windows");
534+ /* Call modified handler in the Ruby world */
535+ MolActionCreateAndPerform(mol, SCRIPT_ACTION(""), "on_modified");
536536
537537 event.Skip(); // Also pass to other notification handlers
538538 UpdateModifyFlag();
--- a/wxSources/RubyDialogFrame.cpp
+++ b/wxSources/RubyDialogFrame.cpp
@@ -66,8 +66,8 @@ RubyDialogFrame::RubyDialogFrame(wxWindow* parent, wxWindowID wid, const wxStrin
6666 dval = NULL;
6767 mySize = gZeroSize;
6868 autoResizeEnabled = true;
69- messageData = NULL;
70- countMessageData = 0;
69+// messageData = NULL;
70+// countMessageData = 0;
7171 onKeyHandlerEnabled = false;
7272 currentContext = NULL;
7373 currentDrawingItem = NULL;
@@ -92,9 +92,10 @@ RubyDialogFrame::~RubyDialogFrame()
9292 delete myTimer;
9393 if (ditems != NULL)
9494 free(ditems);
95- DiscardMessageData();
95+// DiscardMessageData();
9696 }
9797
98+#if 0
9899 void
99100 RubyDialogFrame::DiscardMessageData()
100101 {
@@ -114,6 +115,7 @@ RubyDialogFrame::DiscardMessageData()
114115 messageData = NULL;
115116 countMessageData = 0;
116117 }
118+#endif
117119
118120 int
119121 RubyDialogFrame::AddDialogItem(RDItem *item)
@@ -164,7 +166,7 @@ RubyDialogFrame::SetRubyObject(RubyValue val)
164166 dval = val;
165167 if (dval == NULL) {
166168 /* Stop message mechanism (because this object is already disconnected from the Ruby world) */
167- DiscardMessageData();
169+ /* DiscardMessageData(); */
168170 }
169171 }
170172
@@ -479,6 +481,7 @@ sGetEventHandlerFromObjectAndType(void *obj, wxEventType eventType)
479481 else return NULL;
480482 }
481483
484+#if 0
482485 int
483486 RubyDialogFrame::ListenToObject(void *obj, const char *objtype, const char *msg, RubyValue oval, RubyValue pval)
484487 {
@@ -584,6 +587,7 @@ RubyDialogFrame::HandleDocumentEvent(wxCommandEvent &event)
584587 }
585588 event.Skip();
586589 }
590+#endif
587591
588592 void
589593 RubyDialogFrame::HandlePaintEvent(wxPaintEvent &event)
@@ -905,11 +909,13 @@ RubyDialogCallback_isAutoResizeEnabled(RubyDialog *dref)
905909 return ((RubyDialogFrame *)dref)->IsAutoResizeEnabled();
906910 }
907911
912+/*
908913 int
909914 RubyDialogCallback_Listen(RubyDialog *dref, void *obj, const char *objtype, const char *msg, RubyValue oval, RubyValue pval)
910915 {
911916 return ((RubyDialogFrame *)dref)->ListenToObject(obj, objtype, msg, oval, pval);
912917 }
918+*/
913919
914920 void
915921 RubyDialogCallback_createStandardButtons(RubyDialog *dref, const char *oktitle, const char *canceltitle)
--- a/wxSources/RubyDialogFrame.h
+++ b/wxSources/RubyDialogFrame.h
@@ -72,8 +72,8 @@ public:
7272 bool autoResizeEnabled; /* true if auto resizing is enabled */
7373
7474 /* Message bridge (with Ruby world); obj, event_type, event_id, proc val */
75- void **messageData;
76- int countMessageData;
75+// void **messageData;
76+// int countMessageData;
7777
7878 /* On key handler (the handler is in the Ruby world) */
7979 bool onKeyHandlerEnabled;
@@ -86,13 +86,14 @@ public:
8686 virtual ~RubyDialogFrame();
8787
8888 /* For internal use (discard data in messageData[]) */
89- void DiscardMessageData();
89+// void DiscardMessageData();
9090
9191 void SetAutoResizeEnabled(int flag) { autoResizeEnabled = (flag != 0); }
9292 bool IsAutoResizeEnabled() { return autoResizeEnabled; }
9393
94- int ListenToObject(void *obj, const char *objtype, const char *msg, RubyValue oval, RubyValue pval);
95- void HandleDocumentEvent(wxCommandEvent &event);
94+// int ListenToObject(void *obj, const char *objtype, const char *msg, RubyValue oval, RubyValue pval);
95+// void HandleDocumentEvent(wxCommandEvent &event);
96+
9697 void HandlePaintEvent(wxPaintEvent &event);
9798
9899 int AddDialogItem(RDItem *item);
旧リポジトリブラウザで表示