GtkSource.MarkAttributes

g GObject.Object GObject.Object GtkSource.MarkAttributes GtkSource.MarkAttributes GObject.Object->GtkSource.MarkAttributes

Subclasses:

None

Methods

Inherited:

GObject.Object (37)

Structs:

GObject.ObjectClass (5)

class

new ()

get_background ()

get_gicon ()

get_icon_name ()

get_pixbuf ()

get_tooltip_markup (mark)

get_tooltip_text (mark)

render_icon (widget, size)

set_background (background)

set_gicon (gicon)

set_icon_name (icon_name)

set_pixbuf (pixbuf)

Virtual Methods

Inherited:

GObject.Object (7)

Properties

Name

Type

Flags

Short Description

background

Gdk.RGBA

r/w/en

The background

gicon

Gio.Icon

r/w/en

The Gio.Icon

icon-name

str

r/w/en

The icon name

pixbuf

GdkPixbuf.Pixbuf

r/w/en

The pixbuf

Signals

Inherited:

GObject.Object (1)

Name

Short Description

query-tooltip-markup

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

query-tooltip-text

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

Fields

Inherited:

GObject.Object (1)

Class Details

class GtkSource.MarkAttributes(**kwargs)
Bases:

GObject.Object

Abstract:

No

Structure:

GtkSource.MarkAttributesClass

The source mark attributes object.

GtkSourceMarkAttributes is an object specifying attributes used by a [class`View`] to visually show lines marked with [class`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 [method`MarkAttributes`.set_background]. To check if any custom background color was defined and what color it is, use [method`MarkAttributes`.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 [method`MarkAttributes`.render_icon] must be called. There are several ways to specify a base for an icon:

  • [method`MarkAttributes`.set_icon_name]

  • [method`MarkAttributes`.set_gicon]

  • [method`MarkAttributes`.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 [signal`MarkAttributes`:py:func:::query-tooltip-text<GtkSource.MarkAttributes.signals.query_tooltip_text>] or [signal`MarkAttributes`:py:func:::query-tooltip-markup<GtkSource.MarkAttributes.signals.query_tooltip_markup>] where the latter takes precedence.

classmethod new()
Returns:

a new source mark attributes.

Return type:

GtkSource.MarkAttributes

Creates a new source mark attributes.

get_background()
Returns:

whether background color for self was set.

background:

a Gdk.RGBA.

Return type:

(bool, background: Gdk.RGBA)

Stores background color in background.

get_gicon()
Returns:

An icon. The icon belongs to self and should not be unreffed.

Return type:

Gio.Icon

Gets a [iface`Gio`.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()
Returns:

An icon name. The string belongs to self and should not be freed.

Return type:

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()
Returns:

A pixbuf. The pixbuf belongs to self and should not be unreffed.

Return type:

GdkPixbuf.Pixbuf

Gets a [class`GdkPixbuf`.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)
Parameters:

mark (GtkSource.Mark) – a GtkSource.Mark.

Returns:

A tooltip. The returned string should be freed by using GLib.free() when done with it.

Return type:

str

Queries for a tooltip by emitting a [signal`MarkAttributes`:py:func:::query-tooltip-markup<GtkSource.MarkAttributes.signals.query_tooltip_markup>] signal.

The tooltip may contain a markup.

get_tooltip_text(mark)
Parameters:

mark (GtkSource.Mark) – a GtkSource.Mark.

Returns:

A tooltip. The returned string should be freed by using GLib.free() when done with it.

Return type:

str

Queries for a tooltip by emitting a [signal`MarkAttributes`:py:func:::query-tooltip-text<GtkSource.MarkAttributes.signals.query_tooltip_text>] signal.

The tooltip is a plain text.

render_icon(widget, size)
Parameters:
  • widget (Gtk.Widget) – widget of which style settings may be used.

  • size (int) – size of the rendered icon.

Returns:

A Gdk.Paintable. The paintable belongs to self and should not be unreffed.

Return type:

Gdk.Paintable

Renders an icon of given size.

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

  • [method`MarkAttributes`.set_pixbuf]

  • [method`MarkAttributes`.set_gicon]

  • [method`MarkAttributes`.set_icon_name]

size cannot be lower than 1.

set_background(background)
Parameters:

background (Gdk.RGBA) – a Gdk.RGBA.

Sets background color to the one given in background.

set_gicon(gicon)
Parameters:

gicon (Gio.Icon) – a Gio.Icon to be used.

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

set_icon_name(icon_name)
Parameters:

icon_name (str) – name of an icon to be used.

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

set_pixbuf(pixbuf)
Parameters:

pixbuf (GdkPixbuf.Pixbuf) – a GdkPixbuf.Pixbuf to be used.

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

Signal Details

GtkSource.MarkAttributes.signals.query_tooltip_markup(mark_attributes, mark)
Signal Name:

query-tooltip-markup

Flags:

RUN_LAST

Parameters:
Returns:

A tooltip. The string should be freed with GLib.free() when done with it.

Return type:

str

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

GtkSource.MarkAttributes.signals.query_tooltip_text(mark_attributes, mark)
Signal Name:

query-tooltip-text

Flags:

RUN_LAST

Parameters:
Returns:

A tooltip. The string should be freed with GLib.free() when done with it.

Return type:

str

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

Property Details

GtkSource.MarkAttributes.props.background
Name:

background

Type:

Gdk.RGBA

Default Value:

None

Flags:

READABLE, WRITABLE, EXPLICIT_NOTIFY

A color used for background of a line.

GtkSource.MarkAttributes.props.gicon
Name:

gicon

Type:

Gio.Icon

Default Value:

None

Flags:

READABLE, WRITABLE, EXPLICIT_NOTIFY

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

GtkSource.MarkAttributes.props.icon_name
Name:

icon-name

Type:

str

Default Value:

None

Flags:

READABLE, WRITABLE, EXPLICIT_NOTIFY

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

GtkSource.MarkAttributes.props.pixbuf
Name:

pixbuf

Type:

GdkPixbuf.Pixbuf

Default Value:

None

Flags:

READABLE, WRITABLE, EXPLICIT_NOTIFY

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