GtkSourceGutterRenderer

GtkSourceGutterRenderer — Gutter cell renderer

Functions

Properties

GtkSourceGutterRendererAlignmentMode alignment-mode Read / Write
GtkSourceGutterLines * lines Read
GtkTextView * view Read
float xalign Read / Write
int xpad Read / Write
float yalign Read / Write
int ypad Read / Write

Signals

void activate Run Last
gboolean query-activatable Run Last
void query-data Run Last

Types and Values

Object Hierarchy

    GEnum
    ╰── GtkSourceGutterRendererAlignmentMode
    GObject
    ╰── GInitiallyUnowned
        ╰── GtkWidget
            ╰── GtkSourceGutterRenderer
                ├── GtkSourceGutterRendererPixbuf
                ╰── GtkSourceGutterRendererText

Implemented Interfaces

GtkSourceGutterRenderer implements GtkAccessible, GtkBuildable and GtkConstraintTarget.

Includes

#include <gtksourceview/gtksource.h>

Description

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

The gutter renderer is a GtkWidget 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 GtkSourceMarks 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 gtk_source_gutter_renderer_set_alignment().

The cells rendering occurs using 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 gtk_source_gutter_renderer_align_cell() for a given line number with the width and height measurement of the content they width to render.

Functions

gtk_source_gutter_renderer_get_buffer ()

GtkSourceBuffer *
gtk_source_gutter_renderer_get_buffer (GtkSourceGutterRenderer *renderer);

Gets the GtkSourceBuffer for which the gutter renderer is drawing.

Parameters

renderer

a GtkSourceGutterRenderer

 

Returns

a GtkTextBuffer or NULL.

[transfer none][nullable]

Since: 5.0


gtk_source_gutter_renderer_get_view ()

GtkSourceView *
gtk_source_gutter_renderer_get_view (GtkSourceGutterRenderer *renderer);

Get the view associated to the gutter renderer

Parameters

renderer

a GtkSourceGutterRenderer

 

Returns

a GtkSourceView.

[transfer none]


gtk_source_gutter_renderer_get_alignment_mode ()

GtkSourceGutterRendererAlignmentMode
gtk_source_gutter_renderer_get_alignment_mode
                               (GtkSourceGutterRenderer *renderer);

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

Parameters

renderer

a GtkSourceGutterRenderer

 

gtk_source_gutter_renderer_set_alignment_mode ()

void
gtk_source_gutter_renderer_set_alignment_mode
                               (GtkSourceGutterRenderer *renderer,
                                GtkSourceGutterRendererAlignmentMode mode);

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


gtk_source_gutter_renderer_get_xalign ()

gfloat
gtk_source_gutter_renderer_get_xalign (GtkSourceGutterRenderer *renderer);

Gets the "xalign" property of the GtkSourceGutterRenderer. This may be used to adjust where within the cell rectangle the renderer will draw.

Parameters

renderer

a GtkSourceGutterRenderer

 

Since: 5.0


gtk_source_gutter_renderer_set_xalign ()

void
gtk_source_gutter_renderer_set_xalign (GtkSourceGutterRenderer *renderer,
                                       gfloat xalign);

Adjusts the "xalign" property of the GtkSourceGutterRenderer. This may be used to adjust where within the cell rectangle the renderer will draw.

Parameters

renderer

a GtkSourceGutterRenderer

 

xalign

the Y padding for the drawing cell

 

Since: 5.0


gtk_source_gutter_renderer_get_xpad ()

gint
gtk_source_gutter_renderer_get_xpad (GtkSourceGutterRenderer *renderer);

Gets the "xpad" property of the GtkSourceGutterRenderer. This may be used to adjust the cell rectangle that the renderer will use to draw.

Parameters

renderer

a GtkSourceGutterRenderer

 

Since: 5.0


gtk_source_gutter_renderer_set_xpad ()

void
gtk_source_gutter_renderer_set_xpad (GtkSourceGutterRenderer *renderer,
                                     gint xpad);

Adjusts the "xpad" property of the GtkSourceGutterRenderer. This may be used to adjust the cell rectangle that the renderer will use to draw.

Parameters

renderer

a GtkSourceGutterRenderer

 

xpad

the Y padding for the drawing cell

 

Since: 5.0


gtk_source_gutter_renderer_get_yalign ()

gfloat
gtk_source_gutter_renderer_get_yalign (GtkSourceGutterRenderer *renderer);

Gets the "yalign" property of the GtkSourceGutterRenderer. This may be used to adjust where within the cell rectangle the renderer will draw.

Parameters

renderer

a GtkSourceGutterRenderer

 

Since: 5.0


gtk_source_gutter_renderer_set_yalign ()

void
gtk_source_gutter_renderer_set_yalign (GtkSourceGutterRenderer *renderer,
                                       gfloat yalign);

Adjusts the "yalign" property of the GtkSourceGutterRenderer. This may be used to adjust where within the cell rectangle the renderer will draw.

Parameters

renderer

a GtkSourceGutterRenderer

 

yalign

the Y padding for the drawing cell

 

Since: 5.0


gtk_source_gutter_renderer_get_ypad ()

gint
gtk_source_gutter_renderer_get_ypad (GtkSourceGutterRenderer *renderer);

Gets the "ypad" property of the GtkSourceGutterRenderer. This may be used to adjust the cell rectangle that the renderer will use to draw.

Parameters

renderer

a GtkSourceGutterRenderer

 

Since: 5.0


gtk_source_gutter_renderer_set_ypad ()

void
gtk_source_gutter_renderer_set_ypad (GtkSourceGutterRenderer *renderer,
                                     gint ypad);

Adjusts the "ypad" property of the GtkSourceGutterRenderer. This may be used to adjust the cell rectangle that the renderer will use to draw.

Parameters

renderer

a GtkSourceGutterRenderer

 

ypad

the Y padding for the drawing cell

 

Since: 5.0


gtk_source_gutter_renderer_align_cell ()

void
gtk_source_gutter_renderer_align_cell (GtkSourceGutterRenderer *renderer,
                                       guint line,
                                       gfloat width,
                                       gfloat height,
                                       gfloat *x,
                                       gfloat *y);

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

renderer

the GtkSourceGutterRenderer

 

line

the line number for content

 

width

the width of the content to draw

 

height

the height of the content to draw

 

x

the X position to render the content.

[out]

y

the Y position to render the content.

[out]

Since: 5.0


gtk_source_gutter_renderer_activate ()

void
gtk_source_gutter_renderer_activate (GtkSourceGutterRenderer *renderer,
                                     const GtkTextIter *iter,
                                     const GdkRectangle *area,
                                     guint button,
                                     GdkModifierType state,
                                     gint n_presses);

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

Parameters

renderer

a GtkSourceGutterRenderer

 

iter

a GtkTextIter at the start of the line where the renderer is activated

 

area

a GdkRectangle of the cell area where the renderer is activated

 

button

the button that was pressed

 

state

a GdkModifierType

 

n_presses

the number of button presses

 

gtk_source_gutter_renderer_query_activatable ()

gboolean
gtk_source_gutter_renderer_query_activatable
                               (GtkSourceGutterRenderer *renderer,
                                const GtkTextIter *iter,
                                const GdkRectangle *area);

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

Parameters

renderer

a GtkSourceGutterRenderer

 

iter

a GtkTextIter at the start of the line to be activated

 

area

a GdkRectangle of the cell area to be activated

 

Returns

TRUE if the renderer can be activated, FALSE otherwise

Types and Values

GtkSourceGutterRenderer

typedef struct _GtkSourceGutterRenderer GtkSourceGutterRenderer;

enum GtkSourceGutterRendererAlignmentMode

The alignment mode of the renderer, when a cell spans multiple lines (due to text wrapping).

Members

GTK_SOURCE_GUTTER_RENDERER_ALIGNMENT_MODE_CELL

The full cell.

 

GTK_SOURCE_GUTTER_RENDERER_ALIGNMENT_MODE_FIRST

The first line.

 

GTK_SOURCE_GUTTER_RENDERER_ALIGNMENT_MODE_LAST

The last line.

 

Property Details

The “alignment-mode” property

  “alignment-mode”           GtkSourceGutterRendererAlignmentMode

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.

Owner: GtkSourceGutterRenderer

Flags: Read / Write

Default value: GTK_SOURCE_GUTTER_RENDERER_ALIGNMENT_MODE_CELL


The “lines” property

  “lines”                    GtkSourceGutterLines *

The "lines" property contains information about the lines to be rendered. It should be used by GtkSourceGutterRenderer implementations from gtk_widget_snapshot().

Owner: GtkSourceGutterRenderer

Flags: Read


The “view” property

  “view”                     GtkTextView *

The view on which the renderer is placed.

Owner: GtkSourceGutterRenderer

Flags: Read


The “xalign” property

  “xalign”                   float

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.

Owner: GtkSourceGutterRenderer

Flags: Read / Write

Allowed values: [0,1]

Default value: 0


The “xpad” property

  “xpad”                     int

The left and right padding of the renderer.

Owner: GtkSourceGutterRenderer

Flags: Read / Write

Allowed values: >= 0

Default value: 0


The “yalign” property

  “yalign”                   float

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.

Owner: GtkSourceGutterRenderer

Flags: Read / Write

Allowed values: [0,1]

Default value: 0


The “ypad” property

  “ypad”                     int

The top and bottom padding of the renderer.

Owner: GtkSourceGutterRenderer

Flags: Read / Write

Allowed values: >= 0

Default value: 0

Signal Details

The “activate” signal

void
user_function (GtkSourceGutterRenderer *renderer,
               GtkTextIter             *iter,
               GdkRectangle            *area,
               guint                    button,
               GdkModifierType          state,
               int                      n_presses,
               gpointer                 user_data)

The ::activate signal is emitted when the renderer is activated.

Parameters

renderer

the GtkSourceGutterRenderer who emits the signal

 

iter

a GtkTextIter

 

area

a GdkRectangle

 

button

the button that was pressed

 

state

a GdkModifierType of state

 

n_presses

the number of button presses

 

user_data

user data set when the signal handler was connected.

 

Flags: Run Last


The “query-activatable” signal

gboolean
user_function (GtkSourceGutterRenderer *renderer,
               GtkTextIter             *iter,
               GdkRectangle            *area,
               gpointer                 user_data)

The ::query-activatable signal is emitted when the renderer can possibly be activated.

Parameters

renderer

the GtkSourceGutterRenderer who emits the signal

 

iter

a GtkTextIter

 

area

a GdkRectangle

 

event

the GdkEvent that is causing the activatable query

 

user_data

user data set when the signal handler was connected.

 

Flags: Run Last


The “query-data” signal

void
user_function (GtkSourceGutterRenderer *sourcegutterrenderer,
               GObject                 *arg1,
               guint                    arg2,
               gpointer                 user_data)

Flags: Run Last

See Also

GtkSourceGutter