1 /*
2  * geanypy.h
3  *
4  * Copyright 2011 Matthew Brush <mbrush@codebrainz.ca>
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
19  * 02110-1301  USA.
20  *
21  */
22 
23 #ifndef GEANYPY_H__
24 #define GEANYPY_H__
25 
26 #ifdef __cplusplus
27 extern "C" {
28 #endif
29 
30 /* For plain make file build using Mingw on Windows */
31 #if defined(__MINGW32__) && defined(GEANYPY_WINDOWS_BUILD)
32 #  define GEANYPY_WINDOWS 1
33 #endif
34 
35 #include <Python.h>
36 #ifndef PyMODINIT_FUNC
37 #  define PyMODINIT_FUNC void
38 #endif
39 #include <structmember.h>
40 
41 
42 /* Defines a setter that throws an attribute exception when called. */
43 #define GEANYPY_PROPS_READONLY(cls) \
44 	static int \
45 	cls ## _set_property(cls *self, PyObject *value, const gchar *prop_name) { \
46 		PyErr_SetString(PyExc_AttributeError, "can't set attribute"); \
47 		return -1; }
48 
49 /* Defines a getter/setter for use in the tp_getset table. */
50 #define GEANYPY_GETSETDEF(cls, prop_name, doc) \
51 	{ prop_name, \
52 		(getter) cls ## _get_property, \
53 		(setter) cls ## _set_property, \
54 		doc, \
55 		prop_name }
56 
57 
58 /* Initializes a new `cls` type object. */
59 #define GEANYPY_NEW(cls) \
60 	(cls *) PyObject_CallObject((PyObject *) &(cls ## Type), NULL);
61 
62 
63 /* Returns a new py string or py none if string is NULL. */
64 #define GEANYPY_RETURN_STRING(memb) \
65 	{ \
66 		if (memb != NULL) \
67 			return PyString_FromString(memb); \
68 		else \
69 			Py_RETURN_NONE; \
70 	}
71 
72 
73 #include <stdlib.h>
74 #include <errno.h>
75 #include <string.h>
76 
77 #include <gtk/gtk.h>
78 
79 /* necessary for compilation with -fno-common,
80  * see https://bugzilla.gnome.org/show_bug.cgi?id=610657 for details,
81  * INCLUDE_PYGOBJECT_ONCE_FULL is set only once in geanypy-plugin.c */
82 #ifndef INCLUDE_PYGOBJECT_ONCE_FULL
83 #  define NO_IMPORT_PYGOBJECT
84 #  define NO_IMPORT_PYGTK
85 #endif
86 
87 #include <pygobject.h>
88 
89 #ifndef GEANYPY_WINDOWS
90 /* Used with the results of `pkg-config --cflags pygtk-2.0` */
91 #  include <pygtk/pygtk.h>
92 #else
93 /* On windows the path of pygtk.h is directly an include dir */
94 #  include <pygtk.h>
95 #endif
96 
97 #ifndef GTK
98 #  define GTK
99 #endif
100 #include <Scintilla.h>
101 #include <ScintillaWidget.h>
102 
103 /* Expansion of this Scintilla macro causes name clashes. */
104 #undef NotifyHeader
105 
106 #include <geanyplugin.h>
107 
108 #ifndef G_LOG_DOMAIN
109 #  define G_LOG_DOMAIN "GeanyPy"
110 #endif
111 
112 #include "geanypy-document.h"
113 #include "geanypy-editor.h"
114 #include "geanypy-encoding.h"
115 #include "geanypy-filetypes.h"
116 #include "geanypy-plugin.h"
117 #include "geanypy-project.h"
118 #include "geanypy-scintilla.h"
119 #include "geanypy-signalmanager.h"
120 #include "geanypy-uiutils.h"
121 
122 
123 #ifdef __cplusplus
124 } /* extern "C" */
125 #endif
126 
127 #endif /* GEANYPY_H__ */
128