Fix #629: Keywords are not adding properly to selected files
authorColin Clark <colin.clark@cclark.uk>
Fri, 17 Aug 2018 17:12:04 +0000 (18:12 +0100)
committerColin Clark <colin.clark@cclark.uk>
Fri, 17 Aug 2018 17:12:04 +0000 (18:12 +0100)
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
src/bar_keywords.c
src/ui_misc.c
src/ui_misc.h
web/help/GuideSidebarsInfo.html

index 5191657..4a19e5b 100644 (file)
       <para>This action cannot be undone.</para>\r
     </warning>\r
     <para>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.</para>\r
-    <para>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.</para>\r
+    <para>\r
+      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.\r
+      <warning>\r
+        <para>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.</para>\r
+      </warning>\r
+    </para>\r
     <para>\r
       Right-click on the right-hand box allows a connection to be made between a keyword and a mark. The\r
       <link linkend="GuideImageMarks" endterm="titleGuideImageMarks" />\r
index b62b988..3509bc5 100644 (file)
@@ -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);
 }
 
 
index a5e905d..312d3aa 100644 (file)
@@ -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: */
index 1389ce4..7f65770 100644 (file)
@@ -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: */
index 02c64b1..e31b30e 100644 (file)
@@ -572,7 +572,12 @@ dd.answer div.label { float: left; }
       <p class="para block block-first">This action cannot be undone.</p>
     </div></div>
 <p class="para block">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.</p>
-<p class="para block">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.</p>
+<p class="para block">
+      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.
+      <div class="admonition block warning block-first block-indent"><div class="warning-inner">
+        <p class="para block block-first">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.</p>
+      </div></div>
+    </p>
 <p class="para block">
       Right-click on the right-hand box allows a connection to be made between a keyword and a mark. The
       <a class="link" href="GuideImageMarks.html" title="Marking Images">Marking Images</a>