Branch: refs/heads/master Author: Sagar Chalise chalisesagar@gmail.com Committer: Colomban Wendling ban@herbesfolles.org Date: Wed, 17 Feb 2016 18:38:24 UTC Commit: 57e0cd0dd9f727e689eea6d77eda896c664123d1 https://github.com/geany/geany-plugins/commit/57e0cd0dd9f727e689eea6d77eda89...
Log Message: ----------- geanyvc: Use GTK3-compatible GtkSpell when using GTK3
Closes #342.
Modified Paths: -------------- build/geanyvc.m4 geanyvc/src/geanyvc.c
Modified: build/geanyvc.m4 7 lines changed, 4 insertions(+), 3 deletions(-) =================================================================== @@ -6,12 +6,13 @@ AC_DEFUN([GP_CHECK_GEANYVC], AC_HELP_STRING([--enable-gtkspell=ARG], [Enable GtkSpell support in GeanyVC. [[default=auto]]]),, enable_gtkspell=auto) - + GP_CHECK_GTK3([gtkspell_package=gtkspell3-3.0], + [gtkspell_package=gtkspell-2.0]) if [[ x"$enable_gtkspell" = "xauto" ]]; then - PKG_CHECK_MODULES(GTKSPELL, gtkspell-2.0, + PKG_CHECK_MODULES(GTKSPELL, $gtkspell_package, enable_gtkspell=yes, enable_gtkspell=no) elif [[ x"$enable_gtkspell" = "xyes" ]]; then - PKG_CHECK_MODULES(GTKSPELL, [gtkspell-2.0]) + PKG_CHECK_MODULES(GTKSPELL, [$gtkspell_package]) fi if [[ x"$enable_gtkspell" = "xyes" ]]; then AC_DEFINE(USE_GTKSPELL, 1, [GtkSpell support])
Modified: geanyvc/src/geanyvc.c 38 lines changed, 22 insertions(+), 16 deletions(-) =================================================================== @@ -39,6 +39,25 @@
#ifdef USE_GTKSPELL #include <gtkspell/gtkspell.h> +/* forward compatibility with GtkSpell3 */ +#if GTK_CHECK_VERSION(3, 0, 0) +#define GtkSpell GtkSpellChecker +#define gtkspell_set_language gtk_spell_checker_set_language +static GtkSpell *gtkspell_new_attach(GtkTextView *view, const gchar *lang, GError **error) +{ + GtkSpellChecker *speller = gtk_spell_checker_new(); + + if (! lang || gtk_spell_checker_set_language(speller, lang, error)) + gtk_spell_checker_attach(speller, view); + else + { + g_object_unref(g_object_ref_sink(speller)); + speller = NULL; + } + + return speller; +} +#endif #endif
GeanyData *geany_data; @@ -1586,27 +1605,14 @@ vccommit_activated(G_GNUC_UNUSED GtkMenuItem * menuitem, G_GNUC_UNUSED gpointer gtk_paned_set_position(GTK_PANED(vpaned2), height * 50 / 100);
#ifdef USE_GTKSPELL - speller = gtkspell_new_attach(GTK_TEXT_VIEW(messageView), NULL, &spellcheck_error); - if (speller == NULL) + speller = gtkspell_new_attach(GTK_TEXT_VIEW(messageView), EMPTY(lang) ? NULL : lang, &spellcheck_error); + if (speller == NULL && spellcheck_error != NULL) { - ui_set_statusbar(FALSE, _("Error initializing spell checking: %s"), + ui_set_statusbar(TRUE, _("Error initializing spell checking: %s"), spellcheck_error->message); g_error_free(spellcheck_error); spellcheck_error = NULL; } - else if (!EMPTY(lang)) - { - gtkspell_set_language(speller, lang, &spellcheck_error); - if (spellcheck_error != NULL) - { - ui_set_statusbar(TRUE, - _ - ("Error while setting up language for spellchecking. Please check configuration. Error message was: %s"), - spellcheck_error->message); - g_error_free(spellcheck_error); - spellcheck_error = NULL; - } - } #endif
/* put the input focus to the commit message text view */
-------------- This E-Mail was brought to you by github_commit_mail.py (Source: https://github.com/geany/infrastructure).
plugins-commits@lists.geany.org