org.guifications.plugins: ec717a80332fd34b6b891da438354d43349f04a2

nosnilmot at guifications.org nosnilmot at guifications.org
Sat May 17 13:00:13 CDT 2008


-----------------------------------------------------------------
Revision: ec717a80332fd34b6b891da438354d43349f04a2
Ancestor: 619d98831f7dafd694d34aaa02765a02db2f484b
Author: nosnilmot at guifications.org
Date: 2008-05-17T17:57:09
Branch: org.guifications.plugins

Modified files:
        ChangeLog configure.ac switchspell/Makefile.am
        switchspell/switchspell.c

ChangeLog: 

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.

-----------------------------------------------------------------
This revision's diffstat output:
 ChangeLog                 |    2 ++
 configure.ac              |   12 ++++++++++++
 switchspell/Makefile.am   |    2 ++
 switchspell/switchspell.c |   34 ++++++++++++++++++++++++++++++++--
 4 files changed, 48 insertions(+), 2 deletions(-)
-------------- next part --------------
============================================================
--- ChangeLog	fce1a4fe55ff63ed6ca68434a7776ae7056988e0
+++ ChangeLog	22c9aaba4b26ace7109e4d6b47920ad801582468
@@ -7,6 +7,8 @@ Version 2.4.0mtn:
 	* 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
============================================================
--- configure.ac	0348234a5bfcb1e6892eddda1d65171a372fd024
+++ configure.ac	d17712f29cbe874f076605a88cec0965be961148
@@ -268,6 +268,18 @@ fi
 	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)
 
============================================================
--- switchspell/Makefile.am	a7f6b80398d37a5ef1f055c71b57f76073f68e44
+++ switchspell/Makefile.am	9506d3fcb30d0451d8d6f5630187e30f747ef690
@@ -16,6 +16,7 @@ switchspell_la_LIBADD = \
 
 switchspell_la_LIBADD = \
 	$(ASPELL_LIBS) \
+	$(ENCHANT_LIBS) \
 	$(GTK_LIBS) \
 	$(GTKSPELL_LIBS) \
 	$(PIDGIN_LIBS)
@@ -27,6 +28,7 @@ AM_CPPFLAGS = \
 	-DDATADIR=\"$(PIDGIN_DATADIR)\" \
 	-DPIXMAPSDIR=\"$(PIDGIN_PIXMAPSDIR)\" \
 	$(ASPELL_CFLAGS) \
+	$(ENCHANT_CFLAGS) \
 	$(GTK_CFLAGS) \
 	$(DEBUG_CFLAGS) \
 	$(PIDGIN_CFLAGS) \
============================================================
--- switchspell/switchspell.c	06545759ef818bdca1a398bbde53028b03cc150b
+++ switchspell/switchspell.c	6185396d3a25501074dfcec9d255556ef6de6f03
@@ -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 @@ menu_conv_use_dict_cb(GObject *m, gpoint
 
 	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 @@ regenerate_switchspell_menu(PidginConver
 	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 @@ regenerate_switchspell_menu(PidginConver
 	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 @@ regenerate_switchspell_menu(PidginConver
 	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);
 }
 


More information about the Plugins-commits mailing list