# HG changeset patch # User Colin Clark # Date 1534525924 -3600 # Node ID dbe1524ba0093c3930f403eb6b45047e50c5b4c3 # Parent f1c975235febe5a5b54f282ce2f87ed791c86e12 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 diff -r f1c975235feb -r dbe1524ba009 doc/docbook/GuideSidebarsInfo.xml --- a/doc/docbook/GuideSidebarsInfo.xml Thu Aug 16 19:48:59 2018 +0100 +++ b/doc/docbook/GuideSidebarsInfo.xml Fri Aug 17 18:12:04 2018 +0100 @@ -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 -r f1c975235feb -r dbe1524ba009 src/bar_keywords.c --- a/src/bar_keywords.c Thu Aug 16 19:48:59 2018 +0100 +++ b/src/bar_keywords.c Fri Aug 17 18:12:04 2018 +0100 @@ -62,6 +62,19 @@ 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 @@ 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 @@ 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 -r f1c975235feb -r dbe1524ba009 src/ui_misc.c --- a/src/ui_misc.c Thu Aug 16 19:48:59 2018 +0100 +++ b/src/ui_misc.c Fri Aug 17 18:12:04 2018 +0100 @@ -1732,4 +1732,34 @@ } +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 -r f1c975235feb -r dbe1524ba009 src/ui_misc.h --- a/src/ui_misc.h Thu Aug 16 19:48:59 2018 +0100 +++ b/src/ui_misc.h Fri Aug 17 18:12:04 2018 +0100 @@ -199,6 +199,7 @@ 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 -r f1c975235feb -r dbe1524ba009 web/help/GuideSidebarsInfo.html --- a/web/help/GuideSidebarsInfo.html Thu Aug 16 19:48:59 2018 +0100 +++ b/web/help/GuideSidebarsInfo.html Fri Aug 17 18:12:04 2018 +0100 @@ -572,7 +572,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 Marking Images