[gedit/libgpe] Introduce a python wrapper around the gedit python module.



commit 29d2ee69333e07e32555584e0362461b7eb6e2bb
Author: Steve Frécinaux <code istique net>
Date:   Mon Nov 2 19:33:41 2009 +0100

    Introduce a python wrapper around the gedit python module.
    
    This wrapper will be used to provide some overlay on top of the module,
    the same way pygtk does.

 bindings/python/Makefile.am   |   18 +++++++++++-------
 bindings/python/__init__.py   |   24 ++++++++++++++++++++++++
 bindings/python/geditmodule.c |    8 ++++----
 3 files changed, 39 insertions(+), 11 deletions(-)
---
diff --git a/bindings/python/Makefile.am b/bindings/python/Makefile.am
index fbf5411..a22a0b6 100644
--- a/bindings/python/Makefile.am
+++ b/bindings/python/Makefile.am
@@ -1,29 +1,33 @@
 ## Process this file with automake to produce Makefile.in
 
-pymoduledir = $(libdir)/gedit-2/python
+pymoduledir = $(libdir)/gedit-2/python/gedit
+
+pymodule_PYTHON = \
+	__init__.py
+
 pymodule_LTLIBRARIES = \
-	gedit.la
+	_gedit.la
 
-gedit_la_SOURCES =		\
+_gedit_la_SOURCES =		\
 	geditmodule.c
 
-nodist_gedit_la_SOURCES = 	\
+nodist__gedit_la_SOURCES = 	\
 	gedit.c			\
 	geditutils.c		\
 	geditcommands.c
 
-gedit_la_LDFLAGS = \
+_gedit_la_LDFLAGS = \
 	-module -avoid-version	\
 	-export-symbol-regex initgedit
 
-gedit_la_LIBADD = \
+_gedit_la_LIBADD = \
 	$(top_builddir)/gedit/libgedit-2.20.la	\
 	$(PYTHON_LIB_LOC)       \
 	$(PYTHON_LIBS)		\
 	$(PYTHON_EXTRA_LIBS)	\
 	$(PYGTK_LIBS)
 
-gedit_la_CFLAGS = \
+_gedit_la_CFLAGS = \
 	-I$(top_srcdir)					\
 	-I$(top_builddir)				\
 	-I$(top_srcdir)/gedit				\
diff --git a/bindings/python/__init__.py b/bindings/python/__init__.py
new file mode 100644
index 0000000..7373d06
--- /dev/null
+++ b/bindings/python/__init__.py
@@ -0,0 +1,24 @@
+# -*- coding: utf-8 -*-
+#
+#    Gedit Python bindings
+#    Copyright (C) 2009  Steve Frécinaux
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License
+#    along with this program; if not, write to the Free Software
+#    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+
+# Import everything from the binary module
+from gedit._gedit import *
+
+# Make it harder to access the actual module...
+del _gedit
diff --git a/bindings/python/geditmodule.c b/bindings/python/geditmodule.c
index 8a04ca8..9075fdd 100644
--- a/bindings/python/geditmodule.c
+++ b/bindings/python/geditmodule.c
@@ -159,7 +159,7 @@ init_pygedit (void)
 	PyObject *mdict, *mdict2, *tuple;
 
 	/* import gedit */
-	gedit = Py_InitModule ("gedit", pygedit_functions);
+	gedit = Py_InitModule ("gedit._gedit", pygedit_functions);
 	mdict = PyModule_GetDict (gedit);
 	pygedit_register_classes (mdict);
 	pygedit_add_constants (gedit, "GEDIT_");
@@ -173,14 +173,14 @@ init_pygedit (void)
 	Py_DECREF (tuple);
 
 	/* import gedit.utils */
-	geditutils = Py_InitModule ("gedit.utils", pygeditutils_functions);
+	geditutils = Py_InitModule ("gedit._gedit.utils", pygeditutils_functions);
 	mdict2 = PyModule_GetDict (geditutils);
 	pygeditutils_register_classes (mdict2);
 
 	PyDict_SetItemString (mdict, "utils", geditutils);
 
 	/* import gedit.commands */
-	geditcommands = Py_InitModule ("gedit.commands", pygeditcommands_functions);
+	geditcommands = Py_InitModule ("gedit._gedit.commands", pygeditcommands_functions);
 	mdict2 = PyModule_GetDict (geditcommands);
 	pygeditutils_register_classes (geditcommands);
 
@@ -188,7 +188,7 @@ init_pygedit (void)
 }
 
 DL_EXPORT(void)
-initgedit (void)
+init_gedit (void)
 {
 	init_pygobject_check (2, 11, 5);
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]