Settings

Settings — Sharing settings between applications

Properties

gboolean gtk-alternative-button-order Read / Write
gboolean gtk-alternative-sort-arrows Read / Write
gboolean gtk-application-prefer-dark-theme Read / Write
double gtk-cursor-aspect-ratio Read / Write
gboolean gtk-cursor-blink Read / Write
int gtk-cursor-blink-time Read / Write
int gtk-cursor-blink-timeout Read / Write
char * gtk-cursor-theme-name Read / Write
int gtk-cursor-theme-size Read / Write
char * gtk-decoration-layout Read / Write
gboolean gtk-dialogs-use-header Read / Write
int gtk-dnd-drag-threshold Read / Write
int gtk-double-click-distance Read / Write
int gtk-double-click-time Read / Write
gboolean gtk-enable-accels Read / Write
gboolean gtk-enable-animations Read / Write
gboolean gtk-enable-event-sounds Read / Write
gboolean gtk-enable-input-feedback-sounds Read / Write
gboolean gtk-enable-primary-paste Read / Write
guint gtk-entry-password-hint-timeout Read / Write
gboolean gtk-entry-select-on-focus Read / Write
gboolean gtk-error-bell Read / Write
char * gtk-font-name Read / Write
guint gtk-fontconfig-timestamp Read / Write
char * gtk-icon-theme-name Read / Write
char * gtk-im-module Read / Write
gboolean gtk-keynav-use-caret Read / Write
gboolean gtk-label-select-on-focus Read / Write
guint gtk-long-press-time Read / Write
gboolean gtk-overlay-scrolling Read / Write
gboolean gtk-primary-button-warps-slider Read / Write
char * gtk-print-backends Read / Write
char * gtk-print-preview-command Read / Write
gboolean gtk-recent-files-enabled Read / Write
int gtk-recent-files-max-age Read / Write
gboolean gtk-shell-shows-app-menu Read / Write
gboolean gtk-shell-shows-desktop Read / Write
gboolean gtk-shell-shows-menubar Read / Write
char * gtk-sound-theme-name Read / Write
gboolean gtk-split-cursor Read / Write
char * gtk-theme-name Read / Write
char * gtk-titlebar-double-click Read / Write
char * gtk-titlebar-middle-click Read / Write
char * gtk-titlebar-right-click Read / Write
int gtk-xft-antialias Read / Write
int gtk-xft-dpi Read / Write
int gtk-xft-hinting Read / Write
char * gtk-xft-hintstyle Read / Write
char * gtk-xft-rgba Read / Write

Types and Values

Object Hierarchy

    GObject
    ╰── GtkSettings

Implemented Interfaces

GtkSettings implements GtkStyleProvider.

Includes

#include <gtk/gtk.h>

Description

GtkSettings provide a mechanism to share global settings between applications.

On the X window system, this sharing is realized by an XSettings manager that is usually part of the desktop environment, along with utilities that let the user change these settings.

On Wayland, the settings are obtained either via a settings portal, or by reading desktop settings from DConf.

In the absence of these sharing mechanisms, GTK reads default values for settings from settings.ini files in /etc/gtk-4.0, $XDG_CONFIG_DIRS/gtk-4.0 and $XDG_CONFIG_HOME/gtk-4.0. These files must be valid key files (see GKeyFile), and have a section called Settings. Themes can also provide default values for settings by installing a settings.ini file next to their gtk.css file.

Applications can override system-wide settings by setting the property of the GtkSettings object with g_object_set(). This should be restricted to special cases though; GtkSettings are not meant as an application configuration facility.

There is one GtkSettings instance per display. It can be obtained with gtk_settings_get_for_display(), but in many cases, it is more convenient to use gtk_widget_get_settings().

Functions

gtk_settings_get_default ()

GtkSettings *
gtk_settings_get_default (void);

Gets the GtkSettings object for the default display, creating it if necessary. See gtk_settings_get_for_display().

Returns

a GtkSettings object. If there is no default display, then returns NULL.

[nullable][transfer none]


gtk_settings_get_for_display ()

GtkSettings *
gtk_settings_get_for_display (GdkDisplay *display);

Gets the GtkSettings object for display , creating it if necessary.

Parameters

display

a GdkDisplay.

 

Returns

a GtkSettings object.

[transfer none]


gtk_settings_reset_property ()

void
gtk_settings_reset_property (GtkSettings *settings,
                             const char *name);

Undoes the effect of calling g_object_set() to install an application-specific value for a setting. After this call, the setting will again follow the session-wide value for this setting.

Parameters

settings

a GtkSettings object

 

name

the name of the setting to reset

 

Types and Values

GtkSettings

typedef struct _GtkSettings GtkSettings;

struct GtkSettingsValue

struct GtkSettingsValue {
  /* origin should be something like "filename:linenumber" for rc files,
   * or e.g. "XProperty" for other sources
   */
  char *origin;

  /* valid types are LONG, DOUBLE and STRING corresponding to the token parsed,
   * or a GSTRING holding an unparsed statement
   */
  GValue value;
};

Members

char *origin;

Origin should be something like “filename:linenumber” for rc files, or e.g. “XProperty” for other sources.

 

GValue value;

Valid types are LONG, DOUBLE and STRING corresponding to the token parsed, or a GSTRING holding an unparsed statement

 

enum GtkSystemSetting

Values that can be passed to the GtkWidgetClass.system_setting_changed vfunc to indicate that a system setting has changed and widgets may need to drop caches, or react otherwise.

Most of the values correspond to GtkSettings properties.

More values may be added over time.

Members

GTK_SYSTEM_SETTING_DPI

the “gtk-xft-dpi” setting has changed

 

GTK_SYSTEM_SETTING_FONT_NAME

The “gtk-font-name” setting has changed

 

GTK_SYSTEM_SETTING_FONT_CONFIG

The font configuration has changed in a way that requires text to be redrawn. This can be any of the “gtk-xft-antialias”, “gtk-xft-hinting”, “gtk-xft-hintstyle”, “gtk-xft-rgba” or “gtk-fontconfig-timestamp” settings

 

GTK_SYSTEM_SETTING_DISPLAY

The display has changed

 

GTK_SYSTEM_SETTING_ICON_THEME

The icon theme has changed in a way that requires icons to be looked up again

 

Property Details

The “gtk-alternative-button-order” property

  “gtk-alternative-button-order” gboolean

Whether buttons in dialogs should use the alternative button order.

Owner: GtkSettings

Flags: Read / Write

Default value: FALSE


The “gtk-alternative-sort-arrows” property

  “gtk-alternative-sort-arrows” gboolean

Controls the direction of the sort indicators in sorted list and tree views. By default an arrow pointing down means the column is sorted in ascending order. When set to TRUE, this order will be inverted.

Owner: GtkSettings

Flags: Read / Write

Default value: FALSE


The “gtk-application-prefer-dark-theme” property

  “gtk-application-prefer-dark-theme” gboolean

Whether the application prefers to use a dark theme. If a GTK theme includes a dark variant, it will be used instead of the configured theme.

Some applications benefit from minimizing the amount of light pollution that interferes with the content. Good candidates for dark themes are photo and video editors that make the actual content get all the attention and minimize the distraction of the chrome.

Dark themes should not be used for documents, where large spaces are white/light and the dark chrome creates too much contrast (web browser, text editor...).

Owner: GtkSettings

Flags: Read / Write

Default value: FALSE


The “gtk-cursor-aspect-ratio” property

  “gtk-cursor-aspect-ratio”  double

The aspect ratio of the text caret.

Owner: GtkSettings

Flags: Read / Write

Allowed values: [0,1]

Default value: 0.04


The “gtk-cursor-blink” property

  “gtk-cursor-blink”         gboolean

Whether the cursor should blink.

Also see the “gtk-cursor-blink-timeout” setting, which allows more flexible control over cursor blinking.

Owner: GtkSettings

Flags: Read / Write

Default value: TRUE


The “gtk-cursor-blink-time” property

  “gtk-cursor-blink-time”    int

Length of the cursor blink cycle, in milliseconds.

Owner: GtkSettings

Flags: Read / Write

Allowed values: >= 100

Default value: 1200


The “gtk-cursor-blink-timeout” property

  “gtk-cursor-blink-timeout” int

Time after which the cursor stops blinking, in seconds. The timer is reset after each user interaction.

Setting this to zero has the same effect as setting “gtk-cursor-blink” to FALSE.

Owner: GtkSettings

Flags: Read / Write

Allowed values: >= 1

Default value: 10


The “gtk-cursor-theme-name” property

  “gtk-cursor-theme-name”    char *

Name of the cursor theme to use, or NULL to use the default theme.

Owner: GtkSettings

Flags: Read / Write

Default value: NULL


The “gtk-cursor-theme-size” property

  “gtk-cursor-theme-size”    int

Size to use for cursors, or 0 to use the default size.

Owner: GtkSettings

Flags: Read / Write

Allowed values: [0,128]

Default value: 0


The “gtk-decoration-layout” property

  “gtk-decoration-layout”    char *

This setting determines which buttons should be put in the titlebar of client-side decorated windows, and whether they should be placed at the left of right.

The format of the string is button names, separated by commas. A colon separates the buttons that should appear on the left from those on the right. Recognized button names are minimize, maximize, close, icon (the window icon) and menu (a menu button for the fallback app menu).

For example, "menu:minimize,maximize,close" specifies a menu on the left, and minimize, maximize and close buttons on the right.

Note that buttons will only be shown when they are meaningful. E.g. a menu button only appears when the desktop shell does not show the app menu, and a close button only appears on a window that can be closed.

Also note that the setting can be overridden with the “decoration-layout” property.

Owner: GtkSettings

Flags: Read / Write

Default value: "menu:minimize,maximize,close"


The “gtk-dialogs-use-header” property

  “gtk-dialogs-use-header”   gboolean

Whether builtin GTK dialogs such as the file chooser, the color chooser or the font chooser will use a header bar at the top to show action widgets, or an action area at the bottom.

This setting does not affect custom dialogs using GtkDialog directly, or message dialogs.

Owner: GtkSettings

Flags: Read / Write

Default value: FALSE


The “gtk-dnd-drag-threshold” property

  “gtk-dnd-drag-threshold”   int

Number of pixels the cursor can move before dragging.

Owner: GtkSettings

Flags: Read / Write

Allowed values: >= 1

Default value: 8


The “gtk-double-click-distance” property

  “gtk-double-click-distance” int

Maximum distance allowed between two clicks for them to be considered a double click (in pixels).

Owner: GtkSettings

Flags: Read / Write

Allowed values: >= 0

Default value: 5


The “gtk-double-click-time” property

  “gtk-double-click-time”    int

Maximum time allowed between two clicks for them to be considered a double click (in milliseconds).

Owner: GtkSettings

Flags: Read / Write

Allowed values: >= 0

Default value: 400


The “gtk-enable-accels” property

  “gtk-enable-accels”        gboolean

Whether menu items should have visible accelerators which can be activated.

Owner: GtkSettings

Flags: Read / Write

Default value: TRUE


The “gtk-enable-animations” property

  “gtk-enable-animations”    gboolean

Whether to enable toolkit-wide animations.

Owner: GtkSettings

Flags: Read / Write

Default value: TRUE


The “gtk-enable-event-sounds” property

  “gtk-enable-event-sounds”  gboolean

Whether to play any event sounds at all.

See the Sound Theme Specifications for more information on event sounds and sound themes.

GTK itself does not support event sounds, you have to use a loadable module like the one that comes with libcanberra.

Owner: GtkSettings

Flags: Read / Write

Default value: TRUE


The “gtk-enable-input-feedback-sounds” property

  “gtk-enable-input-feedback-sounds” gboolean

Whether to play event sounds as feedback to user input.

See the Sound Theme Specifications for more information on event sounds and sound themes.

GTK itself does not support event sounds, you have to use a loadable module like the one that comes with libcanberra.

Owner: GtkSettings

Flags: Read / Write

Default value: TRUE


The “gtk-enable-primary-paste” property

  “gtk-enable-primary-paste” gboolean

Whether a middle click on a mouse should paste the 'PRIMARY' clipboard content at the cursor location.

Owner: GtkSettings

Flags: Read / Write

Default value: TRUE


The “gtk-entry-password-hint-timeout” property

  “gtk-entry-password-hint-timeout” guint

How long to show the last input character in hidden entries. This value is in milliseconds. 0 disables showing the last char. 600 is a good value for enabling it.

Owner: GtkSettings

Flags: Read / Write

Default value: 0


The “gtk-entry-select-on-focus” property

  “gtk-entry-select-on-focus” gboolean

Whether to select the contents of an entry when it is focused.

Owner: GtkSettings

Flags: Read / Write

Default value: TRUE


The “gtk-error-bell” property

  “gtk-error-bell”           gboolean

When TRUE, keyboard navigation and other input-related errors will cause a beep. Since the error bell is implemented using gdk_surface_beep(), the windowing system may offer ways to configure the error bell in many ways, such as flashing the window or similar visual effects.

Owner: GtkSettings

Flags: Read / Write

Default value: TRUE


The “gtk-font-name” property

  “gtk-font-name”            char *

The default font to use. GTK uses the family name and size from this string.

Owner: GtkSettings

Flags: Read / Write

Default value: "Sans 10"


The “gtk-fontconfig-timestamp” property

  “gtk-fontconfig-timestamp” guint

Timestamp of current fontconfig configuration.

Owner: GtkSettings

Flags: Read / Write

Default value: 0


The “gtk-icon-theme-name” property

  “gtk-icon-theme-name”      char *

Name of icon theme to use.

Owner: GtkSettings

Flags: Read / Write

Default value: "Adwaita"


The “gtk-im-module” property

  “gtk-im-module”            char *

Which IM (input method) module should be used by default. This is the input method that will be used if the user has not explicitly chosen another input method from the IM context menu. This also can be a colon-separated list of input methods, which GTK will try in turn until it finds one available on the system.

See GtkIMContext.

Owner: GtkSettings

Flags: Read / Write

Default value: NULL


The “gtk-keynav-use-caret” property

  “gtk-keynav-use-caret”     gboolean

Whether GTK should make sure that text can be navigated with a caret, even if it is not editable. This is useful when using a screen reader.

Owner: GtkSettings

Flags: Read / Write

Default value: FALSE


The “gtk-label-select-on-focus” property

  “gtk-label-select-on-focus” gboolean

Whether to select the contents of a selectable label when it is focused.

Owner: GtkSettings

Flags: Read / Write

Default value: TRUE


The “gtk-long-press-time” property

  “gtk-long-press-time”      guint

The time for a button or touch press to be considered a "long press".

Owner: GtkSettings

Flags: Read / Write

Allowed values: <= G_MAXINT

Default value: 500


The “gtk-overlay-scrolling” property

  “gtk-overlay-scrolling”    gboolean

Whether scrolled windows may use overlaid scrolling indicators. If this is set to FALSE, scrolled windows will have permanent scrollbars.

Owner: GtkSettings

Flags: Read / Write

Default value: TRUE


The “gtk-primary-button-warps-slider” property

  “gtk-primary-button-warps-slider” gboolean

If the value of this setting is TRUE, clicking the primary button in a GtkRange trough will move the slider, and hence set the range’s value, to the point that you clicked. If it is FALSE, a primary click will cause the slider/value to move by the range’s page-size towards the point clicked.

Whichever action you choose for the primary button, the other action will be available by holding Shift and primary-clicking, or (since GTK 3.22.25) clicking the middle mouse button.

Owner: GtkSettings

Flags: Read / Write

Default value: TRUE


The “gtk-print-backends” property

  “gtk-print-backends”       char *

A comma-separated list of print backends to use in the print dialog. Available print backends depend on the GTK installation, and may include "file", "cups", "lpr" or "papi".

Owner: GtkSettings

Flags: Read / Write

Default value: "cups,cloudprint,file"


The “gtk-print-preview-command” property

  “gtk-print-preview-command” char *

A command to run for displaying the print preview. The command should contain a %f placeholder, which will get replaced by the path to the pdf file. The command may also contain a %s placeholder, which will get replaced by the path to a file containing the print settings in the format produced by gtk_print_settings_to_file().

The preview application is responsible for removing the pdf file and the print settings file when it is done.

Owner: GtkSettings

Flags: Read / Write

Default value: "evince --unlink-tempfile --preview --print-settings %s %f"


The “gtk-recent-files-enabled” property

  “gtk-recent-files-enabled” gboolean

Whether GTK should keep track of items inside the recently used resources list. If set to FALSE, the list will always be empty.

Owner: GtkSettings

Flags: Read / Write

Default value: TRUE


The “gtk-recent-files-max-age” property

  “gtk-recent-files-max-age” int

The maximum age, in days, of the items inside the recently used resources list. Items older than this setting will be excised from the list. If set to 0, the list will always be empty; if set to -1, no item will be removed.

Owner: GtkSettings

Flags: Read / Write

Allowed values: >= -1

Default value: 30


The “gtk-shell-shows-app-menu” property

  “gtk-shell-shows-app-menu” gboolean

Set to TRUE if the desktop environment is displaying the app menu, FALSE if the app should display it itself.

Owner: GtkSettings

Flags: Read / Write

Default value: FALSE


The “gtk-shell-shows-desktop” property

  “gtk-shell-shows-desktop”  gboolean

Set to TRUE if the desktop environment is displaying the desktop folder, FALSE if not.

Owner: GtkSettings

Flags: Read / Write

Default value: TRUE


The “gtk-shell-shows-menubar” property

  “gtk-shell-shows-menubar”  gboolean

Set to TRUE if the desktop environment is displaying the menubar, FALSE if the app should display it itself.

Owner: GtkSettings

Flags: Read / Write

Default value: FALSE


The “gtk-sound-theme-name” property

  “gtk-sound-theme-name”     char *

The XDG sound theme to use for event sounds.

See the Sound Theme Specifications for more information on event sounds and sound themes.

GTK itself does not support event sounds, you have to use a loadable module like the one that comes with libcanberra.

Owner: GtkSettings

Flags: Read / Write

Default value: "freedesktop"


The “gtk-split-cursor” property

  “gtk-split-cursor”         gboolean

Whether two cursors should be displayed for mixed left-to-right and right-to-left text.

Owner: GtkSettings

Flags: Read / Write

Default value: TRUE


The “gtk-theme-name” property

  “gtk-theme-name”           char *

Name of theme to load.

Owner: GtkSettings

Flags: Read / Write

Default value: "Adwaita"


The “gtk-titlebar-double-click” property

  “gtk-titlebar-double-click” char *

This setting determines the action to take when a double-click occurs on the titlebar of client-side decorated windows.

Recognized actions are minimize, toggle-maximize, menu, lower or none.

Owner: GtkSettings

Flags: Read / Write

Default value: "toggle-maximize"


The “gtk-titlebar-middle-click” property

  “gtk-titlebar-middle-click” char *

This setting determines the action to take when a middle-click occurs on the titlebar of client-side decorated windows.

Recognized actions are minimize, toggle-maximize, menu, lower or none.

Owner: GtkSettings

Flags: Read / Write

Default value: "none"


The “gtk-titlebar-right-click” property

  “gtk-titlebar-right-click” char *

This setting determines the action to take when a right-click occurs on the titlebar of client-side decorated windows.

Recognized actions are minimize, toggle-maximize, menu, lower or none.

Owner: GtkSettings

Flags: Read / Write

Default value: "menu"


The “gtk-xft-antialias” property

  “gtk-xft-antialias”        int

Whether to antialias Xft fonts; 0=no, 1=yes, -1=default.

Owner: GtkSettings

Flags: Read / Write

Allowed values: [-1,1]

Default value: -1


The “gtk-xft-dpi” property

  “gtk-xft-dpi”              int

Resolution for Xft, in 1024 * dots/inch. -1 to use default value.

Owner: GtkSettings

Flags: Read / Write

Allowed values: [-1,1048576]

Default value: -1


The “gtk-xft-hinting” property

  “gtk-xft-hinting”          int

Whether to hint Xft fonts; 0=no, 1=yes, -1=default.

Owner: GtkSettings

Flags: Read / Write

Allowed values: [-1,1]

Default value: -1


The “gtk-xft-hintstyle” property

  “gtk-xft-hintstyle”        char *

What degree of hinting to use; hintnone, hintslight, hintmedium, or hintfull.

Owner: GtkSettings

Flags: Read / Write

Default value: NULL


The “gtk-xft-rgba” property

  “gtk-xft-rgba”             char *

Type of subpixel antialiasing; none, rgb, bgr, vrgb, vbgr.

Owner: GtkSettings

Flags: Read / Write

Default value: NULL