GutterRenderer#

class GutterRenderer(**properties: Any)#

Superclasses: Widget, InitiallyUnowned, Object

Subclasses: GutterRendererPixbuf, GutterRendererText

Implemented Interfaces: Accessible, Buildable, ConstraintTarget

Gutter cell renderer.

A GtkSourceGutterRenderer represents a column in a Gutter. The column contains one cell for each visible line of the TextBuffer. Due to text wrapping, a cell can thus span multiple lines of the TextView. In this case, GutterRendererAlignmentMode controls the alignment of the cell.

The gutter renderer is a Widget and is measured using the normal widget measurement facilities. The width of the gutter will be determined by the measurements of the gutter renderers.

The width of a gutter renderer generally takes into account the entire text buffer. For instance, to display the line numbers, if the buffer contains 100 lines, the gutter renderer will always set its width such as three digits can be printed, even if only the first 20 lines are shown. Another strategy is to take into account only the visible lines. In this case, only two digits are necessary to display the line numbers of the first 20 lines. To take another example, the gutter renderer for Marks doesn’t need to take into account the text buffer to announce its width. It only depends on the icons size displayed in the gutter column.

When the available size to render a cell is greater than the required size to render the cell contents, the cell contents can be aligned horizontally and vertically with set_alignment_mode.

The cells rendering occurs using snapshot. Implementations should use gtk_source_gutter_renderer_get_lines() to retrieve information about the lines to be rendered. To help with aligning content which takes into account the padding and alignment of a cell, implementations may call align_cell for a given line number with the width and height measurement of the content they width to render.

Methods#

class GutterRenderer
activate(iter: TextIter, area: Rectangle, button: int, state: ModifierType, n_presses: int) None#

Emits the activate signal of the renderer. This is called from Gutter and should never have to be called manually.

Parameters:
  • iter – a TextIter at the start of the line where the renderer is activated

  • area – a Rectangle of the cell area where the renderer is activated

  • button – the button that was pressed

  • state – a ModifierType

  • n_presses – the number of button presses

align_cell(line: int, width: float, height: float) Tuple[float, float]#

Locates where to render content that is width x height based on the renderers alignment and padding.

The location will be placed into x and y and is relative to the renderer’s coordinates.

It is encouraged that renderers use this function when snappshotting to ensure consistent placement of their contents.

Parameters:
  • line – the line number for content

  • width – the width of the content to draw

  • height – the height of the content to draw

do_activate(self, iter: TextIter, area: Rectangle, button: int, state: ModifierType, n_presses: int) None#
Parameters:
  • iter

  • area

  • button

  • state

  • n_presses

do_begin(self, lines: GutterLines) None#
Parameters:

lines

do_change_buffer(self, old_buffer: Buffer | None = None) None#
Parameters:

old_buffer

do_change_view(self, old_view: View | None = None) None#
Parameters:

old_view

do_end(self) None#
do_query_activatable(self, iter: TextIter, area: Rectangle) bool#
Parameters:
  • iter

  • area

do_query_data(self, lines: GutterLines, line: int) None#
Parameters:
  • lines

  • line

do_snapshot_line(self, snapshot: Snapshot, lines: GutterLines, line: int) None#
Parameters:
  • snapshot

  • lines

  • line

get_alignment_mode() GutterRendererAlignmentMode#

Get the alignment mode.

The alignment mode describes the manner in which the renderer is aligned (see xalign and yalign).

get_buffer() Buffer | None#

Gets the Buffer for which the gutter renderer is drawing.

get_view() View#

Get the view associated to the gutter renderer

get_xalign() float#

Gets the xalign property.

This may be used to adjust where within the cell rectangle the renderer will draw.

get_xpad() int#

Gets the xpad property.

This may be used to adjust the cell rectangle that the renderer will use to draw.

get_yalign() float#

Gets the yalign property.

This may be used to adjust where within the cell rectangle the renderer will draw.

get_ypad() int#

Gets the ypad property.

This may be used to adjust the cell rectangle that the renderer will use to draw.

query_activatable(iter: TextIter, area: Rectangle) bool#

Get whether the renderer is activatable at the location provided. This is called from Gutter to determine whether a renderer is activatable using the mouse pointer.

Parameters:
  • iter – a TextIter at the start of the line to be activated

  • area – a Rectangle of the cell area to be activated

set_alignment_mode(mode: GutterRendererAlignmentMode) None#

Set the alignment mode. The alignment mode describes the manner in which the renderer is aligned (see xalign and yalign).

Parameters:

mode – a GutterRendererAlignmentMode

set_xalign(xalign: float) None#

Adjusts the xalign property.

This may be used to adjust where within the cell rectangle the renderer will draw.

Parameters:

xalign – the Y padding for the drawing cell

set_xpad(xpad: int) None#

Adjusts the xpad property.

This may be used to adjust the cell rectangle that the renderer will use to draw.

Parameters:

xpad – the Y padding for the drawing cell

set_yalign(yalign: float) None#

Adjusts the yalign property.

This may be used to adjust where within the cell rectangle the renderer will draw.

Parameters:

yalign – the Y padding for the drawing cell

set_ypad(ypad: int) None#

Adjusts the ypad property.

This may be used to adjust the cell rectangle that the renderer will use to draw.

Parameters:

ypad – the Y padding for the drawing cell

Properties#

class GutterRenderer
props.alignment_mode: GutterRendererAlignmentMode#

The type of the None singleton.

props.lines: GutterLines#

The type of the None singleton.

props.view: TextView#

The type of the None singleton.

props.xalign: float#

The type of the None singleton.

props.xpad: int#

The type of the None singleton.

props.yalign: float#

The type of the None singleton.

props.ypad: int#

The type of the None singleton.

Signals#

class GutterRenderer.signals
activate(iter: TextIter, area: Rectangle, button: int, state: ModifierType, n_presses: int) None#

The signal is emitted when the renderer is activated.

Parameters:
  • iter – a TextIter

  • area – a Rectangle

  • button – the button that was pressed

  • state – a ModifierType of state

  • n_presses – the number of button presses

query_activatable(iter: TextIter, area: Rectangle) bool#

The type of the None singleton.

Parameters:
query_data(object: Object, p0: int) None#

The type of the None singleton.

Parameters:
  • object

  • p0

Virtual Methods#

class GutterRenderer
do_activate(iter: TextIter, area: Rectangle, button: int, state: ModifierType, n_presses: int) None#

Emits the activate signal of the renderer. This is called from Gutter and should never have to be called manually.

Parameters:
  • iter – a TextIter at the start of the line where the renderer is activated

  • area – a Rectangle of the cell area where the renderer is activated

  • button – the button that was pressed

  • state – a ModifierType

  • n_presses – the number of button presses

do_begin(lines: GutterLines) None#

The type of the None singleton.

Parameters:

lines

do_change_buffer(old_buffer: Buffer | None = None) None#

The type of the None singleton.

Parameters:

old_buffer – the old TextBuffer.

do_change_view(old_view: View | None = None) None#

The type of the None singleton.

Parameters:

old_view – the old TextView.

do_end() None#

The type of the None singleton.

do_query_activatable(iter: TextIter, area: Rectangle) bool#

Get whether the renderer is activatable at the location provided. This is called from Gutter to determine whether a renderer is activatable using the mouse pointer.

Parameters:
  • iter – a TextIter at the start of the line to be activated

  • area – a Rectangle of the cell area to be activated

do_query_data(lines: GutterLines, line: int) None#

The type of the None singleton.

Parameters:
  • lines

  • line

do_snapshot_line(snapshot: Snapshot, lines: GutterLines, line: int) None#

The type of the None singleton.

Parameters:
  • snapshot

  • lines

  • line

Fields#

class GutterRenderer
parent_instance#