TeplSettings: libgedit-tepl 6 Reference Manual

## TeplSettings TeplSettings — Singleton class containing GSettings objects |

## Functions

TeplSettings * | tepl_settings_get_singleton ()
GSettings * | tepl_settings_peek_desktop_interface_settings ()
void | tepl_settings_provide_font_settings ()
gchar * | tepl_settings_get_selected_font ()
void | tepl_settings_handle_theme_variant ()
void | tepl_settings_provide_style_scheme_settings ()
gchar * | tepl_settings_get_style_scheme_id ()
gboolean | tepl_settings_get_range_uint ()
void | tepl_settings_reset_all ()

## Properties

char * | style-scheme-id | Read

## Signals

void | font-changed | Run First

## Types and Values

struct | TeplSettings
enum | TeplSettingsThemeVariant

## Object Hierarchy

        GEnum
        ╰── TeplSettingsThemeVariant
        GObject
        ╰── TeplSettings

## Includes

    #include <tepl/tepl.h>

## Description

TeplSettings is a singleton class to have a central access to some GSettings objects and having convenience features that are useful for a text editor.

The central access permits to:

- Share the same GSettings objects between different parts of the application.

- Avoid the need to store GSettings objects a bit everywhere in different classes.

## Functions

### tepl_settings_get_singleton ()

    TeplSettings *
    tepl_settings_get_singleton (void);

#### Returns

the TeplSettings singleton instance.

[transfer none]

Since: 6.2

### tepl_settings_peek_desktop_interface_settings ()

    GSettings *
    tepl_settings_peek_desktop_interface_settings
                                   (TeplSettings *self);

#### Parameters

self | the TeplSettings instance. |

#### Returns

the GSettings for `"org.gnome.desktop.interface"`.

[transfer none]

Since: 6.2

### tepl_settings_provide_font_settings ()

    void
    tepl_settings_provide_font_settings (TeplSettings *self,
                                         GSettings *font_settings,
                                         const gchar *use_default_font_key,
                                         const gchar *editor_font_key);

This function can only be called once, to provide two keys:

- `use_default_font_key` : must be of type boolean, to know whether to use the system's font (the default font), or the editor font.

- `editor_font_key` : must be of type string, containing the font name to have a different font for the text editor, rather than using the system's font.

See `tepl_settings_get_selected_font()`.

#### Parameters

self | the TeplSettings instance. |
font_settings | the GSettings object containing the keys. |
use_default_font_key | a key of type boolean. |
editor_font_key | a key of type string. |

Since: 6.2

### tepl_settings_get_selected_font ()

    gchar *
    tepl_settings_get_selected_font (TeplSettings *self);

If `tepl_settings_provide_font_settings()` has *not* been called, this function always returns the current value of the system's fixed width (monospace) font.

If `tepl_settings_provide_font_settings()` *has* been called, this function returns the font name depending on the boolean value of `use_default_font_key` .

See also the “font-changed” signal, `tepl_utils_override_font_string()` and `tepl_prefs_create_font_component()`.

#### Parameters

self | the TeplSettings instance. |

#### Returns

the selected font name.

Since: 6.2

### tepl_settings_handle_theme_variant ()

    void
    tepl_settings_handle_theme_variant (TeplSettings *self,
                                        GSettings *theme_variant_settings,
                                        const gchar *theme_variant_setting_key);

This function permits to setup correctly the GTK theme variant to use.

If `theme_variant_settings` and `theme_variant_setting_key` are `NULL`, only the system's settings will be taken into account.

If `theme_variant_settings` and `theme_variant_setting_key` are provided, they are taken into account according to TeplSettingsThemeVariant.

You should call this function only once, as subsequent calls are ignored (the setting used cannot be reconfigured).

#### Parameters

self | the TeplSettings instance. |
theme_variant_settings | a GSettings object, or `NULL`. | [nullable]
theme_variant_setting_key | a GSettings key of type enum TeplSettingsThemeVariant, or `NULL`. | [nullable]

Since: 6.10

### tepl_settings_provide_style_scheme_settings ()

    void
    tepl_settings_provide_style_scheme_settings
                                   (TeplSettings *self,
                                    GSettings *style_scheme_settings,
                                    const gchar *key_for_light_theme_variant,
                                    const gchar *key_for_dark_theme_variant);

This function can only be called once, to provide two keys:

- `key_for_light_theme_variant` : must be of type string, containing the ID of a GtkSourceStyleScheme that should be used when the GTK theme variant is light.

- `key_for_dark_theme_variant` : the same, but when the GTK theme variant is dark.

See `tepl_settings_get_style_scheme_id()`.

#### Parameters

self | the TeplSettings instance. |
style_scheme_settings | the GSettings object containing the keys. |
key_for_light_theme_variant | a key of type string. |
key_for_dark_theme_variant | a key of type string. |

Since: 6.11

### tepl_settings_get_style_scheme_id ()

    gchar *
    tepl_settings_get_style_scheme_id (TeplSettings *self);

#### Parameters

self | the TeplSettings instance. |

#### Returns

the value of the “style-scheme-id” property.

[transfer full][nullable]

Since: 6.11

### tepl_settings_get_range_uint ()

    gboolean
    tepl_settings_get_range_uint (GSettings *settings,
                                  const gchar *key,
                                  guint32 *min,
                                  guint32 *max);

This function introspects a GSettings key to get its range, if the key as a "u" type (unsigned integer). `FALSE` is returned if the introspection failed.

See `g_settings_schema_key_get_range()` for more flexibility.

#### Parameters

settings | a GSettings. |
key | a key part of `settings` . |
min | the minimum value allowed by the range. | [out]
max | the maximum value allowed by the range. | [out]

#### Returns

whether the operation was successful.

Since: 6.2

### tepl_settings_reset_all ()

    void
    tepl_settings_reset_all (const gchar *schema_id);

Resets all the GSettings keys belonging to `schema_id` .

#### Parameters

schema_id | a GSettings schema id. |

Since: 6.13

## Types and Values

### struct TeplSettings

    struct TeplSettings;

### enum TeplSettingsThemeVariant

This enum is intended to be used for controlling the GTK theme preference.

#### Members

TEPL_SETTINGS_THEME_VARIANT_SYSTEM | Follow the system's preference. |
TEPL_SETTINGS_THEME_VARIANT_LIGHT | Force a light theme. |
TEPL_SETTINGS_THEME_VARIANT_DARK | Force a dark theme. |

Since: 6.10

## Property Details

### The `“style-scheme-id”` property

      “style-scheme-id”          char *

See `tepl_settings_provide_style_scheme_settings()`.

The value of this property depends on whether the GTK theme is light or dark, and uses the corresponding GSettings key.

Owner: TeplSettings

Flags: Read

Default value: NULL

Since: 6.11

## Signal Details

### The `“font-changed”` signal

    void
    user_function (TeplSettings *settings,
                   gpointer      user_data)

The ::font-changed signal is emitted when the return value of `tepl_settings_get_selected_font()` has potentially changed.

It takes into account the `use_default_font_key` provided with `tepl_settings_provide_font_settings()` to avoid unnecessary signal emission. In other words, for example if `use_default_font_key` is `FALSE`, the signal is not emitted even if the default (system's) font has been modified.

The relation between this signal and a potential zoom in and zoom out feature, to temporarily make the font larger or smaller (so the zoom level not being stored in GSettings): when this signal is emitted, it means that the user has explicitly changed the font setting, and as such he or she probably wants to use that font instead. So the expected behavior in that case is to reset the zoom level. But it's left as an exercise for another class, since TeplSettings is only for GSettings.

#### Parameters

settings | the TeplSettings emitting the signal. |
user_data | user data set when the signal handler was connected. |

Flags: Run First

Since: 6.2