]> granicus.if.org Git - python/commitdiff
Accept Dialogs and Windows where Grafports are expected (such as in SetPort) and...
authorJack Jansen <jack.jansen@cwi.nl>
Fri, 2 Feb 2001 22:41:48 +0000 (22:41 +0000)
committerJack Jansen <jack.jansen@cwi.nl>
Fri, 2 Feb 2001 22:41:48 +0000 (22:41 +0000)
Mac/Modules/qd/Qdmodule.c
Mac/Modules/qd/qdsupport.py

index 34476d4d69c6310f43533d99824bf777c25453ac..aece598109b0d424d2bf261f4331813350d60b00 100644 (file)
@@ -144,8 +144,14 @@ GrafObj_Convert(v, p_itself)
        PyObject *v;
        GrafPtr *p_itself;
 {
-       if (DlgObj_Check(v) || WinObj_Check(v)) {
-               *p_itself = ((GrafPortObject *)v)->ob_itself;
+       if (DlgObj_Check(v)) {
+               DialogRef dlg = (DialogRef)((GrafPortObject *)v)->ob_itself;
+               *p_itself = (GrafPtr)GetWindowPort(GetDialogWindow(dlg));
+               return 1;
+       }
+       if (WinObj_Check(v)) {
+               WindowRef win = (WindowRef)((GrafPortObject *)v)->ob_itself;
+               *p_itself = (GrafPtr)GetWindowPort(win);
                return 1;
        }
        if (!GrafObj_Check(v))
index f57cf17ecd20e31d1407ac6dcc2df653692b28e5..fe606f5a94faff9cbf0cdc725394387fe72e324f 100644 (file)
@@ -219,8 +219,14 @@ class MyGRObjectDefinition(GlobalObjectDefinition):
        def outputCheckNewArg(self):
                Output("if (itself == NULL) return PyMac_Error(resNotFound);")
        def outputCheckConvertArg(self):
-               OutLbrace("if (DlgObj_Check(v) || WinObj_Check(v))")
-               Output("*p_itself = ((GrafPortObject *)v)->ob_itself;")
+               OutLbrace("if (DlgObj_Check(v))")
+               Output("DialogRef dlg = (DialogRef)((GrafPortObject *)v)->ob_itself;")
+               Output("*p_itself = (GrafPtr)GetWindowPort(GetDialogWindow(dlg));")
+               Output("return 1;")
+               OutRbrace()
+               OutLbrace("if (WinObj_Check(v))")
+               Output("WindowRef win = (WindowRef)((GrafPortObject *)v)->ob_itself;")
+               Output("*p_itself = (GrafPtr)GetWindowPort(win);")
                Output("return 1;")
                OutRbrace()
        def outputGetattrHook(self):