From c78e429c2949356b893b6c7d5c692c2a4ccaa447 Mon Sep 17 00:00:00 2001 From: Colin Clark Date: Sun, 3 Apr 2022 18:37:50 +0100 Subject: [PATCH] Metadata spelling checks Provide spelling checks for the Comment, Headline and Title metadata panes. --- configure.ac | 26 ++++++++++++++++++++++++++ doc/docbook/GuideOptionsMetadata.xml | 22 ++++++++++++++++++++++ src/Makefile.am | 4 +++- src/bar_comment.c | 20 ++++++++++++++++++++ src/options.c | 1 + src/options.h | 2 ++ src/preferences.c | 9 +++++++++ src/rcfile.c | 2 ++ 8 files changed, 85 insertions(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index accf0296..bbd30fd2 100644 --- a/configure.ac +++ b/configure.ac @@ -393,6 +393,31 @@ AM_CONDITIONAL(HAVE_RAW, [test "x$HAVE_RAW" = xyes]) AC_SUBST(RAW_CFLAGS) AC_SUBST(RAW_LIBS) +# libgspell support +# ---------------------------------------------------------------------- + +AC_ARG_ENABLE([spell], + AC_HELP_STRING([--disable-spell], [disable libgspell support]), + [libgspell=$enableval], [libgspell=auto]) + +if test "x${libgspell}" != "xno" -a "x${gtk3}" != "xno"; then + PKG_CHECK_MODULES(SPELL, [gspell-1 >= 1.6], + [ + HAVE_SPELL=yes + AC_DEFINE(HAVE_SPELL, 1, [define to enable libgspell support]) + ], + [ + HAVE_SPELL=no + AC_MSG_WARN([$SPELL_PKG_ERRORS]) + ]) +else + HAVE_SPELL=disabled +fi + +AM_CONDITIONAL(HAVE_SPELL, [test "x$HAVE_SPELL" = xyes]) +AC_SUBST(SPELL_CFLAGS) +AC_SUBST(SPELL_LIBS) + # libffmpegthumbnailer support # ---------------------------------------------------------------------- @@ -887,6 +912,7 @@ Support: LibRaw: $HAVE_RAW Libjxl: $HAVE_JPEGXL Libarchive: $HAVE_ARCHIVE + Spelling $HAVE_SPELL Documentation: Doxygen: $DX_DOXYGEN diff --git a/doc/docbook/GuideOptionsMetadata.xml b/doc/docbook/GuideOptionsMetadata.xml index 07d011f7..7229317c 100644 --- a/doc/docbook/GuideOptionsMetadata.xml +++ b/doc/docbook/GuideOptionsMetadata.xml @@ -158,6 +158,28 @@ +
+ Spelling Checks + If selected, spelling checks will be enabled on the following panes: + + + + Title + + + + + Comment + + + + + Headline + + + + +
Pre-load metadata diff --git a/src/Makefile.am b/src/Makefile.am index 9a47bb63..ec709bc0 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -12,6 +12,7 @@ AM_CFLAGS = \ $(CLUTTER_GTK_CFLAGS) \ $(FFMPEGTHUMBNAILER_CFLAGS) \ $(PDF_CFLAGS) \ + $(SPELL_CFLAGS) \ $(HEIF_CFLAGS) \ $(WEBP_CFLAGS) \ $(J2K_CFLAGS) \ @@ -31,6 +32,7 @@ AM_CXXFLAGS = \ $(CLUTTER_GTK_CFLAGS) \ $(FFMPEGTHUMBNAILER_CFLAGS) \ $(PDF_CFLAGS) \ + $(SPELL_CFLAGS) \ $(HEIF_CFLAGS) \ $(WEBP_CFLAGS) \ $(J2K_CFLAGS) \ @@ -311,7 +313,7 @@ geeqie_SOURCES = \ zonedetect.c \ zonedetect.h -geeqie_LDADD = $(GTK_LIBS) $(GLIB_LIBS) $(INTLLIBS) $(JPEG_LIBS) $(TIFF_LIBS) $(LCMS_LIBS) $(EXIV2_LIBS) $(LIBCHAMPLAIN_LIBS) $(LIBCHAMPLAIN_GTK_LIBS) $(LUA_LIBS) $(CLUTTER_LIBS) $(CLUTTER_GTK_LIBS) $(FFMPEGTHUMBNAILER_LIBS) $(PDF_LIBS) $(HEIF_LIBS) $(WEBP_LIBS) $(DJVU_LIBS) $(J2K_LIBS) $(RAW_LIBS) $(JPEGXL_LIBS) $(ARCHIVE_LIBS) +geeqie_LDADD = $(GTK_LIBS) $(GLIB_LIBS) $(INTLLIBS) $(JPEG_LIBS) $(TIFF_LIBS) $(LCMS_LIBS) $(EXIV2_LIBS) $(LIBCHAMPLAIN_LIBS) $(LIBCHAMPLAIN_GTK_LIBS) $(LUA_LIBS) $(CLUTTER_LIBS) $(CLUTTER_GTK_LIBS) $(FFMPEGTHUMBNAILER_LIBS) $(PDF_LIBS) $(HEIF_LIBS) $(WEBP_LIBS) $(SPELL_LIBS) $(DJVU_LIBS) $(J2K_LIBS) $(RAW_LIBS) $(JPEGXL_LIBS) $(ARCHIVE_LIBS) EXTRA_DIST = \ $(extra_SLIK) diff --git a/src/bar_comment.c b/src/bar_comment.c index 50470773..5dbc5b54 100644 --- a/src/bar_comment.c +++ b/src/bar_comment.c @@ -30,6 +30,10 @@ #include "rcfile.h" #include "layout.h" +#ifdef HAVE_SPELL +#include +#endif + static void bar_pane_comment_changed(GtkTextBuffer *buffer, gpointer data); /* @@ -253,6 +257,9 @@ static GtkWidget *bar_pane_comment_new(const gchar *id, const gchar *title, cons PaneCommentData *pcd; GtkWidget *scrolled; GtkTextBuffer *buffer; +#ifdef HAVE_SPELL + GspellTextView *gspell_view; +#endif pcd = g_new0(PaneCommentData, 1); @@ -289,6 +296,19 @@ static GtkWidget *bar_pane_comment_new(const gchar *id, const gchar *title, cons G_CALLBACK(bar_pane_comment_populate_popup), pcd); gtk_widget_show(pcd->comment_view); +#ifdef HAVE_SPELL +#if GTK_CHECK_VERSION(3,20,0) + if (g_strcmp0(key, "Xmp.xmp.Rating") != 0) + { + if (options->metadata.check_spelling) + { + gspell_view = gspell_text_view_get_from_gtk_text_view(GTK_TEXT_VIEW(pcd->comment_view)); + gspell_text_view_basic_setup(gspell_view); + } + } +#endif +#endif + buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(pcd->comment_view)); g_signal_connect(G_OBJECT(buffer), "changed", G_CALLBACK(bar_pane_comment_changed), pcd); diff --git a/src/options.c b/src/options.c index f650cf15..995a329e 100644 --- a/src/options.c +++ b/src/options.c @@ -164,6 +164,7 @@ ConfOptions *init_options(ConfOptions *options) options->metadata.keywords_case_sensitive = FALSE; options->metadata.write_orientation = TRUE; options->metadata.sidecar_extended_name = FALSE; + options->metadata.check_spelling = TRUE; options->show_icon_names = TRUE; options->show_star_rating = FALSE; diff --git a/src/options.h b/src/options.h index 1492e413..41fd01f8 100644 --- a/src/options.h +++ b/src/options.h @@ -290,6 +290,8 @@ struct _ConfOptions gboolean keywords_case_sensitive; gboolean write_orientation; gboolean sidecar_extended_name; + + gboolean check_spelling; } metadata; /* Stereo */ diff --git a/src/preferences.c b/src/preferences.c index 831e9de4..a67fc772 100644 --- a/src/preferences.c +++ b/src/preferences.c @@ -415,6 +415,7 @@ static void config_window_apply(void) options->metadata.confirm_on_dir_change = c_options->metadata.confirm_on_dir_change; options->metadata.keywords_case_sensitive = c_options->metadata.keywords_case_sensitive; options->metadata.write_orientation = c_options->metadata.write_orientation; + options->metadata.check_spelling = c_options->metadata.check_spelling; options->stereo.mode = (c_options->stereo.mode & (PR_STEREO_HORIZ | PR_STEREO_VERT | PR_STEREO_FIXED | PR_STEREO_ANAGLYPH | PR_STEREO_HALF)) | (c_options->stereo.tmp.mirror_right ? PR_STEREO_MIRROR_RIGHT : 0) | (c_options->stereo.tmp.flip_right ? PR_STEREO_FLIP_RIGHT : 0) | @@ -2963,6 +2964,14 @@ static void config_tab_metadata(GtkWidget *notebook) pref_checkbox_new_int(group, _("Write metadata on directory change"), options->metadata.confirm_on_dir_change, &c_options->metadata.confirm_on_dir_change); +#ifdef HAVE_SPELL +#if GTK_CHECK_VERSION(3,20,0) + group = pref_group_new(vbox, FALSE, _("Spelling checks"), GTK_ORIENTATION_VERTICAL); + + ct_button = pref_checkbox_new_int(group, _("Check spelling -Requires restart"), options->metadata.check_spelling, &c_options->metadata.check_spelling); +#endif +#endif + group = pref_group_new(vbox, FALSE, _("Pre-load metadata"), GTK_ORIENTATION_VERTICAL); ct_button = pref_checkbox_new_int(group, _("Read metadata in background"), diff --git a/src/rcfile.c b/src/rcfile.c index e546b1be..cc80f202 100644 --- a/src/rcfile.c +++ b/src/rcfile.c @@ -488,6 +488,7 @@ static void write_global_attributes(GString *outstr, gint indent) WRITE_NL(); WRITE_BOOL(*options, metadata.confirm_on_dir_change); WRITE_NL(); WRITE_BOOL(*options, metadata.keywords_case_sensitive); WRITE_NL(); WRITE_BOOL(*options, metadata.write_orientation); + WRITE_NL(); WRITE_BOOL(*options, metadata.check_spelling); WRITE_NL(); WRITE_INT(*options, stereo.mode); WRITE_NL(); WRITE_INT(*options, stereo.fsmode); @@ -982,6 +983,7 @@ static gboolean load_global_params(const gchar **attribute_names, const gchar ** if (READ_BOOL(*options, metadata.confirm_on_dir_change)) continue; if (READ_BOOL(*options, metadata.keywords_case_sensitive)) continue; if (READ_BOOL(*options, metadata.write_orientation)) continue; + if (READ_BOOL(*options, metadata.check_spelling)) continue; if (READ_INT(*options, stereo.mode)) continue; if (READ_INT(*options, stereo.fsmode)) continue; -- 2.20.1