MarkAttributes

class MarkAttributes(**properties: Any)

Superclasses: Object

The source mark attributes object.

GtkSourceMarkAttributes is an object specifying attributes used by a View to visually show lines marked with Mark’s of a specific category. It allows you to define a background color of a line, an icon shown in gutter and tooltips.

The background color is used as a background of a line where a mark is placed and it can be set with set_background. To check if any custom background color was defined and what color it is, use get_background.

An icon is a graphic element which is shown in the gutter of a view. An example use is showing a red filled circle in a debugger to show that a breakpoint was set in certain line. To get an icon that will be placed in a gutter, first a base for it must be specified and then render_icon must be called. There are several ways to specify a base for an icon:

  • set_icon_name

  • set_gicon

  • set_pixbuf

Using any of the above functions overrides the one used earlier. But note that a getter counterpart of earlier used function can still return some value, but it is just not used when rendering the proper icon.

To provide meaningful tooltips for a given mark of a category, you should connect to query_tooltip_text or query_tooltip_markup where the latter takes precedence.

Constructors

class MarkAttributes
classmethod new() MarkAttributes

Creates a new source mark attributes.

Methods

class MarkAttributes
get_background() tuple[bool, RGBA]

Stores background color in background.

get_gicon() Icon

Gets a Icon to be used as a base for rendered icon.

Note that the icon can be None if it wasn’t set earlier.

get_icon_name() str

Gets a name of an icon to be used as a base for rendered icon.

Note that the icon name can be None if it wasn’t set earlier.

get_pixbuf() Pixbuf

Gets a Pixbuf to be used as a base for rendered icon.

Note that the pixbuf can be None if it wasn’t set earlier.

get_tooltip_markup(mark: Mark) str

Queries for a tooltip by emitting a query_tooltip_markup signal.

The tooltip may contain a markup.

Parameters:

mark – a Mark.

get_tooltip_text(mark: Mark) str

Queries for a tooltip by emitting a query_tooltip_text signal.

The tooltip is a plain text.

Parameters:

mark – a Mark.

render_icon(widget: Widget, size: int) Paintable

Renders an icon of given size.

The base of the icon is set by the last call to one of:

  • set_pixbuf

  • set_gicon

  • set_icon_name

size cannot be lower than 1.

Parameters:
  • widget – widget of which style settings may be used.

  • size – size of the rendered icon.

set_background(background: RGBA) None

Sets background color to the one given in background.

Parameters:

background – a RGBA.

set_gicon(gicon: Icon) None

Sets an icon to be used as a base for rendered icon.

Parameters:

gicon – a Icon to be used.

set_icon_name(icon_name: str) None

Sets a name of an icon to be used as a base for rendered icon.

Parameters:

icon_name – name of an icon to be used.

set_pixbuf(pixbuf: Pixbuf) None

Sets a pixbuf to be used as a base for rendered icon.

Parameters:

pixbuf – a Pixbuf to be used.

Properties

class MarkAttributes
props.background: RGBA

A color used for background of a line.

props.gicon: Icon

A Icon that may be a base of a rendered icon.

props.icon_name: str

An icon name that may be a base of a rendered icon.

props.pixbuf: Pixbuf

A Pixbuf that may be a base of a rendered icon.

Signals

class MarkAttributes.signals
query_tooltip_markup(mark: Mark) str

The code should connect to this signal to provide a tooltip for given mark. The tooltip can contain a markup.

Parameters:

mark – The Mark.

query_tooltip_text(mark: Mark) str

The code should connect to this signal to provide a tooltip for given mark. The tooltip should be just a plain text.

Parameters:

mark – The Mark.