Second argument of gtk_source_mark_attributes_render_icon

92 Views Asked by At

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?

2

There are 2 best solutions below

5
ptomato On

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.

0
Edenia On

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.