diff --git a/configure.ac b/configure.ac index ad0f14866..0ed127859 100644 --- a/configure.ac +++ b/configure.ac @@ -66,28 +66,7 @@ else fi AM_CONDITIONAL(BUILD_REMOTE_CONTROL, $have_remote) -dnl **** -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]) +AM_PATH_PYTHON([2.5]) if test "x$PYTHON" = "x:"; then AC_MSG_ERROR([Python not found]) fi @@ -205,7 +184,6 @@ AC_OUTPUT echo " ***************************** Build features: - spell check ...... ${have_gtkspell} remote control ... ${have_remote} trayicon ......... ${have_trayicon} idle module OSX .. ${have_idle_osx} diff --git a/src/Makefile.am b/src/Makefile.am index 30ec3d0ab..9cbe07d3b 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -6,21 +6,6 @@ INCLUDES = \ $(PYTHON_INCLUDES) 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 trayiconlib_LTLIBRARIES = trayicon.la trayiconlibdir = $(pkglibdir) @@ -64,7 +49,6 @@ EXTRA_DIST = $(gajimsrc_PYTHON) \ $(gajimsrc1_PYTHON) \ $(gajimsrc2_PYTHON) \ $(gajimsrc3_PYTHON) \ - gtkspellmodule.c \ eggtrayicon.c \ trayiconmodule.c \ eggtrayicon.h \ diff --git a/src/chat_control.py b/src/chat_control.py index 1adf486e4..857ac9ac4 100644 --- a/src/chat_control.py +++ b/src/chat_control.py @@ -54,7 +54,7 @@ from common.xmpp.protocol import NS_RECEIPTS, NS_ESESSION try: import gtkspell HAS_GTK_SPELL = True -except Exception: +except ImportError: HAS_GTK_SPELL = False HAVE_MARKUP_TOOLTIPS = gtk.pygtk_version >= (2, 12, 0) @@ -300,7 +300,7 @@ class ChatControlBase(MessageControl): for lang in dict(langs): try: spell.set_language(langs[lang]) - except Exception: + except OSError: del langs[lang] # now set the one the user selected per_type = 'contacts' @@ -314,7 +314,7 @@ class ChatControlBase(MessageControl): if lang: self.msg_textview.lang = lang spell.set_language(lang) - except (gobject.GError, RuntimeError): + except (gobject.GError, RuntimeError, TypeError): dialogs.AspellDictError(lang) def on_msg_textview_populate_popup(self, textview, menu): diff --git a/src/config.py b/src/config.py index b89ad14b0..43e1f404d 100644 --- a/src/config.py +++ b/src/config.py @@ -48,7 +48,7 @@ import dataforms_widget try: import gtkspell HAS_GTK_SPELL = True -except Exception: +except ImportError: HAS_GTK_SPELL = False from common import helpers @@ -631,7 +631,7 @@ class PreferencesWindow: if isinstance(ctrl, chat_control.ChatControlBase): try: spell_obj = gtkspell.get_from_text_view(ctrl.msg_textview) - except Exception: + except (TypeError, RuntimeError): spell_obj = None if not spell_obj: @@ -642,7 +642,7 @@ class PreferencesWindow: if isinstance(ctrl, chat_control.ChatControlBase): try: spell_obj = gtkspell.get_from_text_view(ctrl.msg_textview) - except Exception: + except (TypeError, RuntimeError): spell_obj = None if spell_obj: spell_obj.detach() @@ -658,7 +658,7 @@ class PreferencesWindow: tv = gtk.TextView() try: gtkspell.Spell(tv, lang) - except Exception: + except (TypeError, RuntimeError): dialogs.ErrorDialog( _('Dictionary for lang %s not available') % lang, _('You have to install %s dictionary to use spellchecking, or ' diff --git a/src/dialogs.py b/src/dialogs.py index 05c98b9ea..fb531973d 100644 --- a/src/dialogs.py +++ b/src/dialogs.py @@ -45,7 +45,7 @@ from common import pep try: import gtkspell HAS_GTK_SPELL = True -except Exception: +except ImportError: HAS_GTK_SPELL = False # those imports are not used in this file, but in files that 'import dialogs' @@ -2200,7 +2200,7 @@ class SingleMessageWindow: lang = gajim.LANG gtkspell.Spell(self.conversation_textview.tv, lang) gtkspell.Spell(self.message_textview, lang) - except gobject.GError: + except (gobject.GError, TypeError, RuntimeError): AspellDictError(lang) self.prepare_widgets_for(self.action) diff --git a/src/features_window.py b/src/features_window.py index 7bf25f379..0a5ed3b29 100644 --- a/src/features_window.py +++ b/src/features_window.py @@ -76,7 +76,7 @@ class FeaturesWindow: _('Requires nslookup to use SRV records.')), _('Spell Checker'): (self.speller_available, _('Spellchecking of composed messages.'), - _('Requires python-gnome2-extras or compilation of gtkspell module from Gajim sources.'), + _('Requires libgtkspell.'), _('Feature not available under Windows.')), _('Notification'): (self.notification_available, _('Passive popups notifying for new events.'), @@ -217,7 +217,7 @@ class FeaturesWindow: return False try: import gtkspell - except Exception: + except ImportError: return False return True diff --git a/src/gajim.py b/src/gajim.py index 04abb7e7c..081d84a58 100644 --- a/src/gajim.py +++ b/src/gajim.py @@ -3337,7 +3337,7 @@ class Interface: try: import gtkspell spell = gtkspell.Spell(tv, lang) - except Exception: + except (ImportError, TypeError, RuntimeError): dialogs.AspellDictError(lang) if gajim.config.get('soundplayer') == '': diff --git a/src/gtkspellmodule.c b/src/gtkspellmodule.c deleted file mode 100644 index af31bc2c4..000000000 --- a/src/gtkspellmodule.c +++ /dev/null @@ -1,229 +0,0 @@ -/* - * src/gtkspellmodule.c - * - * Copyright (C) 2005 Nikos Kouremenos - * Copyright (C) 2006 Yann Leboulanger - * - * 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 . - * - */ - -#include -#include -#include -#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"); - } -} -