### Class

# GtkSource SpaceDrawer

#### Description [src]

    final class GtkSource.SpaceDrawer : GObject.Object
    {
      /* No available fields */
    }

Represent white space characters with symbols.

`GtkSourceSpaceDrawer` provides a way to visualize white spaces, by drawing symbols.

Call `gtk_source_view_get_space_drawer()` to get the `GtkSourceSpaceDrawer` instance of a certain `GtkSourceView`.

By default, no white spaces are drawn because the `GtkSourceSpaceDrawer:enable-matrix` is `FALSE`.

To draw white spaces, `gtk_source_space_drawer_set_types_for_locations()` can be called to set the `GtkSourceSpaceDrawer:matrix` property (by default all space types are enabled at all locations). Then call `gtk_source_space_drawer_set_enable_matrix()`.

For a finer-grained method, there is also the `GtkSourceTag`‘s `GtkSourceTag:draw-spaces` property.

# Example

To draw non-breaking spaces everywhere and draw all types of trailing spaces except newlines:

    gtk_source_space_drawer_set_types_for_locations (space_drawer,
                                                     GTK_SOURCE_SPACE_LOCATION_ALL,
                                                     GTK_SOURCE_SPACE_TYPE_NBSP);

    gtk_source_space_drawer_set_types_for_locations (space_drawer,
                                                     GTK_SOURCE_SPACE_LOCATION_TRAILING,
                                                     GTK_SOURCE_SPACE_TYPE_ALL &
                                                     ~GTK_SOURCE_SPACE_TYPE_NEWLINE);

    gtk_source_space_drawer_set_enable_matrix (space_drawer, TRUE);

    space_drawer.set_types_for_locations(
        locations=GtkSource.SpaceLocationFlags.ALL,
        types=GtkSource.SpaceTypeFlags.NBSP,
    )

    all_types_except_newline = GtkSource.SpaceTypeFlags(
        int(GtkSource.SpaceTypeFlags.ALL) & ~int(GtkSource.SpaceTypeFlags.NEWLINE)
    )
    space_drawer.set_types_for_locations(
        locations=GtkSource.SpaceLocationFlags.TRAILING,
        types=all_types_except_newline,
    )

    space_drawer.set_enable_matrix(True)

# Use-case: draw unwanted white spaces

A possible use-case is to draw only unwanted white spaces. Examples:

- Draw all trailing spaces.
- If the indentation and alignment must be done with spaces, draw tabs.

And non-breaking spaces can always be drawn, everywhere, to distinguish them from normal spaces.

#### Hierarchy

#### Ancestors

- GObject

#### Constructors

###### gtk_source_space_drawer_new

Creates a new `GtkSourceSpaceDrawer` object.

#### Instance methods

###### gtk_source_space_drawer_bind_matrix_setting

Binds the `GtkSourceSpaceDrawer:matrix` property to a `GSettings` key.

###### gtk_source_space_drawer_get_enable_matrix

No description available.

###### gtk_source_space_drawer_get_matrix

Gets the value of the `GtkSourceSpaceDrawer:matrix` property, as a `GVariant`.

###### gtk_source_space_drawer_get_types_for_locations

If only one location is specified, this function returns what kind of white spaces are drawn at that location.

###### gtk_source_space_drawer_set_enable_matrix

Sets whether the `GtkSourceSpaceDrawer:matrix` property is enabled.

###### gtk_source_space_drawer_set_matrix

Sets a new value to the `GtkSourceSpaceDrawer:matrix` property, as a `GVariant`.

###### gtk_source_space_drawer_set_types_for_locations

Modifies the `GtkSourceSpaceDrawer:matrix` property at the specified `locations`.

##### Methods inherited from GObject (43)

Please see GObject for a full list of methods.

#### Properties

###### GtkSource.SpaceDrawer:enable-matrix

Whether the `GtkSourceSpaceDrawer:matrix` property is enabled.

###### GtkSource.SpaceDrawer:matrix

The property is a `GVariant` property to specify where and what kind of white spaces to draw.

#### Signals

##### Signals inherited from GObject (1)

###### GObject::notify

The notify signal is emitted on an object when one of its properties has its value set through g_object_set_property(), g_object_set(), et al.

#### Class structure

    struct GtkSourceSpaceDrawerClass {
      GObjectClass parent_class;

    }

No description available.

###### Class members

`parent_class: GObjectClass`

  No description available.