Metadata spelling checks
authorColin Clark <colin.clark@cclark.uk>
Sun, 3 Apr 2022 17:37:50 +0000 (18:37 +0100)
committerColin Clark <colin.clark@cclark.uk>
Sun, 3 Apr 2022 17:37:50 +0000 (18:37 +0100)
Provide spelling checks for the Comment, Headline and Title metadata
panes.

configure.ac
doc/docbook/GuideOptionsMetadata.xml
src/Makefile.am
src/bar_comment.c
src/options.c
src/options.h
src/preferences.c
src/rcfile.c

index accf029..bbd30fd 100644 (file)
@@ -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
index 07d011f..7229317 100644 (file)
     </itemizedlist>
     <para />
   </section>
+  <section id="SpellCheck">
+    <title>Spelling Checks</title>
+    <para>If selected, spelling checks will be enabled on the following panes:</para>
+    <itemizedlist>
+      <listitem>
+        <para>
+          <guilabel>Title</guilabel>
+        </para>
+      </listitem>
+      <listitem>
+        <para>
+          <guilabel>Comment</guilabel>
+        </para>
+      </listitem>
+      <listitem>
+        <para>
+          <guilabel>Headline</guilabel>
+        </para>
+      </listitem>
+    </itemizedlist>
+    <para />
+  </section>
   <section id="PreLoadMetadata">
     <title>Pre-load metadata</title>
     <itemizedlist>
index 9a47bb6..ec709bc 100644 (file)
@@ -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)
index 5047077..5dbc5b5 100644 (file)
 #include "rcfile.h"
 #include "layout.h"
 
+#ifdef HAVE_SPELL
+#include <gspell/gspell.h>
+#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);
index f650cf1..995a329 100644 (file)
@@ -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;
index 1492e41..41fd01f 100644 (file)
@@ -290,6 +290,8 @@ struct _ConfOptions
                gboolean keywords_case_sensitive;
                gboolean write_orientation;
                gboolean sidecar_extended_name;
+
+               gboolean check_spelling;
        } metadata;
 
        /* Stereo */
index 831e9de..a67fc77 100644 (file)
@@ -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"),
index e546b1b..cc80f20 100644 (file)
@@ -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;