@@ -212,14 +212,6 @@ - (BOOL)closeButtonPressed;
212212- (void )dealloc ;
213213@end
214214
215- @interface ToolWindow : NSWindow
216- {
217- }
218- - (ToolWindow*)initWithContentRect : (NSRect )rect master : (NSWindow *)window ;
219- - (void )masterCloses : (NSNotification *)notification ;
220- - (void )close ;
221- @end
222-
223215@interface View : NSView <NSWindowDelegate >
224216{ PyObject* canvas;
225217 NSRect rubberband;
@@ -959,74 +951,17 @@ -(void)zoom:(id)sender
959951}
960952
961953-(void )configure_subplots : (id )sender
962- { PyObject* canvas;
963- View* view;
964- PyObject* size;
965- NSRect rect;
966- int width, height;
967-
968- rect.origin .x = 100 ;
969- rect.origin .y = 350 ;
970- PyGILState_STATE gstate = PyGILState_Ensure ();
971- PyObject* master = PyObject_GetAttrString (toolbar, " canvas" );
972- if (master==nil )
973- {
974- PyErr_Print ();
975- PyGILState_Release (gstate);
976- return ;
977- }
978- canvas = PyObject_CallMethod (toolbar, " prepare_configure_subplots" , " " );
979- if (!canvas)
980- {
981- PyErr_Print ();
982- Py_DECREF (master);
983- PyGILState_Release (gstate);
984- return ;
985- }
986-
987- view = ((FigureCanvas*)canvas)->view ;
988- if (!view) /* Something really weird going on */
989- {
990- PyErr_SetString (PyExc_RuntimeError, " NSView* is NULL" );
991- PyErr_Print ();
992- Py_DECREF (canvas);
993- Py_DECREF (master);
994- PyGILState_Release (gstate);
995- return ;
996- }
997-
998- size = PyObject_CallMethod (canvas, " get_width_height" , " " );
999- Py_DECREF (canvas);
1000- if (!size)
1001- {
1002- PyErr_Print ();
1003- Py_DECREF (master);
1004- PyGILState_Release (gstate);
1005- return ;
1006- }
1007-
1008- int ok = PyArg_ParseTuple (size, " ii" , &width, &height);
1009- Py_DECREF (size);
1010- if (!ok)
1011- {
954+ {
955+ PyObject* result;
956+ PyGILState_STATE gstate;
957+ gstate = PyGILState_Ensure ();
958+ result = PyObject_CallMethod (toolbar, " configure_subplots" , NULL );
959+ if (result) {
960+ Py_DECREF (result);
961+ } else {
1012962 PyErr_Print ();
1013- Py_DECREF (master);
1014- PyGILState_Release (gstate);
1015- return ;
1016963 }
1017-
1018- NSWindow * mw = [((FigureCanvas*)master)->view window ];
1019- Py_DECREF (master);
1020964 PyGILState_Release (gstate);
1021-
1022- rect.size .width = width;
1023- rect.size .height = height;
1024-
1025- ToolWindow* window = [ [ToolWindow alloc ] initWithContentRect: rect
1026- master: mw];
1027- [window setContentView: view];
1028- [view release ];
1029- [window makeKeyAndOrderFront: nil ];
1030965}
1031966
1032967-(void )save_figure : (id )sender
@@ -1455,36 +1390,6 @@ - (void)dealloc
14551390}
14561391@end
14571392
1458- @implementation ToolWindow
1459- - (ToolWindow*)initWithContentRect : (NSRect )rect master : (NSWindow *)window
1460- {
1461- [self initWithContentRect: rect
1462- styleMask: NSWindowStyleMaskTitled
1463- | NSWindowStyleMaskClosable
1464- | NSWindowStyleMaskResizable
1465- | NSWindowStyleMaskMiniaturizable
1466- backing: NSBackingStoreBuffered
1467- defer: YES ];
1468- [self setTitle: @" Subplot Configuration Tool" ];
1469- [[NSNotificationCenter defaultCenter ] addObserver: self
1470- selector: @selector (masterCloses: )
1471- name: NSWindowWillCloseNotification
1472- object: window];
1473- return self;
1474- }
1475-
1476- - (void )masterCloses : (NSNotification *)notification
1477- {
1478- [self close ];
1479- }
1480-
1481- - (void )close
1482- {
1483- [[NSNotificationCenter defaultCenter ] removeObserver: self ];
1484- [super close ];
1485- }
1486- @end
1487-
14881393@implementation View
14891394- (BOOL )isFlipped
14901395{
0 commit comments