X-Git-Url: http://geeqie.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fbar_comment.c;h=5a7500762e35026dd4a134b1b5a1c8dc30ada971;hb=a2756cb29e1e1c3380a4047e680f12b579640850;hp=c2228b0b174708875eb487515256e10856ac8a85;hpb=223d36e4c7eae2144f2eb20c6f0c77e27bbe743e;p=geeqie.git diff --git a/src/bar_comment.c b/src/bar_comment.c index c2228b0b..5a750076 100644 --- a/src/bar_comment.c +++ b/src/bar_comment.c @@ -1,7 +1,7 @@ /* * Geeqie * (C) 2004 John Ellis - * Copyright (C) 2008 - 2009 The Geeqie Team + * Copyright (C) 2008 - 2012 The Geeqie Team * * Author: John Ellis * @@ -60,16 +60,22 @@ static void bar_pane_comment_write(PaneCommentData *pcd) static void bar_pane_comment_update(PaneCommentData *pcd) { gchar *comment = NULL; + gchar *orig_comment = NULL; + gchar *comment_not_null; GtkTextBuffer *comment_buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(pcd->comment_view)); - g_signal_handlers_block_by_func(comment_buffer, bar_pane_comment_changed, pcd); - + orig_comment = text_widget_text_pull(pcd->comment_view); comment = metadata_read_string(pcd->fd, pcd->key, METADATA_PLAIN); - gtk_text_buffer_set_text(comment_buffer, - (comment) ? comment : "", -1); - g_free(comment); + comment_not_null = (comment) ? comment : ""; - g_signal_handlers_unblock_by_func(comment_buffer, bar_pane_comment_changed, pcd); + if (strcmp(orig_comment, comment_not_null) != 0) + { + g_signal_handlers_block_by_func(comment_buffer, bar_pane_comment_changed, pcd); + gtk_text_buffer_set_text(comment_buffer, comment_not_null, -1); + g_signal_handlers_unblock_by_func(comment_buffer, bar_pane_comment_changed, pcd); + } + g_free(comment); + g_free(orig_comment); gtk_widget_set_sensitive(pcd->comment_view, (pcd->fd != NULL)); } @@ -83,11 +89,14 @@ static void bar_pane_comment_set_selection(PaneCommentData *pcd, gboolean append comment = text_widget_text_pull(pcd->comment_view); list = layout_selection_list(pcd->pane.lw); + list = file_data_process_groups_in_selection(list, FALSE, NULL); + work = list; while (work) { FileData *fd = work->data; work = work->next; + if (fd == pcd->fd) continue; if (append) { @@ -138,7 +147,7 @@ static gint bar_pane_comment_event(GtkWidget *bar, GdkEvent *event) pcd = g_object_get_data(G_OBJECT(bar), "pane_data"); if (!pcd) return FALSE; - if (GTK_WIDGET_HAS_FOCUS(pcd->comment_view)) return gtk_widget_event(pcd->comment_view, event); + if (gtk_widget_has_focus(pcd->comment_view)) return gtk_widget_event(pcd->comment_view, event); return FALSE; } @@ -162,16 +171,19 @@ static void bar_pane_comment_write_config(GtkWidget *pane, GString *outstr, gint static void bar_pane_comment_notify_cb(FileData *fd, NotifyType type, gpointer data) { PaneCommentData *pcd = data; - if (fd == pcd->fd) bar_pane_comment_update(pcd); + if ((type & (NOTIFY_REREAD | NOTIFY_CHANGE | NOTIFY_METADATA)) && fd == pcd->fd) + { + DEBUG_1("Notify pane_comment: %s %04x", fd->path, type); + + bar_pane_comment_update(pcd); + } } static void bar_pane_comment_changed(GtkTextBuffer *buffer, gpointer data) { PaneCommentData *pcd = data; - file_data_unregister_notify_func(bar_pane_comment_notify_cb, pcd); bar_pane_comment_write(pcd); - file_data_register_notify_func(bar_pane_comment_notify_cb, pcd, NOTIFY_PRIORITY_LOW); } @@ -184,17 +196,6 @@ static void bar_pane_comment_populate_popup(GtkTextView *textview, GtkMenu *menu menu_item_add_stock(GTK_WIDGET(menu), _("Replace existing text in selected files"), GTK_STOCK_CONVERT, G_CALLBACK(bar_pane_comment_sel_replace_cb), data); } - -static void bar_pane_comment_close(GtkWidget *bar) -{ - PaneCommentData *pcd; - - pcd = g_object_get_data(G_OBJECT(bar), "pane_data"); - if (!pcd) return; - - gtk_widget_destroy(pcd->comment_view); -} - static void bar_pane_comment_destroy(GtkWidget *widget, gpointer data) { PaneCommentData *pcd = data; @@ -210,7 +211,7 @@ static void bar_pane_comment_destroy(GtkWidget *widget, gpointer data) } -GtkWidget *bar_pane_comment_new(const gchar *id, const gchar *title, const gchar *key, gboolean expanded, gint height) +static GtkWidget *bar_pane_comment_new(const gchar *id, const gchar *title, const gchar *key, gboolean expanded, gint height) { PaneCommentData *pcd; GtkWidget *scrolled; @@ -263,7 +264,7 @@ GtkWidget *bar_pane_comment_new(const gchar *id, const gchar *title, const gchar GtkWidget *bar_pane_comment_new_from_config(const gchar **attribute_names, const gchar **attribute_values) { - gchar *title = g_strdup(_("Comment")); + gchar *title = NULL; gchar *key = g_strdup(COMMENT_KEY); gboolean expanded = TRUE; gint height = 50; @@ -285,6 +286,7 @@ GtkWidget *bar_pane_comment_new_from_config(const gchar **attribute_names, const log_printf("unknown attribute %s = %s\n", option, value); } + bar_pane_translate_title(PANE_COMMENT, id, &title); ret = bar_pane_comment_new(id, title, key, expanded, height); g_free(title); g_free(key); @@ -318,6 +320,7 @@ void bar_pane_comment_update_from_config(GtkWidget *pane, const gchar **attribut if (title) { + bar_pane_translate_title(PANE_COMMENT, pcd->pane.id, &title); gtk_label_set_text(GTK_LABEL(pcd->pane.title), title); g_free(title); }