python-efl: Initial work on edbus bindings.

Still needs the setup function that takes an existing connection to work 
properly.


SVN revision: 84395
This commit is contained in:
Kai Huuhko 2013-02-28 16:13:07 +00:00
parent 9ac077a8d1
commit 26902af425
5 changed files with 107 additions and 9 deletions

22
INSTALL
View File

@ -9,14 +9,16 @@
- Tested with Cython 0.17.3
* EFL core library
- eo, evas, ecore, edje, elementary and emotion
- eo, evas, ecore, edje, elementary, edbus and emotion
* pkg-config (http://www.freedesktop.org/wiki/Software/pkg-config)
- Windows executable (and GLib dependency) can be downloaded from
http://www.gtk.org/download/win32.php
* To build the DOCS you will also need:
- python-sphinx, graphviz
- python-sphinx
- [optional] graphviz
- [optional] youtube module from the sphinx contrib repository.
@ -61,7 +63,9 @@
4. DOCUMENTATION:
-----------------
To build the docs for the bindings you need Sphinx and Graphvix installed.
To build the docs for the bindings you need to have Sphinx installed, for
(optional) graphs you need Graphviz, for (optional) Youtube demonstration
videos you need the YouTube module from sphinx contrib repository.
packages: python-sphinx, graphviz
Once installed run:
@ -69,27 +73,27 @@
You will find the generated html docs under the folder:
build/sphinx/html
5. TESTS and EXAMPLES:
----------------------
The tests/ folder contain all the unit tests available, you can run individual
The tests/ folder contains all the unit tests available, you can run individual
tests or use the 00_run_all_tests.py in each folder or even in the tests/ base
dir to run all the tests at once.
The examples/ folder instead contain scripts that must be run by the user
as they need some sort of interaction.
The scripts in examples/ folder must be run by the user as they require
user interaction.
6. UNINSTALL:
-------------
Unfortunatly setup.py do not provide a way to remove the installed packages,
Unfortunately setup.py does not provide a way to remove the installed packages,
To completly remove the installed stuff just remove the 'efl' folder in
To completely remove the installed stuff just remove the 'efl' folder in
your python installation, usually /usr/(local/)lib/pythonX.X/dist-packages/efl

28
efl/edbus/edbus.pxd Normal file
View File

@ -0,0 +1,28 @@
from cpython cimport PyObject
from libc.string cimport const_char
from enums cimport EDBus_Connection_Type
cdef extern from "dbus/dbus.h":
ctypedef int dbus_bool_t
ctypedef struct DBusConnection
ctypedef struct DBusServer
cdef extern from "dbus/dbus-python.h":
ctypedef dbus_bool_t (*_dbus_py_conn_setup_func)(DBusConnection *, void *)
ctypedef dbus_bool_t (*_dbus_py_srv_setup_func)(DBusServer *, void *)
ctypedef void (*_dbus_py_free_func)(void *)
PyObject *DBusPyNativeMainLoop_New4(_dbus_py_conn_setup_func conn_func, _dbus_py_srv_setup_func srv_func, _dbus_py_free_func free_func, void *)
void import_dbus_bindings(const_char *this_module_name)
cdef extern from "Ecore.h":
int ecore_init()
void ecore_shutdown()
cdef extern from "EDBus.h":
ctypedef struct EDBus_Connection
EDBus_Connection *edbus_connection_get(EDBus_Connection_Type type)
void edbus_connection_unref(EDBus_Connection *conn)
int edbus_init()
void edbus_shutdown()

50
efl/edbus/edbus.pyx Normal file
View File

@ -0,0 +1,50 @@
"""D-Bus python integration for Ecore main loop."""
cimport enums
EDBUS_CONNECTION_TYPE_UNKNOWN = enums.EDBUS_CONNECTION_TYPE_UNKNOWN
EDBUS_CONNECTION_TYPE_SESSION = enums.EDBUS_CONNECTION_TYPE_SESSION
EDBUS_CONNECTION_TYPE_SYSTEM = enums.EDBUS_CONNECTION_TYPE_SYSTEM
EDBUS_CONNECTION_TYPE_STARTER = enums.EDBUS_CONNECTION_TYPE_STARTER
EDBUS_CONNECTION_TYPE_LAST = enums.EDBUS_CONNECTION_TYPE_LAST
import dbus
import dbus.mainloop
import atexit
import_dbus_bindings("edbus")
cdef EDBus_Connection *edbc
def module_cleanup():
edbus_connection_unref(edbc)
edbus_shutdown()
ecore_shutdown()
ecore_init()
edbus_init()
atexit.register(module_cleanup)
cdef dbus_bool_t dbus_py_ecore_setup_conn(DBusConnection *conn, void* data):
cdef EDBus_Connection_Type ctype = enums.EDBUS_CONNECTION_TYPE_SESSION
edbc = edbus_connection_get(ctype)
return True
cdef object dbus_ecore_native_mainloop():
cdef PyObject *ml = DBusPyNativeMainLoop_New4(dbus_py_ecore_setup_conn, NULL, NULL, NULL)
return <object>ml
def DBusEcoreMainLoop(set_as_default=False):
"""Returns a NativeMainLoop to attach the Ecore main loop to D-Bus from
within Python."""
ml = dbus_ecore_native_mainloop()
if ml and set_as_default:
res = dbus.set_default_main_loop(ml)
if res is None:
raise RuntimeError("Could not set up main loop")
return ml

7
efl/edbus/enums.pxd Normal file
View File

@ -0,0 +1,7 @@
cdef extern from "EDBus.h":
ctypedef enum EDBus_Connection_Type:
EDBUS_CONNECTION_TYPE_UNKNOWN
EDBUS_CONNECTION_TYPE_SESSION
EDBUS_CONNECTION_TYPE_SYSTEM
EDBUS_CONNECTION_TYPE_STARTER
EDBUS_CONNECTION_TYPE_LAST

View File

@ -94,6 +94,15 @@ emotion_ext = Extension("efl.emotion", ["efl/emotion/efl.emotion.pyx"],
extra_link_args = emotion_libs)
modules.append(emotion_ext)
# EDBus
edbus_cflags, edbus_libs = pkg_config('EDBus', 'edbus2', "1.7.99")
pydbus_cflags, pydbus_libs = pkg_config('dbus-python', 'dbus-python')
edbus_ext = Extension("efl.edbus", ["efl/edbus/edbus.pyx"],
include_dirs = ['include/'],
extra_compile_args = edbus_cflags + pydbus_cflags + ecore_cflags,
extra_link_args = edbus_libs)
modules.append(edbus_ext)
# Elementary
elm_cflags, elm_libs = pkg_config('Elementary', 'elementary', "1.7.99")
elm_exts = [