gtksourceview2.Gutter
Prev |  | Next

## gtksourceview2.Gutter

gtksourceview2.Gutter — Mark object for gtksourceview.SourceView

## Synopsis

    class gtksourceview2.Gutter(gobject.GObject):
        def get_window()
        def insert(renderer, position)
        def queue_draw()
        def remove(renderer)
        def reorder(renderer, position)
        def set_cell_data_func(renderer, func, func_data=None)
        def set_cell_size_func(renderer, func, func_data=None)

## Ancestry

    +-- gobject.GObject
        +-- gtksourceview2.Gutter

## Properties

"view" | Read-Write-Construct Only | The `gtksourceview2.View` of the gutter.
"window-type" | Read-Write-Construct Only | The text window type on which the window is placed. Default value: gtk.TEXT_WINDOW_PRIVATE.

## Signal Prototypes

"cell-activated" | `def callback(`gutter`, `renderer`, `iter`, `event`, `user_param1`, `...`)`
"query-tooltip" | `def callback(`gutter`, `renderer`, `iter`, `tooltip`, `user_param1`, `...`)`

## Description

The `gtksourceview2.Gutter` object represents the left and right gutters of the text view. It is used by `gtksourceview2.View` to draw the line numbers and category marks that might be present on a line. By packing additional `gtk.CellRenderer` objects in the gutter, you can extend the gutter by your own custom drawings.

The gutter works very much the same way as cells rendered in a `gtk.TreeView`. The concept is similar, with the exception that the gutter does not have an underlying `gtk.TreeModel`. Instead, you should use `gtksourceview2.Gutter.set_cell_data_func`() to set a callback to fill in any of the cell renderers properties, given the line for which the cell is to be rendered. Renderers are inserted into the gutter at a certain position. The builtin line number renderer is at position GTK_SOURCE_VIEW_GUTTER_POSITION_LINES (-30) and the marks renderer is at GTK_SOURCE_VIEW_GUTTER_POSITION_MARKS (-20). You can use these values to position custom renderers accordingly.

The width of a cell renderer can be specified as either fixed (using `gtk.CellRenderer.set_fixed_size`() ) or dynamic, in which case you MUST set `gtksourceview2.Gutter.set_cell_size_func`(). This callback is used to set the properties of the renderer such that `gtk.CellRenderer.get_size`() yields the maximum width of the cell.

## Methods

### gtksourceview2.Gutter.get_window

        def get_window()

Returns : | the `gtk.gdk.Window` of the gutter, or `None` if the gutter has no window.

The `get_window`() method returns the `gtk.gdk.Window` of the gutter. The window will only be available when the gutter has at least one, non-zero width, cell renderer packed.

### gtksourceview2.Gutter.insert

        def insert(renderer, position)

`renderer` : | a `gtk.CellRenderer`
`position` : | the renderers position.

The `insert`() method inserts renderer into gutter at position.

### gtksourceview2.Gutter.queue_draw

        def queue_draw()

The `queue_draw`() method invalidates the drawable area of the gutter. You can use this to force a redraw of the gutter if something has changed and needs to be redrawn.

### gtksourceview2.Gutter.remove

        def remove(renderer)

`renderer` : | a `gtk.CellRenderer`

The `renderer`() method removes renderer from gutter.

### gtksourceview2.Gutter.reorder

        def reorder(renderer, position)

`renderer` : | a `gtk.CellRenderer`
`position` : | the new renderer position.

The `renderer`() method reorders renderer in gutter to new position.

### gtksourceview2.Gutter.set_cell_data_func

        def set_cell_data_func(renderer, func, func_data)

`renderer` : | a `gtk.CellRenderer`
`func` : | the function.
`func_data` : | the data to pass whitin func.

The `set_cell_data_func`() method sets the func to use for renderer. This function is used to setup the cell renderer properties for rendering the current cell.

        def gutterdatafunc(cell, line_number, current_line, user_data)

Where cell is the `gtk.CellRenderer` to use, line_number is the line number for the gutter and current_line is a boolean indicating if it's the current line, user_data is the data passed to set_cell_data_func().

### gtksourceview2.Gutter.set_cell_size_func

        def set_cell_data_func(renderer, func, func_data)

`renderer` : | a `gtk.CellRenderer`
`func` : | the function.
`func_data` : | the data to pass whitin func.

The `set_cell_size_func`() method sets the func to use for renderer. This function is used to setup the cell renderer properties for measuring the maximum size of the cell.

        def guttersizefunc(cell, user_data)

Where cell is the `gtk.CellRenderer` to use, and user_data is the data passed to set_cell_data_func().

## Signals

### The "cell-activated" gtksourceview2.Gutter Signal

        def callback(gutter, renderer, iter, event, user_param1, ...)

`gutter` : | the gtksourceview2.Gutter
`renderer` : | the `gtk.CellRenderer` which was activated.
`iter` : | the `gtk.TextIter` at which the cell was activated
`event` : | the `gtk.gdk.Event` with which the cell was activated
`user_param1` : | the first user parameter (if any) specified with the `connect`() method
`...` : | additional user parameters (if any)

The "cell-activated" signal is emitted when a cell has been activated (for instance when there was a button press on the cell). The signal is only emitted for cells that have the activatable property set to `True`.

### The "query-tooltip" gtksourceview2.Gutter Signal

        def callback(gutter, renderer, iter, tooltip, user_param1, ...)

`gutter` : | the gtksourceview2.Gutter
`renderer` : | the `gtk.CellRenderer` which was activated.
`iter` : | the `gtk.TextIter` at which the cell was activated
`tooltip` : | the `gtk.Tooltip`
`user_param1` : | the first user parameter (if any) specified with the `connect`() method
`...` : | additional user parameters (if any)

The "query-tooltip" signal is emitted when a tooltip is requested for a specific cell. Signal handlers can return `True` to notify the tooltip has been handled.

Prev |  | Next
gtksourceview2.Buffer | Home | gtksourceview2.Language