1

What should be the second argument of the function gtk_source_mark_attributes_render_icon() It is clearly of type GtkWidget* and according to the reference page this is

"widget of which style settings may be used"

I find it for a bit unclear.

When I call gtk_source_mark_attributes_render_icon(att, some_random_widget, 40); Nothing seems to happen and the pixbuf rendered in the gutter is as small as 10x10 or something. I even set the gutter size to 40, because I initially thought, the image is so small, because the width of the gutter is that small.

How can I render bigger pixbufs in the gutter?

Edenia
  • 2,312
  • 1
  • 16
  • 33

2 Answers2

1

I agree, the documentation is quite unclear on this point. I think the widget should probably be the GtkSourceView corresponding to the buffer.

The size is probably affected by the preceding call to gtk_source_view_mark_attributes_set_icon_name() or whatever you are using to tell it which pixbuf to render.

ptomato
  • 56,175
  • 13
  • 112
  • 165
  • Made the same guess and tried with the sourceview of the buffer the first time. Also I use `gtk_source_mark_attributes_set_pixbuf`. The pixbuf itself is bigger, the renderer size is big enough to hold it, and `gtk_source_mark_attributes_render_icon` is called. But no effect on the size of the rendered pixbuf. – Edenia Dec 24 '18 at 19:56
  • Probably the size setting works only on icons in which case I am out of ideas how to size up the pixbuf in the gutter. – Edenia Dec 24 '18 at 20:15
  • I've been having the same problem. – ptomato Dec 24 '18 at 22:19
  • See gtksourcepixbufhelper.c the function `from_pixbuf` it indeed scales the pixbuf "smaller". It is called by `gtk_source_pixbuf_helper_render()` and then the draw signal handler in gtksourcegutterrendererpixbuf.c, which uses `gdk_cairo_surface_create_from_pixbuf()` with the scale parameter. – Edenia Dec 24 '18 at 22:32
  • If I am to use custom gutter and renderer probably it will behave the same way. – Edenia Dec 24 '18 at 22:34
0

There are two things that play a role into how the pixbuf is rendered. First is the size of the gutter (which is always in width) and second is the height of the line.

According to gtksourcepixbufhelper.c the pixbuf is scaled with one unit for both dimensions. As seen in the function gutter_renderer_pixbuf_draw, here this unit essentially is cell_area->width. This is determined by the size of the gutter.

But the gutter line marks themselves are not coded to be expandable in height, nor they can expand the line in height, so when the gutter is rendered they are clipped.


Therefore in order to allow pixbufs to span further one must increase the height of the line. This can happen with the font-size property of the GtkTextView. But the bigger font is usually unwanted too, so to hack this behavior there is one thing that came across my mind.

A secondary overlay text view can be used to display text (should not have gutter) while the bottom text view displays bigger pixbufs. The overlay text view may need left padding with the size of the gutter. And to synchronize pixbufs with lines one will have to use the pixels-above-lines and pixels-below-lines (tag or textview props) to pad the lines. The height of the line of the bottom text view minus the height of the overlay text view / 2 for both props or something like that.


The less hackish solution is to subclass on the gutter (and perhaps the cell renderer) and override the rendering function to implement your own rules.

Edenia
  • 2,312
  • 1
  • 16
  • 33