Settings
Superclasses: Object
Implemented Interfaces: StyleProvider
GtkSettings
provides 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 Settings
.
On macOS, the settings are obtained from NSUserDefaults
.
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 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
get_for_display
, but in many cases, it is more
convenient to use get_settings
.
Methods
Properties
- class Settings
- props.gtk_alternative_button_order: bool
Whether buttons in dialogs should use the alternative button order.
- props.gtk_alternative_sort_arrows: bool
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.
- props.gtk_application_prefer_dark_theme: bool
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…).
- props.gtk_cursor_blink: bool
Whether the cursor should blink.
Also see the
gtk_cursor_blink_timeout
setting, which allows more flexible control over cursor blinking.
- props.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
toFalse
.
- props.gtk_cursor_theme_name: str
Name of the cursor theme to use.
Use
None
to use the default theme.
- props.gtk_decoration_layout: str
Determines which buttons should be put in the titlebar of client-side decorated windows, and whether they should be placed on the left or 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.
- props.gtk_dialogs_use_header: bool
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.
- props.gtk_double_click_distance: int
The maximum distance allowed between two clicks for them to be considered a double click, in pixels.
- props.gtk_double_click_time: int
The maximum time to allow between two clicks for them to be considered a double click, in milliseconds.
- props.gtk_enable_accels: bool
Whether menu items should have visible accelerators which can be activated.
- props.gtk_enable_event_sounds: bool
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.
- props.gtk_enable_input_feedback_sounds: bool
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.
- props.gtk_enable_primary_paste: bool
Whether a middle click on a mouse should paste the ‘PRIMARY’ clipboard content at the cursor location.
- props.gtk_entry_password_hint_timeout: int
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.
- props.gtk_entry_select_on_focus: bool
Whether to select the contents of an entry when it is focused.
- props.gtk_error_bell: bool
When
True
, keyboard navigation and other input-related errors will cause a beep.Since the error bell is implemented using
beep()
, the windowing system may offer ways to configure the error bell in many ways, such as flashing the window or similar visual effects.
- props.gtk_font_name: str
The default font to use.
GTK uses the family name and size from this string.
- props.gtk_hint_font_metrics: bool
Whether hinting should be applied to font metrics.
Note that this also turns off subpixel positioning of glyphs, since it conflicts with metrics hinting.
Added in version 4.6.
- props.gtk_icon_theme_name: str
Name of the icon theme to use.
See
IconTheme
for details about how GTK handles icon themes.
- props.gtk_im_module: str
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
IMContext
.
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.
- props.gtk_label_select_on_focus: bool
Whether to select the contents of a selectable label when it is focused.
- props.gtk_long_press_time: int
The time for a button or touch press to be considered a “long press”.
See
GestureLongPress
.
- props.gtk_overlay_scrolling: bool
Whether scrolled windows may use overlaid scrolling indicators.
If this is set to
False
, scrolled windows will have permanent scrollbars.
- props.gtk_primary_button_warps_slider: bool
If the value of this setting is
True
, clicking the primary button in aGtkRange
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 clicking the middle mouse button.
- props.gtk_print_backends: str
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”.
- props.gtk_print_preview_command: str
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 byto_file
.The preview application is responsible for removing the pdf file and the print settings file when it is done.
- props.gtk_recent_files_enabled: bool
Whether GTK should keep track of items inside the recently used resources list.
If set to
False
, the list will always be empty.
- props.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.
Set to
True
if the desktop environment is displaying the app menu,False
if the app should display it itself.
- props.gtk_shell_shows_desktop: bool
Set to
True
if the desktop environment is displaying the desktop folder,False
if not.
Set to
True
if the desktop environment is displaying the menubar,False
if the app should display it itself.
- props.gtk_show_status_shapes: bool
When
True
, widgets like switches include shapes to indicate their on/off state.Added in version 4.14.
- props.gtk_sound_theme_name: str
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.
- props.gtk_split_cursor: bool
Whether two cursors should be displayed for mixed left-to-right and right-to-left text.
- props.gtk_theme_name: str
Name of the theme to load.
See
CssProvider
for details about how GTK finds the CSS stylesheet for a theme.
- props.gtk_titlebar_double_click: str
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.
- props.gtk_titlebar_middle_click: str
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.
- props.gtk_titlebar_right_click: str
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.
- props.gtk_xft_antialias: int
Whether to antialias fonts.
The values are 0 for no, 1 for yes, or -1 for the system default.
- props.gtk_xft_hinting: int
Whether to enable font hinting.
The values are 0 for no, 1 for yes, or -1 for the system default.