Changeset 2805

Show
Ignore:
Timestamp:
09/25/07 20:20:00
Author:
mdoff
Message:

Add python implementations for platform factory. Remove
platform bindings generation.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/ChangeLog

    r2804 r2805  
     12007-09-25  Mark Doffman <mark.doffman@codethink.co.uk> 
     2         
     3        * /bindings/python/*: Remove the platform generation 
     4        from the automatically generated bindings.  
     5 
     6        * /bindings/python/README: Update for changes to the way 
     7        the python bindings are generated. 
     8         
     9        * /tests/python-demo/*: Add implementations of a tny-list 
     10        iterator, platform factory, and account store. Update the  
     11        svn ignore to ignore the compiled python files.  
     12 
     13        * /tests/python-demo/tinymail-python-test.py: Modify to use 
     14        the python implementation of the platform factory. 
     15         
    1162007-09-24  Philip Van Hoof  <pvanhoof@gnome.org> 
    217 
  • trunk/bindings/python/Makefile.am

    r2795 r2805  
    1717tinymail_LTLIBRARIES += uigtk.la  
    1818endif 
    19 tinymail_LTLIBRARIES += platform.la  
    2019 
    2120ptinymail_PYTHON = __init__.py 
     
    4443nodist_uigtk_la_SOURCES = tinymailui-gtk-glue.c 
    4544 
    46 platform_la_LDFLAGS = $(common_ldflags) -export-symbols-regex initplatform 
    47 platform_la_LIBADD = $(LIBTINYMAILUI_LIBS) $(LIBTINYMAIL_LIBS) \ 
    48         $(TINYMAIL_PYTHON_LIBS) \ 
    49         $(top_builddir)/libtinymail/libtinymail-$(API_VERSION).la \ 
    50         $(top_builddir)/$(PLATFORMDIR)/$(PLATFORMDIR)-$(API_VERSION).la \ 
    51         $(top_builddir)/libtinymail-camel/libtinymail-camel-$(API_VERSION).la 
    52 platform_la_SOURCES = tinymail-platformmodule.c 
    53 nodist_platform_la_SOURCES = tinymail-platform-glue.c 
    54  
    5545camel_la_LDFLAGS = $(common_ldflags) -export-symbols-regex initcamel 
    5646camel_la_LIBADD = $(LIBTINYMAILUI_LIBS) $(LIBTINYMAIL_LIBS) \ 
     
    6555 
    6656CLEANFILES = tinymail-glue.c tinymailui-glue.c tinymailui-gtk-glue.c \ 
    67         tinymail-platform.defs tinymail-platform-glue.c platform_include.h tinymail.defs \ 
     57        tinymail.defs \ 
    6858        tinymailui.defs tinymailui-gtk.defs \ 
    6959        tinymail-camel.defs tinymail-camel-glue.c 
     
    10292        tinymailui-gtk.defs > $@ 
    10393 
    104 TINYMAIL_PLATFORM_DEFS = $(top_srcdir)/bindings/python/tinymail-platform-base.defs 
    105  
    106 tinymail-platform.defs: $(TINYMAIL_PLATFORM_DEFS) 
    107         $(CREATEDEFS) $@ $(TINYMAIL_PLATFORM_DEFS) 
    108  
    109 platform_include.h: 
    110         ls $(top_srcdir)/libtinymail-gnome-desktop/*h | grep -v \\-priv | sed 's/^/\#include\ \"/g' | sed 's/\.h/\.h\"/g' > $@ 
    111  
    112 tinymail-platform-glue.c: tinymail-platform.defs tinymail-platform.override platform_include.h 
    113         $(PYGTK_CODEGEN) --prefix pyplatform \ 
    114         --register tinymailui.defs \ 
    115         --register tinymail.defs \ 
    116         --register tinymail-camel.defs \ 
    117         --override $(top_srcdir)/bindings/python/tinymail-platform.override \ 
    118         tinymail-platform.defs > $@ 
    119  
    12094TINYMAIL_CAMEL_DEFS = $(top_srcdir)/bindings/python/tinymail-camel-base.defs \ 
    12195        $(top_srcdir)/bindings/python/tinymail-camel-extra.defs 
     
    132106EXTRA_DIST = filter.py tinymail.override \ 
    133107        tinymailui.override tinymailui-gtk.override \ 
    134         tinymail-platform.override tinymail-camel.override \ 
     108        tinymail-camel.override \ 
    135109        tinymail-camel-base.defs tinymail-camel-extra.defs \ 
    136110        tinymail-base.defs tinymail-extra.defs \ 
    137         tinymailui-gtk-base.defs tinymail-platform-base.defs
     111        tinymailui-gtk-base.defs
    138112        tinymailui-base.defs createdefs.py pytny-status.h \ 
    139         platform_include.h pytny-session-camel.h 
     113        pytny-session-camel.h 
    140114 
    141115# 
    142116#       pytny-status.c pytny-session-camel.c tinymailmodule.c \ 
    143 #       tinymail-camelmodule.c tinymail-platformmodule.c
     117#       tinymail-camelmodule.c
    144118#       tinymailui-gtkmodule.c tinymailuimodule.c 
    145119# 
  • trunk/bindings/python/README

    r1533 r2805  
    22---------------- 
    33 
    4 The generator will generate a binding for libtinymail, libtinymailui, the 
    5 selected platform library $(PLATFORMDIR) and libtinymail-camel. 
     4The generator will generate a binding for libtinymail, libtinymailui 
     5and libtinymail-camel. 
    66 
    7 o. It will first use h2def.py to generate out of the .h files of each target 
    8 a list of defines to the standard output 
     7o. The .defs files are checked in as tinymail-base.defs. These can be generated  
     8using the Makefile in /gendefs, but this is not done during the normal course of a build. 
    99 
    10 o. The filter.py(.in) script will read that as standard input. This script will 
    11 also read a .defs.extra file. It will avoid duplicate defines where it will  
    12 prefer the define in the .defs.extra file. It will also append all the other 
    13 defines of the .defs.extra file to the standard output 
    14  
    15 o. The standard output is set to $@ in the Makefile.am. It generates tinymail.defs, 
    16 tinymailui.defs, tinymailui-gtk.defs and tinymail-platform.defs 
    17  
    18 o. Using those .defs files and the non-generated .override files, pygtk-codegen 
     10o. Using those .defs files and the .override files, pygtk-codegen 
    1911generates -glue.c files. Those are compiled to the .so file that gets installed 
    2012in the site-packages directory. 
     
    3325Special defines 
    3426--------------- 
    35 You can override and define extra defines in tinymail.defs.extra,  
    36 tinymailui.defs.extra, tinymailui-gtk.defs.extra and  
    37 tinymail-platform.defs.extra 
     27You can override and define extra defines in tinymail-extra.defs, 
     28tinymailui-extra.defs, tinymailui-gtk-extra.defs and  
     29tinymail-camel-extra.defs 
    3830 
    3931Overrides 
     
    4133 
    4234Overrides go in the .override files 
    43  
  • trunk/bindings/python/tinymail.override

    r2772 r2805  
    172172%% 
    173173override tny_folder_change_get_rename noargs 
     174static PyObject* 
    174175_wrap_tny_folder_change_get_rename (PyGObject *self) 
    175176{ 
     
    180181    return Py_BuildValue("ss", rename, oldname); 
    181182} 
    182  
    183  
    184  
    185  
    186      
    187  
     183%% 
     184override tny_list_foreach args  
     185 
     186typedef struct { 
     187    PyObject* func; 
     188    PyObject* data; 
     189} PyTnyListForeachCaller; 
     190 
     191static void 
     192pytny_list_foreach_marshal(GObject* obj, gpointer data) 
     193
     194    PyGILState_STATE state; 
     195    PyTnyListForeachCaller *call =  (PyTnyListForeachCaller*) data; 
     196    PyObject *pyobj, *retobj; 
     197 
     198    g_assert(call->func); 
     199 
     200    state = pyg_gil_state_ensure(); 
     201 
     202    pyobj = pygobject_new(obj); 
     203    if (call->data) 
     204        retobj = PyEval_CallFunction(call->func, "(NO)", 
     205                                     pyobj, call->data); 
     206    else 
     207        retobj = PyEval_CallFunction(call->func, "(N)", 
     208                                     pyobj); 
     209 
     210    if (retobj == NULL) { 
     211        PyErr_Print(); 
     212    } 
     213 
     214    Py_XDECREF(retobj); 
     215 
     216    pyg_gil_state_release(state); 
     217
     218     
     219 
     220static PyObject * 
     221_wrap_tny_list_foreach(PyGObject* self, PyObject* args) 
     222
     223    PyTnyListForeachCaller call; 
     224    call.data = NULL; 
     225 
     226    if (!PyArg_ParseTuple(args, "O|O",  
     227                          &call.func, &call.data)) 
     228         return NULL; 
     229 
     230    tny_list_foreach(TNY_LIST(self->obj), (GFunc) pytny_list_foreach_marshal, &call); 
     231    Py_RETURN_NONE; 
     232
     233 
     234%% 
     235override TnyList__do_foreach_func args 
     236 
     237static PyObject * 
     238_wrap_TnyList__do_foreach_func(PyGObject *self, PyObject *args) 
     239
     240    TnyListIface *iface; 
     241    PyTnyListForeachCaller call; 
     242 
     243    if (!PyArg_ParseTuple(args, "O|O",  
     244                          &call.func, &call.data)) 
     245         return NULL; 
     246 
     247    iface = g_type_interface_peek(g_type_class_peek(pyg_type_from_object((PyObject*)self)), TNY_TYPE_LIST); 
     248    if (iface->foreach_func) 
     249        iface->foreach_func(TNY_LIST(self->obj), (GFunc) pytny_list_foreach_marshal, (gpointer) &call); 
     250    else { 
     251        PyErr_SetString(PyExc_NotImplementedError, "interface method TnyList.foreach not implemented"); 
     252        return NULL; 
     253    } 
     254    Py_RETURN_NONE; 
     255
     256 
     257%% 
     258override TnyList__proxy_do_foreach_func 
     259 
     260typedef struct { 
     261    GFunc func; 
     262    gpointer data; 
     263} PyTnyListFuncData; 
     264 
     265static PyObject * 
     266pytny_list_forall_proxy_func(PyObject *self, PyObject *args) 
     267
     268    PyObject *py_obj; 
     269    PyObject *py_data; 
     270    PyTnyListFuncData *data;  
     271    if (!PyArg_ParseTuple(args, "O!O!", 
     272                          &PyGObject_Type, &py_obj, 
     273                          &PyCObject_Type, &py_data)) 
     274        return NULL; 
     275     
     276    data = PyCObject_AsVoidPtr(py_data); 
     277    data->func(G_OBJECT(pygobject_get(py_obj)), data->data); 
     278     
     279    Py_RETURN_NONE; 
     280
     281 
     282static void 
     283_wrap_TnyList__proxy_do_foreach_func (TnyList* self, 
     284                                      GFunc func, 
     285                                      gpointer user_data) 
     286
     287    PyGILState_STATE state; 
     288    PyObject *py_obj, *py_func, *py_data; 
     289    PyMethodDef py_func_def = { "TnyList.do_foreach callback", 
     290                                (PyCFunction) pytny_list_forall_proxy_func, 
     291                                METH_VARARGS }; 
     292    PyTnyListFuncData *data;  
     293 
     294    state = pyg_gil_state_ensure(); 
     295    py_obj = pygobject_new((GObject*) self); 
     296    py_func = PyCFunction_NewEx(&py_func_def, NULL, NULL); 
     297 
     298    data = g_new(PyTnyListFuncData, 1); 
     299    data->func = func; 
     300    data->data = user_data; 
     301    py_data = PyCObject_FromVoidPtr(data, g_free);  
     302    if (!PyObject_CallMethod(py_obj, "do_foreach_func", "NN",  
     303                             py_func, 
     304                             py_data)) 
     305        PyErr_Print(); 
     306     
     307    pyg_gil_state_release(state); 
     308
     309 
     310 
     311     
     312 
     313     
    188314     
    189315 
  • trunk/bindings/python/tinymailui-gtk.override

    r2772 r2805  
    4242import gtk.TextView as PyGtkTextView_Type 
    4343 
    44 import tinymai.Header as PyTnyHeader_Type 
     44import tinymail.Header as PyTnyHeader_Type 
    4545import tinymail.Folder as PyTnyFolder_Type 
    4646import tinymail.MimePart as PyTnyMimePart_Type 
    47 import tinymai.Msg as PyTnyMsg_Type 
     47import tinymail.Msg as PyTnyMsg_Type 
    4848import tinymail.List as PyTnyList_Type 
    4949import tinymail.FolderStore as PyTnyFolderStore_Type 
  • trunk/tests/python-demo

    • Property svn:ignore changed from Makefile.in .svnignore Makefile to *.pyc Makefile.in Makefile
  • trunk/tests/python-demo/.svnignore

    r727 r2805  
     1*.pyc 
    12Makefile.in 
    2 .svnignore 
    33Makefile 
  • trunk/tests/python-demo/tinymail-python-test.glade

    r726 r2805  
    88  <property name="height_request">400</property> 
    99  <property name="visible">True</property> 
    10   <property name="title" translatable="yes">window1</property> 
     10  <property name="title" translatable="yes">Tinymail python test</property> 
    1111  <property name="type">GTK_WINDOW_TOPLEVEL</property> 
    1212  <property name="window_position">GTK_WIN_POS_NONE</property> 
  • trunk/tests/python-demo/tinymail-python-test.py

    r2697 r2805  
    55import tinymail.ui 
    66import tinymail.uigtk 
    7 import tinymail.platform 
    87import tinymail.camel 
    98import gc 
     9 
     10from pyplatformfactory import PyPlatformFactory 
    1011 
    1112def on_refresh_folder (folder, cancelled, headerstree): 
     
    7071column.set_sizing (gtk.TREE_VIEW_COLUMN_FIXED) 
    7172headerstree.append_column (column) 
    72 platfact = tinymail.platform.tny_gnome_platform_factory_get_instance () 
     73platfact = PyPlatformFactory() 
    7374msgview = platfact.new_msg_view () 
    7475msgview.show ()