From 8785b68ec2bafc1758472945f5e0a0ee9522a14e Mon Sep 17 00:00:00 2001 From: Colin Clark Date: Fri, 17 Aug 2018 18:12:04 +0100 Subject: [PATCH] Fix #629: Keywords are not adding properly to selected files https://github.com/BestImageViewer/geeqie/issues/629 The right-click menu of the left-hand keywords pane of the info sidebar now uses only the selected keywords. Any partially selected keywords will be expanded to the full keyword. Select none == select all --- doc/docbook/GuideSidebarsInfo.xml | 7 ++++++- src/bar_keywords.c | 19 ++++++++++++++++--- src/ui_misc.c | 30 ++++++++++++++++++++++++++++++ src/ui_misc.h | 1 + web/help/GuideSidebarsInfo.html | 7 ++++++- 5 files changed, 59 insertions(+), 5 deletions(-) diff --git a/doc/docbook/GuideSidebarsInfo.xml b/doc/docbook/GuideSidebarsInfo.xml index 51916570..4a19e5be 100644 --- a/doc/docbook/GuideSidebarsInfo.xml +++ b/doc/docbook/GuideSidebarsInfo.xml @@ -114,7 +114,12 @@ This action cannot be undone. Irrespective of their position in a hierarchy in the right-hand box, all keywords are written as individual entries into metadata. When metadata for an image is read in, Geeqie will attempt to recreate any hierarchies within the data, and display it accordingly in the right-hand box. - Right-click on the left-hand box allows the keywords to be written to the currently selected files - the keywords may be either added to the existing contents, or entirely replace the existing content. + + Right-click on the left-hand box allows the selected keywords to be written to the currently selected files - the keywords may be either added to the existing contents, or entirely replace the existing content. + + Keyword completion is used when selecting keywords. If the selected area includes part of a keyword, the selection will autmatically be expanded to cover the whole keyword. If no text is selected, all keywords will be used. + + Right-click on the right-hand box allows a connection to be made between a keyword and a mark. The diff --git a/src/bar_keywords.c b/src/bar_keywords.c index b62b988a..3509bc5a 100644 --- a/src/bar_keywords.c +++ b/src/bar_keywords.c @@ -62,6 +62,19 @@ GList *keyword_list_pull(GtkWidget *text_widget) return list; } +static GList *keyword_list_pull_selected(GtkWidget *text_widget) +{ + GList *list; + gchar *text; + + text = text_widget_text_pull_selected(text_widget); + list = string_to_keywords_list(text); + + g_free(text); + + return list; +} + /* the "changed" signal should be blocked before calling this */ static void keyword_list_push(GtkWidget *textview, GList *list) { @@ -416,7 +429,7 @@ static void bar_pane_keywords_set_selection(PaneKeywordsData *pkd, gboolean appe GList *list = NULL; GList *work; - keywords = keyword_list_pull(pkd->keyword_view); + keywords = keyword_list_pull_selected(pkd->keyword_view); list = layout_selection_list(pkd->pane.lw); list = file_data_process_groups_in_selection(list, FALSE, NULL); @@ -460,8 +473,8 @@ static void bar_pane_keywords_populate_popup_cb(GtkTextView *textview, GtkMenu * PaneKeywordsData *pkd = data; menu_item_add_divider(GTK_WIDGET(menu)); - menu_item_add_stock(GTK_WIDGET(menu), _("Add keywords to selected files"), GTK_STOCK_ADD, G_CALLBACK(bar_pane_keywords_sel_add_cb), pkd); - menu_item_add_stock(GTK_WIDGET(menu), _("Replace existing keywords in selected files"), GTK_STOCK_CONVERT, G_CALLBACK(bar_pane_keywords_sel_replace_cb), pkd); + menu_item_add_stock(GTK_WIDGET(menu), _("Add selected keywords to selected files"), GTK_STOCK_ADD, G_CALLBACK(bar_pane_keywords_sel_add_cb), pkd); + menu_item_add_stock(GTK_WIDGET(menu), _("Replace existing keywords in selected files with selected keywords"), GTK_STOCK_CONVERT, G_CALLBACK(bar_pane_keywords_sel_replace_cb), pkd); } diff --git a/src/ui_misc.c b/src/ui_misc.c index a5e905d2..312d3aaa 100644 --- a/src/ui_misc.c +++ b/src/ui_misc.c @@ -1732,4 +1732,34 @@ gchar *text_widget_text_pull(GtkWidget *text_widget) } +gchar *text_widget_text_pull_selected(GtkWidget *text_widget) +{ + if (GTK_IS_TEXT_VIEW(text_widget)) + { + GtkTextBuffer *buffer; + GtkTextIter start, end; + GtkTextIter selection_start, selection_end; + + buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(text_widget)); + gtk_text_buffer_get_bounds(buffer, &start, &end); + + if (gtk_text_buffer_get_selection_bounds(buffer, &start, &end)) + { + gtk_text_iter_set_line_offset(&start, 0); + gtk_text_iter_forward_to_line_end(&end); + } + + return gtk_text_buffer_get_text(buffer, &start, &end, FALSE); + } + else if (GTK_IS_ENTRY(text_widget)) + { + return g_strdup(gtk_entry_get_text(GTK_ENTRY(text_widget))); + } + else + { + return NULL; + } + +} + /* vim: set shiftwidth=8 softtabstop=0 cindent cinoptions={1s: */ diff --git a/src/ui_misc.h b/src/ui_misc.h index 1389ce4e..7f65770a 100644 --- a/src/ui_misc.h +++ b/src/ui_misc.h @@ -199,6 +199,7 @@ GtkWidget *pref_color_button_new(GtkWidget *parent_box, GCallback func, gpointer data); gchar *text_widget_text_pull(GtkWidget *text_widget); +gchar *text_widget_text_pull_selected(GtkWidget *text_widget); #endif /* vim: set shiftwidth=8 softtabstop=0 cindent cinoptions={1s: */ diff --git a/web/help/GuideSidebarsInfo.html b/web/help/GuideSidebarsInfo.html index 02c64b1c..e31b30e4 100644 --- a/web/help/GuideSidebarsInfo.html +++ b/web/help/GuideSidebarsInfo.html @@ -572,7 +572,12 @@ dd.answer div.label { float: left; }

This action cannot be undone.

Irrespective of their position in a hierarchy in the right-hand box, all keywords are written as individual entries into metadata. When metadata for an image is read in, Geeqie will attempt to recreate any hierarchies within the data, and display it accordingly in the right-hand box.

-

Right-click on the left-hand box allows the keywords to be written to the currently selected files - the keywords may be either added to the existing contents, or entirely replace the existing content.

+

+ Right-click on the left-hand box allows the selected keywords to be written to the currently selected files - the keywords may be either added to the existing contents, or entirely replace the existing content. +

+

Keyword completion is used when selecting keywords. If the selected area includes part of a keyword, the selection will autmatically be expanded to cover the whole keyword. If no text is selected, all keywords will be used.

+
+

Right-click on the right-hand box allows a connection to be made between a keyword and a mark. The Marking Images -- 2.20.1