/*
- * Geeqie
- * (C) 2004 John Ellis
- * Copyright (C) 2008 - 2012 The Geeqie Team
+ * Copyright (C) 2004 John Ellis
+ * Copyright (C) 2008 - 2016 The Geeqie Team
*
* Author: John Ellis
*
- * This software is released under the GNU General Public License (GNU GPL).
- * Please read the included file COPYING for more information.
- * This software comes with no warranty of any kind, use at your own risk!
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
-
#include "main.h"
#include "bar_comment.h"
#include "rcfile.h"
#include "layout.h"
+#ifdef HAVE_SPELL
+#include <gspell/gspell.h>
+#endif
+
static void bar_pane_comment_changed(GtkTextBuffer *buffer, gpointer data);
/*
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)
{
g_signal_handlers_block_by_func(comment_buffer, bar_pane_comment_changed, pcd);
list = layout_selection_list(pcd->pane.lw);
list = file_data_process_groups_in_selection(list, FALSE, NULL);
-
+
work = list;
while (work)
{
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 = h;
+ }
+ if (!g_strcmp0(pcd->pane.id, "comment"))
+ {
+ 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 ");
write_char_option(outstr, indent, "id", pcd->pane.id);
write_char_option(outstr, indent, "title", gtk_label_get_text(GTK_LABEL(pcd->pane.title)));
WRITE_BOOL(pcd->pane, expanded);
WRITE_CHAR(*pcd, key);
- WRITE_INT(*pcd, height);
+ WRITE_INT(*pcd, height);
WRITE_STRING("/>");
}
static void bar_pane_comment_notify_cb(FileData *fd, NotifyType type, gpointer data)
{
PaneCommentData *pcd = data;
- if ((type & (NOTIFY_REREAD | NOTIFY_CHANGE | NOTIFY_METADATA)) && fd == pcd->fd)
+ if ((type & (NOTIFY_REREAD | NOTIFY_CHANGE | NOTIFY_METADATA)) && fd == pcd->fd)
{
DEBUG_1("Notify pane_comment: %s %04x", fd->path, type);
PaneCommentData *pcd;
GtkWidget *scrolled;
GtkTextBuffer *buffer;
+#ifdef HAVE_SPELL
+ GspellTextView *gspell_view;
+#endif
pcd = g_new0(PaneCommentData, 1);
-
+
pcd->pane.pane_set_fd = bar_pane_comment_set_fd;
pcd->pane.pane_event = bar_pane_comment_event;
pcd->pane.pane_write_config = bar_pane_comment_write_config;
pcd->pane.type = PANE_COMMENT;
pcd->pane.expanded = expanded;
-
+
pcd->key = g_strdup(key);
pcd->height = height;
scrolled = gtk_scrolled_window_new(NULL, NULL);
-
+
pcd->widget = scrolled;
g_object_set_data(G_OBJECT(pcd->widget), "pane_data", pcd);
g_signal_connect(G_OBJECT(pcd->widget), "destroy",
G_CALLBACK(bar_pane_comment_destroy), pcd);
-
+
gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scrolled), GTK_SHADOW_IN);
gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled),
GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
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);
if (READ_BOOL_FULL("expanded", expanded)) continue;
if (READ_INT_FULL("height", height)) continue;
if (READ_CHAR_FULL("id", id)) continue;
-
+
log_printf("unknown attribute %s = %s\n", option, value);
}
-
+
+ if (!g_strcmp0(id, "title"))
+ {
+ options->info_title.height = height;
+ }
+ if (!g_strcmp0(id, "comment"))
+ {
+ 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);
g_free(title);
if (READ_BOOL_FULL("expanded", pcd->pane.expanded)) continue;
if (READ_INT_FULL("height", pcd->height)) continue;
if (READ_CHAR_FULL("id", pcd->pane.id)) continue;
-
+
log_printf("unknown attribute %s = %s\n", option, value);
}