Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[GeanyVC] use compatible gtkspell on building for gtk3 #342

Closed
wants to merge 4 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Changes made according to discussion in pull request. Needs testing o…
…n gtk2.
Sagar Chalise committed Feb 15, 2016
commit 165b723228de9d38c8275a5e95a7dbad7d9467ae
57 changes: 25 additions & 32 deletions geanyvc/src/geanyvc.c
Original file line number Diff line number Diff line change
@@ -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;
@@ -1528,12 +1547,7 @@ vccommit_activated(G_GNUC_UNUSED GtkMenuItem * menuitem, G_GNUC_UNUSED gpointer
gint height;

#ifdef USE_GTKSPELL
#if !GTK_CHECK_VERSION (3, 0, 0)
//Since gtk3 will be default in future may be going this way would be better.
#define GtkSpellSpellChecker GtkSpell
#define gtk_spell_checker_set_language gtkspell_set_language
#endif
GtkSpellChecker *speller = NULL;
GtkSpell *speller = NULL;
GError *spellcheck_error = NULL;
#endif

@@ -1591,34 +1605,13 @@ vccommit_activated(G_GNUC_UNUSED GtkMenuItem * menuitem, G_GNUC_UNUSED gpointer
gtk_paned_set_position(GTK_PANED(vpaned2), height * 50 / 100);

#ifdef USE_GTKSPELL
#if GTK_CHECK_VERSION (3, 0, 0)
speller = gtk_spell_checker_new ();
gtk_spell_checker_attach (speller, GTK_TEXT_VIEW (messageView));
#else
speller = gtkspell_new_attach(GTK_TEXT_VIEW(messageView), NULL, &spellcheck_error);
#endif
if (speller == NULL)
{
if (spellcheck_error != NULL)
{
ui_set_statusbar(FALSE, _("Error initializing spell checking: %s"),
spellcheck_error->message);
speller = gtkspell_new_attach(GTK_TEXT_VIEW(messageView), lang, &spellcheck_error);
if (speller == NULL && spellcheck_error != NULL)
{
ui_set_statusbar(TRUE, _("Error initializing spell checking: %s"),
spellcheck_error->message);
g_error_free(spellcheck_error);
spellcheck_error = NULL;
}
}
else if (!EMPTY(lang))
{
gtk_spell_checker_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