[thorstenp] use ctype to have gtkspell. No need to compile it from C. Fixes #4289
This commit is contained in:
parent
85d758d75d
commit
01bcfe2007
8 changed files with 13 additions and 280 deletions
24
configure.ac
24
configure.ac
|
@ -66,28 +66,7 @@ else
|
||||||
fi
|
fi
|
||||||
AM_CONDITIONAL(BUILD_REMOTE_CONTROL, $have_remote)
|
AM_CONDITIONAL(BUILD_REMOTE_CONTROL, $have_remote)
|
||||||
|
|
||||||
dnl ****
|
AM_PATH_PYTHON([2.5])
|
||||||
dnl gtkspell
|
|
||||||
dnl ****
|
|
||||||
AC_ARG_ENABLE(gtkspell,
|
|
||||||
[ --disable-gtkspell do not build spell checking support [default auto]],
|
|
||||||
enable_gtkspell=$enableval, enable_gtkspell=auto)
|
|
||||||
|
|
||||||
if test "x$enable_gtkspell" = "xauto";then
|
|
||||||
PKG_CHECK_EXISTS([gtkspell-2.0], [enable_gtkspell=yes], [enable_gtkspell=no])
|
|
||||||
fi
|
|
||||||
if test "x$enable_gtkspell" = "xyes";then
|
|
||||||
PKG_CHECK_MODULES([GTKSPELL], [gtkspell-2.0])
|
|
||||||
AC_SUBST(GTKSPELL_CFLAGS)
|
|
||||||
AC_SUBST(GTKSPELL_LIBS)
|
|
||||||
have_gtkspell=true
|
|
||||||
else
|
|
||||||
have_gtkspell=false
|
|
||||||
fi
|
|
||||||
AM_CONDITIONAL(BUILD_GTKSPELL, $have_gtkspell)
|
|
||||||
|
|
||||||
|
|
||||||
AM_PATH_PYTHON([2.4])
|
|
||||||
if test "x$PYTHON" = "x:"; then
|
if test "x$PYTHON" = "x:"; then
|
||||||
AC_MSG_ERROR([Python not found])
|
AC_MSG_ERROR([Python not found])
|
||||||
fi
|
fi
|
||||||
|
@ -205,7 +184,6 @@ AC_OUTPUT
|
||||||
echo "
|
echo "
|
||||||
*****************************
|
*****************************
|
||||||
Build features:
|
Build features:
|
||||||
spell check ...... ${have_gtkspell}
|
|
||||||
remote control ... ${have_remote}
|
remote control ... ${have_remote}
|
||||||
trayicon ......... ${have_trayicon}
|
trayicon ......... ${have_trayicon}
|
||||||
idle module OSX .. ${have_idle_osx}
|
idle module OSX .. ${have_idle_osx}
|
||||||
|
|
|
@ -6,21 +6,6 @@ INCLUDES = \
|
||||||
$(PYTHON_INCLUDES)
|
$(PYTHON_INCLUDES)
|
||||||
export MACOSX_DEPLOYMENT_TARGET=10.4
|
export MACOSX_DEPLOYMENT_TARGET=10.4
|
||||||
|
|
||||||
if BUILD_GTKSPELL
|
|
||||||
gtkspelllib_LTLIBRARIES = gtkspell.la
|
|
||||||
gtkspelllibdir = $(pkglibdir)
|
|
||||||
|
|
||||||
gtkspell_la_LIBADD = \
|
|
||||||
$(GTKSPELL_LIBS) $(PYGTK_LIBS)
|
|
||||||
|
|
||||||
gtkspell_la_SOURCES = \
|
|
||||||
gtkspellmodule.c
|
|
||||||
|
|
||||||
gtkspell_la_LDFLAGS = \
|
|
||||||
-module -avoid-version
|
|
||||||
|
|
||||||
gtkspell_la_CFLAGS = $(GTKSPELL_CFLAGS) $(PYGTK_CFLAGS)
|
|
||||||
endif
|
|
||||||
if BUILD_TRAYICON
|
if BUILD_TRAYICON
|
||||||
trayiconlib_LTLIBRARIES = trayicon.la
|
trayiconlib_LTLIBRARIES = trayicon.la
|
||||||
trayiconlibdir = $(pkglibdir)
|
trayiconlibdir = $(pkglibdir)
|
||||||
|
@ -64,7 +49,6 @@ EXTRA_DIST = $(gajimsrc_PYTHON) \
|
||||||
$(gajimsrc1_PYTHON) \
|
$(gajimsrc1_PYTHON) \
|
||||||
$(gajimsrc2_PYTHON) \
|
$(gajimsrc2_PYTHON) \
|
||||||
$(gajimsrc3_PYTHON) \
|
$(gajimsrc3_PYTHON) \
|
||||||
gtkspellmodule.c \
|
|
||||||
eggtrayicon.c \
|
eggtrayicon.c \
|
||||||
trayiconmodule.c \
|
trayiconmodule.c \
|
||||||
eggtrayicon.h \
|
eggtrayicon.h \
|
||||||
|
|
|
@ -54,7 +54,7 @@ from common.xmpp.protocol import NS_RECEIPTS, NS_ESESSION
|
||||||
try:
|
try:
|
||||||
import gtkspell
|
import gtkspell
|
||||||
HAS_GTK_SPELL = True
|
HAS_GTK_SPELL = True
|
||||||
except Exception:
|
except ImportError:
|
||||||
HAS_GTK_SPELL = False
|
HAS_GTK_SPELL = False
|
||||||
|
|
||||||
HAVE_MARKUP_TOOLTIPS = gtk.pygtk_version >= (2, 12, 0)
|
HAVE_MARKUP_TOOLTIPS = gtk.pygtk_version >= (2, 12, 0)
|
||||||
|
@ -300,7 +300,7 @@ class ChatControlBase(MessageControl):
|
||||||
for lang in dict(langs):
|
for lang in dict(langs):
|
||||||
try:
|
try:
|
||||||
spell.set_language(langs[lang])
|
spell.set_language(langs[lang])
|
||||||
except Exception:
|
except OSError:
|
||||||
del langs[lang]
|
del langs[lang]
|
||||||
# now set the one the user selected
|
# now set the one the user selected
|
||||||
per_type = 'contacts'
|
per_type = 'contacts'
|
||||||
|
@ -314,7 +314,7 @@ class ChatControlBase(MessageControl):
|
||||||
if lang:
|
if lang:
|
||||||
self.msg_textview.lang = lang
|
self.msg_textview.lang = lang
|
||||||
spell.set_language(lang)
|
spell.set_language(lang)
|
||||||
except (gobject.GError, RuntimeError):
|
except (gobject.GError, RuntimeError, TypeError):
|
||||||
dialogs.AspellDictError(lang)
|
dialogs.AspellDictError(lang)
|
||||||
|
|
||||||
def on_msg_textview_populate_popup(self, textview, menu):
|
def on_msg_textview_populate_popup(self, textview, menu):
|
||||||
|
|
|
@ -48,7 +48,7 @@ import dataforms_widget
|
||||||
try:
|
try:
|
||||||
import gtkspell
|
import gtkspell
|
||||||
HAS_GTK_SPELL = True
|
HAS_GTK_SPELL = True
|
||||||
except Exception:
|
except ImportError:
|
||||||
HAS_GTK_SPELL = False
|
HAS_GTK_SPELL = False
|
||||||
|
|
||||||
from common import helpers
|
from common import helpers
|
||||||
|
@ -631,7 +631,7 @@ class PreferencesWindow:
|
||||||
if isinstance(ctrl, chat_control.ChatControlBase):
|
if isinstance(ctrl, chat_control.ChatControlBase):
|
||||||
try:
|
try:
|
||||||
spell_obj = gtkspell.get_from_text_view(ctrl.msg_textview)
|
spell_obj = gtkspell.get_from_text_view(ctrl.msg_textview)
|
||||||
except Exception:
|
except (TypeError, RuntimeError):
|
||||||
spell_obj = None
|
spell_obj = None
|
||||||
|
|
||||||
if not spell_obj:
|
if not spell_obj:
|
||||||
|
@ -642,7 +642,7 @@ class PreferencesWindow:
|
||||||
if isinstance(ctrl, chat_control.ChatControlBase):
|
if isinstance(ctrl, chat_control.ChatControlBase):
|
||||||
try:
|
try:
|
||||||
spell_obj = gtkspell.get_from_text_view(ctrl.msg_textview)
|
spell_obj = gtkspell.get_from_text_view(ctrl.msg_textview)
|
||||||
except Exception:
|
except (TypeError, RuntimeError):
|
||||||
spell_obj = None
|
spell_obj = None
|
||||||
if spell_obj:
|
if spell_obj:
|
||||||
spell_obj.detach()
|
spell_obj.detach()
|
||||||
|
@ -658,7 +658,7 @@ class PreferencesWindow:
|
||||||
tv = gtk.TextView()
|
tv = gtk.TextView()
|
||||||
try:
|
try:
|
||||||
gtkspell.Spell(tv, lang)
|
gtkspell.Spell(tv, lang)
|
||||||
except Exception:
|
except (TypeError, RuntimeError):
|
||||||
dialogs.ErrorDialog(
|
dialogs.ErrorDialog(
|
||||||
_('Dictionary for lang %s not available') % lang,
|
_('Dictionary for lang %s not available') % lang,
|
||||||
_('You have to install %s dictionary to use spellchecking, or '
|
_('You have to install %s dictionary to use spellchecking, or '
|
||||||
|
|
|
@ -45,7 +45,7 @@ from common import pep
|
||||||
try:
|
try:
|
||||||
import gtkspell
|
import gtkspell
|
||||||
HAS_GTK_SPELL = True
|
HAS_GTK_SPELL = True
|
||||||
except Exception:
|
except ImportError:
|
||||||
HAS_GTK_SPELL = False
|
HAS_GTK_SPELL = False
|
||||||
|
|
||||||
# those imports are not used in this file, but in files that 'import dialogs'
|
# those imports are not used in this file, but in files that 'import dialogs'
|
||||||
|
@ -2200,7 +2200,7 @@ class SingleMessageWindow:
|
||||||
lang = gajim.LANG
|
lang = gajim.LANG
|
||||||
gtkspell.Spell(self.conversation_textview.tv, lang)
|
gtkspell.Spell(self.conversation_textview.tv, lang)
|
||||||
gtkspell.Spell(self.message_textview, lang)
|
gtkspell.Spell(self.message_textview, lang)
|
||||||
except gobject.GError:
|
except (gobject.GError, TypeError, RuntimeError):
|
||||||
AspellDictError(lang)
|
AspellDictError(lang)
|
||||||
|
|
||||||
self.prepare_widgets_for(self.action)
|
self.prepare_widgets_for(self.action)
|
||||||
|
|
|
@ -76,7 +76,7 @@ class FeaturesWindow:
|
||||||
_('Requires nslookup to use SRV records.')),
|
_('Requires nslookup to use SRV records.')),
|
||||||
_('Spell Checker'): (self.speller_available,
|
_('Spell Checker'): (self.speller_available,
|
||||||
_('Spellchecking of composed messages.'),
|
_('Spellchecking of composed messages.'),
|
||||||
_('Requires python-gnome2-extras or compilation of gtkspell module from Gajim sources.'),
|
_('Requires libgtkspell.'),
|
||||||
_('Feature not available under Windows.')),
|
_('Feature not available under Windows.')),
|
||||||
_('Notification'): (self.notification_available,
|
_('Notification'): (self.notification_available,
|
||||||
_('Passive popups notifying for new events.'),
|
_('Passive popups notifying for new events.'),
|
||||||
|
@ -217,7 +217,7 @@ class FeaturesWindow:
|
||||||
return False
|
return False
|
||||||
try:
|
try:
|
||||||
import gtkspell
|
import gtkspell
|
||||||
except Exception:
|
except ImportError:
|
||||||
return False
|
return False
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
|
@ -3337,7 +3337,7 @@ class Interface:
|
||||||
try:
|
try:
|
||||||
import gtkspell
|
import gtkspell
|
||||||
spell = gtkspell.Spell(tv, lang)
|
spell = gtkspell.Spell(tv, lang)
|
||||||
except Exception:
|
except (ImportError, TypeError, RuntimeError):
|
||||||
dialogs.AspellDictError(lang)
|
dialogs.AspellDictError(lang)
|
||||||
|
|
||||||
if gajim.config.get('soundplayer') == '':
|
if gajim.config.get('soundplayer') == '':
|
||||||
|
|
|
@ -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");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue