Feature request: copy the current pixel coordinate to the clipboard
ISSUE TYPE
- Feature Request
Hi. It'd make me much happier if I could configure geeqie to place the current pixel coordinate under the mouse into the clipboard with a click. If that's hard, I can live with a keyboard binding. Can somebody suggest a good way to do this? I can write some code, if that's needed. The simplest thing to do, probably, is to made a new plugin to do the write-to-clipboard bit (probably xsel or xclip), bind a key to that plugin, and add a new replaceable token for the coordinates to pass to the plugin. Can somebody suggest a location in the code where this would fit?
Thanks!
I have something good-enough-for-now working with the attached patch. It serves my purposes today, but it's not suitable for acceptance into the codebase. If nothing else, something like gtk_clipboard_set_with_data() should be used instead, to only send data to the X server when the paster requests it. If that were done, then maybe this could be ok, if it was enabled with some option.
diff --git a/src/layout_image.c b/src/layout_image.c
index c18bf230..f74eb39e 100644
--- a/src/layout_image.c
+++ b/src/layout_image.c
@@ -1964,6 +1964,10 @@ void layout_status_update_pixel_cb(PixbufRenderer *pr, gpointer data)
num_length(height - 1), y_pixel,
r_mouse, g_mouse, b_mouse);
+ gchar* coords = g_strdup_printf(_("%d %d"), x_pixel, y_pixel);
+ GtkClipboard* clipboard = gtk_clipboard_get(GDK_SELECTION_PRIMARY);
+ gtk_clipboard_set_text(clipboard, coords, -1);
+ g_free(coords);
}
else
{
There is a remote command which gives pixel coordinates:
geeqie --remote --pixel-info
It is fairly trivial to write a script to extract the coordinates and put them into whichever clipboard. Just call the script from a new plugin.
I will think about the mouse-click over the next days (but maybe not New Years Day) ....
If you go to Edit/Preference/Behavior you will see that if you have a multi-button mouse you can program buttons 8 and 9. Mouse left-click is also programmable - Tomasz Goliński programmed it with the intent of using it to run a video player, so it only functions with files of class Video but can run any plugin.
However the logic could be changed, and given a different description, by removing the class filter from the code.
The user could then, in the called script, first use
geeqie -remote --get-file-info
to get the file class, and then switch jump on the class.
That makes the use of mouse left-click more flexible, but requires the user to do a bit of grepping to get the file class.