changeset 2662:08d2547d72ea

Fix #137: "Copy path" problem (or may be feature) https://github.com/BestImageViewer/geeqie/issues/137 Additional option on Preferences/Behavior to select either PRIMARY or CLIPBOARD for the copy path menu item
author Colin Clark <colin.clark@cclark.uk>
date Wed, 08 Nov 2017 17:06:50 +0000
parents b50d57543696
children 3e6d26094fb4
files doc/docbook/GuideOptionsBehavior.xml src/advanced_exif.c src/options.c src/options.h src/preferences.c src/rcfile.c src/typedefs.h src/utilops.c
diffstat 8 files changed, 101 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/doc/docbook/GuideOptionsBehavior.xml	Sun Nov 05 19:53:36 2017 +0100
+++ b/doc/docbook/GuideOptionsBehavior.xml	Wed Nov 08 17:06:50 2017 +0000
@@ -140,6 +140,34 @@
           <para>This is the width and height of the icon generated from image and displayed when doing drag and drop actions. High resolution screens may require to increase this number.</para>
         </listitem>
       </varlistentry>
+      <varlistentry>
+        <term>
+          <guilabel>Copy path clipboard selection</guilabel>
+        </term>
+        <listitem>
+          <para>
+            This option determines which clipboard selection is used for the "Copy path" menu item. The exact method of the paste operation will depend on the operating system, but in general will be:
+            <variablelist>
+              <varlistentry>
+                <term>
+                  <guilabel>PRIMARY</guilabel>
+                </term>
+                <listitem>
+                  <para>Paste using mouse middle-click, or shift-insert.</para>
+                </listitem>
+              </varlistentry>
+              <varlistentry>
+                <term>
+                  <guilabel>CLIPBOARD</guilabel>
+                </term>
+                <listitem>
+                  <para>Paste using mouse right-click and select paste, or control-v.</para>
+                </listitem>
+              </varlistentry>
+            </variablelist>
+          </para>
+        </listitem>
+      </varlistentry>
     </variablelist>
   </section>
   <section id="Navigation">
--- a/src/advanced_exif.c	Sun Nov 05 19:53:36 2017 +0100
+++ b/src/advanced_exif.c	Wed Nov 08 17:06:50 2017 +0000
@@ -335,7 +335,7 @@
 		col_num = g_list_index(cols, (gpointer)column);
 		gtk_tree_model_get(store, &iter, display_order[col_num], &value, -1);
 
-		clipboard = gtk_clipboard_get(GDK_SELECTION_CLIPBOARD);
+		clipboard = gtk_clipboard_get(GDK_SELECTION_PRIMARY);
 		gtk_clipboard_set_text(clipboard, value, -1);
 
 		g_list_free(cols);
--- a/src/options.c	Sun Nov 05 19:53:36 2017 +0100
+++ b/src/options.c	Wed Nov 08 17:06:50 2017 +0000
@@ -164,6 +164,7 @@
 	options->tree_descend_subdirs = FALSE;
 	options->view_dir_list_single_click_enter = TRUE;
 	options->update_on_time_change = TRUE;
+	options->clipboard_selection = PRIMARY;
 
 	options->stereo.fixed_w = 1920;
 	options->stereo.fixed_h = 1080;
--- a/src/options.h	Sun Nov 05 19:53:36 2017 +0100
+++ b/src/options.h	Wed Nov 08 17:06:50 2017 +0000
@@ -51,6 +51,7 @@
 
 	gint open_recent_list_maxsize;
 	gint dnd_icon_size;
+	gint clipboard_selection;
 
 	gboolean save_window_positions;
 	gboolean use_saved_window_positions_for_new_windows;
--- a/src/preferences.c	Sun Nov 05 19:53:36 2017 +0100
+++ b/src/preferences.c	Wed Nov 08 17:06:50 2017 +0000
@@ -360,6 +360,7 @@
 
 	options->open_recent_list_maxsize = c_options->open_recent_list_maxsize;
 	options->dnd_icon_size = c_options->dnd_icon_size;
+	options->clipboard_selection = c_options->clipboard_selection;
 
 	options->metadata.save_in_image_file = c_options->metadata.save_in_image_file;
 	options->metadata.save_legacy_IPTC = c_options->metadata.save_legacy_IPTC;
@@ -524,6 +525,22 @@
 		}
 }
 
+static void clipboard_selection_menu_cb(GtkWidget *combo, gpointer data)
+{
+	gint *option = data;
+
+	switch (gtk_combo_box_get_active(GTK_COMBO_BOX(combo)))
+		{
+		case 0:
+		default:
+			*option = PRIMARY;
+			break;
+		case 1:
+			*option = CLIPBOARD;
+			break;
+		}
+}
+
 static void add_quality_menu(GtkWidget *table, gint column, gint row, const gchar *text,
 			     guint option, guint *option_c)
 {
@@ -555,6 +572,33 @@
 	gtk_widget_show(combo);
 }
 
+static void add_clipboard_selection_menu(GtkWidget *table, gint column, gint row, const gchar *text,
+			     guint option, guint *option_c)
+{
+	GtkWidget *combo;
+	gint current = 0;
+
+	*option_c = option;
+
+	pref_table_label(table, column, row, text, 0.0);
+
+	combo = gtk_combo_box_text_new();
+
+	gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(combo), _("PRIMARY"));
+	if (option == PRIMARY) current = 0;
+	gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(combo), _("CLIPBOARD"));
+	if (option == CLIPBOARD) current = 1;
+
+	gtk_combo_box_set_active(GTK_COMBO_BOX(combo), current);
+
+	g_signal_connect(G_OBJECT(combo), "changed",
+			 G_CALLBACK(clipboard_selection_menu_cb), option_c);
+
+	gtk_table_attach(GTK_TABLE(table), combo, column + 1, column + 2, row, row + 1,
+			 GTK_EXPAND | GTK_FILL, 0, 0, 0);
+	gtk_widget_show(combo);
+}
+
 static void thumb_size_menu_cb(GtkWidget *combo, gpointer data)
 {
 	gint n;
@@ -2324,6 +2368,9 @@
 	pref_spin_new_int(group, _("Drag'n drop icon size"), NULL,
 			  16, 256, 16, options->dnd_icon_size, &c_options->dnd_icon_size);
 
+	table = pref_table_new(group, 2, 1, FALSE, FALSE);
+	add_clipboard_selection_menu(table, 0, 0, _("Copy path clipboard selection:"), options->clipboard_selection, &c_options->clipboard_selection);
+
 	group = pref_group_new(vbox, FALSE, _("Navigation"), GTK_ORIENTATION_VERTICAL);
 
 	pref_checkbox_new_int(group, _("Progressive keyboard scrolling"),
--- a/src/rcfile.c	Sun Nov 05 19:53:36 2017 +0100
+++ b/src/rcfile.c	Wed Nov 08 17:06:50 2017 +0000
@@ -332,6 +332,7 @@
 	WRITE_NL(); WRITE_INT(*options, open_recent_list_maxsize);
 	WRITE_NL(); WRITE_INT(*options, dnd_icon_size);
 	WRITE_NL(); WRITE_BOOL(*options, place_dialogs_under_mouse);
+	WRITE_NL(); WRITE_INT(*options, clipboard_selection);
 
 	WRITE_NL(); WRITE_BOOL(*options, save_window_positions);
 	WRITE_NL(); WRITE_BOOL(*options, use_saved_window_positions_for_new_windows);
@@ -631,6 +632,7 @@
 		if (READ_INT(*options, open_recent_list_maxsize)) continue;
 		if (READ_INT(*options, dnd_icon_size)) continue;
 		if (READ_BOOL(*options, place_dialogs_under_mouse)) continue;
+		if (READ_INT(*options, clipboard_selection)) continue;
 
 		if (READ_BOOL(*options, save_window_positions)) continue;
 		if (READ_BOOL(*options, use_saved_window_positions_for_new_windows)) continue;
--- a/src/typedefs.h	Sun Nov 05 19:53:36 2017 +0100
+++ b/src/typedefs.h	Wed Nov 08 17:06:50 2017 +0000
@@ -29,6 +29,11 @@
 } ZoomMode;
 
 typedef enum {
+	PRIMARY	= 0,
+	CLIPBOARD = 1,
+} ClipboardSelection;
+
+typedef enum {
 	MOUSE_BUTTON_LEFT	= 1,
 	MOUSE_BUTTON_MIDDLE	= 2,
 	MOUSE_BUTTON_RIGHT	= 3,
--- a/src/utilops.c	Sun Nov 05 19:53:36 2017 +0100
+++ b/src/utilops.c	Wed Nov 08 17:06:50 2017 +0000
@@ -3038,7 +3038,14 @@
 
 	if (!fd || !*fd->path) return;
 
-	clipboard = gtk_clipboard_get(GDK_SELECTION_PRIMARY);
+	if (options->clipboard_selection == PRIMARY)
+		{
+		clipboard = gtk_clipboard_get(GDK_SELECTION_PRIMARY);
+		}
+	else
+		{
+		clipboard = gtk_clipboard_get(GDK_SELECTION_CLIPBOARD);
+		}
 	gtk_clipboard_set_text(clipboard, g_shell_quote(fd->path), -1);
 }
 
@@ -3048,7 +3055,14 @@
 	GList *work;
 	GString *new;
 
-	clipboard = gtk_clipboard_get(GDK_SELECTION_PRIMARY);
+	if (options->clipboard_selection == PRIMARY)
+		{
+		clipboard = gtk_clipboard_get(GDK_SELECTION_PRIMARY);
+		}
+	else
+		{
+		clipboard = gtk_clipboard_get(GDK_SELECTION_CLIPBOARD);
+		}
 
 	new = g_string_new("");
 	work = list;