GNOME Bugzilla – Bug 777587
Gutter pixbuf renderer handles LAST alignment incorrectly
Last modified: 2017-01-22 12:02:09 UTC
Created attachment 343959 [details] [review] Patch When using GTK_SOURCE_GUTTER_RENDERER_ALIGNMENT_MODE_LAST, the pixbuf should be aligned within the last visual line of the wrapped logical line. However, it's actually aligned within the first line, because the code uses the y-coordinate from the cell instead of from the textview line. The attached patch fixes this for me. For what it's worth, I'm only noticing this because I'm implementing a gutter renderer that supports matching this alignment, not because I'm using LAST, so this clearly isn't that vital... Filed against 3.22, because that's where I'm testing it. I've confirmed that this code is the same in master, but not tested the patch there.
Thanks, I've read the code carefully, and your patch totally makes sense. I've also tested by modifying gtksourcegutterrenderermarks.c, and I was able to reproduce the bug and I confirm that the bug is fixed with the patch. Pushed as commit b22640343b0d3f260dab45d88e765ba66a3531d3 on master. And cherry-picked on the gnome-3-24 and gnome-3-22 branches. Thanks again!
Ah, I forgot to test one thing: gtk_text_view_get_iter_location() returns the location in buffer coordinates. It works for pixbufs added at the beginning of the buffer, where buffer coords == window coords. But if the buffer contains enough text to have scrollbars, when we are not at the top the pixbuf is not drawn. Normally it's just a matter of calling gtk_text_view_buffer_to_window_coords(). Can you provide a second patch for this?
Argh! Yeah I'll have a poke at that, but probably next weekend. I should have thought to test that, sorry.
I didn't want to revert the commit, and the fix was simple, so I've fixed it: commit 686bf1557da39af005a1784ae2762b8fd0d71755.