[libpeas] Link against pygobject 3.
- From: Ignacio Casal Quinteiro <icq src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libpeas] Link against pygobject 3.
- Date: Tue, 16 Aug 2011 09:30:43 +0000 (UTC)
commit 653f943222a9642533771932f4eb0430438a69af
Author: Ignacio Casal Quinteiro <icq gnome org>
Date: Mon Aug 15 13:13:45 2011 +0200
Link against pygobject 3.
configure.ac | 10 ++++----
loaders/python/peas-plugin-loader-python.c | 24 +++++-------------
peas-demo/plugins/pythonhello/pythonhello.py | 8 +++---
.../plugins/extension-python/extension-python.py | 25 +++++++------------
4 files changed, 25 insertions(+), 42 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 269c1fa..fead888 100644
--- a/configure.ac
+++ b/configure.ac
@@ -298,8 +298,8 @@ PYTHON_REQUIRED=2.5.2
dnl Used by the Python loader to check the PyGObject version at runtime
PYGOBJECT_MAJOR_VERSION=2
-PYGOBJECT_MINOR_VERSION=28
-PYGOBJECT_MICRO_VERSION=0
+PYGOBJECT_MINOR_VERSION=90
+PYGOBJECT_MICRO_VERSION=2
PYGOBJECT_REQUIRED=$PYGOBJECT_MAJOR_VERSION.$PYGOBJECT_MINOR_VERSION.$PYGOBJECT_MICRO_VERSION
AC_ARG_ENABLE(python,
@@ -333,7 +333,7 @@ else
AC_MSG_CHECKING([for PyGObject availability.])
if test "$found_python" = "yes"; then
- PKG_CHECK_EXISTS([pygobject-2.0 >= $PYGOBJECT_REQUIRED],,
+ PKG_CHECK_EXISTS([pygobject-3.0 >= $PYGOBJECT_REQUIRED],,
[found_python="no (pygobject >= $PYGOBJECT_REQUIRED) not found)"])
fi
AC_MSG_RESULT([$found_python])
@@ -347,8 +347,8 @@ if test "$enable_python" = "yes" -a "$found_python" != "yes"; then
fi
if test "$found_python" = "yes"; then
- PYTHON_CFLAGS="`$PKG_CONFIG --cflags pygobject-2.0` `$PYTHON_CONFIG --includes`"
- PYTHON_LIBS="`$PKG_CONFIG --libs pygobject-2.0` `$PYTHON_CONFIG --libs`"
+ PYTHON_CFLAGS="`$PKG_CONFIG --cflags pygobject-3.0` `$PYTHON_CONFIG --includes`"
+ PYTHON_LIBS="`$PKG_CONFIG --libs pygobject-3.0` `$PYTHON_CONFIG --libs`"
AC_SUBST(PYTHON_CFLAGS)
AC_SUBST(PYTHON_LIBS)
diff --git a/loaders/python/peas-plugin-loader-python.c b/loaders/python/peas-plugin-loader-python.c
index eb59ffa..2d713fd 100644
--- a/loaders/python/peas-plugin-loader-python.c
+++ b/loaders/python/peas-plugin-loader-python.c
@@ -30,8 +30,8 @@
/* _POSIX_C_SOURCE is defined in Python.h and in limits.h included by
* glib-object.h, so we unset it here to avoid a warning. Yep, that's bad. */
#undef _POSIX_C_SOURCE
-#include <Python.h>
#include <pygobject.h>
+#include <Python.h>
#include <signal.h>
#if PY_VERSION_HEX < 0x02050000
@@ -457,30 +457,20 @@ peas_python_init (PeasPluginLoaderPython *loader)
/* Initialize support for threads */
pyg_enable_threads ();
- gobject = PyImport_ImportModule ("gobject");
- if (gobject == NULL)
- {
- g_warning ("Error initializing Python interpreter: could not "
- "import gobject");
-
- goto python_init_error;
- }
-
- mdict = PyModule_GetDict (gobject);
- PyGObject_Type = PyDict_GetItemString (mdict, "GObject");
- if (PyGObject_Type == NULL)
+ gi = PyImport_ImportModule ("gi");
+ if (gi == NULL)
{
g_warning ("Error initializing Python interpreter: could not "
- "get gobject.GObject");
+ "import gi");
goto python_init_error;
}
- gi = PyImport_ImportModule ("gi");
- if (gi == NULL)
+ gobject = PyImport_ImportModule ("gi.repository.GObject");
+ if (gobject == NULL)
{
g_warning ("Error initializing Python interpreter: could not "
- "import gi");
+ "import gobject");
goto python_init_error;
}
diff --git a/peas-demo/plugins/pythonhello/pythonhello.py b/peas-demo/plugins/pythonhello/pythonhello.py
index ea61ef2..923d3d9 100644
--- a/peas-demo/plugins/pythonhello/pythonhello.py
+++ b/peas-demo/plugins/pythonhello/pythonhello.py
@@ -22,17 +22,17 @@
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
##
-import gobject
+from gi.repository import GObject
from gi.repository import Peas
from gi.repository import PeasGtk
from gi.repository import Gtk
LABEL_STRING="Python Says Hello!"
-class PythonHelloPlugin(gobject.GObject, Peas.Activatable):
+class PythonHelloPlugin(GObject.Object, Peas.Activatable):
__gtype_name__ = 'PythonHelloPlugin'
- object = gobject.property(type=gobject.GObject)
+ object = GObject.property(type=GObject.Object)
def do_activate(self):
window = self.object
@@ -51,7 +51,7 @@ class PythonHelloPlugin(gobject.GObject, Peas.Activatable):
def do_update_state(self):
print("PythonHelloPlugin.do_update_state", repr(self.object))
-class PythonHelloConfigurable(gobject.GObject, PeasGtk.Configurable):
+class PythonHelloConfigurable(GObject.Object, PeasGtk.Configurable):
__gtype_name__ = 'PythonHelloConfigurable'
def do_create_configure_widget(self):
diff --git a/tests/libpeas/plugins/extension-python/extension-python.py b/tests/libpeas/plugins/extension-python/extension-python.py
index 34298da..1539481 100644
--- a/tests/libpeas/plugins/extension-python/extension-python.py
+++ b/tests/libpeas/plugins/extension-python/extension-python.py
@@ -1,12 +1,9 @@
# -*- coding: utf-8 -*-
# ex:set ts=4 et sw=4 ai:
-import gobject
-from gi.repository import Introspection, Peas
-
-class CallablePythonPlugin(gobject.GObject, Introspection.Callable):
- __gtype_name__ = "CallablePythonPlugin"
+from gi.repository import GObject, Introspection, Peas
+class CallablePythonPlugin(GObject.Object, Introspection.Callable):
def do_call_with_return(self):
return "Hello, World!";
@@ -19,21 +16,17 @@ class CallablePythonPlugin(gobject.GObject, Introspection.Callable):
def do_call_multi_args(self, in_, inout):
return (inout, in_)
-class PropertiesPythonPlugin(gobject.GObject, Introspection.Properties):
- __gtype_name__ = "PropertiesPythonPlugin"
-
- construct_only = gobject.property(type=str)
+class PropertiesPythonPlugin(GObject.Object, Introspection.Properties):
+ construct_only = GObject.property(type=str)
- read_only = gobject.property(type=str, default="read-only")
+ read_only = GObject.property(type=str, default="read-only")
- write_only = gobject.property(type=str)
-
- readwrite = gobject.property(type=str, default="readwrite")
+ write_only = GObject.property(type=str)
-class ActivatablePythonExtension(gobject.GObject, Peas.Activatable):
- __gtype_name__ = "ActivatablePythonExtension"
+ readwrite = GObject.property(type=str, default="readwrite")
- object = gobject.property(type=gobject.GObject)
+class ActivatablePythonExtension(GObject.Object, Peas.Activatable):
+ object = GObject.property(type=GObject.Object)
def do_activate(self):
pass
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]