GtkSourceSnippet

GtkSourceSnippet — Quick insertion code snippets

Functions

Properties

GtkTextBuffer * buffer Read
char * description Read / Write
int focus-position Read
char * language-id Read / Write
char * name Read / Write
char * trigger Read / Write

Types and Values

Object Hierarchy

    GObject
    ╰── GtkSourceSnippet

Includes

#include <gtksourceview/gtksource.h>

Description

The GtkSourceSnippet represents a series of chunks that can quickly be inserted into the GtkSourceView.

Snippets are defined in XML files which are loaded by the GtkSourceSnippetManager. Alternatively, applications can create snippets on demand and insert them into the GtkSourceView using gtk_source_view_push_snippet().

Snippet chunks can reference other snippet chunks as well as post-process the values from other chunks such as capitalization.

Functions

gtk_source_snippet_add_chunk ()

void
gtk_source_snippet_add_chunk (GtkSourceSnippet *snippet,
                              GtkSourceSnippetChunk *chunk);

Appends chunk to the snippet .

This may only be called before the snippet has been expanded.

Parameters

snippet

a GtkSourceSnippet

 

chunk

a GtkSourceSnippetChunk

 

Since: 5.0


gtk_source_snippet_copy ()

GtkSourceSnippet *
gtk_source_snippet_copy (GtkSourceSnippet *snippet);

Does a deep copy of the snippet.

Parameters

snippet

a GtkSourceSnippet

 

Returns

A new GtkSourceSnippet.

[transfer full]

Since: 5.0


gtk_source_snippet_get_context ()

GtkSourceSnippetContext *
gtk_source_snippet_get_context (GtkSourceSnippet *snippet);

Gets the context used for expanding the snippet.

Parameters

snippet

an GtkSourceSnippet

 

Returns

an GtkSourceSnippetContext.

[nullable][transfer none]

Since: 5.0


gtk_source_snippet_get_description ()

const gchar *
gtk_source_snippet_get_description (GtkSourceSnippet *snippet);

Gets the description for the snippet.

Parameters

snippet

a GtkSourceSnippet

 

Since: 5.0


gtk_source_snippet_get_focus_position ()

gint
gtk_source_snippet_get_focus_position (GtkSourceSnippet *snippet);

Gets the current focus for the snippet. This is changed as the user tabs through focus locations.

Parameters

snippet

a GtkSourceSnippet

 

Returns

The focus position, or -1 if unset.

Since: 5.0


gtk_source_snippet_get_language_id ()

const gchar *
gtk_source_snippet_get_language_id (GtkSourceSnippet *snippet);

Gets the language-id used for the source snippet.

The language identifier should be one that matches a source language “id” property.

Parameters

snippet

a GtkSourceSnippet

 

Returns

the language identifier

Since: 5.0


gtk_source_snippet_get_name ()

const gchar *
gtk_source_snippet_get_name (GtkSourceSnippet *snippet);

Gets the name for the snippet.

Parameters

snippet

a GtkSourceSnippet

 

Since: 5.0


gtk_source_snippet_get_n_chunks ()

guint
gtk_source_snippet_get_n_chunks (GtkSourceSnippet *snippet);

Gets the number of chunks in the snippet.

Note that not all chunks are editable.

Parameters

snippet

a GtkSourceSnippet

 

Returns

The number of chunks.

Since: 5.0


gtk_source_snippet_get_nth_chunk ()

GtkSourceSnippetChunk *
gtk_source_snippet_get_nth_chunk (GtkSourceSnippet *snippet,
                                  guint nth);

Gets the chunk at nth .

Parameters

snippet

a GtkSourceSnippet

 

nth

the nth chunk to get

 

Returns

an GtkSourceSnippetChunk.

[transfer none]

Since: 5.0


gtk_source_snippet_get_trigger ()

const gchar *
gtk_source_snippet_get_trigger (GtkSourceSnippet *snippet);

Gets the trigger for the source snippet. A trigger is a word that can be expanded into the full snippet when the user presses Tab.

Parameters

snippet

a GtkSourceSnippet

 

Returns

A string or NULL.

[nullable]

Since: 5.0


gtk_source_snippet_new ()

GtkSourceSnippet *
gtk_source_snippet_new (const gchar *trigger,
                        const gchar *language_id);

Creates a new GtkSourceSnippet

Parameters

trigger

the trigger word.

[nullable]

language_id

the source language.

[nullable]

Returns

A new GtkSourceSnippet.

[transfer full]

Since: 5.0


gtk_source_snippet_set_description ()

void
gtk_source_snippet_set_description (GtkSourceSnippet *snippet,
                                    const gchar *description);

Sets the description for the snippet.

Parameters

snippet

a GtkSourceSnippet

 

description

the snippet description

 

Since: 5.0


gtk_source_snippet_set_language_id ()

void
gtk_source_snippet_set_language_id (GtkSourceSnippet *snippet,
                                    const gchar *language_id);

Sets the language identifier for the snippet.

This should match the “id” identifier.

Parameters

snippet

a GtkSourceSnippet

 

language_id

the language identifier for the snippet

 

Since: 5.0


gtk_source_snippet_set_name ()

void
gtk_source_snippet_set_name (GtkSourceSnippet *snippet,
                             const gchar *name);

Sets the name for the snippet.

Parameters

snippet

a GtkSourceSnippet

 

name

the snippet name

 

Since: 5.0


gtk_source_snippet_set_trigger ()

void
gtk_source_snippet_set_trigger (GtkSourceSnippet *snippet,
                                const gchar *trigger);

Sets the trigger for the snippet.

Parameters

snippet

a GtkSourceSnippet

 

trigger

the trigger word

 

Since: 5.0

Types and Values

GtkSourceSnippet

typedef struct _GtkSourceSnippet GtkSourceSnippet;

Property Details

The “buffer” property

  “buffer”                   GtkTextBuffer *

The GtkTextBuffer for the snippet.

Owner: GtkSourceSnippet

Flags: Read


The “description” property

  “description”              char *

The description for the snippet.

Owner: GtkSourceSnippet

Flags: Read / Write

Default value: NULL


The “focus-position” property

  “focus-position”           int

The currently focused chunk.

Owner: GtkSourceSnippet

Flags: Read

Allowed values: >= -1

Default value: -1


The “language-id” property

  “language-id”              char *

The language-id for the snippet.

Owner: GtkSourceSnippet

Flags: Read / Write

Default value: NULL


The “name” property

  “name”                     char *

The name for the snippet.

Owner: GtkSourceSnippet

Flags: Read / Write

Default value: NULL


The “trigger” property

  “trigger”                  char *

The trigger for the snippet.

Owner: GtkSourceSnippet

Flags: Read / Write

Default value: NULL

See Also

GtkSourceSnippetChunk, GtkSourceSnippetContext, GtkSourceSnippetManager