When building against gtk3 the gtkspell support was missing. This needs testing in gtk2 environment. You can view, comment on, or merge this pull request online at:
https://github.com/geany/geany-plugins/pull/342
-- Commit Summary --
* use gtk3 compatible gtkspell on commit dialog when using gtk3
-- File Changes --
M build/geanyvc.m4 (7) M geanyvc/src/geanyvc.c (12)
-- Patch Links --
https://github.com/geany/geany-plugins/pull/342.patch https://github.com/geany/geany-plugins/pull/342.diff
--- Reply to this email directly or view it on GitHub: https://github.com/geany/geany-plugins/pull/342
I'm afraid build is failing here ```
geanyvc.c: In function 'vccommit_activated': geanyvc.c:1536:2: error: unknown type name 'GtkSpellChecker' GtkSpellChecker *speller = NULL; ^ geanyvc.c:1598:17: warning: assignment from incompatible pointer type [-Wincompatible-pointer-types] speller = gtkspell_new_attach(GTK_TEXT_VIEW(messageView), NULL, &spellcheck_error); ^ geanyvc.c:1612:34: warning: passing argument 1 of 'gtkspell_set_language' from incompatible pointer type [-Wincompatible-pointer-types] gtk_spell_checker_set_language(speller, lang, &spellcheck_error); ^ In file included from geanyvc.c:41:0: /usr/include/gtkspell-2.0/gtkspell/gtkspell.h:34:11: note: expected 'GtkSpell * {aka struct _GtkSpell *}' but argument is of type 'int *' gboolean gtkspell_set_language(GtkSpell *spell, ^
```
--- Reply to this email directly or view it on GitHub: https://github.com/geany/geany-plugins/pull/342#issuecomment-183517896
Work for me after the mentioned fix.
--- Reply to this email directly or view it on GitHub: https://github.com/geany/geany-plugins/pull/342#issuecomment-183718559
@@ -1528,7 +1528,12 @@ vccommit_activated(G_GNUC_UNUSED GtkMenuItem * menuitem, G_GNUC_UNUSED gpointer gint height;
#ifdef USE_GTKSPELL
- GtkSpell *speller = NULL;
+#if !GTK_CHECK_VERSION (3, 0, 0) +//Since gtk3 will be default in future may be going this way would be better.
comment is not very useful, but I agree adding compat layer for older version rather than newer
--- Reply to this email directly or view it on GitHub: https://github.com/geany/geany-plugins/pull/342/files#r52831585
@@ -1528,7 +1528,12 @@ vccommit_activated(G_GNUC_UNUSED GtkMenuItem * menuitem, G_GNUC_UNUSED gpointer gint height;
#ifdef USE_GTKSPELL
- GtkSpell *speller = NULL;
+#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
might be better to add this compat higher in the file, e.g. near the gtkspell include?
--- Reply to this email directly or view it on GitHub: https://github.com/geany/geany-plugins/pull/342/files#r52831591
@@ -1586,17 +1591,25 @@ 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 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
…though here it might be better to do the contrary and add a compat function for GTK3 ```C static GtkSpellChecker *gtkspell_new_attach(GtkTextView *view, const gchar *lang, GError **error) { GtkSpellChecker *speller = gtk_spell_checker_new (); gtk_spell_checker_attach (speller, view); return speller; } ``` next to the other compat macros so there is a single gtkspell compat layer in one single location?
--- Reply to this email directly or view it on GitHub: https://github.com/geany/geany-plugins/pull/342/files#r52831670
spellcheck_error->message);
g_error_free(spellcheck_error);
spellcheck_error = NULL;
g_error_free(spellcheck_error);
spellcheck_error = NULL;
}
indent mixup, should use tabs like the rest of the file
--- Reply to this email directly or view it on GitHub: https://github.com/geany/geany-plugins/pull/342/files#r52831699
if (speller == NULL) {
ui_set_statusbar(FALSE, _("Error initializing spell checking: %s"),
if (spellcheck_error != NULL)
you could simply check this in place of `speller != NULL` actually. Though in practice for GtkSpell3 I guess it's totally impossible for `speller` to be `NULL`
--- Reply to this email directly or view it on GitHub: https://github.com/geany/geany-plugins/pull/342/files#r52831724
If we wanted a simpler/less intrusive port, we could just do ```diff diff --git a/geanyvc/src/geanyvc.c b/geanyvc/src/geanyvc.c index a95a991..488f1f2 100644 --- a/geanyvc/src/geanyvc.c +++ b/geanyvc/src/geanyvc.c @@ -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(speller); + speller = NULL; + } + + return speller; +} +# endif #endif
GeanyData *geany_data; ``` in the code, and just keep the build system changes from this PR, which are just fine.
--- Reply to this email directly or view it on GitHub: https://github.com/geany/geany-plugins/pull/342#issuecomment-183728796
Sorry about the typo. Have made changes according to suggestions made by @b4n .
--- Reply to this email directly or view it on GitHub: https://github.com/geany/geany-plugins/pull/342#issuecomment-184218627
Indentation style is incorrect in geanyvc.c (should use tabs (with width=4), like the rest of the file). Commits should be squashed. I can do both when merging this if you like.
Apart that, looks good and seems to work fine on both GTK2 and 3. BTW, good job simplifying the error handling that indeed was unnecessarily complex :)
--- Reply to this email directly or view it on GitHub: https://github.com/geany/geany-plugins/pull/342#issuecomment-185267878
@b4n Do whatever you consider necessary. Also, I guess the error message should have something about GeanyVC as user may misunderstand it to be message of spell check plugin. Something like
- Error initializing spell checking for geanyvc: or - [GeanyVC] Error initializing spell checking:
--- Reply to this email directly or view it on GitHub: https://github.com/geany/geany-plugins/pull/342#issuecomment-185327412
Closed #342 via 57e0cd0dd9f727e689eea6d77eda896c664123d1.
--- Reply to this email directly or view it on GitHub: https://github.com/geany/geany-plugins/pull/342#event-554001419
@b4n Do whatever you consider necessary.
Okay, done, committed as 57e0cd0.
Also, I guess the error message should have something about GeanyVC as user may misunderstand it to be message of spell check plugin. […]
Good point. Done in a788c31
--- Reply to this email directly or view it on GitHub: https://github.com/geany/geany-plugins/pull/342#issuecomment-185342420
github-comments@lists.geany.org