[balsa/gtk3] Avoid explicit dependence on enchant when possible
- From: Peter Bloomfield <PeterB src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [balsa/gtk3] Avoid explicit dependence on enchant when possible
- Date: Tue, 28 May 2013 12:45:18 +0000 (UTC)
commit 808ed47d44582950c450df4568fe7e9ecce591ed
Author: Peter Bloomfield <PeterBloomfield bellsouth net>
Date: Tue May 28 08:44:28 2013 -0400
Avoid explicit dependence on enchant when possible
* configure.ac: check GtkSpell version, and avoid explicit
dependence on enchant when possible.
* src/sendmsg-window.c: use gtkspell_get_language_list when
available, instead of enchant API.
ChangeLog | 7 +++++++
configure.ac | 12 +++++++++++-
src/sendmsg-window.c | 21 +++++++++++++++++++++
3 files changed, 39 insertions(+), 1 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 83f090f..d9d631a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2013-05-28 Peter Bloomfield
+
+ * configure.ac: check GtkSpell version, and avoid explicit
+ dependence on enchant when possible.
+ * src/sendmsg-window.c: use gtkspell_get_language_list when
+ available, instead of enchant API.
+
2013-05-26 Peter Bloomfield
* src/main-window.c: report network availability with a
diff --git a/configure.ac b/configure.ac
index ae49199..4e6d001 100644
--- a/configure.ac
+++ b/configure.ac
@@ -834,10 +834,20 @@ dnl #####################################################################
# Spell check detection.
#
+AC_MSG_CHECKING([whether to configure for gtkspell/enchant])
if test x$with_gtkspell != xno; then
- PKG_CHECK_MODULES(SPELL, [ gtkspell3-3.0 enchant ])
+ if $PKG_CONFIG --atleast-version=3.0.3 gtkspell3-3.0; then
+ AC_MSG_RESULT([gtkspell version >= 3.0.3])
+ PKG_CHECK_MODULES(SPELL, [ gtkspell3-3.0 ])
+ AC_DEFINE(HAVE_GTKSPELL_3_0_3,1,[Defined when GtkSpell version
+ is at least 3.0.3.])
+ else
+ AC_MSG_RESULT([gtkspell version < 3.0.3])
+ PKG_CHECK_MODULES(SPELL, [ gtkspell3-3.0 enchant ])
+ fi
AC_DEFINE(HAVE_GTKSPELL,1,[Defined when GtkSpell can be used.])
else
+ AC_MSG_RESULT([configure enchant])
PKG_CHECK_MODULES(SPELL, [ enchant ])
fi
BALSA_CFLAGS="$BALSA_CFLAGS $SPELL_CFLAGS"
diff --git a/src/sendmsg-window.c b/src/sendmsg-window.c
index e91990f..39dada3 100644
--- a/src/sendmsg-window.c
+++ b/src/sendmsg-window.c
@@ -70,7 +70,9 @@
#include "print.h"
#include "macosx-helpers.h"
+#ifndef HAVE_GTKSPELL_3_0_3
#include <enchant/enchant.h>
+#endif /* HAVE_GTKSPELL_3_0_3 */
#if HAVE_GTKSPELL
#include "gtkspell/gtkspell.h"
#else /* HAVE_GTKSPELL */
@@ -4331,7 +4333,11 @@ create_lang_menu(GtkWidget * parent, BalsaSendmsg * bsmsg)
GtkWidget *langs = gtk_menu_new();
static gboolean locales_sorted = FALSE;
GSList *group = NULL;
+#if HAVE_GTKSPELL_3_0_3
+ GList *lang_list;
+#else /* HAVE_GTKSPELL_3_0_3 */
EnchantBroker *broker;
+#endif /* HAVE_GTKSPELL_3_0_3 */
if (!locales_sorted) {
for (i = 0; i < ELEMENTS(locales); i++)
@@ -4351,7 +4357,11 @@ create_lang_menu(GtkWidget * parent, BalsaSendmsg * bsmsg)
selected_pos = find_locale_index_by_locale(setlocale(LC_CTYPE, NULL));
#endif /* HAVE_GTKSPELL */
+#if HAVE_GTKSPELL_3_0_3
+ lang_list = gtkspell_get_language_list();
+#else /* HAVE_GTKSPELL_3_0_3 */
broker = enchant_broker_init();
+#endif /* HAVE_GTKSPELL_3_0_3 */
for (i = 0; i < ELEMENTS(locales); i++) {
if (locales[i].locale == NULL || locales[i].locale[0] == '\0')
@@ -4359,7 +4369,12 @@ create_lang_menu(GtkWidget * parent, BalsaSendmsg * bsmsg)
* lang; in either case, it does not go in the langs menu. */
continue;
+#if HAVE_GTKSPELL_3_0_3
+ if (g_list_find_custom(lang_list, locales[i].locale,
+ (GCompareFunc) strcmp)) {
+#else /* HAVE_GTKSPELL_3_0_3 */
if (enchant_broker_dict_exists(broker, locales[i].locale)) {
+#endif /* HAVE_GTKSPELL_3_0_3 */
GtkWidget *w;
if (selected_pos < 0)
@@ -4382,7 +4397,13 @@ create_lang_menu(GtkWidget * parent, BalsaSendmsg * bsmsg)
gtk_menu_shell_append(GTK_MENU_SHELL(langs), w);
}
}
+#if HAVE_GTKSPELL_3_0_3
+ /* We should add to the langs menu any available languages that are
+ * not listed in locales[]; not implemented, just free the list */
+ g_list_free(lang_list);
+#else /* HAVE_GTKSPELL_3_0_3 */
enchant_broker_free(broker);
+#endif /* HAVE_GTKSPELL_3_0_3 */
if (selected_pos >= 0)
set_locale(bsmsg, selected_pos);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]