Commit b5b294aa authored by Xavier Claessens's avatar Xavier Claessens Committed by Xavier Claessens

Add python binding. Fixes bug #457660 (Michael Sheldon).

2007-08-19 Xavier Claessens  <xclaesse@gmail.com>

	* python/pyempathy/pyempathy.defs:
	* python/pyempathy/pyempathymodule.c:
	* python/pyempathy/Makefile.am:
	* python/pyempathy/pyempathy.override:
	* python/pyempathygtk/pyempathygtk.override:
	* python/pyempathygtk/pyempathygtk.defs:
	* python/pyempathygtk/Makefile.am:
	* python/pyempathygtk/pyempathygtkmodule.c:
	* python/Makefile.am:
	* libempathy/empathy-time.h:
	* configure.ac:
	* Makefile.am: Add python binding. Fixes bug #457660 (Michael Sheldon).


svn path=/trunk/; revision=264
parent 6a23f8ca
2007-08-19 Xavier Claessens <xclaesse@gmail.com>
* python/pyempathy/pyempathy.defs:
* python/pyempathy/pyempathymodule.c:
* python/pyempathy/Makefile.am:
* python/pyempathy/pyempathy.override:
* python/pyempathygtk/pyempathygtk.override:
* python/pyempathygtk/pyempathygtk.defs:
* python/pyempathygtk/Makefile.am:
* python/pyempathygtk/pyempathygtkmodule.c:
* python/Makefile.am:
* libempathy/empathy-time.h:
* configure.ac:
* Makefile.am: Add python binding. Fixes bug #457660 (Michael Sheldon).
2007-08-19 Xavier Claessens <xclaesse@gmail.com>
* libempathy-gtk/empathy-main-window.glade: Edit menu should be second
......
SUBDIRS = po data libempathy libempathy-gtk src doc
if HAVE_PYTHON
SUBDIRS += python
endif
DISTCHECK_CONFIGURE_FLAGS = \
--disable-scrollkeeper \
--enable-gtk-doc
......
......@@ -145,7 +145,46 @@ if test "x$enable_aspell" = "xyes" -a "x$have_aspell" != "xyes"; then
AC_MSG_ERROR([Couldn't find aspell.])
fi
dnl -----------------------------------------------------------
dnl Python Bindings
dnl -----------------------------------------------------------
AC_ARG_ENABLE(python,
AS_HELP_STRING([--enable-python=@<:@no/yes/auto@:>@],
[build python bindings to libempathy and libempathy-gtk]), ,
enable_python=auto)
PKG_CHECK_MODULES(PYTHON_BINDING,
[
pygtk-2.0,
glib-2.0 >= $GLIB_REQUIRED
gobject-2.0
gconf-2.0 >= $GCONF_REQUIRED
libxml-2.0
gnome-vfs-2.0
libtelepathy >= $TELEPATHY_REQUIRED
libmissioncontrol >= $MISSION_CONTROL_REQUIRED
gtk+-2.0 >= $GTK_REQUIRED
libglade-2.0 >= $LIBGLADE_REQUIRED
libgnomeui-2.0
], have_python="yes", have_python="no")
if test "x$have_python" = "xno"; then
if test "x$enable_python" = "xyes"; then
AC_MSG_ERROR([Could not find python dependencies])
fi
enable_python="no (missing dependencies)"
else
if test "x$enable_python" != "xno"; then
enable_python="yes"
else
enable_python="no (disabled)"
fi
fi
AM_CONDITIONAL(HAVE_PYTHON, test x$enable_python = xyes)
dnl -----------------------------------------------------------
AC_OUTPUT([
Makefile
data/Makefile
......@@ -164,5 +203,7 @@ AC_OUTPUT([
doc/Makefile
doc/libempathy/Makefile
doc/libempathy-gtk/Makefile
python/Makefile
python/pyempathy/Makefile
python/pyempathygtk/Makefile
])
......@@ -21,7 +21,9 @@
#ifndef __EMPATHY_TIME_H__
#define __EMPATHY_TIME_H__
#ifndef __USE_XOPEN
#define __USE_XOPEN
#endif
#include <time.h>
#include <glib.h>
......
SUBDIRS = pyempathy pyempathygtk
PYDEFS=`pkg-config --variable=defsdir pygtk-2.0`
AM_CPPFLAGS = \
-I. \
-I$(top_srcdir)/libempathy \
-I$(top_srcdir) \
-DDATADIR=\""$(datadir)"\" \
$(PYTHON_BINDING_CFLAGS) \
`python-config --cflags` \
$(WARN_CFLAGS)
BUILT_SOURCES = \
pyempathy.c
pyempathydir = $(prefix)/lib/`pyversions -d`/site-packages
pyempathy_LTLIBRARIES = empathy.la
empathy_la_SOURCES = \
pyempathymodule.c \
pyempathy.c
empathy_la_LIBADD = \
$(PYTHON_BINDING_LIBS) \
$(top_builddir)/libempathy/libempathy.la
empathy_la_LDFLAGS = \
`python-config --libs` \
-module -avoid-version
pyempathy.c: pyempathy.override pyempathy.defs
pygtk-codegen-2.0 --prefix empathy \
--register $(PYDEFS)/gdk-types.defs \
--register $(PYDEFS)/gtk-types.defs \
--override pyempathy.override \
pyempathy.defs > $@
CLEANFILES = $(BUILT_SOURCES)
This diff is collapsed.
%%
headers
#include <Python.h>
#include <pygobject.h>
#include "empathy-avatar.h"
#include "empathy-chandler.h"
#include "empathy-chatroom-manager.h"
#include "empathy-chatroom.h"
#include "empathy-conf.h"
#include "empathy-contact-list.h"
#include "empathy-contact-manager.h"
#include "empathy-contact.h"
#include "empathy-debug.h"
#include "empathy-filter.h"
#include "empathy-idle.h"
#include "empathy-log-manager.h"
#include "empathy-marshal.h"
#include "empathy-message.h"
#include "empathy-presence.h"
#include "empathy-time.h"
#include "empathy-tp-chat.h"
#include "empathy-tp-chatroom.h"
#include "empathy-tp-contact-list.h"
#include "empathy-tp-group.h"
#include "empathy-utils.h"
/* FIXME */
#define MC_TYPE_PRESENCE 1
#define EMPATHY_TYPE_SUBSCRIPTION 2
#define EMPATHY_TYPE_MESSAGE_TYPE 3
#define EMPATHY_TYPE_REG_EX_TYPE 4
void empathy_add_constants(PyObject *module, const gchar *strip_prefix);
void empathy_register_classes(PyObject *d);
%%
modulename empathy
%%
ignore-glob
*_get_type
%%
import gobject.GObject as PyGObject_Type
%%
override empathy_contact_list_get_members kwargs
static PyObject *
_wrap_empathy_contact_list_get_members(PyGObject *self, PyObject *args, PyObject *kwargs)
{
PyObject *py_contacts = PyList_New(0);
GList *l, *contacts;
contacts = empathy_contact_list_get_members(EMPATHY_CONTACT_LIST(self->obj));
for (l = contacts; l; l = l->next) {
EmpathyContact *contact;
contact = l->data;
PyList_Append(py_contacts, pygobject_new((GObject *) contact));
}
return py_contacts;
}
%%
override empathy_contact_get_groups kwargs
static PyObject *
_wrap_empathy_contact_get_groups(PyGObject *self, PyObject *args, PyObject *kwargs)
{
GList *groups = empathy_contact_get_groups(EMPATHY_CONTACT(self->obj));
PyObject *py_groups = PyList_New(0);
GList *l;
for(l = groups; l; l = l->next) {
const gchar *group;
group = l->data;
PyList_Append(py_groups, PyString_FromString(group));
}
return py_groups;
}
%%
#include <pygobject.h>
void empathy_register_classes (PyObject *d);
DL_EXPORT(void) initempathy(void);
extern PyMethodDef empathy_functions[];
DL_EXPORT(void)
initempathy(void)
{
PyObject *m, *d;
init_pygobject ();
m = Py_InitModule ("empathy", empathy_functions);
d = PyModule_GetDict (m);
empathy_register_classes (d);
if (PyErr_Occurred ()) {
PyErr_Print();
Py_FatalError ("can't initialise module empathy");
}
}
PYDEFS=`pkg-config --variable=defsdir pygtk-2.0`
AM_CPPFLAGS = \
-I. \
-I$(top_srcdir)/libempathy-gtk \
-I$(top_srcdir) \
-DDATADIR=\""$(datadir)"\" \
$(PYTHON_BINDING_CFLAGS) \
`python-config --cflags`
BUILT_SOURCES = \
pyempathygtk.c
pyempathygtkdir = $(prefix)/lib/`pyversions -d`/site-packages
pyempathygtk_LTLIBRARIES = empathygtk.la
empathygtk_la_SOURCES = \
pyempathygtkmodule.c \
pyempathygtk.c
empathygtk_la_LIBADD = \
$(PYTHON_BINDING_LIBS) \
$(top_builddir)/libempathy/libempathy.la \
$(top_builddir)/libempathy-gtk/libempathy-gtk.la
empathygtk_la_LDFLAGS = \
`python-config --libs` \
-module -avoid-version
pyempathygtk.c: pyempathygtk.override pyempathygtk.defs
pygtk-codegen-2.0 --prefix empathy \
--register $(PYDEFS)/gdk-types.defs \
--register $(PYDEFS)/gtk-types.defs \
--register ../pyempathy/pyempathy.defs \
--override pyempathygtk.override \
pyempathygtk.defs > $@
CLEANFILES = $(BUILT_SOURCES)
This diff is collapsed.
%%
headers
#include <Python.h>
#include <pygobject.h>
#include "empathy-about-dialog.h"
#include "empathy-account-chooser.h"
#include "empathy-accounts-dialog.h"
#include "empathy-account-widget-generic.h"
#include "empathy-account-widget-jabber.h"
#include "empathy-account-widget-msn.h"
#include "empathy-cell-renderer-expander.h"
#include "empathy-cell-renderer-text.h"
#include "empathy-chat.h"
#include "empathy-chatrooms-window.h"
#include "empathy-chat-view.h"
#include "empathy-chat-window.h"
#include "empathy-contact-dialogs.h"
#include "empathy-contact-groups.h"
#include "empathy-contact-list-store.h"
#include "empathy-contact-list-view.h"
#include "empathy-contact-widget.h"
#include "empathy-geometry.h"
#include "empathy-group-chat.h"
#include "empathy-images.h"
#include "empathy-log-window.h"
#include "empathy-main-window.h"
#include "empathy-new-chatroom-dialog.h"
#include "empathy-preferences.h"
#include "empathy-presence-chooser.h"
#include "empathy-private-chat.h"
#include "empathy-profile-chooser.h"
#include "empathy-spell-dialog.h"
#include "empathy-spell.h"
#include "empathy-status-icon.h"
#include "empathy-status-presets.h"
#include "empathy-theme-manager.h"
#include "empathy-ui-utils.h"
#include "ephy-spinner.h"
/* FIXME */
#define EMPATHY_TYPE_SMILEY 1
#define EMPATHY_TYPE_CONTACT_LIST_STORE_COL 2
#define EMPATHY_TYPE_CONTACT_LIST_STORE_SORT 3
#define EMPATHY_TYPE_CONTACT_WIDGET_TYPE 4
void empathy_add_constants(PyObject *module, const gchar *strip_prefix);
void empathy_register_classes(PyObject *d);
%%
modulename empathygtk
%%
import gobject.GObject as PyGObject_Type
import gtk.Widget as PyGtkWidget_Type
import gtk.Window as PyGtkWindow_Type
import gtk.CellRenderer as PyGtkCellRenderer_Type
import gtk.CellRendererText as PyGtkCellRendererText_Type
import gtk.TextView as PyGtkTextView_Type
import gtk.TreeView as PyGtkTreeView_Type
import gtk.TreeStore as PyGtkTreeStore_Type
import gtk.ToggleButton as PyGtkToggleButton_Type
import gtk.ComboBox as PyGtkComboBox_Type
import gtk.StatusIcon as PyGtkStatusIcon_Type
import empathy.Contact as PyEmpathyContact_Type
import empathy.ContactList as PyEmpathyContactList_Type
import empathy.TpChat as PyEmpathyTpChat_Type
import empathy.Presence as PyEmpathyPresence_Type
import empathy.Message as PyEmpathyMessage_Type
%%
ignore-glob
*_get_type
%%
ignore
empathy_chat_correct_word
empathy_chat_view_set_margin
empathy_chat_get_view
empathy_spell_dialog_show
empathy_window_iconify
%%
#include <pygobject.h>
void empathy_register_classes (PyObject *d);
DL_EXPORT(void) initempathygtk(void);
extern PyMethodDef empathy_functions[];
DL_EXPORT(void) initempathygtk(void)
{
PyObject *m, *d;
init_pygobject ();
m = Py_InitModule ("empathygtk", empathy_functions);
d = PyModule_GetDict (m);
empathy_register_classes (d);
if (PyErr_Occurred ()) {
PyErr_Print();
Py_FatalError ("can't initialise module empathygtk");
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment