@@ -221,14 +221,6 @@ - (BOOL)closeButtonPressed;
221221- (void )dealloc ;
222222@end
223223
224- @interface ToolWindow : NSWindow
225- {
226- }
227- - (ToolWindow*)initWithContentRect : (NSRect )rect master : (NSWindow *)window ;
228- - (void )masterCloses : (NSNotification *)notification ;
229- - (void )close ;
230- @end
231-
232224@interface View : NSView <NSWindowDelegate >
233225{ PyObject* canvas;
234226 NSRect rubberband;
@@ -1000,74 +992,17 @@ -(void)zoom:(id)sender
1000992}
1001993
1002994-(void )configure_subplots : (id )sender
1003- { PyObject* canvas;
1004- View* view;
1005- PyObject* size;
1006- NSRect rect;
1007- int width, height;
1008-
1009- rect.origin .x = 100 ;
1010- rect.origin .y = 350 ;
1011- PyGILState_STATE gstate = PyGILState_Ensure ();
1012- PyObject* master = PyObject_GetAttrString (toolbar, " canvas" );
1013- if (master==nil )
1014- {
1015- PyErr_Print ();
1016- PyGILState_Release (gstate);
1017- return ;
1018- }
1019- canvas = PyObject_CallMethod (toolbar, " prepare_configure_subplots" , " " );
1020- if (!canvas)
1021- {
1022- PyErr_Print ();
1023- Py_DECREF (master);
1024- PyGILState_Release (gstate);
1025- return ;
1026- }
1027-
1028- view = ((FigureCanvas*)canvas)->view ;
1029- if (!view) /* Something really weird going on */
1030- {
1031- PyErr_SetString (PyExc_RuntimeError, " NSView* is NULL" );
1032- PyErr_Print ();
1033- Py_DECREF (canvas);
1034- Py_DECREF (master);
1035- PyGILState_Release (gstate);
1036- return ;
1037- }
1038-
1039- size = PyObject_CallMethod (canvas, " get_width_height" , " " );
1040- Py_DECREF (canvas);
1041- if (!size)
1042- {
1043- PyErr_Print ();
1044- Py_DECREF (master);
1045- PyGILState_Release (gstate);
1046- return ;
1047- }
1048-
1049- int ok = PyArg_ParseTuple (size, " ii" , &width, &height);
1050- Py_DECREF (size);
1051- if (!ok)
1052- {
995+ {
996+ PyObject* result;
997+ PyGILState_STATE gstate;
998+ gstate = PyGILState_Ensure ();
999+ result = PyObject_CallMethod (toolbar, " configure_subplots" , NULL );
1000+ if (result) {
1001+ Py_DECREF (result);
1002+ } else {
10531003 PyErr_Print ();
1054- Py_DECREF (master);
1055- PyGILState_Release (gstate);
1056- return ;
10571004 }
1058-
1059- NSWindow * mw = [((FigureCanvas*)master)->view window ];
1060- Py_DECREF (master);
10611005 PyGILState_Release (gstate);
1062-
1063- rect.size .width = width;
1064- rect.size .height = height;
1065-
1066- ToolWindow* window = [ [ToolWindow alloc ] initWithContentRect: rect
1067- master: mw];
1068- [window setContentView: view];
1069- [view release ];
1070- [window makeKeyAndOrderFront: nil ];
10711006}
10721007
10731008-(void )save_figure : (id )sender
@@ -1524,36 +1459,6 @@ - (void)dealloc
15241459}
15251460@end
15261461
1527- @implementation ToolWindow
1528- - (ToolWindow*)initWithContentRect : (NSRect )rect master : (NSWindow *)window
1529- {
1530- [self initWithContentRect: rect
1531- styleMask: NSWindowStyleMaskTitled
1532- | NSWindowStyleMaskClosable
1533- | NSWindowStyleMaskResizable
1534- | NSWindowStyleMaskMiniaturizable
1535- backing: NSBackingStoreBuffered
1536- defer: YES ];
1537- [self setTitle: @" Subplot Configuration Tool" ];
1538- [[NSNotificationCenter defaultCenter ] addObserver: self
1539- selector: @selector (masterCloses: )
1540- name: NSWindowWillCloseNotification
1541- object: window];
1542- return self;
1543- }
1544-
1545- - (void )masterCloses : (NSNotification *)notification
1546- {
1547- [self close ];
1548- }
1549-
1550- - (void )close
1551- {
1552- [[NSNotificationCenter defaultCenter ] removeObserver: self ];
1553- [super close ];
1554- }
1555- @end
1556-
15571462@implementation View
15581463- (BOOL )isFlipped
15591464{
0 commit comments