Metadata spelling checks
[geeqie.git] / src / bar_comment.c
index 4377b60..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);
 
 /*
@@ -70,10 +74,19 @@ static void bar_pane_comment_update(PaneCommentData *pcd)
        gchar *comment = NULL;
        gchar *orig_comment = NULL;
        gchar *comment_not_null;
+       gshort rating;
        GtkTextBuffer *comment_buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(pcd->comment_view));
 
        orig_comment = text_widget_text_pull(pcd->comment_view);
-       comment = metadata_read_string(pcd->fd, pcd->key, METADATA_PLAIN);
+       if (g_strcmp0(pcd->key, "Xmp.xmp.Rating") == 0)
+               {
+               rating = metadata_read_int(pcd->fd, pcd->key, 0);
+               comment = g_strdup_printf("%d", rating);
+               }
+       else
+               {
+               comment = metadata_read_string(pcd->fd, pcd->key, METADATA_PLAIN);
+               }
        comment_not_null = (comment) ? comment : "";
 
        if (strcmp(orig_comment, comment_not_null) != 0)
@@ -163,17 +176,28 @@ static gint bar_pane_comment_event(GtkWidget *bar, GdkEvent *event)
 static void bar_pane_comment_write_config(GtkWidget *pane, GString *outstr, gint indent)
 {
        PaneCommentData *pcd;
+       gint w, h;
 
        pcd = g_object_get_data(G_OBJECT(pane), "pane_data");
        if (!pcd) return;
 
+       gtk_widget_get_size_request(GTK_WIDGET(pane), &w, &h);
+
        if (!g_strcmp0(pcd->pane.id, "title"))
                {
-               pcd->height = options->info_title.height;
+               pcd->height = h;
                }
        if (!g_strcmp0(pcd->pane.id, "comment"))
                {
-               pcd->height = options->info_comment.height;
+               pcd->height = h;
+               }
+       if (!g_strcmp0(pcd->pane.id, "rating"))
+               {
+               pcd->height = h;
+               }
+       if (!g_strcmp0(pcd->pane.id, "headline"))
+               {
+               pcd->height = h;
                }
 
        WRITE_NL(); WRITE_STRING("<pane_comment ");
@@ -233,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);
 
@@ -269,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);
@@ -311,6 +351,14 @@ GtkWidget *bar_pane_comment_new_from_config(const gchar **attribute_names, const
                {
                options->info_comment.height = height;
                }
+       if (!g_strcmp0(id, "rating"))
+               {
+               options->info_rating.height = height;
+               }
+       if (!g_strcmp0(id, "headline"))
+               {
+               options->info_headline.height = height;
+               }
 
        bar_pane_translate_title(PANE_COMMENT, id, &title);
        ret = bar_pane_comment_new(id, title, key, expanded, height);