pidgin/purple-plugin-pack

switchspell can now work with a gtkspell that uses enchant by using
org.guifications.plugins
2008-05-17, nosnilmot
b12e0d47e670
Parents 9e2f8ef9e772
Children 62678430991f
switchspell can now work with a gtkspell that uses enchant by using
--enable-enchant option to ./configure. This was initially based on a patch
by Ignacio Vazquez-Abrams in Fedora, and reworked by me to support either
aspell or enchant:
https://bugzilla.redhat.com/show_bug.cgi?id=427949
Also fix a leaky error.
--- a/ChangeLog Sat May 17 17:52:16 2008 -0400
+++ b/ChangeLog Sat May 17 17:57:09 2008 -0400
@@ -7,6 +7,8 @@
* Added google plugin for "I'm Feeling Lucky" searches.
* Fixed aspell dependency in switchspell (fixes gentoo bug #196693)
* Added nodashi's manualsize plugin
+ * Made switchspell work with gtkspell that uses enchant using
+ --enable-enchant option to ./configure
Version 2.3.0: 03/17/08
* Fixed a typo in irc-more's source that allowed a potential double-free
--- a/configure.ac Sat May 17 17:52:16 2008 -0400
+++ b/configure.ac Sat May 17 17:57:09 2008 -0400
@@ -268,6 +268,18 @@
AC_CHECK_LIB([aspell], [new_aspell_config], ASPELL_LIBS="-laspell", BUILD_SWITCH_SPELL=no)
fi
+AC_ARG_ENABLE(enchant, [AC_HELP_STRING([--enable-enchant], [compile with gtkspell using enchant])],
+ enable_enchant="$enableval", enable_enchant="no")
+if test "x$enable_enchant" = "xyes"; then
+ PKG_CHECK_MODULES(ENCHANT, enchant, [
+ BUILD_SWITCH_SPELL=yes
+ ASPELL_CFLAGS=""
+ ASPELL_LIBS=""], [gtkspell=no])
+ ENCHANT_CFLAGS="-DUSE_ENCHANT $ENCHANT_CFLAGS"
+ AC_SUBST(ENCHANT_CFLAGS)
+ AC_SUBST(ENCHANT_LIBS)
+fi
+
AC_SUBST(ASPELL_CFLAGS)
AC_SUBST(ASPELL_LIBS)
--- a/switchspell/Makefile.am Sat May 17 17:52:16 2008 -0400
+++ b/switchspell/Makefile.am Sat May 17 17:57:09 2008 -0400
@@ -16,6 +16,7 @@
switchspell_la_LIBADD = \
$(ASPELL_LIBS) \
+ $(ENCHANT_LIBS) \
$(GTK_LIBS) \
$(GTKSPELL_LIBS) \
$(PIDGIN_LIBS)
@@ -27,6 +28,7 @@
-DDATADIR=\"$(PIDGIN_DATADIR)\" \
-DPIXMAPSDIR=\"$(PIDGIN_PIXMAPSDIR)\" \
$(ASPELL_CFLAGS) \
+ $(ENCHANT_CFLAGS) \
$(GTK_CFLAGS) \
$(DEBUG_CFLAGS) \
$(PIDGIN_CFLAGS) \
--- a/switchspell/switchspell.c Sat May 17 17:52:16 2008 -0400
+++ b/switchspell/switchspell.c Sat May 17 17:57:09 2008 -0400
@@ -35,7 +35,11 @@
#include <gtkconv.h>
#include <gtkplugin.h>
+#ifdef USE_ENCHANT
+#include <enchant.h>
+#else
#include <aspell.h>
+#endif
#include <gtkspell/gtkspell.h>
#include <string.h>
@@ -81,8 +85,12 @@
gtkconv = PIDGIN_CONVERSATION(conv);
spell = gtkspell_get_from_text_view(GTK_TEXT_VIEW(gtkconv->entry));
- if (spell != NULL)
- gtkspell_set_language(spell, lang, &error); /* XXX: error can possibly leak here */
+ if (spell != NULL) {
+ if (!gtkspell_set_language(spell, lang, &error)) {
+ purple_debug_error("switchspell", "failed to set language %s: %s\n", lang, error->message);
+ g_error_free(error);
+ }
+ }
g_object_set_data(G_OBJECT(gtkconv->entry), PROP_LANG, lang);
node = blist_node_for_conv(gtkconv->active_conv);
@@ -97,10 +105,14 @@
GtkWidget *menu;
GtkWidget *mitem;
GSList *group = NULL;
+#ifdef USE_ENCHANT
+ EnchantBroker * eb;
+#else
AspellConfig * config;
AspellDictInfoList * dlist;
AspellDictInfoEnumeration * dels;
const AspellDictInfo * entry;
+#endif
if (gtkconv == NULL)
return;
@@ -122,6 +134,13 @@
menu = gtk_menu_new();
gtk_menu_item_set_submenu(GTK_MENU_ITEM(mitem), menu);
+#ifdef USE_ENCHANT
+ void enchant_dict_desc_cb(const char * const lang_tag, const char * const provider_name,
+ const char * const provider_desc, const char * const provider_file,
+ void *user_data)
+ {
+ GtkWidget *menuitem = gtk_radio_menu_item_new_with_label(group, lang_tag);
+#else
config = new_aspell_config();
dlist = get_aspell_dict_info_list(config);
delete_aspell_config(config);
@@ -130,16 +149,27 @@
aspell_dict_info_list_empty(dlist);
while ((entry = aspell_dict_info_enumeration_next(dels)) != 0) {
GtkWidget *menuitem = gtk_radio_menu_item_new_with_label(group, entry->name);
+#endif
group = gtk_radio_menu_item_get_group(GTK_RADIO_MENU_ITEM(menuitem));
g_object_set_data(G_OBJECT(menuitem), "user_data", win);
+#ifdef USE_ENCHANT
+ g_object_set_data_full(G_OBJECT(menuitem), "lang", g_strdup(lang_tag), g_free);
+#else
g_object_set_data(G_OBJECT(menuitem), "lang", (gchar *)entry->name);
+#endif
g_signal_connect(G_OBJECT(menuitem), "activate",
G_CALLBACK(menu_conv_use_dict_cb), NULL);
gtk_widget_show(menuitem);
gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem);
}
+#ifdef USE_ENCHANT
+ eb = enchant_broker_init();
+ enchant_broker_list_dicts(eb, enchant_dict_desc_cb, NULL);
+ enchant_broker_free(eb);
+#else
delete_aspell_dict_info_enumeration(dels);
+#endif
gtk_widget_show_all(menu);
}