GtkSource.GutterRenderer

g GObject.GInterface GObject.GInterface Gtk.Accessible Gtk.Accessible GObject.GInterface->Gtk.Accessible Gtk.Buildable Gtk.Buildable GObject.GInterface->Gtk.Buildable Gtk.ConstraintTarget Gtk.ConstraintTarget GObject.GInterface->Gtk.ConstraintTarget GObject.InitiallyUnowned GObject.InitiallyUnowned Gtk.Widget Gtk.Widget GObject.InitiallyUnowned->Gtk.Widget GObject.Object GObject.Object GObject.Object->GObject.InitiallyUnowned Gtk.Accessible->Gtk.Widget Gtk.Buildable->Gtk.Widget Gtk.ConstraintTarget->Gtk.Widget GtkSource.GutterRenderer GtkSource.GutterRenderer Gtk.Widget->GtkSource.GutterRenderer

Subclasses:

GtkSource.GutterRendererPixbuf, GtkSource.GutterRendererText

Methods

Inherited:

Gtk.Widget (181), GObject.Object (37), Gtk.Accessible (15), Gtk.Buildable (1)

Structs:

Gtk.WidgetClass (18), GObject.ObjectClass (5)

activate (iter, area, button, state, n_presses)

align_cell (line, width, height)

get_alignment_mode ()

get_buffer ()

get_view ()

get_xalign ()

get_xpad ()

get_yalign ()

get_ypad ()

query_activatable (iter, area)

set_alignment_mode (mode)

set_xalign (xalign)

set_xpad (xpad)

set_yalign (yalign)

set_ypad (ypad)

Virtual Methods

Inherited:

Gtk.Widget (25), GObject.Object (7), Gtk.Accessible (6), Gtk.Buildable (9)

do_activate (iter, area, button, state, n_presses)

do_begin (lines)

do_change_buffer (old_buffer)

do_change_view (old_view)

do_end ()

do_query_activatable (iter, area)

do_query_data (lines, line)

do_snapshot_line (snapshot, lines, line)

Properties

Inherited:

Gtk.Widget (34), Gtk.Accessible (1)

Name

Type

Flags

Short Description

alignment-mode

GtkSource.GutterRendererAlignmentMode

r/w

The alignment mode

lines

GtkSource.GutterLines

r

Information about the lines to render

view

Gtk.TextView

r

The view

xalign

float

r/w

The x-alignment

xpad

int

r/w

The x-padding

yalign

float

r/w

The y-alignment

ypad

int

r/w

The y-padding

Signals

Inherited:

Gtk.Widget (13), GObject.Object (1)

Name

Short Description

activate

The signal is emitted when the renderer is activated.

query-activatable

The signal is emitted when the renderer can possibly be activated.

query-data

Fields

Inherited:

Gtk.Widget (13), GObject.Object (1)

Name

Type

Access

Description

parent_instance

Gtk.Widget

r

Class Details

class GtkSource.GutterRenderer(**kwargs)
Bases:

Gtk.Widget

Abstract:

Yes

Structure:

GtkSource.GutterRendererClass

Gutter cell renderer.

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

The gutter renderer is a [class`Gtk`.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 [class`Mark`]s 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 [method`GutterRenderer`.set_alignment_mode].

The cells rendering occurs using [vfunc`Gtk`.Widget.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 [method`GutterRenderer`.align_cell] for a given line number with the width and height measurement of the content they width to render.

activate(iter, area, button, state, n_presses)
Parameters:

Emits the [signal`GutterRenderer`:py:func:::activate<GtkSource.GutterRenderer.signals.activate>] signal of the renderer. This is called from [class`Gutter`] and should never have to be called manually.

align_cell(line, width, height)
Parameters:
  • line (int) – the line number for content

  • width (float) – the width of the content to draw

  • height (float) – the height of the content to draw

Returns:

x:

the X position to render the content

y:

the Y position to render the content

Return type:

(x: float, y: 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.

get_alignment_mode()
Returns:

a GtkSource.GutterRendererAlignmentMode

Return type:

GtkSource.GutterRendererAlignmentMode

Get the alignment mode.

The alignment mode describes the manner in which the renderer is aligned (see [property`GutterRenderer`:py:data::xalign<GtkSource.GutterRenderer.props.xalign>] and [property`GutterRenderer`:py:data::yalign<GtkSource.GutterRenderer.props.yalign>]).

get_buffer()
Returns:

a Gtk.TextBuffer or None

Return type:

GtkSource.Buffer or None

Gets the [class`Buffer`] for which the gutter renderer is drawing.

get_view()
Returns:

a GtkSource.View

Return type:

GtkSource.View

Get the view associated to the gutter renderer

get_xalign()
Return type:

float

Gets the xalign property.

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

get_xpad()
Return type:

int

Gets the xpad property.

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

get_yalign()
Return type:

float

Gets the yalign property.

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

get_ypad()
Return type:

int

Gets the ypad property.

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

query_activatable(iter, area)
Parameters:
Returns:

True if the renderer can be activated, False otherwise

Return type:

bool

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

set_alignment_mode(mode)
Parameters:

mode (GtkSource.GutterRendererAlignmentMode) – a GtkSource.GutterRendererAlignmentMode

Set the alignment mode. The alignment mode describes the manner in which the renderer is aligned (see [property`GutterRenderer`:py:data::xalign<GtkSource.GutterRenderer.props.xalign>] and [property`GutterRenderer`:py:data::yalign<GtkSource.GutterRenderer.props.yalign>]).

set_xalign(xalign)
Parameters:

xalign (float) – the Y padding for the drawing cell

Adjusts the xalign property.

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

set_xpad(xpad)
Parameters:

xpad (int) – the Y padding for the drawing cell

Adjusts the xpad property.

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

set_yalign(yalign)
Parameters:

yalign (float) – the Y padding for the drawing cell

Adjusts the yalign property.

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

set_ypad(ypad)
Parameters:

ypad (int) – the Y padding for the drawing cell

Adjusts the ypad property.

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

do_activate(iter, area, button, state, n_presses) virtual
Parameters:

Emits the [signal`GutterRenderer`:py:func:::activate<GtkSource.GutterRenderer.signals.activate>] signal of the renderer. This is called from [class`Gutter`] and should never have to be called manually.

do_begin(lines) virtual
Parameters:

lines (GtkSource.GutterLines) –

do_change_buffer(old_buffer) virtual
Parameters:

old_buffer (GtkSource.Buffer or None) – the old Gtk.TextBuffer.

This is called when the text buffer changes for renderer.

do_change_view(old_view) virtual
Parameters:

old_view (GtkSource.View or None) – the old Gtk.TextView.

This is called when the text view changes for renderer.

do_end() virtual
do_query_activatable(iter, area) virtual
Parameters:
Returns:

True if the renderer can be activated, False otherwise

Return type:

bool

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

do_query_data(lines, line) virtual
Parameters:
do_snapshot_line(snapshot, lines, line) virtual
Parameters:

Signal Details

GtkSource.GutterRenderer.signals.activate(gutter_renderer, iter, area, button, state, n_presses)
Signal Name:

activate

Flags:

RUN_LAST

Parameters:

The signal is emitted when the renderer is activated.

GtkSource.GutterRenderer.signals.query_activatable(gutter_renderer, iter, area)
Signal Name:

query-activatable

Flags:

RUN_LAST

Parameters:
Return type:

bool

The signal is emitted when the renderer can possibly be activated.

GtkSource.GutterRenderer.signals.query_data(gutter_renderer, object, p0)
Signal Name:

query-data

Flags:

RUN_LAST

Parameters:

Property Details

GtkSource.GutterRenderer.props.alignment_mode
Name:

alignment-mode

Type:

GtkSource.GutterRendererAlignmentMode

Default Value:

GtkSource.GutterRendererAlignmentMode.CELL

Flags:

READABLE, WRITABLE

The alignment mode of the renderer.

This can be used to indicate that in the case a cell spans multiple lines (due to text wrapping) the alignment should work on either the full cell, the first line or the last line.

GtkSource.GutterRenderer.props.lines
Name:

lines

Type:

GtkSource.GutterLines

Default Value:

None

Flags:

READABLE

Contains information about the lines to be rendered.

It should be used by GtkSource.GutterRenderer implementations from [vfunc`Gtk`.Widget.snapshot].

GtkSource.GutterRenderer.props.view
Name:

view

Type:

Gtk.TextView

Default Value:

None

Flags:

READABLE

The view on which the renderer is placed.

GtkSource.GutterRenderer.props.xalign
Name:

xalign

Type:

float

Default Value:

0.0

Flags:

READABLE, WRITABLE

The horizontal alignment of the renderer.

Set to 0 for a left alignment. 1 for a right alignment. And 0.5 for centering the cells. A value lower than 0 doesn’t modify the alignment.

GtkSource.GutterRenderer.props.xpad
Name:

xpad

Type:

int

Default Value:

0

Flags:

READABLE, WRITABLE

The left and right padding of the renderer.

GtkSource.GutterRenderer.props.yalign
Name:

yalign

Type:

float

Default Value:

0.0

Flags:

READABLE, WRITABLE

The vertical alignment of the renderer.

Set to 0 for a top alignment. 1 for a bottom alignment. And 0.5 for centering the cells. A value lower than 0 doesn’t modify the alignment.

GtkSource.GutterRenderer.props.ypad
Name:

ypad

Type:

int

Default Value:

0

Flags:

READABLE, WRITABLE

The top and bottom padding of the renderer.