Author: js Date: 2008-08-25 21:42:05 +0200 (Mon, 25 Aug 2008) New Revision: 10293
Added: branches/osx_newbuildsys/src/spellmodule/ branches/osx_newbuildsys/src/spellmodule/Makefile branches/osx_newbuildsys/src/spellmodule/gtkspellmodule.c Removed: branches/osx_newbuildsys/src/gtkspellmodule.c Modified: branches/osx_newbuildsys/extra.mk.in branches/osx_newbuildsys/src/Makefile Log: Build spellchecking module. Works.
Modified: branches/osx_newbuildsys/extra.mk.in =================================================================== --- branches/osx_newbuildsys/extra.mk.in 2008-08-25 19:35:47 UTC (rev 10292) +++ branches/osx_newbuildsys/extra.mk.in 2008-08-25 19:42:05 UTC (rev 10293) @@ -6,3 +6,5 @@ PYGTK_CFLAGS = @PYGTK_CFLAGS@ PYGTK_DEFS = @PYGTK_DEFS@ PYGTK_LIBS = @PYGTK_LIBS@ +GTKSPELL_CFLAGS = @GTKSPELL_CFLAGS@ +GTKSPELL_LIBS = @GTKSPELL_LIBS@
Modified: branches/osx_newbuildsys/src/Makefile =================================================================== --- branches/osx_newbuildsys/src/Makefile 2008-08-25 19:35:47 UTC (rev 10292) +++ branches/osx_newbuildsys/src/Makefile 2008-08-25 19:42:05 UTC (rev 10293) @@ -1,6 +1,6 @@ # FIXME: Install files
-SUBDIRS = common traymodule osx +SUBDIRS = common traymodule spellmodule osx
SRCS = adhoc_commands.py \ advanced.py \
Deleted: branches/osx_newbuildsys/src/gtkspellmodule.c =================================================================== --- branches/osx_newbuildsys/src/gtkspellmodule.c 2008-08-25 19:35:47 UTC (rev 10292) +++ branches/osx_newbuildsys/src/gtkspellmodule.c 2008-08-25 19:42:05 UTC (rev 10293) @@ -1,229 +0,0 @@ -/* - * src/gtkspellmodule.c - * - * Copyright (C) 2005 Nikos Kouremenos <kourem AT gmail.com> - * Copyright (C) 2006 Yann Leboulanger <asterix AT lagaule.org> - * - * This file is part of Gajim. - * - * Gajim 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; version 3 only. - * - * Gajim 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 Gajim. If not, see http://www.gnu.org/licenses/. - * - */ - -#include <Python.h> -#include <gtk/gtk.h> -#include <gtkspell/gtkspell.h> -#include "pygobject.h" - -typedef struct { - PyObject_HEAD - GtkSpell *spell; -} gtkspell_SpellObject; - -extern PyTypeObject gtkspell_SpellType; - -static PyTypeObject *_PyGtkTextView_Type; -#define PyGtkTextView_Type (*_PyGtkTextView_Type) - - -static PyObject * -_wrap_gtkspell_new_attach (PyTypeObject *type, PyObject *args, PyObject *kwds) -{ - gtkspell_SpellObject *self; - PyObject *pytextview; - GtkTextView *textview; - GtkSpell *spell; - char *language = NULL; - GError *error = NULL; - - if (!PyArg_ParseTuple(args, "O!|z:gtkspell.Spell.__new__", - &PyGtkTextView_Type, &pytextview, &language)) - return NULL; - - textview = GTK_TEXT_VIEW(((PyGObject *)pytextview)->obj); - spell = gtkspell_new_attach(textview, language, &error); - - if (pyg_error_check(&error)) - return NULL; - if (!spell) { - PyErr_SetString(PyExc_RuntimeError, "unable to create and attach a Spell object"); - return NULL; - } - - self = (gtkspell_SpellObject *)type->tp_alloc(type, 0); - self->spell = spell; - return (PyObject *)self; -} - -static PyObject * -_wrap_gtkspell_set_language (gtkspell_SpellObject *self, PyObject *args, PyObject *kwds) -{ - gchar *lang = NULL; - gboolean result; - char *argnames[] = {"language", NULL}; - - if (!PyArg_ParseTupleAndKeywords (args, kwds, "z", argnames, &lang)) - return NULL; - - result = gtkspell_set_language (self->spell, lang, NULL); - - if (!result) { - /*there are no specific errors in GtkSpell yet*/ - PyErr_SetString(PyExc_RuntimeError, "Error setting language"); - return NULL; - } - - Py_INCREF(Py_None); - return Py_None; -} - -static PyObject * -_wrap_gtkspell_recheck_all (gtkspell_SpellObject *self) -{ - gtkspell_recheck_all ((GtkSpell *)self->spell); - - Py_INCREF(Py_None); - return Py_None; - -} - -static PyObject * -_wrap_gtkspell_get_from_text_view (PyObject *junk, PyObject *args, PyObject *kwds) -{ - PyObject *pytextview; - GtkTextView *textview; - gtkspell_SpellObject *self; - char *argnames[] = {"textview", NULL}; - - if (!PyArg_ParseTupleAndKeywords (args, kwds, "O", argnames, &pytextview)) - return NULL; - - textview = GTK_TEXT_VIEW(((PyGObject *)pytextview)->obj); - - self = (gtkspell_SpellObject *)PyType_GenericAlloc((PyTypeObject *)>kspell_SpellType, 1); - if (self != NULL) { - self->spell = gtkspell_get_from_text_view(textview); - if (self->spell == NULL) { - Py_DECREF(self); - return NULL; - } - } - return (PyObject *)self; -} - -static PyObject * -_wrap_gtkspell_detach (gtkspell_SpellObject *self) -{ - gtkspell_detach(self->spell); - self->spell = NULL; - Py_INCREF(Py_None); - return Py_None; -} - - -static PyMethodDef gtkspell_methods[] = { - {"set_language", (PyCFunction)_wrap_gtkspell_set_language, - METH_KEYWORDS, "Set the language"}, - {"recheck_all", (PyCFunction)_wrap_gtkspell_recheck_all, - METH_NOARGS, "Recheck the spelling in the entire buffer"}, - {"detach", (PyCFunction)_wrap_gtkspell_detach, - METH_NOARGS, "Detaches a Spell object from a TextView"}, - { NULL, NULL, 0 } -}; - - -PyTypeObject gtkspell_SpellType = { - PyObject_HEAD_INIT(NULL) - 0, /*ob_size*/ - "gtkspell.Spell", /*tp_name*/ - sizeof(gtkspell_SpellObject), /*tp_basicsize*/ - 0, /*tp_itemsize*/ - 0, /*tp_dealloc*/ - 0, /*tp_print*/ - 0, /*tp_getattr*/ - 0, /*tp_setattr*/ - 0, /*tp_compare*/ - 0, /*tp_repr*/ - 0, /*tp_as_number*/ - 0, /*tp_as_sequence*/ - 0, /*tp_as_mapping*/ - 0, /*tp_hash */ - 0, /*tp_call*/ - 0, /*tp_str*/ - 0, /*tp_getattro*/ - 0, /*tp_setattro*/ - 0, /*tp_as_buffer*/ - Py_TPFLAGS_DEFAULT, /*tp_flags*/ - "GtkSpell object", /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - gtkspell_methods, /* tp_methods */ - 0, /* tp_members */ - 0, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - 0, /* tp_init */ - 0, /* tp_alloc */ - _wrap_gtkspell_new_attach, /* tp_new */ -}; - -static PyMethodDef gtkspell_functions[] = { - {"get_from_text_view", (PyCFunction)_wrap_gtkspell_get_from_text_view, - METH_KEYWORDS, "Retrieves the Spell object attach"}, - { NULL, NULL, 0, NULL } -}; - -DL_EXPORT(void) -initgtkspell(void) -{ - PyObject *m, *module; - - init_pygobject(); - - if ((module = PyImport_ImportModule("gtk")) != NULL) { - PyObject *moddict = PyModule_GetDict(module); - - _PyGtkTextView_Type = (PyTypeObject *)PyDict_GetItemString(moddict, "TextView"); - if (_PyGtkTextView_Type == NULL) { - PyErr_SetString(PyExc_ImportError, - "cannot import name TextView from gtk"); - return; - } - } else { - PyErr_SetString(PyExc_ImportError, - "could not import gtk"); - return; - } - - - m = Py_InitModule3 ("gtkspell", gtkspell_functions, "GtkSpell bindings"); - - if (PyType_Ready(>kspell_SpellType) < 0) - return; - - Py_INCREF(>kspell_SpellType); - PyModule_AddObject(m, "Spell", (PyObject *)>kspell_SpellType); - - if (PyErr_Occurred ()) { - PyErr_Print(); - Py_FatalError ("can't initialise module gtkspell"); - } -} -
Added: branches/osx_newbuildsys/src/spellmodule/Makefile =================================================================== --- branches/osx_newbuildsys/src/spellmodule/Makefile (rev 0) +++ branches/osx_newbuildsys/src/spellmodule/Makefile 2008-08-25 19:42:05 UTC (rev 10293) @@ -0,0 +1,12 @@ +# FIXME: Install files + +# Python calls these .so, even on OS X, which is very wrong. It should be .impl! +PLUGIN = ../gtkspell.so +SRCS = gtkspellmodule.c + +include ../../buildsys.mk +include ../../extra.mk + +CFLAGS += ${PLUGIN_CFLAGS} ${PYTHON_CFLAGS} ${PYGTK_CFLAGS} ${GTKSPELL_CFLAGS} +LIBS += ${PYTHON_LIBS} ${PYGTK_LIBS} ${GTKSPELL_LIBS} +LDFLAGS += ${PLUGIN_LDFLAGS} ${PYTHON_LDFLAGS}
Copied: branches/osx_newbuildsys/src/spellmodule/gtkspellmodule.c (from rev 10289, branches/osx_newbuildsys/src/gtkspellmodule.c) =================================================================== --- branches/osx_newbuildsys/src/spellmodule/gtkspellmodule.c (rev 0) +++ branches/osx_newbuildsys/src/spellmodule/gtkspellmodule.c 2008-08-25 19:42:05 UTC (rev 10293) @@ -0,0 +1,229 @@ +/* + * src/gtkspellmodule.c + * + * Copyright (C) 2005 Nikos Kouremenos <kourem AT gmail.com> + * Copyright (C) 2006 Yann Leboulanger <asterix AT lagaule.org> + * + * This file is part of Gajim. + * + * Gajim 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; version 3 only. + * + * Gajim 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 Gajim. If not, see http://www.gnu.org/licenses/. + * + */ + +#include <Python.h> +#include <gtk/gtk.h> +#include <gtkspell/gtkspell.h> +#include "pygobject.h" + +typedef struct { + PyObject_HEAD + GtkSpell *spell; +} gtkspell_SpellObject; + +extern PyTypeObject gtkspell_SpellType; + +static PyTypeObject *_PyGtkTextView_Type; +#define PyGtkTextView_Type (*_PyGtkTextView_Type) + + +static PyObject * +_wrap_gtkspell_new_attach (PyTypeObject *type, PyObject *args, PyObject *kwds) +{ + gtkspell_SpellObject *self; + PyObject *pytextview; + GtkTextView *textview; + GtkSpell *spell; + char *language = NULL; + GError *error = NULL; + + if (!PyArg_ParseTuple(args, "O!|z:gtkspell.Spell.__new__", + &PyGtkTextView_Type, &pytextview, &language)) + return NULL; + + textview = GTK_TEXT_VIEW(((PyGObject *)pytextview)->obj); + spell = gtkspell_new_attach(textview, language, &error); + + if (pyg_error_check(&error)) + return NULL; + if (!spell) { + PyErr_SetString(PyExc_RuntimeError, "unable to create and attach a Spell object"); + return NULL; + } + + self = (gtkspell_SpellObject *)type->tp_alloc(type, 0); + self->spell = spell; + return (PyObject *)self; +} + +static PyObject * +_wrap_gtkspell_set_language (gtkspell_SpellObject *self, PyObject *args, PyObject *kwds) +{ + gchar *lang = NULL; + gboolean result; + char *argnames[] = {"language", NULL}; + + if (!PyArg_ParseTupleAndKeywords (args, kwds, "z", argnames, &lang)) + return NULL; + + result = gtkspell_set_language (self->spell, lang, NULL); + + if (!result) { + /*there are no specific errors in GtkSpell yet*/ + PyErr_SetString(PyExc_RuntimeError, "Error setting language"); + return NULL; + } + + Py_INCREF(Py_None); + return Py_None; +} + +static PyObject * +_wrap_gtkspell_recheck_all (gtkspell_SpellObject *self) +{ + gtkspell_recheck_all ((GtkSpell *)self->spell); + + Py_INCREF(Py_None); + return Py_None; + +} + +static PyObject * +_wrap_gtkspell_get_from_text_view (PyObject *junk, PyObject *args, PyObject *kwds) +{ + PyObject *pytextview; + GtkTextView *textview; + gtkspell_SpellObject *self; + char *argnames[] = {"textview", NULL}; + + if (!PyArg_ParseTupleAndKeywords (args, kwds, "O", argnames, &pytextview)) + return NULL; + + textview = GTK_TEXT_VIEW(((PyGObject *)pytextview)->obj); + + self = (gtkspell_SpellObject *)PyType_GenericAlloc((PyTypeObject *)>kspell_SpellType, 1); + if (self != NULL) { + self->spell = gtkspell_get_from_text_view(textview); + if (self->spell == NULL) { + Py_DECREF(self); + return NULL; + } + } + return (PyObject *)self; +} + +static PyObject * +_wrap_gtkspell_detach (gtkspell_SpellObject *self) +{ + gtkspell_detach(self->spell); + self->spell = NULL; + Py_INCREF(Py_None); + return Py_None; +} + + +static PyMethodDef gtkspell_methods[] = { + {"set_language", (PyCFunction)_wrap_gtkspell_set_language, + METH_KEYWORDS, "Set the language"}, + {"recheck_all", (PyCFunction)_wrap_gtkspell_recheck_all, + METH_NOARGS, "Recheck the spelling in the entire buffer"}, + {"detach", (PyCFunction)_wrap_gtkspell_detach, + METH_NOARGS, "Detaches a Spell object from a TextView"}, + { NULL, NULL, 0 } +}; + + +PyTypeObject gtkspell_SpellType = { + PyObject_HEAD_INIT(NULL) + 0, /*ob_size*/ + "gtkspell.Spell", /*tp_name*/ + sizeof(gtkspell_SpellObject), /*tp_basicsize*/ + 0, /*tp_itemsize*/ + 0, /*tp_dealloc*/ + 0, /*tp_print*/ + 0, /*tp_getattr*/ + 0, /*tp_setattr*/ + 0, /*tp_compare*/ + 0, /*tp_repr*/ + 0, /*tp_as_number*/ + 0, /*tp_as_sequence*/ + 0, /*tp_as_mapping*/ + 0, /*tp_hash */ + 0, /*tp_call*/ + 0, /*tp_str*/ + 0, /*tp_getattro*/ + 0, /*tp_setattro*/ + 0, /*tp_as_buffer*/ + Py_TPFLAGS_DEFAULT, /*tp_flags*/ + "GtkSpell object", /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + gtkspell_methods, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + 0, /* tp_init */ + 0, /* tp_alloc */ + _wrap_gtkspell_new_attach, /* tp_new */ +}; + +static PyMethodDef gtkspell_functions[] = { + {"get_from_text_view", (PyCFunction)_wrap_gtkspell_get_from_text_view, + METH_KEYWORDS, "Retrieves the Spell object attach"}, + { NULL, NULL, 0, NULL } +}; + +DL_EXPORT(void) +initgtkspell(void) +{ + PyObject *m, *module; + + init_pygobject(); + + if ((module = PyImport_ImportModule("gtk")) != NULL) { + PyObject *moddict = PyModule_GetDict(module); + + _PyGtkTextView_Type = (PyTypeObject *)PyDict_GetItemString(moddict, "TextView"); + if (_PyGtkTextView_Type == NULL) { + PyErr_SetString(PyExc_ImportError, + "cannot import name TextView from gtk"); + return; + } + } else { + PyErr_SetString(PyExc_ImportError, + "could not import gtk"); + return; + } + + + m = Py_InitModule3 ("gtkspell", gtkspell_functions, "GtkSpell bindings"); + + if (PyType_Ready(>kspell_SpellType) < 0) + return; + + Py_INCREF(>kspell_SpellType); + PyModule_AddObject(m, "Spell", (PyObject *)>kspell_SpellType); + + if (PyErr_Occurred ()) { + PyErr_Print(); + Py_FatalError ("can't initialise module gtkspell"); + } +} +
Property changes on: branches/osx_newbuildsys/src/spellmodule/gtkspellmodule.c ___________________________________________________________________ Added: svn:mergeinfo +