Mercurial > pygame
annotate src/scrap.c @ 3172:d1b367fc08bc tests-returncode
Use a return code of 1 when the tests fail.
| author | Thomas Kluyver <takowl@gmail.com> |
|---|---|
| date | Wed, 09 Jan 2013 10:13:57 +0000 |
| parents | b4d02ac4a5b7 |
| children | 9fcb7abf3185 |
| rev | line source |
|---|---|
|
677
3e8e94054c55
Clipboard manipulation functions. Still needs a unittest, and
Rene Dudfield <renesd@gmail.com>
parents:
673
diff
changeset
|
1 /* |
|
3e8e94054c55
Clipboard manipulation functions. Still needs a unittest, and
Rene Dudfield <renesd@gmail.com>
parents:
673
diff
changeset
|
2 pygame - Python Game Library |
|
794
1633c4302f48
Some code cleanups from Marcus von Appen. min->MIN, indentation, other.
Rene Dudfield <renesd@gmail.com>
parents:
777
diff
changeset
|
3 Copyright (C) 2006, 2007 Rene Dudfield, Marcus von Appen |
|
677
3e8e94054c55
Clipboard manipulation functions. Still needs a unittest, and
Rene Dudfield <renesd@gmail.com>
parents:
673
diff
changeset
|
4 |
|
3e8e94054c55
Clipboard manipulation functions. Still needs a unittest, and
Rene Dudfield <renesd@gmail.com>
parents:
673
diff
changeset
|
5 Originally written and put in the public domain by Sam Lantinga. |
|
3e8e94054c55
Clipboard manipulation functions. Still needs a unittest, and
Rene Dudfield <renesd@gmail.com>
parents:
673
diff
changeset
|
6 |
|
3e8e94054c55
Clipboard manipulation functions. Still needs a unittest, and
Rene Dudfield <renesd@gmail.com>
parents:
673
diff
changeset
|
7 This library is free software; you can redistribute it and/or |
|
3e8e94054c55
Clipboard manipulation functions. Still needs a unittest, and
Rene Dudfield <renesd@gmail.com>
parents:
673
diff
changeset
|
8 modify it under the terms of the GNU Library General Public |
|
3e8e94054c55
Clipboard manipulation functions. Still needs a unittest, and
Rene Dudfield <renesd@gmail.com>
parents:
673
diff
changeset
|
9 License as published by the Free Software Foundation; either |
|
3e8e94054c55
Clipboard manipulation functions. Still needs a unittest, and
Rene Dudfield <renesd@gmail.com>
parents:
673
diff
changeset
|
10 version 2 of the License, or (at your option) any later version. |
|
3e8e94054c55
Clipboard manipulation functions. Still needs a unittest, and
Rene Dudfield <renesd@gmail.com>
parents:
673
diff
changeset
|
11 |
|
3e8e94054c55
Clipboard manipulation functions. Still needs a unittest, and
Rene Dudfield <renesd@gmail.com>
parents:
673
diff
changeset
|
12 This library is distributed in the hope that it will be useful, |
|
3e8e94054c55
Clipboard manipulation functions. Still needs a unittest, and
Rene Dudfield <renesd@gmail.com>
parents:
673
diff
changeset
|
13 but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
3e8e94054c55
Clipboard manipulation functions. Still needs a unittest, and
Rene Dudfield <renesd@gmail.com>
parents:
673
diff
changeset
|
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
3e8e94054c55
Clipboard manipulation functions. Still needs a unittest, and
Rene Dudfield <renesd@gmail.com>
parents:
673
diff
changeset
|
15 Library General Public License for more details. |
|
3e8e94054c55
Clipboard manipulation functions. Still needs a unittest, and
Rene Dudfield <renesd@gmail.com>
parents:
673
diff
changeset
|
16 |
|
3e8e94054c55
Clipboard manipulation functions. Still needs a unittest, and
Rene Dudfield <renesd@gmail.com>
parents:
673
diff
changeset
|
17 You should have received a copy of the GNU Library General Public |
|
3e8e94054c55
Clipboard manipulation functions. Still needs a unittest, and
Rene Dudfield <renesd@gmail.com>
parents:
673
diff
changeset
|
18 License along with this library; if not, write to the Free |
|
3e8e94054c55
Clipboard manipulation functions. Still needs a unittest, and
Rene Dudfield <renesd@gmail.com>
parents:
673
diff
changeset
|
19 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
3e8e94054c55
Clipboard manipulation functions. Still needs a unittest, and
Rene Dudfield <renesd@gmail.com>
parents:
673
diff
changeset
|
20 */ |
|
3e8e94054c55
Clipboard manipulation functions. Still needs a unittest, and
Rene Dudfield <renesd@gmail.com>
parents:
673
diff
changeset
|
21 |
|
673
33035cf4416e
The start of a 'scrap' module based on the scrap library.
Rene Dudfield <renesd@gmail.com>
parents:
diff
changeset
|
22 /* Handle clipboard text and data in arbitrary formats */ |
|
33035cf4416e
The start of a 'scrap' module based on the scrap library.
Rene Dudfield <renesd@gmail.com>
parents:
diff
changeset
|
23 |
|
33035cf4416e
The start of a 'scrap' module based on the scrap library.
Rene Dudfield <renesd@gmail.com>
parents:
diff
changeset
|
24 #include <stdio.h> |
|
33035cf4416e
The start of a 'scrap' module based on the scrap library.
Rene Dudfield <renesd@gmail.com>
parents:
diff
changeset
|
25 #include <limits.h> |
|
33035cf4416e
The start of a 'scrap' module based on the scrap library.
Rene Dudfield <renesd@gmail.com>
parents:
diff
changeset
|
26 |
|
33035cf4416e
The start of a 'scrap' module based on the scrap library.
Rene Dudfield <renesd@gmail.com>
parents:
diff
changeset
|
27 #include "SDL.h" |
|
33035cf4416e
The start of a 'scrap' module based on the scrap library.
Rene Dudfield <renesd@gmail.com>
parents:
diff
changeset
|
28 #include "SDL_syswm.h" |
|
33035cf4416e
The start of a 'scrap' module based on the scrap library.
Rene Dudfield <renesd@gmail.com>
parents:
diff
changeset
|
29 |
|
33035cf4416e
The start of a 'scrap' module based on the scrap library.
Rene Dudfield <renesd@gmail.com>
parents:
diff
changeset
|
30 #include "scrap.h" |
|
33035cf4416e
The start of a 'scrap' module based on the scrap library.
Rene Dudfield <renesd@gmail.com>
parents:
diff
changeset
|
31 #include "pygame.h" |
| 1937 | 32 #include "doc/scrap_doc.h" |
|
2167
949ac8c51629
Correct Event readonly attributes test for Python 3.x: the exception raised on assignment differs from 2.x.
Lenard Lindstrom <len-l@telus.net>
parents:
1937
diff
changeset
|
33 #include "pgcompat.h" |
|
673
33035cf4416e
The start of a 'scrap' module based on the scrap library.
Rene Dudfield <renesd@gmail.com>
parents:
diff
changeset
|
34 |
|
759
ae48ea30bc50
Some scrap fixes, and code cleanup goodness from Marcus von Appen.
Rene Dudfield <renesd@gmail.com>
parents:
743
diff
changeset
|
35 /** |
|
ae48ea30bc50
Some scrap fixes, and code cleanup goodness from Marcus von Appen.
Rene Dudfield <renesd@gmail.com>
parents:
743
diff
changeset
|
36 * Indicates, whether pygame.scrap was initialized or not. |
|
ae48ea30bc50
Some scrap fixes, and code cleanup goodness from Marcus von Appen.
Rene Dudfield <renesd@gmail.com>
parents:
743
diff
changeset
|
37 */ |
|
ae48ea30bc50
Some scrap fixes, and code cleanup goodness from Marcus von Appen.
Rene Dudfield <renesd@gmail.com>
parents:
743
diff
changeset
|
38 static int _scrapinitialized = 0; |
|
673
33035cf4416e
The start of a 'scrap' module based on the scrap library.
Rene Dudfield <renesd@gmail.com>
parents:
diff
changeset
|
39 |
|
759
ae48ea30bc50
Some scrap fixes, and code cleanup goodness from Marcus von Appen.
Rene Dudfield <renesd@gmail.com>
parents:
743
diff
changeset
|
40 /** |
|
794
1633c4302f48
Some code cleanups from Marcus von Appen. min->MIN, indentation, other.
Rene Dudfield <renesd@gmail.com>
parents:
777
diff
changeset
|
41 * Currently active Clipboard object. |
|
759
ae48ea30bc50
Some scrap fixes, and code cleanup goodness from Marcus von Appen.
Rene Dudfield <renesd@gmail.com>
parents:
743
diff
changeset
|
42 */ |
|
794
1633c4302f48
Some code cleanups from Marcus von Appen. min->MIN, indentation, other.
Rene Dudfield <renesd@gmail.com>
parents:
777
diff
changeset
|
43 static ScrapClipType _currentmode; |
|
1633c4302f48
Some code cleanups from Marcus von Appen. min->MIN, indentation, other.
Rene Dudfield <renesd@gmail.com>
parents:
777
diff
changeset
|
44 static PyObject* _selectiondata; |
|
1633c4302f48
Some code cleanups from Marcus von Appen. min->MIN, indentation, other.
Rene Dudfield <renesd@gmail.com>
parents:
777
diff
changeset
|
45 static PyObject* _clipdata; |
|
673
33035cf4416e
The start of a 'scrap' module based on the scrap library.
Rene Dudfield <renesd@gmail.com>
parents:
diff
changeset
|
46 |
|
794
1633c4302f48
Some code cleanups from Marcus von Appen. min->MIN, indentation, other.
Rene Dudfield <renesd@gmail.com>
parents:
777
diff
changeset
|
47 /* Forward declarations. */ |
|
1633c4302f48
Some code cleanups from Marcus von Appen. min->MIN, indentation, other.
Rene Dudfield <renesd@gmail.com>
parents:
777
diff
changeset
|
48 static PyObject* _scrap_get_types (PyObject *self, PyObject *args); |
|
1633c4302f48
Some code cleanups from Marcus von Appen. min->MIN, indentation, other.
Rene Dudfield <renesd@gmail.com>
parents:
777
diff
changeset
|
49 static PyObject* _scrap_contains (PyObject *self, PyObject *args); |
|
1633c4302f48
Some code cleanups from Marcus von Appen. min->MIN, indentation, other.
Rene Dudfield <renesd@gmail.com>
parents:
777
diff
changeset
|
50 static PyObject* _scrap_get_scrap (PyObject* self, PyObject* args); |
|
1633c4302f48
Some code cleanups from Marcus von Appen. min->MIN, indentation, other.
Rene Dudfield <renesd@gmail.com>
parents:
777
diff
changeset
|
51 static PyObject* _scrap_put_scrap (PyObject* self, PyObject* args); |
|
1633c4302f48
Some code cleanups from Marcus von Appen. min->MIN, indentation, other.
Rene Dudfield <renesd@gmail.com>
parents:
777
diff
changeset
|
52 static PyObject* _scrap_lost_scrap (PyObject* self, PyObject* args); |
|
1633c4302f48
Some code cleanups from Marcus von Appen. min->MIN, indentation, other.
Rene Dudfield <renesd@gmail.com>
parents:
777
diff
changeset
|
53 static PyObject* _scrap_set_mode (PyObject* self, PyObject* args); |
|
673
33035cf4416e
The start of a 'scrap' module based on the scrap library.
Rene Dudfield <renesd@gmail.com>
parents:
diff
changeset
|
54 |
|
794
1633c4302f48
Some code cleanups from Marcus von Appen. min->MIN, indentation, other.
Rene Dudfield <renesd@gmail.com>
parents:
777
diff
changeset
|
55 /* Determine what type of clipboard we are using */ |
|
1912
35e02db899ff
bugzilla 29, patch to use SDL_VIDEO_DRIVER_X11 instead of DISABLE_X11. Thanks Robert A. Lerche.
Rene Dudfield <renesd@gmail.com>
parents:
1804
diff
changeset
|
56 #if defined(__unix__) && defined(SDL_VIDEO_DRIVER_X11) |
|
833
b5f47d739cfd
removed qnx compilation, since it is broken. thanks Marcus.
Rene Dudfield <renesd@gmail.com>
parents:
831
diff
changeset
|
57 /*!defined(__QNXNTO__) &&*/ |
|
794
1633c4302f48
Some code cleanups from Marcus von Appen. min->MIN, indentation, other.
Rene Dudfield <renesd@gmail.com>
parents:
777
diff
changeset
|
58 #define X11_SCRAP |
|
1633c4302f48
Some code cleanups from Marcus von Appen. min->MIN, indentation, other.
Rene Dudfield <renesd@gmail.com>
parents:
777
diff
changeset
|
59 #include <time.h> /* Needed for clipboard timeouts. */ |
|
1633c4302f48
Some code cleanups from Marcus von Appen. min->MIN, indentation, other.
Rene Dudfield <renesd@gmail.com>
parents:
777
diff
changeset
|
60 #include "scrap_x11.c" |
|
1633c4302f48
Some code cleanups from Marcus von Appen. min->MIN, indentation, other.
Rene Dudfield <renesd@gmail.com>
parents:
777
diff
changeset
|
61 #elif defined(__WIN32__) |
|
1633c4302f48
Some code cleanups from Marcus von Appen. min->MIN, indentation, other.
Rene Dudfield <renesd@gmail.com>
parents:
777
diff
changeset
|
62 #define WIN_SCRAP |
|
1633c4302f48
Some code cleanups from Marcus von Appen. min->MIN, indentation, other.
Rene Dudfield <renesd@gmail.com>
parents:
777
diff
changeset
|
63 #include "scrap_win.c" |
|
833
b5f47d739cfd
removed qnx compilation, since it is broken. thanks Marcus.
Rene Dudfield <renesd@gmail.com>
parents:
831
diff
changeset
|
64 /* |
|
794
1633c4302f48
Some code cleanups from Marcus von Appen. min->MIN, indentation, other.
Rene Dudfield <renesd@gmail.com>
parents:
777
diff
changeset
|
65 #elif defined(__QNXNTO__) |
|
1633c4302f48
Some code cleanups from Marcus von Appen. min->MIN, indentation, other.
Rene Dudfield <renesd@gmail.com>
parents:
777
diff
changeset
|
66 #define QNX_SCRAP |
|
1633c4302f48
Some code cleanups from Marcus von Appen. min->MIN, indentation, other.
Rene Dudfield <renesd@gmail.com>
parents:
777
diff
changeset
|
67 static uint32_t _cliptype = 0; |
|
1633c4302f48
Some code cleanups from Marcus von Appen. min->MIN, indentation, other.
Rene Dudfield <renesd@gmail.com>
parents:
777
diff
changeset
|
68 #include "scrap_qnx.c" |
|
833
b5f47d739cfd
removed qnx compilation, since it is broken. thanks Marcus.
Rene Dudfield <renesd@gmail.com>
parents:
831
diff
changeset
|
69 */ |
|
794
1633c4302f48
Some code cleanups from Marcus von Appen. min->MIN, indentation, other.
Rene Dudfield <renesd@gmail.com>
parents:
777
diff
changeset
|
70 #elif defined(__APPLE__) |
|
1633c4302f48
Some code cleanups from Marcus von Appen. min->MIN, indentation, other.
Rene Dudfield <renesd@gmail.com>
parents:
777
diff
changeset
|
71 #define MAC_SCRAP |
|
1633c4302f48
Some code cleanups from Marcus von Appen. min->MIN, indentation, other.
Rene Dudfield <renesd@gmail.com>
parents:
777
diff
changeset
|
72 #include "scrap_mac.c" |
|
1633c4302f48
Some code cleanups from Marcus von Appen. min->MIN, indentation, other.
Rene Dudfield <renesd@gmail.com>
parents:
777
diff
changeset
|
73 #else |
|
1633c4302f48
Some code cleanups from Marcus von Appen. min->MIN, indentation, other.
Rene Dudfield <renesd@gmail.com>
parents:
777
diff
changeset
|
74 #error Unknown window manager for clipboard handling |
|
1633c4302f48
Some code cleanups from Marcus von Appen. min->MIN, indentation, other.
Rene Dudfield <renesd@gmail.com>
parents:
777
diff
changeset
|
75 #endif /* scrap type */ |
|
759
ae48ea30bc50
Some scrap fixes, and code cleanup goodness from Marcus von Appen.
Rene Dudfield <renesd@gmail.com>
parents:
743
diff
changeset
|
76 |
|
ae48ea30bc50
Some scrap fixes, and code cleanup goodness from Marcus von Appen.
Rene Dudfield <renesd@gmail.com>
parents:
743
diff
changeset
|
77 /** |
|
794
1633c4302f48
Some code cleanups from Marcus von Appen. min->MIN, indentation, other.
Rene Dudfield <renesd@gmail.com>
parents:
777
diff
changeset
|
78 * \brief Indicates whether the scrap module is already initialized. |
|
759
ae48ea30bc50
Some scrap fixes, and code cleanup goodness from Marcus von Appen.
Rene Dudfield <renesd@gmail.com>
parents:
743
diff
changeset
|
79 * |
|
794
1633c4302f48
Some code cleanups from Marcus von Appen. min->MIN, indentation, other.
Rene Dudfield <renesd@gmail.com>
parents:
777
diff
changeset
|
80 * \return 0 if the module is not initialized, 1, if it is. |
|
759
ae48ea30bc50
Some scrap fixes, and code cleanup goodness from Marcus von Appen.
Rene Dudfield <renesd@gmail.com>
parents:
743
diff
changeset
|
81 */ |
|
ae48ea30bc50
Some scrap fixes, and code cleanup goodness from Marcus von Appen.
Rene Dudfield <renesd@gmail.com>
parents:
743
diff
changeset
|
82 int |
|
ae48ea30bc50
Some scrap fixes, and code cleanup goodness from Marcus von Appen.
Rene Dudfield <renesd@gmail.com>
parents:
743
diff
changeset
|
83 pygame_scrap_initialized (void) |
|
673
33035cf4416e
The start of a 'scrap' module based on the scrap library.
Rene Dudfield <renesd@gmail.com>
parents:
diff
changeset
|
84 { |
|
759
ae48ea30bc50
Some scrap fixes, and code cleanup goodness from Marcus von Appen.
Rene Dudfield <renesd@gmail.com>
parents:
743
diff
changeset
|
85 return _scrapinitialized; |
|
ae48ea30bc50
Some scrap fixes, and code cleanup goodness from Marcus von Appen.
Rene Dudfield <renesd@gmail.com>
parents:
743
diff
changeset
|
86 } |
|
673
33035cf4416e
The start of a 'scrap' module based on the scrap library.
Rene Dudfield <renesd@gmail.com>
parents:
diff
changeset
|
87 |
|
801
1d7a19d25215
Some mac scrap fixes from Marcus.
Rene Dudfield <renesd@gmail.com>
parents:
794
diff
changeset
|
88 #if !defined(MAC_SCRAP) |
|
794
1633c4302f48
Some code cleanups from Marcus von Appen. min->MIN, indentation, other.
Rene Dudfield <renesd@gmail.com>
parents:
777
diff
changeset
|
89 /* |
|
1633c4302f48
Some code cleanups from Marcus von Appen. min->MIN, indentation, other.
Rene Dudfield <renesd@gmail.com>
parents:
777
diff
changeset
|
90 * Initializes the pygame scrap module. |
|
1633c4302f48
Some code cleanups from Marcus von Appen. min->MIN, indentation, other.
Rene Dudfield <renesd@gmail.com>
parents:
777
diff
changeset
|
91 */ |
|
1633c4302f48
Some code cleanups from Marcus von Appen. min->MIN, indentation, other.
Rene Dudfield <renesd@gmail.com>
parents:
777
diff
changeset
|
92 static PyObject* |
|
1633c4302f48
Some code cleanups from Marcus von Appen. min->MIN, indentation, other.
Rene Dudfield <renesd@gmail.com>
parents:
777
diff
changeset
|
93 _scrap_init (PyObject *self, PyObject *args) |
|
673
33035cf4416e
The start of a 'scrap' module based on the scrap library.
Rene Dudfield <renesd@gmail.com>
parents:
diff
changeset
|
94 { |
|
794
1633c4302f48
Some code cleanups from Marcus von Appen. min->MIN, indentation, other.
Rene Dudfield <renesd@gmail.com>
parents:
777
diff
changeset
|
95 VIDEO_INIT_CHECK (); |
|
1633c4302f48
Some code cleanups from Marcus von Appen. min->MIN, indentation, other.
Rene Dudfield <renesd@gmail.com>
parents:
777
diff
changeset
|
96 _clipdata = PyDict_New (); |
|
1633c4302f48
Some code cleanups from Marcus von Appen. min->MIN, indentation, other.
Rene Dudfield <renesd@gmail.com>
parents:
777
diff
changeset
|
97 _selectiondata = PyDict_New (); |
|
759
ae48ea30bc50
Some scrap fixes, and code cleanup goodness from Marcus von Appen.
Rene Dudfield <renesd@gmail.com>
parents:
743
diff
changeset
|
98 |
| 1002 | 99 /* In case we've got not video surface, we won't initialize |
| 100 * anything. | |
| 101 */ | |
| 102 if (!SDL_GetVideoSurface()) | |
| 103 return RAISE (PyExc_SDLError, "No display mode is set"); | |
|
794
1633c4302f48
Some code cleanups from Marcus von Appen. min->MIN, indentation, other.
Rene Dudfield <renesd@gmail.com>
parents:
777
diff
changeset
|
104 if (!pygame_scrap_init ()) |
|
1633c4302f48
Some code cleanups from Marcus von Appen. min->MIN, indentation, other.
Rene Dudfield <renesd@gmail.com>
parents:
777
diff
changeset
|
105 return RAISE (PyExc_SDLError, SDL_GetError ()); |
| 1002 | 106 |
|
794
1633c4302f48
Some code cleanups from Marcus von Appen. min->MIN, indentation, other.
Rene Dudfield <renesd@gmail.com>
parents:
777
diff
changeset
|
107 Py_RETURN_NONE; |
|
673
33035cf4416e
The start of a 'scrap' module based on the scrap library.
Rene Dudfield <renesd@gmail.com>
parents:
diff
changeset
|
108 } |
|
801
1d7a19d25215
Some mac scrap fixes from Marcus.
Rene Dudfield <renesd@gmail.com>
parents:
794
diff
changeset
|
109 #endif |
|
673
33035cf4416e
The start of a 'scrap' module based on the scrap library.
Rene Dudfield <renesd@gmail.com>
parents:
diff
changeset
|
110 |
|
33035cf4416e
The start of a 'scrap' module based on the scrap library.
Rene Dudfield <renesd@gmail.com>
parents:
diff
changeset
|
111 |
|
801
1d7a19d25215
Some mac scrap fixes from Marcus.
Rene Dudfield <renesd@gmail.com>
parents:
794
diff
changeset
|
112 #if !defined(MAC_SCRAP) |
|
794
1633c4302f48
Some code cleanups from Marcus von Appen. min->MIN, indentation, other.
Rene Dudfield <renesd@gmail.com>
parents:
777
diff
changeset
|
113 /* |
|
1633c4302f48
Some code cleanups from Marcus von Appen. min->MIN, indentation, other.
Rene Dudfield <renesd@gmail.com>
parents:
777
diff
changeset
|
114 * Gets the currently available types from the active clipboard. |
|
1633c4302f48
Some code cleanups from Marcus von Appen. min->MIN, indentation, other.
Rene Dudfield <renesd@gmail.com>
parents:
777
diff
changeset
|
115 */ |
|
1633c4302f48
Some code cleanups from Marcus von Appen. min->MIN, indentation, other.
Rene Dudfield <renesd@gmail.com>
parents:
777
diff
changeset
|
116 static PyObject* |
|
1633c4302f48
Some code cleanups from Marcus von Appen. min->MIN, indentation, other.
Rene Dudfield <renesd@gmail.com>
parents:
777
diff
changeset
|
117 _scrap_get_types (PyObject *self, PyObject *args) |
|
1633c4302f48
Some code cleanups from Marcus von Appen. min->MIN, indentation, other.
Rene Dudfield <renesd@gmail.com>
parents:
777
diff
changeset
|
118 { |
|
1633c4302f48
Some code cleanups from Marcus von Appen. min->MIN, indentation, other.
Rene Dudfield <renesd@gmail.com>
parents:
777
diff
changeset
|
119 int i = 0; |
|
1633c4302f48
Some code cleanups from Marcus von Appen. min->MIN, indentation, other.
Rene Dudfield <renesd@gmail.com>
parents:
777
diff
changeset
|
120 char **types; |
|
2167
949ac8c51629
Correct Event readonly attributes test for Python 3.x: the exception raised on assignment differs from 2.x.
Lenard Lindstrom <len-l@telus.net>
parents:
1937
diff
changeset
|
121 char *type; |
|
794
1633c4302f48
Some code cleanups from Marcus von Appen. min->MIN, indentation, other.
Rene Dudfield <renesd@gmail.com>
parents:
777
diff
changeset
|
122 PyObject *list; |
|
831
8749d7c235f8
Changes from Marcus for ref counting bug fixes and
Rene Dudfield <renesd@gmail.com>
parents:
826
diff
changeset
|
123 PyObject *tmp; |
|
759
ae48ea30bc50
Some scrap fixes, and code cleanup goodness from Marcus von Appen.
Rene Dudfield <renesd@gmail.com>
parents:
743
diff
changeset
|
124 |
|
794
1633c4302f48
Some code cleanups from Marcus von Appen. min->MIN, indentation, other.
Rene Dudfield <renesd@gmail.com>
parents:
777
diff
changeset
|
125 PYGAME_SCRAP_INIT_CHECK (); |
|
1633c4302f48
Some code cleanups from Marcus von Appen. min->MIN, indentation, other.
Rene Dudfield <renesd@gmail.com>
parents:
777
diff
changeset
|
126 if (!pygame_scrap_lost ()) |
|
759
ae48ea30bc50
Some scrap fixes, and code cleanup goodness from Marcus von Appen.
Rene Dudfield <renesd@gmail.com>
parents:
743
diff
changeset
|
127 { |
|
794
1633c4302f48
Some code cleanups from Marcus von Appen. min->MIN, indentation, other.
Rene Dudfield <renesd@gmail.com>
parents:
777
diff
changeset
|
128 switch (_currentmode) |
|
673
33035cf4416e
The start of a 'scrap' module based on the scrap library.
Rene Dudfield <renesd@gmail.com>
parents:
diff
changeset
|
129 { |
|
794
1633c4302f48
Some code cleanups from Marcus von Appen. min->MIN, indentation, other.
Rene Dudfield <renesd@gmail.com>
parents:
777
diff
changeset
|
130 case SCRAP_SELECTION: |
|
1633c4302f48
Some code cleanups from Marcus von Appen. min->MIN, indentation, other.
Rene Dudfield <renesd@gmail.com>
parents:
777
diff
changeset
|
131 return PyDict_Keys (_selectiondata); |
|
1633c4302f48
Some code cleanups from Marcus von Appen. min->MIN, indentation, other.
Rene Dudfield <renesd@gmail.com>
parents:
777
diff
changeset
|
132 case SCRAP_CLIPBOARD: |
|
1633c4302f48
Some code cleanups from Marcus von Appen. min->MIN, indentation, other.
Rene Dudfield <renesd@gmail.com>
parents:
777
diff
changeset
|
133 default: |
|
1633c4302f48
Some code cleanups from Marcus von Appen. min->MIN, indentation, other.
Rene Dudfield <renesd@gmail.com>
parents:
777
diff
changeset
|
134 return PyDict_Keys (_clipdata); |
|
673
33035cf4416e
The start of a 'scrap' module based on the scrap library.
Rene Dudfield <renesd@gmail.com>
parents:
diff
changeset
|
135 } |
|
759
ae48ea30bc50
Some scrap fixes, and code cleanup goodness from Marcus von Appen.
Rene Dudfield <renesd@gmail.com>
parents:
743
diff
changeset
|
136 } |
|
673
33035cf4416e
The start of a 'scrap' module based on the scrap library.
Rene Dudfield <renesd@gmail.com>
parents:
diff
changeset
|
137 |
|
794
1633c4302f48
Some code cleanups from Marcus von Appen. min->MIN, indentation, other.
Rene Dudfield <renesd@gmail.com>
parents:
777
diff
changeset
|
138 list = PyList_New (0); |
|
1633c4302f48
Some code cleanups from Marcus von Appen. min->MIN, indentation, other.
Rene Dudfield <renesd@gmail.com>
parents:
777
diff
changeset
|
139 types = pygame_scrap_get_types (); |
|
1633c4302f48
Some code cleanups from Marcus von Appen. min->MIN, indentation, other.
Rene Dudfield <renesd@gmail.com>
parents:
777
diff
changeset
|
140 if (!types) |
|
1633c4302f48
Some code cleanups from Marcus von Appen. min->MIN, indentation, other.
Rene Dudfield <renesd@gmail.com>
parents:
777
diff
changeset
|
141 return list; |
|
1633c4302f48
Some code cleanups from Marcus von Appen. min->MIN, indentation, other.
Rene Dudfield <renesd@gmail.com>
parents:
777
diff
changeset
|
142 while (types[i] != NULL) |
|
759
ae48ea30bc50
Some scrap fixes, and code cleanup goodness from Marcus von Appen.
Rene Dudfield <renesd@gmail.com>
parents:
743
diff
changeset
|
143 { |
|
2167
949ac8c51629
Correct Event readonly attributes test for Python 3.x: the exception raised on assignment differs from 2.x.
Lenard Lindstrom <len-l@telus.net>
parents:
1937
diff
changeset
|
144 type = types[i]; |
|
949ac8c51629
Correct Event readonly attributes test for Python 3.x: the exception raised on assignment differs from 2.x.
Lenard Lindstrom <len-l@telus.net>
parents:
1937
diff
changeset
|
145 tmp = PyUnicode_DecodeASCII (type, strlen (type), 0); |
|
949ac8c51629
Correct Event readonly attributes test for Python 3.x: the exception raised on assignment differs from 2.x.
Lenard Lindstrom <len-l@telus.net>
parents:
1937
diff
changeset
|
146 if (!tmp) { |
|
949ac8c51629
Correct Event readonly attributes test for Python 3.x: the exception raised on assignment differs from 2.x.
Lenard Lindstrom <len-l@telus.net>
parents:
1937
diff
changeset
|
147 Py_DECREF (list); |
|
949ac8c51629
Correct Event readonly attributes test for Python 3.x: the exception raised on assignment differs from 2.x.
Lenard Lindstrom <len-l@telus.net>
parents:
1937
diff
changeset
|
148 return 0; |
|
949ac8c51629
Correct Event readonly attributes test for Python 3.x: the exception raised on assignment differs from 2.x.
Lenard Lindstrom <len-l@telus.net>
parents:
1937
diff
changeset
|
149 } |
|
949ac8c51629
Correct Event readonly attributes test for Python 3.x: the exception raised on assignment differs from 2.x.
Lenard Lindstrom <len-l@telus.net>
parents:
1937
diff
changeset
|
150 if (PyList_Append (list, tmp)) { |
|
949ac8c51629
Correct Event readonly attributes test for Python 3.x: the exception raised on assignment differs from 2.x.
Lenard Lindstrom <len-l@telus.net>
parents:
1937
diff
changeset
|
151 Py_DECREF (list); |
|
949ac8c51629
Correct Event readonly attributes test for Python 3.x: the exception raised on assignment differs from 2.x.
Lenard Lindstrom <len-l@telus.net>
parents:
1937
diff
changeset
|
152 Py_DECREF (tmp); |
|
949ac8c51629
Correct Event readonly attributes test for Python 3.x: the exception raised on assignment differs from 2.x.
Lenard Lindstrom <len-l@telus.net>
parents:
1937
diff
changeset
|
153 return 0; |
|
949ac8c51629
Correct Event readonly attributes test for Python 3.x: the exception raised on assignment differs from 2.x.
Lenard Lindstrom <len-l@telus.net>
parents:
1937
diff
changeset
|
154 } |
|
831
8749d7c235f8
Changes from Marcus for ref counting bug fixes and
Rene Dudfield <renesd@gmail.com>
parents:
826
diff
changeset
|
155 Py_DECREF (tmp); |
|
794
1633c4302f48
Some code cleanups from Marcus von Appen. min->MIN, indentation, other.
Rene Dudfield <renesd@gmail.com>
parents:
777
diff
changeset
|
156 i++; |
|
1633c4302f48
Some code cleanups from Marcus von Appen. min->MIN, indentation, other.
Rene Dudfield <renesd@gmail.com>
parents:
777
diff
changeset
|
157 } |
|
1633c4302f48
Some code cleanups from Marcus von Appen. min->MIN, indentation, other.
Rene Dudfield <renesd@gmail.com>
parents:
777
diff
changeset
|
158 return list; |
|
1633c4302f48
Some code cleanups from Marcus von Appen. min->MIN, indentation, other.
Rene Dudfield <renesd@gmail.com>
parents:
777
diff
changeset
|
159 } |
|
801
1d7a19d25215
Some mac scrap fixes from Marcus.
Rene Dudfield <renesd@gmail.com>
parents:
794
diff
changeset
|
160 #endif |
|
759
ae48ea30bc50
Some scrap fixes, and code cleanup goodness from Marcus von Appen.
Rene Dudfield <renesd@gmail.com>
parents:
743
diff
changeset
|
161 |
|
ae48ea30bc50
Some scrap fixes, and code cleanup goodness from Marcus von Appen.
Rene Dudfield <renesd@gmail.com>
parents:
743
diff
changeset
|
162 |
|
801
1d7a19d25215
Some mac scrap fixes from Marcus.
Rene Dudfield <renesd@gmail.com>
parents:
794
diff
changeset
|
163 #if !defined(MAC_SCRAP) |
|
794
1633c4302f48
Some code cleanups from Marcus von Appen. min->MIN, indentation, other.
Rene Dudfield <renesd@gmail.com>
parents:
777
diff
changeset
|
164 /* |
|
1633c4302f48
Some code cleanups from Marcus von Appen. min->MIN, indentation, other.
Rene Dudfield <renesd@gmail.com>
parents:
777
diff
changeset
|
165 * Checks whether the active clipboard contains a certain type. |
|
1633c4302f48
Some code cleanups from Marcus von Appen. min->MIN, indentation, other.
Rene Dudfield <renesd@gmail.com>
parents:
777
diff
changeset
|
166 */ |
|
1633c4302f48
Some code cleanups from Marcus von Appen. min->MIN, indentation, other.
Rene Dudfield <renesd@gmail.com>
parents:
777
diff
changeset
|
167 static PyObject* |
|
1633c4302f48
Some code cleanups from Marcus von Appen. min->MIN, indentation, other.
Rene Dudfield <renesd@gmail.com>
parents:
777
diff
changeset
|
168 _scrap_contains (PyObject *self, PyObject *args) |
|
1633c4302f48
Some code cleanups from Marcus von Appen. min->MIN, indentation, other.
Rene Dudfield <renesd@gmail.com>
parents:
777
diff
changeset
|
169 { |
|
1633c4302f48
Some code cleanups from Marcus von Appen. min->MIN, indentation, other.
Rene Dudfield <renesd@gmail.com>
parents:
777
diff
changeset
|
170 char *type = NULL; |
|
1633c4302f48
Some code cleanups from Marcus von Appen. min->MIN, indentation, other.
Rene Dudfield <renesd@gmail.com>
parents:
777
diff
changeset
|
171 |
|
1633c4302f48
Some code cleanups from Marcus von Appen. min->MIN, indentation, other.
Rene Dudfield <renesd@gmail.com>
parents:
777
diff
changeset
|
172 if (!PyArg_ParseTuple (args, "s", &type)) |
|
1633c4302f48
Some code cleanups from Marcus von Appen. min->MIN, indentation, other.
Rene Dudfield <renesd@gmail.com>
parents:
777
diff
changeset
|
173 return NULL; |
|
1633c4302f48
Some code cleanups from Marcus von Appen. min->MIN, indentation, other.
Rene Dudfield <renesd@gmail.com>
parents:
777
diff
changeset
|
174 if (pygame_scrap_contains (type)) |
|
1633c4302f48
Some code cleanups from Marcus von Appen. min->MIN, indentation, other.
Rene Dudfield <renesd@gmail.com>
parents:
777
diff
changeset
|
175 Py_RETURN_TRUE; |
|
1633c4302f48
Some code cleanups from Marcus von Appen. min->MIN, indentation, other.
Rene Dudfield <renesd@gmail.com>
parents:
777
diff
changeset
|
176 Py_RETURN_FALSE; |
|
673
33035cf4416e
The start of a 'scrap' module based on the scrap library.
Rene Dudfield <renesd@gmail.com>
parents:
diff
changeset
|
177 } |
|
801
1d7a19d25215
Some mac scrap fixes from Marcus.
Rene Dudfield <renesd@gmail.com>
parents:
794
diff
changeset
|
178 #endif |
|
673
33035cf4416e
The start of a 'scrap' module based on the scrap library.
Rene Dudfield <renesd@gmail.com>
parents:
diff
changeset
|
179 |
|
759
ae48ea30bc50
Some scrap fixes, and code cleanup goodness from Marcus von Appen.
Rene Dudfield <renesd@gmail.com>
parents:
743
diff
changeset
|
180 |
|
801
1d7a19d25215
Some mac scrap fixes from Marcus.
Rene Dudfield <renesd@gmail.com>
parents:
794
diff
changeset
|
181 #if !defined(MAC_SCRAP) |
|
794
1633c4302f48
Some code cleanups from Marcus von Appen. min->MIN, indentation, other.
Rene Dudfield <renesd@gmail.com>
parents:
777
diff
changeset
|
182 /* |
|
1633c4302f48
Some code cleanups from Marcus von Appen. min->MIN, indentation, other.
Rene Dudfield <renesd@gmail.com>
parents:
777
diff
changeset
|
183 * Gets the content for a certain type from the active clipboard. |
|
1633c4302f48
Some code cleanups from Marcus von Appen. min->MIN, indentation, other.
Rene Dudfield <renesd@gmail.com>
parents:
777
diff
changeset
|
184 */ |
|
1633c4302f48
Some code cleanups from Marcus von Appen. min->MIN, indentation, other.
Rene Dudfield <renesd@gmail.com>
parents:
777
diff
changeset
|
185 static PyObject* |
|
1633c4302f48
Some code cleanups from Marcus von Appen. min->MIN, indentation, other.
Rene Dudfield <renesd@gmail.com>
parents:
777
diff
changeset
|
186 _scrap_get_scrap (PyObject* self, PyObject* args) |
|
1633c4302f48
Some code cleanups from Marcus von Appen. min->MIN, indentation, other.
Rene Dudfield <renesd@gmail.com>
parents:
777
diff
changeset
|
187 { |
|
1633c4302f48
Some code cleanups from Marcus von Appen. min->MIN, indentation, other.
Rene Dudfield <renesd@gmail.com>
parents:
777
diff
changeset
|
188 char *scrap = NULL; |
|
1633c4302f48
Some code cleanups from Marcus von Appen. min->MIN, indentation, other.
Rene Dudfield <renesd@gmail.com>
parents:
777
diff
changeset
|
189 PyObject *retval; |
|
1633c4302f48
Some code cleanups from Marcus von Appen. min->MIN, indentation, other.
Rene Dudfield <renesd@gmail.com>
parents:
777
diff
changeset
|
190 char *scrap_type; |
|
1633c4302f48
Some code cleanups from Marcus von Appen. min->MIN, indentation, other.
Rene Dudfield <renesd@gmail.com>
parents:
777
diff
changeset
|
191 PyObject *val; |
|
1633c4302f48
Some code cleanups from Marcus von Appen. min->MIN, indentation, other.
Rene Dudfield <renesd@gmail.com>
parents:
777
diff
changeset
|
192 unsigned long count; |
|
673
33035cf4416e
The start of a 'scrap' module based on the scrap library.
Rene Dudfield <renesd@gmail.com>
parents:
diff
changeset
|
193 |
|
794
1633c4302f48
Some code cleanups from Marcus von Appen. min->MIN, indentation, other.
Rene Dudfield <renesd@gmail.com>
parents:
777
diff
changeset
|
194 PYGAME_SCRAP_INIT_CHECK (); |
|
1633c4302f48
Some code cleanups from Marcus von Appen. min->MIN, indentation, other.
Rene Dudfield <renesd@gmail.com>
parents:
777
diff
changeset
|
195 |
|
1633c4302f48
Some code cleanups from Marcus von Appen. min->MIN, indentation, other.
Rene Dudfield <renesd@gmail.com>
parents:
777
diff
changeset
|
196 if(!PyArg_ParseTuple (args, "s", &scrap_type)) |
|
1633c4302f48
Some code cleanups from Marcus von Appen. min->MIN, indentation, other.
Rene Dudfield <renesd@gmail.com>
parents:
777
diff
changeset
|
197 return NULL; |
|
1633c4302f48
Some code cleanups from Marcus von Appen. min->MIN, indentation, other.
Rene Dudfield <renesd@gmail.com>
parents:
777
diff
changeset
|
198 |
|
1633c4302f48
Some code cleanups from Marcus von Appen. min->MIN, indentation, other.
Rene Dudfield <renesd@gmail.com>
parents:
777
diff
changeset
|
199 if (!pygame_scrap_lost ()) |
|
759
ae48ea30bc50
Some scrap fixes, and code cleanup goodness from Marcus von Appen.
Rene Dudfield <renesd@gmail.com>
parents:
743
diff
changeset
|
200 { |
|
794
1633c4302f48
Some code cleanups from Marcus von Appen. min->MIN, indentation, other.
Rene Dudfield <renesd@gmail.com>
parents:
777
diff
changeset
|
201 /* We are still the active one. */ |
|
1633c4302f48
Some code cleanups from Marcus von Appen. min->MIN, indentation, other.
Rene Dudfield <renesd@gmail.com>
parents:
777
diff
changeset
|
202 switch (_currentmode) |
|
759
ae48ea30bc50
Some scrap fixes, and code cleanup goodness from Marcus von Appen.
Rene Dudfield <renesd@gmail.com>
parents:
743
diff
changeset
|
203 { |
|
794
1633c4302f48
Some code cleanups from Marcus von Appen. min->MIN, indentation, other.
Rene Dudfield <renesd@gmail.com>
parents:
777
diff
changeset
|
204 case SCRAP_SELECTION: |
|
1633c4302f48
Some code cleanups from Marcus von Appen. min->MIN, indentation, other.
Rene Dudfield <renesd@gmail.com>
parents:
777
diff
changeset
|
205 val = PyDict_GetItemString (_selectiondata, scrap_type); |
|
1633c4302f48
Some code cleanups from Marcus von Appen. min->MIN, indentation, other.
Rene Dudfield <renesd@gmail.com>
parents:
777
diff
changeset
|
206 break; |
|
1633c4302f48
Some code cleanups from Marcus von Appen. min->MIN, indentation, other.
Rene Dudfield <renesd@gmail.com>
parents:
777
diff
changeset
|
207 case SCRAP_CLIPBOARD: |
|
1633c4302f48
Some code cleanups from Marcus von Appen. min->MIN, indentation, other.
Rene Dudfield <renesd@gmail.com>
parents:
777
diff
changeset
|
208 default: |
|
1633c4302f48
Some code cleanups from Marcus von Appen. min->MIN, indentation, other.
Rene Dudfield <renesd@gmail.com>
parents:
777
diff
changeset
|
209 val = PyDict_GetItemString (_clipdata, scrap_type); |
|
1633c4302f48
Some code cleanups from Marcus von Appen. min->MIN, indentation, other.
Rene Dudfield <renesd@gmail.com>
parents:
777
diff
changeset
|
210 break; |
|
759
ae48ea30bc50
Some scrap fixes, and code cleanup goodness from Marcus von Appen.
Rene Dudfield <renesd@gmail.com>
parents:
743
diff
changeset
|
211 } |
|
794
1633c4302f48
Some code cleanups from Marcus von Appen. min->MIN, indentation, other.
Rene Dudfield <renesd@gmail.com>
parents:
777
diff
changeset
|
212 Py_XINCREF (val); |
|
1633c4302f48
Some code cleanups from Marcus von Appen. min->MIN, indentation, other.
Rene Dudfield <renesd@gmail.com>
parents:
777
diff
changeset
|
213 return val; |
|
759
ae48ea30bc50
Some scrap fixes, and code cleanup goodness from Marcus von Appen.
Rene Dudfield <renesd@gmail.com>
parents:
743
diff
changeset
|
214 } |
|
673
33035cf4416e
The start of a 'scrap' module based on the scrap library.
Rene Dudfield <renesd@gmail.com>
parents:
diff
changeset
|
215 |
|
794
1633c4302f48
Some code cleanups from Marcus von Appen. min->MIN, indentation, other.
Rene Dudfield <renesd@gmail.com>
parents:
777
diff
changeset
|
216 /* pygame_get_scrap() only returns NULL or !NULL, but won't set any |
|
1633c4302f48
Some code cleanups from Marcus von Appen. min->MIN, indentation, other.
Rene Dudfield <renesd@gmail.com>
parents:
777
diff
changeset
|
217 * errors. */ |
|
1633c4302f48
Some code cleanups from Marcus von Appen. min->MIN, indentation, other.
Rene Dudfield <renesd@gmail.com>
parents:
777
diff
changeset
|
218 scrap = pygame_scrap_get (scrap_type, &count); |
|
1633c4302f48
Some code cleanups from Marcus von Appen. min->MIN, indentation, other.
Rene Dudfield <renesd@gmail.com>
parents:
777
diff
changeset
|
219 if (!scrap) |
|
1633c4302f48
Some code cleanups from Marcus von Appen. min->MIN, indentation, other.
Rene Dudfield <renesd@gmail.com>
parents:
777
diff
changeset
|
220 Py_RETURN_NONE; |
|
759
ae48ea30bc50
Some scrap fixes, and code cleanup goodness from Marcus von Appen.
Rene Dudfield <renesd@gmail.com>
parents:
743
diff
changeset
|
221 |
|
2167
949ac8c51629
Correct Event readonly attributes test for Python 3.x: the exception raised on assignment differs from 2.x.
Lenard Lindstrom <len-l@telus.net>
parents:
1937
diff
changeset
|
222 retval = Bytes_FromStringAndSize (scrap, count); |
|
759
ae48ea30bc50
Some scrap fixes, and code cleanup goodness from Marcus von Appen.
Rene Dudfield <renesd@gmail.com>
parents:
743
diff
changeset
|
223 return retval; |
|
673
33035cf4416e
The start of a 'scrap' module based on the scrap library.
Rene Dudfield <renesd@gmail.com>
parents:
diff
changeset
|
224 } |
|
801
1d7a19d25215
Some mac scrap fixes from Marcus.
Rene Dudfield <renesd@gmail.com>
parents:
794
diff
changeset
|
225 #endif |
|
673
33035cf4416e
The start of a 'scrap' module based on the scrap library.
Rene Dudfield <renesd@gmail.com>
parents:
diff
changeset
|
226 |
|
801
1d7a19d25215
Some mac scrap fixes from Marcus.
Rene Dudfield <renesd@gmail.com>
parents:
794
diff
changeset
|
227 #if !defined(MAC_SCRAP) |
|
673
33035cf4416e
The start of a 'scrap' module based on the scrap library.
Rene Dudfield <renesd@gmail.com>
parents:
diff
changeset
|
228 /* |
|
794
1633c4302f48
Some code cleanups from Marcus von Appen. min->MIN, indentation, other.
Rene Dudfield <renesd@gmail.com>
parents:
777
diff
changeset
|
229 * This will put a python string into the clipboard. |
|
673
33035cf4416e
The start of a 'scrap' module based on the scrap library.
Rene Dudfield <renesd@gmail.com>
parents:
diff
changeset
|
230 */ |
|
759
ae48ea30bc50
Some scrap fixes, and code cleanup goodness from Marcus von Appen.
Rene Dudfield <renesd@gmail.com>
parents:
743
diff
changeset
|
231 static PyObject* |
|
794
1633c4302f48
Some code cleanups from Marcus von Appen. min->MIN, indentation, other.
Rene Dudfield <renesd@gmail.com>
parents:
777
diff
changeset
|
232 _scrap_put_scrap (PyObject* self, PyObject* args) |
|
759
ae48ea30bc50
Some scrap fixes, and code cleanup goodness from Marcus von Appen.
Rene Dudfield <renesd@gmail.com>
parents:
743
diff
changeset
|
233 { |
|
794
1633c4302f48
Some code cleanups from Marcus von Appen. min->MIN, indentation, other.
Rene Dudfield <renesd@gmail.com>
parents:
777
diff
changeset
|
234 int scraplen; |
|
759
ae48ea30bc50
Some scrap fixes, and code cleanup goodness from Marcus von Appen.
Rene Dudfield <renesd@gmail.com>
parents:
743
diff
changeset
|
235 char *scrap = NULL; |
|
794
1633c4302f48
Some code cleanups from Marcus von Appen. min->MIN, indentation, other.
Rene Dudfield <renesd@gmail.com>
parents:
777
diff
changeset
|
236 char *scrap_type; |
|
831
8749d7c235f8
Changes from Marcus for ref counting bug fixes and
Rene Dudfield <renesd@gmail.com>
parents:
826
diff
changeset
|
237 PyObject *tmp; |
|
2167
949ac8c51629
Correct Event readonly attributes test for Python 3.x: the exception raised on assignment differs from 2.x.
Lenard Lindstrom <len-l@telus.net>
parents:
1937
diff
changeset
|
238 #if PY3 |
|
949ac8c51629
Correct Event readonly attributes test for Python 3.x: the exception raised on assignment differs from 2.x.
Lenard Lindstrom <len-l@telus.net>
parents:
1937
diff
changeset
|
239 static const char argfmt[] = "sy#"; |
|
949ac8c51629
Correct Event readonly attributes test for Python 3.x: the exception raised on assignment differs from 2.x.
Lenard Lindstrom <len-l@telus.net>
parents:
1937
diff
changeset
|
240 #else |
|
949ac8c51629
Correct Event readonly attributes test for Python 3.x: the exception raised on assignment differs from 2.x.
Lenard Lindstrom <len-l@telus.net>
parents:
1937
diff
changeset
|
241 static char argfmt[] = "st#"; |
|
949ac8c51629
Correct Event readonly attributes test for Python 3.x: the exception raised on assignment differs from 2.x.
Lenard Lindstrom <len-l@telus.net>
parents:
1937
diff
changeset
|
242 #endif |
|
673
33035cf4416e
The start of a 'scrap' module based on the scrap library.
Rene Dudfield <renesd@gmail.com>
parents:
diff
changeset
|
243 |
|
759
ae48ea30bc50
Some scrap fixes, and code cleanup goodness from Marcus von Appen.
Rene Dudfield <renesd@gmail.com>
parents:
743
diff
changeset
|
244 PYGAME_SCRAP_INIT_CHECK (); |
|
673
33035cf4416e
The start of a 'scrap' module based on the scrap library.
Rene Dudfield <renesd@gmail.com>
parents:
diff
changeset
|
245 |
|
2167
949ac8c51629
Correct Event readonly attributes test for Python 3.x: the exception raised on assignment differs from 2.x.
Lenard Lindstrom <len-l@telus.net>
parents:
1937
diff
changeset
|
246 if (!PyArg_ParseTuple (args, argfmt, &scrap_type, &scrap, &scraplen)) { |
|
759
ae48ea30bc50
Some scrap fixes, and code cleanup goodness from Marcus von Appen.
Rene Dudfield <renesd@gmail.com>
parents:
743
diff
changeset
|
247 return NULL; |
|
2167
949ac8c51629
Correct Event readonly attributes test for Python 3.x: the exception raised on assignment differs from 2.x.
Lenard Lindstrom <len-l@telus.net>
parents:
1937
diff
changeset
|
248 } |
|
673
33035cf4416e
The start of a 'scrap' module based on the scrap library.
Rene Dudfield <renesd@gmail.com>
parents:
diff
changeset
|
249 |
|
794
1633c4302f48
Some code cleanups from Marcus von Appen. min->MIN, indentation, other.
Rene Dudfield <renesd@gmail.com>
parents:
777
diff
changeset
|
250 /* Set it in the clipboard. */ |
|
1633c4302f48
Some code cleanups from Marcus von Appen. min->MIN, indentation, other.
Rene Dudfield <renesd@gmail.com>
parents:
777
diff
changeset
|
251 if (!pygame_scrap_put (scrap_type, scraplen, scrap)) |
|
759
ae48ea30bc50
Some scrap fixes, and code cleanup goodness from Marcus von Appen.
Rene Dudfield <renesd@gmail.com>
parents:
743
diff
changeset
|
252 return RAISE (PyExc_SDLError, |
|
ae48ea30bc50
Some scrap fixes, and code cleanup goodness from Marcus von Appen.
Rene Dudfield <renesd@gmail.com>
parents:
743
diff
changeset
|
253 "content could not be placed in clipboard."); |
|
794
1633c4302f48
Some code cleanups from Marcus von Appen. min->MIN, indentation, other.
Rene Dudfield <renesd@gmail.com>
parents:
777
diff
changeset
|
254 |
|
1633c4302f48
Some code cleanups from Marcus von Appen. min->MIN, indentation, other.
Rene Dudfield <renesd@gmail.com>
parents:
777
diff
changeset
|
255 /* Add or replace the set value. */ |
|
1633c4302f48
Some code cleanups from Marcus von Appen. min->MIN, indentation, other.
Rene Dudfield <renesd@gmail.com>
parents:
777
diff
changeset
|
256 switch (_currentmode) |
|
1633c4302f48
Some code cleanups from Marcus von Appen. min->MIN, indentation, other.
Rene Dudfield <renesd@gmail.com>
parents:
777
diff
changeset
|
257 { |
|
1633c4302f48
Some code cleanups from Marcus von Appen. min->MIN, indentation, other.
Rene Dudfield <renesd@gmail.com>
parents:
777
diff
changeset
|
258 case SCRAP_SELECTION: |
|
831
8749d7c235f8
Changes from Marcus for ref counting bug fixes and
Rene Dudfield <renesd@gmail.com>
parents:
826
diff
changeset
|
259 { |
|
2167
949ac8c51629
Correct Event readonly attributes test for Python 3.x: the exception raised on assignment differs from 2.x.
Lenard Lindstrom <len-l@telus.net>
parents:
1937
diff
changeset
|
260 tmp = Bytes_FromStringAndSize (scrap, scraplen); |
|
831
8749d7c235f8
Changes from Marcus for ref counting bug fixes and
Rene Dudfield <renesd@gmail.com>
parents:
826
diff
changeset
|
261 PyDict_SetItemString (_selectiondata, scrap_type, tmp); |
|
8749d7c235f8
Changes from Marcus for ref counting bug fixes and
Rene Dudfield <renesd@gmail.com>
parents:
826
diff
changeset
|
262 Py_DECREF (tmp); |
|
794
1633c4302f48
Some code cleanups from Marcus von Appen. min->MIN, indentation, other.
Rene Dudfield <renesd@gmail.com>
parents:
777
diff
changeset
|
263 break; |
|
831
8749d7c235f8
Changes from Marcus for ref counting bug fixes and
Rene Dudfield <renesd@gmail.com>
parents:
826
diff
changeset
|
264 } |
|
794
1633c4302f48
Some code cleanups from Marcus von Appen. min->MIN, indentation, other.
Rene Dudfield <renesd@gmail.com>
parents:
777
diff
changeset
|
265 case SCRAP_CLIPBOARD: |
|
1633c4302f48
Some code cleanups from Marcus von Appen. min->MIN, indentation, other.
Rene Dudfield <renesd@gmail.com>
parents:
777
diff
changeset
|
266 default: |
|
831
8749d7c235f8
Changes from Marcus for ref counting bug fixes and
Rene Dudfield <renesd@gmail.com>
parents:
826
diff
changeset
|
267 { |
|
2167
949ac8c51629
Correct Event readonly attributes test for Python 3.x: the exception raised on assignment differs from 2.x.
Lenard Lindstrom <len-l@telus.net>
parents:
1937
diff
changeset
|
268 tmp = Bytes_FromStringAndSize (scrap, scraplen); |
|
831
8749d7c235f8
Changes from Marcus for ref counting bug fixes and
Rene Dudfield <renesd@gmail.com>
parents:
826
diff
changeset
|
269 PyDict_SetItemString (_clipdata, scrap_type, tmp); |
|
8749d7c235f8
Changes from Marcus for ref counting bug fixes and
Rene Dudfield <renesd@gmail.com>
parents:
826
diff
changeset
|
270 Py_DECREF (tmp); |
|
794
1633c4302f48
Some code cleanups from Marcus von Appen. min->MIN, indentation, other.
Rene Dudfield <renesd@gmail.com>
parents:
777
diff
changeset
|
271 break; |
|
1633c4302f48
Some code cleanups from Marcus von Appen. min->MIN, indentation, other.
Rene Dudfield <renesd@gmail.com>
parents:
777
diff
changeset
|
272 } |
|
831
8749d7c235f8
Changes from Marcus for ref counting bug fixes and
Rene Dudfield <renesd@gmail.com>
parents:
826
diff
changeset
|
273 } |
|
794
1633c4302f48
Some code cleanups from Marcus von Appen. min->MIN, indentation, other.
Rene Dudfield <renesd@gmail.com>
parents:
777
diff
changeset
|
274 |
|
759
ae48ea30bc50
Some scrap fixes, and code cleanup goodness from Marcus von Appen.
Rene Dudfield <renesd@gmail.com>
parents:
743
diff
changeset
|
275 Py_RETURN_NONE; |
|
673
33035cf4416e
The start of a 'scrap' module based on the scrap library.
Rene Dudfield <renesd@gmail.com>
parents:
diff
changeset
|
276 } |
|
801
1d7a19d25215
Some mac scrap fixes from Marcus.
Rene Dudfield <renesd@gmail.com>
parents:
794
diff
changeset
|
277 #endif |
|
673
33035cf4416e
The start of a 'scrap' module based on the scrap library.
Rene Dudfield <renesd@gmail.com>
parents:
diff
changeset
|
278 |
|
794
1633c4302f48
Some code cleanups from Marcus von Appen. min->MIN, indentation, other.
Rene Dudfield <renesd@gmail.com>
parents:
777
diff
changeset
|
279 |
|
801
1d7a19d25215
Some mac scrap fixes from Marcus.
Rene Dudfield <renesd@gmail.com>
parents:
794
diff
changeset
|
280 #if !defined(MAC_SCRAP) |
|
794
1633c4302f48
Some code cleanups from Marcus von Appen. min->MIN, indentation, other.
Rene Dudfield <renesd@gmail.com>
parents:
777
diff
changeset
|
281 /* |
|
1633c4302f48
Some code cleanups from Marcus von Appen. min->MIN, indentation, other.
Rene Dudfield <renesd@gmail.com>
parents:
777
diff
changeset
|
282 * Checks whether the pygame window has lost the clipboard. |
|
1633c4302f48
Some code cleanups from Marcus von Appen. min->MIN, indentation, other.
Rene Dudfield <renesd@gmail.com>
parents:
777
diff
changeset
|
283 */ |
|
759
ae48ea30bc50
Some scrap fixes, and code cleanup goodness from Marcus von Appen.
Rene Dudfield <renesd@gmail.com>
parents:
743
diff
changeset
|
284 static PyObject* |
|
794
1633c4302f48
Some code cleanups from Marcus von Appen. min->MIN, indentation, other.
Rene Dudfield <renesd@gmail.com>
parents:
777
diff
changeset
|
285 _scrap_lost_scrap (PyObject* self, PyObject* args) |
|
759
ae48ea30bc50
Some scrap fixes, and code cleanup goodness from Marcus von Appen.
Rene Dudfield <renesd@gmail.com>
parents:
743
diff
changeset
|
286 { |
|
ae48ea30bc50
Some scrap fixes, and code cleanup goodness from Marcus von Appen.
Rene Dudfield <renesd@gmail.com>
parents:
743
diff
changeset
|
287 PYGAME_SCRAP_INIT_CHECK (); |
|
673
33035cf4416e
The start of a 'scrap' module based on the scrap library.
Rene Dudfield <renesd@gmail.com>
parents:
diff
changeset
|
288 |
|
794
1633c4302f48
Some code cleanups from Marcus von Appen. min->MIN, indentation, other.
Rene Dudfield <renesd@gmail.com>
parents:
777
diff
changeset
|
289 if (pygame_scrap_lost ()) |
|
759
ae48ea30bc50
Some scrap fixes, and code cleanup goodness from Marcus von Appen.
Rene Dudfield <renesd@gmail.com>
parents:
743
diff
changeset
|
290 Py_RETURN_TRUE; |
|
ae48ea30bc50
Some scrap fixes, and code cleanup goodness from Marcus von Appen.
Rene Dudfield <renesd@gmail.com>
parents:
743
diff
changeset
|
291 Py_RETURN_FALSE; |
|
677
3e8e94054c55
Clipboard manipulation functions. Still needs a unittest, and
Rene Dudfield <renesd@gmail.com>
parents:
673
diff
changeset
|
292 } |
|
801
1d7a19d25215
Some mac scrap fixes from Marcus.
Rene Dudfield <renesd@gmail.com>
parents:
794
diff
changeset
|
293 #endif |
|
673
33035cf4416e
The start of a 'scrap' module based on the scrap library.
Rene Dudfield <renesd@gmail.com>
parents:
diff
changeset
|
294 |
|
794
1633c4302f48
Some code cleanups from Marcus von Appen. min->MIN, indentation, other.
Rene Dudfield <renesd@gmail.com>
parents:
777
diff
changeset
|
295 |
|
801
1d7a19d25215
Some mac scrap fixes from Marcus.
Rene Dudfield <renesd@gmail.com>
parents:
794
diff
changeset
|
296 #if !defined(MAC_SCRAP) |
|
794
1633c4302f48
Some code cleanups from Marcus von Appen. min->MIN, indentation, other.
Rene Dudfield <renesd@gmail.com>
parents:
777
diff
changeset
|
297 /* |
|
1633c4302f48
Some code cleanups from Marcus von Appen. min->MIN, indentation, other.
Rene Dudfield <renesd@gmail.com>
parents:
777
diff
changeset
|
298 * Sets the clipboard mode. This only works for the X11 environment, which |
|
1633c4302f48
Some code cleanups from Marcus von Appen. min->MIN, indentation, other.
Rene Dudfield <renesd@gmail.com>
parents:
777
diff
changeset
|
299 * diverses between mouse selections and the clipboard. |
|
1633c4302f48
Some code cleanups from Marcus von Appen. min->MIN, indentation, other.
Rene Dudfield <renesd@gmail.com>
parents:
777
diff
changeset
|
300 */ |
|
1633c4302f48
Some code cleanups from Marcus von Appen. min->MIN, indentation, other.
Rene Dudfield <renesd@gmail.com>
parents:
777
diff
changeset
|
301 static PyObject* |
|
1633c4302f48
Some code cleanups from Marcus von Appen. min->MIN, indentation, other.
Rene Dudfield <renesd@gmail.com>
parents:
777
diff
changeset
|
302 _scrap_set_mode (PyObject* self, PyObject* args) |
|
1633c4302f48
Some code cleanups from Marcus von Appen. min->MIN, indentation, other.
Rene Dudfield <renesd@gmail.com>
parents:
777
diff
changeset
|
303 { |
|
1633c4302f48
Some code cleanups from Marcus von Appen. min->MIN, indentation, other.
Rene Dudfield <renesd@gmail.com>
parents:
777
diff
changeset
|
304 PYGAME_SCRAP_INIT_CHECK (); |
|
1633c4302f48
Some code cleanups from Marcus von Appen. min->MIN, indentation, other.
Rene Dudfield <renesd@gmail.com>
parents:
777
diff
changeset
|
305 if (!PyArg_ParseTuple (args, "i", &_currentmode)) |
|
1633c4302f48
Some code cleanups from Marcus von Appen. min->MIN, indentation, other.
Rene Dudfield <renesd@gmail.com>
parents:
777
diff
changeset
|
306 return NULL; |
|
1633c4302f48
Some code cleanups from Marcus von Appen. min->MIN, indentation, other.
Rene Dudfield <renesd@gmail.com>
parents:
777
diff
changeset
|
307 |
|
864
4d8ea3e26e89
Added pygame.scrap unittest. scrap.set_mode() raises an exception on wrong modes now. Minor pixelarray unittest changes.
marcus
parents:
833
diff
changeset
|
308 if (_currentmode != SCRAP_CLIPBOARD && _currentmode != SCRAP_SELECTION) |
|
4d8ea3e26e89
Added pygame.scrap unittest. scrap.set_mode() raises an exception on wrong modes now. Minor pixelarray unittest changes.
marcus
parents:
833
diff
changeset
|
309 return RAISE (PyExc_ValueError, "invalid clipboard mode"); |
|
4d8ea3e26e89
Added pygame.scrap unittest. scrap.set_mode() raises an exception on wrong modes now. Minor pixelarray unittest changes.
marcus
parents:
833
diff
changeset
|
310 |
|
794
1633c4302f48
Some code cleanups from Marcus von Appen. min->MIN, indentation, other.
Rene Dudfield <renesd@gmail.com>
parents:
777
diff
changeset
|
311 #ifndef X11_SCRAP |
|
1633c4302f48
Some code cleanups from Marcus von Appen. min->MIN, indentation, other.
Rene Dudfield <renesd@gmail.com>
parents:
777
diff
changeset
|
312 /* Force the clipboard, if not in a X11 environment. */ |
|
1633c4302f48
Some code cleanups from Marcus von Appen. min->MIN, indentation, other.
Rene Dudfield <renesd@gmail.com>
parents:
777
diff
changeset
|
313 _currentmode = SCRAP_CLIPBOARD; |
|
1633c4302f48
Some code cleanups from Marcus von Appen. min->MIN, indentation, other.
Rene Dudfield <renesd@gmail.com>
parents:
777
diff
changeset
|
314 #endif |
|
1633c4302f48
Some code cleanups from Marcus von Appen. min->MIN, indentation, other.
Rene Dudfield <renesd@gmail.com>
parents:
777
diff
changeset
|
315 Py_RETURN_NONE; |
|
1633c4302f48
Some code cleanups from Marcus von Appen. min->MIN, indentation, other.
Rene Dudfield <renesd@gmail.com>
parents:
777
diff
changeset
|
316 } |
|
1633c4302f48
Some code cleanups from Marcus von Appen. min->MIN, indentation, other.
Rene Dudfield <renesd@gmail.com>
parents:
777
diff
changeset
|
317 |
| 743 | 318 #endif /* !defined(MAC_SCRAP) */ |
| 319 | |
|
673
33035cf4416e
The start of a 'scrap' module based on the scrap library.
Rene Dudfield <renesd@gmail.com>
parents:
diff
changeset
|
320 static PyMethodDef scrap_builtins[] = |
|
33035cf4416e
The start of a 'scrap' module based on the scrap library.
Rene Dudfield <renesd@gmail.com>
parents:
diff
changeset
|
321 { |
|
759
ae48ea30bc50
Some scrap fixes, and code cleanup goodness from Marcus von Appen.
Rene Dudfield <renesd@gmail.com>
parents:
743
diff
changeset
|
322 /* |
|
ae48ea30bc50
Some scrap fixes, and code cleanup goodness from Marcus von Appen.
Rene Dudfield <renesd@gmail.com>
parents:
743
diff
changeset
|
323 * Only initialise these functions for ones we know about. |
|
ae48ea30bc50
Some scrap fixes, and code cleanup goodness from Marcus von Appen.
Rene Dudfield <renesd@gmail.com>
parents:
743
diff
changeset
|
324 * |
|
3108
b4d02ac4a5b7
Clean previous mac_scrap.py using pyobj, in favor of a native implementation
Mathieu Virbel <mat@kivy.org>
parents:
2167
diff
changeset
|
325 * Note, the macosx stuff is done in sdlosx_main.m |
|
759
ae48ea30bc50
Some scrap fixes, and code cleanup goodness from Marcus von Appen.
Rene Dudfield <renesd@gmail.com>
parents:
743
diff
changeset
|
326 */ |
|
794
1633c4302f48
Some code cleanups from Marcus von Appen. min->MIN, indentation, other.
Rene Dudfield <renesd@gmail.com>
parents:
777
diff
changeset
|
327 #if (defined(X11_SCRAP) || defined(WIN_SCRAP) || defined(QNX_SCRAP) \ |
|
1633c4302f48
Some code cleanups from Marcus von Appen. min->MIN, indentation, other.
Rene Dudfield <renesd@gmail.com>
parents:
777
diff
changeset
|
328 || defined(MAC_SCRAP)) |
|
1633c4302f48
Some code cleanups from Marcus von Appen. min->MIN, indentation, other.
Rene Dudfield <renesd@gmail.com>
parents:
777
diff
changeset
|
329 |
|
826
7d9044f4666a
moved the docs out of the scrap.c and into scrap.doc
Rene Dudfield <renesd@gmail.com>
parents:
806
diff
changeset
|
330 { "init", _scrap_init, 1, DOC_PYGAMESCRAPINIT }, |
|
7d9044f4666a
moved the docs out of the scrap.c and into scrap.doc
Rene Dudfield <renesd@gmail.com>
parents:
806
diff
changeset
|
331 { "contains", _scrap_contains, METH_VARARGS, DOC_PYGAMESCRAPCONTAINS }, |
|
7d9044f4666a
moved the docs out of the scrap.c and into scrap.doc
Rene Dudfield <renesd@gmail.com>
parents:
806
diff
changeset
|
332 { "get", _scrap_get_scrap, METH_VARARGS, DOC_PYGAMESCRAPGET }, |
|
7d9044f4666a
moved the docs out of the scrap.c and into scrap.doc
Rene Dudfield <renesd@gmail.com>
parents:
806
diff
changeset
|
333 { "get_types", _scrap_get_types, METH_NOARGS, DOC_PYGAMESCRAPGETTYPES}, |
|
7d9044f4666a
moved the docs out of the scrap.c and into scrap.doc
Rene Dudfield <renesd@gmail.com>
parents:
806
diff
changeset
|
334 { "put", _scrap_put_scrap, METH_VARARGS, DOC_PYGAMESCRAPPUT }, |
|
7d9044f4666a
moved the docs out of the scrap.c and into scrap.doc
Rene Dudfield <renesd@gmail.com>
parents:
806
diff
changeset
|
335 { "lost", _scrap_lost_scrap, METH_NOARGS, DOC_PYGAMESCRAPLOST }, |
|
7d9044f4666a
moved the docs out of the scrap.c and into scrap.doc
Rene Dudfield <renesd@gmail.com>
parents:
806
diff
changeset
|
336 { "set_mode", _scrap_set_mode, METH_VARARGS, DOC_PYGAMESCRAPSETMODE }, |
|
794
1633c4302f48
Some code cleanups from Marcus von Appen. min->MIN, indentation, other.
Rene Dudfield <renesd@gmail.com>
parents:
777
diff
changeset
|
337 |
|
682
a1c5f241adc1
Added macintosh scrap functions. Updated documentation so it didn't
Rene Dudfield <renesd@gmail.com>
parents:
677
diff
changeset
|
338 #endif |
|
794
1633c4302f48
Some code cleanups from Marcus von Appen. min->MIN, indentation, other.
Rene Dudfield <renesd@gmail.com>
parents:
777
diff
changeset
|
339 { NULL, NULL, 0, NULL} |
|
673
33035cf4416e
The start of a 'scrap' module based on the scrap library.
Rene Dudfield <renesd@gmail.com>
parents:
diff
changeset
|
340 }; |
|
33035cf4416e
The start of a 'scrap' module based on the scrap library.
Rene Dudfield <renesd@gmail.com>
parents:
diff
changeset
|
341 |
|
2167
949ac8c51629
Correct Event readonly attributes test for Python 3.x: the exception raised on assignment differs from 2.x.
Lenard Lindstrom <len-l@telus.net>
parents:
1937
diff
changeset
|
342 MODINIT_DEFINE (scrap) |
|
673
33035cf4416e
The start of a 'scrap' module based on the scrap library.
Rene Dudfield <renesd@gmail.com>
parents:
diff
changeset
|
343 { |
|
2167
949ac8c51629
Correct Event readonly attributes test for Python 3.x: the exception raised on assignment differs from 2.x.
Lenard Lindstrom <len-l@telus.net>
parents:
1937
diff
changeset
|
344 PyObject *module; |
|
949ac8c51629
Correct Event readonly attributes test for Python 3.x: the exception raised on assignment differs from 2.x.
Lenard Lindstrom <len-l@telus.net>
parents:
1937
diff
changeset
|
345 |
|
949ac8c51629
Correct Event readonly attributes test for Python 3.x: the exception raised on assignment differs from 2.x.
Lenard Lindstrom <len-l@telus.net>
parents:
1937
diff
changeset
|
346 #if PY3 |
|
949ac8c51629
Correct Event readonly attributes test for Python 3.x: the exception raised on assignment differs from 2.x.
Lenard Lindstrom <len-l@telus.net>
parents:
1937
diff
changeset
|
347 static struct PyModuleDef _module = { |
|
949ac8c51629
Correct Event readonly attributes test for Python 3.x: the exception raised on assignment differs from 2.x.
Lenard Lindstrom <len-l@telus.net>
parents:
1937
diff
changeset
|
348 PyModuleDef_HEAD_INIT, |
|
949ac8c51629
Correct Event readonly attributes test for Python 3.x: the exception raised on assignment differs from 2.x.
Lenard Lindstrom <len-l@telus.net>
parents:
1937
diff
changeset
|
349 "scrap", |
|
949ac8c51629
Correct Event readonly attributes test for Python 3.x: the exception raised on assignment differs from 2.x.
Lenard Lindstrom <len-l@telus.net>
parents:
1937
diff
changeset
|
350 "", |
|
949ac8c51629
Correct Event readonly attributes test for Python 3.x: the exception raised on assignment differs from 2.x.
Lenard Lindstrom <len-l@telus.net>
parents:
1937
diff
changeset
|
351 -1, |
|
949ac8c51629
Correct Event readonly attributes test for Python 3.x: the exception raised on assignment differs from 2.x.
Lenard Lindstrom <len-l@telus.net>
parents:
1937
diff
changeset
|
352 scrap_builtins, |
|
949ac8c51629
Correct Event readonly attributes test for Python 3.x: the exception raised on assignment differs from 2.x.
Lenard Lindstrom <len-l@telus.net>
parents:
1937
diff
changeset
|
353 NULL, NULL, NULL, NULL |
|
949ac8c51629
Correct Event readonly attributes test for Python 3.x: the exception raised on assignment differs from 2.x.
Lenard Lindstrom <len-l@telus.net>
parents:
1937
diff
changeset
|
354 }; |
|
949ac8c51629
Correct Event readonly attributes test for Python 3.x: the exception raised on assignment differs from 2.x.
Lenard Lindstrom <len-l@telus.net>
parents:
1937
diff
changeset
|
355 #endif |
|
794
1633c4302f48
Some code cleanups from Marcus von Appen. min->MIN, indentation, other.
Rene Dudfield <renesd@gmail.com>
parents:
777
diff
changeset
|
356 |
|
1499
65e001d30448
bug fix - required modules not raising error when failing to import.
Lenard Lindstrom <len-l@telus.net>
parents:
1375
diff
changeset
|
357 /* imported needed apis; Do this first so if there is an error |
|
65e001d30448
bug fix - required modules not raising error when failing to import.
Lenard Lindstrom <len-l@telus.net>
parents:
1375
diff
changeset
|
358 the module is not loaded. |
|
65e001d30448
bug fix - required modules not raising error when failing to import.
Lenard Lindstrom <len-l@telus.net>
parents:
1375
diff
changeset
|
359 */ |
|
65e001d30448
bug fix - required modules not raising error when failing to import.
Lenard Lindstrom <len-l@telus.net>
parents:
1375
diff
changeset
|
360 import_pygame_base (); |
|
65e001d30448
bug fix - required modules not raising error when failing to import.
Lenard Lindstrom <len-l@telus.net>
parents:
1375
diff
changeset
|
361 if (PyErr_Occurred ()) { |
|
2167
949ac8c51629
Correct Event readonly attributes test for Python 3.x: the exception raised on assignment differs from 2.x.
Lenard Lindstrom <len-l@telus.net>
parents:
1937
diff
changeset
|
362 MODINIT_ERROR; |
|
1499
65e001d30448
bug fix - required modules not raising error when failing to import.
Lenard Lindstrom <len-l@telus.net>
parents:
1375
diff
changeset
|
363 } |
|
65e001d30448
bug fix - required modules not raising error when failing to import.
Lenard Lindstrom <len-l@telus.net>
parents:
1375
diff
changeset
|
364 |
|
673
33035cf4416e
The start of a 'scrap' module based on the scrap library.
Rene Dudfield <renesd@gmail.com>
parents:
diff
changeset
|
365 /* create the module */ |
|
2167
949ac8c51629
Correct Event readonly attributes test for Python 3.x: the exception raised on assignment differs from 2.x.
Lenard Lindstrom <len-l@telus.net>
parents:
1937
diff
changeset
|
366 #if PY3 |
|
949ac8c51629
Correct Event readonly attributes test for Python 3.x: the exception raised on assignment differs from 2.x.
Lenard Lindstrom <len-l@telus.net>
parents:
1937
diff
changeset
|
367 module = PyModule_Create (&_module); |
|
949ac8c51629
Correct Event readonly attributes test for Python 3.x: the exception raised on assignment differs from 2.x.
Lenard Lindstrom <len-l@telus.net>
parents:
1937
diff
changeset
|
368 #else |
|
949ac8c51629
Correct Event readonly attributes test for Python 3.x: the exception raised on assignment differs from 2.x.
Lenard Lindstrom <len-l@telus.net>
parents:
1937
diff
changeset
|
369 module = Py_InitModule3 (MODPREFIX "scrap", scrap_builtins, NULL); |
|
949ac8c51629
Correct Event readonly attributes test for Python 3.x: the exception raised on assignment differs from 2.x.
Lenard Lindstrom <len-l@telus.net>
parents:
1937
diff
changeset
|
370 #endif |
|
949ac8c51629
Correct Event readonly attributes test for Python 3.x: the exception raised on assignment differs from 2.x.
Lenard Lindstrom <len-l@telus.net>
parents:
1937
diff
changeset
|
371 |
|
949ac8c51629
Correct Event readonly attributes test for Python 3.x: the exception raised on assignment differs from 2.x.
Lenard Lindstrom <len-l@telus.net>
parents:
1937
diff
changeset
|
372 MODINIT_RETURN (module); |
|
673
33035cf4416e
The start of a 'scrap' module based on the scrap library.
Rene Dudfield <renesd@gmail.com>
parents:
diff
changeset
|
373 } |
