# Porting Guides

## GtkSourceView 3 -> 4 Porting Guide

### GTK dependency

Both GtkSourceView 3 and GtkSourceView 4 depend on GTK 3.

### Preparation in GtkSourceView 3

GtkSourceView 3.24 is the latest stable GtkSourceView 3 version. Before continuing this porting guide, you should use the 3.24 version without using any deprecated API.

### New pkg-config name

For GtkSourceView 4, the pkg-config name is: `gtksourceview-4`

To compile a program that uses GtkSourceView 4, you can for example use the following command:

`$ gcc hello.c `pkg-config --cflags --libs gtksourceview-4` -o hello`

### GtkSourceView 3.99.1

- All the deprecated APIs have been removed.

- Only `<gtksourceview/gtksource.h>` can be included directly. There were already warnings about it in GtkSourceView 3. The warnings have been changed to errors.

- Only the version 2 of the GtkSourceView language definition file format is supported (for *.lang files, used for syntax highlighting). The support for the version 1 has been dropped.

### GtkSourceView 3.99.2

- `gtk_source_completion_item_new2()` has been renamed to gtk_source_completion_item_new().

- `gtk_source_search_context_forward2()` has been renamed to gtk_source_search_context_forward().

- `gtk_source_search_context_forward_finish2()` has been renamed to gtk_source_search_context_forward_finish().

- `gtk_source_search_context_backward2()` has been renamed to gtk_source_search_context_backward().

- `gtk_source_search_context_backward_finish2()` has been renamed to gtk_source_search_context_backward_finish().

- `gtk_source_search_context_replace2()` has been renamed to gtk_source_search_context_replace().

- The GtkSourceSearchContext:settings property is now construct-only.

### GtkSourceView 3.99.3

No API changes.

### GtkSourceView 3.99.4

- The API of the GtkSourceView::move-lines keybinding signal has been simplified: the `copy` parameter was deprecated and has been removed; and the `count` parameter has been replaced by the `down` boolean.

### GtkSourceView 3.99.5 and 3.99.6

No API changes.

### GtkSourceView 3.99.7

In order to have a better *.gir file and have less metadata to generate the *.vapi for Vala, the following change has been made:

- `gtk_source_completion_show()` has been renamed to gtk_source_completion_start(). The function conflicted with the GtkSourceCompletion::show signal. Note that in Vala this doesn't require code changes because the method was already renamed to `start()` in GtkSourceView 3.

Other changes in 3.99.7:

- For i18n initialization, the gtk_source_init() function now needs to be called. There is also the gtk_source_finalize() function which is convenient when using memory debugging tools.

## GtkSourceView 4 -> libgedit-gtksourceview 299.0 Porting Guide

### GTK dependency

Both GtkSourceView 4 and libgedit-gtksourceview 299.x.y depend on GTK 3.

### pkg-config name

The new pkg-config name is: `libgedit-gtksourceview-300`

The “3” in “300” means that it targets GTK 3.

### For Vala

For Vala code, use the GObject Introspection file, not the `*.vapi`, because the `*.vapi` file has been removed.

### For Glade

The Glade catalog has been removed, so don't rely on it.

### Paths to lang and style files

The paths to `*.lang` and style scheme files have changed. For example, `/usr/share/libgedit-gtksourceview-300/language-specs/` is the usual location where `*.lang` files are found.

### API breaks

- `GtkSourceMap` has been removed.

- `GtkSourceStyleSchemeChooserButton` and `GtkSourceStyleSchemeChooserWidget` have been removed. See the Tepl library for a replacement.

- The macros and functions to check the library version have been removed: the `gtk_source_check_version()`, `gtk_source_get_major_version()`, etc functions; as well as all the macros such as `GTK_SOURCE_CHECK_VERSION()`.

- The `GtkSourceStyleSchemeManager:scheme-ids` and `GtkSourceStyleSchemeManager:search-path` properties have been removed. Instead, you can connect to the GtkSourceStyleSchemeManager::changed signal to be notified.

  The `gtk_source_style_scheme_manager_get_scheme_ids()` function has been removed, use gtk_source_style_scheme_manager_get_schemes() instead.

  All the GtkSourceStyleScheme properties have been removed. Use the get functions instead.

  All the GtkSourceStyle properties have been removed. Use the `gtk_source_style_get_data()` function instead.

## libgedit-gtksourceview 299.0 -> 299.2 Porting Guide

### API breaks

- The `gtk_source_style_get_data()` function has been removed. GtkSourceStyle is now a boxed type (a simple struct), no longer a GObject. Another important difference is to call the right ref/unref functions for memory management.

  The GtkSourceSearchContext:match-style property is a GtkSourceStyle, so it may require some code changes when using it.

  The `gtk_source_style_scheme_get_authors()` function has been removed.

## libgedit-gtksourceview 299.2 -> 299.3 Porting Guide

### API breaks

- The `GtkSourceStyleSchemeChooser` interface has been removed because it is no longer used by libgedit-tepl.

## libgedit-gtksourceview 299.3 -> 299.4 Porting Guide

### API breaks

- The background-pattern feature (with the grid pattern) has been removed from the GtkSourceView class.