code
stringlengths 2.5k
150k
| kind
stringclasses 1
value |
---|---|
http Feature-Policy: encrypted-media Feature-Policy: encrypted-media
===============================
Feature-Policy: encrypted-media
===============================
**Experimental:** **This is an [experimental technology](https://developer.mozilla.org/en-US/docs/MDN/Writing_guidelines/Experimental_deprecated_obsolete#experimental)**
Check the [Browser compatibility table](#browser_compatibility) carefully before using this in production.
The HTTP [`Feature-Policy`](../feature-policy) header `encrypted-media` directive controls whether the current document is allowed to use the [Encrypted Media Extensions](https://developer.mozilla.org/en-US/docs/Web/API/Encrypted_Media_Extensions_API) API (EME). When this policy is enabled, the [`Promise`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise) returned by [`Navigator.requestMediaKeySystemAccess()`](https://developer.mozilla.org/en-US/docs/Web/API/Navigator/requestMediaKeySystemAccess) will reject with a [`DOMException`](https://developer.mozilla.org/en-US/docs/Web/API/DOMException).
Syntax
------
```
Feature-Policy: encrypted-media <allowlist>;
```
<allowlist> A list of origins for which the feature is allowed. See [`Feature-Policy`](../feature-policy#syntax).
Default policy
--------------
Default allow list for `encrypted-media` is `'self'`.
Specifications
--------------
| Specification |
| --- |
| [Encrypted Media Extensions # permissions-policy-integration](https://w3c.github.io/encrypted-media/#permissions-policy-integration) |
Browser compatibility
---------------------
| | Desktop | Mobile |
| --- | --- | --- |
| | Chrome | Edge | Firefox | Internet Explorer | Opera | Safari | WebView Android | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet |
| `encrypted-media` | 60 | 79 | 74 | No | 48 | No | 60 | 60 | No | 45 | No | 8.0 |
See also
--------
* [`Feature-Policy`](../feature-policy) header
* [Feature Policy](../../feature_policy)
* [Using Feature Policy](../../feature_policy/using_feature_policy)
http Feature-Policy: midi Feature-Policy: midi
====================
Feature-Policy: midi
====================
**Experimental:** **This is an [experimental technology](https://developer.mozilla.org/en-US/docs/MDN/Writing_guidelines/Experimental_deprecated_obsolete#experimental)**
Check the [Browser compatibility table](#browser_compatibility) carefully before using this in production.
The HTTP [`Feature-Policy`](../feature-policy) header `midi` directive controls whether the current document is allowed to use the [Web MIDI API](https://developer.mozilla.org/en-US/docs/Web/API/Web_MIDI_API). When this policy is enabled, the [`Promise`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise) returned by [`Navigator.requestMIDIAccess()`](https://developer.mozilla.org/en-US/docs/Web/API/Navigator/requestMIDIAccess) will reject with a `DOMException`.
Syntax
------
```
Feature-Policy: midi <allowlist>;
```
<allowlist> A list of origins for which the feature is allowed. See [`Feature-Policy`](../feature-policy#syntax).
Default policy
--------------
The allow list is `'self'`.
Specifications
--------------
| Specification |
| --- |
| [Web MIDI API # permissions-policy-integration](https://webaudio.github.io/web-midi-api/#permissions-policy-integration) |
Browser compatibility
---------------------
| | Desktop | Mobile |
| --- | --- | --- |
| | Chrome | Edge | Firefox | Internet Explorer | Opera | Safari | WebView Android | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet |
| `midi` | 60 | 79 | 74 | No | 47 | No | 60 | 60 | No | 44 | No | 8.0 |
See also
--------
* [`Feature-Policy`](../feature-policy) header
* [Feature Policy](../../feature_policy)
* [Using Feature Policy](../../feature_policy/using_feature_policy)
http Feature-Policy: display-capture Feature-Policy: display-capture
===============================
Feature-Policy: display-capture
===============================
The HTTP [`Feature-Policy`](../feature-policy) header `display-capture` directive controls whether or not the document is permitted to use [Screen Capture API](https://developer.mozilla.org/en-US/docs/Web/API/Screen_Capture_API), that is, [`getDisplayMedia()`](https://developer.mozilla.org/en-US/docs/Web/API/MediaDevices/getDisplayMedia) to capture the screen's contents.
If `display-capture` is disabled in a document, the document will not be able to initiate screen capture via [`getDisplayMedia()`](https://developer.mozilla.org/en-US/docs/Web/API/MediaDevices/getDisplayMedia).
Syntax
------
```
Feature-Policy: display-capture <allowlist>;
```
<allowlist> A list of origins for which the feature is allowed. See [`Feature-Policy`](../feature-policy#syntax).
Default policy
--------------
Default allow list for `display-capture` is `'self'`.
Specifications
--------------
| Specification |
| --- |
| [Screen Capture # permissions-policy-integration](https://w3c.github.io/mediacapture-screen-share/#permissions-policy-integration) |
Browser compatibility
---------------------
| | Desktop | Mobile |
| --- | --- | --- |
| | Chrome | Edge | Firefox | Internet Explorer | Opera | Safari | WebView Android | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet |
| `display-capture` | 94 | 94 | 74
Only supported through the `allow` attribute on `<iframe>` elements. | No | 80 | 13
Only supported through the `allow` attribute on `<iframe>` elements. | No | No | No | No | No | No |
See also
--------
* [`Feature-Policy`](../feature-policy) header
* [Feature Policy](../../feature_policy)
* [Using Feature Policy](../../feature_policy/using_feature_policy)
* [Screen Capture API](https://developer.mozilla.org/en-US/docs/Web/API/Screen_Capture_API)
* [Using the Screen Capture API](https://developer.mozilla.org/en-US/docs/Web/API/Screen_Capture_API/Using_Screen_Capture)
http Feature-Policy: document-domain Feature-Policy: document-domain
===============================
Feature-Policy: document-domain
===============================
**Experimental:** **This is an [experimental technology](https://developer.mozilla.org/en-US/docs/MDN/Writing_guidelines/Experimental_deprecated_obsolete#experimental)**
Check the [Browser compatibility table](#browser_compatibility) carefully before using this in production.
The HTTP [`Feature-Policy`](../feature-policy) header `document-domain` directive controls whether the current document is allowed to set [`document.domain`](https://developer.mozilla.org/en-US/docs/Web/API/Document/domain). When this policy is disabled, attempting to set [`document.domain`](https://developer.mozilla.org/en-US/docs/Web/API/Document/domain) will fail and cause a `SecurityError` [`DOMException`](https://developer.mozilla.org/en-US/docs/Web/API/DOMException) to be thrown.
Syntax
------
```
Feature-Policy: document-domain <allowlist>;
```
<allowlist> A list of origins for which the feature is allowed. See [`Feature-Policy`](../feature-policy#syntax).
Default policy
--------------
Default allow list for `document-domain` is `*`.
Specifications
--------------
| Specification |
| --- |
| [HTML Standard # document-domain-feature](https://html.spec.whatwg.org/multipage/infrastructure.html#document-domain-feature) |
Browser compatibility
---------------------
| | Desktop | Mobile |
| --- | --- | --- |
| | Chrome | Edge | Firefox | Internet Explorer | Opera | Safari | WebView Android | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet |
| `document-domain` | 77 | 79 | 74 | No | 64 | No | No | No | No | No | No | No |
See also
--------
* [`Feature-Policy`](../feature-policy) header
* [Feature Policy](../../feature_policy)
* [Using Feature Policy](../../feature_policy/using_feature_policy)
http Feature-Policy: unsized-media Feature-Policy: unsized-media
=============================
Feature-Policy: unsized-media
=============================
**Experimental:** **This is an [experimental technology](https://developer.mozilla.org/en-US/docs/MDN/Writing_guidelines/Experimental_deprecated_obsolete#experimental)**
Check the [Browser compatibility table](#browser_compatibility) carefully before using this in production.
**Non-standard:** This feature is non-standard and is not on a standards track. Do not use it on production sites facing the Web: it will not work for every user. There may also be large incompatibilities between implementations and the behavior may change in the future.
The HTTP [`Feature-Policy`](../feature-policy) header `unsized-media` directive controls whether the current document is allowed to change the size of media elements after the initial layout is complete.
This restriction solves "layout instability" problem caused by providing default dimensions for images whose size is not specified in advance so that image doesn't change size after loading.
Syntax
------
```
Feature-Policy: unsized-media <allowlist>;
```
<allowlist> A list of origins for which the feature is allowed. See [`Feature-Policy`](../feature-policy#syntax).
Default value
-------------
The default value for unsized-media is `'*'`, that is unsized media elements are allowed for all origins by default. The page will re-flow every time an image with unknown dimensions is loaded.
Browser compatibility
---------------------
| | Desktop | Mobile |
| --- | --- | --- |
| | Chrome | Edge | Firefox | Internet Explorer | Opera | Safari | WebView Android | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet |
| `unsized-media` | No | No | No | No | No | No | No | No | No | No | No | No |
See also
--------
* [`Feature-Policy`](../feature-policy) header
* [Feature Policy](../../feature_policy)
* [Using Feature Policy](../../feature_policy/using_feature_policy)
* [Proposal](https://github.com/w3c/webappsec-permissions-policy/blob/main/policies/unsized-media.md)
http Feature-Policy: sync-xhr Feature-Policy: sync-xhr
========================
Feature-Policy: sync-xhr
========================
**Experimental:** **This is an [experimental technology](https://developer.mozilla.org/en-US/docs/MDN/Writing_guidelines/Experimental_deprecated_obsolete#experimental)**
Check the [Browser compatibility table](#browser_compatibility) carefully before using this in production.
**Non-standard:** This feature is non-standard and is not on a standards track. Do not use it on production sites facing the Web: it will not work for every user. There may also be large incompatibilities between implementations and the behavior may change in the future.
The HTTP [`Feature-Policy`](../feature-policy) header `sync-xhr` directive controls whether the current document is allowed to make synchronous [`XMLHttpRequest`](https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest) requests.
Syntax
------
```
Feature-Policy: sync-xhr <allowlist>;
```
<allowlist> A list of origins for which the feature is allowed. See [`Feature-Policy`](../feature-policy#syntax).
Default policy
--------------
By default the policy is set to `*`, which means synchronous requests are allowed in all frames.
Browser compatibility
---------------------
| | Desktop | Mobile |
| --- | --- | --- |
| | Chrome | Edge | Firefox | Internet Explorer | Opera | Safari | WebView Android | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet |
| `sync-xhr` | 65 | 79 | No | No | 52 | No | 65 | 65 | No | 47 | No | 9.0 |
See also
--------
* [Feature Policy](../../feature_policy)
* [Using Feature Policy](../../feature_policy/using_feature_policy)
http Feature-Policy: speaker-selection Feature-Policy: speaker-selection
=================================
Feature-Policy: speaker-selection
=================================
**Experimental:** **This is an [experimental technology](https://developer.mozilla.org/en-US/docs/MDN/Writing_guidelines/Experimental_deprecated_obsolete#experimental)**
Check the [Browser compatibility table](#browser_compatibility) carefully before using this in production.
The HTTP [`Feature-Policy`](../feature-policy) header `speaker-selection` directive controls whether the current document is allowed to enumerate and select audio output devices (speakers, headphones, etc.).
When this policy is enabled and the permission is denied:
* [`MediaDevices.enumerateDevices()`](https://developer.mozilla.org/en-US/docs/Web/API/MediaDevices/enumerateDevices) won't return devices of type *audio output*.
* [`MediaDevices.selectAudioOutput()`](https://developer.mozilla.org/en-US/docs/Web/API/MediaDevices/selectAudioOutput) won't display the popup for selecting an audio output, and will reject the promise with a `NotAllowedError`.
* [`HTMLMediaElement.setSinkId()`](https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement/setSinkId) will throw a `NotAllowedError` if called for an audio output.
Syntax
------
```
Feature-Policy: speaker-selection <allowlist>;
```
`<allowlist>` A list of origins for which the feature is allowed. See [`Feature-Policy`](../feature-policy#syntax).
Default policy
--------------
The default allowlist for `speaker-selection` is `'self'`.
Specifications
--------------
| Specification |
| --- |
| [Audio Output Devices API # permissions-policy-integration](https://w3c.github.io/mediacapture-output/#permissions-policy-integration) |
Browser compatibility
---------------------
| | Desktop | Mobile |
| --- | --- | --- |
| | Chrome | Edge | Firefox | Internet Explorer | Opera | Safari | WebView Android | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet |
| `speaker-selection` | No | No | 92
Only supported through the `allow` attribute on `<iframe>` elements. | No | No | No | No | No | No | No | No | No |
See also
--------
* [`Feature-Policy`](../feature-policy) header
* [Feature Policy](../../feature_policy)
* [Using Feature Policy](../../feature_policy/using_feature_policy)
http Feature-Policy: battery Feature-Policy: battery
=======================
Feature-Policy: battery
=======================
**Experimental:** **This is an [experimental technology](https://developer.mozilla.org/en-US/docs/MDN/Writing_guidelines/Experimental_deprecated_obsolete#experimental)**
Check the [Browser compatibility table](#browser_compatibility) carefully before using this in production.
The HTTP [`Feature-Policy`](../feature-policy) header `battery` directive controls whether the current document is allowed to gather information about the battery of the device through the [`BatteryManager`](https://developer.mozilla.org/en-US/docs/Web/API/BatteryManager) interface obtained via [`Navigator.getBattery()`](https://developer.mozilla.org/en-US/docs/Web/API/Navigator/getBattery).
Syntax
------
```
Feature-Policy: battery <allowlist>;
```
<allowlist> A list of origins for which the feature is allowed. See [`Feature-Policy`](../feature-policy#syntax).
Default policy
--------------
Default allow list for `battery` is `'self'`.
Specifications
--------------
| Specification |
| --- |
| [Battery Status API # permissions-policy-integration](https://w3c.github.io/battery/#permissions-policy-integration) |
Browser compatibility
---------------------
| | Desktop | Mobile |
| --- | --- | --- |
| | Chrome | Edge | Firefox | Internet Explorer | Opera | Safari | WebView Android | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet |
| `battery` | No
Will be implemented, see [bug 1007264](https://crbug.com/1007264). | No
Will be implemented, see [bug 1007264](https://crbug.com/1007264). | No | No | No
Will be implemented, see [bug 1007264](https://crbug.com/1007264). | No | No
Will be implemented, see [bug 1007264](https://crbug.com/1007264). | No
Will be implemented, see [bug 1007264](https://crbug.com/1007264). | No | No
Will be implemented, see [bug 1007264](https://crbug.com/1007264). | No | No
Will be implemented, see [bug 1007264](https://crbug.com/1007264). |
See also
--------
* [`Feature-Policy`](../feature-policy) header
* [Feature Policy](../../feature_policy)
* [Using Feature Policy](../../feature_policy/using_feature_policy)
* [Battery Status API](https://developer.mozilla.org/en-US/docs/Web/API/Battery_Status_API)
* [`Navigator.getBattery()`](https://developer.mozilla.org/en-US/docs/Web/API/Navigator/getBattery)
* [`BatteryManager`](https://developer.mozilla.org/en-US/docs/Web/API/BatteryManager)
http Feature-Policy: oversized-images Feature-Policy: oversized-images
================================
Feature-Policy: oversized-images
================================
**Experimental:** **This is an [experimental technology](https://developer.mozilla.org/en-US/docs/MDN/Writing_guidelines/Experimental_deprecated_obsolete#experimental)**
Check the [Browser compatibility table](#browser_compatibility) carefully before using this in production.
**Non-standard:** This feature is non-standard and is not on a standards track. Do not use it on production sites facing the Web: it will not work for every user. There may also be large incompatibilities between implementations and the behavior may change in the future.
The HTTP [`Feature-Policy`](../feature-policy) header `oversized-images` directive controls whether the current document is allowed to download and display large images.
Syntax
------
```
Feature-Policy: oversized-images <allowlist>;
```
<allowlist> A list of origins for which the feature is allowed. See [`Feature-Policy`](../feature-policy#syntax).
Default value
-------------
The default value is `'*'`.
Browser compatibility
---------------------
| | Desktop | Mobile |
| --- | --- | --- |
| | Chrome | Edge | Firefox | Internet Explorer | Opera | Safari | WebView Android | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet |
| `oversized-images` | No | No | No | No | No | No | No | No | No | No | No | No |
See also
--------
* [`Feature-Policy`](../feature-policy) header
* [Feature Policy](../../feature_policy)
* [Using Feature Policy](../../feature_policy/using_feature_policy)
http Feature-Policy: unoptimized-images Feature-Policy: unoptimized-images
==================================
Feature-Policy: unoptimized-images
==================================
**Experimental:** **This is an [experimental technology](https://developer.mozilla.org/en-US/docs/MDN/Writing_guidelines/Experimental_deprecated_obsolete#experimental)**
Check the [Browser compatibility table](#browser_compatibility) carefully before using this in production.
**Non-standard:** This feature is non-standard and is not on a standards track. Do not use it on production sites facing the Web: it will not work for every user. There may also be large incompatibilities between implementations and the behavior may change in the future.
The HTTP [`Feature-Policy`](../feature-policy) header `unoptimized-images` directive controls whether the current document is allowed to download and display unoptimized images.
Syntax
------
```
Feature-Policy: unoptimized-images <allowlist>;
```
<allowlist> A list of origins for which the feature is allowed. See [`Feature-Policy`](../feature-policy#syntax).
Default policy
--------------
Default allow list for `unoptimized-images` is `'self'`.
Browser compatibility
---------------------
| | Desktop | Mobile |
| --- | --- | --- |
| | Chrome | Edge | Firefox | Internet Explorer | Opera | Safari | WebView Android | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet |
| `unoptimized-images` | No | No | No | No | No | No | No | No | No | No | No | No |
See also
--------
* [`Feature-Policy`](../feature-policy) header
* [Feature Policy](../../feature_policy)
* [Using Feature Policy](../../feature_policy/using_feature_policy)
| programming_docs |
http Feature-Policy: gamepad Feature-Policy: gamepad
=======================
Feature-Policy: gamepad
=======================
**Experimental:** **This is an [experimental technology](https://developer.mozilla.org/en-US/docs/MDN/Writing_guidelines/Experimental_deprecated_obsolete#experimental)**
Check the [Browser compatibility table](#browser_compatibility) carefully before using this in production.
The HTTP [`Feature-Policy`](../feature-policy) header `gamepad` directive controls whether the current document is allowed to use the [Gamepad API](https://developer.mozilla.org/en-US/docs/Web/API/Gamepad_API). When this policy is disabled, calls to [`Navigator.getGamepads()`](https://developer.mozilla.org/en-US/docs/Web/API/Navigator/getGamepads) will throw a `SecurityError` [`DOMException`](https://developer.mozilla.org/en-US/docs/Web/API/DOMException). In addition, the [`gamepadconnected`](https://developer.mozilla.org/en-US/docs/Web/API/Window/gamepadconnected_event) and [`gamepaddisconnected`](https://developer.mozilla.org/en-US/docs/Web/API/Window/gamepaddisconnected_event) events will not fire.
Syntax
------
```
Feature-Policy: gamepad <allowlist>;
```
<allowlist> A list of origins for which the feature is allowed. See [`Feature-Policy`](../feature-policy#syntax).
Default policy
--------------
Default allow list for `gamepad` is `'self'`.
Examples
--------
### General example
SecureCorp Inc. wants to disable the Gamepad API within all browsing contexts except for its own origin and those whose origin is `https://example.com`. It can do so by delivering the following HTTP response header to define a feature policy:
```
Feature-Policy: gamepad 'self' https://example.com
```
### With an <iframe> element
FastCorp Inc. wants to disable `gamepad` for all cross-origin child frames, except for a specific <iframe>. It can do so by delivering the following HTTP response header to define a feature policy:
```
Feature-Policy: gamepad 'self'
```
Then include an [allow](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/iframe#attributes) attribute on the `<iframe>` element:
```
<iframe src="https://other.com/game" allow="gamepad"></iframe>
```
iframe attributes can selectively enable features in certain frames, and not in others, even if those frames contain documents from the same origin.
Specifications
--------------
| Specification |
| --- |
| [Gamepad # permission-policy](https://w3c.github.io/gamepad/#permission-policy) |
Browser compatibility
---------------------
| | Desktop | Mobile |
| --- | --- | --- |
| | Chrome | Edge | Firefox | Internet Explorer | Opera | Safari | WebView Android | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet |
| `gamepad` | 86 | 86 | 91
["Only supported through the `allow` attribute on `<iframe>` elements.", "The default allowlist is `*` instead of `self` (as required by the specification)."] | No | 72 | No | No | 86 | 91
["Only supported through the `allow` attribute on `<iframe>` elements.", "The default allowlist is `*` instead of `self` (as required by the specification)."] | No | No | No |
See also
--------
* [`Feature-Policy`](../feature-policy) header
* [Feature Policy](../../feature_policy)
* [Using Feature Policy](../../feature_policy/using_feature_policy)
http Feature-Policy: payment Feature-Policy: payment
=======================
Feature-Policy: payment
=======================
**Experimental:** **This is an [experimental technology](https://developer.mozilla.org/en-US/docs/MDN/Writing_guidelines/Experimental_deprecated_obsolete#experimental)**
Check the [Browser compatibility table](#browser_compatibility) carefully before using this in production.
The HTTP [`Feature-Policy`](../feature-policy) header field's `payment` directive controls whether the current document is allowed to use the [Payment Request API](https://developer.mozilla.org/en-US/docs/Web/API/Payment_Request_API). When this policy is disabled, the [`PaymentRequest()`](https://developer.mozilla.org/en-US/docs/Web/API/PaymentRequest) constructor will throw a `SyntaxError` [`DOMException`](https://developer.mozilla.org/en-US/docs/Web/API/DOMException).
Syntax
------
```
Feature-Policy: payment <allowlist>;
```
<allowlist> A list of origins for which the feature is allowed. See [`Feature-Policy`](../feature-policy#syntax).
Default policy
--------------
The `payment` feature's default allowlist value is `'self'`.
Specifications
--------------
| Specification |
| --- |
| [Payment Request API 1.1 # permissions-policy](https://w3c.github.io/payment-request/#permissions-policy) |
Browser compatibility
---------------------
| | Desktop | Mobile |
| --- | --- | --- |
| | Chrome | Edge | Firefox | Internet Explorer | Opera | Safari | WebView Android | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet |
| `payment` | 60 | 79 | 74 | No | 47 | No | 60 | 60 | No | 44 | No | 8.0 |
See also
--------
* [`Feature-Policy`](../feature-policy) header field
* [Feature Policy](../../feature_policy)
* [Using Feature Policy](../../feature_policy/using_feature_policy)
http Feature-Policy: microphone Feature-Policy: microphone
==========================
Feature-Policy: microphone
==========================
The HTTP [`Feature-Policy`](../feature-policy) header `microphone` directive controls whether the current document is allowed to use audio input devices. When this policy is enabled, the [`Promise`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise) returned by [`MediaDevices.getUserMedia()`](https://developer.mozilla.org/en-US/docs/Web/API/MediaDevices/getUserMedia) will reject with a `NotAllowedError`.
Syntax
------
```
Feature-Policy: microphone <allowlist>;
```
<allowlist> A list of origins for which the feature is allowed. See [`Feature-Policy`](../feature-policy#syntax).
Default policy
--------------
Default allow list for `microphone` is `'self'`.
Specifications
--------------
| Specification |
| --- |
| [Media Capture and Streams # dfn-microphone](https://w3c.github.io/mediacapture-main/#dfn-microphone) |
Browser compatibility
---------------------
| | Desktop | Mobile |
| --- | --- | --- |
| | Chrome | Edge | Firefox | Internet Explorer | Opera | Safari | WebView Android | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet |
| `microphone` | 60 | 79 | 74
Only supported through the `allow` attribute on `<iframe>` elements. | No | 48 | 11.1 | 60 | 60 | 79
Only supported through the `allow` attribute on `<iframe>` elements. | 45 | 11.3 | 8.0 |
See also
--------
* [`Feature-Policy`](../feature-policy) header
* [Feature Policy](../../feature_policy)
* [Using Feature Policy](../../feature_policy/using_feature_policy)
http Feature-Policy: gyroscope Feature-Policy: gyroscope
=========================
Feature-Policy: gyroscope
=========================
**Experimental:** **This is an [experimental technology](https://developer.mozilla.org/en-US/docs/MDN/Writing_guidelines/Experimental_deprecated_obsolete#experimental)**
Check the [Browser compatibility table](#browser_compatibility) carefully before using this in production.
The HTTP [`Feature-Policy`](../feature-policy) header `gyroscope` directive controls whether the current document is allowed to gather information about the orientation of the device through the [`Gyroscope`](https://developer.mozilla.org/en-US/docs/Web/API/Gyroscope) interface.
Syntax
------
```
Feature-Policy: gyroscope <allowlist>;
```
<allowlist> A list of origins for which the feature is allowed. See [`Feature-Policy`](../feature-policy#syntax).
Default policy
--------------
Default allow list for `gyroscope` is `'self'`.
Specifications
--------------
| Specification |
| --- |
| [Gyroscope # ref-for-policy-controlled-feature](https://w3c.github.io/gyroscope/#ref-for-policy-controlled-feature) |
Browser compatibility
---------------------
| | Desktop | Mobile |
| --- | --- | --- |
| | Chrome | Edge | Firefox | Internet Explorer | Opera | Safari | WebView Android | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet |
| `gyroscope` | 67 | 79 | No | No | 54 | No | 67 | 67 | No | 48 | No | 9.0 |
See also
--------
* [`Feature-Policy`](../feature-policy) header
* [Feature Policy](../../feature_policy)
* [Using Feature Policy](../../feature_policy/using_feature_policy)
http Feature-Policy: publickey-credentials-get Feature-Policy: publickey-credentials-get
=========================================
Feature-Policy: publickey-credentials-get
=========================================
**Experimental:** **This is an [experimental technology](https://developer.mozilla.org/en-US/docs/MDN/Writing_guidelines/Experimental_deprecated_obsolete#experimental)**
Check the [Browser compatibility table](#browser_compatibility) carefully before using this in production.
The HTTP [`Feature-Policy`](../feature-policy) header `publickey-credentials-get` directive controls whether the current document is allowed to access the [Web Authentication API](https://developer.mozilla.org/en-US/docs/Web/API/Web_Authentication_API) to retrieve public-key credentials; i.e., via [`navigator.credentials.get({publicKey: ..., ...})`](https://developer.mozilla.org/en-US/docs/Web/API/CredentialsContainer/get).
When this policy is enabled, any attempt to query public key credentials will result in an error.
Syntax
------
```
Feature-Policy: publickey-credentials-get <allowlist>;
```
<allowlist> A list of origins for which the feature is allowed. See [`Feature-Policy`](../feature-policy#syntax).
Default policy
--------------
The default allowlist is `'self'`.
Specifications
--------------
| Specification |
| --- |
| [Web Authentication: An API for accessing Public Key Credentials - Level 3 # sctn-permissions-policy](https://w3c.github.io/webauthn/#sctn-permissions-policy) |
Browser compatibility
---------------------
| | Desktop | Mobile |
| --- | --- | --- |
| | Chrome | Edge | Firefox | Internet Explorer | Opera | Safari | WebView Android | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet |
| `publickey-credentials-get` | 84 | 84 | No | No | No | No | 84 | 84 | No | No | No | 14.0 |
See also
--------
* [`Feature-Policy`](../feature-policy) header
* [Feature Policy](../../feature_policy)
* [Using Feature Policy](../../feature_policy/using_feature_policy)
* [Web Authentication API](https://developer.mozilla.org/en-US/docs/Web/API/Web_Authentication_API)
* [`PublicKeyCredential`](https://developer.mozilla.org/en-US/docs/Web/API/PublicKeyCredential) interface
http Feature-Policy: picture-in-picture Feature-Policy: picture-in-picture
==================================
Feature-Policy: picture-in-picture
==================================
**Experimental:** **This is an [experimental technology](https://developer.mozilla.org/en-US/docs/MDN/Writing_guidelines/Experimental_deprecated_obsolete#experimental)**
Check the [Browser compatibility table](#browser_compatibility) carefully before using this in production.
The HTTP [`Feature-Policy`](../feature-policy) header `picture-in-picture` directive controls whether the current document is allowed to play a video in a Picture-in-Picture mode via the corresponding API.
Syntax
------
```
Feature-Policy: picture-in-picture <allowlist>;
```
<allowlist> A list of origins for which the feature is allowed. See [`Feature-Policy`](../feature-policy#syntax).
Default policy
--------------
As of June 2019, the [spec draft](https://wicg.github.io/picture-in-picture/#feature-policy) and [Google Chrome](https://bugs.chromium.org/p/chromium/issues/detail?id=806249#c17) set default allow list to `*`.
Specifications
--------------
| Specification |
| --- |
| [Picture-in-Picture # feature-policy](https://w3c.github.io/picture-in-picture/#feature-policy) |
Browser compatibility
---------------------
| | Desktop | Mobile |
| --- | --- | --- |
| | Chrome | Edge | Firefox | Internet Explorer | Opera | Safari | WebView Android | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet |
| `picture-in-picture` | 71 | No | No | No | No | No | No | No | No | No | No | No |
See also
--------
* [`Feature-Policy`](../feature-policy) header
* [Feature Policy](../../feature_policy)
* [Using Feature Policy](../../feature_policy/using_feature_policy)
http Feature-Policy: fullscreen Feature-Policy: fullscreen
==========================
Feature-Policy: fullscreen
==========================
The HTTP [`Feature-Policy`](../feature-policy) header `fullscreen` directive controls whether the current document is allowed to use [`Element.requestFullscreen()`](https://developer.mozilla.org/en-US/docs/Web/API/Element/requestFullscreen). When this policy is enabled, the returned [`Promise`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise) rejects with a [`TypeError`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypeError).
By default, top-level documents and their same-origin child frames can request and enter fullscreen mode. This directive allows or prevents cross-origin frames from using fullscreen mode. This includes same-origin frames.
**Note:** If both this directive (i.e. via the `allow` attribute) and the `allowfullscreen` attribute are present on an `<iframe>` element, this directive takes precedence. There was a bug whereby the `fullscreen` directive didn't work unless the `allowfullscreen` attribute was also present, but this has been fixed as of Firefox 80 ([bug 1608358](https://bugzilla.mozilla.org/show_bug.cgi?id=1608358)).
Syntax
------
```
Feature-Policy: fullscreen <allowlist>;
```
<allowlist> A list of origins for which the feature is allowed. See [`Feature-Policy`](../feature-policy#syntax).
Default policy
--------------
Default allow list for `fullscreen` is `'self'`.
Examples
--------
### General example
SecureCorp Inc. wants to disable the Fullscreen API within all browsing contexts except for its own origin and those whose origin is `https://example.com`. It can do so by delivering the following HTTP response header to define a feature policy:
```
Feature-Policy: fullscreen 'self' https://example.com
```
### With an <iframe> element
FastCorp Inc. wants to disable `fullscreen` for all cross-origin child frames, except for a specific <iframe>. It can do so by delivering the following HTTP response header to define a feature policy:
```
Feature-Policy: fullscreen 'self'
```
Then include an [allow](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/iframe#attributes) attribute on the `<iframe>` element:
```
<iframe src="https://other.com/videoplayer" allow="fullscreen"></iframe>
```
iframe attributes can selectively enable features in certain frames, and not in others, even if those frames contain documents from the same origin.
Specifications
--------------
| Specification |
| --- |
| [Fullscreen API Standard # permissions-policy-integration](https://fullscreen.spec.whatwg.org/#permissions-policy-integration) |
Browser compatibility
---------------------
| | Desktop | Mobile |
| --- | --- | --- |
| | Chrome | Edge | Firefox | Internet Explorer | Opera | Safari | WebView Android | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet |
| `fullscreen` | 62 | 79 | 74
["Only supported through the `allow` attribute on `<iframe>` elements.", "Before Firefox 80, applying `fullscreen` to an `<iframe>` (i.e. via the `allow` attribute) does not work unless the `allowfullscreen` attribute is also present."] | No | 49 | No | 62 | 62 | 79
["Only supported through the `allow` attribute on `<iframe>` elements.", "Before Firefox 80, applying `fullscreen` to an `<iframe>` (i.e. via the `allow` attribute) does not work unless the `allowfullscreen` attribute is also present."] | 46 | No | 8.0 |
See also
--------
* [`Feature-Policy`](../feature-policy) header
* [Feature Policy](../../feature_policy)
* [Using Feature Policy](../../feature_policy/using_feature_policy)
http Feature-Policy: legacy-image-formats Feature-Policy: legacy-image-formats
====================================
Feature-Policy: legacy-image-formats
====================================
**Experimental:** **This is an [experimental technology](https://developer.mozilla.org/en-US/docs/MDN/Writing_guidelines/Experimental_deprecated_obsolete#experimental)**
Check the [Browser compatibility table](#browser_compatibility) carefully before using this in production.
**Non-standard:** This feature is non-standard and is not on a standards track. Do not use it on production sites facing the Web: it will not work for every user. There may also be large incompatibilities between implementations and the behavior may change in the future.
The HTTP [`Feature-Policy`](../feature-policy) header `legacy-image-formats` directive controls whether the current document is allowed to display images in legacy formats.
Syntax
------
```
Feature-Policy: legacy-image-formats <allowlist>;
```
<allowlist> A list of origins for which the feature is allowed. See [`Feature-Policy`](../feature-policy#syntax).
Default policy
--------------
Default allow list for `legacy-image-formats` is `'self'`.
Browser compatibility
---------------------
| | Desktop | Mobile |
| --- | --- | --- |
| | Chrome | Edge | Firefox | Internet Explorer | Opera | Safari | WebView Android | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet |
| `legacy-image-formats` | No | No | No | No | No | No | No | No | No | No | No | No |
See also
--------
* [`Feature-Policy`](../feature-policy) header
* [Feature Policy](../../feature_policy)
* [Using Feature Policy](../../feature_policy/using_feature_policy)
http Feature-Policy: ambient-light-sensor Feature-Policy: ambient-light-sensor
====================================
Feature-Policy: ambient-light-sensor
====================================
**Experimental:** **This is an [experimental technology](https://developer.mozilla.org/en-US/docs/MDN/Writing_guidelines/Experimental_deprecated_obsolete#experimental)**
Check the [Browser compatibility table](#browser_compatibility) carefully before using this in production.
The HTTP [`Feature-Policy`](../feature-policy) header `ambient-light-sensor` directive controls whether the current document is allowed to gather information about the amount of light in the environment around the device through the [`AmbientLightSensor`](https://developer.mozilla.org/en-US/docs/Web/API/AmbientLightSensor) interface.
Syntax
------
```
Feature-Policy: ambient-light-sensor <allowlist>;
```
<allowlist> A list of origins for which the feature is allowed. See [`Feature-Policy`](../feature-policy#syntax).
Default policy
--------------
Default allow list for `ambient-light-sensor` is `'self'`.
Specifications
--------------
| Specification |
| --- |
| [Ambient Light Sensor # ref-for-policy-controlled-feature](https://w3c.github.io/ambient-light/#ref-for-policy-controlled-feature) |
Browser compatibility
---------------------
| | Desktop | Mobile |
| --- | --- | --- |
| | Chrome | Edge | Firefox | Internet Explorer | Opera | Safari | WebView Android | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet |
| `ambient-light-sensor` | 67 | 79 | No | No | 54 | No | 67 | 67 | No | 48 | No | 9.0 |
See also
--------
* [`Feature-Policy`](../feature-policy) header
* [Feature Policy](../../feature_policy)
* [Using Feature Policy](../../feature_policy/using_feature_policy)
| programming_docs |
http Feature-Policy: accelerometer Feature-Policy: accelerometer
=============================
Feature-Policy: accelerometer
=============================
**Experimental:** **This is an [experimental technology](https://developer.mozilla.org/en-US/docs/MDN/Writing_guidelines/Experimental_deprecated_obsolete#experimental)**
Check the [Browser compatibility table](#browser_compatibility) carefully before using this in production.
The HTTP [`Feature-Policy`](../feature-policy) header `accelerometer` directive controls whether the current document is allowed to gather information about the acceleration of the device through the [`Accelerometer`](https://developer.mozilla.org/en-US/docs/Web/API/Accelerometer) interface.
Syntax
------
```
Feature-Policy: accelerometer <allowlist>;
```
<allowlist> A list of origins for which the feature is allowed. See [`Feature-Policy`](../feature-policy#syntax).
Default policy
--------------
The default `allowlist` value for this feature is: `'self'`.
Specifications
--------------
| Specification |
| --- |
| [Accelerometer # ref-for-policy-controlled-feature](https://w3c.github.io/accelerometer/#ref-for-policy-controlled-feature) |
Browser compatibility
---------------------
| | Desktop | Mobile |
| --- | --- | --- |
| | Chrome | Edge | Firefox | Internet Explorer | Opera | Safari | WebView Android | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet |
| `accelerometer` | 67 | 79 | No | No | 54 | No | 67 | 67 | No | 48 | No | 9.0 |
See also
--------
* [`Feature-Policy`](../feature-policy) header
* [Feature Policy](../../feature_policy)
* [Using Feature Policy](../../feature_policy/using_feature_policy)
http Feature-Policy: screen-wake-lock Feature-Policy: screen-wake-lock
================================
Feature-Policy: screen-wake-lock
================================
**Experimental:** **This is an [experimental technology](https://developer.mozilla.org/en-US/docs/MDN/Writing_guidelines/Experimental_deprecated_obsolete#experimental)**
Check the [Browser compatibility table](#browser_compatibility) carefully before using this in production.
The HTTP [`Feature-Policy`](../feature-policy) header `screen-wake-lock` directive controls whether the current document is allowed to use [Screen Wake Lock API](https://developer.mozilla.org/en-US/docs/Web/API/Screen_Wake_Lock_API) to indicate that device should not dim or turn off the screen.
**Note:** In earlier specification drafts this directive was called `wake-lock`.
Syntax
------
```
Feature-Policy: screen-wake-lock <allowlist>;
```
<allowlist> A list of origins for which the feature is allowed. See [`Feature-Policy`](../feature-policy#syntax).
Default policy
--------------
Default allow list for `screen-wake-lock` is `'self'`.
Specifications
--------------
| Specification |
| --- |
| [Screen Wake Lock API # policy-control](https://w3c.github.io/screen-wake-lock/#policy-control) |
Browser compatibility
---------------------
| | Desktop | Mobile |
| --- | --- | --- |
| | Chrome | Edge | Firefox | Internet Explorer | Opera | Safari | WebView Android | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet |
| `screen-wake-lock` | No | No | No | No | No | No | No | No | No | No | No | No |
See also
--------
* [Screen Wake Lock API](https://developer.mozilla.org/en-US/docs/Web/API/Screen_Wake_Lock_API)
* [`Feature-Policy`](../feature-policy) header
* [Feature Policy](../../feature_policy)
* [Using Feature Policy](../../feature_policy/using_feature_policy)
* [Default value of the allow list](https://www.w3.org/TR/screen-wake-lock/#wake-locks)
http Feature-Policy: geolocation Feature-Policy: geolocation
===========================
Feature-Policy: geolocation
===========================
The HTTP [`Feature-Policy`](../feature-policy) header `geolocation` directive controls whether the current document is allowed to use the [`Geolocation`](https://developer.mozilla.org/en-US/docs/Web/API/Geolocation) Interface. When this policy is enabled, calls to [`getCurrentPosition()`](https://developer.mozilla.org/en-US/docs/Web/API/Geolocation/getCurrentPosition) and [`watchPosition()`](https://developer.mozilla.org/en-US/docs/Web/API/Geolocation/watchPosition) will cause those functions' callbacks to be invoked with a [`GeolocationPositionError`](https://developer.mozilla.org/en-US/docs/Web/API/GeolocationPositionError) code of `PERMISSION_DENIED`.
By default, the Geolocation API can be used within top-level documents and their same-origin child frames. This directive allows or prevents cross-origin frames from accessing geolocation. This includes same-origin frames.
Syntax
------
```
Feature-Policy: geolocation <allowlist>;
```
<allowlist> A list of origins for which the feature is allowed. See [`Feature-Policy`](../feature-policy#syntax).
Default policy
--------------
Default allow list for `geolocation` is `'self'`.
Examples
--------
### General example
SecureCorp Inc. wants to disable the Geolocation API within all browsing contexts except for its own origin and those whose origin is `https://example.com`. It can do so by delivering the following HTTP response header to define a feature policy:
```
Feature-Policy: geolocation 'self' https://example.com
```
### With an <iframe> element
FastCorp Inc. wants to disable `geolocation` for all cross-origin child frames, except for a specific <iframe>. It can do so by delivering the following HTTP response header to define a feature policy:
```
Feature-Policy: geolocation 'self'
```
Then include an [allow](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/iframe#attributes) attribute on the `<iframe>` element:
```
<iframe src="https://other.com/map" allow="geolocation"></iframe>
```
Interestingly, `allow` attributes can selectively enable features in certain frames, and not in others, even if those frames contain documents from the same origin.
Specifications
--------------
| Specification |
| --- |
| [Geolocation API # dfn-geolocation](https://w3c.github.io/geolocation-api/#dfn-geolocation) |
Browser compatibility
---------------------
| | Desktop | Mobile |
| --- | --- | --- |
| | Chrome | Edge | Firefox | Internet Explorer | Opera | Safari | WebView Android | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet |
| `geolocation` | 60 | 79 | 74
Only supported through the `allow` attribute on `<iframe>` elements. | No | 47 | No | 60 | 60 | 79
Only supported through the `allow` attribute on `<iframe>` elements. | 44 | No | 8.0 |
See also
--------
* [`Feature-Policy`](../feature-policy) header
* [Feature Policy](../../feature_policy)
* [Using Feature Policy](../../feature_policy/using_feature_policy)
http Feature-Policy: layout-animations Feature-Policy: layout-animations
=================================
Feature-Policy: layout-animations
=================================
**Experimental:** **This is an [experimental technology](https://developer.mozilla.org/en-US/docs/MDN/Writing_guidelines/Experimental_deprecated_obsolete#experimental)**
Check the [Browser compatibility table](#browser_compatibility) carefully before using this in production.
**Non-standard:** This feature is non-standard and is not on a standards track. Do not use it on production sites facing the Web: it will not work for every user. There may also be large incompatibilities between implementations and the behavior may change in the future.
The HTTP [`Feature-Policy`](../feature-policy) header `layout-animations` directive controls whether the current document is allowed to show layout animations.
Syntax
------
```
Feature-Policy: layout-animations <allowlist>;
```
<allowlist> A list of origins for which the feature is allowed. See [`Feature-Policy`](../feature-policy#syntax).
Default policy
--------------
Default allow list for `layout-animations` is `'self'`.
Browser compatibility
---------------------
| | Desktop | Mobile |
| --- | --- | --- |
| | Chrome | Edge | Firefox | Internet Explorer | Opera | Safari | WebView Android | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet |
| `layout-animations` | No | No | No | No | No | No | No | No | No | No | No | No |
See also
--------
* [`Feature-Policy`](../feature-policy) header
* [Feature Policy](../../feature_policy)
* [Using Feature Policy](../../feature_policy/using_feature_policy)
http Feature-Policy: camera Feature-Policy: camera
======================
Feature-Policy: camera
======================
The HTTP [`Feature-Policy`](../feature-policy) header `camera` directive controls whether the current document is allowed to use video input devices. When this policy is enabled, the [`Promise`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise) returned by [`MediaDevices.getUserMedia()`](https://developer.mozilla.org/en-US/docs/Web/API/MediaDevices/getUserMedia) will reject with a `NotAllowedError` [`DOMException`](https://developer.mozilla.org/en-US/docs/Web/API/DOMException).
Syntax
------
```
Feature-Policy: camera <allowlist>;
```
<allowlist> A list of origins for which the feature is allowed. See [`Feature-Policy`](../feature-policy#syntax).
Default policy
--------------
Default allow list for `camera` is `'self'`.
Specifications
--------------
| Specification |
| --- |
| [Media Capture and Streams # dfn-camera](https://w3c.github.io/mediacapture-main/#dfn-camera) |
Browser compatibility
---------------------
| | Desktop | Mobile |
| --- | --- | --- |
| | Chrome | Edge | Firefox | Internet Explorer | Opera | Safari | WebView Android | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet |
| `camera` | 60 | 79 | 74
Only supported through the `allow` attribute on `<iframe>` elements. | No | 48 | 11.1 | 60 | 60 | 79
Only supported through the `allow` attribute on `<iframe>` elements. | 45 | 11.3 | 8.0 |
See also
--------
* [`Feature-Policy`](../feature-policy) header
* [Feature Policy](../../feature_policy)
* [Using Feature Policy](../../feature_policy/using_feature_policy)
http Feature-Policy: web-share Feature-Policy: web-share
=========================
Feature-Policy: web-share
=========================
**Experimental:** **This is an [experimental technology](https://developer.mozilla.org/en-US/docs/MDN/Writing_guidelines/Experimental_deprecated_obsolete#experimental)**
Check the [Browser compatibility table](#browser_compatibility) carefully before using this in production.
The HTTP [`Feature-Policy`](../feature-policy) header `web-share` directive controls whether the current document is allowed to use the [`Navigator.share()`](https://developer.mozilla.org/en-US/docs/Web/API/Navigator/share) method of the Web Share API to share text, links, images, and other content to arbitrary destinations of the user's choice.
Syntax
------
```
Feature-Policy: web-share <allowlist>;
```
<allowlist> A list of origins for which the feature is allowed. See [`Feature-Policy`](../feature-policy#syntax).
Default policy
--------------
The default value is `'self'`.
Specifications
--------------
| Specification |
| --- |
| [Web Share API # permissions-policy](https://w3c.github.io/web-share/#permissions-policy) |
Browser compatibility
---------------------
| | Desktop | Mobile |
| --- | --- | --- |
| | Chrome | Edge | Firefox | Internet Explorer | Opera | Safari | WebView Android | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet |
| `web-share` | No | No | 81
["Only supported through the `allow` attribute on `<iframe>` elements.", "Firefox recognizes the `web-share` permissions policy, but this has no effect in versions of Firefox that do not support the [`share()`](https://developer.mozilla.org/docs/Web/API/Navigator/share) method."] | No | No | No | No | No | 81
Only supported through the `allow` attribute on `<iframe>` elements. | No | No | No |
Browser implementation is being discussed in <https://github.com/w3c/web-share/issues/169>.
See also
--------
* [`Feature-Policy`](../feature-policy) header
* [Feature Policy](../../feature_policy)
* [Using Feature Policy](../../feature_policy/using_feature_policy)
http Feature-Policy: magnetometer Feature-Policy: magnetometer
============================
Feature-Policy: magnetometer
============================
**Experimental:** **This is an [experimental technology](https://developer.mozilla.org/en-US/docs/MDN/Writing_guidelines/Experimental_deprecated_obsolete#experimental)**
Check the [Browser compatibility table](#browser_compatibility) carefully before using this in production.
The HTTP [`Feature-Policy`](../feature-policy) header `magnetometer` directive controls whether the current document is allowed to gather information about the orientation of the device through the [`Magnetometer`](https://developer.mozilla.org/en-US/docs/Web/API/Magnetometer) interface.
Syntax
------
```
Feature-Policy: magnetometer <allowlist>;
```
<allowlist> A list of origins for which the feature is allowed. See [`Feature-Policy`](../feature-policy#syntax).
Default policy
--------------
Default allow list for `magnetometer` is `'self'`.
Specifications
--------------
| Specification |
| --- |
| [Magnetometer # ref-for-policy-controlled-feature](https://w3c.github.io/magnetometer/#ref-for-policy-controlled-feature) |
Browser compatibility
---------------------
| | Desktop | Mobile |
| --- | --- | --- |
| | Chrome | Edge | Firefox | Internet Explorer | Opera | Safari | WebView Android | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet |
| `magnetometer` | 67 | 79 | No | No | 54 | No | No | 67 | No | 48 | No | 9.0 |
See also
--------
* [`Feature-Policy`](../feature-policy) header
* [Feature Policy](../../feature_policy)
* [Using Feature Policy](../../feature_policy/using_feature_policy)
http Feature-Policy: autoplay Feature-Policy: autoplay
========================
Feature-Policy: autoplay
========================
**Experimental:** **This is an [experimental technology](https://developer.mozilla.org/en-US/docs/MDN/Writing_guidelines/Experimental_deprecated_obsolete#experimental)**
Check the [Browser compatibility table](#browser_compatibility) carefully before using this in production.
The HTTP [`Feature-Policy`](../feature-policy) header `autoplay` directive controls whether the current document is allowed to autoplay media requested through the [`HTMLMediaElement`](https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement) interface. When this policy is enabled and there were no user gestures, the [`Promise`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise) returned by [`HTMLMediaElement.play()`](https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement/play) will reject with a [`DOMException`](https://developer.mozilla.org/en-US/docs/Web/API/DOMException). The [`autoplay`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/audio#attr-autoplay) attribute on [`<audio>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/audio) and [`<video>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/video) elements will be ignored.
For more details on autoplay and autoplay blocking, see the article [Autoplay guide for media and Web Audio APIs](https://developer.mozilla.org/en-US/docs/Web/Media/Autoplay_guide).
Syntax
------
```
Feature-Policy: autoplay <allowlist>;
```
<allowlist> A list of origins for which the feature is allowed. See [`Feature-Policy`](../feature-policy#syntax).
Default policy
--------------
The default value in [Google Chrome](https://chromestatus.com/feature/5100524789563392) is `'self'`.
Specifications
--------------
| Specification |
| --- |
| [HTML Standard # autoplay-feature](https://html.spec.whatwg.org/multipage/infrastructure.html#autoplay-feature) |
Browser compatibility
---------------------
| | Desktop | Mobile |
| --- | --- | --- |
| | Chrome | Edge | Firefox | Internet Explorer | Opera | Safari | WebView Android | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet |
| `autoplay` | 64 | 79 | 74 | No | 51 | No | 64 | 64 | No | 47 | No | 9.0 |
See also
--------
* [`Feature-Policy`](../feature-policy) header
* [Feature Policy](../../feature_policy)
* [Using Feature Policy](../../feature_policy/using_feature_policy)
http Feature-Policy: usb Feature-Policy: usb
===================
Feature-Policy: usb
===================
**Experimental:** **This is an [experimental technology](https://developer.mozilla.org/en-US/docs/MDN/Writing_guidelines/Experimental_deprecated_obsolete#experimental)**
Check the [Browser compatibility table](#browser_compatibility) carefully before using this in production.
The HTTP [`Feature-Policy`](../feature-policy) header `usb` directive controls whether the current document is allowed to use the WebUSB API.
Syntax
------
```
Feature-Policy: usb <allowlist>;
```
<allowlist> A list of origins for which the feature is allowed. See [`Feature-Policy`](../feature-policy#syntax).
Default policy
--------------
The default value is `'self'`.
Specifications
--------------
| Specification |
| --- |
| [WebUSB API # permissions-policy](https://wicg.github.io/webusb/#permissions-policy) |
Browser compatibility
---------------------
| | Desktop | Mobile |
| --- | --- | --- |
| | Chrome | Edge | Firefox | Internet Explorer | Opera | Safari | WebView Android | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet |
| `usb` | 60 | 79 | No | No | 47 | No | No | 60 | No | 44 | No | 8.0 |
See also
--------
* [`Feature-Policy`](../feature-policy) header
* [Feature Policy](../../feature_policy)
* [Using Feature Policy](../../feature_policy/using_feature_policy)
http Feature-Policy: xr-spatial-tracking Feature-Policy: xr-spatial-tracking
===================================
Feature-Policy: xr-spatial-tracking
===================================
**Experimental:** **This is an [experimental technology](https://developer.mozilla.org/en-US/docs/MDN/Writing_guidelines/Experimental_deprecated_obsolete#experimental)**
Check the [Browser compatibility table](#browser_compatibility) carefully before using this in production.
The HTTP [`Feature-Policy`](../feature-policy) header `xr-spatial-tracking` directive controls whether the current document is allowed to use the [WebXR Device API](https://developer.mozilla.org/en-US/docs/Web/API/WebXR_Device_API). This policy controls whether [`navigator.xr.requestSession()`](https://developer.mozilla.org/en-US/docs/Web/API/XRSystem/requestSession) can return [`XRSession`](https://developer.mozilla.org/en-US/docs/Web/API/XRSession) that requires spatial tracking and whether user agent can indicate support for sessions supporting spatial tracking via [`navigator.xr.isSessionSupported()`](https://developer.mozilla.org/en-US/docs/Web/API/XRSystem/isSessionSupported) and [`devicechange`](https://developer.mozilla.org/en-US/docs/Web/API/MediaDevices/devicechange_event) event on [`navigator.xr`](https://developer.mozilla.org/en-US/docs/Web/API/Navigator/xr) object.
Syntax
------
```
Feature-Policy: xr-spatial-tracking <allowlist>;
```
<allowlist> A list of origins for which the feature is allowed. See [`Feature-Policy`](../feature-policy#syntax).
Default policy
--------------
The default allowlist is `'self'`.
Specifications
--------------
| Specification |
| --- |
| [WebXR Device API # permissions-policy](https://immersive-web.github.io/webxr/#permissions-policy) |
Browser compatibility
---------------------
| | Desktop | Mobile |
| --- | --- | --- |
| | Chrome | Edge | Firefox | Internet Explorer | Opera | Safari | WebView Android | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet |
| `xr-spatial-tracking` | 79 | 79 | No | No | 66 | No | No | 79 | No | No | No | 12.0 |
See also
--------
* [WebXR Device API](https://developer.mozilla.org/en-US/docs/Web/API/WebXR_Device_API)
* [`navigator.xr.requestSession()`](https://developer.mozilla.org/en-US/docs/Web/API/XRSystem/requestSession), and [`navigator.xr.isSessionSupported()`](https://developer.mozilla.org/en-US/docs/Web/API/XRSystem/isSessionSupported) and [`devicechange`](https://developer.mozilla.org/en-US/docs/Web/API/XRSystem/devicechange_event) event on [`navigator.xr`](https://developer.mozilla.org/en-US/docs/Web/API/Navigator/xr)
* [`Feature-Policy`](../feature-policy) header
* [Feature Policy](../../feature_policy)
* [Using Feature Policy](../../feature_policy/using_feature_policy)
| programming_docs |
http CSP: manifest-src CSP: manifest-src
=================
CSP: manifest-src
=================
The HTTP [`Content-Security-Policy`](../content-security-policy)`: manifest-src` directive specifies which [manifest](https://developer.mozilla.org/en-US/docs/Web/Manifest) can be applied to the resource.
| | |
| --- | --- |
| CSP version | 3 |
| Directive type | [Fetch directive](https://developer.mozilla.org/en-US/docs/Glossary/Fetch_directive) |
| [`default-src`](default-src) fallback | Yes. If this directive is absent, the user agent will look for the `default-src` directive. |
Syntax
------
One or more sources can be allowed for the `manifest-src` policy:
```
Content-Security-Policy: manifest-src <source>;
Content-Security-Policy: manifest-src <source> <source>;
```
### Sources
`<source>` can be any one of the values listed in [CSP Source Values](sources#sources).
Note that this same set of values can be used in all [fetch directives](https://developer.mozilla.org/en-US/docs/Glossary/Fetch_directive) (and a [number of other directives](sources#relevant_directives)).
Examples
--------
### Violation cases
Given this CSP header:
```
Content-Security-Policy: manifest-src https://example.com/
```
The following [`<link>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/link) is blocked and won't load:
```
<link rel="manifest" href="https://not-example.com/manifest" />
```
Specifications
--------------
| Specification |
| --- |
| [Content Security Policy Level 3 # directive-manifest-src](https://w3c.github.io/webappsec-csp/#directive-manifest-src) |
Browser compatibility
---------------------
| | Desktop | Mobile |
| --- | --- | --- |
| | Chrome | Edge | Firefox | Internet Explorer | Opera | Safari | WebView Android | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet |
| `manifest-src` | Yes | 79 | 41 | No | Yes | No | Yes | Yes | 41 | Yes | No | Yes |
See also
--------
* [`Content-Security-Policy`](../content-security-policy)
* [Web app manifest](https://developer.mozilla.org/en-US/docs/Web/Manifest)
* [`<link>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/link)
http CSP: style-src-elem CSP: style-src-elem
===================
CSP: style-src-elem
===================
The HTTP [`Content-Security-Policy`](../content-security-policy) (CSP) `style-src-elem` directive specifies valid sources for stylesheet [`<style>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/style) elements and [`<link>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/link) elements with `rel="stylesheet"`.
The directive does not set valid sources for inline style attributes; these are set using [`style-src-attr`](style-src-attr) (and valid sources for all styles may be set with [`style-src`](style-src)).
| | |
| --- | --- |
| CSP version | 3 |
| Directive type | [Fetch directive](https://developer.mozilla.org/en-US/docs/Glossary/Fetch_directive) |
| [`default-src`](default-src) fallback | Yes. If this directive is absent, the user agent will look for the [`style-src`](style-src) directive, and if both of them are absent, fall back to `default-src` directive. |
Syntax
------
One or more sources can be allowed for the `style-src-elem` policy:
```
Content-Security-Policy: style-src-elem <source>;
Content-Security-Policy: style-src-elem <source> <source>;
```
`style-src-elem` can be used in conjunction with [`style-src`](style-src):
```
Content-Security-Policy: style-src <source>;
Content-Security-Policy: style-src-elem <source>;
```
### Sources
`<source>` can be any one of the values listed in [CSP Source Values](sources#sources).
Note that this same set of values can be used in all [fetch directives](https://developer.mozilla.org/en-US/docs/Glossary/Fetch_directive) (and a [number of other directives](sources#relevant_directives)).
Examples
--------
### Violation cases
Given this CSP header:
```
Content-Security-Policy: style-src-elem https://example.com/
```
…the following stylesheets are blocked and won't load:
```
<link href="https://not-example.com/styles/main.css" rel="stylesheet" />
<style>
#inline-style {
background: red;
}
</style>
<style>
@import url("https://not-example.com/styles/print.css") print;
</style>
```
…as well as styles loaded using the [`Link`](../link) header:
```
Link: <https://not-example.com/styles/stylesheet.css>;rel=stylesheet
```
Specifications
--------------
| Specification |
| --- |
| [Content Security Policy Level 3 # directive-style-src-elem](https://w3c.github.io/webappsec-csp/#directive-style-src-elem) |
Browser compatibility
---------------------
| | Desktop | Mobile |
| --- | --- | --- |
| | Chrome | Edge | Firefox | Internet Explorer | Opera | Safari | WebView Android | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet |
| `style-src-elem` | 75 | 79 | 105
preview | No | 62 | No | 75 | 75 | No | 54 | No | 11.0 |
See also
--------
* [`Content-Security-Policy`](../content-security-policy)
* [`style-src`](style-src)
* [`style-src-attr`](style-src-attr)
* [`Link`](../link) header
* [`<style>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/style), [`<link>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/link)
* [`@import`](https://developer.mozilla.org/en-US/docs/Web/CSS/@import)
* [`CSSStyleSheet.insertRule()`](https://developer.mozilla.org/en-US/docs/Web/API/CSSStyleSheet/insertRule)
* [`CSSGroupingRule.insertRule()`](https://developer.mozilla.org/en-US/docs/Web/API/CSSGroupingRule/insertRule)
* [`CSSStyleDeclaration.cssText`](https://developer.mozilla.org/en-US/docs/Web/API/CSSStyleDeclaration/cssText)
http CSP: script-src-elem CSP: script-src-elem
====================
CSP: script-src-elem
====================
The HTTP [`Content-Security-Policy`](../content-security-policy) (CSP) `script-src-elem` directive specifies valid sources for JavaScript [`<script>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/script) elements.
This directive only specifies valid sources in `<script>` elements (both script requests and blocks). It does not apply to other JavaScript sources that can trigger script execution, such as inline script event handlers (`onclick`), script execution methods [gated on the "unsafe-eval" check](script-src#unsafe_eval_expressions), and [XSLT stylesheets](https://developer.mozilla.org/en-US/docs/Web/XSLT). (Valid sources can be specified for all JavaScript script sources using [`script-src`](script-src), or just for inline script handlers using [`script-src-attr`](script-src-attr).)
| | |
| --- | --- |
| CSP version | 3 |
| Directive type | [Fetch directive](https://developer.mozilla.org/en-US/docs/Glossary/Fetch_directive) |
| [`default-src`](default-src) fallback | Yes. If this directive is absent, the user agent will look for the [`script-src`](script-src) directive, and if both of them are absent, fall back to `default-src` directive. |
Syntax
------
One or more sources can be allowed for the `script-src-elem` policy:
```
Content-Security-Policy: script-src-elem <source>;
Content-Security-Policy: script-src-elem <source> <source>;
```
`script-src-elem` can be used in conjunction with [`script-src`](script-src):
```
Content-Security-Policy: script-src <source>;
Content-Security-Policy: script-src-elem <source>;
```
### Sources
`<source>` can be any one of the values listed in [CSP Source Values](sources#sources).
Note that this same set of values can be used in all [fetch directives](https://developer.mozilla.org/en-US/docs/Glossary/Fetch_directive) (and a [number of other directives](sources#relevant_directives)).
Examples
--------
### Violation case
Given this CSP header:
```
Content-Security-Policy: script-src-elem https://example.com/
```
…the following script is blocked and won't be loaded or executed:
```
<script src="https://not-example.com/js/library.js"></script>
```
Specifications
--------------
| Specification |
| --- |
| [Content Security Policy Level 3 # directive-script-src-elem](https://w3c.github.io/webappsec-csp/#directive-script-src-elem) |
Browser compatibility
---------------------
| | Desktop | Mobile |
| --- | --- | --- |
| | Chrome | Edge | Firefox | Internet Explorer | Opera | Safari | WebView Android | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet |
| `script-src-elem` | 75 | 79 | 105
preview | No | 62 | No | 75 | 75 | No | 54 | No | 11.0 |
See also
--------
* [`Content-Security-Policy`](../content-security-policy)
* [`<script>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/script)
* [`script-src`](script-src)
* [`script-src-attr`](script-src-attr)
http CSP: frame-src CSP: frame-src
==============
CSP: frame-src
==============
The HTTP [`Content-Security-Policy`](../content-security-policy) (CSP) `frame-src` directive specifies valid sources for nested browsing contexts loading using elements such as [`<frame>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/frame) and [`<iframe>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/iframe).
**Note:** `frame-src` allows you to specify where iframes in a page may be loaded from. This differs from `frame-ancestors`, which allows you to specify what parent source may embed a page.
| | |
| --- | --- |
| CSP version | 1 |
| Directive type | [Fetch directive](https://developer.mozilla.org/en-US/docs/Glossary/Fetch_directive) |
| Fallback | If this directive is absent, the user agent will look for the [`child-src`](child-src) directive (which falls back to the [`default-src`](default-src) directive). |
Syntax
------
One or more sources can be allowed for the `frame-src` policy:
```
Content-Security-Policy: frame-src <source>;
Content-Security-Policy: frame-src <source> <source>;
```
### Sources
`<source>` can be any one of the values listed in [CSP Source Values](sources#sources).
Note that this same set of values can be used in all [fetch directives](https://developer.mozilla.org/en-US/docs/Glossary/Fetch_directive) (and a [number of other directives](sources#relevant_directives)).
Examples
--------
### Violation cases
Given this CSP header:
```
Content-Security-Policy: frame-src https://example.com/
```
The following [`<iframe>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/iframe) is blocked and won't load:
```
<iframe src="https://not-example.com/"></iframe>
```
Specifications
--------------
| Specification |
| --- |
| [Content Security Policy Level 3 # directive-frame-src](https://w3c.github.io/webappsec-csp/#directive-frame-src) |
Browser compatibility
---------------------
| | Desktop | Mobile |
| --- | --- | --- |
| | Chrome | Edge | Firefox | Internet Explorer | Opera | Safari | WebView Android | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet |
| `frame-src` | 25 | 14 | 23 | No | 15 | 7 | Yes | Yes | 23 | Yes | 7 | Yes |
See also
--------
* [`Content-Security-Policy`](../content-security-policy)
* [`<frame>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/frame) and [`<iframe>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/iframe)
* [`frame-ancestors`](frame-ancestors)
http CSP: img-src CSP: img-src
============
CSP: img-src
============
The HTTP [`Content-Security-Policy`](../content-security-policy) `img-src` directive specifies valid sources of images and favicons.
| | |
| --- | --- |
| CSP version | 1 |
| Directive type | [Fetch directive](https://developer.mozilla.org/en-US/docs/Glossary/Fetch_directive) |
| [`default-src`](default-src) fallback | Yes. If this directive is absent, the user agent will look for the `default-src` directive. |
Syntax
------
One or more sources can be allowed for the `img-src` policy:
```
Content-Security-Policy: img-src <source>;
Content-Security-Policy: img-src <source> <source>;
```
### Sources
`<source>` can be any one of the values listed in [CSP Source Values](sources#sources).
Note that this same set of values can be used in all [fetch directives](https://developer.mozilla.org/en-US/docs/Glossary/Fetch_directive) (and a [number of other directives](sources#relevant_directives)).
Examples
--------
### Violation cases
Given this CSP header:
```
Content-Security-Policy: img-src https://example.com/
```
The following [`<img>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/img) is blocked and won't load:
```
<img src="https://not-example.com/foo.jpg" alt="example picture" />
```
Specifications
--------------
| Specification |
| --- |
| [Content Security Policy Level 3 # directive-img-src](https://w3c.github.io/webappsec-csp/#directive-img-src) |
Browser compatibility
---------------------
| | Desktop | Mobile |
| --- | --- | --- |
| | Chrome | Edge | Firefox | Internet Explorer | Opera | Safari | WebView Android | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet |
| `img-src` | 25 | 14 | 23 | No | 15 | 7 | Yes | Yes | 23 | Yes | 7 | Yes |
See also
--------
* [`Content-Security-Policy`](../content-security-policy)
* [`<img>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/img)
http CSP: referrer CSP: referrer
=============
CSP: referrer
=============
**Deprecated:** This feature is no longer recommended. Though some browsers might still support it, it may have already been removed from the relevant web standards, may be in the process of being dropped, or may only be kept for compatibility purposes. Avoid using it, and update existing code if possible; see the [compatibility table](#browser_compatibility) at the bottom of this page to guide your decision. Be aware that this feature may cease to work at any time.
**Non-standard:** This feature is non-standard and is not on a standards track. Do not use it on production sites facing the Web: it will not work for every user. There may also be large incompatibilities between implementations and the behavior may change in the future.
The HTTP [`Content-Security-Policy`](../content-security-policy) (CSP) `referrer` directive used to specify information in the [`Referer`](../referer) header (with a single `r` as this was a typo in the original spec) for links away from a page. This API is deprecated and removed from browsers.
**Note:** Use the [`Referrer-Policy`](../referrer-policy) header instead.
Syntax
------
```
Content-Security-Policy: referrer <referrer-policy>;
```
where `<referrer-policy>` can be one of the following values:
"no-referrer" The [`Referer`](../referer) header will be omitted entirely. No referrer information is sent along with requests.
"none-when-downgrade" This is the user agent's default behavior if no policy is specified. The origin is sent as referrer to a-priori as-much-secure destination (HTTPS->HTTPS), but isn't sent to a less secure destination (HTTPS->HTTP).
"origin" Only send the origin of the document as the referrer in all cases. The document `https://example.com/page.html` will send the referrer `https://example.com/`.
"origin-when-cross-origin" / "origin-when-crossorigin" Send a full URL when performing a same-origin request, but only send the origin of the document for other cases.
"unsafe-url" Send a full URL (stripped from parameters) when performing a same-origin or cross-origin request. This policy will leak origins and paths from TLS-protected resources to insecure origins. Carefully consider the impact of this setting.
Examples
--------
```
Content-Security-Policy: referrer "none";
```
Specifications
--------------
Not part of any specification.
Browser compatibility
---------------------
| | Desktop | Mobile |
| --- | --- | --- |
| | Chrome | Edge | Firefox | Internet Explorer | Opera | Safari | WebView Android | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet |
| `referrer` | 33-56 | No | 37-62 | No | 20-43 | No | 4.4.3-56 | 33-56 | 37-62 | 20-43 | No | 2.0-6.0 |
See also
--------
* [`Content-Security-Policy`](../content-security-policy)
* [`Referrer-Policy`](../referrer-policy) header
* [`Referer`](../referer) header
http CSP: style-src-attr CSP: style-src-attr
===================
CSP: style-src-attr
===================
The HTTP [`Content-Security-Policy`](../content-security-policy) (CSP) `style-src-attr` directive specifies valid sources for inline styles applied to individual DOM elements.
The directive does not set valid sources for [`<style>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/style) elements and [`<link>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/link) elements with `rel="stylesheet"`. These are set using [`style-src-elem`](style-src-elem) (and valid sources for all styles may be set with [`style-src`](style-src)).
| | |
| --- | --- |
| CSP version | 3 |
| Directive type | [Fetch directive](https://developer.mozilla.org/en-US/docs/Glossary/Fetch_directive) |
| [`default-src`](default-src) fallback | Yes. If this directive is absent, the user agent will look for the [`style-src`](style-src) directive, and if both of them are absent, fallback to `default-src` directive. |
Syntax
------
One or more sources can be allowed for the `style-src-attr` policy:
```
Content-Security-Policy: style-src-attr <source>;
Content-Security-Policy: style-src-attr <source> <source>;
```
`style-src-attr` can be used in conjunction with [`style-src`](style-src):
```
Content-Security-Policy: style-src <source>;
Content-Security-Policy: style-src-attr <source>;
```
### Sources
`<source>` can be any one of the values listed in [CSP Source Values](sources#sources).
Note that this same set of values can be used in all [fetch directives](https://developer.mozilla.org/en-US/docs/Glossary/Fetch_directive) (and a [number of other directives](sources#relevant_directives)).
Examples
--------
### Violation cases
Given this CSP header:
```
Content-Security-Policy: script-src-attr 'none'
```
…the inline style applied to the element below not be applied:
```
<div style="display:none">Foo</div>
```
The policy would also block any styles applied in JavaScript by setting the `style` attribute directly, or by setting [`cssText`](https://developer.mozilla.org/en-US/docs/Web/API/CSSStyleDeclaration/cssText):
```
document.querySelector('div').setAttribute('style', 'display:none;');
document.querySelector('div').style.cssText = 'display:none;';
```
Style properties that are set directly on the element's [`style`](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/style) property will not be blocked, allowing users to safely manipulate styles via JavaScript:
```
document.querySelector('div').style.display = 'none';
```
Note that using JavaScript might independently be blocked using the [`script-src`](script-src) CSP directive.
Specifications
--------------
| Specification |
| --- |
| [Content Security Policy Level 3 # directive-style-src-attr](https://w3c.github.io/webappsec-csp/#directive-style-src-attr) |
Browser compatibility
---------------------
| | Desktop | Mobile |
| --- | --- | --- |
| | Chrome | Edge | Firefox | Internet Explorer | Opera | Safari | WebView Android | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet |
| `style-src-attr` | 75 | 79 | 105
preview | No | 62 | No | 75 | 75 | No | 54 | No | 11.0 |
See also
--------
* [`Content-Security-Policy`](../content-security-policy)
* [`style-src`](style-src)
* [`style-src-elem`](style-src-elem)
* [`Link`](../link) header
* [`<style>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/style), [`<link>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/link)
* [`@import`](https://developer.mozilla.org/en-US/docs/Web/CSS/@import)
* [`CSSStyleSheet.insertRule()`](https://developer.mozilla.org/en-US/docs/Web/API/CSSStyleSheet/insertRule)
* [`CSSGroupingRule.insertRule()`](https://developer.mozilla.org/en-US/docs/Web/API/CSSGroupingRule/insertRule)
* [`CSSStyleDeclaration.cssText`](https://developer.mozilla.org/en-US/docs/Web/API/CSSStyleDeclaration/cssText)
| programming_docs |
http CSP: require-trusted-types-for CSP: require-trusted-types-for
==============================
CSP: require-trusted-types-for
==============================
**Experimental:** **This is an [experimental technology](https://developer.mozilla.org/en-US/docs/MDN/Writing_guidelines/Experimental_deprecated_obsolete#experimental)**
Check the [Browser compatibility table](#browser_compatibility) carefully before using this in production.
The HTTP [`Content-Security-Policy`](../content-security-policy) (CSP) `require-trusted-types-for` Experimental directive instructs user agents to control the data passed to DOM XSS sink functions, like [`Element.innerHTML`](https://developer.mozilla.org/en-US/docs/Web/API/Element/innerHTML) setter.
When used, those functions only accept non-spoofable, typed values created by Trusted Type policies, and reject strings. Together with **[`trusted-types`](trusted-types)** directive, which guards creation of Trusted Type policies, this allows authors to define rules guarding writing values to the DOM and thus reducing the DOM XSS attack surface to small, isolated parts of the web application codebase, facilitating their monitoring and code review.
Syntax
------
```
Content-Security-Policy: require-trusted-types-for 'script';
```
`'script'` Disallows using strings with DOM XSS injection sink functions, and requires matching types created by Trusted Type policies.
Examples
--------
```
// Content-Security-Policy: require-trusted-types-for 'script'; trusted-types foo;
const attackerInput = '<svg onload="alert(/cross-site-scripting/)" />';
const el = document.createElement('div');
if (typeof trustedTypes !== 'undefined') {
// Create a policy that can create TrustedHTML values
// after sanitizing the input strings with DOMPurify library.
const sanitizer = trustedTypes.createPolicy('foo', {
createHTML: (input) => DOMPurify.sanitize(input)
});
el.innerHTML = sanitizer.createHTML(attackerInput); // Puts the sanitized value into the DOM.
el.innerHTML = attackerInput; // Rejects a string value; throws a TypeError.
}
```
Specifications
--------------
| Specification |
| --- |
| [Trusted Types # require-trusted-types-for-csp-directive](https://w3c.github.io/trusted-types/dist/spec/#require-trusted-types-for-csp-directive) |
Browser compatibility
---------------------
| | Desktop | Mobile |
| --- | --- | --- |
| | Chrome | Edge | Firefox | Internet Explorer | Opera | Safari | WebView Android | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet |
| `require-trusted-types-for` | 83 | 83 | No | No | 69 | No | 83 | 83 | No | 59 | No | 13.0 |
See also
--------
* [`Content-Security-Policy`](../content-security-policy)
* [Cross-Site Scripting (XSS)](https://developer.mozilla.org/en-US/docs/Glossary/Cross-site_scripting)
* [DOM XSS injection sinks covered by Trusted Types](https://w3c.github.io/trusted-types/dist/spec/#injection-sinks)
* [Prevent DOM-based cross-site scripting vulnerabilities with Trusted Types](https://web.dev/trusted-types/)
* Trusted Types with [DOMPurify](https://github.com/cure53/DOMPurify#what-about-dompurify-and-trusted-types) XSS sanitizer
* [Trusted Types polyfill](https://github.com/w3c/webappsec-trusted-types#polyfill)
http CSP: script-src-attr CSP: script-src-attr
====================
CSP: script-src-attr
====================
The HTTP [`Content-Security-Policy`](../content-security-policy) (CSP) `script-src-attr` directive specifies valid sources for JavaScript inline event handlers.
This directive only specifies valid sources for inline script event handlers like `onclick`. It does not apply to other JavaScript sources that can trigger script execution, such as URLs loaded directly into [`<script>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/script) elements and [XSLT stylesheets](https://developer.mozilla.org/en-US/docs/Web/XSLT). (Valid sources can be specified for all JavaScript script sources using [`script-src`](script-src), or just for `<script>` elements using [`script-src-elem`](script-src-elem).)
| | |
| --- | --- |
| CSP version | 3 |
| Directive type | [Fetch directive](https://developer.mozilla.org/en-US/docs/Glossary/Fetch_directive) |
| [`default-src`](default-src) fallback | Yes. If this directive is absent, the user agent will look for the [`script-src`](script-src) directive, and if both of them are absent, fallback to `default-src` directive. |
Syntax
------
One or more sources can be allowed for the `script-src-attr` policy:
```
Content-Security-Policy: script-src-attr <source>;
Content-Security-Policy: script-src-attr <source> <source>;
```
`script-src-attr` can be used in conjunction with [`script-src`](script-src), and will override that directive for checks on inline handlers:
```
Content-Security-Policy: script-src <source>;
Content-Security-Policy: script-src-attr <source>;
```
### Sources
`<source>` can be any one of the values listed in [CSP Source Values](sources#sources).
Note that this same set of values can be used in all [fetch directives](https://developer.mozilla.org/en-US/docs/Glossary/Fetch_directive) (and a [number of other directives](sources#relevant_directives)).
Examples
--------
### Violation case
Given this CSP header:
```
Content-Security-Policy: script-src-attr 'none'
```
…the following inline event handler is blocked and won't be loaded or executed:
```
<button id="btn" onclick="doSomething()"></button>
```
Note that generally you should replace inline event handlers with [`addEventListener`](https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener) calls:
```
document.getElementById("btn").addEventListener("click", doSomething);
```
Specifications
--------------
| Specification |
| --- |
| [Content Security Policy Level 3 # directive-script-src-attr](https://w3c.github.io/webappsec-csp/#directive-script-src-attr) |
Browser compatibility
---------------------
| | Desktop | Mobile |
| --- | --- | --- |
| | Chrome | Edge | Firefox | Internet Explorer | Opera | Safari | WebView Android | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet |
| `script-src-attr` | 75 | 79 | 105
preview | No | 62 | No | 75 | 75 | No | 54 | No | 11.0 |
See also
--------
* [`Content-Security-Policy`](../content-security-policy)
* [`<script>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/script)
* [`script-src`](script-src)
* [`script-src-elem`](script-src-elem)
http CSP: connect-src CSP: connect-src
================
CSP: connect-src
================
The HTTP [`Content-Security-Policy`](../content-security-policy) (CSP) `connect-src` directive restricts the URLs which can be loaded using script interfaces. The APIs that are restricted are:
* [`<a>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a) [`ping`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a#attr-ping),
* [`fetch()`](https://developer.mozilla.org/en-US/docs/Web/API/fetch),
* [`XMLHttpRequest`](https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest),
* [`WebSocket`](https://developer.mozilla.org/en-US/docs/Web/API/WebSocket),
* [`EventSource`](https://developer.mozilla.org/en-US/docs/Web/API/EventSource), and
* [`Navigator.sendBeacon()`](https://developer.mozilla.org/en-US/docs/Web/API/Navigator/sendBeacon).
**Note:** `connect-src 'self'` does not resolve to websocket schemes in all browsers, more info in this [issue](https://github.com/w3c/webappsec-csp/issues/7).
| | |
| --- | --- |
| CSP version | 1 |
| Directive type | [Fetch directive](https://developer.mozilla.org/en-US/docs/Glossary/Fetch_directive) |
| [`default-src`](default-src) fallback | Yes. If this directive is absent, the user agent will look for the `default-src` directive. |
Syntax
------
One or more sources can be allowed for the connect-src policy:
```
Content-Security-Policy: connect-src <source>;
Content-Security-Policy: connect-src <source> <source>;
```
### Sources
`<source>` can be any one of the values listed in [CSP Source Values](sources#sources).
Note that this same set of values can be used in all [fetch directives](https://developer.mozilla.org/en-US/docs/Glossary/Fetch_directive) (and a [number of other directives](sources#relevant_directives)).
Examples
--------
### Violation cases
Given this CSP header:
```
Content-Security-Policy: connect-src https://example.com/
```
The following connections are blocked and won't load:
```
<a ping="https://not-example.com">
<script>
const xhr = new XMLHttpRequest();
xhr.open("GET", "https://not-example.com/");
xhr.send();
const ws = new WebSocket("https://not-example.com/");
const es = new EventSource("https://not-example.com/");
navigator.sendBeacon("https://not-example.com/", {
/\* … \*/
});
</script></a>
```
Specifications
--------------
| Specification |
| --- |
| [Content Security Policy Level 3 # directive-connect-src](https://w3c.github.io/webappsec-csp/#directive-connect-src) |
Browser compatibility
---------------------
| | Desktop | Mobile |
| --- | --- | --- |
| | Chrome | Edge | Firefox | Internet Explorer | Opera | Safari | WebView Android | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet |
| `connect-src` | 25 | 14 | 23
Before Firefox 50, ping attributes of <a> elements weren't covered by connect-src. | No | 15 | 7 | Yes | Yes | 23 | Yes | 7 | Yes |
### Compatibility notes
* Prior to Firefox 23, `xhr-src` was used in place of the `connect-src` directive and only restricted the use of [`XMLHttpRequest`](https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest).
See also
--------
* [`Content-Security-Policy`](../content-security-policy)
* [`<a>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a) [`ping`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a#attr-ping)
* [`fetch()`](https://developer.mozilla.org/en-US/docs/Web/API/fetch)
* [`XMLHttpRequest`](https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest)
* [`WebSocket`](https://developer.mozilla.org/en-US/docs/Web/API/WebSocket)
* [`EventSource`](https://developer.mozilla.org/en-US/docs/Web/API/EventSource)
http CSP: child-src CSP: child-src
==============
CSP: child-src
==============
The HTTP [`Content-Security-Policy`](../content-security-policy) (CSP) `child-src` directive defines the valid sources for [web workers](https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API) and nested browsing contexts loaded using elements such as [`<frame>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/frame) and [`<iframe>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/iframe). For workers, non-compliant requests are treated as fatal network errors by the user agent.
| | |
| --- | --- |
| CSP version | 2 |
| Directive type | [Fetch directive](https://developer.mozilla.org/en-US/docs/Glossary/Fetch_directive) |
| [`default-src`](default-src) fallback | Yes. If this directive is absent, the user agent will look for the `default-src` directive. |
Syntax
------
One or more sources can be allowed for the `child-src` policy:
```
Content-Security-Policy: child-src <source>;
Content-Security-Policy: child-src <source> <source>;
```
### Sources
`<source>` can be any one of the values listed in [CSP Source Values](sources#sources).
Note that this same set of values can be used in all [fetch directives](https://developer.mozilla.org/en-US/docs/Glossary/Fetch_directive) (and a [number of other directives](sources#relevant_directives)).
Examples
--------
### Violation cases
Given this CSP header:
```
Content-Security-Policy: child-src https://example.com/
```
This [`<iframe>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/iframe) and worker are blocked and won't load:
```
<iframe src="https://not-example.com"></iframe>
<script>
const blockedWorker = new Worker("data:application/javascript,…");
</script>
```
Specifications
--------------
| Specification |
| --- |
| [Content Security Policy Level 3 # directive-child-src](https://w3c.github.io/webappsec-csp/#directive-child-src) |
Browser compatibility
---------------------
| | Desktop | Mobile |
| --- | --- | --- |
| | Chrome | Edge | Firefox | Internet Explorer | Opera | Safari | WebView Android | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet |
| `child-src` | 40 | 15 | 45 | No | 27 | 10 | Yes | Yes | 45 | Yes | 9.3 | Yes |
See also
--------
* [`Content-Security-Policy`](../content-security-policy)
* [`<frame>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/frame) and [`<iframe>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/iframe)
* [`Worker`](https://developer.mozilla.org/en-US/docs/Web/API/Worker), [`SharedWorker`](https://developer.mozilla.org/en-US/docs/Web/API/SharedWorker), [`ServiceWorker`](https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorker)
http CSP: prefetch-src CSP: prefetch-src
=================
CSP: prefetch-src
=================
**Experimental:** **This is an [experimental technology](https://developer.mozilla.org/en-US/docs/MDN/Writing_guidelines/Experimental_deprecated_obsolete#experimental)**
Check the [Browser compatibility table](#browser_compatibility) carefully before using this in production.
The HTTP [`Content-Security-Policy`](../content-security-policy) (CSP) `prefetch-src` directive specifies valid resources that may be prefetched or prerendered.
| | |
| --- | --- |
| CSP version | 3 |
| Directive type | [Fetch directive](https://developer.mozilla.org/en-US/docs/Glossary/Fetch_directive) |
| [`default-src`](default-src) fallback | Yes. If this directive is absent, the user agent will look for the `default-src` directive. |
Syntax
------
One or more sources can be allowed for the `prefetch-src` policy:
```
Content-Security-Policy: prefetch-src <source>;
Content-Security-Policy: prefetch-src <source> <source>;
```
### Sources
`<source>` can be any one of the values listed in [CSP Source Values](sources#sources).
Note that this same set of values can be used in all [fetch directives](https://developer.mozilla.org/en-US/docs/Glossary/Fetch_directive) (and a [number of other directives](sources#relevant_directives)).
Example
-------
### Prefetch resources do not match header
Given a page with the following Content Security Policy:
```
Content-Security-Policy: prefetch-src https://example.com/
```
Fetches for the following code will return network errors, as the URLs provided do not match `prefetch-src`'s source list:
```
<link rel="prefetch" href="https://example.org/" />
<link rel="prerender" href="https://example.org/" />
```
Specifications
--------------
| Specification |
| --- |
| [Content Security Policy Level 3 # directive-prefetch-src](https://w3c.github.io/webappsec-csp/#directive-prefetch-src) |
Browser compatibility
---------------------
| | Desktop | Mobile |
| --- | --- | --- |
| | Chrome | Edge | Firefox | Internet Explorer | Opera | Safari | WebView Android | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet |
| `prefetch-src` | No
See [bug 801561](https://crbug.com/801561). | No
See [bug 801561](https://crbug.com/801561). | No
See [bug 1457204](https://bugzil.la/1457204). | No | No
See [bug 801561](https://crbug.com/801561). | No
See [bug 185070](https://webkit.org/b/185070). | No
See [bug 801561](https://crbug.com/801561). | No
See [bug 801561](https://crbug.com/801561). | No
See [bug 1457204](https://bugzil.la/1457204). | No
See [bug 801561](https://crbug.com/801561). | No
See [bug 185070](https://webkit.org/b/185070). | No
See [bug 801561](https://crbug.com/801561). |
See also
--------
* [`Content-Security-Policy`](../content-security-policy)
http CSP: style-src CSP: style-src
==============
CSP: style-src
==============
The HTTP [`Content-Security-Policy`](../content-security-policy) (CSP) `style-src` directive specifies valid sources for stylesheets.
| | |
| --- | --- |
| CSP version | 1 |
| Directive type | [Fetch directive](https://developer.mozilla.org/en-US/docs/Glossary/Fetch_directive) |
| [`default-src`](default-src) fallback | Yes. If this directive is absent, the user agent will look for the `default-src` directive. |
Syntax
------
One or more sources can be allowed for the `style-src` policy:
```
Content-Security-Policy: style-src <source>;
Content-Security-Policy: style-src <source> <source>;
```
### Sources
`<source>` can be any one of the values listed in [CSP Source Values](sources#sources).
Note that this same set of values can be used in all [fetch directives](https://developer.mozilla.org/en-US/docs/Glossary/Fetch_directive) (and a [number of other directives](sources#relevant_directives)).
Examples
--------
### Violation cases
Given this CSP header:
```
Content-Security-Policy: style-src https://example.com/
```
the following stylesheets are blocked and won't load:
```
<link href="https://not-example.com/styles/main.css" rel="stylesheet" />
<style>
#inline-style {
background: red;
}
</style>
<style>
@import url("https://not-example.com/styles/print.css") print;
</style>
```
as well as styles loaded using the [`Link`](../link) header:
```
Link: <https://not-example.com/styles/stylesheet.css>;rel=stylesheet
```
Inline style attributes are also blocked:
```
<div style="display:none">Foo</div>
```
As well as styles that are applied in JavaScript by setting the `style` attribute directly, or by setting [`cssText`](https://developer.mozilla.org/en-US/docs/Web/API/CSSStyleDeclaration/cssText):
```
document.querySelector('div').setAttribute('style', 'display:none;');
document.querySelector('div').style.cssText = 'display:none;';
```
However, styles properties that are set directly on the element's [`style`](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/style) property will not be blocked, allowing users to safely manipulate styles via JavaScript:
```
document.querySelector('div').style.display = 'none';
```
These types of manipulations can be prevented by disallowing JavaScript via the [`script-src`](script-src) CSP directive.
### Unsafe inline styles
**Note:** Disallowing inline styles and inline scripts is one of the biggest security wins CSP provides. However, if you absolutely have to use it, there are a few mechanisms that will allow them.
To allow inline styles, `'unsafe-inline'`, a nonce-source or a hash-source that matches the inline block can be specified.
```
Content-Security-Policy: style-src 'unsafe-inline';
```
The above Content Security Policy will allow inline styles like the [`<style>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/style) element, and the `style` attribute on any element:
```
<style>
#inline-style {
background: red;
}
</style>
<div style="display:none">Foo</div>
```
You can use a nonce-source to only allow specific inline style blocks:
```
Content-Security-Policy: style-src 'nonce-2726c7f26c'
```
You will have to set the same nonce on the [`<style>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/style) element:
```
<style nonce="2726c7f26c">
#inline-style {
background: red;
}
</style>
```
Alternatively, you can create hashes from your inline styles. CSP supports sha256, sha384 and sha512. The **binary** form of the hash has to be encoded with base64. You can obtain the hash of a string on the command line via the `openssl` program:
```
echo -n "#inline-style { background: red; }" | openssl dgst -sha256 -binary | openssl enc -base64
```
You can use a hash-source to only allow specific inline style blocks:
```
Content-Security-Policy: style-src 'sha256-ozBpjL6dxO8fsS4u6fwG1dFDACYvpNxYeBA6tzR+FY8='
```
When generating the hash, don't include the [`<style>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/style) tags and note that capitalization and whitespace matter, including leading or trailing whitespace.
```
<style>
#inline-style {
background: red;
}
</style>
```
### Unsafe style expressions
The `'unsafe-eval'` source expression controls several style methods that create style declarations from strings. If `'unsafe-eval'` isn't specified with the `style-src` directive, the following methods are blocked and won't have any effect:
* [`CSSStyleSheet.insertRule()`](https://developer.mozilla.org/en-US/docs/Web/API/CSSStyleSheet/insertRule)
* [`CSSGroupingRule.insertRule()`](https://developer.mozilla.org/en-US/docs/Web/API/CSSGroupingRule/insertRule)
* [`CSSStyleDeclaration.cssText`](https://developer.mozilla.org/en-US/docs/Web/API/CSSStyleDeclaration/cssText)
Specifications
--------------
| Specification |
| --- |
| [Content Security Policy Level 3 # directive-style-src](https://w3c.github.io/webappsec-csp/#directive-style-src) |
Browser compatibility
---------------------
| | Desktop | Mobile |
| --- | --- | --- |
| | Chrome | Edge | Firefox | Internet Explorer | Opera | Safari | WebView Android | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet |
| `style-src` | 25 | 14 | 23 | No | 15 | 7 | Yes | Yes | 23 | Yes | 7 | Yes |
See also
--------
* [`Content-Security-Policy`](../content-security-policy)
* [`style-src-elem`](style-src-elem)
* [`style-src-attr`](style-src-attr)
* [`Link`](../link) header
* [`<style>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/style), [`<link>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/link)
* [`@import`](https://developer.mozilla.org/en-US/docs/Web/CSS/@import)
* [`CSSStyleSheet.insertRule()`](https://developer.mozilla.org/en-US/docs/Web/API/CSSStyleSheet/insertRule)
* [`CSSGroupingRule.insertRule()`](https://developer.mozilla.org/en-US/docs/Web/API/CSSGroupingRule/insertRule)
* [`CSSStyleDeclaration.cssText`](https://developer.mozilla.org/en-US/docs/Web/API/CSSStyleDeclaration/cssText)
| programming_docs |
http CSP: media-src CSP: media-src
==============
CSP: media-src
==============
The HTTP [`Content-Security-Policy`](../content-security-policy) (CSP) `media-src` directive specifies valid sources for loading media using the [`<audio>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/audio) and [`<video>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/video) elements.
| | |
| --- | --- |
| CSP version | 1 |
| Directive type | [Fetch directive](https://developer.mozilla.org/en-US/docs/Glossary/Fetch_directive) |
| [`default-src`](default-src) fallback | Yes. If this directive is absent, the user agent will look for the `default-src` directive. |
Syntax
------
One or more sources can be allowed for the `media-src` policy:
```
Content-Security-Policy: media-src <source>;
Content-Security-Policy: media-src <source> <source>;
```
### Sources
`<source>` can be any one of the values listed in [CSP Source Values](sources#sources).
Note that this same set of values can be used in all [fetch directives](https://developer.mozilla.org/en-US/docs/Glossary/Fetch_directive) (and a [number of other directives](sources#relevant_directives)).
Examples
--------
### Violation cases
Given this CSP header:
```
Content-Security-Policy: media-src https://example.com/
```
The following [`<audio>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/audio), [`<video>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/video) and [`<track>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/track) elements are blocked and won't load:
```
<audio src="https://not-example.com/audio"></audio>
<video src="https://not-example.com/video">
<track kind="subtitles" src="https://not-example.com/subtitles" />
</video>
```
Specifications
--------------
| Specification |
| --- |
| [Content Security Policy Level 3 # directive-media-src](https://w3c.github.io/webappsec-csp/#directive-media-src) |
Browser compatibility
---------------------
| | Desktop | Mobile |
| --- | --- | --- |
| | Chrome | Edge | Firefox | Internet Explorer | Opera | Safari | WebView Android | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet |
| `media-src` | 25 | 14 | 23 | No | 15 | 7 | Yes | Yes | 23 | Yes | 7 | Yes |
See also
--------
* [`Content-Security-Policy`](../content-security-policy)
* [`<audio>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/audio), [`<video>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/video) and [`<track>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/track)
http CSP: upgrade-insecure-requests CSP: upgrade-insecure-requests
==============================
CSP: upgrade-insecure-requests
==============================
The HTTP [`Content-Security-Policy`](../content-security-policy) (CSP) `upgrade-insecure-requests` directive instructs user agents to treat all of a site's insecure URLs (those served over HTTP) as though they have been replaced with secure URLs (those served over HTTPS). This directive is intended for web sites with large numbers of insecure legacy URLs that need to be rewritten.
**Note:** The `upgrade-insecure-requests` directive is evaluated before [`block-all-mixed-content`](block-all-mixed-content) and if it is set, the latter is effectively a no-op. It is recommended to set either directive, but not both, unless you want to force HTTPS on older browsers that do not force it after a redirect to HTTP.
The `upgrade-insecure-requests` directive will not ensure that users visiting your site via links on third-party sites will be upgraded to HTTPS for the top-level navigation and thus does not replace the [`Strict-Transport-Security`](../strict-transport-security) ([HSTS](https://developer.mozilla.org/en-US/docs/Glossary/HSTS)) header, which should still be set with an appropriate `max-age` to ensure that users are not subject to SSL stripping attacks.
Syntax
------
```
Content-Security-Policy: upgrade-insecure-requests;
```
Examples
--------
### Using the HTTP header
```
Content-Security-Policy: upgrade-insecure-requests;
```
### Using the HTML meta element
```
<meta
http-equiv="Content-Security-Policy"
content="upgrade-insecure-requests" />
```
With the above header set on a domain example.com that wants to migrate from HTTP to HTTPS, non-navigational insecure resource requests are automatically upgraded (first-party as well as third-party requests).
```
<img src="http://example.com/image.png" />
<img src="http://not-example.com/image.png" />
```
These URLs will be rewritten before the request is made, meaning that no insecure requests will hit the network. Note that, if the requested resource is not actually available via HTTPS, the request will fail without any fallback to HTTP.
```
<img src="https://example.com/image.png" />
<img src="https://not-example.com/image.png" />
```
Navigational upgrades to third-party resources brings a significantly higher potential for breakage, these are not upgraded:
```
<a href="https://example.com/">Home</a>
<a href="http://not-example.com/">Home</a>
```
### Finding insecure requests
With the help of the [`Content-Security-Policy-Report-Only`](../content-security-policy-report-only) header and the [`report-uri`](report-uri) directive, you can set-up an enforced policy and a reported policy like this:
```
Content-Security-Policy: upgrade-insecure-requests; default-src https:
Content-Security-Policy-Report-Only: default-src https:; report-uri /endpoint
```
That way, you still upgrade insecure requests on your secure site, but the only monitoring policy is violated and reports insecure resources to your endpoint.
Specifications
--------------
| Specification |
| --- |
| [Upgrade Insecure Requests # delivery](https://w3c.github.io/webappsec-upgrade-insecure-requests/#delivery) |
Browser compatibility
---------------------
| | Desktop | Mobile |
| --- | --- | --- |
| | Chrome | Edge | Firefox | Internet Explorer | Opera | Safari | WebView Android | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet |
| `upgrade-insecure-requests` | 43 | 17 | 42 | No | 30 | 10.1 | 43 | 43 | 42 | 30 | 10.3 | 4.0 |
See also
--------
* [`Content-Security-Policy`](../content-security-policy)
* [`Upgrade-Insecure-Requests`](../upgrade-insecure-requests) header
* [`Strict-Transport-Security`](../strict-transport-security) ([HSTS](https://developer.mozilla.org/en-US/docs/Glossary/HSTS)) header
* [`block-all-mixed-content`](block-all-mixed-content)
* [Mixed content](https://developer.mozilla.org/en-US/docs/Web/Security/Mixed_content)
http CSP: block-all-mixed-content CSP: block-all-mixed-content
============================
CSP: block-all-mixed-content
============================
**Deprecated:** This feature is no longer recommended. Though some browsers might still support it, it may have already been removed from the relevant web standards, may be in the process of being dropped, or may only be kept for compatibility purposes. Avoid using it, and update existing code if possible; see the [compatibility table](#browser_compatibility) at the bottom of this page to guide your decision. Be aware that this feature may cease to work at any time.
**Warning:** This directive is marked as obsolete in the specification: all mixed content is now blocked if it can't be autoupgraded.
The HTTP [`Content-Security-Policy`](../content-security-policy) (CSP) `block-all-mixed-content` directive prevents loading any assets over HTTP when the page uses HTTPS.
All [mixed content](https://developer.mozilla.org/en-US/docs/Web/Security/Mixed_content) resource requests are blocked, including both active and passive mixed content. This also applies to [`<iframe>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/iframe) documents, ensuring the entire page is mixed content-free.
**Note:** The [`upgrade-insecure-requests`](upgrade-insecure-requests) directive is evaluated before `block-all-mixed-content`. If the former is set, the latter does nothing, so set one directive or the other – not both, unless you want to force HTTPS on older browsers that do not force it after a redirect to HTTP.
Syntax
------
```
Content-Security-Policy: block-all-mixed-content;
```
Examples
--------
```
Content-Security-Policy: block-all-mixed-content;
<meta http-equiv="Content-Security-Policy" content="block-all-mixed-content">
```
To disallow http assets on a more granular level, you can also set individual directives to `https:`. For example, to disallow insecure HTTP images:
```
Content-Security-Policy: img-src https:
```
Specifications
--------------
Not part of any current specification. Used to be defined in the outdated [Mixed Content Level 1](https://www.w3.org/TR/mixed-content/#block-all-mixed-content) specification.
Browser compatibility
---------------------
| | Desktop | Mobile |
| --- | --- | --- |
| | Chrome | Edge | Firefox | Internet Explorer | Opera | Safari | WebView Android | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet |
| `block-all-mixed-content` | Yes | ≤79 | 48 | No | Yes | No | Yes | Yes | 48 | Yes | No | Yes |
See also
--------
* [`Content-Security-Policy`](../content-security-policy)
* [`upgrade-insecure-requests`](upgrade-insecure-requests)
* [Mixed content](https://developer.mozilla.org/en-US/docs/Web/Security/Mixed_content)
http CSP: form-action CSP: form-action
================
CSP: form-action
================
The HTTP [`Content-Security-Policy`](../content-security-policy) (CSP) `form-action` directive restricts the URLs which can be used as the target of form submissions from a given context.
**Warning:** Whether `form-action` should block redirects after a form submission is [debated](https://github.com/w3c/webappsec-csp/issues/8) and browser implementations of this aspect are inconsistent (e.g. Firefox 57 doesn't block the redirects whereas Chrome 63 does).
| | |
| --- | --- |
| CSP version | 2 |
| Directive type | [Navigation directive](https://developer.mozilla.org/en-US/docs/Glossary/Navigation_directive) |
| [`default-src`](default-src) fallback | No. Not setting this allows anything. |
Syntax
------
One or more sources can be set for the `form-action` policy:
```
Content-Security-Policy: form-action <source>;
Content-Security-Policy: form-action <source> <source>;
```
### Sources
`<source>` can be any one of the values listed in [CSP Source Values](sources#sources).
Note that this same set of values can be used in all [fetch directives](https://developer.mozilla.org/en-US/docs/Glossary/Fetch_directive) (and a [number of other directives](sources#relevant_directives)).
Examples
--------
### Meta tag configuration
```
<meta http-equiv="Content-Security-Policy" content="form-action 'none'" />
```
### Apache configuration
```
<IfModule mod\_headers.c>
Header set Content-Security-Policy "form-action 'none';"
</IfModule>
```
### Nginx configuration
```
add_header Content-Security-Policy "form-action 'none';"
```
### Violation case
Using a [`<form>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/form) element with an action set to inline JavaScript will result in a CSP violation.
```
<meta http-equiv="Content-Security-Policy" content="form-action 'none'" />
<form action="javascript:alert('Foo')" id="form1" method="post">
<input type="text" name="fieldName" value="fieldValue" />
<input type="submit" id="submit" value="submit" />
</form>
<!--
// Error: Refused to send form data because it violates the following
// Content Security Policy directive: "form-action 'none'".
-->
```
Specifications
--------------
| Specification |
| --- |
| [Content Security Policy Level 3 # directive-form-action](https://w3c.github.io/webappsec-csp/#directive-form-action) |
Browser compatibility
---------------------
| | Desktop | Mobile |
| --- | --- | --- |
| | Chrome | Edge | Firefox | Internet Explorer | Opera | Safari | WebView Android | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet |
| `form-action` | 40 | 15 | 36 | No | 27 | 10 | Yes | Yes | 36 | Yes | 9.3 | Yes |
See also
--------
* [`Content-Security-Policy`](../content-security-policy)
* [`<form>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/form)
http CSP: require-sri-for CSP: require-sri-for
====================
CSP: require-sri-for
====================
**Deprecated:** This feature is no longer recommended. Though some browsers might still support it, it may have already been removed from the relevant web standards, may be in the process of being dropped, or may only be kept for compatibility purposes. Avoid using it, and update existing code if possible; see the [compatibility table](#browser_compatibility) at the bottom of this page to guide your decision. Be aware that this feature may cease to work at any time.
**Non-standard:** This feature is non-standard and is not on a standards track. Do not use it on production sites facing the Web: it will not work for every user. There may also be large incompatibilities between implementations and the behavior may change in the future.
The [HTTP](../../index) [`Content-Security-Policy`](../content-security-policy) `require-sri-for` directive instructs the client to require the use of [Subresource Integrity](https://developer.mozilla.org/en-US/docs/Web/Security/Subresource_Integrity) for scripts or styles on the page.
Syntax
------
```
Content-Security-Policy: require-sri-for script;
Content-Security-Policy: require-sri-for style;
Content-Security-Policy: require-sri-for script style;
```
`script` Requires [SRI](https://developer.mozilla.org/en-US/docs/Glossary/SRI) for scripts.
`style` Requires [SRI](https://developer.mozilla.org/en-US/docs/Glossary/SRI) for style sheets.
`script style` Requires [SRI](https://developer.mozilla.org/en-US/docs/Glossary/SRI) for both, scripts and style sheets.
Examples
--------
If you set your site to require SRI for script and styles using this directive:
```
Content-Security-Policy: require-sri-for script style
```
[`<script>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/script) elements like the following will be loaded as they use a valid integrity attribute.
```
<script
src="https://code.jquery.com/jquery-3.1.1.slim.js"
integrity="sha256-5i/mQ300M779N2OVDrl16lbohwXNUdzL/R2aVUXyXWA="
crossorigin="anonymous"></script>
```
However, scripts without integrity won't load anymore:
```
<script src="https://code.jquery.com/jquery-3.1.1.slim.js"></script>
```
Browser compatibility
---------------------
| | Desktop | Mobile |
| --- | --- | --- |
| | Chrome | Edge | Firefox | Internet Explorer | Opera | Safari | WebView Android | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet |
| `require-sri-for` | 54 | 79 | No | No | 41 | No | 54 | 54 | No | 41 | No | 6.0 |
See also
--------
* [`Content-Security-Policy`](../content-security-policy)
* [Subresource Integrity](https://developer.mozilla.org/en-US/docs/Web/Security/Subresource_Integrity)
http CSP: plugin-types CSP: plugin-types
=================
CSP: plugin-types
=================
**Deprecated:** This feature is no longer recommended. Though some browsers might still support it, it may have already been removed from the relevant web standards, may be in the process of being dropped, or may only be kept for compatibility purposes. Avoid using it, and update existing code if possible; see the [compatibility table](#browser_compatibility) at the bottom of this page to guide your decision. Be aware that this feature may cease to work at any time.
**Non-standard:** This feature is non-standard and is not on a standards track. Do not use it on production sites facing the Web: it will not work for every user. There may also be large incompatibilities between implementations and the behavior may change in the future.
The HTTP [`Content-Security-Policy`](../content-security-policy) (CSP) `plugin-types` directive restricts the set of plugins that can be embedded into a document by limiting the types of resources which can be loaded.
Instantiation of an [`<embed>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/embed), [`<object>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/object) or [`<applet>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/applet) element will fail if:
* the element to load does not declare a valid MIME type,
* the declared type does not match one of specified types in the `plugin-types` directive,
* the fetched resource does not match the declared type.
| | |
| --- | --- |
| CSP version | 2 |
| Directive type | [Document directive](https://developer.mozilla.org/en-US/docs/Glossary/Document_directive) |
| [`default-src`](default-src) fallback | No. Not setting this allows anything. |
Syntax
------
One or more [MIME types](../../basics_of_http/mime_types) can be set for the `plugin-types` policy:
```
Content-Security-Policy: plugin-types <type>/<subtype>;
Content-Security-Policy: plugin-types <type>/<subtype> <type>/<subtype>;
```
<type>/<subtype> A valid [MIME type](../../basics_of_http/mime_types/common_types).
Examples
--------
### Disallowing plugins
To disallow all plugins, the [`object-src`](object-src) directive should be set to `'none'` which will disallow plugins. The `plugin-types` directive is only used if you are allowing plugins with `object-src` at all.
```
<meta http-equiv="Content-Security-Policy" content="object-src 'none'" />
```
### Allowing Java applets
To load an [`<applet>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/applet) you must specify `application/x-java-applet`:
```
Content-Security-Policy: plugin-types application/x-java-applet
```
Specifications
--------------
Not part of any current specification. Used to be defined in [CSP 2](https://www.w3.org/TR/CSP2/#directive-plugin-types).
Browser compatibility
---------------------
| | Desktop | Mobile |
| --- | --- | --- |
| | Chrome | Edge | Firefox | Internet Explorer | Opera | Safari | WebView Android | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet |
| `plugin-types` | 40-90 | 15-90 | No | No | 27-76 | 10 | Yes-90 | Yes-90 | No | Yes-64 | 9.3 | Yes-15.0 |
See also
--------
* [`Content-Security-Policy`](../content-security-policy): [`object-src`](object-src)
* [`<object>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/object)
* [`<embed>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/embed)
* [`<applet>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/applet)
* [`X-Content-Type-Options`](../x-content-type-options)
http CSP: base-uri CSP: base-uri
=============
CSP: base-uri
=============
The HTTP [`Content-Security-Policy`](../content-security-policy) `base-uri` directive restricts the URLs which can be used in a document's [`<base>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/base) element. If this value is absent, then any URI is allowed. If this directive is absent, the user agent will use the value in the [`<base>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/base) element.
| | |
| --- | --- |
| CSP version | 2 |
| Directive type | [Document directive](https://developer.mozilla.org/en-US/docs/Glossary/Document_directive) |
| [`default-src`](default-src) fallback | No. Not setting this allows any URL. |
Syntax
------
One or more *sources* can be allowed for the base-uri policy:
```
Content-Security-Policy: base-uri <source>;
Content-Security-Policy: base-uri <source> <source>;
```
### Sources
This directive uses most of the same source values for arguments as other CSP directives: [CSP Source Values](sources#sources).
Note however that some of the values don't make sense for `base-uri`, such as the keywords `'unsafe-inline'` and `'strict-dynamic'`.
Examples
--------
### Meta tag configuration
```
<meta http-equiv="Content-Security-Policy" content="base-uri 'self'" />
```
### Apache configuration
```
<IfModule mod_headers.c>
Header set Content-Security-Policy "base-uri 'self'";
</IfModule>
```
### Nginx configuration
```
add_header Content-Security-Policy "base-uri 'self';"
```
### Violation case
Since your domain isn't `example.com`, a [`<base>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/base) element with its `href` set to `https://example.com` will result in a CSP violation.
```
<meta http-equiv="Content-Security-Policy" content="base-uri 'self'" />
<base href="https://example.com/" />
<!--
// Error: Refused to set the document's base URI to 'https://example.com/'
// because it violates the following Content Security Policy
// directive: "base-uri 'self'"
-->
```
Specifications
--------------
| Specification |
| --- |
| [Content Security Policy Level 3 # directive-base-uri](https://w3c.github.io/webappsec-csp/#directive-base-uri) |
Browser compatibility
---------------------
| | Desktop | Mobile |
| --- | --- | --- |
| | Chrome | Edge | Firefox | Internet Explorer | Opera | Safari | WebView Android | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet |
| `base-uri` | 40 | 79 | 35 | No | 27 | 10 | Yes | Yes | 35 | Yes | 9.3 | Yes |
See also
--------
* [`Content-Security-Policy`](../content-security-policy)
* [`<base>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/base)
* [`Node.baseURI`](https://developer.mozilla.org/en-US/docs/Web/API/Node/baseURI)
| programming_docs |
http CSP: sandbox CSP: sandbox
============
CSP: sandbox
============
The HTTP [`Content-Security-Policy`](../content-security-policy) (CSP) `sandbox` directive enables a sandbox for the requested resource similar to the [`<iframe>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/iframe) [`sandbox`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/iframe#attr-sandbox) attribute. It applies restrictions to a page's actions including preventing popups, preventing the execution of plugins and scripts, and enforcing a same-origin policy.
| | |
| --- | --- |
| CSP version | 1.1 / 2 |
| Directive type | [Document directive](https://developer.mozilla.org/en-US/docs/Glossary/Document_directive) |
| This directive is not supported in the [`<meta>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/meta) element or by the [`Content-Security-policy-Report-Only`](../content-security-policy-report-only) header field. |
Syntax
------
```
Content-Security-Policy: sandbox;
Content-Security-Policy: sandbox <value>;
```
where `<value>` can optionally be one of the following values:
`allow-downloads` Allows for downloads after the user clicks a button or link.
`allow-downloads-without-user-activation` Experimental
Allows for downloads to occur without a gesture from the user.
`allow-forms` Allows the page to submit forms. If this keyword is not used, this operation is not allowed.
`allow-modals` Allows the page to open modal windows.
`allow-orientation-lock` Allows the page to disable the ability to lock the screen orientation.
`allow-pointer-lock` Allows the page to use the [Pointer Lock API](https://developer.mozilla.org/en-US/docs/Web/API/Pointer_Lock_API).
`allow-popups` Allows popups (like from `window.open`, `target="_blank"`, `showModalDialog`). If this keyword is not used, that functionality will silently fail.
`allow-popups-to-escape-sandbox` Allows a sandboxed document to open new windows without forcing the sandboxing flags upon them. This will allow, for example, a third-party advertisement to be safely sandboxed without forcing the same restrictions upon the page the ad links to.
`allow-presentation` Allows embedders to have control over whether an iframe can start a presentation session.
`allow-same-origin` Allows the content to be treated as being from its normal origin. If this keyword is not used, the embedded content is treated as being from a unique origin.
`allow-scripts` Allows the page to run scripts (but not create pop-up windows). If this keyword is not used, this operation is not allowed.
`allow-storage-access-by-user-activation` Experimental
Lets the resource request access to the parent's storage capabilities with the [Storage Access API](https://developer.mozilla.org/en-US/docs/Web/API/Storage_Access_API).
`allow-top-navigation` Allows the page to navigate (load) content to the top-level browsing context. If this keyword is not used, this operation is not allowed.
`allow-top-navigation-by-user-activation` Lets the resource navigate the top-level browsing context, but only if initiated by a user gesture.
`allow-top-navigation-to-custom-protocols` Allows navigations toward non-fetch schemes to be handed off to external software.
Examples
--------
```
Content-Security-Policy: sandbox allow-scripts;
```
Specifications
--------------
| Specification |
| --- |
| [Content Security Policy Level 3 # directive-sandbox](https://w3c.github.io/webappsec-csp/#directive-sandbox) |
Browser compatibility
---------------------
| | Desktop | Mobile |
| --- | --- | --- |
| | Chrome | Edge | Firefox | Internet Explorer | Opera | Safari | WebView Android | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet |
| `sandbox` | 25 | 14 | 50 | 10 | 15 | 7 | Yes | Yes | 50 | Yes | 7 | Yes |
See also
--------
* [`Content-Security-Policy`](../content-security-policy)
* [`sandbox`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/iframe#attr-sandbox) attribute on [`<iframe>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/iframe) elements
http CSP: script-src CSP: script-src
===============
CSP: script-src
===============
The HTTP [`Content-Security-Policy`](../content-security-policy) (CSP) `script-src` directive specifies valid sources for JavaScript. This includes not only URLs loaded directly into [`<script>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/script) elements, but also things like inline script event handlers (`onclick`) and [XSLT stylesheets](https://developer.mozilla.org/en-US/docs/Web/XSLT) which can trigger script execution.
| | |
| --- | --- |
| CSP version | 1 |
| Directive type | [Fetch directive](https://developer.mozilla.org/en-US/docs/Glossary/Fetch_directive) |
| [`default-src`](default-src) fallback | Yes. If this directive is absent, the user agent will look for the `default-src` directive. |
Syntax
------
One or more sources can be allowed for the `script-src` policy:
```
Content-Security-Policy: script-src <source>;
Content-Security-Policy: script-src <source> <source>;
```
### Sources
`<source>` can be any one of the values listed in [CSP Source Values](sources#sources).
Note that this same set of values can be used in all [fetch directives](https://developer.mozilla.org/en-US/docs/Glossary/Fetch_directive) (and a [number of other directives](sources#relevant_directives)).
Examples
--------
### Violation case
Given this CSP header:
```
Content-Security-Policy: script-src https://example.com/
```
the following script is blocked and won't be loaded or executed:
```
<script src="https://not-example.com/js/library.js"></script>
```
Note that inline event handlers are blocked as well:
```
<button id="btn" onclick="doSomething()"></button>
```
You should replace them with [`addEventListener`](https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener) calls:
```
document.getElementById("btn").addEventListener("click", doSomething);
```
### Unsafe inline script
**Note:** Disallowing inline styles and inline scripts is one of the biggest security wins CSP provides. However, if you absolutely have to use it, there are a few mechanisms that will allow them.
To allow inline scripts and inline event handlers, `'unsafe-inline'`, a nonce-source or a hash-source that matches the inline block can be specified.
```
Content-Security-Policy: script-src 'unsafe-inline';
```
The above Content Security Policy will allow inline [`<script>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/script) elements
```
<script>
const inline = 1;
// …
</script>
```
You can use a nonce-source to only allow specific inline script blocks:
```
Content-Security-Policy: script-src 'nonce-2726c7f26c'
```
You will have to set the same nonce on the [`<script>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/script) element:
```
<script nonce="2726c7f26c">
const inline = 1;
// …
</script>
```
Alternatively, you can create hashes from your inline scripts. CSP supports sha256, sha384 and sha512.
```
Content-Security-Policy: script-src 'sha256-B2yPHKaXnvFWtRChIbabYmUBFZdVfKKXHbWtWidDVF8='
```
When generating the hash, don't include the [`<script>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/script) tags and note that capitalization and whitespace matter, including leading or trailing whitespace.
```
<script>
const inline = 1;
</script>
```
### Unsafe eval expressions
The `'unsafe-eval'` source expression controls several script execution methods that create code from strings. If a page has a CSP header and `'unsafe-eval'` isn't specified with the `script-src` directive, the following methods are blocked and won't have any effect:
* [`eval()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/eval)
* [`Function()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function)
* When passing a string literal like to methods like: `setTimeout("alert(\"Hello World!\");", 500);`
+ [`setTimeout()`](https://developer.mozilla.org/en-US/docs/Web/API/setTimeout)
+ [`setInterval()`](https://developer.mozilla.org/en-US/docs/Web/API/setInterval)
+ [`window.setImmediate`](https://developer.mozilla.org/en-US/docs/Web/API/Window/setImmediate)
* `window.execScript()` Non-standard (IE < 11 only)
### Unsafe WebAssembly execution
The `'wasm-unsafe-eval'` source expression controls WebAssembly execution. If a page has a CSP header and `'wasm-unsafe-eval'` isn't specified in the `script-src` directive, WebAssembly is blocked from loading and executing on the page. The `'wasm-unsafe-eval'` source expression is more specific than `'unsafe-eval'` which permits both compilation (and instantiation) of WebAssembly and, for example, the use of the `eval` operation in JavaScript. If the `'unsafe-eval'` source keyword is used, then this overrides any occurrence of `'wasm-unsafe-eval'` in the CSP policy.
```
Content-Security-Policy: script-src 'wasm-unsafe-eval'
```
### strict-dynamic
The `'strict-dynamic'` source expression specifies that the trust explicitly given to a script present in the markup, by accompanying it with a nonce or a hash, shall be propagated to all the scripts loaded by that root script. At the same time, any allowlist or source expressions such as `'self'` or `'unsafe-inline'` will be ignored.
For example, a policy such as `script-src 'strict-dynamic' 'nonce-R4nd0m' https://allowlisted.example.com/` would allow loading of a root script with `<script nonce="R4nd0m" src="https://example.com/loader.js">` and propagate that trust to any script loaded by `loader.js`, but disallow loading scripts from `https://allowlisted.example.com/` unless accompanied by a nonce or loaded from a trusted script.
```
Content-Security-Policy: script-src 'strict-dynamic' 'nonce-someNonce'
```
Or:
```
Content-Security-Policy: script-src 'strict-dynamic' 'sha256-base64EncodedHash'
```
It is possible to deploy `strict-dynamic` in a backwards compatible way, without requiring user-agent sniffing. The policy:
```
Content-Security-Policy: script-src 'unsafe-inline' https: 'nonce-abcdefg' 'strict-dynamic'
```
will act like `'unsafe-inline' https:` in browsers that support CSP1, `https: 'nonce-abcdefg'` in browsers that support CSP2, and `'nonce-abcdefg' 'strict-dynamic'` in browsers that support CSP3.
Specifications
--------------
| Specification |
| --- |
| [Content Security Policy Level 3 # directive-script-src](https://w3c.github.io/webappsec-csp/#directive-script-src) |
Browser compatibility
---------------------
| | Desktop | Mobile |
| --- | --- | --- |
| | Chrome | Edge | Firefox | Internet Explorer | Opera | Safari | WebView Android | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet |
| `script-src` | 25 | 14 | 23 | No | 15 | 7 | Yes | Yes | 23 | Yes | 7 | Yes |
| `external_scripts` | 59 | ≤79 | No | No | 46 | No | 59 | 59 | No | 43 | No | 7.0 |
| `wasm-unsafe-eval` | 97 | 97 | 102 | No | 83 | 16 | 97 | 97 | 102 | 68 | 16 | 18.0 |
See also
--------
* [`Content-Security-Policy`](../content-security-policy)
* [`Sources`](sources)
* [`<script>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/script)
* [`script-src-elem`](script-src-elem)
* [`script-src-attr`](script-src-attr)
http CSP: default-src CSP: default-src
================
CSP: default-src
================
The HTTP [`Content-Security-Policy`](../content-security-policy) (CSP) `default-src` directive serves as a fallback for the other CSP [fetch directives](https://developer.mozilla.org/en-US/docs/Glossary/Fetch_directive). For each of the following directives that are absent, the user agent looks for the `default-src` directive and uses this value for it:
* [`child-src`](child-src)
* [`connect-src`](connect-src)
* [`font-src`](font-src)
* [`frame-src`](frame-src)
* [`img-src`](img-src)
* [`manifest-src`](manifest-src)
* [`media-src`](media-src)
* [`object-src`](object-src)
* [`prefetch-src`](prefetch-src)
* [`script-src`](script-src)
* [`script-src-elem`](script-src-elem)
* [`script-src-attr`](script-src-attr)
* [`style-src`](style-src)
* [`style-src-elem`](style-src-elem)
* [`style-src-attr`](style-src-attr)
* [`worker-src`](worker-src)
| | |
| --- | --- |
| CSP version | 1 |
| Directive type | [Fetch directive](https://developer.mozilla.org/en-US/docs/Glossary/Fetch_directive) |
Syntax
------
One or more sources can be allowed for the `default-src` policy:
```
Content-Security-Policy: default-src <source>;
Content-Security-Policy: default-src <source> <source>;
```
### Sources
`<source>` can be any one of the values listed in [CSP Source Values](sources#sources).
Note that this same set of values can be used in all [fetch directives](https://developer.mozilla.org/en-US/docs/Glossary/Fetch_directive) (and a [number of other directives](sources#relevant_directives)).
Examples
--------
### No inheritance with default-src
If there are other directives specified, `default-src` does not influence them. The following header:
```
Content-Security-Policy: default-src 'self'; script-src https://example.com
```
is the same as:
```
Content-Security-Policy: connect-src 'self';
font-src 'self';
frame-src 'self';
img-src 'self';
manifest-src 'self';
media-src 'self';
object-src 'self';
script-src https://example.com;
style-src 'self';
worker-src 'self'
```
Specifications
--------------
| Specification |
| --- |
| [Content Security Policy Level 3 # directive-default-src](https://w3c.github.io/webappsec-csp/#directive-default-src) |
Browser compatibility
---------------------
| | Desktop | Mobile |
| --- | --- | --- |
| | Chrome | Edge | Firefox | Internet Explorer | Opera | Safari | WebView Android | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet |
| `default-src` | 25 | 14 | 23 | No | 15 | 7 | Yes | Yes | 23 | Yes | 7 | Yes |
See also
--------
* [`Content-Security-Policy`](../content-security-policy)
* CSP directives (<https://www.w3.org/TR/CSP/#csp-directives>):
+ [Fetch directive](https://developer.mozilla.org/en-US/docs/Glossary/Fetch_directive)
+ [Document directive](https://developer.mozilla.org/en-US/docs/Glossary/Document_directive)
+ [Navigation directive](https://developer.mozilla.org/en-US/docs/Glossary/Navigation_directive)
+ [Reporting directive](https://developer.mozilla.org/en-US/docs/Glossary/Reporting_directive)
+ [`upgrade-insecure-requests`](upgrade-insecure-requests)
+ [`block-all-mixed-content`](block-all-mixed-content)
+ [`require-sri-for`](require-sri-for) Experimental
http CSP: report-to CSP: report-to
==============
CSP: report-to
==============
The `Content-Security-Policy` `Report-To` HTTP response header field instructs the user agent to store reporting endpoints for an origin.
```
Content-Security-Policy: …; report-to groupname
```
The directive has no effect in and of itself, but only gains meaning in combination with other directives.
| | |
| --- | --- |
| CSP version | 1 |
| Directive type | [Reporting directive](https://developer.mozilla.org/en-US/docs/Glossary/Reporting_directive) |
| This directive is not supported in the [`<meta>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/meta) element. |
Syntax
------
```
Content-Security-Policy: report-to <json-field-value>;
```
Examples
--------
See [`Content-Security-Policy-Report-Only`](../content-security-policy-report-only) for more information and examples.
```
Report-To: { "group": "csp-endpoint",
"max\_age": 10886400,
"endpoints": [
{ "url": "https://example.com/csp-reports" }
] },
{ "group": "hpkp-endpoint",
"max\_age": 10886400,
"endpoints": [
{ "url": "https://example.com/hpkp-reports" }
] }
Content-Security-Policy: …; report-to csp-endpoint
```
```
Report-To: { "group": "endpoint-1",
"max\_age": 10886400,
"endpoints": [
{ "url": "https://example.com/reports" },
{ "url": "https://backup.com/reports" }
] }
Content-Security-Policy: …; report-to endpoint-1
```
```
Reporting-Endpoints: endpoint-1="https://example.com/reports"
Content-Security-Policy: …; report-to endpoint-1
```
Specifications
--------------
| Specification |
| --- |
| [Content Security Policy Level 3 # directive-report-to](https://w3c.github.io/webappsec-csp/#directive-report-to) |
Browser compatibility
---------------------
| | Desktop | Mobile |
| --- | --- | --- |
| | Chrome | Edge | Firefox | Internet Explorer | Opera | Safari | WebView Android | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet |
| `report-to` | 70 | 79 | No | No | 57 | No | 70 | 70 | No | 49 | No | 10.0 |
See also
--------
* [`Content-Security-Policy`](../content-security-policy)
* [`Content-Security-Policy-Report-Only`](../content-security-policy-report-only)
http CSP: object-src CSP: object-src
===============
CSP: object-src
===============
The HTTP [`Content-Security-Policy`](../content-security-policy) `object-src` directive specifies valid sources for the [`<object>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/object), [`<embed>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/embed), and [`<applet>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/applet) elements.
To set allowed types for [`<object>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/object), [`<embed>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/embed), and [`<applet>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/applet) elements, use the [`plugin-types`](plugin-types) directive.
**Note:** Elements controlled by `object-src` are perhaps coincidentally considered legacy HTML elements and aren't receiving new standardized features (such as the security attributes `sandbox` or `allow` for `<iframe>`). Therefore it is [recommended](https://csp.withgoogle.com/docs/strict-csp.html) to restrict this fetch-directive (e.g. explicitly set `object-src 'none'` if possible).
| | |
| --- | --- |
| CSP version | 1 |
| Directive type | [Fetch directive](https://developer.mozilla.org/en-US/docs/Glossary/Fetch_directive) |
| [`default-src`](default-src) fallback | Yes. If this directive is absent, the user agent will look for the `default-src` directive. |
Syntax
------
One or more sources can be allowed for the `object-src` policy:
```
Content-Security-Policy: object-src <source>;
Content-Security-Policy: object-src <source> <source>;
```
### Sources
`<source>` can be any one of the values listed in [CSP Source Values](sources#sources).
Note that this same set of values can be used in all [fetch directives](https://developer.mozilla.org/en-US/docs/Glossary/Fetch_directive) (and a [number of other directives](sources#relevant_directives)).
Examples
--------
### Violation cases
Given this CSP header:
```
Content-Security-Policy: object-src https://example.com/
```
The following [`<object>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/object), [`<embed>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/embed), and [`<applet>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/applet) elements are blocked and won't load:
```
<embed src="https://not-example.com/flash"></embed>
<object data="https://not-example.com/plugin"></object>
<applet archive="https://not-example.com/java"></applet>
```
Specifications
--------------
| Specification |
| --- |
| [Content Security Policy Level 3 # directive-object-src](https://w3c.github.io/webappsec-csp/#directive-object-src) |
Browser compatibility
---------------------
| | Desktop | Mobile |
| --- | --- | --- |
| | Chrome | Edge | Firefox | Internet Explorer | Opera | Safari | WebView Android | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet |
| `object-src` | 25 | 14 | 23 | No | 15 | 7 | Yes | Yes | 23 | Yes | 7 | Yes |
See also
--------
* [`Content-Security-Policy`](../content-security-policy)
* [`<object>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/object), [`<embed>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/embed), and [`<applet>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/applet)
* [`plugin-types`](plugin-types)
| programming_docs |
http CSP: font-src CSP: font-src
=============
CSP: font-src
=============
The HTTP [`Content-Security-Policy`](../content-security-policy) (CSP) `font-src` directive specifies valid sources for fonts loaded using [`@font-face`](https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face).
| | |
| --- | --- |
| CSP version | 1 |
| Directive type | [Fetch directive](https://developer.mozilla.org/en-US/docs/Glossary/Fetch_directive) |
| [`default-src`](default-src) fallback | Yes. If this directive is absent, the user agent will look for the `default-src` directive. |
Syntax
------
One or more sources can be allowed for the `font-src` policy:
```
Content-Security-Policy: font-src <source>;
Content-Security-Policy: font-src <source> <source>;
```
### Sources
`<source>` can be any one of the values listed in [CSP Source Values](sources#sources).
Note that this same set of values can be used in all [fetch directives](https://developer.mozilla.org/en-US/docs/Glossary/Fetch_directive) (and a [number of other directives](sources#relevant_directives)).
Examples
--------
### Violation cases
Given this CSP header:
```
Content-Security-Policy: font-src https://example.com/
```
The following font resource loading is blocked and won't load:
```
<style>
@font-face {
font-family: "MyFont";
src: url("https://not-example.com/font");
}
body {
font-family: "MyFont";
}
</style>
```
Specifications
--------------
| Specification |
| --- |
| [Content Security Policy Level 3 # directive-font-src](https://w3c.github.io/webappsec-csp/#directive-font-src) |
Browser compatibility
---------------------
| | Desktop | Mobile |
| --- | --- | --- |
| | Chrome | Edge | Firefox | Internet Explorer | Opera | Safari | WebView Android | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet |
| `font-src` | 25 | 14 | 23 | No | 15 | 7 | Yes | Yes | 23 | Yes | 7 | Yes |
See also
--------
* [`Content-Security-Policy`](../content-security-policy)
* [`@font-face`](https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face)
http CSP: trusted-types CSP: trusted-types
==================
CSP: trusted-types
==================
**Experimental:** **This is an [experimental technology](https://developer.mozilla.org/en-US/docs/MDN/Writing_guidelines/Experimental_deprecated_obsolete#experimental)**
Check the [Browser compatibility table](#browser_compatibility) carefully before using this in production.
The HTTP [`Content-Security-Policy`](../content-security-policy) (CSP) `trusted-types` Experimental directive instructs user agents to restrict the creation of Trusted Types policies - functions that build non-spoofable, typed values intended to be passed to DOM XSS sinks in place of strings.
Together with **[`require-trusted-types-for`](require-trusted-types-for)** directive, this allows authors to define rules guarding writing values to the DOM and thus reducing the DOM XSS attack surface to small, isolated parts of the web application codebase, facilitating their monitoring and code review. This directive declares an allow-list of trusted type policy names created with `trustedTypes.createPolicy` from Trusted Types API.
Syntax
------
```
Content-Security-Policy: trusted-types;
Content-Security-Policy: trusted-types 'none';
Content-Security-Policy: trusted-types <policyName>;
Content-Security-Policy: trusted-types <policyName> <policyName> 'allow-duplicates';
```
<policyName> A valid policy name consists only of alphanumeric characters, or one of "`-#=_/@.%`". A star (`*`) as a policy name instructs the user agent to allow any unique policy name ('`allow-duplicates`' may relax that further).
`'none'` Disallows creating any Trusted Type policy (same as not specifying any *<policyName>*).
`'allow-duplicates'` Allows for creating policies with a name that was already used.
Examples
--------
```
// Content-Security-Policy: trusted-types foo bar 'allow-duplicates';
if (typeof trustedTypes !== 'undefined') {
const policyFoo = trustedTypes.createPolicy('foo', {});
const policyFoo2 = trustedTypes.createPolicy('foo', {});
const policyBaz = trustedTypes.createPolicy('baz', {}); // Throws and dispatches a SecurityPolicyViolationEvent.
}
```
Specifications
--------------
| Specification |
| --- |
| [Trusted Types # trusted-types-csp-directive](https://w3c.github.io/trusted-types/dist/spec/#trusted-types-csp-directive) |
Browser compatibility
---------------------
| | Desktop | Mobile |
| --- | --- | --- |
| | Chrome | Edge | Firefox | Internet Explorer | Opera | Safari | WebView Android | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet |
| `trusted-types` | 83 | 83 | No | No | 69 | No | 83 | 83 | No | No | No | 13.0 |
See also
--------
* [`Content-Security-Policy`](../content-security-policy)
* [Cross-Site Scripting (XSS)](https://developer.mozilla.org/en-US/docs/Glossary/Cross-site_scripting)
* [Prevent DOM-based cross-site scripting vulnerabilities with Trusted Types](https://web.dev/trusted-types/)
* Trusted Types with [DOMPurify](https://github.com/cure53/DOMPurify#what-about-dompurify-and-trusted-types) XSS sanitizer
* [Trusted Types polyfill](https://github.com/w3c/webappsec-trusted-types#polyfill)
http CSP: worker-src CSP: worker-src
===============
CSP: worker-src
===============
The HTTP [`Content-Security-Policy`](../content-security-policy) (CSP) `worker-src` directive specifies valid sources for [`Worker`](https://developer.mozilla.org/en-US/docs/Web/API/Worker), [`SharedWorker`](https://developer.mozilla.org/en-US/docs/Web/API/SharedWorker), or [`ServiceWorker`](https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorker) scripts.
| | |
| --- | --- |
| CSP version | 3 |
| Directive type | [Fetch directive](https://developer.mozilla.org/en-US/docs/Glossary/Fetch_directive) |
| Fallback | If this directive is absent, the user agent will first look for the [`child-src`](child-src) directive, then the [`script-src`](script-src) directive, then finally for the [`default-src`](default-src) directive, when governing worker execution. |
Syntax
------
One or more sources can be allowed for the `worker-src` policy:
```
Content-Security-Policy: worker-src <source>;
Content-Security-Policy: worker-src <source> <source>;
```
### Sources
`<source>` can be any one of the values listed in [CSP Source Values](sources#sources).
Note that this same set of values can be used in all [fetch directives](https://developer.mozilla.org/en-US/docs/Glossary/Fetch_directive) (and a [number of other directives](sources#relevant_directives)).
Examples
--------
### Violation cases
Given this CSP header:
```
Content-Security-Policy: worker-src https://example.com/
```
[`Worker`](https://developer.mozilla.org/en-US/docs/Web/API/Worker), [`SharedWorker`](https://developer.mozilla.org/en-US/docs/Web/API/SharedWorker), [`ServiceWorker`](https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorker) are blocked and won't load:
```
<script>
let blockedWorker = new Worker("data:application/javascript,…");
blockedWorker = new SharedWorker("https://not-example.com/");
navigator.serviceWorker.register("https://not-example.com/sw.js");
</script>
```
Specifications
--------------
| Specification |
| --- |
| [Content Security Policy Level 3 # directive-worker-src](https://w3c.github.io/webappsec-csp/#directive-worker-src) |
Browser compatibility
---------------------
| | Desktop | Mobile |
| --- | --- | --- |
| | Chrome | Edge | Firefox | Internet Explorer | Opera | Safari | WebView Android | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet |
| `worker-src` | 59
Chrome 59 and higher skips the deprecated `child-src` directive. | 79 | 58 | No | 46
Opera 46 and higher skips the deprecated `child-src` directive. | 15.5 | 59
Chrome 59 and higher skips the deprecated `child-src` directive. | 59
Chrome 59 and higher skips the deprecated `child-src` directive. | 58 | 43
Opera 43 and higher skips the deprecated `child-src` directive. | 15.5 | 7.0 |
See also
--------
* [`Content-Security-Policy`](../content-security-policy)
* [CSP for Web Workers](https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Using_web_workers#content_security_policy)
* [`Worker`](https://developer.mozilla.org/en-US/docs/Web/API/Worker), [`SharedWorker`](https://developer.mozilla.org/en-US/docs/Web/API/SharedWorker), [`ServiceWorker`](https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorker)
http CSP: frame-ancestors CSP: frame-ancestors
====================
CSP: frame-ancestors
====================
The HTTP [`Content-Security-Policy`](../content-security-policy) (CSP) `frame-ancestors` directive specifies valid parents that may embed a page using [`<frame>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/frame), [`<iframe>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/iframe), [`<object>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/object), [`<embed>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/embed), or [`<applet>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/applet).
Setting this directive to `'none'` is similar to [`X-Frame-Options`](../x-frame-options)`: deny` (which is also supported in older browsers).
**Note:** `frame-ancestors` allows you to specify what parent source may embed a page. This differs from `frame-src`, which allows you to specify where iframes in a page may be loaded from.
| | |
| --- | --- |
| CSP version | 2 |
| Directive type | [Navigation directive](https://developer.mozilla.org/en-US/docs/Glossary/Navigation_directive) |
| [`default-src`](default-src) fallback | No. Not setting this allows anything. |
| This directive is not supported in the [`<meta>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/meta) element. |
Syntax
------
One or more sources can be set for the `frame-ancestors` policy:
```
Content-Security-Policy: frame-ancestors <source>;
Content-Security-Policy: frame-ancestors <space separated list of sources>;
```
### Sources
<source> can be one of the following:
**Note:** The `frame-ancestors` directive's syntax is similar to a source list of other directives (e.g. [`default-src`](default-src)), but doesn't allow `'unsafe-eval'` or `'unsafe-inline'` for example. It will also not fall back to a `default-src` setting. Only the sources listed below are allowed:
<host-source> Internet hosts by name or IP address, as well as an optional [URL](https://developer.mozilla.org/en-US/docs/Glossary/URL) scheme and/or port number, separated by spaces. The site's address may include an optional leading wildcard (the asterisk character, `'*'`), and you may use a wildcard (again, `'*'`) as the port number, indicating that all legal ports are valid for the source. Single quotes surrounding the host are not allowed. Examples:
* `http://*.example.com`: Matches all attempts to load from any subdomain of example.com using the `http:` URL scheme.
* `mail.example.com:443`: Matches all attempts to access port 443 on mail.example.com.
* `https://store.example.com`: Matches all attempts to access store.example.com using `https:`.
**Warning:** If no URL scheme is specified for a `host-source` and the iframe is loaded from an `https` URL, the URL for the page loading the iframe must also be `https`, per the [Does URL match expression in origin with redirect count?](https://w3c.github.io/webappsec-csp/#match-url-to-source-expression) section of the CSP spec.
<scheme-source> A scheme such as `http:` or `https:`. The colon is required and scheme should not be quoted. You can also specify data schemes (not recommended).
* `data:` Allows [`data:` URLs](../../basics_of_http/data_urls) to be used as a content source. *This is insecure; an attacker can also inject arbitrary `data:` URLs. Use this sparingly and definitely not for scripts.*
* `mediastream:` Allows [`mediastream:` URIs](https://developer.mozilla.org/en-US/docs/Web/API/Media_Capture_and_Streams_API) to be used as a content source.
* `blob:` Allows [`blob:` URIs](https://developer.mozilla.org/en-US/docs/Web/API/Blob) to be used as a content source.
* `filesystem:` Allows [`filesystem:` URIs](https://developer.mozilla.org/en-US/docs/Web/API/FileSystem) to be used as a content source.
`'self'` Refers to the origin from which the protected document is being served, including the same URL scheme and port number. You must include the single quotes. Some browsers specifically exclude `blob` and `filesystem` from source directives. Sites needing to allow these content types can specify them using the Data attribute.
`'none'` Refers to the empty set; that is, no URLs match. The single quotes are required.
Examples
--------
```
Content-Security-Policy: frame-ancestors 'none';
Content-Security-Policy: frame-ancestors 'self' https://www.example.org;
Content-Security-Policy: frame-ancestors 'self' https://example.org https://example.com https://store.example.com;
```
Specifications
--------------
| Specification |
| --- |
| [Content Security Policy Level 3 # directive-frame-ancestors](https://w3c.github.io/webappsec-csp/#directive-frame-ancestors) |
Browser compatibility
---------------------
| | Desktop | Mobile |
| --- | --- | --- |
| | Chrome | Edge | Firefox | Internet Explorer | Opera | Safari | WebView Android | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet |
| `frame-ancestors` | 40 | 15 | 33
Before Firefox 58, `frame-ancestors` is ignored in `Content-Security-Policy-Report-Only`. | No | 26 | 10 | Yes | Yes | 33
Before Firefox for Android 58, `frame-ancestors` is ignored in `Content-Security-Policy-Report-Only`. | Yes | 9.3 | Yes |
See also
--------
* [`Content-Security-Policy`](../content-security-policy)
* [`X-Frame-Options`](../x-frame-options)
* [`frame-src`](frame-src) CSP
http CSP: report-uri CSP: report-uri
===============
CSP: report-uri
===============
**Deprecated:** This feature is no longer recommended. Though some browsers might still support it, it may have already been removed from the relevant web standards, may be in the process of being dropped, or may only be kept for compatibility purposes. Avoid using it, and update existing code if possible; see the [compatibility table](#browser_compatibility) at the bottom of this page to guide your decision. Be aware that this feature may cease to work at any time.
The deprecated HTTP [`Content-Security-Policy`](../content-security-policy) (CSP) `report-uri` directive instructs the user agent to report attempts to violate the Content Security Policy. These violation reports consist of JSON documents sent via an HTTP POST request to the specified URI.
**Warning:** Though the [`report-to`](report-to) directive is intended to replace the deprecated `report-uri` directive, [`report-to`](report-to) isn't supported in most browsers yet. So for compatibility with current browsers while also adding forward compatibility when browsers get [`report-to`](report-to) support, you can specify both `report-uri` and [`report-to`](report-to):
```
Content-Security-Policy: …; report-uri https://endpoint.com; report-to groupname
```
In browsers that support [`report-to`](report-to), the `report-uri` directive will be ignored.
The directive has no effect in and of itself, but only gains meaning in combination with other directives.
| | |
| --- | --- |
| CSP version | 1 |
| Directive type | [Reporting directive](https://developer.mozilla.org/en-US/docs/Glossary/Reporting_directive) |
| This directive is not supported in the [`<meta>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/meta) element. |
Syntax
------
```
Content-Security-Policy: report-uri <uri>;
Content-Security-Policy: report-uri <uri> <uri>;
```
<uri> A URI where to POST the report to.
Examples
--------
See [`Content-Security-Policy-Report-Only`](../content-security-policy-report-only) for more information and examples.
```
Content-Security-Policy: default-src https:; report-uri /csp-violation-report-endpoint/
```
`/csp-violation-report-endpoint/` could for example run a PHP something like the following that logs the JSON detailing the violation and, if the violation is the first one added to the log file, sends an email to an administrator:
```
<?php
// Start configure
$log\_file = dirname(\_\_FILE\_\_) . '/csp-violations.log';
$log\_file\_size\_limit = 1000000; // bytes - once exceeded no further entries are added
$email\_address = '[email protected]';
$email\_subject = 'Content-Security-Policy violation';
// End configuration
$current\_domain = preg\_replace('/www\./i', '', $\_SERVER['SERVER\_NAME']);
$email\_subject = $email\_subject . ' on ' . $current\_domain;
http\_response\_code(204); // HTTP 204 No Content
$json\_data = file\_get\_contents('php://input');
// We pretty print the JSON before adding it to the log file
if ($json\_data = json\_decode($json\_data)) {
$json\_data = json\_encode($json\_data, JSON\_PRETTY\_PRINT | JSON\_UNESCAPED\_SLASHES);
if (!file\_exists($log\_file)) {
// Send an email
$message = "The following Content-Security-Policy violation occurred on " .
$current\_domain . ":\n\n" .
$json\_data .
"\n\nFurther CPS violations will be logged to the following log file, but no further email notifications will be sent until this log file is deleted:\n\n" .
$log\_file;
mail($email\_address, $email\_subject, $message,
'Content-Type: text/plain;charset=utf-8');
} else if (filesize($log\_file) > $log\_file\_size\_limit) {
exit(0);
}
file\_put\_contents($log\_file, $json\_data, FILE\_APPEND | LOCK\_EX);
}
```
Specifications
--------------
| Specification |
| --- |
| [Content Security Policy Level 3 # directive-report-uri](https://w3c.github.io/webappsec-csp/#directive-report-uri) |
Browser compatibility
---------------------
| | Desktop | Mobile |
| --- | --- | --- |
| | Chrome | Edge | Firefox | Internet Explorer | Opera | Safari | WebView Android | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet |
| `report-uri` | 25 | 14 | 23 | No | 15 | 7 | Yes | Yes | 23 | Yes | 7 | Yes |
See also
--------
* [`Content-Security-Policy`](../content-security-policy)
* [`Content-Security-Policy-Report-Only`](../content-security-policy-report-only)
* [`report-to`](report-to)
http CSP: Sources CSP: Sources
============
CSP source values
=================
HTTP [`Content-Security-Policy`](../content-security-policy) (CSP) header directives that specify a `<source>` from which resources may be loaded can use any one of the values listed below. Relevant directives include the [fetch directives](https://developer.mozilla.org/en-US/docs/Glossary/Fetch_directive), along with others [listed below](#relevant_directives).
Sources
-------
`<host-source>` Internet host by name or IP address. The [URL scheme](https://developer.mozilla.org/en-US/docs/Learn/Common_questions/What_is_a_URL), port number, and path are optional. Wildcards (`'*'`) can be used for subdomains, host address, and port number, indicating that all legal values of each are valid. When matching schemes, secure upgrades are allowed (e.g. specifying `http://example.com` will match `https://example.com`). Examples:
* `http://*.example.com`: Matches all attempts to load from any subdomain of example.com. Also matches `https` resources.
* `mail.example.com:443`: Matches all attempts to load from port 443 on mail.example.com.
* `https://store.example.com`: Matches all attempts to access store.example.com using `https:`.
* `*.example.com`: Matches all attempts to load from any subdomain of example.com.
* `https://*.example.com:12/path/to/file.js`: Matches all attempts to load from any subdomain of example.com using `https:` on port 12, and only if the path is `/path/to/file.js`.
* `ws://example.com`: Matches all attempts to load from example.com using `ws:`. Also matches `wss` resources.
`<scheme-source>` A scheme such as `http:` or `https:`. The colon is required. Unlike other values below, single quotes shouldn't be used. You can also specify data schemes (not recommended).
* `data:` Allows [`data:` URLs](../../basics_of_http/data_urls) to be used as a content source. *This is insecure; an attacker can also inject arbitrary `data:` URLs. Use this sparingly and definitely not for scripts.*
* `mediastream:` Allows [`mediastream:` URIs](https://developer.mozilla.org/en-US/docs/Web/API/Media_Capture_and_Streams_API) to be used as a content source.
* `blob:` Allows [`blob:` URIs](https://developer.mozilla.org/en-US/docs/Web/API/Blob) to be used as a content source.
* `filesystem:` Allows [`filesystem:` URIs](https://developer.mozilla.org/en-US/docs/Web/API/FileSystem) to be used as a content source.
**Note:** if a scheme source is missing, the document origin's scheme is used. Secure upgrades are allowed, so if the document is loaded using `https:`, then `example.com` will match `https://example.com` but not `http://example.com`. For more information, see [CSP Level 3](https://www.w3.org/TR/CSP3/#match-url-to-source-list).
`'self'` Refers to the origin from which the protected document is being served, including the same URL scheme and port number. You must include the single quotes. Some browsers specifically exclude `blob` and `filesystem` from source directives. Sites needing to allow these content types can specify them using the Data attribute.
`'unsafe-eval'` Allows the use of `eval()` and other unsafe methods for creating code from strings. You must include the single quotes.
`'wasm-unsafe-eval'` Allows the loading and execution of WebAssembly modules without the need to also allow unsafe JavaScript execution via `'unsafe-eval'`. The single quotes are required.
`'unsafe-hashes'` Allows enabling specific inline [event handlers](https://developer.mozilla.org/en-US/docs/Web/Events/Event_handlers). If you only need to allow inline event handlers and not inline [`<script>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/script) elements or `javascript:` URLs, this is a safer method than using the `unsafe-inline` expression.
`'unsafe-inline'` Allows the use of inline resources, such as inline [`<script>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/script) elements, `javascript:` URLs, inline event handlers, and inline [`<style>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/style) elements. The single quotes are required.
`'none'` Refers to the empty set; that is, no URLs match. The single quotes are required.
`'nonce-<base64-value>'` An allow-list for specific inline scripts using a cryptographic nonce (number used once). The server must generate a unique nonce value each time it transmits a policy. It is critical to provide an unguessable nonce, as bypassing a resource's policy is otherwise trivial. See [unsafe inline script](script-src#unsafe_inline_script) for an example. Specifying nonce makes a modern browser ignore `'unsafe-inline'` which could still be set for older browsers without nonce support.
**Note:** The CSP `nonce` source can only be applied to *nonceable* elements (e.g., as the [`<img>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/img) element has no `nonce` attribute, there is no way to associate it with this CSP source).
`'<hash-algorithm>-<base64-value>'` A sha256, sha384 or sha512 hash of scripts or styles. This value consists of the algorithm used to create the hash followed by a hyphen and the base64-encoded hash of the script or style. When generating the hash, exclude <script> or <style> tags and note that capitalization and whitespace matter, including leading or trailing whitespace. In CSP 2.0, hash sources can be applied to inline scripts and styles. Hash source expressions are allowed in [CSP 3.0](https://www.w3.org/TR/CSP3/#external-hash) for external scripts in `script-src` directives. See the [script-src](script-src#unsafe_inline_script) and [style-src](style-src#unsafe_inline_styles) pages for more information and examples.
`'strict-dynamic'` The `strict-dynamic` source expression specifies that the trust explicitly given to a script present in the markup, by accompanying it with a nonce or a hash, shall be propagated to all the scripts loaded by that root script. At the same time, any allow-list or source expressions such as `'self'` or `'unsafe-inline'` are ignored. See [script-src](script-src#strict-dynamic) for an example.
`'report-sample'` Requires a sample of the violating code to be included in the violation report.
Relevant directives
-------------------
Directives for which the above sources apply include:
* [Fetch directives](https://developer.mozilla.org/en-US/docs/Glossary/Fetch_directive) (all):
+ [`default-src`](default-src)
+ [`child-src`](child-src)
+ [`connect-src`](connect-src)
+ [`font-src`](font-src)
+ [`frame-src`](frame-src)
+ [`img-src`](img-src)
+ [`manifest-src`](manifest-src)
+ [`media-src`](media-src)
+ [`object-src`](object-src)
+ [`prefetch-src`](prefetch-src)
+ [`script-src`](script-src)
+ [`script-src-elem`](script-src-elem)
+ [`script-src-attr`](script-src-attr)
+ [`style-src`](style-src), [`style-src-elem`](style-src-elem)
+ [`style-src-attr`](style-src-attr)
+ [`worker-src`](worker-src)
* [Document directives](https://developer.mozilla.org/en-US/docs/Glossary/Document_directive):
+ [`base-uri`](base-uri)
* [Navigation directives](https://developer.mozilla.org/en-US/docs/Glossary/Navigation_directive):
+ [`navigate-to`](../content-security-policy)
+ [`form-action`](form-action)
| programming_docs |
http Errors Errors
======
CORS errors
===========
[Cross-Origin Resource Sharing](../cors) ([CORS](https://developer.mozilla.org/en-US/docs/Glossary/CORS)) is a standard that allows a server to relax the [same-origin policy](https://developer.mozilla.org/en-US/docs/Web/Security/Same-origin_policy). This is used to explicitly allow some cross-origin requests while rejecting others. For example, if a site offers an embeddable service, it may be necessary to relax certain restrictions. Setting up such a CORS configuration isn't necessarily easy and may present some challenges. In these pages, we'll look into some common CORS error messages and how to resolve them.
If the CORS configuration isn't setup correctly, the browser console will present an error like `"Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at $somesite"` indicating that the request was blocked due to violating the CORS security rules. This might not necessarily be a set-up mistake, though. It's possible that the request is in fact intentionally being disallowed by the user's web application and remote external service. However, If the endpoint is meant to be available, some debugging is needed to succeed.
Identifying the issue
---------------------
To understand the underlying issue with the CORS configuration, you need to find out which request is at fault and why. These steps may help you do so:
1. Navigate to the web site or web app in question and open the [Developer Tools](https://firefox-source-docs.mozilla.org/devtools-user/index.html).
2. Now try to reproduce the failing transaction and check the [console](https://firefox-source-docs.mozilla.org/devtools-user/web_console/index.html) if you are seeing a CORS violation error message. It will probably look like this:
The text of the error message will be something similar to the following:
```
Cross-Origin Request Blocked: The Same Origin Policy disallows
reading the remote resource at https://some-url-here. (Reason:
additional information here).
```
**Note:** For security reasons, specifics about what went wrong with a CORS request *are not available to JavaScript code*. All the code knows is that an error occurred. The only way to determine what specifically went wrong is to look at the browser's console for details.
CORS error messages
-------------------
Firefox's console displays messages in its console when requests fail due to CORS. Part of the error text is a "reason" message that provides added insight into what went wrong. The reason messages are listed below; click the message to open an article explaining the error in more detail and offering possible solutions.
* [Reason: CORS disabled](errors/corsdisabled)
* [Reason: CORS request did not succeed](errors/corsdidnotsucceed)
* [Reason: CORS header 'Origin' cannot be added](errors/corsoriginheadernotadded)
* [Reason: CORS request external redirect not allowed](errors/corsexternalredirectnotallowed)
* [Reason: CORS request not http](errors/corsrequestnothttp)
* [Reason: CORS header 'Access-Control-Allow-Origin' missing](errors/corsmissingalloworigin)
* [Reason: CORS header 'Access-Control-Allow-Origin' does not match 'xyz'](errors/corsalloworiginnotmatchingorigin)
* [Reason: Credential is not supported if the CORS header 'Access-Control-Allow-Origin' is '\*'](errors/corsnotsupportingcredentials)
* [Reason: Did not find method in CORS header 'Access-Control-Allow-Methods'](errors/corsmethodnotfound)
* [Reason: expected 'true' in CORS header 'Access-Control-Allow-Credentials'](errors/corsmissingallowcredentials)
* [Reason: CORS preflight channel did not succeed](errors/corspreflightdidnotsucceed)
* [Reason: invalid token 'xyz' in CORS header 'Access-Control-Allow-Methods'](errors/corsinvalidallowmethod)
* [Reason: invalid token 'xyz' in CORS header 'Access-Control-Allow-Headers'](errors/corsinvalidallowheader)
* [Reason: missing token 'xyz' in CORS header 'Access-Control-Allow-Headers' from CORS preflight channel](errors/corsmissingallowheaderfrompreflight)
* [Reason: Multiple CORS header 'Access-Control-Allow-Origin' not allowed](errors/corsmultiplealloworiginnotallowed)
See also
--------
* Glossary: [CORS](https://developer.mozilla.org/en-US/docs/Glossary/CORS)
* [CORS introduction](../cors)
* [Server-side CORS settings](../cors)
* [CORS enabled image](https://developer.mozilla.org/en-US/docs/Web/HTML/CORS_enabled_image)
* [CORS settings attributes](https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/crossorigin)
* <https://www.test-cors.org> – page to test CORS requests
http Errors: CORSMissingAllowHeaderFromPreflight Errors: CORSMissingAllowHeaderFromPreflight
===========================================
Reason: missing token 'xyz' in CORS header 'Access-Control-Allow-Headers' from CORS preflight channel
=====================================================================================================
Reason
------
```
Reason: missing token 'xyz' in CORS header 'Access-Control-Allow-Headers' from CORS preflight channel
```
What went wrong?
----------------
The `Access-Control-Allow-Headers` header is sent by the server to let the client know which headers it supports for [CORS](https://developer.mozilla.org/en-US/docs/Glossary/CORS) requests. The value of `Access-Control-Allow-Headers` should be a comma-delineated list of header names, such as "`X-Custom-Information`" or any of the standard but non-basic header names (which are always allowed).
This error occurs when attempting to preflight a header that is not expressly allowed (that is, it's not included in the list specified by the `Access-Control-Allow-Headers` header sent by the server). To fix this, the server needs to be updated so that it allows the indicated header, or you need to avoid using that header.
See also
--------
* [CORS errors](../errors)
* Glossary: [CORS](https://developer.mozilla.org/en-US/docs/Glossary/CORS)
* [CORS introduction](../../cors)
* [HTTP headers](../../headers)
http Errors: CORSAllowOriginNotMatchingOrigin Errors: CORSAllowOriginNotMatchingOrigin
========================================
Reason: CORS header 'Access-Control-Allow-Origin' does not match 'xyz'
======================================================================
Reason
------
```
Reason: CORS header 'Access-Control-Allow-Origin' does not match 'xyz'
```
What went wrong?
----------------
The origin making the request does not match the origin permitted by the [`Access-Control-Allow-Origin`](../../headers/access-control-allow-origin) header. This error can also occur if the response includes more than one `Access-Control-Allow-Origin` header.
If the service your code is accessing uses a CORS request under your control, make sure it is configured to include your origin in its `Access-Control-Allow-Origin` header. In addition, confirm that only one such header is included in responses, and that it includes only a single origin.
For example, in Apache, add a line such as the following to the server's configuration (within the appropriate `<Directory>`, `<Location>`, `<Files>`, or `<VirtualHost>` section). The configuration is typically found in a `.conf` file (`httpd.conf` and `apache.conf` are common names for these), or in an `.htaccess` file.
**Warning:** You must include the HTTPS or HTTP protocol as part of the origin.
```
Header set Access-Control-Allow-Origin 'origin'
```
For Nginx, the command to set up this header is:
```
add_header 'Access-Control-Allow-Origin' 'origin'
```
See also
--------
* [CORS errors](../errors)
* Glossary: [CORS](https://developer.mozilla.org/en-US/docs/Glossary/CORS)
* [CORS introduction](../../cors)
* [Enable CORS: I want to add CORS support to my server](https://enable-cors.org/server.html)
http Errors: CORSDidNotSucceed Errors: CORSDidNotSucceed
=========================
Reason: CORS request did not succeed
====================================
Reason
------
```
Reason: CORS request did not succeed
```
What went wrong?
----------------
The [HTTP](https://developer.mozilla.org/en-US/docs/Glossary/HTTP) request which makes use of CORS failed because the HTTP connection failed at either the network or protocol level. The error is not directly related to CORS, but is a fundamental network error of some kind.
In many cases, it is caused by a browser plugin (e.g. an ad blocker or privacy protector) blocking the request.
Other possible causes include:
* Trying to access an `https` resource that has an invalid certificate will cause this error.
* Trying to access an `http` resource from a page with an `https` origin will also cause this error.
* As of Firefox 68, `https` pages are not permitted to access `http://localhost`, although this may be changed by [Bug 1488740](https://bugzilla.mozilla.org/show_bug.cgi?id=1488740).
* The server did not respond to the actual request (even if it responded to the [Preflight request](https://developer.mozilla.org/en-US/docs/Glossary/Preflight_request)). One scenario might be an HTTP service being developed that panicked without returning any data.
See also
--------
* [CORS errors](../errors)
* Glossary: [CORS](https://developer.mozilla.org/en-US/docs/Glossary/CORS)
* [CORS introduction](../../cors)
http Errors: CORSInvalidAllowMethod Errors: CORSInvalidAllowMethod
==============================
Reason: invalid token 'xyz' in CORS header 'Access-Control-Allow-Methods'
=========================================================================
Reason
------
```
Reason: invalid token 'xyz' in CORS header 'Access-Control-Allow-Methods'
```
What went wrong?
----------------
The response to the [CORS](https://developer.mozilla.org/en-US/docs/Glossary/CORS) request that was sent by the server includes an [`Access-Control-Allow-Methods`](../../headers/access-control-allow-methods) header which includes at least one invalid method name.
The `Access-Control-Allow-Methods` header is sent by the server to let the client know what [HTTP request methods](../../methods) it supports for CORS requests. The header's value is a comma-delineated string of HTTP method names, such as [`GET`](../../methods/get), [`POST`](../../methods/post), or [`HEAD`](../../methods/head). If any of the specified values are not recognized by the client [user agent](https://developer.mozilla.org/en-US/docs/Glossary/User_agent), this error occurs.
This is a problem that most likely can only be fixed on the server side, by modifying the server's configuration to no longer send the invalid or unknown method name with the `Access-Control-Allow-Methods` header. It may also be worth checking to ensure that the user agent or HTTP library you're using on the client is up-to-date.
See also
--------
* [CORS errors](../errors)
* Glossary: [CORS](https://developer.mozilla.org/en-US/docs/Glossary/CORS)
* [CORS introduction](../../cors)
* [HTTP request methods](../../methods)
http Errors: CORSNotSupportingCredentials Errors: CORSNotSupportingCredentials
====================================
Reason: Credential is not supported if the CORS header 'Access-Control-Allow-Origin' is '\*'
============================================================================================
Reason
------
```
Reason: Credential is not supported if the CORS header 'Access-Control-Allow-Origin' is '*'
```
What went wrong?
----------------
The [CORS](https://developer.mozilla.org/en-US/docs/Glossary/CORS) request was attempted with the credentials flag set, but the server is configured using the wildcard (`"*"`) as the value of [`Access-Control-Allow-Origin`](../../headers/access-control-allow-origin), which doesn't allow the use of credentials.
To correct this problem on the client side, ensure that the credentials flag's value is `false` when issuing your CORS request.
* If the request is being issued using [`XMLHttpRequest`](https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest), make sure you're not setting [`withCredentials`](https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/withCredentials) to `true`.
* If using [Server-sent events](https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events), make sure [`EventSource.withCredentials`](https://developer.mozilla.org/en-US/docs/Web/API/EventSource/withCredentials) is `false` (it's the default value).
* If using the [Fetch API](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API), make sure [`Request.credentials`](https://developer.mozilla.org/en-US/docs/Web/API/Request/credentials) is `"omit"`.
If, instead, you need to adjust the server's behavior, you'll need to change the value of `Access-Control-Allow-Origin` to grant access to the origin from which the client is loaded.
See also
--------
* [CORS errors](../errors)
* Glossary: [CORS](https://developer.mozilla.org/en-US/docs/Glossary/CORS)
* [CORS introduction](../../cors)
http Errors: CORSMissingAllowOrigin Errors: CORSMissingAllowOrigin
==============================
Reason: CORS header 'Access-Control-Allow-Origin' missing
=========================================================
Reason
------
```
Reason: CORS header 'Access-Control-Allow-Origin' missing
```
What went wrong?
----------------
The response to the [CORS](https://developer.mozilla.org/en-US/docs/Glossary/CORS) request is missing the required [`Access-Control-Allow-Origin`](../../headers/access-control-allow-origin) header, which is used to determine whether or not the resource can be accessed by content operating within the current origin.
If the server is under your control, add the origin of the requesting site to the set of domains permitted access by adding it to the `Access-Control-Allow-Origin` header's value.
For example, to allow a site at `https://amazing.site` to access the resource using CORS, the header should be:
```
Access-Control-Allow-Origin: https://amazing.site
```
You can also configure a site to allow any site to access it by using the `*` wildcard. You should only use this for public APIs. Private APIs should never use `*`, and should instead have a specific domain or domains set. In addition, the wildcard only works for requests made with the [`crossorigin`](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes#crossorigin) attribute set to `anonymous`, and it prevents sending credentials like cookies in requests.
```
Access-Control-Allow-Origin: \*
```
**Warning:** Using the wildcard to allow all sites to access a private API is a bad idea.
To allow any site to make CORS requests *without* using the `*` wildcard (for example, to enable credentials), your server must read the value of the request's `Origin` header and use that value to set `Access-Control-Allow-Origin`, and must also set a `Vary: Origin` header to indicate that some headers are being set dynamically depending on the origin.
The exact directive for setting headers depends on your web server. In Apache, add a line such as the following to the server's configuration (within the appropriate `<Directory>`, `<Location>`, `<Files>`, or `<VirtualHost>` section). The configuration is typically found in a `.conf` file (`httpd.conf` and `apache.conf` are common names for these), or in an `.htaccess` file.
```
Header set Access-Control-Allow-Origin 'origin-list'
```
For Nginx, the command to set up this header is:
```
add_header 'Access-Control-Allow-Origin' 'origin-list';
```
See also
--------
* [CORS errors](../errors)
* Glossary: [CORS](https://developer.mozilla.org/en-US/docs/Glossary/CORS)
* [CORS introduction](../../cors)
http Errors: CORSRequestNotHttp Errors: CORSRequestNotHttp
==========================
Reason: CORS request not HTTP
=============================
Reason
------
```
Reason: CORS request not HTTP
```
What went wrong?
----------------
[CORS](https://developer.mozilla.org/en-US/docs/Glossary/CORS) requests may only use the HTTP or HTTPS URL scheme, but the URL specified by the request is of a different type. This often occurs if the URL specifies a local file, using the `file:///` scheme.
To fix this problem, make sure you use HTTPS URLs when issuing requests involving CORS, such as [`XMLHttpRequest`](https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest), [Fetch](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API) APIs, Web Fonts (`@font-face`), and [WebGL textures](https://developer.mozilla.org/en-US/docs/Web/API/WebGL_API/Tutorial/Using_textures_in_WebGL), and XSL stylesheets.
### Loading a local file
Local files from the same directory and subdirectories were historically treated as being from the [same origin](https://developer.mozilla.org/en-US/docs/Web/Security/Same-origin_policy). This meant that a file and all its resources could be loaded from a local directory or subdirectory during testing, without triggering a CORS error.
Unfortunately this had security implications, as noted in this advisory: [CVE-2019-11730](https://www.mozilla.org/en-US/security/advisories/mfsa2019-21/#CVE-2019-11730). Many browsers, including Firefox and Chrome, now treat all local files as having *opaque origins* (by default). As a result, loading a local file with included local resources will now result in CORS errors.
Developers who need to perform local testing should now [set up a local server](https://developer.mozilla.org/en-US/docs/Learn/Common_questions/set_up_a_local_testing_server). As all files are served from the same scheme and domain (`localhost`) they all have the same origin, and do not trigger cross-origin errors.
**Note:** This change is in line with the [URL specification](https://url.spec.whatwg.org/#origin), which leaves the origin behavior for files to the implementation, but recommends that file origins are treated as opaque if in doubt.
See also
--------
* [CORS errors](../errors)
* [CORS introduction](../../cors)
* [What is a URL?](https://developer.mozilla.org/en-US/docs/Learn/Common_questions/What_is_a_URL)
http Errors: CORSInvalidAllowHeader Errors: CORSInvalidAllowHeader
==============================
Reason: invalid token 'xyz' in CORS header 'Access-Control-Allow-Headers'
=========================================================================
Reason
------
```
Reason: invalid token 'xyz' in CORS header 'Access-Control-Allow-Headers'
```
What went wrong?
----------------
The response to the [CORS](https://developer.mozilla.org/en-US/docs/Glossary/CORS) request that was sent by the server includes an [`Access-Control-Allow-Headers`](../../headers/access-control-allow-headers) header which includes at least one invalid header name.
The `Access-Control-Allow-Headers` header is sent by the server in response to a [preflight request](https://developer.mozilla.org/en-US/docs/Glossary/Preflight_request); it lets the client know which [HTTP headers](../../headers) are permitted in CORS requests. If the client [user agent](https://developer.mozilla.org/en-US/docs/Glossary/User_agent) finds among the comma-delineated values provided by the header any header name it does not recognize, this error occurs.
This is a problem that most likely can only be fixed on the server side, by modifying the server's configuration to no longer send the invalid or unknown header name with the `Access-Control-Allow-Headers` header. It may also be worth checking to ensure that the user agent or HTTP library you're using on the client is up-to-date.
See also
--------
* [CORS errors](../errors)
* Glossary: [CORS](https://developer.mozilla.org/en-US/docs/Glossary/CORS)
* [CORS introduction](../../cors)
* [HTTP headers](../../headers)
http Errors: CORSMultipleAllowOriginNotAllowed Errors: CORSMultipleAllowOriginNotAllowed
=========================================
Reason: Multiple CORS header 'Access-Control-Allow-Origin' not allowed
======================================================================
Reason
------
```
Reason: Multiple CORS header 'Access-Control-Allow-Origin' not allowed
```
What went wrong?
----------------
More than one [`Access-Control-Allow-Origin`](../../headers/access-control-allow-origin) header was sent by the server. This isn't allowed.
If you have access to the server you can change your implementation to echo back an origin in the `Access-Control-Allow-Origin` header. You cannot send back a list of origins, because browsers only accept a value that is either a single origin or null
See also
--------
* [CORS errors](../errors)
* Glossary: [CORS](https://developer.mozilla.org/en-US/docs/Glossary/CORS)
* [CORS introduction](../../cors)
* [Enable CORS: I want to add CORS support to my server](https://enable-cors.org/server.html)
| programming_docs |
http Errors: CORSOriginHeaderNotAdded Errors: CORSOriginHeaderNotAdded
================================
Reason: CORS header 'Origin' cannot be added
============================================
Reason
------
```
Reason: CORS header 'Origin' cannot be added
```
What went wrong?
----------------
The [user agent](https://developer.mozilla.org/en-US/docs/Glossary/User_agent) was unable to add the required [`Origin`](../../headers/origin) header to the [HTTP](https://developer.mozilla.org/en-US/docs/Glossary/HTTP) request. All CORS requests must have an `Origin` header.
This can happen if the JavaScript code is running with enhanced privileges allowing it access to multiple domains' content, for example.
See also
--------
* [CORS errors](../errors)
* Glossary: [CORS](https://developer.mozilla.org/en-US/docs/Glossary/CORS)
* [CORS introduction](../../cors)
http Errors: CORSPreflightDidNotSucceed Errors: CORSPreflightDidNotSucceed
==================================
Reason: CORS preflight channel did not succeed
==============================================
Reason
------
```
Reason: CORS preflight channel did not succeed
```
What went wrong?
----------------
The [CORS](https://developer.mozilla.org/en-US/docs/Glossary/CORS) request requires preflight, preflighting could not be performed. There are a couple of reasons why preflighting might fail:
* A cross-site request has previously been performed that already did a preflight, and doing the preflight again is not permitted. Make sure your code only preflights once per connection.
* The preflight request suffered any kind of networking error that might ordinarily occur.
See also
--------
* [CORS errors](../errors)
* Glossary: [CORS](https://developer.mozilla.org/en-US/docs/Glossary/CORS)
* [CORS introduction](../../cors)
http Errors: CORSDisabled Errors: CORSDisabled
====================
Reason: CORS disabled
=====================
Reason
------
```
Reason: CORS disabled
```
What went wrong?
----------------
A request that needs to use [CORS](https://developer.mozilla.org/en-US/docs/Glossary/CORS) was attempted, but CORS is disabled in the user's browser. When this happens, the user needs to turn CORS back on in their browser.
In Firefox, the preference that disables CORS is `content.cors.disable`. Setting this to `true` disables CORS, so whenever that's the case, CORS requests will always fail with this error.
See also
--------
* [CORS errors](../errors)
* Glossary: [CORS](https://developer.mozilla.org/en-US/docs/Glossary/CORS)
* [CORS introduction](../../cors)
http Errors: CORSExternalRedirectNotAllowed Errors: CORSExternalRedirectNotAllowed
======================================
Reason: CORS request external redirect not allowed
==================================================
Reason
------
```
Reason: CORS request external redirect not allowed
```
What went wrong?
----------------
The [CORS](https://developer.mozilla.org/en-US/docs/Glossary/CORS) request was responded to by the server with an HTTP redirect to a URL on a different origin than the original request, which is not permitted during CORS requests.
For example, if the page `https://service.tld/fetchdata` were requested, and the HTTP response is "301 Moved Permanently", "307 Temporary Redirect", or "308 Permanent Redirect" with a `Location` of `https://anotherservice.net/getdata`, the CORS request will fail in this manner.
To fix the problem, update your code to use the new URL as reported by the redirect, thereby avoiding the redirect.
See also
--------
* [CORS errors](../errors)
* Glossary: [CORS](https://developer.mozilla.org/en-US/docs/Glossary/CORS)
* [CORS introduction](../../cors)
http Errors: CORSMethodNotFound Errors: CORSMethodNotFound
==========================
Reason: Did not find method in CORS header 'Access-Control-Allow-Methods'
=========================================================================
Reason
------
```
Reason: Did not find method in CORS header 'Access-Control-Allow-Methods'
```
What went wrong?
----------------
The HTTP method being used by the [CORS](https://developer.mozilla.org/en-US/docs/Glossary/CORS) request is not included in the list of methods specified by the response's [`Access-Control-Allow-Methods`](../../headers/access-control-allow-methods) header. This header specifies a comma-delineated list of the HTTP methods which may be used when using CORS to access the URL specified in the request; if the request is using any other method, this error occurs.
For example, if the response includes:
```
Access-Control-Allow-Methods: GET,HEAD,POST
```
Trying to use a [`PUT`](../../methods/put) request will fail with this error.
Make sure your code only uses the permitted HTTP methods when accessing the service.
**Note:** If the server includes any unrecognized or undefined method names in its `Access-Control-Allow-methods` header, a different error occurs: [`Reason: invalid token 'xyz' in CORS header 'Access-Control-Allow-Methods'`](corsinvalidallowmethod).
See also
--------
* [CORS errors](../errors)
* Glossary: [CORS](https://developer.mozilla.org/en-US/docs/Glossary/CORS)
* [CORS introduction](../../cors)
* [HTTP request methods](../../methods)
http Errors: CORSMIssingAllowCredentials Errors: CORSMIssingAllowCredentials
===================================
Reason: expected 'true' in CORS header 'Access-Control-Allow-Credentials'
=========================================================================
Reason
------
```
Reason: expected 'true' in CORS header 'Access-Control-Allow-Credentials'
```
What went wrong?
----------------
The [CORS](https://developer.mozilla.org/en-US/docs/Glossary/CORS) request requires that the server permit the use of credentials, but the server's [`Access-Control-Allow-Credentials`](../../headers/access-control-allow-credentials) header's value isn't set to `true` to enable their use.
To fix this problem on the client side, revise the code to not request the use of credentials.
* If the request is being issued using [`XMLHttpRequest`](https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest), make sure you're not setting [`withCredentials`](https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/withCredentials) to `true`.
* If using [Server-sent events](https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events), make sure [`EventSource.withCredentials`](https://developer.mozilla.org/en-US/docs/Web/API/EventSource/withCredentials) is `false` (it's the default value).
* If using the [Fetch API](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API), make sure [`Request.credentials`](https://developer.mozilla.org/en-US/docs/Web/API/Request/credentials) is `"omit"`.
To eliminate this error by changing the server's configuration, adjust the server's configuration to set the `Access-Control-Allow-Credentials` header's value to `true`.
See also
--------
* [CORS errors](../errors)
* Glossary: [CORS](https://developer.mozilla.org/en-US/docs/Glossary/CORS)
* [CORS introduction](../../cors)
http Feature Policy: Using Feature Policy Feature Policy: Using Feature Policy
====================================
Using Feature Policy
====================
[Feature Policy](../feature_policy) allows you to control which origins can use which features, both in the top-level page and in embedded frames. Essentially, you write a policy, which is an allowed list of origins for each feature. For every feature controlled by Feature Policy, the feature is only enabled in the current document or frame if its origin matches the allowed list of origins.
For each policy-controlled feature, the browser maintains a list of origins for which the feature is enabled, known as an allowlist. If you do not specify a policy for a feature, then a default allowlist will be used. The default allowlist is specific to each feature.
**Note:** The `Feature-Policy` header has now been renamed to `Permissions-Policy` in the spec, and this article will eventually be updated to reflect that change.
Writing a policy
----------------
A policy is described using a set of individual policy directives. A policy directive is a combination of a defined feature name, and an allowlist of origins that can use the feature. Features within a policy are separated by semicolons.
### allowlist
An `allowlist` is a list of origins that takes one or more of the following values, separated by spaces:
* `*`: The feature will be allowed in this document, and all nested browsing contexts (iframes) regardless of their origin.
* `'self'`: The feature will be allowed in this document, and in all nested browsing contexts (iframes) in the same origin.
* `'src'`: (In an iframe `allow` attribute only) The feature will be allowed in this iframe, as long as the document loaded into it comes from the same origin as the URL in the iframe's [src](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/iframe#attributes) attribute. **Note:** The `'src'` origin is used in the iframe `allow` attribute only, and is the *default* `allowlist` value.
* `'none'`: The feature is disabled in top-level and nested browsing contexts.
* <origin(s)>: The feature is allowed for specific origins (for example, `https://example.com`). Origins should be separated by a space.
The values `*` (enable for all origins) or `'none'` (disable for all origins) may only be used alone, while `'self'` and `'src'` may be used with one or more origins.
Features are each defined to have a default allowlist, which is one of:
* `*`: The feature is allowed by default in top-level browsing contexts and all nested browsing contexts (iframes).
* `'self'`: The feature is allowed by default in top-level browsing contexts and in nested browsing contexts (iframes) in the same origin. The feature is not allowed in cross-origin documents in nested browsing contexts.
* `'none'`: The feature is disabled in top-level and nested browsing contexts.
Specifying your policy
----------------------
Feature Policy provides two ways to specify policies to control features:
* The [`Feature-Policy`](../headers/feature-policy) HTTP header.
* The [`allow`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/iframe#attr-allow) attribute on [`<iframe>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/iframe)s.
The primary difference between the HTTP header and the `allow` attribute is that the allow attribute only controls features within an iframe. The header controls features in the response and any embedded content within the page.
### The Feature-Policy HTTP header
You can send the `Feature-Policy` HTTP header with the response of a page. The value of this header is a policy to be enforced by the browser for the given page. It has the following structure.
```
Feature-Policy: <feature name> <allowlist of origin(s)>
```
For example, to block all content from using the Geolocation API across your site:
```
Feature-Policy: geolocation 'none'
```
Several features can be controlled at the same time by sending the HTTP header with a semicolon-separated list of policy directives, or by sending a separate header for each policy.
For example, the following are equivalent:
```
Feature-Policy: unsized-media 'none'; geolocation 'self' https://example.com; camera *;
Feature-Policy: unsized-media 'none'
Feature-Policy: geolocation 'self' https://example.com
Feature-Policy: camera *;
```
### The iframe allow attribute
The second way to use Feature Policy is for controlling content within an iframe. Use the `allow` attribute to specify a policy list for embedded content.
For example, allow all browsing contexts within this iframe to use fullscreen:
```
<iframe src="https://example.com/…" allow="fullscreen"></iframe>
```
The default `<iframe>` [allowlist](#allowlist) value is `'src'`, so this is equivalent to:
```
<iframe src="https://example.com/…" allow="fullscreen 'src'"></iframe>
```
This example allows `<iframe>` content on a particular origin to access the user's location:
```
<iframe
src="https://google-developers.appspot.com/demos/…"
allow="geolocation https://google-developers.appspot.com"></iframe>
```
Similar to the HTTP header, several features can be controlled at the same time by specifying a semicolon-separated list of policy directives.
For example, this blocks the `<iframe>` from using the camera and microphone:
```
<iframe allow="camera 'none'; microphone 'none'">…</iframe>
```
Inheritance of policy for embedded content
------------------------------------------
Scripts inherit the policy of their browsing context, regardless of their origin. That means that top-level scripts inherit the policy from the main document.
All iframes inherit the policy of their parent page. If the iframe has an `allow` attribute, the policies of the parent page and the `allow` attribute are combined, using the most restrictive subset. For an iframe to have a feature enabled, the origin must be in the allowlist for both the parent page and the allow attribute.
Disabling a feature in a policy is a one-way toggle. If a feature has been disabled for a child frame by its parent frame, the child cannot re-enable it, and neither can any of the child's descendants.
Enforcing best practices for good user experiences
--------------------------------------------------
It's difficult to build a website that uses all the latest best practices and provides great performance and user experiences. As the website evolves, it can become even harder to maintain the user experience over time. You can use feature policies to specify the desired best practices, and rely on the browser to enforce the policies to prevent regressions.
There are several policy-controlled features designed to represent functionality that can negatively impact the user experience. These features include:
* Layout-inducing Animations
* Unoptimized (poorly compressed) images
* Oversized images
* Synchronous scripts
* Synchronous XMLHttpRequest
* Unsized media
To avoid breaking existing web content, the default for such policy-controlled features is to allow the functionality to be used by all origins. That is, the default allowlist is `'*'` for each feature. Preventing the use of the sub-optimal functionality requires explicitly specifying a policy that disables the features.
For new content, you can start developing with a policy that disables all the features. This approach ensures that none of the functionality is introduced. When applying a policy to existing content, testing is likely required to verify it continues to work as expected. This is especially important for embedded or third-party content that you do not control.
To turn on the enforcement of all the best practices, specify the policy as below.
Send the following the HTTP header:
```
Feature-Policy: layout-animations 'none'; unoptimized-images 'none'; oversized-images 'none'; sync-script 'none'; sync-xhr 'none'; unsized-media 'none';
```
Using the `<iframe>` `allow` attribute:
```
<iframe
src="https://example.com/…"
allow="layout-animations 'none'; unoptimized-images 'none'; oversized-images 'none'; sync-script 'none'; sync-xhr 'none'; unsized-media 'none';"></iframe>
```
See also
--------
* [Feature Policy](../feature_policy)
* [`Feature-Policy`](../headers/feature-policy) header
* [allow](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/iframe#attributes) attribute on iframes
* [`Content-Security-Policy`](../headers/content-security-policy) header
* [`Referrer-Policy`](../headers/referrer-policy) header
* [Privacy, permissions, and information security](https://developer.mozilla.org/en-US/docs/Web/Privacy)
handlebars Execution Execution
=========
Get the HTML result of evaluating a Handlebars template by executing the template with a context.
```
var context = {title: "My New Post", body: "This is my first post!"}
var html = template(context);
```
results in
```
<div class="entry">
<h1>My New Post</h1>
<div class="body">
This is my first post!
</div>
</div>
```
Options
--------
The template function can be passed an options object as the second parameter which allows for customization: * `data` Pass in an object to define custom `@variable` private variables.
* `helpers` Pass in to provide custom helpers in addition to the globally defined helpers.
Values defined in this object will replace any values defined in the global object for the duration of the template execution.
* `partials` Pass in to provide custom partials in addition to the globally defined partials.
Values defined in this object will replace any values defined in the global object for the duration of the template execution.
handlebars Handlebars.js Handlebars.js
=============
Handlebars provides the power necessary to let you build **semantic templates** effectively with no frustration.
Handlebars is largely compatible with Mustache templates. In most cases it is possible to swap out Mustache with Handlebars and continue using your current templates. Complete details can be found [here](https://github.com/wycats/handlebars.js#differences-between-handlebarsjs-and-mustache).
[Installation](installation) Getting Started
----------------
### Expressions
Handlebars templates look like regular HTML, with embedded handlebars expressions.
```
<div class="entry">
<h1>{{title}}</h1>
<div class="body">
{{body}}
</div>
</div>
```
A handlebars expression is a `{{`, some contents, followed by a `}}` [Learn More: Expressions](expressions) You can deliver a template to the browser by including it in a `<script>` tag.
```
<script id="entry-template" type="text/x-handlebars-template">
<div class="entry">
<h1>{{title}}</h1>
<div class="body">
{{body}}
</div>
</div>
</script>
```
It is important that you put the template inside a `<script>` tag. Do not put it into the HTML directly or the HTML-parser might modify it (for example, if it [contains a table](https://html.spec.whatwg.org/multipage/parsing.html#unexpected-markup-in-tables)).
### Precompilation
Compile a template in JavaScript by using `Handlebars.compile`
```
var source = document.getElementById("entry-template").innerHTML;
var template = Handlebars.compile(source);
```
Please note that this approach is not recommended for production applications. A better way is to precompile your templates. This will result in a smaller required runtime library and significant savings from not having to compile the template in the browser. This can be especially important when working with mobile devices. [Learn More: Precompilation](precompilation)
### Execution
Get the HTML result of evaluating a Handlebars template by executing the template with a context.
```
var context = {title: "My New Post", body: "This is my first post!"};
var html = template(context);
```
results in
```
<div class="entry">
<h1>My New Post</h1>
<div class="body">
This is my first post!
</div>
</div>
```
[Learn More: Execution](execution) HTML Escaping
--------------
Handlebars HTML-escapes values returned by a `{{expression}}`. If you don't want Handlebars to escape a value, use the "triple-stash", `{{{`.
```
<div class="entry">
<h1>{{title}}</h1>
<div class="body">
{{{body}}}
</div>
</div>
```
with this context:
```
{
title: "All about <p> Tags",
body: "<p>This is a post about <p> tags</p>"
}
```
results in:
```
<div class="entry">
<h1>All About <p> Tags</h1>
<div class="body">
<p>This is a post about <p> tags</p>
</div>
</div>
```
Handlebars will not escape a `Handlebars.SafeString`. If you write a helper that generates its own HTML, you will usually want to return a `new Handlebars.SafeString(result)`. In such a circumstance, you will want to manually escape parameters.
```
Handlebars.registerHelper('link', function(text, url) {
text = Handlebars.Utils.escapeExpression(text);
url = Handlebars.Utils.escapeExpression(url);
var result = '<a href="' + url + '">' + text + '</a>';
return new Handlebars.SafeString(result);
});
```
This will escape the passed in parameters, but mark the response as safe, so Handlebars will not try to escape it even if the "triple-stash" is not used. Block Expressions
------------------
Block expressions allow you to define helpers that will invoke a section of your template with a different context than the current. These block helpers are identified by a `#` preceeding the helper name and require a matching closing mustache, `/`, of the same name. Let's consider a helper that will generate an HTML list:
```
{{#list people}}{{firstName}} {{lastName}}{{/list}}
```
If we have the following context:
```
{
people: [
{firstName: "Yehuda", lastName: "Katz"},
{firstName: "Carl", lastName: "Lerche"},
{firstName: "Alan", lastName: "Johnson"}
]
}
```
we would create a helper named `list` to generate our HTML list. The helper receives the `people` as its first parameter, and an options hash as its second parameter. The options hash contains a property named `fn`, which you can invoke with a context just as you would invoke a normal Handlebars template.
```
Handlebars.registerHelper('list', function(items, options) {
var out = "<ul>";
for(var i=0, l=items.length; i<l; i++) {
out = out + "<li>" + options.fn(items[i]) + "</li>";
}
return out + "</ul>";
});
```
When executed, the template will render:
```
<ul>
<li>Yehuda Katz</li>
<li>Carl Lerche</li>
<li>Alan Johnson</li>
</ul>
```
Block helpers have more features, such as the ability to create an `else` section (used, for instance, by the built-in `if` helper). Since the contents of a block helper are escaped when you call `options.fn(context)`, Handlebars does not escape the results of a block helper. If it did, inner content would be double-escaped! [Learn More: Block Helpers](block_helpers) Handlebars Paths
-----------------
Handlebars supports simple paths, just like Mustache.
```
<p>{{name}}</p>
```
Handlebars also supports nested paths, making it possible to look up properties nested below the current context.
```
<div class="entry">
<h1>{{title}}</h1>
<h2>By {{author.name}}</h2>
<div class="body">
{{body}}
</div>
</div>
```
That template works with this context
```
var context = {
title: "My First Blog Post!",
author: {
id: 47,
name: "Yehuda Katz"
},
body: "My first post. Wheeeee!"
};
```
This makes it possible to use Handlebars templates with more raw JSON objects. Nested handlebars paths can also include `../` segments, which evaluate their paths against a parent context.
```
<h1>Comments</h1>
<div id="comments">
{{#each comments}}
<h2><a href="/posts/{{../permalink}}#{{id}}">{{title}}</a></h2>
<div>{{body}}</div>
{{/each}}
</div>
```
Even though the link is printed while in the context of a comment, it can still go back to the main context (the post) to retrieve its permalink. The exact value that `../` will resolve to varies based on the helper that is calling the block. Using `../` is only necessary when context changes, so children of helpers such as `each` would require the use of `../` while children of helpers such as `if` do not.
```
{{permalink}}
{{#each comments}}
{{../permalink}}
{{#if title}}
{{../permalink}}
{{/if}}
{{/each}}
```
In this example all of the above reference the same `permalink` value even though they are located within different blocks. This behavior is new as of Handlebars 4, the [release notes](https://github.com/wycats/handlebars.js/blob/master/release-notes.md) discuss the prior behavior as well as the migration plan. Handlebars also allows for name conflict resolution between helpers and data fields via a `this` reference:
```
<p>{{./name}} or {{this/name}} or {{this.name}}</p>
```
Any of the above would cause the `name` field on the current context to be used rather than a helper of the same name. Template comments with `{{!-- --}}` or `{{! }}`.
-------------------------------------------------
You can use comments in your handlebars code just as you would in your code. Since there is generally some level of logic, this is a good practice.
```
<div class="entry">
{{!-- only output author name if an author exists --}}
{{#if author}}
<h1>{{author.firstName}} {{author.lastName}}</h1>
{{/if}}
</div>
```
The comments will not be in the resulting output. If you'd like the comments to show up. Just use html comments, and they will be output.
```
<div class="entry">
{{! This comment will not be in the output }}
<!-- This comment will be in the output -->
</div>
```
Any comments that must contain `}}` or other handlebars tokens should use the `{{!-- --}}` syntax. Helpers
--------
Handlebars helpers can be accessed from any context in a template. You can register a helper with the `Handlebars.registerHelper` method.
```
<div class="post">
<h1>By {{fullName author}}</h1>
<div class="body">{{body}}</div>
<h1>Comments</h1>
{{#each comments}}
<h2>By {{fullName author}}</h2>
<div class="body">{{body}}</div>
{{/each}}
</div>
```
when using this context and helpers:
```
var context = {
author: {firstName: "Alan", lastName: "Johnson"},
body: "I Love Handlebars",
comments: [{
author: {firstName: "Yehuda", lastName: "Katz"},
body: "Me too!"
}]
};
Handlebars.registerHelper('fullName', function(person) {
return person.firstName + " " + person.lastName;
});
```
results in:
```
<div class="post">
<h1>By Alan Johnson</h1>
<div class="body">I Love Handlebars</div>
<h1>Comments</h1>
<h2>By Yehuda Katz</h2>
<div class="body">Me Too!</div>
</div>
```
Helpers receive the current context as the `this` context of the function.
```
<ul>
{{#each items}}
<li>{{agree_button}}</li>
{{/each}}
</ul>
```
when using this context and helpers:
```
var context = {
items: [
{name: "Handlebars", emotion: "love"},
{name: "Mustache", emotion: "enjoy"},
{name: "Ember", emotion: "want to learn"}
]
};
Handlebars.registerHelper('agree_button', function() {
var emotion = Handlebars.escapeExpression(this.emotion),
name = Handlebars.escapeExpression(this.name);
return new Handlebars.SafeString(
"<button>I agree. I " + emotion + " " + name + "</button>"
);
});
```
results in:
```
<ul>
<li><button>I agree. I love Handlebars</button></li>
<li><button>I agree. I enjoy Mustache</button></li>
<li><button>I agree. I want to learn Ember</button></li>
</ul>
```
If your helper returns HTML that you do not want escaped, make sure to return a new `Handlebars.SafeString`. Literals
---------
Helper calls may also have literal values passed to them either as parameter arguments or hash arguments. Supported literals include numbers, strings, `true`, `false`, `null` and `undefined`.
```
{{agree_button "My Text" class="my-class" visible=true counter=4}}
```
Partials
---------
Handlebars partials allow for code reuse by creating shared templates. Rendering this template
```
<div class="post">
{{> userMessage tagName="h1" }}
<h1>Comments</h1>
{{#each comments}}
{{> userMessage tagName="h2" }}
{{/each}}
</div>
```
when using this partial and context:
```
Handlebars.registerPartial('userMessage',
'<{{tagName}}>By {{author.firstName}} {{author.lastName}}</{{tagName}}>'
+ '<div class="body">{{body}}</div>');
```
```
var context = {
author: {firstName: "Alan", lastName: "Johnson"},
body: "I Love Handlebars",
comments: [{
author: {firstName: "Yehuda", lastName: "Katz"},
body: "Me too!"
}]
};
```
results in:
```
<div class="post">
<h1>By Alan Johnson</h1>
<div class="body">I Love Handlebars</div>
<h1>Comments</h1>
<h2>By Yehuda Katz</h2>
<div class="body">Me Too!</div>
</div>
```
[Learn More: Partials](partials) Built-In Helpers
-----------------
Handlebars offers a variety of built-in helpers such as the `if` conditional and `each` iterator. [Learn More: Built-In Helpers](builtin_helpers) API Reference
--------------
Handlebars offers a variety of APIs and utility methods for applications and helpers. [Learn More: API Reference](reference)
| programming_docs |
handlebars Partials Partials
========
Handlebars allows for template reuse through partials. Partials are normal Handlebars templates that may be called directly by other templates.
Basic Partials
---------------
In order to use a partial, it must be registered via `Handlebars.registerPartial`.
```
Handlebars.registerPartial('myPartial', '{{name}}')
```
This call will register the `myPartial` partial. Partials may be precompiled and the precompiled template passed into the second parameter. Calling the partial is done through the partial call syntax:
```
{{> myPartial }}
```
Will render the partial named `myPartial`. When the partial executes, it will be run under the current execution context. Dynamic Partials
-----------------
It's possible to dynamically select the partial to be executed by using sub expression syntax.
```
{{> (whichPartial) }}
```
Will evaluate `whichPartial` and then render the partial whose name is returned by this function. Subexpressions do not resolve variables so `whichPartial` must be a function. If a simple variable has the partial name, it's possible to resolve it via the `lookup` helper.
```
{{> (lookup . 'myVariable') }}
```
Partial Contexts
-----------------
It's possible to execute partials on a custom context by passing in the context to the partial call.
```
{{> myPartial myOtherContext }}
```
Partial Parameters
-------------------
Custom data can be passed to partials through hash parameters.
```
{{> myPartial parameter=value }}
```
Will set `parameter` to `value` when the partial runs. This is particularly useful for exposing data from parent contexts to the partial:
```
{{> myPartial name=../name }}
```
Partial Blocks
---------------
The normal behavior when attempting to render a partial that is not found is for the implementation to throw an error. If failover is desired instead, partials may be called using the block syntax.
```
{{#> myPartial }}
Failover content
{{/myPartial}}
```
Which will render `Failover content` if the `myPartial` partial is not registered. This block syntax may also be used to pass templates to the partial, which can be executed by the specially named partial, `@partial-block`. A template of
```
{{#> layout }}
My Content
{{/layout}}
```
with the `layout` partial containing
```
Site Content
{{> @partial-block }}
```
Would render
```
Site Content
My Content
```
When called in this manner, the block will execute under the context of the partial at the time of the call. Depthed paths and block parameters operate relative to the partial block rather than the partial template.
```
{{#each children as |child|}}
{{#> childEntry}}
{{child.value}}
{{/childEntry}}
{{/each}}
```
Will render `child.value` from this template, not the partial. Inline Partials
----------------
Templates may define block scoped partials via the `inline` decorator.
```
{{#*inline "myPartial"}}
My Content
{{/inline}}
{{#each children}}
{{> myPartial}}
{{/each}}
```
Which will render the `myPartial` partial for each child. Each inline partial is available to the current block and all children, including execution of other partials. This allows for layout templates and similar functionality:
```
{{#> layout}}
{{#*inline "nav"}}
My Nav
{{/inline}}
{{#*inline "content"}}
My Content
{{/inline}}
{{/layout}}
```
Where the `layout` partial may be:
```
<div class="nav">
{{> nav}}
</div>
<div class="content">
{{> content}}
</div>
```
handlebars Reference Reference
=========
Base
-----
### `Handlebars.compile(template, options)`
Compiles a template so it can be executed immediately.
```
var template = Handlebars.compile('{{foo}}');
template({});
```
Supports a variety of options that alter how the template executes. * `data`: Set to false to disable `@data` tracking.
* `compat`: Set to true to enable recursive field lookup.
* `knownHelpers`: Hash containing list of helpers that are known to exist (truthy) at template execution time. Passing this allows the compiler to optimize a number of cases. Builtin helpers are automatically included in this list and may be omitted by setting that value to `false`.
* `knownHelpersOnly`: Set to true to allow further optimzations based on the known helpers list.
* `noEscape`: Set to true to not HTML escape any content.
* `strict`: Run in strict mode. In this mode, templates will throw rather than silently ignore missing fields. This has the side effect of disabling inverse operations such as `{{^foo}}{{/foo}}` unless fields are explicitly included in the source object.
* `assumeObjects`: Removes object existence checks when traversing paths. This is a subset of `strict` mode that generates optimized templates when the data inputs are known to be safe.
* `preventIndent`: By default, an indented partial-call causes the output of the whole partial being indented by the same amount. This can lead to unexpected behavior when the partial writes `pre`-tags. Setting this option to `true` will disable the auto-indent feature.
* `ignoreStandalone`: Disables standalone tag removal when set to `true`. When set, blocks and partials that are on their own line will not remove the whitespace on that line.
* `explicitPartialContext`: Disables implicit context for partials. When enabled, partials that are not passed a context value will execute against an empty object.
### `Handlebars.precompile(template, options)`
Precompiles a given template so it can be sent to the client and executed without compilation.
```
var templateSpec = Handlebars.precompile('{{foo}}');
```
Supports all of the same options parameters as the `Handlebars.compile` method. Additionally may pass: * `srcName`: Passed to generate the source map for the input file. When run in this manner, the return structure is `{code, map}` with `code` containing the template definition and `map` containing the source map.
* `destName`: Optional parameter used in conjunction with `srcName` to provide a destination file name when generating source maps.
### `Handlebars.template(templateSpec)`
Sets up a template that was precompiled with `Handlebars.precompile`.
```
var template = Handlebars.template(templateSpec);
template({});
```
### `Handlebars.registerPartial(name, partial)`
Registers partials accessible by any template in the environment.
```
Handlebars.registerPartial('foo', partial);
```
Also supports registering multiple partials at once.
```
Handlebars.registerPartial({
foo: partial,
bar: partial
});
```
If loading the whole library, the partials may be string values which will be compiled on demand. If only loading the runtime, the partials must be a precompiled template that has been set up properly using the `Handlebars.template` method. ### `Handlebars.unregisterPartial(name)`
Unregisters a previously registered partial.
```
Handlebars.unregisterPartial('foo');
```
### `Handlebars.registerHelper(name, helper)`
Registers helpers accessible by any template in the environment.
```
Handlebars.registerHelper('foo', function() {
});
```
Also supports registering multiple helpers at once.
```
Handlebars.registerHelper({
foo: function() {
},
bar: function() {
}
});
```
### `Handlebars.unregisterHelper(name)`
Unregisters a previously registered helper.
```
Handlebars.unregisterHelper('foo');
```
### `Handlebars.registerDecorator(name, helper)`
Registers a decorator accessible by any template in the environment.
```
Handlebars.registerDecorator('foo', function() {
});
```
Also supports registering multiple decorators at once.
```
Handlebars.registerDecorator({
foo: function() {
},
bar: function() {
}
});
```
### `Handlebars.unregisterDecorator(name)`
Unregisters a previously registered decorator.
```
Handlebars.unregisterDecorator('foo');
```
### `Handlebars.SafeString(string)`
Prevents `string` from being escaped when the template is rendered.
```
new Handlebars.SafeString('<div>HTML Content!</div>')
```
When constructing the string that will be marked as safe, any external content should be properly escaped using the `Handlebars.escapeExpression` method to avoid potential security concerns. ### `Handlebars.escapeExpression(string)`
HTML escapes the passed string, making it safe for rendering as text within HTML content.
```
Handlebars.Utils.escapeExpression(string)
```
Replaces `&`, `<`, `>`, `"`, `'`, ```, `=` with the HTML entity equivalent value for string values. `SafeString` values are left untouched. The output of all expressions except for triple-braced expressions are passed through this method. Helpers should also use this method when returning HTML content via a `SafeString` instance, to prevent possible code injection. This method is aliased at `Handlebars.Utils.escapeExpression`. ### `Handlebars.createFrame(data)`
Used by block helpers to create child data objects.
```
if (options.data) {
var data = Handlebars.createFrame(options.data);
data.foo = 'bar';
options.data = data;
}
```
Helpers that modify the data state should create a new frame when doing so, to isolate themselves and avoid corrupting the state of any parents. Generally, only one frame needs to be created per helper execution. For example, the `each` iterator creates a single frame which is reused for all child execution. ### `Handlebars.create()`
Creates an isolated Handlebars environment.
```
var OtherHandlebars = Handlebars.create();
```
Each environment has its own helpers and partials. This is only necessary for use cases that demand distinct helpers or partials. Most use cases can use the root `Handlebars` environment directly. Templates created for a given environment are bound to that environment. This means that templates that need to run in multiple environments will need to be recompiled or reconstructed via `Handlebars.template` for each environment. This applies to partials as well. ### `Handlebars.noConflict()`
Removes this Handlebars instance from the global namespace, restoring the global `Handlebars` variable to its previous value.
```
var myHandlebars = Handlebars.noConflict();
```
This allows for distinct versions of the library to be used simultaneously without concern for version conflicts. ### `Handlebars.log(level, message)`
Logger used by the `log` helper. May be overriden if desired. Utilities
----------
Handlebars offers a variety of utility methods that are exposed through the `Handlebars.Utils` object. ### `Handlebars.Utils.isEmpty(value)`
Determines if a given value is empty.
```
Handlebars.Utils.isEmpty(value)
```
This is used by the built-in `if` and `with` helpers to control their execution flow. The Handlebars definition of empty is any of: * Array with length 0
* falsy values other than 0
This is intended to match the [Mustache behavior](http://mustache.github.io/mustache.5.html#Sections). ### `Handlebars.Utils.extend(obj, value)`
Simple utility method to augment `obj` with all keys defined on `value`.
```
Handlebars.Utils.extend(foo, {bar: true})
```
Will set the key `bar` on object `foo` with the value `true`. ### `Handlebars.Utils.toString(obj)`
Generic `toString` method. ### `Handlebars.Utils.isArray(obj)`
Determines if an object is an array. ### `Handlebars.Utils.isFunction(obj)`
Determines if an object is a function. @data Variables
----------------
The following `@data` variables are implemented by Handlebars and its builtin helpers. ### `@root`
Initial context with which the template was executed.
```
{{#each array}}
{{@root.foo}}
{{/each}}
```
Unless explicitly modified, this value is consistent across all portions of the page rendering, meaning it can be used within partials where depthed parameters are unable to reference their parent templates. ### `@first`
Set to true by the `each` helper for the first step of iteration.
```
{{#each array}}
{{#if @first}}
First!
{{/if}}
{{/each}}
```
### `@index`
Zero-based index for the current iteration step. Set by the `each` helper.
```
{{#each array}}
{{@index}}
{{/each}}
```
### `@key`
Key name for the current iteration step. Set by the `each` helper when iterating over objects.
```
{{#each array}}
{{@key}}
{{/each}}
```
### `@last`
Set to true by the `each` helper for the last step of iteration.
```
{{#each array}}
{{#if @last}}
Last :(
{{/if}}
{{/each}}
```
### `@level`
Assigned log level.
```
template({}, {data: {level: Handlebars.logger.WARN}})
```
May be set to one of `Handlebars.logger.DEBUG` , `Handlebars.logger.INFO` , `Handlebars.logger.WARN` , or `Handlebars.logger.ERROR` When set, the logger will include in its output only messages with a log level of `Handlebars.logger.level` or higher. The default value is `Handlebars.logger.ERROR`.
handlebars Precompilation Precompilation
==============
Using the Handlebars precompiler, you can precompile your Handlebars templates to save time on the client and reduce the required runtime size of the handlebars library. Getting Started
----------------
First, you will need to install node and npm. On OS X:
```
$ brew install node
```
This assumes you already have Homebrew installed. If not, [install it](http://brew.sh/) first. Next, install the Handlebars npm package.
```
$ npm install handlebars -g
```
Using the `-g` flag installs the package globally, so it can be used in any project. Now, you're ready to use the precompiler:
```
$ handlebars <input> -f <output>
```
The compiler will insert templates in `Handlebars.templates`. If your input file is `person.handlebars`, the compiler will insert it at `Handlebars.templates.person`. This template will be a function that may be directly executed in the same manner as templates compiled locally. I.e.
```
Handlebars.templates.person(context, options);
```
If you're working with precompiled templates, you don't need to ship the compiler with your deployed application. Instead, you can use the smaller "runtime" build.
```
<script src="/libs/handlebars.runtime.js"></script>
```
In addition to reducing the download size, eliminating client-side compilation will significantly speed up boot time, as compilation is the most expensive part of Handlebars. Optimizations
--------------
Because you are precompiling templates, you can also apply several optimization to the compiler. The first allows you to specify a list of the known helpers to the compiler
```
handlebars <input> -f <output> -k each -k if -k unless
```
The Handlebars compiler will optimize accesses to those helpers for performance. When all helpers are known at compile time, the `--knownOnly` option provides the smallest generated code that also provides the fastest execution. Usage
------
```
Usage: node ./bin/handlebars [template|directory]...
Options:
-f, --output Output File
--map Source Map File [string] [default: undefined]
-a, --amd Exports amd style (require.js)
-c, --commonjs Exports CommonJS style, path to Handlebars module [default: null]
-h, --handlebarPath Path to handlebar.js (only valid for amd-style) [default: ""]
-k, --known Known helpers
-o, --knownOnly Known helpers only
-m, --min Minimize output
-n, --namespace Template namespace [default: "Handlebars.templates"]
-s, --simple Output template function only.
-N, --name Name of passed string templates. Optional if running in a simple mode. Required when operating
on multiple templates.
-i, --string Generates a template from the passed CLI argument.
"-" is treated as a special value and causes stdin to be read for the template value.
-r, --root Template root. Base value that will be stripped from template names.
-p, --partial Compiling a partial template
-d, --data Include data when compiling
-e, --extension Template extension. [default: "handlebars"]
-b, --bom Removes the BOM (Byte Order Mark) from the beginning of the templates.
-v, --version Prints the current compiler version
--help Outputs this message
```
If using the precompiler's normal mode, the resulting templates will be stored to the `Handlebars.templates` object using the relative template name sans the extension. These templates may be executed in the same manner as templates. If using the simple mode the precompiler will generate a single javascript method. To execute this method it must be passed to the `Handlebars.template` method and the resulting object may be used as normal. Precompiling Templates Inside NodeJS
-------------------------------------
If you wish to precompile templates from inside NodeJS--without invoking "handlebars" from the command line--that can be done with Handlebars.precompile. Transmit the string result of this function to your clients, and they can in turn parse that with Handlebars.template.
```
var template = "<div>whatever {{ name }}</div>";
var Handlebars = require("handlebars");
var compiled = Handlebars.precompile(template);
```
On the client side you have Javascript along the lines of the following.
```
var template = Handlebars.template, templates = Handlebars.templates = Handlebars.templates || {};
Handlebars.partials["test1"] = template({"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) {
var helper;
return "<div>whatever "
+ container.escapeExpression(((helper = (helper = helpers.name || (depth0 != null ? depth0.name : depth0)) != null ? helper : helpers.helperMissing),(typeof helper === "function" ? helper.call(depth0 != null ? depth0 : (container.nullContext || {}),{"name":"name","hash":{},"data":data}) : helper)))
+ "</div>";
},"useData":true});
```
Finally, you can reference these templates dynamically in your Javascript.
```
var result = Handlebars.partials["test1"]({name : "yourname"});
//do whatever you want with the result
```
handlebars Block Helpers Block Helpers
=============
Block helpers make it possible to define custom iterators and other functionality that can invoke the passed block with a new context.
Basic Blocks
-------------
For demonstration purposes, let's define a block helper that invokes the block as though no helper existed.
```
<div class="entry">
<h1>{{title}}</h1>
<div class="body">
{{#noop}}{{body}}{{/noop}}
</div>
</div>
```
The `noop` helper (short for "no operation") will receive an options hash. This options hash contains a function (`options.fn`) that behaves like a normal compiled Handlebars template. Specifically, the function will take a context and return a String.
```
Handlebars.registerHelper('noop', function(options) {
return options.fn(this);
});
```
Handlebars always invokes helpers with the current context as `this`, so you can invoke the block with `this` to evaluate the block in the current context. Any helpers defined in this manner will take precedence over fields defined in the context. To access a field that is masked by a helper, a path reference may be used. In the example above a field named `noop` on the context object would be referenced using:
```
{{./noop}}
```
Basic Block Variation
----------------------
To better illustrate the syntax, let's define another block helper that adds some markup to the wrapped text.
```
<div class="entry">
<h1>{{title}}</h1>
<div class="body">
{{#bold}}{{body}}{{/bold}}
</div>
</div>
```
The `bold` helper will add markup to make its text bold. As before, the function will take a context as input and return a String.
```
Handlebars.registerHelper('bold', function(options) {
return new Handlebars.SafeString(
'<div class="mybold">'
+ options.fn(this)
+ '</div>');
});
```
The `with` helper
------------------
The `with` helper demonstrates how to pass a parameter to your helper. When a helper is called with a parameter, it is invoked with whatever context the template passed in.
```
<div class="entry">
<h1>{{title}}</h1>
{{#with story}}
<div class="intro">{{{intro}}}</div>
<div class="body">{{{body}}}</div>
{{/with}}
</div>
```
You might find a helper like this useful if a section of your JSON object contains deeply nested properties, and you want to avoid repeating the parent name. The above template could be useful with a JSON like:
```
{
title: "First Post",
story: {
intro: "Before the jump",
body: "After the jump"
}
}
```
Implementing a helper like this is a lot like implementing the `noop` helper. Helpers can take parameters, and parameters are evaluated just like expressions used directly inside `{{mustache}}` blocks.
```
Handlebars.registerHelper('with', function(context, options) {
return options.fn(context);
});
```
Parameters are passed to helpers in the order that they are passed, followed by the options hash. Simple Iterators
-----------------
A common use-case for block helpers is using them to define custom iterators. In fact, all Handlebars built-in helpers are defined as regular Handlebars block helpers. Let's take a look at how the built-in `each` helper works.
```
<div class="entry">
<h1>{{title}}</h1>
{{#with story}}
<div class="intro">{{{intro}}}</div>
<div class="body">{{{body}}}</div>
{{/with}}
</div>
<div class="comments">
{{#each comments}}
<div class="comment">
<h2>{{subject}}</h2>
{{{body}}}
</div>
{{/each}}
</div>
```
In this case, we want to invoke the block passed to `each` once for each element in the comments Array.
```
Handlebars.registerHelper('each', function(context, options) {
var ret = "";
for(var i=0, j=context.length; i<j; i++) {
ret = ret + options.fn(context[i]);
}
return ret;
});
```
In this case, we iterate over the items in the passed parameter, invoking the block once with each item. As we iterate, we build up a String result, and then return it. This pattern can be used to implement more advanced iterators. For instance, let's create an iterator that creates a `<ul>` wrapper, and wraps each resulting element in an `<li>`.
```
{{#list nav}}
<a href="{{url}}">{{title}}</a>
{{/list}}
```
You would evaluate this template using something like this as the context:
```
{
nav: [
{ url: "http://www.yehudakatz.com", title: "Katz Got Your Tongue" },
{ url: "http://www.sproutcore.com/block", title: "SproutCore Blog" },
]
}
```
The helper is similar to the original `each` helper.
```
Handlebars.registerHelper('list', function(context, options) {
var ret = "<ul>";
for(var i=0, j=context.length; i<j; i++) {
ret = ret + "<li>" + options.fn(context[i]) + "</li>";
}
return ret + "</ul>";
});
```
Using a library like underscore.js or SproutCore's runtime library could make this a bit prettier. For example, here's what it might look like using SproutCore's runtime library:
```
Handlebars.registerHelper('list', function(context, options) {
return "<ul>" + context.map(function(item) {
return "<li>" + options.fn(item) + "</li>";
}).join("\n") + "</ul>";
});
```
Conditionals
-------------
Another common use-case for block helpers is to evaluate conditional statements. As with the iterators, Handlebars' built-in `if` and `unless` control structures are implemented as regular Handlebars helpers.
```
{{#if isActive}}
<img src="star.gif" alt="Active">
{{/if}}
```
Control structures typically do not change the current context, instead they decide whether or not to invoke the block based upon some variable.
```
Handlebars.registerHelper('if', function(conditional, options) {
if(conditional) {
return options.fn(this);
}
});
```
When writing a conditional, you will often want to make it possible for templates to provide a block of HTML that your helper should insert if the conditional evaluates to false. Handlebars handles this problem by providing generic `else` functionality to block helpers.
```
{{#if isActive}}
<img src="star.gif" alt="Active">
{{else}}
<img src="cry.gif" alt="Inactive">
{{/if}}
```
Handlebars provides the block for the `else` fragment as `options.inverse`. You do not need to check for the existence of the `else` fragment: Handlebars will detect it automatically and register a "noop" function.
```
Handlebars.registerHelper('if', function(conditional, options) {
if(conditional) {
return options.fn(this);
} else {
return options.inverse(this);
}
});
```
Handlebars provides additional metadata to block helpers by attaching them as properties of the options hash. Keep reading for more examples. Conditionals may also be chained by including the subsequent helper call within the else mustache.
```
{{#if isActive}}
<img src="star.gif" alt="Active">
{{else if isInactive}}
<img src="cry.gif" alt="Inactive">
{{/if}}
```
It is not necessary to use the same helper in subsequent calls, the `unless` helper could be used in the else portion as with any other helper. When the helper values are different, the closing mustache should match the opening helper name. Hash Arguments
---------------
Like regular helpers, block helpers can accept an optional Hash as its final argument. Let's revisit the `list` helper and make it possible for us to add any number of optional attributes to the `<ul>` element we will create.
```
{{#list nav id="nav-bar" class="top"}}
<a href="{{url}}">{{title}}</a>
{{/list}}
```
Handlebars provides the final hash as `options.hash`. This makes it easier to accept a variable number of parameters, while also accepting an optional Hash. If the template provides no hash arguments, Handlebars will automatically pass an empty object (`{}`), so you don't need to check for the existence of hash arguments.
```
Handlebars.registerHelper('list', function(context, options) {
var attrs = Object.keys(options.hash).map(function(key) {
return key + '="' + options.hash[key] + '"';
}).join(" ");
return "<ul " + attrs + ">" + context.map(function(item) {
return "<li>" + options.fn(item) + "</li>";
}).join("\n") + "</ul>";
});
```
Hash arguments provide a powerful way to offer a number of optional parameters to a block helper without the complexity caused by positional arguments. Block helpers can also inject private variables into their child templates. This can be useful to add extra information that is not in the original context data.
For example, when iterating over a list, you may provide the current index as a private variable.
```
{{#list array}}
{{@index}}. {{title}}
{{/list}}
```
```
Handlebars.registerHelper('list', function(context, options) {
var out = "<ul>", data;
if (options.data) {
data = Handlebars.createFrame(options.data);
}
for (var i=0; i<context.length; i++) {
if (data) {
data.index = i;
}
out += "<li>" + options.fn(context[i], { data: data }) + "</li>";
}
out += "</ul>";
return out;
});
```
Private variables provided via the `data` option are available in all descendent scopes. Private variables defined in parent scopes may be accessed via pathed queries. To access the `index` field of the parent iterator, `@../index` may be used. Make sure you create a new data frame in each helper that assigns its own data. Otherwise, downstream helpers might unexpectedly mutate upstream variables. Also ensure that the `data` field is defined prior to attempting to interact with an existing data object. The private variable behavior is condtionally compiled and some templates might not create this field. Block Parameters
-----------------
New in Handlebars 3.0, it's possible to receive named parameters from supporting helpers.
```
{{#each users as |user userId|}}
Id: {{userId}} Name: {{user.name}}
{{/each}}
```
In this particular example, `user` will have the same value as the current context and `userId` will have the index value for the iteration. This allows for nested helpers to avoid name conflicts that can occur with private variables.
```
{{#each users as |user userId|}}
{{#each user.book as |book bookId|}}
User Id: {{userId}} Book Id: {{bookId}}
{{/each}}
{{/each}}
```
A number of [builtin helpers](builtin_helpers) support block parameters and any custom helper may provide them through the `blockParams` options field.
```
Handlebars.registerHelper('block-params', function() {
var args = [],
options = arguments[arguments.length - 1];
for (var i = 0; i < arguments.length - 1; i++) {
args.push(arguments[i]);
}
return options.fn(this, {data: options.data, blockParams: args});
});
```
```
{{#block-params 1 2 3 as |foo bar baz|}}
{{foo}} {{bar}} {{baz}}
{{/block-params}}
```
Implements a helper that allows for named variable declarations within a given block. This example would output `1 2 3` on render. Helpers can determine the number of block parameters referenced by the template via the `options.fn.blockParams` field, which is an integer count. This value represents the number of block parameters that could be referenced by the child template. Parameters beyond this count will never be referenced and can safely be omitted by the helper if desired. This is optional and any additional parameters passed to the template will be silently ignored. Raw Blocks
-----------
Raw blocks are available for templates needing to handle unprocessed mustache blocks.
```
{{{{raw-helper}}}}
{{bar}}
{{{{/raw-helper}}}}
```
will execute the helper `raw-helper` without interpreting the content.
```
Handlebars.registerHelper('raw-helper', function(options) {
return options.fn();
});
```
will render
```
{{bar}}
```
| programming_docs |
handlebars Installation Installation
============
There are many different ways to install and use Handlebars, the following are some of the more popular. Please send [pull requests](https://github.com/wycats/handlebars-site/blob/master/src/pages/installation.haml) if we are missing one! The fastest route is to manually download the package and copy into your project but a number of other systems are available. [Download: 4.0.12](http://builds.handlebarsjs.com.s3.amazonaws.com/handlebars-v4.0.12.js) [Download: runtime-4.0.12](http://builds.handlebarsjs.com.s3.amazonaws.com/handlebars.runtime-v4.0.12.js) NPM
----
Handlebar's npm package includes both libraries suitable for CommonJS aware systems and built browser libraries that can be consumed direct browser mechanisms.
```
npm install --save handlebars
```
Require-aware systems such as Node and Webpack can then load via:
```
require('handlebars');
```
or for the runtime only:
```
require('handlebars/runtime');
```
The browser builds are located in the `node_modules/handlebars/dist/` directory. Making these accessible to the browser will depend on what build system you are using but this may be as simple as copying the files to an acessible place. This is the preferred method of installation when using the precompiler as it ensures that your precompiled templates always run against the same version of the runtime. Bower
------
Handlebars maintains a [bower component](https://github.com/components/handlebars.js) as well that is available for [bower](http://bower.io/) users. This can be installed in a project like so.
```
bower install --save handlebars
```
The default bower library is UMD-style so this should work properly with global, CJS, and AMD module systems. `handlebars.js` and `handlebars.runtime.js` are the primary source files but a number of other options exist in this component. We recommend looking at them and selecting the best one for your needs. This component should also work with other packagers such as [component](https://github.com/componentjs/component) but these have not been tested as throughly. Manual Download
----------------
All of Handlebar's released versions and CI builds are available for download on S3 in our [builds page](http://builds.handlebarsjs.com.s3.amazonaws.com/bucket-listing.html?sort=lastmod&sortdir=desc). The latest passing master build is named `handlebars-latest.js` and each passing SHA on master will create a `handlebars-gitSHA.js` file. While these all pass the CI, it's preferrable to use one of the tagged releases. \*\*Note\*\*: The S3 builds page is provided as a convenience for the community, but you should not use it for hosting Handlebars in production. CDNs
-----
Handlebars is hosted on a number of free CDNs as well. * [cdnjs](https://cdnjs.com/libraries/handlebars.js)
* [jsDelivr](http://www.jsdelivr.com/#!handlebarsjs). Advanced usage, such as [version aliasing & concocting](https://github.com/jsdelivr/jsdelivr#usage), is available.
handlebars Expressions Expressions
===========
Handlebars expressions are the basic unit of a Handlebars template. You can use them alone in a `{{mustache}}`, pass them to a Handlebars helper, or use them as values in hash arguments. Basic Usage
------------
The simplest Handlebars expression is a simple identifier:
```
<h1>{{title}}</h1>
```
This expression means "look up the `title` property in the current context". Block helpers may manipulate the current context, but they do not change the basic meaning of an expression. Actually, it means "look for a helper named `title`, then do the above", but we'll get to that soon enough. Handlebars expressions can also be dot-separated paths.
```
<h1>{{article.title}}</h1>
```
This expression means "look up the `article` property in the current context. Then look up the `title` property in the result". Handlebars also supports a deprecated `/` syntax, so you could write the above template as:
```
<h1>{{article/title}}</h1>
```
Identifiers may be any unicode character except for the following: Whitespace `!` `"` `#` `%` `&` `'` `(` `)` `*` `+` `,` `.` `/` `;` `<` `=` `>` `@` `[` `\` `]` `^` ``` `{` `|` `}` `~` To reference a property that is not a valid identifier, you can use segment-literal notation, `[`:
```
{{#each articles.[10].[#comments]}}
<h1>{{subject}}</h1>
<div>
{{body}}
</div>
{{/each}}
```
In the example above, the template will treat the `each` parameter roughly equivalent to this javascript: `articles[10]['#comments']` You may not include a closing `]` in a path-literal, but all other characters are fair game. JavaScript-style strings, `"` and `'`, may also be used vs. `[` pairs. Handlebars HTML-escapes values returned by a `{{expression}}`. If you don't want Handlebars to escape a value, use the "triple-stash", `{{{`
```
{{{foo}}}
```
Helpers
--------
A Handlebars helper call is a simple identifier, followed by zero or more parameters (separated by space). Each parameter is a Handlebars expression.
```
{{{link story}}}
```
In this case, `link` is the name of a Handlebars helper, and story is a parameter to the helper. Handlebars evaluates parameters in exactly the same way described above in "Basic Usage".
```
Handlebars.registerHelper('link', function(object) {
var url = Handlebars.escapeExpression(object.url),
text = Handlebars.escapeExpression(object.text);
return new Handlebars.SafeString(
"<a href='" + url + "'>" + text + "</a>"
);
});
```
When returning HTML from a helper, you should return a Handlebars SafeString if you don't want it to be escaped by default. When using SafeString all unknown or unsafe data should be manually escaped with the `escapeExpression` method. You can also pass a simple String, number, or boolean as a parameter to Handlebars helpers.
```
{{{link "See more..." story.url}}}
```
In this case, Handlebars will pass the link helper two parameters: the String `"See more..."` and the result of evaluating `story.url` in the current context.
```
Handlebars.registerHelper('link', function(text, url) {
url = Handlebars.escapeExpression(url);
text = Handlebars.escapeExpression(text);
return new Handlebars.SafeString(
"<a href='" + url + "'>" + text + "</a>"
);
});
```
You could use the exact same helper with dynamic text based on the value of `story.text`:
```
{{{link story.text story.url}}}
```
Handlebars helpers can also receive an optional sequence of key-value pairs as their final parameter (referred to as hash arguments in the documentation):
```
{{{link "See more..." href=story.url class="story"}}}
```
The keys in hash arguments must each be simple identifiers, and the values are Handlebars expressions. This means that values can be simple identifiers, paths, or Strings.
```
Handlebars.registerHelper('link', function(text, options) {
var attrs = [];
for (var prop in options.hash) {
attrs.push(
Handlebars.escapeExpression(prop) + '="'
+ Handlebars.escapeExpression(options.hash[prop]) + '"');
}
return new Handlebars.SafeString(
"<a " + attrs.join(" ") + ">" + Handlebars.escapeExpression(text) + "</a>"
);
});
```
Handlebars provides additional metadata, such as Hash arguments, to helpers as a final parameter. Handlebars also offers a mechanism for invoking a helper with a block of the template. Block helpers can then invoke that block zero or more times with any context it chooses. [Learn More: Block Helpers](block_helpers) Subexpressions
---------------
Handlebars offers support for subexpressions, which allows you to invoke multiple helpers within a single mustache, and pass in the results of inner helper invocations as arguments to outer helpers. Subexpressions are delimited by parentheses.
```
{{outer-helper (inner-helper 'abc') 'def'}}
```
In this case, `inner-helper` will get invoked with the string argument `'abc'`, and whatever the `inner-helper` function returns will get passed in as the first argument to `outer-helper` (and `'def'` will get passed in as the second argument to `outer-helper`). Whitespace Control
-------------------
Template whitespace may be omitted from either side of any mustache statement by adding a `~` character by the braces. When applied all whitespace on that side will be removed up to the first handlebars expression or non-whitespace character on that side.
```
{{#each nav ~}}
<a href="{{url}}">
{{~#if test}}
{{~title}}
{{~^~}}
Empty
{{~/if~}}
</a>
{{~/each}}
```
with this context:
```
{
nav: [
{url: 'foo', test: true, title: 'bar'},
{url: 'bar'}
]
}
```
results in output sans newlines and formatting whitespace:
```
<a href="foo">bar</a><a href="bar">Empty</a>
```
This expands the default behavior of stripping lines that are "standalone" helpers (only a block helper, comment, or partial and whitespace).
```
{{#each nav}}
<a href="{{url}}">
{{#if test}}
{{title}}
{{^}}
Empty
{{/if}}
</a>
{{~/each}}
```
will render
```
<a href="foo">
bar
</a>
<a href="bar">
Empty
</a>
```
Escaping
---------
Handlebars content may be escaped in one of two ways, inline escapes or raw block helpers. Inline escapes created by prefixing a mustache block with `\`. Raw blocks are created using `{{{{` mustache braces.
```
\{{escaped}}
{{{{raw}}}}
{{escaped}}
{{{{/raw}}}}
```
Raw blocks operate in the same manner as other [block helpers](block_helpers) with the distinction of the child content is treated as a literal string.
handlebars Builtin Helpers Builtin Helpers
===============
The `if` block helper
----------------------
You can use the `if` helper to conditionally render a block. If its argument returns `false`, `undefined`, `null`, `""`, `0`, or `[]`, Handlebars will not render the block.
```
<div class="entry">
{{#if author}}
<h1>{{firstName}} {{lastName}}</h1>
{{/if}}
</div>
```
when used with an empty (`{}`) context, `author` will be `undefined`, resulting in:
```
<div class="entry">
</div>
```
When using a block expression, you can specify a template section to run if the expression returns a falsy value. The section, marked by `{{else}}` is called an "else section".
```
<div class="entry">
{{#if author}}
<h1>{{firstName}} {{lastName}}</h1>
{{else}}
<h1>Unknown Author</h1>
{{/if}}
</div>
```
The `unless` block helper
--------------------------
You can use the `unless` helper as the inverse of the `if` helper. Its block will be rendered if the expression returns a falsy value.
```
<div class="entry">
{{#unless license}}
<h3 class="warning">WARNING: This entry does not have a license!</h3>
{{/unless}}
</div>
```
If looking up `license` under the current context returns a falsy value, Handlebars will render the warning. Otherwise, it will render nothing. The `each` block helper
------------------------
You can iterate over a list using the built-in `each` helper. Inside the block, you can use `this` to reference the element being iterated over.
```
<ul class="people_list">
{{#each people}}
<li>{{this}}</li>
{{/each}}
</ul>
```
when used with this context:
```
{
people: [
"Yehuda Katz",
"Alan Johnson",
"Charles Jolley"
]
}
```
will result in:
```
<ul class="people_list">
<li>Yehuda Katz</li>
<li>Alan Johnson</li>
<li>Charles Jolley</li>
</ul>
```
You can use the `this` expression in any context to reference the current context. You can optionally provide an `{{else}}` section which will display only when the list is empty.
```
{{#each paragraphs}}
<p>{{this}}</p>
{{else}}
<p class="empty">No content</p>
{{/each}}
```
When looping through items in `each`, you can optionally reference the current loop index via `{{@index}}`
```
{{#each array}}
{{@index}}: {{this}}
{{/each}}
```
Additionally for object iteration, `{{@key}}` references the current key name:
```
{{#each object}}
{{@key}}: {{this}}
{{/each}}
```
The first and last steps of iteration are noted via the `@first` and `@last` variables when iterating over an array. When iterating over an object only the `@first` is available. Nested `each` blocks may access the iteration variables via depth based paths. To access the parent index, for example, `{{@../index}}` can be used. The `each` helper also supports [block parameters](block_helpers#block-params), allowing for named references anywhere in the block.
```
{{#each array as |value key|}}
{{#each child as |childValue childKey|}}
{{key}} - {{childKey}}. {{childValue}}
{{/each}}
{{/each}}
```
Will create a `key` and `value` variable that children may access without the need for depthed variable references. In the example above, `{{key}}` is identical to `{{@../key}}` but in many cases is more readable. The `with` Block Helper
------------------------
Normally, Handlebars templates are evaluated against the context passed into the compiled method.
```
var source = "<p>{{lastName}}, {{firstName}}</p>";
var template = Handlebars.compile(source);
template({firstName: "Alan", lastName: "Johnson"});
```
results in
```
<p>Johnson, Alan</p>
```
You can shift the context for a section of a template by using the built-in `with` block helper.
```
<div class="entry">
<h1>{{title}}</h1>
{{#with author}}
<h2>By {{firstName}} {{lastName}}</h2>
{{/with}}
</div>
```
when used with this context:
```
{
title: "My first post!",
author: {
firstName: "Charles",
lastName: "Jolley"
}
}
```
will result in:
```
<div class="entry">
<h1>My first post!</h1>
<h2>By Charles Jolley</h2>
</div>
```
`with` can also be used with block parameters to define known references in the current block. The example above can be converted to
```
<div class="entry">
<h1>{{title}}</h1>
{{#with author as |myAuthor|}}
<h2>By {{myAuthor.firstName}} {{myAuthor.lastName}}</h2>
{{/with}}
</div>
```
Which allows for complex templates to potentially provide clearer code than `../` depthed references allow for. You can optionally provide an `{{else}}` section which will display only when the passed value is empty.
```
{{#with author}}
<p>{{name}}</p>
{{else}}
<p class="empty">No content</p>
{{/with}}
```
The `lookup` helper
--------------------
The `lookup` helper allows for dynamic parameter resolution using Handlebars variables. This is useful for resolving values for array indexes.
```
{{#each bar}}
{{lookup ../foo @index}}
{{/each}}
```
The `log` block helper
-----------------------
The `log` helper allows for logging of context state while executing a template.
```
{{log "Look at me!"}}
```
Delegates to `Handlebars.logger.log` which may be overriden to perform custom logging. Any number of arguments may be passed to this method and all will be forwarded to the logger.
```
{{log "This is logged" foo "And so is this"}}
```
The log level may be set using the `level` hash parameter. Supported values are `debug`, `info`, `warn`, and `error`. When omitted, `info` is the default value,
```
{{log "Log!" level="error"}}
```
Logging is conditional based on the level and to value set in `Handlebars.logger.level`, which defaults to `info`. All log statements at or above the current level will be output. The `blockHelperMissing` helper
--------------------------------
Implicitly called when a helper can not be directly resolved in the environment's helpers hash.
```
{{#foo}}{{/foo}}
```
will call this helper with the resolved value of `foo` on the current context and the `options.name` field set to `"foo"`. For instances where there is no registered helper named `foo`. This may be overriden by users that wish to change the behavior of block evaluation. For example
```
Handlebars.registerHelper('blockHelperMissing', function(context, options) {
throw new Handlebars.Exception('Only if or each is allowed');
});
```
could be used to prevent the use of mustache-style block evaluation in favor of the more efficent `if` and `each` helpers. The `helperMissing` helper
---------------------------
Internal helper that is called when a potential helper expression was not found in either the environment helpers or the current context. For cases where both are run, this is run prior to the `blockHelperMissing` helper.
```
{{foo}}
{{foo bar}}
{{#foo}}{{/foo}}
```
Will each call this helper, passing any arguments that would have been otherwise passed to a helper of the same name. This helper is not called when using `knownHelpersOnly` mode. This may be overriden by applications. To force the existence of the field, the following may be used:
```
Handlebars.registerHelper('helperMissing', function(/* [args, ] options */) {
var options = arguments[arguments.length - 1];
throw new Handlebars.Exception('Unknown field: ' + options.name);
});
```
gtk gtk4-broadwayd gtk4-broadwayd
==============
gtk4-broadwayd — Broadway display server
Synopsis
--------
`gtk4-broadwayd` [--port *`PORT`*] [--address *`ADDRESS`*] [--unixsocket *`ADDRESS`*] [*`:DISPLAY`*]
Description
-----------
**gtk4-broadwayd** is a display server for the Broadway GDK backend. It allows multiple GTK applications to display their windows in the same web browser, by connecting to gtk4-broadwayd.
When using gtk4-broadwayd, specify the display number to use, prefixed with a colon, similar to X. The default display number is 0.
```
gtk4-broadwayd :5
```
Then point your web browser at `http://127.0.0.1:8085`. Start your applications like this:
```
GDK_BACKEND=broadway BROADWAY_DISPLAY=:5 gtk4-demo
```
Options
-------
| | |
| --- | --- |
| --port | Use *`PORT`* as the HTTP port, instead of the default 8080 + (*`DISPLAY`* - 1). |
| --address | Use *`ADDRESS`* as the HTTP address, instead of the default `http://127.0.0.1:*`PORT`*`. |
| --unixsocket | Use *`ADDRESS`* as the unix domain socket address. This option overrides `--address` and `--port`. It is available only on Unix-like systems. |
gtk GtkAssistant GtkAssistant
============
GtkAssistant — A widget used to guide users through multi-step operations
Functions
---------
| | |
| --- | --- |
| [GtkWidget](gtkwidget#GtkWidget-struct) \* | [gtk\_assistant\_new](gtkassistant#gtk-assistant-new) () |
| [GtkAssistantPage](gtkassistant#GtkAssistantPage-struct) \* | [gtk\_assistant\_get\_page](gtkassistant#gtk-assistant-get-page) () |
| GListModel \* | [gtk\_assistant\_get\_pages](gtkassistant#gtk-assistant-get-pages) () |
| [GtkWidget](gtkwidget#GtkWidget-struct) \* | [gtk\_assistant\_page\_get\_child](gtkassistant#gtk-assistant-page-get-child) () |
| int | [gtk\_assistant\_get\_current\_page](gtkassistant#gtk-assistant-get-current-page) () |
| void | [gtk\_assistant\_set\_current\_page](gtkassistant#gtk-assistant-set-current-page) () |
| int | [gtk\_assistant\_get\_n\_pages](gtkassistant#gtk-assistant-get-n-pages) () |
| [GtkWidget](gtkwidget#GtkWidget-struct) \* | [gtk\_assistant\_get\_nth\_page](gtkassistant#gtk-assistant-get-nth-page) () |
| int | [gtk\_assistant\_prepend\_page](gtkassistant#gtk-assistant-prepend-page) () |
| int | [gtk\_assistant\_append\_page](gtkassistant#gtk-assistant-append-page) () |
| int | [gtk\_assistant\_insert\_page](gtkassistant#gtk-assistant-insert-page) () |
| void | [gtk\_assistant\_remove\_page](gtkassistant#gtk-assistant-remove-page) () |
| int | ([\*GtkAssistantPageFunc](gtkassistant#GtkAssistantPageFunc)) () |
| void | [gtk\_assistant\_set\_forward\_page\_func](gtkassistant#gtk-assistant-set-forward-page-func) () |
| void | [gtk\_assistant\_set\_page\_type](gtkassistant#gtk-assistant-set-page-type) () |
| [GtkAssistantPageType](gtkassistant#GtkAssistantPageType) | [gtk\_assistant\_get\_page\_type](gtkassistant#gtk-assistant-get-page-type) () |
| void | [gtk\_assistant\_set\_page\_title](gtkassistant#gtk-assistant-set-page-title) () |
| const char \* | [gtk\_assistant\_get\_page\_title](gtkassistant#gtk-assistant-get-page-title) () |
| void | [gtk\_assistant\_set\_page\_complete](gtkassistant#gtk-assistant-set-page-complete) () |
| gboolean | [gtk\_assistant\_get\_page\_complete](gtkassistant#gtk-assistant-get-page-complete) () |
| void | [gtk\_assistant\_add\_action\_widget](gtkassistant#gtk-assistant-add-action-widget) () |
| void | [gtk\_assistant\_remove\_action\_widget](gtkassistant#gtk-assistant-remove-action-widget) () |
| void | [gtk\_assistant\_update\_buttons\_state](gtkassistant#gtk-assistant-update-buttons-state) () |
| void | [gtk\_assistant\_commit](gtkassistant#gtk-assistant-commit) () |
| void | [gtk\_assistant\_next\_page](gtkassistant#gtk-assistant-next-page) () |
| void | [gtk\_assistant\_previous\_page](gtkassistant#gtk-assistant-previous-page) () |
Properties
----------
| | | |
| --- | --- | --- |
| GListModel \* | [pages](gtkassistant#GtkAssistant--pages) | Read |
| int | [use-header-bar](gtkassistant#GtkAssistant--use-header-bar) | Read / Write / Construct Only |
| [GtkWidget](gtkwidget#GtkWidget-struct) \* | [child](gtkassistant#GtkAssistantPage--child) | Read / Write / Construct Only |
| gboolean | [complete](gtkassistant#GtkAssistantPage--complete) | Read / Write |
| [GtkAssistantPageType](gtkassistant#GtkAssistantPageType) | [page-type](gtkassistant#GtkAssistantPage--page-type) | Read / Write |
| char \* | [title](gtkassistant#GtkAssistantPage--title) | Read / Write |
Signals
-------
| | | |
| --- | --- | --- |
| void | [apply](gtkassistant#GtkAssistant-apply) | Run Last |
| void | [cancel](gtkassistant#GtkAssistant-cancel) | Run Last |
| void | [close](gtkassistant#GtkAssistant-close) | Run Last |
| void | [escape](gtkassistant#GtkAssistant-escape) | Action |
| void | [prepare](gtkassistant#GtkAssistant-prepare) | Run Last |
Types and Values
----------------
| | |
| --- | --- |
| | [GtkAssistant](gtkassistant#GtkAssistant-struct) |
| | [GtkAssistantPage](gtkassistant#GtkAssistantPage-struct) |
| enum | [GtkAssistantPageType](gtkassistant#GtkAssistantPageType) |
Object Hierarchy
----------------
```
GObject
├── GInitiallyUnowned
│ ╰── [GtkWidget](gtkwidget#GtkWidget-struct)
│ ╰── [GtkWindow](gtkwindow#GtkWindow-struct)
│ ╰── GtkAssistant
╰── GtkAssistantPage
```
Implemented Interfaces
----------------------
GtkAssistant implements [GtkAccessible](gtkaccessible#GtkAccessible-struct), [GtkBuildable](gtkbuildable#GtkBuildable-struct), [GtkConstraintTarget](gtkconstraint#GtkConstraintTarget-struct), [GtkNative](gtknative#GtkNative-struct), [GtkShortcutManager](gtkshortcutmanager#GtkShortcutManager-struct) and [GtkRoot](gtkroot#GtkRoot-struct).
Includes
--------
```
#include <gtk/gtk.h>
```
Description
-----------
A [GtkAssistant](gtkassistant#GtkAssistant-struct) is a widget used to represent a generally complex operation split up into several steps. Each step consists of one or more pages. GtkAssistant guides the user through the pages, and controls the page flow to collect the data needed for the operation.
GtkAssistant handles which buttons to show and to make sensitive based on page sequence knowledge and the [type](gtkassistant#GtkAssistantPageType) of each page in addition to state information like the [completion](gtkassistant#gtk-assistant-set-page-complete) and [committed](gtkassistant#gtk-assistant-commit) page statuses.
If you have a case that doesn’t quite fit in [GtkAssistants](gtkassistant#GtkAssistant-struct) way of handling buttons, you can use the [GTK\_ASSISTANT\_PAGE\_CUSTOM](gtkassistant#GTK-ASSISTANT-PAGE-CUSTOM:CAPS) page type and handle buttons yourself.
GtkAssistant maintains a [GtkAssistantPage](gtkassistant#GtkAssistantPage-struct) object for each added child, which holds additional per-child properties. You obtain the [GtkAssistantPage](gtkassistant#GtkAssistantPage-struct) for a child with [`gtk_assistant_get_page()`](gtkassistant#gtk-assistant-get-page).
### GtkAssistant as GtkBuildable
The GtkAssistant implementation of the [GtkBuildable](gtkbuildable#GtkBuildable-struct) interface exposes the *`action_area`* as internal children with the name “action\_area”.
To add pages to an assistant in [GtkBuilder](gtkbuilder#GtkBuilder-struct), simply add it as a child to the GtkAssistant object. If you need to set per-object properties, create a [GtkAssistantPage](gtkassistant#GtkAssistantPage-struct) object explicitly, and set the child widget as a property on it.
### CSS nodes
GtkAssistant has a single CSS node with the name window and style class .assistant.
Functions
---------
### gtk\_assistant\_new ()
```
[GtkWidget](gtkwidget#GtkWidget-struct) *
gtk_assistant_new (*`void`*);
```
Creates a new [GtkAssistant](gtkassistant#GtkAssistant-struct).
#### Returns
a newly created [GtkAssistant](gtkassistant#GtkAssistant-struct)
### gtk\_assistant\_get\_page ()
```
[GtkAssistantPage](gtkassistant#GtkAssistantPage-struct) *
gtk_assistant_get_page (*`[GtkAssistant](gtkassistant#GtkAssistant-struct) *assistant`*,
*`[GtkWidget](gtkwidget#GtkWidget-struct) *child`*);
```
Returns the [GtkAssistantPage](gtkassistant#GtkAssistantPage-struct) object for *`child`* .
#### Parameters
| | | |
| --- | --- | --- |
| assistant | a [GtkAssistant](gtkassistant#GtkAssistant-struct) | |
| child | a child of *`assistant`* | |
#### Returns
the [GtkAssistantPage](gtkassistant#GtkAssistantPage-struct) for *`child`* .
[transfer none]
### gtk\_assistant\_get\_pages ()
```
GListModel *
gtk_assistant_get_pages (*`[GtkAssistant](gtkassistant#GtkAssistant-struct) *assistant`*);
```
Gets a list model of the assistant pages.
#### Parameters
| | | |
| --- | --- | --- |
| assistant | a [GtkAssistant](gtkassistant#GtkAssistant-struct) | |
#### Returns
A list model of the pages.
[transfer full][attributes element-type=GtkAssistantPage]
### gtk\_assistant\_page\_get\_child ()
```
[GtkWidget](gtkwidget#GtkWidget-struct) *
gtk_assistant_page_get_child (*`[GtkAssistantPage](gtkassistant#GtkAssistantPage-struct) *page`*);
```
Returns the child to which *`page`* belongs.
#### Parameters
| | | |
| --- | --- | --- |
| page | a [GtkAssistantPage](gtkassistant#GtkAssistantPage-struct) | |
#### Returns
the child to which *`page`* belongs.
[transfer none]
### gtk\_assistant\_get\_current\_page ()
```
int
gtk_assistant_get_current_page (*`[GtkAssistant](gtkassistant#GtkAssistant-struct) *assistant`*);
```
Returns the page number of the current page.
#### Parameters
| | | |
| --- | --- | --- |
| assistant | a [GtkAssistant](gtkassistant#GtkAssistant-struct) | |
#### Returns
The index (starting from 0) of the current page in the *`assistant`* , or -1 if the *`assistant`* has no pages, or no current page.
### gtk\_assistant\_set\_current\_page ()
```
void
gtk_assistant_set_current_page (*`[GtkAssistant](gtkassistant#GtkAssistant-struct) *assistant`*,
*`int page_num`*);
```
Switches the page to *`page_num`* .
Note that this will only be necessary in custom buttons, as the *`assistant`* flow can be set with [`gtk_assistant_set_forward_page_func()`](gtkassistant#gtk-assistant-set-forward-page-func).
#### Parameters
| | | |
| --- | --- | --- |
| assistant | a [GtkAssistant](gtkassistant#GtkAssistant-struct) | |
| page\_num | index of the page to switch to, starting from 0. If negative, the last page will be used. If greater than the number of pages in the *`assistant`* , nothing will be done. | |
### gtk\_assistant\_get\_n\_pages ()
```
int
gtk_assistant_get_n_pages (*`[GtkAssistant](gtkassistant#GtkAssistant-struct) *assistant`*);
```
Returns the number of pages in the *`assistant`*
#### Parameters
| | | |
| --- | --- | --- |
| assistant | a [GtkAssistant](gtkassistant#GtkAssistant-struct) | |
#### Returns
the number of pages in the *`assistant`*
### gtk\_assistant\_get\_nth\_page ()
```
[GtkWidget](gtkwidget#GtkWidget-struct) *
gtk_assistant_get_nth_page (*`[GtkAssistant](gtkassistant#GtkAssistant-struct) *assistant`*,
*`int page_num`*);
```
Returns the child widget contained in page number *`page_num`* .
#### Parameters
| | | |
| --- | --- | --- |
| assistant | a [GtkAssistant](gtkassistant#GtkAssistant-struct) | |
| page\_num | the index of a page in the *`assistant`* , or -1 to get the last page | |
#### Returns
the child widget, or `NULL` if *`page_num`* is out of bounds.
[nullable][transfer none]
### gtk\_assistant\_prepend\_page ()
```
int
gtk_assistant_prepend_page (*`[GtkAssistant](gtkassistant#GtkAssistant-struct) *assistant`*,
*`[GtkWidget](gtkwidget#GtkWidget-struct) *page`*);
```
Prepends a page to the *`assistant`* .
#### Parameters
| | | |
| --- | --- | --- |
| assistant | a [GtkAssistant](gtkassistant#GtkAssistant-struct) | |
| page | a [GtkWidget](gtkwidget#GtkWidget-struct) | |
#### Returns
the index (starting at 0) of the inserted page
### gtk\_assistant\_append\_page ()
```
int
gtk_assistant_append_page (*`[GtkAssistant](gtkassistant#GtkAssistant-struct) *assistant`*,
*`[GtkWidget](gtkwidget#GtkWidget-struct) *page`*);
```
Appends a page to the *`assistant`* .
#### Parameters
| | | |
| --- | --- | --- |
| assistant | a [GtkAssistant](gtkassistant#GtkAssistant-struct) | |
| page | a [GtkWidget](gtkwidget#GtkWidget-struct) | |
#### Returns
the index (starting at 0) of the inserted page
### gtk\_assistant\_insert\_page ()
```
int
gtk_assistant_insert_page (*`[GtkAssistant](gtkassistant#GtkAssistant-struct) *assistant`*,
*`[GtkWidget](gtkwidget#GtkWidget-struct) *page`*,
*`int position`*);
```
Inserts a page in the *`assistant`* at a given position.
#### Parameters
| | | |
| --- | --- | --- |
| assistant | a [GtkAssistant](gtkassistant#GtkAssistant-struct) | |
| page | a [GtkWidget](gtkwidget#GtkWidget-struct) | |
| position | the index (starting at 0) at which to insert the page, or -1 to append the page to the *`assistant`* | |
#### Returns
the index (starting from 0) of the inserted page
### gtk\_assistant\_remove\_page ()
```
void
gtk_assistant_remove_page (*`[GtkAssistant](gtkassistant#GtkAssistant-struct) *assistant`*,
*`int page_num`*);
```
Removes the *`page_num`* ’s page from *`assistant`* .
#### Parameters
| | | |
| --- | --- | --- |
| assistant | a [GtkAssistant](gtkassistant#GtkAssistant-struct) | |
| page\_num | the index of a page in the *`assistant`* , or -1 to remove the last page | |
### GtkAssistantPageFunc ()
```
int
(*GtkAssistantPageFunc) (int current_page,
gpointer data);
```
A function used by [`gtk_assistant_set_forward_page_func()`](gtkassistant#gtk-assistant-set-forward-page-func) to know which is the next page given a current one. It’s called both for computing the next page when the user presses the “forward” button and for handling the behavior of the “last” button.
#### Parameters
| | | |
| --- | --- | --- |
| current\_page | The page number used to calculate the next page. | |
| data | user data. | [closure] |
#### Returns
The next page number.
### gtk\_assistant\_set\_forward\_page\_func ()
```
void
gtk_assistant_set_forward_page_func (*`[GtkAssistant](gtkassistant#GtkAssistant-struct) *assistant`*,
*`[GtkAssistantPageFunc](gtkassistant#GtkAssistantPageFunc) page_func`*,
*`gpointer data`*,
*`GDestroyNotify destroy`*);
```
Sets the page forwarding function to be *`page_func`* .
This function will be used to determine what will be the next page when the user presses the forward button. Setting *`page_func`* to `NULL` will make the assistant to use the default forward function, which just goes to the next visible page.
#### Parameters
| | | |
| --- | --- | --- |
| assistant | a [GtkAssistant](gtkassistant#GtkAssistant-struct) | |
| page\_func | the [GtkAssistantPageFunc](gtkassistant#GtkAssistantPageFunc), or `NULL` to use the default one. | [allow-none] |
| data | user data for *`page_func`* | |
| destroy | destroy notifier for *`data`* | |
### gtk\_assistant\_set\_page\_type ()
```
void
gtk_assistant_set_page_type (*`[GtkAssistant](gtkassistant#GtkAssistant-struct) *assistant`*,
*`[GtkWidget](gtkwidget#GtkWidget-struct) *page`*,
*`[GtkAssistantPageType](gtkassistant#GtkAssistantPageType) type`*);
```
Sets the page type for *`page`* .
The page type determines the page behavior in the *`assistant`* .
#### Parameters
| | | |
| --- | --- | --- |
| assistant | a [GtkAssistant](gtkassistant#GtkAssistant-struct) | |
| page | a page of *`assistant`* | |
| type | the new type for *`page`* | |
### gtk\_assistant\_get\_page\_type ()
```
[GtkAssistantPageType](gtkassistant#GtkAssistantPageType)
gtk_assistant_get_page_type (*`[GtkAssistant](gtkassistant#GtkAssistant-struct) *assistant`*,
*`[GtkWidget](gtkwidget#GtkWidget-struct) *page`*);
```
Gets the page type of *`page`* .
#### Parameters
| | | |
| --- | --- | --- |
| assistant | a [GtkAssistant](gtkassistant#GtkAssistant-struct) | |
| page | a page of *`assistant`* | |
#### Returns
the page type of *`page`*
### gtk\_assistant\_set\_page\_title ()
```
void
gtk_assistant_set_page_title (*`[GtkAssistant](gtkassistant#GtkAssistant-struct) *assistant`*,
*`[GtkWidget](gtkwidget#GtkWidget-struct) *page`*,
*`const char *title`*);
```
Sets a title for *`page`* .
The title is displayed in the header area of the assistant when *`page`* is the current page.
#### Parameters
| | | |
| --- | --- | --- |
| assistant | a [GtkAssistant](gtkassistant#GtkAssistant-struct) | |
| page | a page of *`assistant`* | |
| title | the new title for *`page`* | |
### gtk\_assistant\_get\_page\_title ()
```
const char *
gtk_assistant_get_page_title (*`[GtkAssistant](gtkassistant#GtkAssistant-struct) *assistant`*,
*`[GtkWidget](gtkwidget#GtkWidget-struct) *page`*);
```
Gets the title for *`page`* .
#### Parameters
| | | |
| --- | --- | --- |
| assistant | a [GtkAssistant](gtkassistant#GtkAssistant-struct) | |
| page | a page of *`assistant`* | |
#### Returns
the title for *`page`*
### gtk\_assistant\_set\_page\_complete ()
```
void
gtk_assistant_set_page_complete (*`[GtkAssistant](gtkassistant#GtkAssistant-struct) *assistant`*,
*`[GtkWidget](gtkwidget#GtkWidget-struct) *page`*,
*`gboolean complete`*);
```
Sets whether *`page`* contents are complete.
This will make *`assistant`* update the buttons state to be able to continue the task.
#### Parameters
| | | |
| --- | --- | --- |
| assistant | a [GtkAssistant](gtkassistant#GtkAssistant-struct) | |
| page | a page of *`assistant`* | |
| complete | the completeness status of the page | |
### gtk\_assistant\_get\_page\_complete ()
```
gboolean
gtk_assistant_get_page_complete (*`[GtkAssistant](gtkassistant#GtkAssistant-struct) *assistant`*,
*`[GtkWidget](gtkwidget#GtkWidget-struct) *page`*);
```
Gets whether *`page`* is complete.
#### Parameters
| | | |
| --- | --- | --- |
| assistant | a [GtkAssistant](gtkassistant#GtkAssistant-struct) | |
| page | a page of *`assistant`* | |
#### Returns
`TRUE` if *`page`* is complete.
### gtk\_assistant\_add\_action\_widget ()
```
void
gtk_assistant_add_action_widget (*`[GtkAssistant](gtkassistant#GtkAssistant-struct) *assistant`*,
*`[GtkWidget](gtkwidget#GtkWidget-struct) *child`*);
```
Adds a widget to the action area of a [GtkAssistant](gtkassistant#GtkAssistant-struct).
#### Parameters
| | | |
| --- | --- | --- |
| assistant | a [GtkAssistant](gtkassistant#GtkAssistant-struct) | |
| child | a [GtkWidget](gtkwidget#GtkWidget-struct) | |
### gtk\_assistant\_remove\_action\_widget ()
```
void
gtk_assistant_remove_action_widget (*`[GtkAssistant](gtkassistant#GtkAssistant-struct) *assistant`*,
*`[GtkWidget](gtkwidget#GtkWidget-struct) *child`*);
```
Removes a widget from the action area of a [GtkAssistant](gtkassistant#GtkAssistant-struct).
#### Parameters
| | | |
| --- | --- | --- |
| assistant | a [GtkAssistant](gtkassistant#GtkAssistant-struct) | |
| child | a [GtkWidget](gtkwidget#GtkWidget-struct) | |
### gtk\_assistant\_update\_buttons\_state ()
```
void
gtk_assistant_update_buttons_state (*`[GtkAssistant](gtkassistant#GtkAssistant-struct) *assistant`*);
```
Forces *`assistant`* to recompute the buttons state.
GTK automatically takes care of this in most situations, e.g. when the user goes to a different page, or when the visibility or completeness of a page changes.
One situation where it can be necessary to call this function is when changing a value on the current page affects the future page flow of the assistant.
#### Parameters
| | | |
| --- | --- | --- |
| assistant | a [GtkAssistant](gtkassistant#GtkAssistant-struct) | |
### gtk\_assistant\_commit ()
```
void
gtk_assistant_commit (*`[GtkAssistant](gtkassistant#GtkAssistant-struct) *assistant`*);
```
Erases the visited page history so the back button is not shown on the current page, and removes the cancel button from subsequent pages.
Use this when the information provided up to the current page is hereafter deemed permanent and cannot be modified or undone. For example, showing a progress page to track a long-running, unreversible operation after the user has clicked apply on a confirmation page.
#### Parameters
| | | |
| --- | --- | --- |
| assistant | a [GtkAssistant](gtkassistant#GtkAssistant-struct) | |
### gtk\_assistant\_next\_page ()
```
void
gtk_assistant_next_page (*`[GtkAssistant](gtkassistant#GtkAssistant-struct) *assistant`*);
```
Navigate to the next page.
It is a programming error to call this function when there is no next page.
This function is for use when creating pages of the [GTK\_ASSISTANT\_PAGE\_CUSTOM](gtkassistant#GTK-ASSISTANT-PAGE-CUSTOM:CAPS) type.
#### Parameters
| | | |
| --- | --- | --- |
| assistant | a [GtkAssistant](gtkassistant#GtkAssistant-struct) | |
### gtk\_assistant\_previous\_page ()
```
void
gtk_assistant_previous_page (*`[GtkAssistant](gtkassistant#GtkAssistant-struct) *assistant`*);
```
Navigate to the previous visited page.
It is a programming error to call this function when no previous page is available.
This function is for use when creating pages of the [GTK\_ASSISTANT\_PAGE\_CUSTOM](gtkassistant#GTK-ASSISTANT-PAGE-CUSTOM:CAPS) type.
#### Parameters
| | | |
| --- | --- | --- |
| assistant | a [GtkAssistant](gtkassistant#GtkAssistant-struct) | |
Types and Values
----------------
### GtkAssistant
```
typedef struct _GtkAssistant GtkAssistant;
```
### GtkAssistantPage
```
typedef struct _GtkAssistantPage GtkAssistantPage;
```
### enum GtkAssistantPageType
An enum for determining the page role inside the [GtkAssistant](gtkassistant#GtkAssistant-struct). It's used to handle buttons sensitivity and visibility.
Note that an assistant needs to end its page flow with a page of type [`GTK_ASSISTANT_PAGE_CONFIRM`](gtkassistant#GTK-ASSISTANT-PAGE-CONFIRM:CAPS), [`GTK_ASSISTANT_PAGE_SUMMARY`](gtkassistant#GTK-ASSISTANT-PAGE-SUMMARY:CAPS) or [`GTK_ASSISTANT_PAGE_PROGRESS`](gtkassistant#GTK-ASSISTANT-PAGE-PROGRESS:CAPS) to be correct.
The Cancel button will only be shown if the page isn’t “committed”. See [`gtk_assistant_commit()`](gtkassistant#gtk-assistant-commit) for details.
#### Members
| | | |
| --- | --- | --- |
| GTK\_ASSISTANT\_PAGE\_CONTENT | The page has regular contents. Both the Back and forward buttons will be shown. | |
| GTK\_ASSISTANT\_PAGE\_INTRO | The page contains an introduction to the assistant task. Only the Forward button will be shown if there is a next page. | |
| GTK\_ASSISTANT\_PAGE\_CONFIRM | The page lets the user confirm or deny the changes. The Back and Apply buttons will be shown. | |
| GTK\_ASSISTANT\_PAGE\_SUMMARY | The page informs the user of the changes done. Only the Close button will be shown. | |
| GTK\_ASSISTANT\_PAGE\_PROGRESS | Used for tasks that take a long time to complete, blocks the assistant until the page is marked as complete. Only the back button will be shown. | |
| GTK\_ASSISTANT\_PAGE\_CUSTOM | Used for when other page types are not appropriate. No buttons will be shown, and the application must add its own buttons through [`gtk_assistant_add_action_widget()`](gtkassistant#gtk-assistant-add-action-widget). | |
Property Details
----------------
### The `“pages”` property
```
“pages” GListModel *
```
The pages of the assistant.
Owner: GtkAssistant
Flags: Read
### The `“use-header-bar”` property
```
“use-header-bar” int
```
`TRUE` if the assistant uses a [GtkHeaderBar](gtkheaderbar#GtkHeaderBar-struct) for action buttons instead of the action-area.
For technical reasons, this property is declared as an integer property, but you should only set it to `TRUE` or `FALSE`.
Owner: GtkAssistant
Flags: Read / Write / Construct Only
Allowed values: [-1,1]
Default value: -1
### The `“child”` property
```
“child” [GtkWidget](gtkwidget#GtkWidget-struct) *
```
The content the assistant page.
Owner: GtkAssistantPage
Flags: Read / Write / Construct Only
### The `“complete”` property
```
“complete” gboolean
```
Setting the "complete" property to `TRUE` marks a page as complete (i.e.: all the required fields are filled out). GTK uses this information to control the sensitivity of the navigation buttons.
Owner: GtkAssistantPage
Flags: Read / Write
Default value: FALSE
### The `“page-type”` property
```
“page-type” [GtkAssistantPageType](gtkassistant#GtkAssistantPageType)
```
The type of the assistant page.
Owner: GtkAssistantPage
Flags: Read / Write
Default value: GTK\_ASSISTANT\_PAGE\_CONTENT
### The `“title”` property
```
“title” char *
```
The title of the page.
Owner: GtkAssistantPage
Flags: Read / Write
Default value: NULL
Signal Details
--------------
### The `“apply”` signal
```
void
user_function ([GtkAssistant](gtkassistant#GtkAssistant-struct) *assistant,
gpointer user_data)
```
The ::apply signal is emitted when the apply button is clicked.
The default behavior of the [GtkAssistant](gtkassistant#GtkAssistant-struct) is to switch to the page after the current page, unless the current page is the last one.
A handler for the ::apply signal should carry out the actions for which the wizard has collected data. If the action takes a long time to complete, you might consider putting a page of type [`GTK_ASSISTANT_PAGE_PROGRESS`](gtkassistant#GTK-ASSISTANT-PAGE-PROGRESS:CAPS) after the confirmation page and handle this operation within the [“prepare”](gtkassistant#GtkAssistant-prepare) signal of the progress page.
#### Parameters
| | | |
| --- | --- | --- |
| assistant | the [GtkAssistant](gtkassistant#GtkAssistant-struct) | |
| user\_data | user data set when the signal handler was connected. | |
Flags: Run Last
### The `“cancel”` signal
```
void
user_function ([GtkAssistant](gtkassistant#GtkAssistant-struct) *assistant,
gpointer user_data)
```
The ::cancel signal is emitted when then the cancel button is clicked.
#### Parameters
| | | |
| --- | --- | --- |
| assistant | the [GtkAssistant](gtkassistant#GtkAssistant-struct) | |
| user\_data | user data set when the signal handler was connected. | |
Flags: Run Last
### The `“close”` signal
```
void
user_function ([GtkAssistant](gtkassistant#GtkAssistant-struct) *assistant,
gpointer user_data)
```
The ::close signal is emitted either when the close button of a summary page is clicked, or when the apply button in the last page in the flow (of type [`GTK_ASSISTANT_PAGE_CONFIRM`](gtkassistant#GTK-ASSISTANT-PAGE-CONFIRM:CAPS)) is clicked.
#### Parameters
| | | |
| --- | --- | --- |
| assistant | the [GtkAssistant](gtkassistant#GtkAssistant-struct) | |
| user\_data | user data set when the signal handler was connected. | |
Flags: Run Last
### The `“escape”` signal
```
void
user_function ([GtkAssistant](gtkassistant#GtkAssistant-struct) *assistant,
gpointer user_data)
```
The action signal for the Escape binding.
#### Parameters
| | | |
| --- | --- | --- |
| assistant | the [GtkAssistant](gtkassistant#GtkAssistant-struct) | |
| user\_data | user data set when the signal handler was connected. | |
Flags: Action
### The `“prepare”` signal
```
void
user_function ([GtkAssistant](gtkassistant#GtkAssistant-struct) *assistant,
[GtkWidget](gtkwidget#GtkWidget-struct) *page,
gpointer user_data)
```
The ::prepare signal is emitted when a new page is set as the assistant's current page, before making the new page visible.
A handler for this signal can do any preparations which are necessary before showing *`page`* .
#### Parameters
| | | |
| --- | --- | --- |
| assistant | the [GtkAssistant](gtkassistant#GtkAssistant-struct) | |
| page | the current page | |
| user\_data | user data set when the signal handler was connected. | |
Flags: Run Last
| programming_docs |
gtk GtkTextTagTable GtkTextTagTable
===============
GtkTextTagTable — Collection of tags that can be used together
Functions
---------
| | |
| --- | --- |
| void | ([\*GtkTextTagTableForeach](gtktexttagtable#GtkTextTagTableForeach)) () |
| [GtkTextTagTable](gtktexttagtable#GtkTextTagTable-struct) \* | [gtk\_text\_tag\_table\_new](gtktexttagtable#gtk-text-tag-table-new) () |
| gboolean | [gtk\_text\_tag\_table\_add](gtktexttagtable#gtk-text-tag-table-add) () |
| void | [gtk\_text\_tag\_table\_remove](gtktexttagtable#gtk-text-tag-table-remove) () |
| [GtkTextTag](gtktexttag#GtkTextTag-struct) \* | [gtk\_text\_tag\_table\_lookup](gtktexttagtable#gtk-text-tag-table-lookup) () |
| void | [gtk\_text\_tag\_table\_foreach](gtktexttagtable#gtk-text-tag-table-foreach) () |
| int | [gtk\_text\_tag\_table\_get\_size](gtktexttagtable#gtk-text-tag-table-get-size) () |
Signals
-------
| | | |
| --- | --- | --- |
| void | [tag-added](gtktexttagtable#GtkTextTagTable-tag-added) | Run Last |
| void | [tag-changed](gtktexttagtable#GtkTextTagTable-tag-changed) | Run Last |
| void | [tag-removed](gtktexttagtable#GtkTextTagTable-tag-removed) | Run Last |
Types and Values
----------------
| | |
| --- | --- |
| | [GtkTextTagTable](gtktexttagtable#GtkTextTagTable-struct) |
Object Hierarchy
----------------
```
GObject
╰── GtkTextTagTable
```
Implemented Interfaces
----------------------
GtkTextTagTable implements [GtkBuildable](gtkbuildable#GtkBuildable-struct).
Includes
--------
```
#include <gtk/gtk.h>
```
Description
-----------
You may wish to begin by reading the [text widget conceptual overview](textwidgetobjects#TextWidget) which gives an overview of all the objects and data types related to the text widget and how they work together.
### GtkTextTagTables as GtkBuildable
The GtkTextTagTable implementation of the GtkBuildable interface supports adding tags by specifying “tag” as the “type” attribute of a <child> element.
An example of a UI definition fragment specifying tags:
```
<object class="GtkTextTagTable">
<child type="tag">
<object class="GtkTextTag"/>
</child>
</object>
```
| Functions
---------
### GtkTextTagTableForeach ()
```
void
(*GtkTextTagTableForeach) (*`[GtkTextTag](gtktexttag#GtkTextTag-struct) *tag`*,
*`gpointer data`*);
```
A function used with [`gtk_text_tag_table_foreach()`](gtktexttagtable#gtk-text-tag-table-foreach), to iterate over every [GtkTextTag](gtktexttag#GtkTextTag-struct) inside a [GtkTextTagTable](gtktexttagtable#GtkTextTagTable-struct).
#### Parameters
| | | |
| --- | --- | --- |
| tag | the [GtkTextTag](gtktexttag#GtkTextTag-struct) | |
| data | data passed to [`gtk_text_tag_table_foreach()`](gtktexttagtable#gtk-text-tag-table-foreach). | [closure] |
### gtk\_text\_tag\_table\_new ()
```
[GtkTextTagTable](gtktexttagtable#GtkTextTagTable-struct) *
gtk_text_tag_table_new (*`void`*);
```
Creates a new [GtkTextTagTable](gtktexttagtable#GtkTextTagTable-struct). The table contains no tags by default.
#### Returns
a new [GtkTextTagTable](gtktexttagtable#GtkTextTagTable-struct)
### gtk\_text\_tag\_table\_add ()
```
gboolean
gtk_text_tag_table_add (*`[GtkTextTagTable](gtktexttagtable#GtkTextTagTable-struct) *table`*,
*`[GtkTextTag](gtktexttag#GtkTextTag-struct) *tag`*);
```
Add a tag to the table. The tag is assigned the highest priority in the table.
*`tag`* must not be in a tag table already, and may not have the same name as an already-added tag.
#### Parameters
| | | |
| --- | --- | --- |
| table | a [GtkTextTagTable](gtktexttagtable#GtkTextTagTable-struct) | |
| tag | a [GtkTextTag](gtktexttag#GtkTextTag-struct) | |
#### Returns
`TRUE` on success.
### gtk\_text\_tag\_table\_remove ()
```
void
gtk_text_tag_table_remove (*`[GtkTextTagTable](gtktexttagtable#GtkTextTagTable-struct) *table`*,
*`[GtkTextTag](gtktexttag#GtkTextTag-struct) *tag`*);
```
Remove a tag from the table. If a [GtkTextBuffer](gtktextbuffer#GtkTextBuffer-struct) has *`table`* as its tag table, the tag is removed from the buffer. The table’s reference to the tag is removed, so the tag will end up destroyed if you don’t have a reference to it.
#### Parameters
| | | |
| --- | --- | --- |
| table | a [GtkTextTagTable](gtktexttagtable#GtkTextTagTable-struct) | |
| tag | a [GtkTextTag](gtktexttag#GtkTextTag-struct) | |
### gtk\_text\_tag\_table\_lookup ()
```
[GtkTextTag](gtktexttag#GtkTextTag-struct) *
gtk_text_tag_table_lookup (*`[GtkTextTagTable](gtktexttagtable#GtkTextTagTable-struct) *table`*,
*`const char *name`*);
```
Look up a named tag.
#### Parameters
| | | |
| --- | --- | --- |
| table | a [GtkTextTagTable](gtktexttagtable#GtkTextTagTable-struct) | |
| name | name of a tag | |
#### Returns
The tag, or `NULL` if none by that name is in the table.
[nullable][transfer none]
### gtk\_text\_tag\_table\_foreach ()
```
void
gtk_text_tag_table_foreach (*`[GtkTextTagTable](gtktexttagtable#GtkTextTagTable-struct) *table`*,
*`[GtkTextTagTableForeach](gtktexttagtable#GtkTextTagTableForeach) func`*,
*`gpointer data`*);
```
Calls *`func`* on each tag in *`table`* , with user data *`data`* . Note that the table may not be modified while iterating over it (you can’t add/remove tags).
#### Parameters
| | | |
| --- | --- | --- |
| table | a [GtkTextTagTable](gtktexttagtable#GtkTextTagTable-struct) | |
| func | a function to call on each tag. | [scope call] |
| data | user data | |
### gtk\_text\_tag\_table\_get\_size ()
```
int
gtk_text_tag_table_get_size (*`[GtkTextTagTable](gtktexttagtable#GtkTextTagTable-struct) *table`*);
```
Returns the size of the table (number of tags)
#### Parameters
| | | |
| --- | --- | --- |
| table | a [GtkTextTagTable](gtktexttagtable#GtkTextTagTable-struct) | |
#### Returns
number of tags in *`table`*
Types and Values
----------------
### GtkTextTagTable
```
typedef struct _GtkTextTagTable GtkTextTagTable;
```
An object holding all the [GtkTextTag](gtktexttag#GtkTextTag-struct) instances for a [GtkTextBuffer](gtktextbuffer#GtkTextBuffer-struct).
Signal Details
--------------
### The `“tag-added”` signal
```
void
user_function ([GtkTextTagTable](gtktexttagtable#GtkTextTagTable-struct) *texttagtable,
[GtkTextTag](gtktexttag#GtkTextTag-struct) *tag,
gpointer user_data)
```
Emitted every time a new tag is added in the [GtkTextTagTable](gtktexttagtable#GtkTextTagTable-struct).
#### Parameters
| | | |
| --- | --- | --- |
| texttagtable | the object which received the signal. | |
| tag | the added tag. | |
| user\_data | user data set when the signal handler was connected. | |
Flags: Run Last
### The `“tag-changed”` signal
```
void
user_function ([GtkTextTagTable](gtktexttagtable#GtkTextTagTable-struct) *texttagtable,
[GtkTextTag](gtktexttag#GtkTextTag-struct) *tag,
gboolean size_changed,
gpointer user_data)
```
Emitted every time a tag in the [GtkTextTagTable](gtktexttagtable#GtkTextTagTable-struct) changes.
#### Parameters
| | | |
| --- | --- | --- |
| texttagtable | the object which received the signal. | |
| tag | the changed tag. | |
| size\_changed | whether the change affects the [GtkTextView](gtktextview#GtkTextView-struct) layout. | |
| user\_data | user data set when the signal handler was connected. | |
Flags: Run Last
### The `“tag-removed”` signal
```
void
user_function ([GtkTextTagTable](gtktexttagtable#GtkTextTagTable-struct) *texttagtable,
[GtkTextTag](gtktexttag#GtkTextTag-struct) *tag,
gpointer user_data)
```
Emitted every time a tag is removed from the [GtkTextTagTable](gtktexttagtable#GtkTextTagTable-struct).
The *`tag`* is still valid by the time the signal is emitted, but it is not associated with a tag table any more.
#### Parameters
| | | |
| --- | --- | --- |
| texttagtable | the object which received the signal. | |
| tag | the removed tag. | |
| user\_data | user data set when the signal handler was connected. | |
Flags: Run Last
gtk GtkDropDown GtkDropDown
===========
GtkDropDown — Choose an item from a list
Functions
---------
| | |
| --- | --- |
| [GtkWidget](gtkwidget#GtkWidget-struct) \* | [gtk\_drop\_down\_new](gtkdropdown#gtk-drop-down-new) () |
| [GtkWidget](gtkwidget#GtkWidget-struct) \* | [gtk\_drop\_down\_new\_from\_strings](gtkdropdown#gtk-drop-down-new-from-strings) () |
| void | [gtk\_drop\_down\_set\_model](gtkdropdown#gtk-drop-down-set-model) () |
| GListModel \* | [gtk\_drop\_down\_get\_model](gtkdropdown#gtk-drop-down-get-model) () |
| void | [gtk\_drop\_down\_set\_selected](gtkdropdown#gtk-drop-down-set-selected) () |
| guint | [gtk\_drop\_down\_get\_selected](gtkdropdown#gtk-drop-down-get-selected) () |
| gpointer | [gtk\_drop\_down\_get\_selected\_item](gtkdropdown#gtk-drop-down-get-selected-item) () |
| void | [gtk\_drop\_down\_set\_factory](gtkdropdown#gtk-drop-down-set-factory) () |
| [GtkListItemFactory](gtklistitemfactory#GtkListItemFactory-struct) \* | [gtk\_drop\_down\_get\_factory](gtkdropdown#gtk-drop-down-get-factory) () |
| void | [gtk\_drop\_down\_set\_list\_factory](gtkdropdown#gtk-drop-down-set-list-factory) () |
| [GtkListItemFactory](gtklistitemfactory#GtkListItemFactory-struct) \* | [gtk\_drop\_down\_get\_list\_factory](gtkdropdown#gtk-drop-down-get-list-factory) () |
| void | [gtk\_drop\_down\_set\_expression](gtkdropdown#gtk-drop-down-set-expression) () |
| [GtkExpression](gtkexpression#GtkExpression-struct) \* | [gtk\_drop\_down\_get\_expression](gtkdropdown#gtk-drop-down-get-expression) () |
| void | [gtk\_drop\_down\_set\_enable\_search](gtkdropdown#gtk-drop-down-set-enable-search) () |
| gboolean | [gtk\_drop\_down\_get\_enable\_search](gtkdropdown#gtk-drop-down-get-enable-search) () |
Properties
----------
| | | |
| --- | --- | --- |
| gboolean | [enable-search](gtkdropdown#GtkDropDown--enable-search) | Read / Write |
| [GtkExpression](gtkexpression#GtkExpression-struct) \* | [expression](gtkdropdown#GtkDropDown--expression) | Read / Write |
| [GtkListItemFactory](gtklistitemfactory#GtkListItemFactory-struct) \* | [factory](gtkdropdown#GtkDropDown--factory) | Read / Write |
| [GtkListItemFactory](gtklistitemfactory#GtkListItemFactory-struct) \* | [list-factory](gtkdropdown#GtkDropDown--list-factory) | Read / Write |
| GListModel \* | [model](gtkdropdown#GtkDropDown--model) | Read / Write |
| guint | [selected](gtkdropdown#GtkDropDown--selected) | Read / Write |
| GObject \* | [selected-item](gtkdropdown#GtkDropDown--selected-item) | Read |
Types and Values
----------------
| | |
| --- | --- |
| | [GtkDropDown](gtkdropdown#GtkDropDown-struct) |
Object Hierarchy
----------------
```
GObject
╰── GInitiallyUnowned
╰── [GtkWidget](gtkwidget#GtkWidget-struct)
╰── GtkDropDown
```
Implemented Interfaces
----------------------
GtkDropDown implements [GtkAccessible](gtkaccessible#GtkAccessible-struct), [GtkBuildable](gtkbuildable#GtkBuildable-struct) and [GtkConstraintTarget](gtkconstraint#GtkConstraintTarget-struct).
Includes
--------
```
#include <gtk/gtk.h>
```
Description
-----------
GtkDropDown is a widget that allows the user to choose an item from a list of options. The GtkDropDown displays the selected choice.
The options are given to GtkDropDown in the form of GListModel, and how the individual options are represented is determined by a [GtkListItemFactory](gtklistitemfactory#GtkListItemFactory-struct). The default factory displays simple strings.
GtkDropDown knows how to obtain strings from the items in a [GtkStringList](gtkstringlist#GtkStringList-struct); for other models, you have to provide an expression to find the strings via [`gtk_drop_down_set_expression()`](gtkdropdown#gtk-drop-down-set-expression).
GtkDropDown can optionally allow search in the popup, which is useful if the list of options is long. To enable the search entry, use [`gtk_drop_down_set_enable_search()`](gtkdropdown#gtk-drop-down-set-enable-search).
### CSS nodes
GtkDropDown has a single CSS node with name dropdown, with the button and popover nodes as children.
### Accessibility
GtkDropDown uses the [GTK\_ACCESSIBLE\_ROLE\_COMBO\_BOX](gtkaccessible#GTK-ACCESSIBLE-ROLE-COMBO-BOX:CAPS) role.
Functions
---------
### gtk\_drop\_down\_new ()
```
[GtkWidget](gtkwidget#GtkWidget-struct) *
gtk_drop_down_new (*`GListModel *model`*,
*`[GtkExpression](gtkexpression#GtkExpression-struct) *expression`*);
```
Creates a new [GtkDropDown](gtkdropdown#GtkDropDown-struct).
You may want to call [`gtk_drop_down_set_factory()`](gtkdropdown#gtk-drop-down-set-factory) to set up a way to map its items to widgets.
#### Parameters
| | | |
| --- | --- | --- |
| model | the model to use or `NULL` for none. | [transfer full][allow-none] |
| expression | the expression to use or `NULL` for none. | [transfer full][allow-none] |
#### Returns
a new [GtkDropDown](gtkdropdown#GtkDropDown-struct)
### gtk\_drop\_down\_new\_from\_strings ()
```
[GtkWidget](gtkwidget#GtkWidget-struct) *
gtk_drop_down_new_from_strings (*`const char * const *strings`*);
```
Creates a new [GtkDropDown](gtkdropdown#GtkDropDown-struct) that is populated with the strings in *`strings`* .
#### Parameters
| | | |
| --- | --- | --- |
| strings | The strings to put in the dropdown. | [array zero-terminated=1] |
#### Returns
a new [GtkDropDown](gtkdropdown#GtkDropDown-struct)
### gtk\_drop\_down\_set\_model ()
```
void
gtk_drop_down_set_model (*`[GtkDropDown](gtkdropdown#GtkDropDown-struct) *self`*,
*`GListModel *model`*);
```
Sets the GListModel to use.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkDropDown](gtkdropdown#GtkDropDown-struct) | |
| model | the model to use or `NULL` for none. | [allow-none][transfer none] |
### gtk\_drop\_down\_get\_model ()
```
GListModel *
gtk_drop_down_get_model (*`[GtkDropDown](gtkdropdown#GtkDropDown-struct) *self`*);
```
Gets the model that provides the displayed items.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkDropDown](gtkdropdown#GtkDropDown-struct) | |
#### Returns
The model in use.
[nullable][transfer none]
### gtk\_drop\_down\_set\_selected ()
```
void
gtk_drop_down_set_selected (*`[GtkDropDown](gtkdropdown#GtkDropDown-struct) *self`*,
*`guint position`*);
```
Selects the item at the given position.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkDropDown](gtkdropdown#GtkDropDown-struct) | |
| position | the position of the item to select, or [GTK\_INVALID\_LIST\_POSITION](gtksingleselection#GTK-INVALID-LIST-POSITION:CAPS) | |
### gtk\_drop\_down\_get\_selected ()
```
guint
gtk_drop_down_get_selected (*`[GtkDropDown](gtkdropdown#GtkDropDown-struct) *self`*);
```
Gets the position of the selected item.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkDropDown](gtkdropdown#GtkDropDown-struct) | |
#### Returns
the position of the selected item, or [GTK\_INVALID\_LIST\_POSITION](gtksingleselection#GTK-INVALID-LIST-POSITION:CAPS) if not item is selected
### gtk\_drop\_down\_get\_selected\_item ()
```
gpointer
gtk_drop_down_get_selected_item (*`[GtkDropDown](gtkdropdown#GtkDropDown-struct) *self`*);
```
Gets the selected item. If no item is selected, `NULL` is returned.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkDropDown](gtkdropdown#GtkDropDown-struct) | |
#### Returns
The selected item.
[transfer none][type GObject][nullable]
### gtk\_drop\_down\_set\_factory ()
```
void
gtk_drop_down_set_factory (*`[GtkDropDown](gtkdropdown#GtkDropDown-struct) *self`*,
*`[GtkListItemFactory](gtklistitemfactory#GtkListItemFactory-struct) *factory`*);
```
Sets the [GtkListItemFactory](gtklistitemfactory#GtkListItemFactory-struct) to use for populating list items.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkDropDown](gtkdropdown#GtkDropDown-struct) | |
| factory | the factory to use or `NULL` for none. | [allow-none][transfer none] |
### gtk\_drop\_down\_get\_factory ()
```
[GtkListItemFactory](gtklistitemfactory#GtkListItemFactory-struct) *
gtk_drop_down_get_factory (*`[GtkDropDown](gtkdropdown#GtkDropDown-struct) *self`*);
```
Gets the factory that's currently used to populate list items.
The factory returned by this function is always used for the item in the button. It is also used for items in the popup if [“list-factory”](gtkdropdown#GtkDropDown--list-factory) is not set.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkDropDown](gtkdropdown#GtkDropDown-struct) | |
#### Returns
The factory in use.
[nullable][transfer none]
### gtk\_drop\_down\_set\_list\_factory ()
```
void
gtk_drop_down_set_list_factory (*`[GtkDropDown](gtkdropdown#GtkDropDown-struct) *self`*,
*`[GtkListItemFactory](gtklistitemfactory#GtkListItemFactory-struct) *factory`*);
```
Sets the [GtkListItemFactory](gtklistitemfactory#GtkListItemFactory-struct) to use for populating list items in the popup.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkDropDown](gtkdropdown#GtkDropDown-struct) | |
| factory | the factory to use or `NULL` for none. | [allow-none][transfer none] |
### gtk\_drop\_down\_get\_list\_factory ()
```
[GtkListItemFactory](gtklistitemfactory#GtkListItemFactory-struct) *
gtk_drop_down_get_list_factory (*`[GtkDropDown](gtkdropdown#GtkDropDown-struct) *self`*);
```
Gets the factory that's currently used to populate list items in the popup.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkDropDown](gtkdropdown#GtkDropDown-struct) | |
#### Returns
The factory in use.
[nullable][transfer none]
### gtk\_drop\_down\_set\_expression ()
```
void
gtk_drop_down_set_expression (*`[GtkDropDown](gtkdropdown#GtkDropDown-struct) *self`*,
*`[GtkExpression](gtkexpression#GtkExpression-struct) *expression`*);
```
Sets the expression that gets evaluated to obtain strings from items when searching in the popup. The expression must have a value type of G\_TYPE\_STRING.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkDropDown](gtkdropdown#GtkDropDown-struct) | |
| expression | a [GtkExpression](gtkexpression#GtkExpression-struct), or `NULL`. | [nullable] |
### gtk\_drop\_down\_get\_expression ()
```
[GtkExpression](gtkexpression#GtkExpression-struct) *
gtk_drop_down_get_expression (*`[GtkDropDown](gtkdropdown#GtkDropDown-struct) *self`*);
```
Gets the expression set with [`gtk_drop_down_set_expression()`](gtkdropdown#gtk-drop-down-set-expression).
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkDropDown](gtkdropdown#GtkDropDown-struct) | |
#### Returns
a [GtkExpression](gtkexpression#GtkExpression-struct) or `NULL`.
[nullable][transfer none]
### gtk\_drop\_down\_set\_enable\_search ()
```
void
gtk_drop_down_set_enable_search (*`[GtkDropDown](gtkdropdown#GtkDropDown-struct) *self`*,
*`gboolean enable_search`*);
```
Sets whether a search entry will be shown in the popup that allows to search for items in the list.
Note that [“expression”](gtkdropdown#GtkDropDown--expression) must be set for search to work.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkDropDown](gtkdropdown#GtkDropDown-struct) | |
| enable\_search | whether to enable search | |
### gtk\_drop\_down\_get\_enable\_search ()
```
gboolean
gtk_drop_down_get_enable_search (*`[GtkDropDown](gtkdropdown#GtkDropDown-struct) *self`*);
```
Returns whether search is enabled.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkDropDown](gtkdropdown#GtkDropDown-struct) | |
#### Returns
`TRUE` if the popup includes a search entry
Types and Values
----------------
### GtkDropDown
```
typedef struct _GtkDropDown GtkDropDown;
```
Property Details
----------------
### The `“enable-search”` property
```
“enable-search” gboolean
```
Whether to show a search entry in the popup.
Note that search requires [“expression”](gtkdropdown#GtkDropDown--expression) to be set.
Owner: GtkDropDown
Flags: Read / Write
Default value: FALSE
### The `“expression”` property
```
“expression” [GtkExpression](gtkexpression#GtkExpression-struct) *
```
An expression to evaluate to obtain strings to match against the search term (see [“enable-search”](gtkdropdown#GtkDropDown--enable-search)). If [“factory”](gtkdropdown#GtkDropDown--factory) is not set, the expression is also used to bind strings to labels produced by a default factory.
[type GtkExpression]
Owner: GtkDropDown
Flags: Read / Write
### The `“factory”` property
```
“factory” [GtkListItemFactory](gtklistitemfactory#GtkListItemFactory-struct) *
```
Factory for populating list items.
Owner: GtkDropDown
Flags: Read / Write
### The `“list-factory”` property
```
“list-factory” [GtkListItemFactory](gtklistitemfactory#GtkListItemFactory-struct) *
```
The factory for populating list items in the popup.
If this is not set, [“factory”](gtkdropdown#GtkDropDown--factory) is used.
Owner: GtkDropDown
Flags: Read / Write
### The `“model”` property
```
“model” GListModel *
```
Model for the displayed items.
Owner: GtkDropDown
Flags: Read / Write
### The `“selected”` property
```
“selected” guint
```
The position of the selected item in [“model”](gtkdropdown#GtkDropDown--model), or [GTK\_INVALID\_LIST\_POSITION](gtksingleselection#GTK-INVALID-LIST-POSITION:CAPS) if no item is selected.
Owner: GtkDropDown
Flags: Read / Write
Default value: 4294967295
### The `“selected-item”` property
```
“selected-item” GObject *
```
The selected item.
Owner: GtkDropDown
Flags: Read
See Also
--------
[GtkComboBox](gtkcombobox#GtkComboBox-struct)
| programming_docs |
gtk GtkBox GtkBox
======
GtkBox — A container for packing widgets in a single row or column
Functions
---------
| | |
| --- | --- |
| [GtkWidget](gtkwidget#GtkWidget-struct) \* | [gtk\_box\_new](gtkbox#gtk-box-new) () |
| gboolean | [gtk\_box\_get\_homogeneous](gtkbox#gtk-box-get-homogeneous) () |
| void | [gtk\_box\_set\_homogeneous](gtkbox#gtk-box-set-homogeneous) () |
| int | [gtk\_box\_get\_spacing](gtkbox#gtk-box-get-spacing) () |
| void | [gtk\_box\_set\_spacing](gtkbox#gtk-box-set-spacing) () |
| [GtkBaselinePosition](gtk4-standard-enumerations#GtkBaselinePosition) | [gtk\_box\_get\_baseline\_position](gtkbox#gtk-box-get-baseline-position) () |
| void | [gtk\_box\_set\_baseline\_position](gtkbox#gtk-box-set-baseline-position) () |
| void | [gtk\_box\_append](gtkbox#gtk-box-append) () |
| void | [gtk\_box\_prepend](gtkbox#gtk-box-prepend) () |
| void | [gtk\_box\_remove](gtkbox#gtk-box-remove) () |
| void | [gtk\_box\_insert\_child\_after](gtkbox#gtk-box-insert-child-after) () |
| void | [gtk\_box\_reorder\_child\_after](gtkbox#gtk-box-reorder-child-after) () |
Properties
----------
| | | |
| --- | --- | --- |
| [GtkBaselinePosition](gtk4-standard-enumerations#GtkBaselinePosition) | [baseline-position](gtkbox#GtkBox--baseline-position) | Read / Write |
| gboolean | [homogeneous](gtkbox#GtkBox--homogeneous) | Read / Write |
| int | [spacing](gtkbox#GtkBox--spacing) | Read / Write |
Types and Values
----------------
| | |
| --- | --- |
| struct | [GtkBox](gtkbox#GtkBox-struct) |
| struct | [GtkBoxClass](gtkbox#GtkBoxClass) |
Object Hierarchy
----------------
```
GObject
╰── GInitiallyUnowned
╰── [GtkWidget](gtkwidget#GtkWidget-struct)
╰── GtkBox
├── [GtkShortcutsSection](gtkshortcutssection#GtkShortcutsSection-struct)
╰── [GtkShortcutsGroup](gtkshortcutsgroup#GtkShortcutsGroup-struct)
```
Implemented Interfaces
----------------------
GtkBox implements [GtkAccessible](gtkaccessible#GtkAccessible-struct), [GtkBuildable](gtkbuildable#GtkBuildable-struct), [GtkConstraintTarget](gtkconstraint#GtkConstraintTarget-struct) and [GtkOrientable](gtk4-orientable#GtkOrientable-struct).
Includes
--------
```
#include <gtk/gtk.h>
```
Description
-----------
The GtkBox widget arranges child widgets into a single row or column, depending upon the value of its [“orientation”](gtk4-orientable#GtkOrientable--orientation) property. Within the other dimension, all children are allocated the same size. Of course, the [“halign”](gtkwidget#GtkWidget--halign) and [“valign”](gtkwidget#GtkWidget--valign) properties can be used on the children to influence their allocation.
Use repeated calls to [`gtk_box_append()`](gtkbox#gtk-box-append) to pack widgets into a GtkBox from start to end. Use [`gtk_box_remove()`](gtkbox#gtk-box-remove) to remove widgets from the GtkBox. [`gtk_box_insert_child_after()`](gtkbox#gtk-box-insert-child-after) can be used to add a child at a particular position.
Use [`gtk_box_set_homogeneous()`](gtkbox#gtk-box-set-homogeneous) to specify whether or not all children of the GtkBox are forced to get the same amount of space.
Use [`gtk_box_set_spacing()`](gtkbox#gtk-box-set-spacing) to determine how much space will be minimally placed between all children in the GtkBox. Note that spacing is added between the children.
Use [`gtk_box_reorder_child_after()`](gtkbox#gtk-box-reorder-child-after) to move a child to a different place in the box.
### CSS nodes
GtkBox uses a single CSS node with name box.
### Accessibility
GtkBox uses the [`GTK_ACCESSIBLE_ROLE_GROUP`](gtkaccessible#GTK-ACCESSIBLE-ROLE-GROUP:CAPS) role.
Functions
---------
### gtk\_box\_new ()
```
[GtkWidget](gtkwidget#GtkWidget-struct) *
gtk_box_new (*`[GtkOrientation](gtk4-standard-enumerations#GtkOrientation) orientation`*,
*`int spacing`*);
```
Creates a new [GtkBox](gtkbox#GtkBox-struct).
#### Parameters
| | | |
| --- | --- | --- |
| orientation | the box’s orientation | |
| spacing | the number of pixels to place by default between children | |
#### Returns
a new [GtkBox](gtkbox#GtkBox-struct).
### gtk\_box\_get\_homogeneous ()
```
gboolean
gtk_box_get_homogeneous (*`[GtkBox](gtkbox#GtkBox-struct) *box`*);
```
Returns whether the box is homogeneous (all children are the same size). See [`gtk_box_set_homogeneous()`](gtkbox#gtk-box-set-homogeneous).
#### Parameters
| | | |
| --- | --- | --- |
| box | a [GtkBox](gtkbox#GtkBox-struct) | |
#### Returns
`TRUE` if the box is homogeneous.
### gtk\_box\_set\_homogeneous ()
```
void
gtk_box_set_homogeneous (*`[GtkBox](gtkbox#GtkBox-struct) *box`*,
*`gboolean homogeneous`*);
```
Sets the [“homogeneous”](gtkbox#GtkBox--homogeneous) property of *`box`* , controlling whether or not all children of *`box`* are given equal space in the box.
#### Parameters
| | | |
| --- | --- | --- |
| box | a [GtkBox](gtkbox#GtkBox-struct) | |
| homogeneous | a boolean value, `TRUE` to create equal allotments, `FALSE` for variable allotments | |
### gtk\_box\_get\_spacing ()
```
int
gtk_box_get_spacing (*`[GtkBox](gtkbox#GtkBox-struct) *box`*);
```
Gets the value set by [`gtk_box_set_spacing()`](gtkbox#gtk-box-set-spacing).
#### Parameters
| | | |
| --- | --- | --- |
| box | a [GtkBox](gtkbox#GtkBox-struct) | |
#### Returns
spacing between children
### gtk\_box\_set\_spacing ()
```
void
gtk_box_set_spacing (*`[GtkBox](gtkbox#GtkBox-struct) *box`*,
*`int spacing`*);
```
Sets the [“spacing”](gtkbox#GtkBox--spacing) property of *`box`* , which is the number of pixels to place between children of *`box`* .
#### Parameters
| | | |
| --- | --- | --- |
| box | a [GtkBox](gtkbox#GtkBox-struct) | |
| spacing | the number of pixels to put between children | |
### gtk\_box\_get\_baseline\_position ()
```
[GtkBaselinePosition](gtk4-standard-enumerations#GtkBaselinePosition)
gtk_box_get_baseline_position (*`[GtkBox](gtkbox#GtkBox-struct) *box`*);
```
Gets the value set by [`gtk_box_set_baseline_position()`](gtkbox#gtk-box-set-baseline-position).
#### Parameters
| | | |
| --- | --- | --- |
| box | a [GtkBox](gtkbox#GtkBox-struct) | |
#### Returns
the baseline position
### gtk\_box\_set\_baseline\_position ()
```
void
gtk_box_set_baseline_position (*`[GtkBox](gtkbox#GtkBox-struct) *box`*,
*`[GtkBaselinePosition](gtk4-standard-enumerations#GtkBaselinePosition) position`*);
```
Sets the baseline position of a box. This affects only horizontal boxes with at least one baseline aligned child. If there is more vertical space available than requested, and the baseline is not allocated by the parent then *`position`* is used to allocate the baseline wrt the extra space available.
#### Parameters
| | | |
| --- | --- | --- |
| box | a [GtkBox](gtkbox#GtkBox-struct) | |
| position | a [GtkBaselinePosition](gtk4-standard-enumerations#GtkBaselinePosition) | |
### gtk\_box\_append ()
```
void
gtk_box_append (*`[GtkBox](gtkbox#GtkBox-struct) *box`*,
*`[GtkWidget](gtkwidget#GtkWidget-struct) *child`*);
```
Adds *`child`* as the last child to *`box`* .
#### Parameters
| | | |
| --- | --- | --- |
| box | a [GtkBox](gtkbox#GtkBox-struct) | |
| child | the [GtkWidget](gtkwidget#GtkWidget-struct) to append | |
### gtk\_box\_prepend ()
```
void
gtk_box_prepend (*`[GtkBox](gtkbox#GtkBox-struct) *box`*,
*`[GtkWidget](gtkwidget#GtkWidget-struct) *child`*);
```
Adds *`child`* as the first child to *`box`* .
#### Parameters
| | | |
| --- | --- | --- |
| box | a [GtkBox](gtkbox#GtkBox-struct) | |
| child | the [GtkWidget](gtkwidget#GtkWidget-struct) to prepend | |
### gtk\_box\_remove ()
```
void
gtk_box_remove (*`[GtkBox](gtkbox#GtkBox-struct) *box`*,
*`[GtkWidget](gtkwidget#GtkWidget-struct) *child`*);
```
Removes a child widget from *`box`* , after it has been added with [`gtk_box_append()`](gtkbox#gtk-box-append), [`gtk_box_prepend()`](gtkbox#gtk-box-prepend), or [`gtk_box_insert_child_after()`](gtkbox#gtk-box-insert-child-after).
#### Parameters
| | | |
| --- | --- | --- |
| box | a [GtkBox](gtkbox#GtkBox-struct) | |
| child | the child to remove | |
### gtk\_box\_insert\_child\_after ()
```
void
gtk_box_insert_child_after (*`[GtkBox](gtkbox#GtkBox-struct) *box`*,
*`[GtkWidget](gtkwidget#GtkWidget-struct) *child`*,
*`[GtkWidget](gtkwidget#GtkWidget-struct) *sibling`*);
```
Inserts *`child`* in the position after *`sibling`* in the list of *`box`* children. If *`sibling`* is `NULL`, insert *`child`* at the first position.
#### Parameters
| | | |
| --- | --- | --- |
| box | a [GtkBox](gtkbox#GtkBox-struct) | |
| child | the [GtkWidget](gtkwidget#GtkWidget-struct) to insert | |
| sibling | the sibling after which to insert *`child`* . | [nullable] |
### gtk\_box\_reorder\_child\_after ()
```
void
gtk_box_reorder_child_after (*`[GtkBox](gtkbox#GtkBox-struct) *box`*,
*`[GtkWidget](gtkwidget#GtkWidget-struct) *child`*,
*`[GtkWidget](gtkwidget#GtkWidget-struct) *sibling`*);
```
Moves *`child`* to the position after *`sibling`* in the list of *`box`* children. If *`sibling`* is `NULL`, move *`child`* to the first position.
#### Parameters
| | | |
| --- | --- | --- |
| box | a [GtkBox](gtkbox#GtkBox-struct) | |
| child | the [GtkWidget](gtkwidget#GtkWidget-struct) to move, must be a child of *`box`* | |
| sibling | the sibling to move *`child`* after, or `NULL`. | [nullable] |
Types and Values
----------------
### struct GtkBox
```
struct GtkBox;
```
### struct GtkBoxClass
```
struct GtkBoxClass {
GtkWidgetClass parent_class;
};
```
#### Members
Property Details
----------------
### The `“baseline-position”` property
```
“baseline-position” [GtkBaselinePosition](gtk4-standard-enumerations#GtkBaselinePosition)
```
The position of the baseline aligned widgets if extra space is available.
Owner: GtkBox
Flags: Read / Write
Default value: GTK\_BASELINE\_POSITION\_CENTER
### The `“homogeneous”` property
```
“homogeneous” gboolean
```
Whether the children should all be the same size.
Owner: GtkBox
Flags: Read / Write
Default value: FALSE
### The `“spacing”` property
```
“spacing” int
```
The amount of space between children.
Owner: GtkBox
Flags: Read / Write
Allowed values: >= 0
Default value: 0
See Also
--------
[GtkGrid](gtkgrid#GtkGrid-struct)
gtk GtkLabel GtkLabel
========
GtkLabel — A widget that displays a small to medium amount of text
Functions
---------
| | |
| --- | --- |
| [GtkWidget](gtkwidget#GtkWidget-struct) \* | [gtk\_label\_new](gtklabel#gtk-label-new) () |
| void | [gtk\_label\_set\_text](gtklabel#gtk-label-set-text) () |
| void | [gtk\_label\_set\_attributes](gtklabel#gtk-label-set-attributes) () |
| void | [gtk\_label\_set\_markup](gtklabel#gtk-label-set-markup) () |
| void | [gtk\_label\_set\_markup\_with\_mnemonic](gtklabel#gtk-label-set-markup-with-mnemonic) () |
| void | [gtk\_label\_set\_justify](gtklabel#gtk-label-set-justify) () |
| void | [gtk\_label\_set\_xalign](gtklabel#gtk-label-set-xalign) () |
| void | [gtk\_label\_set\_yalign](gtklabel#gtk-label-set-yalign) () |
| void | [gtk\_label\_set\_ellipsize](gtklabel#gtk-label-set-ellipsize) () |
| void | [gtk\_label\_set\_width\_chars](gtklabel#gtk-label-set-width-chars) () |
| void | [gtk\_label\_set\_max\_width\_chars](gtklabel#gtk-label-set-max-width-chars) () |
| void | [gtk\_label\_set\_wrap](gtklabel#gtk-label-set-wrap) () |
| void | [gtk\_label\_set\_wrap\_mode](gtklabel#gtk-label-set-wrap-mode) () |
| void | [gtk\_label\_set\_lines](gtklabel#gtk-label-set-lines) () |
| void | [gtk\_label\_get\_layout\_offsets](gtklabel#gtk-label-get-layout-offsets) () |
| guint | [gtk\_label\_get\_mnemonic\_keyval](gtklabel#gtk-label-get-mnemonic-keyval) () |
| gboolean | [gtk\_label\_get\_selectable](gtklabel#gtk-label-get-selectable) () |
| const char \* | [gtk\_label\_get\_text](gtklabel#gtk-label-get-text) () |
| [GtkWidget](gtkwidget#GtkWidget-struct) \* | [gtk\_label\_new\_with\_mnemonic](gtklabel#gtk-label-new-with-mnemonic) () |
| void | [gtk\_label\_select\_region](gtklabel#gtk-label-select-region) () |
| void | [gtk\_label\_set\_mnemonic\_widget](gtklabel#gtk-label-set-mnemonic-widget) () |
| void | [gtk\_label\_set\_selectable](gtklabel#gtk-label-set-selectable) () |
| void | [gtk\_label\_set\_text\_with\_mnemonic](gtklabel#gtk-label-set-text-with-mnemonic) () |
| [PangoAttrList](https://developer-old.gnome.org/pango/stable/pango-Text-Attributes.html#PangoAttrList-struct) \* | [gtk\_label\_get\_attributes](gtklabel#gtk-label-get-attributes) () |
| [GtkJustification](gtk4-standard-enumerations#GtkJustification) | [gtk\_label\_get\_justify](gtklabel#gtk-label-get-justify) () |
| float | [gtk\_label\_get\_xalign](gtklabel#gtk-label-get-xalign) () |
| float | [gtk\_label\_get\_yalign](gtklabel#gtk-label-get-yalign) () |
| [PangoEllipsizeMode](https://developer-old.gnome.org/pango/stable/pango-Layout-Objects.html#PangoEllipsizeMode) | [gtk\_label\_get\_ellipsize](gtklabel#gtk-label-get-ellipsize) () |
| int | [gtk\_label\_get\_width\_chars](gtklabel#gtk-label-get-width-chars) () |
| int | [gtk\_label\_get\_max\_width\_chars](gtklabel#gtk-label-get-max-width-chars) () |
| const char \* | [gtk\_label\_get\_label](gtklabel#gtk-label-get-label) () |
| [PangoLayout](https://developer-old.gnome.org/pango/stable/pango-Layout-Objects.html#PangoLayout-struct) \* | [gtk\_label\_get\_layout](gtklabel#gtk-label-get-layout) () |
| gboolean | [gtk\_label\_get\_wrap](gtklabel#gtk-label-get-wrap) () |
| [PangoWrapMode](https://developer-old.gnome.org/pango/stable/pango-Layout-Objects.html#PangoWrapMode) | [gtk\_label\_get\_wrap\_mode](gtklabel#gtk-label-get-wrap-mode) () |
| int | [gtk\_label\_get\_lines](gtklabel#gtk-label-get-lines) () |
| [GtkWidget](gtkwidget#GtkWidget-struct) \* | [gtk\_label\_get\_mnemonic\_widget](gtklabel#gtk-label-get-mnemonic-widget) () |
| gboolean | [gtk\_label\_get\_selection\_bounds](gtklabel#gtk-label-get-selection-bounds) () |
| gboolean | [gtk\_label\_get\_use\_markup](gtklabel#gtk-label-get-use-markup) () |
| gboolean | [gtk\_label\_get\_use\_underline](gtklabel#gtk-label-get-use-underline) () |
| gboolean | [gtk\_label\_get\_single\_line\_mode](gtklabel#gtk-label-get-single-line-mode) () |
| void | [gtk\_label\_set\_label](gtklabel#gtk-label-set-label) () |
| void | [gtk\_label\_set\_use\_markup](gtklabel#gtk-label-set-use-markup) () |
| void | [gtk\_label\_set\_use\_underline](gtklabel#gtk-label-set-use-underline) () |
| void | [gtk\_label\_set\_single\_line\_mode](gtklabel#gtk-label-set-single-line-mode) () |
| const char \* | [gtk\_label\_get\_current\_uri](gtklabel#gtk-label-get-current-uri) () |
| void | [gtk\_label\_set\_extra\_menu](gtklabel#gtk-label-set-extra-menu) () |
| GMenuModel \* | [gtk\_label\_get\_extra\_menu](gtklabel#gtk-label-get-extra-menu) () |
Properties
----------
| | | |
| --- | --- | --- |
| [PangoAttrList](https://developer-old.gnome.org/pango/stable/pango-Text-Attributes.html#PangoAttrList-struct) \* | [attributes](gtklabel#GtkLabel--attributes) | Read / Write |
| [PangoEllipsizeMode](https://developer-old.gnome.org/pango/stable/pango-Layout-Objects.html#PangoEllipsizeMode) | [ellipsize](gtklabel#GtkLabel--ellipsize) | Read / Write |
| GMenuModel \* | [extra-menu](gtklabel#GtkLabel--extra-menu) | Read / Write |
| [GtkJustification](gtk4-standard-enumerations#GtkJustification) | [justify](gtklabel#GtkLabel--justify) | Read / Write |
| char \* | [label](gtklabel#GtkLabel--label) | Read / Write |
| int | [lines](gtklabel#GtkLabel--lines) | Read / Write |
| int | [max-width-chars](gtklabel#GtkLabel--max-width-chars) | Read / Write |
| guint | [mnemonic-keyval](gtklabel#GtkLabel--mnemonic-keyval) | Read |
| [GtkWidget](gtkwidget#GtkWidget-struct) \* | [mnemonic-widget](gtklabel#GtkLabel--mnemonic-widget) | Read / Write |
| gboolean | [selectable](gtklabel#GtkLabel--selectable) | Read / Write |
| gboolean | [single-line-mode](gtklabel#GtkLabel--single-line-mode) | Read / Write |
| gboolean | [use-markup](gtklabel#GtkLabel--use-markup) | Read / Write |
| gboolean | [use-underline](gtklabel#GtkLabel--use-underline) | Read / Write |
| int | [width-chars](gtklabel#GtkLabel--width-chars) | Read / Write |
| gboolean | [wrap](gtklabel#GtkLabel--wrap) | Read / Write |
| [PangoWrapMode](https://developer-old.gnome.org/pango/stable/pango-Layout-Objects.html#PangoWrapMode) | [wrap-mode](gtklabel#GtkLabel--wrap-mode) | Read / Write |
| float | [xalign](gtklabel#GtkLabel--xalign) | Read / Write |
| float | [yalign](gtklabel#GtkLabel--yalign) | Read / Write |
Signals
-------
| | | |
| --- | --- | --- |
| void | [activate-current-link](gtklabel#GtkLabel-activate-current-link) | Action |
| gboolean | [activate-link](gtklabel#GtkLabel-activate-link) | Run Last |
| void | [copy-clipboard](gtklabel#GtkLabel-copy-clipboard) | Action |
| void | [move-cursor](gtklabel#GtkLabel-move-cursor) | Action |
Actions
-------
| | | |
| --- | --- | --- |
| | link.copy | |
| | link.open | |
| | selection.select-all | |
| | selection.delete | |
| | clipboard.paste | |
| | clipboard.copy | |
| | clipboard.cut | |
| | menu.popup | |
Types and Values
----------------
| | |
| --- | --- |
| | [GtkLabel](gtklabel#GtkLabel-struct) |
Object Hierarchy
----------------
```
GObject
╰── GInitiallyUnowned
╰── [GtkWidget](gtkwidget#GtkWidget-struct)
╰── GtkLabel
```
Implemented Interfaces
----------------------
GtkLabel implements [GtkAccessible](gtkaccessible#GtkAccessible-struct), [GtkBuildable](gtkbuildable#GtkBuildable-struct) and [GtkConstraintTarget](gtkconstraint#GtkConstraintTarget-struct).
Includes
--------
```
#include <gtk/gtk.h>
```
Description
-----------
The [GtkLabel](gtklabel#GtkLabel-struct) widget displays a small amount of text. As the name implies, most labels are used to label another widget such as a [GtkButton](gtkbutton#GtkButton-struct).
### CSS nodes
GtkLabel has a single CSS node with the name label. A wide variety of style classes may be applied to labels, such as .title, .subtitle, .dim-label, etc. In the [GtkShortcutsWindow](gtkshortcutswindow#GtkShortcutsWindow-struct), labels are used with the .keycap style class.
If the label has a selection, it gets a subnode with name selection.
If the label has links, there is one subnode per link. These subnodes carry the link or visited state depending on whether they have been visited. In this case, label node also gets a .link style class.
### GtkLabel as GtkBuildable
The GtkLabel implementation of the GtkBuildable interface supports a custom <attributes> element, which supports any number of <attribute> elements. The <attribute> element has attributes named “name“, “value“, “start“ and “end“ and allows you to specify [PangoAttribute](https://developer-old.gnome.org/pango/stable/pango-Text-Attributes.html#PangoAttribute-struct) values for this label.
An example of a UI definition fragment specifying Pango attributes:
The start and end attributes specify the range of characters to which the Pango attribute applies. If start and end are not specified, the attribute is applied to the whole text. Note that specifying ranges does not make much sense with translatable attributes. Use markup embedded in the translatable content instead.
### Accessibility
GtkLabel uses the [GTK\_ACCESSIBLE\_ROLE\_LABEL](gtkaccessible#GTK-ACCESSIBLE-ROLE-LABEL:CAPS) role.
### Mnemonics
Labels may contain “mnemonics”. Mnemonics are underlined characters in the label, used for keyboard navigation. Mnemonics are created by providing a string with an underscore before the mnemonic character, such as `"_File"`, to the functions [`gtk_label_new_with_mnemonic()`](gtklabel#gtk-label-new-with-mnemonic) or [`gtk_label_set_text_with_mnemonic()`](gtklabel#gtk-label-set-text-with-mnemonic).
Mnemonics automatically activate any activatable widget the label is inside, such as a [GtkButton](gtkbutton#GtkButton-struct); if the label is not inside the mnemonic’s target widget, you have to tell the label about the target using [`gtk_label_set_mnemonic_widget()`](gtklabel#gtk-label-set-mnemonic-widget). Here’s a simple example where the label is inside a button:
There’s a convenience function to create buttons with a mnemonic label already inside:
To create a mnemonic for a widget alongside the label, such as a [GtkEntry](gtkentry#GtkEntry-struct), you have to point the label at the entry with [`gtk_label_set_mnemonic_widget()`](gtklabel#gtk-label-set-mnemonic-widget):
### Markup (styled text)
To make it easy to format text in a label (changing colors, fonts, etc.), label text can be provided in a simple markup format.
Here’s how to create a label with a small font:
(See complete documentation of available tags in the Pango manual.)
The markup passed to [`gtk_label_set_markup()`](gtklabel#gtk-label-set-markup) must be valid; for example, literal <, > and & characters must be escaped as <, >, and &. If you pass text obtained from the user, file, or a network to [`gtk_label_set_markup()`](gtklabel#gtk-label-set-markup), you’ll want to escape it with `g_markup_escape_text()` or `g_markup_printf_escaped()`.
Markup strings are just a convenient way to set the [PangoAttrList](https://developer-old.gnome.org/pango/stable/pango-Text-Attributes.html#PangoAttrList-struct) on a label; [`gtk_label_set_attributes()`](gtklabel#gtk-label-set-attributes) may be a simpler way to set attributes in some cases. Be careful though; [PangoAttrList](https://developer-old.gnome.org/pango/stable/pango-Text-Attributes.html#PangoAttrList-struct) tends to cause internationalization problems, unless you’re applying attributes to the entire string (i.e. unless you set the range of each attribute to [0, `G_MAXINT`)). The reason is that specifying the start\_index and end\_index for a [PangoAttribute](https://developer-old.gnome.org/pango/stable/pango-Text-Attributes.html#PangoAttribute-struct) requires knowledge of the exact string being displayed, so translations will cause problems.
### Selectable labels
Labels can be made selectable with [`gtk_label_set_selectable()`](gtklabel#gtk-label-set-selectable). Selectable labels allow the user to copy the label contents to the clipboard. Only labels that contain useful-to-copy information — such as error messages — should be made selectable.
### Text layout
A label can contain any number of paragraphs, but will have performance problems if it contains more than a small number. Paragraphs are separated by newlines or other paragraph separators understood by Pango.
Labels can automatically wrap text if you call [`gtk_label_set_wrap()`](gtklabel#gtk-label-set-wrap).
gtk\_label\_set\_justify() sets how the lines in a label align with one another. If you want to set how the label as a whole aligns in its available space, see the [“halign”](gtkwidget#GtkWidget--halign) and [“valign”](gtkwidget#GtkWidget--valign) properties.
The [“width-chars”](gtklabel#GtkLabel--width-chars) and [“max-width-chars”](gtklabel#GtkLabel--max-width-chars) properties can be used to control the size allocation of ellipsized or wrapped labels. For ellipsizing labels, if either is specified (and less than the actual text size), it is used as the minimum width, and the actual text size is used as the natural width of the label. For wrapping labels, width-chars is used as the minimum width, if specified, and max-width-chars is used as the natural width. Even if max-width-chars specified, wrapping labels will be rewrapped to use all of the available width.
Note that the interpretation of [“width-chars”](gtklabel#GtkLabel--width-chars) and [“max-width-chars”](gtklabel#GtkLabel--max-width-chars) has changed a bit with the introduction of width-for-height geometry management.
### Links
GTK supports markup for clickable hyperlinks in addition to regular Pango markup. The markup for links is borrowed from HTML, using the `<a>` with “href“, “title“ and “class“ attributes. GTK renders links similar to the way they appear in web browsers, with colored, underlined text. The “title“ attribute is displayed as a tooltip on the link. The “class“ attribute is used as style class on the CSS node for the link.
An example looks like this:
It is possible to implement custom handling for links and their tooltips with the [“activate-link”](gtklabel#GtkLabel-activate-link) signal and the [`gtk_label_get_current_uri()`](gtklabel#gtk-label-get-current-uri) function.
Functions
---------
### gtk\_label\_new ()
```
[GtkWidget](gtkwidget#GtkWidget-struct) *
gtk_label_new (*`const char *str`*);
```
Creates a new label with the given text inside it. You can pass `NULL` to get an empty label widget.
#### Parameters
| | | |
| --- | --- | --- |
| str | The text of the label. | [nullable] |
#### Returns
the new [GtkLabel](gtklabel#GtkLabel-struct)
### gtk\_label\_set\_text ()
```
void
gtk_label_set_text (*`[GtkLabel](gtklabel#GtkLabel-struct) *self`*,
*`const char *str`*);
```
Sets the text within the [GtkLabel](gtklabel#GtkLabel-struct) widget. It overwrites any text that was there before.
This function will clear any previously set mnemonic accelerators, and set the [“use-underline”](gtklabel#GtkLabel--use-underline) property to `FALSE` as a side effect.
This function will set the [“use-markup”](gtklabel#GtkLabel--use-markup) property to `FALSE` as a side effect.
See also: [`gtk_label_set_markup()`](gtklabel#gtk-label-set-markup)
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkLabel](gtklabel#GtkLabel-struct) | |
| str | The text you want to set | |
### gtk\_label\_set\_attributes ()
```
void
gtk_label_set_attributes (*`[GtkLabel](gtklabel#GtkLabel-struct) *self`*,
*`[PangoAttrList](https://developer-old.gnome.org/pango/stable/pango-Text-Attributes.html#PangoAttrList-struct) *attrs`*);
```
Sets a [PangoAttrList](https://developer-old.gnome.org/pango/stable/pango-Text-Attributes.html#PangoAttrList-struct); the attributes in the list are applied to the label text.
The attributes set with this function will be applied and merged with any other attributes previously effected by way of the [“use-underline”](gtklabel#GtkLabel--use-underline) or [“use-markup”](gtklabel#GtkLabel--use-markup) properties. While it is not recommended to mix markup strings with manually set attributes, if you must; know that the attributes will be applied to the label after the markup string is parsed.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkLabel](gtklabel#GtkLabel-struct) | |
| attrs | a [PangoAttrList](https://developer-old.gnome.org/pango/stable/pango-Text-Attributes.html#PangoAttrList-struct), or `NULL`. | [nullable] |
### gtk\_label\_set\_markup ()
```
void
gtk_label_set_markup (*`[GtkLabel](gtklabel#GtkLabel-struct) *self`*,
*`const char *str`*);
```
Parses *`str`* which is marked up with the Pango text markup language, setting the label’s text and attribute list based on the parse results.
If the *`str`* is external data, you may need to escape it with `g_markup_escape_text()` or `g_markup_printf_escaped()`:
```
label
├── [selection]
├── [link]
┊
╰── [link]
```
| This function will set the [“use-markup”](gtklabel#GtkLabel--use-markup) property to `TRUE` as a side effect.
If you set the label contents using the [“label”](gtklabel#GtkLabel--label) property you should also ensure that you set the [“use-markup”](gtklabel#GtkLabel--use-markup) property accordingly.
See also: [`gtk_label_set_text()`](gtklabel#gtk-label-set-text)
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkLabel](gtklabel#GtkLabel-struct) | |
| str | a markup string (see Pango markup format) | |
### gtk\_label\_set\_markup\_with\_mnemonic ()
```
void
gtk_label_set_markup_with_mnemonic (*`[GtkLabel](gtklabel#GtkLabel-struct) *self`*,
*`const char *str`*);
```
Parses *`str`* which is marked up with the Pango text markup language, setting the label’s text and attribute list based on the parse results. If characters in *`str`* are preceded by an underscore, they are underlined indicating that they represent a keyboard accelerator called a mnemonic.
The mnemonic key can be used to activate another widget, chosen automatically, or explicitly using [`gtk_label_set_mnemonic_widget()`](gtklabel#gtk-label-set-mnemonic-widget).
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkLabel](gtklabel#GtkLabel-struct) | |
| str | a markup string (see Pango markup format) | |
### gtk\_label\_set\_justify ()
```
void
gtk_label_set_justify (*`[GtkLabel](gtklabel#GtkLabel-struct) *self`*,
*`[GtkJustification](gtk4-standard-enumerations#GtkJustification) jtype`*);
```
Sets the alignment of the lines in the text of the label relative to each other. [`GTK_JUSTIFY_LEFT`](gtk4-standard-enumerations#GTK-JUSTIFY-LEFT:CAPS) is the default value when the widget is first created with [`gtk_label_new()`](gtklabel#gtk-label-new). If you instead want to set the alignment of the label as a whole, use [`gtk_widget_set_halign()`](gtkwidget#gtk-widget-set-halign) instead. [`gtk_label_set_justify()`](gtklabel#gtk-label-set-justify) has no effect on labels containing only a single line.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkLabel](gtklabel#GtkLabel-struct) | |
| jtype | a [GtkJustification](gtk4-standard-enumerations#GtkJustification) | |
### gtk\_label\_set\_xalign ()
```
void
gtk_label_set_xalign (*`[GtkLabel](gtklabel#GtkLabel-struct) *self`*,
*`float xalign`*);
```
Sets the [“xalign”](gtklabel#GtkLabel--xalign) property for *`label`* .
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkLabel](gtklabel#GtkLabel-struct) | |
| xalign | the new xalign value, between 0 and 1 | |
### gtk\_label\_set\_yalign ()
```
void
gtk_label_set_yalign (*`[GtkLabel](gtklabel#GtkLabel-struct) *self`*,
*`float yalign`*);
```
Sets the [“yalign”](gtklabel#GtkLabel--yalign) property for *`label`* .
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkLabel](gtklabel#GtkLabel-struct) | |
| yalign | the new yalign value, between 0 and 1 | |
### gtk\_label\_set\_ellipsize ()
```
void
gtk_label_set_ellipsize (*`[GtkLabel](gtklabel#GtkLabel-struct) *self`*,
*`[PangoEllipsizeMode](https://developer-old.gnome.org/pango/stable/pango-Layout-Objects.html#PangoEllipsizeMode) mode`*);
```
Sets the mode used to ellipsize (add an ellipsis: "...") to the text if there is not enough space to render the entire string.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkLabel](gtklabel#GtkLabel-struct) | |
| mode | a [PangoEllipsizeMode](https://developer-old.gnome.org/pango/stable/pango-Layout-Objects.html#PangoEllipsizeMode) | |
### gtk\_label\_set\_width\_chars ()
```
void
gtk_label_set_width_chars (*`[GtkLabel](gtklabel#GtkLabel-struct) *self`*,
*`int n_chars`*);
```
Sets the desired width in characters of *`label`* to *`n_chars`* .
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkLabel](gtklabel#GtkLabel-struct) | |
| n\_chars | the new desired width, in characters. | |
### gtk\_label\_set\_max\_width\_chars ()
```
void
gtk_label_set_max_width_chars (*`[GtkLabel](gtklabel#GtkLabel-struct) *self`*,
*`int n_chars`*);
```
Sets the desired maximum width in characters of *`label`* to *`n_chars`* .
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkLabel](gtklabel#GtkLabel-struct) | |
| n\_chars | the new desired maximum width, in characters. | |
### gtk\_label\_set\_wrap ()
```
void
gtk_label_set_wrap (*`[GtkLabel](gtklabel#GtkLabel-struct) *self`*,
*`gboolean wrap`*);
```
Toggles line wrapping within the [GtkLabel](gtklabel#GtkLabel-struct) widget. `TRUE` makes it break lines if text exceeds the widget’s size. `FALSE` lets the text get cut off by the edge of the widget if it exceeds the widget size.
Note that setting line wrapping to `TRUE` does not make the label wrap at its parent container’s width, because GTK widgets conceptually can’t make their requisition depend on the parent container’s size. For a label that wraps at a specific position, set the label’s width using [`gtk_widget_set_size_request()`](gtkwidget#gtk-widget-set-size-request).
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkLabel](gtklabel#GtkLabel-struct) | |
| wrap | the setting | |
### gtk\_label\_set\_wrap\_mode ()
```
void
gtk_label_set_wrap_mode (*`[GtkLabel](gtklabel#GtkLabel-struct) *self`*,
*`[PangoWrapMode](https://developer-old.gnome.org/pango/stable/pango-Layout-Objects.html#PangoWrapMode) wrap_mode`*);
```
If line wrapping is on (see [`gtk_label_set_wrap()`](gtklabel#gtk-label-set-wrap)) this controls how the line wrapping is done. The default is [`PANGO_WRAP_WORD`](https://developer-old.gnome.org/pango/stable/pango-Layout-Objects.html#PANGO-WRAP-WORD:CAPS) which means wrap on word boundaries.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkLabel](gtklabel#GtkLabel-struct) | |
| wrap\_mode | the line wrapping mode | |
### gtk\_label\_set\_lines ()
```
void
gtk_label_set_lines (*`[GtkLabel](gtklabel#GtkLabel-struct) *self`*,
*`int lines`*);
```
Sets the number of lines to which an ellipsized, wrapping label should be limited. This has no effect if the label is not wrapping or ellipsized. Set this to -1 if you don’t want to limit the number of lines.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkLabel](gtklabel#GtkLabel-struct) | |
| lines | the desired number of lines, or -1 | |
### gtk\_label\_get\_layout\_offsets ()
```
void
gtk_label_get_layout_offsets (*`[GtkLabel](gtklabel#GtkLabel-struct) *self`*,
*`int *x`*,
*`int *y`*);
```
Obtains the coordinates where the label will draw the [PangoLayout](https://developer-old.gnome.org/pango/stable/pango-Layout-Objects.html#PangoLayout-struct) representing the text in the label; useful to convert mouse events into coordinates inside the [PangoLayout](https://developer-old.gnome.org/pango/stable/pango-Layout-Objects.html#PangoLayout-struct), e.g. to take some action if some part of the label is clicked. Remember when using the [PangoLayout](https://developer-old.gnome.org/pango/stable/pango-Layout-Objects.html#PangoLayout-struct) functions you need to convert to and from pixels using [`PANGO_PIXELS()`](https://developer-old.gnome.org/pango/stable/pango-Glyph-Storage.html#PANGO-PIXELS:CAPS) or [PANGO\_SCALE](https://developer-old.gnome.org/pango/stable/pango-Glyph-Storage.html#PANGO-SCALE:CAPS).
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkLabel](gtklabel#GtkLabel-struct) | |
| x | location to store X offset of layout, or `NULL`. | [out][optional] |
| y | location to store Y offset of layout, or `NULL`. | [out][optional] |
### gtk\_label\_get\_mnemonic\_keyval ()
```
guint
gtk_label_get_mnemonic_keyval (*`[GtkLabel](gtklabel#GtkLabel-struct) *self`*);
```
If the label has been set so that it has a mnemonic key this function returns the keyval used for the mnemonic accelerator. If there is no mnemonic set up it returns GDK\_KEY\_VoidSymbol.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkLabel](gtklabel#GtkLabel-struct) | |
#### Returns
GDK keyval usable for accelerators, or GDK\_KEY\_VoidSymbol
### gtk\_label\_get\_selectable ()
```
gboolean
gtk_label_get_selectable (*`[GtkLabel](gtklabel#GtkLabel-struct) *self`*);
```
Gets the value set by [`gtk_label_set_selectable()`](gtklabel#gtk-label-set-selectable).
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkLabel](gtklabel#GtkLabel-struct) | |
#### Returns
`TRUE` if the user can copy text from the label
### gtk\_label\_get\_text ()
```
const char *
gtk_label_get_text (*`[GtkLabel](gtklabel#GtkLabel-struct) *self`*);
```
Fetches the text from a label widget, as displayed on the screen. This does not include any embedded underlines indicating mnemonics or Pango markup. (See [`gtk_label_get_label()`](gtklabel#gtk-label-get-label))
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkLabel](gtklabel#GtkLabel-struct) | |
#### Returns
the text in the label widget. This is the internal string used by the label, and must not be modified.
### gtk\_label\_new\_with\_mnemonic ()
```
[GtkWidget](gtkwidget#GtkWidget-struct) *
gtk_label_new_with_mnemonic (*`const char *str`*);
```
Creates a new [GtkLabel](gtklabel#GtkLabel-struct), containing the text in *`str`* .
If characters in *`str`* are preceded by an underscore, they are underlined. If you need a literal underscore character in a label, use '\_\_' (two underscores). The first underlined character represents a keyboard accelerator called a mnemonic. The mnemonic key can be used to activate another widget, chosen automatically, or explicitly using [`gtk_label_set_mnemonic_widget()`](gtklabel#gtk-label-set-mnemonic-widget).
If [`gtk_label_set_mnemonic_widget()`](gtklabel#gtk-label-set-mnemonic-widget) is not called, then the first activatable ancestor of the [GtkLabel](gtklabel#GtkLabel-struct) will be chosen as the mnemonic widget. For instance, if the label is inside a button or menu item, the button or menu item will automatically become the mnemonic widget and be activated by the mnemonic.
#### Parameters
| | | |
| --- | --- | --- |
| str | The text of the label, with an underscore in front of the mnemonic character. | [nullable] |
#### Returns
the new [GtkLabel](gtklabel#GtkLabel-struct)
### gtk\_label\_select\_region ()
```
void
gtk_label_select_region (*`[GtkLabel](gtklabel#GtkLabel-struct) *self`*,
*`int start_offset`*,
*`int end_offset`*);
```
Selects a range of characters in the label, if the label is selectable. See [`gtk_label_set_selectable()`](gtklabel#gtk-label-set-selectable). If the label is not selectable, this function has no effect. If *`start_offset`* or *`end_offset`* are -1, then the end of the label will be substituted.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkLabel](gtklabel#GtkLabel-struct) | |
| start\_offset | start offset (in characters not bytes) | |
| end\_offset | end offset (in characters not bytes) | |
### gtk\_label\_set\_mnemonic\_widget ()
```
void
gtk_label_set_mnemonic_widget (*`[GtkLabel](gtklabel#GtkLabel-struct) *self`*,
*`[GtkWidget](gtkwidget#GtkWidget-struct) *widget`*);
```
If the label has been set so that it has a mnemonic key (using i.e. [`gtk_label_set_markup_with_mnemonic()`](gtklabel#gtk-label-set-markup-with-mnemonic), [`gtk_label_set_text_with_mnemonic()`](gtklabel#gtk-label-set-text-with-mnemonic), [`gtk_label_new_with_mnemonic()`](gtklabel#gtk-label-new-with-mnemonic) or the “use\_underline” property) the label can be associated with a widget that is the target of the mnemonic. When the label is inside a widget (like a [GtkButton](gtkbutton#GtkButton-struct) or a [GtkNotebook](gtknotebook#GtkNotebook-struct) tab) it is automatically associated with the correct widget, but sometimes (i.e. when the target is a [GtkEntry](gtkentry#GtkEntry-struct) next to the label) you need to set it explicitly using this function.
The target widget will be accelerated by emitting the GtkWidget::mnemonic-activate signal on it. The default handler for this signal will activate the widget if there are no mnemonic collisions and toggle focus between the colliding widgets otherwise.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkLabel](gtklabel#GtkLabel-struct) | |
| widget | the target [GtkWidget](gtkwidget#GtkWidget-struct), or `NULL` to unset. | [nullable] |
### gtk\_label\_set\_selectable ()
```
void
gtk_label_set_selectable (*`[GtkLabel](gtklabel#GtkLabel-struct) *self`*,
*`gboolean setting`*);
```
Selectable labels allow the user to select text from the label, for copy-and-paste.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkLabel](gtklabel#GtkLabel-struct) | |
| setting | `TRUE` to allow selecting text in the label | |
### gtk\_label\_set\_text\_with\_mnemonic ()
```
void
gtk_label_set_text_with_mnemonic (*`[GtkLabel](gtklabel#GtkLabel-struct) *self`*,
*`const char *str`*);
```
Sets the label’s text from the string *`str`* . If characters in *`str`* are preceded by an underscore, they are underlined indicating that they represent a keyboard accelerator called a mnemonic. The mnemonic key can be used to activate another widget, chosen automatically, or explicitly using [`gtk_label_set_mnemonic_widget()`](gtklabel#gtk-label-set-mnemonic-widget).
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkLabel](gtklabel#GtkLabel-struct) | |
| str | a string | |
### gtk\_label\_get\_attributes ()
```
[PangoAttrList](https://developer-old.gnome.org/pango/stable/pango-Text-Attributes.html#PangoAttrList-struct) *
gtk_label_get_attributes (*`[GtkLabel](gtklabel#GtkLabel-struct) *self`*);
```
Gets the attribute list that was set on the label using [`gtk_label_set_attributes()`](gtklabel#gtk-label-set-attributes), if any. This function does not reflect attributes that come from the labels markup (see [`gtk_label_set_markup()`](gtklabel#gtk-label-set-markup)). If you want to get the effective attributes for the label, use pango\_layout\_get\_attribute (gtk\_label\_get\_layout (self)).
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkLabel](gtklabel#GtkLabel-struct) | |
#### Returns
the attribute list, or `NULL` if none was set.
[nullable][transfer none]
### gtk\_label\_get\_justify ()
```
[GtkJustification](gtk4-standard-enumerations#GtkJustification)
gtk_label_get_justify (*`[GtkLabel](gtklabel#GtkLabel-struct) *self`*);
```
Returns the justification of the label. See [`gtk_label_set_justify()`](gtklabel#gtk-label-set-justify).
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkLabel](gtklabel#GtkLabel-struct) | |
#### Returns
[GtkJustification](gtk4-standard-enumerations#GtkJustification)
### gtk\_label\_get\_xalign ()
```
float
gtk_label_get_xalign (*`[GtkLabel](gtklabel#GtkLabel-struct) *self`*);
```
Gets the [“xalign”](gtklabel#GtkLabel--xalign) property for *`label`* .
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkLabel](gtklabel#GtkLabel-struct) | |
#### Returns
the xalign property
### gtk\_label\_get\_yalign ()
```
float
gtk_label_get_yalign (*`[GtkLabel](gtklabel#GtkLabel-struct) *self`*);
```
Gets the [“yalign”](gtklabel#GtkLabel--yalign) property for *`label`* .
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkLabel](gtklabel#GtkLabel-struct) | |
#### Returns
the yalign property
### gtk\_label\_get\_ellipsize ()
```
[PangoEllipsizeMode](https://developer-old.gnome.org/pango/stable/pango-Layout-Objects.html#PangoEllipsizeMode)
gtk_label_get_ellipsize (*`[GtkLabel](gtklabel#GtkLabel-struct) *self`*);
```
Returns the ellipsizing position of the label. See [`gtk_label_set_ellipsize()`](gtklabel#gtk-label-set-ellipsize).
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkLabel](gtklabel#GtkLabel-struct) | |
#### Returns
[PangoEllipsizeMode](https://developer-old.gnome.org/pango/stable/pango-Layout-Objects.html#PangoEllipsizeMode)
### gtk\_label\_get\_width\_chars ()
```
int
gtk_label_get_width_chars (*`[GtkLabel](gtklabel#GtkLabel-struct) *self`*);
```
Retrieves the desired width of *`label`* , in characters. See [`gtk_label_set_width_chars()`](gtklabel#gtk-label-set-width-chars).
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkLabel](gtklabel#GtkLabel-struct) | |
#### Returns
the width of the label in characters.
### gtk\_label\_get\_max\_width\_chars ()
```
int
gtk_label_get_max_width_chars (*`[GtkLabel](gtklabel#GtkLabel-struct) *self`*);
```
Retrieves the desired maximum width of *`label`* , in characters. See [`gtk_label_set_width_chars()`](gtklabel#gtk-label-set-width-chars).
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkLabel](gtklabel#GtkLabel-struct) | |
#### Returns
the maximum width of the label in characters.
### gtk\_label\_get\_label ()
```
const char *
gtk_label_get_label (*`[GtkLabel](gtklabel#GtkLabel-struct) *self`*);
```
Fetches the text from a label widget including any embedded underlines indicating mnemonics and Pango markup. (See [`gtk_label_get_text()`](gtklabel#gtk-label-get-text)).
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkLabel](gtklabel#GtkLabel-struct) | |
#### Returns
the text of the label widget. This string is owned by the widget and must not be modified or freed.
### gtk\_label\_get\_layout ()
```
[PangoLayout](https://developer-old.gnome.org/pango/stable/pango-Layout-Objects.html#PangoLayout-struct) *
gtk_label_get_layout (*`[GtkLabel](gtklabel#GtkLabel-struct) *self`*);
```
Gets the [PangoLayout](https://developer-old.gnome.org/pango/stable/pango-Layout-Objects.html#PangoLayout-struct) used to display the label. The layout is useful to e.g. convert text positions to pixel positions, in combination with [`gtk_label_get_layout_offsets()`](gtklabel#gtk-label-get-layout-offsets). The returned layout is owned by the *`label`* so need not be freed by the caller. The *`label`* is free to recreate its layout at any time, so it should be considered read-only.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkLabel](gtklabel#GtkLabel-struct) | |
#### Returns
the [PangoLayout](https://developer-old.gnome.org/pango/stable/pango-Layout-Objects.html#PangoLayout-struct) for this label.
[transfer none]
### gtk\_label\_get\_wrap ()
```
gboolean
gtk_label_get_wrap (*`[GtkLabel](gtklabel#GtkLabel-struct) *self`*);
```
Returns whether lines in the label are automatically wrapped. See [`gtk_label_set_wrap()`](gtklabel#gtk-label-set-wrap).
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkLabel](gtklabel#GtkLabel-struct) | |
#### Returns
`TRUE` if the lines of the label are automatically wrapped.
### gtk\_label\_get\_wrap\_mode ()
```
[PangoWrapMode](https://developer-old.gnome.org/pango/stable/pango-Layout-Objects.html#PangoWrapMode)
gtk_label_get_wrap_mode (*`[GtkLabel](gtklabel#GtkLabel-struct) *self`*);
```
Returns line wrap mode used by the label. See [`gtk_label_set_wrap_mode()`](gtklabel#gtk-label-set-wrap-mode).
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkLabel](gtklabel#GtkLabel-struct) | |
#### Returns
`TRUE` if the lines of the label are automatically wrapped.
### gtk\_label\_get\_lines ()
```
int
gtk_label_get_lines (*`[GtkLabel](gtklabel#GtkLabel-struct) *self`*);
```
Gets the number of lines to which an ellipsized, wrapping label should be limited. See [`gtk_label_set_lines()`](gtklabel#gtk-label-set-lines).
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkLabel](gtklabel#GtkLabel-struct) | |
#### Returns
The number of lines
### gtk\_label\_get\_mnemonic\_widget ()
```
[GtkWidget](gtkwidget#GtkWidget-struct) *
gtk_label_get_mnemonic_widget (*`[GtkLabel](gtklabel#GtkLabel-struct) *self`*);
```
Retrieves the target of the mnemonic (keyboard shortcut) of this label. See [`gtk_label_set_mnemonic_widget()`](gtklabel#gtk-label-set-mnemonic-widget).
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkLabel](gtklabel#GtkLabel-struct) | |
#### Returns
the target of the label’s mnemonic, or `NULL` if none has been set and the default algorithm will be used.
[nullable][transfer none]
### gtk\_label\_get\_selection\_bounds ()
```
gboolean
gtk_label_get_selection_bounds (*`[GtkLabel](gtklabel#GtkLabel-struct) *self`*,
*`int *start`*,
*`int *end`*);
```
Gets the selected range of characters in the label, returning `TRUE` if there’s a selection.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkLabel](gtklabel#GtkLabel-struct) | |
| start | return location for start of selection, as a character offset. | [out] |
| end | return location for end of selection, as a character offset. | [out] |
#### Returns
`TRUE` if selection is non-empty
### gtk\_label\_get\_use\_markup ()
```
gboolean
gtk_label_get_use_markup (*`[GtkLabel](gtklabel#GtkLabel-struct) *self`*);
```
Returns whether the label’s text is interpreted as marked up with the Pango text markup language. See [`gtk_label_set_use_markup()`](gtklabel#gtk-label-set-use-markup).
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkLabel](gtklabel#GtkLabel-struct) | |
#### Returns
`TRUE` if the label’s text will be parsed for markup.
### gtk\_label\_get\_use\_underline ()
```
gboolean
gtk_label_get_use_underline (*`[GtkLabel](gtklabel#GtkLabel-struct) *self`*);
```
Returns whether an embedded underline in the label indicates a mnemonic. See [`gtk_label_set_use_underline()`](gtklabel#gtk-label-set-use-underline).
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkLabel](gtklabel#GtkLabel-struct) | |
#### Returns
`TRUE` whether an embedded underline in the label indicates the mnemonic accelerator keys.
### gtk\_label\_get\_single\_line\_mode ()
```
gboolean
gtk_label_get_single_line_mode (*`[GtkLabel](gtklabel#GtkLabel-struct) *self`*);
```
Returns whether the label is in single line mode.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkLabel](gtklabel#GtkLabel-struct) | |
#### Returns
`TRUE` when the label is in single line mode.
### gtk\_label\_set\_label ()
```
void
gtk_label_set_label (*`[GtkLabel](gtklabel#GtkLabel-struct) *self`*,
*`const char *str`*);
```
Sets the text of the label. The label is interpreted as including embedded underlines and/or Pango markup depending on the values of the [“use-underline”](gtklabel#GtkLabel--use-underline) and [“use-markup”](gtklabel#GtkLabel--use-markup) properties.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkLabel](gtklabel#GtkLabel-struct) | |
| str | the new text to set for the label | |
### gtk\_label\_set\_use\_markup ()
```
void
gtk_label_set_use_markup (*`[GtkLabel](gtklabel#GtkLabel-struct) *self`*,
*`gboolean setting`*);
```
Sets whether the text of the label contains markup in Pango’s text markup language. See [`gtk_label_set_markup()`](gtklabel#gtk-label-set-markup).
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkLabel](gtklabel#GtkLabel-struct) | |
| setting | `TRUE` if the label’s text should be parsed for markup. | |
### gtk\_label\_set\_use\_underline ()
```
void
gtk_label_set_use_underline (*`[GtkLabel](gtklabel#GtkLabel-struct) *self`*,
*`gboolean setting`*);
```
If true, an underline in the text indicates the next character should be used for the mnemonic accelerator key.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkLabel](gtklabel#GtkLabel-struct) | |
| setting | `TRUE` if underlines in the text indicate mnemonics | |
### gtk\_label\_set\_single\_line\_mode ()
```
void
gtk_label_set_single_line_mode (*`[GtkLabel](gtklabel#GtkLabel-struct) *self`*,
*`gboolean single_line_mode`*);
```
Sets whether the label is in single line mode.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkLabel](gtklabel#GtkLabel-struct) | |
| single\_line\_mode | `TRUE` if the label should be in single line mode | |
### gtk\_label\_get\_current\_uri ()
```
const char *
gtk_label_get_current_uri (*`[GtkLabel](gtklabel#GtkLabel-struct) *self`*);
```
Returns the URI for the currently active link in the label. The active link is the one under the mouse pointer or, in a selectable label, the link in which the text cursor is currently positioned.
This function is intended for use in a [“activate-link”](gtklabel#GtkLabel-activate-link) handler or for use in a [“query-tooltip”](gtkwidget#GtkWidget-query-tooltip) handler.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkLabel](gtklabel#GtkLabel-struct) | |
#### Returns
the currently active URI or `NULL` if there is none. The string is owned by GTK and must not be freed or modified.
[nullable]
### gtk\_label\_set\_extra\_menu ()
```
void
gtk_label_set_extra_menu (*`[GtkLabel](gtklabel#GtkLabel-struct) *self`*,
*`GMenuModel *model`*);
```
Sets a menu model to add when constructing the context menu for *`label`* .
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkLabel](gtklabel#GtkLabel-struct) | |
| model | a GMenuModel. | [allow-none] |
### gtk\_label\_get\_extra\_menu ()
```
GMenuModel *
gtk_label_get_extra_menu (*`[GtkLabel](gtklabel#GtkLabel-struct) *self`*);
```
Gets the menu model set with [`gtk_label_set_extra_menu()`](gtklabel#gtk-label-set-extra-menu).
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkLabel](gtklabel#GtkLabel-struct) | |
#### Returns
the menu model.
[transfer none][nullable]
Types and Values
----------------
### GtkLabel
```
typedef struct _GtkLabel GtkLabel;
```
Property Details
----------------
### The `“attributes”` property
```
“attributes” [PangoAttrList](https://developer-old.gnome.org/pango/stable/pango-Text-Attributes.html#PangoAttrList-struct) *
```
A list of style attributes to apply to the text of the label.
Owner: GtkLabel
Flags: Read / Write
### The `“ellipsize”` property
```
“ellipsize” [PangoEllipsizeMode](https://developer-old.gnome.org/pango/stable/pango-Layout-Objects.html#PangoEllipsizeMode)
```
The preferred place to ellipsize the string, if the label does not have enough room to display the entire string, specified as a [PangoEllipsizeMode](https://developer-old.gnome.org/pango/stable/pango-Layout-Objects.html#PangoEllipsizeMode).
Note that setting this property to a value other than [`PANGO_ELLIPSIZE_NONE`](https://developer-old.gnome.org/pango/stable/pango-Layout-Objects.html#PANGO-ELLIPSIZE-NONE:CAPS) has the side-effect that the label requests only enough space to display the ellipsis "...". In particular, this means that ellipsizing labels do not work well in notebook tabs, unless the [GtkNotebook](gtknotebook#GtkNotebook-struct) tab-expand child property is set to `TRUE`. Other ways to set a label's width are [`gtk_widget_set_size_request()`](gtkwidget#gtk-widget-set-size-request) and [`gtk_label_set_width_chars()`](gtklabel#gtk-label-set-width-chars).
Owner: GtkLabel
Flags: Read / Write
Default value: PANGO\_ELLIPSIZE\_NONE
### The `“extra-menu”` property
```
“extra-menu” GMenuModel *
```
A menu model whose contents will be appended to the context menu.
Owner: GtkLabel
Flags: Read / Write
### The `“justify”` property
```
“justify” [GtkJustification](gtk4-standard-enumerations#GtkJustification)
```
The alignment of the lines in the text of the label relative to each other. This does NOT affect the alignment of the label within its allocation. See GtkLabel:xalign for that.
Owner: GtkLabel
Flags: Read / Write
Default value: GTK\_JUSTIFY\_LEFT
### The `“label”` property
```
“label” char *
```
The contents of the label.
If the string contains Pango XML markup, you will have to set the [“use-markup”](gtklabel#GtkLabel--use-markup) property to `TRUE` in order for the label to display the markup attributes. See also [`gtk_label_set_markup()`](gtklabel#gtk-label-set-markup) for a convenience function that sets both this property and the [“use-markup”](gtklabel#GtkLabel--use-markup) property at the same time.
If the string contains underlines acting as mnemonics, you will have to set the [“use-underline”](gtklabel#GtkLabel--use-underline) property to `TRUE` in order for the label to display them.
Owner: GtkLabel
Flags: Read / Write
Default value: ""
### The `“lines”` property
```
“lines” int
```
The number of lines to which an ellipsized, wrapping label should be limited. This property has no effect if the label is not wrapping or ellipsized. Set this property to -1 if you don't want to limit the number of lines.
Owner: GtkLabel
Flags: Read / Write
Allowed values: >= -1
Default value: -1
### The `“max-width-chars”` property
```
“max-width-chars” int
```
The desired maximum width of the label, in characters. If this property is set to -1, the width will be calculated automatically.
See the section on text layout for details of how [“width-chars”](gtklabel#GtkLabel--width-chars) and [“max-width-chars”](gtklabel#GtkLabel--max-width-chars) determine the width of ellipsized and wrapped labels.
Owner: GtkLabel
Flags: Read / Write
Allowed values: >= -1
Default value: -1
### The `“mnemonic-keyval”` property
```
“mnemonic-keyval” guint
```
The mnemonic accelerator key for this label.
Owner: GtkLabel
Flags: Read
Default value: 16777215
### The `“mnemonic-widget”` property
```
“mnemonic-widget” [GtkWidget](gtkwidget#GtkWidget-struct) *
```
The widget to be activated when the label’s mnemonic key is pressed.
Owner: GtkLabel
Flags: Read / Write
### The `“selectable”` property
```
“selectable” gboolean
```
Whether the label text can be selected with the mouse.
Owner: GtkLabel
Flags: Read / Write
Default value: FALSE
### The `“single-line-mode”` property
```
“single-line-mode” gboolean
```
Whether the label is in single line mode. In single line mode, the height of the label does not depend on the actual text, it is always set to ascent + descent of the font. This can be an advantage in situations where resizing the label because of text changes would be distracting, e.g. in a statusbar.
Owner: GtkLabel
Flags: Read / Write
Default value: FALSE
### The `“use-markup”` property
```
“use-markup” gboolean
```
The text of the label includes XML markup. See pango\_parse\_markup().
Owner: GtkLabel
Flags: Read / Write
Default value: FALSE
### The `“use-underline”` property
```
“use-underline” gboolean
```
If set, an underline in the text indicates the next character should be used for the mnemonic accelerator key.
Owner: GtkLabel
Flags: Read / Write
Default value: FALSE
### The `“width-chars”` property
```
“width-chars” int
```
The desired width of the label, in characters. If this property is set to -1, the width will be calculated automatically.
See the section on text layout for details of how [“width-chars”](gtklabel#GtkLabel--width-chars) and [“max-width-chars”](gtklabel#GtkLabel--max-width-chars) determine the width of ellipsized and wrapped labels.
Owner: GtkLabel
Flags: Read / Write
Allowed values: >= -1
Default value: -1
### The `“wrap”` property
```
“wrap” gboolean
```
If set, wrap lines if the text becomes too wide.
Owner: GtkLabel
Flags: Read / Write
Default value: FALSE
### The `“wrap-mode”` property
```
“wrap-mode” [PangoWrapMode](https://developer-old.gnome.org/pango/stable/pango-Layout-Objects.html#PangoWrapMode)
```
If line wrapping is on (see the [“wrap”](gtklabel#GtkLabel--wrap) property) this controls how the line wrapping is done. The default is [`PANGO_WRAP_WORD`](https://developer-old.gnome.org/pango/stable/pango-Layout-Objects.html#PANGO-WRAP-WORD:CAPS), which means wrap on word boundaries.
Owner: GtkLabel
Flags: Read / Write
Default value: PANGO\_WRAP\_WORD
### The `“xalign”` property
```
“xalign” float
```
The xalign property determines the horizontal alignment of the label text inside the labels size allocation. Compare this to [“halign”](gtkwidget#GtkWidget--halign), which determines how the labels size allocation is positioned in the space available for the label.
Owner: GtkLabel
Flags: Read / Write
Allowed values: [0,1]
Default value: 0.5
### The `“yalign”` property
```
“yalign” float
```
The yalign property determines the vertical alignment of the label text inside the labels size allocation. Compare this to [“valign”](gtkwidget#GtkWidget--valign), which determines how the labels size allocation is positioned in the space available for the label.
Owner: GtkLabel
Flags: Read / Write
Allowed values: [0,1]
Default value: 0.5
Signal Details
--------------
### The `“activate-current-link”` signal
```
void
user_function ([GtkLabel](gtklabel#GtkLabel-struct) *self,
gpointer user_data)
```
A [keybinding signal](gtkshortcutaction#GtkSignalAction-struct) which gets emitted when the user activates a link in the label.
Applications may also emit the signal with `g_signal_emit_by_name()` if they need to control activation of URIs programmatically.
The default bindings for this signal are all forms of the Enter key.
#### Parameters
| | | |
| --- | --- | --- |
| self | The label on which the signal was emitted | |
| user\_data | user data set when the signal handler was connected. | |
Flags: Action
### The `“activate-link”` signal
```
gboolean
user_function ([GtkLabel](gtklabel#GtkLabel-struct) *self,
char *uri,
gpointer user_data)
```
The signal which gets emitted to activate a URI. Applications may connect to it to override the default behaviour, which is to call [`gtk_show_uri()`](gtk4-filesystem-utilities#gtk-show-uri).
#### Parameters
| | | |
| --- | --- | --- |
| self | The label on which the signal was emitted | |
| uri | the URI that is activated | |
| user\_data | user data set when the signal handler was connected. | |
#### Returns
`TRUE` if the link has been activated
Flags: Run Last
### The `“copy-clipboard”` signal
```
void
user_function ([GtkLabel](gtklabel#GtkLabel-struct) *self,
gpointer user_data)
```
The ::copy-clipboard signal is a [keybinding signal](gtkshortcutaction#GtkSignalAction-struct) which gets emitted to copy the selection to the clipboard.
The default binding for this signal is Ctrl-c.
#### Parameters
| | | |
| --- | --- | --- |
| self | the object which received the signal | |
| user\_data | user data set when the signal handler was connected. | |
Flags: Action
### The `“move-cursor”` signal
```
void
user_function ([GtkLabel](gtklabel#GtkLabel-struct) *entry,
[GtkMovementStep](gtk4-standard-enumerations#GtkMovementStep) step,
int count,
gboolean extend_selection,
gpointer user_data)
```
The ::move-cursor signal is a [keybinding signal](gtkshortcutaction#GtkSignalAction-struct) which gets emitted when the user initiates a cursor movement. If the cursor is not visible in *`entry`* , this signal causes the viewport to be moved instead.
Applications should not connect to it, but may emit it with `g_signal_emit_by_name()` if they need to control the cursor programmatically.
The default bindings for this signal come in two variants, the variant with the Shift modifier extends the selection, the variant without the Shift modifier does not. There are too many key combinations to list them all here.
* Arrow keys move by individual characters/lines
* Ctrl-arrow key combinations move by words/paragraphs
* Home/End keys move to the ends of the buffer
#### Parameters
| | | |
| --- | --- | --- |
| entry | the object which received the signal | |
| step | the granularity of the move, as a [GtkMovementStep](gtk4-standard-enumerations#GtkMovementStep) | |
| count | the number of *`step`* units to move | |
| extend\_selection | `TRUE` if the move should extend the selection | |
| user\_data | user data set when the signal handler was connected. | |
Flags: Action
Action Details
--------------
### The `“link.copy”` action
Copies the link to the clipboard, when activated on a link inside the label.
### The `“link.open”` action
Opens the link, when activated on a link inside the label.
### The `“selection.select-all”` action
Selects all of the text, if the label allows selection.
### The `“selection.delete”` action
Doesn't do anything, since text in labels can't be deleted.
### The `“clipboard.paste”` action
Doesn't do anything, since text in labels can't be edited.
### The `“clipboard.copy”` action
Copies the text to the clipboard.
### The `“clipboard.cut”` action
Doesn't do anything, since text in labels can't be deleted.
### The `“menu.popup”` action
Opens the context menu.
| programming_docs |
gtk GtkPaned GtkPaned
========
GtkPaned — A widget with two adjustable panes
Functions
---------
| | |
| --- | --- |
| [GtkWidget](gtkwidget#GtkWidget-struct) \* | [gtk\_paned\_new](gtkpaned#gtk-paned-new) () |
| void | [gtk\_paned\_set\_start\_child](gtkpaned#gtk-paned-set-start-child) () |
| [GtkWidget](gtkwidget#GtkWidget-struct) \* | [gtk\_paned\_get\_start\_child](gtkpaned#gtk-paned-get-start-child) () |
| void | [gtk\_paned\_set\_end\_child](gtkpaned#gtk-paned-set-end-child) () |
| [GtkWidget](gtkwidget#GtkWidget-struct) \* | [gtk\_paned\_get\_end\_child](gtkpaned#gtk-paned-get-end-child) () |
| void | [gtk\_paned\_set\_resize\_start\_child](gtkpaned#gtk-paned-set-resize-start-child) () |
| gboolean | [gtk\_paned\_get\_resize\_start\_child](gtkpaned#gtk-paned-get-resize-start-child) () |
| void | [gtk\_paned\_set\_resize\_end\_child](gtkpaned#gtk-paned-set-resize-end-child) () |
| gboolean | [gtk\_paned\_get\_resize\_end\_child](gtkpaned#gtk-paned-get-resize-end-child) () |
| void | [gtk\_paned\_set\_shrink\_start\_child](gtkpaned#gtk-paned-set-shrink-start-child) () |
| gboolean | [gtk\_paned\_get\_shrink\_start\_child](gtkpaned#gtk-paned-get-shrink-start-child) () |
| void | [gtk\_paned\_set\_shrink\_end\_child](gtkpaned#gtk-paned-set-shrink-end-child) () |
| gboolean | [gtk\_paned\_get\_shrink\_end\_child](gtkpaned#gtk-paned-get-shrink-end-child) () |
| void | [gtk\_paned\_set\_position](gtkpaned#gtk-paned-set-position) () |
| int | [gtk\_paned\_get\_position](gtkpaned#gtk-paned-get-position) () |
| void | [gtk\_paned\_set\_wide\_handle](gtkpaned#gtk-paned-set-wide-handle) () |
| gboolean | [gtk\_paned\_get\_wide\_handle](gtkpaned#gtk-paned-get-wide-handle) () |
Properties
----------
| | | |
| --- | --- | --- |
| [GtkWidget](gtkwidget#GtkWidget-struct) \* | [end-child](gtkpaned#GtkPaned--end-child) | Read / Write |
| int | [max-position](gtkpaned#GtkPaned--max-position) | Read |
| int | [min-position](gtkpaned#GtkPaned--min-position) | Read |
| int | [position](gtkpaned#GtkPaned--position) | Read / Write |
| gboolean | [position-set](gtkpaned#GtkPaned--position-set) | Read / Write |
| gboolean | [resize-end-child](gtkpaned#GtkPaned--resize-end-child) | Read / Write |
| gboolean | [resize-start-child](gtkpaned#GtkPaned--resize-start-child) | Read / Write |
| gboolean | [shrink-end-child](gtkpaned#GtkPaned--shrink-end-child) | Read / Write |
| gboolean | [shrink-start-child](gtkpaned#GtkPaned--shrink-start-child) | Read / Write |
| [GtkWidget](gtkwidget#GtkWidget-struct) \* | [start-child](gtkpaned#GtkPaned--start-child) | Read / Write |
| gboolean | [wide-handle](gtkpaned#GtkPaned--wide-handle) | Read / Write |
Signals
-------
| | | |
| --- | --- | --- |
| gboolean | [accept-position](gtkpaned#GtkPaned-accept-position) | Action |
| gboolean | [cancel-position](gtkpaned#GtkPaned-cancel-position) | Action |
| gboolean | [cycle-child-focus](gtkpaned#GtkPaned-cycle-child-focus) | Action |
| gboolean | [cycle-handle-focus](gtkpaned#GtkPaned-cycle-handle-focus) | Action |
| gboolean | [move-handle](gtkpaned#GtkPaned-move-handle) | Action |
| gboolean | [toggle-handle-focus](gtkpaned#GtkPaned-toggle-handle-focus) | Action |
Types and Values
----------------
| | |
| --- | --- |
| | [GtkPaned](gtkpaned#GtkPaned-struct) |
Object Hierarchy
----------------
```
GObject
╰── GInitiallyUnowned
╰── [GtkWidget](gtkwidget#GtkWidget-struct)
╰── GtkPaned
```
Implemented Interfaces
----------------------
GtkPaned implements [GtkAccessible](gtkaccessible#GtkAccessible-struct), [GtkBuildable](gtkbuildable#GtkBuildable-struct), [GtkConstraintTarget](gtkconstraint#GtkConstraintTarget-struct) and [GtkOrientable](gtk4-orientable#GtkOrientable-struct).
Includes
--------
```
#include <gtk/gtk.h>
```
Description
-----------
[GtkPaned](gtkpaned#GtkPaned-struct) has two panes, arranged either horizontally or vertically. The division between the two panes is adjustable by the user by dragging a handle.
Child widgets are added to the panes of the widget with [`gtk_paned_set_start_child()`](gtkpaned#gtk-paned-set-start-child) and [`gtk_paned_set_end_child()`](gtkpaned#gtk-paned-set-end-child). The division between the two children is set by default from the size requests of the children, but it can be adjusted by the user.
A paned widget draws a separator between the two child widgets and a small handle that the user can drag to adjust the division. It does not draw any relief around the children or around the separator. (The space in which the separator is called the gutter.) Often, it is useful to put each child inside a [GtkFrame](gtkframe#GtkFrame-struct) so that the gutter appears as a ridge. No separator is drawn if one of the children is missing.
Each child has two options that can be set, *`resize`* and *`shrink`* . If *`resize`* is true, then when the [GtkPaned](gtkpaned#GtkPaned-struct) is resized, that child will expand or shrink along with the paned widget. If *`shrink`* is true, then that child can be made smaller than its requisition by the user. Setting *`shrink`* to `FALSE` allows the application to set a minimum size. If *`resize`* is false for both children, then this is treated as if *`resize`* is true for both children.
The application can set the position of the slider as if it were set by the user, by calling [`gtk_paned_set_position()`](gtkpaned#gtk-paned-set-position).
### CSS nodes
GtkPaned has a main CSS node with name paned, and a subnode for the separator with name separator. The subnode gets a .wide style class when the paned is supposed to be wide.
In horizontal orientation, the nodes are arranged based on the text direction, so in left-to-right mode, :first-child will select the leftmost child, while it will select the rightmost child in RTL layouts.
#### Creating a paned widget with minimum sizes.
```
paned
├── <child>
├── separator[.wide]
╰── <child>
```
| Functions
---------
### gtk\_paned\_new ()
```
[GtkWidget](gtkwidget#GtkWidget-struct) *
gtk_paned_new (*`[GtkOrientation](gtk4-standard-enumerations#GtkOrientation) orientation`*);
```
Creates a new [GtkPaned](gtkpaned#GtkPaned-struct) widget.
#### Parameters
| | | |
| --- | --- | --- |
| orientation | the paned’s orientation. | |
#### Returns
a new [GtkPaned](gtkpaned#GtkPaned-struct).
### gtk\_paned\_set\_start\_child ()
```
void
gtk_paned_set_start_child (*`[GtkPaned](gtkpaned#GtkPaned-struct) *paned`*,
*`[GtkWidget](gtkwidget#GtkWidget-struct) *child`*);
```
Sets the start child of *`paned`* to *`child`* .
#### Parameters
| | | |
| --- | --- | --- |
| paned | a [GtkPaned](gtkpaned#GtkPaned-struct) | |
| child | the widget to add | |
### gtk\_paned\_get\_start\_child ()
```
[GtkWidget](gtkwidget#GtkWidget-struct) *
gtk_paned_get_start_child (*`[GtkPaned](gtkpaned#GtkPaned-struct) *paned`*);
```
Retrieves the start child of the given [GtkPaned](gtkpaned#GtkPaned-struct).
See also: [“start-child”](gtkpaned#GtkPaned--start-child)
#### Parameters
| | | |
| --- | --- | --- |
| paned | a [GtkPaned](gtkpaned#GtkPaned-struct) | |
#### Returns
the start child widget.
[transfer none][nullable]
### gtk\_paned\_set\_end\_child ()
```
void
gtk_paned_set_end_child (*`[GtkPaned](gtkpaned#GtkPaned-struct) *paned`*,
*`[GtkWidget](gtkwidget#GtkWidget-struct) *child`*);
```
Sets the end child of *`paned`* to *`child`* .
#### Parameters
| | | |
| --- | --- | --- |
| paned | a [GtkPaned](gtkpaned#GtkPaned-struct) | |
| child | the widget to add | |
### gtk\_paned\_get\_end\_child ()
```
[GtkWidget](gtkwidget#GtkWidget-struct) *
gtk_paned_get_end_child (*`[GtkPaned](gtkpaned#GtkPaned-struct) *paned`*);
```
Retrieves the end child of the given [GtkPaned](gtkpaned#GtkPaned-struct).
See also: [“end-child”](gtkpaned#GtkPaned--end-child)
#### Parameters
| | | |
| --- | --- | --- |
| paned | a [GtkPaned](gtkpaned#GtkPaned-struct) | |
#### Returns
the end child widget.
[transfer none][nullable]
### gtk\_paned\_set\_resize\_start\_child ()
```
void
gtk_paned_set_resize_start_child (*`[GtkPaned](gtkpaned#GtkPaned-struct) *paned`*,
*`gboolean resize`*);
```
Sets the [“resize-start-child”](gtkpaned#GtkPaned--resize-start-child) property
#### Parameters
| | | |
| --- | --- | --- |
| paned | a [GtkPaned](gtkpaned#GtkPaned-struct) | |
| resize | `TRUE` to let the start child be resized | |
### gtk\_paned\_get\_resize\_start\_child ()
```
gboolean
gtk_paned_get_resize_start_child (*`[GtkPaned](gtkpaned#GtkPaned-struct) *paned`*);
```
Returns whether the start child can be resized.
#### Parameters
| | | |
| --- | --- | --- |
| paned | a [GtkPaned](gtkpaned#GtkPaned-struct) | |
#### Returns
`TRUE` if the start child is resizable
### gtk\_paned\_set\_resize\_end\_child ()
```
void
gtk_paned_set_resize_end_child (*`[GtkPaned](gtkpaned#GtkPaned-struct) *paned`*,
*`gboolean resize`*);
```
Sets the [“resize-end-child”](gtkpaned#GtkPaned--resize-end-child) property
#### Parameters
| | | |
| --- | --- | --- |
| paned | a [GtkPaned](gtkpaned#GtkPaned-struct) | |
| resize | `TRUE` to let the end child be resized | |
### gtk\_paned\_get\_resize\_end\_child ()
```
gboolean
gtk_paned_get_resize_end_child (*`[GtkPaned](gtkpaned#GtkPaned-struct) *paned`*);
```
Returns whether the end child can be resized.
#### Parameters
| | | |
| --- | --- | --- |
| paned | a [GtkPaned](gtkpaned#GtkPaned-struct) | |
#### Returns
`TRUE` if the end child is resizable
### gtk\_paned\_set\_shrink\_start\_child ()
```
void
gtk_paned_set_shrink_start_child (*`[GtkPaned](gtkpaned#GtkPaned-struct) *paned`*,
*`gboolean resize`*);
```
Sets the [“shrink-start-child”](gtkpaned#GtkPaned--shrink-start-child) property
#### Parameters
| | | |
| --- | --- | --- |
| paned | a [GtkPaned](gtkpaned#GtkPaned-struct) | |
| resize | `TRUE` to let the start child be shrunk | |
### gtk\_paned\_get\_shrink\_start\_child ()
```
gboolean
gtk_paned_get_shrink_start_child (*`[GtkPaned](gtkpaned#GtkPaned-struct) *paned`*);
```
Returns whether the start child can be shrunk.
#### Parameters
| | | |
| --- | --- | --- |
| paned | a [GtkPaned](gtkpaned#GtkPaned-struct) | |
#### Returns
`TRUE` if the start child is shrinkable
### gtk\_paned\_set\_shrink\_end\_child ()
```
void
gtk_paned_set_shrink_end_child (*`[GtkPaned](gtkpaned#GtkPaned-struct) *paned`*,
*`gboolean resize`*);
```
Sets the [“shrink-end-child”](gtkpaned#GtkPaned--shrink-end-child) property
#### Parameters
| | | |
| --- | --- | --- |
| paned | a [GtkPaned](gtkpaned#GtkPaned-struct) | |
| resize | `TRUE` to let the end child be shrunk | |
### gtk\_paned\_get\_shrink\_end\_child ()
```
gboolean
gtk_paned_get_shrink_end_child (*`[GtkPaned](gtkpaned#GtkPaned-struct) *paned`*);
```
Returns whether the end child can be shrunk.
#### Parameters
| | | |
| --- | --- | --- |
| paned | a [GtkPaned](gtkpaned#GtkPaned-struct) | |
#### Returns
`TRUE` if the end child is shrinkable
### gtk\_paned\_set\_position ()
```
void
gtk_paned_set_position (*`[GtkPaned](gtkpaned#GtkPaned-struct) *paned`*,
*`int position`*);
```
Sets the position of the divider between the two panes.
#### Parameters
| | | |
| --- | --- | --- |
| paned | a [GtkPaned](gtkpaned#GtkPaned-struct) widget | |
| position | pixel position of divider, a negative value means that the position is unset. | |
### gtk\_paned\_get\_position ()
```
int
gtk_paned_get_position (*`[GtkPaned](gtkpaned#GtkPaned-struct) *paned`*);
```
Obtains the position of the divider between the two panes.
#### Parameters
| | | |
| --- | --- | --- |
| paned | a [GtkPaned](gtkpaned#GtkPaned-struct) widget | |
#### Returns
position of the divider
### gtk\_paned\_set\_wide\_handle ()
```
void
gtk_paned_set_wide_handle (*`[GtkPaned](gtkpaned#GtkPaned-struct) *paned`*,
*`gboolean wide`*);
```
Sets the [“wide-handle”](gtkpaned#GtkPaned--wide-handle) property.
#### Parameters
| | | |
| --- | --- | --- |
| paned | a [GtkPaned](gtkpaned#GtkPaned-struct) | |
| wide | the new value for the [“wide-handle”](gtkpaned#GtkPaned--wide-handle) property | |
### gtk\_paned\_get\_wide\_handle ()
```
gboolean
gtk_paned_get_wide_handle (*`[GtkPaned](gtkpaned#GtkPaned-struct) *paned`*);
```
Gets the [“wide-handle”](gtkpaned#GtkPaned--wide-handle) property.
#### Parameters
| | | |
| --- | --- | --- |
| paned | a [GtkPaned](gtkpaned#GtkPaned-struct) | |
#### Returns
`TRUE` if the paned should have a wide handle
Types and Values
----------------
### GtkPaned
```
typedef struct _GtkPaned GtkPaned;
```
Property Details
----------------
### The `“end-child”` property
```
“end-child” [GtkWidget](gtkwidget#GtkWidget-struct) *
```
The second child.
Owner: GtkPaned
Flags: Read / Write
### The `“max-position”` property
```
“max-position” int
```
The largest possible value for the position property. This property is derived from the size and shrinkability of the widget's children.
Owner: GtkPaned
Flags: Read
Allowed values: >= 0
Default value: 2147483647
### The `“min-position”` property
```
“min-position” int
```
The smallest possible value for the position property. This property is derived from the size and shrinkability of the widget's children.
Owner: GtkPaned
Flags: Read
Allowed values: >= 0
Default value: 0
### The `“position”` property
```
“position” int
```
Position of paned separator in pixels (0 means all the way to the left/top).
Owner: GtkPaned
Flags: Read / Write
Allowed values: >= 0
Default value: 0
### The `“position-set”` property
```
“position-set” gboolean
```
TRUE if the Position property should be used.
Owner: GtkPaned
Flags: Read / Write
Default value: FALSE
### The `“resize-end-child”` property
```
“resize-end-child” gboolean
```
The "resize-end-child" property determines whether the second child expands and shrinks along with the paned widget.
Owner: GtkPaned
Flags: Read / Write
Default value: TRUE
### The `“resize-start-child”` property
```
“resize-start-child” gboolean
```
The "resize-start-child" property determines whether the first child expands and shrinks along with the paned widget.
Owner: GtkPaned
Flags: Read / Write
Default value: TRUE
### The `“shrink-end-child”` property
```
“shrink-end-child” gboolean
```
The "shrink-end-child" property determines whether the second child can be made smaller than its requisition.
Owner: GtkPaned
Flags: Read / Write
Default value: TRUE
### The `“shrink-start-child”` property
```
“shrink-start-child” gboolean
```
The "shrink-start-child" property determines whether the first child can be made smaller than its requisition.
Owner: GtkPaned
Flags: Read / Write
Default value: TRUE
### The `“start-child”` property
```
“start-child” [GtkWidget](gtkwidget#GtkWidget-struct) *
```
The first child.
Owner: GtkPaned
Flags: Read / Write
### The `“wide-handle”` property
```
“wide-handle” gboolean
```
Setting this property to `TRUE` indicates that the paned needs to provide stronger visual separation (e.g. because it separates between two notebooks, whose tab rows would otherwise merge visually).
Owner: GtkPaned
Flags: Read / Write
Default value: FALSE
Signal Details
--------------
### The `“accept-position”` signal
```
gboolean
user_function ([GtkPaned](gtkpaned#GtkPaned-struct) *widget,
gpointer user_data)
```
The ::accept-position signal is a [keybinding signal](gtkshortcutaction#GtkSignalAction-struct) which gets emitted to accept the current position of the handle when moving it using key bindings.
The default binding for this signal is Return or Space.
#### Parameters
| | | |
| --- | --- | --- |
| widget | the object that received the signal | |
| user\_data | user data set when the signal handler was connected. | |
Flags: Action
### The `“cancel-position”` signal
```
gboolean
user_function ([GtkPaned](gtkpaned#GtkPaned-struct) *widget,
gpointer user_data)
```
The ::cancel-position signal is a [keybinding signal](gtkshortcutaction#GtkSignalAction-struct) which gets emitted to cancel moving the position of the handle using key bindings. The position of the handle will be reset to the value prior to moving it.
The default binding for this signal is Escape.
#### Parameters
| | | |
| --- | --- | --- |
| widget | the object that received the signal | |
| user\_data | user data set when the signal handler was connected. | |
Flags: Action
### The `“cycle-child-focus”` signal
```
gboolean
user_function ([GtkPaned](gtkpaned#GtkPaned-struct) *widget,
gboolean reversed,
gpointer user_data)
```
The ::cycle-child-focus signal is a [keybinding signal](gtkshortcutaction#GtkSignalAction-struct) which gets emitted to cycle the focus between the children of the paned.
The default binding is f6.
#### Parameters
| | | |
| --- | --- | --- |
| widget | the object that received the signal | |
| reversed | whether cycling backward or forward | |
| user\_data | user data set when the signal handler was connected. | |
Flags: Action
### The `“cycle-handle-focus”` signal
```
gboolean
user_function ([GtkPaned](gtkpaned#GtkPaned-struct) *widget,
gboolean reversed,
gpointer user_data)
```
The ::cycle-handle-focus signal is a [keybinding signal](gtkshortcutaction#GtkSignalAction-struct) which gets emitted to cycle whether the paned should grab focus to allow the user to change position of the handle by using key bindings.
The default binding for this signal is f8.
#### Parameters
| | | |
| --- | --- | --- |
| widget | the object that received the signal | |
| reversed | whether cycling backward or forward | |
| user\_data | user data set when the signal handler was connected. | |
Flags: Action
### The `“move-handle”` signal
```
gboolean
user_function ([GtkPaned](gtkpaned#GtkPaned-struct) *widget,
[GtkScrollType](gtk4-standard-enumerations#GtkScrollType) scroll_type,
gpointer user_data)
```
The ::move-handle signal is a [keybinding signal](gtkshortcutaction#GtkSignalAction-struct) which gets emitted to move the handle when the user is using key bindings to move it.
#### Parameters
| | | |
| --- | --- | --- |
| widget | the object that received the signal | |
| scroll\_type | a [GtkScrollType](gtk4-standard-enumerations#GtkScrollType) | |
| user\_data | user data set when the signal handler was connected. | |
Flags: Action
### The `“toggle-handle-focus”` signal
```
gboolean
user_function ([GtkPaned](gtkpaned#GtkPaned-struct) *widget,
gpointer user_data)
```
The ::toggle-handle-focus is a [keybinding signal](gtkshortcutaction#GtkSignalAction-struct) which gets emitted to accept the current position of the handle and then move focus to the next widget in the focus chain.
The default binding is Tab.
#### Parameters
| | | |
| --- | --- | --- |
| widget | the object that received the signal | |
| user\_data | user data set when the signal handler was connected. | |
Flags: Action
gtk GtkGestureClick GtkGestureClick
===============
GtkGestureClick — Multipress gesture
Functions
---------
| | |
| --- | --- |
| [GtkGesture](gtkgesture#GtkGesture-struct) \* | [gtk\_gesture\_click\_new](gtkgestureclick#gtk-gesture-click-new) () |
Signals
-------
| | | |
| --- | --- | --- |
| void | [pressed](gtkgestureclick#GtkGestureClick-pressed) | Run Last |
| void | [released](gtkgestureclick#GtkGestureClick-released) | Run Last |
| void | [stopped](gtkgestureclick#GtkGestureClick-stopped) | Run Last |
| void | [unpaired-release](gtkgestureclick#GtkGestureClick-unpaired-release) | Run Last |
Types and Values
----------------
| | |
| --- | --- |
| | [GtkGestureClick](gtkgestureclick#GtkGestureClick-struct) |
Object Hierarchy
----------------
```
GObject
╰── [GtkEventController](gtkeventcontroller#GtkEventController-struct)
╰── [GtkGesture](gtkgesture#GtkGesture-struct)
╰── [GtkGestureSingle](gtkgesturesingle#GtkGestureSingle-struct)
╰── GtkGestureClick
```
Includes
--------
```
#include <gtk/gtk.h>
```
Description
-----------
[GtkGestureClick](gtkgestureclick#GtkGestureClick-struct) is a [GtkGesture](gtkgesture#GtkGesture-struct) implementation able to recognize multiple clicks on a nearby zone, which can be listened for through the [“pressed”](gtkgestureclick#GtkGestureClick-pressed) signal. Whenever time or distance between clicks exceed the GTK defaults, [“stopped”](gtkgestureclick#GtkGestureClick-stopped) is emitted, and the click counter is reset.
Functions
---------
### gtk\_gesture\_click\_new ()
```
[GtkGesture](gtkgesture#GtkGesture-struct) *
gtk_gesture_click_new (*`void`*);
```
Returns a newly created [GtkGesture](gtkgesture#GtkGesture-struct) that recognizes single and multiple presses.
#### Returns
a newly created [GtkGestureClick](gtkgestureclick#GtkGestureClick-struct)
Types and Values
----------------
### GtkGestureClick
```
typedef struct _GtkGestureClick GtkGestureClick;
```
Signal Details
--------------
### The `“pressed”` signal
```
void
user_function ([GtkGestureClick](gtkgestureclick#GtkGestureClick-struct) *gesture,
int n_press,
double x,
double y,
gpointer user_data)
```
This signal is emitted whenever a button or touch press happens.
#### Parameters
| | | |
| --- | --- | --- |
| gesture | the object which received the signal | |
| n\_press | how many touch/button presses happened with this one | |
| x | The X coordinate, in widget allocation coordinates | |
| y | The Y coordinate, in widget allocation coordinates | |
| user\_data | user data set when the signal handler was connected. | |
Flags: Run Last
### The `“released”` signal
```
void
user_function ([GtkGestureClick](gtkgestureclick#GtkGestureClick-struct) *gesture,
int n_press,
double x,
double y,
gpointer user_data)
```
This signal is emitted when a button or touch is released. *`n_press`* will report the number of press that is paired to this event, note that [“stopped”](gtkgestureclick#GtkGestureClick-stopped) may have been emitted between the press and its release, *`n_press`* will only start over at the next press.
#### Parameters
| | | |
| --- | --- | --- |
| gesture | the object which received the signal | |
| n\_press | number of press that is paired with this release | |
| x | The X coordinate, in widget allocation coordinates | |
| y | The Y coordinate, in widget allocation coordinates | |
| user\_data | user data set when the signal handler was connected. | |
Flags: Run Last
### The `“stopped”` signal
```
void
user_function ([GtkGestureClick](gtkgestureclick#GtkGestureClick-struct) *gesture,
gpointer user_data)
```
This signal is emitted whenever any time/distance threshold has been exceeded.
#### Parameters
| | | |
| --- | --- | --- |
| gesture | the object which received the signal | |
| user\_data | user data set when the signal handler was connected. | |
Flags: Run Last
### The `“unpaired-release”` signal
```
void
user_function ([GtkGestureClick](gtkgestureclick#GtkGestureClick-struct) *gesture,
double x,
double y,
guint button,
[GdkEventSequence](https://developer-old.gnome.org/gtk4/html/gdk4-Events.html#GdkEventSequence) *sequence,
gpointer user_data)
```
This signal is emitted whenever the gesture receives a release event that had no previous corresponding press. Due to implicit grabs, this can only happen on situations where input is grabbed elsewhere mid-press or the pressed widget voluntarily relinquishes its implicit grab.
#### Parameters
| | | |
| --- | --- | --- |
| gesture | the object which received the signal | |
| x | X coordinate of the event | |
| y | Y coordinate of the event | |
| button | Button being released | |
| sequence | Sequence being released | |
| user\_data | user data set when the signal handler was connected. | |
Flags: Run Last
| programming_docs |
gtk GtkSwitch GtkSwitch
=========
GtkSwitch — A “light switch” style toggle
Functions
---------
| | |
| --- | --- |
| [GtkWidget](gtkwidget#GtkWidget-struct) \* | [gtk\_switch\_new](gtkswitch#gtk-switch-new) () |
| void | [gtk\_switch\_set\_active](gtkswitch#gtk-switch-set-active) () |
| gboolean | [gtk\_switch\_get\_active](gtkswitch#gtk-switch-get-active) () |
| void | [gtk\_switch\_set\_state](gtkswitch#gtk-switch-set-state) () |
| gboolean | [gtk\_switch\_get\_state](gtkswitch#gtk-switch-get-state) () |
Properties
----------
| | | |
| --- | --- | --- |
| gboolean | [active](gtkswitch#GtkSwitch--active) | Read / Write |
| gboolean | [state](gtkswitch#GtkSwitch--state) | Read / Write |
Signals
-------
| | | |
| --- | --- | --- |
| void | [activate](gtkswitch#GtkSwitch-activate) | Action |
| gboolean | [state-set](gtkswitch#GtkSwitch-state-set) | Run Last |
Types and Values
----------------
| | |
| --- | --- |
| | [GtkSwitch](gtkswitch#GtkSwitch-struct) |
Object Hierarchy
----------------
```
GObject
╰── GInitiallyUnowned
╰── [GtkWidget](gtkwidget#GtkWidget-struct)
╰── GtkSwitch
```
Implemented Interfaces
----------------------
GtkSwitch implements [GtkAccessible](gtkaccessible#GtkAccessible-struct), [GtkBuildable](gtkbuildable#GtkBuildable-struct), [GtkConstraintTarget](gtkconstraint#GtkConstraintTarget-struct) and [GtkActionable](gtkactionable#GtkActionable-struct).
Includes
--------
```
#include <gtk/gtk.h>
```
Description
-----------
[GtkSwitch](gtkswitch#GtkSwitch-struct) is a widget that has two states: on or off. The user can control which state should be active by clicking the empty area, or by dragging the handle.
GtkSwitch can also handle situations where the underlying state changes with a delay. See [“state-set”](gtkswitch#GtkSwitch-state-set) for details.
### CSS nodes
```
switch
├── label
├── label
╰── slider
```
| GtkSwitch has four css nodes, the main node with the name switch and subnodes for the slider and the on and off labels. Neither of them is using any style classes.
### Accessibility
GtkSwitch uses the [GTK\_ACCESSIBLE\_ROLE\_SWITCH](gtkaccessible#GTK-ACCESSIBLE-ROLE-SWITCH:CAPS) role.
Functions
---------
### gtk\_switch\_new ()
```
[GtkWidget](gtkwidget#GtkWidget-struct) *
gtk_switch_new (*`void`*);
```
Creates a new [GtkSwitch](gtkswitch#GtkSwitch-struct) widget.
#### Returns
the newly created [GtkSwitch](gtkswitch#GtkSwitch-struct) instance
### gtk\_switch\_set\_active ()
```
void
gtk_switch_set_active (*`[GtkSwitch](gtkswitch#GtkSwitch-struct) *self`*,
*`gboolean is_active`*);
```
Changes the state of *`self`* to the desired one.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkSwitch](gtkswitch#GtkSwitch-struct) | |
| is\_active | `TRUE` if *`self`* should be active, and `FALSE` otherwise | |
### gtk\_switch\_get\_active ()
```
gboolean
gtk_switch_get_active (*`[GtkSwitch](gtkswitch#GtkSwitch-struct) *self`*);
```
Gets whether the [GtkSwitch](gtkswitch#GtkSwitch-struct) is in its “on” or “off” state.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkSwitch](gtkswitch#GtkSwitch-struct) | |
#### Returns
`TRUE` if the [GtkSwitch](gtkswitch#GtkSwitch-struct) is active, and `FALSE` otherwise
### gtk\_switch\_set\_state ()
```
void
gtk_switch_set_state (*`[GtkSwitch](gtkswitch#GtkSwitch-struct) *self`*,
*`gboolean state`*);
```
Sets the underlying state of the [GtkSwitch](gtkswitch#GtkSwitch-struct).
Normally, this is the same as [“active”](gtkswitch#GtkSwitch--active), unless the switch is set up for delayed state changes. This function is typically called from a [“state-set”](gtkswitch#GtkSwitch-state-set) signal handler.
See [“state-set”](gtkswitch#GtkSwitch-state-set) for details.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkSwitch](gtkswitch#GtkSwitch-struct) | |
| state | the new state | |
### gtk\_switch\_get\_state ()
```
gboolean
gtk_switch_get_state (*`[GtkSwitch](gtkswitch#GtkSwitch-struct) *self`*);
```
Gets the underlying state of the [GtkSwitch](gtkswitch#GtkSwitch-struct).
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkSwitch](gtkswitch#GtkSwitch-struct) | |
#### Returns
the underlying state
Types and Values
----------------
### GtkSwitch
```
typedef struct _GtkSwitch GtkSwitch;
```
The [GtkSwitch](gtkswitch#GtkSwitch-struct) contains private data and it should only be accessed using the provided API.
Property Details
----------------
### The `“active”` property
```
“active” gboolean
```
Whether the [GtkSwitch](gtkswitch#GtkSwitch-struct) widget is in its on or off state.
Owner: GtkSwitch
Flags: Read / Write
Default value: FALSE
### The `“state”` property
```
“state” gboolean
```
The backend state that is controlled by the switch. See [“state-set”](gtkswitch#GtkSwitch-state-set) for details.
Owner: GtkSwitch
Flags: Read / Write
Default value: FALSE
Signal Details
--------------
### The `“activate”` signal
```
void
user_function ([GtkSwitch](gtkswitch#GtkSwitch-struct) *widget,
gpointer user_data)
```
The ::activate signal on GtkSwitch is an action signal and emitting it causes the switch to animate. Applications should never connect to this signal, but use the notify::active signal.
#### Parameters
| | | |
| --- | --- | --- |
| widget | the object which received the signal. | |
| user\_data | user data set when the signal handler was connected. | |
Flags: Action
### The `“state-set”` signal
```
gboolean
user_function ([GtkSwitch](gtkswitch#GtkSwitch-struct) *widget,
gboolean state,
gpointer user_data)
```
The ::state-set signal on GtkSwitch is emitted to change the underlying state. It is emitted when the user changes the switch position. The default handler keeps the state in sync with the [“active”](gtkswitch#GtkSwitch--active) property.
To implement delayed state change, applications can connect to this signal, initiate the change of the underlying state, and call [`gtk_switch_set_state()`](gtkswitch#gtk-switch-set-state) when the underlying state change is complete. The signal handler should return `TRUE` to prevent the default handler from running.
Visually, the underlying state is represented by the trough color of the switch, while the [“active”](gtkswitch#GtkSwitch--active) property is represented by the position of the switch.
#### Parameters
| | | |
| --- | --- | --- |
| widget | the object on which the signal was emitted | |
| state | the new state of the switch | |
| user\_data | user data set when the signal handler was connected. | |
#### Returns
`TRUE` to stop the signal emission
Flags: Run Last
See Also
--------
[GtkToggleButton](gtktogglebutton#GtkToggleButton-struct)
gtk Building user interfaces Building user interfaces
========================
When constructing a more complicated user interface, with dozens or hundreds of widgets, doing all the setup work in C code is cumbersome, and making changes becomes next to impossible.
Thankfully, GTK supports the separation of user interface layout from your business logic, by using UI descriptions in an XML format that can be parsed by the GtkBuilder class.</para>
### Packing buttons with GtkBuilder
Create a new file with the following content named `example-3.c`.
```
#include <gtk/gtk.h>
#include <glib/gstdio.h>
static void
print_hello (GtkWidget *widget,
gpointer data)
{
g_print ("Hello World\n");
}
static void
quit_cb (GtkWindow *window)
{
gtk_window_close (window);
}
static void
activate (GtkApplication *app,
gpointer user_data)
{
/* Construct a GtkBuilder instance and load our UI description */
GtkBuilder *builder = [`gtk_builder_new()`](gtkbuilder#gtk-builder-new);
gtk_builder_add_from_file (builder, "builder.ui", NULL);
/* Connect signal handlers to the constructed widgets. */
GObject *window = gtk_builder_get_object (builder, "window");
gtk_window_set_application (GTK_WINDOW (window), app);
GObject *button = gtk_builder_get_object (builder, "button1");
g_signal_connect (button, "clicked", G_CALLBACK (print_hello), NULL);
button = gtk_builder_get_object (builder, "button2");
g_signal_connect (button, "clicked", G_CALLBACK (print_hello), NULL);
button = gtk_builder_get_object (builder, "quit");
g_signal_connect_swapped (button, "clicked", G_CALLBACK (quit_cb), window);
gtk_widget_show (GTK_WIDGET (window));
/* We do not need the builder any more */
g_object_unref (builder);
}
int
main (int argc,
char *argv[])
{
#ifdef GTK_SRCDIR
g_chdir (GTK_SRCDIR);
#endif
GtkApplication *app = gtk_application_new ("org.gtk.example", G_APPLICATION_FLAGS_NONE);
g_signal_connect (app, "activate", G_CALLBACK (activate), NULL);
int status = g_application_run (G_APPLICATION (app), argc, argv);
g_object_unref (app);
return status;
}
```
Create a new file with the following content named `builder.ui`.
```
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<object id="window" class="GtkWindow">
<property name="title">Grid</property>
<child>
<object id="grid" class="GtkGrid">
<child>
<object id="button1" class="GtkButton">
<property name="label">Button 1</property>
<layout>
<property name="column">0</property>
<property name="row">0</property>
</layout>
</object>
</child>
<child>
<object id="button2" class="GtkButton">
<property name="label">Button 2</property>
<layout>
<property name="column">1</property>
<property name="row">0</property>
</layout>
</object>
</child>
<child>
<object id="quit" class="GtkButton">
<property name="label">Quit</property>
<layout>
<property name="column">0</property>
<property name="row">1</property>
<property name="column-span">2</property>
</layout>
</object>
</child>
</object>
</child>
</object>
</interface>
```
You can compile the program above with GCC using:
```
gcc `pkg-config --cflags gtk4` -o example-3 example-3.c `pkg-config --libs gtk4`
```
Note that GtkBuilder can also be used to construct objects that are not widgets, such as tree models, adjustments, etc. That is the reason the method we use here is called [`gtk_builder_get_object()`](gtkbuilder#gtk-builder-get-object) and returns a GObject\* instead of a GtkWidget\*.
Normally, you would pass a full path to [`gtk_builder_add_from_file()`](gtkbuilder#gtk-builder-add-from-file) to make the execution of your program independent of the current directory. A common location to install UI descriptions and similar data is `/usr/share/appname`.
It is also possible to embed the UI description in the source code as a string and use [`gtk_builder_add_from_string()`](gtkbuilder#gtk-builder-add-from-string) to load it. But keeping the UI description in a separate file has several advantages: It is then possible to make minor adjustments to the UI without recompiling your program, and, more importantly, graphical UI editors such as [glade](http://glade.gnome.org) can load the file and allow you to create and modify your UI by point-and-click.
gtk GtkWindowControls GtkWindowControls
=================
GtkWindowControls — A widget displaying window buttons
Functions
---------
| | |
| --- | --- |
| [GtkWidget](gtkwidget#GtkWidget-struct) \* | [gtk\_window\_controls\_new](gtkwindowcontrols#gtk-window-controls-new) () |
| [GtkPackType](gtk4-standard-enumerations#GtkPackType) | [gtk\_window\_controls\_get\_side](gtkwindowcontrols#gtk-window-controls-get-side) () |
| void | [gtk\_window\_controls\_set\_side](gtkwindowcontrols#gtk-window-controls-set-side) () |
| const char \* | [gtk\_window\_controls\_get\_decoration\_layout](gtkwindowcontrols#gtk-window-controls-get-decoration-layout) () |
| void | [gtk\_window\_controls\_set\_decoration\_layout](gtkwindowcontrols#gtk-window-controls-set-decoration-layout) () |
| gboolean | [gtk\_window\_controls\_get\_empty](gtkwindowcontrols#gtk-window-controls-get-empty) () |
Properties
----------
| | | |
| --- | --- | --- |
| char \* | [decoration-layout](gtkwindowcontrols#GtkWindowControls--decoration-layout) | Read / Write |
| gboolean | [empty](gtkwindowcontrols#GtkWindowControls--empty) | Read |
| [GtkPackType](gtk4-standard-enumerations#GtkPackType) | [side](gtkwindowcontrols#GtkWindowControls--side) | Read / Write |
Types and Values
----------------
| | |
| --- | --- |
| | [GtkWindowControls](gtkwindowcontrols#GtkWindowControls-struct) |
Object Hierarchy
----------------
```
GObject
╰── GInitiallyUnowned
╰── [GtkWidget](gtkwidget#GtkWidget-struct)
╰── GtkWindowControls
```
Implemented Interfaces
----------------------
GtkWindowControls implements [GtkAccessible](gtkaccessible#GtkAccessible-struct), [GtkBuildable](gtkbuildable#GtkBuildable-struct) and [GtkConstraintTarget](gtkconstraint#GtkConstraintTarget-struct).
Includes
--------
```
#include <gtk/gtk.h>
```
Description
-----------
GtkWindowControls shows window frame controls, such as minimize, maximize and close buttons, and the window icon.
[GtkWindowControls](gtkwindowcontrols#GtkWindowControls-struct) only displays start or end side of the controls (see [“side”](gtkwindowcontrols#GtkWindowControls--side)), so it's intended to be always used in pair with another [GtkWindowControls](gtkwindowcontrols#GtkWindowControls-struct) using the opposite side, for example:
### CSS nodes
```
<object class="GtkBox">
<child>
<object class="GtkWindowControls">
<property name="side">start</property>
</object>
</child>
...
<child>
<object class="GtkWindowControls">
<property name="side">end</property>
</object>
</child>
</object>
```
| A [GtkWindowControls](gtkwindowcontrols#GtkWindowControls-struct)' CSS node is called windowcontrols. It contains subnodes corresponding to each title button. Which of the title buttons exist and where they are placed exactly depends on the desktop environment and [“decoration-layout”](gtkwindowcontrols#GtkWindowControls--decoration-layout) value.
When [“empty”](gtkwindowcontrols#GtkWindowControls--empty) is `TRUE`, it gets the .empty style class.
### Accessibility
GtkWindowHandle uses the [`GTK_ACCESSIBLE_ROLE_GROUP`](gtkaccessible#GTK-ACCESSIBLE-ROLE-GROUP:CAPS) role.
Functions
---------
### gtk\_window\_controls\_new ()
```
[GtkWidget](gtkwidget#GtkWidget-struct) *
gtk_window_controls_new (*`[GtkPackType](gtk4-standard-enumerations#GtkPackType) side`*);
```
Creates a new [GtkWindowControls](gtkwindowcontrols#GtkWindowControls-struct).
#### Parameters
| | | |
| --- | --- | --- |
| side | the side | |
#### Returns
a new [GtkWindowControls](gtkwindowcontrols#GtkWindowControls-struct).
### gtk\_window\_controls\_get\_side ()
```
[GtkPackType](gtk4-standard-enumerations#GtkPackType)
gtk_window_controls_get_side (*`[GtkWindowControls](gtkwindowcontrols#GtkWindowControls-struct) *self`*);
```
Gets the side set with [`gtk_window_controls_set_side()`](gtkwindowcontrols#gtk-window-controls-set-side).
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkWindowControls](gtkwindowcontrols#GtkWindowControls-struct) | |
#### Returns
the side
### gtk\_window\_controls\_set\_side ()
```
void
gtk_window_controls_set_side (*`[GtkWindowControls](gtkwindowcontrols#GtkWindowControls-struct) *self`*,
*`[GtkPackType](gtk4-standard-enumerations#GtkPackType) side`*);
```
Sets the side for *`self`* , determining which part of decoration layout it uses.
See [`gtk_window_controls_set_decoration_layout()`](gtkwindowcontrols#gtk-window-controls-set-decoration-layout)
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkWindowControls](gtkwindowcontrols#GtkWindowControls-struct) | |
| side | a side | |
### gtk\_window\_controls\_get\_decoration\_layout ()
```
const char *
gtk_window_controls_get_decoration_layout
(*`[GtkWindowControls](gtkwindowcontrols#GtkWindowControls-struct) *self`*);
```
Gets the decoration layout set with [`gtk_window_controls_set_decoration_layout()`](gtkwindowcontrols#gtk-window-controls-set-decoration-layout).
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkWindowControls](gtkwindowcontrols#GtkWindowControls-struct) | |
#### Returns
the decoration layout or `NULL` if it is unset.
[nullable]
### gtk\_window\_controls\_set\_decoration\_layout ()
```
void
gtk_window_controls_set_decoration_layout
(*`[GtkWindowControls](gtkwindowcontrols#GtkWindowControls-struct) *self`*,
*`const char *layout`*);
```
Sets the decoration layout for the title buttons, overriding the [“gtk-decoration-layout”](gtksettings#GtkSettings--gtk-decoration-layout) setting.
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 and icon (the window icon).
For example, “icon:minimize,maximize,close” specifies a icon on the left, and minimize, maximize and close buttons on the right.
If [“side”](gtkwindowcontrols#GtkWindowControls--side) value is *`GTK_PACK_START`* , *`self`* will display the part before the colon, otherwise after that.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkWindowControls](gtkwindowcontrols#GtkWindowControls-struct) | |
| layout | a decoration layout, or `NULL` to unset the layout. | [nullable] |
### gtk\_window\_controls\_get\_empty ()
```
gboolean
gtk_window_controls_get_empty (*`[GtkWindowControls](gtkwindowcontrols#GtkWindowControls-struct) *self`*);
```
Gets whether the widget has any window buttons.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkWindowControls](gtkwindowcontrols#GtkWindowControls-struct) | |
#### Returns
`TRUE` if the widget has window buttons, otherwise `FALSE`
Types and Values
----------------
### GtkWindowControls
```
typedef struct _GtkWindowControls GtkWindowControls;
```
Property Details
----------------
### The `“decoration-layout”` property
```
“decoration-layout” char *
```
The decoration layout for window buttons. If this property is not set, the [“gtk-decoration-layout”](gtksettings#GtkSettings--gtk-decoration-layout) setting is used.
See [`gtk_window_controls_set_decoration_layout()`](gtkwindowcontrols#gtk-window-controls-set-decoration-layout) for information about the format of this string.
Owner: GtkWindowControls
Flags: Read / Write
Default value: NULL
### The `“empty”` property
```
“empty” gboolean
```
Whether the widget has any window buttons.
Owner: GtkWindowControls
Flags: Read
Default value: TRUE
### The `“side”` property
```
“side” [GtkPackType](gtk4-standard-enumerations#GtkPackType)
```
Whether the widget shows start or end side of the decoration layout.
See [`gtk_window_controls_set_decoration_layout()`](gtkwindowcontrols#gtk-window-controls-set-decoration-layout).
Owner: GtkWindowControls
Flags: Read / Write
Default value: GTK\_PACK\_START
See Also
--------
[GtkHeaderBar](gtkheaderbar#GtkHeaderBar-struct)
| programming_docs |
gtk GtkViewport GtkViewport
===========
GtkViewport — An adapter which makes widgets scrollable
Functions
---------
| | |
| --- | --- |
| [GtkWidget](gtkwidget#GtkWidget-struct) \* | [gtk\_viewport\_new](gtkviewport#gtk-viewport-new) () |
| void | [gtk\_viewport\_set\_scroll\_to\_focus](gtkviewport#gtk-viewport-set-scroll-to-focus) () |
| gboolean | [gtk\_viewport\_get\_scroll\_to\_focus](gtkviewport#gtk-viewport-get-scroll-to-focus) () |
| void | [gtk\_viewport\_set\_child](gtkviewport#gtk-viewport-set-child) () |
| [GtkWidget](gtkwidget#GtkWidget-struct) \* | [gtk\_viewport\_get\_child](gtkviewport#gtk-viewport-get-child) () |
Properties
----------
| | | |
| --- | --- | --- |
| [GtkWidget](gtkwidget#GtkWidget-struct) \* | [child](gtkviewport#GtkViewport--child) | Read / Write |
| gboolean | [scroll-to-focus](gtkviewport#GtkViewport--scroll-to-focus) | Read / Write |
Types and Values
----------------
| | |
| --- | --- |
| | [GtkViewport](gtkviewport#GtkViewport-struct) |
Object Hierarchy
----------------
```
GObject
╰── GInitiallyUnowned
╰── [GtkWidget](gtkwidget#GtkWidget-struct)
╰── GtkViewport
```
Implemented Interfaces
----------------------
GtkViewport implements [GtkAccessible](gtkaccessible#GtkAccessible-struct), [GtkBuildable](gtkbuildable#GtkBuildable-struct), [GtkConstraintTarget](gtkconstraint#GtkConstraintTarget-struct) and [GtkScrollable](gtkscrollable#GtkScrollable-struct).
Includes
--------
```
#include <gtk/gtk.h>
```
Description
-----------
The [GtkViewport](gtkviewport#GtkViewport-struct) widget acts as an adaptor class, implementing scrollability for child widgets that lack their own scrolling capabilities. Use GtkViewport to scroll child widgets such as [GtkGrid](gtkgrid#GtkGrid-struct), [GtkBox](gtkbox#GtkBox-struct), and so on.
The GtkViewport will start scrolling content only if allocated less than the child widget’s minimum size in a given orientation.
### CSS nodes
GtkViewport has a single CSS node with name `viewport`.
### Accessibility
GtkViewport uses the [`GTK_ACCESSIBLE_ROLE_GROUP`](gtkaccessible#GTK-ACCESSIBLE-ROLE-GROUP:CAPS) role.
Functions
---------
### gtk\_viewport\_new ()
```
[GtkWidget](gtkwidget#GtkWidget-struct) *
gtk_viewport_new (*`[GtkAdjustment](gtkadjustment#GtkAdjustment-struct) *hadjustment`*,
*`[GtkAdjustment](gtkadjustment#GtkAdjustment-struct) *vadjustment`*);
```
Creates a new [GtkViewport](gtkviewport#GtkViewport-struct) with the given adjustments, or with default adjustments if none are given.
#### Parameters
| | | |
| --- | --- | --- |
| hadjustment | horizontal adjustment. | [allow-none] |
| vadjustment | vertical adjustment. | [allow-none] |
#### Returns
a new [GtkViewport](gtkviewport#GtkViewport-struct)
### gtk\_viewport\_set\_scroll\_to\_focus ()
```
void
gtk_viewport_set_scroll_to_focus (*`[GtkViewport](gtkviewport#GtkViewport-struct) *viewport`*,
*`gboolean scroll_to_focus`*);
```
Sets whether the viewport should automatically scroll to keep the focused child in view.
#### Parameters
| | | |
| --- | --- | --- |
| viewport | a [GtkViewport](gtkviewport#GtkViewport-struct) | |
| scroll\_to\_focus | whether to keep the focus widget scrolled to view | |
### gtk\_viewport\_get\_scroll\_to\_focus ()
```
gboolean
gtk_viewport_get_scroll_to_focus (*`[GtkViewport](gtkviewport#GtkViewport-struct) *viewport`*);
```
Gets whether the viewport is scrolling to keep the focused child in view. See [`gtk_viewport_set_scroll_to_focus()`](gtkviewport#gtk-viewport-set-scroll-to-focus).
#### Parameters
| | | |
| --- | --- | --- |
| viewport | a [GtkViewport](gtkviewport#GtkViewport-struct) | |
#### Returns
`TRUE` if the viewport keeps the focus child scrolled to view
### gtk\_viewport\_set\_child ()
```
void
gtk_viewport_set_child (*`[GtkViewport](gtkviewport#GtkViewport-struct) *viewport`*,
*`[GtkWidget](gtkwidget#GtkWidget-struct) *child`*);
```
Sets the child widget of *`viewport`* .
#### Parameters
| | | |
| --- | --- | --- |
| viewport | a [GtkViewport](gtkviewport#GtkViewport-struct) | |
| child | the child widget. | [allow-none] |
### gtk\_viewport\_get\_child ()
```
[GtkWidget](gtkwidget#GtkWidget-struct) *
gtk_viewport_get_child (*`[GtkViewport](gtkviewport#GtkViewport-struct) *viewport`*);
```
Gets the child widget of *`viewport`* .
#### Parameters
| | | |
| --- | --- | --- |
| viewport | a [GtkViewport](gtkviewport#GtkViewport-struct) | |
#### Returns
the child widget of *`viewport`* .
[nullable][transfer none]
Types and Values
----------------
### GtkViewport
```
typedef struct _GtkViewport GtkViewport;
```
Property Details
----------------
### The `“child”` property
```
“child” [GtkWidget](gtkwidget#GtkWidget-struct) *
```
The child widget.
Owner: GtkViewport
Flags: Read / Write
### The `“scroll-to-focus”` property
```
“scroll-to-focus” gboolean
```
Whether to scroll when the focus changes.
Owner: GtkViewport
Flags: Read / Write
Default value: FALSE
See Also
--------
[GtkScrolledWindow](gtkscrolledwindow#GtkScrolledWindow-struct), [GtkAdjustment](gtkadjustment#GtkAdjustment-struct)
gtk GtkFilter GtkFilter
=========
GtkFilter — Filtering items
Functions
---------
| | |
| --- | --- |
| gboolean | [gtk\_filter\_match](gtkfilter#gtk-filter-match) () |
| [GtkFilterMatch](gtkfilter#GtkFilterMatch) | [gtk\_filter\_get\_strictness](gtkfilter#gtk-filter-get-strictness) () |
| void | [gtk\_filter\_changed](gtkfilter#gtk-filter-changed) () |
Signals
-------
| | | |
| --- | --- | --- |
| void | [changed](gtkfilter#GtkFilter-changed) | Run Last |
Types and Values
----------------
| | |
| --- | --- |
| | [GtkFilter](gtkfilter#GtkFilter-struct) |
| enum | [GtkFilterMatch](gtkfilter#GtkFilterMatch) |
| enum | [GtkFilterChange](gtkfilter#GtkFilterChange) |
Object Hierarchy
----------------
```
GObject
╰── GtkFilter
├── [GtkMultiFilter](gtkmultifilter#GtkMultiFilter-struct)
├── [GtkBoolFilter](https://developer-old.gnome.org/usr/share/gtk-doc/html/gtk4/gtk4-GtkBoolFilter.html#GtkBoolFilter)
├── [GtkCustomFilter](gtkcustomfilter#GtkCustomFilter-struct)
├── [GtkFileFilter](gtkfilefilter#GtkFileFilter-struct)
╰── [GtkStringFilter](gtkstringfilter#GtkStringFilter-struct)
```
Includes
--------
```
#include <gtk/gtk.h>
```
Description
-----------
A [GtkFilter](gtkfilter#GtkFilter-struct) object describes the filtering to be performed by a [GtkFilterListModel](gtkfilterlistmodel#GtkFilterListModel-struct).
The model will use the filter to determine if it should include items or not by calling [`gtk_filter_match()`](gtkfilter#gtk-filter-match) for each item and only keeping the ones that the function returns `TRUE` for.
Filters may change what items they match through their lifetime. In that case, they will emit the [“changed”](gtkfilter#GtkFilter-changed) signal to notify that previous filter results are no longer valid and that items should be checked again via [`gtk_filter_match()`](gtkfilter#gtk-filter-match).
GTK provides various pre-made filter implementations for common filtering operations. These filters often include properties that can be linked to various widgets to easily allow searches.
However, in particular for large lists or complex search methods, it is also possible to subclass [GtkFilter](gtkfilter#GtkFilter-struct) and provide one's own filter.
Functions
---------
### gtk\_filter\_match ()
```
gboolean
gtk_filter_match (*`[GtkFilter](gtkfilter#GtkFilter-struct) *self`*,
*`gpointer item`*);
```
Checks if the given *`item`* is matched by the filter or not.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkFilter](gtkfilter#GtkFilter-struct) | |
| item | The item to check. | [type GObject][transfer none] |
#### Returns
`TRUE` if the filter matches the item and a filter model should keep it, `FALSE` if not.
### gtk\_filter\_get\_strictness ()
```
[GtkFilterMatch](gtkfilter#GtkFilterMatch)
gtk_filter_get_strictness (*`[GtkFilter](gtkfilter#GtkFilter-struct) *self`*);
```
Gets the known strictness of *`filters`* . If the strictness is not known, [`GTK_FILTER_MATCH_SOME`](gtkfilter#GTK-FILTER-MATCH-SOME:CAPS) is returned.
This value may change after emission of the [“changed”](gtkfilter#GtkFilter-changed) signal.
This function is meant purely for optimization purposes, filters can choose to omit implementing it, but [GtkFilterListModel](gtkfilterlistmodel#GtkFilterListModel-struct) uses it.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkFilter](gtkfilter#GtkFilter-struct) | |
#### Returns
the strictness of *`self`*
### gtk\_filter\_changed ()
```
void
gtk_filter_changed (*`[GtkFilter](gtkfilter#GtkFilter-struct) *self`*,
*`[GtkFilterChange](gtkfilter#GtkFilterChange) change`*);
```
Emits the [“changed”](gtkfilter#GtkFilter-changed) signal to notify all users of the filter that the filter changed. Users of the filter should then check items again via [`gtk_filter_match()`](gtkfilter#gtk-filter-match).
Depending on the *`change`* parameter, not all items need to be changed, but only some. Refer to the [GtkFilterChange](gtkfilter#GtkFilterChange) documentation for details.
This function is intended for implementors of [GtkFilter](gtkfilter#GtkFilter-struct) subclasses and should not be called from other functions.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkFilter](gtkfilter#GtkFilter-struct) | |
| change | How the filter changed | |
Types and Values
----------------
### GtkFilter
```
typedef struct _GtkFilter GtkFilter;
```
The object describing a filter.
### enum GtkFilterMatch
Describes the known strictness of a filter.
Note that for filters where the strictness is not known, [`GTK_FILTER_MATCH_SOME`](gtkfilter#GTK-FILTER-MATCH-SOME:CAPS) is always an acceptable value, even if a filter does match all or no items.
#### Members
| | | |
| --- | --- | --- |
| GTK\_FILTER\_MATCH\_SOME | The filter matches some items, [`gtk_filter_match()`](gtkfilter#gtk-filter-match) may return `TRUE` or `FALSE` | |
| GTK\_FILTER\_MATCH\_NONE | The filter does not match any item, [`gtk_filter_match()`](gtkfilter#gtk-filter-match) will always return `FALSE`. | |
| GTK\_FILTER\_MATCH\_ALL | The filter matches all items, [`gtk_filter_match()`](gtkfilter#gtk-filter-match) will alays return `TRUE`. | |
### enum GtkFilterChange
Describes changes in a filter in more detail and allows objects using the filter to optimize refiltering items.
If you are writing an implementation and are not sure which value to pass, [`GTK_FILTER_CHANGE_DIFFERENT`](gtkfilter#GTK-FILTER-CHANGE-DIFFERENT:CAPS) is always a correct choice.
#### Members
| | | |
| --- | --- | --- |
| GTK\_FILTER\_CHANGE\_DIFFERENT | The filter change cannot be described with any of the other enumeration values. | |
| GTK\_FILTER\_CHANGE\_LESS\_STRICT | The filter is less strict than it was before: All items that it used to return `TRUE` for still return `TRUE`, others now may, too. | |
| GTK\_FILTER\_CHANGE\_MORE\_STRICT | The filter is more strict than it was before: All items that it used to return `FALSE` for still return `FALSE`, others now may, too. | |
Signal Details
--------------
### The `“changed”` signal
```
void
user_function ([GtkFilter](gtkfilter#GtkFilter-struct) *self,
[GtkFilterChange](gtkfilter#GtkFilterChange) change,
gpointer user_data)
```
This signal is emitted whenever the filter changed. Users of the filter should then check items again via [`gtk_filter_match()`](gtkfilter#gtk-filter-match).
[GtkFilterListModel](gtkfilterlistmodel#GtkFilterListModel-struct) handles this signal automatically.
Depending on the *`change`* parameter, not all items need to be changed, but only some. Refer to the [GtkFilterChange](gtkfilter#GtkFilterChange) documentation for details.
#### Parameters
| | | |
| --- | --- | --- |
| self | The [GtkFilter](gtkfilter#GtkFilter-struct) | |
| change | how the filter changed | |
| user\_data | user data set when the signal handler was connected. | |
Flags: Run Last
See Also
--------
[GtkFilterListModel](gtkfilterlistmodel#GtkFilterListModel-struct)
gtk GtkSignalListItemFactory GtkSignalListItemFactory
========================
GtkSignalListItemFactory — A listitem factory providing signals
Functions
---------
| | |
| --- | --- |
| [GtkListItemFactory](gtklistitemfactory#GtkListItemFactory-struct) \* | [gtk\_signal\_list\_item\_factory\_new](gtksignallistitemfactory#gtk-signal-list-item-factory-new) () |
Signals
-------
| | | |
| --- | --- | --- |
| void | [bind](gtksignallistitemfactory#GtkSignalListItemFactory-bind) | Run First |
| void | [setup](gtksignallistitemfactory#GtkSignalListItemFactory-setup) | Run First |
| void | [teardown](gtksignallistitemfactory#GtkSignalListItemFactory-teardown) | Run First |
| void | [unbind](gtksignallistitemfactory#GtkSignalListItemFactory-unbind) | Run First |
Types and Values
----------------
| | |
| --- | --- |
| | [GtkSignalListItemFactory](gtksignallistitemfactory#GtkSignalListItemFactory-struct) |
Object Hierarchy
----------------
```
GObject
╰── [GtkListItemFactory](gtklistitemfactory#GtkListItemFactory-struct)
╰── GtkSignalListItemFactory
```
Includes
--------
```
#include <gtk/gtk.h>
```
Description
-----------
[GtkSignalListItemFactory](gtksignallistitemfactory#GtkSignalListItemFactory-struct) is a [GtkListItemFactory](gtklistitemfactory#GtkListItemFactory-struct) that provides signals that user code can connect to to manage listitems. Signals are emitted for every listitem in the same order:
1. [“setup”](gtksignallistitemfactory#GtkSignalListItemFactory-setup) is emitted to set up permanent things on the listitem. This usually means constructing the widgets used in the row and adding them to the listitem.
2. [“bind”](gtksignallistitemfactory#GtkSignalListItemFactory-bind) is emitted to bind the item passed via [“item”](gtklistitem#GtkListItem--item) to the widgets that have been created in step 1 or to add item-specific widgets. Signals are connected to listen to changes - both to changes in the item to update the widgets or to changes in the widgets to update the item. After this signal has been called, the listitem may be shown in a list widget.
3. [“unbind”](gtksignallistitemfactory#GtkSignalListItemFactory-unbind) is emitted to undo everything done in step 2. Usually this means disconnecting signal handlers. Once this signal has been called, the listitem will no longer be used in a list widget.
4. [“bind”](gtksignallistitemfactory#GtkSignalListItemFactory-bind) and [“unbind”](gtksignallistitemfactory#GtkSignalListItemFactory-unbind) may be emitted multiple times again to bind the listitem for use with new items. By reusing listitems, potentially costly setup can be avoided. However, it means code needs to make sure to properly clean up the listitem in step 3 so that no information from the previous use leaks into the next use.
1. [“teardown”](gtksignallistitemfactory#GtkSignalListItemFactory-teardown) is emitted to allow undoing the
effects of [“setup”](gtksignallistitemfactory#GtkSignalListItemFactory-setup). After this signal was emitted on a listitem, the listitem will be destroyed and not be used again.
Note that during the signal emissions, changing properties on the [GtkListItems](gtklistitem#GtkListItem-struct) passed will not trigger notify signals as the listitem's notifications are frozen. See `g_object_freeze_notify()` for details.
For tracking changes in other properties in the [GtkListItem](gtklistitem#GtkListItem-struct), the “notify” signal is recommended. The signal can be connected in the [“setup”](gtksignallistitemfactory#GtkSignalListItemFactory-setup) signal and removed again during [“teardown”](gtksignallistitemfactory#GtkSignalListItemFactory-teardown).
Functions
---------
### gtk\_signal\_list\_item\_factory\_new ()
```
[GtkListItemFactory](gtklistitemfactory#GtkListItemFactory-struct) *
gtk_signal_list_item_factory_new (*`void`*);
```
Creates a new [GtkSignalListItemFactory](gtksignallistitemfactory#GtkSignalListItemFactory-struct). You need to connect signal handlers before you use it.
#### Returns
a new [GtkSignalListItemFactory](gtksignallistitemfactory#GtkSignalListItemFactory-struct)
Types and Values
----------------
### GtkSignalListItemFactory
```
typedef struct _GtkSignalListItemFactory GtkSignalListItemFactory;
```
The object for the [GtkSignalListItemFactory](gtksignallistitemfactory#GtkSignalListItemFactory-struct).
Signal Details
--------------
### The `“bind”` signal
```
void
user_function ([GtkSignalListItemFactory](gtksignallistitemfactory#GtkSignalListItemFactory-struct) *self,
[GtkListItem](gtklistitem#GtkListItem-struct) *listitem,
gpointer user_data)
```
The ::bind signal is emitted when a new [“item”](gtklistitem#GtkListItem--item) has been set on the *`listitem`* and should be bound for use.
After this signal was emitted, the listitem might be shown in a [GtkListView](gtklistview#GtkListView-struct) or other list widget.
The [“unbind”](gtksignallistitemfactory#GtkSignalListItemFactory-unbind) signal is the opposite of this signal and can be used to undo everything done in this signal.
#### Parameters
| | | |
| --- | --- | --- |
| self | The [GtkSignalListItemFactory](gtksignallistitemfactory#GtkSignalListItemFactory-struct) | |
| listitem | The [GtkListItem](gtklistitem#GtkListItem-struct) to bind | |
| user\_data | user data set when the signal handler was connected. | |
Flags: Run First
### The `“setup”` signal
```
void
user_function ([GtkSignalListItemFactory](gtksignallistitemfactory#GtkSignalListItemFactory-struct) *self,
[GtkListItem](gtklistitem#GtkListItem-struct) *listitem,
gpointer user_data)
```
The ::setup signal is emitted when a new listitem has been created and needs to be setup for use. It is the first signal emitted for every listitem.
The [“teardown”](gtksignallistitemfactory#GtkSignalListItemFactory-teardown) signal is the opposite of this signal and can be used to undo everything done in this signal.
#### Parameters
| | | |
| --- | --- | --- |
| self | The [GtkSignalListItemFactory](gtksignallistitemfactory#GtkSignalListItemFactory-struct) | |
| listitem | The [GtkListItem](gtklistitem#GtkListItem-struct) to set up | |
| user\_data | user data set when the signal handler was connected. | |
Flags: Run First
### The `“teardown”` signal
```
void
user_function ([GtkSignalListItemFactory](gtksignallistitemfactory#GtkSignalListItemFactory-struct) *self,
[GtkListItem](gtklistitem#GtkListItem-struct) *listitem,
gpointer user_data)
```
The ::teardown signal is emitted when a listitem is about to be destroyed. It is the last signal ever emitted for this *`listitem`* .
This signal is the opposite of the [“setup”](gtksignallistitemfactory#GtkSignalListItemFactory-setup) signal and should be used to undo everything done in that signal.
#### Parameters
| | | |
| --- | --- | --- |
| self | The [GtkSignalListItemFactory](gtksignallistitemfactory#GtkSignalListItemFactory-struct) | |
| listitem | The [GtkListItem](gtklistitem#GtkListItem-struct) to teardown | |
| user\_data | user data set when the signal handler was connected. | |
Flags: Run First
### The `“unbind”` signal
```
void
user_function ([GtkSignalListItemFactory](gtksignallistitemfactory#GtkSignalListItemFactory-struct) *self,
[GtkListItem](gtklistitem#GtkListItem-struct) *listitem,
gpointer user_data)
```
The ::unbind signal is emitted when a listitem has been removed from use in a list widget and its new [“item”](gtklistitem#GtkListItem--item) is about to be unset.
This signal is the opposite of the [“bind”](gtksignallistitemfactory#GtkSignalListItemFactory-bind) signal and should be used to undo everything done in that signal.
#### Parameters
| | | |
| --- | --- | --- |
| self | The [GtkSignalListItemFactory](gtksignallistitemfactory#GtkSignalListItemFactory-struct) | |
| listitem | The [GtkListItem](gtklistitem#GtkListItem-struct) to unbind | |
| user\_data | user data set when the signal handler was connected. | |
Flags: Run First
See Also
--------
[GtkListItemFactory](gtklistitemfactory#GtkListItemFactory-struct)
| programming_docs |
gtk GtkShortcutsShortcut GtkShortcutsShortcut
====================
GtkShortcutsShortcut — Represents a keyboard shortcut in a GtkShortcutsWindow
Properties
----------
| | | |
| --- | --- | --- |
| [GtkSizeGroup](gtksizegroup#GtkSizeGroup-struct) \* | [accel-size-group](gtkshortcutsshortcut#GtkShortcutsShortcut--accel-size-group) | Write |
| char \* | [accelerator](gtkshortcutsshortcut#GtkShortcutsShortcut--accelerator) | Read / Write |
| char \* | [action-name](gtkshortcutsshortcut#GtkShortcutsShortcut--action-name) | Read / Write |
| [GtkTextDirection](gtkwidget#GtkTextDirection) | [direction](gtkshortcutsshortcut#GtkShortcutsShortcut--direction) | Read / Write |
| GIcon \* | [icon](gtkshortcutsshortcut#GtkShortcutsShortcut--icon) | Read / Write |
| gboolean | [icon-set](gtkshortcutsshortcut#GtkShortcutsShortcut--icon-set) | Read / Write |
| [GtkShortcutType](gtkshortcutsshortcut#GtkShortcutType) | [shortcut-type](gtkshortcutsshortcut#GtkShortcutsShortcut--shortcut-type) | Read / Write |
| char \* | [subtitle](gtkshortcutsshortcut#GtkShortcutsShortcut--subtitle) | Read / Write |
| gboolean | [subtitle-set](gtkshortcutsshortcut#GtkShortcutsShortcut--subtitle-set) | Read / Write |
| char \* | [title](gtkshortcutsshortcut#GtkShortcutsShortcut--title) | Read / Write |
| [GtkSizeGroup](gtksizegroup#GtkSizeGroup-struct) \* | [title-size-group](gtkshortcutsshortcut#GtkShortcutsShortcut--title-size-group) | Write |
Types and Values
----------------
| | |
| --- | --- |
| | [GtkShortcutsShortcut](gtkshortcutsshortcut#GtkShortcutsShortcut-struct) |
| enum | [GtkShortcutType](gtkshortcutsshortcut#GtkShortcutType) |
Object Hierarchy
----------------
```
GObject
╰── GInitiallyUnowned
╰── [GtkWidget](gtkwidget#GtkWidget-struct)
╰── GtkShortcutsShortcut
```
Implemented Interfaces
----------------------
GtkShortcutsShortcut implements [GtkAccessible](gtkaccessible#GtkAccessible-struct), [GtkBuildable](gtkbuildable#GtkBuildable-struct) and [GtkConstraintTarget](gtkconstraint#GtkConstraintTarget-struct).
Includes
--------
```
#include <gtk/gtk.h>
```
Description
-----------
A GtkShortcutsShortcut represents a single keyboard shortcut or gesture with a short text. This widget is only meant to be used with [GtkShortcutsWindow](gtkshortcutswindow#GtkShortcutsWindow-struct).
Functions
---------
Types and Values
----------------
### GtkShortcutsShortcut
```
typedef struct _GtkShortcutsShortcut GtkShortcutsShortcut;
```
### enum GtkShortcutType
GtkShortcutType specifies the kind of shortcut that is being described. More values may be added to this enumeration over time.
#### Members
| | | |
| --- | --- | --- |
| GTK\_SHORTCUT\_ACCELERATOR | The shortcut is a keyboard accelerator. The [“accelerator”](gtkshortcutsshortcut#GtkShortcutsShortcut--accelerator) property will be used. | |
| GTK\_SHORTCUT\_GESTURE\_PINCH | The shortcut is a pinch gesture. GTK+ provides an icon and subtitle. | |
| GTK\_SHORTCUT\_GESTURE\_STRETCH | The shortcut is a stretch gesture. GTK+ provides an icon and subtitle. | |
| GTK\_SHORTCUT\_GESTURE\_ROTATE\_CLOCKWISE | The shortcut is a clockwise rotation gesture. GTK+ provides an icon and subtitle. | |
| GTK\_SHORTCUT\_GESTURE\_ROTATE\_COUNTERCLOCKWISE | The shortcut is a counterclockwise rotation gesture. GTK+ provides an icon and subtitle. | |
| GTK\_SHORTCUT\_GESTURE\_TWO\_FINGER\_SWIPE\_LEFT | The shortcut is a two-finger swipe gesture. GTK+ provides an icon and subtitle. | |
| GTK\_SHORTCUT\_GESTURE\_TWO\_FINGER\_SWIPE\_RIGHT | The shortcut is a two-finger swipe gesture. GTK+ provides an icon and subtitle. | |
| GTK\_SHORTCUT\_GESTURE | The shortcut is a gesture. The [“icon”](gtkshortcutsshortcut#GtkShortcutsShortcut--icon) property will be used. | |
| GTK\_SHORTCUT\_GESTURE\_SWIPE\_LEFT | The shortcut is a swipe gesture. GTK+ provides an icon and subtitle. | |
| GTK\_SHORTCUT\_GESTURE\_SWIPE\_RIGHT | The shortcut is a swipe gesture. GTK+ provides an icon and subtitle. | |
Property Details
----------------
### The `“accel-size-group”` property
```
“accel-size-group” [GtkSizeGroup](gtksizegroup#GtkSizeGroup-struct) *
```
The size group for the accelerator portion of this shortcut.
This is used internally by GTK, and must not be modified by applications.
Owner: GtkShortcutsShortcut
Flags: Write
### The `“accelerator”` property
```
“accelerator” char *
```
The accelerator(s) represented by this object. This property is used if [“shortcut-type”](gtkshortcutsshortcut#GtkShortcutsShortcut--shortcut-type) is set to [GTK\_SHORTCUT\_ACCELERATOR](gtkshortcutsshortcut#GTK-SHORTCUT-ACCELERATOR:CAPS).
The syntax of this property is (an extension of) the syntax understood by [`gtk_accelerator_parse()`](gtk4-keyboard-accelerators#gtk-accelerator-parse). Multiple accelerators can be specified by separating them with a space, but keep in mind that the available width is limited. It is also possible to specify ranges of shortcuts, using ... between the keys. Sequences of keys can be specified using a + or & between the keys.
Examples:
* A single shortcut: <ctl><alt>delete
* Two alternative shortcuts: <shift>a Home
* A range of shortcuts: <alt>1...<alt>9
* Several keys pressed together: Control\_L&Control\_R
* A sequence of shortcuts or keys: <ctl>c+<ctl>x
Use + instead of & when the keys may (or have to be) pressed sequentially (e.g use t+t for 'press the t key twice').
Note that <, > and & need to be escaped as <, > and & when used in .ui files.
Owner: GtkShortcutsShortcut
Flags: Read / Write
Default value: NULL
### The `“action-name”` property
```
“action-name” char *
```
A detailed action name. If this is set for a shortcut of type [`GTK_SHORTCUT_ACCELERATOR`](gtkshortcutsshortcut#GTK-SHORTCUT-ACCELERATOR:CAPS), then GTK will use the accelerators that are associated with the action via [`gtk_application_set_accels_for_action()`](gtkapplication#gtk-application-set-accels-for-action), and setting [“accelerator”](gtkshortcutsshortcut#GtkShortcutsShortcut--accelerator) is not necessary.
Owner: GtkShortcutsShortcut
Flags: Read / Write
Default value: NULL
### The `“direction”` property
```
“direction” [GtkTextDirection](gtkwidget#GtkTextDirection)
```
The text direction for which this shortcut is active. If the shortcut is used regardless of the text direction, set this property to [GTK\_TEXT\_DIR\_NONE](gtkwidget#GTK-TEXT-DIR-NONE:CAPS).
Owner: GtkShortcutsShortcut
Flags: Read / Write
Default value: GTK\_TEXT\_DIR\_NONE
### The `“icon”` property
```
“icon” GIcon *
```
An icon to represent the shortcut or gesture. This property is used if [“shortcut-type”](gtkshortcutsshortcut#GtkShortcutsShortcut--shortcut-type) is set to [GTK\_SHORTCUT\_GESTURE](gtkshortcutsshortcut#GTK-SHORTCUT-GESTURE:CAPS). For the other predefined gesture types, GTK provides an icon on its own.
Owner: GtkShortcutsShortcut
Flags: Read / Write
### The `“icon-set”` property
```
“icon-set” gboolean
```
`TRUE` if an icon has been set.
Owner: GtkShortcutsShortcut
Flags: Read / Write
Default value: FALSE
### The `“shortcut-type”` property
```
“shortcut-type” [GtkShortcutType](gtkshortcutsshortcut#GtkShortcutType)
```
The type of shortcut that is represented.
Owner: GtkShortcutsShortcut
Flags: Read / Write
Default value: GTK\_SHORTCUT\_ACCELERATOR
### The `“subtitle”` property
```
“subtitle” char *
```
The subtitle for the shortcut or gesture.
This is typically used for gestures and should be a short, one-line text that describes the gesture itself. For the predefined gesture types, GTK provides a subtitle on its own.
Owner: GtkShortcutsShortcut
Flags: Read / Write
Default value: ""
### The `“subtitle-set”` property
```
“subtitle-set” gboolean
```
`TRUE` if a subtitle has been set.
Owner: GtkShortcutsShortcut
Flags: Read / Write
Default value: FALSE
### The `“title”` property
```
“title” char *
```
The textual description for the shortcut or gesture represented by this object. This should be a short string that can fit in a single line.
Owner: GtkShortcutsShortcut
Flags: Read / Write
Default value: ""
### The `“title-size-group”` property
```
“title-size-group” [GtkSizeGroup](gtksizegroup#GtkSizeGroup-struct) *
```
The size group for the textual portion of this shortcut.
This is used internally by GTK, and must not be modified by applications.
Owner: GtkShortcutsShortcut
Flags: Write
gtk Multiline Text Editor Multiline Text Editor
=====================
[Text Widget Overview](textwidgetobjects#TextWidget) [Simple Example](textwidgetobjects#id-1.4.16.2.13) [Example of Changing Text Attributes](textwidgetobjects#id-1.4.16.2.14) [GtkTextIter](gtktextiter) — Text buffer iterator [GtkTextMark](gtktextmark) — A position in the buffer preserved across buffer modifications [GtkTextBuffer](gtktextbuffer) — Stores attributed text for display in a GtkTextView [GtkTextTag](gtktexttag) — A tag that can be applied to text in a GtkTextBuffer [GtkTextTagTable](gtktexttagtable) — Collection of tags that can be used together [GtkTextView](gtktextview) — Widget that displays a GtkTextBuffer GTK has an extremely powerful framework for multiline text editing. The primary objects involved in the process are [GtkTextBuffer](gtktextbuffer#GtkTextBuffer-struct), which represents the text being edited, and [GtkTextView](gtktextview#GtkTextView-struct), a widget which can display a [GtkTextBuffer](gtktextbuffer#GtkTextBuffer-struct). Each buffer can be displayed by any number of views.
One of the important things to remember about text in GTK is that it’s in the UTF-8 encoding. This means that one character can be encoded as multiple bytes. Character counts are usually referred to as *offsets*, while byte counts are called *indexes*. If you confuse these two, things will work fine with ASCII, but as soon as your buffer contains multibyte characters, bad things will happen.
Text in a buffer can be marked with *tags*. A tag is an attribute that can be applied to some range of text. For example, a tag might be called “bold” and make the text inside the tag bold. However, the tag concept is more general than that; tags don’t have to affect appearance. They can instead affect the behavior of mouse and key presses, “lock” a range of text so the user can’t edit it, or countless other things. A tag is represented by a [GtkTextTag](gtktexttag#GtkTextTag-struct) object. One [GtkTextTag](gtktexttag#GtkTextTag-struct) can be applied to any number of text ranges in any number of buffers.
Each tag is stored in a [GtkTextTagTable](gtktexttagtable#GtkTextTagTable-struct). A tag table defines a set of tags that can be used together. Each buffer has one tag table associated with it; only tags from that tag table can be used with the buffer. A single tag table can be shared between multiple buffers, however.
Tags can have names, which is convenient sometimes (for example, you can name your tag that makes things bold “bold”), but they can also be anonymous (which is convenient if you’re creating tags on-the-fly).
Most text manipulation is accomplished with *iterators*, represented by a [GtkTextIter](gtktextiter#GtkTextIter-struct). An iterator represents a position between two characters in the text buffer. [GtkTextIter](gtktextiter#GtkTextIter-struct) is a struct designed to be allocated on the stack; it’s guaranteed to be copiable by value and never contain any heap-allocated data. Iterators are not valid indefinitely; whenever the buffer is modified in a way that affects the number of characters in the buffer, all outstanding iterators become invalid. (Note that deleting 5 characters and then reinserting 5 still invalidates iterators, though you end up with the same number of characters you pass through a state with a different number).
Because of this, iterators can’t be used to preserve positions across buffer modifications. To preserve a position, the [GtkTextMark](gtktextmark#GtkTextMark-struct) object is ideal. You can think of a mark as an invisible cursor or insertion point; it floats in the buffer, saving a position. If the text surrounding the mark is deleted, the mark remains in the position the text once occupied; if text is inserted at the mark, the mark ends up either to the left or to the right of the new text, depending on its *gravity*. The standard text cursor in left-to-right languages is a mark with right gravity, because it stays to the right of inserted text.
Like tags, marks can be either named or anonymous. There are two marks built-in to [GtkTextBuffer](gtktextbuffer#GtkTextBuffer-struct); these are named “insert” and “selection\_bound” and refer to the insertion point and the boundary of the selection which is not the insertion point, respectively. If no text is selected, these two marks will be in the same position. You can manipulate what is selected and where the cursor appears by moving these marks around.
If you want to place the cursor in response to a user action, be sure to use [`gtk_text_buffer_place_cursor()`](gtktextbuffer#gtk-text-buffer-place-cursor), which moves both at once without causing a temporary selection (moving one then the other temporarily selects the range in between the old and new positions).
Text buffers always contain at least one line, but may be empty (that is, buffers can contain zero characters). The last line in the text buffer never ends in a line separator (such as newline); the other lines in the buffer always end in a line separator. Line separators count as characters when computing character counts and character offsets. Note that some Unicode line separators are represented with multiple bytes in UTF-8, and the two-character sequence “” is also considered a line separator.
Text buffers support undo and redo if [`gtk_text_buffer_set_enable_undo()`](gtktextbuffer#gtk-text-buffer-set-enable-undo) has been set to `TRUE`. Use [`gtk_text_buffer_undo()`](gtktextbuffer#gtk-text-buffer-undo) or [`gtk_text_buffer_redo()`](gtktextbuffer#gtk-text-buffer-redo) to perform the necessary action. Note that these operations are ignored if the buffer is not editable. Developers may want some operations to not be undoable. To do this, wrap your changes in [`gtk_text_buffer_begin_irreversible_action()`](gtktextbuffer#gtk-text-buffer-begin-irreversible-action) and [`gtk_text_buffer_end_irreversible_action()`](gtktextbuffer#gtk-text-buffer-end-irreversible-action).
### Simple Example
The simplest usage of [GtkTextView](gtktextview#GtkTextView-struct) might look like this:
```
GtkWidget *view;
GtkTextBuffer *buffer;
view = [`gtk_text_view_new()`](gtktextview#gtk-text-view-new);
buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view));
gtk_text_buffer_set_text (buffer, "Hello, this is some text", -1);
/* Now you might put the view in a container and display it on the
* screen; when the user edits the text, signals on the buffer
* will be emitted, such as "changed", "insert_text", and so on.
*/
```
In many cases it’s also convenient to first create the buffer with [`gtk_text_buffer_new()`](gtktextbuffer#gtk-text-buffer-new), then create a widget for that buffer with [`gtk_text_view_new_with_buffer()`](gtktextview#gtk-text-view-new-with-buffer). Or you can change the buffer the widget displays after the widget is created with [`gtk_text_view_set_buffer()`](gtktextview#gtk-text-view-set-buffer).
### Example of Changing Text Attributes
The way to affect text attributes in [GtkTextView](gtktextview#GtkTextView-struct) is to apply tags that change the attributes for a region of text. For text features that come from the theme — such as font and foreground color – use CSS to override their default values.
```
GtkWidget *view;
GtkTextBuffer *buffer;
GtkTextIter start, end;
PangoFontDescription *font_desc;
GdkRGBA rgba;
GtkTextTag *tag;
GtkCssProvider *provider;
GtkStyleContext *context;
view = [`gtk_text_view_new()`](gtktextview#gtk-text-view-new);
buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view));
gtk_text_buffer_set_text (buffer, "Hello, this is some text", -1);
/* Change default font and color throughout the widget */
provider = [`gtk_css_provider_new()`](gtkcssprovider#gtk-css-provider-new);
gtk_css_provider_load_from_data (provider,
"textview {"
" font: 15 serif;"
" color: green;"
"}",
-1);
context = gtk_widget_get_style_context (view);
gtk_style_context_add_provider (context,
GTK_STYLE_PROVIDER (provider),
GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
/* Change left margin throughout the widget */
gtk_text_view_set_left_margin (GTK_TEXT_VIEW (view), 30);
/* Use a tag to change the color for just one part of the widget */
tag = gtk_text_buffer_create_tag (buffer, "blue_foreground",
"foreground", "blue",
NULL);
gtk_text_buffer_get_iter_at_offset (buffer, &start, 7);
gtk_text_buffer_get_iter_at_offset (buffer, &end, 12);
gtk_text_buffer_apply_tag (buffer, tag, &start, &end);
```
The `gtk4-demo` application that comes with GTK contains more example code for [GtkTextView](gtktextview#GtkTextView-struct).
gtk GtkCellAreaContext GtkCellAreaContext
==================
GtkCellAreaContext — Stores geometrical information for a series of rows in a GtkCellArea
Functions
---------
| | |
| --- | --- |
| [GtkCellArea](gtkcellarea#GtkCellArea-struct) \* | [gtk\_cell\_area\_context\_get\_area](gtkcellareacontext#gtk-cell-area-context-get-area) () |
| void | [gtk\_cell\_area\_context\_allocate](gtkcellareacontext#gtk-cell-area-context-allocate) () |
| void | [gtk\_cell\_area\_context\_reset](gtkcellareacontext#gtk-cell-area-context-reset) () |
| void | [gtk\_cell\_area\_context\_get\_preferred\_width](gtkcellareacontext#gtk-cell-area-context-get-preferred-width) () |
| void | [gtk\_cell\_area\_context\_get\_preferred\_height](gtkcellareacontext#gtk-cell-area-context-get-preferred-height) () |
| void | [gtk\_cell\_area\_context\_get\_preferred\_height\_for\_width](gtkcellareacontext#gtk-cell-area-context-get-preferred-height-for-width) () |
| void | [gtk\_cell\_area\_context\_get\_preferred\_width\_for\_height](gtkcellareacontext#gtk-cell-area-context-get-preferred-width-for-height) () |
| void | [gtk\_cell\_area\_context\_get\_allocation](gtkcellareacontext#gtk-cell-area-context-get-allocation) () |
| void | [gtk\_cell\_area\_context\_push\_preferred\_width](gtkcellareacontext#gtk-cell-area-context-push-preferred-width) () |
| void | [gtk\_cell\_area\_context\_push\_preferred\_height](gtkcellareacontext#gtk-cell-area-context-push-preferred-height) () |
Properties
----------
| | | |
| --- | --- | --- |
| [GtkCellArea](gtkcellarea#GtkCellArea-struct) \* | [area](gtkcellareacontext#GtkCellAreaContext--area) | Read / Write / Construct Only |
| int | [minimum-height](gtkcellareacontext#GtkCellAreaContext--minimum-height) | Read |
| int | [minimum-width](gtkcellareacontext#GtkCellAreaContext--minimum-width) | Read |
| int | [natural-height](gtkcellareacontext#GtkCellAreaContext--natural-height) | Read |
| int | [natural-width](gtkcellareacontext#GtkCellAreaContext--natural-width) | Read |
Types and Values
----------------
| | |
| --- | --- |
| struct | [GtkCellAreaContextClass](gtkcellareacontext#GtkCellAreaContextClass) |
| | [GtkCellAreaContext](gtkcellareacontext#GtkCellAreaContext-struct) |
Object Hierarchy
----------------
```
GObject
╰── GtkCellAreaContext
```
Includes
--------
```
#include <gtk/gtk.h>
```
Description
-----------
The [GtkCellAreaContext](gtkcellareacontext#GtkCellAreaContext-struct) object is created by a given [GtkCellArea](gtkcellarea#GtkCellArea-struct) implementation via its [`GtkCellAreaClass.create_context()`](gtkcellarea#GtkCellAreaClass.create-context) virtual method and is used to store cell sizes and alignments for a series of [GtkTreeModel](gtktreemodel#GtkTreeModel-struct) rows that are requested and rendered in the same context.
[GtkCellLayout](gtkcelllayout#GtkCellLayout-struct) widgets can create any number of contexts in which to request and render groups of data rows. However, it’s important that the same context which was used to request sizes for a given [GtkTreeModel](gtktreemodel#GtkTreeModel-struct) row also be used for the same row when calling other [GtkCellArea](gtkcellarea#GtkCellArea-struct) APIs such as `gtk_cell_area_render()` and [`gtk_cell_area_event()`](gtkcellarea#gtk-cell-area-event).
Functions
---------
### gtk\_cell\_area\_context\_get\_area ()
```
[GtkCellArea](gtkcellarea#GtkCellArea-struct) *
gtk_cell_area_context_get_area (*`[GtkCellAreaContext](gtkcellareacontext#GtkCellAreaContext-struct) *context`*);
```
Fetches the [GtkCellArea](gtkcellarea#GtkCellArea-struct) this *`context`* was created by.
This is generally unneeded by layouting widgets; however, it is important for the context implementation itself to fetch information about the area it is being used for.
For instance at [`GtkCellAreaContextClass.allocate()`](gtkcellareacontext#GtkCellAreaContextClass.allocate) time it’s important to know details about any cell spacing that the [GtkCellArea](gtkcellarea#GtkCellArea-struct) is configured with in order to compute a proper allocation.
#### Parameters
| | | |
| --- | --- | --- |
| context | a [GtkCellAreaContext](gtkcellareacontext#GtkCellAreaContext-struct) | |
#### Returns
the [GtkCellArea](gtkcellarea#GtkCellArea-struct) this context was created by.
[transfer none]
### gtk\_cell\_area\_context\_allocate ()
```
void
gtk_cell_area_context_allocate (*`[GtkCellAreaContext](gtkcellareacontext#GtkCellAreaContext-struct) *context`*,
*`int width`*,
*`int height`*);
```
Allocates a width and/or a height for all rows which are to be rendered with *`context`* .
Usually allocation is performed only horizontally or sometimes vertically since a group of rows are usually rendered side by side vertically or horizontally and share either the same width or the same height. Sometimes they are allocated in both horizontal and vertical orientations producing a homogeneous effect of the rows. This is generally the case for [GtkTreeView](gtktreeview#GtkTreeView-struct) when [“fixed-height-mode”](gtktreeview#GtkTreeView--fixed-height-mode) is enabled.
#### Parameters
| | | |
| --- | --- | --- |
| context | a [GtkCellAreaContext](gtkcellareacontext#GtkCellAreaContext-struct) | |
| width | the allocated width for all [GtkTreeModel](gtktreemodel#GtkTreeModel-struct) rows rendered with *`context`* , or -1. | |
| height | the allocated height for all [GtkTreeModel](gtktreemodel#GtkTreeModel-struct) rows rendered with *`context`* , or -1. | |
### gtk\_cell\_area\_context\_reset ()
```
void
gtk_cell_area_context_reset (*`[GtkCellAreaContext](gtkcellareacontext#GtkCellAreaContext-struct) *context`*);
```
Resets any previously cached request and allocation data.
When underlying [GtkTreeModel](gtktreemodel#GtkTreeModel-struct) data changes its important to reset the context if the content size is allowed to shrink. If the content size is only allowed to grow (this is usually an option for views rendering large data stores as a measure of optimization), then only the row that changed or was inserted needs to be (re)requested with [`gtk_cell_area_get_preferred_width()`](gtkcellarea#gtk-cell-area-get-preferred-width).
When the new overall size of the context requires that the allocated size changes (or whenever this allocation changes at all), the variable row sizes need to be re-requested for every row.
For instance, if the rows are displayed all with the same width from top to bottom then a change in the allocated width necessitates a recalculation of all the displayed row heights using [`gtk_cell_area_get_preferred_height_for_width()`](gtkcellarea#gtk-cell-area-get-preferred-height-for-width).
#### Parameters
| | | |
| --- | --- | --- |
| context | a [GtkCellAreaContext](gtkcellareacontext#GtkCellAreaContext-struct) | |
### gtk\_cell\_area\_context\_get\_preferred\_width ()
```
void
gtk_cell_area_context_get_preferred_width
(*`[GtkCellAreaContext](gtkcellareacontext#GtkCellAreaContext-struct) *context`*,
*`int *minimum_width`*,
*`int *natural_width`*);
```
Gets the accumulative preferred width for all rows which have been requested with this context.
After [`gtk_cell_area_context_reset()`](gtkcellareacontext#gtk-cell-area-context-reset) is called and/or before ever requesting the size of a [GtkCellArea](gtkcellarea#GtkCellArea-struct), the returned values are 0.
#### Parameters
| | | |
| --- | --- | --- |
| context | a [GtkCellAreaContext](gtkcellareacontext#GtkCellAreaContext-struct) | |
| minimum\_width | location to store the minimum width, or `NULL`. | [out][allow-none] |
| natural\_width | location to store the natural width, or `NULL`. | [out][allow-none] |
### gtk\_cell\_area\_context\_get\_preferred\_height ()
```
void
gtk_cell_area_context_get_preferred_height
(*`[GtkCellAreaContext](gtkcellareacontext#GtkCellAreaContext-struct) *context`*,
*`int *minimum_height`*,
*`int *natural_height`*);
```
Gets the accumulative preferred height for all rows which have been requested with this context.
After [`gtk_cell_area_context_reset()`](gtkcellareacontext#gtk-cell-area-context-reset) is called and/or before ever requesting the size of a [GtkCellArea](gtkcellarea#GtkCellArea-struct), the returned values are 0.
#### Parameters
| | | |
| --- | --- | --- |
| context | a [GtkCellAreaContext](gtkcellareacontext#GtkCellAreaContext-struct) | |
| minimum\_height | location to store the minimum height, or `NULL`. | [out][allow-none] |
| natural\_height | location to store the natural height, or `NULL`. | [out][allow-none] |
### gtk\_cell\_area\_context\_get\_preferred\_height\_for\_width ()
```
void
gtk_cell_area_context_get_preferred_height_for_width
(*`[GtkCellAreaContext](gtkcellareacontext#GtkCellAreaContext-struct) *context`*,
*`int width`*,
*`int *minimum_height`*,
*`int *natural_height`*);
```
Gets the accumulative preferred height for *`width`* for all rows which have been requested for the same said *`width`* with this context.
After [`gtk_cell_area_context_reset()`](gtkcellareacontext#gtk-cell-area-context-reset) is called and/or before ever requesting the size of a [GtkCellArea](gtkcellarea#GtkCellArea-struct), the returned values are -1.
#### Parameters
| | | |
| --- | --- | --- |
| context | a [GtkCellAreaContext](gtkcellareacontext#GtkCellAreaContext-struct) | |
| width | a proposed width for allocation | |
| minimum\_height | location to store the minimum height, or `NULL`. | [out][allow-none] |
| natural\_height | location to store the natural height, or `NULL`. | [out][allow-none] |
### gtk\_cell\_area\_context\_get\_preferred\_width\_for\_height ()
```
void
gtk_cell_area_context_get_preferred_width_for_height
(*`[GtkCellAreaContext](gtkcellareacontext#GtkCellAreaContext-struct) *context`*,
*`int height`*,
*`int *minimum_width`*,
*`int *natural_width`*);
```
Gets the accumulative preferred width for *`height`* for all rows which have been requested for the same said *`height`* with this context.
After [`gtk_cell_area_context_reset()`](gtkcellareacontext#gtk-cell-area-context-reset) is called and/or before ever requesting the size of a [GtkCellArea](gtkcellarea#GtkCellArea-struct), the returned values are -1.
#### Parameters
| | | |
| --- | --- | --- |
| context | a [GtkCellAreaContext](gtkcellareacontext#GtkCellAreaContext-struct) | |
| height | a proposed height for allocation | |
| minimum\_width | location to store the minimum width, or `NULL`. | [out][allow-none] |
| natural\_width | location to store the natural width, or `NULL`. | [out][allow-none] |
### gtk\_cell\_area\_context\_get\_allocation ()
```
void
gtk_cell_area_context_get_allocation (*`[GtkCellAreaContext](gtkcellareacontext#GtkCellAreaContext-struct) *context`*,
*`int *width`*,
*`int *height`*);
```
Fetches the current allocation size for *`context`* .
If the context was not allocated in width or height, or if the context was recently reset with [`gtk_cell_area_context_reset()`](gtkcellareacontext#gtk-cell-area-context-reset), the returned value will be -1.
#### Parameters
| | | |
| --- | --- | --- |
| context | a [GtkCellAreaContext](gtkcellareacontext#GtkCellAreaContext-struct) | |
| width | location to store the allocated width, or `NULL`. | [out][allow-none] |
| height | location to store the allocated height, or `NULL`. | [out][allow-none] |
### gtk\_cell\_area\_context\_push\_preferred\_width ()
```
void
gtk_cell_area_context_push_preferred_width
(*`[GtkCellAreaContext](gtkcellareacontext#GtkCellAreaContext-struct) *context`*,
*`int minimum_width`*,
*`int natural_width`*);
```
Causes the minimum and/or natural width to grow if the new proposed sizes exceed the current minimum and natural width.
This is used by [GtkCellAreaContext](gtkcellareacontext#GtkCellAreaContext-struct) implementations during the request process over a series of [GtkTreeModel](gtktreemodel#GtkTreeModel-struct) rows to progressively push the requested width over a series of [`gtk_cell_area_get_preferred_width()`](gtkcellarea#gtk-cell-area-get-preferred-width) requests.
#### Parameters
| | | |
| --- | --- | --- |
| context | a [GtkCellAreaContext](gtkcellareacontext#GtkCellAreaContext-struct) | |
| minimum\_width | the proposed new minimum width for *`context`* | |
| natural\_width | the proposed new natural width for *`context`* | |
### gtk\_cell\_area\_context\_push\_preferred\_height ()
```
void
gtk_cell_area_context_push_preferred_height
(*`[GtkCellAreaContext](gtkcellareacontext#GtkCellAreaContext-struct) *context`*,
*`int minimum_height`*,
*`int natural_height`*);
```
Causes the minimum and/or natural height to grow if the new proposed sizes exceed the current minimum and natural height.
This is used by [GtkCellAreaContext](gtkcellareacontext#GtkCellAreaContext-struct) implementations during the request process over a series of [GtkTreeModel](gtktreemodel#GtkTreeModel-struct) rows to progressively push the requested height over a series of [`gtk_cell_area_get_preferred_height()`](gtkcellarea#gtk-cell-area-get-preferred-height) requests.
#### Parameters
| | | |
| --- | --- | --- |
| context | a [GtkCellAreaContext](gtkcellareacontext#GtkCellAreaContext-struct) | |
| minimum\_height | the proposed new minimum height for *`context`* | |
| natural\_height | the proposed new natural height for *`context`* | |
Types and Values
----------------
### struct GtkCellAreaContextClass
```
struct GtkCellAreaContextClass {
void (* allocate) (GtkCellAreaContext *context,
int width,
int height);
void (* reset) (GtkCellAreaContext *context);
void (* get_preferred_height_for_width) (GtkCellAreaContext *context,
int width,
int *minimum_height,
int *natural_height);
void (* get_preferred_width_for_height) (GtkCellAreaContext *context,
int height,
int *minimum_width,
int *natural_width);
};
```
#### Members
| | | |
| --- | --- | --- |
| *`allocate`* () | This tells the context that an allocation width or height (or both) have been decided for a group of rows. The context should store any allocations for internally aligned cells at this point so that they dont need to be recalculated at `gtk_cell_area_render()` time. | |
| *`reset`* () | Clear any previously stored information about requested and allocated sizes for the context. | |
| *`get_preferred_height_for_width`* () | Returns the aligned height for the given width that context must store while collecting sizes for it’s rows. | |
| *`get_preferred_width_for_height`* () | Returns the aligned width for the given height that context must store while collecting sizes for it’s rows. | |
### GtkCellAreaContext
```
typedef struct _GtkCellAreaContext GtkCellAreaContext;
```
Property Details
----------------
### The `“area”` property
```
“area” [GtkCellArea](gtkcellarea#GtkCellArea-struct) *
```
The [GtkCellArea](gtkcellarea#GtkCellArea-struct) this context was created by
Owner: GtkCellAreaContext
Flags: Read / Write / Construct Only
### The `“minimum-height”` property
```
“minimum-height” int
```
The minimum height for the [GtkCellArea](gtkcellarea#GtkCellArea-struct) in this context for all [GtkTreeModel](gtktreemodel#GtkTreeModel-struct) rows that this context was requested for using [`gtk_cell_area_get_preferred_height()`](gtkcellarea#gtk-cell-area-get-preferred-height).
Owner: GtkCellAreaContext
Flags: Read
Allowed values: >= -1
Default value: -1
### The `“minimum-width”` property
```
“minimum-width” int
```
The minimum width for the [GtkCellArea](gtkcellarea#GtkCellArea-struct) in this context for all [GtkTreeModel](gtktreemodel#GtkTreeModel-struct) rows that this context was requested for using [`gtk_cell_area_get_preferred_width()`](gtkcellarea#gtk-cell-area-get-preferred-width).
Owner: GtkCellAreaContext
Flags: Read
Allowed values: >= -1
Default value: -1
### The `“natural-height”` property
```
“natural-height” int
```
The natural height for the [GtkCellArea](gtkcellarea#GtkCellArea-struct) in this context for all [GtkTreeModel](gtktreemodel#GtkTreeModel-struct) rows that this context was requested for using [`gtk_cell_area_get_preferred_height()`](gtkcellarea#gtk-cell-area-get-preferred-height).
Owner: GtkCellAreaContext
Flags: Read
Allowed values: >= -1
Default value: -1
### The `“natural-width”` property
```
“natural-width” int
```
The natural width for the [GtkCellArea](gtkcellarea#GtkCellArea-struct) in this context for all [GtkTreeModel](gtktreemodel#GtkTreeModel-struct) rows that this context was requested for using [`gtk_cell_area_get_preferred_width()`](gtkcellarea#gtk-cell-area-get-preferred-width).
Owner: GtkCellAreaContext
Flags: Read
Allowed values: >= -1
Default value: -1
| programming_docs |
gtk GtkPopoverMenuBar GtkPopoverMenuBar
=================
GtkPopoverMenuBar — A menu bar with popovers
Functions
---------
| | |
| --- | --- |
| [GtkWidget](gtkwidget#GtkWidget-struct) \* | [gtk\_popover\_menu\_bar\_new\_from\_model](gtkpopovermenubar#gtk-popover-menu-bar-new-from-model) () |
| void | [gtk\_popover\_menu\_bar\_set\_menu\_model](gtkpopovermenubar#gtk-popover-menu-bar-set-menu-model) () |
| GMenuModel \* | [gtk\_popover\_menu\_bar\_get\_menu\_model](gtkpopovermenubar#gtk-popover-menu-bar-get-menu-model) () |
| gboolean | [gtk\_popover\_menu\_bar\_add\_child](gtkpopovermenubar#gtk-popover-menu-bar-add-child) () |
| gboolean | [gtk\_popover\_menu\_bar\_remove\_child](gtkpopovermenubar#gtk-popover-menu-bar-remove-child) () |
Properties
----------
| | | |
| --- | --- | --- |
| GMenuModel \* | [menu-model](gtkpopovermenubar#GtkPopoverMenuBar--menu-model) | Read / Write |
Types and Values
----------------
| | |
| --- | --- |
| | [GtkPopoverMenuBar](gtkpopovermenubar#GtkPopoverMenuBar-struct) |
Object Hierarchy
----------------
```
GObject
╰── GInitiallyUnowned
╰── [GtkWidget](gtkwidget#GtkWidget-struct)
╰── GtkPopoverMenuBar
```
Implemented Interfaces
----------------------
GtkPopoverMenuBar implements [GtkAccessible](gtkaccessible#GtkAccessible-struct), [GtkBuildable](gtkbuildable#GtkBuildable-struct) and [GtkConstraintTarget](gtkconstraint#GtkConstraintTarget-struct).
Includes
--------
```
#include <gtk/gtk.h>
```
Description
-----------
GtkPopoverMenuBar presents a horizontal bar of items that pop up popover menus when clicked.
The only way to create instances of GtkPopoverMenuBar is from a GMenuModel.
### CSS nodes
```
menubar
├── item[.active]
┊ ╰── popover
╰── item
╰── popover
```
| GtkPopoverMenuBar has a single CSS node with name menubar, below which each item has its CSS node, and below that the corresponding popover.
The item whose popover is currently open gets the .active style class.
### Accessibility
GtkPopoverMenuBar uses the [GTK\_ACCESSIBLE\_ROLE\_MENU\_BAR](gtkaccessible#GTK-ACCESSIBLE-ROLE-MENU-BAR:CAPS) role, the menu items use the [GTK\_ACCESSIBLE\_ROLE\_MENU\_ITEM](gtkaccessible#GTK-ACCESSIBLE-ROLE-MENU-ITEM:CAPS) role and the menus use the [GTK\_ACCESSIBLE\_ROLE\_MENU](gtkaccessible#GTK-ACCESSIBLE-ROLE-MENU:CAPS) role.
Functions
---------
### gtk\_popover\_menu\_bar\_new\_from\_model ()
```
[GtkWidget](gtkwidget#GtkWidget-struct) *
gtk_popover_menu_bar_new_from_model (*`GMenuModel *model`*);
```
Creates a [GtkPopoverMenuBar](gtkpopovermenubar#GtkPopoverMenuBar-struct) from a GMenuModel.
#### Parameters
| | | |
| --- | --- | --- |
| model | a GMenuModel, or `NULL`. | [allow-none] |
#### Returns
a new [GtkPopoverMenuBar](gtkpopovermenubar#GtkPopoverMenuBar-struct)
### gtk\_popover\_menu\_bar\_set\_menu\_model ()
```
void
gtk_popover_menu_bar_set_menu_model (*`[GtkPopoverMenuBar](gtkpopovermenubar#GtkPopoverMenuBar-struct) *bar`*,
*`GMenuModel *model`*);
```
Sets a menu model from which *`bar`* should take its contents.
#### Parameters
| | | |
| --- | --- | --- |
| bar | a [GtkPopoverMenuBar](gtkpopovermenubar#GtkPopoverMenuBar-struct) | |
| model | a GMenuModel, or `NULL`. | [allow-none] |
### gtk\_popover\_menu\_bar\_get\_menu\_model ()
```
GMenuModel *
gtk_popover_menu_bar_get_menu_model (*`[GtkPopoverMenuBar](gtkpopovermenubar#GtkPopoverMenuBar-struct) *bar`*);
```
Returns the model from which the contents of *`bar`* are taken.
#### Parameters
| | | |
| --- | --- | --- |
| bar | a [GtkPopoverMenuBar](gtkpopovermenubar#GtkPopoverMenuBar-struct) | |
#### Returns
a GMenuModel.
[transfer none]
### gtk\_popover\_menu\_bar\_add\_child ()
```
gboolean
gtk_popover_menu_bar_add_child (*`[GtkPopoverMenuBar](gtkpopovermenubar#GtkPopoverMenuBar-struct) *bar`*,
*`[GtkWidget](gtkwidget#GtkWidget-struct) *child`*,
*`const char *id`*);
```
Adds a custom widget to a generated menubar.
For this to work, the menu model of *`bar`* must have an item with a `custom` attribute that matches *`id`* .
#### Parameters
| | | |
| --- | --- | --- |
| bar | a [GtkPopoverMenuBar](gtkpopovermenubar#GtkPopoverMenuBar-struct) | |
| child | the [GtkWidget](gtkwidget#GtkWidget-struct) to add | |
| id | the ID to insert *`child`* at | |
#### Returns
`TRUE` if *`id`* was found and the widget added
### gtk\_popover\_menu\_bar\_remove\_child ()
```
gboolean
gtk_popover_menu_bar_remove_child (*`[GtkPopoverMenuBar](gtkpopovermenubar#GtkPopoverMenuBar-struct) *bar`*,
*`[GtkWidget](gtkwidget#GtkWidget-struct) *child`*);
```
Removes a widget that has previously been added with [`gtk_popover_menu_bar_add_child()`](gtkpopovermenubar#gtk-popover-menu-bar-add-child).
#### Parameters
| | | |
| --- | --- | --- |
| bar | a [GtkPopoverMenuBar](gtkpopovermenubar#GtkPopoverMenuBar-struct) | |
| child | the [GtkWidget](gtkwidget#GtkWidget-struct) to remove | |
#### Returns
`TRUE` if the widget was removed
Types and Values
----------------
### GtkPopoverMenuBar
```
typedef struct _GtkPopoverMenuBar GtkPopoverMenuBar;
```
Property Details
----------------
### The `“menu-model”` property
```
“menu-model” GMenuModel *
```
The GMenuModel from which the menu bar is created.
The model should only contain submenus as toplevel elements.
Owner: GtkPopoverMenuBar
Flags: Read / Write
See Also
--------
[GtkPopover](gtkpopover#GtkPopover-struct), [GtkPopoverMenu](gtkpopovermenu#GtkPopoverMenu-struct), GMenuModel
gtk GtkStyleContext GtkStyleContext
===============
GtkStyleContext — Rendering UI elements
Functions
---------
| | |
| --- | --- |
| void | [gtk\_style\_context\_add\_provider](gtkstylecontext#gtk-style-context-add-provider) () |
| void | [gtk\_style\_context\_add\_provider\_for\_display](gtkstylecontext#gtk-style-context-add-provider-for-display) () |
| [GdkDisplay](https://developer-old.gnome.org/gtk4/html/GdkDisplay.html#GdkDisplay-struct) \* | [gtk\_style\_context\_get\_display](gtkstylecontext#gtk-style-context-get-display) () |
| [GtkStateFlags](gtk4-standard-enumerations#GtkStateFlags) | [gtk\_style\_context\_get\_state](gtkstylecontext#gtk-style-context-get-state) () |
| void | [gtk\_style\_context\_get\_color](gtkstylecontext#gtk-style-context-get-color) () |
| void | [gtk\_style\_context\_get\_border](gtkstylecontext#gtk-style-context-get-border) () |
| void | [gtk\_style\_context\_get\_padding](gtkstylecontext#gtk-style-context-get-padding) () |
| void | [gtk\_style\_context\_get\_margin](gtkstylecontext#gtk-style-context-get-margin) () |
| gboolean | [gtk\_style\_context\_lookup\_color](gtkstylecontext#gtk-style-context-lookup-color) () |
| void | [gtk\_style\_context\_remove\_provider](gtkstylecontext#gtk-style-context-remove-provider) () |
| void | [gtk\_style\_context\_remove\_provider\_for\_display](gtkstylecontext#gtk-style-context-remove-provider-for-display) () |
| void | [gtk\_style\_context\_restore](gtkstylecontext#gtk-style-context-restore) () |
| void | [gtk\_style\_context\_save](gtkstylecontext#gtk-style-context-save) () |
| void | [gtk\_style\_context\_add\_class](gtkstylecontext#gtk-style-context-add-class) () |
| void | [gtk\_style\_context\_remove\_class](gtkstylecontext#gtk-style-context-remove-class) () |
| gboolean | [gtk\_style\_context\_has\_class](gtkstylecontext#gtk-style-context-has-class) () |
| void | [gtk\_style\_context\_set\_display](gtkstylecontext#gtk-style-context-set-display) () |
| void | [gtk\_style\_context\_set\_state](gtkstylecontext#gtk-style-context-set-state) () |
| void | [gtk\_style\_context\_set\_scale](gtkstylecontext#gtk-style-context-set-scale) () |
| int | [gtk\_style\_context\_get\_scale](gtkstylecontext#gtk-style-context-get-scale) () |
| char \* | [gtk\_style\_context\_to\_string](gtkstylecontext#gtk-style-context-to-string) () |
| [GtkBorder](gtkstylecontext#GtkBorder) \* | [gtk\_border\_new](gtkstylecontext#gtk-border-new) () |
| [GtkBorder](gtkstylecontext#GtkBorder) \* | [gtk\_border\_copy](gtkstylecontext#gtk-border-copy) () |
| void | [gtk\_border\_free](gtkstylecontext#gtk-border-free) () |
| void | [gtk\_render\_arrow](gtkstylecontext#gtk-render-arrow) () |
| void | [gtk\_render\_background](gtkstylecontext#gtk-render-background) () |
| void | [gtk\_render\_check](gtkstylecontext#gtk-render-check) () |
| void | [gtk\_render\_expander](gtkstylecontext#gtk-render-expander) () |
| void | [gtk\_render\_focus](gtkstylecontext#gtk-render-focus) () |
| void | [gtk\_render\_frame](gtkstylecontext#gtk-render-frame) () |
| void | [gtk\_render\_handle](gtkstylecontext#gtk-render-handle) () |
| void | [gtk\_render\_layout](gtkstylecontext#gtk-render-layout) () |
| void | [gtk\_render\_line](gtkstylecontext#gtk-render-line) () |
| void | [gtk\_render\_option](gtkstylecontext#gtk-render-option) () |
| void | [gtk\_render\_activity](gtkstylecontext#gtk-render-activity) () |
| void | [gtk\_render\_icon](gtkstylecontext#gtk-render-icon) () |
Properties
----------
| | | |
| --- | --- | --- |
| [GdkDisplay](https://developer-old.gnome.org/gtk4/html/GdkDisplay.html#GdkDisplay-struct) \* | [display](gtkstylecontext#GtkStyleContext--display) | Read / Write |
Types and Values
----------------
| | |
| --- | --- |
| enum | [GtkBorderStyle](gtkstylecontext#GtkBorderStyle) |
| | [GtkStyleContext](gtkstylecontext#GtkStyleContext-struct) |
| enum | [GtkStyleContextPrintFlags](gtkstylecontext#GtkStyleContextPrintFlags) |
| struct | [GtkBorder](gtkstylecontext#GtkBorder) |
Object Hierarchy
----------------
```
GObject
╰── GtkStyleContext
```
Includes
--------
```
#include <gtk/gtk.h>
```
Description
-----------
[GtkStyleContext](gtkstylecontext#GtkStyleContext-struct) is an object that stores styling information affecting a widget.
In order to construct the final style information, [GtkStyleContext](gtkstylecontext#GtkStyleContext-struct) queries information from all attached [GtkStyleProviders](gtkstyleprovider#GtkStyleProvider-struct). Style providers can be either attached explicitly to the context through [`gtk_style_context_add_provider()`](gtkstylecontext#gtk-style-context-add-provider), or to the display through [`gtk_style_context_add_provider_for_display()`](gtkstylecontext#gtk-style-context-add-provider-for-display). The resulting style is a combination of all providers’ information in priority order.
For GTK widgets, any [GtkStyleContext](gtkstylecontext#GtkStyleContext-struct) returned by [`gtk_widget_get_style_context()`](gtkwidget#gtk-widget-get-style-context) will already have a [GdkDisplay](https://developer-old.gnome.org/gtk4/html/GdkDisplay.html#GdkDisplay-struct) and RTL/LTR information set. The style context will also be updated automatically if any of these settings change on the widget.
### Style Classes
Widgets can add style classes to their context, which can be used to associate different styles by class. The documentation for individual widgets lists which style classes it uses itself, and which style classes may be added by applications to affect their appearance.
GTK defines macros for a number of style classes.
### Custom styling in UI libraries and applications
If you are developing a library with custom [GtkWidgets](gtkwidget#GtkWidget-struct) that render differently than standard components, you may need to add a [GtkStyleProvider](gtkstyleprovider#GtkStyleProvider-struct) yourself with the [`GTK_STYLE_PROVIDER_PRIORITY_FALLBACK`](gtkstyleprovider#GTK-STYLE-PROVIDER-PRIORITY-FALLBACK:CAPS) priority, either a [GtkCssProvider](gtkcssprovider#GtkCssProvider-struct) or a custom object implementing the [GtkStyleProvider](gtkstyleprovider#GtkStyleProvider-struct) interface. This way themes may still attempt to style your UI elements in a different way if needed so.
If you are using custom styling on an applications, you probably want then to make your style information prevail to the theme’s, so you must use a [GtkStyleProvider](gtkstyleprovider#GtkStyleProvider-struct) with the [`GTK_STYLE_PROVIDER_PRIORITY_APPLICATION`](gtkstyleprovider#GTK-STYLE-PROVIDER-PRIORITY-APPLICATION:CAPS) priority, keep in mind that the user settings in `XDG_CONFIG_HOME/gtk-4.0/gtk.css` will still take precedence over your changes, as it uses the [`GTK_STYLE_PROVIDER_PRIORITY_USER`](gtkstyleprovider#GTK-STYLE-PROVIDER-PRIORITY-USER:CAPS) priority.
Functions
---------
### gtk\_style\_context\_add\_provider ()
```
void
gtk_style_context_add_provider (*`[GtkStyleContext](gtkstylecontext#GtkStyleContext-struct) *context`*,
*`[GtkStyleProvider](gtkstyleprovider#GtkStyleProvider-struct) *provider`*,
*`guint priority`*);
```
Adds a style provider to *`context`* , to be used in style construction. Note that a style provider added by this function only affects the style of the widget to which *`context`* belongs. If you want to affect the style of all widgets, use [`gtk_style_context_add_provider_for_display()`](gtkstylecontext#gtk-style-context-add-provider-for-display).
Note: If both priorities are the same, a [GtkStyleProvider](gtkstyleprovider#GtkStyleProvider-struct) added through this function takes precedence over another added through [`gtk_style_context_add_provider_for_display()`](gtkstylecontext#gtk-style-context-add-provider-for-display).
#### Parameters
| | | |
| --- | --- | --- |
| context | a [GtkStyleContext](gtkstylecontext#GtkStyleContext-struct) | |
| provider | a [GtkStyleProvider](gtkstyleprovider#GtkStyleProvider-struct) | |
| priority | the priority of the style provider. The lower it is, the earlier it will be used in the style construction. Typically this will be in the range between [`GTK_STYLE_PROVIDER_PRIORITY_FALLBACK`](gtkstyleprovider#GTK-STYLE-PROVIDER-PRIORITY-FALLBACK:CAPS) and [`GTK_STYLE_PROVIDER_PRIORITY_USER`](gtkstyleprovider#GTK-STYLE-PROVIDER-PRIORITY-USER:CAPS) | |
### gtk\_style\_context\_add\_provider\_for\_display ()
```
void
gtk_style_context_add_provider_for_display
(*`[GdkDisplay](https://developer-old.gnome.org/gtk4/html/GdkDisplay.html#GdkDisplay-struct) *display`*,
*`[GtkStyleProvider](gtkstyleprovider#GtkStyleProvider-struct) *provider`*,
*`guint priority`*);
```
Adds a global style provider to *`display`* , which will be used in style construction for all [GtkStyleContexts](gtkstylecontext#GtkStyleContext-struct) under *`display`* .
GTK uses this to make styling information from [GtkSettings](gtksettings#GtkSettings-struct) available.
Note: If both priorities are the same, A [GtkStyleProvider](gtkstyleprovider#GtkStyleProvider-struct) added through [`gtk_style_context_add_provider()`](gtkstylecontext#gtk-style-context-add-provider) takes precedence over another added through this function.
#### Parameters
| | | |
| --- | --- | --- |
| display | a [GdkDisplay](https://developer-old.gnome.org/gtk4/html/GdkDisplay.html#GdkDisplay-struct) | |
| provider | a [GtkStyleProvider](gtkstyleprovider#GtkStyleProvider-struct) | |
| priority | the priority of the style provider. The lower it is, the earlier it will be used in the style construction. Typically this will be in the range between [`GTK_STYLE_PROVIDER_PRIORITY_FALLBACK`](gtkstyleprovider#GTK-STYLE-PROVIDER-PRIORITY-FALLBACK:CAPS) and [`GTK_STYLE_PROVIDER_PRIORITY_USER`](gtkstyleprovider#GTK-STYLE-PROVIDER-PRIORITY-USER:CAPS) | |
### gtk\_style\_context\_get\_display ()
```
[GdkDisplay](https://developer-old.gnome.org/gtk4/html/GdkDisplay.html#GdkDisplay-struct) *
gtk_style_context_get_display (*`[GtkStyleContext](gtkstylecontext#GtkStyleContext-struct) *context`*);
```
Returns the [GdkDisplay](https://developer-old.gnome.org/gtk4/html/GdkDisplay.html#GdkDisplay-struct) to which *`context`* is attached.
#### Parameters
| | | |
| --- | --- | --- |
| context | a [GtkStyleContext](gtkstylecontext#GtkStyleContext-struct) | |
#### Returns
a [GdkDisplay](https://developer-old.gnome.org/gtk4/html/GdkDisplay.html#GdkDisplay-struct).
[transfer none]
### gtk\_style\_context\_get\_state ()
```
[GtkStateFlags](gtk4-standard-enumerations#GtkStateFlags)
gtk_style_context_get_state (*`[GtkStyleContext](gtkstylecontext#GtkStyleContext-struct) *context`*);
```
Returns the state used for style matching.
This method should only be used to retrieve the [GtkStateFlags](gtk4-standard-enumerations#GtkStateFlags) to pass to [GtkStyleContext](gtkstylecontext#GtkStyleContext-struct) methods, like [`gtk_style_context_get_padding()`](gtkstylecontext#gtk-style-context-get-padding). If you need to retrieve the current state of a [GtkWidget](gtkwidget#GtkWidget-struct), use [`gtk_widget_get_state_flags()`](gtkwidget#gtk-widget-get-state-flags).
#### Parameters
| | | |
| --- | --- | --- |
| context | a [GtkStyleContext](gtkstylecontext#GtkStyleContext-struct) | |
#### Returns
the state flags
### gtk\_style\_context\_get\_color ()
```
void
gtk_style_context_get_color (*`[GtkStyleContext](gtkstylecontext#GtkStyleContext-struct) *context`*,
*`[GdkRGBA](https://developer-old.gnome.org/gtk4/html/gdk4-RGBA-Colors.html#GdkRGBA-struct) *color`*);
```
Gets the foreground color for a given state.
#### Parameters
| | | |
| --- | --- | --- |
| context | a [GtkStyleContext](gtkstylecontext#GtkStyleContext-struct) | |
| color | return value for the foreground color. | [out] |
### gtk\_style\_context\_get\_border ()
```
void
gtk_style_context_get_border (*`[GtkStyleContext](gtkstylecontext#GtkStyleContext-struct) *context`*,
*`[GtkBorder](gtkstylecontext#GtkBorder) *border`*);
```
Gets the border for a given state as a [GtkBorder](gtkstylecontext#GtkBorder).
#### Parameters
| | | |
| --- | --- | --- |
| context | a [GtkStyleContext](gtkstylecontext#GtkStyleContext-struct) | |
| border | return value for the border settings. | [out] |
### gtk\_style\_context\_get\_padding ()
```
void
gtk_style_context_get_padding (*`[GtkStyleContext](gtkstylecontext#GtkStyleContext-struct) *context`*,
*`[GtkBorder](gtkstylecontext#GtkBorder) *padding`*);
```
Gets the padding for a given state as a [GtkBorder](gtkstylecontext#GtkBorder).
#### Parameters
| | | |
| --- | --- | --- |
| context | a [GtkStyleContext](gtkstylecontext#GtkStyleContext-struct) | |
| padding | return value for the padding settings. | [out] |
### gtk\_style\_context\_get\_margin ()
```
void
gtk_style_context_get_margin (*`[GtkStyleContext](gtkstylecontext#GtkStyleContext-struct) *context`*,
*`[GtkBorder](gtkstylecontext#GtkBorder) *margin`*);
```
Gets the margin for a given state as a [GtkBorder](gtkstylecontext#GtkBorder).
#### Parameters
| | | |
| --- | --- | --- |
| context | a [GtkStyleContext](gtkstylecontext#GtkStyleContext-struct) | |
| margin | return value for the margin settings. | [out] |
### gtk\_style\_context\_lookup\_color ()
```
gboolean
gtk_style_context_lookup_color (*`[GtkStyleContext](gtkstylecontext#GtkStyleContext-struct) *context`*,
*`const char *color_name`*,
*`[GdkRGBA](https://developer-old.gnome.org/gtk4/html/gdk4-RGBA-Colors.html#GdkRGBA-struct) *color`*);
```
Looks up and resolves a color name in the *`context`* color map.
#### Parameters
| | | |
| --- | --- | --- |
| context | a [GtkStyleContext](gtkstylecontext#GtkStyleContext-struct) | |
| color\_name | color name to lookup | |
| color | Return location for the looked up color. | [out] |
#### Returns
`TRUE` if *`color_name`* was found and resolved, `FALSE` otherwise
### gtk\_style\_context\_remove\_provider ()
```
void
gtk_style_context_remove_provider (*`[GtkStyleContext](gtkstylecontext#GtkStyleContext-struct) *context`*,
*`[GtkStyleProvider](gtkstyleprovider#GtkStyleProvider-struct) *provider`*);
```
Removes *`provider`* from the style providers list in *`context`* .
#### Parameters
| | | |
| --- | --- | --- |
| context | a [GtkStyleContext](gtkstylecontext#GtkStyleContext-struct) | |
| provider | a [GtkStyleProvider](gtkstyleprovider#GtkStyleProvider-struct) | |
### gtk\_style\_context\_remove\_provider\_for\_display ()
```
void
gtk_style_context_remove_provider_for_display
(*`[GdkDisplay](https://developer-old.gnome.org/gtk4/html/GdkDisplay.html#GdkDisplay-struct) *display`*,
*`[GtkStyleProvider](gtkstyleprovider#GtkStyleProvider-struct) *provider`*);
```
Removes *`provider`* from the global style providers list in *`display`* .
#### Parameters
| | | |
| --- | --- | --- |
| display | a [GdkDisplay](https://developer-old.gnome.org/gtk4/html/GdkDisplay.html#GdkDisplay-struct) | |
| provider | a [GtkStyleProvider](gtkstyleprovider#GtkStyleProvider-struct) | |
### gtk\_style\_context\_restore ()
```
void
gtk_style_context_restore (*`[GtkStyleContext](gtkstylecontext#GtkStyleContext-struct) *context`*);
```
Restores *`context`* state to a previous stage. See [`gtk_style_context_save()`](gtkstylecontext#gtk-style-context-save).
#### Parameters
| | | |
| --- | --- | --- |
| context | a [GtkStyleContext](gtkstylecontext#GtkStyleContext-struct) | |
### gtk\_style\_context\_save ()
```
void
gtk_style_context_save (*`[GtkStyleContext](gtkstylecontext#GtkStyleContext-struct) *context`*);
```
Saves the *`context`* state, so temporary modifications done through [`gtk_style_context_add_class()`](gtkstylecontext#gtk-style-context-add-class), [`gtk_style_context_remove_class()`](gtkstylecontext#gtk-style-context-remove-class), [`gtk_style_context_set_state()`](gtkstylecontext#gtk-style-context-set-state), etc. can quickly be reverted in one go through [`gtk_style_context_restore()`](gtkstylecontext#gtk-style-context-restore).
The matching call to [`gtk_style_context_restore()`](gtkstylecontext#gtk-style-context-restore) must be done before GTK returns to the main loop.
#### Parameters
| | | |
| --- | --- | --- |
| context | a [GtkStyleContext](gtkstylecontext#GtkStyleContext-struct) | |
### gtk\_style\_context\_add\_class ()
```
void
gtk_style_context_add_class (*`[GtkStyleContext](gtkstylecontext#GtkStyleContext-struct) *context`*,
*`const char *class_name`*);
```
Adds a style class to *`context`* , so later uses of the style context will make use of this new class for styling.
In the CSS file format, a [GtkEntry](gtkentry#GtkEntry-struct) defining a “search” class, would be matched by:
While any widget defining a “search” class would be matched by:
```
entry.search { ... }
```
| #### Parameters
| | | |
| --- | --- | --- |
| context | a [GtkStyleContext](gtkstylecontext#GtkStyleContext-struct) | |
| class\_name | class name to use in styling | |
### gtk\_style\_context\_remove\_class ()
```
void
gtk_style_context_remove_class (*`[GtkStyleContext](gtkstylecontext#GtkStyleContext-struct) *context`*,
*`const char *class_name`*);
```
Removes *`class_name`* from *`context`* .
#### Parameters
| | | |
| --- | --- | --- |
| context | a [GtkStyleContext](gtkstylecontext#GtkStyleContext-struct) | |
| class\_name | class name to remove | |
### gtk\_style\_context\_has\_class ()
```
gboolean
gtk_style_context_has_class (*`[GtkStyleContext](gtkstylecontext#GtkStyleContext-struct) *context`*,
*`const char *class_name`*);
```
Returns `TRUE` if *`context`* currently has defined the given class name.
#### Parameters
| | | |
| --- | --- | --- |
| context | a [GtkStyleContext](gtkstylecontext#GtkStyleContext-struct) | |
| class\_name | a class name | |
#### Returns
`TRUE` if *`context`* has *`class_name`* defined
### gtk\_style\_context\_set\_display ()
```
void
gtk_style_context_set_display (*`[GtkStyleContext](gtkstylecontext#GtkStyleContext-struct) *context`*,
*`[GdkDisplay](https://developer-old.gnome.org/gtk4/html/GdkDisplay.html#GdkDisplay-struct) *display`*);
```
Attaches *`context`* to the given display.
The display is used to add style information from “global” style providers, such as the display's [GtkSettings](gtksettings#GtkSettings-struct) instance.
If you are using a [GtkStyleContext](gtkstylecontext#GtkStyleContext-struct) returned from [`gtk_widget_get_style_context()`](gtkwidget#gtk-widget-get-style-context), you do not need to call this yourself.
#### Parameters
| | | |
| --- | --- | --- |
| context | a [GtkStyleContext](gtkstylecontext#GtkStyleContext-struct) | |
| display | a [GdkDisplay](https://developer-old.gnome.org/gtk4/html/GdkDisplay.html#GdkDisplay-struct) | |
### gtk\_style\_context\_set\_state ()
```
void
gtk_style_context_set_state (*`[GtkStyleContext](gtkstylecontext#GtkStyleContext-struct) *context`*,
*`[GtkStateFlags](gtk4-standard-enumerations#GtkStateFlags) flags`*);
```
Sets the state to be used for style matching.
#### Parameters
| | | |
| --- | --- | --- |
| context | a [GtkStyleContext](gtkstylecontext#GtkStyleContext-struct) | |
| flags | state to represent | |
### gtk\_style\_context\_set\_scale ()
```
void
gtk_style_context_set_scale (*`[GtkStyleContext](gtkstylecontext#GtkStyleContext-struct) *context`*,
*`int scale`*);
```
Sets the scale to use when getting image assets for the style.
#### Parameters
| | | |
| --- | --- | --- |
| context | a [GtkStyleContext](gtkstylecontext#GtkStyleContext-struct) | |
| scale | scale | |
### gtk\_style\_context\_get\_scale ()
```
int
gtk_style_context_get_scale (*`[GtkStyleContext](gtkstylecontext#GtkStyleContext-struct) *context`*);
```
Returns the scale used for assets.
#### Parameters
| | | |
| --- | --- | --- |
| context | a [GtkStyleContext](gtkstylecontext#GtkStyleContext-struct) | |
#### Returns
the scale
### gtk\_style\_context\_to\_string ()
```
char *
gtk_style_context_to_string (*`[GtkStyleContext](gtkstylecontext#GtkStyleContext-struct) *context`*,
*`[GtkStyleContextPrintFlags](gtkstylecontext#GtkStyleContextPrintFlags) flags`*);
```
Converts the style context into a string representation.
The string representation always includes information about the name, state, id, visibility and style classes of the CSS node that is backing *`context`* . Depending on the flags, more information may be included.
This function is intended for testing and debugging of the CSS implementation in GTK. There are no guarantees about the format of the returned string, it may change.
#### Parameters
| | | |
| --- | --- | --- |
| context | a [GtkStyleContext](gtkstylecontext#GtkStyleContext-struct) | |
| flags | Flags that determine what to print | |
#### Returns
a newly allocated string representing *`context`*
### gtk\_border\_new ()
```
[GtkBorder](gtkstylecontext#GtkBorder) *
gtk_border_new (*`void`*);
```
Allocates a new GtkBorder and initializes its elements to zero.
#### Returns
a newly allocated GtkBorder. Free with [`gtk_border_free()`](gtkstylecontext#gtk-border-free).
[transfer full]
### gtk\_border\_copy ()
```
[GtkBorder](gtkstylecontext#GtkBorder) *
gtk_border_copy (*`const [GtkBorder](gtkstylecontext#GtkBorder) *border_`*);
```
Copies a GtkBorder.
#### Parameters
| | | |
| --- | --- | --- |
| border\_ | a GtkBorder | |
#### Returns
a copy of *`border_`* .
[transfer full]
### gtk\_border\_free ()
```
void
gtk_border_free (*`[GtkBorder](gtkstylecontext#GtkBorder) *border_`*);
```
Frees a GtkBorder.
#### Parameters
| | | |
| --- | --- | --- |
| border\_ | a GtkBorder | |
### gtk\_render\_arrow ()
```
void
gtk_render_arrow (*`[GtkStyleContext](gtkstylecontext#GtkStyleContext-struct) *context`*,
*`[cairo\_t](https://developer-old.gnome.org/cairo/stable/cairo-cairo-t.html#cairo-t) *cr`*,
*`double angle`*,
*`double x`*,
*`double y`*,
*`double size`*);
```
Renders an arrow pointing to *`angle`* .
Typical arrow rendering at 0, 1⁄2 π;, π; and 3⁄2 π:
#### Parameters
| | | |
| --- | --- | --- |
| context | a [GtkStyleContext](gtkstylecontext#GtkStyleContext-struct) | |
| cr | a [cairo\_t](https://developer-old.gnome.org/cairo/stable/cairo-cairo-t.html#cairo-t) | |
| angle | arrow angle from 0 to 2 \* `G_PI`, being 0 the arrow pointing to the north | |
| x | X origin of the render area | |
| y | Y origin of the render area | |
| size | square side for render area | |
### gtk\_render\_background ()
```
void
gtk_render_background (*`[GtkStyleContext](gtkstylecontext#GtkStyleContext-struct) *context`*,
*`[cairo\_t](https://developer-old.gnome.org/cairo/stable/cairo-cairo-t.html#cairo-t) *cr`*,
*`double x`*,
*`double y`*,
*`double width`*,
*`double height`*);
```
Renders the background of an element.
Typical background rendering, showing the effect of `background-image`, `border-width` and `border-radius`:
#### Parameters
| | | |
| --- | --- | --- |
| context | a [GtkStyleContext](gtkstylecontext#GtkStyleContext-struct) | |
| cr | a [cairo\_t](https://developer-old.gnome.org/cairo/stable/cairo-cairo-t.html#cairo-t) | |
| x | X origin of the rectangle | |
| y | Y origin of the rectangle | |
| width | rectangle width | |
| height | rectangle height | |
### gtk\_render\_check ()
```
void
gtk_render_check (*`[GtkStyleContext](gtkstylecontext#GtkStyleContext-struct) *context`*,
*`[cairo\_t](https://developer-old.gnome.org/cairo/stable/cairo-cairo-t.html#cairo-t) *cr`*,
*`double x`*,
*`double y`*,
*`double width`*,
*`double height`*);
```
Renders a checkmark (as in a [GtkCheckButton](gtkcheckbutton#GtkCheckButton-struct)).
The [`GTK_STATE_FLAG_CHECKED`](gtk4-standard-enumerations#GTK-STATE-FLAG-CHECKED:CAPS) state determines whether the check is on or off, and [`GTK_STATE_FLAG_INCONSISTENT`](gtk4-standard-enumerations#GTK-STATE-FLAG-INCONSISTENT:CAPS) determines whether it should be marked as undefined.
Typical checkmark rendering:
#### Parameters
| | | |
| --- | --- | --- |
| context | a [GtkStyleContext](gtkstylecontext#GtkStyleContext-struct) | |
| cr | a [cairo\_t](https://developer-old.gnome.org/cairo/stable/cairo-cairo-t.html#cairo-t) | |
| x | X origin of the rectangle | |
| y | Y origin of the rectangle | |
| width | rectangle width | |
| height | rectangle height | |
### gtk\_render\_expander ()
```
void
gtk_render_expander (*`[GtkStyleContext](gtkstylecontext#GtkStyleContext-struct) *context`*,
*`[cairo\_t](https://developer-old.gnome.org/cairo/stable/cairo-cairo-t.html#cairo-t) *cr`*,
*`double x`*,
*`double y`*,
*`double width`*,
*`double height`*);
```
Renders an expander (as used in [GtkTreeView](gtktreeview#GtkTreeView-struct) and [GtkExpander](gtkexpander#GtkExpander-struct)) in the area defined by *`x`* , *`y`* , *`width`* , *`height`* . The state [`GTK_STATE_FLAG_CHECKED`](gtk4-standard-enumerations#GTK-STATE-FLAG-CHECKED:CAPS) determines whether the expander is collapsed or expanded.
Typical expander rendering:
#### Parameters
| | | |
| --- | --- | --- |
| context | a [GtkStyleContext](gtkstylecontext#GtkStyleContext-struct) | |
| cr | a [cairo\_t](https://developer-old.gnome.org/cairo/stable/cairo-cairo-t.html#cairo-t) | |
| x | X origin of the rectangle | |
| y | Y origin of the rectangle | |
| width | rectangle width | |
| height | rectangle height | |
### gtk\_render\_focus ()
```
void
gtk_render_focus (*`[GtkStyleContext](gtkstylecontext#GtkStyleContext-struct) *context`*,
*`[cairo\_t](https://developer-old.gnome.org/cairo/stable/cairo-cairo-t.html#cairo-t) *cr`*,
*`double x`*,
*`double y`*,
*`double width`*,
*`double height`*);
```
Renders a focus indicator on the rectangle determined by *`x`* , *`y`* , *`width`* , *`height`* .
Typical focus rendering:
#### Parameters
| | | |
| --- | --- | --- |
| context | a [GtkStyleContext](gtkstylecontext#GtkStyleContext-struct) | |
| cr | a [cairo\_t](https://developer-old.gnome.org/cairo/stable/cairo-cairo-t.html#cairo-t) | |
| x | X origin of the rectangle | |
| y | Y origin of the rectangle | |
| width | rectangle width | |
| height | rectangle height | |
### gtk\_render\_frame ()
```
void
gtk_render_frame (*`[GtkStyleContext](gtkstylecontext#GtkStyleContext-struct) *context`*,
*`[cairo\_t](https://developer-old.gnome.org/cairo/stable/cairo-cairo-t.html#cairo-t) *cr`*,
*`double x`*,
*`double y`*,
*`double width`*,
*`double height`*);
```
Renders a frame around the rectangle defined by *`x`* , *`y`* , *`width`* , *`height`* .
Examples of frame rendering, showing the effect of `border-image`, `border-color`, `border-width`, `border-radius` and junctions:
#### Parameters
| | | |
| --- | --- | --- |
| context | a [GtkStyleContext](gtkstylecontext#GtkStyleContext-struct) | |
| cr | a [cairo\_t](https://developer-old.gnome.org/cairo/stable/cairo-cairo-t.html#cairo-t) | |
| x | X origin of the rectangle | |
| y | Y origin of the rectangle | |
| width | rectangle width | |
| height | rectangle height | |
### gtk\_render\_handle ()
```
void
gtk_render_handle (*`[GtkStyleContext](gtkstylecontext#GtkStyleContext-struct) *context`*,
*`[cairo\_t](https://developer-old.gnome.org/cairo/stable/cairo-cairo-t.html#cairo-t) *cr`*,
*`double x`*,
*`double y`*,
*`double width`*,
*`double height`*);
```
Renders a handle (as in [GtkPaned](gtkpaned#GtkPaned-struct) and [GtkWindow](gtkwindow#GtkWindow-struct)’s resize grip), in the rectangle determined by *`x`* , *`y`* , *`width`* , *`height`* .
Handles rendered for the paned and grip classes:
#### Parameters
| | | |
| --- | --- | --- |
| context | a [GtkStyleContext](gtkstylecontext#GtkStyleContext-struct) | |
| cr | a [cairo\_t](https://developer-old.gnome.org/cairo/stable/cairo-cairo-t.html#cairo-t) | |
| x | X origin of the rectangle | |
| y | Y origin of the rectangle | |
| width | rectangle width | |
| height | rectangle height | |
### gtk\_render\_layout ()
```
void
gtk_render_layout (*`[GtkStyleContext](gtkstylecontext#GtkStyleContext-struct) *context`*,
*`[cairo\_t](https://developer-old.gnome.org/cairo/stable/cairo-cairo-t.html#cairo-t) *cr`*,
*`double x`*,
*`double y`*,
*`[PangoLayout](https://developer-old.gnome.org/pango/stable/pango-Layout-Objects.html#PangoLayout-struct) *layout`*);
```
Renders *`layout`* on the coordinates *`x`* , *`y`*
#### Parameters
| | | |
| --- | --- | --- |
| context | a [GtkStyleContext](gtkstylecontext#GtkStyleContext-struct) | |
| cr | a [cairo\_t](https://developer-old.gnome.org/cairo/stable/cairo-cairo-t.html#cairo-t) | |
| x | X origin | |
| y | Y origin | |
| layout | the [PangoLayout](https://developer-old.gnome.org/pango/stable/pango-Layout-Objects.html#PangoLayout-struct) to render | |
### gtk\_render\_line ()
```
void
gtk_render_line (*`[GtkStyleContext](gtkstylecontext#GtkStyleContext-struct) *context`*,
*`[cairo\_t](https://developer-old.gnome.org/cairo/stable/cairo-cairo-t.html#cairo-t) *cr`*,
*`double x0`*,
*`double y0`*,
*`double x1`*,
*`double y1`*);
```
Renders a line from (x0, y0) to (x1, y1).
#### Parameters
| | | |
| --- | --- | --- |
| context | a [GtkStyleContext](gtkstylecontext#GtkStyleContext-struct) | |
| cr | a [cairo\_t](https://developer-old.gnome.org/cairo/stable/cairo-cairo-t.html#cairo-t) | |
| x0 | X coordinate for the origin of the line | |
| y0 | Y coordinate for the origin of the line | |
| x1 | X coordinate for the end of the line | |
| y1 | Y coordinate for the end of the line | |
### gtk\_render\_option ()
```
void
gtk_render_option (*`[GtkStyleContext](gtkstylecontext#GtkStyleContext-struct) *context`*,
*`[cairo\_t](https://developer-old.gnome.org/cairo/stable/cairo-cairo-t.html#cairo-t) *cr`*,
*`double x`*,
*`double y`*,
*`double width`*,
*`double height`*);
```
Renders an option mark (as in a radio button), the [`GTK_STATE_FLAG_CHECKED`](gtk4-standard-enumerations#GTK-STATE-FLAG-CHECKED:CAPS) state will determine whether the option is on or off, and [`GTK_STATE_FLAG_INCONSISTENT`](gtk4-standard-enumerations#GTK-STATE-FLAG-INCONSISTENT:CAPS) whether it should be marked as undefined.
Typical option mark rendering:
#### Parameters
| | | |
| --- | --- | --- |
| context | a [GtkStyleContext](gtkstylecontext#GtkStyleContext-struct) | |
| cr | a [cairo\_t](https://developer-old.gnome.org/cairo/stable/cairo-cairo-t.html#cairo-t) | |
| x | X origin of the rectangle | |
| y | Y origin of the rectangle | |
| width | rectangle width | |
| height | rectangle height | |
### gtk\_render\_activity ()
```
void
gtk_render_activity (*`[GtkStyleContext](gtkstylecontext#GtkStyleContext-struct) *context`*,
*`[cairo\_t](https://developer-old.gnome.org/cairo/stable/cairo-cairo-t.html#cairo-t) *cr`*,
*`double x`*,
*`double y`*,
*`double width`*,
*`double height`*);
```
Renders an activity indicator (such as in [GtkSpinner](gtkspinner#GtkSpinner-struct)). The state [`GTK_STATE_FLAG_CHECKED`](gtk4-standard-enumerations#GTK-STATE-FLAG-CHECKED:CAPS) determines whether there is activity going on.
#### Parameters
| | | |
| --- | --- | --- |
| context | a [GtkStyleContext](gtkstylecontext#GtkStyleContext-struct) | |
| cr | a [cairo\_t](https://developer-old.gnome.org/cairo/stable/cairo-cairo-t.html#cairo-t) | |
| x | X origin of the rectangle | |
| y | Y origin of the rectangle | |
| width | rectangle width | |
| height | rectangle height | |
### gtk\_render\_icon ()
```
void
gtk_render_icon (*`[GtkStyleContext](gtkstylecontext#GtkStyleContext-struct) *context`*,
*`[cairo\_t](https://developer-old.gnome.org/cairo/stable/cairo-cairo-t.html#cairo-t) *cr`*,
*`[GdkTexture](https://developer-old.gnome.org/gtk4/html/gdk4-Textures.html#GdkTexture-struct) *texture`*,
*`double x`*,
*`double y`*);
```
Renders the icon in *`texture`* at the specified *`x`* and *`y`* coordinates.
This function will render the icon in *`texture`* at exactly its size, regardless of scaling factors, which may not be appropriate when drawing on displays with high pixel densities.
#### Parameters
| | | |
| --- | --- | --- |
| context | a [GtkStyleContext](gtkstylecontext#GtkStyleContext-struct) | |
| cr | a [cairo\_t](https://developer-old.gnome.org/cairo/stable/cairo-cairo-t.html#cairo-t) | |
| texture | a [GdkTexture](https://developer-old.gnome.org/gtk4/html/gdk4-Textures.html#GdkTexture-struct) containing the icon to draw | |
| x | X position for the *`texture`* | |
| y | Y position for the *`texture`* | |
Types and Values
----------------
### enum GtkBorderStyle
Describes how the border of a UI element should be rendered.
#### Members
| | | |
| --- | --- | --- |
| GTK\_BORDER\_STYLE\_NONE | No visible border | |
| GTK\_BORDER\_STYLE\_HIDDEN | Same as [`GTK_BORDER_STYLE_NONE`](gtkstylecontext#GTK-BORDER-STYLE-NONE:CAPS) | |
| GTK\_BORDER\_STYLE\_SOLID | A single line segment | |
| GTK\_BORDER\_STYLE\_INSET | Looks as if the content is sunken into the canvas | |
| GTK\_BORDER\_STYLE\_OUTSET | Looks as if the content is coming out of the canvas | |
| GTK\_BORDER\_STYLE\_DOTTED | A series of round dots | |
| GTK\_BORDER\_STYLE\_DASHED | A series of square-ended dashes | |
| GTK\_BORDER\_STYLE\_DOUBLE | Two parallel lines with some space between them | |
| GTK\_BORDER\_STYLE\_GROOVE | Looks as if it were carved in the canvas | |
| GTK\_BORDER\_STYLE\_RIDGE | Looks as if it were coming out of the canvas | |
### GtkStyleContext
```
typedef struct _GtkStyleContext GtkStyleContext;
```
### enum GtkStyleContextPrintFlags
Flags that modify the behavior of [`gtk_style_context_to_string()`](gtkstylecontext#gtk-style-context-to-string). New values may be added to this enumeration.
#### Members
| | | |
| --- | --- | --- |
| GTK\_STYLE\_CONTEXT\_PRINT\_NONE | Default value. | |
| GTK\_STYLE\_CONTEXT\_PRINT\_RECURSE | Print the entire tree of CSS nodes starting at the style context's node | |
| GTK\_STYLE\_CONTEXT\_PRINT\_SHOW\_STYLE | Show the values of the CSS properties for each node | |
| GTK\_STYLE\_CONTEXT\_PRINT\_SHOW\_CHANGE | Show information about what changes affect the styles | |
### struct GtkBorder
```
struct GtkBorder {
gint16 left;
gint16 right;
gint16 top;
gint16 bottom;
};
```
A struct that specifies a border around a rectangular area that can be of different width on each side.
#### Members
| | | |
| --- | --- | --- |
| gint16 *`left`*; | The width of the left border | |
| gint16 *`right`*; | The width of the right border | |
| gint16 *`top`*; | The width of the top border | |
| gint16 *`bottom`*; | The width of the bottom border | |
Property Details
----------------
### The `“display”` property
```
“display” [GdkDisplay](https://developer-old.gnome.org/gtk4/html/GdkDisplay.html#GdkDisplay-struct) *
```
The associated GdkDisplay.
Owner: GtkStyleContext
Flags: Read / Write
| programming_docs |
gtk Overview of the drawing model Overview of the drawing model
=============================
[Windows and events](drawing-overview#drawing-windows) [The frame clock](frameclock) [The scene graph](scene-graph) [Hierarchical drawing](hierarchical-drawing) This chapter describes the GTK drawing model in detail. If you are interested in the procedure which GTK follows to draw its widgets and windows, you should read this chapter; this will be useful to know if you decide to implement your own widgets. This chapter will also clarify the reasons behind the ways certain things are done in GTK.
Applications that use a windowing system generally create rectangular regions in the screen called *surfaces* (GTK is following the Wayland terminology, other windowing systems such as X11 may call these *windows*). Traditional windowing systems do not automatically save the graphical content of surfaces, and instead ask applications to provide new content whenever it is needed. For example, if a window that is stacked below other windows gets raised to the top, then the application has to repaint it, so the previously obscured area can be shown. When the windowing system asks an application to redraw a window, it sends a *frame event* (*expose event* in X11 terminology) for that window.
Each GTK toplevel window or dialog is associated with a windowing system surface. Child widgets such as buttons or entries don’t have their own surface; they use the surface of their toplevel.
Generally, the drawing cycle begins when GTK receives a frame event from the underlying windowing system: if the user drags a window over another one, the windowing system will tell the underlying surface that it needs to repaint itself. The drawing cycle can also be initiated when a widget itself decides that it needs to update its display. For example, when the user types a character in an entry widget, the entry asks GTK to queue a redraw operation for itself.
The windowing system generates frame events for surfaces. The GDK interface to the windowing system translates such events into emissions of the ::render signal on the affected surfaces. The GTK toplevel window connects to that signal, and reacts appropriately.
The following sections describe how GTK decides which widgets need to be repainted in response to such events, and how widgets work internally in terms of the resources they use from the windowing system.
gtk GtkComboBoxText GtkComboBoxText
===============
GtkComboBoxText — A simple, text-only combo box
Functions
---------
| | |
| --- | --- |
| [GtkWidget](gtkwidget#GtkWidget-struct) \* | [gtk\_combo\_box\_text\_new](gtkcomboboxtext#gtk-combo-box-text-new) () |
| [GtkWidget](gtkwidget#GtkWidget-struct) \* | [gtk\_combo\_box\_text\_new\_with\_entry](gtkcomboboxtext#gtk-combo-box-text-new-with-entry) () |
| void | [gtk\_combo\_box\_text\_append](gtkcomboboxtext#gtk-combo-box-text-append) () |
| void | [gtk\_combo\_box\_text\_prepend](gtkcomboboxtext#gtk-combo-box-text-prepend) () |
| void | [gtk\_combo\_box\_text\_insert](gtkcomboboxtext#gtk-combo-box-text-insert) () |
| void | [gtk\_combo\_box\_text\_append\_text](gtkcomboboxtext#gtk-combo-box-text-append-text) () |
| void | [gtk\_combo\_box\_text\_prepend\_text](gtkcomboboxtext#gtk-combo-box-text-prepend-text) () |
| void | [gtk\_combo\_box\_text\_insert\_text](gtkcomboboxtext#gtk-combo-box-text-insert-text) () |
| void | [gtk\_combo\_box\_text\_remove](gtkcomboboxtext#gtk-combo-box-text-remove) () |
| void | [gtk\_combo\_box\_text\_remove\_all](gtkcomboboxtext#gtk-combo-box-text-remove-all) () |
| char \* | [gtk\_combo\_box\_text\_get\_active\_text](gtkcomboboxtext#gtk-combo-box-text-get-active-text) () |
Types and Values
----------------
| | |
| --- | --- |
| | [GtkComboBoxText](gtkcomboboxtext#GtkComboBoxText-struct) |
Object Hierarchy
----------------
```
GObject
╰── GInitiallyUnowned
╰── [GtkWidget](gtkwidget#GtkWidget-struct)
╰── [GtkComboBox](gtkcombobox#GtkComboBox-struct)
╰── GtkComboBoxText
```
Implemented Interfaces
----------------------
GtkComboBoxText implements [GtkAccessible](gtkaccessible#GtkAccessible-struct), [GtkBuildable](gtkbuildable#GtkBuildable-struct), [GtkConstraintTarget](gtkconstraint#GtkConstraintTarget-struct), [GtkCellLayout](gtkcelllayout#GtkCellLayout-struct) and [GtkCellEditable](gtkcelleditable#GtkCellEditable-struct).
Includes
--------
```
#include <gtk/gtk.h>
```
Description
-----------
A GtkComboBoxText is a simple variant of [GtkComboBox](gtkcombobox#GtkComboBox-struct) that hides the model-view complexity for simple text-only use cases.
To create a GtkComboBoxText, use [`gtk_combo_box_text_new()`](gtkcomboboxtext#gtk-combo-box-text-new) or [`gtk_combo_box_text_new_with_entry()`](gtkcomboboxtext#gtk-combo-box-text-new-with-entry).
You can add items to a GtkComboBoxText with [`gtk_combo_box_text_append_text()`](gtkcomboboxtext#gtk-combo-box-text-append-text), [`gtk_combo_box_text_insert_text()`](gtkcomboboxtext#gtk-combo-box-text-insert-text) or [`gtk_combo_box_text_prepend_text()`](gtkcomboboxtext#gtk-combo-box-text-prepend-text) and remove options with [`gtk_combo_box_text_remove()`](gtkcomboboxtext#gtk-combo-box-text-remove).
If the GtkComboBoxText contains an entry (via the “has-entry” property), its contents can be retrieved using [`gtk_combo_box_text_get_active_text()`](gtkcomboboxtext#gtk-combo-box-text-get-active-text). The entry itself can be accessed by calling `gtk_bin_get_child()` on the combo box.
You should not call [`gtk_combo_box_set_model()`](gtkcombobox#gtk-combo-box-set-model) or attempt to pack more cells into this combo box via its GtkCellLayout interface.
### GtkComboBoxText as GtkBuildable
The GtkComboBoxText implementation of the GtkBuildable interface supports adding items directly using the <items> element and specifying <item> elements for each item. Each <item> element can specify the “id” corresponding to the appended text and also supports the regular translation attributes “translatable”, “context” and “comments”.
Here is a UI definition fragment specifying GtkComboBoxText items:
### CSS nodes
```
<object class="GtkComboBoxText">
<items>
<item translatable="yes" id="factory">Factory</item>
<item translatable="yes" id="home">Home</item>
<item translatable="yes" id="subway">Subway</item>
</items>
</object>
```
| GtkComboBoxText has a single CSS node with name combobox. It adds the style class .combo to the main CSS nodes of its entry and button children, and the .linked class to the node of its internal box.
Functions
---------
### gtk\_combo\_box\_text\_new ()
```
[GtkWidget](gtkwidget#GtkWidget-struct) *
gtk_combo_box_text_new (*`void`*);
```
Creates a new [GtkComboBoxText](gtkcomboboxtext#GtkComboBoxText-struct), which is a [GtkComboBox](gtkcombobox#GtkComboBox-struct) just displaying strings.
#### Returns
A new [GtkComboBoxText](gtkcomboboxtext#GtkComboBoxText-struct)
### gtk\_combo\_box\_text\_new\_with\_entry ()
```
[GtkWidget](gtkwidget#GtkWidget-struct) *
gtk_combo_box_text_new_with_entry (*`void`*);
```
Creates a new [GtkComboBoxText](gtkcomboboxtext#GtkComboBoxText-struct), which is a [GtkComboBox](gtkcombobox#GtkComboBox-struct) just displaying strings. The combo box created by this function has an entry.
#### Returns
a new [GtkComboBoxText](gtkcomboboxtext#GtkComboBoxText-struct)
### gtk\_combo\_box\_text\_append ()
```
void
gtk_combo_box_text_append (*`[GtkComboBoxText](gtkcomboboxtext#GtkComboBoxText-struct) *combo_box`*,
*`const char *id`*,
*`const char *text`*);
```
Appends *`text`* to the list of strings stored in *`combo_box`* . If *`id`* is non-`NULL` then it is used as the ID of the row.
This is the same as calling [`gtk_combo_box_text_insert()`](gtkcomboboxtext#gtk-combo-box-text-insert) with a position of -1.
#### Parameters
| | | |
| --- | --- | --- |
| combo\_box | A [GtkComboBoxText](gtkcomboboxtext#GtkComboBoxText-struct) | |
| id | a string ID for this value, or `NULL`. | [allow-none] |
| text | A string | |
### gtk\_combo\_box\_text\_prepend ()
```
void
gtk_combo_box_text_prepend (*`[GtkComboBoxText](gtkcomboboxtext#GtkComboBoxText-struct) *combo_box`*,
*`const char *id`*,
*`const char *text`*);
```
Prepends *`text`* to the list of strings stored in *`combo_box`* . If *`id`* is non-`NULL` then it is used as the ID of the row.
This is the same as calling [`gtk_combo_box_text_insert()`](gtkcomboboxtext#gtk-combo-box-text-insert) with a position of 0.
#### Parameters
| | | |
| --- | --- | --- |
| combo\_box | A [GtkComboBox](gtkcombobox#GtkComboBox-struct) | |
| id | a string ID for this value, or `NULL`. | [allow-none] |
| text | a string | |
### gtk\_combo\_box\_text\_insert ()
```
void
gtk_combo_box_text_insert (*`[GtkComboBoxText](gtkcomboboxtext#GtkComboBoxText-struct) *combo_box`*,
*`int position`*,
*`const char *id`*,
*`const char *text`*);
```
Inserts *`text`* at *`position`* in the list of strings stored in *`combo_box`* . If *`id`* is non-`NULL` then it is used as the ID of the row. See [“id-column”](gtkcombobox#GtkComboBox--id-column).
If *`position`* is negative then *`text`* is appended.
#### Parameters
| | | |
| --- | --- | --- |
| combo\_box | A [GtkComboBoxText](gtkcomboboxtext#GtkComboBoxText-struct) | |
| position | An index to insert *`text`* | |
| id | a string ID for this value, or `NULL`. | [allow-none] |
| text | A string to display | |
### gtk\_combo\_box\_text\_append\_text ()
```
void
gtk_combo_box_text_append_text (*`[GtkComboBoxText](gtkcomboboxtext#GtkComboBoxText-struct) *combo_box`*,
*`const char *text`*);
```
Appends *`text`* to the list of strings stored in *`combo_box`* .
This is the same as calling [`gtk_combo_box_text_insert_text()`](gtkcomboboxtext#gtk-combo-box-text-insert-text) with a position of -1.
#### Parameters
| | | |
| --- | --- | --- |
| combo\_box | A [GtkComboBoxText](gtkcomboboxtext#GtkComboBoxText-struct) | |
| text | A string | |
### gtk\_combo\_box\_text\_prepend\_text ()
```
void
gtk_combo_box_text_prepend_text (*`[GtkComboBoxText](gtkcomboboxtext#GtkComboBoxText-struct) *combo_box`*,
*`const char *text`*);
```
Prepends *`text`* to the list of strings stored in *`combo_box`* .
This is the same as calling [`gtk_combo_box_text_insert_text()`](gtkcomboboxtext#gtk-combo-box-text-insert-text) with a position of 0.
#### Parameters
| | | |
| --- | --- | --- |
| combo\_box | A [GtkComboBox](gtkcombobox#GtkComboBox-struct) | |
| text | A string | |
### gtk\_combo\_box\_text\_insert\_text ()
```
void
gtk_combo_box_text_insert_text (*`[GtkComboBoxText](gtkcomboboxtext#GtkComboBoxText-struct) *combo_box`*,
*`int position`*,
*`const char *text`*);
```
Inserts *`text`* at *`position`* in the list of strings stored in *`combo_box`* .
If *`position`* is negative then *`text`* is appended.
This is the same as calling [`gtk_combo_box_text_insert()`](gtkcomboboxtext#gtk-combo-box-text-insert) with a `NULL` ID string.
#### Parameters
| | | |
| --- | --- | --- |
| combo\_box | A [GtkComboBoxText](gtkcomboboxtext#GtkComboBoxText-struct) | |
| position | An index to insert *`text`* | |
| text | A string | |
### gtk\_combo\_box\_text\_remove ()
```
void
gtk_combo_box_text_remove (*`[GtkComboBoxText](gtkcomboboxtext#GtkComboBoxText-struct) *combo_box`*,
*`int position`*);
```
Removes the string at *`position`* from *`combo_box`* .
#### Parameters
| | | |
| --- | --- | --- |
| combo\_box | A [GtkComboBox](gtkcombobox#GtkComboBox-struct) | |
| position | Index of the item to remove | |
### gtk\_combo\_box\_text\_remove\_all ()
```
void
gtk_combo_box_text_remove_all (*`[GtkComboBoxText](gtkcomboboxtext#GtkComboBoxText-struct) *combo_box`*);
```
Removes all the text entries from the combo box.
#### Parameters
| | | |
| --- | --- | --- |
| combo\_box | A [GtkComboBoxText](gtkcomboboxtext#GtkComboBoxText-struct) | |
### gtk\_combo\_box\_text\_get\_active\_text ()
```
char *
gtk_combo_box_text_get_active_text (*`[GtkComboBoxText](gtkcomboboxtext#GtkComboBoxText-struct) *combo_box`*);
```
Returns the currently active string in *`combo_box`* , or `NULL` if none is selected. If *`combo_box`* contains an entry, this function will return its contents (which will not necessarily be an item from the list).
#### Parameters
| | | |
| --- | --- | --- |
| combo\_box | A [GtkComboBoxText](gtkcomboboxtext#GtkComboBoxText-struct) | |
#### Returns
a newly allocated string containing the currently active text. Must be freed with `g_free()`.
[nullable][transfer full]
Types and Values
----------------
### GtkComboBoxText
```
typedef struct _GtkComboBoxText GtkComboBoxText;
```
See Also
--------
[GtkComboBox](gtkcombobox#GtkComboBox-struct)
gtk Accessibility Accessibility
=============
[GTK Accessibility](accessibility#gtk-accessibility) [The standard accessibility interface](accessibility#id-1.4.25.2.2) [Accessible roles and attributes](accessibility#id-1.4.25.2.3) [Application development rules](accessibility#id-1.4.25.2.4) [Implementations](accessibility#id-1.4.25.2.5) [Authoring practices](accessibility#authoring-practices) [Hiding UI elements from the accessible tree](accessibility#id-1.4.25.2.7) [Design patterns and custom widgets](accessibility#id-1.4.25.2.8) [GtkAccessible](gtkaccessible) — Accessible interface [GtkATContext](gtkatcontext) — An object communicating to Assistive Technologies ### The standard accessibility interface
The [GtkAccessible](gtkaccessible#GtkAccessible-struct) interface provides the accessibility information about an application’s user interface elements. Assistive technology (AT) applications, like Orca, convey this information to users with disabilities, or reduced abilities, to help them use the application.
Standard GTK controls implement the [GtkAccessible](gtkaccessible#GtkAccessible-struct) interface and are thus accessible to ATs by default. This means that if you use GTK controls such as [GtkButton](gtkbutton#GtkButton-struct), [GtkEntry](gtkentry#GtkEntry-struct), or [GtkListView](gtklistview#GtkListView-struct), you only need to supply application-specific details when the defaults values are incomplete. You can do this by setting the appropriate properties in your [GtkBuilder](gtkbuilder#GtkBuilder-struct) template and UI definition files, or by setting the properties defined by the [GtkAccessible](gtkaccessible#GtkAccessible-struct) interface.
If you are implementing your own [GtkWidget](gtkwidget#GtkWidget-struct) derived type, you will need to set the [GtkAccessible](gtkaccessible#GtkAccessible-struct) properties yourself, and provide an implementation of the [GtkAccessible](gtkaccessible#GtkAccessible-struct) virtual functions.
### Accessible roles and attributes
The fundamental concepts of an accessible widget are *roles* and *attributes*; each GTK control has a role, while its functionality is described by a set of *attributes*.
#### Roles
Roles define the taxonomy and semantics of a UI control to any assistive technology application; for instance, a button will have a role of `GTK_ACCESSIBLE_ROLE_BUTTON`; an entry will have a role of `GTK_ACCESSIBLE_ROLE_TEXTBOX`; a toggle button will have a role of `GTK_ACCESSIBLE_ROLE_CHECKBOX`; etc.
Each role is part of the widget’s instance, and **cannot** be changed over time or as the result of a user action. Roles allows assistive technology applications to identify a UI control and decide how to present it to a user; if a part of the application’s UI changes role, the control needs to be removed and replaced with another one with the appropriate role.
##### List of accessible roles
Each role name is part of the [GtkAccessibleRole](gtkaccessible#GtkAccessibleRole) enumeration.
| Role name | Description | Related GTK widget |
| --- | --- | --- |
| `BUTTON` | A control that performs an action when pressed | [GtkButton](gtkbutton#GtkButton-struct), [GtkLinkButton](gtklinkbutton#GtkLinkButton-struct), [GtkExpander](gtkexpander#GtkExpander-struct) |
| `CHECKBOX` | A control that has three possible value: `true`, `false`, or `undefined` | [GtkCheckButton](gtkcheckbutton#GtkCheckButton-struct) |
| `COMBOBOX` | A control that can be expanded to show a list of possible values to select | [GtkComboBox](gtkcombobox#GtkComboBox-struct) |
| `COLUMN_HEADER` | A header in a columned list | [GtkColumnView](gtkcolumnview#GtkColumnView-struct) |
| `DIALOG` | A dialog that prompts the user to enter information or require a response | [GtkDialog](gtkdialog#GtkDialog-struct) and subclasses |
| `GRID` | A grid of items | [GtkFlowBox](gtkflowbox#GtkFlowBox-struct), [GtkGridView](gtkgridview#GtkGridView-struct) |
| `GRID_CELL` | An item in a grid | [GtkFlowBoxChild](gtkflowbox#GtkFlowBoxChild-struct), [GtkGridView](gtkgridview#GtkGridView-struct), [GtkColumnView](gtkcolumnview#GtkColumnView-struct) |
| `IMG` | An image | [GtkImage](gtkimage#GtkImage-struct), [GtkPicture](gtkpicture#GtkPicture-struct) |
| `LABEL` | A visible name or caption for a user interface component | [GtkLabel](gtklabel#GtkLabel-struct) |
| `LINK` | A clickable hyperlink | [GtkLinkButton](gtklinkbutton#GtkLinkButton-struct) |
| `LIST` | A list of items | [GtkListBox](gtklistbox#GtkListBox-struct) |
| `LIST_ITEM` | An item in a list | [GtkListBoxRow](gtklistbox#GtkListBoxRow-struct) |
| `MENU` | A menu | [GtkPopoverMenu](gtkpopovermenu#GtkPopoverMenu-struct) |
| `MENU_BAR` | A menubar | [GtkPopoverMenuBar](gtkpopovermenubar#GtkPopoverMenuBar-struct) |
| `MENU_ITEM` | A menu item | Items in [GtkPopoverMenu](gtkpopovermenu#GtkPopoverMenu-struct) |
| `MENU_ITEM_CHECKBOX` | Check menu item | Items in [GtkPopoverMenu](gtkpopovermenu#GtkPopoverMenu-struct) |
| `MENU_ITEM_RADIO` | Radio menu item | Items in [GtkPopoverMenu](gtkpopovermenu#GtkPopoverMenu-struct) |
| `METER` | Represents a value within a known range | [GtkLevelBar](gtklevelbar#GtkLevelBar-struct) |
| `NONE` | Not represented in the accessibility tree | the slider of a [GtkScale](gtkscale#GtkScale-struct) |
| `PROGRESS_BAR` | An element that display progress | [GtkProgressBar](gtkprogressbar#GtkProgressBar-struct) |
| `RADIO` | A checkable input in a group of radio roles | [GtkCheckButton](gtkcheckbutton#GtkCheckButton-struct) |
| `ROW` | A row in a columned list | [GtkColumnView](gtkcolumnview#GtkColumnView-struct) |
| `SCROLLBAR` | A graphical object controlling the scrolling of content | [GtkScrollbar](gtkscrollbar#GtkScrollbar-struct) |
| `SEARCH_BOX` | A text box for entering search criteria | [GtkSearchEntry](gtksearchentry#GtkSearchEntry-struct) |
| `SEPARATOR` | A divider that separates sections of content or groups of items | [GtkSeparator](gtkseparator#GtkSeparator-struct) |
| `SPIN_BUTTON` | A range control that allows seelcting among discrete choices | [GtkSpinButton](gtkspinbutton#GtkSpinButton-struct) |
| `SWITCH` | A control that represents on/off values | [GtkSwitch](gtkswitch#GtkSwitch-struct) |
| `TAB` | A tab in a list of tabs for switching pages | [GtkStackSwitcher](gtkstackswitcher#GtkStackSwitcher-struct), [GtkNotebook](gtknotebook#GtkNotebook-struct) |
| `TAB_LIST` | A list of tabs for switching pages | [GtkStackSwitcher](gtkstackswitcher#GtkStackSwitcher-struct), [GtkNotebook](gtknotebook#GtkNotebook-struct) |
| `TAB_PANEL` | A page in a notebook or stack | [GtkStack](gtkstack#GtkStack-struct) |
| `TEXT_BOX` | A type of input that allows free-form text as its value. | [GtkEntry](gtkentry#GtkEntry-struct), [GtkPasswordEntry](gtkpasswordentry#GtkPasswordEntry-struct), [GtkTextView](gtktextview#GtkTextView-struct) |
| `TREE_GRID` | A treeview-like columned list | [GtkColumnView](gtkcolumnview#GtkColumnView-struct) |
| `WINDOW` | An application window | [GtkWindow](gtkwindow#GtkWindow-struct) |
| `...` | … | |
See the [WAI-ARIA](https://www.w3.org/WAI/PF/aria/appendices#quickref) list of roles for additional information.
#### Attributes
Attributes provide specific information about an accessible UI control, and describe it for the assistive technology applications. GTK divides the accessible attributes into three categories:
* *properties*, described by the values of the [GtkAccessibleProperty](gtkaccessible#GtkAccessibleProperty) enumeration
* *relations*, described by the values of the [GtkAccessibleRelation](gtkaccessible#GtkAccessibleRelation) enumeration
* *states*, described by the values of the [GtkAccessibleState](gtkaccessible#GtkAccessibleState) enumeration
Each attribute accepts a value of a specific type.
Unlike roles, attributes may change over time, or in response to user action; for instance:
* a toggle button will change its [`GTK_ACCESSIBLE_STATE_CHECKED`](gtkaccessible#GTK-ACCESSIBLE-STATE-CHECKED:CAPS) state every time it is toggled, either by the user or programmatically
* setting the mnemonic widget on a [GtkLabel](gtklabel#GtkLabel-struct) will update the [`GTK_ACCESSIBLE_RELATION_LABELLED_BY`](gtkaccessible#GTK-ACCESSIBLE-RELATION-LABELLED-BY:CAPS) relation on the widget with a reference to the label
* changing the [GtkAdjustment](gtkadjustment#GtkAdjustment-struct) instance on a [GtkScrollbar](gtkscrollbar#GtkScrollbar-struct) will change the [`GTK_ACCESSIBLE_PROPERTY_VALUE_MAX`](gtkaccessible#GTK-ACCESSIBLE-PROPERTY-VALUE-MAX:CAPS), [`GTK_ACCESSIBLE_PROPERTY_VALUE_MIN`](gtkaccessible#GTK-ACCESSIBLE-PROPERTY-VALUE-MIN:CAPS), and [`GTK_ACCESSIBLE_PROPERTY_VALUE_NOW`](gtkaccessible#GTK-ACCESSIBLE-PROPERTY-VALUE-NOW:CAPS) properties with the upper, lower, and value properties of the [GtkAdjustment](gtkadjustment#GtkAdjustment-struct)
See the [WAI-ARIA](https://www.w3.org/WAI/PF/aria/appendices#quickref) list of attributes for additional information.
##### List of accessible states
Each state name is part of the [GtkAccessibleState](gtkaccessible#GtkAccessibleState) enumeration.
| State name | ARIA attribute | Value type | Notes |
| --- | --- | --- | --- |
| [`GTK_ACCESSIBLE_STATE_BUSY`](gtkaccessible#GTK-ACCESSIBLE-STATE-BUSY:CAPS) | “aria-busy” | boolean | |
| [`GTK_ACCESSIBLE_STATE_CHECKED`](gtkaccessible#GTK-ACCESSIBLE-STATE-CHECKED:CAPS) | “aria-checked” | [GtkAccessibleTristate](gtkaccessible#GtkAccessibleTristate) | Indicates the current state of a [GtkCheckButton](gtkcheckbutton#GtkCheckButton-struct) |
| [`GTK_ACCESSIBLE_STATE_DISABLED`](gtkaccessible#GTK-ACCESSIBLE-STATE-DISABLED:CAPS) | “aria-disabled” | boolean | Corresponds to the [“sensitive”](gtkwidget#GtkWidget--sensitive) property on [GtkWidget](gtkwidget#GtkWidget-struct) |
| [`GTK_ACCESSIBLE_STATE_EXPANDED`](gtkaccessible#GTK-ACCESSIBLE-STATE-EXPANDED:CAPS) | “aria-expanded” | boolean or undefined | Corresponds to the [“expanded”](gtkexpander#GtkExpander--expanded) property on [GtkExpander](gtkexpander#GtkExpander-struct) |
| [`GTK_ACCESSIBLE_STATE_HIDDEN`](gtkaccessible#GTK-ACCESSIBLE-STATE-HIDDEN:CAPS) | “aria-hidden” | boolean | Corresponds to the [“visible”](gtkwidget#GtkWidget--visible) property on [GtkWidget](gtkwidget#GtkWidget-struct) |
| [`GTK_ACCESSIBLE_STATE_INVALID`](gtkaccessible#GTK-ACCESSIBLE-STATE-INVALID:CAPS) | “aria-invalid” | [GtkAccessibleInvalidState](gtkaccessible#GtkAccessibleInvalidState) | Set when a widget is showing an error |
| [`GTK_ACCESSIBLE_STATE_PRESSED`](gtkaccessible#GTK-ACCESSIBLE-STATE-PRESSED:CAPS) | “aria-pressed” | [GtkAccessibleTristate](gtkaccessible#GtkAccessibleTristate) | Indicates the current state of a [GtkToggleButton](gtktogglebutton#GtkToggleButton-struct) |
| [`GTK_ACCESSIBLE_STATE_SELECTED`](gtkaccessible#GTK-ACCESSIBLE-STATE-SELECTED:CAPS) | “aria-selected” | boolean or undefined | Set when a widget is selected |
##### List of accessible properties
Each property name is part of the [GtkAccessibleProperty](gtkaccessible#GtkAccessibleProperty) enumeration.
| State name | ARIA attribute | Value type |
| --- | --- | --- |
| [`GTK_ACCESSIBLE_PROPERTY_AUTOCOMPLETE`](gtkaccessible#GTK-ACCESSIBLE-PROPERTY-AUTOCOMPLETE:CAPS) | “aria-autocomplete” | [GtkAccessibleAutocomplete](gtkaccessible#GtkAccessibleAutocomplete) |
| [`GTK_ACCESSIBLE_PROPERTY_DESCRIPTION`](gtkaccessible#GTK-ACCESSIBLE-PROPERTY-DESCRIPTION:CAPS) | “aria-description” | translatable string |
| [`GTK_ACCESSIBLE_PROPERTY_HAS_POPUP`](gtkaccessible#GTK-ACCESSIBLE-PROPERTY-HAS-POPUP:CAPS) | “aria-haspopup” | boolean |
| [`GTK_ACCESSIBLE_PROPERTY_KEY_SHORTCUTS`](gtkaccessible#GTK-ACCESSIBLE-PROPERTY-KEY-SHORTCUTS:CAPS) | “aria-keyshortcuts” | string |
| [`GTK_ACCESSIBLE_PROPERTY_LABEL`](gtkaccessible#GTK-ACCESSIBLE-PROPERTY-LABEL:CAPS) | “aria-label” | translatable string |
| [`GTK_ACCESSIBLE_PROPERTY_LEVEL`](gtkaccessible#GTK-ACCESSIBLE-PROPERTY-LEVEL:CAPS) | “aria-level” | integer |
| [`GTK_ACCESSIBLE_PROPERTY_MODAL`](gtkaccessible#GTK-ACCESSIBLE-PROPERTY-MODAL:CAPS) | “aria-modal” | boolean |
| [`GTK_ACCESSIBLE_PROPERTY_MULTI_LINE`](gtkaccessible#GTK-ACCESSIBLE-PROPERTY-MULTI-LINE:CAPS) | “aria-multiline” | boolean |
| [`GTK_ACCESSIBLE_PROPERTY_MULTI_SELECTABLE`](gtkaccessible#GTK-ACCESSIBLE-PROPERTY-MULTI-SELECTABLE:CAPS) | “aria-multiselectable” | boolean |
| [`GTK_ACCESSIBLE_PROPERTY_ORIENTATION`](gtkaccessible#GTK-ACCESSIBLE-PROPERTY-ORIENTATION:CAPS) | “aria-orientation” | [GtkOrientation](gtk4-standard-enumerations#GtkOrientation) |
| [`GTK_ACCESSIBLE_PROPERTY_PLACEHOLDER`](gtkaccessible#GTK-ACCESSIBLE-PROPERTY-PLACEHOLDER:CAPS) | “aria-placeholder” | translatable string |
| [`GTK_ACCESSIBLE_PROPERTY_READ_ONLY`](gtkaccessible#GTK-ACCESSIBLE-PROPERTY-READ-ONLY:CAPS) | “aria-readonly” | boolean |
| [`GTK_ACCESSIBLE_PROPERTY_REQUIRED`](gtkaccessible#GTK-ACCESSIBLE-PROPERTY-REQUIRED:CAPS) | “aria-required” | boolean |
| [`GTK_ACCESSIBLE_PROPERTY_ROLE_DESCRIPTION`](gtkaccessible#GTK-ACCESSIBLE-PROPERTY-ROLE-DESCRIPTION:CAPS) | “aria-roledescription” | translatable string |
| [`GTK_ACCESSIBLE_PROPERTY_SORT`](gtkaccessible#GTK-ACCESSIBLE-PROPERTY-SORT:CAPS) | “aria-sort” | [GtkAccessibleSort](gtkaccessible#GtkAccessibleSort) |
| [`GTK_ACCESSIBLE_PROPERTY_VALUE_MAX`](gtkaccessible#GTK-ACCESSIBLE-PROPERTY-VALUE-MAX:CAPS) | “aria-valuemax” | double |
| [`GTK_ACCESSIBLE_PROPERTY_VALUE_MIN`](gtkaccessible#GTK-ACCESSIBLE-PROPERTY-VALUE-MIN:CAPS) | “aria-valuemin” | double |
| [`GTK_ACCESSIBLE_PROPERTY_VALUE_NOW`](gtkaccessible#GTK-ACCESSIBLE-PROPERTY-VALUE-NOW:CAPS) | “aria-valuenow” | double |
| [`GTK_ACCESSIBLE_PROPERTY_VALUE_TEXT`](gtkaccessible#GTK-ACCESSIBLE-PROPERTY-VALUE-TEXT:CAPS) | “aria-valuetext” | translatable string |
##### List of accessible relations
Each relation name is part of the [GtkAccessibleRelation](gtkaccessible#GtkAccessibleRelation) enumeration.
| State name | ARIA attribute | Value type |
| --- | --- | --- |
| [`GTK_ACCESSIBLE_RELATION_ACTIVE_DESCENDANT`](gtkaccessible#GTK-ACCESSIBLE-RELATION-ACTIVE-DESCENDANT:CAPS) | “aria-activedescendant” | [GtkAccessible](gtkaccessible#GtkAccessible-struct) |
| [`GTK_ACCESSIBLE_RELATION_COL_COUNT`](gtkaccessible#GTK-ACCESSIBLE-RELATION-COL-COUNT:CAPS) | “aria-colcount” | integer |
| [`GTK_ACCESSIBLE_RELATION_COL_INDEX`](gtkaccessible#GTK-ACCESSIBLE-RELATION-COL-INDEX:CAPS) | “aria-colindex” | integer |
| [`GTK_ACCESSIBLE_RELATION_COL_INDEX_TEXT`](gtkaccessible#GTK-ACCESSIBLE-RELATION-COL-INDEX-TEXT:CAPS) | “aria-colindextext” | translatable string |
| [`GTK_ACCESSIBLE_RELATION_COL_SPAN`](gtkaccessible#GTK-ACCESSIBLE-RELATION-COL-SPAN:CAPS) | “aria-colspan” | integer |
| [`GTK_ACCESSIBLE_RELATION_CONTROLS`](gtkaccessible#GTK-ACCESSIBLE-RELATION-CONTROLS:CAPS) | “aria-controls” | a list of [GtkAccessible](gtkaccessible#GtkAccessible-struct) |
| [`GTK_ACCESSIBLE_RELATION_DESCRIBED_BY`](gtkaccessible#GTK-ACCESSIBLE-RELATION-DESCRIBED-BY:CAPS) | “aria-describedby” | a list of [GtkAccessible](gtkaccessible#GtkAccessible-struct) |
| [`GTK_ACCESSIBLE_RELATION_DETAILS`](gtkaccessible#GTK-ACCESSIBLE-RELATION-DETAILS:CAPS) | “aria-details” | a list of [GtkAccessible](gtkaccessible#GtkAccessible-struct) |
| [`GTK_ACCESSIBLE_RELATION_ERROR_MESSAGE`](gtkaccessible#GTK-ACCESSIBLE-RELATION-ERROR-MESSAGE:CAPS) | “aria-errormessage” | [GtkAccessible](gtkaccessible#GtkAccessible-struct) |
| [`GTK_ACCESSIBLE_RELATION_FLOW_TO`](gtkaccessible#GTK-ACCESSIBLE-RELATION-FLOW-TO:CAPS) | “aria-flowto” | a list of [GtkAccessible](gtkaccessible#GtkAccessible-struct) |
| [`GTK_ACCESSIBLE_RELATION_LABELLED_BY`](gtkaccessible#GTK-ACCESSIBLE-RELATION-LABELLED-BY:CAPS) | “aria-labelledby” | a list of [GtkAccessible](gtkaccessible#GtkAccessible-struct) |
| [`GTK_ACCESSIBLE_RELATION_OWNS`](gtkaccessible#GTK-ACCESSIBLE-RELATION-OWNS:CAPS) | “aria-owns” | a list of [GtkAccessible](gtkaccessible#GtkAccessible-struct) |
| [`GTK_ACCESSIBLE_RELATION_POS_IN_SET`](gtkaccessible#GTK-ACCESSIBLE-RELATION-POS-IN-SET:CAPS) | “aria-posinset” | integer |
| [`GTK_ACCESSIBLE_RELATION_ROW_COUNT`](gtkaccessible#GTK-ACCESSIBLE-RELATION-ROW-COUNT:CAPS) | “aria-rowcount” | integer |
| [`GTK_ACCESSIBLE_RELATION_ROW_INDEX`](gtkaccessible#GTK-ACCESSIBLE-RELATION-ROW-INDEX:CAPS) | “aria-rowindex” | integer |
| [`GTK_ACCESSIBLE_RELATION_ROW_INDEX_TEXT`](gtkaccessible#GTK-ACCESSIBLE-RELATION-ROW-INDEX-TEXT:CAPS) | “aria-rowindextext” | translatable string |
| [`GTK_ACCESSIBLE_RELATION_ROW_SPAN`](gtkaccessible#GTK-ACCESSIBLE-RELATION-ROW-SPAN:CAPS) | “aria-rowspan” | integer |
| [`GTK_ACCESSIBLE_RELATION_SET_SIZE`](gtkaccessible#GTK-ACCESSIBLE-RELATION-SET-SIZE:CAPS) | “aria-setsize” | integer |
*Note*: When using [`gtk_accessible_update_relation()`](gtkaccessible#gtk-accessible-update-relation) with a relation that requires a list of [GtkAccessible](gtkaccessible#GtkAccessible-struct) instances, you should pass every accessible object separately, followed by `NULL`.
### Application development rules
Even if standard UI controls provided by GTK have accessibility information out of the box, there are some additional properties and considerations for application developers. For instance, if your application presents the user with a form to fill out, you should ensure that:
* the container of the form has a `GTK_ACCESSIBLE_ROLE_FORM` role
* each text entry widget in the form has the `GTK_ACCESSIBLE_RELATION_LABELLED_BY` relation pointing to the label widget that describes it
Another example: if you create a toolbar containing buttons with only icons, you should ensure that:
* the container has a `GTK_ACCESSIBLE_ROLE_TOOLBAR` role
* each button has a `GTK_ACCESSIBLE_PROPERTY_LABEL` property set with the user readable and localised action performed when pressed; for instance “Copy”, “Paste”, “Add layer”, or “Remove”
GTK will try to fill in some information by using ancillary UI control properties, for instance the accessible label will be taken from the label or placeholder text used by the UI control, or from its tooltip, if the `GTK_ACCESSIBLE_PROPERTY_LABEL` property or the `GTK_ACCESSIBLE_RELATION_LABELLED_BY` relation are unset. Nevertheless, it is good practice and project hygiene to explicitly specify the accessible properties, just like it’s good practice to specify tooltips and style classes.
Application developers using GTK **should** ensure that their UI controls are accessible as part of the development process. When using `GtkBuilder` templates and UI definition files, GTK provides a validation tool that verifies that each UI element has a valid role and properties; this tool can be used as part of the application’s test suite to avoid regressions.
### Implementations
Each UI control implements the [GtkAccessible](gtkaccessible#GtkAccessible-struct) interface to allow widget and application developers to specify the roles, state, and relations between UI controls. This API is purely descriptive.
Each `GtkAccessible` implementation must provide a [GtkATContext](gtkatcontext#GtkATContext-struct) instance, which acts as a proxy to the specific platform’s accessibility API:
* AT-SPI on Linux/BSD
* NSAccessibility on macOS
* Active Accessibility on Windows
Additionally, an ad hoc accessibility backend is available for the GTK testsuite, to ensure reproducibility of issues in the CI pipeline.
### Authoring practices
The authoring practices are aimed at application developers, as well as developers of GUI elements based on GTK.
Functionally, [GtkAccessible](gtkaccessible#GtkAccessible-struct) roles, states, properties, and relations are analogous to a CSS for assistive technologies. For screen reader users, for instance, the various accessible attributes control the rendering of their non-visual experience. Incorrect roles and attributes may result in a completely inaccessible user interface.
#### A role is a promise
The following code:
```
gtk_widget_class_set_accessible_role (widget_class, GTK_ACCESSIBLE_ROLE_BUTTON);
```
is a promise that the widget being created will provide the same keyboard interactions expected for a button. An accessible role of a button will not turn automatically any widget into a [GtkButton](gtkbutton#GtkButton-struct); but if your widget behaves like a button, using the [`GTK_ACCESSIBLE_ROLE_BUTTON`](gtkaccessible#GTK-ACCESSIBLE-ROLE-BUTTON:CAPS) will allow any assistive technology to handle it like they would a [GtkButton](gtkbutton#GtkButton-struct).
#### Attributes can both hide and enhance
Accessible attributes can be used to override the content of a UI element, for instance:
```
gtk_label_set_text (GTK_LABEL (label), "Some text");
gtk_accessible_update_property (GTK_ACCESSIBLE (label),
GTK_ACCESSIBLE_PROPERTY_LABEL,
"Assistive technologies users will perceive "
"this text, not the contents of the label",
-1);
```
In the example above, the “label” property will override the contents of the label widget.
The attributes can also enhance the UI:
```
gtk_button_set_label (GTK_BUTTON (button), "Download");
gtk_box_append (GTK_BOX (button), button);
gtk_label_set_text (GTK_LABEL (label), "Final report.pdf");
gtk_box_append (GTK_BOX (box), label);
gtk_accessible_update_relation (GTK_ACCESSIBLE (button),
GTK_ACCESSIBLE_RELATION_LABELLED_BY,
g_list_append (NULL, label),
-1);
```
In the example above, an assistive technology will read the button’s accessible label as “Download Final report.pdf”.
The power of hiding and enhancing can be a double-edged sword, as it can lead to inadvertently overriding the accessible semantics of existing widgets.
### Hiding UI elements from the accessible tree
The accessibility API is mainly used to express semantics useful for assistive technologies, but it can also be used to hide elements. The canonical way to do so is to use the [`GTK_ACCESSIBLE_ROLE_PRESENTATION`](gtkaccessible#GTK-ACCESSIBLE-ROLE-PRESENTATION:CAPS), which declares that a UI element is purely meant for presentation purposes, and as such it has no meaningful impact on the accessibility of the interface.
A “presentation” role should not be confused with the [`GTK_ACCESSIBLE_STATE_HIDDEN`](gtkaccessible#GTK-ACCESSIBLE-STATE-HIDDEN:CAPS) state; the “hidden” state is transient, and is typically controlled by showing and hiding a widget using the [GtkWidget](gtkwidget#GtkWidget-struct) API.
### Design patterns and custom widgets
When creating custom widgets, following established patterns can help ensuring that the widgets work well for users of accessible technologies as well.
#### Buttons
A button is a widget that enables users to trigger an action. While it is recommended you use [GtkButton](gtkbutton#GtkButton-struct) for anything that looks and behaves like a button, it is possible to apply a button behavior to UI elements like images by using a [GtkGestureClick](gtkgestureclick#GtkGestureClick-struct) gesture. When doing so, you should:
* Give your widget the role [`GTK_ACCESSIBLE_ROLE_BUTTON`](gtkaccessible#GTK-ACCESSIBLE-ROLE-BUTTON:CAPS)
* Install an action with no parameters, which will activate the widget
#### Custom entries
For custom entries, it is highly recommended that you implement the [GtkEditable](gtkeditable#GtkEditable-struct) interface by using a [GtkText](gtktext#GtkText-struct) widget as delegate. If you do this, GTK will make your widgets text editing functionality accessible in the same way as a [GtkSpinButton](gtkspinbutton#GtkSpinButton-struct) or [GtkSearchEntry](gtksearchentry#GtkSearchEntry-struct).
#### Tab-based UI
If you make a tab-based interface, you should consider using [GtkStack](gtkstack#GtkStack-struct) as the core, and just make a custom tab widget to control the active stack page. When doing so, the following extra steps will ensure that your tabs are accessible in the same way as [GtkStackSwitcher](gtkstackswitcher#GtkStackSwitcher-struct) or [GtkNotebook](gtknotebook#GtkNotebook-struct):
* Give your tab container the role [`GTK_ACCESSIBLE_ROLE_TAB_LIST`](gtkaccessible#GTK-ACCESSIBLE-ROLE-TAB-LIST:CAPS)
* Give your tab widgets the role [`GTK_ACCESSIBLE_ROLE_TAB`](gtkaccessible#GTK-ACCESSIBLE-ROLE-TAB:CAPS)
* Set up the [`GTK_ACCESSIBLE_RELATION_CONTROLS`](gtkaccessible#GTK-ACCESSIBLE-RELATION-CONTROLS:CAPS) relation between each tab and the [GtkStackPage](gtkstack#GtkStackPage-struct) object for its page
* Set the `GTK_ACCESSIBLE_PROPERTY_SELECTED` property on each tab, with the active tab getting the value `TRUE`, all others `FALSE`
To allow changing the active tab via accessible technologies, you can export actions. Since the accessibility interfaces only support actions without parameters, you can either provide `previous-tab` and `next-tab` actions on the tab container that let users step through the tabs one-by-one, or add a `activate-tab` action on each tab.
#### Value controls
A value control (ie a widget that controls a one-dimensional quantity that can be represented by a [GtkAdjustment](gtkadjustment#GtkAdjustment-struct)) can be represented to accessible technologies by setting the [`GTK_ACCESSIBLE_PROPERTY_VALUE_MIN`](gtkaccessible#GTK-ACCESSIBLE-PROPERTY-VALUE-MIN:CAPS), [`GTK_ACCESSIBLE_PROPERTY_VALUE_MAX`](gtkaccessible#GTK-ACCESSIBLE-PROPERTY-VALUE-MAX:CAPS), and [`GTK_ACCESSIBLE_PROPERTY_VALUE_NOW`](gtkaccessible#GTK-ACCESSIBLE-PROPERTY-VALUE-NOW:CAPS) properties.
To allow changing the value via accessible technologies, you can export actions. Since the accessibility interfaces only support actions without parameters, you should provide actions such as `increase-value` and `decrease-value`.
| programming_docs |
gtk GtkGesture GtkGesture
==========
GtkGesture — Base class for gestures
Functions
---------
| | |
| --- | --- |
| [GdkDevice](https://developer-old.gnome.org/gtk4/html/GdkDevice.html#GdkDevice-struct) \* | [gtk\_gesture\_get\_device](gtkgesture#gtk-gesture-get-device) () |
| gboolean | [gtk\_gesture\_is\_active](gtkgesture#gtk-gesture-is-active) () |
| gboolean | [gtk\_gesture\_is\_recognized](gtkgesture#gtk-gesture-is-recognized) () |
| [GtkEventSequenceState](gtkgesture#GtkEventSequenceState) | [gtk\_gesture\_get\_sequence\_state](gtkgesture#gtk-gesture-get-sequence-state) () |
| gboolean | [gtk\_gesture\_set\_sequence\_state](gtkgesture#gtk-gesture-set-sequence-state) () |
| gboolean | [gtk\_gesture\_set\_state](gtkgesture#gtk-gesture-set-state) () |
| GList \* | [gtk\_gesture\_get\_sequences](gtkgesture#gtk-gesture-get-sequences) () |
| gboolean | [gtk\_gesture\_handles\_sequence](gtkgesture#gtk-gesture-handles-sequence) () |
| [GdkEventSequence](https://developer-old.gnome.org/gtk4/html/gdk4-Events.html#GdkEventSequence) \* | [gtk\_gesture\_get\_last\_updated\_sequence](gtkgesture#gtk-gesture-get-last-updated-sequence) () |
| [GdkEvent](https://developer-old.gnome.org/gtk4/html/gdk4-Events.html#GdkEvent-struct) \* | [gtk\_gesture\_get\_last\_event](gtkgesture#gtk-gesture-get-last-event) () |
| gboolean | [gtk\_gesture\_get\_point](gtkgesture#gtk-gesture-get-point) () |
| gboolean | [gtk\_gesture\_get\_bounding\_box](gtkgesture#gtk-gesture-get-bounding-box) () |
| gboolean | [gtk\_gesture\_get\_bounding\_box\_center](gtkgesture#gtk-gesture-get-bounding-box-center) () |
| void | [gtk\_gesture\_group](gtkgesture#gtk-gesture-group) () |
| void | [gtk\_gesture\_ungroup](gtkgesture#gtk-gesture-ungroup) () |
| GList \* | [gtk\_gesture\_get\_group](gtkgesture#gtk-gesture-get-group) () |
| gboolean | [gtk\_gesture\_is\_grouped\_with](gtkgesture#gtk-gesture-is-grouped-with) () |
Properties
----------
| | | |
| --- | --- | --- |
| guint | [n-points](gtkgesture#GtkGesture--n-points) | Read / Write / Construct Only |
Signals
-------
| | | |
| --- | --- | --- |
| void | [begin](gtkgesture#GtkGesture-begin) | Run Last |
| void | [cancel](gtkgesture#GtkGesture-cancel) | Run Last |
| void | [end](gtkgesture#GtkGesture-end) | Run Last |
| void | [sequence-state-changed](gtkgesture#GtkGesture-sequence-state-changed) | Run Last |
| void | [update](gtkgesture#GtkGesture-update) | Run Last |
Types and Values
----------------
| | |
| --- | --- |
| | [GtkGesture](gtkgesture#GtkGesture-struct) |
| enum | [GtkEventSequenceState](gtkgesture#GtkEventSequenceState) |
Object Hierarchy
----------------
```
GObject
╰── [GtkEventController](gtkeventcontroller#GtkEventController-struct)
╰── GtkGesture
├── [GtkGestureSingle](gtkgesturesingle#GtkGestureSingle-struct)
├── [GtkGestureRotate](gtkgesturerotate#GtkGestureRotate-struct)
╰── [GtkGestureZoom](gtkgesturezoom#GtkGestureZoom-struct)
```
Includes
--------
```
#include <gtk/gtk.h>
```
Description
-----------
[GtkGesture](gtkgesture#GtkGesture-struct) is the base object for gesture recognition, although this object is quite generalized to serve as a base for multi-touch gestures, it is suitable to implement single-touch and pointer-based gestures (using the special `NULL` [GdkEventSequence](https://developer-old.gnome.org/gtk4/html/gdk4-Events.html#GdkEventSequence) value for these).
The number of touches that a [GtkGesture](gtkgesture#GtkGesture-struct) need to be recognized is controlled by the [“n-points”](gtkgesture#GtkGesture--n-points) property, if a gesture is keeping track of less or more than that number of sequences, it won't check whether the gesture is recognized.
As soon as the gesture has the expected number of touches, it will check regularly if it is recognized, the criteria to consider a gesture as "recognized" is left to [GtkGesture](gtkgesture#GtkGesture-struct) subclasses.
A recognized gesture will then emit the following signals:
* [“begin”](gtkgesture#GtkGesture-begin) when the gesture is recognized.
* A number of [“update”](gtkgesture#GtkGesture-update), whenever an input event is processed.
* [“end”](gtkgesture#GtkGesture-end) when the gesture is no longer recognized.
#### Event propagation
In order to receive events, a gesture needs to set a propagation phase through [`gtk_event_controller_set_propagation_phase()`](gtkeventcontroller#gtk-event-controller-set-propagation-phase).
In the capture phase, events are propagated from the toplevel down to the target widget, and gestures that are attached to containers above the widget get a chance to interact with the event before it reaches the target.
In the bubble phase, events are propagated up from the target widget to the toplevel, and gestures that are attached to containers above the widget get a chance to interact with events that have not been handled yet.
#### States of a sequence
Whenever input interaction happens, a single event may trigger a cascade of GtkGestures, both across the parents of the widget receiving the event and in parallel within an individual widget. It is a responsibility of the widgets using those gestures to set the state of touch sequences accordingly in order to enable cooperation of gestures around the GdkEventSequences triggering those.
Within a widget, gestures can be grouped through [`gtk_gesture_group()`](gtkgesture#gtk-gesture-group), grouped gestures synchronize the state of sequences, so calling [`gtk_gesture_set_sequence_state()`](gtkgesture#gtk-gesture-set-sequence-state) on one will effectively propagate the state throughout the group.
By default, all sequences start out in the [GTK\_EVENT\_SEQUENCE\_NONE](gtkgesture#GTK-EVENT-SEQUENCE-NONE:CAPS) state, sequences in this state trigger the gesture event handler, but event propagation will continue unstopped by gestures.
If a sequence enters into the [GTK\_EVENT\_SEQUENCE\_DENIED](gtkgesture#GTK-EVENT-SEQUENCE-DENIED:CAPS) state, the gesture group will effectively ignore the sequence, letting events go unstopped through the gesture, but the "slot" will still remain occupied while the touch is active.
If a sequence enters in the [GTK\_EVENT\_SEQUENCE\_CLAIMED](gtkgesture#GTK-EVENT-SEQUENCE-CLAIMED:CAPS) state, the gesture group will grab all interaction on the sequence, by:
* Setting the same sequence to [GTK\_EVENT\_SEQUENCE\_DENIED](gtkgesture#GTK-EVENT-SEQUENCE-DENIED:CAPS) on every other gesture group within the widget, and every gesture on parent widgets in the propagation chain.
* calling [“cancel”](gtkgesture#GtkGesture-cancel) on every gesture in widgets underneath in the propagation chain.
* Stopping event propagation after the gesture group handles the event.
Note: if a sequence is set early to [GTK\_EVENT\_SEQUENCE\_CLAIMED](gtkgesture#GTK-EVENT-SEQUENCE-CLAIMED:CAPS) on [GDK\_TOUCH\_BEGIN](https://developer-old.gnome.org/gtk4/html/gdk4-Events.html#GDK-TOUCH-BEGIN:CAPS)/[GDK\_BUTTON\_PRESS](https://developer-old.gnome.org/gtk4/html/gdk4-Events.html#GDK-BUTTON-PRESS:CAPS) (so those events are captured before reaching the event widget, this implies [GTK\_PHASE\_CAPTURE](gtkeventcontroller#GTK-PHASE-CAPTURE:CAPS)), one similar event will emulated if the sequence changes to [GTK\_EVENT\_SEQUENCE\_DENIED](gtkgesture#GTK-EVENT-SEQUENCE-DENIED:CAPS). This way event coherence is preserved before event propagation is unstopped again.
Sequence states can't be changed freely, see [`gtk_gesture_set_sequence_state()`](gtkgesture#gtk-gesture-set-sequence-state) to know about the possible lifetimes of a [GdkEventSequence](https://developer-old.gnome.org/gtk4/html/gdk4-Events.html#GdkEventSequence).
#### Touchpad gestures
On the platforms that support it, [GtkGesture](gtkgesture#GtkGesture-struct) will handle transparently touchpad gesture events. The only precautions users of [GtkGesture](gtkgesture#GtkGesture-struct) should do to enable this support are:
* Enabling `GDK_TOUCHPAD_GESTURE_MASK` on their GdkSurfaces
* If the gesture has [`GTK_PHASE_NONE`](gtkeventcontroller#GTK-PHASE-NONE:CAPS), ensuring events of type [`GDK_TOUCHPAD_SWIPE`](https://developer-old.gnome.org/gtk4/html/gdk4-Events.html#GDK-TOUCHPAD-SWIPE:CAPS) and [`GDK_TOUCHPAD_PINCH`](https://developer-old.gnome.org/gtk4/html/gdk4-Events.html#GDK-TOUCHPAD-PINCH:CAPS) are handled by the [GtkGesture](gtkgesture#GtkGesture-struct)
Functions
---------
### gtk\_gesture\_get\_device ()
```
[GdkDevice](https://developer-old.gnome.org/gtk4/html/GdkDevice.html#GdkDevice-struct) *
gtk_gesture_get_device (*`[GtkGesture](gtkgesture#GtkGesture-struct) *gesture`*);
```
Returns the logical [GdkDevice](https://developer-old.gnome.org/gtk4/html/GdkDevice.html#GdkDevice-struct) that is currently operating on *`gesture`* , or `NULL` if the gesture is not being interacted.
#### Parameters
| | | |
| --- | --- | --- |
| gesture | a [GtkGesture](gtkgesture#GtkGesture-struct) | |
#### Returns
a [GdkDevice](https://developer-old.gnome.org/gtk4/html/GdkDevice.html#GdkDevice-struct), or `NULL`.
[nullable][transfer none]
### gtk\_gesture\_is\_active ()
```
gboolean
gtk_gesture_is_active (*`[GtkGesture](gtkgesture#GtkGesture-struct) *gesture`*);
```
Returns `TRUE` if the gesture is currently active. A gesture is active meanwhile there are touch sequences interacting with it.
#### Parameters
| | | |
| --- | --- | --- |
| gesture | a [GtkGesture](gtkgesture#GtkGesture-struct) | |
#### Returns
`TRUE` if gesture is active
### gtk\_gesture\_is\_recognized ()
```
gboolean
gtk_gesture_is_recognized (*`[GtkGesture](gtkgesture#GtkGesture-struct) *gesture`*);
```
Returns `TRUE` if the gesture is currently recognized. A gesture is recognized if there are as many interacting touch sequences as required by *`gesture`* .
#### Parameters
| | | |
| --- | --- | --- |
| gesture | a [GtkGesture](gtkgesture#GtkGesture-struct) | |
#### Returns
`TRUE` if gesture is recognized
### gtk\_gesture\_get\_sequence\_state ()
```
[GtkEventSequenceState](gtkgesture#GtkEventSequenceState)
gtk_gesture_get_sequence_state (*`[GtkGesture](gtkgesture#GtkGesture-struct) *gesture`*,
*`[GdkEventSequence](https://developer-old.gnome.org/gtk4/html/gdk4-Events.html#GdkEventSequence) *sequence`*);
```
Returns the *`sequence`* state, as seen by *`gesture`* .
#### Parameters
| | | |
| --- | --- | --- |
| gesture | a [GtkGesture](gtkgesture#GtkGesture-struct) | |
| sequence | a [GdkEventSequence](https://developer-old.gnome.org/gtk4/html/gdk4-Events.html#GdkEventSequence) | |
#### Returns
The sequence state in *`gesture`*
### gtk\_gesture\_set\_sequence\_state ()
```
gboolean
gtk_gesture_set_sequence_state (*`[GtkGesture](gtkgesture#GtkGesture-struct) *gesture`*,
*`[GdkEventSequence](https://developer-old.gnome.org/gtk4/html/gdk4-Events.html#GdkEventSequence) *sequence`*,
*`[GtkEventSequenceState](gtkgesture#GtkEventSequenceState) state`*);
```
Sets the state of *`sequence`* in *`gesture`* . Sequences start in state [GTK\_EVENT\_SEQUENCE\_NONE](gtkgesture#GTK-EVENT-SEQUENCE-NONE:CAPS), and whenever they change state, they can never go back to that state. Likewise, sequences in state [GTK\_EVENT\_SEQUENCE\_DENIED](gtkgesture#GTK-EVENT-SEQUENCE-DENIED:CAPS) cannot turn back to a not denied state. With these rules, the lifetime of an event sequence is constrained to the next four:
* None
* None → Denied
* None → Claimed
* None → Claimed → Denied
Note: Due to event handling ordering, it may be unsafe to set the state on another gesture within a [“begin”](gtkgesture#GtkGesture-begin) signal handler, as the callback might be executed before the other gesture knows about the sequence. A safe way to perform this could be:
```
static void
first_gesture_begin_cb (GtkGesture *first_gesture,
GdkEventSequence *sequence,
gpointer user_data)
{
gtk_gesture_set_sequence_state (first_gesture, sequence, GTK_EVENT_SEQUENCE_CLAIMED);
gtk_gesture_set_sequence_state (second_gesture, sequence, GTK_EVENT_SEQUENCE_DENIED);
}
static void
second_gesture_begin_cb (GtkGesture *second_gesture,
GdkEventSequence *sequence,
gpointer user_data)
{
if (gtk_gesture_get_sequence_state (first_gesture, sequence) == GTK_EVENT_SEQUENCE_CLAIMED)
gtk_gesture_set_sequence_state (second_gesture, sequence, GTK_EVENT_SEQUENCE_DENIED);
}
```
| If both gestures are in the same group, just set the state on the gesture emitting the event, the sequence will be already be initialized to the group's global state when the second gesture processes the event.
#### Parameters
| | | |
| --- | --- | --- |
| gesture | a [GtkGesture](gtkgesture#GtkGesture-struct) | |
| sequence | a [GdkEventSequence](https://developer-old.gnome.org/gtk4/html/gdk4-Events.html#GdkEventSequence) | |
| state | the sequence state | |
#### Returns
`TRUE` if *`sequence`* is handled by *`gesture`* , and the state is changed successfully
### gtk\_gesture\_set\_state ()
```
gboolean
gtk_gesture_set_state (*`[GtkGesture](gtkgesture#GtkGesture-struct) *gesture`*,
*`[GtkEventSequenceState](gtkgesture#GtkEventSequenceState) state`*);
```
Sets the state of all sequences that *`gesture`* is currently interacting with. See [`gtk_gesture_set_sequence_state()`](gtkgesture#gtk-gesture-set-sequence-state) for more details on sequence states.
#### Parameters
| | | |
| --- | --- | --- |
| gesture | a [GtkGesture](gtkgesture#GtkGesture-struct) | |
| state | the sequence state | |
#### Returns
`TRUE` if the state of at least one sequence was changed successfully
### gtk\_gesture\_get\_sequences ()
```
GList *
gtk_gesture_get_sequences (*`[GtkGesture](gtkgesture#GtkGesture-struct) *gesture`*);
```
Returns the list of GdkEventSequences currently being interpreted by *`gesture`* .
#### Parameters
| | | |
| --- | --- | --- |
| gesture | a [GtkGesture](gtkgesture#GtkGesture-struct) | |
#### Returns
A list of GdkEventSequences, the list elements are owned by GTK and must not be freed or modified, the list itself must be deleted through `g_list_free()`.
[transfer container][element-type GdkEventSequence]
### gtk\_gesture\_handles\_sequence ()
```
gboolean
gtk_gesture_handles_sequence (*`[GtkGesture](gtkgesture#GtkGesture-struct) *gesture`*,
*`[GdkEventSequence](https://developer-old.gnome.org/gtk4/html/gdk4-Events.html#GdkEventSequence) *sequence`*);
```
Returns `TRUE` if *`gesture`* is currently handling events corresponding to *`sequence`* .
#### Parameters
| | | |
| --- | --- | --- |
| gesture | a [GtkGesture](gtkgesture#GtkGesture-struct) | |
| sequence | a [GdkEventSequence](https://developer-old.gnome.org/gtk4/html/gdk4-Events.html#GdkEventSequence) or `NULL`. | [nullable] |
#### Returns
`TRUE` if *`gesture`* is handling *`sequence`* , `FALSE` otherwise
### gtk\_gesture\_get\_last\_updated\_sequence ()
```
[GdkEventSequence](https://developer-old.gnome.org/gtk4/html/gdk4-Events.html#GdkEventSequence) *
gtk_gesture_get_last_updated_sequence (*`[GtkGesture](gtkgesture#GtkGesture-struct) *gesture`*);
```
Returns the [GdkEventSequence](https://developer-old.gnome.org/gtk4/html/gdk4-Events.html#GdkEventSequence) that was last updated on *`gesture`* .
#### Parameters
| | | |
| --- | --- | --- |
| gesture | a [GtkGesture](gtkgesture#GtkGesture-struct) | |
#### Returns
The last updated sequence.
[transfer none][nullable]
### gtk\_gesture\_get\_last\_event ()
```
[GdkEvent](https://developer-old.gnome.org/gtk4/html/gdk4-Events.html#GdkEvent-struct) *
gtk_gesture_get_last_event (*`[GtkGesture](gtkgesture#GtkGesture-struct) *gesture`*,
*`[GdkEventSequence](https://developer-old.gnome.org/gtk4/html/gdk4-Events.html#GdkEventSequence) *sequence`*);
```
Returns the last event that was processed for *`sequence`* .
Note that the returned pointer is only valid as long as the *`sequence`* is still interpreted by the *`gesture`* . If in doubt, you should make a copy of the event.
#### Parameters
| | | |
| --- | --- | --- |
| gesture | a [GtkGesture](gtkgesture#GtkGesture-struct) | |
| sequence | a [GdkEventSequence](https://developer-old.gnome.org/gtk4/html/gdk4-Events.html#GdkEventSequence). | [nullable] |
#### Returns
The last event from *`sequence`* .
[transfer none][nullable]
### gtk\_gesture\_get\_point ()
```
gboolean
gtk_gesture_get_point (*`[GtkGesture](gtkgesture#GtkGesture-struct) *gesture`*,
*`[GdkEventSequence](https://developer-old.gnome.org/gtk4/html/gdk4-Events.html#GdkEventSequence) *sequence`*,
*`double *x`*,
*`double *y`*);
```
If *`sequence`* is currently being interpreted by *`gesture`* , this function returns `TRUE` and fills in *`x`* and *`y`* with the last coordinates stored for that event sequence. The coordinates are always relative to the widget allocation.
#### Parameters
| | | |
| --- | --- | --- |
| gesture | a [GtkGesture](gtkgesture#GtkGesture-struct) | |
| sequence | a [GdkEventSequence](https://developer-old.gnome.org/gtk4/html/gdk4-Events.html#GdkEventSequence), or `NULL` for pointer events. | [allow-none] |
| x | return location for X axis of the sequence coordinates. | [out][allow-none] |
| y | return location for Y axis of the sequence coordinates. | [out][allow-none] |
#### Returns
`TRUE` if *`sequence`* is currently interpreted
### gtk\_gesture\_get\_bounding\_box ()
```
gboolean
gtk_gesture_get_bounding_box (*`[GtkGesture](gtkgesture#GtkGesture-struct) *gesture`*,
*`[GdkRectangle](https://developer-old.gnome.org/gtk4/html/gdk4-Rectangles-and-Regions.html#GdkRectangle-struct) *rect`*);
```
If there are touch sequences being currently handled by *`gesture`* , this function returns `TRUE` and fills in *`rect`* with the bounding box containing all active touches. Otherwise, `FALSE` will be returned.
Note: This function will yield unexpected results on touchpad gestures. Since there is no correlation between physical and pixel distances, these will look as if constrained in an infinitely small area, *`rect`* width and height will thus be 0 regardless of the number of touchpoints.
#### Parameters
| | | |
| --- | --- | --- |
| gesture | a [GtkGesture](gtkgesture#GtkGesture-struct) | |
| rect | bounding box containing all active touches. | [out] |
#### Returns
`TRUE` if there are active touches, `FALSE` otherwise
### gtk\_gesture\_get\_bounding\_box\_center ()
```
gboolean
gtk_gesture_get_bounding_box_center (*`[GtkGesture](gtkgesture#GtkGesture-struct) *gesture`*,
*`double *x`*,
*`double *y`*);
```
If there are touch sequences being currently handled by *`gesture`* , this function returns `TRUE` and fills in *`x`* and *`y`* with the center of the bounding box containing all active touches. Otherwise, `FALSE` will be returned.
#### Parameters
| | | |
| --- | --- | --- |
| gesture | a [GtkGesture](gtkgesture#GtkGesture-struct) | |
| x | X coordinate for the bounding box center. | [out] |
| y | Y coordinate for the bounding box center. | [out] |
#### Returns
`FALSE` if no active touches are present, `TRUE` otherwise
### gtk\_gesture\_group ()
```
void
gtk_gesture_group (*`[GtkGesture](gtkgesture#GtkGesture-struct) *group_gesture`*,
*`[GtkGesture](gtkgesture#GtkGesture-struct) *gesture`*);
```
Adds *`gesture`* to the same group than *`group_gesture`* . Gestures are by default isolated in their own groups.
Both gestures must have been added to the same widget before they can be grouped.
When gestures are grouped, the state of GdkEventSequences is kept in sync for all of those, so calling [`gtk_gesture_set_sequence_state()`](gtkgesture#gtk-gesture-set-sequence-state), on one will transfer the same value to the others.
Groups also perform an "implicit grabbing" of sequences, if a [GdkEventSequence](https://developer-old.gnome.org/gtk4/html/gdk4-Events.html#GdkEventSequence) state is set to [GTK\_EVENT\_SEQUENCE\_CLAIMED](gtkgesture#GTK-EVENT-SEQUENCE-CLAIMED:CAPS) on one group, every other gesture group attached to the same [GtkWidget](gtkwidget#GtkWidget-struct) will switch the state for that sequence to [GTK\_EVENT\_SEQUENCE\_DENIED](gtkgesture#GTK-EVENT-SEQUENCE-DENIED:CAPS).
#### Parameters
| | | |
| --- | --- | --- |
| gesture | a [GtkGesture](gtkgesture#GtkGesture-struct) | |
| group\_gesture | [GtkGesture](gtkgesture#GtkGesture-struct) to group *`gesture`* with | |
### gtk\_gesture\_ungroup ()
```
void
gtk_gesture_ungroup (*`[GtkGesture](gtkgesture#GtkGesture-struct) *gesture`*);
```
Separates *`gesture`* into an isolated group.
#### Parameters
| | | |
| --- | --- | --- |
| gesture | a [GtkGesture](gtkgesture#GtkGesture-struct) | |
### gtk\_gesture\_get\_group ()
```
GList *
gtk_gesture_get_group (*`[GtkGesture](gtkgesture#GtkGesture-struct) *gesture`*);
```
Returns all gestures in the group of *`gesture`*
#### Parameters
| | | |
| --- | --- | --- |
| gesture | a [GtkGesture](gtkgesture#GtkGesture-struct) | |
#### Returns
The list of GtkGestures, free with `g_list_free()`.
[element-type GtkGesture][transfer container]
### gtk\_gesture\_is\_grouped\_with ()
```
gboolean
gtk_gesture_is_grouped_with (*`[GtkGesture](gtkgesture#GtkGesture-struct) *gesture`*,
*`[GtkGesture](gtkgesture#GtkGesture-struct) *other`*);
```
Returns `TRUE` if both gestures pertain to the same group.
#### Parameters
| | | |
| --- | --- | --- |
| gesture | a [GtkGesture](gtkgesture#GtkGesture-struct) | |
| other | another [GtkGesture](gtkgesture#GtkGesture-struct) | |
#### Returns
whether the gestures are grouped
Types and Values
----------------
### GtkGesture
```
typedef struct _GtkGesture GtkGesture;
```
### enum GtkEventSequenceState
Describes the state of a [GdkEventSequence](https://developer-old.gnome.org/gtk4/html/gdk4-Events.html#GdkEventSequence) in a [GtkGesture](gtkgesture#GtkGesture-struct).
#### Members
| | | |
| --- | --- | --- |
| GTK\_EVENT\_SEQUENCE\_NONE | The sequence is handled, but not grabbed. | |
| GTK\_EVENT\_SEQUENCE\_CLAIMED | The sequence is handled and grabbed. | |
| GTK\_EVENT\_SEQUENCE\_DENIED | The sequence is denied. | |
Property Details
----------------
### The `“n-points”` property
```
“n-points” guint
```
The number of touch points that trigger recognition on this gesture,
Owner: GtkGesture
Flags: Read / Write / Construct Only
Allowed values: >= 1
Default value: 1
Signal Details
--------------
### The `“begin”` signal
```
void
user_function ([GtkGesture](gtkgesture#GtkGesture-struct) *gesture,
[GdkEventSequence](https://developer-old.gnome.org/gtk4/html/gdk4-Events.html#GdkEventSequence) *sequence,
gpointer user_data)
```
This signal is emitted when the gesture is recognized. This means the number of touch sequences matches [“n-points”](gtkgesture#GtkGesture--n-points).
Note: These conditions may also happen when an extra touch (eg. a third touch on a 2-touches gesture) is lifted, in that situation *`sequence`* won't pertain to the current set of active touches, so don't rely on this being true.
#### Parameters
| | | |
| --- | --- | --- |
| gesture | the object which received the signal | |
| sequence | the [GdkEventSequence](https://developer-old.gnome.org/gtk4/html/gdk4-Events.html#GdkEventSequence) that made the gesture to be recognized. | [nullable] |
| user\_data | user data set when the signal handler was connected. | |
Flags: Run Last
### The `“cancel”` signal
```
void
user_function ([GtkGesture](gtkgesture#GtkGesture-struct) *gesture,
[GdkEventSequence](https://developer-old.gnome.org/gtk4/html/gdk4-Events.html#GdkEventSequence) *sequence,
gpointer user_data)
```
This signal is emitted whenever a sequence is cancelled. This usually happens on active touches when [`gtk_event_controller_reset()`](gtkeventcontroller#gtk-event-controller-reset) is called on *`gesture`* (manually, due to grabs...), or the individual *`sequence`* was claimed by parent widgets' controllers (see [`gtk_gesture_set_sequence_state()`](gtkgesture#gtk-gesture-set-sequence-state)).
*`gesture`* must forget everything about *`sequence`* as a reaction to this signal.
#### Parameters
| | | |
| --- | --- | --- |
| gesture | the object which received the signal | |
| sequence | the [GdkEventSequence](https://developer-old.gnome.org/gtk4/html/gdk4-Events.html#GdkEventSequence) that was cancelled. | [nullable] |
| user\_data | user data set when the signal handler was connected. | |
Flags: Run Last
### The `“end”` signal
```
void
user_function ([GtkGesture](gtkgesture#GtkGesture-struct) *gesture,
[GdkEventSequence](https://developer-old.gnome.org/gtk4/html/gdk4-Events.html#GdkEventSequence) *sequence,
gpointer user_data)
```
This signal is emitted when *`gesture`* either stopped recognizing the event sequences as something to be handled, or the number of touch sequences became higher or lower than [“n-points”](gtkgesture#GtkGesture--n-points).
Note: *`sequence`* might not pertain to the group of sequences that were previously triggering recognition on *`gesture`* (ie. a just pressed touch sequence that exceeds [“n-points”](gtkgesture#GtkGesture--n-points)). This situation may be detected by checking through [`gtk_gesture_handles_sequence()`](gtkgesture#gtk-gesture-handles-sequence).
#### Parameters
| | | |
| --- | --- | --- |
| gesture | the object which received the signal | |
| sequence | the [GdkEventSequence](https://developer-old.gnome.org/gtk4/html/gdk4-Events.html#GdkEventSequence) that made gesture recognition to finish. | [nullable] |
| user\_data | user data set when the signal handler was connected. | |
Flags: Run Last
### The `“sequence-state-changed”` signal
```
void
user_function ([GtkGesture](gtkgesture#GtkGesture-struct) *gesture,
[GdkEventSequence](https://developer-old.gnome.org/gtk4/html/gdk4-Events.html#GdkEventSequence) *sequence,
[GtkEventSequenceState](gtkgesture#GtkEventSequenceState) state,
gpointer user_data)
```
This signal is emitted whenever a sequence state changes. See [`gtk_gesture_set_sequence_state()`](gtkgesture#gtk-gesture-set-sequence-state) to know more about the expectable sequence lifetimes.
#### Parameters
| | | |
| --- | --- | --- |
| gesture | the object which received the signal | |
| sequence | the [GdkEventSequence](https://developer-old.gnome.org/gtk4/html/gdk4-Events.html#GdkEventSequence) that was cancelled. | [nullable] |
| state | the new sequence state | |
| user\_data | user data set when the signal handler was connected. | |
Flags: Run Last
### The `“update”` signal
```
void
user_function ([GtkGesture](gtkgesture#GtkGesture-struct) *gesture,
[GdkEventSequence](https://developer-old.gnome.org/gtk4/html/gdk4-Events.html#GdkEventSequence) *sequence,
gpointer user_data)
```
This signal is emitted whenever an event is handled while the gesture is recognized. *`sequence`* is guaranteed to pertain to the set of active touches.
#### Parameters
| | | |
| --- | --- | --- |
| gesture | the object which received the signal | |
| sequence | the [GdkEventSequence](https://developer-old.gnome.org/gtk4/html/gdk4-Events.html#GdkEventSequence) that was updated. | [nullable] |
| user\_data | user data set when the signal handler was connected. | |
Flags: Run Last
See Also
--------
[GtkEventController](gtkeventcontroller#GtkEventController-struct), [GtkGestureSingle](gtkgesturesingle#GtkGestureSingle-struct)
| programming_docs |
gtk GtkColumnViewColumn GtkColumnViewColumn
===================
GtkColumnViewColumn — The column added to GtkColumnView
Functions
---------
| | |
| --- | --- |
| [GtkColumnViewColumn](gtkcolumnviewcolumn#GtkColumnViewColumn-struct) \* | [gtk\_column\_view\_column\_new](gtkcolumnviewcolumn#gtk-column-view-column-new) () |
| [GtkColumnView](gtkcolumnview#GtkColumnView-struct) \* | [gtk\_column\_view\_column\_get\_column\_view](gtkcolumnviewcolumn#gtk-column-view-column-get-column-view) () |
| void | [gtk\_column\_view\_column\_set\_factory](gtkcolumnviewcolumn#gtk-column-view-column-set-factory) () |
| [GtkListItemFactory](gtklistitemfactory#GtkListItemFactory-struct) \* | [gtk\_column\_view\_column\_get\_factory](gtkcolumnviewcolumn#gtk-column-view-column-get-factory) () |
| void | [gtk\_column\_view\_column\_set\_title](gtkcolumnviewcolumn#gtk-column-view-column-set-title) () |
| const char \* | [gtk\_column\_view\_column\_get\_title](gtkcolumnviewcolumn#gtk-column-view-column-get-title) () |
| void | [gtk\_column\_view\_column\_set\_sorter](gtkcolumnviewcolumn#gtk-column-view-column-set-sorter) () |
| [GtkSorter](gtksorter#GtkSorter-struct) \* | [gtk\_column\_view\_column\_get\_sorter](gtkcolumnviewcolumn#gtk-column-view-column-get-sorter) () |
| void | [gtk\_column\_view\_column\_set\_visible](gtkcolumnviewcolumn#gtk-column-view-column-set-visible) () |
| gboolean | [gtk\_column\_view\_column\_get\_visible](gtkcolumnviewcolumn#gtk-column-view-column-get-visible) () |
| void | [gtk\_column\_view\_column\_set\_resizable](gtkcolumnviewcolumn#gtk-column-view-column-set-resizable) () |
| gboolean | [gtk\_column\_view\_column\_get\_resizable](gtkcolumnviewcolumn#gtk-column-view-column-get-resizable) () |
| void | [gtk\_column\_view\_column\_set\_header\_menu](gtkcolumnviewcolumn#gtk-column-view-column-set-header-menu) () |
| GMenuModel \* | [gtk\_column\_view\_column\_get\_header\_menu](gtkcolumnviewcolumn#gtk-column-view-column-get-header-menu) () |
| void | [gtk\_column\_view\_column\_set\_fixed\_width](gtkcolumnviewcolumn#gtk-column-view-column-set-fixed-width) () |
| int | [gtk\_column\_view\_column\_get\_fixed\_width](gtkcolumnviewcolumn#gtk-column-view-column-get-fixed-width) () |
| void | [gtk\_column\_view\_column\_set\_expand](gtkcolumnviewcolumn#gtk-column-view-column-set-expand) () |
| gboolean | [gtk\_column\_view\_column\_get\_expand](gtkcolumnviewcolumn#gtk-column-view-column-get-expand) () |
Properties
----------
| | | |
| --- | --- | --- |
| [GtkColumnView](gtkcolumnview#GtkColumnView-struct) \* | [column-view](gtkcolumnviewcolumn#GtkColumnViewColumn--column-view) | Read |
| gboolean | [expand](gtkcolumnviewcolumn#GtkColumnViewColumn--expand) | Read / Write |
| [GtkListItemFactory](gtklistitemfactory#GtkListItemFactory-struct) \* | [factory](gtkcolumnviewcolumn#GtkColumnViewColumn--factory) | Read / Write |
| int | [fixed-width](gtkcolumnviewcolumn#GtkColumnViewColumn--fixed-width) | Read / Write |
| GMenuModel \* | [header-menu](gtkcolumnviewcolumn#GtkColumnViewColumn--header-menu) | Read / Write |
| gboolean | [resizable](gtkcolumnviewcolumn#GtkColumnViewColumn--resizable) | Read / Write |
| [GtkSorter](gtksorter#GtkSorter-struct) \* | [sorter](gtkcolumnviewcolumn#GtkColumnViewColumn--sorter) | Read / Write |
| char \* | [title](gtkcolumnviewcolumn#GtkColumnViewColumn--title) | Read / Write |
| gboolean | [visible](gtkcolumnviewcolumn#GtkColumnViewColumn--visible) | Read / Write |
Types and Values
----------------
| | |
| --- | --- |
| | [GtkColumnViewColumn](gtkcolumnviewcolumn#GtkColumnViewColumn-struct) |
Object Hierarchy
----------------
```
GObject
╰── GtkColumnViewColumn
```
Includes
--------
```
#include <gtk/gtk.h>
```
Description
-----------
GtkColumnViewColumn represents the columns being added to [GtkColumnView](gtkcolumnview#GtkColumnView-struct).
Columns have a title, and can optionally have a header menu set with [`gtk_column_view_column_set_header_menu()`](gtkcolumnviewcolumn#gtk-column-view-column-set-header-menu).
A sorter can be associated with a column using [`gtk_column_view_column_set_sorter()`](gtkcolumnviewcolumn#gtk-column-view-column-set-sorter), to let users influence sorting by clicking on the column header.
Functions
---------
### gtk\_column\_view\_column\_new ()
```
[GtkColumnViewColumn](gtkcolumnviewcolumn#GtkColumnViewColumn-struct) *
gtk_column_view_column_new (*`const char *title`*,
*`[GtkListItemFactory](gtklistitemfactory#GtkListItemFactory-struct) *factory`*);
```
Creates a new [GtkColumnViewColumn](gtkcolumnviewcolumn#GtkColumnViewColumn-struct) that uses the given *`factory`* for mapping items to widgets.
You most likely want to call `gtk_column_add_column()` next.
The function takes ownership of the argument, so you can write code like `column = gtk_column_view_column_new (_("Name"),
gtk_builder_list_item_factory_new_from_resource ("/name.ui"));`
#### Parameters
| | | |
| --- | --- | --- |
| title | Title to use for this column. | [nullable] |
| factory | The factory to populate items with. | [transfer full][nullable] |
#### Returns
a new [GtkColumnViewColumn](gtkcolumnviewcolumn#GtkColumnViewColumn-struct) using the given *`factory`*
### gtk\_column\_view\_column\_get\_column\_view ()
```
[GtkColumnView](gtkcolumnview#GtkColumnView-struct) *
gtk_column_view_column_get_column_view
(*`[GtkColumnViewColumn](gtkcolumnviewcolumn#GtkColumnViewColumn-struct) *self`*);
```
Gets the column view that's currently displaying this column.
If *`self`* has not been added to a column view yet, `NULL` is returned.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkColumnViewColumn](gtkcolumnviewcolumn#GtkColumnViewColumn-struct) | |
#### Returns
The column view displaying *`self`* .
[nullable][transfer none]
### gtk\_column\_view\_column\_set\_factory ()
```
void
gtk_column_view_column_set_factory (*`[GtkColumnViewColumn](gtkcolumnviewcolumn#GtkColumnViewColumn-struct) *self`*,
*`[GtkListItemFactory](gtklistitemfactory#GtkListItemFactory-struct) *factory`*);
```
Sets the [GtkListItemFactory](gtklistitemfactory#GtkListItemFactory-struct) to use for populating list items for this column.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkColumnViewColumn](gtkcolumnviewcolumn#GtkColumnViewColumn-struct) | |
| factory | the factory to use or `NULL` for none. | [allow-none][transfer none] |
### gtk\_column\_view\_column\_get\_factory ()
```
[GtkListItemFactory](gtklistitemfactory#GtkListItemFactory-struct) *
gtk_column_view_column_get_factory (*`[GtkColumnViewColumn](gtkcolumnviewcolumn#GtkColumnViewColumn-struct) *self`*);
```
Gets the factory that's currently used to populate list items for this column.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkColumnViewColumn](gtkcolumnviewcolumn#GtkColumnViewColumn-struct) | |
#### Returns
The factory in use.
[nullable][transfer none]
### gtk\_column\_view\_column\_set\_title ()
```
void
gtk_column_view_column_set_title (*`[GtkColumnViewColumn](gtkcolumnviewcolumn#GtkColumnViewColumn-struct) *self`*,
*`const char *title`*);
```
Sets the title of this column. The title is displayed in the header of a [GtkColumnView](gtkcolumnview#GtkColumnView-struct) for this column and is therefore user-facing text that should be translated.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkColumnViewColumn](gtkcolumnviewcolumn#GtkColumnViewColumn-struct) | |
| title | Title to use for this column. | [nullable] |
### gtk\_column\_view\_column\_get\_title ()
```
const char *
gtk_column_view_column_get_title (*`[GtkColumnViewColumn](gtkcolumnviewcolumn#GtkColumnViewColumn-struct) *self`*);
```
Returns the title set with [`gtk_column_view_column_set_title()`](gtkcolumnviewcolumn#gtk-column-view-column-set-title).
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkColumnViewColumn](gtkcolumnviewcolumn#GtkColumnViewColumn-struct) | |
#### Returns
The column's title.
[nullable]
### gtk\_column\_view\_column\_set\_sorter ()
```
void
gtk_column_view_column_set_sorter (*`[GtkColumnViewColumn](gtkcolumnviewcolumn#GtkColumnViewColumn-struct) *self`*,
*`[GtkSorter](gtksorter#GtkSorter-struct) *sorter`*);
```
Associates a sorter with the column.
If *`sorter`* is `NULL`, the column will not let users change the sorting by clicking on its header.
This sorter can be made active by clicking on the column header, or by calling [`gtk_column_view_sort_by_column()`](gtkcolumnview#gtk-column-view-sort-by-column).
See [`gtk_column_view_get_sorter()`](gtkcolumnview#gtk-column-view-get-sorter) for the necessary steps for setting up customizable sorting for [GtkColumnView](gtkcolumnview#GtkColumnView-struct).
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkColumnViewColumn](gtkcolumnviewcolumn#GtkColumnViewColumn-struct) | |
| sorter | the [GtkSorter](gtksorter#GtkSorter-struct) to associate with *`column`* . | [nullable] |
### gtk\_column\_view\_column\_get\_sorter ()
```
[GtkSorter](gtksorter#GtkSorter-struct) *
gtk_column_view_column_get_sorter (*`[GtkColumnViewColumn](gtkcolumnviewcolumn#GtkColumnViewColumn-struct) *self`*);
```
Returns the sorter that is associated with the column.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkColumnViewColumn](gtkcolumnviewcolumn#GtkColumnViewColumn-struct) | |
#### Returns
the [GtkSorter](gtksorter#GtkSorter-struct) of *`self`* .
[nullable][transfer none]
### gtk\_column\_view\_column\_set\_visible ()
```
void
gtk_column_view_column_set_visible (*`[GtkColumnViewColumn](gtkcolumnviewcolumn#GtkColumnViewColumn-struct) *self`*,
*`gboolean visible`*);
```
Sets whether this column should be visible in views.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkColumnViewColumn](gtkcolumnviewcolumn#GtkColumnViewColumn-struct) | |
| visible | whether this column should be visible | |
### gtk\_column\_view\_column\_get\_visible ()
```
gboolean
gtk_column_view_column_get_visible (*`[GtkColumnViewColumn](gtkcolumnviewcolumn#GtkColumnViewColumn-struct) *self`*);
```
Returns whether this column is visible.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkColumnViewColumn](gtkcolumnviewcolumn#GtkColumnViewColumn-struct) | |
#### Returns
`TRUE` if this column is visible
### gtk\_column\_view\_column\_set\_resizable ()
```
void
gtk_column_view_column_set_resizable (*`[GtkColumnViewColumn](gtkcolumnviewcolumn#GtkColumnViewColumn-struct) *self`*,
*`gboolean resizable`*);
```
Sets whether this column should be resizable by dragging.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkColumnViewColumn](gtkcolumnviewcolumn#GtkColumnViewColumn-struct) | |
| resizable | whether this column should be resizable | |
### gtk\_column\_view\_column\_get\_resizable ()
```
gboolean
gtk_column_view_column_get_resizable (*`[GtkColumnViewColumn](gtkcolumnviewcolumn#GtkColumnViewColumn-struct) *self`*);
```
Returns whether this column is resizable.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkColumnView](gtkcolumnview#GtkColumnView-struct) | |
#### Returns
`TRUE` if this column is resizable
### gtk\_column\_view\_column\_set\_header\_menu ()
```
void
gtk_column_view_column_set_header_menu
(*`[GtkColumnViewColumn](gtkcolumnviewcolumn#GtkColumnViewColumn-struct) *self`*,
*`GMenuModel *menu`*);
```
Sets the menu model that is used to create the context menu for the column header.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkColumnViewColumn](gtkcolumnviewcolumn#GtkColumnViewColumn-struct) | |
| menu | a GMenuModel, or `NULL`. | [allow-none] |
### gtk\_column\_view\_column\_get\_header\_menu ()
```
GMenuModel *
gtk_column_view_column_get_header_menu
(*`[GtkColumnViewColumn](gtkcolumnviewcolumn#GtkColumnViewColumn-struct) *self`*);
```
Gets the menu model that is used to create the context menu for the column header.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkColumnViewColumn](gtkcolumnviewcolumn#GtkColumnViewColumn-struct) | |
#### Returns
the GMenuModel, or `NULL`.
[transfer none][nullable]
### gtk\_column\_view\_column\_set\_fixed\_width ()
```
void
gtk_column_view_column_set_fixed_width
(*`[GtkColumnViewColumn](gtkcolumnviewcolumn#GtkColumnViewColumn-struct) *self`*,
*`int fixed_width`*);
```
If *`fixed_width`* is not -1, sets the fixed width of *`column`* ; otherwise unsets it.
Setting a fixed width overrides the automatically calculated width. Interactive resizing also sets the “fixed-width” property.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkColumnViewColumn](gtkcolumnviewcolumn#GtkColumnViewColumn-struct) | |
| fixed\_width | the new fixed width, or -1 | |
### gtk\_column\_view\_column\_get\_fixed\_width ()
```
int
gtk_column_view_column_get_fixed_width
(*`[GtkColumnViewColumn](gtkcolumnviewcolumn#GtkColumnViewColumn-struct) *self`*);
```
Gets the fixed width of the column.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkColumnViewColumn](gtkcolumnviewcolumn#GtkColumnViewColumn-struct) | |
#### Returns
the fixed with of the column
### gtk\_column\_view\_column\_set\_expand ()
```
void
gtk_column_view_column_set_expand (*`[GtkColumnViewColumn](gtkcolumnviewcolumn#GtkColumnViewColumn-struct) *self`*,
*`gboolean expand`*);
```
Sets the column to take available extra space.
The extra space is shared equally amongst all columns that have the expand set to `TRUE`.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkColumnViewColumn](gtkcolumnviewcolumn#GtkColumnViewColumn-struct) | |
| expand | `TRUE` if this column should expand to fill available sace | |
### gtk\_column\_view\_column\_get\_expand ()
```
gboolean
gtk_column_view_column_get_expand (*`[GtkColumnViewColumn](gtkcolumnviewcolumn#GtkColumnViewColumn-struct) *self`*);
```
Returns whether this column should expand.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkColumnViewColumn](gtkcolumnviewcolumn#GtkColumnViewColumn-struct) | |
#### Returns
`TRUE` if this column expands
Types and Values
----------------
### GtkColumnViewColumn
```
typedef struct _GtkColumnViewColumn GtkColumnViewColumn;
```
GtkColumnViewColumns are added to [GtkColumnViews](gtkcolumnview#GtkColumnView-struct).
Property Details
----------------
### The `“column-view”` property
```
“column-view” [GtkColumnView](gtkcolumnview#GtkColumnView-struct) *
```
[GtkColumnView](gtkcolumnview#GtkColumnView-struct) this column is a part of
Owner: GtkColumnViewColumn
Flags: Read
### The `“expand”` property
```
“expand” gboolean
```
Column gets share of extra width allocated to the view
Owner: GtkColumnViewColumn
Flags: Read / Write
Default value: FALSE
### The `“factory”` property
```
“factory” [GtkListItemFactory](gtklistitemfactory#GtkListItemFactory-struct) *
```
Factory for populating list items
Owner: GtkColumnViewColumn
Flags: Read / Write
### The `“fixed-width”` property
```
“fixed-width” int
```
If not -1, this is the width that the column is allocated, regardless of the size of its content.
Owner: GtkColumnViewColumn
Flags: Read / Write
Allowed values: >= -1
Default value: -1
### The `“header-menu”` property
```
“header-menu” GMenuModel *
```
Menu model used to create the context menu for the column header.
Owner: GtkColumnViewColumn
Flags: Read / Write
### The `“resizable”` property
```
“resizable” gboolean
```
Whether this column is resizable
Owner: GtkColumnViewColumn
Flags: Read / Write
Default value: FALSE
### The `“sorter”` property
```
“sorter” [GtkSorter](gtksorter#GtkSorter-struct) *
```
Sorter for sorting items according to this column
Owner: GtkColumnViewColumn
Flags: Read / Write
### The `“title”` property
```
“title” char *
```
Title displayed in the header
Owner: GtkColumnViewColumn
Flags: Read / Write
Default value: NULL
### The `“visible”` property
```
“visible” gboolean
```
Whether this column is visible
Owner: GtkColumnViewColumn
Flags: Read / Write
Default value: TRUE
See Also
--------
[GtkColumnView](gtkcolumnview#GtkColumnView-struct)
gtk Overview of actions in GTK Overview of actions in GTK
==========================
[Basics about actions](actions-overview#id-1.3.4.3) [Action state and parameters](ch06s02) [Action scopes](ch06s03) [Action groups and action maps](ch06s04) [Connecting actions to widgets](ch06s05) [Activation](ch06s06) [Built-in Actions](ch06s07) This chapter describes in detail how GTK uses actions to connect activatable UI elements to callbacks. GTK inherits the underlying architecture of GAction and GMe:u for describing abstract actions and menus from the GIO library.
A GAction is essentially a way to tell the toolkit about a piece of functionality in your program, and to give it a name.
Actions are purely functional. They do not contain any presentational information.
An action has four pieces of information associated with it:
* a name as an identifier (usually all-lowercase, untranslated English string)
* an enabled flag indicating if the action can be activated or not (like the “sensitive” property on widgets)
* an optional state value, for stateful actions (like a boolean for toggles)
* an optional parameter type, used when activating the action
An action supports two operations. You can activate it, which requires passing a parameter of the correct type And you can request to change the actions state (for stateful actions) to a new state value of the correct type.
Here are some rules about an action:
* the name is immutable (in the sense that it will never change) and it is never `NULL`
* the enabled flag can change
* the parameter type is immutable
* the parameter type is optional: it can be `NULL`
* if the parameter type is `NULL` then action activation must be done without a parameter (ie: a `NULL` GVariant pointer)
* if the parameter type is non-`NULL` then the parameter must have this type
* the state can change, but it cannot change type
* if the action was stateful when it was created, it will always have a state and it will always have exactly the same type (such as boolean or string)
* if the action was stateless when it was created, it can never have a state
* you can only request state changes on stateful actions and it is only possible to request that the state change to a value of the same type as the existing state
An action does not have any sort of presentational information such as a label, an icon or a way of creating a widget from it.
gtk GtkWidget GtkWidget
=========
GtkWidget — Base class for all widgets
Functions
---------
| | |
| --- | --- |
| gboolean | [gtk\_widget\_in\_destruction](gtkwidget#gtk-widget-in-destruction) () |
| void | [gtk\_widget\_unparent](gtkwidget#gtk-widget-unparent) () |
| void | [gtk\_widget\_show](gtkwidget#gtk-widget-show) () |
| void | [gtk\_widget\_hide](gtkwidget#gtk-widget-hide) () |
| void | [gtk\_widget\_map](gtkwidget#gtk-widget-map) () |
| void | [gtk\_widget\_unmap](gtkwidget#gtk-widget-unmap) () |
| void | [gtk\_widget\_realize](gtkwidget#gtk-widget-realize) () |
| void | [gtk\_widget\_unrealize](gtkwidget#gtk-widget-unrealize) () |
| void | [gtk\_widget\_queue\_draw](gtkwidget#gtk-widget-queue-draw) () |
| void | [gtk\_widget\_queue\_resize](gtkwidget#gtk-widget-queue-resize) () |
| void | [gtk\_widget\_queue\_allocate](gtkwidget#gtk-widget-queue-allocate) () |
| [GdkFrameClock](https://developer-old.gnome.org/gtk4/html/GdkFrameClock.html#GdkFrameClock-struct) \* | [gtk\_widget\_get\_frame\_clock](gtkwidget#gtk-widget-get-frame-clock) () |
| int | [gtk\_widget\_get\_scale\_factor](gtkwidget#gtk-widget-get-scale-factor) () |
| gboolean | ([\*GtkTickCallback](gtkwidget#GtkTickCallback)) () |
| guint | [gtk\_widget\_add\_tick\_callback](gtkwidget#gtk-widget-add-tick-callback) () |
| void | [gtk\_widget\_remove\_tick\_callback](gtkwidget#gtk-widget-remove-tick-callback) () |
| void | [gtk\_widget\_size\_allocate](gtkwidget#gtk-widget-size-allocate) () |
| void | [gtk\_widget\_allocate](gtkwidget#gtk-widget-allocate) () |
| void | [gtk\_widget\_class\_add\_shortcut](gtkwidget#gtk-widget-class-add-shortcut) () |
| void | [gtk\_widget\_class\_add\_binding](gtkwidget#gtk-widget-class-add-binding) () |
| void | [gtk\_widget\_class\_add\_binding\_signal](gtkwidget#gtk-widget-class-add-binding-signal) () |
| void | [gtk\_widget\_class\_add\_binding\_action](gtkwidget#gtk-widget-class-add-binding-action) () |
| void | [gtk\_widget\_class\_set\_layout\_manager\_type](gtkwidget#gtk-widget-class-set-layout-manager-type) () |
| GType | [gtk\_widget\_class\_get\_layout\_manager\_type](gtkwidget#gtk-widget-class-get-layout-manager-type) () |
| void | [gtk\_widget\_class\_set\_activate\_signal](gtkwidget#gtk-widget-class-set-activate-signal) () |
| void | [gtk\_widget\_class\_set\_activate\_signal\_from\_name](gtkwidget#gtk-widget-class-set-activate-signal-from-name) () |
| guint | [gtk\_widget\_class\_get\_activate\_signal](gtkwidget#gtk-widget-class-get-activate-signal) () |
| gboolean | [gtk\_widget\_activate](gtkwidget#gtk-widget-activate) () |
| gboolean | [gtk\_widget\_is\_focus](gtkwidget#gtk-widget-is-focus) () |
| gboolean | [gtk\_widget\_grab\_focus](gtkwidget#gtk-widget-grab-focus) () |
| void | [gtk\_widget\_set\_name](gtkwidget#gtk-widget-set-name) () |
| const char \* | [gtk\_widget\_get\_name](gtkwidget#gtk-widget-get-name) () |
| void | [gtk\_widget\_set\_sensitive](gtkwidget#gtk-widget-set-sensitive) () |
| void | [gtk\_widget\_set\_parent](gtkwidget#gtk-widget-set-parent) () |
| [GtkRoot](gtkroot#GtkRoot-struct) \* | [gtk\_widget\_get\_root](gtkwidget#gtk-widget-get-root) () |
| [GtkNative](gtknative#GtkNative-struct) \* | [gtk\_widget\_get\_native](gtkwidget#gtk-widget-get-native) () |
| [GtkWidget](gtkwidget#GtkWidget-struct) \* | [gtk\_widget\_get\_ancestor](gtkwidget#gtk-widget-get-ancestor) () |
| gboolean | [gtk\_widget\_is\_ancestor](gtkwidget#gtk-widget-is-ancestor) () |
| gboolean | [gtk\_widget\_translate\_coordinates](gtkwidget#gtk-widget-translate-coordinates) () |
| void | [gtk\_widget\_add\_controller](gtkwidget#gtk-widget-add-controller) () |
| void | [gtk\_widget\_remove\_controller](gtkwidget#gtk-widget-remove-controller) () |
| void | [gtk\_widget\_set\_direction](gtkwidget#gtk-widget-set-direction) () |
| [GtkTextDirection](gtkwidget#GtkTextDirection) | [gtk\_widget\_get\_direction](gtkwidget#gtk-widget-get-direction) () |
| void | [gtk\_widget\_set\_default\_direction](gtkwidget#gtk-widget-set-default-direction) () |
| [GtkTextDirection](gtkwidget#GtkTextDirection) | [gtk\_widget\_get\_default\_direction](gtkwidget#gtk-widget-get-default-direction) () |
| [PangoContext](https://developer-old.gnome.org/pango/stable/pango-Contexts.html#PangoContext-struct) \* | [gtk\_widget\_create\_pango\_context](gtkwidget#gtk-widget-create-pango-context) () |
| [PangoContext](https://developer-old.gnome.org/pango/stable/pango-Contexts.html#PangoContext-struct) \* | [gtk\_widget\_get\_pango\_context](gtkwidget#gtk-widget-get-pango-context) () |
| void | [gtk\_widget\_set\_font\_options](gtkwidget#gtk-widget-set-font-options) () |
| const [cairo\_font\_options\_t](https://developer-old.gnome.org/cairo/stable/cairo-cairo-font-options-t.html#cairo-font-options-t) \* | [gtk\_widget\_get\_font\_options](gtkwidget#gtk-widget-get-font-options) () |
| void | [gtk\_widget\_set\_font\_map](gtkwidget#gtk-widget-set-font-map) () |
| [PangoFontMap](https://developer-old.gnome.org/pango/stable/pango-Fonts.html#PangoFontMap-struct) \* | [gtk\_widget\_get\_font\_map](gtkwidget#gtk-widget-get-font-map) () |
| [PangoLayout](https://developer-old.gnome.org/pango/stable/pango-Layout-Objects.html#PangoLayout-struct) \* | [gtk\_widget\_create\_pango\_layout](gtkwidget#gtk-widget-create-pango-layout) () |
| [GdkCursor](https://developer-old.gnome.org/gtk4/html/gdk4-Cursors.html#GdkCursor-struct) \* | [gtk\_widget\_get\_cursor](gtkwidget#gtk-widget-get-cursor) () |
| void | [gtk\_widget\_set\_cursor](gtkwidget#gtk-widget-set-cursor) () |
| void | [gtk\_widget\_set\_cursor\_from\_name](gtkwidget#gtk-widget-set-cursor-from-name) () |
| gboolean | [gtk\_widget\_mnemonic\_activate](gtkwidget#gtk-widget-mnemonic-activate) () |
| void | [gtk\_widget\_class\_set\_accessible\_role](gtkwidget#gtk-widget-class-set-accessible-role) () |
| [GtkAccessibleRole](gtkaccessible#GtkAccessibleRole) | [gtk\_widget\_class\_get\_accessible\_role](gtkwidget#gtk-widget-class-get-accessible-role) () |
| gboolean | [gtk\_widget\_child\_focus](gtkwidget#gtk-widget-child-focus) () |
| gboolean | [gtk\_widget\_get\_child\_visible](gtkwidget#gtk-widget-get-child-visible) () |
| [GtkWidget](gtkwidget#GtkWidget-struct) \* | [gtk\_widget\_get\_parent](gtkwidget#gtk-widget-get-parent) () |
| [GtkSettings](gtksettings#GtkSettings-struct) \* | [gtk\_widget\_get\_settings](gtkwidget#gtk-widget-get-settings) () |
| [GdkClipboard](https://developer-old.gnome.org/gtk4/html/gdk4-Clipboards.html#GdkClipboard-struct) \* | [gtk\_widget\_get\_clipboard](gtkwidget#gtk-widget-get-clipboard) () |
| [GdkClipboard](https://developer-old.gnome.org/gtk4/html/gdk4-Clipboards.html#GdkClipboard-struct) \* | [gtk\_widget\_get\_primary\_clipboard](gtkwidget#gtk-widget-get-primary-clipboard) () |
| [GdkDisplay](https://developer-old.gnome.org/gtk4/html/GdkDisplay.html#GdkDisplay-struct) \* | [gtk\_widget\_get\_display](gtkwidget#gtk-widget-get-display) () |
| void | [gtk\_widget\_get\_size\_request](gtkwidget#gtk-widget-get-size-request) () |
| void | [gtk\_widget\_set\_child\_visible](gtkwidget#gtk-widget-set-child-visible) () |
| void | [gtk\_widget\_set\_size\_request](gtkwidget#gtk-widget-set-size-request) () |
| GList \* | [gtk\_widget\_list\_mnemonic\_labels](gtkwidget#gtk-widget-list-mnemonic-labels) () |
| void | [gtk\_widget\_add\_mnemonic\_label](gtkwidget#gtk-widget-add-mnemonic-label) () |
| void | [gtk\_widget\_remove\_mnemonic\_label](gtkwidget#gtk-widget-remove-mnemonic-label) () |
| void | [gtk\_widget\_error\_bell](gtkwidget#gtk-widget-error-bell) () |
| gboolean | [gtk\_widget\_keynav\_failed](gtkwidget#gtk-widget-keynav-failed) () |
| const char \* | [gtk\_widget\_get\_tooltip\_markup](gtkwidget#gtk-widget-get-tooltip-markup) () |
| void | [gtk\_widget\_set\_tooltip\_markup](gtkwidget#gtk-widget-set-tooltip-markup) () |
| const char \* | [gtk\_widget\_get\_tooltip\_text](gtkwidget#gtk-widget-get-tooltip-text) () |
| void | [gtk\_widget\_set\_tooltip\_text](gtkwidget#gtk-widget-set-tooltip-text) () |
| gboolean | [gtk\_widget\_get\_has\_tooltip](gtkwidget#gtk-widget-get-has-tooltip) () |
| void | [gtk\_widget\_set\_has\_tooltip](gtkwidget#gtk-widget-set-has-tooltip) () |
| void | [gtk\_widget\_trigger\_tooltip\_query](gtkwidget#gtk-widget-trigger-tooltip-query) () |
| int | [gtk\_widget\_get\_allocated\_width](gtkwidget#gtk-widget-get-allocated-width) () |
| int | [gtk\_widget\_get\_allocated\_height](gtkwidget#gtk-widget-get-allocated-height) () |
| void | [gtk\_widget\_get\_allocation](gtkwidget#gtk-widget-get-allocation) () |
| int | [gtk\_widget\_get\_allocated\_baseline](gtkwidget#gtk-widget-get-allocated-baseline) () |
| int | [gtk\_widget\_get\_width](gtkwidget#gtk-widget-get-width) () |
| int | [gtk\_widget\_get\_height](gtkwidget#gtk-widget-get-height) () |
| int | [gtk\_widget\_get\_size](gtkwidget#gtk-widget-get-size) () |
| gboolean | [gtk\_widget\_compute\_bounds](gtkwidget#gtk-widget-compute-bounds) () |
| gboolean | [gtk\_widget\_compute\_transform](gtkwidget#gtk-widget-compute-transform) () |
| gboolean | [gtk\_widget\_compute\_point](gtkwidget#gtk-widget-compute-point) () |
| gboolean | [gtk\_widget\_contains](gtkwidget#gtk-widget-contains) () |
| [GtkWidget](gtkwidget#GtkWidget-struct) \* | [gtk\_widget\_pick](gtkwidget#gtk-widget-pick) () |
| gboolean | [gtk\_widget\_get\_can\_focus](gtkwidget#gtk-widget-get-can-focus) () |
| void | [gtk\_widget\_set\_can\_focus](gtkwidget#gtk-widget-set-can-focus) () |
| gboolean | [gtk\_widget\_get\_focusable](gtkwidget#gtk-widget-get-focusable) () |
| void | [gtk\_widget\_set\_focusable](gtkwidget#gtk-widget-set-focusable) () |
| gboolean | [gtk\_widget\_get\_focus\_on\_click](gtkwidget#gtk-widget-get-focus-on-click) () |
| void | [gtk\_widget\_set\_focus\_on\_click](gtkwidget#gtk-widget-set-focus-on-click) () |
| [GtkWidget](gtkwidget#GtkWidget-struct) \* | [gtk\_widget\_get\_focus\_child](gtkwidget#gtk-widget-get-focus-child) () |
| void | [gtk\_widget\_set\_focus\_child](gtkwidget#gtk-widget-set-focus-child) () |
| gboolean | [gtk\_widget\_get\_can\_target](gtkwidget#gtk-widget-get-can-target) () |
| void | [gtk\_widget\_set\_can\_target](gtkwidget#gtk-widget-set-can-target) () |
| gboolean | [gtk\_widget\_get\_sensitive](gtkwidget#gtk-widget-get-sensitive) () |
| gboolean | [gtk\_widget\_is\_sensitive](gtkwidget#gtk-widget-is-sensitive) () |
| gboolean | [gtk\_widget\_get\_visible](gtkwidget#gtk-widget-get-visible) () |
| gboolean | [gtk\_widget\_is\_visible](gtkwidget#gtk-widget-is-visible) () |
| void | [gtk\_widget\_set\_visible](gtkwidget#gtk-widget-set-visible) () |
| void | [gtk\_widget\_set\_state\_flags](gtkwidget#gtk-widget-set-state-flags) () |
| void | [gtk\_widget\_unset\_state\_flags](gtkwidget#gtk-widget-unset-state-flags) () |
| [GtkStateFlags](gtk4-standard-enumerations#GtkStateFlags) | [gtk\_widget\_get\_state\_flags](gtkwidget#gtk-widget-get-state-flags) () |
| gboolean | [gtk\_widget\_has\_default](gtkwidget#gtk-widget-has-default) () |
| gboolean | [gtk\_widget\_has\_focus](gtkwidget#gtk-widget-has-focus) () |
| gboolean | [gtk\_widget\_has\_visible\_focus](gtkwidget#gtk-widget-has-visible-focus) () |
| gboolean | [gtk\_widget\_is\_drawable](gtkwidget#gtk-widget-is-drawable) () |
| void | [gtk\_widget\_set\_receives\_default](gtkwidget#gtk-widget-set-receives-default) () |
| gboolean | [gtk\_widget\_get\_receives\_default](gtkwidget#gtk-widget-get-receives-default) () |
| gboolean | [gtk\_widget\_get\_realized](gtkwidget#gtk-widget-get-realized) () |
| gboolean | [gtk\_widget\_get\_mapped](gtkwidget#gtk-widget-get-mapped) () |
| double | [gtk\_widget\_get\_opacity](gtkwidget#gtk-widget-get-opacity) () |
| void | [gtk\_widget\_set\_opacity](gtkwidget#gtk-widget-set-opacity) () |
| [GtkOverflow](gtkwidget#GtkOverflow) | [gtk\_widget\_get\_overflow](gtkwidget#gtk-widget-get-overflow) () |
| void | [gtk\_widget\_set\_overflow](gtkwidget#gtk-widget-set-overflow) () |
| void | [gtk\_widget\_measure](gtkwidget#gtk-widget-measure) () |
| void | [gtk\_widget\_snapshot\_child](gtkwidget#gtk-widget-snapshot-child) () |
| [GtkWidget](gtkwidget#GtkWidget-struct) \* | [gtk\_widget\_get\_next\_sibling](gtkwidget#gtk-widget-get-next-sibling) () |
| [GtkWidget](gtkwidget#GtkWidget-struct) \* | [gtk\_widget\_get\_prev\_sibling](gtkwidget#gtk-widget-get-prev-sibling) () |
| [GtkWidget](gtkwidget#GtkWidget-struct) \* | [gtk\_widget\_get\_first\_child](gtkwidget#gtk-widget-get-first-child) () |
| [GtkWidget](gtkwidget#GtkWidget-struct) \* | [gtk\_widget\_get\_last\_child](gtkwidget#gtk-widget-get-last-child) () |
| void | [gtk\_widget\_insert\_before](gtkwidget#gtk-widget-insert-before) () |
| void | [gtk\_widget\_insert\_after](gtkwidget#gtk-widget-insert-after) () |
| void | [gtk\_widget\_set\_layout\_manager](gtkwidget#gtk-widget-set-layout-manager) () |
| [GtkLayoutManager](gtklayoutmanager#GtkLayoutManager-struct) \* | [gtk\_widget\_get\_layout\_manager](gtkwidget#gtk-widget-get-layout-manager) () |
| gboolean | [gtk\_widget\_should\_layout](gtkwidget#gtk-widget-should-layout) () |
| const char \* | [gtk\_widget\_get\_css\_name](gtkwidget#gtk-widget-get-css-name) () |
| void | [gtk\_widget\_add\_css\_class](gtkwidget#gtk-widget-add-css-class) () |
| void | [gtk\_widget\_remove\_css\_class](gtkwidget#gtk-widget-remove-css-class) () |
| gboolean | [gtk\_widget\_has\_css\_class](gtkwidget#gtk-widget-has-css-class) () |
| char \*\* | [gtk\_widget\_get\_css\_classes](gtkwidget#gtk-widget-get-css-classes) () |
| void | [gtk\_widget\_set\_css\_classes](gtkwidget#gtk-widget-set-css-classes) () |
| [GtkStyleContext](gtkstylecontext#GtkStyleContext-struct) \* | [gtk\_widget\_get\_style\_context](gtkwidget#gtk-widget-get-style-context) () |
| const char \* | [gtk\_widget\_class\_get\_css\_name](gtkwidget#gtk-widget-class-get-css-name) () |
| void | [gtk\_widget\_class\_set\_css\_name](gtkwidget#gtk-widget-class-set-css-name) () |
| [GtkRequisition](gtkwidget#GtkRequisition) \* | [gtk\_requisition\_new](gtkwidget#gtk-requisition-new) () |
| [GtkRequisition](gtkwidget#GtkRequisition) \* | [gtk\_requisition\_copy](gtkwidget#gtk-requisition-copy) () |
| void | [gtk\_requisition\_free](gtkwidget#gtk-requisition-free) () |
| [GtkSizeRequestMode](gtkwidget#GtkSizeRequestMode) | [gtk\_widget\_get\_request\_mode](gtkwidget#gtk-widget-get-request-mode) () |
| void | [gtk\_widget\_get\_preferred\_size](gtkwidget#gtk-widget-get-preferred-size) () |
| int | [gtk\_distribute\_natural\_allocation](gtkwidget#gtk-distribute-natural-allocation) () |
| [GtkAlign](gtkwidget#GtkAlign) | [gtk\_widget\_get\_halign](gtkwidget#gtk-widget-get-halign) () |
| void | [gtk\_widget\_set\_halign](gtkwidget#gtk-widget-set-halign) () |
| [GtkAlign](gtkwidget#GtkAlign) | [gtk\_widget\_get\_valign](gtkwidget#gtk-widget-get-valign) () |
| void | [gtk\_widget\_set\_valign](gtkwidget#gtk-widget-set-valign) () |
| int | [gtk\_widget\_get\_margin\_start](gtkwidget#gtk-widget-get-margin-start) () |
| void | [gtk\_widget\_set\_margin\_start](gtkwidget#gtk-widget-set-margin-start) () |
| int | [gtk\_widget\_get\_margin\_end](gtkwidget#gtk-widget-get-margin-end) () |
| void | [gtk\_widget\_set\_margin\_end](gtkwidget#gtk-widget-set-margin-end) () |
| int | [gtk\_widget\_get\_margin\_top](gtkwidget#gtk-widget-get-margin-top) () |
| void | [gtk\_widget\_set\_margin\_top](gtkwidget#gtk-widget-set-margin-top) () |
| int | [gtk\_widget\_get\_margin\_bottom](gtkwidget#gtk-widget-get-margin-bottom) () |
| void | [gtk\_widget\_set\_margin\_bottom](gtkwidget#gtk-widget-set-margin-bottom) () |
| gboolean | [gtk\_widget\_get\_hexpand](gtkwidget#gtk-widget-get-hexpand) () |
| void | [gtk\_widget\_set\_hexpand](gtkwidget#gtk-widget-set-hexpand) () |
| gboolean | [gtk\_widget\_get\_hexpand\_set](gtkwidget#gtk-widget-get-hexpand-set) () |
| void | [gtk\_widget\_set\_hexpand\_set](gtkwidget#gtk-widget-set-hexpand-set) () |
| gboolean | [gtk\_widget\_get\_vexpand](gtkwidget#gtk-widget-get-vexpand) () |
| void | [gtk\_widget\_set\_vexpand](gtkwidget#gtk-widget-set-vexpand) () |
| gboolean | [gtk\_widget\_get\_vexpand\_set](gtkwidget#gtk-widget-get-vexpand-set) () |
| void | [gtk\_widget\_set\_vexpand\_set](gtkwidget#gtk-widget-set-vexpand-set) () |
| gboolean | [gtk\_widget\_compute\_expand](gtkwidget#gtk-widget-compute-expand) () |
| void | [gtk\_widget\_init\_template](gtkwidget#gtk-widget-init-template) () |
| void | [gtk\_widget\_class\_set\_template](gtkwidget#gtk-widget-class-set-template) () |
| void | [gtk\_widget\_class\_set\_template\_from\_resource](gtkwidget#gtk-widget-class-set-template-from-resource) () |
| GObject \* | [gtk\_widget\_get\_template\_child](gtkwidget#gtk-widget-get-template-child) () |
| #define | [gtk\_widget\_class\_bind\_template\_child](gtkwidget#gtk-widget-class-bind-template-child)() |
| #define | [gtk\_widget\_class\_bind\_template\_child\_internal](gtkwidget#gtk-widget-class-bind-template-child-internal)() |
| #define | [gtk\_widget\_class\_bind\_template\_child\_private](gtkwidget#gtk-widget-class-bind-template-child-private)() |
| #define | [gtk\_widget\_class\_bind\_template\_child\_internal\_private](gtkwidget#gtk-widget-class-bind-template-child-internal-private)() |
| void | [gtk\_widget\_class\_bind\_template\_child\_full](gtkwidget#gtk-widget-class-bind-template-child-full) () |
| #define | [gtk\_widget\_class\_bind\_template\_callback](gtkwidget#gtk-widget-class-bind-template-callback)() |
| void | [gtk\_widget\_class\_bind\_template\_callback\_full](gtkwidget#gtk-widget-class-bind-template-callback-full) () |
| void | [gtk\_widget\_class\_set\_template\_scope](gtkwidget#gtk-widget-class-set-template-scope) () |
| GListModel \* | [gtk\_widget\_observe\_children](gtkwidget#gtk-widget-observe-children) () |
| GListModel \* | [gtk\_widget\_observe\_controllers](gtkwidget#gtk-widget-observe-controllers) () |
| void | [gtk\_widget\_insert\_action\_group](gtkwidget#gtk-widget-insert-action-group) () |
| gboolean | [gtk\_widget\_activate\_action](gtkwidget#gtk-widget-activate-action) () |
| gboolean | [gtk\_widget\_activate\_action\_variant](gtkwidget#gtk-widget-activate-action-variant) () |
| void | [gtk\_widget\_activate\_default](gtkwidget#gtk-widget-activate-default) () |
| void | ([\*GtkWidgetActionActivateFunc](gtkwidget#GtkWidgetActionActivateFunc)) () |
| void | [gtk\_widget\_class\_install\_action](gtkwidget#gtk-widget-class-install-action) () |
| void | [gtk\_widget\_class\_install\_property\_action](gtkwidget#gtk-widget-class-install-property-action) () |
| gboolean | [gtk\_widget\_class\_query\_action](gtkwidget#gtk-widget-class-query-action) () |
| void | [gtk\_widget\_action\_set\_enabled](gtkwidget#gtk-widget-action-set-enabled) () |
Properties
----------
| | | |
| --- | --- | --- |
| gboolean | [can-focus](gtkwidget#GtkWidget--can-focus) | Read / Write |
| gboolean | [can-target](gtkwidget#GtkWidget--can-target) | Read / Write |
| GStrv | [css-classes](gtkwidget#GtkWidget--css-classes) | Read / Write |
| char \* | [css-name](gtkwidget#GtkWidget--css-name) | Read / Write / Construct Only |
| [GdkCursor](https://developer-old.gnome.org/gtk4/html/gdk4-Cursors.html#GdkCursor-struct) \* | [cursor](gtkwidget#GtkWidget--cursor) | Read / Write |
| gboolean | [focus-on-click](gtkwidget#GtkWidget--focus-on-click) | Read / Write |
| gboolean | [focusable](gtkwidget#GtkWidget--focusable) | Read / Write |
| [GtkAlign](gtkwidget#GtkAlign) | [halign](gtkwidget#GtkWidget--halign) | Read / Write |
| gboolean | [has-default](gtkwidget#GtkWidget--has-default) | Read |
| gboolean | [has-focus](gtkwidget#GtkWidget--has-focus) | Read |
| gboolean | [has-tooltip](gtkwidget#GtkWidget--has-tooltip) | Read / Write |
| int | [height-request](gtkwidget#GtkWidget--height-request) | Read / Write |
| gboolean | [hexpand](gtkwidget#GtkWidget--hexpand) | Read / Write |
| gboolean | [hexpand-set](gtkwidget#GtkWidget--hexpand-set) | Read / Write |
| [GtkLayoutManager](gtklayoutmanager#GtkLayoutManager-struct) \* | [layout-manager](gtkwidget#GtkWidget--layout-manager) | Read / Write |
| int | [margin-bottom](gtkwidget#GtkWidget--margin-bottom) | Read / Write |
| int | [margin-end](gtkwidget#GtkWidget--margin-end) | Read / Write |
| int | [margin-start](gtkwidget#GtkWidget--margin-start) | Read / Write |
| int | [margin-top](gtkwidget#GtkWidget--margin-top) | Read / Write |
| char \* | [name](gtkwidget#GtkWidget--name) | Read / Write |
| double | [opacity](gtkwidget#GtkWidget--opacity) | Read / Write |
| [GtkOverflow](gtkwidget#GtkOverflow) | [overflow](gtkwidget#GtkWidget--overflow) | Read / Write |
| [GtkWidget](gtkwidget#GtkWidget-struct) \* | [parent](gtkwidget#GtkWidget--parent) | Read |
| gboolean | [receives-default](gtkwidget#GtkWidget--receives-default) | Read / Write |
| [GtkRoot](gtkroot#GtkRoot-struct) \* | [root](gtkwidget#GtkWidget--root) | Read |
| int | [scale-factor](gtkwidget#GtkWidget--scale-factor) | Read |
| gboolean | [sensitive](gtkwidget#GtkWidget--sensitive) | Read / Write |
| char \* | [tooltip-markup](gtkwidget#GtkWidget--tooltip-markup) | Read / Write |
| char \* | [tooltip-text](gtkwidget#GtkWidget--tooltip-text) | Read / Write |
| [GtkAlign](gtkwidget#GtkAlign) | [valign](gtkwidget#GtkWidget--valign) | Read / Write |
| gboolean | [vexpand](gtkwidget#GtkWidget--vexpand) | Read / Write |
| gboolean | [vexpand-set](gtkwidget#GtkWidget--vexpand-set) | Read / Write |
| gboolean | [visible](gtkwidget#GtkWidget--visible) | Read / Write |
| int | [width-request](gtkwidget#GtkWidget--width-request) | Read / Write |
Signals
-------
| | | |
| --- | --- | --- |
| void | [destroy](gtkwidget#GtkWidget-destroy) | No Hooks |
| void | [direction-changed](gtkwidget#GtkWidget-direction-changed) | Run First |
| void | [hide](gtkwidget#GtkWidget-hide) | Run First |
| gboolean | [keynav-failed](gtkwidget#GtkWidget-keynav-failed) | Run Last |
| void | [map](gtkwidget#GtkWidget-map) | Run First |
| gboolean | [mnemonic-activate](gtkwidget#GtkWidget-mnemonic-activate) | Run Last |
| void | [move-focus](gtkwidget#GtkWidget-move-focus) | Action |
| gboolean | [query-tooltip](gtkwidget#GtkWidget-query-tooltip) | Run Last |
| void | [realize](gtkwidget#GtkWidget-realize) | Run First |
| void | [show](gtkwidget#GtkWidget-show) | Run First |
| void | [state-flags-changed](gtkwidget#GtkWidget-state-flags-changed) | Run First |
| void | [unmap](gtkwidget#GtkWidget-unmap) | Run First |
| void | [unrealize](gtkwidget#GtkWidget-unrealize) | Run Last |
Types and Values
----------------
| | |
| --- | --- |
| | [GtkWidget](gtkwidget#GtkWidget-struct) |
| struct | [GtkWidgetClass](gtkwidget#GtkWidgetClass) |
| | [GtkRequisition](gtkwidget#GtkRequisition) |
| typedef | [GtkAllocation](gtkwidget#GtkAllocation) |
| enum | [GtkTextDirection](gtkwidget#GtkTextDirection) |
| enum | [GtkPickFlags](gtkwidget#GtkPickFlags) |
| enum | [GtkOverflow](gtkwidget#GtkOverflow) |
| enum | [GtkSizeRequestMode](gtkwidget#GtkSizeRequestMode) |
| struct | [GtkRequestedSize](gtkwidget#GtkRequestedSize) |
| enum | [GtkAlign](gtkwidget#GtkAlign) |
Object Hierarchy
----------------
```
GObject
╰── GInitiallyUnowned
╰── GtkWidget
├── [GtkWindow](gtkwindow#GtkWindow-struct)
├── [GtkActionBar](gtkactionbar#GtkActionBar-struct)
├── [GtkAppChooserButton](gtkappchooserbutton#GtkAppChooserButton-struct)
├── [GtkAppChooserWidget](gtkappchooserwidget#GtkAppChooserWidget-struct)
├── [GtkAspectFrame](gtkaspectframe#GtkAspectFrame-struct)
├── [GtkBox](gtkbox#GtkBox-struct)
├── [GtkButton](gtkbutton#GtkButton-struct)
├── [GtkCalendar](gtkcalendar#GtkCalendar-struct)
├── [GtkCellView](gtkcellview#GtkCellView-struct)
├── [GtkCenterBox](https://developer-old.gnome.org/usr/share/gtk-doc/html/gtk4/gtk4-GtkCenterBox.html#GtkCenterBox)
├── [GtkCheckButton](gtkcheckbutton#GtkCheckButton-struct)
├── [GtkColorButton](gtkcolorbutton#GtkColorButton-struct)
├── [GtkColorChooserWidget](gtkcolorchooserwidget#GtkColorChooserWidget-struct)
├── [GtkColumnView](gtkcolumnview#GtkColumnView-struct)
├── [GtkComboBox](gtkcombobox#GtkComboBox-struct)
├── [GtkDragIcon](gtkdragicon#GtkDragIcon-struct)
├── [GtkDrawingArea](gtkdrawingarea#GtkDrawingArea-struct)
├── [GtkDropDown](gtkdropdown#GtkDropDown-struct)
├── [GtkEditableLabel](gtkeditablelabel#GtkEditableLabel-struct)
├── [GtkPopover](gtkpopover#GtkPopover-struct)
├── [GtkEntry](gtkentry#GtkEntry-struct)
├── [GtkExpander](gtkexpander#GtkExpander-struct)
├── [GtkFileChooserWidget](gtkfilechooserwidget#GtkFileChooserWidget-struct)
├── [GtkFixed](gtkfixed#GtkFixed-struct)
├── [GtkFlowBox](gtkflowbox#GtkFlowBox-struct)
├── [GtkFlowBoxChild](gtkflowbox#GtkFlowBoxChild-struct)
├── [GtkFontButton](gtkfontbutton#GtkFontButton-struct)
├── [GtkFontChooserWidget](gtkfontchooserwidget#GtkFontChooserWidget-struct)
├── [GtkFrame](gtkframe#GtkFrame-struct)
├── [GtkGLArea](gtkglarea#GtkGLArea-struct)
├── [GtkGrid](gtkgrid#GtkGrid-struct)
├── GtkListBase
├── [GtkHeaderBar](gtkheaderbar#GtkHeaderBar-struct)
├── [GtkIconView](gtkiconview#GtkIconView-struct)
├── [GtkImage](gtkimage#GtkImage-struct)
├── [GtkInfoBar](gtkinfobar#GtkInfoBar-struct)
├── [GtkLabel](gtklabel#GtkLabel-struct)
├── [GtkListBox](gtklistbox#GtkListBox-struct)
├── [GtkListBoxRow](gtklistbox#GtkListBoxRow-struct)
├── [GtkMediaControls](gtkmediacontrols#GtkMediaControls-struct)
├── [GtkMenuButton](gtkmenubutton#GtkMenuButton-struct)
├── [GtkNotebook](gtknotebook#GtkNotebook-struct)
├── [GtkOverlay](gtkoverlay#GtkOverlay-struct)
├── [GtkPaned](gtkpaned#GtkPaned-struct)
├── [GtkPasswordEntry](gtkpasswordentry#GtkPasswordEntry-struct)
├── [GtkPicture](gtkpicture#GtkPicture-struct)
├── [GtkPopoverMenuBar](gtkpopovermenubar#GtkPopoverMenuBar-struct)
├── [GtkProgressBar](gtkprogressbar#GtkProgressBar-struct)
├── [GtkRange](gtkrange#GtkRange-struct)
├── [GtkRevealer](gtkrevealer#GtkRevealer-struct)
├── [GtkScaleButton](gtkscalebutton#GtkScaleButton-struct)
├── [GtkScrollbar](gtkscrollbar#GtkScrollbar-struct)
├── [GtkScrolledWindow](gtkscrolledwindow#GtkScrolledWindow-struct)
├── [GtkSearchBar](gtksearchbar#GtkSearchBar-struct)
├── [GtkSearchEntry](gtksearchentry#GtkSearchEntry-struct)
├── [GtkSeparator](gtkseparator#GtkSeparator-struct)
├── [GtkShortcutLabel](gtkshortcutlabel#GtkShortcutLabel-struct)
├── [GtkShortcutsShortcut](gtkshortcutsshortcut#GtkShortcutsShortcut-struct)
├── [GtkSpinButton](gtkspinbutton#GtkSpinButton-struct)
├── [GtkSpinner](gtkspinner#GtkSpinner-struct)
├── [GtkStack](gtkstack#GtkStack-struct)
├── [GtkStackSidebar](gtkstacksidebar#GtkStackSidebar-struct)
├── [GtkStackSwitcher](gtkstackswitcher#GtkStackSwitcher-struct)
├── [GtkStatusbar](gtkstatusbar#GtkStatusbar-struct)
├── [GtkSwitch](gtkswitch#GtkSwitch-struct)
├── [GtkLevelBar](gtklevelbar#GtkLevelBar-struct)
├── [GtkText](gtktext#GtkText-struct)
├── [GtkTextView](gtktextview#GtkTextView-struct)
├── [GtkTreeExpander](gtktreeexpander#GtkTreeExpander-struct)
├── [GtkTreeView](gtktreeview#GtkTreeView-struct)
├── [GtkVideo](gtkvideo#GtkVideo-struct)
├── [GtkViewport](gtkviewport#GtkViewport-struct)
├── [GtkWindowControls](gtkwindowcontrols#GtkWindowControls-struct)
╰── [GtkWindowHandle](gtkwindowhandle#GtkWindowHandle-struct)
```
Known Derived Interfaces
------------------------
GtkWidget is required by [GtkActionable](gtkactionable#GtkActionable-struct), [GtkAppChooser](gtkappchooser#GtkAppChooser-struct), [GtkCellEditable](gtkcelleditable#GtkCellEditable-struct), [GtkEditable](gtkeditable#GtkEditable-struct), [GtkNative](gtknative#GtkNative-struct) and [GtkRoot](gtkroot#GtkRoot-struct).
Implemented Interfaces
----------------------
GtkWidget implements [GtkAccessible](gtkaccessible#GtkAccessible-struct), [GtkBuildable](gtkbuildable#GtkBuildable-struct) and [GtkConstraintTarget](gtkconstraint#GtkConstraintTarget-struct).
Includes
--------
```
#include <gtk/gtk.h>
```
Description
-----------
GtkWidget is the base class all widgets in GTK derive from. It manages the widget lifecycle, states and style.
### Height-for-width Geometry Management
GTK uses a height-for-width (and width-for-height) geometry management system. Height-for-width means that a widget can change how much vertical space it needs, depending on the amount of horizontal space that it is given (and similar for width-for-height). The most common example is a label that reflows to fill up the available width, wraps to fewer lines, and therefore needs less height.
Height-for-width geometry management is implemented in GTK by way of two virtual methods:
* [`GtkWidgetClass.get_request_mode()`](gtkwidget#GtkWidgetClass.get-request-mode)
* [`GtkWidgetClass.measure()`](gtkwidget#GtkWidgetClass.measure)
There are some important things to keep in mind when implementing height-for-width and when using it in widget implementations.
If you implement a direct [GtkWidget](gtkwidget#GtkWidget-struct) subclass that supports height-for-width or width-for-height geometry management for itself or its child widgets, the [`GtkWidgetClass.get_request_mode()`](gtkwidget#GtkWidgetClass.get-request-mode) virtual function must be implemented as well and return the widget's preferred request mode. The default implementation of this virtual function returns [`GTK_SIZE_REQUEST_CONSTANT_SIZE`](gtkwidget#GTK-SIZE-REQUEST-CONSTANT-SIZE:CAPS), which means that the widget will only ever get -1 passed as the for\_size value to its [`GtkWidgetClass.measure()`](gtkwidget#GtkWidgetClass.measure) implementation.
The geometry management system will query a widget hierarchy in only one orientation at a time. When widgets are initially queried for their minimum sizes it is generally done in two initial passes in the [GtkSizeRequestMode](gtkwidget#GtkSizeRequestMode) chosen by the toplevel.
For example, when queried in the normal [`GTK_SIZE_REQUEST_HEIGHT_FOR_WIDTH`](gtkwidget#GTK-SIZE-REQUEST-HEIGHT-FOR-WIDTH:CAPS) mode: First, the default minimum and natural width for each widget in the interface will be computed using [`gtk_widget_measure()`](gtkwidget#gtk-widget-measure) with an orientation of [`GTK_ORIENTATION_HORIZONTAL`](gtk4-standard-enumerations#GTK-ORIENTATION-HORIZONTAL:CAPS) and a for\_size of -1. Because the preferred widths for each widget depend on the preferred widths of their children, this information propagates up the hierarchy, and finally a minimum and natural width is determined for the entire toplevel. Next, the toplevel will use the minimum width to query for the minimum height contextual to that width using [`gtk_widget_measure()`](gtkwidget#gtk-widget-measure) with an orientation of [`GTK_ORIENTATION_VERTICAL`](gtk4-standard-enumerations#GTK-ORIENTATION-VERTICAL:CAPS) and a for\_size of the just computed width. This will also be a highly recursive operation. The minimum height for the minimum width is normally used to set the minimum size constraint on the toplevel.
After the toplevel window has initially requested its size in both dimensions it can go on to allocate itself a reasonable size (or a size previously specified with [`gtk_window_set_default_size()`](gtkwindow#gtk-window-set-default-size)). During the recursive allocation process it’s important to note that request cycles will be recursively executed while widgets allocate their children. Each widget, once allocated a size, will go on to first share the space in one orientation among its children and then request each child's height for its target allocated width or its width for allocated height, depending. In this way a [GtkWidget](gtkwidget#GtkWidget-struct) will typically be requested its size a number of times before actually being allocated a size. The size a widget is finally allocated can of course differ from the size it has requested. For this reason, [GtkWidget](gtkwidget#GtkWidget-struct) caches a small number of results to avoid re-querying for the same sizes in one allocation cycle.
If a widget does move content around to intelligently use up the allocated size then it must support the request in both GtkSizeRequestModes even if the widget in question only trades sizes in a single orientation.
For instance, a [GtkLabel](gtklabel#GtkLabel-struct) that does height-for-width word wrapping will not expect to have [`GtkWidgetClass.measure()`](gtkwidget#GtkWidgetClass.measure) with an orientation of [`GTK_ORIENTATION_VERTICAL`](gtk4-standard-enumerations#GTK-ORIENTATION-VERTICAL:CAPS) called because that call is specific to a width-for-height request. In this case the label must return the height required for its own minimum possible width. By following this rule any widget that handles height-for-width or width-for-height requests will always be allocated at least enough space to fit its own content.
Here are some examples of how a [`GTK_SIZE_REQUEST_HEIGHT_FOR_WIDTH`](gtkwidget#GTK-SIZE-REQUEST-HEIGHT-FOR-WIDTH:CAPS) widget generally deals with width-for-height requests:
Often a widget needs to get its own request during size request or allocation. For example, when computing height it may need to also compute width. Or when deciding how to use an allocation, the widget may need to know its natural size. In these cases, the widget should be careful to call its virtual methods directly, like in the code example above.
It will not work to use the wrapper function [`gtk_widget_measure()`](gtkwidget#gtk-widget-measure) inside your own [`GtkWidgetClass.size-`allocate()``](gtkwidget#GtkWidgetClass.size-allocate) implementation. These return a request adjusted by [GtkSizeGroup](gtksizegroup#GtkSizeGroup-struct), the widget's align and expand flags as well as its CSS style. If a widget used the wrappers inside its virtual method implementations, then the adjustments (such as widget margins) would be applied twice. GTK therefore does not allow this and will warn if you try to do it.
Of course if you are getting the size request for another widget, such as a child widget, you must use [`gtk_widget_measure()`](gtkwidget#gtk-widget-measure). Otherwise, you would not properly consider widget margins, [GtkSizeGroup](gtksizegroup#GtkSizeGroup-struct), and so forth.
GTK also supports baseline vertical alignment of widgets. This means that widgets are positioned such that the typographical baseline of widgets in the same row are aligned. This happens if a widget supports baselines, has a vertical alignment of [`GTK_ALIGN_BASELINE`](gtkwidget#GTK-ALIGN-BASELINE:CAPS), and is inside a widget that supports baselines and has a natural “row” that it aligns to the baseline, or a baseline assigned to it by the grandparent.
Baseline alignment support for a widget is also done by the [`GtkWidgetClass.measure()`](gtkwidget#GtkWidgetClass.measure) virtual function. It allows you to report both a minimum and natural size.
If a widget ends up baseline aligned it will be allocated all the space in the parent as if it was [`GTK_ALIGN_FILL`](gtkwidget#GTK-ALIGN-FILL:CAPS), but the selected baseline can be found via [`gtk_widget_get_allocated_baseline()`](gtkwidget#gtk-widget-get-allocated-baseline). If this has a value other than -1 you need to align the widget such that the baseline appears at the position.
### GtkWidget as GtkBuildable
The GtkWidget implementation of the [GtkBuildable](gtkbuildable#GtkBuildable-struct) interface supports a custom elements to specify various aspects of widgets that are not directly expressed as properties.
If the parent widget uses a [GtkLayoutManager](gtklayoutmanager#GtkLayoutManager-struct), [GtkWidget](gtkwidget#GtkWidget-struct) supports a custom `<layout>` element, used to define layout properties:
GtkWidget allows style information such as style classes to be associated with widgets, using the custom `<style>` element:
GtkWidget allows defining accessibility information, such as properties, relations, and states, using the custom `<accessibility>` element:
### Building composite widgets from template XML
GtkWidget exposes some facilities to automate the procedure of creating composite widgets using [GtkBuilder](gtkbuilder#GtkBuilder-struct) interface description language.
To create composite widgets with [GtkBuilder](gtkbuilder#GtkBuilder-struct) XML, one must associate the interface description with the widget class at class initialization time using [`gtk_widget_class_set_template()`](gtkwidget#gtk-widget-class-set-template).
The interface description semantics expected in composite template descriptions is slightly different from regular [GtkBuilder](gtkbuilder#GtkBuilder-struct) XML.
Unlike regular interface descriptions, [`gtk_widget_class_set_template()`](gtkwidget#gtk-widget-class-set-template) will expect a `<template>` tag as a direct child of the toplevel `<interface>` tag. The `<template>` tag must specify the “class” attribute which must be the type name of the widget. Optionally, the “parent” attribute may be specified to specify the direct parent type of the widget type, this is ignored by the GtkBuilder but required for Glade to introspect what kind of properties and internal children exist for a given type when the actual type does not exist.
The XML which is contained inside the `<template>` tag behaves as if it were added to the `<object>` tag defining *`widget`* itself. You may set properties on *`widget`* by inserting `<property>` tags into the `<template>` tag, and also add `<child>` tags to add children and extend *`widget`* in the normal way you would with `<object>` tags.
Additionally, `<object>` tags can also be added before and after the initial `<template>` tag in the normal way, allowing one to define auxiliary objects which might be referenced by other widgets declared as children of the `<template>` tag.
An example of a GtkBuilder Template Definition:
Typically, you'll place the template fragment into a file that is bundled with your project, using GResource. In order to load the template, you need to call [`gtk_widget_class_set_template_from_resource()`](gtkwidget#gtk-widget-class-set-template-from-resource) from the class initialization of your [GtkWidget](gtkwidget#GtkWidget-struct) type:
You will also need to call [`gtk_widget_init_template()`](gtkwidget#gtk-widget-init-template) from the instance initialization function:
You can access widgets defined in the template using the [`gtk_widget_get_template_child()`](gtkwidget#gtk-widget-get-template-child) function, but you will typically declare a pointer in the instance private data structure of your type using the same name as the widget in the template definition, and call [`gtk_widget_class_bind_template_child_private()`](gtkwidget#gtk-widget-class-bind-template-child-private) with that name, e.g.
You can also use [`gtk_widget_class_bind_template_callback()`](gtkwidget#gtk-widget-class-bind-template-callback) to connect a signal callback defined in the template with a function visible in the scope of the class, e.g.
```
static void
foo_widget_measure (GtkWidget *widget,
GtkOrientation orientation,
int for_size,
int *minimum_size,
int *natural_size,
int *minimum_baseline,
int *natural_baseline)
{
if (orientation == GTK_ORIENTATION_HORIZONTAL)
{
// Calculate minimum and natural width
}
else // VERTICAL
{
if (i_am_in_height_for_width_mode)
{
int min_width, dummy;
// First, get the minimum width of our widget
GTK_WIDGET_GET_CLASS (widget)->measure (widget, GTK_ORIENTATION_HORIZONTAL, -1,
&min_width, &dummy, &dummy, &dummy);
// Now use the minimum width to retrieve the minimum and natural height to display
// that width.
GTK_WIDGET_GET_CLASS (widget)->measure (widget, GTK_ORIENTATION_VERTICAL, min_width,
minimum_size, natural_size, &dummy, &dummy);
}
else
{
// ... some widgets do both.
}
}
}
```
| Functions
---------
### gtk\_widget\_in\_destruction ()
```
gboolean
gtk_widget_in_destruction (*`[GtkWidget](gtkwidget#GtkWidget-struct) *widget`*);
```
Returns whether the widget is currently being destroyed. This information can sometimes be used to avoid doing unnecessary work.
#### Parameters
| | | |
| --- | --- | --- |
| widget | a [GtkWidget](gtkwidget#GtkWidget-struct) | |
#### Returns
`TRUE` if *`widget`* is being destroyed
### gtk\_widget\_unparent ()
```
void
gtk_widget_unparent (*`[GtkWidget](gtkwidget#GtkWidget-struct) *widget`*);
```
This function is only for use in widget implementations. It should be called by parent widgets to dissociate *`widget`* from the parent, typically in dispose.
#### Parameters
| | | |
| --- | --- | --- |
| widget | a [GtkWidget](gtkwidget#GtkWidget-struct) | |
### gtk\_widget\_show ()
```
void
gtk_widget_show (*`[GtkWidget](gtkwidget#GtkWidget-struct) *widget`*);
```
Flags a widget to be displayed. Any widget that isn’t shown will not appear on the screen.
Remember that you have to show the containers containing a widget, in addition to the widget itself, before it will appear onscreen.
When a toplevel container is shown, it is immediately realized and mapped; other shown widgets are realized and mapped when their toplevel container is realized and mapped.
#### Parameters
| | | |
| --- | --- | --- |
| widget | a [GtkWidget](gtkwidget#GtkWidget-struct) | |
### gtk\_widget\_hide ()
```
void
gtk_widget_hide (*`[GtkWidget](gtkwidget#GtkWidget-struct) *widget`*);
```
Reverses the effects of [`gtk_widget_show()`](gtkwidget#gtk-widget-show), causing the widget to be hidden (invisible to the user).
#### Parameters
| | | |
| --- | --- | --- |
| widget | a [GtkWidget](gtkwidget#GtkWidget-struct) | |
### gtk\_widget\_map ()
```
void
gtk_widget_map (*`[GtkWidget](gtkwidget#GtkWidget-struct) *widget`*);
```
This function is only for use in widget implementations. Causes a widget to be mapped if it isn’t already.
#### Parameters
| | | |
| --- | --- | --- |
| widget | a [GtkWidget](gtkwidget#GtkWidget-struct) | |
### gtk\_widget\_unmap ()
```
void
gtk_widget_unmap (*`[GtkWidget](gtkwidget#GtkWidget-struct) *widget`*);
```
This function is only for use in widget implementations. Causes a widget to be unmapped if it’s currently mapped.
#### Parameters
| | | |
| --- | --- | --- |
| widget | a [GtkWidget](gtkwidget#GtkWidget-struct) | |
### gtk\_widget\_realize ()
```
void
gtk_widget_realize (*`[GtkWidget](gtkwidget#GtkWidget-struct) *widget`*);
```
Creates the GDK (windowing system) resources associated with a widget. Normally realization happens implicitly; if you show a widget and all its parent containers, then the widget will be realized and mapped automatically.
Realizing a widget requires all the widget’s parent widgets to be realized; calling [`gtk_widget_realize()`](gtkwidget#gtk-widget-realize) realizes the widget’s parents in addition to *`widget`* itself. If a widget is not yet inside a toplevel window when you realize it, bad things will happen.
This function is primarily used in widget implementations, and isn’t very useful otherwise. Many times when you think you might need it, a better approach is to connect to a signal that will be called after the widget is realized automatically, such as [“realize”](gtkwidget#GtkWidget-realize).
#### Parameters
| | | |
| --- | --- | --- |
| widget | a [GtkWidget](gtkwidget#GtkWidget-struct) | |
### gtk\_widget\_unrealize ()
```
void
gtk_widget_unrealize (*`[GtkWidget](gtkwidget#GtkWidget-struct) *widget`*);
```
This function is only useful in widget implementations. Causes a widget to be unrealized (frees all GDK resources associated with the widget).
#### Parameters
| | | |
| --- | --- | --- |
| widget | a [GtkWidget](gtkwidget#GtkWidget-struct) | |
### gtk\_widget\_queue\_draw ()
```
void
gtk_widget_queue_draw (*`[GtkWidget](gtkwidget#GtkWidget-struct) *widget`*);
```
Schedules this widget to be redrawn in paint phase of the current or the next frame. This means *`widget`* 's GtkWidgetClass.snapshot() implementation will be called.
#### Parameters
| | | |
| --- | --- | --- |
| widget | a [GtkWidget](gtkwidget#GtkWidget-struct) | |
### gtk\_widget\_queue\_resize ()
```
void
gtk_widget_queue_resize (*`[GtkWidget](gtkwidget#GtkWidget-struct) *widget`*);
```
This function is only for use in widget implementations. Flags a widget to have its size renegotiated; should be called when a widget for some reason has a new size request. For example, when you change the text in a [GtkLabel](gtklabel#GtkLabel-struct), [GtkLabel](gtklabel#GtkLabel-struct) queues a resize to ensure there’s enough space for the new text.
Note that you cannot call [`gtk_widget_queue_resize()`](gtkwidget#gtk-widget-queue-resize) on a widget from inside its implementation of the GtkWidgetClass::size\_allocate virtual method. Calls to [`gtk_widget_queue_resize()`](gtkwidget#gtk-widget-queue-resize) from inside GtkWidgetClass::size\_allocate will be silently ignored.
#### Parameters
| | | |
| --- | --- | --- |
| widget | a [GtkWidget](gtkwidget#GtkWidget-struct) | |
### gtk\_widget\_queue\_allocate ()
```
void
gtk_widget_queue_allocate (*`[GtkWidget](gtkwidget#GtkWidget-struct) *widget`*);
```
This function is only for use in widget implementations.
Flags the widget for a rerun of the GtkWidgetClass::size\_allocate function. Use this function instead of [`gtk_widget_queue_resize()`](gtkwidget#gtk-widget-queue-resize) when the *`widget`* 's size request didn't change but it wants to reposition its contents.
An example user of this function is [`gtk_widget_set_halign()`](gtkwidget#gtk-widget-set-halign).
#### Parameters
| | | |
| --- | --- | --- |
| widget | a [GtkWidget](gtkwidget#GtkWidget-struct) | |
### gtk\_widget\_get\_frame\_clock ()
```
[GdkFrameClock](https://developer-old.gnome.org/gtk4/html/GdkFrameClock.html#GdkFrameClock-struct) *
gtk_widget_get_frame_clock (*`[GtkWidget](gtkwidget#GtkWidget-struct) *widget`*);
```
Obtains the frame clock for a widget. The frame clock is a global “ticker” that can be used to drive animations and repaints. The most common reason to get the frame clock is to call [`gdk_frame_clock_get_frame_time()`](https://developer-old.gnome.org/gtk4/html/GdkFrameClock.html#gdk-frame-clock-get-frame-time), in order to get a time to use for animating. For example you might record the start of the animation with an initial value from [`gdk_frame_clock_get_frame_time()`](https://developer-old.gnome.org/gtk4/html/GdkFrameClock.html#gdk-frame-clock-get-frame-time), and then update the animation by calling [`gdk_frame_clock_get_frame_time()`](https://developer-old.gnome.org/gtk4/html/GdkFrameClock.html#gdk-frame-clock-get-frame-time) again during each repaint.
gdk\_frame\_clock\_request\_phase() will result in a new frame on the clock, but won’t necessarily repaint any widgets. To repaint a widget, you have to use [`gtk_widget_queue_draw()`](gtkwidget#gtk-widget-queue-draw) which invalidates the widget (thus scheduling it to receive a draw on the next frame). [`gtk_widget_queue_draw()`](gtkwidget#gtk-widget-queue-draw) will also end up requesting a frame on the appropriate frame clock.
A widget’s frame clock will not change while the widget is mapped. Reparenting a widget (which implies a temporary unmap) can change the widget’s frame clock.
Unrealized widgets do not have a frame clock.
#### Parameters
| | | |
| --- | --- | --- |
| widget | a [GtkWidget](gtkwidget#GtkWidget-struct) | |
#### Returns
a [GdkFrameClock](https://developer-old.gnome.org/gtk4/html/GdkFrameClock.html#GdkFrameClock-struct), or `NULL` if widget is unrealized.
[nullable][transfer none]
### gtk\_widget\_get\_scale\_factor ()
```
int
gtk_widget_get_scale_factor (*`[GtkWidget](gtkwidget#GtkWidget-struct) *widget`*);
```
Retrieves the internal scale factor that maps from window coordinates to the actual device pixels. On traditional systems this is 1, on high density outputs, it can be a higher value (typically 2).
See [`gdk_surface_get_scale_factor()`](https://developer-old.gnome.org/gtk4/html/GdkSurface.html#gdk-surface-get-scale-factor).
#### Parameters
| | | |
| --- | --- | --- |
| widget | a [GtkWidget](gtkwidget#GtkWidget-struct) | |
#### Returns
the scale factor for *`widget`*
### GtkTickCallback ()
```
gboolean
(*GtkTickCallback) (*`[GtkWidget](gtkwidget#GtkWidget-struct) *widget`*,
*`[GdkFrameClock](https://developer-old.gnome.org/gtk4/html/GdkFrameClock.html#GdkFrameClock-struct) *frame_clock`*,
*`gpointer user_data`*);
```
Callback type for adding a function to update animations. See [`gtk_widget_add_tick_callback()`](gtkwidget#gtk-widget-add-tick-callback).
#### Parameters
| | | |
| --- | --- | --- |
| widget | the widget | |
| frame\_clock | the frame clock for the widget (same as calling [`gtk_widget_get_frame_clock()`](gtkwidget#gtk-widget-get-frame-clock)) | |
| user\_data | user data passed to [`gtk_widget_add_tick_callback()`](gtkwidget#gtk-widget-add-tick-callback). | |
#### Returns
`G_SOURCE_CONTINUE` if the tick callback should continue to be called, `G_SOURCE_REMOVE` if the tick callback should be removed.
### gtk\_widget\_add\_tick\_callback ()
```
guint
gtk_widget_add_tick_callback (*`[GtkWidget](gtkwidget#GtkWidget-struct) *widget`*,
*`[GtkTickCallback](gtkwidget#GtkTickCallback) callback`*,
*`gpointer user_data`*,
*`GDestroyNotify notify`*);
```
Queues an animation frame update and adds a callback to be called before each frame. Until the tick callback is removed, it will be called frequently (usually at the frame rate of the output device or as quickly as the application can be repainted, whichever is slower). For this reason, is most suitable for handling graphics that change every frame or every few frames. The tick callback does not automatically imply a relayout or repaint. If you want a repaint or relayout, and aren’t changing widget properties that would trigger that (for example, changing the text of a [GtkLabel](gtklabel#GtkLabel-struct)), then you will have to call [`gtk_widget_queue_resize()`](gtkwidget#gtk-widget-queue-resize) or [`gtk_widget_queue_draw()`](gtkwidget#gtk-widget-queue-draw) yourself.
gdk\_frame\_clock\_get\_frame\_time() should generally be used for timing continuous animations and [`gdk_frame_timings_get_predicted_presentation_time()`](https://developer-old.gnome.org/gtk4/html/gdk4-GdkFrameTimings.html#gdk-frame-timings-get-predicted-presentation-time) if you are trying to display isolated frames at particular times.
This is a more convenient alternative to connecting directly to the [“update”](https://developer-old.gnome.org/gtk4/html/GdkFrameClock.html#GdkFrameClock-update) signal of [GdkFrameClock](https://developer-old.gnome.org/gtk4/html/GdkFrameClock.html#GdkFrameClock-struct), since you don't have to worry about when a [GdkFrameClock](https://developer-old.gnome.org/gtk4/html/GdkFrameClock.html#GdkFrameClock-struct) is assigned to a widget.
#### Parameters
| | | |
| --- | --- | --- |
| widget | a [GtkWidget](gtkwidget#GtkWidget-struct) | |
| callback | function to call for updating animations | |
| user\_data | data to pass to *`callback`* . | [closure] |
| notify | function to call to free *`user_data`* when the callback is removed. | |
#### Returns
an id for the connection of this callback. Remove the callback by passing the id returned from this function to [`gtk_widget_remove_tick_callback()`](gtkwidget#gtk-widget-remove-tick-callback)
### gtk\_widget\_remove\_tick\_callback ()
```
void
gtk_widget_remove_tick_callback (*`[GtkWidget](gtkwidget#GtkWidget-struct) *widget`*,
*`guint id`*);
```
Removes a tick callback previously registered with [`gtk_widget_add_tick_callback()`](gtkwidget#gtk-widget-add-tick-callback).
#### Parameters
| | | |
| --- | --- | --- |
| widget | a [GtkWidget](gtkwidget#GtkWidget-struct) | |
| id | an id returned by [`gtk_widget_add_tick_callback()`](gtkwidget#gtk-widget-add-tick-callback) | |
### gtk\_widget\_size\_allocate ()
```
void
gtk_widget_size_allocate (*`[GtkWidget](gtkwidget#GtkWidget-struct) *widget`*,
*`const [GtkAllocation](gtkwidget#GtkAllocation) *allocation`*,
*`int baseline`*);
```
This is a simple form of [`gtk_widget_allocate()`](gtkwidget#gtk-widget-allocate) that takes the new position of *`widget`* as part of *`allocation`* .
#### Parameters
| | | |
| --- | --- | --- |
| widget | a [GtkWidget](gtkwidget#GtkWidget-struct) | |
| allocation | position and size to be allocated to *`widget`* | |
| baseline | The baseline of the child, or -1 | |
### gtk\_widget\_allocate ()
```
void
gtk_widget_allocate (*`[GtkWidget](gtkwidget#GtkWidget-struct) *widget`*,
*`int width`*,
*`int height`*,
*`int baseline`*,
*`[GskTransform](https://developer-old.gnome.org/gtk4/html/gsk4-GskTransform.html#GskTransform) *transform`*);
```
This function is only used by [GtkWidget](gtkwidget#GtkWidget-struct) subclasses, to assign a size, position and (optionally) baseline to their child widgets.
In this function, the allocation and baseline may be adjusted. The given allocation will be forced to be bigger than the widget's minimum size, as well as at least 0×0 in size.
For a version that does not take a transform, see [`gtk_widget_size_allocate()`](gtkwidget#gtk-widget-size-allocate)
#### Parameters
| | | |
| --- | --- | --- |
| widget | A [GtkWidget](gtkwidget#GtkWidget-struct) | |
| width | New width of *`widget`* | |
| height | New height of *`widget`* | |
| baseline | New baseline of *`widget`* , or -1 | |
| transform | Transformation to be applied to *`widget`* . | [transfer full][allow-none] |
### gtk\_widget\_class\_add\_shortcut ()
```
void
gtk_widget_class_add_shortcut (*`[GtkWidgetClass](gtkwidget#GtkWidgetClass) *widget_class`*,
*`[GtkShortcut](gtkshortcut#GtkShortcut-struct) *shortcut`*);
```
Installs a shortcut in *`widget_class`* . Every instance created for *`widget_class`* or its subclasses will inherit this shortcut and trigger it.
Shortcuts added this way will be triggered in the *`GTK_PHASE_BUBBLE`* phase, which means they may also trigger if child widgets have focus.
This function must only be used in class initialization functions otherwise it is not guaranteed that the shortcut will be installed.
#### Parameters
| | | |
| --- | --- | --- |
| widget\_class | the class to add the shortcut to | |
| shortcut | the [GtkShortcut](gtkshortcut#GtkShortcut-struct) to add. | [transfer none] |
### gtk\_widget\_class\_add\_binding ()
```
void
gtk_widget_class_add_binding (*`[GtkWidgetClass](gtkwidget#GtkWidgetClass) *widget_class`*,
*`guint keyval`*,
*`[GdkModifierType](https://developer-old.gnome.org/gtk4/html/GdkSurface.html#GdkModifierType) mods`*,
*`[GtkShortcutFunc](gtkshortcutaction#GtkShortcutFunc) callback`*,
*`const char *format_string`*,
*`...`*);
```
Creates a new shortcut for *`widget_class`* that calls the given *`callback`* with arguments read according to *`format_string`* . The arguments and format string must be provided in the same way as with `g_variant_new()`.
This function is a convenience wrapper around [`gtk_widget_class_add_shortcut()`](gtkwidget#gtk-widget-class-add-shortcut) and must be called during class initialization. It does not provide for user\_data, if you need that, you will have to use [`gtk_widget_class_add_shortcut()`](gtkwidget#gtk-widget-class-add-shortcut) with a custom shortcut.
[skip]
#### Parameters
| | | |
| --- | --- | --- |
| widget\_class | the class to add the binding to | |
| keyval | key value of binding to install | |
| mods | key modifier of binding to install | |
| callback | the callback to call upon activation | |
| format\_string | GVariant format string for arguments or `NULL` for no arguments. | [nullable] |
| ... | arguments, as given by format string. | |
### gtk\_widget\_class\_add\_binding\_signal ()
```
void
gtk_widget_class_add_binding_signal (*`[GtkWidgetClass](gtkwidget#GtkWidgetClass) *widget_class`*,
*`guint keyval`*,
*`[GdkModifierType](https://developer-old.gnome.org/gtk4/html/GdkSurface.html#GdkModifierType) mods`*,
*`const char *signal`*,
*`const char *format_string`*,
*`...`*);
```
Creates a new shortcut for *`widget_class`* that emits the given action *`signal`* with arguments read according to *`format_string`* . The arguments and format string must be provided in the same way as with `g_variant_new()`.
This function is a convenience wrapper around [`gtk_widget_class_add_shortcut()`](gtkwidget#gtk-widget-class-add-shortcut) and must be called during class initialization.
[skip]
#### Parameters
| | | |
| --- | --- | --- |
| widget\_class | the class to add the binding to | |
| keyval | key value of binding to install | |
| mods | key modifier of binding to install | |
| signal | the signal to execute | |
| format\_string | GVariant format string for arguments or `NULL` for no arguments. | [nullable] |
| ... | arguments, as given by format string. | |
### gtk\_widget\_class\_add\_binding\_action ()
```
void
gtk_widget_class_add_binding_action (*`[GtkWidgetClass](gtkwidget#GtkWidgetClass) *widget_class`*,
*`guint keyval`*,
*`[GdkModifierType](https://developer-old.gnome.org/gtk4/html/GdkSurface.html#GdkModifierType) mods`*,
*`const char *action_name`*,
*`const char *format_string`*,
*`...`*);
```
Creates a new shortcut for *`widget_class`* that activates the given *`action_name`* with arguments read according to *`format_string`* . The arguments and format string must be provided in the same way as with `g_variant_new()`.
This function is a convenience wrapper around [`gtk_widget_class_add_shortcut()`](gtkwidget#gtk-widget-class-add-shortcut) and must be called during class initialization.
[skip]
#### Parameters
| | | |
| --- | --- | --- |
| widget\_class | the class to add the binding to | |
| keyval | key value of binding to install | |
| mods | key modifier of binding to install | |
| action\_name | the action to activate | |
| format\_string | GVariant format string for arguments or `NULL` for no arguments. | [nullable] |
| ... | arguments, as given by format string. | |
### gtk\_widget\_class\_set\_layout\_manager\_type ()
```
void
gtk_widget_class_set_layout_manager_type
(*`[GtkWidgetClass](gtkwidget#GtkWidgetClass) *widget_class`*,
*`GType type`*);
```
Sets the type to be used for creating layout managers for widgets of *`widget_class`* . The given *`type`* must be a subtype of [GtkLayoutManager](gtklayoutmanager#GtkLayoutManager-struct).
This function should only be called from class init functions of widgets.
#### Parameters
| | | |
| --- | --- | --- |
| widget\_class | class to set the layout manager type for | |
| type | The object type that implements the [GtkLayoutManager](gtklayoutmanager#GtkLayoutManager-struct) for *`widget_class`* | |
### gtk\_widget\_class\_get\_layout\_manager\_type ()
```
GType
gtk_widget_class_get_layout_manager_type
(*`[GtkWidgetClass](gtkwidget#GtkWidgetClass) *widget_class`*);
```
Retrieves the type of the [GtkLayoutManager](gtklayoutmanager#GtkLayoutManager-struct) used by the [GtkWidget](gtkwidget#GtkWidget-struct) class.
See also: [`gtk_widget_class_set_layout_manager_type()`](gtkwidget#gtk-widget-class-set-layout-manager-type)
#### Parameters
| | | |
| --- | --- | --- |
| widget\_class | a [GtkWidgetClass](gtkwidget#GtkWidgetClass) | |
#### Returns
a [GtkLayoutManager](gtklayoutmanager#GtkLayoutManager-struct) subclass, or `G_TYPE_INVALID`
### gtk\_widget\_class\_set\_activate\_signal ()
```
void
gtk_widget_class_set_activate_signal (*`[GtkWidgetClass](gtkwidget#GtkWidgetClass) *widget_class`*,
*`guint signal_id`*);
```
Sets the [GtkWidgetClass.activate\_signal](https://developer-old.gnome.org/usr/share/gtk-doc/html/gtk4/GtkWidget.html#GtkWidgetClass.activate-signal) field with the given *`signal_id`* ; the signal will be emitted when calling [`gtk_widget_activate()`](gtkwidget#gtk-widget-activate).
The *`signal_id`* must have been registered with `g_signal_new()` or `g_signal_newv()` before calling this function.
#### Parameters
| | | |
| --- | --- | --- |
| widget\_class | a [GtkWidgetClass](gtkwidget#GtkWidgetClass) | |
| signal\_id | the id for the activate signal | |
### gtk\_widget\_class\_set\_activate\_signal\_from\_name ()
```
void
gtk_widget_class_set_activate_signal_from_name
(*`[GtkWidgetClass](gtkwidget#GtkWidgetClass) *widget_class`*,
*`const char *signal_name`*);
```
Sets the [GtkWidgetClass.activate\_signal](https://developer-old.gnome.org/usr/share/gtk-doc/html/gtk4/GtkWidget.html#GtkWidgetClass.activate-signal) field with the signal id for the given *`signal_name`* ; the signal will be emitted when calling [`gtk_widget_activate()`](gtkwidget#gtk-widget-activate).
The *`signal_name`* of *`widget_type`* must have been registered with `g_signal_new()` or `g_signal_newv()` before calling this function.
#### Parameters
| | | |
| --- | --- | --- |
| widget\_class | a [GtkWidgetClass](gtkwidget#GtkWidgetClass) | |
| signal\_name | the name of the activate signal of *`widget_type`* | |
### gtk\_widget\_class\_get\_activate\_signal ()
```
guint
gtk_widget_class_get_activate_signal (*`[GtkWidgetClass](gtkwidget#GtkWidgetClass) *widget_class`*);
```
Retrieves the signal id for the activation signal set using [`gtk_widget_class_set_activate_signal()`](gtkwidget#gtk-widget-class-set-activate-signal).
#### Parameters
| | | |
| --- | --- | --- |
| widget\_class | a [GtkWidgetClass](gtkwidget#GtkWidgetClass) | |
#### Returns
a signal id, or 0 if the widget class does not specify an activation signal
### gtk\_widget\_activate ()
```
gboolean
gtk_widget_activate (*`[GtkWidget](gtkwidget#GtkWidget-struct) *widget`*);
```
For widgets that can be “activated” (buttons, menu items, etc.) this function activates them. The activation will emit the signal set using [`gtk_widget_class_set_activate_signal()`](gtkwidget#gtk-widget-class-set-activate-signal) during class initialization.
Activation is what happens when you press Enter on a widget during key navigation.
If you wish to handle the activation keybinding yourself, it is recommended to use [`gtk_widget_class_add_shortcut()`](gtkwidget#gtk-widget-class-add-shortcut) with an action created with [`gtk_signal_action_new()`](gtkshortcutaction#gtk-signal-action-new).
If *`widget`* isn't activatable, the function returns `FALSE`.
#### Parameters
| | | |
| --- | --- | --- |
| widget | a [GtkWidget](gtkwidget#GtkWidget-struct) that’s activatable | |
#### Returns
`TRUE` if the widget was activatable
### gtk\_widget\_is\_focus ()
```
gboolean
gtk_widget_is_focus (*`[GtkWidget](gtkwidget#GtkWidget-struct) *widget`*);
```
Determines if the widget is the focus widget within its toplevel. (This does not mean that the [“has-focus”](gtkwidget#GtkWidget--has-focus) property is necessarily set; [“has-focus”](gtkwidget#GtkWidget--has-focus) will only be set if the toplevel widget additionally has the global input focus.)
#### Parameters
| | | |
| --- | --- | --- |
| widget | a [GtkWidget](gtkwidget#GtkWidget-struct) | |
#### Returns
`TRUE` if the widget is the focus widget.
### gtk\_widget\_grab\_focus ()
```
gboolean
gtk_widget_grab_focus (*`[GtkWidget](gtkwidget#GtkWidget-struct) *widget`*);
```
Causes *`widget`* (or one of its descendents) to have the keyboard focus for the [GtkWindow](gtkwindow#GtkWindow-struct) it's inside.
If *`widget`* is not focusable, or its ::grab\_focus implementation cannot transfer the focus to a descendant of *`widget`* that is focusable, it will not take focus and `FALSE` will be returned.
Calling [`gtk_widget_grab_focus()`](gtkwidget#gtk-widget-grab-focus) on an already focused widget is allowed, should not have an effect, and return `TRUE`.
#### Parameters
| | | |
| --- | --- | --- |
| widget | a [GtkWidget](gtkwidget#GtkWidget-struct) | |
#### Returns
`TRUE` if focus is now inside *`widget`* .
### gtk\_widget\_set\_name ()
```
void
gtk_widget_set_name (*`[GtkWidget](gtkwidget#GtkWidget-struct) *widget`*,
*`const char *name`*);
```
Widgets can be named, which allows you to refer to them from a CSS file. You can apply a style to widgets with a particular name in the CSS file. See the documentation for the CSS syntax (on the same page as the docs for [GtkStyleContext](gtkstylecontext#GtkStyleContext-struct)).
Note that the CSS syntax has certain special characters to delimit and represent elements in a selector (period, #, >, \*...), so using these will make your widget impossible to match by name. Any combination of alphanumeric symbols, dashes and underscores will suffice.
#### Parameters
| | | |
| --- | --- | --- |
| widget | a [GtkWidget](gtkwidget#GtkWidget-struct) | |
| name | name for the widget | |
### gtk\_widget\_get\_name ()
```
const char *
gtk_widget_get_name (*`[GtkWidget](gtkwidget#GtkWidget-struct) *widget`*);
```
Retrieves the name of a widget. See [`gtk_widget_set_name()`](gtkwidget#gtk-widget-set-name) for the significance of widget names.
#### Parameters
| | | |
| --- | --- | --- |
| widget | a [GtkWidget](gtkwidget#GtkWidget-struct) | |
#### Returns
name of the widget. This string is owned by GTK and should not be modified or freed.
[nullable]
### gtk\_widget\_set\_sensitive ()
```
void
gtk_widget_set_sensitive (*`[GtkWidget](gtkwidget#GtkWidget-struct) *widget`*,
*`gboolean sensitive`*);
```
Sets the sensitivity of a widget. A widget is sensitive if the user can interact with it. Insensitive widgets are “grayed out” and the user can’t interact with them. Insensitive widgets are known as “inactive”, “disabled”, or “ghosted” in some other toolkits.
#### Parameters
| | | |
| --- | --- | --- |
| widget | a [GtkWidget](gtkwidget#GtkWidget-struct) | |
| sensitive | `TRUE` to make the widget sensitive | |
### gtk\_widget\_set\_parent ()
```
void
gtk_widget_set_parent (*`[GtkWidget](gtkwidget#GtkWidget-struct) *widget`*,
*`[GtkWidget](gtkwidget#GtkWidget-struct) *parent`*);
```
This function is useful only when implementing subclasses of [GtkWidget](gtkwidget#GtkWidget-struct).
Sets *`parent`* as the parent widget of *`widget`* , and takes care of some details such as updating the state and style of the child to reflect its new location and resizing the parent. The opposite function is [`gtk_widget_unparent()`](gtkwidget#gtk-widget-unparent).
#### Parameters
| | | |
| --- | --- | --- |
| widget | a [GtkWidget](gtkwidget#GtkWidget-struct) | |
| parent | parent widget | |
### gtk\_widget\_get\_root ()
```
[GtkRoot](gtkroot#GtkRoot-struct) *
gtk_widget_get_root (*`[GtkWidget](gtkwidget#GtkWidget-struct) *widget`*);
```
Returns the [GtkRoot](gtkroot#GtkRoot-struct) widget of *`widget`* or `NULL` if the widget is not contained inside a widget tree with a root widget.
[GtkRoot](gtkroot#GtkRoot-struct) widgets will return themselves here.
#### Parameters
| | | |
| --- | --- | --- |
| widget | a [GtkWidget](gtkwidget#GtkWidget-struct) | |
#### Returns
the root widget of *`widget`* , or `NULL`.
[transfer none][nullable]
### gtk\_widget\_get\_native ()
```
[GtkNative](gtknative#GtkNative-struct) *
gtk_widget_get_native (*`[GtkWidget](gtkwidget#GtkWidget-struct) *widget`*);
```
Returns the GtkNative widget that contains *`widget`* , or `NULL` if the widget is not contained inside a widget tree with a native ancestor.
[GtkNative](gtknative#GtkNative-struct) widgets will return themselves here.
#### Parameters
| | | |
| --- | --- | --- |
| widget | a [GtkWidget](gtkwidget#GtkWidget-struct) | |
#### Returns
the [GtkNative](gtknative#GtkNative-struct) widget of *`widget`* , or `NULL`.
[transfer none][nullable]
### gtk\_widget\_get\_ancestor ()
```
[GtkWidget](gtkwidget#GtkWidget-struct) *
gtk_widget_get_ancestor (*`[GtkWidget](gtkwidget#GtkWidget-struct) *widget`*,
*`GType widget_type`*);
```
Gets the first ancestor of *`widget`* with type *`widget_type`* . For example, `gtk_widget_get_ancestor (widget, GTK_TYPE_BOX)` gets the first [GtkBox](gtkbox#GtkBox-struct) that’s an ancestor of *`widget`* . No reference will be added to the returned widget; it should not be unreferenced.
Note that unlike [`gtk_widget_is_ancestor()`](gtkwidget#gtk-widget-is-ancestor), [`gtk_widget_get_ancestor()`](gtkwidget#gtk-widget-get-ancestor) considers *`widget`* to be an ancestor of itself.
#### Parameters
| | | |
| --- | --- | --- |
| widget | a [GtkWidget](gtkwidget#GtkWidget-struct) | |
| widget\_type | ancestor type | |
#### Returns
the ancestor widget, or `NULL` if not found.
[transfer none][nullable]
### gtk\_widget\_is\_ancestor ()
```
gboolean
gtk_widget_is_ancestor (*`[GtkWidget](gtkwidget#GtkWidget-struct) *widget`*,
*`[GtkWidget](gtkwidget#GtkWidget-struct) *ancestor`*);
```
Determines whether *`widget`* is somewhere inside *`ancestor`* , possibly with intermediate containers.
#### Parameters
| | | |
| --- | --- | --- |
| widget | a [GtkWidget](gtkwidget#GtkWidget-struct) | |
| ancestor | another [GtkWidget](gtkwidget#GtkWidget-struct) | |
#### Returns
`TRUE` if *`ancestor`* contains *`widget`* as a child, grandchild, great grandchild, etc.
### gtk\_widget\_translate\_coordinates ()
```
gboolean
gtk_widget_translate_coordinates (*`[GtkWidget](gtkwidget#GtkWidget-struct) *src_widget`*,
*`[GtkWidget](gtkwidget#GtkWidget-struct) *dest_widget`*,
*`double src_x`*,
*`double src_y`*,
*`double *dest_x`*,
*`double *dest_y`*);
```
Translate coordinates relative to *`src_widget`* ’s allocation to coordinates relative to *`dest_widget`* ’s allocations. In order to perform this operation, both widget must share a common toplevel.
#### Parameters
| | | |
| --- | --- | --- |
| src\_widget | a [GtkWidget](gtkwidget#GtkWidget-struct) | |
| dest\_widget | a [GtkWidget](gtkwidget#GtkWidget-struct) | |
| src\_x | X position relative to *`src_widget`* | |
| src\_y | Y position relative to *`src_widget`* | |
| dest\_x | location to store X position relative to *`dest_widget`* . | [out][optional] |
| dest\_y | location to store Y position relative to *`dest_widget`* . | [out][optional] |
#### Returns
`FALSE` if *`src_widget`* and *`dest_widget`* have no common ancestor. In this case, 0 is stored in \**`dest_x`* and \**`dest_y`* . Otherwise `TRUE`.
### gtk\_widget\_add\_controller ()
```
void
gtk_widget_add_controller (*`[GtkWidget](gtkwidget#GtkWidget-struct) *widget`*,
*`[GtkEventController](gtkeventcontroller#GtkEventController-struct) *controller`*);
```
Adds *`controller`* to *`widget`* so that it will receive events. You will usually want to call this function right after creating any kind of [GtkEventController](gtkeventcontroller#GtkEventController-struct).
#### Parameters
| | | |
| --- | --- | --- |
| widget | a [GtkWidget](gtkwidget#GtkWidget-struct) | |
| controller | a [GtkEventController](gtkeventcontroller#GtkEventController-struct) that hasn't been added to a widget yet. | [transfer full] |
### gtk\_widget\_remove\_controller ()
```
void
gtk_widget_remove_controller (*`[GtkWidget](gtkwidget#GtkWidget-struct) *widget`*,
*`[GtkEventController](gtkeventcontroller#GtkEventController-struct) *controller`*);
```
Removes *`controller`* from *`widget`* , so that it doesn't process events anymore. It should not be used again.
Widgets will remove all event controllers automatically when they are destroyed, there is normally no need to call this function.
#### Parameters
| | | |
| --- | --- | --- |
| widget | a [GtkWidget](gtkwidget#GtkWidget-struct) | |
| controller | a [GtkEventController](gtkeventcontroller#GtkEventController-struct). | [transfer none] |
### gtk\_widget\_set\_direction ()
```
void
gtk_widget_set_direction (*`[GtkWidget](gtkwidget#GtkWidget-struct) *widget`*,
*`[GtkTextDirection](gtkwidget#GtkTextDirection) dir`*);
```
Sets the reading direction on a particular widget. This direction controls the primary direction for widgets containing text, and also the direction in which the children of a container are packed. The ability to set the direction is present in order so that correct localization into languages with right-to-left reading directions can be done. Generally, applications will let the default reading direction present, except for containers where the containers are arranged in an order that is explicitly visual rather than logical (such as buttons for text justification).
If the direction is set to [`GTK_TEXT_DIR_NONE`](gtkwidget#GTK-TEXT-DIR-NONE:CAPS), then the value set by [`gtk_widget_set_default_direction()`](gtkwidget#gtk-widget-set-default-direction) will be used.
#### Parameters
| | | |
| --- | --- | --- |
| widget | a [GtkWidget](gtkwidget#GtkWidget-struct) | |
| dir | the new direction | |
### gtk\_widget\_get\_direction ()
```
[GtkTextDirection](gtkwidget#GtkTextDirection)
gtk_widget_get_direction (*`[GtkWidget](gtkwidget#GtkWidget-struct) *widget`*);
```
Gets the reading direction for a particular widget. See [`gtk_widget_set_direction()`](gtkwidget#gtk-widget-set-direction).
#### Parameters
| | | |
| --- | --- | --- |
| widget | a [GtkWidget](gtkwidget#GtkWidget-struct) | |
#### Returns
the reading direction for the widget.
### gtk\_widget\_set\_default\_direction ()
```
void
gtk_widget_set_default_direction (*`[GtkTextDirection](gtkwidget#GtkTextDirection) dir`*);
```
Sets the default reading direction for widgets where the direction has not been explicitly set by [`gtk_widget_set_direction()`](gtkwidget#gtk-widget-set-direction).
#### Parameters
| | | |
| --- | --- | --- |
| dir | the new default direction. This cannot be [`GTK_TEXT_DIR_NONE`](gtkwidget#GTK-TEXT-DIR-NONE:CAPS). | |
### gtk\_widget\_get\_default\_direction ()
```
[GtkTextDirection](gtkwidget#GtkTextDirection)
gtk_widget_get_default_direction (*`void`*);
```
Obtains the current default reading direction. See [`gtk_widget_set_default_direction()`](gtkwidget#gtk-widget-set-default-direction).
#### Returns
the current default direction.
### gtk\_widget\_create\_pango\_context ()
```
[PangoContext](https://developer-old.gnome.org/pango/stable/pango-Contexts.html#PangoContext-struct) *
gtk_widget_create_pango_context (*`[GtkWidget](gtkwidget#GtkWidget-struct) *widget`*);
```
Creates a new [PangoContext](https://developer-old.gnome.org/pango/stable/pango-Contexts.html#PangoContext-struct) with the appropriate font map, font options, font description, and base direction for drawing text for this widget. See also [`gtk_widget_get_pango_context()`](gtkwidget#gtk-widget-get-pango-context).
#### Parameters
| | | |
| --- | --- | --- |
| widget | a [GtkWidget](gtkwidget#GtkWidget-struct) | |
#### Returns
the new [PangoContext](https://developer-old.gnome.org/pango/stable/pango-Contexts.html#PangoContext-struct).
[transfer full]
### gtk\_widget\_get\_pango\_context ()
```
[PangoContext](https://developer-old.gnome.org/pango/stable/pango-Contexts.html#PangoContext-struct) *
gtk_widget_get_pango_context (*`[GtkWidget](gtkwidget#GtkWidget-struct) *widget`*);
```
Gets a [PangoContext](https://developer-old.gnome.org/pango/stable/pango-Contexts.html#PangoContext-struct) with the appropriate font map, font description, and base direction for this widget. Unlike the context returned by [`gtk_widget_create_pango_context()`](gtkwidget#gtk-widget-create-pango-context), this context is owned by the widget (it can be used until the screen for the widget changes or the widget is removed from its toplevel), and will be updated to match any changes to the widget’s attributes. This can be tracked by listening to changes of the [“root”](gtkwidget#GtkWidget--root) property on the widget.
#### Parameters
| | | |
| --- | --- | --- |
| widget | a [GtkWidget](gtkwidget#GtkWidget-struct) | |
#### Returns
the [PangoContext](https://developer-old.gnome.org/pango/stable/pango-Contexts.html#PangoContext-struct) for the widget.
[transfer none]
### gtk\_widget\_set\_font\_options ()
```
void
gtk_widget_set_font_options (*`[GtkWidget](gtkwidget#GtkWidget-struct) *widget`*,
*`const [cairo\_font\_options\_t](https://developer-old.gnome.org/cairo/stable/cairo-cairo-font-options-t.html#cairo-font-options-t) *options`*);
```
Sets the [cairo\_font\_options\_t](https://developer-old.gnome.org/cairo/stable/cairo-cairo-font-options-t.html#cairo-font-options-t) used for Pango rendering in this widget. When not set, the default font options for the [GdkDisplay](https://developer-old.gnome.org/gtk4/html/GdkDisplay.html#GdkDisplay-struct) will be used.
#### Parameters
| | | |
| --- | --- | --- |
| widget | a [GtkWidget](gtkwidget#GtkWidget-struct) | |
| options | a [cairo\_font\_options\_t](https://developer-old.gnome.org/cairo/stable/cairo-cairo-font-options-t.html#cairo-font-options-t), or `NULL` to unset any previously set default font options. | [allow-none] |
### gtk\_widget\_get\_font\_options ()
```
const [cairo\_font\_options\_t](https://developer-old.gnome.org/cairo/stable/cairo-cairo-font-options-t.html#cairo-font-options-t) *
gtk_widget_get_font_options (*`[GtkWidget](gtkwidget#GtkWidget-struct) *widget`*);
```
Returns the [cairo\_font\_options\_t](https://developer-old.gnome.org/cairo/stable/cairo-cairo-font-options-t.html#cairo-font-options-t) used for Pango rendering. When not set, the defaults font options for the [GdkDisplay](https://developer-old.gnome.org/gtk4/html/GdkDisplay.html#GdkDisplay-struct) will be used.
#### Parameters
| | | |
| --- | --- | --- |
| widget | a [GtkWidget](gtkwidget#GtkWidget-struct) | |
#### Returns
the [cairo\_font\_options\_t](https://developer-old.gnome.org/cairo/stable/cairo-cairo-font-options-t.html#cairo-font-options-t) or `NULL` if not set.
[transfer none][nullable]
### gtk\_widget\_set\_font\_map ()
```
void
gtk_widget_set_font_map (*`[GtkWidget](gtkwidget#GtkWidget-struct) *widget`*,
*`[PangoFontMap](https://developer-old.gnome.org/pango/stable/pango-Fonts.html#PangoFontMap-struct) *font_map`*);
```
Sets the font map to use for Pango rendering. The font map is the object that is used to look up fonts. Setting a custom font map can be useful in special situations, e.g. when you need to add application-specific fonts to the set of available fonts.
When not set, the widget will inherit the font map from its parent.
#### Parameters
| | | |
| --- | --- | --- |
| widget | a [GtkWidget](gtkwidget#GtkWidget-struct) | |
| font\_map | a [PangoFontMap](https://developer-old.gnome.org/pango/stable/pango-Fonts.html#PangoFontMap-struct), or `NULL` to unset any previously set font map. | [allow-none] |
### gtk\_widget\_get\_font\_map ()
```
[PangoFontMap](https://developer-old.gnome.org/pango/stable/pango-Fonts.html#PangoFontMap-struct) *
gtk_widget_get_font_map (*`[GtkWidget](gtkwidget#GtkWidget-struct) *widget`*);
```
Gets the font map that has been set with [`gtk_widget_set_font_map()`](gtkwidget#gtk-widget-set-font-map).
#### Parameters
| | | |
| --- | --- | --- |
| widget | a [GtkWidget](gtkwidget#GtkWidget-struct) | |
#### Returns
A [PangoFontMap](https://developer-old.gnome.org/pango/stable/pango-Fonts.html#PangoFontMap-struct), or `NULL`.
[transfer none][nullable]
### gtk\_widget\_create\_pango\_layout ()
```
[PangoLayout](https://developer-old.gnome.org/pango/stable/pango-Layout-Objects.html#PangoLayout-struct) *
gtk_widget_create_pango_layout (*`[GtkWidget](gtkwidget#GtkWidget-struct) *widget`*,
*`const char *text`*);
```
Creates a new [PangoLayout](https://developer-old.gnome.org/pango/stable/pango-Layout-Objects.html#PangoLayout-struct) with the appropriate font map, font description, and base direction for drawing text for this widget.
If you keep a [PangoLayout](https://developer-old.gnome.org/pango/stable/pango-Layout-Objects.html#PangoLayout-struct) created in this way around, you need to re-create it when the widget [PangoContext](https://developer-old.gnome.org/pango/stable/pango-Contexts.html#PangoContext-struct) is replaced. This can be tracked by listening to changes of the [“root”](gtkwidget#GtkWidget--root) property on the widget.
#### Parameters
| | | |
| --- | --- | --- |
| widget | a [GtkWidget](gtkwidget#GtkWidget-struct) | |
| text | text to set on the layout (can be `NULL`). | [nullable] |
#### Returns
the new [PangoLayout](https://developer-old.gnome.org/pango/stable/pango-Layout-Objects.html#PangoLayout-struct).
[transfer full]
### gtk\_widget\_get\_cursor ()
```
[GdkCursor](https://developer-old.gnome.org/gtk4/html/gdk4-Cursors.html#GdkCursor-struct) *
gtk_widget_get_cursor (*`[GtkWidget](gtkwidget#GtkWidget-struct) *widget`*);
```
Queries the cursor set via [`gtk_widget_set_cursor()`](gtkwidget#gtk-widget-set-cursor). See that function for details.
#### Parameters
| | | |
| --- | --- | --- |
| widget | a [GtkWidget](gtkwidget#GtkWidget-struct) | |
#### Returns
the cursor currently in use or `NULL` to use the default.
[nullable][transfer none]
### gtk\_widget\_set\_cursor ()
```
void
gtk_widget_set_cursor (*`[GtkWidget](gtkwidget#GtkWidget-struct) *widget`*,
*`[GdkCursor](https://developer-old.gnome.org/gtk4/html/gdk4-Cursors.html#GdkCursor-struct) *cursor`*);
```
Sets the cursor to be shown when pointer devices point towards *`widget`* .
If the *`cursor`* is NULL, *`widget`* will use the cursor inherited from the parent widget.
#### Parameters
| | | |
| --- | --- | --- |
| widget | a [GtkWidget](gtkwidget#GtkWidget-struct) | |
| cursor | the new cursor or `NULL` to use the default cursor. | [allow-none] |
### gtk\_widget\_set\_cursor\_from\_name ()
```
void
gtk_widget_set_cursor_from_name (*`[GtkWidget](gtkwidget#GtkWidget-struct) *widget`*,
*`const char *name`*);
```
Sets a named cursor to be shown when pointer devices point towards *`widget`* .
This is a utility function that creates a cursor via [`gdk_cursor_new_from_name()`](https://developer-old.gnome.org/gtk4/html/gdk4-Cursors.html#gdk-cursor-new-from-name) and then sets it on *`widget`* with [`gtk_widget_set_cursor()`](gtkwidget#gtk-widget-set-cursor). See those 2 functions for details.
On top of that, this function allows *`name`* to be `NULL`, which will do the same as calling [`gtk_widget_set_cursor()`](gtkwidget#gtk-widget-set-cursor) with a `NULL` cursor.
#### Parameters
| | | |
| --- | --- | --- |
| widget | a [GtkWidget](gtkwidget#GtkWidget-struct) | |
| name | The name of the cursor or `NULL` to use the default cursor. | [nullable] |
### gtk\_widget\_mnemonic\_activate ()
```
gboolean
gtk_widget_mnemonic_activate (*`[GtkWidget](gtkwidget#GtkWidget-struct) *widget`*,
*`gboolean group_cycling`*);
```
Emits the [“mnemonic-activate”](gtkwidget#GtkWidget-mnemonic-activate) signal.
#### Parameters
| | | |
| --- | --- | --- |
| widget | a [GtkWidget](gtkwidget#GtkWidget-struct) | |
| group\_cycling | `TRUE` if there are other widgets with the same mnemonic | |
#### Returns
`TRUE` if the signal has been handled
### gtk\_widget\_class\_set\_accessible\_role ()
```
void
gtk_widget_class_set_accessible_role (*`[GtkWidgetClass](gtkwidget#GtkWidgetClass) *widget_class`*,
*`[GtkAccessibleRole](gtkaccessible#GtkAccessibleRole) accessible_role`*);
```
Sets the accessible role used by the given [GtkWidget](gtkwidget#GtkWidget-struct) class.
Different accessible roles have different states, and are rendered differently by assistive technologies.
#### Parameters
| | | |
| --- | --- | --- |
| widget\_class | a [GtkWidgetClass](gtkwidget#GtkWidgetClass) | |
| accessible\_role | the [GtkAccessibleRole](gtkaccessible#GtkAccessibleRole) used by the *`widget_class`* | |
### gtk\_widget\_class\_get\_accessible\_role ()
```
[GtkAccessibleRole](gtkaccessible#GtkAccessibleRole)
gtk_widget_class_get_accessible_role (*`[GtkWidgetClass](gtkwidget#GtkWidgetClass) *widget_class`*);
```
Retrieves the accessible role used by the given [GtkWidget](gtkwidget#GtkWidget-struct) class.
Different accessible roles have different states, and are rendered differently by assistive technologies.
See also: [`gtk_accessible_get_accessible_role()`](gtkaccessible#gtk-accessible-get-accessible-role)
#### Parameters
| | | |
| --- | --- | --- |
| widget\_class | a [GtkWidgetClass](gtkwidget#GtkWidgetClass) | |
#### Returns
the accessible role for the widget class
### gtk\_widget\_child\_focus ()
```
gboolean
gtk_widget_child_focus (*`[GtkWidget](gtkwidget#GtkWidget-struct) *widget`*,
*`[GtkDirectionType](gtk4-standard-enumerations#GtkDirectionType) direction`*);
```
This function is used by custom widget implementations; if you're writing an app, you’d use [`gtk_widget_grab_focus()`](gtkwidget#gtk-widget-grab-focus) to move the focus to a particular widget.
gtk\_widget\_child\_focus() is called by widgets as the user moves around the window using keyboard shortcuts. *`direction`* indicates what kind of motion is taking place (up, down, left, right, tab forward, tab backward). [`gtk_widget_child_focus()`](gtkwidget#gtk-widget-child-focus) calls the [`GtkWidgetClass.focus()`](gtkwidget#GtkWidgetClass.focus) vfunc; widgets override this vfunc in order to implement appropriate focus behavior.
The default `focus()` vfunc for a widget should return `TRUE` if moving in *`direction`* left the focus on a focusable location inside that widget, and `FALSE` if moving in *`direction`* moved the focus outside the widget. If returning `TRUE`, widgets normally call [`gtk_widget_grab_focus()`](gtkwidget#gtk-widget-grab-focus) to place the focus accordingly; if returning `FALSE`, they don’t modify the current focus location.
#### Parameters
| | | |
| --- | --- | --- |
| widget | a [GtkWidget](gtkwidget#GtkWidget-struct) | |
| direction | direction of focus movement | |
#### Returns
`TRUE` if focus ended up inside *`widget`*
### gtk\_widget\_get\_child\_visible ()
```
gboolean
gtk_widget_get_child_visible (*`[GtkWidget](gtkwidget#GtkWidget-struct) *widget`*);
```
Gets the value set with [`gtk_widget_set_child_visible()`](gtkwidget#gtk-widget-set-child-visible). If you feel a need to use this function, your code probably needs reorganization.
This function is only useful for container implementations and never should be called by an application.
#### Parameters
| | | |
| --- | --- | --- |
| widget | a [GtkWidget](gtkwidget#GtkWidget-struct) | |
#### Returns
`TRUE` if the widget is mapped with the parent.
### gtk\_widget\_get\_parent ()
```
[GtkWidget](gtkwidget#GtkWidget-struct) *
gtk_widget_get_parent (*`[GtkWidget](gtkwidget#GtkWidget-struct) *widget`*);
```
Returns the parent widget of *`widget`* .
#### Parameters
| | | |
| --- | --- | --- |
| widget | a [GtkWidget](gtkwidget#GtkWidget-struct) | |
#### Returns
the parent widget of *`widget`* , or `NULL`.
[transfer none][nullable]
### gtk\_widget\_get\_settings ()
```
[GtkSettings](gtksettings#GtkSettings-struct) *
gtk_widget_get_settings (*`[GtkWidget](gtkwidget#GtkWidget-struct) *widget`*);
```
Gets the settings object holding the settings used for this widget.
Note that this function can only be called when the [GtkWidget](gtkwidget#GtkWidget-struct) is attached to a toplevel, since the settings object is specific to a particular [GdkDisplay](https://developer-old.gnome.org/gtk4/html/GdkDisplay.html#GdkDisplay-struct). If you want to monitor the widget for changes in its settings, connect to notify::display.
#### Parameters
| | | |
| --- | --- | --- |
| widget | a [GtkWidget](gtkwidget#GtkWidget-struct) | |
#### Returns
the relevant [GtkSettings](gtksettings#GtkSettings-struct) object.
[transfer none]
### gtk\_widget\_get\_clipboard ()
```
[GdkClipboard](https://developer-old.gnome.org/gtk4/html/gdk4-Clipboards.html#GdkClipboard-struct) *
gtk_widget_get_clipboard (*`[GtkWidget](gtkwidget#GtkWidget-struct) *widget`*);
```
This is a utility function to get the clipboard object for the [GdkDisplay](https://developer-old.gnome.org/gtk4/html/GdkDisplay.html#GdkDisplay-struct) that *`widget`* is using.
Note that this function always works, even when *`widget`* is not realized yet.
#### Parameters
| | | |
| --- | --- | --- |
| widget | a [GtkWidget](gtkwidget#GtkWidget-struct) | |
#### Returns
the appropriate clipboard object.
[transfer none]
### gtk\_widget\_get\_primary\_clipboard ()
```
[GdkClipboard](https://developer-old.gnome.org/gtk4/html/gdk4-Clipboards.html#GdkClipboard-struct) *
gtk_widget_get_primary_clipboard (*`[GtkWidget](gtkwidget#GtkWidget-struct) *widget`*);
```
This is a utility function to get the primary clipboard object for the [GdkDisplay](https://developer-old.gnome.org/gtk4/html/GdkDisplay.html#GdkDisplay-struct) that *`widget`* is using.
Note that this function always works, even when *`widget`* is not realized yet.
#### Parameters
| | | |
| --- | --- | --- |
| widget | a [GtkWidget](gtkwidget#GtkWidget-struct) | |
#### Returns
the appropriate clipboard object.
[transfer none]
### gtk\_widget\_get\_display ()
```
[GdkDisplay](https://developer-old.gnome.org/gtk4/html/GdkDisplay.html#GdkDisplay-struct) *
gtk_widget_get_display (*`[GtkWidget](gtkwidget#GtkWidget-struct) *widget`*);
```
Get the [GdkDisplay](https://developer-old.gnome.org/gtk4/html/GdkDisplay.html#GdkDisplay-struct) for the toplevel window associated with this widget. This function can only be called after the widget has been added to a widget hierarchy with a [GtkWindow](gtkwindow#GtkWindow-struct) at the top.
In general, you should only create display specific resources when a widget has been realized, and you should free those resources when the widget is unrealized.
#### Parameters
| | | |
| --- | --- | --- |
| widget | a [GtkWidget](gtkwidget#GtkWidget-struct) | |
#### Returns
the [GdkDisplay](https://developer-old.gnome.org/gtk4/html/GdkDisplay.html#GdkDisplay-struct) for the toplevel for this widget.
[transfer none]
### gtk\_widget\_get\_size\_request ()
```
void
gtk_widget_get_size_request (*`[GtkWidget](gtkwidget#GtkWidget-struct) *widget`*,
*`int *width`*,
*`int *height`*);
```
Gets the size request that was explicitly set for the widget using [`gtk_widget_set_size_request()`](gtkwidget#gtk-widget-set-size-request). A value of -1 stored in *`width`* or *`height`* indicates that that dimension has not been set explicitly and the natural requisition of the widget will be used instead. See [`gtk_widget_set_size_request()`](gtkwidget#gtk-widget-set-size-request). To get the size a widget will actually request, call [`gtk_widget_measure()`](gtkwidget#gtk-widget-measure) instead of this function.
#### Parameters
| | | |
| --- | --- | --- |
| widget | a [GtkWidget](gtkwidget#GtkWidget-struct) | |
| width | return location for width, or `NULL`. | [out][allow-none] |
| height | return location for height, or `NULL`. | [out][allow-none] |
### gtk\_widget\_set\_child\_visible ()
```
void
gtk_widget_set_child_visible (*`[GtkWidget](gtkwidget#GtkWidget-struct) *widget`*,
*`gboolean child_visible`*);
```
Sets whether *`widget`* should be mapped along with its when its parent is mapped and *`widget`* has been shown with [`gtk_widget_show()`](gtkwidget#gtk-widget-show).
The child visibility can be set for widget before it is added to a container with [`gtk_widget_set_parent()`](gtkwidget#gtk-widget-set-parent), to avoid mapping children unnecessary before immediately unmapping them. However it will be reset to its default state of `TRUE` when the widget is removed from a container.
Note that changing the child visibility of a widget does not queue a resize on the widget. Most of the time, the size of a widget is computed from all visible children, whether or not they are mapped. If this is not the case, the container can queue a resize itself.
This function is only useful for container implementations and never should be called by an application.
#### Parameters
| | | |
| --- | --- | --- |
| widget | a [GtkWidget](gtkwidget#GtkWidget-struct) | |
| child\_visible | if `TRUE`, *`widget`* should be mapped along with its parent. | |
### gtk\_widget\_set\_size\_request ()
```
void
gtk_widget_set_size_request (*`[GtkWidget](gtkwidget#GtkWidget-struct) *widget`*,
*`int width`*,
*`int height`*);
```
Sets the minimum size of a widget; that is, the widget’s size request will be at least *`width`* by *`height`* . You can use this function to force a widget to be larger than it normally would be.
In most cases, [`gtk_window_set_default_size()`](gtkwindow#gtk-window-set-default-size) is a better choice for toplevel windows than this function; setting the default size will still allow users to shrink the window. Setting the size request will force them to leave the window at least as large as the size request. When dealing with window sizes, `gtk_window_set_geometry_hints()` can be a useful function as well.
Note the inherent danger of setting any fixed size - themes, translations into other languages, different fonts, and user action can all change the appropriate size for a given widget. So, it's basically impossible to hardcode a size that will always be correct.
The size request of a widget is the smallest size a widget can accept while still functioning well and drawing itself correctly. However in some strange cases a widget may be allocated less than its requested size, and in many cases a widget may be allocated more space than it requested.
If the size request in a given direction is -1 (unset), then the “natural” size request of the widget will be used instead.
The size request set here does not include any margin from the [GtkWidget](gtkwidget#GtkWidget-struct) properties margin-left, margin-right, margin-top, and margin-bottom, but it does include pretty much all other padding or border properties set by any subclass of [GtkWidget](gtkwidget#GtkWidget-struct).
#### Parameters
| | | |
| --- | --- | --- |
| widget | a [GtkWidget](gtkwidget#GtkWidget-struct) | |
| width | width *`widget`* should request, or -1 to unset | |
| height | height *`widget`* should request, or -1 to unset | |
### gtk\_widget\_list\_mnemonic\_labels ()
```
GList *
gtk_widget_list_mnemonic_labels (*`[GtkWidget](gtkwidget#GtkWidget-struct) *widget`*);
```
Returns a newly allocated list of the widgets, normally labels, for which this widget is the target of a mnemonic (see for example, [`gtk_label_set_mnemonic_widget()`](gtklabel#gtk-label-set-mnemonic-widget)).
The widgets in the list are not individually referenced. If you want to iterate through the list and perform actions involving callbacks that might destroy the widgets, you must call `g_list_foreach (result,
(GFunc)g_object_ref, NULL)` first, and then unref all the widgets afterwards.
#### Parameters
| | | |
| --- | --- | --- |
| widget | a [GtkWidget](gtkwidget#GtkWidget-struct) | |
#### Returns
the list of mnemonic labels; free this list with `g_list_free()` when you are done with it.
[element-type GtkWidget][transfer container]
### gtk\_widget\_add\_mnemonic\_label ()
```
void
gtk_widget_add_mnemonic_label (*`[GtkWidget](gtkwidget#GtkWidget-struct) *widget`*,
*`[GtkWidget](gtkwidget#GtkWidget-struct) *label`*);
```
Adds a widget to the list of mnemonic labels for this widget. (See [`gtk_widget_list_mnemonic_labels()`](gtkwidget#gtk-widget-list-mnemonic-labels)). Note the list of mnemonic labels for the widget is cleared when the widget is destroyed, so the caller must make sure to update its internal state at this point as well, by using a connection to the [“destroy”](gtkwidget#GtkWidget-destroy) signal or a weak notifier.
#### Parameters
| | | |
| --- | --- | --- |
| widget | a [GtkWidget](gtkwidget#GtkWidget-struct) | |
| label | a [GtkWidget](gtkwidget#GtkWidget-struct) that acts as a mnemonic label for *`widget`* | |
### gtk\_widget\_remove\_mnemonic\_label ()
```
void
gtk_widget_remove_mnemonic_label (*`[GtkWidget](gtkwidget#GtkWidget-struct) *widget`*,
*`[GtkWidget](gtkwidget#GtkWidget-struct) *label`*);
```
Removes a widget from the list of mnemonic labels for this widget. (See [`gtk_widget_list_mnemonic_labels()`](gtkwidget#gtk-widget-list-mnemonic-labels)). The widget must have previously been added to the list with [`gtk_widget_add_mnemonic_label()`](gtkwidget#gtk-widget-add-mnemonic-label).
#### Parameters
| | | |
| --- | --- | --- |
| widget | a [GtkWidget](gtkwidget#GtkWidget-struct) | |
| label | a [GtkWidget](gtkwidget#GtkWidget-struct) that was previously set as a mnemonic label for *`widget`* with [`gtk_widget_add_mnemonic_label()`](gtkwidget#gtk-widget-add-mnemonic-label). | |
### gtk\_widget\_error\_bell ()
```
void
gtk_widget_error_bell (*`[GtkWidget](gtkwidget#GtkWidget-struct) *widget`*);
```
Notifies the user about an input-related error on this widget. If the [“gtk-error-bell”](gtksettings#GtkSettings--gtk-error-bell) setting is `TRUE`, it calls [`gdk_surface_beep()`](https://developer-old.gnome.org/gtk4/html/GdkSurface.html#gdk-surface-beep), otherwise it does nothing.
Note that the effect of [`gdk_surface_beep()`](https://developer-old.gnome.org/gtk4/html/GdkSurface.html#gdk-surface-beep) can be configured in many ways, depending on the windowing backend and the desktop environment or window manager that is used.
#### Parameters
| | | |
| --- | --- | --- |
| widget | a [GtkWidget](gtkwidget#GtkWidget-struct) | |
### gtk\_widget\_keynav\_failed ()
```
gboolean
gtk_widget_keynav_failed (*`[GtkWidget](gtkwidget#GtkWidget-struct) *widget`*,
*`[GtkDirectionType](gtk4-standard-enumerations#GtkDirectionType) direction`*);
```
This function should be called whenever keyboard navigation within a single widget hits a boundary. The function emits the [“keynav-failed”](gtkwidget#GtkWidget-keynav-failed) signal on the widget and its return value should be interpreted in a way similar to the return value of [`gtk_widget_child_focus()`](gtkwidget#gtk-widget-child-focus):
When `TRUE` is returned, stay in the widget, the failed keyboard navigation is OK and/or there is nowhere we can/should move the focus to.
When `FALSE` is returned, the caller should continue with keyboard navigation outside the widget, e.g. by calling [`gtk_widget_child_focus()`](gtkwidget#gtk-widget-child-focus) on the widget’s toplevel.
The default ::keynav-failed handler returns `FALSE` for [`GTK_DIR_TAB_FORWARD`](gtk4-standard-enumerations#GTK-DIR-TAB-FORWARD:CAPS) and [`GTK_DIR_TAB_BACKWARD`](gtk4-standard-enumerations#GTK-DIR-TAB-BACKWARD:CAPS). For the other values of [GtkDirectionType](gtk4-standard-enumerations#GtkDirectionType) it returns `TRUE`.
Whenever the default handler returns `TRUE`, it also calls [`gtk_widget_error_bell()`](gtkwidget#gtk-widget-error-bell) to notify the user of the failed keyboard navigation.
A use case for providing an own implementation of ::keynav-failed (either by connecting to it or by overriding it) would be a row of [GtkEntry](gtkentry#GtkEntry-struct) widgets where the user should be able to navigate the entire row with the cursor keys, as e.g. known from user interfaces that require entering license keys.
#### Parameters
| | | |
| --- | --- | --- |
| widget | a [GtkWidget](gtkwidget#GtkWidget-struct) | |
| direction | direction of focus movement | |
#### Returns
`TRUE` if stopping keyboard navigation is fine, `FALSE` if the emitting widget should try to handle the keyboard navigation attempt in its parent container(s).
### gtk\_widget\_get\_tooltip\_markup ()
```
const char *
gtk_widget_get_tooltip_markup (*`[GtkWidget](gtkwidget#GtkWidget-struct) *widget`*);
```
Gets the contents of the tooltip for *`widget`* set using [`gtk_widget_set_tooltip_markup()`](gtkwidget#gtk-widget-set-tooltip-markup).
#### Parameters
| | | |
| --- | --- | --- |
| widget | a [GtkWidget](gtkwidget#GtkWidget-struct) | |
#### Returns
the tooltip text.
[nullable]
### gtk\_widget\_set\_tooltip\_markup ()
```
void
gtk_widget_set_tooltip_markup (*`[GtkWidget](gtkwidget#GtkWidget-struct) *widget`*,
*`const char *markup`*);
```
Sets *`markup`* as the contents of the tooltip, which is marked up with the Pango text markup language.
This function will take care of setting the [“has-tooltip”](gtkwidget#GtkWidget--has-tooltip) as a side effect, and of the default handler for the [“query-tooltip”](gtkwidget#GtkWidget-query-tooltip) signal.
See also the [“tooltip-markup”](gtkwidget#GtkWidget--tooltip-markup) property and [`gtk_tooltip_set_markup()`](gtktooltip#gtk-tooltip-set-markup).
#### Parameters
| | | |
| --- | --- | --- |
| widget | a [GtkWidget](gtkwidget#GtkWidget-struct) | |
| markup | the contents of the tooltip for *`widget`* . | [nullable] |
### gtk\_widget\_get\_tooltip\_text ()
```
const char *
gtk_widget_get_tooltip_text (*`[GtkWidget](gtkwidget#GtkWidget-struct) *widget`*);
```
Gets the contents of the tooltip for *`widget`* .
If the *`widget`* 's tooltip was set using [`gtk_widget_set_tooltip_markup()`](gtkwidget#gtk-widget-set-tooltip-markup), this function will return the escaped text.
#### Parameters
| | | |
| --- | --- | --- |
| widget | a [GtkWidget](gtkwidget#GtkWidget-struct) | |
#### Returns
the tooltip text.
[nullable]
### gtk\_widget\_set\_tooltip\_text ()
```
void
gtk_widget_set_tooltip_text (*`[GtkWidget](gtkwidget#GtkWidget-struct) *widget`*,
*`const char *text`*);
```
Sets *`text`* as the contents of the tooltip.
If *`text`* contains any markup, it will be escaped.
This function will take care of setting [“has-tooltip”](gtkwidget#GtkWidget--has-tooltip) as a side effect, and of the default handler for the [“query-tooltip”](gtkwidget#GtkWidget-query-tooltip) signal.
See also the [“tooltip-text”](gtkwidget#GtkWidget--tooltip-text) property and [`gtk_tooltip_set_text()`](gtktooltip#gtk-tooltip-set-text).
#### Parameters
| | | |
| --- | --- | --- |
| widget | a [GtkWidget](gtkwidget#GtkWidget-struct) | |
| text | the contents of the tooltip for *`widget`* . | [nullable] |
### gtk\_widget\_get\_has\_tooltip ()
```
gboolean
gtk_widget_get_has_tooltip (*`[GtkWidget](gtkwidget#GtkWidget-struct) *widget`*);
```
Returns the current value of the has-tooltip property. See [“has-tooltip”](gtkwidget#GtkWidget--has-tooltip) for more information.
#### Parameters
| | | |
| --- | --- | --- |
| widget | a [GtkWidget](gtkwidget#GtkWidget-struct) | |
#### Returns
current value of has-tooltip on *`widget`* .
### gtk\_widget\_set\_has\_tooltip ()
```
void
gtk_widget_set_has_tooltip (*`[GtkWidget](gtkwidget#GtkWidget-struct) *widget`*,
*`gboolean has_tooltip`*);
```
Sets the has-tooltip property on *`widget`* to *`has_tooltip`* . See [“has-tooltip”](gtkwidget#GtkWidget--has-tooltip) for more information.
#### Parameters
| | | |
| --- | --- | --- |
| widget | a [GtkWidget](gtkwidget#GtkWidget-struct) | |
| has\_tooltip | whether or not *`widget`* has a tooltip. | |
### gtk\_widget\_trigger\_tooltip\_query ()
```
void
gtk_widget_trigger_tooltip_query (*`[GtkWidget](gtkwidget#GtkWidget-struct) *widget`*);
```
Triggers a tooltip query on the display where the toplevel of *`widget`* is located.
#### Parameters
| | | |
| --- | --- | --- |
| widget | a [GtkWidget](gtkwidget#GtkWidget-struct) | |
### gtk\_widget\_get\_allocated\_width ()
```
int
gtk_widget_get_allocated_width (*`[GtkWidget](gtkwidget#GtkWidget-struct) *widget`*);
```
Returns the width that has currently been allocated to *`widget`* .
#### Parameters
| | | |
| --- | --- | --- |
| widget | the widget to query | |
#### Returns
the width of the *`widget`*
### gtk\_widget\_get\_allocated\_height ()
```
int
gtk_widget_get_allocated_height (*`[GtkWidget](gtkwidget#GtkWidget-struct) *widget`*);
```
Returns the height that has currently been allocated to *`widget`* .
#### Parameters
| | | |
| --- | --- | --- |
| widget | the widget to query | |
#### Returns
the height of the *`widget`*
### gtk\_widget\_get\_allocation ()
```
void
gtk_widget_get_allocation (*`[GtkWidget](gtkwidget#GtkWidget-struct) *widget`*,
*`[GtkAllocation](gtkwidget#GtkAllocation) *allocation`*);
```
Retrieves the widget’s allocation.
Note, when implementing a layout container: a widget’s allocation will be its “adjusted” allocation, that is, the widget’s parent typically calls [`gtk_widget_size_allocate()`](gtkwidget#gtk-widget-size-allocate) with an allocation, and that allocation is then adjusted (to handle margin and alignment for example) before assignment to the widget. [`gtk_widget_get_allocation()`](gtkwidget#gtk-widget-get-allocation) returns the adjusted allocation that was actually assigned to the widget. The adjusted allocation is guaranteed to be completely contained within the [`gtk_widget_size_allocate()`](gtkwidget#gtk-widget-size-allocate) allocation, however.
So a layout container is guaranteed that its children stay inside the assigned bounds, but not that they have exactly the bounds the container assigned.
#### Parameters
| | | |
| --- | --- | --- |
| widget | a [GtkWidget](gtkwidget#GtkWidget-struct) | |
| allocation | a pointer to a [GtkAllocation](gtkwidget#GtkAllocation) to copy to. | [out] |
### gtk\_widget\_get\_allocated\_baseline ()
```
int
gtk_widget_get_allocated_baseline (*`[GtkWidget](gtkwidget#GtkWidget-struct) *widget`*);
```
Returns the baseline that has currently been allocated to *`widget`* . This function is intended to be used when implementing handlers for the [`GtkWidgetClass.snapshot()`](gtkwidget#GtkWidgetClass.snapshot) function, and when allocating child widgets in [`GtkWidgetClass.size_allocate()`](gtkwidget#GtkWidgetClass.size-allocate).
#### Parameters
| | | |
| --- | --- | --- |
| widget | the widget to query | |
#### Returns
the baseline of the *`widget`* , or -1 if none
### gtk\_widget\_get\_width ()
```
int
gtk_widget_get_width (*`[GtkWidget](gtkwidget#GtkWidget-struct) *widget`*);
```
Returns the content width of the widget, as passed to its size-allocate implementation. This is the size you should be using in GtkWidgetClass.snapshot(). For pointer events, see [`gtk_widget_contains()`](gtkwidget#gtk-widget-contains).
#### Parameters
| | | |
| --- | --- | --- |
| widget | a [GtkWidget](gtkwidget#GtkWidget-struct) | |
#### Returns
The width of *`widget`*
### gtk\_widget\_get\_height ()
```
int
gtk_widget_get_height (*`[GtkWidget](gtkwidget#GtkWidget-struct) *widget`*);
```
Returns the content height of the widget, as passed to its size-allocate implementation. This is the size you should be using in GtkWidgetClass.snapshot(). For pointer events, see [`gtk_widget_contains()`](gtkwidget#gtk-widget-contains).
#### Parameters
| | | |
| --- | --- | --- |
| widget | a [GtkWidget](gtkwidget#GtkWidget-struct) | |
#### Returns
The height of *`widget`*
### gtk\_widget\_get\_size ()
```
int
gtk_widget_get_size (*`[GtkWidget](gtkwidget#GtkWidget-struct) *widget`*,
*`[GtkOrientation](gtk4-standard-enumerations#GtkOrientation) orientation`*);
```
Returns the content width or height of the widget, depending on *`orientation`* . This is equivalent to calling [`gtk_widget_get_width()`](gtkwidget#gtk-widget-get-width) for [`GTK_ORIENTATION_HORIZONTAL`](gtk4-standard-enumerations#GTK-ORIENTATION-HORIZONTAL:CAPS) or [`gtk_widget_get_height()`](gtkwidget#gtk-widget-get-height) for [`GTK_ORIENTATION_VERTICAL`](gtk4-standard-enumerations#GTK-ORIENTATION-VERTICAL:CAPS), but can be used when writing orientation-independent code, such as when implementing [GtkOrientable](gtk4-orientable#GtkOrientable-struct) widgets.
#### Parameters
| | | |
| --- | --- | --- |
| widget | a [GtkWidget](gtkwidget#GtkWidget-struct) | |
| orientation | the orientation to query | |
#### Returns
The size of *`widget`* in *`orientation`* .
### gtk\_widget\_compute\_bounds ()
```
gboolean
gtk_widget_compute_bounds (*`[GtkWidget](gtkwidget#GtkWidget-struct) *widget`*,
*`[GtkWidget](gtkwidget#GtkWidget-struct) *target`*,
*`[graphene\_rect\_t](https://developer-old.gnome.org/usr/share/gtk-doc/html/graphene/graphene-Rectangle.html#graphene-rect-t) *out_bounds`*);
```
Computes the bounds for *`widget`* in the coordinate space of *`target`* . FIXME: Explain what "bounds" are.
If the operation is successful, `TRUE` is returned. If *`widget`* has no bounds or the bounds cannot be expressed in *`target`* 's coordinate space (for example if both widgets are in different windows), `FALSE` is returned and *`bounds`* is set to the zero rectangle.
It is valid for *`widget`* and *`target`* to be the same widget.
#### Parameters
| | | |
| --- | --- | --- |
| widget | the [GtkWidget](gtkwidget#GtkWidget-struct) to query | |
| target | the [GtkWidget](gtkwidget#GtkWidget-struct) | |
| out\_bounds | the rectangle taking the bounds. | [out caller-allocates] |
#### Returns
`TRUE` if the bounds could be computed
### gtk\_widget\_compute\_transform ()
```
gboolean
gtk_widget_compute_transform (*`[GtkWidget](gtkwidget#GtkWidget-struct) *widget`*,
*`[GtkWidget](gtkwidget#GtkWidget-struct) *target`*,
*`[graphene\_matrix\_t](https://developer-old.gnome.org/usr/share/gtk-doc/html/graphene/graphene-Matrix.html#graphene-matrix-t) *out_transform`*);
```
Computes a matrix suitable to describe a transformation from *`widget`* 's coordinate system into *`target`* 's coordinate system.
#### Parameters
| | | |
| --- | --- | --- |
| widget | a [GtkWidget](gtkwidget#GtkWidget-struct) | |
| target | the target widget that the matrix will transform to | |
| out\_transform | location to store the final transformation. | [out caller-allocates] |
#### Returns
`TRUE` if the transform could be computed, `FALSE` otherwise. The transform can not be computed in certain cases, for example when *`widget`* and *`target`* do not share a common ancestor. In that case *`out_transform`* gets set to the identity matrix.
### gtk\_widget\_compute\_point ()
```
gboolean
gtk_widget_compute_point (*`[GtkWidget](gtkwidget#GtkWidget-struct) *widget`*,
*`[GtkWidget](gtkwidget#GtkWidget-struct) *target`*,
*`const [graphene\_point\_t](https://developer-old.gnome.org/usr/share/gtk-doc/html/graphene/graphene-Point.html#graphene-point-t) *point`*,
*`[graphene\_point\_t](https://developer-old.gnome.org/usr/share/gtk-doc/html/graphene/graphene-Point.html#graphene-point-t) *out_point`*);
```
Translates the given *`point`* in *`widget`* 's coordinates to coordinates relative to *`target`* ’s coordinate system. In order to perform this operation, both widgets must share a common root.
#### Parameters
| | | |
| --- | --- | --- |
| widget | the [GtkWidget](gtkwidget#GtkWidget-struct) to query | |
| target | the [GtkWidget](gtkwidget#GtkWidget-struct) to transform into | |
| point | a point in *`widget`* 's coordinate system | |
| out\_point | Set to the corresponding coordinates in *`target`* 's coordinate system. | [out caller-allocates] |
#### Returns
`TRUE` if the point could be determined, `FALSE` on failure. In this case, 0 is stored in *`out_point`* .
### gtk\_widget\_contains ()
```
gboolean
gtk_widget_contains (*`[GtkWidget](gtkwidget#GtkWidget-struct) *widget`*,
*`double x`*,
*`double y`*);
```
Tests if the point at (*`x`* , *`y`* ) is contained in *`widget`* .
The coordinates for (*`x`* , *`y`* ) must be in widget coordinates, so (0, 0) is assumed to be the top left of *`widget`* 's content area.
#### Parameters
| | | |
| --- | --- | --- |
| widget | the widget to query | |
| x | X coordinate to test, relative to *`widget`* 's origin | |
| y | Y coordinate to test, relative to *`widget`* 's origin | |
#### Returns
`TRUE` if *`widget`* contains (*`x`* , *`y`* ).
### gtk\_widget\_pick ()
```
[GtkWidget](gtkwidget#GtkWidget-struct) *
gtk_widget_pick (*`[GtkWidget](gtkwidget#GtkWidget-struct) *widget`*,
*`double x`*,
*`double y`*,
*`[GtkPickFlags](gtkwidget#GtkPickFlags) flags`*);
```
Finds the descendant of *`widget`* (including *`widget`* itself) closest to the screen at the point (*`x`* , *`y`* ). The point must be given in widget coordinates, so (0, 0) is assumed to be the top left of *`widget`* 's content area.
Usually widgets will return `NULL` if the given coordinate is not contained in *`widget`* checked via [`gtk_widget_contains()`](gtkwidget#gtk-widget-contains). Otherwise they will recursively try to find a child that does not return `NULL`. Widgets are however free to customize their picking algorithm.
This function is used on the toplevel to determine the widget below the mouse cursor for purposes of hover highlighting and delivering events.
#### Parameters
| | | |
| --- | --- | --- |
| widget | the widget to query | |
| x | X coordinate to test, relative to *`widget`* 's origin | |
| y | Y coordinate to test, relative to *`widget`* 's origin | |
| flags | Flags to influence what is picked | |
#### Returns
The widget descendant at the given coordinate or `NULL` if none.
[nullable][transfer none]
### gtk\_widget\_get\_can\_focus ()
```
gboolean
gtk_widget_get_can_focus (*`[GtkWidget](gtkwidget#GtkWidget-struct) *widget`*);
```
Determines whether the input focus can enter *`widget`* or any of its children.
See [`gtk_widget_set_focusable()`](gtkwidget#gtk-widget-set-focusable).
#### Parameters
| | | |
| --- | --- | --- |
| widget | a [GtkWidget](gtkwidget#GtkWidget-struct) | |
#### Returns
`TRUE` if the input focus can enter *`widget`* , `FALSE` otherwise
### gtk\_widget\_set\_can\_focus ()
```
void
gtk_widget_set_can_focus (*`[GtkWidget](gtkwidget#GtkWidget-struct) *widget`*,
*`gboolean can_focus`*);
```
Specifies whether the input focus can enter the widget or any of its children.
Applications should set *`can_focus`* to `FALSE` to mark a widget as for pointer/touch use only.
Note that having *`can_focus`* be `TRUE` is only one of the necessary conditions for being focusable. A widget must also be sensitive and focusable and not have an ancestor that is marked as not can-focus in order to receive input focus.
See [`gtk_widget_grab_focus()`](gtkwidget#gtk-widget-grab-focus) for actually setting the input focus on a widget.
#### Parameters
| | | |
| --- | --- | --- |
| widget | a [GtkWidget](gtkwidget#GtkWidget-struct) | |
| can\_focus | whether or not the input focus can enter the widget or any of its children | |
### gtk\_widget\_get\_focusable ()
```
gboolean
gtk_widget_get_focusable (*`[GtkWidget](gtkwidget#GtkWidget-struct) *widget`*);
```
Determines whether *`widget`* can own the input focus. See [`gtk_widget_set_focusable()`](gtkwidget#gtk-widget-set-focusable).
#### Parameters
| | | |
| --- | --- | --- |
| widget | a [GtkWidget](gtkwidget#GtkWidget-struct) | |
#### Returns
`TRUE` if *`widget`* can own the input focus, `FALSE` otherwise
### gtk\_widget\_set\_focusable ()
```
void
gtk_widget_set_focusable (*`[GtkWidget](gtkwidget#GtkWidget-struct) *widget`*,
*`gboolean focusable`*);
```
Specifies whether *`widget`* can own the input focus.
Widget implementations should set *`focusable`* to `TRUE` in their `init()` function if they want to receive keyboard input.
Note that having *`focusable`* be `TRUE` is only one of the necessary conditions for being focusable. A widget must also be sensitive and can-focus and not have an ancestor that is marked as not can-focus in order to receive input focus.
See [`gtk_widget_grab_focus()`](gtkwidget#gtk-widget-grab-focus) for actually setting the input focus on a widget.
#### Parameters
| | | |
| --- | --- | --- |
| widget | a [GtkWidget](gtkwidget#GtkWidget-struct) | |
| focusable | whether or not *`widget`* can own the input focus | |
### gtk\_widget\_get\_focus\_on\_click ()
```
gboolean
gtk_widget_get_focus_on_click (*`[GtkWidget](gtkwidget#GtkWidget-struct) *widget`*);
```
Returns whether the widget should grab focus when it is clicked with the mouse. See [`gtk_widget_set_focus_on_click()`](gtkwidget#gtk-widget-set-focus-on-click).
#### Parameters
| | | |
| --- | --- | --- |
| widget | a [GtkWidget](gtkwidget#GtkWidget-struct) | |
#### Returns
`TRUE` if the widget should grab focus when it is clicked with the mouse.
### gtk\_widget\_set\_focus\_on\_click ()
```
void
gtk_widget_set_focus_on_click (*`[GtkWidget](gtkwidget#GtkWidget-struct) *widget`*,
*`gboolean focus_on_click`*);
```
Sets whether the widget should grab focus when it is clicked with the mouse. Making mouse clicks not grab focus is useful in places like toolbars where you don’t want the keyboard focus removed from the main area of the application.
#### Parameters
| | | |
| --- | --- | --- |
| widget | a [GtkWidget](gtkwidget#GtkWidget-struct) | |
| focus\_on\_click | whether the widget should grab focus when clicked with the mouse | |
### gtk\_widget\_get\_focus\_child ()
```
[GtkWidget](gtkwidget#GtkWidget-struct) *
gtk_widget_get_focus_child (*`[GtkWidget](gtkwidget#GtkWidget-struct) *widget`*);
```
Returns the current focus child of *`widget`* .
#### Parameters
| | | |
| --- | --- | --- |
| widget | a [GtkWidget](gtkwidget#GtkWidget-struct) | |
#### Returns
The current focus child of *`widget`* , or `NULL` in case the focus child is unset.
[nullable][transfer none]
### gtk\_widget\_set\_focus\_child ()
```
void
gtk_widget_set_focus_child (*`[GtkWidget](gtkwidget#GtkWidget-struct) *widget`*,
*`[GtkWidget](gtkwidget#GtkWidget-struct) *child`*);
```
Set *`child`* as the current focus child of *`widget`* . The previous focus child will be unset.
This function is only suitable for widget implementations. If you want a certain widget to get the input focus, call [`gtk_widget_grab_focus()`](gtkwidget#gtk-widget-grab-focus) on it.
#### Parameters
| | | |
| --- | --- | --- |
| widget | a [GtkWidget](gtkwidget#GtkWidget-struct) | |
| child | a direct child widget of *`widget`* or `NULL` to unset the focus child of *`widget`* . | [nullable] |
### gtk\_widget\_get\_can\_target ()
```
gboolean
gtk_widget_get_can_target (*`[GtkWidget](gtkwidget#GtkWidget-struct) *widget`*);
```
Queries whether *`widget`* can be the target of pointer events.
#### Parameters
| | | |
| --- | --- | --- |
| widget | a [GtkWidget](gtkwidget#GtkWidget-struct) | |
#### Returns
`TRUE` if *`widget`* can receive pointer events
### gtk\_widget\_set\_can\_target ()
```
void
gtk_widget_set_can_target (*`[GtkWidget](gtkwidget#GtkWidget-struct) *widget`*,
*`gboolean can_target`*);
```
Sets whether *`widget`* can be the target of pointer events.
#### Parameters
| | | |
| --- | --- | --- |
| widget | a [GtkWidget](gtkwidget#GtkWidget-struct) | |
| can\_target | whether this widget should be able to receive pointer events | |
### gtk\_widget\_get\_sensitive ()
```
gboolean
gtk_widget_get_sensitive (*`[GtkWidget](gtkwidget#GtkWidget-struct) *widget`*);
```
Returns the widget’s sensitivity (in the sense of returning the value that has been set using [`gtk_widget_set_sensitive()`](gtkwidget#gtk-widget-set-sensitive)).
The effective sensitivity of a widget is however determined by both its own and its parent widget’s sensitivity. See [`gtk_widget_is_sensitive()`](gtkwidget#gtk-widget-is-sensitive).
#### Parameters
| | | |
| --- | --- | --- |
| widget | a [GtkWidget](gtkwidget#GtkWidget-struct) | |
#### Returns
`TRUE` if the widget is sensitive
### gtk\_widget\_is\_sensitive ()
```
gboolean
gtk_widget_is_sensitive (*`[GtkWidget](gtkwidget#GtkWidget-struct) *widget`*);
```
Returns the widget’s effective sensitivity, which means it is sensitive itself and also its parent widget is sensitive
#### Parameters
| | | |
| --- | --- | --- |
| widget | a [GtkWidget](gtkwidget#GtkWidget-struct) | |
#### Returns
`TRUE` if the widget is effectively sensitive
### gtk\_widget\_get\_visible ()
```
gboolean
gtk_widget_get_visible (*`[GtkWidget](gtkwidget#GtkWidget-struct) *widget`*);
```
Determines whether the widget is visible. If you want to take into account whether the widget’s parent is also marked as visible, use [`gtk_widget_is_visible()`](gtkwidget#gtk-widget-is-visible) instead.
This function does not check if the widget is obscured in any way.
See [`gtk_widget_set_visible()`](gtkwidget#gtk-widget-set-visible).
#### Parameters
| | | |
| --- | --- | --- |
| widget | a [GtkWidget](gtkwidget#GtkWidget-struct) | |
#### Returns
`TRUE` if the widget is visible
### gtk\_widget\_is\_visible ()
```
gboolean
gtk_widget_is_visible (*`[GtkWidget](gtkwidget#GtkWidget-struct) *widget`*);
```
Determines whether the widget and all its parents are marked as visible.
This function does not check if the widget is obscured in any way.
See also [`gtk_widget_get_visible()`](gtkwidget#gtk-widget-get-visible) and [`gtk_widget_set_visible()`](gtkwidget#gtk-widget-set-visible)
#### Parameters
| | | |
| --- | --- | --- |
| widget | a [GtkWidget](gtkwidget#GtkWidget-struct) | |
#### Returns
`TRUE` if the widget and all its parents are visible
### gtk\_widget\_set\_visible ()
```
void
gtk_widget_set_visible (*`[GtkWidget](gtkwidget#GtkWidget-struct) *widget`*,
*`gboolean visible`*);
```
Sets the visibility state of *`widget`* . Note that setting this to `TRUE` doesn’t mean the widget is actually viewable, see [`gtk_widget_get_visible()`](gtkwidget#gtk-widget-get-visible).
This function simply calls [`gtk_widget_show()`](gtkwidget#gtk-widget-show) or [`gtk_widget_hide()`](gtkwidget#gtk-widget-hide) but is nicer to use when the visibility of the widget depends on some condition.
#### Parameters
| | | |
| --- | --- | --- |
| widget | a [GtkWidget](gtkwidget#GtkWidget-struct) | |
| visible | whether the widget should be shown or not | |
### gtk\_widget\_set\_state\_flags ()
```
void
gtk_widget_set_state_flags (*`[GtkWidget](gtkwidget#GtkWidget-struct) *widget`*,
*`[GtkStateFlags](gtk4-standard-enumerations#GtkStateFlags) flags`*,
*`gboolean clear`*);
```
This function is for use in widget implementations. Turns on flag values in the current widget state (insensitive, prelighted, etc.).
This function accepts the values [`GTK_STATE_FLAG_DIR_LTR`](gtk4-standard-enumerations#GTK-STATE-FLAG-DIR-LTR:CAPS) and [`GTK_STATE_FLAG_DIR_RTL`](gtk4-standard-enumerations#GTK-STATE-FLAG-DIR-RTL:CAPS) but ignores them. If you want to set the widget's direction, use [`gtk_widget_set_direction()`](gtkwidget#gtk-widget-set-direction).
#### Parameters
| | | |
| --- | --- | --- |
| widget | a [GtkWidget](gtkwidget#GtkWidget-struct) | |
| flags | State flags to turn on | |
| clear | Whether to clear state before turning on *`flags`* | |
### gtk\_widget\_unset\_state\_flags ()
```
void
gtk_widget_unset_state_flags (*`[GtkWidget](gtkwidget#GtkWidget-struct) *widget`*,
*`[GtkStateFlags](gtk4-standard-enumerations#GtkStateFlags) flags`*);
```
This function is for use in widget implementations. Turns off flag values for the current widget state (insensitive, prelighted, etc.). See [`gtk_widget_set_state_flags()`](gtkwidget#gtk-widget-set-state-flags).
#### Parameters
| | | |
| --- | --- | --- |
| widget | a [GtkWidget](gtkwidget#GtkWidget-struct) | |
| flags | State flags to turn off | |
### gtk\_widget\_get\_state\_flags ()
```
[GtkStateFlags](gtk4-standard-enumerations#GtkStateFlags)
gtk_widget_get_state_flags (*`[GtkWidget](gtkwidget#GtkWidget-struct) *widget`*);
```
Returns the widget state as a flag set. It is worth mentioning that the effective [`GTK_STATE_FLAG_INSENSITIVE`](gtk4-standard-enumerations#GTK-STATE-FLAG-INSENSITIVE:CAPS) state will be returned, that is, also based on parent insensitivity, even if *`widget`* itself is sensitive.
Also note that if you are looking for a way to obtain the [GtkStateFlags](gtk4-standard-enumerations#GtkStateFlags) to pass to a [GtkStyleContext](gtkstylecontext#GtkStyleContext-struct) method, you should look at [`gtk_style_context_get_state()`](gtkstylecontext#gtk-style-context-get-state).
#### Parameters
| | | |
| --- | --- | --- |
| widget | a [GtkWidget](gtkwidget#GtkWidget-struct) | |
#### Returns
The state flags for widget
### gtk\_widget\_has\_default ()
```
gboolean
gtk_widget_has_default (*`[GtkWidget](gtkwidget#GtkWidget-struct) *widget`*);
```
Determines whether *`widget`* is the current default widget within its toplevel.
#### Parameters
| | | |
| --- | --- | --- |
| widget | a [GtkWidget](gtkwidget#GtkWidget-struct) | |
#### Returns
`TRUE` if *`widget`* is the current default widget within its toplevel, `FALSE` otherwise
### gtk\_widget\_has\_focus ()
```
gboolean
gtk_widget_has_focus (*`[GtkWidget](gtkwidget#GtkWidget-struct) *widget`*);
```
Determines if the widget has the global input focus. See [`gtk_widget_is_focus()`](gtkwidget#gtk-widget-is-focus) for the difference between having the global input focus, and only having the focus within a toplevel.
#### Parameters
| | | |
| --- | --- | --- |
| widget | a [GtkWidget](gtkwidget#GtkWidget-struct) | |
#### Returns
`TRUE` if the widget has the global input focus.
### gtk\_widget\_has\_visible\_focus ()
```
gboolean
gtk_widget_has_visible_focus (*`[GtkWidget](gtkwidget#GtkWidget-struct) *widget`*);
```
Determines if the widget should show a visible indication that it has the global input focus. This is a convenience function that takes into account whether focus indication should currently be shown in the toplevel window of *`widget`* . See [`gtk_window_get_focus_visible()`](gtkwindow#gtk-window-get-focus-visible) for more information about focus indication.
To find out if the widget has the global input focus, use [`gtk_widget_has_focus()`](gtkwidget#gtk-widget-has-focus).
#### Parameters
| | | |
| --- | --- | --- |
| widget | a [GtkWidget](gtkwidget#GtkWidget-struct) | |
#### Returns
`TRUE` if the widget should display a “focus rectangle”
### gtk\_widget\_is\_drawable ()
```
gboolean
gtk_widget_is_drawable (*`[GtkWidget](gtkwidget#GtkWidget-struct) *widget`*);
```
Determines whether *`widget`* can be drawn to. A widget can be drawn if it is mapped and visible.
#### Parameters
| | | |
| --- | --- | --- |
| widget | a [GtkWidget](gtkwidget#GtkWidget-struct) | |
#### Returns
`TRUE` if *`widget`* is drawable, `FALSE` otherwise
### gtk\_widget\_set\_receives\_default ()
```
void
gtk_widget_set_receives_default (*`[GtkWidget](gtkwidget#GtkWidget-struct) *widget`*,
*`gboolean receives_default`*);
```
Specifies whether *`widget`* will be treated as the default widget within its toplevel when it has the focus, even if another widget is the default.
#### Parameters
| | | |
| --- | --- | --- |
| widget | a [GtkWidget](gtkwidget#GtkWidget-struct) | |
| receives\_default | whether or not *`widget`* can be a default widget. | |
### gtk\_widget\_get\_receives\_default ()
```
gboolean
gtk_widget_get_receives_default (*`[GtkWidget](gtkwidget#GtkWidget-struct) *widget`*);
```
Determines whether *`widget`* is always treated as the default widget within its toplevel when it has the focus, even if another widget is the default.
See [`gtk_widget_set_receives_default()`](gtkwidget#gtk-widget-set-receives-default).
#### Parameters
| | | |
| --- | --- | --- |
| widget | a [GtkWidget](gtkwidget#GtkWidget-struct) | |
#### Returns
`TRUE` if *`widget`* acts as the default widget when focused, `FALSE` otherwise
### gtk\_widget\_get\_realized ()
```
gboolean
gtk_widget_get_realized (*`[GtkWidget](gtkwidget#GtkWidget-struct) *widget`*);
```
Determines whether *`widget`* is realized.
#### Parameters
| | | |
| --- | --- | --- |
| widget | a [GtkWidget](gtkwidget#GtkWidget-struct) | |
#### Returns
`TRUE` if *`widget`* is realized, `FALSE` otherwise
### gtk\_widget\_get\_mapped ()
```
gboolean
gtk_widget_get_mapped (*`[GtkWidget](gtkwidget#GtkWidget-struct) *widget`*);
```
Whether the widget is mapped.
#### Parameters
| | | |
| --- | --- | --- |
| widget | a [GtkWidget](gtkwidget#GtkWidget-struct) | |
#### Returns
`TRUE` if the widget is mapped, `FALSE` otherwise.
### gtk\_widget\_get\_opacity ()
```
double
gtk_widget_get_opacity (*`[GtkWidget](gtkwidget#GtkWidget-struct) *widget`*);
```
Fetches the requested opacity for this widget. See [`gtk_widget_set_opacity()`](gtkwidget#gtk-widget-set-opacity).
#### Parameters
| | | |
| --- | --- | --- |
| widget | a [GtkWidget](gtkwidget#GtkWidget-struct) | |
#### Returns
the requested opacity for this widget.
### gtk\_widget\_set\_opacity ()
```
void
gtk_widget_set_opacity (*`[GtkWidget](gtkwidget#GtkWidget-struct) *widget`*,
*`double opacity`*);
```
Request the *`widget`* to be rendered partially transparent, with opacity 0 being fully transparent and 1 fully opaque. (Opacity values are clamped to the [0,1] range).
Opacity works on both toplevel widgets and child widgets, although there are some limitations: For toplevel widgets, applying opacity depends on the capabilities of the windowing system. On X11, this has any effect only on X displays with a compositing manager, see [`gdk_display_is_composited()`](https://developer-old.gnome.org/gtk4/html/GdkDisplay.html#gdk-display-is-composited). On Windows and Wayland it should always work, although setting a window’s opacity after the window has been shown may cause some flicker.
Note that the opacity is inherited through inclusion — if you set a toplevel to be partially translucent, all of its content will appear translucent, since it is ultimatively rendered on that toplevel. The opacity value itself is not inherited by child widgets (since that would make widgets deeper in the hierarchy progressively more translucent). As a consequence, [GtkPopovers](gtkpopover#GtkPopover-struct) and other [GtkNative](gtknative#GtkNative-struct) widgets with their own surface will use their own opacity value, and thus by default appear non-translucent, even if they are attached to a toplevel that is translucent.
#### Parameters
| | | |
| --- | --- | --- |
| widget | a [GtkWidget](gtkwidget#GtkWidget-struct) | |
| opacity | desired opacity, between 0 and 1 | |
### gtk\_widget\_get\_overflow ()
```
[GtkOverflow](gtkwidget#GtkOverflow)
gtk_widget_get_overflow (*`[GtkWidget](gtkwidget#GtkWidget-struct) *widget`*);
```
Returns the value set via [`gtk_widget_set_overflow()`](gtkwidget#gtk-widget-set-overflow).
#### Parameters
| | | |
| --- | --- | --- |
| widget | a [GtkWidget](gtkwidget#GtkWidget-struct) | |
#### Returns
The widget's overflow.
### gtk\_widget\_set\_overflow ()
```
void
gtk_widget_set_overflow (*`[GtkWidget](gtkwidget#GtkWidget-struct) *widget`*,
*`[GtkOverflow](gtkwidget#GtkOverflow) overflow`*);
```
Sets how *`widget`* treats content that is drawn outside the widget's content area. See the definition of [GtkOverflow](gtkwidget#GtkOverflow) for details.
This setting is provided for widget implementations and should not be used by application code.
The default value is [`GTK_OVERFLOW_VISIBLE`](gtkwidget#GTK-OVERFLOW-VISIBLE:CAPS).
#### Parameters
| | | |
| --- | --- | --- |
| widget | a [GtkWidget](gtkwidget#GtkWidget-struct) | |
| overflow | desired overflow | |
### gtk\_widget\_measure ()
```
void
gtk_widget_measure (*`[GtkWidget](gtkwidget#GtkWidget-struct) *widget`*,
*`[GtkOrientation](gtk4-standard-enumerations#GtkOrientation) orientation`*,
*`int for_size`*,
*`int *minimum`*,
*`int *natural`*,
*`int *minimum_baseline`*,
*`int *natural_baseline`*);
```
Measures *`widget`* in the orientation *`orientation`* and for the given *`for_size`* . As an example, if *`orientation`* is [`GTK_ORIENTATION_HORIZONTAL`](gtk4-standard-enumerations#GTK-ORIENTATION-HORIZONTAL:CAPS) and *`for_size`* is 300, this functions will compute the minimum and natural width of *`widget`* if it is allocated at a height of 300 pixels.
See GtkWidget’s geometry management section for a more details on implementing [`GtkWidgetClass.measure()`](gtkwidget#GtkWidgetClass.measure).
#### Parameters
| | | |
| --- | --- | --- |
| widget | A [GtkWidget](gtkwidget#GtkWidget-struct) instance | |
| orientation | the orientation to measure | |
| for\_size | Size for the opposite of *`orientation`* , i.e. if *`orientation`* is [`GTK_ORIENTATION_HORIZONTAL`](gtk4-standard-enumerations#GTK-ORIENTATION-HORIZONTAL:CAPS), this is the height the widget should be measured with. The [`GTK_ORIENTATION_VERTICAL`](gtk4-standard-enumerations#GTK-ORIENTATION-VERTICAL:CAPS) case is analogous. This way, both height-for-width and width-for-height requests can be implemented. If no size is known, -1 can be passed. | |
| minimum | location to store the minimum size, or `NULL`. | [out][optional] |
| natural | location to store the natural size, or `NULL`. | [out][optional] |
| minimum\_baseline | location to store the baseline position for the minimum size, or `NULL`. | [out][optional] |
| natural\_baseline | location to store the baseline position for the natural size, or `NULL`. | [out][optional] |
### gtk\_widget\_snapshot\_child ()
```
void
gtk_widget_snapshot_child (*`[GtkWidget](gtkwidget#GtkWidget-struct) *widget`*,
*`[GtkWidget](gtkwidget#GtkWidget-struct) *child`*,
*`[GtkSnapshot](gtksnapshot#GtkSnapshot) *snapshot`*);
```
When a widget receives a call to the snapshot function, it must send synthetic [`GtkWidgetClass.snapshot()`](gtkwidget#GtkWidgetClass.snapshot) calls to all children. This function provides a convenient way of doing this. A widget, when it receives a call to its [`GtkWidgetClass.snapshot()`](gtkwidget#GtkWidgetClass.snapshot) function, calls [`gtk_widget_snapshot_child()`](gtkwidget#gtk-widget-snapshot-child) once for each child, passing in the *`snapshot`* the widget received.
gtk\_widget\_snapshot\_child() takes care of translating the origin of *`snapshot`* , and deciding whether the child needs to be snapshot.
This function does nothing for children that implement [GtkNative](gtknative#GtkNative-struct).
#### Parameters
| | | |
| --- | --- | --- |
| widget | a [GtkWidget](gtkwidget#GtkWidget-struct) | |
| child | a child of *`widget`* | |
| snapshot | [GtkSnapshot](gtksnapshot#GtkSnapshot) as passed to the widget. In particular, no calls to [`gtk_snapshot_translate()`](gtksnapshot#gtk-snapshot-translate) or other transform calls should have been made. | |
### gtk\_widget\_get\_next\_sibling ()
```
[GtkWidget](gtkwidget#GtkWidget-struct) *
gtk_widget_get_next_sibling (*`[GtkWidget](gtkwidget#GtkWidget-struct) *widget`*);
```
Returns the widgets next sibling.
This API is primarily meant for widget implementations.
#### Parameters
| | | |
| --- | --- | --- |
| widget | a [GtkWidget](gtkwidget#GtkWidget-struct) | |
#### Returns
The widget's next sibling.
[transfer none][nullable]
### gtk\_widget\_get\_prev\_sibling ()
```
[GtkWidget](gtkwidget#GtkWidget-struct) *
gtk_widget_get_prev_sibling (*`[GtkWidget](gtkwidget#GtkWidget-struct) *widget`*);
```
Returns the widgets previous sibling.
This API is primarily meant for widget implementations.
#### Parameters
| | | |
| --- | --- | --- |
| widget | a [GtkWidget](gtkwidget#GtkWidget-struct) | |
#### Returns
The widget's previous sibling.
[transfer none][nullable]
### gtk\_widget\_get\_first\_child ()
```
[GtkWidget](gtkwidget#GtkWidget-struct) *
gtk_widget_get_first_child (*`[GtkWidget](gtkwidget#GtkWidget-struct) *widget`*);
```
Returns the widgets first child.
This API is primarily meant for widget implementations.
#### Parameters
| | | |
| --- | --- | --- |
| widget | a [GtkWidget](gtkwidget#GtkWidget-struct) | |
#### Returns
The widget's first child.
[transfer none][nullable]
### gtk\_widget\_get\_last\_child ()
```
[GtkWidget](gtkwidget#GtkWidget-struct) *
gtk_widget_get_last_child (*`[GtkWidget](gtkwidget#GtkWidget-struct) *widget`*);
```
Returns the widgets last child.
This API is primarily meant for widget implementations.
#### Parameters
| | | |
| --- | --- | --- |
| widget | a [GtkWidget](gtkwidget#GtkWidget-struct) | |
#### Returns
The widget's last child.
[transfer none][nullable]
### gtk\_widget\_insert\_before ()
```
void
gtk_widget_insert_before (*`[GtkWidget](gtkwidget#GtkWidget-struct) *widget`*,
*`[GtkWidget](gtkwidget#GtkWidget-struct) *parent`*,
*`[GtkWidget](gtkwidget#GtkWidget-struct) *next_sibling`*);
```
Inserts *`widget`* into the child widget list of *`parent`* .
It will be placed before *`next_sibling`* , or at the end if *`next_sibling`* is `NULL`.
After calling this function, gtk\_widget\_get\_next\_sibling(widget) will return *`next_sibling`* .
If *`parent`* is already set as the parent widget of *`widget`* , this function can also be used to reorder *`widget`* in the child widget list of *`parent`* .
This API is primarily meant for widget implementations; if you are just using a widget, you \*must\* use its own API for adding children.
#### Parameters
| | | |
| --- | --- | --- |
| widget | a [GtkWidget](gtkwidget#GtkWidget-struct) | |
| parent | the parent [GtkWidget](gtkwidget#GtkWidget-struct) to insert *`widget`* into | |
| next\_sibling | the new next sibling of *`widget`* or `NULL`. | [nullable] |
### gtk\_widget\_insert\_after ()
```
void
gtk_widget_insert_after (*`[GtkWidget](gtkwidget#GtkWidget-struct) *widget`*,
*`[GtkWidget](gtkwidget#GtkWidget-struct) *parent`*,
*`[GtkWidget](gtkwidget#GtkWidget-struct) *previous_sibling`*);
```
Inserts *`widget`* into the child widget list of *`parent`* .
It will be placed after *`previous_sibling`* , or at the beginning if *`previous_sibling`* is `NULL`.
After calling this function, gtk\_widget\_get\_prev\_sibling(widget) will return *`previous_sibling`* .
If *`parent`* is already set as the parent widget of *`widget`* , this function can also be used to reorder *`widget`* in the child widget list of *`parent`* .
This API is primarily meant for widget implementations; if you are just using a widget, you \*must\* use its own API for adding children.
#### Parameters
| | | |
| --- | --- | --- |
| widget | a [GtkWidget](gtkwidget#GtkWidget-struct) | |
| parent | the parent [GtkWidget](gtkwidget#GtkWidget-struct) to insert *`widget`* into | |
| previous\_sibling | the new previous sibling of *`widget`* or `NULL`. | [nullable] |
### gtk\_widget\_set\_layout\_manager ()
```
void
gtk_widget_set_layout_manager (*`[GtkWidget](gtkwidget#GtkWidget-struct) *widget`*,
*`[GtkLayoutManager](gtklayoutmanager#GtkLayoutManager-struct) *layout_manager`*);
```
Sets the layout manager delegate instance that provides an implementation for measuring and allocating the children of *`widget`* .
#### Parameters
| | | |
| --- | --- | --- |
| widget | a [GtkWidget](gtkwidget#GtkWidget-struct) | |
| layout\_manager | a [GtkLayoutManager](gtklayoutmanager#GtkLayoutManager-struct). | [nullable][transfer full] |
### gtk\_widget\_get\_layout\_manager ()
```
[GtkLayoutManager](gtklayoutmanager#GtkLayoutManager-struct) *
gtk_widget_get_layout_manager (*`[GtkWidget](gtkwidget#GtkWidget-struct) *widget`*);
```
Retrieves the layout manager set using [`gtk_widget_set_layout_manager()`](gtkwidget#gtk-widget-set-layout-manager).
#### Parameters
| | | |
| --- | --- | --- |
| widget | a [GtkWidget](gtkwidget#GtkWidget-struct) | |
#### Returns
a [GtkLayoutManager](gtklayoutmanager#GtkLayoutManager-struct).
[transfer none][nullable]
### gtk\_widget\_should\_layout ()
```
gboolean
gtk_widget_should_layout (*`[GtkWidget](gtkwidget#GtkWidget-struct) *widget`*);
```
Returns whether *`widget`* should contribute to the measuring and allocation of its parent. This is `FALSE` for invisible children, but also for children that have their own surface.
#### Parameters
| | | |
| --- | --- | --- |
| widget | a widget | |
#### Returns
`TRUE` if child should be included in measuring and allocating
### gtk\_widget\_get\_css\_name ()
```
const char *
gtk_widget_get_css_name (*`[GtkWidget](gtkwidget#GtkWidget-struct) *self`*);
```
Returns the CSS name that is used for *`self`* .
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkWidget](gtkwidget#GtkWidget-struct) | |
#### Returns
the CSS name.
[transfer none]
### gtk\_widget\_add\_css\_class ()
```
void
gtk_widget_add_css_class (*`[GtkWidget](gtkwidget#GtkWidget-struct) *widget`*,
*`const char *css_class`*);
```
Adds *`css_class`* to *`widget`* . After calling this function, *`widget`* 's style will match for *`css_class`* , after the CSS matching rules.
#### Parameters
| | | |
| --- | --- | --- |
| widget | a [GtkWidget](gtkwidget#GtkWidget-struct) | |
| css\_class | The style class to add to *`widget`* , without the leading '.' used for notation of style classes | |
### gtk\_widget\_remove\_css\_class ()
```
void
gtk_widget_remove_css_class (*`[GtkWidget](gtkwidget#GtkWidget-struct) *widget`*,
*`const char *css_class`*);
```
Removes *`css_class`* from *`widget`* . After this, the style of *`widget`* will stop matching for *`css_class`* .
#### Parameters
| | | |
| --- | --- | --- |
| widget | a [GtkWidget](gtkwidget#GtkWidget-struct) | |
| css\_class | The style class to remove from *`widget`* , without the leading '.' used for notation of style classes | |
### gtk\_widget\_has\_css\_class ()
```
gboolean
gtk_widget_has_css_class (*`[GtkWidget](gtkwidget#GtkWidget-struct) *widget`*,
*`const char *css_class`*);
```
Returns whether *`css_class`* is currently applied to *`widget`* .
#### Parameters
| | | |
| --- | --- | --- |
| widget | a [GtkWidget](gtkwidget#GtkWidget-struct) | |
| css\_class | A CSS style class, without the leading '.' used for notation of style classes | |
#### Returns
`TRUE` if *`css_class`* is currently applied to *`widget`* , `FALSE` otherwise.
### gtk\_widget\_get\_css\_classes ()
```
char **
gtk_widget_get_css_classes (*`[GtkWidget](gtkwidget#GtkWidget-struct) *widget`*);
```
Returns the list of css classes applied to *`widget`* .
#### Parameters
| | | |
| --- | --- | --- |
| widget | a [GtkWidget](gtkwidget#GtkWidget-struct) | |
#### Returns
a `NULL`-terminated list of css classes currently applied to *`widget`* . The returned list can be freed using `g_strfreev()`.
[transfer full]
### gtk\_widget\_set\_css\_classes ()
```
void
gtk_widget_set_css_classes (*`[GtkWidget](gtkwidget#GtkWidget-struct) *widget`*,
*`const char **classes`*);
```
Will clear all css classes applied to *`widget`* and replace them with *`classes`* .
#### Parameters
| | | |
| --- | --- | --- |
| widget | a [GtkWidget](gtkwidget#GtkWidget-struct) | |
| classes | `NULL`-terminated list of css classes to apply to *`widget`* . | [transfer none][array zero-terminated=1] |
### gtk\_widget\_get\_style\_context ()
```
[GtkStyleContext](gtkstylecontext#GtkStyleContext-struct) *
gtk_widget_get_style_context (*`[GtkWidget](gtkwidget#GtkWidget-struct) *widget`*);
```
Returns the style context associated to *`widget`* . The returned object is guaranteed to be the same for the lifetime of *`widget`* .
#### Parameters
| | | |
| --- | --- | --- |
| widget | a [GtkWidget](gtkwidget#GtkWidget-struct) | |
#### Returns
a [GtkStyleContext](gtkstylecontext#GtkStyleContext-struct). This memory is owned by *`widget`* and must not be freed.
[transfer none]
### gtk\_widget\_class\_get\_css\_name ()
```
const char *
gtk_widget_class_get_css_name (*`[GtkWidgetClass](gtkwidget#GtkWidgetClass) *widget_class`*);
```
Gets the name used by this class for matching in CSS code. See [`gtk_widget_class_set_css_name()`](gtkwidget#gtk-widget-class-set-css-name) for details.
#### Parameters
| | | |
| --- | --- | --- |
| widget\_class | class to set the name on | |
#### Returns
the CSS name of the given class
### gtk\_widget\_class\_set\_css\_name ()
```
void
gtk_widget_class_set_css_name (*`[GtkWidgetClass](gtkwidget#GtkWidgetClass) *widget_class`*,
*`const char *name`*);
```
Sets the name to be used for CSS matching of widgets.
If this function is not called for a given class, the name set on the parent class is used. By default, GtkWidget uses the name "widget".
#### Parameters
| | | |
| --- | --- | --- |
| widget\_class | class to set the name on | |
| name | name to use | |
### gtk\_requisition\_new ()
```
[GtkRequisition](gtkwidget#GtkRequisition) *
gtk_requisition_new (*`void`*);
```
Allocates a new GtkRequisition and initializes its elements to zero.
#### Returns
a new empty [GtkRequisition](gtkwidget#GtkRequisition). The newly allocated [GtkRequisition](gtkwidget#GtkRequisition) should be freed with [`gtk_requisition_free()`](gtkwidget#gtk-requisition-free).
### gtk\_requisition\_copy ()
```
[GtkRequisition](gtkwidget#GtkRequisition) *
gtk_requisition_copy (*`const [GtkRequisition](gtkwidget#GtkRequisition) *requisition`*);
```
Copies a [GtkRequisition](gtkwidget#GtkRequisition).
#### Parameters
| | | |
| --- | --- | --- |
| requisition | a [GtkRequisition](gtkwidget#GtkRequisition) | |
#### Returns
a copy of *`requisition`*
### gtk\_requisition\_free ()
```
void
gtk_requisition_free (*`[GtkRequisition](gtkwidget#GtkRequisition) *requisition`*);
```
Frees a [GtkRequisition](gtkwidget#GtkRequisition).
#### Parameters
| | | |
| --- | --- | --- |
| requisition | a [GtkRequisition](gtkwidget#GtkRequisition) | |
### gtk\_widget\_get\_request\_mode ()
```
[GtkSizeRequestMode](gtkwidget#GtkSizeRequestMode)
gtk_widget_get_request_mode (*`[GtkWidget](gtkwidget#GtkWidget-struct) *widget`*);
```
Gets whether the widget prefers a height-for-width layout or a width-for-height layout.
GtkBin widgets generally propagate the preference of their child, container widgets need to request something either in context of their children or in context of their allocation capabilities.
#### Parameters
| | | |
| --- | --- | --- |
| widget | a [GtkWidget](gtkwidget#GtkWidget-struct) instance | |
#### Returns
The [GtkSizeRequestMode](gtkwidget#GtkSizeRequestMode) preferred by *`widget`* .
### gtk\_widget\_get\_preferred\_size ()
```
void
gtk_widget_get_preferred_size (*`[GtkWidget](gtkwidget#GtkWidget-struct) *widget`*,
*`[GtkRequisition](gtkwidget#GtkRequisition) *minimum_size`*,
*`[GtkRequisition](gtkwidget#GtkRequisition) *natural_size`*);
```
Retrieves the minimum and natural size of a widget, taking into account the widget’s preference for height-for-width management.
This is used to retrieve a suitable size by container widgets which do not impose any restrictions on the child placement. It can be used to deduce toplevel window and menu sizes as well as child widgets in free-form containers such as GtkLayout.
Handle with care. Note that the natural height of a height-for-width widget will generally be a smaller size than the minimum height, since the required height for the natural width is generally smaller than the required height for the minimum width.
Use [`gtk_widget_measure()`](gtkwidget#gtk-widget-measure) if you want to support baseline alignment.
#### Parameters
| | | |
| --- | --- | --- |
| widget | a [GtkWidget](gtkwidget#GtkWidget-struct) instance | |
| minimum\_size | location for storing the minimum size, or `NULL`. | [out][allow-none] |
| natural\_size | location for storing the natural size, or `NULL`. | [out][allow-none] |
### gtk\_distribute\_natural\_allocation ()
```
int
gtk_distribute_natural_allocation (*`int extra_space`*,
*`guint n_requested_sizes`*,
*`[GtkRequestedSize](gtkwidget#GtkRequestedSize) *sizes`*);
```
Distributes *`extra_space`* to child *`sizes`* by bringing smaller children up to natural size first.
The remaining space will be added to the *`minimum_size`* member of the GtkRequestedSize struct. If all sizes reach their natural size then the remaining space is returned.
#### Parameters
| | | |
| --- | --- | --- |
| extra\_space | Extra space to redistribute among children after subtracting minimum sizes and any child padding from the overall allocation | |
| n\_requested\_sizes | Number of requests to fit into the allocation | |
| sizes | An array of structs with a client pointer and a minimum/natural size in the orientation of the allocation. | |
#### Returns
The remainder of *`extra_space`* after redistributing space to *`sizes`* .
### gtk\_widget\_get\_halign ()
```
[GtkAlign](gtkwidget#GtkAlign)
gtk_widget_get_halign (*`[GtkWidget](gtkwidget#GtkWidget-struct) *widget`*);
```
Gets the value of the [“halign”](gtkwidget#GtkWidget--halign) property.
For backwards compatibility reasons this method will never return [`GTK_ALIGN_BASELINE`](gtkwidget#GTK-ALIGN-BASELINE:CAPS), but instead it will convert it to [`GTK_ALIGN_FILL`](gtkwidget#GTK-ALIGN-FILL:CAPS). Baselines are not supported for horizontal alignment.
#### Parameters
| | | |
| --- | --- | --- |
| widget | a [GtkWidget](gtkwidget#GtkWidget-struct) | |
#### Returns
the horizontal alignment of *`widget`*
### gtk\_widget\_set\_halign ()
```
void
gtk_widget_set_halign (*`[GtkWidget](gtkwidget#GtkWidget-struct) *widget`*,
*`[GtkAlign](gtkwidget#GtkAlign) align`*);
```
Sets the horizontal alignment of *`widget`* . See the [“halign”](gtkwidget#GtkWidget--halign) property.
#### Parameters
| | | |
| --- | --- | --- |
| widget | a [GtkWidget](gtkwidget#GtkWidget-struct) | |
| align | the horizontal alignment | |
### gtk\_widget\_get\_valign ()
```
[GtkAlign](gtkwidget#GtkAlign)
gtk_widget_get_valign (*`[GtkWidget](gtkwidget#GtkWidget-struct) *widget`*);
```
Gets the value of the [“valign”](gtkwidget#GtkWidget--valign) property.
#### Parameters
| | | |
| --- | --- | --- |
| widget | a [GtkWidget](gtkwidget#GtkWidget-struct) | |
#### Returns
the vertical alignment of *`widget`*
### gtk\_widget\_set\_valign ()
```
void
gtk_widget_set_valign (*`[GtkWidget](gtkwidget#GtkWidget-struct) *widget`*,
*`[GtkAlign](gtkwidget#GtkAlign) align`*);
```
Sets the vertical alignment of *`widget`* . See the [“valign”](gtkwidget#GtkWidget--valign) property.
#### Parameters
| | | |
| --- | --- | --- |
| widget | a [GtkWidget](gtkwidget#GtkWidget-struct) | |
| align | the vertical alignment | |
### gtk\_widget\_get\_margin\_start ()
```
int
gtk_widget_get_margin_start (*`[GtkWidget](gtkwidget#GtkWidget-struct) *widget`*);
```
Gets the value of the [“margin-start”](gtkwidget#GtkWidget--margin-start) property.
#### Parameters
| | | |
| --- | --- | --- |
| widget | a [GtkWidget](gtkwidget#GtkWidget-struct) | |
#### Returns
The start margin of *`widget`*
### gtk\_widget\_set\_margin\_start ()
```
void
gtk_widget_set_margin_start (*`[GtkWidget](gtkwidget#GtkWidget-struct) *widget`*,
*`int margin`*);
```
Sets the start margin of *`widget`* . See the [“margin-start”](gtkwidget#GtkWidget--margin-start) property.
#### Parameters
| | | |
| --- | --- | --- |
| widget | a [GtkWidget](gtkwidget#GtkWidget-struct) | |
| margin | the start margin | |
### gtk\_widget\_get\_margin\_end ()
```
int
gtk_widget_get_margin_end (*`[GtkWidget](gtkwidget#GtkWidget-struct) *widget`*);
```
Gets the value of the [“margin-end”](gtkwidget#GtkWidget--margin-end) property.
#### Parameters
| | | |
| --- | --- | --- |
| widget | a [GtkWidget](gtkwidget#GtkWidget-struct) | |
#### Returns
The end margin of *`widget`*
### gtk\_widget\_set\_margin\_end ()
```
void
gtk_widget_set_margin_end (*`[GtkWidget](gtkwidget#GtkWidget-struct) *widget`*,
*`int margin`*);
```
Sets the end margin of *`widget`* . See the [“margin-end”](gtkwidget#GtkWidget--margin-end) property.
#### Parameters
| | | |
| --- | --- | --- |
| widget | a [GtkWidget](gtkwidget#GtkWidget-struct) | |
| margin | the end margin | |
### gtk\_widget\_get\_margin\_top ()
```
int
gtk_widget_get_margin_top (*`[GtkWidget](gtkwidget#GtkWidget-struct) *widget`*);
```
Gets the value of the [“margin-top”](gtkwidget#GtkWidget--margin-top) property.
#### Parameters
| | | |
| --- | --- | --- |
| widget | a [GtkWidget](gtkwidget#GtkWidget-struct) | |
#### Returns
The top margin of *`widget`*
### gtk\_widget\_set\_margin\_top ()
```
void
gtk_widget_set_margin_top (*`[GtkWidget](gtkwidget#GtkWidget-struct) *widget`*,
*`int margin`*);
```
Sets the top margin of *`widget`* . See the [“margin-top”](gtkwidget#GtkWidget--margin-top) property.
#### Parameters
| | | |
| --- | --- | --- |
| widget | a [GtkWidget](gtkwidget#GtkWidget-struct) | |
| margin | the top margin | |
### gtk\_widget\_get\_margin\_bottom ()
```
int
gtk_widget_get_margin_bottom (*`[GtkWidget](gtkwidget#GtkWidget-struct) *widget`*);
```
Gets the value of the [“margin-bottom”](gtkwidget#GtkWidget--margin-bottom) property.
#### Parameters
| | | |
| --- | --- | --- |
| widget | a [GtkWidget](gtkwidget#GtkWidget-struct) | |
#### Returns
The bottom margin of *`widget`*
### gtk\_widget\_set\_margin\_bottom ()
```
void
gtk_widget_set_margin_bottom (*`[GtkWidget](gtkwidget#GtkWidget-struct) *widget`*,
*`int margin`*);
```
Sets the bottom margin of *`widget`* . See the [“margin-bottom”](gtkwidget#GtkWidget--margin-bottom) property.
#### Parameters
| | | |
| --- | --- | --- |
| widget | a [GtkWidget](gtkwidget#GtkWidget-struct) | |
| margin | the bottom margin | |
### gtk\_widget\_get\_hexpand ()
```
gboolean
gtk_widget_get_hexpand (*`[GtkWidget](gtkwidget#GtkWidget-struct) *widget`*);
```
Gets whether the widget would like any available extra horizontal space. When a user resizes a [GtkWindow](gtkwindow#GtkWindow-struct), widgets with expand=TRUE generally receive the extra space. For example, a list or scrollable area or document in your window would often be set to expand.
Containers should use [`gtk_widget_compute_expand()`](gtkwidget#gtk-widget-compute-expand) rather than this function, to see whether a widget, or any of its children, has the expand flag set. If any child of a widget wants to expand, the parent may ask to expand also.
This function only looks at the widget’s own hexpand flag, rather than computing whether the entire widget tree rooted at this widget wants to expand.
#### Parameters
| | | |
| --- | --- | --- |
| widget | the widget | |
#### Returns
whether hexpand flag is set
### gtk\_widget\_set\_hexpand ()
```
void
gtk_widget_set_hexpand (*`[GtkWidget](gtkwidget#GtkWidget-struct) *widget`*,
*`gboolean expand`*);
```
Sets whether the widget would like any available extra horizontal space. When a user resizes a [GtkWindow](gtkwindow#GtkWindow-struct), widgets with expand=TRUE generally receive the extra space. For example, a list or scrollable area or document in your window would often be set to expand.
Call this function to set the expand flag if you would like your widget to become larger horizontally when the window has extra room.
By default, widgets automatically expand if any of their children want to expand. (To see if a widget will automatically expand given its current children and state, call [`gtk_widget_compute_expand()`](gtkwidget#gtk-widget-compute-expand). A container can decide how the expandability of children affects the expansion of the container by overriding the compute\_expand virtual method on [GtkWidget](gtkwidget#GtkWidget-struct).).
Setting hexpand explicitly with this function will override the automatic expand behavior.
This function forces the widget to expand or not to expand, regardless of children. The override occurs because [`gtk_widget_set_hexpand()`](gtkwidget#gtk-widget-set-hexpand) sets the hexpand-set property (see [`gtk_widget_set_hexpand_set()`](gtkwidget#gtk-widget-set-hexpand-set)) which causes the widget’s hexpand value to be used, rather than looking at children and widget state.
#### Parameters
| | | |
| --- | --- | --- |
| widget | the widget | |
| expand | whether to expand | |
### gtk\_widget\_get\_hexpand\_set ()
```
gboolean
gtk_widget_get_hexpand_set (*`[GtkWidget](gtkwidget#GtkWidget-struct) *widget`*);
```
Gets whether [`gtk_widget_set_hexpand()`](gtkwidget#gtk-widget-set-hexpand) has been used to explicitly set the expand flag on this widget.
If hexpand is set, then it overrides any computed expand value based on child widgets. If hexpand is not set, then the expand value depends on whether any children of the widget would like to expand.
There are few reasons to use this function, but it’s here for completeness and consistency.
#### Parameters
| | | |
| --- | --- | --- |
| widget | the widget | |
#### Returns
whether hexpand has been explicitly set
### gtk\_widget\_set\_hexpand\_set ()
```
void
gtk_widget_set_hexpand_set (*`[GtkWidget](gtkwidget#GtkWidget-struct) *widget`*,
*`gboolean set`*);
```
Sets whether the hexpand flag (see [`gtk_widget_get_hexpand()`](gtkwidget#gtk-widget-get-hexpand)) will be used.
The hexpand-set property will be set automatically when you call [`gtk_widget_set_hexpand()`](gtkwidget#gtk-widget-set-hexpand) to set hexpand, so the most likely reason to use this function would be to unset an explicit expand flag.
If hexpand is set, then it overrides any computed expand value based on child widgets. If hexpand is not set, then the expand value depends on whether any children of the widget would like to expand.
There are few reasons to use this function, but it’s here for completeness and consistency.
#### Parameters
| | | |
| --- | --- | --- |
| widget | the widget | |
| set | value for hexpand-set property | |
### gtk\_widget\_get\_vexpand ()
```
gboolean
gtk_widget_get_vexpand (*`[GtkWidget](gtkwidget#GtkWidget-struct) *widget`*);
```
Gets whether the widget would like any available extra vertical space.
See [`gtk_widget_get_hexpand()`](gtkwidget#gtk-widget-get-hexpand) for more detail.
#### Parameters
| | | |
| --- | --- | --- |
| widget | the widget | |
#### Returns
whether vexpand flag is set
### gtk\_widget\_set\_vexpand ()
```
void
gtk_widget_set_vexpand (*`[GtkWidget](gtkwidget#GtkWidget-struct) *widget`*,
*`gboolean expand`*);
```
Sets whether the widget would like any available extra vertical space.
See [`gtk_widget_set_hexpand()`](gtkwidget#gtk-widget-set-hexpand) for more detail.
#### Parameters
| | | |
| --- | --- | --- |
| widget | the widget | |
| expand | whether to expand | |
### gtk\_widget\_get\_vexpand\_set ()
```
gboolean
gtk_widget_get_vexpand_set (*`[GtkWidget](gtkwidget#GtkWidget-struct) *widget`*);
```
Gets whether [`gtk_widget_set_vexpand()`](gtkwidget#gtk-widget-set-vexpand) has been used to explicitly set the expand flag on this widget.
See [`gtk_widget_get_hexpand_set()`](gtkwidget#gtk-widget-get-hexpand-set) for more detail.
#### Parameters
| | | |
| --- | --- | --- |
| widget | the widget | |
#### Returns
whether vexpand has been explicitly set
### gtk\_widget\_set\_vexpand\_set ()
```
void
gtk_widget_set_vexpand_set (*`[GtkWidget](gtkwidget#GtkWidget-struct) *widget`*,
*`gboolean set`*);
```
Sets whether the vexpand flag (see [`gtk_widget_get_vexpand()`](gtkwidget#gtk-widget-get-vexpand)) will be used.
See [`gtk_widget_set_hexpand_set()`](gtkwidget#gtk-widget-set-hexpand-set) for more detail.
#### Parameters
| | | |
| --- | --- | --- |
| widget | the widget | |
| set | value for vexpand-set property | |
### gtk\_widget\_compute\_expand ()
```
gboolean
gtk_widget_compute_expand (*`[GtkWidget](gtkwidget#GtkWidget-struct) *widget`*,
*`[GtkOrientation](gtk4-standard-enumerations#GtkOrientation) orientation`*);
```
Computes whether a container should give this widget extra space when possible. Containers should check this, rather than looking at [`gtk_widget_get_hexpand()`](gtkwidget#gtk-widget-get-hexpand) or [`gtk_widget_get_vexpand()`](gtkwidget#gtk-widget-get-vexpand).
This function already checks whether the widget is visible, so visibility does not need to be checked separately. Non-visible widgets are not expanded.
The computed expand value uses either the expand setting explicitly set on the widget itself, or, if none has been explicitly set, the widget may expand if some of its children do.
#### Parameters
| | | |
| --- | --- | --- |
| widget | the widget | |
| orientation | expand direction | |
#### Returns
whether widget tree rooted here should be expanded
### gtk\_widget\_init\_template ()
```
void
gtk_widget_init_template (*`[GtkWidget](gtkwidget#GtkWidget-struct) *widget`*);
```
Creates and initializes child widgets defined in templates. This function must be called in the instance initializer for any class which assigned itself a template using [`gtk_widget_class_set_template()`](gtkwidget#gtk-widget-class-set-template)
It is important to call this function in the instance initializer of a [GtkWidget](gtkwidget#GtkWidget-struct) subclass and not in `GObject.constructed()` or `GObject.constructor()` for two reasons.
One reason is that generally derived widgets will assume that parent class composite widgets have been created in their instance initializers.
Another reason is that when calling `g_object_new()` on a widget with composite templates, it’s important to build the composite widgets before the construct properties are set. Properties passed to `g_object_new()` should take precedence over properties set in the private template XML.
#### Parameters
| | | |
| --- | --- | --- |
| widget | a [GtkWidget](gtkwidget#GtkWidget-struct) | |
### gtk\_widget\_class\_set\_template ()
```
void
gtk_widget_class_set_template (*`[GtkWidgetClass](gtkwidget#GtkWidgetClass) *widget_class`*,
*`GBytes *template_bytes`*);
```
This should be called at class initialization time to specify the GtkBuilder XML to be used to extend a widget.
For convenience, [`gtk_widget_class_set_template_from_resource()`](gtkwidget#gtk-widget-class-set-template-from-resource) is also provided.
Note that any class that installs templates must call [`gtk_widget_init_template()`](gtkwidget#gtk-widget-init-template) in the widget’s instance initializer.
#### Parameters
| | | |
| --- | --- | --- |
| widget\_class | A [GtkWidgetClass](gtkwidget#GtkWidgetClass) | |
| template\_bytes | A GBytes holding the [GtkBuilder](gtkbuilder#GtkBuilder-struct) XML | |
### gtk\_widget\_class\_set\_template\_from\_resource ()
```
void
gtk_widget_class_set_template_from_resource
(*`[GtkWidgetClass](gtkwidget#GtkWidgetClass) *widget_class`*,
*`const char *resource_name`*);
```
A convenience function to call [`gtk_widget_class_set_template()`](gtkwidget#gtk-widget-class-set-template).
Note that any class that installs templates must call [`gtk_widget_init_template()`](gtkwidget#gtk-widget-init-template) in the widget’s instance initializer.
#### Parameters
| | | |
| --- | --- | --- |
| widget\_class | A [GtkWidgetClass](gtkwidget#GtkWidgetClass) | |
| resource\_name | The name of the resource to load the template from | |
### gtk\_widget\_get\_template\_child ()
```
GObject *
gtk_widget_get_template_child (*`[GtkWidget](gtkwidget#GtkWidget-struct) *widget`*,
*`GType widget_type`*,
*`const char *name`*);
```
Fetch an object build from the template XML for *`widget_type`* in this *`widget`* instance.
This will only report children which were previously declared with [`gtk_widget_class_bind_template_child_full()`](gtkwidget#gtk-widget-class-bind-template-child-full) or one of its variants.
This function is only meant to be called for code which is private to the *`widget_type`* which declared the child and is meant for language bindings which cannot easily make use of the GObject structure offsets.
#### Parameters
| | | |
| --- | --- | --- |
| widget | A [GtkWidget](gtkwidget#GtkWidget-struct) | |
| widget\_type | The GType to get a template child for | |
| name | The “id” of the child defined in the template XML | |
#### Returns
The object built in the template XML with the id *`name`* .
[transfer none]
### gtk\_widget\_class\_bind\_template\_child()
```
#define gtk_widget_class_bind_template_child(widget_class, TypeName, member_name)
```
Binds a child widget defined in a template to the *`widget_class`* .
This macro is a convenience wrapper around the [`gtk_widget_class_bind_template_child_full()`](gtkwidget#gtk-widget-class-bind-template-child-full) function.
This macro will use the offset of the *`member_name`* inside the *`TypeName`* instance structure.
#### Parameters
| | | |
| --- | --- | --- |
| widget\_class | a [GtkWidgetClass](gtkwidget#GtkWidgetClass) | |
| TypeName | the type name of this widget | |
| member\_name | name of the instance member in the instance struct for *`data_type`* | |
### gtk\_widget\_class\_bind\_template\_child\_internal()
```
#define gtk_widget_class_bind_template_child_internal(widget_class, TypeName, member_name)
```
Binds a child widget defined in a template to the *`widget_class`* , and also makes it available as an internal child in GtkBuilder, under the name *`member_name`* .
This macro is a convenience wrapper around the [`gtk_widget_class_bind_template_child_full()`](gtkwidget#gtk-widget-class-bind-template-child-full) function.
This macro will use the offset of the *`member_name`* inside the *`TypeName`* instance structure.
#### Parameters
| | | |
| --- | --- | --- |
| widget\_class | a [GtkWidgetClass](gtkwidget#GtkWidgetClass) | |
| TypeName | the type name, in CamelCase | |
| member\_name | name of the instance member in the instance struct for *`data_type`* | |
### gtk\_widget\_class\_bind\_template\_child\_private()
```
#define gtk_widget_class_bind_template_child_private(widget_class, TypeName, member_name)
```
Binds a child widget defined in a template to the *`widget_class`* .
This macro is a convenience wrapper around the [`gtk_widget_class_bind_template_child_full()`](gtkwidget#gtk-widget-class-bind-template-child-full) function.
This macro will use the offset of the *`member_name`* inside the *`TypeName`* private data structure (it uses `G_PRIVATE_OFFSET()`, so the private struct must be added with `G_ADD_PRIVATE()`).
#### Parameters
| | | |
| --- | --- | --- |
| widget\_class | a [GtkWidgetClass](gtkwidget#GtkWidgetClass) | |
| TypeName | the type name of this widget | |
| member\_name | name of the instance private member in the private struct for *`data_type`* | |
### gtk\_widget\_class\_bind\_template\_child\_internal\_private()
```
#define gtk_widget_class_bind_template_child_internal_private(widget_class, TypeName, member_name)
```
Binds a child widget defined in a template to the *`widget_class`* , and also makes it available as an internal child in GtkBuilder, under the name *`member_name`* .
This macro is a convenience wrapper around the [`gtk_widget_class_bind_template_child_full()`](gtkwidget#gtk-widget-class-bind-template-child-full) function.
This macro will use the offset of the *`member_name`* inside the *`TypeName`* private data structure.
#### Parameters
| | | |
| --- | --- | --- |
| widget\_class | a [GtkWidgetClass](gtkwidget#GtkWidgetClass) | |
| TypeName | the type name, in CamelCase | |
| member\_name | name of the instance private member on the private struct for *`data_type`* | |
### gtk\_widget\_class\_bind\_template\_child\_full ()
```
void
gtk_widget_class_bind_template_child_full
(*`[GtkWidgetClass](gtkwidget#GtkWidgetClass) *widget_class`*,
*`const char *name`*,
*`gboolean internal_child`*,
*`gssize struct_offset`*);
```
Automatically assign an object declared in the class template XML to be set to a location on a freshly built instance’s private data, or alternatively accessible via [`gtk_widget_get_template_child()`](gtkwidget#gtk-widget-get-template-child).
The struct can point either into the public instance, then you should use G\_STRUCT\_OFFSET(WidgetType, member) for *`struct_offset`* , or in the private struct, then you should use G\_PRIVATE\_OFFSET(WidgetType, member).
An explicit strong reference will be held automatically for the duration of your instance’s life cycle, it will be released automatically when `GObjectClass.dispose()` runs on your instance and if a *`struct_offset`* that is != 0 is specified, then the automatic location in your instance public or private data will be set to `NULL`. You can however access an automated child pointer the first time your classes `GObjectClass.dispose()` runs, or alternatively in `GtkWidgetClass.destroy()`.
If *`internal_child`* is specified, [`GtkBuildableIface.get_internal_child()`](gtkbuildable#GtkBuildableIface.get-internal-child) will be automatically implemented by the [GtkWidget](gtkwidget#GtkWidget-struct) class so there is no need to implement it manually.
The wrapper macros [`gtk_widget_class_bind_template_child()`](gtkwidget#gtk-widget-class-bind-template-child), [`gtk_widget_class_bind_template_child_internal()`](gtkwidget#gtk-widget-class-bind-template-child-internal), [`gtk_widget_class_bind_template_child_private()`](gtkwidget#gtk-widget-class-bind-template-child-private) and [`gtk_widget_class_bind_template_child_internal_private()`](gtkwidget#gtk-widget-class-bind-template-child-internal-private) might be more convenient to use.
Note that this must be called from a composite widget classes class initializer after calling [`gtk_widget_class_set_template()`](gtkwidget#gtk-widget-class-set-template).
#### Parameters
| | | |
| --- | --- | --- |
| widget\_class | A [GtkWidgetClass](gtkwidget#GtkWidgetClass) | |
| name | The “id” of the child defined in the template XML | |
| internal\_child | Whether the child should be accessible as an “internal-child” when this class is used in GtkBuilder XML | |
| struct\_offset | The structure offset into the composite widget’s instance public or private structure where the automated child pointer should be set, or 0 to not assign the pointer. | |
### gtk\_widget\_class\_bind\_template\_callback()
```
#define gtk_widget_class_bind_template_callback(widget_class, callback)
```
Binds a callback function defined in a template to the *`widget_class`* .
This macro is a convenience wrapper around the [`gtk_widget_class_bind_template_callback_full()`](gtkwidget#gtk-widget-class-bind-template-callback-full) function. It is not supported after [`gtk_widget_class_set_template_scope()`](gtkwidget#gtk-widget-class-set-template-scope) has been used on *`widget_class`* .
#### Parameters
| | | |
| --- | --- | --- |
| widget\_class | a [GtkWidgetClass](gtkwidget#GtkWidgetClass) | |
| callback | the callback symbol | |
### gtk\_widget\_class\_bind\_template\_callback\_full ()
```
void
gtk_widget_class_bind_template_callback_full
(*`[GtkWidgetClass](gtkwidget#GtkWidgetClass) *widget_class`*,
*`const char *callback_name`*,
*`GCallback callback_symbol`*);
```
Declares a *`callback_symbol`* to handle *`callback_name`* from the template XML defined for *`widget_type`* . This function is not supported after [`gtk_widget_class_set_template_scope()`](gtkwidget#gtk-widget-class-set-template-scope) has been used on *`widget_class`* . See [`gtk_builder_cscope_add_callback_symbol()`](gtkbuilderscope#gtk-builder-cscope-add-callback-symbol).
Note that this must be called from a composite widget classes class initializer after calling [`gtk_widget_class_set_template()`](gtkwidget#gtk-widget-class-set-template).
#### Parameters
| | | |
| --- | --- | --- |
| widget\_class | A [GtkWidgetClass](gtkwidget#GtkWidgetClass) | |
| callback\_name | The name of the callback as expected in the template XML | |
| callback\_symbol | The callback symbol. | [scope async] |
### gtk\_widget\_class\_set\_template\_scope ()
```
void
gtk_widget_class_set_template_scope (*`[GtkWidgetClass](gtkwidget#GtkWidgetClass) *widget_class`*,
*`[GtkBuilderScope](gtkbuilderscope#GtkBuilderScope-struct) *scope`*);
```
For use in language bindings, this will override the default [GtkBuilderScope](gtkbuilderscope#GtkBuilderScope-struct) to be used when parsing GtkBuilder XML from this class’s template data.
Note that this must be called from a composite widget classes class initializer after calling [`gtk_widget_class_set_template()`](gtkwidget#gtk-widget-class-set-template).
#### Parameters
| | | |
| --- | --- | --- |
| widget\_class | A [GtkWidgetClass](gtkwidget#GtkWidgetClass) | |
| scope | The [GtkBuilderScope](gtkbuilderscope#GtkBuilderScope-struct) to use when loading the class template. | [transfer none] |
### gtk\_widget\_observe\_children ()
```
GListModel *
gtk_widget_observe_children (*`[GtkWidget](gtkwidget#GtkWidget-struct) *widget`*);
```
Returns a GListModel to track the children of *`widget`* .
Calling this function will enable extra internal bookkeeping to track children and emit signals on the returned listmodel. It may slow down operations a lot.
Applications should try hard to avoid calling this function because of the slowdowns.
#### Parameters
| | | |
| --- | --- | --- |
| widget | a [GtkWidget](gtkwidget#GtkWidget-struct) | |
#### Returns
a GListModel tracking *`widget`* 's children.
[transfer full][attributes element-type=GtkWidget]
### gtk\_widget\_observe\_controllers ()
```
GListModel *
gtk_widget_observe_controllers (*`[GtkWidget](gtkwidget#GtkWidget-struct) *widget`*);
```
Returns a GListModel to track the [GtkEventControllers](gtkeventcontroller#GtkEventController-struct) of *`widget`* .
Calling this function will enable extra internal bookkeeping to track controllers and emit signals on the returned listmodel. It may slow down operations a lot.
Applications should try hard to avoid calling this function because of the slowdowns.
#### Parameters
| | | |
| --- | --- | --- |
| widget | a [GtkWidget](gtkwidget#GtkWidget-struct) | |
#### Returns
a GListModel tracking *`widget`* 's controllers.
[transfer full][attributes element-type=GtkEventController]
### gtk\_widget\_insert\_action\_group ()
```
void
gtk_widget_insert_action_group (*`[GtkWidget](gtkwidget#GtkWidget-struct) *widget`*,
*`const char *name`*,
*`GActionGroup *group`*);
```
Inserts *`group`* into *`widget`* . Children of *`widget`* that implement [GtkActionable](gtkactionable#GtkActionable-struct) can then be associated with actions in *`group`* by setting their “action-name” to *`prefix`* .`action-name`.
Note that inheritance is defined for individual actions. I.e. even if you insert a group with prefix *`prefix`* , actions with the same prefix will still be inherited from the parent, unless the group contains an action with the same name.
If *`group`* is `NULL`, a previously inserted group for *`name`* is removed from *`widget`* .
#### Parameters
| | | |
| --- | --- | --- |
| widget | a [GtkWidget](gtkwidget#GtkWidget-struct) | |
| name | the prefix for actions in *`group`* | |
| group | a GActionGroup, or `NULL`. | [allow-none] |
### gtk\_widget\_activate\_action ()
```
gboolean
gtk_widget_activate_action (*`[GtkWidget](gtkwidget#GtkWidget-struct) *widget`*,
*`const char *name`*,
*`const char *format_string`*,
*`...`*);
```
Looks up the action in the action groups associated with *`widget`* and its ancestors, and activates it.
This is a wrapper around [`gtk_widget_activate_action_variant()`](gtkwidget#gtk-widget-activate-action-variant) that constructs the *`args`* variant according to *`format_string`* .
#### Parameters
| | | |
| --- | --- | --- |
| widget | a [GtkWidget](gtkwidget#GtkWidget-struct) | |
| name | the name of the action to activate | |
| format\_string | GVariant format string for arguments or `NULL` for no arguments | |
| ... | arguments, as given by format string | |
#### Returns
`TRUE` if the action was activated, `FALSE` if the action does not exist.
### gtk\_widget\_activate\_action\_variant ()
```
gboolean
gtk_widget_activate_action_variant (*`[GtkWidget](gtkwidget#GtkWidget-struct) *widget`*,
*`const char *name`*,
*`GVariant *args`*);
```
Looks up the action in the action groups associated with *`widget`* and its ancestors, and activates it.
If the action is in an action group added with [`gtk_widget_insert_action_group()`](gtkwidget#gtk-widget-insert-action-group), the *`name`* is expected to be prefixed with the prefix that was used when the group was inserted.
The arguments must match the actions expected parameter type, as returned by `g_action_get_parameter_type()`.
[rename-to gtk\_widget\_activate\_action]
#### Parameters
| | | |
| --- | --- | --- |
| widget | a [GtkWidget](gtkwidget#GtkWidget-struct) | |
| name | the name of the action to activate | |
| args | parameters to use, or `NULL`. | [allow-none] |
#### Returns
`TRUE` if the action was activated, `FALSE` if the action does not exist.
### gtk\_widget\_activate\_default ()
```
void
gtk_widget_activate_default (*`[GtkWidget](gtkwidget#GtkWidget-struct) *widget`*);
```
Activate the default.activate action from *`widget`* .
#### Parameters
| | | |
| --- | --- | --- |
| widget | a [GtkWidget](gtkwidget#GtkWidget-struct) | |
### GtkWidgetActionActivateFunc ()
```
void
(*GtkWidgetActionActivateFunc) (*`[GtkWidget](gtkwidget#GtkWidget-struct) *widget`*,
*`const char *action_name`*,
*`GVariant *parameter`*);
```
The type of the callback functions used for activating actions installed with [`gtk_widget_class_install_action()`](gtkwidget#gtk-widget-class-install-action).
The *`parameter`* must match the *`parameter_type`* of the action.
#### Parameters
| | | |
| --- | --- | --- |
| widget | the widget to which the action belongs | |
| action\_name | the action name | |
| parameter | parameter for activation | |
### gtk\_widget\_class\_install\_action ()
```
void
gtk_widget_class_install_action (*`[GtkWidgetClass](gtkwidget#GtkWidgetClass) *widget_class`*,
*`const char *action_name`*,
*`const char *parameter_type`*,
*`[GtkWidgetActionActivateFunc](gtkwidget#GtkWidgetActionActivateFunc) activate`*);
```
This should be called at class initialization time to specify actions to be added for all instances of this class.
Actions installed by this function are stateless. The only state they have is whether they are enabled or not.
#### Parameters
| | | |
| --- | --- | --- |
| widget\_class | a [GtkWidgetClass](gtkwidget#GtkWidgetClass) | |
| action\_name | a prefixed action name, such as "clipboard.paste" | |
| parameter\_type | the parameter type, or `NULL`. | [nullable] |
| activate | callback to use when the action is activated. | [scope call] |
### gtk\_widget\_class\_install\_property\_action ()
```
void
gtk_widget_class_install_property_action
(*`[GtkWidgetClass](gtkwidget#GtkWidgetClass) *widget_class`*,
*`const char *action_name`*,
*`const char *property_name`*);
```
Installs an action called *`action_name`* on *`widget_class`* and binds its state to the value of the *`property_name`* property.
This function will perform a few santity checks on the property selected via *`property_name`* . Namely, the property must exist, must be readable, writable and must not be construct-only. There are also restrictions on the type of the given property, it must be boolean, int, unsigned int, double or string. If any of these conditions are not met, a critical warning will be printed and no action will be added.
The state type of the action matches the property type.
If the property is boolean, the action will have no parameter and toggle the property value. Otherwise, the action will have a parameter of the same type as the property.
#### Parameters
| | | |
| --- | --- | --- |
| widget\_class | a [GtkWidgetClass](gtkwidget#GtkWidgetClass) | |
| action\_name | name of the action | |
| property\_name | name of the property in instances of *`widget_class`* or any parent class. | |
### gtk\_widget\_class\_query\_action ()
```
gboolean
gtk_widget_class_query_action (*`[GtkWidgetClass](gtkwidget#GtkWidgetClass) *widget_class`*,
*`guint index_`*,
*`GType *owner`*,
*`const char **action_name`*,
*`const GVariantType **parameter_type`*,
*`const char **property_name`*);
```
Queries the actions that have been installed for a widget class using [`gtk_widget_class_install_action()`](gtkwidget#gtk-widget-class-install-action) during class initialization.
Note that this function will also return actions defined by parent classes. You can identify those by looking at *`owner`* .
#### Parameters
| | | |
| --- | --- | --- |
| widget\_class | a [GtkWidgetClass](gtkwidget#GtkWidgetClass) | |
| index\_ | position of the action to query | |
| owner | return location for the type where the action was defined. | [out] |
| action\_name | return location for the action name. | [out] |
| parameter\_type | return location for the parameter type. | [out] |
| property\_name | return location for the property name. | [out] |
#### Returns
`TRUE` if the action was found, `FALSE` if *`index_`* is out of range
### gtk\_widget\_action\_set\_enabled ()
```
void
gtk_widget_action_set_enabled (*`[GtkWidget](gtkwidget#GtkWidget-struct) *widget`*,
*`const char *action_name`*,
*`gboolean enabled`*);
```
Enable or disable an action installed with [`gtk_widget_class_install_action()`](gtkwidget#gtk-widget-class-install-action).
#### Parameters
| | | |
| --- | --- | --- |
| widget | a [GtkWidget](gtkwidget#GtkWidget-struct) | |
| action\_name | action name, such as "clipboard.paste" | |
| enabled | whether the action is now enabled | |
Types and Values
----------------
### GtkWidget
```
typedef struct _GtkWidget GtkWidget;
```
### struct GtkWidgetClass
```
struct GtkWidgetClass {
GInitiallyUnownedClass parent_class;
/* basics */
void (* show) (GtkWidget *widget);
void (* hide) (GtkWidget *widget);
void (* map) (GtkWidget *widget);
void (* unmap) (GtkWidget *widget);
void (* realize) (GtkWidget *widget);
void (* unrealize) (GtkWidget *widget);
void (* root) (GtkWidget *widget);
void (* unroot) (GtkWidget *widget);
void (* size_allocate) (GtkWidget *widget,
int width,
int height,
int baseline);
void (* state_flags_changed) (GtkWidget *widget,
GtkStateFlags previous_state_flags);
void (* direction_changed) (GtkWidget *widget,
GtkTextDirection previous_direction);
/* size requests */
GtkSizeRequestMode (* get_request_mode) (GtkWidget *widget);
void (* measure) (GtkWidget *widget,
GtkOrientation orientation,
int for_size,
int *minimum,
int *natural,
int *minimum_baseline,
int *natural_baseline);
/* Mnemonics */
gboolean (* mnemonic_activate) (GtkWidget *widget,
gboolean group_cycling);
/* explicit focus */
gboolean (* grab_focus) (GtkWidget *widget);
gboolean (* focus) (GtkWidget *widget,
GtkDirectionType direction);
void (* set_focus_child) (GtkWidget *widget,
GtkWidget *child);
/* keyboard navigation */
void (* move_focus) (GtkWidget *widget,
GtkDirectionType direction);
gboolean (* keynav_failed) (GtkWidget *widget,
GtkDirectionType direction);
gboolean (* query_tooltip) (GtkWidget *widget,
int x,
int y,
gboolean keyboard_tooltip,
GtkTooltip *tooltip);
void (* compute_expand) (GtkWidget *widget,
gboolean *hexpand_p,
gboolean *vexpand_p);
void (* css_changed) (GtkWidget *widget,
GtkCssStyleChange *change);
void (* system_setting_changed) (GtkWidget *widget,
GtkSystemSetting settings);
void (* snapshot) (GtkWidget *widget,
GtkSnapshot *snapshot);
gboolean (* contains) (GtkWidget *widget,
double x,
double y);
};
```
#### Members
| | | |
| --- | --- | --- |
| *`show`* () | Signal emitted when widget is shown | |
| *`hide`* () | Signal emitted when widget is hidden. | |
| *`map`* () | Signal emitted when widget is going to be mapped, that is when the widget is visible (which is controlled with [`gtk_widget_set_visible()`](gtkwidget#gtk-widget-set-visible)) and all its parents up to the toplevel widget are also visible. | |
| *`unmap`* () | Signal emitted when widget is going to be unmapped, which means that either it or any of its parents up to the toplevel widget have been set as hidden. | |
| *`realize`* () | Signal emitted when widget is associated with a [GdkSurface](https://developer-old.gnome.org/gtk4/html/GdkSurface.html#GdkSurface-struct), which means that [`gtk_widget_realize()`](gtkwidget#gtk-widget-realize) has been called or the widget has been mapped (that is, it is going to be drawn). | |
| *`unrealize`* () | Signal emitted when the GdkSurface associated with widget is destroyed, which means that [`gtk_widget_unrealize()`](gtkwidget#gtk-widget-unrealize) has been called or the widget has been unmapped (that is, it is going to be hidden). | |
| *`root`* () | Called when the widget gets added to a [GtkRoot](gtkroot#GtkRoot-struct) widget. Must chain up | |
| *`unroot`* () | Called when the widget is about to be removed from its [GtkRoot](gtkroot#GtkRoot-struct) widget. Must chain up | |
| *`size_allocate`* () | Called to set the allocation, if the widget does not have a layout manager. | |
| *`state_flags_changed`* () | Signal emitted when the widget state changes, see [`gtk_widget_get_state_flags()`](gtkwidget#gtk-widget-get-state-flags). | |
| *`direction_changed`* () | Signal emitted when the text direction of a widget changes. | |
| *`get_request_mode`* () | Called to get the request mode, if the widget does not have a layout manager. This allows a widget to tell its parent container whether it prefers to be allocated in [`GTK_SIZE_REQUEST_HEIGHT_FOR_WIDTH`](gtkwidget#GTK-SIZE-REQUEST-HEIGHT-FOR-WIDTH:CAPS) or [`GTK_SIZE_REQUEST_WIDTH_FOR_HEIGHT`](gtkwidget#GTK-SIZE-REQUEST-WIDTH-FOR-HEIGHT:CAPS) mode. [`GTK_SIZE_REQUEST_HEIGHT_FOR_WIDTH`](gtkwidget#GTK-SIZE-REQUEST-HEIGHT-FOR-WIDTH:CAPS) means the widget prefers to have [`GtkWidgetClass.measure()`](gtkwidget#GtkWidgetClass.measure) called first to get the default width (passing a for\_size of -1), then again to get the height for said default width. [`GTK_SIZE_REQUEST_CONSTANT_SIZE`](gtkwidget#GTK-SIZE-REQUEST-CONSTANT-SIZE:CAPS) disables any height-for-width or width-for-height geometry management for said widget and is the default return. It’s important to note that any widget which trades height-for-width or width-for-height must respond properly to a for\_size value >= -1 passed to [GtkWidgetClass.measure](gtkwidget#GtkWidgetClass.measure), for both possible orientations. | |
| *`measure`* () | Called to obtain the minimum and natural size of the widget, if the widget does not have a layout manager. Depending on the orientation parameter, the passed for\_size can be interpreted as width or height. A widget will never be allocated less than its minimum size. | |
| *`mnemonic_activate`* () | Activates the *`widget`* if *`group_cycling`* is `FALSE`, and just grabs the focus if *`group_cycling`* is `TRUE`. | |
| *`grab_focus`* () | Causes *`widget`* to have the keyboard focus for the [GtkWindow](gtkwindow#GtkWindow-struct) it’s inside. | |
| *`focus`* () | Vfunc for [`gtk_widget_child_focus()`](gtkwidget#gtk-widget-child-focus) | |
| *`set_focus_child`* () | Sets the focused child of a widget. Must chain up | |
| *`move_focus`* () | Signal emitted when a change of focus is requested | |
| *`keynav_failed`* () | Signal emitted if keyboard navigation fails. | |
| *`query_tooltip`* () | Signal emitted when “has-tooltip” is `TRUE` and the hover timeout has expired with the cursor hovering “above” widget; or emitted when widget got focus in keyboard mode. | |
| *`compute_expand`* () | Computes whether a container should give this widget extra space when possible. | |
| *`css_changed`* () | Vfunc called when the CSS used by widget was changed. Widgets should then discard their caches that depend on CSS and queue resizes or redraws accordingly. The default implementation will take care of this for all the default CSS properties, so implementations must chain up. | |
| *`system_setting_changed`* () | Emitted when a system setting was changed. Must chain up. | |
| *`snapshot`* () | Vfunc called when a new snapshot of the widget has to be taken. | |
| *`contains`* () | Vfunc for [`gtk_widget_contains()`](gtkwidget#gtk-widget-contains). | |
### GtkRequisition
```
typedef struct {
int width;
int height;
} GtkRequisition;
```
A GtkRequisition represents the desired size of a widget. See GtkWidget’s geometry management section for more information.
#### Members
| | | |
| --- | --- | --- |
| int *`width`*; | the widget’s desired width | |
| int *`height`*; | the widget’s desired height | |
### GtkAllocation
```
typedef GdkRectangle GtkAllocation;
```
A GtkAllocation of a widget represents region which has been allocated to the widget by its parent. It is a subregion of its parents allocation. See GtkWidget’s geometry management section for more information.
### enum GtkTextDirection
Reading directions for text.
#### Members
| | | |
| --- | --- | --- |
| GTK\_TEXT\_DIR\_NONE | No direction. | |
| GTK\_TEXT\_DIR\_LTR | Left to right text direction. | |
| GTK\_TEXT\_DIR\_RTL | Right to left text direction. | |
### enum GtkPickFlags
Flags that influence the behavior of [`gtk_widget_pick()`](gtkwidget#gtk-widget-pick)
#### Members
| | | |
| --- | --- | --- |
| GTK\_PICK\_DEFAULT | The default behavior, include widgets that are receiving events | |
| GTK\_PICK\_INSENSITIVE | Include widgets that are insensitive | |
| GTK\_PICK\_NON\_TARGETABLE | Include widgets that are marked as non-targetable. See [“can-target”](gtkwidget#GtkWidget--can-target) | |
### enum GtkOverflow
Defines how content overflowing a given area should be handled, such as with [`gtk_widget_set_overflow()`](gtkwidget#gtk-widget-set-overflow). This property is modeled after the CSS overflow property, but implements it only partially.
#### Members
| | | |
| --- | --- | --- |
| GTK\_OVERFLOW\_VISIBLE | No change is applied. Content is drawn at the specified position. | |
| GTK\_OVERFLOW\_HIDDEN | Content is clipped to the bounds of the area. Content outside the area is not drawn and cannot be interacted with. | |
### enum GtkSizeRequestMode
Specifies a preference for height-for-width or width-for-height geometry management.
#### Members
| | | |
| --- | --- | --- |
| GTK\_SIZE\_REQUEST\_HEIGHT\_FOR\_WIDTH | Prefer height-for-width geometry management | |
| GTK\_SIZE\_REQUEST\_WIDTH\_FOR\_HEIGHT | Prefer width-for-height geometry management | |
| GTK\_SIZE\_REQUEST\_CONSTANT\_SIZE | Don’t trade height-for-width or width-for-height | |
### struct GtkRequestedSize
```
struct GtkRequestedSize {
gpointer data;
int minimum_size;
int natural_size;
};
```
Represents a request of a screen object in a given orientation. These are primarily used in container implementations when allocating a natural size for children calling. See [`gtk_distribute_natural_allocation()`](gtkwidget#gtk-distribute-natural-allocation).
#### Members
| | | |
| --- | --- | --- |
| gpointer *`data`*; | A client pointer | |
| int *`minimum_size`*; | The minimum size needed for allocation in a given orientation | |
| int *`natural_size`*; | The natural size for allocation in a given orientation | |
### enum GtkAlign
Controls how a widget deals with extra space in a single (x or y) dimension.
Alignment only matters if the widget receives a “too large” allocation, for example if you packed the widget with the [“hexpand”](gtkwidget#GtkWidget--hexpand) property inside a [GtkBox](gtkbox#GtkBox-struct), then the widget might get extra space. If you have for example a 16x16 icon inside a 32x32 space, the icon could be scaled and stretched, it could be centered, or it could be positioned to one side of the space.
Note that in horizontal context [`GTK_ALIGN_START`](gtkwidget#GTK-ALIGN-START:CAPS) and [`GTK_ALIGN_END`](gtkwidget#GTK-ALIGN-END:CAPS) are interpreted relative to text direction.
[`GTK_ALIGN_BASELINE`](gtkwidget#GTK-ALIGN-BASELINE:CAPS) support is optional for containers and widgets, and it is only supported for vertical alignment. When it's not supported by a child or a container it is treated as [`GTK_ALIGN_FILL`](gtkwidget#GTK-ALIGN-FILL:CAPS).
#### Members
| | | |
| --- | --- | --- |
| GTK\_ALIGN\_FILL | stretch to fill all space if possible, center if no meaningful way to stretch | |
| GTK\_ALIGN\_START | snap to left or top side, leaving space on right or bottom | |
| GTK\_ALIGN\_END | snap to right or bottom side, leaving space on left or top | |
| GTK\_ALIGN\_CENTER | center natural width of widget inside the allocation | |
| GTK\_ALIGN\_BASELINE | align the widget according to the baseline. See [GtkWidget](gtkwidget#GtkWidget-struct) | |
Property Details
----------------
### The `“can-focus”` property
```
“can-focus” gboolean
```
Whether the widget or any of its descendents can accept the input focus.
This property is meant to be set by widget implementations, typically in their instance init function.
Owner: GtkWidget
Flags: Read / Write
Default value: TRUE
### The `“can-target”` property
```
“can-target” gboolean
```
Whether the widget can receive pointer events.
Owner: GtkWidget
Flags: Read / Write
Default value: TRUE
### The `“css-classes”` property
```
“css-classes” GStrv
```
A list of css classes applied to this widget.
Owner: GtkWidget
Flags: Read / Write
### The `“css-name”` property
```
“css-name” char *
```
The name of this widget in the CSS tree.
This property is meant to be set by widget implementations, typically in their instance init function.
Owner: GtkWidget
Flags: Read / Write / Construct Only
Default value: NULL
### The `“cursor”` property
```
“cursor” [GdkCursor](https://developer-old.gnome.org/gtk4/html/gdk4-Cursors.html#GdkCursor-struct) *
```
The cursor used by *`widget`* . See [`gtk_widget_set_cursor()`](gtkwidget#gtk-widget-set-cursor) for details.
Owner: GtkWidget
Flags: Read / Write
### The `“focus-on-click”` property
```
“focus-on-click” gboolean
```
Whether the widget should grab focus when it is clicked with the mouse.
This property is only relevant for widgets that can take focus.
Owner: GtkWidget
Flags: Read / Write
Default value: TRUE
### The `“focusable”` property
```
“focusable” gboolean
```
Whether this widget itself will accept the input focus.
Owner: GtkWidget
Flags: Read / Write
Default value: FALSE
### The `“halign”` property
```
“halign” [GtkAlign](gtkwidget#GtkAlign)
```
How to distribute horizontal space if widget gets extra space, see [GtkAlign](gtkwidget#GtkAlign)
Owner: GtkWidget
Flags: Read / Write
Default value: GTK\_ALIGN\_FILL
### The `“has-default”` property
```
“has-default” gboolean
```
Whether the widget is the default widget.
Owner: GtkWidget
Flags: Read
Default value: FALSE
### The `“has-focus”` property
```
“has-focus” gboolean
```
Whether the widget has the input focus.
Owner: GtkWidget
Flags: Read
Default value: FALSE
### The `“has-tooltip”` property
```
“has-tooltip” gboolean
```
Enables or disables the emission of [“query-tooltip”](gtkwidget#GtkWidget-query-tooltip) on *`widget`* . A value of `TRUE` indicates that *`widget`* can have a tooltip, in this case the widget will be queried using [“query-tooltip”](gtkwidget#GtkWidget-query-tooltip) to determine whether it will provide a tooltip or not.
Owner: GtkWidget
Flags: Read / Write
Default value: FALSE
### The `“height-request”` property
```
“height-request” int
```
Override for height request of the widget, or -1 if natural request should be used.
Owner: GtkWidget
Flags: Read / Write
Allowed values: >= -1
Default value: -1
### The `“hexpand”` property
```
“hexpand” gboolean
```
Whether to expand horizontally. See [`gtk_widget_set_hexpand()`](gtkwidget#gtk-widget-set-hexpand).
Owner: GtkWidget
Flags: Read / Write
Default value: FALSE
### The `“hexpand-set”` property
```
“hexpand-set” gboolean
```
Whether to use the [“hexpand”](gtkwidget#GtkWidget--hexpand) property. See [`gtk_widget_get_hexpand_set()`](gtkwidget#gtk-widget-get-hexpand-set).
Owner: GtkWidget
Flags: Read / Write
Default value: FALSE
### The `“layout-manager”` property
```
“layout-manager” [GtkLayoutManager](gtklayoutmanager#GtkLayoutManager-struct) *
```
The [GtkLayoutManager](gtklayoutmanager#GtkLayoutManager-struct) instance to use to compute the preferred size of the widget, and allocate its children.
This property is meant to be set by widget implementations, typically in their instance init function.
Owner: GtkWidget
Flags: Read / Write
### The `“margin-bottom”` property
```
“margin-bottom” int
```
Margin on bottom side of widget.
This property adds margin outside of the widget's normal size request, the margin will be added in addition to the size from [`gtk_widget_set_size_request()`](gtkwidget#gtk-widget-set-size-request) for example.
Owner: GtkWidget
Flags: Read / Write
Allowed values: [0,32767]
Default value: 0
### The `“margin-end”` property
```
“margin-end” int
```
Margin on end of widget, horizontally. This property supports left-to-right and right-to-left text directions.
This property adds margin outside of the widget's normal size request, the margin will be added in addition to the size from [`gtk_widget_set_size_request()`](gtkwidget#gtk-widget-set-size-request) for example.
Owner: GtkWidget
Flags: Read / Write
Allowed values: [0,32767]
Default value: 0
### The `“margin-start”` property
```
“margin-start” int
```
Margin on start of widget, horizontally. This property supports left-to-right and right-to-left text directions.
This property adds margin outside of the widget's normal size request, the margin will be added in addition to the size from [`gtk_widget_set_size_request()`](gtkwidget#gtk-widget-set-size-request) for example.
Owner: GtkWidget
Flags: Read / Write
Allowed values: [0,32767]
Default value: 0
### The `“margin-top”` property
```
“margin-top” int
```
Margin on top side of widget.
This property adds margin outside of the widget's normal size request, the margin will be added in addition to the size from [`gtk_widget_set_size_request()`](gtkwidget#gtk-widget-set-size-request) for example.
Owner: GtkWidget
Flags: Read / Write
Allowed values: [0,32767]
Default value: 0
### The `“name”` property
```
“name” char *
```
The name of the widget.
Owner: GtkWidget
Flags: Read / Write
Default value: NULL
### The `“opacity”` property
```
“opacity” double
```
The requested opacity of the widget. See [`gtk_widget_set_opacity()`](gtkwidget#gtk-widget-set-opacity) for more details about window opacity.
Owner: GtkWidget
Flags: Read / Write
Allowed values: [0,1]
Default value: 1
### The `“overflow”` property
```
“overflow” [GtkOverflow](gtkwidget#GtkOverflow)
```
How content outside the widget's content area is treated.
This property is meant to be set by widget implementations, typically in their instance init function.
Owner: GtkWidget
Flags: Read / Write
Default value: GTK\_OVERFLOW\_VISIBLE
### The `“parent”` property
```
“parent” [GtkWidget](gtkwidget#GtkWidget-struct) *
```
The parent widget of this widget.
Owner: GtkWidget
Flags: Read
### The `“receives-default”` property
```
“receives-default” gboolean
```
If TRUE, the widget will receive the default action when it is focused.
Owner: GtkWidget
Flags: Read / Write
Default value: FALSE
### The `“root”` property
```
“root” [GtkRoot](gtkroot#GtkRoot-struct) *
```
The [GtkRoot](gtkroot#GtkRoot-struct) widget of the widget tree containing this widget or `NULL` if the widget is not contained in a root widget.
Owner: GtkWidget
Flags: Read
### The `“scale-factor”` property
```
“scale-factor” int
```
The scale factor of the widget. See [`gtk_widget_get_scale_factor()`](gtkwidget#gtk-widget-get-scale-factor) for more details about widget scaling.
Owner: GtkWidget
Flags: Read
Allowed values: >= 1
Default value: 1
### The `“sensitive”` property
```
“sensitive” gboolean
```
Whether the widget responds to input.
Owner: GtkWidget
Flags: Read / Write
Default value: TRUE
### The `“tooltip-markup”` property
```
“tooltip-markup” char *
```
Sets the text of tooltip to be the given string, which is marked up with the Pango text markup language. Also see [`gtk_tooltip_set_markup()`](gtktooltip#gtk-tooltip-set-markup).
This is a convenience property which will take care of getting the tooltip shown if the given string is not `NULL`: [“has-tooltip”](gtkwidget#GtkWidget--has-tooltip) will automatically be set to `TRUE` and there will be taken care of [“query-tooltip”](gtkwidget#GtkWidget-query-tooltip) in the default signal handler.
Note that if both [“tooltip-text”](gtkwidget#GtkWidget--tooltip-text) and [“tooltip-markup”](gtkwidget#GtkWidget--tooltip-markup) are set, the last one wins.
Owner: GtkWidget
Flags: Read / Write
Default value: NULL
### The `“tooltip-text”` property
```
“tooltip-text” char *
```
Sets the text of tooltip to be the given string.
Also see [`gtk_tooltip_set_text()`](gtktooltip#gtk-tooltip-set-text).
This is a convenience property which will take care of getting the tooltip shown if the given string is not `NULL`: [“has-tooltip”](gtkwidget#GtkWidget--has-tooltip) will automatically be set to `TRUE` and there will be taken care of [“query-tooltip”](gtkwidget#GtkWidget-query-tooltip) in the default signal handler.
Note that if both [“tooltip-text”](gtkwidget#GtkWidget--tooltip-text) and [“tooltip-markup”](gtkwidget#GtkWidget--tooltip-markup) are set, the last one wins.
Owner: GtkWidget
Flags: Read / Write
Default value: NULL
### The `“valign”` property
```
“valign” [GtkAlign](gtkwidget#GtkAlign)
```
How to distribute vertical space if widget gets extra space, see [GtkAlign](gtkwidget#GtkAlign)
Owner: GtkWidget
Flags: Read / Write
Default value: GTK\_ALIGN\_FILL
### The `“vexpand”` property
```
“vexpand” gboolean
```
Whether to expand vertically. See [`gtk_widget_set_vexpand()`](gtkwidget#gtk-widget-set-vexpand).
Owner: GtkWidget
Flags: Read / Write
Default value: FALSE
### The `“vexpand-set”` property
```
“vexpand-set” gboolean
```
Whether to use the [“vexpand”](gtkwidget#GtkWidget--vexpand) property. See [`gtk_widget_get_vexpand_set()`](gtkwidget#gtk-widget-get-vexpand-set).
Owner: GtkWidget
Flags: Read / Write
Default value: FALSE
### The `“visible”` property
```
“visible” gboolean
```
Whether the widget is visible.
Owner: GtkWidget
Flags: Read / Write
Default value: TRUE
### The `“width-request”` property
```
“width-request” int
```
Override for width request of the widget, or -1 if natural request should be used.
Owner: GtkWidget
Flags: Read / Write
Allowed values: >= -1
Default value: -1
Signal Details
--------------
### The `“destroy”` signal
```
void
user_function ([GtkWidget](gtkwidget#GtkWidget-struct) *object,
gpointer user_data)
```
Signals that all holders of a reference to the widget should release the reference that they hold. May result in finalization of the widget if all references are released.
This signal is not suitable for saving widget state.
#### Parameters
| | | |
| --- | --- | --- |
| object | the object which received the signal | |
| user\_data | user data set when the signal handler was connected. | |
Flags: No Hooks
### The `“direction-changed”` signal
```
void
user_function ([GtkWidget](gtkwidget#GtkWidget-struct) *widget,
[GtkTextDirection](gtkwidget#GtkTextDirection) previous_direction,
gpointer user_data)
```
The ::direction-changed signal is emitted when the text direction of a widget changes.
#### Parameters
| | | |
| --- | --- | --- |
| widget | the object on which the signal is emitted | |
| previous\_direction | the previous text direction of *`widget`* | |
| user\_data | user data set when the signal handler was connected. | |
Flags: Run First
### The `“hide”` signal
```
void
user_function ([GtkWidget](gtkwidget#GtkWidget-struct) *widget,
gpointer user_data)
```
The ::hide signal is emitted when *`widget`* is hidden, for example with [`gtk_widget_hide()`](gtkwidget#gtk-widget-hide).
#### Parameters
| | | |
| --- | --- | --- |
| widget | the object which received the signal. | |
| user\_data | user data set when the signal handler was connected. | |
Flags: Run First
### The `“keynav-failed”` signal
```
gboolean
user_function ([GtkWidget](gtkwidget#GtkWidget-struct) *widget,
[GtkDirectionType](gtk4-standard-enumerations#GtkDirectionType) direction,
gpointer user_data)
```
Gets emitted if keyboard navigation fails. See [`gtk_widget_keynav_failed()`](gtkwidget#gtk-widget-keynav-failed) for details.
#### Parameters
| | | |
| --- | --- | --- |
| widget | the object which received the signal | |
| direction | the direction of movement | |
| user\_data | user data set when the signal handler was connected. | |
#### Returns
`TRUE` if stopping keyboard navigation is fine, `FALSE` if the emitting widget should try to handle the keyboard navigation attempt in its parent widget(s).
Flags: Run Last
### The `“map”` signal
```
void
user_function ([GtkWidget](gtkwidget#GtkWidget-struct) *widget,
gpointer user_data)
```
The ::map signal is emitted when *`widget`* is going to be mapped, that is when the widget is visible (which is controlled with [`gtk_widget_set_visible()`](gtkwidget#gtk-widget-set-visible)) and all its parents up to the toplevel widget are also visible.
The ::map signal can be used to determine whether a widget will be drawn, for instance it can resume an animation that was stopped during the emission of [“unmap”](gtkwidget#GtkWidget-unmap).
#### Parameters
| | | |
| --- | --- | --- |
| widget | the object which received the signal. | |
| user\_data | user data set when the signal handler was connected. | |
Flags: Run First
### The `“mnemonic-activate”` signal
```
gboolean
user_function ([GtkWidget](gtkwidget#GtkWidget-struct) *widget,
gboolean group_cycling,
gpointer user_data)
```
The default handler for this signal activates *`widget`* if *`group_cycling`* is `FALSE`, or just makes *`widget`* grab focus if *`group_cycling`* is `TRUE`.
#### Parameters
| | | |
| --- | --- | --- |
| widget | the object which received the signal. | |
| group\_cycling | `TRUE` if there are other widgets with the same mnemonic | |
| user\_data | user data set when the signal handler was connected. | |
#### Returns
`TRUE` to stop other handlers from being invoked for the event. `FALSE` to propagate the event further.
Flags: Run Last
### The `“move-focus”` signal
```
void
user_function ([GtkWidget](gtkwidget#GtkWidget-struct) *widget,
[GtkDirectionType](gtk4-standard-enumerations#GtkDirectionType) direction,
gpointer user_data)
```
Emitted when the focus is moved.
#### Parameters
| | | |
| --- | --- | --- |
| widget | the object which received the signal. | |
| direction | the direction of the focus move | |
| user\_data | user data set when the signal handler was connected. | |
Flags: Action
### The `“query-tooltip”` signal
```
gboolean
user_function ([GtkWidget](gtkwidget#GtkWidget-struct) *widget,
int x,
int y,
gboolean keyboard_mode,
[GtkTooltip](gtktooltip#GtkTooltip-struct) *tooltip,
gpointer user_data)
```
Emitted when [“has-tooltip”](gtkwidget#GtkWidget--has-tooltip) is `TRUE` and the hover timeout has expired with the cursor hovering "above" *`widget`* ; or emitted when *`widget`* got focus in keyboard mode.
Using the given coordinates, the signal handler should determine whether a tooltip should be shown for *`widget`* . If this is the case `TRUE` should be returned, `FALSE` otherwise. Note that if *`keyboard_mode`* is `TRUE`, the values of *`x`* and *`y`* are undefined and should not be used.
The signal handler is free to manipulate *`tooltip`* with the therefore destined function calls.
#### Parameters
| | | |
| --- | --- | --- |
| widget | the object which received the signal | |
| x | the x coordinate of the cursor position where the request has been emitted, relative to *`widget`* 's left side | |
| y | the y coordinate of the cursor position where the request has been emitted, relative to *`widget`* 's top | |
| keyboard\_mode | `TRUE` if the tooltip was triggered using the keyboard | |
| tooltip | a [GtkTooltip](gtktooltip#GtkTooltip-struct) | |
| user\_data | user data set when the signal handler was connected. | |
#### Returns
`TRUE` if *`tooltip`* should be shown right now, `FALSE` otherwise.
Flags: Run Last
### The `“realize”` signal
```
void
user_function ([GtkWidget](gtkwidget#GtkWidget-struct) *widget,
gpointer user_data)
```
The ::realize signal is emitted when *`widget`* is associated with a [GdkSurface](https://developer-old.gnome.org/gtk4/html/GdkSurface.html#GdkSurface-struct), which means that [`gtk_widget_realize()`](gtkwidget#gtk-widget-realize) has been called or the widget has been mapped (that is, it is going to be drawn).
#### Parameters
| | | |
| --- | --- | --- |
| widget | the object which received the signal. | |
| user\_data | user data set when the signal handler was connected. | |
Flags: Run First
### The `“show”` signal
```
void
user_function ([GtkWidget](gtkwidget#GtkWidget-struct) *widget,
gpointer user_data)
```
The ::show signal is emitted when *`widget`* is shown, for example with [`gtk_widget_show()`](gtkwidget#gtk-widget-show).
#### Parameters
| | | |
| --- | --- | --- |
| widget | the object which received the signal. | |
| user\_data | user data set when the signal handler was connected. | |
Flags: Run First
### The `“state-flags-changed”` signal
```
void
user_function ([GtkWidget](gtkwidget#GtkWidget-struct) *widget,
[GtkStateFlags](gtk4-standard-enumerations#GtkStateFlags) flags,
gpointer user_data)
```
The ::state-flags-changed signal is emitted when the widget state changes, see [`gtk_widget_get_state_flags()`](gtkwidget#gtk-widget-get-state-flags).
#### Parameters
| | | |
| --- | --- | --- |
| widget | the object which received the signal. | |
| flags | The previous state flags. | |
| user\_data | user data set when the signal handler was connected. | |
Flags: Run First
### The `“unmap”` signal
```
void
user_function ([GtkWidget](gtkwidget#GtkWidget-struct) *widget,
gpointer user_data)
```
The ::unmap signal is emitted when *`widget`* is going to be unmapped, which means that either it or any of its parents up to the toplevel widget have been set as hidden.
As ::unmap indicates that a widget will not be shown any longer, it can be used to, for example, stop an animation on the widget.
#### Parameters
| | | |
| --- | --- | --- |
| widget | the object which received the signal. | |
| user\_data | user data set when the signal handler was connected. | |
Flags: Run First
### The `“unrealize”` signal
```
void
user_function ([GtkWidget](gtkwidget#GtkWidget-struct) *widget,
gpointer user_data)
```
The ::unrealize signal is emitted when the [GdkSurface](https://developer-old.gnome.org/gtk4/html/GdkSurface.html#GdkSurface-struct) associated with *`widget`* is destroyed, which means that [`gtk_widget_unrealize()`](gtkwidget#gtk-widget-unrealize) has been called or the widget has been unmapped (that is, it is going to be hidden).
#### Parameters
| | | |
| --- | --- | --- |
| widget | the object which received the signal. | |
| user\_data | user data set when the signal handler was connected. | |
Flags: Run Last
| programming_docs |
gtk GtkCustomLayout GtkCustomLayout
===============
GtkCustomLayout — A convenience layout manager
Functions
---------
| | |
| --- | --- |
| [GtkSizeRequestMode](gtkwidget#GtkSizeRequestMode) | ([\*GtkCustomRequestModeFunc](gtkcustomlayout#GtkCustomRequestModeFunc)) () |
| void | ([\*GtkCustomMeasureFunc](gtkcustomlayout#GtkCustomMeasureFunc)) () |
| void | ([\*GtkCustomAllocateFunc](gtkcustomlayout#GtkCustomAllocateFunc)) () |
| [GtkLayoutManager](gtklayoutmanager#GtkLayoutManager-struct) \* | [gtk\_custom\_layout\_new](gtkcustomlayout#gtk-custom-layout-new) () |
Types and Values
----------------
| | |
| --- | --- |
| | [GtkCustomLayout](gtkcustomlayout#GtkCustomLayout-struct) |
Object Hierarchy
----------------
```
GObject
╰── [GtkLayoutManager](gtklayoutmanager#GtkLayoutManager-struct)
╰── GtkCustomLayout
```
Includes
--------
```
#include <gtk/gtk.h>
```
Description
-----------
[GtkCustomLayout](https://developer-old.gnome.org/usr/share/gtk-doc/html/gtk4/gtk4-GtkCustomLayout.html#GtkCustomLayout) is a convenience type meant to be used as a transition mechanism between [GtkWidgets](gtkwidget#GtkWidget-struct) implementing a layout policy, and [GtkLayoutManager](gtklayoutmanager#GtkLayoutManager-struct) classes.
A [GtkCustomLayout](https://developer-old.gnome.org/usr/share/gtk-doc/html/gtk4/gtk4-GtkCustomLayout.html#GtkCustomLayout) uses closures matching to the old [GtkWidget](gtkwidget#GtkWidget-struct) virtual functions for size negotiation, as a convenience API to ease the porting towards the corresponding [GtkLayoutManager](gtklayoutmanager#GtkLayoutManager-struct) virtual functions.
Functions
---------
### GtkCustomRequestModeFunc ()
```
[GtkSizeRequestMode](gtkwidget#GtkSizeRequestMode)
(*GtkCustomRequestModeFunc) (*`[GtkWidget](gtkwidget#GtkWidget-struct) *widget`*);
```
Queries a widget for its preferred size request mode.
#### Parameters
| | | |
| --- | --- | --- |
| widget | the widget to be queried | |
#### Returns
the size request mode
### GtkCustomMeasureFunc ()
```
void
(*GtkCustomMeasureFunc) (*`[GtkWidget](gtkwidget#GtkWidget-struct) *widget`*,
*`[GtkOrientation](gtk4-standard-enumerations#GtkOrientation) orientation`*,
*`int for_size`*,
*`int *minimum`*,
*`int *natural`*,
*`int *minimum_baseline`*,
*`int *natural_baseline`*);
```
A function to be used by [GtkCustomLayout](https://developer-old.gnome.org/usr/share/gtk-doc/html/gtk4/gtk4-GtkCustomLayout.html#GtkCustomLayout) to measure a widget.
#### Parameters
| | | |
| --- | --- | --- |
| widget | the widget to be measured | |
| orientation | the direction to be measured | |
| for\_size | the size to be measured for | |
| minimum | the measured minimum size of the widget. | [out] |
| natural | the measured natural size of the widget. | [out] |
| minimum\_baseline | the measured minimum baseline of the widget. | [out] |
| natural\_baseline | the measured natural baseline of the widget. | [out] |
### GtkCustomAllocateFunc ()
```
void
(*GtkCustomAllocateFunc) (*`[GtkWidget](gtkwidget#GtkWidget-struct) *widget`*,
*`int width`*,
*`int height`*,
*`int baseline`*);
```
A function to be used by [GtkCustomLayout](https://developer-old.gnome.org/usr/share/gtk-doc/html/gtk4/gtk4-GtkCustomLayout.html#GtkCustomLayout) to allocate a widget.
#### Parameters
| | | |
| --- | --- | --- |
| widget | the widget to allocate | |
| width | the new width of the widget | |
| height | the new height of the widget | |
| baseline | the new baseline of the widget, or -1 | |
### gtk\_custom\_layout\_new ()
```
[GtkLayoutManager](gtklayoutmanager#GtkLayoutManager-struct) *
gtk_custom_layout_new (*`[GtkCustomRequestModeFunc](gtkcustomlayout#GtkCustomRequestModeFunc) request_mode`*,
*`[GtkCustomMeasureFunc](gtkcustomlayout#GtkCustomMeasureFunc) measure`*,
*`[GtkCustomAllocateFunc](gtkcustomlayout#GtkCustomAllocateFunc) allocate`*);
```
Creates a new legacy layout manager.
Legacy layout managers map to the old [GtkWidget](gtkwidget#GtkWidget-struct) size negotiation virtual functions, and are meant to be used during the transition from layout containers to layout manager delegates.
#### Parameters
| | | |
| --- | --- | --- |
| request\_mode | a function to retrieve the [GtkSizeRequestMode](gtkwidget#GtkSizeRequestMode) of the widget using the layout; the default request mode is [`GTK_SIZE_REQUEST_CONSTANT_SIZE`](gtkwidget#GTK-SIZE-REQUEST-CONSTANT-SIZE:CAPS). | [nullable][scope call] |
| measure | a function to measure the widget using the layout manager. | [not nullable][scope call] |
| allocate | a function to allocate the children of the widget using the layout manager. | [not nullable][scope call] |
#### Returns
the newly created [GtkCustomLayout](https://developer-old.gnome.org/usr/share/gtk-doc/html/gtk4/gtk4-GtkCustomLayout.html#GtkCustomLayout).
[transfer full]
Types and Values
----------------
### GtkCustomLayout
```
typedef struct _GtkCustomLayout GtkCustomLayout;
```
gtk GtkTreeModelSort GtkTreeModelSort
================
GtkTreeModelSort — A GtkTreeModel which makes an underlying tree model sortable
Functions
---------
| | |
| --- | --- |
| [GtkTreeModel](gtktreemodel#GtkTreeModel-struct) \* | [gtk\_tree\_model\_sort\_new\_with\_model](gtktreemodelsort#gtk-tree-model-sort-new-with-model) () |
| [GtkTreeModel](gtktreemodel#GtkTreeModel-struct) \* | [gtk\_tree\_model\_sort\_get\_model](gtktreemodelsort#gtk-tree-model-sort-get-model) () |
| [GtkTreePath](gtktreemodel#GtkTreePath-struct) \* | [gtk\_tree\_model\_sort\_convert\_child\_path\_to\_path](gtktreemodelsort#gtk-tree-model-sort-convert-child-path-to-path) () |
| gboolean | [gtk\_tree\_model\_sort\_convert\_child\_iter\_to\_iter](gtktreemodelsort#gtk-tree-model-sort-convert-child-iter-to-iter) () |
| [GtkTreePath](gtktreemodel#GtkTreePath-struct) \* | [gtk\_tree\_model\_sort\_convert\_path\_to\_child\_path](gtktreemodelsort#gtk-tree-model-sort-convert-path-to-child-path) () |
| void | [gtk\_tree\_model\_sort\_convert\_iter\_to\_child\_iter](gtktreemodelsort#gtk-tree-model-sort-convert-iter-to-child-iter) () |
| void | [gtk\_tree\_model\_sort\_reset\_default\_sort\_func](gtktreemodelsort#gtk-tree-model-sort-reset-default-sort-func) () |
| void | [gtk\_tree\_model\_sort\_clear\_cache](gtktreemodelsort#gtk-tree-model-sort-clear-cache) () |
| gboolean | [gtk\_tree\_model\_sort\_iter\_is\_valid](gtktreemodelsort#gtk-tree-model-sort-iter-is-valid) () |
Properties
----------
| | | |
| --- | --- | --- |
| [GtkTreeModel](gtktreemodel#GtkTreeModel-struct) \* | [model](gtktreemodelsort#GtkTreeModelSort--model) | Read / Write / Construct Only |
Types and Values
----------------
| | |
| --- | --- |
| struct | [GtkTreeModelSort](gtktreemodelsort#GtkTreeModelSort-struct) |
Object Hierarchy
----------------
```
GObject
╰── GtkTreeModelSort
```
Implemented Interfaces
----------------------
GtkTreeModelSort implements [GtkTreeModel](gtktreemodel#GtkTreeModel-struct), [GtkTreeSortable](gtktreesortable#GtkTreeSortable-struct) and [GtkTreeDragSource](gtk4-gtktreeview-drag-and-drop#GtkTreeDragSource-struct).
Includes
--------
```
#include <gtk/gtk.h>
```
Description
-----------
The [GtkTreeModelSort](gtktreemodelsort#GtkTreeModelSort-struct) is a model which implements the [GtkTreeSortable](gtktreesortable#GtkTreeSortable-struct) interface. It does not hold any data itself, but rather is created with a child model and proxies its data. It has identical column types to this child model, and the changes in the child are propagated. The primary purpose of this model is to provide a way to sort a different model without modifying it. Note that the sort function used by [GtkTreeModelSort](gtktreemodelsort#GtkTreeModelSort-struct) is not guaranteed to be stable.
The use of this is best demonstrated through an example. In the following sample code we create two [GtkTreeView](gtktreeview#GtkTreeView-struct) widgets each with a view of the same data. As the model is wrapped here by a [GtkTreeModelSort](gtktreemodelsort#GtkTreeModelSort-struct), the two [GtkTreeViews](gtktreeview#GtkTreeView-struct) can each sort their view of the data without affecting the other. By contrast, if we simply put the same model in each widget, then sorting the first would sort the second.
#### Using a [GtkTreeModelSort](gtktreemodelsort#GtkTreeModelSort-struct)
To demonstrate how to access the underlying child model from the sort model, the next example will be a callback for the [GtkTreeSelection](gtktreeselection#GtkTreeSelection-struct) [“changed”](gtktreeselection#GtkTreeSelection-changed) signal. In this callback, we get a string from COLUMN\_1 of the model. We then modify the string, find the same selected row on the child model, and change the row there.
#### Accessing the child model of in a selection changed callback
```
{
GtkTreeView *tree_view1;
GtkTreeView *tree_view2;
GtkTreeModel *sort_model1;
GtkTreeModel *sort_model2;
GtkTreeModel *child_model;
// get the child model
child_model = get_my_model ();
// Create the first tree
sort_model1 = gtk_tree_model_sort_new_with_model (child_model);
tree_view1 = gtk_tree_view_new_with_model (sort_model1);
// Create the second tree
sort_model2 = gtk_tree_model_sort_new_with_model (child_model);
tree_view2 = gtk_tree_view_new_with_model (sort_model2);
// Now we can sort the two models independently
gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (sort_model1),
COLUMN_1, GTK_SORT_ASCENDING);
gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (sort_model2),
COLUMN_1, GTK_SORT_DESCENDING);
}
```
| Functions
---------
### gtk\_tree\_model\_sort\_new\_with\_model ()
```
[GtkTreeModel](gtktreemodel#GtkTreeModel-struct) *
gtk_tree_model_sort_new_with_model (*`[GtkTreeModel](gtktreemodel#GtkTreeModel-struct) *child_model`*);
```
Creates a new [GtkTreeModelSort](gtktreemodelsort#GtkTreeModelSort-struct), with *`child_model`* as the child model.
[constructor]
#### Parameters
| | | |
| --- | --- | --- |
| child\_model | A [GtkTreeModel](gtktreemodel#GtkTreeModel-struct) | |
#### Returns
A new [GtkTreeModelSort](gtktreemodelsort#GtkTreeModelSort-struct).
[transfer full][type Gtk.TreeModelSort]
### gtk\_tree\_model\_sort\_get\_model ()
```
[GtkTreeModel](gtktreemodel#GtkTreeModel-struct) *
gtk_tree_model_sort_get_model (*`[GtkTreeModelSort](gtktreemodelsort#GtkTreeModelSort-struct) *tree_model`*);
```
Returns the model the [GtkTreeModelSort](gtktreemodelsort#GtkTreeModelSort-struct) is sorting.
#### Parameters
| | | |
| --- | --- | --- |
| tree\_model | a [GtkTreeModelSort](gtktreemodelsort#GtkTreeModelSort-struct) | |
#### Returns
the "child model" being sorted.
[transfer none]
### gtk\_tree\_model\_sort\_convert\_child\_path\_to\_path ()
```
[GtkTreePath](gtktreemodel#GtkTreePath-struct) *
gtk_tree_model_sort_convert_child_path_to_path
(*`[GtkTreeModelSort](gtktreemodelsort#GtkTreeModelSort-struct) *tree_model_sort`*,
*`[GtkTreePath](gtktreemodel#GtkTreePath-struct) *child_path`*);
```
Converts *`child_path`* to a path relative to *`tree_model_sort`* . That is, *`child_path`* points to a path in the child model. The returned path will point to the same row in the sorted model. If *`child_path`* isn’t a valid path on the child model, then `NULL` is returned.
#### Parameters
| | | |
| --- | --- | --- |
| tree\_model\_sort | A [GtkTreeModelSort](gtktreemodelsort#GtkTreeModelSort-struct) | |
| child\_path | A [GtkTreePath](gtktreemodel#GtkTreePath-struct) to convert | |
#### Returns
A newly allocated [GtkTreePath](gtktreemodel#GtkTreePath-struct), or `NULL`.
[nullable][transfer full]
### gtk\_tree\_model\_sort\_convert\_child\_iter\_to\_iter ()
```
gboolean
gtk_tree_model_sort_convert_child_iter_to_iter
(*`[GtkTreeModelSort](gtktreemodelsort#GtkTreeModelSort-struct) *tree_model_sort`*,
*`[GtkTreeIter](gtktreemodel#GtkTreeIter-struct) *sort_iter`*,
*`[GtkTreeIter](gtktreemodel#GtkTreeIter-struct) *child_iter`*);
```
Sets *`sort_iter`* to point to the row in *`tree_model_sort`* that corresponds to the row pointed at by *`child_iter`* . If *`sort_iter`* was not set, `FALSE` is returned. Note: a boolean is only returned since 2.14.
#### Parameters
| | | |
| --- | --- | --- |
| tree\_model\_sort | A [GtkTreeModelSort](gtktreemodelsort#GtkTreeModelSort-struct) | |
| sort\_iter | An uninitialized [GtkTreeIter](gtktreemodel#GtkTreeIter-struct). | [out] |
| child\_iter | A valid [GtkTreeIter](gtktreemodel#GtkTreeIter-struct) pointing to a row on the child model | |
#### Returns
`TRUE`, if *`sort_iter`* was set, i.e. if *`sort_iter`* is a valid iterator pointer to a visible row in the child model.
### gtk\_tree\_model\_sort\_convert\_path\_to\_child\_path ()
```
[GtkTreePath](gtktreemodel#GtkTreePath-struct) *
gtk_tree_model_sort_convert_path_to_child_path
(*`[GtkTreeModelSort](gtktreemodelsort#GtkTreeModelSort-struct) *tree_model_sort`*,
*`[GtkTreePath](gtktreemodel#GtkTreePath-struct) *sorted_path`*);
```
Converts *`sorted_path`* to a path on the child model of *`tree_model_sort`* . That is, *`sorted_path`* points to a location in *`tree_model_sort`* . The returned path will point to the same location in the model not being sorted. If *`sorted_path`* does not point to a location in the child model, `NULL` is returned.
#### Parameters
| | | |
| --- | --- | --- |
| tree\_model\_sort | A [GtkTreeModelSort](gtktreemodelsort#GtkTreeModelSort-struct) | |
| sorted\_path | A [GtkTreePath](gtktreemodel#GtkTreePath-struct) to convert | |
#### Returns
A newly allocated [GtkTreePath](gtktreemodel#GtkTreePath-struct), or `NULL`.
[nullable][transfer full]
### gtk\_tree\_model\_sort\_convert\_iter\_to\_child\_iter ()
```
void
gtk_tree_model_sort_convert_iter_to_child_iter
(*`[GtkTreeModelSort](gtktreemodelsort#GtkTreeModelSort-struct) *tree_model_sort`*,
*`[GtkTreeIter](gtktreemodel#GtkTreeIter-struct) *child_iter`*,
*`[GtkTreeIter](gtktreemodel#GtkTreeIter-struct) *sorted_iter`*);
```
Sets *`child_iter`* to point to the row pointed to by *`sorted_iter`* .
#### Parameters
| | | |
| --- | --- | --- |
| tree\_model\_sort | A [GtkTreeModelSort](gtktreemodelsort#GtkTreeModelSort-struct) | |
| child\_iter | An uninitialized [GtkTreeIter](gtktreemodel#GtkTreeIter-struct). | [out] |
| sorted\_iter | A valid [GtkTreeIter](gtktreemodel#GtkTreeIter-struct) pointing to a row on *`tree_model_sort`* . | |
### gtk\_tree\_model\_sort\_reset\_default\_sort\_func ()
```
void
gtk_tree_model_sort_reset_default_sort_func
(*`[GtkTreeModelSort](gtktreemodelsort#GtkTreeModelSort-struct) *tree_model_sort`*);
```
This resets the default sort function to be in the “unsorted” state. That is, it is in the same order as the child model. It will re-sort the model to be in the same order as the child model only if the [GtkTreeModelSort](gtktreemodelsort#GtkTreeModelSort-struct) is in “unsorted” state.
#### Parameters
| | | |
| --- | --- | --- |
| tree\_model\_sort | A [GtkTreeModelSort](gtktreemodelsort#GtkTreeModelSort-struct) | |
### gtk\_tree\_model\_sort\_clear\_cache ()
```
void
gtk_tree_model_sort_clear_cache (*`[GtkTreeModelSort](gtktreemodelsort#GtkTreeModelSort-struct) *tree_model_sort`*);
```
This function should almost never be called. It clears the *`tree_model_sort`* of any cached iterators that haven’t been reffed with [`gtk_tree_model_ref_node()`](gtktreemodel#gtk-tree-model-ref-node). This might be useful if the child model being sorted is static (and doesn’t change often) and there has been a lot of unreffed access to nodes. As a side effect of this function, all unreffed iters will be invalid.
#### Parameters
| | | |
| --- | --- | --- |
| tree\_model\_sort | A [GtkTreeModelSort](gtktreemodelsort#GtkTreeModelSort-struct) | |
### gtk\_tree\_model\_sort\_iter\_is\_valid ()
```
gboolean
gtk_tree_model_sort_iter_is_valid (*`[GtkTreeModelSort](gtktreemodelsort#GtkTreeModelSort-struct) *tree_model_sort`*,
*`[GtkTreeIter](gtktreemodel#GtkTreeIter-struct) *iter`*);
```
> This function is slow. Only use it for debugging and/or testing purposes.
>
>
Checks if the given iter is a valid iter for this [GtkTreeModelSort](gtktreemodelsort#GtkTreeModelSort-struct).
#### Parameters
| | | |
| --- | --- | --- |
| tree\_model\_sort | A [GtkTreeModelSort](gtktreemodelsort#GtkTreeModelSort-struct). | |
| iter | A [GtkTreeIter](gtktreemodel#GtkTreeIter-struct). | |
#### Returns
`TRUE` if the iter is valid, `FALSE` if the iter is invalid.
Types and Values
----------------
### struct GtkTreeModelSort
```
struct GtkTreeModelSort;
```
Property Details
----------------
### The `“model”` property
```
“model” [GtkTreeModel](gtktreemodel#GtkTreeModel-struct) *
```
The model for the TreeModelSort to sort.
Owner: GtkTreeModelSort
Flags: Read / Write / Construct Only
See Also
--------
[GtkTreeModel](gtktreemodel#GtkTreeModel-struct), [GtkListStore](gtkliststore#GtkListStore-struct), [GtkTreeStore](gtktreestore#GtkTreeStore-struct), [GtkTreeSortable](gtktreesortable#GtkTreeSortable-struct), [GtkTreeModelFilter](gtktreemodelfilter#GtkTreeModelFilter-struct)
gtk GtkSliceListModel GtkSliceListModel
=================
GtkSliceListModel — A list model that presents a slice out of a larger list
Functions
---------
| | |
| --- | --- |
| [GtkSliceListModel](gtkslicelistmodel#GtkSliceListModel-struct) \* | [gtk\_slice\_list\_model\_new](gtkslicelistmodel#gtk-slice-list-model-new) () |
| void | [gtk\_slice\_list\_model\_set\_model](gtkslicelistmodel#gtk-slice-list-model-set-model) () |
| GListModel \* | [gtk\_slice\_list\_model\_get\_model](gtkslicelistmodel#gtk-slice-list-model-get-model) () |
| void | [gtk\_slice\_list\_model\_set\_offset](gtkslicelistmodel#gtk-slice-list-model-set-offset) () |
| guint | [gtk\_slice\_list\_model\_get\_offset](gtkslicelistmodel#gtk-slice-list-model-get-offset) () |
| void | [gtk\_slice\_list\_model\_set\_size](gtkslicelistmodel#gtk-slice-list-model-set-size) () |
| guint | [gtk\_slice\_list\_model\_get\_size](gtkslicelistmodel#gtk-slice-list-model-get-size) () |
Properties
----------
| | | |
| --- | --- | --- |
| GListModel \* | [model](gtkslicelistmodel#GtkSliceListModel--model) | Read / Write |
| guint | [offset](gtkslicelistmodel#GtkSliceListModel--offset) | Read / Write |
| guint | [size](gtkslicelistmodel#GtkSliceListModel--size) | Read / Write |
Types and Values
----------------
| | |
| --- | --- |
| | [GtkSliceListModel](gtkslicelistmodel#GtkSliceListModel-struct) |
Object Hierarchy
----------------
```
GObject
╰── GtkSliceListModel
```
Implemented Interfaces
----------------------
GtkSliceListModel implements GListModel.
Includes
--------
```
#include <gtk/gtk.h>
```
Description
-----------
[GtkSliceListModel](gtkslicelistmodel#GtkSliceListModel-struct) is a list model that takes a list model and presents a slice of that model.
This is useful when implementing paging by setting the size to the number of elements per page and updating the offset whenever a different page is opened.
Functions
---------
### gtk\_slice\_list\_model\_new ()
```
[GtkSliceListModel](gtkslicelistmodel#GtkSliceListModel-struct) *
gtk_slice_list_model_new (*`GListModel *model`*,
*`guint offset`*,
*`guint size`*);
```
Creates a new slice model that presents the slice from *`offset`* to *`offset`* + *`size`* our of the given *`model`* .
#### Parameters
| | | |
| --- | --- | --- |
| model | The model to use, or `NULL`. | [transfer full][allow-none] |
| offset | the offset of the slice | |
| size | maximum size of the slice | |
#### Returns
A new [GtkSliceListModel](gtkslicelistmodel#GtkSliceListModel-struct)
### gtk\_slice\_list\_model\_set\_model ()
```
void
gtk_slice_list_model_set_model (*`[GtkSliceListModel](gtkslicelistmodel#GtkSliceListModel-struct) *self`*,
*`GListModel *model`*);
```
Sets the model to show a slice of. The model's item type must conform to *`self`* 's item type.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkSliceListModel](gtkslicelistmodel#GtkSliceListModel-struct) | |
| model | The model to be sliced. | [allow-none] |
### gtk\_slice\_list\_model\_get\_model ()
```
GListModel *
gtk_slice_list_model_get_model (*`[GtkSliceListModel](gtkslicelistmodel#GtkSliceListModel-struct) *self`*);
```
Gets the model that is currently being used or `NULL` if none.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkSliceListModel](gtkslicelistmodel#GtkSliceListModel-struct) | |
#### Returns
The model in use.
[nullable][transfer none]
### gtk\_slice\_list\_model\_set\_offset ()
```
void
gtk_slice_list_model_set_offset (*`[GtkSliceListModel](gtkslicelistmodel#GtkSliceListModel-struct) *self`*,
*`guint offset`*);
```
Sets the offset into the original model for this slice.
If the offset is too large for the sliced model, *`self`* will end up empty.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkSliceListModel](gtkslicelistmodel#GtkSliceListModel-struct) | |
| offset | the new offset to use | |
### gtk\_slice\_list\_model\_get\_offset ()
```
guint
gtk_slice_list_model_get_offset (*`[GtkSliceListModel](gtkslicelistmodel#GtkSliceListModel-struct) *self`*);
```
Gets the offset set via [`gtk_slice_list_model_set_offset()`](gtkslicelistmodel#gtk-slice-list-model-set-offset)
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkSliceListModel](gtkslicelistmodel#GtkSliceListModel-struct) | |
#### Returns
The offset
### gtk\_slice\_list\_model\_set\_size ()
```
void
gtk_slice_list_model_set_size (*`[GtkSliceListModel](gtkslicelistmodel#GtkSliceListModel-struct) *self`*,
*`guint size`*);
```
Sets the maximum size. *`self`* will never have more items than *`size`* .
It can however have fewer items if the offset is too large or the model sliced from doesn't have enough items.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkSliceListModel](gtkslicelistmodel#GtkSliceListModel-struct) | |
| size | the maximum size | |
### gtk\_slice\_list\_model\_get\_size ()
```
guint
gtk_slice_list_model_get_size (*`[GtkSliceListModel](gtkslicelistmodel#GtkSliceListModel-struct) *self`*);
```
Gets the size set via [`gtk_slice_list_model_set_size()`](gtkslicelistmodel#gtk-slice-list-model-set-size).
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkSliceListModel](gtkslicelistmodel#GtkSliceListModel-struct) | |
#### Returns
The size
Types and Values
----------------
### GtkSliceListModel
```
typedef struct _GtkSliceListModel GtkSliceListModel;
```
Property Details
----------------
### The `“model”` property
```
“model” GListModel *
```
Child model to take slice from
Owner: GtkSliceListModel
Flags: Read / Write
### The `“offset”` property
```
“offset” guint
```
Offset of slice
Owner: GtkSliceListModel
Flags: Read / Write
Default value: 0
### The `“size”` property
```
“size” guint
```
Maximum size of slice
Owner: GtkSliceListModel
Flags: Read / Write
Default value: 10
See Also
--------
GListModel
| programming_docs |
gtk GtkDragSource GtkDragSource
=============
GtkDragSource — Event controller to initiate DND operations
Functions
---------
| | |
| --- | --- |
| [GtkDragSource](gtkdragsource#GtkDragSource-struct) \* | [gtk\_drag\_source\_new](gtkdragsource#gtk-drag-source-new) () |
| void | [gtk\_drag\_source\_set\_content](gtkdragsource#gtk-drag-source-set-content) () |
| [GdkContentProvider](https://developer-old.gnome.org/gtk4/html/GdkContentProvider.html#GdkContentProvider-struct) \* | [gtk\_drag\_source\_get\_content](gtkdragsource#gtk-drag-source-get-content) () |
| void | [gtk\_drag\_source\_set\_actions](gtkdragsource#gtk-drag-source-set-actions) () |
| [GdkDragAction](https://developer-old.gnome.org/gtk4/html/gdk4-Drag-and-Drop.html#GdkDragAction) | [gtk\_drag\_source\_get\_actions](gtkdragsource#gtk-drag-source-get-actions) () |
| void | [gtk\_drag\_source\_set\_icon](gtkdragsource#gtk-drag-source-set-icon) () |
| void | [gtk\_drag\_source\_drag\_cancel](gtkdragsource#gtk-drag-source-drag-cancel) () |
| [GdkDrag](https://developer-old.gnome.org/gtk4/html/gdk4-Drag-and-Drop.html#GdkDrag-struct) \* | [gtk\_drag\_source\_get\_drag](gtkdragsource#gtk-drag-source-get-drag) () |
| gboolean | [gtk\_drag\_check\_threshold](gtkdragsource#gtk-drag-check-threshold) () |
Properties
----------
| | | |
| --- | --- | --- |
| [GdkDragAction](https://developer-old.gnome.org/gtk4/html/gdk4-Drag-and-Drop.html#GdkDragAction) | [actions](gtkdragsource#GtkDragSource--actions) | Read / Write |
| [GdkContentProvider](https://developer-old.gnome.org/gtk4/html/GdkContentProvider.html#GdkContentProvider-struct) \* | [content](gtkdragsource#GtkDragSource--content) | Read / Write |
Signals
-------
| | | |
| --- | --- | --- |
| void | [drag-begin](gtkdragsource#GtkDragSource-drag-begin) | Run Last |
| gboolean | [drag-cancel](gtkdragsource#GtkDragSource-drag-cancel) | Run Last |
| void | [drag-end](gtkdragsource#GtkDragSource-drag-end) | Run Last |
| [GdkContentProvider](https://developer-old.gnome.org/gtk4/html/GdkContentProvider.html#GdkContentProvider-struct)\* | [prepare](gtkdragsource#GtkDragSource-prepare) | Run Last |
Types and Values
----------------
| | |
| --- | --- |
| | [GtkDragSource](gtkdragsource#GtkDragSource-struct) |
Object Hierarchy
----------------
```
GObject
╰── [GtkEventController](gtkeventcontroller#GtkEventController-struct)
╰── [GtkGesture](gtkgesture#GtkGesture-struct)
╰── [GtkGestureSingle](gtkgesturesingle#GtkGestureSingle-struct)
╰── GtkDragSource
```
Includes
--------
```
#include <gtk/gtk.h>
```
Description
-----------
GtkDragSource is an auxiliary object that is used to initiate Drag-And-Drop operations. It can be set up with the necessary ingredients for a DND operation ahead of time. This includes the source for the data that is being transferred, in the form of a [GdkContentProvider](https://developer-old.gnome.org/gtk4/html/GdkContentProvider.html#GdkContentProvider-struct), the desired action, and the icon to use during the drag operation. After setting it up, the drag source must be added to a widget as an event controller, using [`gtk_widget_add_controller()`](gtkwidget#gtk-widget-add-controller).
Setting up the content provider and icon ahead of time only makes sense when the data does not change. More commonly, you will want to set them up just in time. To do so, [GtkDragSource](gtkdragsource#GtkDragSource-struct) has [“prepare”](gtkdragsource#GtkDragSource-prepare) and [“drag-begin”](gtkdragsource#GtkDragSource-drag-begin) signals.
The ::prepare signal is emitted before a drag is started, and can be used to set the content provider and actions that the drag should be started with.
The ::drag-begin signal is emitted after the [GdkDrag](https://developer-old.gnome.org/gtk4/html/gdk4-Drag-and-Drop.html#GdkDrag-struct) object has been created, and can be used to set up the drag icon.
```
static void
my_widget_init (MyWidget *self)
{
GtkDragSource *drag_source = gtk_drag_source_new ();
g_signal_connect (drag_source, "prepare", G_CALLBACK (on_drag_prepare), self);
g_signal_connect (drag_source, "drag-begin", G_CALLBACK (on_drag_begin), self);
gtk_widget_add_controller (GTK_WIDGET (self), GTK_EVENT_CONTROLLER (drag_source));
}
```
| During the DND operation, GtkDragSource emits signals that can be used to obtain updates about the status of the operation, but it is not normally necessary to connect to any signals, except for one case: when the supported actions include [`GDK_ACTION_MOVE`](https://developer-old.gnome.org/gtk4/html/gdk4-Drag-and-Drop.html#GDK-ACTION-MOVE:CAPS), you need to listen for the [“drag-end”](gtkdragsource#GtkDragSource-drag-end) signal and delete the data after it has been transferred.
Functions
---------
### gtk\_drag\_source\_new ()
```
[GtkDragSource](gtkdragsource#GtkDragSource-struct) *
gtk_drag_source_new (*`void`*);
```
Creates a new [GtkDragSource](gtkdragsource#GtkDragSource-struct) object.
#### Returns
the new [GtkDragSource](gtkdragsource#GtkDragSource-struct)
### gtk\_drag\_source\_set\_content ()
```
void
gtk_drag_source_set_content (*`[GtkDragSource](gtkdragsource#GtkDragSource-struct) *source`*,
*`[GdkContentProvider](https://developer-old.gnome.org/gtk4/html/GdkContentProvider.html#GdkContentProvider-struct) *content`*);
```
Sets a content provider on a [GtkDragSource](gtkdragsource#GtkDragSource-struct).
When the data is requested in the cause of a DND operation, it will be obtained from the content provider.
This function can be called before a drag is started, or in a handler for the [“prepare”](gtkdragsource#GtkDragSource-prepare) signal.
You may consider setting the content provider back to `NULL` in a [“drag-end”](gtkdragsource#GtkDragSource-drag-end) signal handler.
#### Parameters
| | | |
| --- | --- | --- |
| source | a [GtkDragSource](gtkdragsource#GtkDragSource-struct) | |
| content | a [GdkContentProvider](https://developer-old.gnome.org/gtk4/html/GdkContentProvider.html#GdkContentProvider-struct), or `NULL`. | [nullable] |
### gtk\_drag\_source\_get\_content ()
```
[GdkContentProvider](https://developer-old.gnome.org/gtk4/html/GdkContentProvider.html#GdkContentProvider-struct) *
gtk_drag_source_get_content (*`[GtkDragSource](gtkdragsource#GtkDragSource-struct) *source`*);
```
Gets the current content provider of a [GtkDragSource](gtkdragsource#GtkDragSource-struct).
#### Parameters
| | | |
| --- | --- | --- |
| source | a [GtkDragSource](gtkdragsource#GtkDragSource-struct) | |
#### Returns
the [GdkContentProvider](https://developer-old.gnome.org/gtk4/html/GdkContentProvider.html#GdkContentProvider-struct) of *`source`* .
[nullable][transfer none]
### gtk\_drag\_source\_set\_actions ()
```
void
gtk_drag_source_set_actions (*`[GtkDragSource](gtkdragsource#GtkDragSource-struct) *source`*,
*`[GdkDragAction](https://developer-old.gnome.org/gtk4/html/gdk4-Drag-and-Drop.html#GdkDragAction) actions`*);
```
Sets the actions on the [GtkDragSource](gtkdragsource#GtkDragSource-struct).
During a DND operation, the actions are offered to potential drop targets. If *`actions`* include [`GDK_ACTION_MOVE`](https://developer-old.gnome.org/gtk4/html/gdk4-Drag-and-Drop.html#GDK-ACTION-MOVE:CAPS), you need to listen to the [“drag-end”](gtkdragsource#GtkDragSource-drag-end) signal and handle *`delete_data`* being `TRUE`.
This function can be called before a drag is started, or in a handler for the [“prepare”](gtkdragsource#GtkDragSource-prepare) signal.
#### Parameters
| | | |
| --- | --- | --- |
| source | a [GtkDragSource](gtkdragsource#GtkDragSource-struct) | |
| actions | the actions to offer | |
### gtk\_drag\_source\_get\_actions ()
```
[GdkDragAction](https://developer-old.gnome.org/gtk4/html/gdk4-Drag-and-Drop.html#GdkDragAction)
gtk_drag_source_get_actions (*`[GtkDragSource](gtkdragsource#GtkDragSource-struct) *source`*);
```
Gets the actions that are currently set on the [GtkDragSource](gtkdragsource#GtkDragSource-struct).
#### Parameters
| | | |
| --- | --- | --- |
| source | a [GtkDragSource](gtkdragsource#GtkDragSource-struct) | |
#### Returns
the actions set on *`source`*
### gtk\_drag\_source\_set\_icon ()
```
void
gtk_drag_source_set_icon (*`[GtkDragSource](gtkdragsource#GtkDragSource-struct) *source`*,
*`[GdkPaintable](https://developer-old.gnome.org/gtk4/html/GdkPaintable.html#GdkPaintable-struct) *paintable`*,
*`int hot_x`*,
*`int hot_y`*);
```
Sets a paintable to use as icon during DND operations.
The hotspot coordinates determine the point on the icon that gets aligned with the hotspot of the cursor.
If *`paintable`* is `NULL`, a default icon is used.
This function can be called before a drag is started, or in a [“prepare”](gtkdragsource#GtkDragSource-prepare) or [“drag-begin”](gtkdragsource#GtkDragSource-drag-begin) signal handler.
#### Parameters
| | | |
| --- | --- | --- |
| source | a [GtkDragSource](gtkdragsource#GtkDragSource-struct) | |
| paintable | the [GdkPaintable](https://developer-old.gnome.org/gtk4/html/GdkPaintable.html#GdkPaintable-struct) to use as icon, or `NULL`. | [nullable] |
| hot\_x | the hotspot X coordinate on the icon | |
| hot\_y | the hotspot Y coordinate on the icon | |
### gtk\_drag\_source\_drag\_cancel ()
```
void
gtk_drag_source_drag_cancel (*`[GtkDragSource](gtkdragsource#GtkDragSource-struct) *source`*);
```
Cancels a currently ongoing drag operation.
#### Parameters
| | | |
| --- | --- | --- |
| source | a [GtkDragSource](gtkdragsource#GtkDragSource-struct) | |
### gtk\_drag\_source\_get\_drag ()
```
[GdkDrag](https://developer-old.gnome.org/gtk4/html/gdk4-Drag-and-Drop.html#GdkDrag-struct) *
gtk_drag_source_get_drag (*`[GtkDragSource](gtkdragsource#GtkDragSource-struct) *source`*);
```
Returns the underlying [GdkDrag](https://developer-old.gnome.org/gtk4/html/gdk4-Drag-and-Drop.html#GdkDrag-struct) object for an ongoing drag.
#### Parameters
| | | |
| --- | --- | --- |
| source | a [GtkDragSource](gtkdragsource#GtkDragSource-struct) | |
#### Returns
the [GdkDrag](https://developer-old.gnome.org/gtk4/html/gdk4-Drag-and-Drop.html#GdkDrag-struct) of the current drag operation, or `NULL`.
[nullable][transfer none]
### gtk\_drag\_check\_threshold ()
```
gboolean
gtk_drag_check_threshold (*`[GtkWidget](gtkwidget#GtkWidget-struct) *widget`*,
*`int start_x`*,
*`int start_y`*,
*`int current_x`*,
*`int current_y`*);
```
Checks to see if a mouse drag starting at (*`start_x`* , *`start_y`* ) and ending at (*`current_x`* , *`current_y`* ) has passed the GTK drag threshold, and thus should trigger the beginning of a drag-and-drop operation.
[method]
#### Parameters
| | | |
| --- | --- | --- |
| widget | a [GtkWidget](gtkwidget#GtkWidget-struct) | |
| start\_x | X coordinate of start of drag | |
| start\_y | Y coordinate of start of drag | |
| current\_x | current X coordinate | |
| current\_y | current Y coordinate | |
#### Returns
`TRUE` if the drag threshold has been passed.
Types and Values
----------------
### GtkDragSource
```
typedef struct _GtkDragSource GtkDragSource;
```
Property Details
----------------
### The `“actions”` property
```
“actions” [GdkDragAction](https://developer-old.gnome.org/gtk4/html/gdk4-Drag-and-Drop.html#GdkDragAction)
```
The actions that are supported by drag operations from the source.
Note that you must handle the [“drag-end”](gtkdragsource#GtkDragSource-drag-end) signal if the actions include [`GDK_ACTION_MOVE`](https://developer-old.gnome.org/gtk4/html/gdk4-Drag-and-Drop.html#GDK-ACTION-MOVE:CAPS).
Owner: GtkDragSource
Flags: Read / Write
Default value: GDK\_ACTION\_COPY
### The `“content”` property
```
“content” [GdkContentProvider](https://developer-old.gnome.org/gtk4/html/GdkContentProvider.html#GdkContentProvider-struct) *
```
The data that is offered by drag operations from this source, in the form of a [GdkContentProvider](https://developer-old.gnome.org/gtk4/html/GdkContentProvider.html#GdkContentProvider-struct).
Owner: GtkDragSource
Flags: Read / Write
Signal Details
--------------
### The `“drag-begin”` signal
```
void
user_function ([GtkDragSource](gtkdragsource#GtkDragSource-struct) *source,
[GdkDrag](https://developer-old.gnome.org/gtk4/html/gdk4-Drag-and-Drop.html#GdkDrag-struct) *drag,
gpointer user_data)
```
The ::drag-begin signal is emitted on the drag source when a drag is started. It can be used to e.g. set a custom drag icon with [`gtk_drag_source_set_icon()`](gtkdragsource#gtk-drag-source-set-icon).
#### Parameters
| | | |
| --- | --- | --- |
| source | the [GtkDragSource](gtkdragsource#GtkDragSource-struct) | |
| drag | the [GdkDrag](https://developer-old.gnome.org/gtk4/html/gdk4-Drag-and-Drop.html#GdkDrag-struct) object | |
| user\_data | user data set when the signal handler was connected. | |
Flags: Run Last
### The `“drag-cancel”` signal
```
gboolean
user_function ([GtkDragSource](gtkdragsource#GtkDragSource-struct) *source,
[GdkDrag](https://developer-old.gnome.org/gtk4/html/gdk4-Drag-and-Drop.html#GdkDrag-struct) *drag,
[GdkDragCancelReason](https://developer-old.gnome.org/gtk4/html/gdk4-Drag-and-Drop.html#GdkDragCancelReason) reason,
gpointer user_data)
```
The ::drag-cancel signal is emitted on the drag source when a drag has failed. The signal handler may handle a failed drag operation based on the type of error. It should return `TRUE` if the failure has been handled and the default "drag operation failed" animation should not be shown.
#### Parameters
| | | |
| --- | --- | --- |
| source | the [GtkDragSource](gtkdragsource#GtkDragSource-struct) | |
| drag | the [GdkDrag](https://developer-old.gnome.org/gtk4/html/gdk4-Drag-and-Drop.html#GdkDrag-struct) object | |
| reason | information on why the drag failed | |
| user\_data | user data set when the signal handler was connected. | |
#### Returns
`TRUE` if the failed drag operation has been already handled
Flags: Run Last
### The `“drag-end”` signal
```
void
user_function ([GtkDragSource](gtkdragsource#GtkDragSource-struct) *source,
[GdkDrag](https://developer-old.gnome.org/gtk4/html/gdk4-Drag-and-Drop.html#GdkDrag-struct) *drag,
gboolean delete_data,
gpointer user_data)
```
The ::drag-end signal is emitted on the drag source when a drag is finished. A typical reason to connect to this signal is to undo things done in [“prepare”](gtkdragsource#GtkDragSource-prepare) or [“drag-begin”](gtkdragsource#GtkDragSource-drag-begin).
#### Parameters
| | | |
| --- | --- | --- |
| source | the [GtkDragSource](gtkdragsource#GtkDragSource-struct) | |
| drag | the [GdkDrag](https://developer-old.gnome.org/gtk4/html/gdk4-Drag-and-Drop.html#GdkDrag-struct) object | |
| delete\_data | `TRUE` if the drag was performing [`GDK_ACTION_MOVE`](https://developer-old.gnome.org/gtk4/html/gdk4-Drag-and-Drop.html#GDK-ACTION-MOVE:CAPS), and the data should be deleted | |
| user\_data | user data set when the signal handler was connected. | |
Flags: Run Last
### The `“prepare”` signal
```
[GdkContentProvider](https://developer-old.gnome.org/gtk4/html/GdkContentProvider.html#GdkContentProvider-struct)*
user_function ([GtkDragSource](gtkdragsource#GtkDragSource-struct) *source,
double x,
double y,
gpointer user_data)
```
The ::prepare signal is emitted when a drag is about to be initiated. It returns the \* [GdkContentProvider](https://developer-old.gnome.org/gtk4/html/GdkContentProvider.html#GdkContentProvider-struct) to use for the drag that is about to start. The default handler for this signal returns the value of the [“content”](gtkdragsource#GtkDragSource--content) property, so if you set up that property ahead of time, you don't need to connect to this signal.
#### Parameters
| | | |
| --- | --- | --- |
| source | the [GtkDragSource](gtkdragsource#GtkDragSource-struct) | |
| x | the X coordinate of the drag starting point | |
| y | the Y coordinate fo the drag starting point | |
| user\_data | user data set when the signal handler was connected. | |
#### Returns
a [GdkContentProvider](https://developer-old.gnome.org/gtk4/html/GdkContentProvider.html#GdkContentProvider-struct), or `NULL`.
[transfer full][nullable]
Flags: Run Last
gtk GtkScrollbar GtkScrollbar
============
GtkScrollbar — A Scrollbar
Functions
---------
| | |
| --- | --- |
| [GtkWidget](gtkwidget#GtkWidget-struct) \* | [gtk\_scrollbar\_new](gtkscrollbar#gtk-scrollbar-new) () |
| [GtkAdjustment](gtkadjustment#GtkAdjustment-struct) \* | [gtk\_scrollbar\_get\_adjustment](gtkscrollbar#gtk-scrollbar-get-adjustment) () |
| void | [gtk\_scrollbar\_set\_adjustment](gtkscrollbar#gtk-scrollbar-set-adjustment) () |
Properties
----------
| | | |
| --- | --- | --- |
| [GtkAdjustment](gtkadjustment#GtkAdjustment-struct) \* | [adjustment](gtkscrollbar#GtkScrollbar--adjustment) | Read / Write / Construct |
Types and Values
----------------
| | |
| --- | --- |
| | [GtkScrollbar](gtkscrollbar#GtkScrollbar-struct) |
Object Hierarchy
----------------
```
GObject
╰── GInitiallyUnowned
╰── [GtkWidget](gtkwidget#GtkWidget-struct)
╰── GtkScrollbar
```
Implemented Interfaces
----------------------
GtkScrollbar implements [GtkAccessible](gtkaccessible#GtkAccessible-struct), [GtkBuildable](gtkbuildable#GtkBuildable-struct), [GtkConstraintTarget](gtkconstraint#GtkConstraintTarget-struct) and [GtkOrientable](gtk4-orientable#GtkOrientable-struct).
Includes
--------
```
#include <gtk/gtk.h>
```
Description
-----------
The [GtkScrollbar](gtkscrollbar#GtkScrollbar-struct) widget is a horizontal or vertical scrollbar, depending on the value of the [“orientation”](gtk4-orientable#GtkOrientable--orientation) property.
Its position and movement are controlled by the adjustment that is passed to or created by [`gtk_scrollbar_new()`](gtkscrollbar#gtk-scrollbar-new). See [GtkAdjustment](gtkadjustment#GtkAdjustment-struct) for more details. The [“value”](gtkadjustment#GtkAdjustment--value) field sets the position of the thumb and must be between [“lower”](gtkadjustment#GtkAdjustment--lower) and [“upper”](gtkadjustment#GtkAdjustment--upper) - [“page-size”](gtkadjustment#GtkAdjustment--page-size). The [“page-size”](gtkadjustment#GtkAdjustment--page-size) represents the size of the visible scrollable area. The fields [“step-increment”](gtkadjustment#GtkAdjustment--step-increment) and [“page-increment”](gtkadjustment#GtkAdjustment--page-increment) fields are added to or subtracted from the [“value”](gtkadjustment#GtkAdjustment--value) when the user asks to move by a step (using e.g. the cursor arrow keys) or by a page (using e.g. the Page Down/Up keys).
### CSS nodes
```
scrollbar
╰── range[.fine-tune]
╰── trough
╰── slider
```
| GtkScrollbar has a main CSS node with name scrollbar and a subnode for its contents. The main node gets the .horizontal or .vertical style classes applied, depending on the scrollbar's orientation.
The range node gets the style class .fine-tune added when the scrollbar is in 'fine-tuning' mode.
Other style classes that may be added to scrollbars inside [GtkScrolledWindow](gtkscrolledwindow#GtkScrolledWindow-struct) include the positional classes (.left, .right, .top, .bottom) and style classes related to overlay scrolling (.overlay-indicator, .dragging, .hovering).
### Accessibility
GtkScrollbar uses the [GTK\_ACCESSIBLE\_ROLE\_SCROLLBAR](gtkaccessible#GTK-ACCESSIBLE-ROLE-SCROLLBAR:CAPS) role.
Functions
---------
### gtk\_scrollbar\_new ()
```
[GtkWidget](gtkwidget#GtkWidget-struct) *
gtk_scrollbar_new (*`[GtkOrientation](gtk4-standard-enumerations#GtkOrientation) orientation`*,
*`[GtkAdjustment](gtkadjustment#GtkAdjustment-struct) *adjustment`*);
```
Creates a new scrollbar with the given orientation.
#### Parameters
| | | |
| --- | --- | --- |
| orientation | the scrollbar’s orientation. | |
| adjustment | the [GtkAdjustment](gtkadjustment#GtkAdjustment-struct) to use, or `NULL` to create a new adjustment. | [allow-none] |
#### Returns
the new [GtkScrollbar](gtkscrollbar#GtkScrollbar-struct).
### gtk\_scrollbar\_get\_adjustment ()
```
[GtkAdjustment](gtkadjustment#GtkAdjustment-struct) *
gtk_scrollbar_get_adjustment (*`[GtkScrollbar](gtkscrollbar#GtkScrollbar-struct) *self`*);
```
Returns the scrollbar's adjustment.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkScrollbar](gtkscrollbar#GtkScrollbar-struct) | |
#### Returns
the scrollbar's adjustment.
[transfer none]
### gtk\_scrollbar\_set\_adjustment ()
```
void
gtk_scrollbar_set_adjustment (*`[GtkScrollbar](gtkscrollbar#GtkScrollbar-struct) *self`*,
*`[GtkAdjustment](gtkadjustment#GtkAdjustment-struct) *adjustment`*);
```
Makes the scrollbar use the given adjustment.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkScrollbar](gtkscrollbar#GtkScrollbar-struct) | |
| adjustment | the adjustment to set. | [nullable] |
Types and Values
----------------
### GtkScrollbar
```
typedef struct _GtkScrollbar GtkScrollbar;
```
Property Details
----------------
### The `“adjustment”` property
```
“adjustment” [GtkAdjustment](gtkadjustment#GtkAdjustment-struct) *
```
The GtkAdjustment that contains the current value of this scrollbar.
Owner: GtkScrollbar
Flags: Read / Write / Construct
See Also
--------
[GtkAdjustment](gtkadjustment#GtkAdjustment-struct), [GtkScrolledWindow](gtkscrolledwindow#GtkScrolledWindow-struct)
| programming_docs |
gtk Keyboard Accelerators Keyboard Accelerators
=====================
Keyboard Accelerators — Utilities for accelerators
Functions
---------
| | |
| --- | --- |
| gboolean | [gtk\_accelerator\_valid](gtk4-keyboard-accelerators#gtk-accelerator-valid) () |
| gboolean | [gtk\_accelerator\_parse](gtk4-keyboard-accelerators#gtk-accelerator-parse) () |
| char \* | [gtk\_accelerator\_name](gtk4-keyboard-accelerators#gtk-accelerator-name) () |
| char \* | [gtk\_accelerator\_get\_label](gtk4-keyboard-accelerators#gtk-accelerator-get-label) () |
| gboolean | [gtk\_accelerator\_parse\_with\_keycode](gtk4-keyboard-accelerators#gtk-accelerator-parse-with-keycode) () |
| char \* | [gtk\_accelerator\_name\_with\_keycode](gtk4-keyboard-accelerators#gtk-accelerator-name-with-keycode) () |
| char \* | [gtk\_accelerator\_get\_label\_with\_keycode](gtk4-keyboard-accelerators#gtk-accelerator-get-label-with-keycode) () |
| [GdkModifierType](https://developer-old.gnome.org/gtk4/html/GdkSurface.html#GdkModifierType) | [gtk\_accelerator\_get\_default\_mod\_mask](gtk4-keyboard-accelerators#gtk-accelerator-get-default-mod-mask) () |
Includes
--------
```
#include <gtk/gtk.h>
```
Description
-----------
We have various utility functions to parse and generate textual representations of keyboard accelerators.
If you want to set up keyboard accelerators for widgets, [GtkShortcutTrigger](gtkshortcuttrigger#GtkShortcutTrigger-struct) is probably more convenient than the functions in this section.
Functions
---------
### gtk\_accelerator\_valid ()
```
gboolean
gtk_accelerator_valid (*`guint keyval`*,
*`[GdkModifierType](https://developer-old.gnome.org/gtk4/html/GdkSurface.html#GdkModifierType) modifiers`*);
```
Determines whether a given keyval and modifier mask constitute a valid keyboard accelerator. For example, the GDK\_KEY\_a keyval plus [GDK\_CONTROL\_MASK](https://developer-old.gnome.org/gtk4/html/GdkSurface.html#GDK-CONTROL-MASK:CAPS) is valid - this is a “Ctrl+a” accelerator. But, you can't, for instance, use the GDK\_KEY\_Control\_L keyval as an accelerator.
#### Parameters
| | | |
| --- | --- | --- |
| keyval | a GDK keyval | |
| modifiers | modifier mask | |
#### Returns
`TRUE` if the accelerator is valid
### gtk\_accelerator\_parse ()
```
gboolean
gtk_accelerator_parse (*`const char *accelerator`*,
*`guint *accelerator_key`*,
*`[GdkModifierType](https://developer-old.gnome.org/gtk4/html/GdkSurface.html#GdkModifierType) *accelerator_mods`*);
```
Parses a string representing an accelerator. The format looks like “<Control>a” or “<Shift><Alt>F1”.
The parser is fairly liberal and allows lower or upper case, and also abbreviations such as “<Ctl>” and “<Ctrl>”. Key names are parsed using [`gdk_keyval_from_name()`](https://developer-old.gnome.org/gtk4/html/gdk4-Keyboard-Handling.html#gdk-keyval-from-name). For character keys the name is not the symbol, but the lowercase name, e.g. one would use “<Ctrl>minus” instead of “<Ctrl>-”.
If the parse fails, *`accelerator_key`* and *`accelerator_mods`* will be set to 0 (zero).
#### Parameters
| | | |
| --- | --- | --- |
| accelerator | string representing an accelerator | |
| accelerator\_key | return location for accelerator keyval, or `NULL`. | [out][allow-none] |
| accelerator\_mods | return location for accelerator modifier mask, `NULL`. | [out][allow-none] |
### gtk\_accelerator\_name ()
```
char *
gtk_accelerator_name (*`guint accelerator_key`*,
*`[GdkModifierType](https://developer-old.gnome.org/gtk4/html/GdkSurface.html#GdkModifierType) accelerator_mods`*);
```
Converts an accelerator keyval and modifier mask into a string parseable by [`gtk_accelerator_parse()`](gtk4-keyboard-accelerators#gtk-accelerator-parse). For example, if you pass in GDK\_KEY\_q and [GDK\_CONTROL\_MASK](https://developer-old.gnome.org/gtk4/html/GdkSurface.html#GDK-CONTROL-MASK:CAPS), this function returns “<Control>q”.
If you need to display accelerators in the user interface, see [`gtk_accelerator_get_label()`](gtk4-keyboard-accelerators#gtk-accelerator-get-label).
#### Parameters
| | | |
| --- | --- | --- |
| accelerator\_key | accelerator keyval | |
| accelerator\_mods | accelerator modifier mask | |
#### Returns
a newly-allocated accelerator name
### gtk\_accelerator\_get\_label ()
```
char *
gtk_accelerator_get_label (*`guint accelerator_key`*,
*`[GdkModifierType](https://developer-old.gnome.org/gtk4/html/GdkSurface.html#GdkModifierType) accelerator_mods`*);
```
Converts an accelerator keyval and modifier mask into a string which can be used to represent the accelerator to the user.
#### Parameters
| | | |
| --- | --- | --- |
| accelerator\_key | accelerator keyval | |
| accelerator\_mods | accelerator modifier mask | |
#### Returns
a newly-allocated string representing the accelerator.
### gtk\_accelerator\_parse\_with\_keycode ()
```
gboolean
gtk_accelerator_parse_with_keycode (*`const char *accelerator`*,
*`[GdkDisplay](https://developer-old.gnome.org/gtk4/html/GdkDisplay.html#GdkDisplay-struct) *display`*,
*`guint *accelerator_key`*,
*`guint **accelerator_codes`*,
*`[GdkModifierType](https://developer-old.gnome.org/gtk4/html/GdkSurface.html#GdkModifierType) *accelerator_mods`*);
```
Parses a string representing an accelerator, similarly to [`gtk_accelerator_parse()`](gtk4-keyboard-accelerators#gtk-accelerator-parse) but handles keycodes as well. This is only useful for system-level components, applications should use [`gtk_accelerator_parse()`](gtk4-keyboard-accelerators#gtk-accelerator-parse) instead.
If *`accelerator_codes`* is given and the result stored in it is non-`NULL`, the result must be freed with `g_free()`.
If a keycode is present in the accelerator and no *`accelerator_codes`* is given, the parse will fail.
If the parse fails, *`accelerator_key`* , *`accelerator_mods`* and *`accelerator_codes`* will be set to 0 (zero).
#### Parameters
| | | |
| --- | --- | --- |
| accelerator | string representing an accelerator | |
| display | the [GdkDisplay](https://developer-old.gnome.org/gtk4/html/GdkDisplay.html#GdkDisplay-struct) to look up *`accelerator_codes`* in. | [allow-none] |
| accelerator\_key | return location for accelerator keyval, or `NULL`. | [out][allow-none] |
| accelerator\_codes | return location for accelerator keycodes, or `NULL`. | [out][array zero-terminated=1][transfer full][allow-none] |
| accelerator\_mods | return location for accelerator modifier mask, `NULL`. | [out][allow-none] |
#### Returns
`TRUE` if parsing succeeded
### gtk\_accelerator\_name\_with\_keycode ()
```
char *
gtk_accelerator_name_with_keycode (*`[GdkDisplay](https://developer-old.gnome.org/gtk4/html/GdkDisplay.html#GdkDisplay-struct) *display`*,
*`guint accelerator_key`*,
*`guint keycode`*,
*`[GdkModifierType](https://developer-old.gnome.org/gtk4/html/GdkSurface.html#GdkModifierType) accelerator_mods`*);
```
Converts an accelerator keyval and modifier mask into a string parseable by [`gtk_accelerator_parse_with_keycode()`](gtk4-keyboard-accelerators#gtk-accelerator-parse-with-keycode), similarly to [`gtk_accelerator_name()`](gtk4-keyboard-accelerators#gtk-accelerator-name) but handling keycodes. This is only useful for system-level components, applications should use [`gtk_accelerator_parse()`](gtk4-keyboard-accelerators#gtk-accelerator-parse) instead.
#### Parameters
| | | |
| --- | --- | --- |
| display | a [GdkDisplay](https://developer-old.gnome.org/gtk4/html/GdkDisplay.html#GdkDisplay-struct) or `NULL` to use the default display. | [allow-none] |
| accelerator\_key | accelerator keyval | |
| keycode | accelerator keycode | |
| accelerator\_mods | accelerator modifier mask | |
#### Returns
a newly allocated accelerator name.
### gtk\_accelerator\_get\_label\_with\_keycode ()
```
char *
gtk_accelerator_get_label_with_keycode
(*`[GdkDisplay](https://developer-old.gnome.org/gtk4/html/GdkDisplay.html#GdkDisplay-struct) *display`*,
*`guint accelerator_key`*,
*`guint keycode`*,
*`[GdkModifierType](https://developer-old.gnome.org/gtk4/html/GdkSurface.html#GdkModifierType) accelerator_mods`*);
```
Converts an accelerator keyval and modifier mask into a (possibly translated) string that can be displayed to a user, similarly to [`gtk_accelerator_get_label()`](gtk4-keyboard-accelerators#gtk-accelerator-get-label), but handling keycodes.
This is only useful for system-level components, applications should use [`gtk_accelerator_parse()`](gtk4-keyboard-accelerators#gtk-accelerator-parse) instead.
#### Parameters
| | | |
| --- | --- | --- |
| display | a [GdkDisplay](https://developer-old.gnome.org/gtk4/html/GdkDisplay.html#GdkDisplay-struct) or `NULL` to use the default display. | [allow-none] |
| accelerator\_key | accelerator keyval | |
| keycode | accelerator keycode | |
| accelerator\_mods | accelerator modifier mask | |
#### Returns
a newly-allocated string representing the accelerator.
### gtk\_accelerator\_get\_default\_mod\_mask ()
```
[GdkModifierType](https://developer-old.gnome.org/gtk4/html/GdkSurface.html#GdkModifierType)
gtk_accelerator_get_default_mod_mask (*`void`*);
```
Gets the modifier mask.
The modifier mask determines which modifiers are considered significant for keyboard accelerators. This includes all keyboard modifiers except for [`GDK_LOCK_MASK`](https://developer-old.gnome.org/gtk4/html/GdkSurface.html#GDK-LOCK-MASK:CAPS).
#### Returns
the modifier mask for accelerators
gtk GtkMediaControls GtkMediaControls
================
GtkMediaControls — A widget showing controls for a media stream
Functions
---------
| | |
| --- | --- |
| [GtkWidget](gtkwidget#GtkWidget-struct) \* | [gtk\_media\_controls\_new](gtkmediacontrols#gtk-media-controls-new) () |
| [GtkMediaStream](gtkmediastream#GtkMediaStream-struct) \* | [gtk\_media\_controls\_get\_media\_stream](gtkmediacontrols#gtk-media-controls-get-media-stream) () |
| void | [gtk\_media\_controls\_set\_media\_stream](gtkmediacontrols#gtk-media-controls-set-media-stream) () |
Properties
----------
| | | |
| --- | --- | --- |
| [GtkMediaStream](gtkmediastream#GtkMediaStream-struct) \* | [media-stream](gtkmediacontrols#GtkMediaControls--media-stream) | Read / Write |
Types and Values
----------------
| | |
| --- | --- |
| | [GtkMediaControls](gtkmediacontrols#GtkMediaControls-struct) |
Object Hierarchy
----------------
```
GObject
╰── GInitiallyUnowned
╰── [GtkWidget](gtkwidget#GtkWidget-struct)
╰── GtkMediaControls
```
Implemented Interfaces
----------------------
GtkMediaControls implements [GtkAccessible](gtkaccessible#GtkAccessible-struct), [GtkBuildable](gtkbuildable#GtkBuildable-struct) and [GtkConstraintTarget](gtkconstraint#GtkConstraintTarget-struct).
Includes
--------
```
#include <gtk/gtk.h>
```
Description
-----------
GtkMediaControls is a widget to show controls for a [GtkMediaStream](gtkmediastream#GtkMediaStream-struct) and giving users a way to use it.
Functions
---------
### gtk\_media\_controls\_new ()
```
[GtkWidget](gtkwidget#GtkWidget-struct) *
gtk_media_controls_new (*`[GtkMediaStream](gtkmediastream#GtkMediaStream-struct) *stream`*);
```
Creates a new [GtkMediaControls](gtkmediacontrols#GtkMediaControls-struct) managing the *`stream`* passed to it.
#### Parameters
| | | |
| --- | --- | --- |
| stream | a [GtkMediaStream](gtkmediastream#GtkMediaStream-struct) to manage or `NULL` for none. | [allow-none][transfer none] |
#### Returns
a new [GtkMediaControls](gtkmediacontrols#GtkMediaControls-struct)
### gtk\_media\_controls\_get\_media\_stream ()
```
[GtkMediaStream](gtkmediastream#GtkMediaStream-struct) *
gtk_media_controls_get_media_stream (*`[GtkMediaControls](gtkmediacontrols#GtkMediaControls-struct) *controls`*);
```
Gets the media stream managed by *`controls`* or `NULL` if none.
#### Parameters
| | | |
| --- | --- | --- |
| controls | a [GtkMediaControls](gtkmediacontrols#GtkMediaControls-struct) | |
#### Returns
The media stream managed by *`controls`* .
[nullable][transfer none]
### gtk\_media\_controls\_set\_media\_stream ()
```
void
gtk_media_controls_set_media_stream (*`[GtkMediaControls](gtkmediacontrols#GtkMediaControls-struct) *controls`*,
*`[GtkMediaStream](gtkmediastream#GtkMediaStream-struct) *stream`*);
```
Sets the stream that is controlled by *`controls`* .
#### Parameters
| | | |
| --- | --- | --- |
| controls | a [GtkMediaControls](gtkmediacontrols#GtkMediaControls-struct) widget | |
| stream | a [GtkMediaStream](gtkmediastream#GtkMediaStream-struct), or `NULL`. | [nullable] |
Types and Values
----------------
### GtkMediaControls
```
typedef struct _GtkMediaControls GtkMediaControls;
```
Property Details
----------------
### The `“media-stream”` property
```
“media-stream” [GtkMediaStream](gtkmediastream#GtkMediaStream-struct) *
```
The media-stream managed by this object or `NULL` if none.
Owner: GtkMediaControls
Flags: Read / Write
See Also
--------
[GtkVideo](gtkvideo#GtkVideo-struct)
gtk Using GTK on Apple macOS Using GTK on Apple macOS
========================
The Apple macOS port of GTK is an implementation of GDK (and therefore GTK) on top of the Quartz API.
Currently, the macOS port does not use any additional commandline options or environment variables.
For up-to-date information about the current status of this port, see the [project page](https://wiki.gnome.org/Projects/GTK/OSX).
gtk GtkSorter GtkSorter
=========
GtkSorter — Sorting items
Functions
---------
| | |
| --- | --- |
| [GtkOrdering](gtk4-standard-enumerations#GtkOrdering) | [gtk\_sorter\_compare](gtksorter#gtk-sorter-compare) () |
| [GtkSorterOrder](gtksorter#GtkSorterOrder) | [gtk\_sorter\_get\_order](gtksorter#gtk-sorter-get-order) () |
| void | [gtk\_sorter\_changed](gtksorter#gtk-sorter-changed) () |
Signals
-------
| | | |
| --- | --- | --- |
| void | [changed](gtksorter#GtkSorter-changed) | Run Last |
Types and Values
----------------
| | |
| --- | --- |
| | [GtkSorter](gtksorter#GtkSorter-struct) |
| enum | [GtkSorterOrder](gtksorter#GtkSorterOrder) |
| enum | [GtkSorterChange](gtksorter#GtkSorterChange) |
Object Hierarchy
----------------
```
GObject
╰── GtkSorter
├── [GtkCustomSorter](gtkcustomsorter#GtkCustomSorter-struct)
├── [GtkMultiSorter](gtkmultisorter#GtkMultiSorter-struct)
├── [GtkNumericSorter](gtknumericsorter#GtkNumericSorter-struct)
├── [GtkStringSorter](gtkstringsorter#GtkStringSorter-struct)
╰── [GtkTreeListRowSorter](gtktreelistrowsorter#GtkTreeListRowSorter-struct)
```
Includes
--------
```
#include <gtk/gtk.h>
```
Description
-----------
[GtkSorter](gtksorter#GtkSorter-struct) is the way to describe sorting criteria. Its primary user is [GtkSortListModel](gtksortlistmodel#GtkSortListModel-struct).
The model will use a sorter to determine the order in which its items should appear by calling [`gtk_sorter_compare()`](gtksorter#gtk-sorter-compare) for pairs of items.
Sorters may change their sorting behavior through their lifetime. In that case, they will emit the [“changed”](gtksorter#GtkSorter-changed) signal to notify that the sort order is no longer valid and should be updated by calling [`gtk_sorter_compare()`](gtksorter#gtk-sorter-compare) again.
GTK provides various pre-made sorter implementations for common sorting operations. [GtkColumnView](gtkcolumnview#GtkColumnView-struct) has built-in support for sorting lists via the [“sorter”](gtkcolumnviewcolumn#GtkColumnViewColumn--sorter) property, where the user can change the sorting by clicking on list headers.
Of course, in particular for large lists, it is also possible to subclass [GtkSorter](gtksorter#GtkSorter-struct) and provide one's own sorter.
Functions
---------
### gtk\_sorter\_compare ()
```
[GtkOrdering](gtk4-standard-enumerations#GtkOrdering)
gtk_sorter_compare (*`[GtkSorter](gtksorter#GtkSorter-struct) *self`*,
*`gpointer item1`*,
*`gpointer item2`*);
```
Compares two given items according to the sort order implemented by the sorter.
Sorters implement a partial order:
* It is reflexive, ie a = a
* It is antisymmetric, ie if a < b and b < a, then a = b
* It is transitive, ie given any 3 items with a ≤ b and b ≤ c, then a ≤ c
The sorter may signal it conforms to additional constraints via the return value of [`gtk_sorter_get_order()`](gtksorter#gtk-sorter-get-order).
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkSorter](gtksorter#GtkSorter-struct) | |
| item1 | first item to compare. | [type GObject][transfer none] |
| item2 | second item to compare. | [type GObject][transfer none] |
#### Returns
[`GTK_ORDERING_EQUAL`](gtk4-standard-enumerations#GTK-ORDERING-EQUAL:CAPS) if *`item1`* == *`item2`* , [`GTK_ORDERING_SMALLER`](gtk4-standard-enumerations#GTK-ORDERING-SMALLER:CAPS) if *`item1`* < *`item2`* , [`GTK_ORDERING_LARGER`](gtk4-standard-enumerations#GTK-ORDERING-LARGER:CAPS) if *`item1`* > *`item2`*
### gtk\_sorter\_get\_order ()
```
[GtkSorterOrder](gtksorter#GtkSorterOrder)
gtk_sorter_get_order (*`[GtkSorter](gtksorter#GtkSorter-struct) *self`*);
```
Gets the order that *`self`* conforms to. See [GtkSorterOrder](gtksorter#GtkSorterOrder) for details of the possible return values.
This function is intended to allow optimizations.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkSorter](gtksorter#GtkSorter-struct) | |
#### Returns
The order
### gtk\_sorter\_changed ()
```
void
gtk_sorter_changed (*`[GtkSorter](gtksorter#GtkSorter-struct) *self`*,
*`[GtkSorterChange](gtksorter#GtkSorterChange) change`*);
```
Emits the [“changed”](gtksorter#GtkSorter-changed) signal to notify all users of the sorter that it has changed. Users of the sorter should then update the sort order via [`gtk_sorter_compare()`](gtksorter#gtk-sorter-compare).
Depending on the *`change`* parameter, it may be possible to update the sort order without a full resorting. Refer to the [GtkSorterChange](gtksorter#GtkSorterChange) documentation for details.
This function is intended for implementors of [GtkSorter](gtksorter#GtkSorter-struct) subclasses and should not be called from other functions.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkSorter](gtksorter#GtkSorter-struct) | |
| change | How the sorter changed | |
Types and Values
----------------
### GtkSorter
```
typedef struct _GtkSorter GtkSorter;
```
### enum GtkSorterOrder
Describes the type of order that a [GtkSorter](gtksorter#GtkSorter-struct) may describe.
#### Members
| | | |
| --- | --- | --- |
| GTK\_SORTER\_ORDER\_PARTIAL | A partial order. Any [GtkOrdering](gtk4-standard-enumerations#GtkOrdering) is possible. | |
| GTK\_SORTER\_ORDER\_NONE | No order, all elements are considered equal. [`gtk_sorter_compare()`](gtksorter#gtk-sorter-compare) will only return [`GTK_ORDERING_EQUAL`](gtk4-standard-enumerations#GTK-ORDERING-EQUAL:CAPS). | |
| GTK\_SORTER\_ORDER\_TOTAL | A total order. [`gtk_sorter_compare()`](gtksorter#gtk-sorter-compare) will only return [`GTK_ORDERING_EQUAL`](gtk4-standard-enumerations#GTK-ORDERING-EQUAL:CAPS) if an item is compared with itself. Two different items will never cause this value to be returned. | |
### enum GtkSorterChange
Describes changes in a sorter in more detail and allows users to optimize resorting.
#### Members
| | | |
| --- | --- | --- |
| GTK\_SORTER\_CHANGE\_DIFFERENT | The sorter change cannot be described by any of the other enumeration values | |
| GTK\_SORTER\_CHANGE\_INVERTED | The sort order was inverted. Comparisons that returned [`GTK_ORDERING_SMALLER`](gtk4-standard-enumerations#GTK-ORDERING-SMALLER:CAPS) now return [`GTK_ORDERING_LARGER`](gtk4-standard-enumerations#GTK-ORDERING-LARGER:CAPS) and vice versa. Other comparisons return the same values as before. | |
| GTK\_SORTER\_CHANGE\_LESS\_STRICT | The sorter is less strict: Comparisons may now return [`GTK_ORDERING_EQUAL`](gtk4-standard-enumerations#GTK-ORDERING-EQUAL:CAPS) that did not do so before. | |
| GTK\_SORTER\_CHANGE\_MORE\_STRICT | The sorter is more strict: Comparisons that did return [`GTK_ORDERING_EQUAL`](gtk4-standard-enumerations#GTK-ORDERING-EQUAL:CAPS) may not do so anymore. | |
Signal Details
--------------
### The `“changed”` signal
```
void
user_function ([GtkSorter](gtksorter#GtkSorter-struct) *self,
[GtkSorterChange](gtksorter#GtkSorterChange) change,
gpointer user_data)
```
This signal is emitted whenever the sorter changed. Users of the sorter should then update the sort order again via [`gtk_sorter_compare()`](gtksorter#gtk-sorter-compare).
[GtkSortListModel](gtksortlistmodel#GtkSortListModel-struct) handles this signal automatically.
Depending on the *`change`* parameter, it may be possible to update the sort order without a full resorting. Refer to the [GtkSorterChange](gtksorter#GtkSorterChange) documentation for details.
#### Parameters
| | | |
| --- | --- | --- |
| self | The [GtkSorter](gtksorter#GtkSorter-struct) | |
| change | how the sorter changed | |
| user\_data | user data set when the signal handler was connected. | |
Flags: Run Last
See Also
--------
[GtkSortListModel](gtksortlistmodel#GtkSortListModel-struct)
| programming_docs |
gtk GtkIconTheme GtkIconTheme
============
GtkIconTheme — Looking up icons by name
Functions
---------
| | |
| --- | --- |
| [GtkIconTheme](gtkicontheme#GtkIconTheme-struct) \* | [gtk\_icon\_theme\_new](gtkicontheme#gtk-icon-theme-new) () |
| [GtkIconTheme](gtkicontheme#GtkIconTheme-struct) \* | [gtk\_icon\_theme\_get\_for\_display](gtkicontheme#gtk-icon-theme-get-for-display) () |
| [GdkDisplay](https://developer-old.gnome.org/gtk4/html/GdkDisplay.html#GdkDisplay-struct) \* | [gtk\_icon\_theme\_get\_display](gtkicontheme#gtk-icon-theme-get-display) () |
| void | [gtk\_icon\_theme\_set\_search\_path](gtkicontheme#gtk-icon-theme-set-search-path) () |
| char \*\* | [gtk\_icon\_theme\_get\_search\_path](gtkicontheme#gtk-icon-theme-get-search-path) () |
| void | [gtk\_icon\_theme\_add\_search\_path](gtkicontheme#gtk-icon-theme-add-search-path) () |
| void | [gtk\_icon\_theme\_set\_resource\_path](gtkicontheme#gtk-icon-theme-set-resource-path) () |
| char \*\* | [gtk\_icon\_theme\_get\_resource\_path](gtkicontheme#gtk-icon-theme-get-resource-path) () |
| void | [gtk\_icon\_theme\_add\_resource\_path](gtkicontheme#gtk-icon-theme-add-resource-path) () |
| void | [gtk\_icon\_theme\_set\_theme\_name](gtkicontheme#gtk-icon-theme-set-theme-name) () |
| char \* | [gtk\_icon\_theme\_get\_theme\_name](gtkicontheme#gtk-icon-theme-get-theme-name) () |
| gboolean | [gtk\_icon\_theme\_has\_icon](gtkicontheme#gtk-icon-theme-has-icon) () |
| [GtkIconPaintable](gtkicontheme#GtkIconPaintable) \* | [gtk\_icon\_theme\_lookup\_icon](gtkicontheme#gtk-icon-theme-lookup-icon) () |
| [GtkIconPaintable](gtkicontheme#GtkIconPaintable) \* | [gtk\_icon\_theme\_lookup\_by\_gicon](gtkicontheme#gtk-icon-theme-lookup-by-gicon) () |
| char \*\* | [gtk\_icon\_theme\_get\_icon\_names](gtkicontheme#gtk-icon-theme-get-icon-names) () |
| int \* | [gtk\_icon\_theme\_get\_icon\_sizes](gtkicontheme#gtk-icon-theme-get-icon-sizes) () |
| [GtkIconPaintable](gtkicontheme#GtkIconPaintable) \* | [gtk\_icon\_paintable\_new\_for\_file](gtkicontheme#gtk-icon-paintable-new-for-file) () |
| GFile \* | [gtk\_icon\_paintable\_get\_file](gtkicontheme#gtk-icon-paintable-get-file) () |
| const char \* | [gtk\_icon\_paintable\_get\_icon\_name](gtkicontheme#gtk-icon-paintable-get-icon-name) () |
| gboolean | [gtk\_icon\_paintable\_is\_symbolic](gtkicontheme#gtk-icon-paintable-is-symbolic) () |
Properties
----------
| | | |
| --- | --- | --- |
| [GdkDisplay](https://developer-old.gnome.org/gtk4/html/GdkDisplay.html#GdkDisplay-struct) \* | [display](gtkicontheme#GtkIconTheme--display) | Read / Write |
| GStrv | [icon-names](gtkicontheme#GtkIconTheme--icon-names) | Read |
| GStrv | [resource-path](gtkicontheme#GtkIconTheme--resource-path) | Read / Write |
| GStrv | [search-path](gtkicontheme#GtkIconTheme--search-path) | Read / Write |
| char \* | [theme-name](gtkicontheme#GtkIconTheme--theme-name) | Read / Write |
Signals
-------
| | | |
| --- | --- | --- |
| void | [changed](gtkicontheme#GtkIconTheme-changed) | Run Last |
Types and Values
----------------
| | |
| --- | --- |
| | [GtkIconPaintable](gtkicontheme#GtkIconPaintable) |
| | [GtkIconTheme](gtkicontheme#GtkIconTheme-struct) |
| enum | [GtkIconLookupFlags](gtkicontheme#GtkIconLookupFlags) |
| #define | [GTK\_ICON\_THEME\_ERROR](gtkicontheme#GTK-ICON-THEME-ERROR:CAPS) |
| #define | [GTK\_TYPE\_ICON\_THEME\_ERROR](gtkicontheme#GTK-TYPE-ICON-THEME-ERROR:CAPS) |
| #define | [GTK\_TYPE\_ICON\_LOOKUP\_FLAGS](gtkicontheme#GTK-TYPE-ICON-LOOKUP-FLAGS:CAPS) |
| enum | [GtkIconThemeError](gtkicontheme#GtkIconThemeError) |
Object Hierarchy
----------------
```
GObject
╰── GtkIconTheme
```
Includes
--------
```
#include <gtk/gtk.h>
```
Description
-----------
[GtkIconTheme](gtkicontheme#GtkIconTheme-struct) provides a facility for looking up icons by name and size. The main reason for using a name rather than simply providing a filename is to allow different icons to be used depending on what “icon theme” is selected by the user. The operation of icon themes on Linux and Unix follows the [Icon Theme Specification](http://www.freedesktop.org/Standards/icon-theme-spec) There is a fallback icon theme, named `hicolor`, where applications should install their icons, but additional icon themes can be installed as operating system vendors and users choose.
In many cases, named themes are used indirectly, via [GtkImage](gtkimage#GtkImage-struct) rather than directly, but looking up icons directly is also simple. The [GtkIconTheme](gtkicontheme#GtkIconTheme-struct) object acts as a database of all the icons in the current theme. You can create new [GtkIconTheme](gtkicontheme#GtkIconTheme-struct) objects, but it’s much more efficient to use the standard icon theme of the [GtkWidget](gtkwidget#GtkWidget-struct) so that the icon information is shared with other people looking up icons.
```
GtkIconTheme *icon_theme;
GtkIconPaintable *icon;
GdkPaintable *paintable;
icon_theme = gtk_icon_theme_get_for_display (gtk_widget_get_display (my_widget));
icon = gtk_icon_theme_lookup_icon (icon_theme,
"my-icon-name", // icon name
48, // icon size
1, // scale
0, // flags);
paintable = GDK_PAINTABLE (icon);
// Use the paintable
g_object_unref (icon);
```
| Functions
---------
### gtk\_icon\_theme\_new ()
```
[GtkIconTheme](gtkicontheme#GtkIconTheme-struct) *
gtk_icon_theme_new (*`void`*);
```
Creates a new icon theme object. Icon theme objects are used to lookup up an icon by name in a particular icon theme. Usually, you’ll want to use [`gtk_icon_theme_get_for_display()`](gtkicontheme#gtk-icon-theme-get-for-display) rather than creating a new icon theme object for scratch.
#### Returns
the newly created [GtkIconTheme](gtkicontheme#GtkIconTheme-struct) object.
### gtk\_icon\_theme\_get\_for\_display ()
```
[GtkIconTheme](gtkicontheme#GtkIconTheme-struct) *
gtk_icon_theme_get_for_display (*`[GdkDisplay](https://developer-old.gnome.org/gtk4/html/GdkDisplay.html#GdkDisplay-struct) *display`*);
```
Gets the icon theme object associated with *`display`* ; if this function has not previously been called for the given display, a new icon theme object will be created and associated with the display. Icon theme objects are fairly expensive to create, so using this function is usually a better choice than calling than [`gtk_icon_theme_new()`](gtkicontheme#gtk-icon-theme-new) and setting the display yourself; by using this function a single icon theme object will be shared between users.
#### Parameters
| | | |
| --- | --- | --- |
| display | a [GdkDisplay](https://developer-old.gnome.org/gtk4/html/GdkDisplay.html#GdkDisplay-struct) | |
#### Returns
A unique [GtkIconTheme](gtkicontheme#GtkIconTheme-struct) associated with the given display. This icon theme is associated with the display and can be used as long as the display is open. Do not ref or unref it.
[transfer none]
### gtk\_icon\_theme\_get\_display ()
```
[GdkDisplay](https://developer-old.gnome.org/gtk4/html/GdkDisplay.html#GdkDisplay-struct) *
gtk_icon_theme_get_display (*`[GtkIconTheme](gtkicontheme#GtkIconTheme-struct) *self`*);
```
Returns the display that the GtkIconTheme object was created for.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkIconTheme](gtkicontheme#GtkIconTheme-struct) | |
#### Returns
the display of *`icon_theme`* .
[nullable][transfer none]
### gtk\_icon\_theme\_set\_search\_path ()
```
void
gtk_icon_theme_set_search_path (*`[GtkIconTheme](gtkicontheme#GtkIconTheme-struct) *self`*,
*`const char * const *path`*);
```
Sets the search path for the icon theme object. When looking for an icon theme, GTK will search for a subdirectory of one or more of the directories in *`path`* with the same name as the icon theme containing an index.theme file. (Themes from multiple of the path elements are combined to allow themes to be extended by adding icons in the user’s home directory.)
In addition if an icon found isn’t found either in the current icon theme or the default icon theme, and an image file with the right name is found directly in one of the elements of *`path`* , then that image will be used for the icon name. (This is legacy feature, and new icons should be put into the fallback icon theme, which is called hicolor, rather than directly on the icon path.)
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkIconTheme](gtkicontheme#GtkIconTheme-struct) | |
| path | NULL-terminated array of directories that are searched for icon themes. | [array zero-terminated=1][element-type filename][nullable] |
### gtk\_icon\_theme\_get\_search\_path ()
```
char **
gtk_icon_theme_get_search_path (*`[GtkIconTheme](gtkicontheme#GtkIconTheme-struct) *self`*);
```
Gets the current search path. See [`gtk_icon_theme_set_search_path()`](gtkicontheme#gtk-icon-theme-set-search-path).
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkIconTheme](gtkicontheme#GtkIconTheme-struct) | |
#### Returns
a list of icon theme path directories or `NULL`. The returned value should be freed with `g_strfreev()`.
[transfer full][array zero-terminated=1][element-type filename][nullable]
### gtk\_icon\_theme\_add\_search\_path ()
```
void
gtk_icon_theme_add_search_path (*`[GtkIconTheme](gtkicontheme#GtkIconTheme-struct) *self`*,
*`const char *path`*);
```
Appends a directory to the search path. See [`gtk_icon_theme_set_search_path()`](gtkicontheme#gtk-icon-theme-set-search-path).
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkIconTheme](gtkicontheme#GtkIconTheme-struct) | |
| path | directory name to append to the icon path. | [type filename] |
### gtk\_icon\_theme\_set\_resource\_path ()
```
void
gtk_icon_theme_set_resource_path (*`[GtkIconTheme](gtkicontheme#GtkIconTheme-struct) *self`*,
*`const char * const *path`*);
```
Sets the resource paths that will be looked at when looking for icons, similar to search paths.
The resources are considered as part of the hicolor icon theme and must be located in subdirectories that are defined in the hicolor icon theme, such as `@path/16x16/actions/run.png` or `@path/scalable/actions/run.svg`.
Icons that are directly placed in the resource path instead of a subdirectory are also considered as ultimate fallback, but they are treated like unthemed icons.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkIconTheme](gtkicontheme#GtkIconTheme-struct) | |
| path | NULL-terminated array of resource paths that are searched for icons | |
### gtk\_icon\_theme\_get\_resource\_path ()
```
char **
gtk_icon_theme_get_resource_path (*`[GtkIconTheme](gtkicontheme#GtkIconTheme-struct) *self`*);
```
Gets the current resource path.
See [`gtk_icon_theme_set_resource_path()`](gtkicontheme#gtk-icon-theme-set-resource-path).
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkIconTheme](gtkicontheme#GtkIconTheme-struct) | |
#### Returns
A list of resource paths or `NULL`. The returned value should be freed with `g_strfreev()`.
[transfer full][array zero-terminated=1][element-type utf8][nullable]
### gtk\_icon\_theme\_add\_resource\_path ()
```
void
gtk_icon_theme_add_resource_path (*`[GtkIconTheme](gtkicontheme#GtkIconTheme-struct) *self`*,
*`const char *path`*);
```
Adds a resource path that will be looked at when looking for icons, similar to search paths.
See [`gtk_icon_theme_set_resource_path()`](gtkicontheme#gtk-icon-theme-set-resource-path).
This function should be used to make application-specific icons available as part of the icon theme.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkIconTheme](gtkicontheme#GtkIconTheme-struct) | |
| path | a resource path | |
### gtk\_icon\_theme\_set\_theme\_name ()
```
void
gtk_icon_theme_set_theme_name (*`[GtkIconTheme](gtkicontheme#GtkIconTheme-struct) *self`*,
*`const char *theme_name`*);
```
Sets the name of the icon theme that the [GtkIconTheme](gtkicontheme#GtkIconTheme-struct) object uses overriding system configuration. This function cannot be called on the icon theme objects returned from [`gtk_icon_theme_get_for_display()`](gtkicontheme#gtk-icon-theme-get-for-display).
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkIconTheme](gtkicontheme#GtkIconTheme-struct) | |
| theme\_name | name of icon theme to use instead of configured theme, or `NULL` to unset a previously set custom theme. | [allow-none] |
### gtk\_icon\_theme\_get\_theme\_name ()
```
char *
gtk_icon_theme_get_theme_name (*`[GtkIconTheme](gtkicontheme#GtkIconTheme-struct) *self`*);
```
Gets the current icon theme name.
Returns (transfer full): the current icon theme name,
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkIconTheme](gtkicontheme#GtkIconTheme-struct) | |
### gtk\_icon\_theme\_has\_icon ()
```
gboolean
gtk_icon_theme_has_icon (*`[GtkIconTheme](gtkicontheme#GtkIconTheme-struct) *self`*,
*`const char *icon_name`*);
```
Checks whether an icon theme includes an icon for a particular name.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkIconTheme](gtkicontheme#GtkIconTheme-struct) | |
| icon\_name | the name of an icon | |
#### Returns
`TRUE` if *`self`* includes an icon for *`icon_name`* .
### gtk\_icon\_theme\_lookup\_icon ()
```
[GtkIconPaintable](gtkicontheme#GtkIconPaintable) *
gtk_icon_theme_lookup_icon (*`[GtkIconTheme](gtkicontheme#GtkIconTheme-struct) *self`*,
*`const char *icon_name`*,
*`const char *fallbacks[]`*,
*`int size`*,
*`int scale`*,
*`[GtkTextDirection](gtkwidget#GtkTextDirection) direction`*,
*`[GtkIconLookupFlags](gtkicontheme#GtkIconLookupFlags) flags`*);
```
Looks up a named icon for a desired size and window scale, returning a [GtkIconPaintable](gtkicontheme#GtkIconPaintable). The icon can then be rendered by using it as a [GdkPaintable](https://developer-old.gnome.org/gtk4/html/GdkPaintable.html#GdkPaintable-struct), or you can get information such as the filename and size.
If the available *`icon_name`* is not available and *`fallbacks`* are provided, they will be tried in order.
If no matching icon is found, then a paintable that renders the "missing icon" icon is returned. If you need to do something else for missing icons you need to use [`gtk_icon_theme_has_icon()`](gtkicontheme#gtk-icon-theme-has-icon).
Note that you probably want to listen for icon theme changes and update the icon. This is usually done by overriding the [`GtkWidgetClass.css-`changed()``](gtkwidget#GtkWidgetClass.css-changed) function.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkIconTheme](gtkicontheme#GtkIconTheme-struct) | |
| icon\_name | the name of the icon to lookup | |
| fallbacks | . | [nullable][array zero-terminated=1] |
| size | desired icon size. | |
| scale | the window scale this will be displayed on | |
| direction | text direction the icon will be displayed in | |
| flags | flags modifying the behavior of the icon lookup | |
#### Returns
a [GtkIconPaintable](gtkicontheme#GtkIconPaintable) object containing the icon.
[transfer full]
### gtk\_icon\_theme\_lookup\_by\_gicon ()
```
[GtkIconPaintable](gtkicontheme#GtkIconPaintable) *
gtk_icon_theme_lookup_by_gicon (*`[GtkIconTheme](gtkicontheme#GtkIconTheme-struct) *self`*,
*`GIcon *icon`*,
*`int size`*,
*`int scale`*,
*`[GtkTextDirection](gtkwidget#GtkTextDirection) direction`*,
*`[GtkIconLookupFlags](gtkicontheme#GtkIconLookupFlags) flags`*);
```
Looks up a icon for a desired size and window scale, returning a [GtkIconPaintable](gtkicontheme#GtkIconPaintable). The icon can then be rendered by using it as a [GdkPaintable](https://developer-old.gnome.org/gtk4/html/GdkPaintable.html#GdkPaintable-struct), or you can get information such as the filename and size.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkIconTheme](gtkicontheme#GtkIconTheme-struct) | |
| icon | the GIcon to look up | |
| size | desired icon size | |
| scale | the desired scale | |
| direction | text direction the icon will be displayed in | |
| flags | flags modifying the behavior of the icon lookup | |
#### Returns
a [GtkIconPaintable](gtkicontheme#GtkIconPaintable) containing information about the icon. Unref with `g_object_unref()`.
[transfer full]
### gtk\_icon\_theme\_get\_icon\_names ()
```
char **
gtk_icon_theme_get_icon_names (*`[GtkIconTheme](gtkicontheme#GtkIconTheme-struct) *self`*);
```
Lists the names of icons in the current icon theme.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkIconTheme](gtkicontheme#GtkIconTheme-struct) | |
#### Returns
a string array holding the names of all the icons in the theme. You must free the array using `g_strfreev()`.
[element-type utf8][transfer full]
### gtk\_icon\_theme\_get\_icon\_sizes ()
```
int *
gtk_icon_theme_get_icon_sizes (*`[GtkIconTheme](gtkicontheme#GtkIconTheme-struct) *self`*,
*`const char *icon_name`*);
```
Returns an array of integers describing the sizes at which the icon is available without scaling. A size of -1 means that the icon is available in a scalable format. The array is zero-terminated.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkIconTheme](gtkicontheme#GtkIconTheme-struct) | |
| icon\_name | the name of an icon | |
#### Returns
A newly allocated array describing the sizes at which the icon is available. The array should be freed with `g_free()` when it is no longer needed.
[array zero-terminated=1][transfer full]
### gtk\_icon\_paintable\_new\_for\_file ()
```
[GtkIconPaintable](gtkicontheme#GtkIconPaintable) *
gtk_icon_paintable_new_for_file (*`GFile *file`*,
*`int size`*,
*`int scale`*);
```
Creates a [GtkIconPaintable](gtkicontheme#GtkIconPaintable) for a file with a given size and scale [GtkIconPaintable](gtkicontheme#GtkIconPaintable). The icon can then be rendered by using it as a [GdkPaintable](https://developer-old.gnome.org/gtk4/html/GdkPaintable.html#GdkPaintable-struct).
#### Parameters
| | | |
| --- | --- | --- |
| file | a GFile | |
| size | desired icon size | |
| scale | the desired scale | |
#### Returns
a [GtkIconPaintable](gtkicontheme#GtkIconPaintable) containing for the icon. Unref with `g_object_unref()`.
[transfer full]
### gtk\_icon\_paintable\_get\_file ()
```
GFile *
gtk_icon_paintable_get_file (*`[GtkIconPaintable](gtkicontheme#GtkIconPaintable) *self`*);
```
Gets the GFile that was used to load the icon, or `NULL` if the icon was not loaded from a file.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkIconPaintable](gtkicontheme#GtkIconPaintable) | |
#### Returns
the GFile for the icon, or `NULL`. Free with `g_object_unref()`.
[nullable][transfer full]
### gtk\_icon\_paintable\_get\_icon\_name ()
```
const char *
gtk_icon_paintable_get_icon_name (*`[GtkIconPaintable](gtkicontheme#GtkIconPaintable) *self`*);
```
Get the icon name being used for this icon.
When an icon looked up in the icon theme was not available, the icon theme may use fallback icons - either those specified to [`gtk_icon_theme_lookup_icon()`](gtkicontheme#gtk-icon-theme-lookup-icon) or the always-available "image-missing". The icon chosen is returned by this function.
If the icon was created without an icon theme, this function returns `NULL`.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkIconPaintable](gtkicontheme#GtkIconPaintable) | |
#### Returns
the themed icon-name for the icon, or `NULL` if its not a themed icon.
[nullable][type filename]
### gtk\_icon\_paintable\_is\_symbolic ()
```
gboolean
gtk_icon_paintable_is_symbolic (*`[GtkIconPaintable](gtkicontheme#GtkIconPaintable) *self`*);
```
Checks if the icon is symbolic or not. This currently uses only the file name and not the file contents for determining this. This behaviour may change in the future.
Note that to render a symbolic [GtkIconPaintable](gtkicontheme#GtkIconPaintable) properly (with recoloring), you have to set its icon name on a [GtkImage](gtkimage#GtkImage-struct).
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkIconPaintable](gtkicontheme#GtkIconPaintable) | |
#### Returns
`TRUE` if the icon is symbolic, `FALSE` otherwise
Types and Values
----------------
### GtkIconPaintable
```
typedef struct _GtkIconPaintable GtkIconPaintable;
```
Contains information found when looking up an icon in an icon theme and supports painting it as a [GdkPaintable](https://developer-old.gnome.org/gtk4/html/GdkPaintable.html#GdkPaintable-struct).
### GtkIconTheme
```
typedef struct _GtkIconTheme GtkIconTheme;
```
Acts as a database of information about an icon theme. Normally, you retrieve the icon theme for a particular display using [`gtk_icon_theme_get_for_display()`](gtkicontheme#gtk-icon-theme-get-for-display) and it will contain information about current icon theme for that display, but you can also create a new [GtkIconTheme](gtkicontheme#GtkIconTheme-struct) object and set the icon theme name explicitly using [`gtk_icon_theme_set_theme_name()`](gtkicontheme#gtk-icon-theme-set-theme-name).
### enum GtkIconLookupFlags
Used to specify options for [`gtk_icon_theme_lookup_icon()`](gtkicontheme#gtk-icon-theme-lookup-icon)
#### Members
| | | |
| --- | --- | --- |
| GTK\_ICON\_LOOKUP\_FORCE\_REGULAR | Try to always load regular icons, even when symbolic icon names are given | |
| GTK\_ICON\_LOOKUP\_FORCE\_SYMBOLIC | Try to always load symbolic icons, even when regular icon names are given | |
| GTK\_ICON\_LOOKUP\_PRELOAD | Starts loading the texture in the background so it is ready when later needed. | |
### GTK\_ICON\_THEME\_ERROR
```
#define GTK_ICON_THEME_ERROR gtk_icon_theme_error_quark ()
```
The GQuark used for [GtkIconThemeError](gtkicontheme#GtkIconThemeError) errors.
### GTK\_TYPE\_ICON\_THEME\_ERROR
```
#define GTK_TYPE_ICON_THEME_ERROR (gtk_icon_theme_error_get_type ())
```
### GTK\_TYPE\_ICON\_LOOKUP\_FLAGS
```
#define GTK_TYPE_ICON_LOOKUP_FLAGS (gtk_icon_lookup_flags_get_type ())
```
### enum GtkIconThemeError
Error codes for GtkIconTheme operations.
#### Members
| | | |
| --- | --- | --- |
| GTK\_ICON\_THEME\_NOT\_FOUND | The icon specified does not exist in the theme | |
| GTK\_ICON\_THEME\_FAILED | An unspecified error occurred. | |
Property Details
----------------
### The `“display”` property
```
“display” [GdkDisplay](https://developer-old.gnome.org/gtk4/html/GdkDisplay.html#GdkDisplay-struct) *
```
The display that this icon theme object is attached to.
Owner: GtkIconTheme
Flags: Read / Write
### The `“icon-names”` property
```
“icon-names” GStrv
```
The icon names that are supported by the icon theme.
Owner: GtkIconTheme
Flags: Read
### The `“resource-path”` property
```
“resource-path” GStrv
```
Resource paths that will be looked at when looking for icons, similar to search paths.
The resources are considered as part of the hicolor icon theme and must be located in subdirectories that are defined in the hicolor icon theme, such as `@path/16x16/actions/run.png`. Icons that are directly placed in the resource path instead of a subdirectory are also considered as ultimate fallback.
Owner: GtkIconTheme
Flags: Read / Write
### The `“search-path”` property
```
“search-path” GStrv
```
The search path for this icon theme.
When looking for icons, GTK will search for a subdirectory of one or more of the directories in the search path with the same name as the icon theme containing an index.theme file. (Themes from multiple of the path elements are combined to allow themes to be extended by adding icons in the user’s home directory.)
Owner: GtkIconTheme
Flags: Read / Write
### The `“theme-name”` property
```
“theme-name” char *
```
The name of the icon theme that is being used.
Unless set to a different value, this will be the value of the [“gtk-icon-theme-name”](gtksettings#GtkSettings--gtk-icon-theme-name) property of the [GtkSettings](gtksettings#GtkSettings-struct) object associated to the display of the icontheme object.
Owner: GtkIconTheme
Flags: Read / Write
Default value: NULL
Signal Details
--------------
### The `“changed”` signal
```
void
user_function ([GtkIconTheme](gtkicontheme#GtkIconTheme-struct) *self,
gpointer user_data)
```
Emitted when the current icon theme is switched or GTK detects that a change has occurred in the contents of the current icon theme.
#### Parameters
| | | |
| --- | --- | --- |
| self | the icon theme | |
| user\_data | user data set when the signal handler was connected. | |
Flags: Run Last
| programming_docs |
gtk GtkBoolFilter GtkBoolFilter
=============
GtkBoolFilter — Filtering by boolean expressions
Functions
---------
| | |
| --- | --- |
| [GtkBoolFilter](https://developer-old.gnome.org/usr/share/gtk-doc/html/gtk4/gtk4-GtkBoolFilter.html#GtkBoolFilter) \* | [gtk\_bool\_filter\_new](gtkboolfilter#gtk-bool-filter-new) () |
| [GtkExpression](gtkexpression#GtkExpression-struct) \* | [gtk\_bool\_filter\_get\_expression](gtkboolfilter#gtk-bool-filter-get-expression) () |
| void | [gtk\_bool\_filter\_set\_expression](gtkboolfilter#gtk-bool-filter-set-expression) () |
| gboolean | [gtk\_bool\_filter\_get\_invert](gtkboolfilter#gtk-bool-filter-get-invert) () |
| void | [gtk\_bool\_filter\_set\_invert](gtkboolfilter#gtk-bool-filter-set-invert) () |
Properties
----------
| | | |
| --- | --- | --- |
| [GtkExpression](gtkexpression#GtkExpression-struct) \* | [expression](gtkboolfilter#GtkBoolFilter--expression) | Read / Write |
| gboolean | [invert](gtkboolfilter#GtkBoolFilter--invert) | Read / Write |
Types and Values
----------------
| | |
| --- | --- |
| | [GtkBoolFilter](gtkboolfilter#GtkBoolFilter-struct) |
Object Hierarchy
----------------
```
GObject
╰── [GtkFilter](gtkfilter#GtkFilter-struct)
╰── GtkBoolFilter
```
Includes
--------
```
#include <gtk/gtk.h>
```
Description
-----------
GtkBoolFilter is a simple filter that takes a boolean [GtkExpression](gtkexpression#GtkExpression-struct) to determine whether to include items.
Functions
---------
### gtk\_bool\_filter\_new ()
```
[GtkBoolFilter](https://developer-old.gnome.org/usr/share/gtk-doc/html/gtk4/gtk4-GtkBoolFilter.html#GtkBoolFilter) *
gtk_bool_filter_new (*`[GtkExpression](gtkexpression#GtkExpression-struct) *expression`*);
```
Creates a new bool filter.
#### Parameters
| | | |
| --- | --- | --- |
| expression | The expression to evaluate or `NULL` for none. | [transfer full][nullable] |
#### Returns
a new [GtkBoolFilter](https://developer-old.gnome.org/usr/share/gtk-doc/html/gtk4/gtk4-GtkBoolFilter.html#GtkBoolFilter)
### gtk\_bool\_filter\_get\_expression ()
```
[GtkExpression](gtkexpression#GtkExpression-struct) *
gtk_bool_filter_get_expression (*`[GtkBoolFilter](https://developer-old.gnome.org/usr/share/gtk-doc/html/gtk4/gtk4-GtkBoolFilter.html#GtkBoolFilter) *self`*);
```
Gets the expression that the filter uses to evaluate if an item should be filtered.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkBoolFilter](https://developer-old.gnome.org/usr/share/gtk-doc/html/gtk4/gtk4-GtkBoolFilter.html#GtkBoolFilter) | |
#### Returns
a [GtkExpression](gtkexpression#GtkExpression-struct).
[transfer none]
### gtk\_bool\_filter\_set\_expression ()
```
void
gtk_bool_filter_set_expression (*`[GtkBoolFilter](https://developer-old.gnome.org/usr/share/gtk-doc/html/gtk4/gtk4-GtkBoolFilter.html#GtkBoolFilter) *self`*,
*`[GtkExpression](gtkexpression#GtkExpression-struct) *expression`*);
```
Sets the expression that the filter uses to check if items should be filtered. The expression must have a value type of G\_TYPE\_BOOLEAN.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkBoolFilter](https://developer-old.gnome.org/usr/share/gtk-doc/html/gtk4/gtk4-GtkBoolFilter.html#GtkBoolFilter) | |
| expression | a [GtkExpression](gtkexpression#GtkExpression-struct) | |
### gtk\_bool\_filter\_get\_invert ()
```
gboolean
gtk_bool_filter_get_invert (*`[GtkBoolFilter](https://developer-old.gnome.org/usr/share/gtk-doc/html/gtk4/gtk4-GtkBoolFilter.html#GtkBoolFilter) *self`*);
```
Returns whether the filter inverts the expression.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkBoolFilter](https://developer-old.gnome.org/usr/share/gtk-doc/html/gtk4/gtk4-GtkBoolFilter.html#GtkBoolFilter) | |
#### Returns
`TRUE` if the filter inverts
### gtk\_bool\_filter\_set\_invert ()
```
void
gtk_bool_filter_set_invert (*`[GtkBoolFilter](https://developer-old.gnome.org/usr/share/gtk-doc/html/gtk4/gtk4-GtkBoolFilter.html#GtkBoolFilter) *self`*,
*`gboolean invert`*);
```
Sets whether the filter should invert the expression.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkBoolFilter](https://developer-old.gnome.org/usr/share/gtk-doc/html/gtk4/gtk4-GtkBoolFilter.html#GtkBoolFilter) | |
| invert | `TRUE` to invert | |
Types and Values
----------------
### GtkBoolFilter
```
typedef struct _GtkBoolFilter GtkBoolFilter;
```
Property Details
----------------
### The `“expression”` property
```
“expression” [GtkExpression](gtkexpression#GtkExpression-struct) *
```
The boolean expression to evaluate on item
[type GtkExpression]
Owner: GtkBoolFilter
Flags: Read / Write
### The `“invert”` property
```
“invert” gboolean
```
If the expression result should be inverted
Owner: GtkBoolFilter
Flags: Read / Write
Default value: FALSE
gtk GtkScaleButton GtkScaleButton
==============
GtkScaleButton — A button which pops up a scale
Functions
---------
| | |
| --- | --- |
| [GtkWidget](gtkwidget#GtkWidget-struct) \* | [gtk\_scale\_button\_new](gtkscalebutton#gtk-scale-button-new) () |
| void | [gtk\_scale\_button\_set\_adjustment](gtkscalebutton#gtk-scale-button-set-adjustment) () |
| void | [gtk\_scale\_button\_set\_icons](gtkscalebutton#gtk-scale-button-set-icons) () |
| void | [gtk\_scale\_button\_set\_value](gtkscalebutton#gtk-scale-button-set-value) () |
| [GtkAdjustment](gtkadjustment#GtkAdjustment-struct) \* | [gtk\_scale\_button\_get\_adjustment](gtkscalebutton#gtk-scale-button-get-adjustment) () |
| double | [gtk\_scale\_button\_get\_value](gtkscalebutton#gtk-scale-button-get-value) () |
| [GtkWidget](gtkwidget#GtkWidget-struct) \* | [gtk\_scale\_button\_get\_popup](gtkscalebutton#gtk-scale-button-get-popup) () |
| [GtkWidget](gtkwidget#GtkWidget-struct) \* | [gtk\_scale\_button\_get\_plus\_button](gtkscalebutton#gtk-scale-button-get-plus-button) () |
| [GtkWidget](gtkwidget#GtkWidget-struct) \* | [gtk\_scale\_button\_get\_minus\_button](gtkscalebutton#gtk-scale-button-get-minus-button) () |
Properties
----------
| | | |
| --- | --- | --- |
| [GtkAdjustment](gtkadjustment#GtkAdjustment-struct) \* | [adjustment](gtkscalebutton#GtkScaleButton--adjustment) | Read / Write |
| GStrv | [icons](gtkscalebutton#GtkScaleButton--icons) | Read / Write |
| double | [value](gtkscalebutton#GtkScaleButton--value) | Read / Write |
Signals
-------
| | | |
| --- | --- | --- |
| void | [popdown](gtkscalebutton#GtkScaleButton-popdown) | Action |
| void | [popup](gtkscalebutton#GtkScaleButton-popup) | Action |
| void | [value-changed](gtkscalebutton#GtkScaleButton-value-changed) | Run Last |
Types and Values
----------------
| | |
| --- | --- |
| struct | [GtkScaleButton](gtkscalebutton#GtkScaleButton-struct) |
Object Hierarchy
----------------
```
GObject
╰── GInitiallyUnowned
╰── [GtkWidget](gtkwidget#GtkWidget-struct)
╰── GtkScaleButton
╰── [GtkVolumeButton](gtkvolumebutton#GtkVolumeButton-struct)
```
Implemented Interfaces
----------------------
GtkScaleButton implements [GtkAccessible](gtkaccessible#GtkAccessible-struct), [GtkBuildable](gtkbuildable#GtkBuildable-struct), [GtkConstraintTarget](gtkconstraint#GtkConstraintTarget-struct) and [GtkOrientable](gtk4-orientable#GtkOrientable-struct).
Includes
--------
```
#include <gtk/gtk.h>
```
Description
-----------
[GtkScaleButton](gtkscalebutton#GtkScaleButton-struct) provides a button which pops up a scale widget. This kind of widget is commonly used for volume controls in multimedia applications, and GTK provides a [GtkVolumeButton](gtkvolumebutton#GtkVolumeButton-struct) subclass that is tailored for this use case.
### CSS nodes
GtkScaleButton has a single CSS node with name button. To differentiate it from a plain [GtkButton](gtkbutton#GtkButton-struct), it gets the .scale style class.
Functions
---------
### gtk\_scale\_button\_new ()
```
[GtkWidget](gtkwidget#GtkWidget-struct) *
gtk_scale_button_new (*`double min`*,
*`double max`*,
*`double step`*,
*`const char **icons`*);
```
Creates a [GtkScaleButton](gtkscalebutton#GtkScaleButton-struct), with a range between *`min`* and *`max`* , with a stepping of *`step`* .
#### Parameters
| | | |
| --- | --- | --- |
| min | the minimum value of the scale (usually 0) | |
| max | the maximum value of the scale (usually 100) | |
| step | the stepping of value when a scroll-wheel event, or up/down arrow event occurs (usually 2) | |
| icons | a `NULL`-terminated array of icon names, or `NULL` if you want to set the list later with [`gtk_scale_button_set_icons()`](gtkscalebutton#gtk-scale-button-set-icons). | [allow-none][array zero-terminated=1] |
#### Returns
a new [GtkScaleButton](gtkscalebutton#GtkScaleButton-struct)
### gtk\_scale\_button\_set\_adjustment ()
```
void
gtk_scale_button_set_adjustment (*`[GtkScaleButton](gtkscalebutton#GtkScaleButton-struct) *button`*,
*`[GtkAdjustment](gtkadjustment#GtkAdjustment-struct) *adjustment`*);
```
Sets the [GtkAdjustment](gtkadjustment#GtkAdjustment-struct) to be used as a model for the [GtkScaleButton](gtkscalebutton#GtkScaleButton-struct)’s scale. See [`gtk_range_set_adjustment()`](gtkrange#gtk-range-set-adjustment) for details.
#### Parameters
| | | |
| --- | --- | --- |
| button | a [GtkScaleButton](gtkscalebutton#GtkScaleButton-struct) | |
| adjustment | a [GtkAdjustment](gtkadjustment#GtkAdjustment-struct) | |
### gtk\_scale\_button\_set\_icons ()
```
void
gtk_scale_button_set_icons (*`[GtkScaleButton](gtkscalebutton#GtkScaleButton-struct) *button`*,
*`const char **icons`*);
```
Sets the icons to be used by the scale button. For details, see the [“icons”](gtkscalebutton#GtkScaleButton--icons) property.
#### Parameters
| | | |
| --- | --- | --- |
| button | a [GtkScaleButton](gtkscalebutton#GtkScaleButton-struct) | |
| icons | a `NULL`-terminated array of icon names. | [array zero-terminated=1] |
### gtk\_scale\_button\_set\_value ()
```
void
gtk_scale_button_set_value (*`[GtkScaleButton](gtkscalebutton#GtkScaleButton-struct) *button`*,
*`double value`*);
```
Sets the current value of the scale; if the value is outside the minimum or maximum range values, it will be clamped to fit inside them. The scale button emits the [“value-changed”](gtkscalebutton#GtkScaleButton-value-changed) signal if the value changes.
#### Parameters
| | | |
| --- | --- | --- |
| button | a [GtkScaleButton](gtkscalebutton#GtkScaleButton-struct) | |
| value | new value of the scale button | |
### gtk\_scale\_button\_get\_adjustment ()
```
[GtkAdjustment](gtkadjustment#GtkAdjustment-struct) *
gtk_scale_button_get_adjustment (*`[GtkScaleButton](gtkscalebutton#GtkScaleButton-struct) *button`*);
```
Gets the [GtkAdjustment](gtkadjustment#GtkAdjustment-struct) associated with the [GtkScaleButton](gtkscalebutton#GtkScaleButton-struct)’s scale. See [`gtk_range_get_adjustment()`](gtkrange#gtk-range-get-adjustment) for details.
#### Parameters
| | | |
| --- | --- | --- |
| button | a [GtkScaleButton](gtkscalebutton#GtkScaleButton-struct) | |
#### Returns
the adjustment associated with the scale.
[transfer none]
### gtk\_scale\_button\_get\_value ()
```
double
gtk_scale_button_get_value (*`[GtkScaleButton](gtkscalebutton#GtkScaleButton-struct) *button`*);
```
Gets the current value of the scale button.
#### Parameters
| | | |
| --- | --- | --- |
| button | a [GtkScaleButton](gtkscalebutton#GtkScaleButton-struct) | |
#### Returns
current value of the scale button
### gtk\_scale\_button\_get\_popup ()
```
[GtkWidget](gtkwidget#GtkWidget-struct) *
gtk_scale_button_get_popup (*`[GtkScaleButton](gtkscalebutton#GtkScaleButton-struct) *button`*);
```
Retrieves the popup of the [GtkScaleButton](gtkscalebutton#GtkScaleButton-struct).
#### Parameters
| | | |
| --- | --- | --- |
| button | a [GtkScaleButton](gtkscalebutton#GtkScaleButton-struct) | |
#### Returns
the popup of the [GtkScaleButton](gtkscalebutton#GtkScaleButton-struct).
[transfer none]
### gtk\_scale\_button\_get\_plus\_button ()
```
[GtkWidget](gtkwidget#GtkWidget-struct) *
gtk_scale_button_get_plus_button (*`[GtkScaleButton](gtkscalebutton#GtkScaleButton-struct) *button`*);
```
Retrieves the plus button of the [GtkScaleButton](gtkscalebutton#GtkScaleButton-struct).
#### Parameters
| | | |
| --- | --- | --- |
| button | a [GtkScaleButton](gtkscalebutton#GtkScaleButton-struct) | |
#### Returns
the plus button of the [GtkScaleButton](gtkscalebutton#GtkScaleButton-struct) as a [GtkButton](gtkbutton#GtkButton-struct).
[transfer none][type Gtk.Button]
### gtk\_scale\_button\_get\_minus\_button ()
```
[GtkWidget](gtkwidget#GtkWidget-struct) *
gtk_scale_button_get_minus_button (*`[GtkScaleButton](gtkscalebutton#GtkScaleButton-struct) *button`*);
```
Retrieves the minus button of the [GtkScaleButton](gtkscalebutton#GtkScaleButton-struct).
#### Parameters
| | | |
| --- | --- | --- |
| button | a [GtkScaleButton](gtkscalebutton#GtkScaleButton-struct) | |
#### Returns
the minus button of the [GtkScaleButton](gtkscalebutton#GtkScaleButton-struct) as a [GtkButton](gtkbutton#GtkButton-struct).
[transfer none][type Gtk.Button]
Types and Values
----------------
### struct GtkScaleButton
```
struct GtkScaleButton;
```
Property Details
----------------
### The `“adjustment”` property
```
“adjustment” [GtkAdjustment](gtkadjustment#GtkAdjustment-struct) *
```
The GtkAdjustment that contains the current value of this scale button object.
Owner: GtkScaleButton
Flags: Read / Write
### The `“icons”` property
```
“icons” GStrv
```
The names of the icons to be used by the scale button. The first item in the array will be used in the button when the current value is the lowest value, the second item for the highest value. All the subsequent icons will be used for all the other values, spread evenly over the range of values.
If there's only one icon name in the *`icons`* array, it will be used for all the values. If only two icon names are in the *`icons`* array, the first one will be used for the bottom 50% of the scale, and the second one for the top 50%.
It is recommended to use at least 3 icons so that the [GtkScaleButton](gtkscalebutton#GtkScaleButton-struct) reflects the current value of the scale better for the users.
Owner: GtkScaleButton
Flags: Read / Write
### The `“value”` property
```
“value” double
```
The value of the scale.
Owner: GtkScaleButton
Flags: Read / Write
Default value: 0
Signal Details
--------------
### The `“popdown”` signal
```
void
user_function ([GtkScaleButton](gtkscalebutton#GtkScaleButton-struct) *button,
gpointer user_data)
```
The ::popdown signal is a [keybinding signal](gtkshortcutaction#GtkSignalAction-struct) which gets emitted to popdown the scale widget.
The default binding for this signal is Escape.
#### Parameters
| | | |
| --- | --- | --- |
| button | the object which received the signal | |
| user\_data | user data set when the signal handler was connected. | |
Flags: Action
### The `“popup”` signal
```
void
user_function ([GtkScaleButton](gtkscalebutton#GtkScaleButton-struct) *button,
gpointer user_data)
```
The ::popup signal is a [keybinding signal](gtkshortcutaction#GtkSignalAction-struct) which gets emitted to popup the scale widget.
The default bindings for this signal are Space, Enter and Return.
#### Parameters
| | | |
| --- | --- | --- |
| button | the object which received the signal | |
| user\_data | user data set when the signal handler was connected. | |
Flags: Action
### The `“value-changed”` signal
```
void
user_function ([GtkScaleButton](gtkscalebutton#GtkScaleButton-struct) *button,
double value,
gpointer user_data)
```
The ::value-changed signal is emitted when the value field has changed.
#### Parameters
| | | |
| --- | --- | --- |
| button | the object which received the signal | |
| value | the new value | |
| user\_data | user data set when the signal handler was connected. | |
Flags: Run Last
gtk GtkStringList GtkStringList
=============
GtkStringList — A list model for strings
Functions
---------
| | |
| --- | --- |
| [GtkStringList](gtkstringlist#GtkStringList-struct) \* | [gtk\_string\_list\_new](gtkstringlist#gtk-string-list-new) () |
| void | [gtk\_string\_list\_append](gtkstringlist#gtk-string-list-append) () |
| void | [gtk\_string\_list\_take](gtkstringlist#gtk-string-list-take) () |
| void | [gtk\_string\_list\_remove](gtkstringlist#gtk-string-list-remove) () |
| void | [gtk\_string\_list\_splice](gtkstringlist#gtk-string-list-splice) () |
| const char \* | [gtk\_string\_list\_get\_string](gtkstringlist#gtk-string-list-get-string) () |
| [GtkStringObject](gtkstringlist#GtkStringObject-struct) \* | [gtk\_string\_object\_new](gtkstringlist#gtk-string-object-new) () |
| const char \* | [gtk\_string\_object\_get\_string](gtkstringlist#gtk-string-object-get-string) () |
Properties
----------
| | | |
| --- | --- | --- |
| char \* | [string](gtkstringlist#GtkStringObject--string) | Read |
Types and Values
----------------
| | |
| --- | --- |
| | [GtkStringList](gtkstringlist#GtkStringList-struct) |
| | [GtkStringObject](gtkstringlist#GtkStringObject-struct) |
Object Hierarchy
----------------
```
GObject
├── GtkStringList
╰── GtkStringObject
```
Implemented Interfaces
----------------------
GtkStringList implements [GtkBuildable](gtkbuildable#GtkBuildable-struct) and GListModel.
Includes
--------
```
#include <gtk/gtk.h>
```
Description
-----------
[GtkStringList](gtkstringlist#GtkStringList-struct) is a list model that wraps an array of strings.
The objects in the model have a "string" property.
GtkStringList is well-suited for any place where you would typically use a `char*[]`, but need a list model.
### GtkStringList as GtkBuildable
The GtkStringList implementation of the GtkBuildable interface supports adding items directly using the <items> element and specifying <item> elements for each item. Each <item> element supports the regular translation attributes “translatable”, “context” and “comments”.
Here is a UI definition fragment specifying a GtkStringList
Functions
---------
### gtk\_string\_list\_new ()
```
[GtkStringList](gtkstringlist#GtkStringList-struct) *
gtk_string_list_new (*`const char * const *strings`*);
```
Creates a new [GtkStringList](gtkstringlist#GtkStringList-struct) with the given *`strings`* .
#### Parameters
| | | |
| --- | --- | --- |
| strings | The strings to put in the model. | [array zero-terminated=1][nullable] |
#### Returns
a new [GtkStringList](gtkstringlist#GtkStringList-struct)
### gtk\_string\_list\_append ()
```
void
gtk_string_list_append (*`[GtkStringList](gtkstringlist#GtkStringList-struct) *self`*,
*`const char *string`*);
```
Appends *`string`* to *`self`* .
The *`string`* will be copied. See [`gtk_string_list_take()`](gtkstringlist#gtk-string-list-take) for a way to avoid that.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkStringList](gtkstringlist#GtkStringList-struct) | |
| string | the string to insert | |
### gtk\_string\_list\_take ()
```
void
gtk_string_list_take (*`[GtkStringList](gtkstringlist#GtkStringList-struct) *self`*,
*`char *string`*);
```
Adds *`string`* to self at the end, and takes ownership of it.
This variant of [`gtk_string_list_append()`](gtkstringlist#gtk-string-list-append) is convenient for formatting strings:
```
<object class="GtkStringList">
<items>
<item translatable="yes">Factory</item>
<item translatable="yes">Home</item>
<item translatable="yes">Subway</item>
</items>
</object>
```
| #### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkStringList](gtkstringlist#GtkStringList-struct) | |
| string | the string to insert. | [transfer full] |
### gtk\_string\_list\_remove ()
```
void
gtk_string_list_remove (*`[GtkStringList](gtkstringlist#GtkStringList-struct) *self`*,
*`guint position`*);
```
Removes the string at *`position`* from *`self`* . *`position`* must be smaller than the current length of the list.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkStringList](gtkstringlist#GtkStringList-struct) | |
| position | the position of the string that is to be removed | |
### gtk\_string\_list\_splice ()
```
void
gtk_string_list_splice (*`[GtkStringList](gtkstringlist#GtkStringList-struct) *self`*,
*`guint position`*,
*`guint n_removals`*,
*`const char * const *additions`*);
```
Changes *`self`* by removing *`n_removals`* strings and adding *`additions`* to it.
This function is more efficient than [`gtk_string_list_append()`](gtkstringlist#gtk-string-list-append) and [`gtk_string_list_remove()`](gtkstringlist#gtk-string-list-remove), because it only emits “items-changed” once for the change.
This function copies the strings in *`additions`* .
The parameters *`position`* and *`n_removals`* must be correct (ie: *`position`* + *`n_removals`* must be less than or equal to the length of the list at the time this function is called).
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkStringList](gtkstringlist#GtkStringList-struct) | |
| position | the position at which to make the change | |
| n\_removals | the number of strings to remove | |
| additions | The strings to add. | [array zero-terminated=1][nullable] |
### gtk\_string\_list\_get\_string ()
```
const char *
gtk_string_list_get_string (*`[GtkStringList](gtkstringlist#GtkStringList-struct) *self`*,
*`guint position`*);
```
Gets the string that is at *`position`* in *`self`* . If *`self`* does not contain *`position`* items, `NULL` is returned.
This function returns the const char \*. To get the object wrapping it, use `g_list_model_get_item()`.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkStringList](gtkstringlist#GtkStringList-struct) | |
| position | the position to get the string for | |
#### Returns
the string at the given position.
[nullable]
### gtk\_string\_object\_new ()
```
[GtkStringObject](gtkstringlist#GtkStringObject-struct) *
gtk_string_object_new (*`const char *string`*);
```
Wraps a string in an object for use with GListModel
#### Parameters
| | | |
| --- | --- | --- |
| string | The string to wrap. | [not nullable] |
#### Returns
a new [GtkStringObject](gtkstringlist#GtkStringObject-struct)
### gtk\_string\_object\_get\_string ()
```
const char *
gtk_string_object_get_string (*`[GtkStringObject](gtkstringlist#GtkStringObject-struct) *self`*);
```
Returns the string contained in a [GtkStringObject](gtkstringlist#GtkStringObject-struct).
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkStringObject](gtkstringlist#GtkStringObject-struct) | |
#### Returns
the string of *`self`*
Types and Values
----------------
### GtkStringList
```
typedef struct _GtkStringList GtkStringList;
```
### GtkStringObject
```
typedef struct _GtkStringObject GtkStringObject;
```
Property Details
----------------
### The `“string”` property
```
“string” char *
```
String.
Owner: GtkStringObject
Flags: Read
Default value: NULL
See Also
--------
GListModel
| programming_docs |
gtk GtkMultiFilter GtkMultiFilter
==============
GtkMultiFilter — Combining multiple filters
Functions
---------
| | |
| --- | --- |
| void | [gtk\_multi\_filter\_append](gtkmultifilter#gtk-multi-filter-append) () |
| void | [gtk\_multi\_filter\_remove](gtkmultifilter#gtk-multi-filter-remove) () |
| [GtkAnyFilter](gtkmultifilter#GtkAnyFilter-struct) \* | [gtk\_any\_filter\_new](gtkmultifilter#gtk-any-filter-new) () |
| [GtkEveryFilter](gtkmultifilter#GtkEveryFilter-struct) \* | [gtk\_every\_filter\_new](gtkmultifilter#gtk-every-filter-new) () |
Types and Values
----------------
| | |
| --- | --- |
| | [GtkMultiFilter](gtkmultifilter#GtkMultiFilter-struct) |
| | [GtkAnyFilter](gtkmultifilter#GtkAnyFilter-struct) |
| | [GtkEveryFilter](gtkmultifilter#GtkEveryFilter-struct) |
Object Hierarchy
----------------
```
GObject
╰── [GtkFilter](gtkfilter#GtkFilter-struct)
╰── GtkMultiFilter
├── GtkAnyFilter
╰── GtkEveryFilter
```
Implemented Interfaces
----------------------
GtkMultiFilter implements GListModel and [GtkBuildable](gtkbuildable#GtkBuildable-struct).
GtkAnyFilter implements GListModel and [GtkBuildable](gtkbuildable#GtkBuildable-struct).
GtkEveryFilter implements GListModel and [GtkBuildable](gtkbuildable#GtkBuildable-struct).
Includes
--------
```
#include <gtk/gtk.h>
```
Description
-----------
GtkMultiFilter is the base type that implements support for handling multiple filters.
GtkAnyFilter is a subclass of GtkMultiFilter that matches an item when at least one of its filters matches.
GtkEveryFilter is a subclass of GtkMultiFilter that matches an item when each of its filters matches.
Functions
---------
### gtk\_multi\_filter\_append ()
```
void
gtk_multi_filter_append (*`[GtkMultiFilter](gtkmultifilter#GtkMultiFilter-struct) *self`*,
*`[GtkFilter](gtkfilter#GtkFilter-struct) *filter`*);
```
Adds a *`filter`* to *`self`* to use for matching.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkMultiFilter](gtkmultifilter#GtkMultiFilter-struct) | |
| filter | A new filter to use. | [transfer full] |
### gtk\_multi\_filter\_remove ()
```
void
gtk_multi_filter_remove (*`[GtkMultiFilter](gtkmultifilter#GtkMultiFilter-struct) *self`*,
*`guint position`*);
```
Removes the filter at the given *`position`* from the list of filters used by *`self`* . If *`position`* is larger than the number of filters, nothing happens and the function returns.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkMultiFilter](gtkmultifilter#GtkMultiFilter-struct) | |
| position | position of filter to remove | |
### gtk\_any\_filter\_new ()
```
[GtkAnyFilter](gtkmultifilter#GtkAnyFilter-struct) *
gtk_any_filter_new (*`void`*);
```
Creates a new empty "any" filter. Use [`gtk_multi_filter_append()`](gtkmultifilter#gtk-multi-filter-append) to add filters to it.
This filter matches an item if any of the filters added to it matches the item. In particular, this means that if no filter has been added to it, the filter matches no item.
#### Returns
a new [GtkAnyFilter](gtkmultifilter#GtkAnyFilter-struct)
### gtk\_every\_filter\_new ()
```
[GtkEveryFilter](gtkmultifilter#GtkEveryFilter-struct) *
gtk_every_filter_new (*`void`*);
```
Creates a new empty "every" filter. Use [`gtk_multi_filter_append()`](gtkmultifilter#gtk-multi-filter-append) to add filters to it.
This filter matches an item if each of the filters added to it matches the item. In particular, this means that if no filter has been added to it, the filter matches every item.
#### Returns
a new [GtkEveryFilter](gtkmultifilter#GtkEveryFilter-struct)
Types and Values
----------------
### GtkMultiFilter
```
typedef struct _GtkMultiFilter GtkMultiFilter;
```
### GtkAnyFilter
```
typedef struct _GtkAnyFilter GtkAnyFilter;
```
### GtkEveryFilter
```
typedef struct _GtkEveryFilter GtkEveryFilter;
```
gtk GtkTreeExpander GtkTreeExpander
===============
GtkTreeExpander — An indenting expander button for use in a tree list
Functions
---------
| | |
| --- | --- |
| [GtkWidget](gtkwidget#GtkWidget-struct) \* | [gtk\_tree\_expander\_new](gtktreeexpander#gtk-tree-expander-new) () |
| [GtkWidget](gtkwidget#GtkWidget-struct) \* | [gtk\_tree\_expander\_get\_child](gtktreeexpander#gtk-tree-expander-get-child) () |
| void | [gtk\_tree\_expander\_set\_child](gtktreeexpander#gtk-tree-expander-set-child) () |
| gpointer | [gtk\_tree\_expander\_get\_item](gtktreeexpander#gtk-tree-expander-get-item) () |
| [GtkTreeListRow](gtktreelistmodel#GtkTreeListRow-struct) \* | [gtk\_tree\_expander\_get\_list\_row](gtktreeexpander#gtk-tree-expander-get-list-row) () |
| void | [gtk\_tree\_expander\_set\_list\_row](gtktreeexpander#gtk-tree-expander-set-list-row) () |
Properties
----------
| | | |
| --- | --- | --- |
| [GtkWidget](gtkwidget#GtkWidget-struct) \* | [child](gtktreeexpander#GtkTreeExpander--child) | Read / Write |
| GObject \* | [item](gtktreeexpander#GtkTreeExpander--item) | Read |
| [GtkTreeListRow](gtktreelistmodel#GtkTreeListRow-struct) \* | [list-row](gtktreeexpander#GtkTreeExpander--list-row) | Read / Write |
Actions
-------
| | | |
| --- | --- | --- |
| | listitem.toggle-expand | |
| | listitem.collapse | |
| | listitem.expand | |
Types and Values
----------------
| | |
| --- | --- |
| | [GtkTreeExpander](gtktreeexpander#GtkTreeExpander-struct) |
Object Hierarchy
----------------
```
GObject
╰── GInitiallyUnowned
╰── [GtkWidget](gtkwidget#GtkWidget-struct)
╰── GtkTreeExpander
```
Implemented Interfaces
----------------------
GtkTreeExpander implements [GtkAccessible](gtkaccessible#GtkAccessible-struct), [GtkBuildable](gtkbuildable#GtkBuildable-struct) and [GtkConstraintTarget](gtkconstraint#GtkConstraintTarget-struct).
Includes
--------
```
#include <gtk/gtk.h>
```
Description
-----------
GtkTreeExpander is a widget that provides an expander for a list.
It is typically placed as a bottommost child into a [GtkListView](gtklistview#GtkListView-struct) to allow users to expand and collapse children in a list with a [GtkTreeListModel](gtktreelistmodel#GtkTreeListModel-struct). It will provide the common UI elements, gestures and keybindings for this purpose.
On top of this, the "listitem.expand", "listitem.collapse" and "listitem.toggle-expand" actions are provided to allow adding custom UI for managing expanded state.
The [GtkTreeListModel](gtktreelistmodel#GtkTreeListModel-struct) must be set to not be passthrough. Then it will provide [GtkTreeListRow](gtktreelistmodel#GtkTreeListRow-struct) items which can be set via [`gtk_tree_expander_set_list_row()`](gtktreeexpander#gtk-tree-expander-set-list-row) on the expander. The expander will then watch that row item automatically. [`gtk_tree_expander_set_child()`](gtktreeexpander#gtk-tree-expander-set-child) sets the widget that displays the actual row contents.
### CSS nodes
GtkTreeExpander has zero or one CSS nodes with the name "expander" that should display the expander icon. The node will be `:checked` when it is expanded. If the node is not expandable, an "indent" node will be displayed instead.
For every level of depth, another "indent" node is prepended.
### Accessibility
GtkTreeExpander uses the [`GTK_ACCESSIBLE_ROLE_GROUP`](gtkaccessible#GTK-ACCESSIBLE-ROLE-GROUP:CAPS) role. The expander icon is represented as a [`GTK_ACCESSIBLE_ROLE_BUTTON`](gtkaccessible#GTK-ACCESSIBLE-ROLE-BUTTON:CAPS), labelled by the expander's child, and toggling it will change the [`GTK_ACCESSIBLE_STATE_EXPANDED`](gtkaccessible#GTK-ACCESSIBLE-STATE-EXPANDED:CAPS) state.
Functions
---------
### gtk\_tree\_expander\_new ()
```
[GtkWidget](gtkwidget#GtkWidget-struct) *
gtk_tree_expander_new (*`void`*);
```
Creates a new [GtkTreeExpander](gtktreeexpander#GtkTreeExpander-struct)
#### Returns
a new [GtkTreeExpander](gtktreeexpander#GtkTreeExpander-struct)
### gtk\_tree\_expander\_get\_child ()
```
[GtkWidget](gtkwidget#GtkWidget-struct) *
gtk_tree_expander_get_child (*`[GtkTreeExpander](gtktreeexpander#GtkTreeExpander-struct) *self`*);
```
Gets the child widget displayed by *`self`* .
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkTreeExpander](gtktreeexpander#GtkTreeExpander-struct) | |
#### Returns
The child displayed by *`self`* .
[nullable][transfer none]
### gtk\_tree\_expander\_set\_child ()
```
void
gtk_tree_expander_set_child (*`[GtkTreeExpander](gtktreeexpander#GtkTreeExpander-struct) *self`*,
*`[GtkWidget](gtkwidget#GtkWidget-struct) *child`*);
```
Sets the content widget to display.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkTreeExpander](gtktreeexpander#GtkTreeExpander-struct) widget | |
| child | a [GtkWidget](gtkwidget#GtkWidget-struct), or `NULL`. | [nullable] |
### gtk\_tree\_expander\_get\_item ()
```
gpointer
gtk_tree_expander_get_item (*`[GtkTreeExpander](gtktreeexpander#GtkTreeExpander-struct) *self`*);
```
Forwards the item set on the [GtkTreeListRow](gtktreelistmodel#GtkTreeListRow-struct) that *`self`* is managing.
This call is essentially equivalent to calling:
```
treeexpander
├── [indent]*
├── [expander]
╰── <child>
```
| #### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkTreeExpander](gtktreeexpander#GtkTreeExpander-struct) | |
#### Returns
The item of the row.
[nullable][transfer full][type GObject]
### gtk\_tree\_expander\_get\_list\_row ()
```
[GtkTreeListRow](gtktreelistmodel#GtkTreeListRow-struct) *
gtk_tree_expander_get_list_row (*`[GtkTreeExpander](gtktreeexpander#GtkTreeExpander-struct) *self`*);
```
Gets the list row managed by *`self`* .
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkTreeExpander](gtktreeexpander#GtkTreeExpander-struct) | |
#### Returns
The list row displayed by *`self`* .
[nullable][transfer none]
### gtk\_tree\_expander\_set\_list\_row ()
```
void
gtk_tree_expander_set_list_row (*`[GtkTreeExpander](gtktreeexpander#GtkTreeExpander-struct) *self`*,
*`[GtkTreeListRow](gtktreelistmodel#GtkTreeListRow-struct) *list_row`*);
```
Sets the tree list row that this expander should manage.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkTreeExpander](gtktreeexpander#GtkTreeExpander-struct) widget | |
| list\_row | a [GtkTreeListRow](gtktreelistmodel#GtkTreeListRow-struct), or `NULL`. | [nullable] |
Types and Values
----------------
### GtkTreeExpander
```
typedef struct _GtkTreeExpander GtkTreeExpander;
```
Property Details
----------------
### The `“child”` property
```
“child” [GtkWidget](gtkwidget#GtkWidget-struct) *
```
The child widget with the actual contents
Owner: GtkTreeExpander
Flags: Read / Write
### The `“item”` property
```
“item” GObject *
```
The item held by this expander's row
Owner: GtkTreeExpander
Flags: Read
### The `“list-row”` property
```
“list-row” [GtkTreeListRow](gtktreelistmodel#GtkTreeListRow-struct) *
```
The list row to track for expander state
Owner: GtkTreeExpander
Flags: Read / Write
Action Details
--------------
### The `“listitem.toggle-expand”` action
Tries to expand the expander if it was collapsed or collapses it if it was expanded.
### The `“listitem.collapse”` action
Collapses the expander.
### The `“listitem.expand”` action
Expands the expander if it can be expanded.
See Also
--------
[GtkTreeListModel](gtktreelistmodel#GtkTreeListModel-struct)
gtk GTK 4 Reference Manual GTK 4 Reference Manual
======================
This document is for the GTK 4 library, version 4.0.3 . The latest versions can be found online at <https://developer.gnome.org/gtk4/>. If you are looking for the older GTK 3 series of libraries, see [https://developer.gnome.org/gtk3/](https://developer-old.gnome.org/gtk3/stable/).
[I. Introduction](https://developer-old.gnome.org/gtk4/4.0/gtk.html) [Getting Started with GTK](gtk-getting-started) [Basics](gtk-getting-started#id-1.2.3.5) [Hello, World](ch01s02) [Hello World in C](ch01s02#gtk-getting-started-hello-world) [Packing](ch01s03) [Packing buttons](ch01s03#gtk-getting-started-grid-packing) [Custom Drawing](ch01s04) [Drawing in response to input](ch01s04#gtk-getting-started-drawing) [Building user interfaces](ch01s05) [Packing buttons with GtkBuilder](ch01s05#id-1.2.3.9.4) [Building applications](ch01s06) [A trivial application](ch01s06#id-1.2.3.10.7) [Populating the window](ch01s06#id-1.2.3.10.8) [Opening files](ch01s06#id-1.2.3.10.9) [A menu](ch01s06#id-1.2.3.10.10) [A preference dialog](ch01s06#id-1.2.3.10.11) [Adding a search bar](ch01s06#id-1.2.3.10.12) [Adding a side bar](ch01s06#id-1.2.3.10.13) [Properties](ch01s06#id-1.2.3.10.14) [Contact information and bug reports](https://developer-old.gnome.org/gtk4/4.0/gtk-resources.html) [Opening a bug or feature request](https://developer-old.gnome.org/gtk4/4.0/gtk-resources.html#id-1.2.4.2) [Working on GTK](https://developer-old.gnome.org/gtk4/4.0/ch02s02.html) [Common Questions](https://developer-old.gnome.org/gtk4/4.0/gtk-question-index.html) [General Questions](https://developer-old.gnome.org/gtk4/4.0/gtk-question-index.html#id-1.2.5.3) [Which widget should I use…](https://developer-old.gnome.org/gtk4/4.0/ch03s02.html) [Questions about GtkWidget](https://developer-old.gnome.org/gtk4/4.0/ch03s03.html) [GtkTextView questions](https://developer-old.gnome.org/gtk4/4.0/ch03s04.html) [GtkTreeView questions](https://developer-old.gnome.org/gtk4/4.0/ch03s05.html) [Using cairo with GTK](https://developer-old.gnome.org/gtk4/4.0/ch03s06.html) [II. GTK Concepts](https://developer-old.gnome.org/gtk4/4.0/concepts.html) [Overview of the drawing model](drawing-overview) [Windows and events](drawing-overview#drawing-windows) [The frame clock](frameclock) [The scene graph](scene-graph) [Hierarchical drawing](hierarchical-drawing) [Overview of GTK input and event handling](input-overview) [Devices and events](input-overview#id-1.3.3.3) [Event propagation](event-propagation) [Keyboard input](ch05s03) [Event controllers and gestures](event-controllers-and-gestures) [Gesture states](ch05s05) [Overview of actions in GTK](actions-overview) [Basics about actions](actions-overview#id-1.3.4.3) [Action state and parameters](ch06s02) [Action scopes](ch06s03) [Action groups and action maps](ch06s04) [Connecting actions to widgets](ch06s05) [Activation](ch06s06) [Built-in Actions](ch06s07) [III. GTK Widgets and Objects](https://developer-old.gnome.org/gtk4/4.0/gtkobjects.html) [Object Hierarchy](ch07) [Widget Gallery](ch08) [GListModel support](https://developer-old.gnome.org/gtk4/4.0/Lists.html) [GtkBitset](gtkbitset) — Sets of integers [GtkExpression](gtkexpression) — Expressions to values [GtkFilterListModel](gtkfilterlistmodel) — A list model that filters its items [GtkFilter](gtkfilter) — Filtering items [GtkCustomFilter](gtkcustomfilter) — Filtering with callbacks [GtkMultiFilter](gtkmultifilter) — Combining multiple filters [GtkBoolFilter](gtkboolfilter) — Filtering by boolean expressions [GtkStringFilter](gtkstringfilter) — Filtering by strings [GtkFileFilter](gtkfilefilter) — Filtering files [GtkFlattenListModel](gtkflattenlistmodel) — A list model that flattens a list of lists [GtkMapListModel](gtkmaplistmodel) — A list model that transforms its items [GtkSliceListModel](gtkslicelistmodel) — A list model that presents a slice out of a larger list [GtkSortListModel](gtksortlistmodel) — A list model that sorts its items [GtkSorter](gtksorter) — Sorting items [GtkCustomSorter](gtkcustomsorter) — Sorting with a callbacks [GtkMultiSorter](gtkmultisorter) — Combining multiple sorters [GtkStringSorter](gtkstringsorter) — Sort by comparing strings [GtkNumericSorter](gtknumericsorter) — Sort by comparing numbers [GtkSelectionModel](gtkselectionmodel) — An extension of the list model interface that handles selections [GtkNoSelection](gtknoselection) — A selection model that does not allow selecting anything [GtkSingleSelection](gtksingleselection) — A selection model that allows selecting a single item [GtkMultiSelection](gtkmultiselection) — A selection model that allows selecting multiple items [GtkSelectionFilterModel](gtkselectionfiltermodel) — A list model that turns a selection in a model [GtkBookmarkList](gtkbookmarklist) — A list model for recently used files [GtkDirectoryList](gtkdirectorylist) — A list model for directory listings [GtkStringList](gtkstringlist) — A list model for strings [List-based Widgets](listcontainers) [List Widget Overview](listcontainers#ListWidget) [Terminology](listcontainers#id-1.4.5.2.6) [Behind the scenes](listcontainers#id-1.4.5.2.7) [Choosing the right model](listcontainers#model-choosing) [Displaying trees](listcontainers#displaying-trees) [List styles](listcontainers#list-styles) [Comparison to GtkTreeView](listcontainers#id-1.4.5.2.11) [GtkListItem](gtklistitem) — Object used to represent items of a list model [GtkListItemFactory](gtklistitemfactory) — Mapping list items to widgets [GtkSignalListItemFactory](gtksignallistitemfactory) — A listitem factory providing signals [GtkBuilderListItemFactory](gtkbuilderlistitemfactory) — A listitem factory using ui files [GtkListView](gtklistview) — A widget for displaying lists [GtkGridView](gtkgridview) — A widget for displaying grids [GtkColumnView](gtkcolumnview) — A widget for displaying lists in multiple columns [GtkColumnViewColumn](gtkcolumnviewcolumn) — The column added to GtkColumnView [GtkDropDown](gtkdropdown) — Choose an item from a list [Tree support](https://developer-old.gnome.org/gtk4/4.0/Trees.html) [GtkTreeListModel](gtktreelistmodel) — A list model that can create child models on demand [GtkTreeListRow](gtktreelistrow) — A row in a GtkTreeListModel [GtkTreeListRowSorter](gtktreelistrowsorter) — Sort trees by levels [GtkTreeExpander](gtktreeexpander) — An indenting expander button for use in a tree list [Application support](https://developer-old.gnome.org/gtk4/4.0/Application.html) [GtkApplication](gtkapplication) — Application class [GtkApplicationWindow](gtkapplicationwindow) — GtkWindow subclass with GtkApplication support [GtkActionable](gtkactionable) — An interface for widgets that can be associated with actions [Interface builder](https://developer-old.gnome.org/gtk4/4.0/Builder.html) [GtkBuilder](gtkbuilder) — Build an interface from an XML UI definition [GtkBuildable](gtkbuildable) — Interface for objects that can be built by GtkBuilder [GtkBuilderScope](gtkbuilderscope) — Bindings for GtkBuilder [Windows](https://developer-old.gnome.org/gtk4/4.0/WindowWidgets.html) [GtkRoot](gtkroot) — Interface for root widgets [GtkNative](gtknative) — Interface for widgets having surfaces [GtkWindow](gtkwindow) — Toplevel which can contain other widgets [GtkDialog](gtkdialog) — Create popup windows [GtkMessageDialog](gtkmessagedialog) — A convenient message window [GtkAboutDialog](gtkaboutdialog) — Display information about an application [GtkAssistant](gtkassistant) — A widget used to guide users through multi-step operations [GtkWindowGroup](gtkwindowgroup) — Limit the effect of grabs [GtkNativeDialog](gtknativedialog) — Integrate with native dialogs [Layout Containers](https://developer-old.gnome.org/gtk4/4.0/LayoutContainers.html) [GtkBox](gtkbox) — A container for packing widgets in a single row or column [GtkCenterBox](gtkcenterbox) — A centering container [GtkGrid](gtkgrid) — Pack widgets in rows and columns [GtkRevealer](gtkrevealer) — Hide and show with animation [GtkListBox](gtklistbox) — A list container [GtkFlowBox](gtkflowbox) — A container that allows reflowing its children [GtkStack](gtkstack) — A stacking container [GtkStackSwitcher](gtkstackswitcher) — A controller for GtkStack [GtkStackSidebar](gtkstacksidebar) — An automatic sidebar widget [GtkActionBar](gtkactionbar) — A full width bar for presenting contextual actions [GtkHeaderBar](gtkheaderbar) — A box with a centered child [GtkOverlay](gtkoverlay) — A container which overlays widgets on top of each other [GtkPaned](gtkpaned) — A widget with two adjustable panes [GtkNotebook](gtknotebook) — A tabbed notebook container [GtkExpander](gtkexpander) — A container which can hide its child [GtkOrientable](gtk4-orientable) — An interface for flippable widgets [GtkAspectFrame](gtkaspectframe) — A frame that constrains its child to a particular aspect ratio [GtkFixed](gtkfixed) — A container which allows you to position widgets at fixed coordinates [Layout Managers](https://developer-old.gnome.org/gtk4/4.0/LayoutManagers.html) [GtkLayoutManager](gtklayoutmanager) — Base class for layout manager [GtkLayoutChild](gtklayoutchild) — An object containing layout properties [GtkBinLayout](gtkbinlayout) — A layout manager for bin-like widgets [GtkBoxLayout](gtkboxlayout) — Layout manager for placing all children in a single row or column [GtkCenterLayout](gtkcenterlayout) — A centering layout [GtkFixedLayout](gtkfixedlayout) — A layout manager that allows positioning at fixed coordinates [GtkGridLayout](gtkgridlayout) — Layout manager for grid-like widgets [GtkOverlayLayout](gtkoverlaylayout) — Layout manager that places widgets as overlays [GtkCustomLayout](gtkcustomlayout) — A convenience layout manager [GtkConstraintLayout](gtkconstraintlayout) — A layout manager using constraints [GtkConstraint](gtkconstraint) — The description of a constraint [GtkConstraintGuide](gtkconstraintguide) — An invisible constraint target [Display Widgets](https://developer-old.gnome.org/gtk4/4.0/DisplayWidgets.html) [GtkLabel](gtklabel) — A widget that displays a small to medium amount of text [GtkImage](gtkimage) — A widget displaying an image [GtkPicture](gtkpicture) — A widget displaying a GdkPaintable [GtkSpinner](gtkspinner) — Show a spinner animation [GtkInfoBar](gtkinfobar) — Report important messages to the user [GtkProgressBar](gtkprogressbar) — A widget which indicates progress visually [GtkLevelBar](gtklevelbar) — A bar that can used as a level indicator [GtkStatusbar](gtkstatusbar) — Report messages of minor importance to the user [GtkCalendar](gtkcalendar) — Displays a calendar and allows the user to select a date [Media Support](https://developer-old.gnome.org/gtk4/4.0/MediaSupport.html) [GtkVideo](gtkvideo) — A widget for displaying video [GtkMediaControls](gtkmediacontrols) — A widget showing controls for a media stream [GtkMediaStream](gtkmediastream) — Display media in GTK [GtkMediaFile](gtkmediafile) — Open media files for use in GTK [Buttons and Toggles](https://developer-old.gnome.org/gtk4/4.0/ButtonWidgets.html) [GtkButton](gtkbutton) — A widget that emits a signal when clicked on [GtkCheckButton](gtkcheckbutton) — Create widgets with a discrete toggle button [GtkToggleButton](gtktogglebutton) — Create buttons which retain their state [GtkLinkButton](gtklinkbutton) — Create buttons bound to a URL [GtkMenuButton](gtkmenubutton) — A widget that shows a popup when clicked on [GtkSwitch](gtkswitch) — A “light switch” style toggle [GtkScaleButton](gtkscalebutton) — A button which pops up a scale [GtkVolumeButton](gtkvolumebutton) — A button which pops up a volume control [GtkLockButton](gtklockbutton) — A widget to unlock or lock privileged operations [Numeric and Text Data Entry](https://developer-old.gnome.org/gtk4/4.0/NumericEntry.html) [GtkEditable](gtkeditable) — Interface for text-editing widgets [GtkEntryBuffer](gtkentrybuffer) — Text buffer for GtkEntry [GtkText](gtktext) — A simple single-line text entry field [GtkEntry](gtkentry) — A single line text entry field [GtkEntryCompletion](gtkentrycompletion) — Completion functionality for GtkEntry [GtkPasswordEntry](gtkpasswordentry) — An entry for secrets [GtkScale](gtkscale) — A slider widget for selecting a value from a range [GtkSpinButton](gtkspinbutton) — Retrieve an integer or floating-point number from the user [GtkSearchEntry](gtksearchentry) — An entry which shows a search icon [GtkSearchBar](gtksearchbar) — A toolbar to integrate a search entry with [GtkEditableLabel](gtkeditablelabel) — A label that can be edited [Multiline Text Editor](textwidgetobjects) [Text Widget Overview](textwidgetobjects#TextWidget) [Simple Example](textwidgetobjects#id-1.4.16.2.13) [Example of Changing Text Attributes](textwidgetobjects#id-1.4.16.2.14) [GtkTextIter](gtktextiter) — Text buffer iterator [GtkTextMark](gtktextmark) — A position in the buffer preserved across buffer modifications [GtkTextBuffer](gtktextbuffer) — Stores attributed text for display in a GtkTextView [GtkTextTag](gtktexttag) — A tag that can be applied to text in a GtkTextBuffer [GtkTextTagTable](gtktexttagtable) — Collection of tags that can be used together [GtkTextView](gtktextview) — Widget that displays a GtkTextBuffer [Tree, List and Icon Grid Widgets](treewidgetobjects) [Tree and List Widget Overview](treewidgetobjects#TreeWidget) [Creating a model](treewidgetobjects#id-1.4.17.2.6) [Creating the view component](treewidgetobjects#id-1.4.17.2.7) [Columns and cell renderers](treewidgetobjects#id-1.4.17.2.8) [Selection handling](treewidgetobjects#id-1.4.17.2.9) [Simple Example](treewidgetobjects#id-1.4.17.2.10) [GtkTreeModel](gtktreemodel) — The tree interface used by GtkTreeView [GtkTreeSelection](gtktreeselection) — The selection object for GtkTreeView [GtkTreeViewColumn](gtktreeviewcolumn) — A visible column in a GtkTreeView widget [GtkTreeView](gtktreeview) — A widget for displaying both trees and lists [GtkTreeView drag-and-drop](gtk4-gtktreeview-drag-and-drop) — Interfaces for drag-and-drop support in GtkTreeView [GtkCellView](gtkcellview) — A widget displaying a single row of a GtkTreeModel [GtkIconView](gtkiconview) — A widget which displays a list of icons in a grid [GtkTreeSortable](gtktreesortable) — The interface for sortable models used by GtkTreeView [GtkTreeModelSort](gtktreemodelsort) — A GtkTreeModel which makes an underlying tree model sortable [GtkTreeModelFilter](gtktreemodelfilter) — A GtkTreeModel which hides parts of an underlying tree model [GtkCellLayout](gtkcelllayout) — An interface for packing cells [GtkCellArea](gtkcellarea) — An abstract class for laying out GtkCellRenderers [GtkCellAreaBox](gtkcellareabox) — A cell area that renders GtkCellRenderers into a row or a column [GtkCellAreaContext](gtkcellareacontext) — Stores geometrical information for a series of rows in a GtkCellArea [GtkCellRenderer](gtkcellrenderer) — An object for rendering a single cell [GtkCellEditable](gtkcelleditable) — Interface for widgets that can be used for editing cells [GtkCellRendererAccel](gtkcellrendereraccel) — Renders a keyboard accelerator in a cell [GtkCellRendererCombo](gtkcellrenderercombo) — Renders a combobox in a cell [GtkCellRendererPixbuf](gtkcellrendererpixbuf) — Renders a pixbuf in a cell [GtkCellRendererProgress](gtkcellrendererprogress) — Renders numbers as progress bars [GtkCellRendererSpin](gtkcellrendererspin) — Renders a spin button in a cell [GtkCellRendererText](gtkcellrenderertext) — Renders text in a cell [GtkCellRendererToggle](gtkcellrenderertoggle) — Renders a toggle button in a cell [GtkCellRendererSpinner](gtkcellrendererspinner) — Renders a spinning animation in a cell [GtkListStore](gtkliststore) — A list-like data structure that can be used with the GtkTreeView [GtkTreeStore](gtktreestore) — A tree-like data structure that can be used with the GtkTreeView [Menus, Combo Box](https://developer-old.gnome.org/gtk4/4.0/MenusAndCombos.html) [GtkComboBox](gtkcombobox) — A widget used to choose from a list of items [GtkComboBoxText](gtkcomboboxtext) — A simple, text-only combo box [GtkPopover](gtkpopover) — Context dependent bubbles [GtkPopoverMenu](gtkpopovermenu) — Popovers to use as menus [GtkPopoverMenuBar](gtkpopovermenubar) — A menu bar with popovers [GtkDropDown](gtkdropdown) — Choose an item from a list [Selector Widgets and Dialogs](https://developer-old.gnome.org/gtk4/4.0/SelectorWidgets.html) [GtkColorChooser](gtkcolorchooser) — Interface implemented by widgets for choosing colors [GtkColorButton](gtkcolorbutton) — A button to launch a color selection dialog [GtkColorChooserWidget](gtkcolorchooserwidget) — A widget for choosing colors [GtkColorChooserDialog](gtkcolorchooserdialog) — A dialog for choosing colors [GtkFileChooser](gtkfilechooser) — File chooser interface used by GtkFileChooserWidget and GtkFileChooserDialog [GtkFileChooserNative](gtkfilechoosernative) — A native file chooser dialog, suitable for “File Open” or “File Save” commands [GtkFileChooserDialog](gtkfilechooserdialog) — A file chooser dialog, suitable for “File Open” or “File Save” commands [GtkFileChooserWidget](gtkfilechooserwidget) — A file chooser widget [GtkFontChooser](gtkfontchooser) — Interface implemented by widgets displaying fonts [GtkFontButton](gtkfontbutton) — A button to launch a font chooser dialog [GtkFontChooserWidget](gtkfontchooserwidget) — A widget for selecting fonts [GtkFontChooserDialog](gtkfontchooserdialog) — A dialog for selecting fonts [GtkEmojiChooser](gtkemojichooser) — A popover to choose an Emoji character [Widgets for custom drawing](https://developer-old.gnome.org/gtk4/4.0/DrawingWidgets.html) [GtkDrawingArea](gtkdrawingarea) — A simple widget for drawing with cairo [GtkGLArea](gtkglarea) — A widget for custom drawing with OpenGL [Ornaments](https://developer-old.gnome.org/gtk4/4.0/Ornaments.html) [GtkFrame](gtkframe) — A widget with a decorative frame and optional label [GtkSeparator](gtkseparator) — A separator widget [Scrolling](https://developer-old.gnome.org/gtk4/4.0/ScrollingWidgets.html) [GtkScrollbar](gtkscrollbar) — A Scrollbar [GtkScrolledWindow](gtkscrolledwindow) — Adds scrollbars to its child widget [GtkScrollable](gtkscrollable) — An interface for scrollable widgets [GtkViewport](gtkviewport) — An adapter which makes widgets scrollable [Printing](https://developer-old.gnome.org/gtk4/4.0/Printing.html) [GtkPrintOperation](gtk4-high-level-printing-api) — High-level Printing API [GtkPrintContext](gtkprintcontext) — Encapsulates context for drawing pages [GtkPrintSettings](gtkprintsettings) — Stores print settings [GtkPageSetup](gtkpagesetup) — Stores page setup information [GtkPaperSize](gtkpapersize) — Support for named paper sizes [GtkPrinter](gtkprinter) — Represents a printer [GtkPrintJob](gtkprintjob) — Represents a print job [GtkPrintUnixDialog](gtkprintunixdialog) — A print dialog [GtkPageSetupUnixDialog](gtkpagesetupunixdialog) — A page setup dialog [Shortcuts Overview](https://developer-old.gnome.org/gtk4/4.0/ShortcutsOverview.html) [GtkShortcutsWindow](gtkshortcutswindow) — Toplevel which shows help for shortcuts [GtkShortcutsSection](gtkshortcutssection) — Represents an application mode in a GtkShortcutsWindow [GtkShortcutsGroup](gtkshortcutsgroup) — Represents a group of shortcuts in a GtkShortcutsWindow [GtkShortcutsShortcut](gtkshortcutsshortcut) — Represents a keyboard shortcut in a GtkShortcutsWindow [GtkShortcutLabel](gtkshortcutlabel) — Displays a keyboard shortcut [Accessibility](accessibility) [GTK Accessibility](accessibility#gtk-accessibility) [The standard accessibility interface](accessibility#id-1.4.25.2.2) [Accessible roles and attributes](accessibility#id-1.4.25.2.3) [Application development rules](accessibility#id-1.4.25.2.4) [Implementations](accessibility#id-1.4.25.2.5) [Authoring practices](accessibility#authoring-practices) [Hiding UI elements from the accessible tree](accessibility#id-1.4.25.2.7) [Design patterns and custom widgets](accessibility#id-1.4.25.2.8) [GtkAccessible](gtkaccessible) — Accessible interface [GtkATContext](gtkatcontext) — An object communicating to Assistive Technologies [Miscellaneous](https://developer-old.gnome.org/gtk4/4.0/MiscObjects.html) [GtkAdjustment](gtkadjustment) — A representation of an adjustable bounded value [GtkIMContextSimple](gtkimcontextsimple) — An input method context supporting table-based input methods [GtkIMMulticontext](gtkimmulticontext) — An input method context supporting multiple, loadable input methods [GtkSizeGroup](gtksizegroup) — Grouping widgets so they request the same size [GtkSnapshot](gtksnapshot) — Auxiliary object for snapshots [GtkTooltip](gtktooltip) — Add tips to your widgets [GtkWidgetPaintable](gtkwidgetpaintable) — Drawing a widget elsewhere [GtkWindowControls](gtkwindowcontrols) — A widget displaying window buttons [GtkWindowHandle](gtkwindowhandle) — A titlebar area widget [Abstract Base Classes](https://developer-old.gnome.org/gtk4/4.0/AbstractObjects.html) [GtkWidget](gtkwidget) — Base class for all widgets [GtkRange](gtkrange) — Base class for widgets which visualize an adjustment [GtkIMContext](gtkimcontext) — Base class for input method contexts [GtkNativeDialog](gtknativedialog) — Integrate with native dialogs [GtkAccessible](gtkaccessible) — Accessible interface [Recently Used Documents](https://developer-old.gnome.org/gtk4/4.0/RecentDocuments.html) [GtkRecentManager](gtkrecentmanager) — Managing recently used files [Choosing from installed applications](https://developer-old.gnome.org/gtk4/4.0/ApplicationChoosing.html) [GtkAppChooser](gtkappchooser) — Interface implemented by widgets for choosing an application [GtkAppChooserButton](gtkappchooserbutton) — A button to launch an application chooser dialog [GtkAppChooserDialog](gtkappchooserdialog) — An application chooser dialog [GtkAppChooserWidget](gtkappchooserwidget) — Application chooser widget that can be embedded in other widgets [Gestures and event handling](https://developer-old.gnome.org/gtk4/4.0/Gestures.html) [GtkEventController](gtkeventcontroller) — Self-contained handler of series of events [GtkEventControllerKey](gtkeventcontrollerkey) — Event controller for key events [GtkEventControllerFocus](gtkeventcontrollerfocus) — Event controller for focus [GtkEventControllerLegacy](gtkeventcontrollerlegacy) — Event controller for miscellaneous events [GtkEventControllerScroll](gtkeventcontrollerscroll) — Event controller for scroll events [GtkEventControllerMotion](gtkeventcontrollermotion) — Event controller for motion events [GtkGesture](gtkgesture) — Base class for gestures [GtkGestureSingle](gtkgesturesingle) — Base class for mouse/single-touch gestures [GtkGestureDrag](gtkgesturedrag) — Drag gesture [GtkGestureLongPress](gtkgesturelongpress) — "Press and Hold" gesture [GtkGestureClick](gtkgestureclick) — Multipress gesture [GtkGesturePan](gtkgesturepan) — Pan gesture [GtkGestureSwipe](gtkgestureswipe) — Swipe gesture [GtkGestureRotate](gtkgesturerotate) — Rotate gesture [GtkGestureZoom](gtkgesturezoom) — Zoom gesture [GtkGestureStylus](gtkgesturestylus) — Gesture for stylus input [GtkPadController](gtkpadcontroller) — Controller for drawing tablet pads [GtkShortcutController](gtkshortcutcontroller) — Event controller for shortcuts [Keyboard shortcuts](https://developer-old.gnome.org/gtk4/4.0/ch36.html) [Keyboard Accelerators](gtk4-keyboard-accelerators) — Utilities for accelerators [GtkShortcut](gtkshortcut) — An object describing a keyboard shortcut [GtkShortcutTrigger](gtkshortcuttrigger) — Triggers to track if shortcuts should be activated [GtkShortcutAction](gtkshortcutaction) — Tracking if shortcuts should be activated [GtkShortcutManager](gtkshortcutmanager) — Interface for managing shortcuts [Data exchange, clipboards and Drag-and-Drop](https://developer-old.gnome.org/gtk4/4.0/ch37.html) [GtkDragSource](gtkdragsource) — Event controller to initiate DND operations [GtkDragIcon](gtkdragicon) — A toplevel to use as drag icon [GtkDropTarget](gtkdroptarget) — Event controller to receive DND drops [GtkDropTargetAsync](gtkdroptargetasync) — Event controller to receive DND drops [GtkDropControllerMotion](gtkdropcontrollermotion) — Event controller for motion events during a drop [IV. GTK Core Reference](https://developer-old.gnome.org/gtk4/4.0/gtkbase.html) [Initialization](gtk4-general) — Library initialization and main loop [Version Information](gtk4-feature-test-macros) — Variables and functions to check the GTK version [Settings](gtksettings) — Sharing settings between applications [Standard Enumerations](gtk4-standard-enumerations) — Public enumerated types used throughout GTK [Testing](gtk4-testing) — Utilities for testing GTK applications [Filesystem utilities](gtk4-filesystem-utilities) — Functions for working with GIO [V. Theming in GTK](https://developer-old.gnome.org/gtk4/4.0/theming.html) [CSS in GTK](css) [CSS nodes](css#id-1.6.2.4) [The CSS nodes of a GtkScale](css#id-1.6.2.4.4) [Selectors](ch38s02) [GTK CSS Selectors](ch38s02#id-1.6.2.5.4) [GTK CSS Properties](ch39) [Basic types](ch39#id-1.6.3.3) [Colors](ch39s02) [Images](ch39s03) [GTK CSS Properties](ch39s04) [GtkStyleContext](gtkstylecontext) — Rendering UI elements [GtkCssProvider](gtkcssprovider) — CSS-like styling for widgets [GtkStyleProvider](gtkstyleprovider) — Interface to provide style information to GtkStyleContext [GtkIconTheme](gtkicontheme) — Looking up icons by name [VI. Migrating from Previous Versions of GTK](https://developer-old.gnome.org/gtk4/4.0/migrating.html) [Migrating from GTK 2.x to GTK 4](https://developer-old.gnome.org/gtk4/4.0/gtk-migrating-2-to-4.html) [Migrating from GTK 3.x to GTK 4](https://developer-old.gnome.org/gtk4/4.0/gtk-migrating-3-to-4.html) [Preparation in GTK 3.x](https://developer-old.gnome.org/gtk4/4.0/gtk-migrating-3-to-4.html#id-1.7.4.3) [Do not use deprecated symbols](https://developer-old.gnome.org/gtk4/4.0/gtk-migrating-3-to-4.html#id-1.7.4.3.3) [Enable diagnostic warnings](https://developer-old.gnome.org/gtk4/4.0/gtk-migrating-3-to-4.html#id-1.7.4.3.4) [Do not use GTK-specific command line arguments](https://developer-old.gnome.org/gtk4/4.0/gtk-migrating-3-to-4.html#id-1.7.4.3.5) [Do not use widget style properties](https://developer-old.gnome.org/gtk4/4.0/gtk-migrating-3-to-4.html#id-1.7.4.3.6) [Review your window creation flags](https://developer-old.gnome.org/gtk4/4.0/gtk-migrating-3-to-4.html#id-1.7.4.3.7) [Stop using direct access to GdkEvent structs](https://developer-old.gnome.org/gtk4/4.0/gtk-migrating-3-to-4.html#id-1.7.4.3.8) [Stop using `gdk_pointer_warp()`](https://developer-old.gnome.org/gtk4/4.0/gtk-migrating-3-to-4.html#id-1.7.4.3.9) [Stop using non-RGBA visuals](https://developer-old.gnome.org/gtk4/4.0/gtk-migrating-3-to-4.html#id-1.7.4.3.10) [Stop using GtkBox padding, fill and expand child properties](https://developer-old.gnome.org/gtk4/4.0/gtk-migrating-3-to-4.html#id-1.7.4.3.11) [Stop using the state argument of GtkStyleContext getters](https://developer-old.gnome.org/gtk4/4.0/gtk-migrating-3-to-4.html#id-1.7.4.3.12) [Stop using `gdk_pixbuf_get_from_window()` and `gdk_cairo_set_source_surface()`](https://developer-old.gnome.org/gtk4/4.0/gtk-migrating-3-to-4.html#id-1.7.4.3.13) [Stop using GtkWidget event signals](https://developer-old.gnome.org/gtk4/4.0/gtk-migrating-3-to-4.html#id-1.7.4.3.14) [Set a proper application ID](https://developer-old.gnome.org/gtk4/4.0/gtk-migrating-3-to-4.html#id-1.7.4.3.15) [Stop using `gtk_main()` and related APIs](https://developer-old.gnome.org/gtk4/4.0/gtk-migrating-3-to-4.html#id-1.7.4.3.16) [Reduce the use of `gtk_widget_destroy()`](https://developer-old.gnome.org/gtk4/4.0/gtk-migrating-3-to-4.html#id-1.7.4.3.17) [Reduce the use of generic container APIs](https://developer-old.gnome.org/gtk4/4.0/gtk-migrating-3-to-4.html#id-1.7.4.3.18) [Review your use of icon resources](https://developer-old.gnome.org/gtk4/4.0/gtk-migrating-3-to-4.html#id-1.7.4.3.19) [Changes that need to be done at the time of the switch](https://developer-old.gnome.org/gtk4/4.0/ch41s02.html) [Larger changes](https://developer-old.gnome.org/gtk4/4.0/ch41s02.html#id-1.7.4.4.3) [Stop using GdkScreen](https://developer-old.gnome.org/gtk4/4.0/ch41s02.html#id-1.7.4.4.4) [Stop using the root window](https://developer-old.gnome.org/gtk4/4.0/ch41s02.html#id-1.7.4.4.5) [Stop using GdkVisual](https://developer-old.gnome.org/gtk4/4.0/ch41s02.html#id-1.7.4.4.6) [Stop using GdkDeviceManager](https://developer-old.gnome.org/gtk4/4.0/ch41s02.html#id-1.7.4.4.7) [Adapt to GdkWindow API changes](https://developer-old.gnome.org/gtk4/4.0/ch41s02.html#id-1.7.4.4.8) [The “iconified” window state has been renamed to “minimized”](https://developer-old.gnome.org/gtk4/4.0/ch41s02.html#id-1.7.4.4.9) [Adapt to GdkEvent API changes](https://developer-old.gnome.org/gtk4/4.0/ch41s02.html#id-1.7.4.4.10) [Stop using grabs](https://developer-old.gnome.org/gtk4/4.0/ch41s02.html#id-1.7.4.4.11) [Adapt to coordinate API changes](https://developer-old.gnome.org/gtk4/4.0/ch41s02.html#id-1.7.4.4.12) [Adapt to GdkKeymap API changes](https://developer-old.gnome.org/gtk4/4.0/ch41s02.html#id-1.7.4.4.13) [Adapt to changes in keyboard modifier handling](https://developer-old.gnome.org/gtk4/4.0/ch41s02.html#id-1.7.4.4.14) [Replace GtkClipboard with GdkClipboard](https://developer-old.gnome.org/gtk4/4.0/ch41s02.html#id-1.7.4.4.15) [Stop using `gtk_get_current_...` APIs](https://developer-old.gnome.org/gtk4/4.0/ch41s02.html#id-1.7.4.4.16) [Convert your ui files](https://developer-old.gnome.org/gtk4/4.0/ch41s02.html#id-1.7.4.4.17) [Adapt to GtkBuilder API changes](https://developer-old.gnome.org/gtk4/4.0/ch41s02.html#id-1.7.4.4.18) [Adapt to event controller API changes](https://developer-old.gnome.org/gtk4/4.0/ch41s02.html#id-1.7.4.4.19) [Focus handling changes](https://developer-old.gnome.org/gtk4/4.0/ch41s02.html#id-1.7.4.4.20) [Use the new apis for keyboard shortcuts](https://developer-old.gnome.org/gtk4/4.0/ch41s02.html#id-1.7.4.4.21) [Stop using GtkEventBox](https://developer-old.gnome.org/gtk4/4.0/ch41s02.html#id-1.7.4.4.22) [Stop using GtkButtonBox](https://developer-old.gnome.org/gtk4/4.0/ch41s02.html#id-1.7.4.4.23) [Adapt to GtkBox API changes](https://developer-old.gnome.org/gtk4/4.0/ch41s02.html#id-1.7.4.4.24) [Adapt to GtkWindow API changes](https://developer-old.gnome.org/gtk4/4.0/ch41s02.html#id-1.7.4.4.25) [Adapt to GtkHeaderBar and GtkActionBar API changes](https://developer-old.gnome.org/gtk4/4.0/ch41s02.html#id-1.7.4.4.26) [Adapt to GtkStack, GtkAssistant and GtkNotebook API changes](https://developer-old.gnome.org/gtk4/4.0/ch41s02.html#id-1.7.4.4.27) [Adapt to button class hierarchy changes](https://developer-old.gnome.org/gtk4/4.0/ch41s02.html#id-1.7.4.4.28) [Adapt to GtkScrolledWindow API changes](https://developer-old.gnome.org/gtk4/4.0/ch41s02.html#id-1.7.4.4.29) [Adapt to GtkBin removal](https://developer-old.gnome.org/gtk4/4.0/ch41s02.html#id-1.7.4.4.30) [Adapt to GtkContainer removal](https://developer-old.gnome.org/gtk4/4.0/ch41s02.html#id-1.7.4.4.31) [Stop using GtkContainer::border-width](https://developer-old.gnome.org/gtk4/4.0/ch41s02.html#id-1.7.4.4.32) [Adapt to `gtk_widget_destroy()` removal](https://developer-old.gnome.org/gtk4/4.0/ch41s02.html#id-1.7.4.4.33) [Adapt to coordinate API changes](https://developer-old.gnome.org/gtk4/4.0/ch41s02.html#id-1.7.4.4.34) [Adapt to GtkStyleContext API changes](https://developer-old.gnome.org/gtk4/4.0/ch41s02.html#id-1.7.4.4.35) [Adapt to GtkCssProvider API changes](https://developer-old.gnome.org/gtk4/4.0/ch41s02.html#id-1.7.4.4.36) [Stop using GtkShadowType and GtkRelief properties](https://developer-old.gnome.org/gtk4/4.0/ch41s02.html#id-1.7.4.4.37) [Adapt to GtkWidget’s size request changes](https://developer-old.gnome.org/gtk4/4.0/ch41s02.html#id-1.7.4.4.38) [Adapt to GtkWidget’s size allocation changes](https://developer-old.gnome.org/gtk4/4.0/ch41s02.html#id-1.7.4.4.39) [Switch to GtkWidget’s children APIs](https://developer-old.gnome.org/gtk4/4.0/ch41s02.html#id-1.7.4.4.40) [Don’t use -gtk-gradient in your CSS](https://developer-old.gnome.org/gtk4/4.0/ch41s02.html#id-1.7.4.4.41) [Don’t use -gtk-icon-effect in your CSS](https://developer-old.gnome.org/gtk4/4.0/ch41s02.html#id-1.7.4.4.42) [Don’t use -gtk-icon-theme in your CSS](https://developer-old.gnome.org/gtk4/4.0/ch41s02.html#id-1.7.4.4.43) [Don’t use -gtk-outline-…-radius in your CSS](https://developer-old.gnome.org/gtk4/4.0/ch41s02.html#id-1.7.4.4.44) [Adapt to drawing model changes](https://developer-old.gnome.org/gtk4/4.0/ch41s02.html#id-1.7.4.4.45) [Stop using APIs to query GdkSurfaces](https://developer-old.gnome.org/gtk4/4.0/ch41s02.html#id-1.7.4.4.46) [Widgets are now visible by default](https://developer-old.gnome.org/gtk4/4.0/ch41s02.html#id-1.7.4.4.47) [Adapt to changes in animated hiding and showing of widgets](https://developer-old.gnome.org/gtk4/4.0/ch41s02.html#id-1.7.4.4.48) [Stop passing commandline arguments to gtk\_init](https://developer-old.gnome.org/gtk4/4.0/ch41s02.html#id-1.7.4.4.49) [GdkPixbuf is deemphasized](https://developer-old.gnome.org/gtk4/4.0/ch41s02.html#id-1.7.4.4.50) [GtkWidget event signals are removed](https://developer-old.gnome.org/gtk4/4.0/ch41s02.html#id-1.7.4.4.51) [Invalidation handling has changed](https://developer-old.gnome.org/gtk4/4.0/ch41s02.html#id-1.7.4.4.52) [Stop using GtkWidget::draw](https://developer-old.gnome.org/gtk4/4.0/ch41s02.html#id-1.7.4.4.53) [Window content observation has changed](https://developer-old.gnome.org/gtk4/4.0/ch41s02.html#id-1.7.4.4.54) [Monitor handling has changed](https://developer-old.gnome.org/gtk4/4.0/ch41s02.html#id-1.7.4.4.55) [Adapt to monitor API changes](https://developer-old.gnome.org/gtk4/4.0/ch41s02.html#id-1.7.4.4.56) [Adapt to cursor API changes](https://developer-old.gnome.org/gtk4/4.0/ch41s02.html#id-1.7.4.4.57) [Adapt to icon size API changes](https://developer-old.gnome.org/gtk4/4.0/ch41s02.html#id-1.7.4.4.58) [Adapt to changes in the GtkAssistant API](https://developer-old.gnome.org/gtk4/4.0/ch41s02.html#id-1.7.4.4.59) [Adapt to changes in the API of GtkEntry, GtkSearchEntry and GtkSpinButton](https://developer-old.gnome.org/gtk4/4.0/ch41s02.html#id-1.7.4.4.60) [Adapt to changes in GtkOverlay API](https://developer-old.gnome.org/gtk4/4.0/ch41s02.html#id-1.7.4.4.61) [Use GtkFixed instead of GtkLayout](https://developer-old.gnome.org/gtk4/4.0/ch41s02.html#id-1.7.4.4.62) [Adapt to search entry changes](https://developer-old.gnome.org/gtk4/4.0/ch41s02.html#id-1.7.4.4.63) [Adapt to GtkScale changes](https://developer-old.gnome.org/gtk4/4.0/ch41s02.html#id-1.7.4.4.64) [Stop using `gtk_window_activate_default()`](https://developer-old.gnome.org/gtk4/4.0/ch41s02.html#id-1.7.4.4.65) [Stop using `gtk_widget_grab_default()`](https://developer-old.gnome.org/gtk4/4.0/ch41s02.html#id-1.7.4.4.66) [Stop setting ::has-default and ::has-focus in .ui files](https://developer-old.gnome.org/gtk4/4.0/ch41s02.html#id-1.7.4.4.67) [Stop using the GtkWidget::display-changed signal](https://developer-old.gnome.org/gtk4/4.0/ch41s02.html#id-1.7.4.4.68) [GtkPopover::modal has been renamed to autohide](https://developer-old.gnome.org/gtk4/4.0/ch41s02.html#id-1.7.4.4.69) [gtk\_widget\_get\_surface has been removed](https://developer-old.gnome.org/gtk4/4.0/ch41s02.html#id-1.7.4.4.70) [gtk\_widget\_is\_toplevel has been removed](https://developer-old.gnome.org/gtk4/4.0/ch41s02.html#id-1.7.4.4.71) [gtk\_widget\_get\_toplevel has been removed](https://developer-old.gnome.org/gtk4/4.0/ch41s02.html#id-1.7.4.4.72) [GtkEntryBuffer ::deleted-text has changed](https://developer-old.gnome.org/gtk4/4.0/ch41s02.html#id-1.7.4.4.73) [GtkMenu, GtkMenuBar and GtkMenuItem are gone](https://developer-old.gnome.org/gtk4/4.0/ch41s02.html#id-1.7.4.4.74) [GtkToolbar has been removed](https://developer-old.gnome.org/gtk4/4.0/ch41s02.html#id-1.7.4.4.75) [GtkAspectFrame is no longer a frame](https://developer-old.gnome.org/gtk4/4.0/ch41s02.html#id-1.7.4.4.76) [Stop using custom tooltip windows](https://developer-old.gnome.org/gtk4/4.0/ch41s02.html#id-1.7.4.4.77) [Switch to the new Drag-and-Drop api](https://developer-old.gnome.org/gtk4/4.0/ch41s02.html#id-1.7.4.4.78) [Adapt to GtkIconTheme API changes](https://developer-old.gnome.org/gtk4/4.0/ch41s02.html#id-1.7.4.4.79) [Update to GtkFileChooser API changes](https://developer-old.gnome.org/gtk4/4.0/ch41s02.html#id-1.7.4.4.80) [Stop using blocking dialog functions](https://developer-old.gnome.org/gtk4/4.0/ch41s02.html#id-1.7.4.4.81) [Stop using GtkBuildable API](https://developer-old.gnome.org/gtk4/4.0/ch41s02.html#id-1.7.4.4.82) [Adapt to GtkAboutDialog API changes](https://developer-old.gnome.org/gtk4/4.0/ch41s02.html#id-1.7.4.4.83) [Adapt to GtkTreeView and GtkIconView tooltip context changes](https://developer-old.gnome.org/gtk4/4.0/ch41s02.html#id-1.7.4.4.84) [Stop using GtkFileChooserButton](https://developer-old.gnome.org/gtk4/4.0/ch41s02.html#id-1.7.4.4.85) [Adapt to changed GtkSettings properties](https://developer-old.gnome.org/gtk4/4.0/ch41s02.html#id-1.7.4.4.86) [Changes to consider after the switch](https://developer-old.gnome.org/gtk4/4.0/ch41s03.html) [Consider porting to the new list widgets](https://developer-old.gnome.org/gtk4/4.0/ch41s03.html#id-1.7.4.5.3) [VII. GTK Tools](https://developer-old.gnome.org/gtk4/4.0/pt07.html) <gtk4-demo> — Demonstrate GTK widgets <gtk4-demo-application> — Demonstrate GtkApplication <gtk4-widget-factory> — Demonstrate GTK widgets <gtk4-icon-browser> — List themed icons <gtk4-update-icon-cache> — Icon theme caching utility <gtk4-encode-symbolic-svg> — Symbolic icon conversion utility <gtk4-builder-tool> — GtkBuilder file utility <gtk4-launch> — Launch an application <gtk4-query-settings> — Utility to print name and value of all GtkSettings properties <gtk4-broadwayd> — Broadway display server [VIII. GTK Platform Support](https://developer-old.gnome.org/gtk4/4.0/platform-support.html) [Compiling the GTK Libraries](gtk-building) [Building GTK](gtk-building#id-1.9.2.2) [Build types](build-types) [Debug builds](build-types#id-1.9.2.3.3) [Release builds](build-types#id-1.9.2.3.4) [Dependencies](dependencies) [Building and testing GTK](building) [Extra Configuration Options](extra-configuration-options) [`x11-backend`, `win32-backend`, `broadway-backend`, `wayland-backend` and `macos-backend`](extra-configuration-options#id-1.9.2.6.5) [`vulkan`](extra-configuration-options#id-1.9.2.6.6) [`xinerama`](extra-configuration-options#id-1.9.2.6.7) [`media`](extra-configuration-options#id-1.9.2.6.8) [`print`](extra-configuration-options#id-1.9.2.6.9) [`cloudproviders`](extra-configuration-options#id-1.9.2.6.10) [`sysprof`](extra-configuration-options#id-1.9.2.6.11) [`tracker`](extra-configuration-options#id-1.9.2.6.12) [`colord`](extra-configuration-options#id-1.9.2.6.13) [`gtk_doc` and `man-pages`](extra-configuration-options#id-1.9.2.6.14) [`introspection`](extra-configuration-options#id-1.9.2.6.15) [`build-tests`, `install-tests`, `demos`](extra-configuration-options#id-1.9.2.6.16) [Compiling GTK Applications on UNIX](gtk-compiling) [Running and debugging GTK Applications](gtk-running) [Environment variables](gtk-running#id-1.9.4.2) [GTK\_DEBUG](gtk-running#GTK_Debug-Options) [GTK\_PATH](gtk-running#gtk-path) [GTK\_IM\_MODULE](gtk-running#id-1.9.4.2.5) [GTK\_MEDIA](gtk-running#id-1.9.4.2.6) [GTK\_EXE\_PREFIX](gtk-running#id-1.9.4.2.7) [GTK\_DATA\_PREFIX](gtk-running#id-1.9.4.2.8) [GTK\_THEME](gtk-running#id-1.9.4.2.9) [GDK\_PIXBUF\_MODULE\_FILE](gtk-running#id-1.9.4.2.10) [GDK\_DEBUG](gtk-running#id-1.9.4.2.11) [GSK\_DEBUG](gtk-running#GSK-Debug-Options) [GDK\_BACKEND](gtk-running#id-1.9.4.2.13) [GDK\_VULKAN\_DEVICE](gtk-running#id-1.9.4.2.14) [GSK\_RENDERER](gtk-running#id-1.9.4.2.15) [GTK\_CSD](gtk-running#id-1.9.4.2.16) [GTK\_A11Y](gtk-running#id-1.9.4.2.17) [XDG\_DTA\_HOME, XDG\_DATA\_DIRS](gtk-running#id-1.9.4.2.18) [DESKTOP\_STARTUP\_ID](gtk-running#id-1.9.4.2.19) [Interactive debugging](interactive-debugging) [Profiling](profiling) [GTK for the X Window System](gtk-x11) [X11-specific environment variables](gtk-x11#x11-envar) [GDK\_SYNCHRONIZE](gtk-x11#id-1.9.5.4.3) [GDK\_SCALE](gtk-x11#id-1.9.5.4.4) [Understanding the X11 architecture](gtk-x11-arch) [Server, client, window manager](gtk-x11-arch#id-1.9.5.5.5) [Using GTK on Windows](gtk-windows) [Windows-specific environment variables](gtk-windows#win32-envar) [GDK\_IGNORE\_WINTAB](gtk-windows#id-1.9.6.4.3) [GDK\_USE\_WINTAB](gtk-windows#id-1.9.6.4.4) [Windows-specific handling of cursors](win32-cursors) [Using GTK on Apple macOS](gtk-osx) [Using GTK with Broadway](gtk-broadway) [Broadway-specific environment variables](gtk-broadway#broadway-envar) [BROADWAY\_DISPLAY](gtk-broadway#id-1.9.8.8.2) [Using GTK with Wayland](gtk-wayland) [Wayland-specific environment variables](gtk-wayland#wayland-envar) [WAYLAND\_DISPLAY](gtk-wayland#id-1.9.9.4.2) [XDG\_RUNTIME\_DIR](gtk-wayland#id-1.9.9.4.3) [Index of all symbols](https://developer-old.gnome.org/gtk4/4.0/api-index-full.html) [Annotation Glossary](https://developer-old.gnome.org/gtk4/4.0/annotation-glossary.html)
| programming_docs |
gtk GtkEventController GtkEventController
==================
GtkEventController — Self-contained handler of series of events
Functions
---------
| | |
| --- | --- |
| [GtkPropagationPhase](gtkeventcontroller#GtkPropagationPhase) | [gtk\_event\_controller\_get\_propagation\_phase](gtkeventcontroller#gtk-event-controller-get-propagation-phase) () |
| void | [gtk\_event\_controller\_set\_propagation\_phase](gtkeventcontroller#gtk-event-controller-set-propagation-phase) () |
| [GtkPropagationLimit](gtkeventcontroller#GtkPropagationLimit) | [gtk\_event\_controller\_get\_propagation\_limit](gtkeventcontroller#gtk-event-controller-get-propagation-limit) () |
| void | [gtk\_event\_controller\_set\_propagation\_limit](gtkeventcontroller#gtk-event-controller-set-propagation-limit) () |
| [GtkWidget](gtkwidget#GtkWidget-struct) \* | [gtk\_event\_controller\_get\_widget](gtkeventcontroller#gtk-event-controller-get-widget) () |
| void | [gtk\_event\_controller\_reset](gtkeventcontroller#gtk-event-controller-reset) () |
| const char \* | [gtk\_event\_controller\_get\_name](gtkeventcontroller#gtk-event-controller-get-name) () |
| void | [gtk\_event\_controller\_set\_name](gtkeventcontroller#gtk-event-controller-set-name) () |
| [GdkEvent](https://developer-old.gnome.org/gtk4/html/gdk4-Events.html#GdkEvent-struct) \* | [gtk\_event\_controller\_get\_current\_event](gtkeventcontroller#gtk-event-controller-get-current-event) () |
| [GdkDevice](https://developer-old.gnome.org/gtk4/html/GdkDevice.html#GdkDevice-struct) \* | [gtk\_event\_controller\_get\_current\_event\_device](gtkeventcontroller#gtk-event-controller-get-current-event-device) () |
| [GdkModifierType](https://developer-old.gnome.org/gtk4/html/GdkSurface.html#GdkModifierType) | [gtk\_event\_controller\_get\_current\_event\_state](gtkeventcontroller#gtk-event-controller-get-current-event-state) () |
| guint32 | [gtk\_event\_controller\_get\_current\_event\_time](gtkeventcontroller#gtk-event-controller-get-current-event-time) () |
Properties
----------
| | | |
| --- | --- | --- |
| char \* | [name](gtkeventcontroller#GtkEventController--name) | Read / Write |
| [GtkPropagationLimit](gtkeventcontroller#GtkPropagationLimit) | [propagation-limit](gtkeventcontroller#GtkEventController--propagation-limit) | Read / Write |
| [GtkPropagationPhase](gtkeventcontroller#GtkPropagationPhase) | [propagation-phase](gtkeventcontroller#GtkEventController--propagation-phase) | Read / Write |
| [GtkWidget](gtkwidget#GtkWidget-struct) \* | [widget](gtkeventcontroller#GtkEventController--widget) | Read |
Types and Values
----------------
| | |
| --- | --- |
| | [GtkEventController](gtkeventcontroller#GtkEventController-struct) |
| enum | [GtkPropagationPhase](gtkeventcontroller#GtkPropagationPhase) |
| enum | [GtkPropagationLimit](gtkeventcontroller#GtkPropagationLimit) |
Object Hierarchy
----------------
```
GObject
╰── GtkEventController
├── [GtkGesture](gtkgesture#GtkGesture-struct)
├── [GtkDropControllerMotion](https://developer-old.gnome.org/usr/share/gtk-doc/html/gtk4/gtk4-GtkDropControllerMotion.html#GtkDropControllerMotion)
├── [GtkDropTargetAsync](gtkdroptargetasync#GtkDropTargetAsync-struct)
├── [GtkDropTarget](gtkdroptarget#GtkDropTarget-struct)
├── [GtkEventControllerKey](gtkeventcontrollerkey#GtkEventControllerKey-struct)
├── [GtkEventControllerFocus](gtkeventcontrollerfocus#GtkEventControllerFocus-struct)
├── [GtkEventControllerLegacy](gtkeventcontrollerlegacy#GtkEventControllerLegacy-struct)
├── [GtkEventControllerMotion](gtkeventcontrollermotion#GtkEventControllerMotion-struct)
├── [GtkEventControllerScroll](gtkeventcontrollerscroll#GtkEventControllerScroll-struct)
├── [GtkPadController](gtkpadcontroller#GtkPadController-struct)
╰── [GtkShortcutController](gtkshortcutcontroller#GtkShortcutController-struct)
```
Includes
--------
```
#include <gtk/gtk.h>
```
Description
-----------
[GtkEventController](gtkeventcontroller#GtkEventController-struct) is a base, low-level implementation for event controllers. Those react to a series of [GdkEvents](https://developer-old.gnome.org/gtk4/html/gdk4-Events.html#GdkEvent-struct), and possibly trigger actions as a consequence of those.
Functions
---------
### gtk\_event\_controller\_get\_propagation\_phase ()
```
[GtkPropagationPhase](gtkeventcontroller#GtkPropagationPhase)
gtk_event_controller_get_propagation_phase
(*`[GtkEventController](gtkeventcontroller#GtkEventController-struct) *controller`*);
```
Gets the propagation phase at which *`controller`* handles events.
#### Parameters
| | | |
| --- | --- | --- |
| controller | a [GtkEventController](gtkeventcontroller#GtkEventController-struct) | |
#### Returns
the propagation phase
### gtk\_event\_controller\_set\_propagation\_phase ()
```
void
gtk_event_controller_set_propagation_phase
(*`[GtkEventController](gtkeventcontroller#GtkEventController-struct) *controller`*,
*`[GtkPropagationPhase](gtkeventcontroller#GtkPropagationPhase) phase`*);
```
Sets the propagation phase at which a controller handles events.
If *`phase`* is [`GTK_PHASE_NONE`](gtkeventcontroller#GTK-PHASE-NONE:CAPS), no automatic event handling will be performed, but other additional gesture maintenance will. In that phase, the events can be managed by calling `gtk_event_controller_handle_event()`.
#### Parameters
| | | |
| --- | --- | --- |
| controller | a [GtkEventController](gtkeventcontroller#GtkEventController-struct) | |
| phase | a propagation phase | |
### gtk\_event\_controller\_get\_propagation\_limit ()
```
[GtkPropagationLimit](gtkeventcontroller#GtkPropagationLimit)
gtk_event_controller_get_propagation_limit
(*`[GtkEventController](gtkeventcontroller#GtkEventController-struct) *controller`*);
```
Gets the propagation limit of the event controller.
#### Parameters
| | | |
| --- | --- | --- |
| controller | a [GtkEventController](gtkeventcontroller#GtkEventController-struct) | |
#### Returns
the propagation limit
### gtk\_event\_controller\_set\_propagation\_limit ()
```
void
gtk_event_controller_set_propagation_limit
(*`[GtkEventController](gtkeventcontroller#GtkEventController-struct) *controller`*,
*`[GtkPropagationLimit](gtkeventcontroller#GtkPropagationLimit) limit`*);
```
Sets the event propagation limit on the event controller.
If the limit is set to [`GTK_LIMIT_SAME_NATIVE`](gtkeventcontroller#GTK-LIMIT-SAME-NATIVE:CAPS), the controller won't handle events that are targeted at widgets on a different surface, such as popovers.
#### Parameters
| | | |
| --- | --- | --- |
| controller | a [GtkEventController](gtkeventcontroller#GtkEventController-struct) | |
| limit | the propagation limit | |
### gtk\_event\_controller\_get\_widget ()
```
[GtkWidget](gtkwidget#GtkWidget-struct) *
gtk_event_controller_get_widget (*`[GtkEventController](gtkeventcontroller#GtkEventController-struct) *controller`*);
```
Returns the [GtkWidget](gtkwidget#GtkWidget-struct) this controller relates to.
#### Parameters
| | | |
| --- | --- | --- |
| controller | a [GtkEventController](gtkeventcontroller#GtkEventController-struct) | |
#### Returns
a [GtkWidget](gtkwidget#GtkWidget-struct).
[transfer none]
### gtk\_event\_controller\_reset ()
```
void
gtk_event_controller_reset (*`[GtkEventController](gtkeventcontroller#GtkEventController-struct) *controller`*);
```
Resets the *`controller`* to a clean state. Every interaction the controller did through `gtk_event_controller_handle_event()` will be dropped at this point.
#### Parameters
| | | |
| --- | --- | --- |
| controller | a [GtkEventController](gtkeventcontroller#GtkEventController-struct) | |
### gtk\_event\_controller\_get\_name ()
```
const char *
gtk_event_controller_get_name (*`[GtkEventController](gtkeventcontroller#GtkEventController-struct) *controller`*);
```
Gets the name of *`controller`* .
#### Parameters
| | | |
| --- | --- | --- |
| controller | a [GtkEventController](gtkeventcontroller#GtkEventController-struct) | |
### gtk\_event\_controller\_set\_name ()
```
void
gtk_event_controller_set_name (*`[GtkEventController](gtkeventcontroller#GtkEventController-struct) *controller`*,
*`const char *name`*);
```
Sets a name on the controller that can be used for debugging.
#### Parameters
| | | |
| --- | --- | --- |
| controller | a [GtkEventController](gtkeventcontroller#GtkEventController-struct) | |
| name | a name for *`controller`* | |
### gtk\_event\_controller\_get\_current\_event ()
```
[GdkEvent](https://developer-old.gnome.org/gtk4/html/gdk4-Events.html#GdkEvent-struct) *
gtk_event_controller_get_current_event
(*`[GtkEventController](gtkeventcontroller#GtkEventController-struct) *controller`*);
```
Returns the event that is currently being handled by the controller, and `NULL` at other times.
#### Parameters
| | | |
| --- | --- | --- |
| controller | a [GtkEventController](gtkeventcontroller#GtkEventController-struct) | |
#### Returns
the event is current handled by *`controller`* .
[nullable][transfer none]
### gtk\_event\_controller\_get\_current\_event\_device ()
```
[GdkDevice](https://developer-old.gnome.org/gtk4/html/GdkDevice.html#GdkDevice-struct) *
gtk_event_controller_get_current_event_device
(*`[GtkEventController](gtkeventcontroller#GtkEventController-struct) *controller`*);
```
Returns the device of the event that is currently being handled by the controller, and `NULL` otherwise.
#### Parameters
| | | |
| --- | --- | --- |
| controller | a [GtkEventController](gtkeventcontroller#GtkEventController-struct) | |
#### Returns
device of the event is current handled by *`controller`* .
[nullable][transfer none]
### gtk\_event\_controller\_get\_current\_event\_state ()
```
[GdkModifierType](https://developer-old.gnome.org/gtk4/html/GdkSurface.html#GdkModifierType)
gtk_event_controller_get_current_event_state
(*`[GtkEventController](gtkeventcontroller#GtkEventController-struct) *controller`*);
```
Returns the modifier state of the event that is currently being handled by the controller, and 0 otherwise.
#### Parameters
| | | |
| --- | --- | --- |
| controller | a [GtkEventController](gtkeventcontroller#GtkEventController-struct) | |
#### Returns
modifier state of the event is current handled by *`controller`*
### gtk\_event\_controller\_get\_current\_event\_time ()
```
guint32
gtk_event_controller_get_current_event_time
(*`[GtkEventController](gtkeventcontroller#GtkEventController-struct) *controller`*);
```
Returns the timestamp of the event that is currently being handled by the controller, and 0 otherwise.
#### Parameters
| | | |
| --- | --- | --- |
| controller | a [GtkEventController](gtkeventcontroller#GtkEventController-struct) | |
#### Returns
timestamp of the event is current handled by *`controller`*
Types and Values
----------------
### GtkEventController
```
typedef struct _GtkEventController GtkEventController;
```
### enum GtkPropagationPhase
Describes the stage at which events are fed into a [GtkEventController](gtkeventcontroller#GtkEventController-struct).
#### Members
| | | |
| --- | --- | --- |
| GTK\_PHASE\_NONE | Events are not delivered. | |
| GTK\_PHASE\_CAPTURE | Events are delivered in the capture phase. The capture phase happens before the bubble phase, runs from the toplevel down to the event widget. This option should only be used on containers that might possibly handle events before their children do. | |
| GTK\_PHASE\_BUBBLE | Events are delivered in the bubble phase. The bubble phase happens after the capture phase, and before the default handlers are run. This phase runs from the event widget, up to the toplevel. | |
| GTK\_PHASE\_TARGET | Events are delivered in the default widget event handlers, note that widget implementations must chain up on button, motion, touch and grab broken handlers for controllers in this phase to be run. | |
### enum GtkPropagationLimit
Describes limits of a [GtkEventController](gtkeventcontroller#GtkEventController-struct) for handling events targeting other widgets.
#### Members
| | | |
| --- | --- | --- |
| GTK\_LIMIT\_NONE | Events are handled regardless of what their target is. | |
| GTK\_LIMIT\_SAME\_NATIVE | Events are only handled if their target is in the same [GtkNative](gtknative#GtkNative-struct) as the event controllers widget. Note that some event types have two targets (origin and destination). | |
Property Details
----------------
### The `“name”` property
```
“name” char *
```
The name for this controller, typically used for debugging purposes.
Owner: GtkEventController
Flags: Read / Write
Default value: NULL
### The `“propagation-limit”` property
```
“propagation-limit” [GtkPropagationLimit](gtkeventcontroller#GtkPropagationLimit)
```
The limit for which events this controller will handle.
Owner: GtkEventController
Flags: Read / Write
Default value: GTK\_LIMIT\_SAME\_NATIVE
### The `“propagation-phase”` property
```
“propagation-phase” [GtkPropagationPhase](gtkeventcontroller#GtkPropagationPhase)
```
The propagation phase at which this controller will handle events.
Owner: GtkEventController
Flags: Read / Write
Default value: GTK\_PHASE\_BUBBLE
### The `“widget”` property
```
“widget” [GtkWidget](gtkwidget#GtkWidget-struct) *
```
The widget receiving the [GdkEvents](https://developer-old.gnome.org/gtk4/html/gdk4-Events.html#GdkEvent-struct) that the controller will handle.
Owner: GtkEventController
Flags: Read
See Also
--------
[GtkGesture](gtkgesture#GtkGesture-struct)
gtk GtkCellEditable GtkCellEditable
===============
GtkCellEditable — Interface for widgets that can be used for editing cells
Functions
---------
| | |
| --- | --- |
| void | [gtk\_cell\_editable\_start\_editing](gtkcelleditable#gtk-cell-editable-start-editing) () |
| void | [gtk\_cell\_editable\_editing\_done](gtkcelleditable#gtk-cell-editable-editing-done) () |
| void | [gtk\_cell\_editable\_remove\_widget](gtkcelleditable#gtk-cell-editable-remove-widget) () |
Properties
----------
| | | |
| --- | --- | --- |
| gboolean | [editing-canceled](gtkcelleditable#GtkCellEditable--editing-canceled) | Read / Write |
Signals
-------
| | | |
| --- | --- | --- |
| void | [editing-done](gtkcelleditable#GtkCellEditable-editing-done) | Run Last |
| void | [remove-widget](gtkcelleditable#GtkCellEditable-remove-widget) | Run Last |
Types and Values
----------------
| | |
| --- | --- |
| | [GtkCellEditable](gtkcelleditable#GtkCellEditable-struct) |
| struct | [GtkCellEditableIface](gtkcelleditable#GtkCellEditableIface) |
Object Hierarchy
----------------
```
[GInterface](https://developer-old.gnome.org/gobject/stable/GTypeModule.html)
╰── GtkCellEditable
```
Prerequisites
-------------
GtkCellEditable requires [GtkWidget](gtkwidget#GtkWidget-struct).
Known Implementations
---------------------
GtkCellEditable is implemented by [GtkComboBox](gtkcombobox#GtkComboBox-struct), [GtkComboBoxText](gtkcomboboxtext#GtkComboBoxText-struct), [GtkEntry](gtkentry#GtkEntry-struct) and [GtkSpinButton](gtkspinbutton#GtkSpinButton-struct).
Includes
--------
```
#include <gtk/gtk.h>
```
Description
-----------
The [GtkCellEditable](gtkcelleditable#GtkCellEditable-struct) interface must be implemented for widgets to be usable to edit the contents of a [GtkTreeView](gtktreeview#GtkTreeView-struct) cell. It provides a way to specify how temporary widgets should be configured for editing, get the new value, etc.
Functions
---------
### gtk\_cell\_editable\_start\_editing ()
```
void
gtk_cell_editable_start_editing (*`[GtkCellEditable](gtkcelleditable#GtkCellEditable-struct) *cell_editable`*,
*`[GdkEvent](https://developer-old.gnome.org/gtk4/html/gdk4-Events.html#GdkEvent-struct) *event`*);
```
Begins editing on a *`cell_editable`* .
The [GtkCellRenderer](gtkcellrenderer#GtkCellRenderer-struct) for the cell creates and returns a [GtkCellEditable](gtkcelleditable#GtkCellEditable-struct) from [`gtk_cell_renderer_start_editing()`](gtkcellrenderer#gtk-cell-renderer-start-editing), configured for the [GtkCellRenderer](gtkcellrenderer#GtkCellRenderer-struct) type.
gtk\_cell\_editable\_start\_editing() can then set up *`cell_editable`* suitably for editing a cell, e.g. making the Esc key emit [“editing-done”](gtkcelleditable#GtkCellEditable-editing-done).
Note that the *`cell_editable`* is created on-demand for the current edit; its lifetime is temporary and does not persist across other edits and/or cells.
#### Parameters
| | | |
| --- | --- | --- |
| cell\_editable | A [GtkCellEditable](gtkcelleditable#GtkCellEditable-struct) | |
| event | The [GdkEvent](https://developer-old.gnome.org/gtk4/html/gdk4-Events.html#GdkEvent-struct) that began the editing process, or `NULL` if editing was initiated programmatically. | [nullable] |
### gtk\_cell\_editable\_editing\_done ()
```
void
gtk_cell_editable_editing_done (*`[GtkCellEditable](gtkcelleditable#GtkCellEditable-struct) *cell_editable`*);
```
Emits the [“editing-done”](gtkcelleditable#GtkCellEditable-editing-done) signal.
#### Parameters
| | | |
| --- | --- | --- |
| cell\_editable | A [GtkCellEditable](gtkcelleditable#GtkCellEditable-struct) | |
### gtk\_cell\_editable\_remove\_widget ()
```
void
gtk_cell_editable_remove_widget (*`[GtkCellEditable](gtkcelleditable#GtkCellEditable-struct) *cell_editable`*);
```
Emits the [“remove-widget”](gtkcelleditable#GtkCellEditable-remove-widget) signal.
#### Parameters
| | | |
| --- | --- | --- |
| cell\_editable | A [GtkCellEditable](gtkcelleditable#GtkCellEditable-struct) | |
Types and Values
----------------
### GtkCellEditable
```
typedef struct _GtkCellEditable GtkCellEditable;
```
### struct GtkCellEditableIface
```
struct GtkCellEditableIface {
/* signals */
void (* editing_done) (GtkCellEditable *cell_editable);
void (* remove_widget) (GtkCellEditable *cell_editable);
/* virtual table */
void (* start_editing) (GtkCellEditable *cell_editable,
GdkEvent *event);
};
```
#### Members
| | | |
| --- | --- | --- |
| *`editing_done`* () | Signal is a sign for the cell renderer to update its value from the cell\_editable. | |
| *`remove_widget`* () | Signal is meant to indicate that the cell is finished editing, and the widget may now be destroyed. | |
| *`start_editing`* () | Begins editing on a cell\_editable. | |
Property Details
----------------
### The `“editing-canceled”` property
```
“editing-canceled” gboolean
```
Indicates whether editing on the cell has been canceled.
Owner: GtkCellEditable
Flags: Read / Write
Default value: FALSE
Signal Details
--------------
### The `“editing-done”` signal
```
void
user_function ([GtkCellEditable](gtkcelleditable#GtkCellEditable-struct) *cell_editable,
gpointer user_data)
```
This signal is a sign for the cell renderer to update its value from the *`cell_editable`* .
Implementations of [GtkCellEditable](gtkcelleditable#GtkCellEditable-struct) are responsible for emitting this signal when they are done editing, e.g. [GtkEntry](gtkentry#GtkEntry-struct) emits this signal when the user presses Enter. Typical things to do in a handler for ::editing-done are to capture the edited value, disconnect the *`cell_editable`* from signals on the [GtkCellRenderer](gtkcellrenderer#GtkCellRenderer-struct), etc.
gtk\_cell\_editable\_editing\_done() is a convenience method for emitting [“editing-done”](gtkcelleditable#GtkCellEditable-editing-done).
#### Parameters
| | | |
| --- | --- | --- |
| cell\_editable | the object on which the signal was emitted | |
| user\_data | user data set when the signal handler was connected. | |
Flags: Run Last
### The `“remove-widget”` signal
```
void
user_function ([GtkCellEditable](gtkcelleditable#GtkCellEditable-struct) *cell_editable,
gpointer user_data)
```
This signal is meant to indicate that the cell is finished editing, and the *`cell_editable`* widget is being removed and may subsequently be destroyed.
Implementations of [GtkCellEditable](gtkcelleditable#GtkCellEditable-struct) are responsible for emitting this signal when they are done editing. It must be emitted after the [“editing-done”](gtkcelleditable#GtkCellEditable-editing-done) signal, to give the cell renderer a chance to update the cell's value before the widget is removed.
gtk\_cell\_editable\_remove\_widget() is a convenience method for emitting [“remove-widget”](gtkcelleditable#GtkCellEditable-remove-widget).
#### Parameters
| | | |
| --- | --- | --- |
| cell\_editable | the object on which the signal was emitted | |
| user\_data | user data set when the signal handler was connected. | |
Flags: Run Last
See Also
--------
[GtkCellRenderer](gtkcellrenderer#GtkCellRenderer-struct)
| programming_docs |
gtk GtkGesturePan GtkGesturePan
=============
GtkGesturePan — Pan gesture
Functions
---------
| | |
| --- | --- |
| [GtkGesture](gtkgesture#GtkGesture-struct) \* | [gtk\_gesture\_pan\_new](gtkgesturepan#gtk-gesture-pan-new) () |
| [GtkOrientation](gtk4-standard-enumerations#GtkOrientation) | [gtk\_gesture\_pan\_get\_orientation](gtkgesturepan#gtk-gesture-pan-get-orientation) () |
| void | [gtk\_gesture\_pan\_set\_orientation](gtkgesturepan#gtk-gesture-pan-set-orientation) () |
Properties
----------
| | | |
| --- | --- | --- |
| [GtkOrientation](gtk4-standard-enumerations#GtkOrientation) | [orientation](gtkgesturepan#GtkGesturePan--orientation) | Read / Write |
Signals
-------
| | | |
| --- | --- | --- |
| void | [pan](gtkgesturepan#GtkGesturePan-pan) | Run Last |
Types and Values
----------------
| | |
| --- | --- |
| | [GtkGesturePan](gtkgesturepan#GtkGesturePan-struct) |
| enum | [GtkPanDirection](gtkgesturepan#GtkPanDirection) |
Object Hierarchy
----------------
```
GObject
╰── [GtkEventController](gtkeventcontroller#GtkEventController-struct)
╰── [GtkGesture](gtkgesture#GtkGesture-struct)
╰── [GtkGestureSingle](gtkgesturesingle#GtkGestureSingle-struct)
╰── [GtkGestureDrag](gtkgesturedrag#GtkGestureDrag-struct)
╰── GtkGesturePan
```
Includes
--------
```
#include <gtk/gtk.h>
```
Description
-----------
[GtkGesturePan](gtkgesturepan#GtkGesturePan-struct) is a [GtkGesture](gtkgesture#GtkGesture-struct) implementation able to recognize pan gestures, those are drags that are locked to happen along one axis. The axis that a [GtkGesturePan](gtkgesturepan#GtkGesturePan-struct) handles is defined at construct time, and can be changed through [`gtk_gesture_pan_set_orientation()`](gtkgesturepan#gtk-gesture-pan-set-orientation).
When the gesture starts to be recognized, [GtkGesturePan](gtkgesturepan#GtkGesturePan-struct) will attempt to determine as early as possible whether the sequence is moving in the expected direction, and denying the sequence if this does not happen.
Once a panning gesture along the expected axis is recognized, the [“pan”](gtkgesturepan#GtkGesturePan-pan) signal will be emitted as input events are received, containing the offset in the given axis.
Functions
---------
### gtk\_gesture\_pan\_new ()
```
[GtkGesture](gtkgesture#GtkGesture-struct) *
gtk_gesture_pan_new (*`[GtkOrientation](gtk4-standard-enumerations#GtkOrientation) orientation`*);
```
Returns a newly created [GtkGesture](gtkgesture#GtkGesture-struct) that recognizes pan gestures.
#### Parameters
| | | |
| --- | --- | --- |
| orientation | expected orientation | |
#### Returns
a newly created [GtkGesturePan](gtkgesturepan#GtkGesturePan-struct)
### gtk\_gesture\_pan\_get\_orientation ()
```
[GtkOrientation](gtk4-standard-enumerations#GtkOrientation)
gtk_gesture_pan_get_orientation (*`[GtkGesturePan](gtkgesturepan#GtkGesturePan-struct) *gesture`*);
```
Returns the orientation of the pan gestures that this *`gesture`* expects.
#### Parameters
| | | |
| --- | --- | --- |
| gesture | A [GtkGesturePan](gtkgesturepan#GtkGesturePan-struct) | |
#### Returns
the expected orientation for pan gestures
### gtk\_gesture\_pan\_set\_orientation ()
```
void
gtk_gesture_pan_set_orientation (*`[GtkGesturePan](gtkgesturepan#GtkGesturePan-struct) *gesture`*,
*`[GtkOrientation](gtk4-standard-enumerations#GtkOrientation) orientation`*);
```
Sets the orientation to be expected on pan gestures.
#### Parameters
| | | |
| --- | --- | --- |
| gesture | A [GtkGesturePan](gtkgesturepan#GtkGesturePan-struct) | |
| orientation | expected orientation | |
Types and Values
----------------
### GtkGesturePan
```
typedef struct _GtkGesturePan GtkGesturePan;
```
### enum GtkPanDirection
Describes the panning direction of a [GtkGesturePan](gtkgesturepan#GtkGesturePan-struct)
#### Members
| | | |
| --- | --- | --- |
| GTK\_PAN\_DIRECTION\_LEFT | panned towards the left | |
| GTK\_PAN\_DIRECTION\_RIGHT | panned towards the right | |
| GTK\_PAN\_DIRECTION\_UP | panned upwards | |
| GTK\_PAN\_DIRECTION\_DOWN | panned downwards | |
Property Details
----------------
### The `“orientation”` property
```
“orientation” [GtkOrientation](gtk4-standard-enumerations#GtkOrientation)
```
The expected orientation of pan gestures.
Owner: GtkGesturePan
Flags: Read / Write
Default value: GTK\_ORIENTATION\_HORIZONTAL
Signal Details
--------------
### The `“pan”` signal
```
void
user_function ([GtkGesturePan](gtkgesturepan#GtkGesturePan-struct) *gesture,
[GtkPanDirection](gtkgesturepan#GtkPanDirection) direction,
double offset,
gpointer user_data)
```
This signal is emitted once a panning gesture along the expected axis is detected.
#### Parameters
| | | |
| --- | --- | --- |
| gesture | The object which received the signal | |
| direction | current direction of the pan gesture | |
| offset | Offset along the gesture orientation | |
| user\_data | user data set when the signal handler was connected. | |
Flags: Run Last
gtk GtkBuilderScope GtkBuilderScope
===============
GtkBuilderScope — Bindings for GtkBuilder
Functions
---------
| | |
| --- | --- |
| [GtkBuilderScope](gtkbuilderscope#GtkBuilderScope-struct) \* | [gtk\_builder\_cscope\_new](gtkbuilderscope#gtk-builder-cscope-new) () |
| void | [gtk\_builder\_cscope\_add\_callback\_symbol](gtkbuilderscope#gtk-builder-cscope-add-callback-symbol) () |
| void | [gtk\_builder\_cscope\_add\_callback\_symbols](gtkbuilderscope#gtk-builder-cscope-add-callback-symbols) () |
| GCallback | [gtk\_builder\_cscope\_lookup\_callback\_symbol](gtkbuilderscope#gtk-builder-cscope-lookup-callback-symbol) () |
Types and Values
----------------
| | |
| --- | --- |
| | [GtkBuilderScope](gtkbuilderscope#GtkBuilderScope-struct) |
| enum | [GtkBuilderClosureFlags](gtkbuilderscope#GtkBuilderClosureFlags) |
| struct | [GtkBuilderScopeInterface](gtkbuilderscope#GtkBuilderScopeInterface) |
| | [GtkBuilderCScope](gtkbuilderscope#GtkBuilderCScope-struct) |
Object Hierarchy
----------------
```
[GInterface](https://developer-old.gnome.org/gobject/stable/GTypeModule.html)
╰── GtkBuilderScope
GObject
╰── GtkBuilderCScope
```
Prerequisites
-------------
GtkBuilderScope requires GObject.
Implemented Interfaces
----------------------
GtkBuilderCScope implements [GtkBuilderScope](gtkbuilderscope#GtkBuilderScope-struct).
Known Implementations
---------------------
GtkBuilderScope is implemented by [GtkBuilderCScope](gtkbuilderscope#GtkBuilderCScope-struct).
Includes
--------
```
#include <gtk/gtk.h>
```
Description
-----------
[GtkBuilderScope](gtkbuilderscope#GtkBuilderScope-struct) is an interface to provide support to [GtkBuilder](gtkbuilder#GtkBuilder-struct), primarily for looking up programming-language-specific values for strings that are given in a [GtkBuilder](gtkbuilder#GtkBuilder-struct) UI file.
The primary intended audience is bindings that want to provide deeper integration of [GtkBuilder](gtkbuilder#GtkBuilder-struct) into the language.
A [GtkBuilderScope](gtkbuilderscope#GtkBuilderScope-struct) instance may be used with multiple [GtkBuilder](gtkbuilder#GtkBuilder-struct) objects, even at once.
By default, GTK will use its own implementation of [GtkBuilderScope](gtkbuilderscope#GtkBuilderScope-struct) for the C language which can be created via [`gtk_builder_cscope_new()`](gtkbuilderscope#gtk-builder-cscope-new).
[GtkBuilderCScope](gtkbuilderscope#GtkBuilderCScope-struct) instances use symbols explicitly added to *`builder`* with prior calls to [`gtk_builder_cscope_add_callback_symbol()`](gtkbuilderscope#gtk-builder-cscope-add-callback-symbol). If developers want to do that, they are encouraged to create their own scopes for that purpose.
In the case that symbols are not explicitly added; GTK will uses GModule’s introspective features (by opening the module `NULL`) to look at the application’s symbol table. From here it tries to match the signal function names given in the interface description with symbols in the application.
Note that unless [`gtk_builder_cscope_add_callback_symbol()`](gtkbuilderscope#gtk-builder-cscope-add-callback-symbol) is called for all signal callbacks which are referenced by the loaded XML, this functionality will require that GModule be supported on the platform.
Functions
---------
### gtk\_builder\_cscope\_new ()
```
[GtkBuilderScope](gtkbuilderscope#GtkBuilderScope-struct) *
gtk_builder_cscope_new (*`void`*);
```
Creates a new [GtkBuilderCScope](gtkbuilderscope#GtkBuilderCScope-struct) object to use with future [GtkBuilder](gtkbuilder#GtkBuilder-struct) instances.
Calling this function is only necessary if you want to add custom callbacks via [`gtk_builder_cscope_add_callback_symbol()`](gtkbuilderscope#gtk-builder-cscope-add-callback-symbol).
#### Returns
a new [GtkBuilderCScope](gtkbuilderscope#GtkBuilderCScope-struct).
[transfer full][type GtkBuilderCScope]
### gtk\_builder\_cscope\_add\_callback\_symbol ()
```
void
gtk_builder_cscope_add_callback_symbol
(*`[GtkBuilderCScope](gtkbuilderscope#GtkBuilderCScope-struct) *self`*,
*`const char *callback_name`*,
*`GCallback callback_symbol`*);
```
Adds the *`callback_symbol`* to the scope of *`builder`* under the given *`callback_name`* .
Using this function overrides the behavior of [`gtk_builder_create_closure()`](gtkbuilder#gtk-builder-create-closure) for any callback symbols that are added. Using this method allows for better encapsulation as it does not require that callback symbols be declared in the global namespace.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkBuilderCScope](gtkbuilderscope#GtkBuilderCScope-struct) | |
| callback\_name | The name of the callback, as expected in the XML | |
| callback\_symbol | The callback pointer. | [scope async] |
### gtk\_builder\_cscope\_add\_callback\_symbols ()
```
void
gtk_builder_cscope_add_callback_symbols
(*`[GtkBuilderCScope](gtkbuilderscope#GtkBuilderCScope-struct) *self`*,
*`const char *first_callback_name`*,
*`GCallback first_callback_symbol`*,
*`...`*);
```
A convenience function to add many callbacks instead of calling [`gtk_builder_cscope_add_callback_symbol()`](gtkbuilderscope#gtk-builder-cscope-add-callback-symbol) for each symbol.
[skip]
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkBuilderCScope](gtkbuilderscope#GtkBuilderCScope-struct) | |
| first\_callback\_name | The name of the callback, as expected in the XML | |
| first\_callback\_symbol | The callback pointer. | [scope async] |
| ... | A list of callback name and callback symbol pairs terminated with `NULL` | |
### gtk\_builder\_cscope\_lookup\_callback\_symbol ()
```
GCallback
gtk_builder_cscope_lookup_callback_symbol
(*`[GtkBuilderCScope](gtkbuilderscope#GtkBuilderCScope-struct) *self`*,
*`const char *callback_name`*);
```
Fetches a symbol previously added to *`self`* with [`gtk_builder_cscope_add_callback_symbol()`](gtkbuilderscope#gtk-builder-cscope-add-callback-symbol).
[skip]
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkBuilderCScope](gtkbuilderscope#GtkBuilderCScope-struct) | |
| callback\_name | The name of the callback | |
#### Returns
The callback symbol in *`builder`* for *`callback_name`* , or `NULL`.
[nullable][transfer none]
Types and Values
----------------
### GtkBuilderScope
```
typedef struct _GtkBuilderScope GtkBuilderScope;
```
### enum GtkBuilderClosureFlags
The list of flags that can be passed to [`gtk_builder_create_closure()`](gtkbuilder#gtk-builder-create-closure). New values may be added in the future for new features, so external implementations of GtkBuilderScopeInterface should test the flags for unknown values and raise a [`GTK_BUILDER_ERROR_INVALID_ATTRIBUTE`](gtkbuilder#GTK-BUILDER-ERROR-INVALID-ATTRIBUTE:CAPS) error when they encounter one.
#### Members
| | | |
| --- | --- | --- |
| GTK\_BUILDER\_CLOSURE\_SWAPPED | The closure should be created swapped. See `g_cclosure_new_swap()` for details. | |
### struct GtkBuilderScopeInterface
```
struct GtkBuilderScopeInterface {
GType (* get_type_from_name) (GtkBuilderScope *self,
GtkBuilder *builder,
const char *type_name);
GType (* get_type_from_function) (GtkBuilderScope *self,
GtkBuilder *builder,
const char *function_name);
GClosure * (* create_closure) (GtkBuilderScope *self,
GtkBuilder *builder,
const char *function_name,
GtkBuilderClosureFlags flags,
GObject *object,
GError **error);
};
```
The virtual function table to implement for [GtkBuilderScope](gtkbuilderscope#GtkBuilderScope-struct) implementations. Default implementations for each function do exist, but they usually just fail, so it is suggested that implementations implement all of them.
#### Members
| | | |
| --- | --- | --- |
| *`get_type_from_name`* () | Try to lookup a GType via the its name. See [`gtk_builder_get_type_from_name()`](gtkbuilder#gtk-builder-get-type-from-name) for more details. The C implementation will use `g_type_from_name()` and if that fails try to guess the correct function name for registering the type and then use `dlsym()` to load it. The default implementation just tries `g_type_from_name()` and otherwise fails. | |
| *`get_type_from_function`* () | Try to lookup a GType via the given function name, specified explicitly in a GtkBuilder file, like via the "type-func" attribute in the "<object>" tag. This function is very rarely used. The C implementation will use `dlsym()` and call the resulting function as a GTypeFunc. The default implementation will fail and just return `G_TYPE_INVALID`. | |
| *`create_closure`* () | Create a closure with the given arguments. See [`gtk_builder_create_closure()`](gtkbuilder#gtk-builder-create-closure) for more details on those. The C implementation will try to use `dlsym()` to locate the function name and then `g_cclosure_new()` to create a closure for the symbol. The default implementation just fails and returns `NULL`. | |
### GtkBuilderCScope
```
typedef struct _GtkBuilderCScope GtkBuilderCScope;
```
See Also
--------
[GtkBuilder](gtkbuilder#GtkBuilder-struct), GClosure
gtk GtkLinkButton GtkLinkButton
=============
GtkLinkButton — Create buttons bound to a URL
Functions
---------
| | |
| --- | --- |
| [GtkWidget](gtkwidget#GtkWidget-struct) \* | [gtk\_link\_button\_new](gtklinkbutton#gtk-link-button-new) () |
| [GtkWidget](gtkwidget#GtkWidget-struct) \* | [gtk\_link\_button\_new\_with\_label](gtklinkbutton#gtk-link-button-new-with-label) () |
| const char \* | [gtk\_link\_button\_get\_uri](gtklinkbutton#gtk-link-button-get-uri) () |
| void | [gtk\_link\_button\_set\_uri](gtklinkbutton#gtk-link-button-set-uri) () |
| gboolean | [gtk\_link\_button\_get\_visited](gtklinkbutton#gtk-link-button-get-visited) () |
| void | [gtk\_link\_button\_set\_visited](gtklinkbutton#gtk-link-button-set-visited) () |
Properties
----------
| | | |
| --- | --- | --- |
| char \* | [uri](gtklinkbutton#GtkLinkButton--uri) | Read / Write |
| gboolean | [visited](gtklinkbutton#GtkLinkButton--visited) | Read / Write |
Signals
-------
| | | |
| --- | --- | --- |
| gboolean | [activate-link](gtklinkbutton#GtkLinkButton-activate-link) | Run Last |
Actions
-------
| | | |
| --- | --- | --- |
| | menu.popup | |
| | clipboard.copy | |
Types and Values
----------------
| | |
| --- | --- |
| | [GtkLinkButton](gtklinkbutton#GtkLinkButton-struct) |
Object Hierarchy
----------------
```
GObject
╰── GInitiallyUnowned
╰── [GtkWidget](gtkwidget#GtkWidget-struct)
╰── [GtkButton](gtkbutton#GtkButton-struct)
╰── GtkLinkButton
```
Implemented Interfaces
----------------------
GtkLinkButton implements [GtkAccessible](gtkaccessible#GtkAccessible-struct), [GtkBuildable](gtkbuildable#GtkBuildable-struct), [GtkConstraintTarget](gtkconstraint#GtkConstraintTarget-struct) and [GtkActionable](gtkactionable#GtkActionable-struct).
Includes
--------
```
#include <gtk/gtk.h>
```
Description
-----------
A GtkLinkButton is a [GtkButton](gtkbutton#GtkButton-struct) with a hyperlink, similar to the one used by web browsers, which triggers an action when clicked. It is useful to show quick links to resources.
A link button is created by calling either [`gtk_link_button_new()`](gtklinkbutton#gtk-link-button-new) or [`gtk_link_button_new_with_label()`](gtklinkbutton#gtk-link-button-new-with-label). If using the former, the URI you pass to the constructor is used as a label for the widget.
The URI bound to a GtkLinkButton can be set specifically using [`gtk_link_button_set_uri()`](gtklinkbutton#gtk-link-button-set-uri), and retrieved using [`gtk_link_button_get_uri()`](gtklinkbutton#gtk-link-button-get-uri).
By default, GtkLinkButton calls [`gtk_show_uri()`](gtk4-filesystem-utilities#gtk-show-uri) when the button is clicked. This behaviour can be overridden by connecting to the [“activate-link”](gtklinkbutton#GtkLinkButton-activate-link) signal and returning `TRUE` from the signal handler.
### CSS nodes
GtkLinkButton has a single CSS node with name button. To differentiate it from a plain [GtkButton](gtkbutton#GtkButton-struct), it gets the .link style class.
### Accessibility
GtkLinkButton uses the [GTK\_ACCESSIBLE\_ROLE\_LINK](gtkaccessible#GTK-ACCESSIBLE-ROLE-LINK:CAPS) role.
Functions
---------
### gtk\_link\_button\_new ()
```
[GtkWidget](gtkwidget#GtkWidget-struct) *
gtk_link_button_new (*`const char *uri`*);
```
Creates a new [GtkLinkButton](gtklinkbutton#GtkLinkButton-struct) with the URI as its text.
#### Parameters
| | | |
| --- | --- | --- |
| uri | a valid URI | |
#### Returns
a new link button widget.
### gtk\_link\_button\_new\_with\_label ()
```
[GtkWidget](gtkwidget#GtkWidget-struct) *
gtk_link_button_new_with_label (*`const char *uri`*,
*`const char *label`*);
```
Creates a new [GtkLinkButton](gtklinkbutton#GtkLinkButton-struct) containing a label.
#### Parameters
| | | |
| --- | --- | --- |
| uri | a valid URI | |
| label | the text of the button. | [allow-none] |
#### Returns
a new link button widget.
[transfer none]
### gtk\_link\_button\_get\_uri ()
```
const char *
gtk_link_button_get_uri (*`[GtkLinkButton](gtklinkbutton#GtkLinkButton-struct) *link_button`*);
```
Retrieves the URI set using [`gtk_link_button_set_uri()`](gtklinkbutton#gtk-link-button-set-uri).
#### Parameters
| | | |
| --- | --- | --- |
| link\_button | a [GtkLinkButton](gtklinkbutton#GtkLinkButton-struct) | |
#### Returns
a valid URI. The returned string is owned by the link button and should not be modified or freed.
### gtk\_link\_button\_set\_uri ()
```
void
gtk_link_button_set_uri (*`[GtkLinkButton](gtklinkbutton#GtkLinkButton-struct) *link_button`*,
*`const char *uri`*);
```
Sets *`uri`* as the URI where the [GtkLinkButton](gtklinkbutton#GtkLinkButton-struct) points. As a side-effect this unsets the “visited” state of the button.
#### Parameters
| | | |
| --- | --- | --- |
| link\_button | a [GtkLinkButton](gtklinkbutton#GtkLinkButton-struct) | |
| uri | a valid URI | |
### gtk\_link\_button\_get\_visited ()
```
gboolean
gtk_link_button_get_visited (*`[GtkLinkButton](gtklinkbutton#GtkLinkButton-struct) *link_button`*);
```
Retrieves the “visited” state of the URI where the [GtkLinkButton](gtklinkbutton#GtkLinkButton-struct) points. The button becomes visited when it is clicked. If the URI is changed on the button, the “visited” state is unset again.
The state may also be changed using [`gtk_link_button_set_visited()`](gtklinkbutton#gtk-link-button-set-visited).
#### Parameters
| | | |
| --- | --- | --- |
| link\_button | a [GtkLinkButton](gtklinkbutton#GtkLinkButton-struct) | |
#### Returns
`TRUE` if the link has been visited, `FALSE` otherwise
### gtk\_link\_button\_set\_visited ()
```
void
gtk_link_button_set_visited (*`[GtkLinkButton](gtklinkbutton#GtkLinkButton-struct) *link_button`*,
*`gboolean visited`*);
```
Sets the “visited” state of the URI where the [GtkLinkButton](gtklinkbutton#GtkLinkButton-struct) points. See [`gtk_link_button_get_visited()`](gtklinkbutton#gtk-link-button-get-visited) for more details.
#### Parameters
| | | |
| --- | --- | --- |
| link\_button | a [GtkLinkButton](gtklinkbutton#GtkLinkButton-struct) | |
| visited | the new “visited” state | |
Types and Values
----------------
### GtkLinkButton
```
typedef struct _GtkLinkButton GtkLinkButton;
```
Property Details
----------------
### The `“uri”` property
```
“uri” char *
```
The URI bound to this button.
Owner: GtkLinkButton
Flags: Read / Write
Default value: NULL
### The `“visited”` property
```
“visited” gboolean
```
The 'visited' state of this button. A visited link is drawn in a different color.
Owner: GtkLinkButton
Flags: Read / Write
Default value: FALSE
Signal Details
--------------
### The `“activate-link”` signal
```
gboolean
user_function ([GtkLinkButton](gtklinkbutton#GtkLinkButton-struct) *button,
gpointer user_data)
```
The ::activate-link signal is emitted each time the [GtkLinkButton](gtklinkbutton#GtkLinkButton-struct) has been clicked.
The default handler will call [`gtk_show_uri()`](gtk4-filesystem-utilities#gtk-show-uri) with the URI stored inside the [“uri”](gtklinkbutton#GtkLinkButton--uri) property.
To override the default behavior, you can connect to the ::activate-link signal and stop the propagation of the signal by returning `TRUE` from your handler.
#### Parameters
| | | |
| --- | --- | --- |
| button | the [GtkLinkButton](gtklinkbutton#GtkLinkButton-struct) that emitted the signal | |
| user\_data | user data set when the signal handler was connected. | |
Flags: Run Last
Action Details
--------------
### The `“menu.popup”` action
Opens the context menu.
### The `“clipboard.copy”` action
Copies the url to the clipboard.
See Also
--------
[GtkButton](gtkbutton#GtkButton-struct)
| programming_docs |
gtk GtkNumericSorter GtkNumericSorter
================
GtkNumericSorter — Sort by comparing numbers
Functions
---------
| | |
| --- | --- |
| [GtkNumericSorter](gtknumericsorter#GtkNumericSorter-struct) \* | [gtk\_numeric\_sorter\_new](gtknumericsorter#gtk-numeric-sorter-new) () |
| [GtkExpression](gtkexpression#GtkExpression-struct) \* | [gtk\_numeric\_sorter\_get\_expression](gtknumericsorter#gtk-numeric-sorter-get-expression) () |
| void | [gtk\_numeric\_sorter\_set\_expression](gtknumericsorter#gtk-numeric-sorter-set-expression) () |
| [GtkSortType](gtk4-standard-enumerations#GtkSortType) | [gtk\_numeric\_sorter\_get\_sort\_order](gtknumericsorter#gtk-numeric-sorter-get-sort-order) () |
| void | [gtk\_numeric\_sorter\_set\_sort\_order](gtknumericsorter#gtk-numeric-sorter-set-sort-order) () |
Properties
----------
| | | |
| --- | --- | --- |
| [GtkExpression](gtkexpression#GtkExpression-struct) \* | [expression](gtknumericsorter#GtkNumericSorter--expression) | Read / Write |
| [GtkSortType](gtk4-standard-enumerations#GtkSortType) | [sort-order](gtknumericsorter#GtkNumericSorter--sort-order) | Read / Write |
Types and Values
----------------
| | |
| --- | --- |
| | [GtkNumericSorter](gtknumericsorter#GtkNumericSorter-struct) |
Object Hierarchy
----------------
```
GObject
╰── [GtkSorter](gtksorter#GtkSorter-struct)
╰── GtkNumericSorter
```
Includes
--------
```
#include <gtk/gtk.h>
```
Description
-----------
GtkNumericSorter is a [GtkSorter](gtksorter#GtkSorter-struct) that compares numbers.
To obtain the numbers to compare, this sorter evaluates a [GtkExpression](gtkexpression#GtkExpression-struct).
Functions
---------
### gtk\_numeric\_sorter\_new ()
```
[GtkNumericSorter](gtknumericsorter#GtkNumericSorter-struct) *
gtk_numeric_sorter_new (*`[GtkExpression](gtkexpression#GtkExpression-struct) *expression`*);
```
Creates a new numeric sorter using the given *`expression`* .
Smaller numbers will be sorted first. You can call [`gtk_numeric_sorter_set_sort_order()`](gtknumericsorter#gtk-numeric-sorter-set-sort-order) to change this.
#### Parameters
| | | |
| --- | --- | --- |
| expression | The expression to evaluate. | [transfer full][nullable] |
#### Returns
a new [GtkNumericSorter](gtknumericsorter#GtkNumericSorter-struct)
### gtk\_numeric\_sorter\_get\_expression ()
```
[GtkExpression](gtkexpression#GtkExpression-struct) *
gtk_numeric_sorter_get_expression (*`[GtkNumericSorter](gtknumericsorter#GtkNumericSorter-struct) *self`*);
```
Gets the expression that is evaluated to obtain numbers from items.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkNumericSorter](gtknumericsorter#GtkNumericSorter-struct) | |
#### Returns
a [GtkExpression](gtkexpression#GtkExpression-struct), or `NULL`.
[transfer none][nullable]
### gtk\_numeric\_sorter\_set\_expression ()
```
void
gtk_numeric_sorter_set_expression (*`[GtkNumericSorter](gtknumericsorter#GtkNumericSorter-struct) *self`*,
*`[GtkExpression](gtkexpression#GtkExpression-struct) *expression`*);
```
Sets the expression that is evaluated to obtain numbers from items.
Unless an expression is set on *`self`* , the sorter will always compare items as invalid.
The expression must have a return type that can be compared numerically, such as G\_TYPE\_INT or G\_TYPE\_DOUBLE.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkNumericSorter](gtknumericsorter#GtkNumericSorter-struct) | |
| expression | a [GtkExpression](gtkexpression#GtkExpression-struct), or `NULL`. | [nullable][transfer none] |
### gtk\_numeric\_sorter\_get\_sort\_order ()
```
[GtkSortType](gtk4-standard-enumerations#GtkSortType)
gtk_numeric_sorter_get_sort_order (*`[GtkNumericSorter](gtknumericsorter#GtkNumericSorter-struct) *self`*);
```
Gets whether this sorter will sort smaller numbers first.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkNumericSorter](gtknumericsorter#GtkNumericSorter-struct) | |
#### Returns
the order of the numbers
### gtk\_numeric\_sorter\_set\_sort\_order ()
```
void
gtk_numeric_sorter_set_sort_order (*`[GtkNumericSorter](gtknumericsorter#GtkNumericSorter-struct) *self`*,
*`[GtkSortType](gtk4-standard-enumerations#GtkSortType) sort_order`*);
```
Sets whether to sort smaller numbers before larger ones.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkNumericSorter](gtknumericsorter#GtkNumericSorter-struct) | |
| sort\_order | whether to sort smaller numbers first | |
Types and Values
----------------
### GtkNumericSorter
```
typedef struct _GtkNumericSorter GtkNumericSorter;
```
Property Details
----------------
### The `“expression”` property
```
“expression” [GtkExpression](gtkexpression#GtkExpression-struct) *
```
The expression to evaluate on items to get a number to compare with
[type GtkExpression]
Owner: GtkNumericSorter
Flags: Read / Write
### The `“sort-order”` property
```
“sort-order” [GtkSortType](gtk4-standard-enumerations#GtkSortType)
```
Whether the sorter will sort smaller numbers first
Owner: GtkNumericSorter
Flags: Read / Write
Default value: GTK\_SORT\_ASCENDING
See Also
--------
[GtkExpression](gtkexpression#GtkExpression-struct)
gtk Profiling Profiling
=========
GTK supports profiling with sysprof. It exports timing information about frameclock phases and various characteristics of GskRenderers in a format that can be displayed by sysprof or GNOME Builder.
A simple way to capture data is to run your application under the `sysprof-cli` wrapper, which will write profiling data to a file called `capture.syscap`.
When launching the application from sysprof, it will set the `SYSPROF_TRACE_FD` environment variable to point GTK at a file descriptor to write profiling data to.
gtk GtkFixedLayout GtkFixedLayout
==============
GtkFixedLayout — A layout manager that allows positioning at fixed coordinates
Functions
---------
| | |
| --- | --- |
| [GtkLayoutManager](gtklayoutmanager#GtkLayoutManager-struct) \* | [gtk\_fixed\_layout\_new](gtkfixedlayout#gtk-fixed-layout-new) () |
| void | [gtk\_fixed\_layout\_child\_set\_transform](gtkfixedlayout#gtk-fixed-layout-child-set-transform) () |
| [GskTransform](https://developer-old.gnome.org/gtk4/html/gsk4-GskTransform.html#GskTransform) \* | [gtk\_fixed\_layout\_child\_get\_transform](gtkfixedlayout#gtk-fixed-layout-child-get-transform) () |
Types and Values
----------------
| | |
| --- | --- |
| | [GtkFixedLayout](gtkfixedlayout#GtkFixedLayout-struct) |
| | [GtkFixedLayoutChild](gtkfixedlayout#GtkFixedLayoutChild-struct) |
Object Hierarchy
----------------
```
GObject
├── [GtkLayoutChild](gtklayoutchild#GtkLayoutChild-struct)
│ ╰── GtkFixedLayoutChild
╰── [GtkLayoutManager](gtklayoutmanager#GtkLayoutManager-struct)
╰── GtkFixedLayout
```
Includes
--------
```
#include <gtk/gtk.h>
```
Description
-----------
[GtkFixedLayout](gtkfixedlayout#GtkFixedLayout-struct) is a layout manager which can place child widgets at fixed positions, and with fixed sizes.
Most applications should never use this layout manager; fixed positioning and sizing requires constant recalculations on where children need to be positioned and sized. Other layout managers perform this kind of work internally so that application developers don't need to do it. Specifically, widgets positioned in a fixed layout manager will need to take into account:
* Themes, which may change widget sizes.
* Fonts other than the one you used to write the app will of course change the size of widgets containing text; keep in mind that users may use a larger font because of difficulty reading the default, or they may be using a different OS that provides different fonts.
* Translation of text into other languages changes its size. Also, display of non-English text will use a different font in many cases.
In addition, [GtkFixedLayout](gtkfixedlayout#GtkFixedLayout-struct) does not pay attention to text direction and thus may produce unwanted results if your app is run under right-to-left languages such as Hebrew or Arabic. That is: normally GTK will order containers appropriately depending on the text direction, e.g. to put labels to the right of the thing they label when using an RTL language; [GtkFixedLayout](gtkfixedlayout#GtkFixedLayout-struct) won't be able to do that for you.
Finally, fixed positioning makes it kind of annoying to add/remove GUI elements, since you have to reposition all the other elements. This is a long-term maintenance problem for your application.
Functions
---------
### gtk\_fixed\_layout\_new ()
```
[GtkLayoutManager](gtklayoutmanager#GtkLayoutManager-struct) *
gtk_fixed_layout_new (*`void`*);
```
Creates a new [GtkFixedLayout](gtkfixedlayout#GtkFixedLayout-struct).
#### Returns
the newly created [GtkFixedLayout](gtkfixedlayout#GtkFixedLayout-struct)
### gtk\_fixed\_layout\_child\_set\_transform ()
```
void
gtk_fixed_layout_child_set_transform (*`[GtkFixedLayoutChild](gtkfixedlayout#GtkFixedLayoutChild-struct) *child`*,
*`[GskTransform](https://developer-old.gnome.org/gtk4/html/gsk4-GskTransform.html#GskTransform) *transform`*);
```
Sets the transformation of the child of a [GtkFixedLayout](gtkfixedlayout#GtkFixedLayout-struct).
#### Parameters
| | | |
| --- | --- | --- |
| child | a [GtkFixedLayoutChild](gtkfixedlayout#GtkFixedLayoutChild-struct) | |
| transform | a [GskTransform](https://developer-old.gnome.org/gtk4/html/gsk4-GskTransform.html#GskTransform) | |
### gtk\_fixed\_layout\_child\_get\_transform ()
```
[GskTransform](https://developer-old.gnome.org/gtk4/html/gsk4-GskTransform.html#GskTransform) *
gtk_fixed_layout_child_get_transform (*`[GtkFixedLayoutChild](gtkfixedlayout#GtkFixedLayoutChild-struct) *child`*);
```
Retrieves the transformation of the child of a [GtkFixedLayout](gtkfixedlayout#GtkFixedLayout-struct).
#### Parameters
| | | |
| --- | --- | --- |
| child | a [GtkFixedLayoutChild](gtkfixedlayout#GtkFixedLayoutChild-struct) | |
#### Returns
a [GskTransform](https://developer-old.gnome.org/gtk4/html/gsk4-GskTransform.html#GskTransform).
[transfer none][nullable]
Types and Values
----------------
### GtkFixedLayout
```
typedef struct _GtkFixedLayout GtkFixedLayout;
```
### GtkFixedLayoutChild
```
typedef struct _GtkFixedLayoutChild GtkFixedLayoutChild;
```
gtk Tree, List and Icon Grid Widgets Tree, List and Icon Grid Widgets
================================
[Tree and List Widget Overview](treewidgetobjects#TreeWidget) [Creating a model](treewidgetobjects#id-1.4.17.2.6) [Creating the view component](treewidgetobjects#id-1.4.17.2.7) [Columns and cell renderers](treewidgetobjects#id-1.4.17.2.8) [Selection handling](treewidgetobjects#id-1.4.17.2.9) [Simple Example](treewidgetobjects#id-1.4.17.2.10) [GtkTreeModel](gtktreemodel) — The tree interface used by GtkTreeView [GtkTreeSelection](gtktreeselection) — The selection object for GtkTreeView [GtkTreeViewColumn](gtktreeviewcolumn) — A visible column in a GtkTreeView widget [GtkTreeView](gtktreeview) — A widget for displaying both trees and lists [GtkTreeView drag-and-drop](gtk4-gtktreeview-drag-and-drop) — Interfaces for drag-and-drop support in GtkTreeView [GtkCellView](gtkcellview) — A widget displaying a single row of a GtkTreeModel [GtkIconView](gtkiconview) — A widget which displays a list of icons in a grid [GtkTreeSortable](gtktreesortable) — The interface for sortable models used by GtkTreeView [GtkTreeModelSort](gtktreemodelsort) — A GtkTreeModel which makes an underlying tree model sortable [GtkTreeModelFilter](gtktreemodelfilter) — A GtkTreeModel which hides parts of an underlying tree model [GtkCellLayout](gtkcelllayout) — An interface for packing cells [GtkCellArea](gtkcellarea) — An abstract class for laying out GtkCellRenderers [GtkCellAreaBox](gtkcellareabox) — A cell area that renders GtkCellRenderers into a row or a column [GtkCellAreaContext](gtkcellareacontext) — Stores geometrical information for a series of rows in a GtkCellArea [GtkCellRenderer](gtkcellrenderer) — An object for rendering a single cell [GtkCellEditable](gtkcelleditable) — Interface for widgets that can be used for editing cells [GtkCellRendererAccel](gtkcellrendereraccel) — Renders a keyboard accelerator in a cell [GtkCellRendererCombo](gtkcellrenderercombo) — Renders a combobox in a cell [GtkCellRendererPixbuf](gtkcellrendererpixbuf) — Renders a pixbuf in a cell [GtkCellRendererProgress](gtkcellrendererprogress) — Renders numbers as progress bars [GtkCellRendererSpin](gtkcellrendererspin) — Renders a spin button in a cell [GtkCellRendererText](gtkcellrenderertext) — Renders text in a cell [GtkCellRendererToggle](gtkcellrenderertoggle) — Renders a toggle button in a cell [GtkCellRendererSpinner](gtkcellrendererspinner) — Renders a spinning animation in a cell [GtkListStore](gtkliststore) — A list-like data structure that can be used with the GtkTreeView [GtkTreeStore](gtktreestore) — A tree-like data structure that can be used with the GtkTreeView To create a tree or list in GTK, use the [GtkTreeModel](gtktreemodel#GtkTreeModel-struct) interface in conjunction with the [GtkTreeView](gtktreeview#GtkTreeView-struct) widget. This widget is designed around a *Model/View/Controller* design and consists of four major parts:
* The tree view widget (GtkTreeView)
* The view column (GtkTreeViewColumn)
* The cell renderers (GtkCellRenderer etc.)
* The model interface (GtkTreeModel)
The *View* is composed of the first three objects, while the last is the *Model*. One of the prime benefits of the MVC design is that multiple views can be created of a single model. For example, a model mapping the file system could be created for a file manager. Many views could be created to display various parts of the file system, but only one copy need be kept in memory.
The purpose of the cell renderers is to provide extensibility to the widget and to allow multiple ways of rendering the same type of data. For example, consider how to render a boolean variable. Should it render it as a string of “True” or “False”, “On” or “Off”, or should it be rendered as a checkbox?
### Creating a model
GTK provides two simple models that can be used: the [GtkListStore](gtkliststore#GtkListStore-struct) and the [GtkTreeStore](gtktreestore#GtkTreeStore-struct). GtkListStore is used to model list widgets, while the GtkTreeStore models trees. It is possible to develop a new type of model, but the existing models should be satisfactory for all but the most specialized of situations. Creating the model is quite
```
GtkListStore *store = gtk_list_store_new (2, G_TYPE_STRING, G_TYPE_BOOLEAN);
```
This creates a list store with two columns: a string column and a boolean column. Typically the 2 is never passed directly like that; usually an enum is created wherein the different columns are enumerated, followed by a token that represents the total number of columns. The next example will illustrate this, only using a tree store instead of a list store. Creating a tree store operates almost exactly the same.
```
enum
{
TITLE_COLUMN,
AUTHOR_COLUMN,
CHECKED_COLUMN,
N_COLUMNS
};
GtkTreeStore *store = gtk_tree_store_new (N_COLUMNS, /* Total number of columns */
G_TYPE_STRING, /* Book title */
G_TYPE_STRING, /* Author */
G_TYPE_BOOLEAN); /* Is checked out? */
```
Adding data to the model is done using [`gtk_tree_store_set()`](gtktreestore#gtk-tree-store-set) or [`gtk_list_store_set()`](gtkliststore#gtk-list-store-set), depending upon which sort of model was created. To do this, a [GtkTreeIter](gtktreemodel#GtkTreeIter-struct) must be acquired. The iterator points to the location where data will be added.
Once an iterator has been acquired, [`gtk_tree_store_set()`](gtktreestore#gtk-tree-store-set) is used to apply data to the part of the model that the iterator points to. Consider the following example:
```
GtkTreeIter iter;
gtk_tree_store_append (store, &iter, NULL); /* Acquire an iterator */
gtk_tree_store_set (store, &iter,
TITLE_COLUMN, "The Principle of Reason",
AUTHOR_COLUMN, "Martin Heidegger",
CHECKED_COLUMN, FALSE,
-1);
```
Notice that the last argument is -1. This is always done because this is a variable-argument function and it needs to know when to stop processing arguments. It can be used to set the data in any or all columns in a given row.
The third argument to [`gtk_tree_store_append()`](gtktreestore#gtk-tree-store-append) is the parent iterator. It is used to add a row to a GtkTreeStore as a child of an existing row. This means that the new row will only be visible when its parent is visible and in its expanded state. Consider the following example:
```
GtkTreeIter iter1; /* Parent iter */
GtkTreeIter iter2; /* Child iter */
gtk_tree_store_append (store, &iter1, NULL); /* Acquire a top-level iterator */
gtk_tree_store_set (store, &iter1,
TITLE_COLUMN, "The Art of Computer Programming",
AUTHOR_COLUMN, "Donald E. Knuth",
CHECKED_COLUMN, FALSE,
-1);
gtk_tree_store_append (store, &iter2, &iter1); /* Acquire a child iterator */
gtk_tree_store_set (store, &iter2,
TITLE_COLUMN, "Volume 1: Fundamental Algorithms",
-1);
gtk_tree_store_append (store, &iter2, &iter1);
gtk_tree_store_set (store, &iter2,
TITLE_COLUMN, "Volume 2: Seminumerical Algorithms",
-1);
gtk_tree_store_append (store, &iter2, &iter1);
gtk_tree_store_set (store, &iter2,
TITLE_COLUMN, "Volume 3: Sorting and Searching",
-1);
```
### Creating the view component
While there are several different models to choose from, there is only one view widget to deal with. It works with either the list or the tree store. Setting up a [GtkTreeView](gtktreeview#GtkTreeView-struct) is not a difficult matter. It needs a [GtkTreeModel](gtktreemodel#GtkTreeModel-struct) to know where to retrieve its data from.
```
GtkWidget *tree;
tree = gtk_tree_view_new_with_model (GTK_TREE_MODEL (store));
```
### Columns and cell renderers
Once the [GtkTreeView](gtktreeview#GtkTreeView-struct) widget has a model, it will need to know how to display the model. It does this with columns and cell renderers.
Cell renderers are used to draw the data in the tree model in a way. There are a number of cell renderers that come with GTK, including the [GtkCellRendererText](gtkcellrenderertext#GtkCellRendererText-struct), [GtkCellRendererPixbuf](gtkcellrendererpixbuf#GtkCellRendererPixbuf-struct) and the [GtkCellRendererToggle](gtkcellrenderertoggle#GtkCellRendererToggle-struct). It is relatively easy to write a custom renderer.
A [GtkTreeViewColumn](gtktreeviewcolumn#GtkTreeViewColumn-struct) is the object that GtkTreeView uses to organize the vertical columns in the tree view. It needs to know the name of the column to label for the user, what type of cell renderer to use, and which piece of data to retrieve from the model for a given row.
```
GtkCellRenderer *renderer;
GtkTreeViewColumn *column;
renderer = gtk_cell_renderer_text_new (<!-- -->);
column = gtk_tree_view_column_new_with_attributes ("Author",
renderer,
"text", AUTHOR_COLUMN,
NULL);
gtk_tree_view_append_column (GTK_TREE_VIEW (tree), column);
```
At this point, all the steps in creating a displayable tree have been covered. The model is created, data is stored in it, a tree view is created and columns are added to it.
### Selection handling
Most applications will need to not only deal with displaying data, but also receiving input events from users. To do this, simply get a reference to a selection object and connect to the [“changed”](gtktreeselection#GtkTreeSelection-changed) signal.
```
/* Prototype for selection handler callback */
static void tree_selection_changed_cb (GtkTreeSelection *selection, gpointer data);
/* Setup the selection handler */
GtkTreeSelection *select;
select = gtk_tree_view_get_selection (GTK_TREE_VIEW (tree));
gtk_tree_selection_set_mode (select, GTK_SELECTION_SINGLE);
g_signal_connect (G_OBJECT (select), "changed",
G_CALLBACK (tree_selection_changed_cb),
NULL);
```
Then to retrieve data for the row selected:
```
static void
tree_selection_changed_cb (GtkTreeSelection *selection, gpointer data)
{
GtkTreeIter iter;
GtkTreeModel *model;
char *author;
if (gtk_tree_selection_get_selected (selection, &model, &iter))
{
gtk_tree_model_get (model, &iter, AUTHOR_COLUMN, &author, -1);
g_print ("You selected a book by s\n", author);
g_free (author);
}
}
```
### Simple Example
Here is a simple example of using a [GtkTreeView](gtktreeview#GtkTreeView-struct) widget in context of the other widgets. It simply creates a simple model and view, and puts them together. Note that the model is never populated with data — that is left as an exercise for the reader. More information can be found on this in the [GtkTreeModel](gtktreemodel#GtkTreeModel-struct) section.
```
enum
{
TITLE_COLUMN,
AUTHOR_COLUMN,
CHECKED_COLUMN,
N_COLUMNS
};
void
setup_tree (void)
{
GtkTreeStore *store;
GtkWidget *tree;
GtkTreeViewColumn *column;
GtkCellRenderer *renderer;
/* Create a model. We are using the store model for now, though we
* could use any other GtkTreeModel */
store = gtk_tree_store_new (N_COLUMNS,
G_TYPE_STRING,
G_TYPE_STRING,
G_TYPE_BOOLEAN);
/* custom function to fill the model with data */
populate_tree_model (store);
/* Create a view */
tree = gtk_tree_view_new_with_model (GTK_TREE_MODEL (store));
/* The view now holds a reference. We can get rid of our own
* reference */
g_object_unref (G_OBJECT (store));
/* Create a cell render and arbitrarily make it red for demonstration
* purposes */
renderer = gtk_cell_renderer_text_new (<!-- -->);
g_object_set (G_OBJECT (renderer),
"foreground", "red",
NULL);
/* Create a column, associating the "text" attribute of the
* cell_renderer to the first column of the model */
column = gtk_tree_view_column_new_with_attributes ("Author", renderer,
"text", AUTHOR_COLUMN,
NULL);
/* Add the column to the view. */
gtk_tree_view_append_column (GTK_TREE_VIEW (tree), column);
/* Second column.. title of the book. */
renderer = gtk_cell_renderer_text_new (<!-- -->);
column = gtk_tree_view_column_new_with_attributes ("Title",
renderer,
"text", TITLE_COLUMN,
NULL);
gtk_tree_view_append_column (GTK_TREE_VIEW (tree), column);
/* Last column.. whether a book is checked out. */
renderer = gtk_cell_renderer_toggle_new (<!-- -->);
column = gtk_tree_view_column_new_with_attributes ("Checked out",
renderer,
"active", CHECKED_COLUMN,
NULL);
gtk_tree_view_append_column (GTK_TREE_VIEW (tree), column);
/* Now we can manipulate the view just like any other GTK widget */
...
}
```
| programming_docs |
gtk GtkBoxLayout GtkBoxLayout
============
GtkBoxLayout — Layout manager for placing all children in a single row or column
Functions
---------
| | |
| --- | --- |
| [GtkLayoutManager](gtklayoutmanager#GtkLayoutManager-struct) \* | [gtk\_box\_layout\_new](gtkboxlayout#gtk-box-layout-new) () |
| void | [gtk\_box\_layout\_set\_homogeneous](gtkboxlayout#gtk-box-layout-set-homogeneous) () |
| gboolean | [gtk\_box\_layout\_get\_homogeneous](gtkboxlayout#gtk-box-layout-get-homogeneous) () |
| void | [gtk\_box\_layout\_set\_spacing](gtkboxlayout#gtk-box-layout-set-spacing) () |
| guint | [gtk\_box\_layout\_get\_spacing](gtkboxlayout#gtk-box-layout-get-spacing) () |
| void | [gtk\_box\_layout\_set\_baseline\_position](gtkboxlayout#gtk-box-layout-set-baseline-position) () |
| [GtkBaselinePosition](gtk4-standard-enumerations#GtkBaselinePosition) | [gtk\_box\_layout\_get\_baseline\_position](gtkboxlayout#gtk-box-layout-get-baseline-position) () |
Properties
----------
| | | |
| --- | --- | --- |
| [GtkBaselinePosition](gtk4-standard-enumerations#GtkBaselinePosition) | [baseline-position](gtkboxlayout#GtkBoxLayout--baseline-position) | Read / Write |
| gboolean | [homogeneous](gtkboxlayout#GtkBoxLayout--homogeneous) | Read / Write |
| int | [spacing](gtkboxlayout#GtkBoxLayout--spacing) | Read / Write |
Types and Values
----------------
| | |
| --- | --- |
| | [GtkBoxLayout](gtkboxlayout#GtkBoxLayout-struct) |
Object Hierarchy
----------------
```
GObject
╰── [GtkLayoutManager](gtklayoutmanager#GtkLayoutManager-struct)
╰── GtkBoxLayout
```
Implemented Interfaces
----------------------
GtkBoxLayout implements [GtkOrientable](gtk4-orientable#GtkOrientable-struct).
Includes
--------
```
#include <gtk/gtk.h>
```
Description
-----------
A GtkBoxLayout is a layout manager that arranges the children of any widget using it into a single row or column, depending on the value of its [“orientation”](gtk4-orientable#GtkOrientable--orientation) property. Within the other dimension all children all allocated the same size. The GtkBoxLayout will respect the [“halign”](gtkwidget#GtkWidget--halign) and [“valign”](gtkwidget#GtkWidget--valign) properties of each child widget.
If you want all children to be assigned the same size, you can use the [“homogeneous”](gtkboxlayout#GtkBoxLayout--homogeneous) property.
If you want to specify the amount of space placed between each child, you can use the [“spacing”](gtkboxlayout#GtkBoxLayout--spacing) property.
Functions
---------
### gtk\_box\_layout\_new ()
```
[GtkLayoutManager](gtklayoutmanager#GtkLayoutManager-struct) *
gtk_box_layout_new (*`[GtkOrientation](gtk4-standard-enumerations#GtkOrientation) orientation`*);
```
Creates a new box layout.
#### Parameters
| | | |
| --- | --- | --- |
| orientation | the orientation for the new layout | |
#### Returns
a new box layout
### gtk\_box\_layout\_set\_homogeneous ()
```
void
gtk_box_layout_set_homogeneous (*`[GtkBoxLayout](gtkboxlayout#GtkBoxLayout-struct) *box_layout`*,
*`gboolean homogeneous`*);
```
Sets whether the box layout will allocate the same size to all children.
#### Parameters
| | | |
| --- | --- | --- |
| box\_layout | a [GtkBoxLayout](gtkboxlayout#GtkBoxLayout-struct) | |
| homogeneous | `TRUE` to set the box layout as homogeneous | |
### gtk\_box\_layout\_get\_homogeneous ()
```
gboolean
gtk_box_layout_get_homogeneous (*`[GtkBoxLayout](gtkboxlayout#GtkBoxLayout-struct) *box_layout`*);
```
Returns whether the layout is set to be homogeneous.
Return: `TRUE` if the layout is homogeneous
#### Parameters
| | | |
| --- | --- | --- |
| box\_layout | a [GtkBoxLayout](gtkboxlayout#GtkBoxLayout-struct) | |
### gtk\_box\_layout\_set\_spacing ()
```
void
gtk_box_layout_set_spacing (*`[GtkBoxLayout](gtkboxlayout#GtkBoxLayout-struct) *box_layout`*,
*`guint spacing`*);
```
Sets how much spacing to put between children.
#### Parameters
| | | |
| --- | --- | --- |
| box\_layout | a [GtkBoxLayout](gtkboxlayout#GtkBoxLayout-struct) | |
| spacing | the spacing to apply between children | |
### gtk\_box\_layout\_get\_spacing ()
```
guint
gtk_box_layout_get_spacing (*`[GtkBoxLayout](gtkboxlayout#GtkBoxLayout-struct) *box_layout`*);
```
Returns the space that *`box_layout`* puts between children.
#### Parameters
| | | |
| --- | --- | --- |
| box\_layout | a [GtkBoxLayout](gtkboxlayout#GtkBoxLayout-struct) | |
#### Returns
the spacing of the layout
### gtk\_box\_layout\_set\_baseline\_position ()
```
void
gtk_box_layout_set_baseline_position (*`[GtkBoxLayout](gtkboxlayout#GtkBoxLayout-struct) *box_layout`*,
*`[GtkBaselinePosition](gtk4-standard-enumerations#GtkBaselinePosition) position`*);
```
Sets the baseline position of a box layout.
The baseline position affects only horizontal boxes with at least one baseline aligned child. If there is more vertical space available than requested, and the baseline is not allocated by the parent then the given *`position`* is used to allocate the baseline within the extra space available.
#### Parameters
| | | |
| --- | --- | --- |
| box\_layout | a [GtkBoxLayout](gtkboxlayout#GtkBoxLayout-struct) | |
| position | a [GtkBaselinePosition](gtk4-standard-enumerations#GtkBaselinePosition) | |
### gtk\_box\_layout\_get\_baseline\_position ()
```
[GtkBaselinePosition](gtk4-standard-enumerations#GtkBaselinePosition)
gtk_box_layout_get_baseline_position (*`[GtkBoxLayout](gtkboxlayout#GtkBoxLayout-struct) *box_layout`*);
```
Gets the value set by [`gtk_box_layout_set_baseline_position()`](gtkboxlayout#gtk-box-layout-set-baseline-position).
#### Parameters
| | | |
| --- | --- | --- |
| box\_layout | a [GtkBoxLayout](gtkboxlayout#GtkBoxLayout-struct) | |
#### Returns
the baseline position
Types and Values
----------------
### GtkBoxLayout
```
typedef struct _GtkBoxLayout GtkBoxLayout;
```
Property Details
----------------
### The `“baseline-position”` property
```
“baseline-position” [GtkBaselinePosition](gtk4-standard-enumerations#GtkBaselinePosition)
```
The position of the allocated baseline within the extra space allocated to each child of the widget using a box layout manager.
This property is only relevant for horizontal layouts containing at least one child with a baseline alignment.
Owner: GtkBoxLayout
Flags: Read / Write
Default value: GTK\_BASELINE\_POSITION\_CENTER
### The `“homogeneous”` property
```
“homogeneous” gboolean
```
Whether the box layout should distribute the available space homogeneously among the children of the widget using it as a layout manager.
Owner: GtkBoxLayout
Flags: Read / Write
Default value: FALSE
### The `“spacing”` property
```
“spacing” int
```
The space between each child of the widget using the box layout as its layout manager.
Owner: GtkBoxLayout
Flags: Read / Write
Allowed values: >= 0
Default value: 0
gtk GtkSortListModel GtkSortListModel
================
GtkSortListModel — A list model that sorts its items
Functions
---------
| | |
| --- | --- |
| [GtkSortListModel](gtksortlistmodel#GtkSortListModel-struct) \* | [gtk\_sort\_list\_model\_new](gtksortlistmodel#gtk-sort-list-model-new) () |
| void | [gtk\_sort\_list\_model\_set\_sorter](gtksortlistmodel#gtk-sort-list-model-set-sorter) () |
| [GtkSorter](gtksorter#GtkSorter-struct) \* | [gtk\_sort\_list\_model\_get\_sorter](gtksortlistmodel#gtk-sort-list-model-get-sorter) () |
| void | [gtk\_sort\_list\_model\_set\_model](gtksortlistmodel#gtk-sort-list-model-set-model) () |
| GListModel \* | [gtk\_sort\_list\_model\_get\_model](gtksortlistmodel#gtk-sort-list-model-get-model) () |
| void | [gtk\_sort\_list\_model\_set\_incremental](gtksortlistmodel#gtk-sort-list-model-set-incremental) () |
| gboolean | [gtk\_sort\_list\_model\_get\_incremental](gtksortlistmodel#gtk-sort-list-model-get-incremental) () |
| guint | [gtk\_sort\_list\_model\_get\_pending](gtksortlistmodel#gtk-sort-list-model-get-pending) () |
Properties
----------
| | | |
| --- | --- | --- |
| gboolean | [incremental](gtksortlistmodel#GtkSortListModel--incremental) | Read / Write |
| GListModel \* | [model](gtksortlistmodel#GtkSortListModel--model) | Read / Write |
| guint | [pending](gtksortlistmodel#GtkSortListModel--pending) | Read |
| [GtkSorter](gtksorter#GtkSorter-struct) \* | [sorter](gtksortlistmodel#GtkSortListModel--sorter) | Read / Write |
Types and Values
----------------
| | |
| --- | --- |
| | [GtkSortListModel](gtksortlistmodel#GtkSortListModel-struct) |
Object Hierarchy
----------------
```
GObject
╰── GtkSortListModel
```
Implemented Interfaces
----------------------
GtkSortListModel implements GListModel.
Includes
--------
```
#include <gtk/gtk.h>
```
Description
-----------
[GtkSortListModel](gtksortlistmodel#GtkSortListModel-struct) is a list model that takes a list model and sorts its elements according to a [GtkSorter](gtksorter#GtkSorter-struct).
The model can be set up to do incremental sorting, so that sorting long lists doesn't block the UI. See [`gtk_sort_list_model_set_incremental()`](gtksortlistmodel#gtk-sort-list-model-set-incremental) for details.
[GtkSortListModel](gtksortlistmodel#GtkSortListModel-struct) is a generic model and because of that it cannot take advantage of any external knowledge when sorting. If you run into performance issues with [GtkSortListModel](gtksortlistmodel#GtkSortListModel-struct), it is strongly recommended that you write your own sorting list model.
Functions
---------
### gtk\_sort\_list\_model\_new ()
```
[GtkSortListModel](gtksortlistmodel#GtkSortListModel-struct) *
gtk_sort_list_model_new (*`GListModel *model`*,
*`[GtkSorter](gtksorter#GtkSorter-struct) *sorter`*);
```
Creates a new sort list model that uses the *`sorter`* to sort *`model`* .
#### Parameters
| | | |
| --- | --- | --- |
| model | the model to sort, or `NULL`. | [allow-none][transfer full] |
| sorter | the [GtkSorter](gtksorter#GtkSorter-struct) to sort *`model`* with, or `NULL`. | [allow-none][transfer full] |
#### Returns
a new [GtkSortListModel](gtksortlistmodel#GtkSortListModel-struct)
### gtk\_sort\_list\_model\_set\_sorter ()
```
void
gtk_sort_list_model_set_sorter (*`[GtkSortListModel](gtksortlistmodel#GtkSortListModel-struct) *self`*,
*`[GtkSorter](gtksorter#GtkSorter-struct) *sorter`*);
```
Sets a new sorter on *`self`* .
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkSortListModel](gtksortlistmodel#GtkSortListModel-struct) | |
| sorter | the [GtkSorter](gtksorter#GtkSorter-struct) to sort *`model`* with. | [allow-none] |
### gtk\_sort\_list\_model\_get\_sorter ()
```
[GtkSorter](gtksorter#GtkSorter-struct) *
gtk_sort_list_model_get_sorter (*`[GtkSortListModel](gtksortlistmodel#GtkSortListModel-struct) *self`*);
```
Gets the sorter that is used to sort *`self`* .
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkSortListModel](gtksortlistmodel#GtkSortListModel-struct) | |
#### Returns
the sorter of self.
[nullable][transfer none]
### gtk\_sort\_list\_model\_set\_model ()
```
void
gtk_sort_list_model_set_model (*`[GtkSortListModel](gtksortlistmodel#GtkSortListModel-struct) *self`*,
*`GListModel *model`*);
```
Sets the model to be sorted. The *`model`* 's item type must conform to the item type of *`self`* .
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkSortListModel](gtksortlistmodel#GtkSortListModel-struct) | |
| model | The model to be sorted. | [allow-none] |
### gtk\_sort\_list\_model\_get\_model ()
```
GListModel *
gtk_sort_list_model_get_model (*`[GtkSortListModel](gtksortlistmodel#GtkSortListModel-struct) *self`*);
```
Gets the model currently sorted or `NULL` if none.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkSortListModel](gtksortlistmodel#GtkSortListModel-struct) | |
#### Returns
The model that gets sorted.
[nullable][transfer none]
### gtk\_sort\_list\_model\_set\_incremental ()
```
void
gtk_sort_list_model_set_incremental (*`[GtkSortListModel](gtksortlistmodel#GtkSortListModel-struct) *self`*,
*`gboolean incremental`*);
```
Sets the sort model to do an incremental sort.
When incremental sorting is enabled, the sortlistmodel will not do a complete sort immediately, but will instead queue an idle handler that incrementally sorts the items towards their correct position. This of course means that items do not instantly appear in the right place. It also means that the total sorting time is a lot slower.
When your filter blocks the UI while sorting, you might consider turning this on. Depending on your model and sorters, this may become interesting around 10,000 to 100,000 items.
By default, incremental sorting is disabled.
See [`gtk_sort_list_model_get_pending()`](gtksortlistmodel#gtk-sort-list-model-get-pending) for progress information about an ongoing incremental sorting operation.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkSortListModel](gtksortlistmodel#GtkSortListModel-struct) | |
| incremental | `TRUE` to sort incrementally | |
### gtk\_sort\_list\_model\_get\_incremental ()
```
gboolean
gtk_sort_list_model_get_incremental (*`[GtkSortListModel](gtksortlistmodel#GtkSortListModel-struct) *self`*);
```
Returns whether incremental sorting was enabled via [`gtk_sort_list_model_set_incremental()`](gtksortlistmodel#gtk-sort-list-model-set-incremental).
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkSortListModel](gtksortlistmodel#GtkSortListModel-struct) | |
#### Returns
`TRUE` if incremental sorting is enabled
### gtk\_sort\_list\_model\_get\_pending ()
```
guint
gtk_sort_list_model_get_pending (*`[GtkSortListModel](gtksortlistmodel#GtkSortListModel-struct) *self`*);
```
Estimates progress of an ongoing sorting operation
The estimate is the number of items that would still need to be sorted to finish the sorting operation if this was a linear algorithm. So this number is not related to how many items are already correctly sorted.
If you want to estimate the progress, you can use code like this:
```
pending = gtk_sort_list_model_get_pending (self);
model = gtk_sort_list_model_get_model (self);
progress = 1.0 - pending / (double) MAX (1, g_list_model_get_n_items (model));
```
| If no sort operation is ongoing - in particular when [“incremental”](gtksortlistmodel#GtkSortListModel--incremental) is `FALSE` - this function returns 0.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkSortListModel](gtksortlistmodel#GtkSortListModel-struct) | |
#### Returns
a progress estimate of remaining items to sort
Types and Values
----------------
### GtkSortListModel
```
typedef struct _GtkSortListModel GtkSortListModel;
```
Property Details
----------------
### The `“incremental”` property
```
“incremental” gboolean
```
If the model should sort items incrementally
Owner: GtkSortListModel
Flags: Read / Write
Default value: FALSE
### The `“model”` property
```
“model” GListModel *
```
The model being sorted
Owner: GtkSortListModel
Flags: Read / Write
### The `“pending”` property
```
“pending” guint
```
Estimate of unsorted items remaining
Owner: GtkSortListModel
Flags: Read
Default value: 0
### The `“sorter”` property
```
“sorter” [GtkSorter](gtksorter#GtkSorter-struct) *
```
The sorter for this model
Owner: GtkSortListModel
Flags: Read / Write
See Also
--------
GListModel, [GtkSorter](gtksorter#GtkSorter-struct)
gtk GtkNotebook GtkNotebook
===========
GtkNotebook — A tabbed notebook container
Functions
---------
| | |
| --- | --- |
| [GtkWidget](gtkwidget#GtkWidget-struct) \* | [gtk\_notebook\_new](gtknotebook#gtk-notebook-new) () |
| [GtkNotebookPage](gtknotebook#GtkNotebookPage-struct) \* | [gtk\_notebook\_get\_page](gtknotebook#gtk-notebook-get-page) () |
| GListModel \* | [gtk\_notebook\_get\_pages](gtknotebook#gtk-notebook-get-pages) () |
| [GtkWidget](gtkwidget#GtkWidget-struct) \* | [gtk\_notebook\_page\_get\_child](gtknotebook#gtk-notebook-page-get-child) () |
| int | [gtk\_notebook\_append\_page](gtknotebook#gtk-notebook-append-page) () |
| int | [gtk\_notebook\_append\_page\_menu](gtknotebook#gtk-notebook-append-page-menu) () |
| int | [gtk\_notebook\_prepend\_page](gtknotebook#gtk-notebook-prepend-page) () |
| int | [gtk\_notebook\_prepend\_page\_menu](gtknotebook#gtk-notebook-prepend-page-menu) () |
| int | [gtk\_notebook\_insert\_page](gtknotebook#gtk-notebook-insert-page) () |
| int | [gtk\_notebook\_insert\_page\_menu](gtknotebook#gtk-notebook-insert-page-menu) () |
| void | [gtk\_notebook\_remove\_page](gtknotebook#gtk-notebook-remove-page) () |
| void | [gtk\_notebook\_detach\_tab](gtknotebook#gtk-notebook-detach-tab) () |
| int | [gtk\_notebook\_page\_num](gtknotebook#gtk-notebook-page-num) () |
| void | [gtk\_notebook\_next\_page](gtknotebook#gtk-notebook-next-page) () |
| void | [gtk\_notebook\_prev\_page](gtknotebook#gtk-notebook-prev-page) () |
| void | [gtk\_notebook\_reorder\_child](gtknotebook#gtk-notebook-reorder-child) () |
| void | [gtk\_notebook\_set\_tab\_pos](gtknotebook#gtk-notebook-set-tab-pos) () |
| void | [gtk\_notebook\_set\_show\_tabs](gtknotebook#gtk-notebook-set-show-tabs) () |
| void | [gtk\_notebook\_set\_show\_border](gtknotebook#gtk-notebook-set-show-border) () |
| void | [gtk\_notebook\_set\_scrollable](gtknotebook#gtk-notebook-set-scrollable) () |
| void | [gtk\_notebook\_popup\_enable](gtknotebook#gtk-notebook-popup-enable) () |
| void | [gtk\_notebook\_popup\_disable](gtknotebook#gtk-notebook-popup-disable) () |
| int | [gtk\_notebook\_get\_current\_page](gtknotebook#gtk-notebook-get-current-page) () |
| [GtkWidget](gtkwidget#GtkWidget-struct) \* | [gtk\_notebook\_get\_menu\_label](gtknotebook#gtk-notebook-get-menu-label) () |
| [GtkWidget](gtkwidget#GtkWidget-struct) \* | [gtk\_notebook\_get\_nth\_page](gtknotebook#gtk-notebook-get-nth-page) () |
| int | [gtk\_notebook\_get\_n\_pages](gtknotebook#gtk-notebook-get-n-pages) () |
| [GtkWidget](gtkwidget#GtkWidget-struct) \* | [gtk\_notebook\_get\_tab\_label](gtknotebook#gtk-notebook-get-tab-label) () |
| void | [gtk\_notebook\_set\_menu\_label](gtknotebook#gtk-notebook-set-menu-label) () |
| void | [gtk\_notebook\_set\_menu\_label\_text](gtknotebook#gtk-notebook-set-menu-label-text) () |
| void | [gtk\_notebook\_set\_tab\_label](gtknotebook#gtk-notebook-set-tab-label) () |
| void | [gtk\_notebook\_set\_tab\_label\_text](gtknotebook#gtk-notebook-set-tab-label-text) () |
| void | [gtk\_notebook\_set\_tab\_reorderable](gtknotebook#gtk-notebook-set-tab-reorderable) () |
| void | [gtk\_notebook\_set\_tab\_detachable](gtknotebook#gtk-notebook-set-tab-detachable) () |
| const char \* | [gtk\_notebook\_get\_menu\_label\_text](gtknotebook#gtk-notebook-get-menu-label-text) () |
| gboolean | [gtk\_notebook\_get\_scrollable](gtknotebook#gtk-notebook-get-scrollable) () |
| gboolean | [gtk\_notebook\_get\_show\_border](gtknotebook#gtk-notebook-get-show-border) () |
| gboolean | [gtk\_notebook\_get\_show\_tabs](gtknotebook#gtk-notebook-get-show-tabs) () |
| const char \* | [gtk\_notebook\_get\_tab\_label\_text](gtknotebook#gtk-notebook-get-tab-label-text) () |
| [GtkPositionType](gtk4-standard-enumerations#GtkPositionType) | [gtk\_notebook\_get\_tab\_pos](gtknotebook#gtk-notebook-get-tab-pos) () |
| gboolean | [gtk\_notebook\_get\_tab\_reorderable](gtknotebook#gtk-notebook-get-tab-reorderable) () |
| gboolean | [gtk\_notebook\_get\_tab\_detachable](gtknotebook#gtk-notebook-get-tab-detachable) () |
| void | [gtk\_notebook\_set\_current\_page](gtknotebook#gtk-notebook-set-current-page) () |
| void | [gtk\_notebook\_set\_group\_name](gtknotebook#gtk-notebook-set-group-name) () |
| const char \* | [gtk\_notebook\_get\_group\_name](gtknotebook#gtk-notebook-get-group-name) () |
| void | [gtk\_notebook\_set\_action\_widget](gtknotebook#gtk-notebook-set-action-widget) () |
| [GtkWidget](gtkwidget#GtkWidget-struct) \* | [gtk\_notebook\_get\_action\_widget](gtknotebook#gtk-notebook-get-action-widget) () |
Properties
----------
| | | |
| --- | --- | --- |
| gboolean | [enable-popup](gtknotebook#GtkNotebook--enable-popup) | Read / Write |
| char \* | [group-name](gtknotebook#GtkNotebook--group-name) | Read / Write |
| int | [page](gtknotebook#GtkNotebook--page) | Read / Write |
| GListModel \* | [pages](gtknotebook#GtkNotebook--pages) | Read |
| gboolean | [scrollable](gtknotebook#GtkNotebook--scrollable) | Read / Write |
| gboolean | [show-border](gtknotebook#GtkNotebook--show-border) | Read / Write |
| gboolean | [show-tabs](gtknotebook#GtkNotebook--show-tabs) | Read / Write |
| [GtkPositionType](gtk4-standard-enumerations#GtkPositionType) | [tab-pos](gtknotebook#GtkNotebook--tab-pos) | Read / Write |
| [GtkWidget](gtkwidget#GtkWidget-struct) \* | [child](gtknotebook#GtkNotebookPage--child) | Read / Write / Construct Only |
| gboolean | [detachable](gtknotebook#GtkNotebookPage--detachable) | Read / Write |
| [GtkWidget](gtkwidget#GtkWidget-struct) \* | [menu](gtknotebook#GtkNotebookPage--menu) | Read / Write / Construct Only |
| char \* | [menu-label](gtknotebook#GtkNotebookPage--menu-label) | Read / Write |
| int | [position](gtknotebook#GtkNotebookPage--position) | Read / Write |
| gboolean | [reorderable](gtknotebook#GtkNotebookPage--reorderable) | Read / Write |
| [GtkWidget](gtkwidget#GtkWidget-struct) \* | [tab](gtknotebook#GtkNotebookPage--tab) | Read / Write / Construct Only |
| gboolean | [tab-expand](gtknotebook#GtkNotebookPage--tab-expand) | Read / Write |
| gboolean | [tab-fill](gtknotebook#GtkNotebookPage--tab-fill) | Read / Write |
| char \* | [tab-label](gtknotebook#GtkNotebookPage--tab-label) | Read / Write |
Signals
-------
| | | |
| --- | --- | --- |
| gboolean | [change-current-page](gtknotebook#GtkNotebook-change-current-page) | Action |
| [GtkNotebook](gtknotebook#GtkNotebook-struct)\* | [create-window](gtknotebook#GtkNotebook-create-window) | Run Last |
| gboolean | [focus-tab](gtknotebook#GtkNotebook-focus-tab) | Action |
| void | [move-focus-out](gtknotebook#GtkNotebook-move-focus-out) | Action |
| void | [page-added](gtknotebook#GtkNotebook-page-added) | Run Last |
| void | [page-removed](gtknotebook#GtkNotebook-page-removed) | Run Last |
| void | [page-reordered](gtknotebook#GtkNotebook-page-reordered) | Run Last |
| gboolean | [reorder-tab](gtknotebook#GtkNotebook-reorder-tab) | Action |
| gboolean | [select-page](gtknotebook#GtkNotebook-select-page) | Action |
| void | [switch-page](gtknotebook#GtkNotebook-switch-page) | Run Last |
Actions
-------
| | | |
| --- | --- | --- |
| | menu.popup | |
Types and Values
----------------
| | |
| --- | --- |
| | [GtkNotebook](gtknotebook#GtkNotebook-struct) |
| | [GtkNotebookPage](gtknotebook#GtkNotebookPage-struct) |
| enum | [GtkNotebookTab](gtknotebook#GtkNotebookTab) |
Object Hierarchy
----------------
```
GObject
├── GInitiallyUnowned
│ ╰── [GtkWidget](gtkwidget#GtkWidget-struct)
│ ╰── GtkNotebook
╰── GtkNotebookPage
```
Implemented Interfaces
----------------------
GtkNotebook implements [GtkAccessible](gtkaccessible#GtkAccessible-struct), [GtkBuildable](gtkbuildable#GtkBuildable-struct) and [GtkConstraintTarget](gtkconstraint#GtkConstraintTarget-struct).
Includes
--------
```
#include <gtk/gtk.h>
```
Description
-----------
The [GtkNotebook](gtknotebook#GtkNotebook-struct) widget is a layout container whose children are pages that can be switched between using tab labels along one edge.
There are many configuration options for GtkNotebook. Among other things, you can choose on which edge the tabs appear (see [`gtk_notebook_set_tab_pos()`](gtknotebook#gtk-notebook-set-tab-pos)), whether, if there are too many tabs to fit the notebook should be made bigger or scrolling arrows added (see [`gtk_notebook_set_scrollable()`](gtknotebook#gtk-notebook-set-scrollable)), and whether there will be a popup menu allowing the users to switch pages. (see [`gtk_notebook_popup_enable()`](gtknotebook#gtk-notebook-popup-enable), [`gtk_notebook_popup_disable()`](gtknotebook#gtk-notebook-popup-disable))
### GtkNotebook as GtkBuildable
The GtkNotebook implementation of the [GtkBuildable](gtkbuildable#GtkBuildable-struct) interface supports placing children into tabs by specifying “tab” as the “type” attribute of a <child> element. Note that the content of the tab must be created before the tab can be filled. A tab child can be specified without specifying a <child> type attribute.
To add a child widget in the notebooks action area, specify "action-start" or “action-end” as the “type” attribute of the <child> element.
An example of a UI definition fragment with GtkNotebook:
### CSS nodes
GtkNotebook has a main CSS node with name `notebook`, a subnode with name `header` and below that a subnode with name `tabs` which contains one subnode per tab with name `tab`.
If action widgets are present, their CSS nodes are placed next to the `tabs` node. If the notebook is scrollable, CSS nodes with name `arrow` are placed as first and last child of the `tabs` node.
The main node gets the `.frame` style class when the notebook has a border (see [`gtk_notebook_set_show_border()`](gtknotebook#gtk-notebook-set-show-border)).
The header node gets one of the style class `.top`, `.bottom`, `.left` or `.right`, depending on where the tabs are placed. For reorderable pages, the tab node gets the `.reorderable-page` class.
A `tab` node gets the `.dnd` style class while it is moved with drag-and-drop.
The nodes are always arranged from left-to-right, regardless of text direction.
### Accessibility
GtkNotebook uses the following roles:
* [`GTK_ACCESSIBLE_ROLE_GROUP`](gtkaccessible#GTK-ACCESSIBLE-ROLE-GROUP:CAPS) for the notebook widget
* [`GTK_ACCESSIBLE_ROLE_TAB_LIST`](gtkaccessible#GTK-ACCESSIBLE-ROLE-TAB-LIST:CAPS) for the list of tabs
* [`GTK_ACCESSIBLE_ROLE_TAB`](gtkaccessible#GTK-ACCESSIBLE-ROLE-TAB:CAPS) role for each tab
* [`GTK_ACCESSIBLE_ROLE_TAB_PANEL`](gtkaccessible#GTK-ACCESSIBLE-ROLE-TAB-PANEL:CAPS) for each page
Functions
---------
### gtk\_notebook\_new ()
```
[GtkWidget](gtkwidget#GtkWidget-struct) *
gtk_notebook_new (*`void`*);
```
Creates a new [GtkNotebook](gtknotebook#GtkNotebook-struct) widget with no pages.
#### Returns
the newly created [GtkNotebook](gtknotebook#GtkNotebook-struct)
### gtk\_notebook\_get\_page ()
```
[GtkNotebookPage](gtknotebook#GtkNotebookPage-struct) *
gtk_notebook_get_page (*`[GtkNotebook](gtknotebook#GtkNotebook-struct) *notebook`*,
*`[GtkWidget](gtkwidget#GtkWidget-struct) *child`*);
```
Returns the [GtkNotebookPage](gtknotebook#GtkNotebookPage-struct) for *`child`* .
#### Parameters
| | | |
| --- | --- | --- |
| notebook | a [GtkNotebook](gtknotebook#GtkNotebook-struct) | |
| child | a child of *`notebook`* | |
#### Returns
the [GtkNotebookPage](gtknotebook#GtkNotebookPage-struct) for *`child`* .
[transfer none]
### gtk\_notebook\_get\_pages ()
```
GListModel *
gtk_notebook_get_pages (*`[GtkNotebook](gtknotebook#GtkNotebook-struct) *notebook`*);
```
Returns a GListModel that contains the pages of the notebook, and can be used to keep an up-to-date view.
#### Parameters
| | | |
| --- | --- | --- |
| notebook | a [GtkNotebook](gtknotebook#GtkNotebook-struct) | |
#### Returns
a GListModel for the notebook's children.
[transfer full][attributes element-type=GtkNotebookPage]
### gtk\_notebook\_page\_get\_child ()
```
[GtkWidget](gtkwidget#GtkWidget-struct) *
gtk_notebook_page_get_child (*`[GtkNotebookPage](gtknotebook#GtkNotebookPage-struct) *page`*);
```
Returns the notebook child to which *`page`* belongs.
#### Parameters
| | | |
| --- | --- | --- |
| page | a [GtkNotebookPage](gtknotebook#GtkNotebookPage-struct) | |
#### Returns
the child to which *`page`* belongs.
[transfer none]
### gtk\_notebook\_append\_page ()
```
int
gtk_notebook_append_page (*`[GtkNotebook](gtknotebook#GtkNotebook-struct) *notebook`*,
*`[GtkWidget](gtkwidget#GtkWidget-struct) *child`*,
*`[GtkWidget](gtkwidget#GtkWidget-struct) *tab_label`*);
```
Appends a page to *`notebook`* .
#### Parameters
| | | |
| --- | --- | --- |
| notebook | a [GtkNotebook](gtknotebook#GtkNotebook-struct) | |
| child | the [GtkWidget](gtkwidget#GtkWidget-struct) to use as the contents of the page | |
| tab\_label | the [GtkWidget](gtkwidget#GtkWidget-struct) to be used as the label for the page, or `NULL` to use the default label, “page N”. | [allow-none] |
#### Returns
the index (starting from 0) of the appended page in the notebook, or -1 if function fails
### gtk\_notebook\_append\_page\_menu ()
```
int
gtk_notebook_append_page_menu (*`[GtkNotebook](gtknotebook#GtkNotebook-struct) *notebook`*,
*`[GtkWidget](gtkwidget#GtkWidget-struct) *child`*,
*`[GtkWidget](gtkwidget#GtkWidget-struct) *tab_label`*,
*`[GtkWidget](gtkwidget#GtkWidget-struct) *menu_label`*);
```
Appends a page to *`notebook`* , specifying the widget to use as the label in the popup menu.
#### Parameters
| | | |
| --- | --- | --- |
| notebook | a [GtkNotebook](gtknotebook#GtkNotebook-struct) | |
| child | the [GtkWidget](gtkwidget#GtkWidget-struct) to use as the contents of the page | |
| tab\_label | the [GtkWidget](gtkwidget#GtkWidget-struct) to be used as the label for the page, or `NULL` to use the default label, “page N”. | [allow-none] |
| menu\_label | the widget to use as a label for the page-switch menu, if that is enabled. If `NULL`, and *`tab_label`* is a [GtkLabel](gtklabel#GtkLabel-struct) or `NULL`, then the menu label will be a newly created label with the same text as *`tab_label`* ; if *`tab_label`* is not a [GtkLabel](gtklabel#GtkLabel-struct), *`menu_label`* must be specified if the page-switch menu is to be used. | [allow-none] |
#### Returns
the index (starting from 0) of the appended page in the notebook, or -1 if function fails
### gtk\_notebook\_prepend\_page ()
```
int
gtk_notebook_prepend_page (*`[GtkNotebook](gtknotebook#GtkNotebook-struct) *notebook`*,
*`[GtkWidget](gtkwidget#GtkWidget-struct) *child`*,
*`[GtkWidget](gtkwidget#GtkWidget-struct) *tab_label`*);
```
Prepends a page to *`notebook`* .
#### Parameters
| | | |
| --- | --- | --- |
| notebook | a [GtkNotebook](gtknotebook#GtkNotebook-struct) | |
| child | the [GtkWidget](gtkwidget#GtkWidget-struct) to use as the contents of the page | |
| tab\_label | the [GtkWidget](gtkwidget#GtkWidget-struct) to be used as the label for the page, or `NULL` to use the default label, “page N”. | [allow-none] |
#### Returns
the index (starting from 0) of the prepended page in the notebook, or -1 if function fails
### gtk\_notebook\_prepend\_page\_menu ()
```
int
gtk_notebook_prepend_page_menu (*`[GtkNotebook](gtknotebook#GtkNotebook-struct) *notebook`*,
*`[GtkWidget](gtkwidget#GtkWidget-struct) *child`*,
*`[GtkWidget](gtkwidget#GtkWidget-struct) *tab_label`*,
*`[GtkWidget](gtkwidget#GtkWidget-struct) *menu_label`*);
```
Prepends a page to *`notebook`* , specifying the widget to use as the label in the popup menu.
#### Parameters
| | | |
| --- | --- | --- |
| notebook | a [GtkNotebook](gtknotebook#GtkNotebook-struct) | |
| child | the [GtkWidget](gtkwidget#GtkWidget-struct) to use as the contents of the page | |
| tab\_label | the [GtkWidget](gtkwidget#GtkWidget-struct) to be used as the label for the page, or `NULL` to use the default label, “page N”. | [allow-none] |
| menu\_label | the widget to use as a label for the page-switch menu, if that is enabled. If `NULL`, and *`tab_label`* is a [GtkLabel](gtklabel#GtkLabel-struct) or `NULL`, then the menu label will be a newly created label with the same text as *`tab_label`* ; if *`tab_label`* is not a [GtkLabel](gtklabel#GtkLabel-struct), *`menu_label`* must be specified if the page-switch menu is to be used. | [allow-none] |
#### Returns
the index (starting from 0) of the prepended page in the notebook, or -1 if function fails
### gtk\_notebook\_insert\_page ()
```
int
gtk_notebook_insert_page (*`[GtkNotebook](gtknotebook#GtkNotebook-struct) *notebook`*,
*`[GtkWidget](gtkwidget#GtkWidget-struct) *child`*,
*`[GtkWidget](gtkwidget#GtkWidget-struct) *tab_label`*,
*`int position`*);
```
Insert a page into *`notebook`* at the given position.
#### Parameters
| | | |
| --- | --- | --- |
| notebook | a [GtkNotebook](gtknotebook#GtkNotebook-struct) | |
| child | the [GtkWidget](gtkwidget#GtkWidget-struct) to use as the contents of the page | |
| tab\_label | the [GtkWidget](gtkwidget#GtkWidget-struct) to be used as the label for the page, or `NULL` to use the default label, “page N”. | [allow-none] |
| position | the index (starting at 0) at which to insert the page, or -1 to append the page after all other pages | |
#### Returns
the index (starting from 0) of the inserted page in the notebook, or -1 if function fails
### gtk\_notebook\_insert\_page\_menu ()
```
int
gtk_notebook_insert_page_menu (*`[GtkNotebook](gtknotebook#GtkNotebook-struct) *notebook`*,
*`[GtkWidget](gtkwidget#GtkWidget-struct) *child`*,
*`[GtkWidget](gtkwidget#GtkWidget-struct) *tab_label`*,
*`[GtkWidget](gtkwidget#GtkWidget-struct) *menu_label`*,
*`int position`*);
```
Insert a page into *`notebook`* at the given position, specifying the widget to use as the label in the popup menu.
#### Parameters
| | | |
| --- | --- | --- |
| notebook | a [GtkNotebook](gtknotebook#GtkNotebook-struct) | |
| child | the [GtkWidget](gtkwidget#GtkWidget-struct) to use as the contents of the page | |
| tab\_label | the [GtkWidget](gtkwidget#GtkWidget-struct) to be used as the label for the page, or `NULL` to use the default label, “page N”. | [allow-none] |
| menu\_label | the widget to use as a label for the page-switch menu, if that is enabled. If `NULL`, and *`tab_label`* is a [GtkLabel](gtklabel#GtkLabel-struct) or `NULL`, then the menu label will be a newly created label with the same text as *`tab_label`* ; if *`tab_label`* is not a [GtkLabel](gtklabel#GtkLabel-struct), *`menu_label`* must be specified if the page-switch menu is to be used. | [allow-none] |
| position | the index (starting at 0) at which to insert the page, or -1 to append the page after all other pages. | |
#### Returns
the index (starting from 0) of the inserted page in the notebook
### gtk\_notebook\_remove\_page ()
```
void
gtk_notebook_remove_page (*`[GtkNotebook](gtknotebook#GtkNotebook-struct) *notebook`*,
*`int page_num`*);
```
Removes a page from the notebook given its index in the notebook.
#### Parameters
| | | |
| --- | --- | --- |
| notebook | a [GtkNotebook](gtknotebook#GtkNotebook-struct) | |
| page\_num | the index of a notebook page, starting from 0. If -1, the last page will be removed. | |
### gtk\_notebook\_detach\_tab ()
```
void
gtk_notebook_detach_tab (*`[GtkNotebook](gtknotebook#GtkNotebook-struct) *notebook`*,
*`[GtkWidget](gtkwidget#GtkWidget-struct) *child`*);
```
Removes the child from the notebook.
This function is very similar to [`gtk_notebook_remove_page()`](gtknotebook#gtk-notebook-remove-page), but additionally informs the notebook that the removal is happening as part of a tab DND operation, which should not be cancelled.
#### Parameters
| | | |
| --- | --- | --- |
| notebook | a [GtkNotebook](gtknotebook#GtkNotebook-struct) | |
| child | a child | |
### gtk\_notebook\_page\_num ()
```
int
gtk_notebook_page_num (*`[GtkNotebook](gtknotebook#GtkNotebook-struct) *notebook`*,
*`[GtkWidget](gtkwidget#GtkWidget-struct) *child`*);
```
Finds the index of the page which contains the given child widget.
#### Parameters
| | | |
| --- | --- | --- |
| notebook | a [GtkNotebook](gtknotebook#GtkNotebook-struct) | |
| child | a [GtkWidget](gtkwidget#GtkWidget-struct) | |
#### Returns
the index of the page containing *`child`* , or -1 if *`child`* is not in the notebook
### gtk\_notebook\_next\_page ()
```
void
gtk_notebook_next_page (*`[GtkNotebook](gtknotebook#GtkNotebook-struct) *notebook`*);
```
Switches to the next page. Nothing happens if the current page is the last page.
#### Parameters
| | | |
| --- | --- | --- |
| notebook | a [GtkNotebook](gtknotebook#GtkNotebook-struct) | |
### gtk\_notebook\_prev\_page ()
```
void
gtk_notebook_prev_page (*`[GtkNotebook](gtknotebook#GtkNotebook-struct) *notebook`*);
```
Switches to the previous page. Nothing happens if the current page is the first page.
#### Parameters
| | | |
| --- | --- | --- |
| notebook | a [GtkNotebook](gtknotebook#GtkNotebook-struct) | |
### gtk\_notebook\_reorder\_child ()
```
void
gtk_notebook_reorder_child (*`[GtkNotebook](gtknotebook#GtkNotebook-struct) *notebook`*,
*`[GtkWidget](gtkwidget#GtkWidget-struct) *child`*,
*`int position`*);
```
Reorders the page containing *`child`* , so that it appears in position *`position`* . If *`position`* is greater than or equal to the number of children in the list or negative, *`child`* will be moved to the end of the list.
#### Parameters
| | | |
| --- | --- | --- |
| notebook | a [GtkNotebook](gtknotebook#GtkNotebook-struct) | |
| child | the child to move | |
| position | the new position, or -1 to move to the end | |
### gtk\_notebook\_set\_tab\_pos ()
```
void
gtk_notebook_set_tab_pos (*`[GtkNotebook](gtknotebook#GtkNotebook-struct) *notebook`*,
*`[GtkPositionType](gtk4-standard-enumerations#GtkPositionType) pos`*);
```
Sets the edge at which the tabs for switching pages in the notebook are drawn.
#### Parameters
| | | |
| --- | --- | --- |
| notebook | a [GtkNotebook](gtknotebook#GtkNotebook-struct). | |
| pos | the edge to draw the tabs at | |
### gtk\_notebook\_set\_show\_tabs ()
```
void
gtk_notebook_set_show_tabs (*`[GtkNotebook](gtknotebook#GtkNotebook-struct) *notebook`*,
*`gboolean show_tabs`*);
```
Sets whether to show the tabs for the notebook or not.
#### Parameters
| | | |
| --- | --- | --- |
| notebook | a [GtkNotebook](gtknotebook#GtkNotebook-struct) | |
| show\_tabs | `TRUE` if the tabs should be shown | |
### gtk\_notebook\_set\_show\_border ()
```
void
gtk_notebook_set_show_border (*`[GtkNotebook](gtknotebook#GtkNotebook-struct) *notebook`*,
*`gboolean show_border`*);
```
Sets whether a bevel will be drawn around the notebook pages. This only has a visual effect when the tabs are not shown. See [`gtk_notebook_set_show_tabs()`](gtknotebook#gtk-notebook-set-show-tabs).
#### Parameters
| | | |
| --- | --- | --- |
| notebook | a [GtkNotebook](gtknotebook#GtkNotebook-struct) | |
| show\_border | `TRUE` if a bevel should be drawn around the notebook | |
### gtk\_notebook\_set\_scrollable ()
```
void
gtk_notebook_set_scrollable (*`[GtkNotebook](gtknotebook#GtkNotebook-struct) *notebook`*,
*`gboolean scrollable`*);
```
Sets whether the tab label area will have arrows for scrolling if there are too many tabs to fit in the area.
#### Parameters
| | | |
| --- | --- | --- |
| notebook | a [GtkNotebook](gtknotebook#GtkNotebook-struct) | |
| scrollable | `TRUE` if scroll arrows should be added | |
### gtk\_notebook\_popup\_enable ()
```
void
gtk_notebook_popup_enable (*`[GtkNotebook](gtknotebook#GtkNotebook-struct) *notebook`*);
```
Enables the popup menu: if the user clicks with the right mouse button on the tab labels, a menu with all the pages will be popped up.
#### Parameters
| | | |
| --- | --- | --- |
| notebook | a [GtkNotebook](gtknotebook#GtkNotebook-struct) | |
### gtk\_notebook\_popup\_disable ()
```
void
gtk_notebook_popup_disable (*`[GtkNotebook](gtknotebook#GtkNotebook-struct) *notebook`*);
```
Disables the popup menu.
#### Parameters
| | | |
| --- | --- | --- |
| notebook | a [GtkNotebook](gtknotebook#GtkNotebook-struct) | |
### gtk\_notebook\_get\_current\_page ()
```
int
gtk_notebook_get_current_page (*`[GtkNotebook](gtknotebook#GtkNotebook-struct) *notebook`*);
```
Returns the page number of the current page.
#### Parameters
| | | |
| --- | --- | --- |
| notebook | a [GtkNotebook](gtknotebook#GtkNotebook-struct) | |
#### Returns
the index (starting from 0) of the current page in the notebook. If the notebook has no pages, then -1 will be returned.
### gtk\_notebook\_get\_menu\_label ()
```
[GtkWidget](gtkwidget#GtkWidget-struct) *
gtk_notebook_get_menu_label (*`[GtkNotebook](gtknotebook#GtkNotebook-struct) *notebook`*,
*`[GtkWidget](gtkwidget#GtkWidget-struct) *child`*);
```
Retrieves the menu label widget of the page containing *`child`* .
#### Parameters
| | | |
| --- | --- | --- |
| notebook | a [GtkNotebook](gtknotebook#GtkNotebook-struct) | |
| child | a widget contained in a page of *`notebook`* | |
#### Returns
the menu label, or `NULL` if the notebook page does not have a menu label other than the default (the tab label).
[nullable][transfer none]
### gtk\_notebook\_get\_nth\_page ()
```
[GtkWidget](gtkwidget#GtkWidget-struct) *
gtk_notebook_get_nth_page (*`[GtkNotebook](gtknotebook#GtkNotebook-struct) *notebook`*,
*`int page_num`*);
```
Returns the child widget contained in page number *`page_num`* .
#### Parameters
| | | |
| --- | --- | --- |
| notebook | a [GtkNotebook](gtknotebook#GtkNotebook-struct) | |
| page\_num | the index of a page in the notebook, or -1 to get the last page | |
#### Returns
the child widget, or `NULL` if *`page_num`* is out of bounds.
[nullable][transfer none]
### gtk\_notebook\_get\_n\_pages ()
```
int
gtk_notebook_get_n_pages (*`[GtkNotebook](gtknotebook#GtkNotebook-struct) *notebook`*);
```
Gets the number of pages in a notebook.
#### Parameters
| | | |
| --- | --- | --- |
| notebook | a [GtkNotebook](gtknotebook#GtkNotebook-struct) | |
#### Returns
the number of pages in the notebook
### gtk\_notebook\_get\_tab\_label ()
```
[GtkWidget](gtkwidget#GtkWidget-struct) *
gtk_notebook_get_tab_label (*`[GtkNotebook](gtknotebook#GtkNotebook-struct) *notebook`*,
*`[GtkWidget](gtkwidget#GtkWidget-struct) *child`*);
```
Returns the tab label widget for the page *`child`* . `NULL` is returned if *`child`* is not in *`notebook`* or if no tab label has specifically been set for *`child`* .
#### Parameters
| | | |
| --- | --- | --- |
| notebook | a [GtkNotebook](gtknotebook#GtkNotebook-struct) | |
| child | the page | |
#### Returns
the tab label.
[transfer none][nullable]
### gtk\_notebook\_set\_menu\_label ()
```
void
gtk_notebook_set_menu_label (*`[GtkNotebook](gtknotebook#GtkNotebook-struct) *notebook`*,
*`[GtkWidget](gtkwidget#GtkWidget-struct) *child`*,
*`[GtkWidget](gtkwidget#GtkWidget-struct) *menu_label`*);
```
Changes the menu label for the page containing *`child`* .
#### Parameters
| | | |
| --- | --- | --- |
| notebook | a [GtkNotebook](gtknotebook#GtkNotebook-struct) | |
| child | the child widget | |
| menu\_label | the menu label, or `NULL` for default. | [allow-none] |
### gtk\_notebook\_set\_menu\_label\_text ()
```
void
gtk_notebook_set_menu_label_text (*`[GtkNotebook](gtknotebook#GtkNotebook-struct) *notebook`*,
*`[GtkWidget](gtkwidget#GtkWidget-struct) *child`*,
*`const char *menu_text`*);
```
Creates a new label and sets it as the menu label of *`child`* .
#### Parameters
| | | |
| --- | --- | --- |
| notebook | a [GtkNotebook](gtknotebook#GtkNotebook-struct) | |
| child | the child widget | |
| menu\_text | the label text | |
### gtk\_notebook\_set\_tab\_label ()
```
void
gtk_notebook_set_tab_label (*`[GtkNotebook](gtknotebook#GtkNotebook-struct) *notebook`*,
*`[GtkWidget](gtkwidget#GtkWidget-struct) *child`*,
*`[GtkWidget](gtkwidget#GtkWidget-struct) *tab_label`*);
```
Changes the tab label for *`child`* . If `NULL` is specified for *`tab_label`* , then the page will have the label “page N”.
#### Parameters
| | | |
| --- | --- | --- |
| notebook | a [GtkNotebook](gtknotebook#GtkNotebook-struct) | |
| child | the page | |
| tab\_label | the tab label widget to use, or `NULL` for default tab label. | [allow-none] |
### gtk\_notebook\_set\_tab\_label\_text ()
```
void
gtk_notebook_set_tab_label_text (*`[GtkNotebook](gtknotebook#GtkNotebook-struct) *notebook`*,
*`[GtkWidget](gtkwidget#GtkWidget-struct) *child`*,
*`const char *tab_text`*);
```
Creates a new label and sets it as the tab label for the page containing *`child`* .
#### Parameters
| | | |
| --- | --- | --- |
| notebook | a [GtkNotebook](gtknotebook#GtkNotebook-struct) | |
| child | the page | |
| tab\_text | the label text | |
### gtk\_notebook\_set\_tab\_reorderable ()
```
void
gtk_notebook_set_tab_reorderable (*`[GtkNotebook](gtknotebook#GtkNotebook-struct) *notebook`*,
*`[GtkWidget](gtkwidget#GtkWidget-struct) *child`*,
*`gboolean reorderable`*);
```
Sets whether the notebook tab can be reordered via drag and drop or not.
#### Parameters
| | | |
| --- | --- | --- |
| notebook | a [GtkNotebook](gtknotebook#GtkNotebook-struct) | |
| child | a child [GtkWidget](gtkwidget#GtkWidget-struct) | |
| reorderable | whether the tab is reorderable or not | |
### gtk\_notebook\_set\_tab\_detachable ()
```
void
gtk_notebook_set_tab_detachable (*`[GtkNotebook](gtknotebook#GtkNotebook-struct) *notebook`*,
*`[GtkWidget](gtkwidget#GtkWidget-struct) *child`*,
*`gboolean detachable`*);
```
Sets whether the tab can be detached from *`notebook`* to another notebook or widget.
Note that 2 notebooks must share a common group identificator (see [`gtk_notebook_set_group_name()`](gtknotebook#gtk-notebook-set-group-name)) to allow automatic tabs interchange between them.
If you want a widget to interact with a notebook through DnD (i.e.: accept dragged tabs from it) it must be set as a drop destination and accept the target “GTK\_NOTEBOOK\_TAB”. The notebook will fill the selection with a GtkWidget\*\* pointing to the child widget that corresponds to the dropped tab.
Note that you should use [`gtk_notebook_detach_tab()`](gtknotebook#gtk-notebook-detach-tab) instead of [`gtk_notebook_remove_page()`](gtknotebook#gtk-notebook-remove-page) if you want to remove the tab from the source notebook as part of accepting a drop. Otherwise, the source notebook will think that the dragged tab was removed from underneath the ongoing drag operation, and will initiate a drag cancel animation.
```
<object class="GtkNotebook">
<child>
<object class="GtkLabel" id="notebook-content">
<property name="label">Content</property>
</object>
</child>
<child type="tab">
<object class="GtkLabel" id="notebook-tab">
<property name="label">Tab</property>
</object>
</child>
</object>
```
| If you want a notebook to accept drags from other widgets, you will have to set your own DnD code to do it.
#### Parameters
| | | |
| --- | --- | --- |
| notebook | a [GtkNotebook](gtknotebook#GtkNotebook-struct) | |
| child | a child [GtkWidget](gtkwidget#GtkWidget-struct) | |
| detachable | whether the tab is detachable or not | |
### gtk\_notebook\_get\_menu\_label\_text ()
```
const char *
gtk_notebook_get_menu_label_text (*`[GtkNotebook](gtknotebook#GtkNotebook-struct) *notebook`*,
*`[GtkWidget](gtkwidget#GtkWidget-struct) *child`*);
```
Retrieves the text of the menu label for the page containing *`child`* .
#### Parameters
| | | |
| --- | --- | --- |
| notebook | a [GtkNotebook](gtknotebook#GtkNotebook-struct) | |
| child | the child widget of a page of the notebook. | |
#### Returns
the text of the tab label, or `NULL` if the widget does not have a menu label other than the default menu label, or the menu label widget is not a [GtkLabel](gtklabel#GtkLabel-struct). The string is owned by the widget and must not be freed.
[nullable]
### gtk\_notebook\_get\_scrollable ()
```
gboolean
gtk_notebook_get_scrollable (*`[GtkNotebook](gtknotebook#GtkNotebook-struct) *notebook`*);
```
Returns whether the tab label area has arrows for scrolling. See [`gtk_notebook_set_scrollable()`](gtknotebook#gtk-notebook-set-scrollable).
#### Parameters
| | | |
| --- | --- | --- |
| notebook | a [GtkNotebook](gtknotebook#GtkNotebook-struct) | |
#### Returns
`TRUE` if arrows for scrolling are present
### gtk\_notebook\_get\_show\_border ()
```
gboolean
gtk_notebook_get_show_border (*`[GtkNotebook](gtknotebook#GtkNotebook-struct) *notebook`*);
```
Returns whether a bevel will be drawn around the notebook pages. See [`gtk_notebook_set_show_border()`](gtknotebook#gtk-notebook-set-show-border).
#### Parameters
| | | |
| --- | --- | --- |
| notebook | a [GtkNotebook](gtknotebook#GtkNotebook-struct) | |
#### Returns
`TRUE` if the bevel is drawn
### gtk\_notebook\_get\_show\_tabs ()
```
gboolean
gtk_notebook_get_show_tabs (*`[GtkNotebook](gtknotebook#GtkNotebook-struct) *notebook`*);
```
Returns whether the tabs of the notebook are shown. See [`gtk_notebook_set_show_tabs()`](gtknotebook#gtk-notebook-set-show-tabs).
#### Parameters
| | | |
| --- | --- | --- |
| notebook | a [GtkNotebook](gtknotebook#GtkNotebook-struct) | |
#### Returns
`TRUE` if the tabs are shown
### gtk\_notebook\_get\_tab\_label\_text ()
```
const char *
gtk_notebook_get_tab_label_text (*`[GtkNotebook](gtknotebook#GtkNotebook-struct) *notebook`*,
*`[GtkWidget](gtkwidget#GtkWidget-struct) *child`*);
```
Retrieves the text of the tab label for the page containing *`child`* .
#### Parameters
| | | |
| --- | --- | --- |
| notebook | a [GtkNotebook](gtknotebook#GtkNotebook-struct) | |
| child | a widget contained in a page of *`notebook`* | |
#### Returns
the text of the tab label, or `NULL` if the tab label widget is not a [GtkLabel](gtklabel#GtkLabel-struct). The string is owned by the widget and must not be freed.
[nullable]
### gtk\_notebook\_get\_tab\_pos ()
```
[GtkPositionType](gtk4-standard-enumerations#GtkPositionType)
gtk_notebook_get_tab_pos (*`[GtkNotebook](gtknotebook#GtkNotebook-struct) *notebook`*);
```
Gets the edge at which the tabs for switching pages in the notebook are drawn.
#### Parameters
| | | |
| --- | --- | --- |
| notebook | a [GtkNotebook](gtknotebook#GtkNotebook-struct) | |
#### Returns
the edge at which the tabs are drawn
### gtk\_notebook\_get\_tab\_reorderable ()
```
gboolean
gtk_notebook_get_tab_reorderable (*`[GtkNotebook](gtknotebook#GtkNotebook-struct) *notebook`*,
*`[GtkWidget](gtkwidget#GtkWidget-struct) *child`*);
```
Gets whether the tab can be reordered via drag and drop or not.
#### Parameters
| | | |
| --- | --- | --- |
| notebook | a [GtkNotebook](gtknotebook#GtkNotebook-struct) | |
| child | a child [GtkWidget](gtkwidget#GtkWidget-struct) | |
#### Returns
`TRUE` if the tab is reorderable.
### gtk\_notebook\_get\_tab\_detachable ()
```
gboolean
gtk_notebook_get_tab_detachable (*`[GtkNotebook](gtknotebook#GtkNotebook-struct) *notebook`*,
*`[GtkWidget](gtkwidget#GtkWidget-struct) *child`*);
```
Returns whether the tab contents can be detached from *`notebook`* .
#### Parameters
| | | |
| --- | --- | --- |
| notebook | a [GtkNotebook](gtknotebook#GtkNotebook-struct) | |
| child | a child [GtkWidget](gtkwidget#GtkWidget-struct) | |
#### Returns
`TRUE` if the tab is detachable.
### gtk\_notebook\_set\_current\_page ()
```
void
gtk_notebook_set_current_page (*`[GtkNotebook](gtknotebook#GtkNotebook-struct) *notebook`*,
*`int page_num`*);
```
Switches to the page number *`page_num`* .
Note that due to historical reasons, GtkNotebook refuses to switch to a page unless the child widget is visible. Therefore, it is recommended to show child widgets before adding them to a notebook.
#### Parameters
| | | |
| --- | --- | --- |
| notebook | a [GtkNotebook](gtknotebook#GtkNotebook-struct) | |
| page\_num | index of the page to switch to, starting from 0. If negative, the last page will be used. If greater than the number of pages in the notebook, nothing will be done. | |
### gtk\_notebook\_set\_group\_name ()
```
void
gtk_notebook_set_group_name (*`[GtkNotebook](gtknotebook#GtkNotebook-struct) *notebook`*,
*`const char *group_name`*);
```
Sets a group name for *`notebook`* .
Notebooks with the same name will be able to exchange tabs via drag and drop. A notebook with a `NULL` group name will not be able to exchange tabs with any other notebook.
#### Parameters
| | | |
| --- | --- | --- |
| notebook | a [GtkNotebook](gtknotebook#GtkNotebook-struct) | |
| group\_name | the name of the notebook group, or `NULL` to unset it. | [allow-none] |
### gtk\_notebook\_get\_group\_name ()
```
const char *
gtk_notebook_get_group_name (*`[GtkNotebook](gtknotebook#GtkNotebook-struct) *notebook`*);
```
Gets the current group name for *`notebook`* .
#### Parameters
| | | |
| --- | --- | --- |
| notebook | a [GtkNotebook](gtknotebook#GtkNotebook-struct) | |
#### Returns
the group name, or `NULL` if none is set.
[nullable][transfer none]
### gtk\_notebook\_set\_action\_widget ()
```
void
gtk_notebook_set_action_widget (*`[GtkNotebook](gtknotebook#GtkNotebook-struct) *notebook`*,
*`[GtkWidget](gtkwidget#GtkWidget-struct) *widget`*,
*`[GtkPackType](gtk4-standard-enumerations#GtkPackType) pack_type`*);
```
Sets *`widget`* as one of the action widgets. Depending on the pack type the widget will be placed before or after the tabs. You can use a [GtkBox](gtkbox#GtkBox-struct) if you need to pack more than one widget on the same side.
#### Parameters
| | | |
| --- | --- | --- |
| notebook | a [GtkNotebook](gtknotebook#GtkNotebook-struct) | |
| widget | a [GtkWidget](gtkwidget#GtkWidget-struct) | |
| pack\_type | pack type of the action widget | |
### gtk\_notebook\_get\_action\_widget ()
```
[GtkWidget](gtkwidget#GtkWidget-struct) *
gtk_notebook_get_action_widget (*`[GtkNotebook](gtknotebook#GtkNotebook-struct) *notebook`*,
*`[GtkPackType](gtk4-standard-enumerations#GtkPackType) pack_type`*);
```
Gets one of the action widgets. See [`gtk_notebook_set_action_widget()`](gtknotebook#gtk-notebook-set-action-widget).
#### Parameters
| | | |
| --- | --- | --- |
| notebook | a [GtkNotebook](gtknotebook#GtkNotebook-struct) | |
| pack\_type | pack type of the action widget to receive | |
#### Returns
The action widget with the given *`pack_type`* or `NULL` when this action widget has not been set.
[nullable][transfer none]
Types and Values
----------------
### GtkNotebook
```
typedef struct _GtkNotebook GtkNotebook;
```
### GtkNotebookPage
```
typedef struct _GtkNotebookPage GtkNotebookPage;
```
A page in the [GtkNotebook](gtknotebook#GtkNotebook-struct).
The `GtkNotebookPage` structure only contains private data.
### enum GtkNotebookTab
The parameter used in the action signals of [GtkNotebook](gtknotebook#GtkNotebook-struct).
#### Members
| | | |
| --- | --- | --- |
| GTK\_NOTEBOOK\_TAB\_FIRST | the first tab in the notebook | |
| GTK\_NOTEBOOK\_TAB\_LAST | the last tab in the notebook | |
Property Details
----------------
### The `“enable-popup”` property
```
“enable-popup” gboolean
```
If TRUE, pressing the right mouse button on the notebook pops up a menu that you can use to go to a page.
Owner: GtkNotebook
Flags: Read / Write
Default value: FALSE
### The `“group-name”` property
```
“group-name” char *
```
Group name for tab drag and drop.
Owner: GtkNotebook
Flags: Read / Write
Default value: NULL
### The `“page”` property
```
“page” int
```
The index of the current page.
Owner: GtkNotebook
Flags: Read / Write
Allowed values: >= -1
Default value: -1
### The `“pages”` property
```
“pages” GListModel *
```
The pages of the notebook.
Owner: GtkNotebook
Flags: Read
### The `“scrollable”` property
```
“scrollable” gboolean
```
If TRUE, scroll arrows are added if there are too many tabs to fit.
Owner: GtkNotebook
Flags: Read / Write
Default value: FALSE
### The `“show-border”` property
```
“show-border” gboolean
```
Whether the border should be shown.
Owner: GtkNotebook
Flags: Read / Write
Default value: TRUE
### The `“show-tabs”` property
```
“show-tabs” gboolean
```
Whether tabs should be shown.
Owner: GtkNotebook
Flags: Read / Write
Default value: TRUE
### The `“tab-pos”` property
```
“tab-pos” [GtkPositionType](gtk4-standard-enumerations#GtkPositionType)
```
Which side of the notebook holds the tabs.
Owner: GtkNotebook
Flags: Read / Write
Default value: GTK\_POS\_TOP
### The `“child”` property
```
“child” [GtkWidget](gtkwidget#GtkWidget-struct) *
```
The child for this page.
Owner: GtkNotebookPage
Flags: Read / Write / Construct Only
### The `“detachable”` property
```
“detachable” gboolean
```
Whether the tab is detachable.
Owner: GtkNotebookPage
Flags: Read / Write
Default value: FALSE
### The `“menu”` property
```
“menu” [GtkWidget](gtkwidget#GtkWidget-struct) *
```
The label widget displayed in the child’s menu entry.
Owner: GtkNotebookPage
Flags: Read / Write / Construct Only
### The `“menu-label”` property
```
“menu-label” char *
```
The text of the menu widget.
Owner: GtkNotebookPage
Flags: Read / Write
Default value: NULL
### The `“position”` property
```
“position” int
```
The index of the child in the parent.
Owner: GtkNotebookPage
Flags: Read / Write
Allowed values: >= -1
Default value: 0
### The `“reorderable”` property
```
“reorderable” gboolean
```
Whether the tab is reorderable by user action.
Owner: GtkNotebookPage
Flags: Read / Write
Default value: FALSE
### The `“tab”` property
```
“tab” [GtkWidget](gtkwidget#GtkWidget-struct) *
```
The tab widget for this page.
Owner: GtkNotebookPage
Flags: Read / Write / Construct Only
### The `“tab-expand”` property
```
“tab-expand” gboolean
```
Whether to expand the child’s tab.
Owner: GtkNotebookPage
Flags: Read / Write
Default value: FALSE
### The `“tab-fill”` property
```
“tab-fill” gboolean
```
Whether the child’s tab should fill the allocated area.
Owner: GtkNotebookPage
Flags: Read / Write
Default value: TRUE
### The `“tab-label”` property
```
“tab-label” char *
```
The text of the tab widget.
Owner: GtkNotebookPage
Flags: Read / Write
Default value: NULL
Signal Details
--------------
### The `“change-current-page”` signal
```
gboolean
user_function ([GtkNotebook](gtknotebook#GtkNotebook-struct) *notebook,
int arg1,
gpointer user_data)
```
Flags: Action
### The `“create-window”` signal
```
[GtkNotebook](gtknotebook#GtkNotebook-struct)*
user_function ([GtkNotebook](gtknotebook#GtkNotebook-struct) *notebook,
[GtkWidget](gtkwidget#GtkWidget-struct) *page,
gpointer user_data)
```
The ::create-window signal is emitted when a detachable tab is dropped on the root window.
A handler for this signal can create a window containing a notebook where the tab will be attached. It is also responsible for moving/resizing the window and adding the necessary properties to the notebook (e.g. the [“group-name”](gtknotebook#GtkNotebook--group-name) ).
#### Parameters
| | | |
| --- | --- | --- |
| notebook | the [GtkNotebook](gtknotebook#GtkNotebook-struct) emitting the signal | |
| page | the tab of *`notebook`* that is being detached | |
| user\_data | user data set when the signal handler was connected. | |
#### Returns
a [GtkNotebook](gtknotebook#GtkNotebook-struct) that *`page`* should be added to, or `NULL`.
[transfer none]
Flags: Run Last
### The `“focus-tab”` signal
```
gboolean
user_function ([GtkNotebook](gtknotebook#GtkNotebook-struct) *notebook,
[GtkNotebookTab](gtknotebook#GtkNotebookTab) arg1,
gpointer user_data)
```
Flags: Action
### The `“move-focus-out”` signal
```
void
user_function ([GtkNotebook](gtknotebook#GtkNotebook-struct) *notebook,
[GtkDirectionType](gtk4-standard-enumerations#GtkDirectionType) arg1,
gpointer user_data)
```
Flags: Action
### The `“page-added”` signal
```
void
user_function ([GtkNotebook](gtknotebook#GtkNotebook-struct) *notebook,
[GtkWidget](gtkwidget#GtkWidget-struct) *child,
guint page_num,
gpointer user_data)
```
the ::page-added signal is emitted in the notebook right after a page is added to the notebook.
#### Parameters
| | | |
| --- | --- | --- |
| notebook | the [GtkNotebook](gtknotebook#GtkNotebook-struct) | |
| child | the child [GtkWidget](gtkwidget#GtkWidget-struct) affected | |
| page\_num | the new page number for *`child`* | |
| user\_data | user data set when the signal handler was connected. | |
Flags: Run Last
### The `“page-removed”` signal
```
void
user_function ([GtkNotebook](gtknotebook#GtkNotebook-struct) *notebook,
[GtkWidget](gtkwidget#GtkWidget-struct) *child,
guint page_num,
gpointer user_data)
```
the ::page-removed signal is emitted in the notebook right after a page is removed from the notebook.
#### Parameters
| | | |
| --- | --- | --- |
| notebook | the [GtkNotebook](gtknotebook#GtkNotebook-struct) | |
| child | the child [GtkWidget](gtkwidget#GtkWidget-struct) affected | |
| page\_num | the *`child`* page number | |
| user\_data | user data set when the signal handler was connected. | |
Flags: Run Last
### The `“page-reordered”` signal
```
void
user_function ([GtkNotebook](gtknotebook#GtkNotebook-struct) *notebook,
[GtkWidget](gtkwidget#GtkWidget-struct) *child,
guint page_num,
gpointer user_data)
```
the ::page-reordered signal is emitted in the notebook right after a page has been reordered.
#### Parameters
| | | |
| --- | --- | --- |
| notebook | the [GtkNotebook](gtknotebook#GtkNotebook-struct) | |
| child | the child [GtkWidget](gtkwidget#GtkWidget-struct) affected | |
| page\_num | the new page number for *`child`* | |
| user\_data | user data set when the signal handler was connected. | |
Flags: Run Last
### The `“reorder-tab”` signal
```
gboolean
user_function ([GtkNotebook](gtknotebook#GtkNotebook-struct) *notebook,
[GtkDirectionType](gtk4-standard-enumerations#GtkDirectionType) arg1,
gboolean arg2,
gpointer user_data)
```
Flags: Action
### The `“select-page”` signal
```
gboolean
user_function ([GtkNotebook](gtknotebook#GtkNotebook-struct) *notebook,
gboolean arg1,
gpointer user_data)
```
Flags: Action
### The `“switch-page”` signal
```
void
user_function ([GtkNotebook](gtknotebook#GtkNotebook-struct) *notebook,
[GtkWidget](gtkwidget#GtkWidget-struct) *page,
guint page_num,
gpointer user_data)
```
Emitted when the user or a function changes the current page.
#### Parameters
| | | |
| --- | --- | --- |
| notebook | the object which received the signal. | |
| page | the new current page | |
| page\_num | the index of the page | |
| user\_data | user data set when the signal handler was connected. | |
Flags: Run Last
Action Details
--------------
### The `“menu.popup”` action
Opens the context menu.
| programming_docs |
gtk GtkFileChooserWidget GtkFileChooserWidget
====================
GtkFileChooserWidget — A file chooser widget
Functions
---------
| | |
| --- | --- |
| [GtkWidget](gtkwidget#GtkWidget-struct) \* | [gtk\_file\_chooser\_widget\_new](gtkfilechooserwidget#gtk-file-chooser-widget-new) () |
Properties
----------
| | | |
| --- | --- | --- |
| gboolean | [search-mode](gtkfilechooserwidget#GtkFileChooserWidget--search-mode) | Read / Write |
| char \* | [subtitle](gtkfilechooserwidget#GtkFileChooserWidget--subtitle) | Read |
Signals
-------
| | | |
| --- | --- | --- |
| void | [desktop-folder](gtkfilechooserwidget#GtkFileChooserWidget-desktop-folder) | Action |
| void | [down-folder](gtkfilechooserwidget#GtkFileChooserWidget-down-folder) | Action |
| void | [home-folder](gtkfilechooserwidget#GtkFileChooserWidget-home-folder) | Action |
| void | [location-popup](gtkfilechooserwidget#GtkFileChooserWidget-location-popup) | Action |
| void | [location-popup-on-paste](gtkfilechooserwidget#GtkFileChooserWidget-location-popup-on-paste) | Action |
| void | [location-toggle-popup](gtkfilechooserwidget#GtkFileChooserWidget-location-toggle-popup) | Action |
| void | [places-shortcut](gtkfilechooserwidget#GtkFileChooserWidget-places-shortcut) | Action |
| void | [quick-bookmark](gtkfilechooserwidget#GtkFileChooserWidget-quick-bookmark) | Action |
| void | [recent-shortcut](gtkfilechooserwidget#GtkFileChooserWidget-recent-shortcut) | Action |
| void | [search-shortcut](gtkfilechooserwidget#GtkFileChooserWidget-search-shortcut) | Action |
| void | [show-hidden](gtkfilechooserwidget#GtkFileChooserWidget-show-hidden) | Action |
| void | [up-folder](gtkfilechooserwidget#GtkFileChooserWidget-up-folder) | Action |
Types and Values
----------------
| | |
| --- | --- |
| | [GtkFileChooserWidget](gtkfilechooserwidget#GtkFileChooserWidget-struct) |
Object Hierarchy
----------------
```
GObject
╰── GInitiallyUnowned
╰── [GtkWidget](gtkwidget#GtkWidget-struct)
╰── GtkFileChooserWidget
```
Implemented Interfaces
----------------------
GtkFileChooserWidget implements [GtkAccessible](gtkaccessible#GtkAccessible-struct), [GtkBuildable](gtkbuildable#GtkBuildable-struct), [GtkConstraintTarget](gtkconstraint#GtkConstraintTarget-struct) and [GtkFileChooser](gtkfilechooser#GtkFileChooser-struct).
Includes
--------
```
#include <gtk/gtk.h>
```
Description
-----------
[GtkFileChooserWidget](gtkfilechooserwidget#GtkFileChooserWidget-struct) is a widget for choosing files. It exposes the [GtkFileChooser](gtkfilechooser#GtkFileChooser-struct) interface, and you should use the methods of this interface to interact with the widget.
### CSS nodes
GtkFileChooserWidget has a single CSS node with name filechooser.
Functions
---------
### gtk\_file\_chooser\_widget\_new ()
```
[GtkWidget](gtkwidget#GtkWidget-struct) *
gtk_file_chooser_widget_new (*`[GtkFileChooserAction](gtkfilechooser#GtkFileChooserAction) action`*);
```
Creates a new [GtkFileChooserWidget](gtkfilechooserwidget#GtkFileChooserWidget-struct). This is a file chooser widget that can be embedded in custom windows, and it is the same widget that is used by [GtkFileChooserDialog](gtkfilechooserdialog#GtkFileChooserDialog-struct).
#### Parameters
| | | |
| --- | --- | --- |
| action | Open or save mode for the widget | |
#### Returns
a new [GtkFileChooserWidget](gtkfilechooserwidget#GtkFileChooserWidget-struct)
Types and Values
----------------
### GtkFileChooserWidget
```
typedef struct _GtkFileChooserWidget GtkFileChooserWidget;
```
Property Details
----------------
### The `“search-mode”` property
```
“search-mode” gboolean
```
Search mode.
Owner: GtkFileChooserWidget
Flags: Read / Write
Default value: FALSE
### The `“subtitle”` property
```
“subtitle” char *
```
Subtitle.
Owner: GtkFileChooserWidget
Flags: Read
Default value: ""
Signal Details
--------------
### The `“desktop-folder”` signal
```
void
user_function ([GtkFileChooserWidget](gtkfilechooserwidget#GtkFileChooserWidget-struct) *widget,
gpointer user_data)
```
The ::desktop-folder signal is a [keybinding signal](gtkshortcutaction#GtkSignalAction-struct) which gets emitted when the user asks for it.
This is used to make the file chooser show the user's Desktop folder in the file list.
The default binding for this signal is `Alt + D`.
#### Parameters
| | | |
| --- | --- | --- |
| widget | the object which received the signal | |
| user\_data | user data set when the signal handler was connected. | |
Flags: Action
### The `“down-folder”` signal
```
void
user_function ([GtkFileChooserWidget](gtkfilechooserwidget#GtkFileChooserWidget-struct) *widget,
gpointer user_data)
```
The ::down-folder signal is a [keybinding signal](gtkshortcutaction#GtkSignalAction-struct) which gets emitted when the user asks for it.
This is used to make the file chooser go to a child of the current folder in the file hierarchy. The subfolder that will be used is displayed in the path bar widget of the file chooser. For example, if the path bar is showing "/foo/bar/baz", with bar currently displayed, then this will cause the file chooser to switch to the "baz" subfolder.
The default binding for this signal is `Alt + Down`.
#### Parameters
| | | |
| --- | --- | --- |
| widget | the object which received the signal | |
| user\_data | user data set when the signal handler was connected. | |
Flags: Action
### The `“home-folder”` signal
```
void
user_function ([GtkFileChooserWidget](gtkfilechooserwidget#GtkFileChooserWidget-struct) *widget,
gpointer user_data)
```
The ::home-folder signal is a [keybinding signal](gtkshortcutaction#GtkSignalAction-struct) which gets emitted when the user asks for it.
This is used to make the file chooser show the user's home folder in the file list.
The default binding for this signal is `Alt + Home`.
#### Parameters
| | | |
| --- | --- | --- |
| widget | the object which received the signal | |
| user\_data | user data set when the signal handler was connected. | |
Flags: Action
### The `“location-popup”` signal
```
void
user_function ([GtkFileChooserWidget](gtkfilechooserwidget#GtkFileChooserWidget-struct) *widget,
char *path,
gpointer user_data)
```
The ::location-popup signal is a [keybinding signal](gtkshortcutaction#GtkSignalAction-struct) which gets emitted when the user asks for it.
This is used to make the file chooser show a "Location" prompt which the user can use to manually type the name of the file he wishes to select.
The default bindings for this signal are `Control + L` with a *`path`* string of "" (the empty string). It is also bound to `/` with a *`path`* string of "`/`" (a slash): this lets you type `/` and immediately type a path name. On Unix systems, this is bound to `~` (tilde) with a *`path`* string of "~" itself for access to home directories.
#### Parameters
| | | |
| --- | --- | --- |
| widget | the object which received the signal | |
| path | a string that gets put in the text entry for the file name | |
| user\_data | user data set when the signal handler was connected. | |
Flags: Action
### The `“location-popup-on-paste”` signal
```
void
user_function ([GtkFileChooserWidget](gtkfilechooserwidget#GtkFileChooserWidget-struct) *widget,
gpointer user_data)
```
The ::location-popup-on-paste signal is a [keybinding signal](gtkshortcutaction#GtkSignalAction-struct) which gets emitted when the user asks for it.
This is used to make the file chooser show a "Location" prompt when the user pastes into a [GtkFileChooserWidget](gtkfilechooserwidget#GtkFileChooserWidget-struct).
The default binding for this signal is `Control + V`.
#### Parameters
| | | |
| --- | --- | --- |
| widget | the object which received the signal | |
| user\_data | user data set when the signal handler was connected. | |
Flags: Action
### The `“location-toggle-popup”` signal
```
void
user_function ([GtkFileChooserWidget](gtkfilechooserwidget#GtkFileChooserWidget-struct) *widget,
gpointer user_data)
```
The ::location-toggle-popup signal is a [keybinding signal](gtkshortcutaction#GtkSignalAction-struct) which gets emitted when the user asks for it.
This is used to toggle the visibility of a "Location" prompt which the user can use to manually type the name of the file he wishes to select.
The default binding for this signal is `Control + L`.
#### Parameters
| | | |
| --- | --- | --- |
| widget | the object which received the signal | |
| user\_data | user data set when the signal handler was connected. | |
Flags: Action
### The `“places-shortcut”` signal
```
void
user_function ([GtkFileChooserWidget](gtkfilechooserwidget#GtkFileChooserWidget-struct) *widget,
gpointer user_data)
```
The ::places-shortcut signal is a [keybinding signal](gtkshortcutaction#GtkSignalAction-struct) which gets emitted when the user asks for it.
This is used to move the focus to the places sidebar.
The default binding for this signal is `Alt + P`.
#### Parameters
| | | |
| --- | --- | --- |
| widget | the object which received the signal | |
| user\_data | user data set when the signal handler was connected. | |
Flags: Action
### The `“quick-bookmark”` signal
```
void
user_function ([GtkFileChooserWidget](gtkfilechooserwidget#GtkFileChooserWidget-struct) *widget,
int bookmark_index,
gpointer user_data)
```
The ::quick-bookmark signal is a [keybinding signal](gtkshortcutaction#GtkSignalAction-struct) which gets emitted when the user asks for it.
This is used to make the file chooser switch to the bookmark specified in the *`bookmark_index`* parameter. For example, if you have three bookmarks, you can pass 0, 1, 2 to this signal to switch to each of them, respectively.
The default binding for this signal is `Alt + 1`, `Alt + 2`, etc. until `Alt + 0`. Note that in the default binding, that `Alt + 1` is actually defined to switch to the bookmark at index 0, and so on successively; `Alt + 0` is defined to switch to the bookmark at index 10.
#### Parameters
| | | |
| --- | --- | --- |
| widget | the object which received the signal | |
| bookmark\_index | the number of the bookmark to switch to | |
| user\_data | user data set when the signal handler was connected. | |
Flags: Action
### The `“recent-shortcut”` signal
```
void
user_function ([GtkFileChooserWidget](gtkfilechooserwidget#GtkFileChooserWidget-struct) *widget,
gpointer user_data)
```
The ::recent-shortcut signal is a [keybinding signal](gtkshortcutaction#GtkSignalAction-struct) which gets emitted when the user asks for it.
This is used to make the file chooser show the Recent location.
The default binding for this signal is `Alt + R`.
#### Parameters
| | | |
| --- | --- | --- |
| widget | the object which received the signal | |
| user\_data | user data set when the signal handler was connected. | |
Flags: Action
### The `“search-shortcut”` signal
```
void
user_function ([GtkFileChooserWidget](gtkfilechooserwidget#GtkFileChooserWidget-struct) *widget,
gpointer user_data)
```
The ::search-shortcut signal is a [keybinding signal](gtkshortcutaction#GtkSignalAction-struct) which gets emitted when the user asks for it.
This is used to make the file chooser show the search entry.
The default binding for this signal is `Alt + S`.
#### Parameters
| | | |
| --- | --- | --- |
| widget | the object which received the signal | |
| user\_data | user data set when the signal handler was connected. | |
Flags: Action
### The `“show-hidden”` signal
```
void
user_function ([GtkFileChooserWidget](gtkfilechooserwidget#GtkFileChooserWidget-struct) *widget,
gpointer user_data)
```
The ::show-hidden signal is a [keybinding signal](gtkshortcutaction#GtkSignalAction-struct) which gets emitted when the user asks for it.
This is used to make the file chooser display hidden files.
The default binding for this signal is `Control + H`.
#### Parameters
| | | |
| --- | --- | --- |
| widget | the object which received the signal | |
| user\_data | user data set when the signal handler was connected. | |
Flags: Action
### The `“up-folder”` signal
```
void
user_function ([GtkFileChooserWidget](gtkfilechooserwidget#GtkFileChooserWidget-struct) *widget,
gpointer user_data)
```
The ::up-folder signal is a [keybinding signal](gtkshortcutaction#GtkSignalAction-struct) which gets emitted when the user asks for it.
This is used to make the file chooser go to the parent of the current folder in the file hierarchy.
The default binding for this signal is `Alt + Up`.
#### Parameters
| | | |
| --- | --- | --- |
| widget | the object which received the signal | |
| user\_data | user data set when the signal handler was connected. | |
Flags: Action
See Also
--------
[GtkFileChooserDialog](gtkfilechooserdialog#GtkFileChooserDialog-struct)
gtk GtkPicture GtkPicture
==========
GtkPicture — A widget displaying a [GdkPaintable](https://developer-old.gnome.org/gtk4/html/GdkPaintable.html#GdkPaintable-struct)
Functions
---------
| | |
| --- | --- |
| [GtkWidget](gtkwidget#GtkWidget-struct) \* | [gtk\_picture\_new](gtkpicture#gtk-picture-new) () |
| [GtkWidget](gtkwidget#GtkWidget-struct) \* | [gtk\_picture\_new\_for\_paintable](gtkpicture#gtk-picture-new-for-paintable) () |
| [GtkWidget](gtkwidget#GtkWidget-struct) \* | [gtk\_picture\_new\_for\_pixbuf](gtkpicture#gtk-picture-new-for-pixbuf) () |
| [GtkWidget](gtkwidget#GtkWidget-struct) \* | [gtk\_picture\_new\_for\_file](gtkpicture#gtk-picture-new-for-file) () |
| [GtkWidget](gtkwidget#GtkWidget-struct) \* | [gtk\_picture\_new\_for\_filename](gtkpicture#gtk-picture-new-for-filename) () |
| [GtkWidget](gtkwidget#GtkWidget-struct) \* | [gtk\_picture\_new\_for\_resource](gtkpicture#gtk-picture-new-for-resource) () |
| void | [gtk\_picture\_set\_paintable](gtkpicture#gtk-picture-set-paintable) () |
| [GdkPaintable](https://developer-old.gnome.org/gtk4/html/GdkPaintable.html#GdkPaintable-struct) \* | [gtk\_picture\_get\_paintable](gtkpicture#gtk-picture-get-paintable) () |
| void | [gtk\_picture\_set\_pixbuf](gtkpicture#gtk-picture-set-pixbuf) () |
| void | [gtk\_picture\_set\_file](gtkpicture#gtk-picture-set-file) () |
| GFile \* | [gtk\_picture\_get\_file](gtkpicture#gtk-picture-get-file) () |
| void | [gtk\_picture\_set\_filename](gtkpicture#gtk-picture-set-filename) () |
| void | [gtk\_picture\_set\_resource](gtkpicture#gtk-picture-set-resource) () |
| void | [gtk\_picture\_set\_keep\_aspect\_ratio](gtkpicture#gtk-picture-set-keep-aspect-ratio) () |
| gboolean | [gtk\_picture\_get\_keep\_aspect\_ratio](gtkpicture#gtk-picture-get-keep-aspect-ratio) () |
| void | [gtk\_picture\_set\_can\_shrink](gtkpicture#gtk-picture-set-can-shrink) () |
| gboolean | [gtk\_picture\_get\_can\_shrink](gtkpicture#gtk-picture-get-can-shrink) () |
| void | [gtk\_picture\_set\_alternative\_text](gtkpicture#gtk-picture-set-alternative-text) () |
| const char \* | [gtk\_picture\_get\_alternative\_text](gtkpicture#gtk-picture-get-alternative-text) () |
Properties
----------
| | | |
| --- | --- | --- |
| char \* | [alternative-text](gtkpicture#GtkPicture--alternative-text) | Read / Write |
| gboolean | [can-shrink](gtkpicture#GtkPicture--can-shrink) | Read / Write |
| GFile \* | [file](gtkpicture#GtkPicture--file) | Read / Write |
| gboolean | [keep-aspect-ratio](gtkpicture#GtkPicture--keep-aspect-ratio) | Read / Write |
| [GdkPaintable](https://developer-old.gnome.org/gtk4/html/GdkPaintable.html#GdkPaintable-struct) \* | [paintable](gtkpicture#GtkPicture--paintable) | Read / Write |
Types and Values
----------------
| | |
| --- | --- |
| | [GtkPicture](gtkpicture#GtkPicture-struct) |
Object Hierarchy
----------------
```
GObject
╰── GInitiallyUnowned
╰── [GtkWidget](gtkwidget#GtkWidget-struct)
╰── GtkPicture
```
Implemented Interfaces
----------------------
GtkPicture implements [GtkAccessible](gtkaccessible#GtkAccessible-struct), [GtkBuildable](gtkbuildable#GtkBuildable-struct) and [GtkConstraintTarget](gtkconstraint#GtkConstraintTarget-struct).
Includes
--------
```
#include <gtk/gtk.h>
```
Description
-----------
The [GtkPicture](gtkpicture#GtkPicture-struct) widget displays a [GdkPaintable](https://developer-old.gnome.org/gtk4/html/GdkPaintable.html#GdkPaintable-struct). Many convenience functions are provided to make pictures simple to use. For example, if you want to load an image from a file, and then display that, there’s a convenience function to do this:
```
GtkWidget *widget;
widget = gtk_picture_new_for_filename ("myfile.png");
```
| If the file isn’t loaded successfully, the picture will contain a “broken image” icon similar to that used in many web browsers. If you want to handle errors in loading the file yourself, for example by displaying an error message, then load the image with [`gdk_texture_new_from_file()`](https://developer-old.gnome.org/gtk4/html/gdk4-Textures.html#gdk-texture-new-from-file), then create the [GtkPicture](gtkpicture#GtkPicture-struct) with [`gtk_picture_new_for_paintable()`](gtkpicture#gtk-picture-new-for-paintable).
Sometimes an application will want to avoid depending on external data files, such as image files. See the documentation of GResource for details. In this case, [`gtk_picture_new_for_resource()`](gtkpicture#gtk-picture-new-for-resource) and [`gtk_picture_set_resource()`](gtkpicture#gtk-picture-set-resource) should be used.
GtkPicture displays an image at its natural size. See [GtkImage](gtkimage#GtkImage-struct) if you want to display a fixed-size image, such as an icon.
### Sizing the paintable
You can influence how the paintable is displayed inside the [GtkPicture](gtkpicture#GtkPicture-struct). By turning off [“keep-aspect-ratio”](gtkpicture#GtkPicture--keep-aspect-ratio) you can allow the paintable to get stretched. [“can-shrink”](gtkpicture#GtkPicture--can-shrink) can be unset to make sure that paintables are never made smaller than their ideal size - but be careful if you do not know the size of the paintable in use (like when displaying user-loaded images). This can easily cause the picture to grow larger than the screen. And [“halign”](gtkwidget#GtkWidget--halign) and [“valign”](gtkwidget#GtkWidget--valign) can be used to make sure the paintable doesn't fill all available space but is instead displayed at its original size.
### CSS nodes
GtkPicture has a single CSS node with the name picture.
### Accessibility
GtkPicture uses the [GTK\_ACCESSIBLE\_ROLE\_IMG](gtkaccessible#GTK-ACCESSIBLE-ROLE-IMG:CAPS) role.
Functions
---------
### gtk\_picture\_new ()
```
[GtkWidget](gtkwidget#GtkWidget-struct) *
gtk_picture_new (*`void`*);
```
Creates a new empty [GtkPicture](gtkpicture#GtkPicture-struct) widget.
#### Returns
a newly created [GtkPicture](gtkpicture#GtkPicture-struct) widget.
### gtk\_picture\_new\_for\_paintable ()
```
[GtkWidget](gtkwidget#GtkWidget-struct) *
gtk_picture_new_for_paintable (*`[GdkPaintable](https://developer-old.gnome.org/gtk4/html/GdkPaintable.html#GdkPaintable-struct) *paintable`*);
```
Creates a new [GtkPicture](gtkpicture#GtkPicture-struct) displaying *`paintable`* .
The [GtkPicture](gtkpicture#GtkPicture-struct) will track changes to the *`paintable`* and update its size and contents in response to it.
#### Parameters
| | | |
| --- | --- | --- |
| paintable | a [GdkPaintable](https://developer-old.gnome.org/gtk4/html/GdkPaintable.html#GdkPaintable-struct), or `NULL`. | [nullable] |
#### Returns
a new [GtkPicture](gtkpicture#GtkPicture-struct)
### gtk\_picture\_new\_for\_pixbuf ()
```
[GtkWidget](gtkwidget#GtkWidget-struct) *
gtk_picture_new_for_pixbuf (*`[GdkPixbuf](https://developer-old.gnome.org/gdk-pixbuf/stable/gdk-pixbuf-The-GdkPixbuf-Structure.html#GdkPixbuf-struct) *pixbuf`*);
```
Creates a new [GtkPicture](gtkpicture#GtkPicture-struct) displaying *`pixbuf`* .
This is a utility function that calls [`gtk_picture_new_for_paintable()`](gtkpicture#gtk-picture-new-for-paintable), See that function for details.
The pixbuf must not be modified after passing it to this function.
#### Parameters
| | | |
| --- | --- | --- |
| pixbuf | a [GdkPixbuf](https://developer-old.gnome.org/gdk-pixbuf/stable/gdk-pixbuf-The-GdkPixbuf-Structure.html#GdkPixbuf-struct), or `NULL`. | [nullable] |
#### Returns
a new [GtkPicture](gtkpicture#GtkPicture-struct)
### gtk\_picture\_new\_for\_file ()
```
[GtkWidget](gtkwidget#GtkWidget-struct) *
gtk_picture_new_for_file (*`GFile *file`*);
```
Creates a new [GtkPicture](gtkpicture#GtkPicture-struct) displaying the given *`file`* . If the file isn’t found or can’t be loaded, the resulting [GtkPicture](gtkpicture#GtkPicture-struct) be empty.
If you need to detect failures to load the file, use [`gdk_texture_new_from_file()`](https://developer-old.gnome.org/gtk4/html/gdk4-Textures.html#gdk-texture-new-from-file) to load the file yourself, then create the [GtkPicture](gtkpicture#GtkPicture-struct) from the texture.
#### Parameters
| | | |
| --- | --- | --- |
| file | a GFile. | [nullable] |
#### Returns
a new [GtkPicture](gtkpicture#GtkPicture-struct)
### gtk\_picture\_new\_for\_filename ()
```
[GtkWidget](gtkwidget#GtkWidget-struct) *
gtk_picture_new_for_filename (*`const char *filename`*);
```
Creates a new [GtkPicture](gtkpicture#GtkPicture-struct) displaying the file *`filename`* .
This is a utility function that calls [`gtk_picture_new_for_file()`](gtkpicture#gtk-picture-new-for-file). See that function for details.
#### Parameters
| | | |
| --- | --- | --- |
| filename | a filename. | [type filename][nullable] |
#### Returns
a new [GtkPicture](gtkpicture#GtkPicture-struct)
### gtk\_picture\_new\_for\_resource ()
```
[GtkWidget](gtkwidget#GtkWidget-struct) *
gtk_picture_new_for_resource (*`const char *resource_path`*);
```
Creates a new [GtkPicture](gtkpicture#GtkPicture-struct) displaying the resource at *`resource_path`* .
This is a utility function that calls [`gtk_picture_new_for_file()`](gtkpicture#gtk-picture-new-for-file). See that function for details.
#### Parameters
| | | |
| --- | --- | --- |
| resource\_path | resource path to play back. | [nullable] |
#### Returns
a new [GtkPicture](gtkpicture#GtkPicture-struct)
### gtk\_picture\_set\_paintable ()
```
void
gtk_picture_set_paintable (*`[GtkPicture](gtkpicture#GtkPicture-struct) *self`*,
*`[GdkPaintable](https://developer-old.gnome.org/gtk4/html/GdkPaintable.html#GdkPaintable-struct) *paintable`*);
```
Makes *`self`* display the given *`paintable`* . If *`paintable`* is `NULL`, nothing will be displayed.
See [`gtk_picture_new_for_paintable()`](gtkpicture#gtk-picture-new-for-paintable) for details.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkPicture](gtkpicture#GtkPicture-struct) | |
| paintable | a [GdkPaintable](https://developer-old.gnome.org/gtk4/html/GdkPaintable.html#GdkPaintable-struct) or `NULL`. | [nullable] |
### gtk\_picture\_get\_paintable ()
```
[GdkPaintable](https://developer-old.gnome.org/gtk4/html/GdkPaintable.html#GdkPaintable-struct) *
gtk_picture_get_paintable (*`[GtkPicture](gtkpicture#GtkPicture-struct) *self`*);
```
Gets the [GdkPaintable](https://developer-old.gnome.org/gtk4/html/GdkPaintable.html#GdkPaintable-struct) being displayed by the [GtkPicture](gtkpicture#GtkPicture-struct).
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkPicture](gtkpicture#GtkPicture-struct) | |
#### Returns
the displayed paintable, or `NULL` if the picture is empty.
[nullable][transfer none]
### gtk\_picture\_set\_pixbuf ()
```
void
gtk_picture_set_pixbuf (*`[GtkPicture](gtkpicture#GtkPicture-struct) *self`*,
*`[GdkPixbuf](https://developer-old.gnome.org/gdk-pixbuf/stable/gdk-pixbuf-The-GdkPixbuf-Structure.html#GdkPixbuf-struct) *pixbuf`*);
```
See [`gtk_picture_new_for_pixbuf()`](gtkpicture#gtk-picture-new-for-pixbuf) for details.
This is a utility function that calls [`gtk_picture_set_paintable()`](gtkpicture#gtk-picture-set-paintable),
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkPicture](gtkpicture#GtkPicture-struct) | |
| pixbuf | a [GdkPixbuf](https://developer-old.gnome.org/gdk-pixbuf/stable/gdk-pixbuf-The-GdkPixbuf-Structure.html#GdkPixbuf-struct) or `NULL`. | [nullable] |
### gtk\_picture\_set\_file ()
```
void
gtk_picture_set_file (*`[GtkPicture](gtkpicture#GtkPicture-struct) *self`*,
*`GFile *file`*);
```
Makes *`self`* load and display *`file`* .
See [`gtk_picture_new_for_file()`](gtkpicture#gtk-picture-new-for-file) for details.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkPicture](gtkpicture#GtkPicture-struct) | |
| file | a `GFile` or `NULL`. | [nullable] |
### gtk\_picture\_get\_file ()
```
GFile *
gtk_picture_get_file (*`[GtkPicture](gtkpicture#GtkPicture-struct) *self`*);
```
Gets the GFile currently displayed if *`self`* is displaying a file. If *`self`* is not displaying a file, for example when [`gtk_picture_set_paintable()`](gtkpicture#gtk-picture-set-paintable) was used, then `NULL` is returned.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkPicture](gtkpicture#GtkPicture-struct) | |
#### Returns
The GFile displayed by *`self`* .
[nullable][transfer none]
### gtk\_picture\_set\_filename ()
```
void
gtk_picture_set_filename (*`[GtkPicture](gtkpicture#GtkPicture-struct) *self`*,
*`const char *filename`*);
```
Makes *`self`* load and display the given *`filename`* .
This is a utility function that calls [`gtk_picture_set_file()`](gtkpicture#gtk-picture-set-file).
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkPicture](gtkpicture#GtkPicture-struct) | |
| filename | the filename to play. | [nullable] |
### gtk\_picture\_set\_resource ()
```
void
gtk_picture_set_resource (*`[GtkPicture](gtkpicture#GtkPicture-struct) *self`*,
*`const char *resource_path`*);
```
Makes *`self`* load and display the resource at the given *`resource_path`* .
This is a utility function that calls [`gtk_picture_set_file()`](gtkpicture#gtk-picture-set-file),
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkPicture](gtkpicture#GtkPicture-struct) | |
| resource\_path | the resource to set. | [nullable] |
### gtk\_picture\_set\_keep\_aspect\_ratio ()
```
void
gtk_picture_set_keep_aspect_ratio (*`[GtkPicture](gtkpicture#GtkPicture-struct) *self`*,
*`gboolean keep_aspect_ratio`*);
```
If set to `TRUE`, the *`self`* will render its contents according to their aspect ratio. That means that empty space may show up at the top/bottom or left/right of *`self`* .
If set to `FALSE` or if the contents provide no aspect ratio, the contents will be stretched over the picture's whole area.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkPicture](gtkpicture#GtkPicture-struct) | |
| keep\_aspect\_ratio | whether to keep aspect ratio | |
### gtk\_picture\_get\_keep\_aspect\_ratio ()
```
gboolean
gtk_picture_get_keep_aspect_ratio (*`[GtkPicture](gtkpicture#GtkPicture-struct) *self`*);
```
Gets the value set via [`gtk_picture_set_keep_aspect_ratio()`](gtkpicture#gtk-picture-set-keep-aspect-ratio).
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkPicture](gtkpicture#GtkPicture-struct) | |
#### Returns
`TRUE` if the self tries to keep the contents' aspect ratio
### gtk\_picture\_set\_can\_shrink ()
```
void
gtk_picture_set_can_shrink (*`[GtkPicture](gtkpicture#GtkPicture-struct) *self`*,
*`gboolean can_shrink`*);
```
If set to `TRUE`, the *`self`* can be made smaller than its contents. The contents will then be scaled down when rendering.
If you want to still force a minimum size manually, consider using [`gtk_widget_set_size_request()`](gtkwidget#gtk-widget-set-size-request).
Also of note is that a similar function for growing does not exist because the grow behavior can be controlled via [`gtk_widget_set_halign()`](gtkwidget#gtk-widget-set-halign) and [`gtk_widget_set_valign()`](gtkwidget#gtk-widget-set-valign).
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkPicture](gtkpicture#GtkPicture-struct) | |
| can\_shrink | if *`self`* can be made smaller than its contents | |
### gtk\_picture\_get\_can\_shrink ()
```
gboolean
gtk_picture_get_can_shrink (*`[GtkPicture](gtkpicture#GtkPicture-struct) *self`*);
```
Gets the value set via [`gtk_picture_set_can_shrink()`](gtkpicture#gtk-picture-set-can-shrink).
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkPicture](gtkpicture#GtkPicture-struct) | |
#### Returns
`TRUE` if the picture can be made smaller than its contents
### gtk\_picture\_set\_alternative\_text ()
```
void
gtk_picture_set_alternative_text (*`[GtkPicture](gtkpicture#GtkPicture-struct) *self`*,
*`const char *alternative_text`*);
```
Sets an alternative textual description for the picture contents. It is equivalent to the "alt" attribute for images on websites.
This text will be made available to accessibility tools.
If the picture cannot be described textually, set this property to `NULL`.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkPicture](gtkpicture#GtkPicture-struct) | |
| alternative\_text | a textual description of the contents. | [nullable] |
### gtk\_picture\_get\_alternative\_text ()
```
const char *
gtk_picture_get_alternative_text (*`[GtkPicture](gtkpicture#GtkPicture-struct) *self`*);
```
Gets the alternative textual description of the picture or returns `NULL` if the picture cannot be described textually.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkPicture](gtkpicture#GtkPicture-struct) | |
#### Returns
the alternative textual description of *`self`* .
[nullable][transfer none]
Types and Values
----------------
### GtkPicture
```
typedef struct _GtkPicture GtkPicture;
```
Property Details
----------------
### The `“alternative-text”` property
```
“alternative-text” char *
```
The alternative textual description for the picture.
Owner: GtkPicture
Flags: Read / Write
Default value: NULL
### The `“can-shrink”` property
```
“can-shrink” gboolean
```
If the [GtkPicture](gtkpicture#GtkPicture-struct) can be made smaller than the self it contains.
Owner: GtkPicture
Flags: Read / Write
Default value: TRUE
### The `“file”` property
```
“file” GFile *
```
The GFile that is displayed or `NULL` if none.
Owner: GtkPicture
Flags: Read / Write
### The `“keep-aspect-ratio”` property
```
“keep-aspect-ratio” gboolean
```
Whether the GtkPicture will render its contents trying to preserve the aspect ratio of the contents.
Owner: GtkPicture
Flags: Read / Write
Default value: TRUE
### The `“paintable”` property
```
“paintable” [GdkPaintable](https://developer-old.gnome.org/gtk4/html/GdkPaintable.html#GdkPaintable-struct) *
```
The [GdkPaintable](https://developer-old.gnome.org/gtk4/html/GdkPaintable.html#GdkPaintable-struct) to be displayed by this [GtkPicture](gtkpicture#GtkPicture-struct).
Owner: GtkPicture
Flags: Read / Write
| programming_docs |
gtk GtkOrientable GtkOrientable
=============
GtkOrientable — An interface for flippable widgets
Functions
---------
| | |
| --- | --- |
| [GtkOrientation](gtk4-standard-enumerations#GtkOrientation) | [gtk\_orientable\_get\_orientation](gtk4-orientable#gtk-orientable-get-orientation) () |
| void | [gtk\_orientable\_set\_orientation](gtk4-orientable#gtk-orientable-set-orientation) () |
Properties
----------
| | | |
| --- | --- | --- |
| [GtkOrientation](gtk4-standard-enumerations#GtkOrientation) | [orientation](gtk4-orientable#GtkOrientable--orientation) | Read / Write |
Types and Values
----------------
| | |
| --- | --- |
| | [GtkOrientable](gtk4-orientable#GtkOrientable-struct) |
Object Hierarchy
----------------
```
[GInterface](https://developer-old.gnome.org/gobject/stable/GTypeModule.html)
╰── GtkOrientable
```
Prerequisites
-------------
GtkOrientable requires GObject.
Known Implementations
---------------------
GtkOrientable is implemented by [GtkBox](gtkbox#GtkBox-struct), [GtkBoxLayout](gtkboxlayout#GtkBoxLayout-struct), [GtkCellAreaBox](gtkcellareabox#GtkCellAreaBox-struct), [GtkCellRendererProgress](gtkcellrendererprogress#GtkCellRendererProgress-struct), [GtkCellView](gtkcellview#GtkCellView-struct), [GtkCenterBox](https://developer-old.gnome.org/usr/share/gtk-doc/html/gtk4/gtk4-GtkCenterBox.html#GtkCenterBox), [GtkFlowBox](gtkflowbox#GtkFlowBox-struct), [GtkGrid](gtkgrid#GtkGrid-struct), [GtkGridView](gtkgridview#GtkGridView-struct), [GtkLevelBar](gtklevelbar#GtkLevelBar-struct), [GtkListView](gtklistview#GtkListView-struct), [GtkPaned](gtkpaned#GtkPaned-struct), [GtkProgressBar](gtkprogressbar#GtkProgressBar-struct), [GtkRange](gtkrange#GtkRange-struct), [GtkScale](gtkscale#GtkScale-struct), [GtkScaleButton](gtkscalebutton#GtkScaleButton-struct), [GtkScrollbar](gtkscrollbar#GtkScrollbar-struct), [GtkSeparator](gtkseparator#GtkSeparator-struct), [GtkShortcutsGroup](gtkshortcutsgroup#GtkShortcutsGroup-struct), [GtkShortcutsSection](gtkshortcutssection#GtkShortcutsSection-struct), [GtkSpinButton](gtkspinbutton#GtkSpinButton-struct) and [GtkVolumeButton](gtkvolumebutton#GtkVolumeButton-struct).
Includes
--------
```
#include <gtk/gtk.h>
```
Description
-----------
The [GtkOrientable](gtk4-orientable#GtkOrientable-struct) interface is implemented by all widgets that can be oriented horizontally or vertically. [GtkOrientable](gtk4-orientable#GtkOrientable-struct) is more flexible in that it allows the orientation to be changed at runtime, allowing the widgets to “flip”.
Functions
---------
### gtk\_orientable\_get\_orientation ()
```
[GtkOrientation](gtk4-standard-enumerations#GtkOrientation)
gtk_orientable_get_orientation (*`[GtkOrientable](gtk4-orientable#GtkOrientable-struct) *orientable`*);
```
Retrieves the orientation of the *`orientable`* .
#### Parameters
| | | |
| --- | --- | --- |
| orientable | a [GtkOrientable](gtk4-orientable#GtkOrientable-struct) | |
#### Returns
the orientation of the *`orientable`* .
### gtk\_orientable\_set\_orientation ()
```
void
gtk_orientable_set_orientation (*`[GtkOrientable](gtk4-orientable#GtkOrientable-struct) *orientable`*,
*`[GtkOrientation](gtk4-standard-enumerations#GtkOrientation) orientation`*);
```
Sets the orientation of the *`orientable`* .
#### Parameters
| | | |
| --- | --- | --- |
| orientable | a [GtkOrientable](gtk4-orientable#GtkOrientable-struct) | |
| orientation | the orientable’s new orientation. | |
Types and Values
----------------
### GtkOrientable
```
typedef struct _GtkOrientable GtkOrientable;
```
Property Details
----------------
### The `“orientation”` property
```
“orientation” [GtkOrientation](gtk4-standard-enumerations#GtkOrientation)
```
The orientation of the orientable.
Owner: GtkOrientable
Flags: Read / Write
Default value: GTK\_ORIENTATION\_HORIZONTAL
gtk GtkWindowGroup GtkWindowGroup
==============
GtkWindowGroup — Limit the effect of grabs
Functions
---------
| | |
| --- | --- |
| [GtkWindowGroup](gtkwindowgroup#GtkWindowGroup-struct) \* | [gtk\_window\_group\_new](gtkwindowgroup#gtk-window-group-new) () |
| void | [gtk\_window\_group\_add\_window](gtkwindowgroup#gtk-window-group-add-window) () |
| void | [gtk\_window\_group\_remove\_window](gtkwindowgroup#gtk-window-group-remove-window) () |
| GList \* | [gtk\_window\_group\_list\_windows](gtkwindowgroup#gtk-window-group-list-windows) () |
Types and Values
----------------
| | |
| --- | --- |
| | [GtkWindowGroup](gtkwindowgroup#GtkWindowGroup-struct) |
Object Hierarchy
----------------
```
GObject
╰── GtkWindowGroup
```
Includes
--------
```
#include <gtk/gtk.h>
```
Description
-----------
A [GtkWindowGroup](gtkwindowgroup#GtkWindowGroup-struct) restricts the effect of grabs to windows in the same group, thereby making window groups almost behave like separate applications.
A window can be a member in at most one window group at a time. Windows that have not been explicitly assigned to a group are implicitly treated like windows of the default window group.
GtkWindowGroup objects are referenced by each window in the group, so once you have added all windows to a GtkWindowGroup, you can drop the initial reference to the window group with `g_object_unref()`. If the windows in the window group are subsequently destroyed, then they will be removed from the window group and drop their references on the window group; when all window have been removed, the window group will be freed.
Functions
---------
### gtk\_window\_group\_new ()
```
[GtkWindowGroup](gtkwindowgroup#GtkWindowGroup-struct) *
gtk_window_group_new (*`void`*);
```
Creates a new [GtkWindowGroup](gtkwindowgroup#GtkWindowGroup-struct) object.
Modality of windows only affects windows within the same [GtkWindowGroup](gtkwindowgroup#GtkWindowGroup-struct).
#### Returns
a new [GtkWindowGroup](gtkwindowgroup#GtkWindowGroup-struct).
### gtk\_window\_group\_add\_window ()
```
void
gtk_window_group_add_window (*`[GtkWindowGroup](gtkwindowgroup#GtkWindowGroup-struct) *window_group`*,
*`[GtkWindow](gtkwindow#GtkWindow-struct) *window`*);
```
Adds a window to a [GtkWindowGroup](gtkwindowgroup#GtkWindowGroup-struct).
#### Parameters
| | | |
| --- | --- | --- |
| window\_group | a [GtkWindowGroup](gtkwindowgroup#GtkWindowGroup-struct) | |
| window | the [GtkWindow](gtkwindow#GtkWindow-struct) to add | |
### gtk\_window\_group\_remove\_window ()
```
void
gtk_window_group_remove_window (*`[GtkWindowGroup](gtkwindowgroup#GtkWindowGroup-struct) *window_group`*,
*`[GtkWindow](gtkwindow#GtkWindow-struct) *window`*);
```
Removes a window from a [GtkWindowGroup](gtkwindowgroup#GtkWindowGroup-struct).
#### Parameters
| | | |
| --- | --- | --- |
| window\_group | a [GtkWindowGroup](gtkwindowgroup#GtkWindowGroup-struct) | |
| window | the [GtkWindow](gtkwindow#GtkWindow-struct) to remove | |
### gtk\_window\_group\_list\_windows ()
```
GList *
gtk_window_group_list_windows (*`[GtkWindowGroup](gtkwindowgroup#GtkWindowGroup-struct) *window_group`*);
```
Returns a list of the [GtkWindows](gtkwindow#GtkWindow-struct) that belong to *`window_group`* .
#### Parameters
| | | |
| --- | --- | --- |
| window\_group | a [GtkWindowGroup](gtkwindowgroup#GtkWindowGroup-struct) | |
#### Returns
A newly-allocated list of windows inside the group.
[element-type GtkWindow][transfer container]
Types and Values
----------------
### GtkWindowGroup
```
typedef struct _GtkWindowGroup GtkWindowGroup;
```
gtk GtkShortcutController GtkShortcutController
=====================
GtkShortcutController — Event controller for shortcuts
Functions
---------
| | |
| --- | --- |
| [GtkEventController](gtkeventcontroller#GtkEventController-struct) \* | [gtk\_shortcut\_controller\_new](gtkshortcutcontroller#gtk-shortcut-controller-new) () |
| [GtkEventController](gtkeventcontroller#GtkEventController-struct) \* | [gtk\_shortcut\_controller\_new\_for\_model](gtkshortcutcontroller#gtk-shortcut-controller-new-for-model) () |
| void | [gtk\_shortcut\_controller\_set\_mnemonics\_modifiers](gtkshortcutcontroller#gtk-shortcut-controller-set-mnemonics-modifiers) () |
| [GdkModifierType](https://developer-old.gnome.org/gtk4/html/GdkSurface.html#GdkModifierType) | [gtk\_shortcut\_controller\_get\_mnemonics\_modifiers](gtkshortcutcontroller#gtk-shortcut-controller-get-mnemonics-modifiers) () |
| void | [gtk\_shortcut\_controller\_set\_scope](gtkshortcutcontroller#gtk-shortcut-controller-set-scope) () |
| [GtkShortcutScope](gtkshortcutcontroller#GtkShortcutScope) | [gtk\_shortcut\_controller\_get\_scope](gtkshortcutcontroller#gtk-shortcut-controller-get-scope) () |
| void | [gtk\_shortcut\_controller\_add\_shortcut](gtkshortcutcontroller#gtk-shortcut-controller-add-shortcut) () |
| void | [gtk\_shortcut\_controller\_remove\_shortcut](gtkshortcutcontroller#gtk-shortcut-controller-remove-shortcut) () |
Properties
----------
| | | |
| --- | --- | --- |
| [GdkModifierType](https://developer-old.gnome.org/gtk4/html/GdkSurface.html#GdkModifierType) | [mnemonic-modifiers](gtkshortcutcontroller#GtkShortcutController--mnemonic-modifiers) | Read / Write |
| GListModel \* | [model](gtkshortcutcontroller#GtkShortcutController--model) | Write / Construct Only |
| [GtkShortcutScope](gtkshortcutcontroller#GtkShortcutScope) | [scope](gtkshortcutcontroller#GtkShortcutController--scope) | Read / Write |
Types and Values
----------------
| | |
| --- | --- |
| | [GtkShortcutController](gtkshortcutcontroller#GtkShortcutController-struct) |
| enum | [GtkShortcutScope](gtkshortcutcontroller#GtkShortcutScope) |
| | [GtkShortcutManager](gtkshortcutmanager#GtkShortcutManager-struct) |
| struct | [GtkShortcutManagerInterface](gtkshortcutmanager#GtkShortcutManagerInterface) |
Object Hierarchy
----------------
```
[GInterface](https://developer-old.gnome.org/gobject/stable/GTypeModule.html)
╰── GtkShortcutManager
GObject
╰── [GtkEventController](gtkeventcontroller#GtkEventController-struct)
╰── GtkShortcutController
```
Prerequisites
-------------
GtkShortcutManager requires GObject.
Implemented Interfaces
----------------------
GtkShortcutController implements GListModel and [GtkBuildable](gtkbuildable#GtkBuildable-struct).
Known Implementations
---------------------
GtkShortcutManager is implemented by [GtkAboutDialog](gtkaboutdialog#GtkAboutDialog-struct), [GtkAppChooserDialog](gtkappchooserdialog#GtkAppChooserDialog-struct), [GtkApplicationWindow](gtkapplicationwindow#GtkApplicationWindow-struct), [GtkAssistant](gtkassistant#GtkAssistant-struct), [GtkColorChooserDialog](gtkcolorchooserdialog#GtkColorChooserDialog-struct), [GtkDialog](gtkdialog#GtkDialog-struct), [GtkEmojiChooser](gtkemojichooser#GtkEmojiChooser-struct), [GtkFileChooserDialog](gtkfilechooserdialog#GtkFileChooserDialog-struct), [GtkFontChooserDialog](gtkfontchooserdialog#GtkFontChooserDialog-struct), [GtkMessageDialog](gtkmessagedialog#GtkMessageDialog-struct), [GtkPageSetupUnixDialog](gtkpagesetupunixdialog#GtkPageSetupUnixDialog-struct), [GtkPopover](gtkpopover#GtkPopover-struct), [GtkPopoverMenu](gtkpopovermenu#GtkPopoverMenu-struct), [GtkPrintUnixDialog](gtkprintunixdialog#GtkPrintUnixDialog-struct), [GtkShortcutsWindow](gtkshortcutswindow#GtkShortcutsWindow-struct) and [GtkWindow](gtkwindow#GtkWindow-struct).
Includes
--------
```
#include <gtk/gtk.h>
```
Description
-----------
[GtkShortcutController](gtkshortcutcontroller#GtkShortcutController-struct) is an event controller that manages shortcuts.
Most common shortcuts are using this controller implicitly, e.g. by adding a mnemonic underline to a [GtkLabel](gtklabel#GtkLabel-struct), or by installing a key binding using [`gtk_widget_class_add_binding()`](gtkwidget#gtk-widget-class-add-binding), or by adding accelerators to global actions using [`gtk_application_set_accels_for_action()`](gtkapplication#gtk-application-set-accels-for-action).
But it is possible to create your own shortcut controller, and add shortcuts to it.
[GtkShortcutController](gtkshortcutcontroller#GtkShortcutController-struct) implements GListModel for querying the shortcuts that have been added to it.
### GtkShortcutController as a GtkBuildable
GtkShortcutControllers can be creates in ui files to set up shortcuts in the same place as the widgets.
An example of a UI definition fragment with GtkShortcutController:
```
<object class='GtkButton'>
<child>
<object class='GtkShortcutController'>
<property name='scope'>managed</property>
<child>
<object class='GtkShortcut'>
<property name='trigger'><Control>k</property>
<property name='action'>activate</property>
</object>
</child>
</object>
</child>
</object>
```
| This example creates a [GtkActivateAction](gtkshortcutaction#GtkActivateAction) for triggering the `activate` signal of the GtkButton. See [`gtk_shortcut_action_parse_string()`](gtkshortcutaction#gtk-shortcut-action-parse-string) for the syntax for other kinds of [GtkShortcutAction](gtkshortcutaction#GtkShortcutAction-struct). See [`gtk_shortcut_trigger_parse_string()`](gtkshortcuttrigger#gtk-shortcut-trigger-parse-string) to learn more about the syntax for triggers.
Functions
---------
### gtk\_shortcut\_controller\_new ()
```
[GtkEventController](gtkeventcontroller#GtkEventController-struct) *
gtk_shortcut_controller_new (*`void`*);
```
Creates a new shortcut controller.
#### Returns
a newly created shortcut controller
### gtk\_shortcut\_controller\_new\_for\_model ()
```
[GtkEventController](gtkeventcontroller#GtkEventController-struct) *
gtk_shortcut_controller_new_for_model (*`GListModel *model`*);
```
Creates a new shortcut controller that takes its shortcuts from the given list model.
A controller created by this function does not let you add or remove individual shortcuts using the shortcut controller api, but you can change the contents of the model.
#### Parameters
| | | |
| --- | --- | --- |
| model | a GListModel containing shortcuts | |
#### Returns
a newly created shortcut controller
### gtk\_shortcut\_controller\_set\_mnemonics\_modifiers ()
```
void
gtk_shortcut_controller_set_mnemonics_modifiers
(*`[GtkShortcutController](gtkshortcutcontroller#GtkShortcutController-struct) *self`*,
*`[GdkModifierType](https://developer-old.gnome.org/gtk4/html/GdkSurface.html#GdkModifierType) modifiers`*);
```
Sets the controller to have the given *`mnemonics_modifiers`* .
The mnemonics modifiers determines which modifiers need to be pressed to allow activation of shortcuts with mnemonics triggers.
GTK normally uses the Alt modifier for mnemonics, except in [GtkPopoverMenus](gtkpopovermenu#GtkPopoverMenu-struct), where mnemonics can be triggered without any modifiers. It should be very rarely necessary to change this, and doing so is likely to interfere with other shortcuts.
This value is only relevant for local shortcut controllers. Global and managed shortcut controllers will have their shortcuts activated from other places which have their own modifiers for activating mnemonics.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkShortcutController](gtkshortcutcontroller#GtkShortcutController-struct) | |
| modifiers | the new mnemonics\_modifiers to use | |
### gtk\_shortcut\_controller\_get\_mnemonics\_modifiers ()
```
[GdkModifierType](https://developer-old.gnome.org/gtk4/html/GdkSurface.html#GdkModifierType)
gtk_shortcut_controller_get_mnemonics_modifiers
(*`[GtkShortcutController](gtkshortcutcontroller#GtkShortcutController-struct) *self`*);
```
Gets the mnemonics modifiers for when this controller activates its shortcuts. See [`gtk_shortcut_controller_set_mnemonics_modifiers()`](gtkshortcutcontroller#gtk-shortcut-controller-set-mnemonics-modifiers) for details.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkShortcutController](gtkshortcutcontroller#GtkShortcutController-struct) | |
#### Returns
the controller's mnemonics modifiers
### gtk\_shortcut\_controller\_set\_scope ()
```
void
gtk_shortcut_controller_set_scope (*`[GtkShortcutController](gtkshortcutcontroller#GtkShortcutController-struct) *self`*,
*`[GtkShortcutScope](gtkshortcutcontroller#GtkShortcutScope) scope`*);
```
Sets the controller to have the given *`scope`* .
The scope allows shortcuts to be activated outside of the normal event propagation. In particular, it allows installing global keyboard shortcuts that can be activated even when a widget does not have focus.
With [`GTK_SHORTCUT_SCOPE_LOCAL`](gtkshortcutcontroller#GTK-SHORTCUT-SCOPE-LOCAL:CAPS), shortcuts will only be activated when the widget has focus.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkShortcutController](gtkshortcutcontroller#GtkShortcutController-struct) | |
| scope | the new scope to use | |
### gtk\_shortcut\_controller\_get\_scope ()
```
[GtkShortcutScope](gtkshortcutcontroller#GtkShortcutScope)
gtk_shortcut_controller_get_scope (*`[GtkShortcutController](gtkshortcutcontroller#GtkShortcutController-struct) *self`*);
```
Gets the scope for when this controller activates its shortcuts. See [`gtk_shortcut_controller_set_scope()`](gtkshortcutcontroller#gtk-shortcut-controller-set-scope) for details.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkShortcutController](gtkshortcutcontroller#GtkShortcutController-struct) | |
#### Returns
the controller's scope
### gtk\_shortcut\_controller\_add\_shortcut ()
```
void
gtk_shortcut_controller_add_shortcut (*`[GtkShortcutController](gtkshortcutcontroller#GtkShortcutController-struct) *self`*,
*`[GtkShortcut](gtkshortcut#GtkShortcut-struct) *shortcut`*);
```
Adds *`shortcut`* to the list of shortcuts handled by *`self`* .
If this controller uses an external shortcut list, this function does nothing.
#### Parameters
| | | |
| --- | --- | --- |
| self | the controller | |
| shortcut | a [GtkShortcut](gtkshortcut#GtkShortcut-struct). | [transfer full] |
### gtk\_shortcut\_controller\_remove\_shortcut ()
```
void
gtk_shortcut_controller_remove_shortcut
(*`[GtkShortcutController](gtkshortcutcontroller#GtkShortcutController-struct) *self`*,
*`[GtkShortcut](gtkshortcut#GtkShortcut-struct) *shortcut`*);
```
Removes *`shortcut`* from the list of shortcuts handled by *`self`* .
If *`shortcut`* had not been added to *`controller`* or this controller uses an external shortcut list, this function does nothing.
#### Parameters
| | | |
| --- | --- | --- |
| self | the controller | |
| shortcut | a [GtkShortcut](gtkshortcut#GtkShortcut-struct) | |
Types and Values
----------------
### GtkShortcutController
```
typedef struct _GtkShortcutController GtkShortcutController;
```
### enum GtkShortcutScope
Describes where [GtkShortcuts](gtkshortcut#GtkShortcut-struct) added to a [GtkShortcutController](gtkshortcutcontroller#GtkShortcutController-struct) get handled.
#### Members
| | | |
| --- | --- | --- |
| GTK\_SHORTCUT\_SCOPE\_LOCAL | Shortcuts are handled inside the widget the controller belongs to. | |
| GTK\_SHORTCUT\_SCOPE\_MANAGED | Shortcuts are handled by the first ancestor that is a [GtkShortcutManager](gtkshortcutmanager#GtkShortcutManager-struct) | |
| GTK\_SHORTCUT\_SCOPE\_GLOBAL | Shortcuts are handled by the root widget. | |
### GtkShortcutManager
```
typedef struct _GtkShortcutManager GtkShortcutManager;
```
This object is used to implement support for GtkShortcutScopes. Every widget that implements [GtkShortcutManager](gtkshortcutmanager#GtkShortcutManager-struct) will be used as a [`GTK_SHORTCUT_SCOPE_MANAGED`](gtkshortcutcontroller#GTK-SHORTCUT-SCOPE-MANAGED:CAPS).
### struct GtkShortcutManagerInterface
```
struct GtkShortcutManagerInterface {
void (* add_controller) (GtkShortcutManager *self,
GtkShortcutController *controller);
void (* remove_controller) (GtkShortcutManager *self,
GtkShortcutController *controller);
};
```
The list of functions that can be implemented for the [GtkShortcutManager](gtkshortcutmanager#GtkShortcutManager-struct) interface.
Note that no function is mandatory to implement, the default implementation will work fine.
Property Details
----------------
### The `“mnemonic-modifiers”` property
```
“mnemonic-modifiers” [GdkModifierType](https://developer-old.gnome.org/gtk4/html/GdkSurface.html#GdkModifierType)
```
The modifiers that need to be pressed to allow mnemonics activation.
Owner: GtkShortcutController
Flags: Read / Write
Default value: GDK\_ALT\_MASK
### The `“model”` property
```
“model” GListModel *
```
A list model to take shortcuts from
Owner: GtkShortcutController
Flags: Write / Construct Only
### The `“scope”` property
```
“scope” [GtkShortcutScope](gtkshortcutcontroller#GtkShortcutScope)
```
What scope the shortcuts will be handled in.
Owner: GtkShortcutController
Flags: Read / Write
Default value: GTK\_SHORTCUT\_SCOPE\_LOCAL
See Also
--------
[GtkEventController](gtkeventcontroller#GtkEventController-struct), [GtkShortcut](gtkshortcut#GtkShortcut-struct)
| programming_docs |
gtk GtkGridView GtkGridView
===========
GtkGridView — A widget for displaying grids
Functions
---------
| | |
| --- | --- |
| [GtkWidget](gtkwidget#GtkWidget-struct) \* | [gtk\_grid\_view\_new](gtkgridview#gtk-grid-view-new) () |
| void | [gtk\_grid\_view\_set\_model](gtkgridview#gtk-grid-view-set-model) () |
| [GtkSelectionModel](gtkselectionmodel#GtkSelectionModel-struct) \* | [gtk\_grid\_view\_get\_model](gtkgridview#gtk-grid-view-get-model) () |
| void | [gtk\_grid\_view\_set\_max\_columns](gtkgridview#gtk-grid-view-set-max-columns) () |
| guint | [gtk\_grid\_view\_get\_max\_columns](gtkgridview#gtk-grid-view-get-max-columns) () |
| void | [gtk\_grid\_view\_set\_min\_columns](gtkgridview#gtk-grid-view-set-min-columns) () |
| guint | [gtk\_grid\_view\_get\_min\_columns](gtkgridview#gtk-grid-view-get-min-columns) () |
| void | [gtk\_grid\_view\_set\_single\_click\_activate](gtkgridview#gtk-grid-view-set-single-click-activate) () |
| gboolean | [gtk\_grid\_view\_get\_single\_click\_activate](gtkgridview#gtk-grid-view-get-single-click-activate) () |
| void | [gtk\_grid\_view\_set\_enable\_rubberband](gtkgridview#gtk-grid-view-set-enable-rubberband) () |
| gboolean | [gtk\_grid\_view\_get\_enable\_rubberband](gtkgridview#gtk-grid-view-get-enable-rubberband) () |
| void | [gtk\_grid\_view\_set\_factory](gtkgridview#gtk-grid-view-set-factory) () |
| [GtkListItemFactory](gtklistitemfactory#GtkListItemFactory-struct) \* | [gtk\_grid\_view\_get\_factory](gtkgridview#gtk-grid-view-get-factory) () |
Properties
----------
| | | |
| --- | --- | --- |
| gboolean | [enable-rubberband](gtkgridview#GtkGridView--enable-rubberband) | Read / Write |
| [GtkListItemFactory](gtklistitemfactory#GtkListItemFactory-struct) \* | [factory](gtkgridview#GtkGridView--factory) | Read / Write |
| guint | [max-columns](gtkgridview#GtkGridView--max-columns) | Read / Write |
| guint | [min-columns](gtkgridview#GtkGridView--min-columns) | Read / Write |
| [GtkSelectionModel](gtkselectionmodel#GtkSelectionModel-struct) \* | [model](gtkgridview#GtkGridView--model) | Read / Write |
| gboolean | [single-click-activate](gtkgridview#GtkGridView--single-click-activate) | Read / Write |
Signals
-------
| | | |
| --- | --- | --- |
| void | [activate](gtkgridview#GtkGridView-activate) | Run Last |
Actions
-------
| | | |
| --- | --- | --- |
| | list.activate-item | u |
Types and Values
----------------
| | |
| --- | --- |
| | [GtkGridView](gtkgridview#GtkGridView-struct) |
Object Hierarchy
----------------
```
GObject
╰── GInitiallyUnowned
╰── [GtkWidget](gtkwidget#GtkWidget-struct)
╰── GtkListBase
╰── GtkGridView
```
Implemented Interfaces
----------------------
GtkGridView implements [GtkAccessible](gtkaccessible#GtkAccessible-struct), [GtkBuildable](gtkbuildable#GtkBuildable-struct), [GtkConstraintTarget](gtkconstraint#GtkConstraintTarget-struct), [GtkOrientable](gtk4-orientable#GtkOrientable-struct) and [GtkScrollable](gtkscrollable#GtkScrollable-struct).
Includes
--------
```
#include <gtk/gtk.h>
```
Description
-----------
GtkGridView is a widget to present a view into a large dynamic grid of items.
GtkGridView uses its factory to generate one child widget for each visible item and shows them in a grid. The orientation of the grid view determines if the grid reflows vertically or horizontally.
GtkGridView allows the user to select items according to the selection characteristics of the model. For models that allow multiple selected items, it is possible to turn on \_rubberband selection\_, using [“enable-rubberband”](gtkgridview#GtkGridView--enable-rubberband).
To learn more about the list widget framework, see the [overview](#ListWidget).
### CSS nodes
```
gridview
├── child
│
├── child
│
┊
╰── [rubberband]
```
| GtkGridView uses a single CSS node with name gridview. Each child uses a single CSS node with name child. For rubberband selection, a subnode with name rubberband is used.
### Accessibility
GtkGridView uses the [GTK\_ACCESSIBLE\_ROLE\_GRID](gtkaccessible#GTK-ACCESSIBLE-ROLE-GRID:CAPS) role, and the items use the [GTK\_ACCESSIBLE\_ROLE\_GRID\_CELL](gtkaccessible#GTK-ACCESSIBLE-ROLE-GRID-CELL:CAPS) role.
Functions
---------
### gtk\_grid\_view\_new ()
```
[GtkWidget](gtkwidget#GtkWidget-struct) *
gtk_grid_view_new (*`[GtkSelectionModel](gtkselectionmodel#GtkSelectionModel-struct) *model`*,
*`[GtkListItemFactory](gtklistitemfactory#GtkListItemFactory-struct) *factory`*);
```
Creates a new [GtkGridView](gtkgridview#GtkGridView-struct) that uses the given *`factory`* for mapping items to widgets.
The function takes ownership of the arguments, so you can write code like `grid_view = gtk_grid_view_new (`create_model()`,
gtk_builder_list_item_factory_new_from_resource ("/resource.ui"));`
#### Parameters
| | | |
| --- | --- | --- |
| model | the model to use, or `NULL`. | [allow-none][transfer full] |
| factory | The factory to populate items with, or `NULL`. | [allow-none][transfer full] |
#### Returns
a new [GtkGridView](gtkgridview#GtkGridView-struct) using the given *`model`* and *`factory`*
### gtk\_grid\_view\_set\_model ()
```
void
gtk_grid_view_set_model (*`[GtkGridView](gtkgridview#GtkGridView-struct) *self`*,
*`[GtkSelectionModel](gtkselectionmodel#GtkSelectionModel-struct) *model`*);
```
Sets the [GtkSelectionModel](gtkselectionmodel#GtkSelectionModel-struct) to use for
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkGridView](gtkgridview#GtkGridView-struct) | |
| model | the model to use or `NULL` for none. | [allow-none][transfer none] |
### gtk\_grid\_view\_get\_model ()
```
[GtkSelectionModel](gtkselectionmodel#GtkSelectionModel-struct) *
gtk_grid_view_get_model (*`[GtkGridView](gtkgridview#GtkGridView-struct) *self`*);
```
Gets the model that's currently used to read the items displayed.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkGridView](gtkgridview#GtkGridView-struct) | |
#### Returns
The model in use.
[nullable][transfer none]
### gtk\_grid\_view\_set\_max\_columns ()
```
void
gtk_grid_view_set_max_columns (*`[GtkGridView](gtkgridview#GtkGridView-struct) *self`*,
*`guint max_columns`*);
```
Sets the maximum number of columns to use. This number must be at least 1.
If *`max_columns`* is smaller than the minimum set via [`gtk_grid_view_set_min_columns()`](gtkgridview#gtk-grid-view-set-min-columns), that value is used instead.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkGridView](gtkgridview#GtkGridView-struct) | |
| max\_columns | The maximum number of columns | |
### gtk\_grid\_view\_get\_max\_columns ()
```
guint
gtk_grid_view_get_max_columns (*`[GtkGridView](gtkgridview#GtkGridView-struct) *self`*);
```
Gets the maximum number of columns that the grid will use.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkGridView](gtkgridview#GtkGridView-struct) | |
#### Returns
The maximum number of columns
### gtk\_grid\_view\_set\_min\_columns ()
```
void
gtk_grid_view_set_min_columns (*`[GtkGridView](gtkgridview#GtkGridView-struct) *self`*,
*`guint min_columns`*);
```
Sets the minimum number of columns to use. This number must be at least 1.
If *`min_columns`* is smaller than the minimum set via [`gtk_grid_view_set_max_columns()`](gtkgridview#gtk-grid-view-set-max-columns), that value is ignored.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkGridView](gtkgridview#GtkGridView-struct) | |
| min\_columns | The minimum number of columns | |
### gtk\_grid\_view\_get\_min\_columns ()
```
guint
gtk_grid_view_get_min_columns (*`[GtkGridView](gtkgridview#GtkGridView-struct) *self`*);
```
Gets the minimum number of columns that the grid will use.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkGridView](gtkgridview#GtkGridView-struct) | |
#### Returns
The minimum number of columns
### gtk\_grid\_view\_set\_single\_click\_activate ()
```
void
gtk_grid_view_set_single_click_activate
(*`[GtkGridView](gtkgridview#GtkGridView-struct) *self`*,
*`gboolean single_click_activate`*);
```
Sets whether items should be activated on single click and selected on hover.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkGridView](gtkgridview#GtkGridView-struct) | |
| single\_click\_activate | `TRUE` to activate items on single click | |
### gtk\_grid\_view\_get\_single\_click\_activate ()
```
gboolean
gtk_grid_view_get_single_click_activate
(*`[GtkGridView](gtkgridview#GtkGridView-struct) *self`*);
```
Returns whether items will be activated on single click and selected on hover.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkListView](gtklistview#GtkListView-struct) | |
#### Returns
`TRUE` if items are activated on single click
### gtk\_grid\_view\_set\_enable\_rubberband ()
```
void
gtk_grid_view_set_enable_rubberband (*`[GtkGridView](gtkgridview#GtkGridView-struct) *self`*,
*`gboolean enable_rubberband`*);
```
Sets whether selections can be changed by dragging with the mouse.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkGridView](gtkgridview#GtkGridView-struct) | |
| enable\_rubberband | `TRUE` to enable rubberband selection | |
### gtk\_grid\_view\_get\_enable\_rubberband ()
```
gboolean
gtk_grid_view_get_enable_rubberband (*`[GtkGridView](gtkgridview#GtkGridView-struct) *self`*);
```
Returns whether rows can be selected by dragging with the mouse.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkGridView](gtkgridview#GtkGridView-struct) | |
#### Returns
`TRUE` if rubberband selection is enabled
### gtk\_grid\_view\_set\_factory ()
```
void
gtk_grid_view_set_factory (*`[GtkGridView](gtkgridview#GtkGridView-struct) *self`*,
*`[GtkListItemFactory](gtklistitemfactory#GtkListItemFactory-struct) *factory`*);
```
Sets the [GtkListItemFactory](gtklistitemfactory#GtkListItemFactory-struct) to use for populating list items.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkGridView](gtkgridview#GtkGridView-struct) | |
| factory | the factory to use or `NULL` for none. | [allow-none][transfer none] |
### gtk\_grid\_view\_get\_factory ()
```
[GtkListItemFactory](gtklistitemfactory#GtkListItemFactory-struct) *
gtk_grid_view_get_factory (*`[GtkGridView](gtkgridview#GtkGridView-struct) *self`*);
```
Gets the factory that's currently used to populate list items.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkGridView](gtkgridview#GtkGridView-struct) | |
#### Returns
The factory in use.
[nullable][transfer none]
Types and Values
----------------
### GtkGridView
```
typedef struct _GtkGridView GtkGridView;
```
GtkGridView is a list widget implementation that arranges its items in a grid.
Property Details
----------------
### The `“enable-rubberband”` property
```
“enable-rubberband” gboolean
```
Allow rubberband selection
Owner: GtkGridView
Flags: Read / Write
Default value: FALSE
### The `“factory”` property
```
“factory” [GtkListItemFactory](gtklistitemfactory#GtkListItemFactory-struct) *
```
Factory for populating list items
Owner: GtkGridView
Flags: Read / Write
### The `“max-columns”` property
```
“max-columns” guint
```
Maximum number of columns per row
If this number is smaller than GtkGridView:min-columns, that value is used instead.
Owner: GtkGridView
Flags: Read / Write
Allowed values: >= 1
Default value: 7
### The `“min-columns”` property
```
“min-columns” guint
```
Minimum number of columns per row
Owner: GtkGridView
Flags: Read / Write
Allowed values: >= 1
Default value: 1
### The `“model”` property
```
“model” [GtkSelectionModel](gtkselectionmodel#GtkSelectionModel-struct) *
```
Model for the items displayed
Owner: GtkGridView
Flags: Read / Write
### The `“single-click-activate”` property
```
“single-click-activate” gboolean
```
Activate rows on single click and select them on hover
Owner: GtkGridView
Flags: Read / Write
Default value: FALSE
Signal Details
--------------
### The `“activate”` signal
```
void
user_function ([GtkGridView](gtkgridview#GtkGridView-struct) *self,
guint position,
gpointer user_data)
```
The ::activate signal is emitted when a cell has been activated by the user, usually via activating the GtkGridView|list.activate-item action.
This allows for a convenient way to handle activation in a gridview. See GtkListItem:activatable for details on how to use this signal.
#### Parameters
| | | |
| --- | --- | --- |
| self | The [GtkGridView](gtkgridview#GtkGridView-struct) | |
| position | position of item to activate | |
| user\_data | user data set when the signal handler was connected. | |
Flags: Run Last
Action Details
--------------
### The `“list.activate-item”` action
Activates the item given in *`position`* by emitting the GtkGridView::activate signal.
Parameter type: u
#### Parameters
| | | |
| --- | --- | --- |
| position | position of item to activate | |
See Also
--------
[GtkSelectionModel](gtkselectionmodel#GtkSelectionModel-struct), [GtkListView](gtklistview#GtkListView-struct), [GtkColumnView](gtkcolumnview#GtkColumnView-struct)
gtk Custom Drawing Custom Drawing
==============
Many widgets, like buttons, do all their drawing themselves. You just tell them the label you want to see, and they figure out what font to use, draw the button outline and focus rectangle, etc. Sometimes, it is necessary to do some custom drawing. In that case, a GtkDrawingArea might be the right widget to use. It offers a canvas on which you can draw by connecting to the ::draw signal.
The contents of a widget often need to be partially or fully redrawn, e.g. when another window is moved and uncovers part of the widget, or when the window containing it is resized. It is also possible to explicitly cause part or all of the widget to be redrawn, by calling [`gtk_widget_queue_draw()`](gtkwidget#gtk-widget-queue-draw) or its variants. GTK takes care of most of the details by providing a ready-to-use cairo context to the ::draw signal handler.
The following example shows a ::draw signal handler. It is a bit more complicated than the previous examples, since it also demonstrates input event handling by means of event controllers.
**Figure 4. Drawing**
### Drawing in response to input
Create a new file with the following content named `example-4.c`.
```
#include <gtk/gtk.h>
/* Surface to store current scribbles */
static cairo_surface_t *surface = NULL;
static void
clear_surface (void)
{
cairo_t *cr;
cr = cairo_create (surface);
cairo_set_source_rgb (cr, 1, 1, 1);
cairo_paint (cr);
cairo_destroy (cr);
}
/* Create a new surface of the appropriate size to store our scribbles */
static void
resize_cb (GtkWidget *widget,
int width,
int height,
gpointer data)
{
if (surface)
{
cairo_surface_destroy (surface);
surface = NULL;
}
if (gtk_native_get_surface (gtk_widget_get_native (widget)))
{
surface = gdk_surface_create_similar_surface (gtk_native_get_surface (gtk_widget_get_native (widget)),
CAIRO_CONTENT_COLOR,
gtk_widget_get_width (widget),
gtk_widget_get_height (widget));
/* Initialize the surface to white */
clear_surface();
}
}
/* Redraw the screen from the surface. Note that the draw
* callback receives a ready-to-be-used cairo_t that is already
* clipped to only draw the exposed areas of the widget
*/
static void
draw_cb (GtkDrawingArea *drawing_area,
cairo_t *cr,
int width,
int height,
gpointer data)
{
cairo_set_source_surface (cr, surface, 0, 0);
cairo_paint (cr);
}
/* Draw a rectangle on the surface at the given position */
static void
draw_brush (GtkWidget *widget,
double x,
double y)
{
cairo_t *cr;
/* Paint to the surface, where we store our state */
cr = cairo_create (surface);
cairo_rectangle (cr, x - 3, y - 3, 6, 6);
cairo_fill (cr);
cairo_destroy (cr);
/* Now invalidate the drawing area. */
gtk_widget_queue_draw (widget);
}
static double start_x;
static double start_y;
static void
drag_begin (GtkGestureDrag *gesture,
double x,
double y,
GtkWidget *area)
{
start_x = x;
start_y = y;
draw_brush (area, x, y);
}
static void
drag_update (GtkGestureDrag *gesture,
double x,
double y,
GtkWidget *area)
{
draw_brush (area, start_x + x, start_y + y);
}
static void
drag_end (GtkGestureDrag *gesture,
double x,
double y,
GtkWidget *area)
{
draw_brush (area, start_x + x, start_y + y);
}
static void
pressed (GtkGestureClick *gesture,
int n_press,
double x,
double y,
GtkWidget *area)
{
clear_surface();
gtk_widget_queue_draw (area);
}
static void
close_window (void)
{
if (surface)
cairo_surface_destroy (surface);
}
static void
activate (GtkApplication *app,
gpointer user_data)
{
GtkWidget *window;
GtkWidget *frame;
GtkWidget *drawing_area;
GtkGesture *drag;
GtkGesture *press;
window = gtk_application_window_new (app);
gtk_window_set_title (GTK_WINDOW (window), "Drawing Area");
g_signal_connect (window, "destroy", G_CALLBACK (close_window), NULL);
frame = gtk_frame_new (NULL);
gtk_window_set_child (GTK_WINDOW (window), frame);
drawing_area = [`gtk_drawing_area_new()`](gtkdrawingarea#gtk-drawing-area-new);
/* set a minimum size */
gtk_widget_set_size_request (drawing_area, 100, 100);
gtk_frame_set_child (GTK_FRAME (frame), drawing_area);
gtk_drawing_area_set_draw_func (GTK_DRAWING_AREA (drawing_area), draw_cb, NULL, NULL);
g_signal_connect_after (drawing_area, "resize", G_CALLBACK (resize_cb), NULL);
drag = [`gtk_gesture_drag_new()`](gtkgesturedrag#gtk-gesture-drag-new);
gtk_gesture_single_set_button (GTK_GESTURE_SINGLE (drag), GDK_BUTTON_PRIMARY);
gtk_widget_add_controller (drawing_area, GTK_EVENT_CONTROLLER (drag));
g_signal_connect (drag, "drag-begin", G_CALLBACK (drag_begin), drawing_area);
g_signal_connect (drag, "drag-update", G_CALLBACK (drag_update), drawing_area);
g_signal_connect (drag, "drag-end", G_CALLBACK (drag_end), drawing_area);
press = [`gtk_gesture_click_new()`](gtkgestureclick#gtk-gesture-click-new);
gtk_gesture_single_set_button (GTK_GESTURE_SINGLE (press), GDK_BUTTON_SECONDARY);
gtk_widget_add_controller (drawing_area, GTK_EVENT_CONTROLLER (press));
g_signal_connect (press, "pressed", G_CALLBACK (pressed), drawing_area);
gtk_widget_show (window);
}
int
main (int argc,
char **argv)
{
GtkApplication *app;
int status;
app = gtk_application_new ("org.gtk.example", G_APPLICATION_FLAGS_NONE);
g_signal_connect (app, "activate", G_CALLBACK (activate), NULL);
status = g_application_run (G_APPLICATION (app), argc, argv);
g_object_unref (app);
return status;
}
```
You can compile the program above with GCC using:
```
gcc `pkg-config --cflags gtk4` -o example-4 example-4.c `pkg-config --libs gtk4`
```
| programming_docs |
gtk GtkMultiSorter GtkMultiSorter
==============
GtkMultiSorter — Combining multiple sorters
Functions
---------
| | |
| --- | --- |
| [GtkMultiSorter](gtkmultisorter#GtkMultiSorter-struct) \* | [gtk\_multi\_sorter\_new](gtkmultisorter#gtk-multi-sorter-new) () |
| void | [gtk\_multi\_sorter\_append](gtkmultisorter#gtk-multi-sorter-append) () |
| void | [gtk\_multi\_sorter\_remove](gtkmultisorter#gtk-multi-sorter-remove) () |
Types and Values
----------------
| | |
| --- | --- |
| | [GtkMultiSorter](gtkmultisorter#GtkMultiSorter-struct) |
Object Hierarchy
----------------
```
GObject
╰── [GtkSorter](gtksorter#GtkSorter-struct)
╰── GtkMultiSorter
```
Implemented Interfaces
----------------------
GtkMultiSorter implements GListModel and [GtkBuildable](gtkbuildable#GtkBuildable-struct).
Includes
--------
```
#include <gtk/gtk.h>
```
Description
-----------
GtkMultiSorter combines multiple sorters by trying them in turn. If the first sorter compares two items as equal, the second is tried next, and so on.
Functions
---------
### gtk\_multi\_sorter\_new ()
```
[GtkMultiSorter](gtkmultisorter#GtkMultiSorter-struct) *
gtk_multi_sorter_new (*`void`*);
```
Creates a new multi sorter.
This sorter compares items by trying each of the sorters in turn, until one returns non-zero. In particular, if no sorter has been added to it, it will always compare items as equal.
#### Returns
a new [GtkMultiSorter](gtkmultisorter#GtkMultiSorter-struct)
### gtk\_multi\_sorter\_append ()
```
void
gtk_multi_sorter_append (*`[GtkMultiSorter](gtkmultisorter#GtkMultiSorter-struct) *self`*,
*`[GtkSorter](gtksorter#GtkSorter-struct) *sorter`*);
```
Add *`sorter`* to *`self`* to use for sorting at the end. *`self`* will consult all existing sorters before it will sort with the given *`sorter`* .
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkMultiSorter](gtkmultisorter#GtkMultiSorter-struct) | |
| sorter | a sorter to add. | [transfer full] |
### gtk\_multi\_sorter\_remove ()
```
void
gtk_multi_sorter_remove (*`[GtkMultiSorter](gtkmultisorter#GtkMultiSorter-struct) *self`*,
*`guint position`*);
```
Removes the sorter at the given *`position`* from the list of sorter used by *`self`* .
If *`position`* is larger than the number of sorters, nothing happens.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkMultiSorter](gtkmultisorter#GtkMultiSorter-struct) | |
| position | position of sorter to remove | |
Types and Values
----------------
### GtkMultiSorter
```
typedef struct _GtkMultiSorter GtkMultiSorter;
```
gtk GtkListItemFactory GtkListItemFactory
==================
GtkListItemFactory — Mapping list items to widgets
Types and Values
----------------
| | |
| --- | --- |
| | [GtkListItemFactory](gtklistitemfactory#GtkListItemFactory-struct) |
Object Hierarchy
----------------
```
GObject
╰── GtkListItemFactory
├── [GtkBuilderListItemFactory](gtkbuilderlistitemfactory#GtkBuilderListItemFactory-struct)
╰── [GtkSignalListItemFactory](gtksignallistitemfactory#GtkSignalListItemFactory-struct)
```
Includes
--------
```
#include <gtk/gtk.h>
```
Description
-----------
[GtkListItemFactory](gtklistitemfactory#GtkListItemFactory-struct) is one of the core concepts of handling list widgets. It is the object tasked with creating widgets for items taken from a GListModel when the views need them and updating them as the items displayed by the view change.
A view is usually only able to display anything after both a factory and a model have been set on the view. So it is important that you do not skip this step when setting up your first view.
Because views do not display the whole list at once but only a few items, they only need to maintain a few widgets at a time. They will instruct the [GtkListItemFactory](gtklistitemfactory#GtkListItemFactory-struct) to create these widgets and bind them to the items that are currently displayed. As the list model changes or the user scrolls to the list, the items will change and the view will instruct the factory to bind the widgets to those new items.
The actual widgets used for displaying those widgets is provided by you.
When the factory needs widgets created, it will create a [GtkListItem](gtklistitem#GtkListItem-struct) and hand it to your code to set up a widget for. This list item will provide various properties with information about what item to display and provide you with some opportunities to configure its behavior. See the [GtkListItem](gtklistitem#GtkListItem-struct) documentation for further details.
Various implementations of [GtkListItemFactory](gtklistitemfactory#GtkListItemFactory-struct) exist to allow you different ways to provide those widgets. The most common implementations are [GtkBuilderListItemFactory](gtkbuilderlistitemfactory#GtkBuilderListItemFactory-struct) which takes a [GtkBuilder](gtkbuilder#GtkBuilder-struct) .ui file and then creates widgets and manages everything automatically from the information in that file and [GtkSignalListItemFactory](gtksignallistitemfactory#GtkSignalListItemFactory-struct) which allows you to connect to signals with your own code and retain full control over how the widgets are setup and managed.
A [GtkListItemFactory](gtklistitemfactory#GtkListItemFactory-struct) is supposed to be final - that means its behavior should not change and the first widget created from it should behave the same way as the last widget created from it. If you intend to do changes to the behavior, it is recommended that you create a new [GtkListItemFactory](gtklistitemfactory#GtkListItemFactory-struct) which will allow the views to recreate its widgets.
Once you have chosen your factory and created it, you need to set it on the view widget you want to use it with, such as via [`gtk_list_view_set_factory()`](gtklistview#gtk-list-view-set-factory). Reusing factories across different views is allowed, but very uncommon.
Functions
---------
Types and Values
----------------
### GtkListItemFactory
```
typedef struct _GtkListItemFactory GtkListItemFactory;
```
gtk Version Information Version Information
===================
Version Information — Variables and functions to check the GTK version
Functions
---------
| | |
| --- | --- |
| guint | [gtk\_get\_major\_version](gtk4-feature-test-macros#gtk-get-major-version) () |
| guint | [gtk\_get\_minor\_version](gtk4-feature-test-macros#gtk-get-minor-version) () |
| guint | [gtk\_get\_micro\_version](gtk4-feature-test-macros#gtk-get-micro-version) () |
| guint | [gtk\_get\_binary\_age](gtk4-feature-test-macros#gtk-get-binary-age) () |
| guint | [gtk\_get\_interface\_age](gtk4-feature-test-macros#gtk-get-interface-age) () |
| const char \* | [gtk\_check\_version](gtk4-feature-test-macros#gtk-check-version) () |
| #define | [GTK\_CHECK\_VERSION](gtk4-feature-test-macros#GTK-CHECK-VERSION:CAPS)() |
Types and Values
----------------
| | |
| --- | --- |
| #define | [GTK\_MAJOR\_VERSION](gtk4-feature-test-macros#GTK-MAJOR-VERSION:CAPS) |
| #define | [GTK\_MINOR\_VERSION](gtk4-feature-test-macros#GTK-MINOR-VERSION:CAPS) |
| #define | [GTK\_MICRO\_VERSION](gtk4-feature-test-macros#GTK-MICRO-VERSION:CAPS) |
| #define | [GTK\_BINARY\_AGE](gtk4-feature-test-macros#GTK-BINARY-AGE:CAPS) |
| #define | [GTK\_INTERFACE\_AGE](gtk4-feature-test-macros#GTK-INTERFACE-AGE:CAPS) |
Includes
--------
```
#include <gtk/gtk.h>
```
Description
-----------
GTK provides version information, primarily useful in configure checks for builds that have a configure script. Applications will not typically use the features described here.
Functions
---------
### gtk\_get\_major\_version ()
```
guint
gtk_get_major_version (void);
```
Returns the major version number of the GTK library. (e.g. in GTK version 3.1.5 this is 3.)
This function is in the library, so it represents the GTK library your code is running against. Contrast with the [`GTK_MAJOR_VERSION`](gtk4-feature-test-macros#GTK-MAJOR-VERSION:CAPS) macro, which represents the major version of the GTK headers you have included when compiling your code.
#### Returns
the major version number of the GTK library
### gtk\_get\_minor\_version ()
```
guint
gtk_get_minor_version (void);
```
Returns the minor version number of the GTK library. (e.g. in GTK version 3.1.5 this is 1.)
This function is in the library, so it represents the GTK library your code is are running against. Contrast with the [`GTK_MINOR_VERSION`](gtk4-feature-test-macros#GTK-MINOR-VERSION:CAPS) macro, which represents the minor version of the GTK headers you have included when compiling your code.
#### Returns
the minor version number of the GTK library
### gtk\_get\_micro\_version ()
```
guint
gtk_get_micro_version (void);
```
Returns the micro version number of the GTK library. (e.g. in GTK version 3.1.5 this is 5.)
This function is in the library, so it represents the GTK library your code is are running against. Contrast with the [`GTK_MICRO_VERSION`](gtk4-feature-test-macros#GTK-MICRO-VERSION:CAPS) macro, which represents the micro version of the GTK headers you have included when compiling your code.
#### Returns
the micro version number of the GTK library
### gtk\_get\_binary\_age ()
```
guint
gtk_get_binary_age (void);
```
Returns the binary age as passed to `libtool` when building the GTK library the process is running against. If `libtool` means nothing to you, don't worry about it.
#### Returns
the binary age of the GTK library
### gtk\_get\_interface\_age ()
```
guint
gtk_get_interface_age (void);
```
Returns the interface age as passed to `libtool` when building the GTK library the process is running against. If `libtool` means nothing to you, don't worry about it.
#### Returns
the interface age of the GTK library
### gtk\_check\_version ()
```
const char *
gtk_check_version (guint required_major,
guint required_minor,
guint required_micro);
```
Checks that the GTK library in use is compatible with the given version. Generally you would pass in the constants [`GTK_MAJOR_VERSION`](gtk4-feature-test-macros#GTK-MAJOR-VERSION:CAPS), [`GTK_MINOR_VERSION`](gtk4-feature-test-macros#GTK-MINOR-VERSION:CAPS), [`GTK_MICRO_VERSION`](gtk4-feature-test-macros#GTK-MICRO-VERSION:CAPS) as the three arguments to this function; that produces a check that the library in use is compatible with the version of GTK the application or module was compiled against.
Compatibility is defined by two things: first the version of the running library is newer than the version *`required_major.required_minor`* .*`required_micro`* . Second the running library must be binary compatible with the version *`required_major.required_minor`* .*`required_micro`* (same major version.)
This function is primarily for GTK modules; the module can call this function to check that it wasn’t loaded into an incompatible version of GTK. However, such a check isn’t completely reliable, since the module may be linked against an old version of GTK and calling the old version of [`gtk_check_version()`](gtk4-feature-test-macros#gtk-check-version), but still get loaded into an application using a newer version of GTK.
#### Parameters
| | | |
| --- | --- | --- |
| required\_major | the required major version | |
| required\_minor | the required minor version | |
| required\_micro | the required micro version | |
#### Returns
`NULL` if the GTK library is compatible with the given version, or a string describing the version mismatch. The returned string is owned by GTK and should not be modified or freed.
[nullable]
### GTK\_CHECK\_VERSION()
```
#define GTK_CHECK_VERSION(major,minor,micro)
```
Returns `TRUE` if the version of the GTK header files is the same as or newer than the passed-in version.
#### Parameters
| | | |
| --- | --- | --- |
| major | major version (e.g. 1 for version 1.2.5) | |
| minor | minor version (e.g. 2 for version 1.2.5) | |
| micro | micro version (e.g. 5 for version 1.2.5) | |
#### Returns
`TRUE` if GTK headers are new enough
Types and Values
----------------
### GTK\_MAJOR\_VERSION
```
#define GTK_MAJOR_VERSION (4)
```
Like [`gtk_get_major_version()`](gtk4-feature-test-macros#gtk-get-major-version), but from the headers used at application compile time, rather than from the library linked against at application run time.
### GTK\_MINOR\_VERSION
```
#define GTK_MINOR_VERSION (0)
```
Like [`gtk_get_minor_version()`](gtk4-feature-test-macros#gtk-get-minor-version), but from the headers used at application compile time, rather than from the library linked against at application run time.
### GTK\_MICRO\_VERSION
```
#define GTK_MICRO_VERSION (3)
```
Like [`gtk_get_micro_version()`](gtk4-feature-test-macros#gtk-get-micro-version), but from the headers used at application compile time, rather than from the library linked against at application run time.
### GTK\_BINARY\_AGE
```
#define GTK_BINARY_AGE (3)
```
Like [`gtk_get_binary_age()`](gtk4-feature-test-macros#gtk-get-binary-age), but from the headers used at application compile time, rather than from the library linked against at application run time.
### GTK\_INTERFACE\_AGE
```
#define GTK_INTERFACE_AGE (3)
```
Like [`gtk_get_interface_age()`](gtk4-feature-test-macros#gtk-get-interface-age), but from the headers used at application compile time, rather than from the library linked against at application run time.
gtk GtkBuilder GtkBuilder
==========
GtkBuilder — Build an interface from an XML UI definition
Functions
---------
| | |
| --- | --- |
| [GtkBuilder](gtkbuilder#GtkBuilder-struct) \* | [gtk\_builder\_new](gtkbuilder#gtk-builder-new) () |
| [GtkBuilder](gtkbuilder#GtkBuilder-struct) \* | [gtk\_builder\_new\_from\_file](gtkbuilder#gtk-builder-new-from-file) () |
| [GtkBuilder](gtkbuilder#GtkBuilder-struct) \* | [gtk\_builder\_new\_from\_resource](gtkbuilder#gtk-builder-new-from-resource) () |
| [GtkBuilder](gtkbuilder#GtkBuilder-struct) \* | [gtk\_builder\_new\_from\_string](gtkbuilder#gtk-builder-new-from-string) () |
| GClosure \* | [gtk\_builder\_create\_closure](gtkbuilder#gtk-builder-create-closure) () |
| gboolean | [gtk\_builder\_add\_from\_file](gtkbuilder#gtk-builder-add-from-file) () |
| gboolean | [gtk\_builder\_add\_from\_resource](gtkbuilder#gtk-builder-add-from-resource) () |
| gboolean | [gtk\_builder\_add\_from\_string](gtkbuilder#gtk-builder-add-from-string) () |
| gboolean | [gtk\_builder\_add\_objects\_from\_file](gtkbuilder#gtk-builder-add-objects-from-file) () |
| gboolean | [gtk\_builder\_add\_objects\_from\_string](gtkbuilder#gtk-builder-add-objects-from-string) () |
| gboolean | [gtk\_builder\_add\_objects\_from\_resource](gtkbuilder#gtk-builder-add-objects-from-resource) () |
| gboolean | [gtk\_builder\_extend\_with\_template](gtkbuilder#gtk-builder-extend-with-template) () |
| GObject \* | [gtk\_builder\_get\_object](gtkbuilder#gtk-builder-get-object) () |
| GSList \* | [gtk\_builder\_get\_objects](gtkbuilder#gtk-builder-get-objects) () |
| void | [gtk\_builder\_expose\_object](gtkbuilder#gtk-builder-expose-object) () |
| void | [gtk\_builder\_set\_current\_object](gtkbuilder#gtk-builder-set-current-object) () |
| GObject \* | [gtk\_builder\_get\_current\_object](gtkbuilder#gtk-builder-get-current-object) () |
| void | [gtk\_builder\_set\_scope](gtkbuilder#gtk-builder-set-scope) () |
| [GtkBuilderScope](gtkbuilderscope#GtkBuilderScope-struct) \* | [gtk\_builder\_get\_scope](gtkbuilder#gtk-builder-get-scope) () |
| void | [gtk\_builder\_set\_translation\_domain](gtkbuilder#gtk-builder-set-translation-domain) () |
| const char \* | [gtk\_builder\_get\_translation\_domain](gtkbuilder#gtk-builder-get-translation-domain) () |
| GType | [gtk\_builder\_get\_type\_from\_name](gtkbuilder#gtk-builder-get-type-from-name) () |
| gboolean | [gtk\_builder\_value\_from\_string](gtkbuilder#gtk-builder-value-from-string) () |
| gboolean | [gtk\_builder\_value\_from\_string\_type](gtkbuilder#gtk-builder-value-from-string-type) () |
| #define | [GTK\_BUILDER\_WARN\_INVALID\_CHILD\_TYPE](gtkbuilder#GTK-BUILDER-WARN-INVALID-CHILD-TYPE:CAPS)() |
Properties
----------
| | | |
| --- | --- | --- |
| GObject \* | [current-object](gtkbuilder#GtkBuilder--current-object) | Read / Write |
| [GtkBuilderScope](gtkbuilderscope#GtkBuilderScope-struct) \* | [scope](gtkbuilder#GtkBuilder--scope) | Read / Write / Construct |
| char \* | [translation-domain](gtkbuilder#GtkBuilder--translation-domain) | Read / Write |
Types and Values
----------------
| | |
| --- | --- |
| | [GtkBuilder](gtkbuilder#GtkBuilder-struct) |
| enum | [GtkBuilderClosureFlags](gtkbuilderscope#GtkBuilderClosureFlags) |
| enum | [GtkBuilderError](gtkbuilder#GtkBuilderError) |
| #define | [GTK\_BUILDER\_ERROR](gtkbuilder#GTK-BUILDER-ERROR:CAPS) |
Object Hierarchy
----------------
```
GObject
╰── GtkBuilder
```
Includes
--------
```
#include <gtk/gtk.h>
```
Description
-----------
A GtkBuilder is an auxiliary object that reads textual descriptions of a user interface and instantiates the described objects. To create a GtkBuilder from a user interface description, call [`gtk_builder_new_from_file()`](gtkbuilder#gtk-builder-new-from-file), [`gtk_builder_new_from_resource()`](gtkbuilder#gtk-builder-new-from-resource) or [`gtk_builder_new_from_string()`](gtkbuilder#gtk-builder-new-from-string).
In the (unusual) case that you want to add user interface descriptions from multiple sources to the same GtkBuilder you can call [`gtk_builder_new()`](gtkbuilder#gtk-builder-new) to get an empty builder and populate it by (multiple) calls to [`gtk_builder_add_from_file()`](gtkbuilder#gtk-builder-add-from-file), [`gtk_builder_add_from_resource()`](gtkbuilder#gtk-builder-add-from-resource) or [`gtk_builder_add_from_string()`](gtkbuilder#gtk-builder-add-from-string).
A GtkBuilder holds a reference to all objects that it has constructed and drops these references when it is finalized. This finalization can cause the destruction of non-widget objects or widgets which are not contained in a toplevel window. For toplevel windows constructed by a builder, it is the responsibility of the user to call [`gtk_window_destroy()`](gtkwindow#gtk-window-destroy) to get rid of them and all the widgets they contain.
The functions [`gtk_builder_get_object()`](gtkbuilder#gtk-builder-get-object) and [`gtk_builder_get_objects()`](gtkbuilder#gtk-builder-get-objects) can be used to access the widgets in the interface by the names assigned to them inside the UI description. Toplevel windows returned by these functions will stay around until the user explicitly destroys them with [`gtk_window_destroy()`](gtkwindow#gtk-window-destroy). Other widgets will either be part of a larger hierarchy constructed by the builder (in which case you should not have to worry about their lifecycle), or without a parent, in which case they have to be added to some container to make use of them. Non-widget objects need to be reffed with `g_object_ref()` to keep them beyond the lifespan of the builder.
### GtkBuilder UI Definitions
GtkBuilder parses textual descriptions of user interfaces which are specified in XML format. We refer to these descriptions as “GtkBuilder UI definitions” or just “UI definitions” if the context is clear.
The toplevel element is `<interface>`. It optionally takes a “domain” attribute, which will make the builder look for translated strings using ``dgettext()`` in the domain specified. This can also be done by calling [`gtk_builder_set_translation_domain()`](gtkbuilder#gtk-builder-set-translation-domain) on the builder. Objects are described by `<object>` elements, which can contain <property> elements to set properties, `<signal>` elements which connect signals to handlers, and `<child>` elements, which describe child objects (most often widgets inside a container, but also e.g. actions in an action group, or columns in a tree model). A `<child>` element contains an `<object>` element which describes the child object. The target toolkit version(s) are described by <requires> elements, the “lib” attribute specifies the widget library in question (currently the only supported value is “gtk”) and the “version” attribute specifies the target version in the form “`<major>`.`<minor>`”. The builder will error out if the version requirements are not met.
Typically, the specific kind of object represented by an `<object>` element is specified by the “class” attribute. If the type has not been loaded yet, GTK tries to find the ``get_type()`` function from the class name by applying heuristics. This works in most cases, but if necessary, it is possible to specify the name of the ``get_type()`` function explicitly with the "type-func" attribute.
Objects may be given a name with the “id” attribute, which allows the application to retrieve them from the builder with [`gtk_builder_get_object()`](gtkbuilder#gtk-builder-get-object). An id is also necessary to use the object as property value in other parts of the UI definition. GTK reserves ids starting and ending with `___` (three consecutive underscores) for its own purposes.
Setting properties of objects is pretty straightforward with the <property> element: the “name” attribute specifies the name of the property, and the content of the element specifies the value. If the “translatable” attribute is set to a true value, GTK uses ``gettext()`` (or ``dgettext()`` if the builder has a translation domain set) to find a translation for the value. This happens before the value is parsed, so it can be used for properties of any type, but it is probably most useful for string properties. It is also possible to specify a context to disambiguate short strings, and comments which may help the translators.
[GtkBuilder](gtkbuilder#GtkBuilder-struct) can parse textual representations for the most common property types: characters, strings, integers, floating-point numbers, booleans (strings like “TRUE”, “t”, “yes”, “y”, “1” are interpreted as `TRUE`, strings like “FALSE”, “f”, “no”, “n”, “0” are interpreted as `FALSE`), enumerations (can be specified by their name, nick or integer value), flags (can be specified by their name, nick, integer value, optionally combined with “|”, e.g. “GTK\_INPUT\_HINT\_EMOJI|GTK\_INPUT\_HINT\_LOWERCASE”) and colors (in a format understood by [`gdk_rgba_parse()`](https://developer-old.gnome.org/gtk4/html/gdk4-RGBA-Colors.html#gdk-rgba-parse)).
GVariants can be specified in the format understood by `g_variant_parse()`, and pixbufs can be specified as a filename of an image file to load.
Objects can be referred to by their name and by default refer to objects declared in the local XML fragment and objects exposed via [`gtk_builder_expose_object()`](gtkbuilder#gtk-builder-expose-object). In general, GtkBuilder allows forward references to objects — declared in the local XML; an object doesn’t have to be constructed before it can be referred to. The exception to this rule is that an object has to be constructed before it can be used as the value of a construct-only property.
It is also possible to bind a property value to another object's property value using the attributes "bind-source" to specify the source object of the binding, and optionally, "bind-property" and "bind-flags" to specify the source property and source binding flags respectively. Internally builder implements this using GBinding objects. For more information see `g_object_bind_property()`
Sometimes it is necessary to refer to widgets which have implicitly been constructed by GTK as part of a composite widget, to set properties on them or to add further children (e.g. the content area of a [GtkDialog](gtkdialog#GtkDialog-struct)). This can be achieved by setting the “internal-child” property of the `<child>` element to a true value. Note that [GtkBuilder](gtkbuilder#GtkBuilder-struct) still requires an `<object>` element for the internal child, even if it has already been constructed.
A number of widgets have different places where a child can be added (e.g. tabs vs. page content in notebooks). This can be reflected in a UI definition by specifying the “type” attribute on a `<child>` The possible values for the “type” attribute are described in the sections describing the widget-specific portions of UI definitions.
### Signal handlers and function pointers
Signal handlers are set up with the <signal> element. The “name” attribute specifies the name of the signal, and the “handler” attribute specifies the function to connect to the signal. The remaining attributes, “after”, “swapped” and “object”, have the same meaning as the corresponding parameters of the `g_signal_connect_object()` or `g_signal_connect_data()` functions. A “last\_modification\_time” attribute is also allowed, but it does not have a meaning to the builder.
If you rely on GModule support to lookup callbacks in the symbol table, the following details should be noted:
When compiling applications for Windows, you must declare signal callbacks with G\_MODULE\_EXPORT, or they will not be put in the symbol table. On Linux and Unices, this is not necessary; applications should instead be compiled with the -Wl,--export-dynamic CFLAGS, and linked against gmodule-export-2.0.
### A GtkBuilder UI Definition
```
<interface>
<object class="GtkDialog" id="dialog1">
<child internal-child="vbox">
<object class="GtkBox" id="vbox1">
<child internal-child="action_area">
<object class="GtkBox" id="hbuttonbox1">
<child>
<object class="GtkButton" id="ok_button">
<property name="label">gtk-ok</property>
<signal name="clicked" handler="ok_button_clicked"/>
</object>
</child>
</object>
</child>
</object>
</child>
</object>
</interface>
```
| Beyond this general structure, several object classes define their own XML DTD fragments for filling in the ANY placeholders in the DTD above. Note that a custom element in a <child> element gets parsed by the custom tag handler of the parent object, while a custom element in an <object> element gets parsed by the custom tag handler of the object.
These XML fragments are explained in the documentation of the respective objects.
Additionally, since 3.10 a special <template> tag has been added to the format allowing one to define a widget class’s components. See the GtkWidget documentation for details.
Functions
---------
### gtk\_builder\_new ()
```
[GtkBuilder](gtkbuilder#GtkBuilder-struct) *
gtk_builder_new (*`void`*);
```
Creates a new empty builder object.
This function is only useful if you intend to make multiple calls to [`gtk_builder_add_from_file()`](gtkbuilder#gtk-builder-add-from-file), [`gtk_builder_add_from_resource()`](gtkbuilder#gtk-builder-add-from-resource) or [`gtk_builder_add_from_string()`](gtkbuilder#gtk-builder-add-from-string) in order to merge multiple UI descriptions into a single builder.
#### Returns
a new (empty) [GtkBuilder](gtkbuilder#GtkBuilder-struct) object
### gtk\_builder\_new\_from\_file ()
```
[GtkBuilder](gtkbuilder#GtkBuilder-struct) *
gtk_builder_new_from_file (*`const char *filename`*);
```
Builds the GtkBuilder UI definition in the file *`filename`* .
If there is an error opening the file or parsing the description then the program will be aborted. You should only ever attempt to parse user interface descriptions that are shipped as part of your program.
#### Parameters
| | | |
| --- | --- | --- |
| filename | filename of user interface description file | |
#### Returns
a [GtkBuilder](gtkbuilder#GtkBuilder-struct) containing the described interface
### gtk\_builder\_new\_from\_resource ()
```
[GtkBuilder](gtkbuilder#GtkBuilder-struct) *
gtk_builder_new_from_resource (*`const char *resource_path`*);
```
Builds the GtkBuilder UI definition at *`resource_path`* .
If there is an error locating the resource or parsing the description, then the program will be aborted.
#### Parameters
| | | |
| --- | --- | --- |
| resource\_path | a GResource resource path | |
#### Returns
a [GtkBuilder](gtkbuilder#GtkBuilder-struct) containing the described interface
### gtk\_builder\_new\_from\_string ()
```
[GtkBuilder](gtkbuilder#GtkBuilder-struct) *
gtk_builder_new_from_string (*`const char *string`*,
*`gssize length`*);
```
Builds the user interface described by *`string`* (in the GtkBuilder UI definition format).
If *`string`* is `NULL`-terminated, then *`length`* should be -1. If *`length`* is not -1, then it is the length of *`string`* .
If there is an error parsing *`string`* then the program will be aborted. You should not attempt to parse user interface description from untrusted sources.
#### Parameters
| | | |
| --- | --- | --- |
| string | a user interface (XML) description | |
| length | the length of *`string`* , or -1 | |
#### Returns
a [GtkBuilder](gtkbuilder#GtkBuilder-struct) containing the interface described by *`string`*
### gtk\_builder\_create\_closure ()
```
GClosure *
gtk_builder_create_closure (*`[GtkBuilder](gtkbuilder#GtkBuilder-struct) *builder`*,
*`const char *function_name`*,
*`[GtkBuilderClosureFlags](gtkbuilderscope#GtkBuilderClosureFlags) flags`*,
*`GObject *object`*,
*`GError **error`*);
```
Creates a closure to invoke the function called *`function_name`* , by using the `create_closure()` implementation of *`builder`* 's [GtkBuilderScope](gtkbuilderscope#GtkBuilderScope-struct).
If no closure could be created, `NULL` will be returned and *`error`* will be set.
#### Parameters
| | | |
| --- | --- | --- |
| builder | a [GtkBuilder](gtkbuilder#GtkBuilder-struct) | |
| function\_name | name of the function to look up | |
| flags | closure creation flags | |
| object | Object to create the closure with. | [nullable] |
| error | return location for an error, or `NULL`. | [allow-none] |
#### Returns
A new closure for invoking *`function_name`* .
[nullable]
### gtk\_builder\_add\_from\_file ()
```
gboolean
gtk_builder_add_from_file (*`[GtkBuilder](gtkbuilder#GtkBuilder-struct) *builder`*,
*`const char *filename`*,
*`GError **error`*);
```
Parses a file containing a GtkBuilder UI definition and merges it with the current contents of *`builder`* .
This function is useful if you need to call [`gtk_builder_set_current_object()`](gtkbuilder#gtk-builder-set-current-object) to add user data to callbacks before loading GtkBuilder UI. Otherwise, you probably want [`gtk_builder_new_from_file()`](gtkbuilder#gtk-builder-new-from-file) instead.
If an error occurs, 0 will be returned and *`error`* will be assigned a GError from the [GTK\_BUILDER\_ERROR](gtkbuilder#GTK-BUILDER-ERROR:CAPS), G\_MARKUP\_ERROR or G\_FILE\_ERROR domain.
It’s not really reasonable to attempt to handle failures of this call. You should not use this function with untrusted files (ie: files that are not part of your application). Broken [GtkBuilder](gtkbuilder#GtkBuilder-struct) files can easily crash your program, and it’s possible that memory was leaked leading up to the reported failure. The only reasonable thing to do when an error is detected is to call `g_error()`.
#### Parameters
| | | |
| --- | --- | --- |
| builder | a [GtkBuilder](gtkbuilder#GtkBuilder-struct) | |
| filename | the name of the file to parse | |
| error | return location for an error, or `NULL`. | [allow-none] |
#### Returns
`TRUE` on success, `FALSE` if an error occurred
### gtk\_builder\_add\_from\_resource ()
```
gboolean
gtk_builder_add_from_resource (*`[GtkBuilder](gtkbuilder#GtkBuilder-struct) *builder`*,
*`const char *resource_path`*,
*`GError **error`*);
```
Parses a resource file containing a GtkBuilder UI definition and merges it with the current contents of *`builder`* .
This function is useful if you need to call [`gtk_builder_set_current_object()`](gtkbuilder#gtk-builder-set-current-object) to add user data to callbacks before loading GtkBuilder UI. Otherwise, you probably want [`gtk_builder_new_from_resource()`](gtkbuilder#gtk-builder-new-from-resource) instead.
If an error occurs, 0 will be returned and *`error`* will be assigned a GError from the [GTK\_BUILDER\_ERROR](gtkbuilder#GTK-BUILDER-ERROR:CAPS), G\_MARKUP\_ERROR or G\_RESOURCE\_ERROR domain.
It’s not really reasonable to attempt to handle failures of this call. The only reasonable thing to do when an error is detected is to call `g_error()`.
#### Parameters
| | | |
| --- | --- | --- |
| builder | a [GtkBuilder](gtkbuilder#GtkBuilder-struct) | |
| resource\_path | the path of the resource file to parse | |
| error | return location for an error, or `NULL`. | [allow-none] |
#### Returns
`TRUE` on success, `FALSE` if an error occurred
### gtk\_builder\_add\_from\_string ()
```
gboolean
gtk_builder_add_from_string (*`[GtkBuilder](gtkbuilder#GtkBuilder-struct) *builder`*,
*`const char *buffer`*,
*`gssize length`*,
*`GError **error`*);
```
Parses a string containing a GtkBuilder UI definition and merges it with the current contents of *`builder`* .
This function is useful if you need to call [`gtk_builder_set_current_object()`](gtkbuilder#gtk-builder-set-current-object) to add user data to callbacks before loading GtkBuilder UI. Otherwise, you probably want [`gtk_builder_new_from_string()`](gtkbuilder#gtk-builder-new-from-string) instead.
Upon errors `FALSE` will be returned and *`error`* will be assigned a GError from the [GTK\_BUILDER\_ERROR](gtkbuilder#GTK-BUILDER-ERROR:CAPS), G\_MARKUP\_ERROR or G\_VARIANT\_PARSE\_ERROR domain.
It’s not really reasonable to attempt to handle failures of this call. The only reasonable thing to do when an error is detected is to call `g_error()`.
#### Parameters
| | | |
| --- | --- | --- |
| builder | a [GtkBuilder](gtkbuilder#GtkBuilder-struct) | |
| buffer | the string to parse | |
| length | the length of *`buffer`* (may be -1 if *`buffer`* is nul-terminated) | |
| error | return location for an error, or `NULL`. | [allow-none] |
#### Returns
`TRUE` on success, `FALSE` if an error occurred
### gtk\_builder\_add\_objects\_from\_file ()
```
gboolean
gtk_builder_add_objects_from_file (*`[GtkBuilder](gtkbuilder#GtkBuilder-struct) *builder`*,
*`const char *filename`*,
*`const char **object_ids`*,
*`GError **error`*);
```
Parses a file containing a GtkBuilder UI definition building only the requested objects and merges them with the current contents of *`builder`* .
Upon errors 0 will be returned and *`error`* will be assigned a GError from the [GTK\_BUILDER\_ERROR](gtkbuilder#GTK-BUILDER-ERROR:CAPS), G\_MARKUP\_ERROR or G\_FILE\_ERROR domain.
If you are adding an object that depends on an object that is not its child (for instance a [GtkTreeView](gtktreeview#GtkTreeView-struct) that depends on its [GtkTreeModel](gtktreemodel#GtkTreeModel-struct)), you have to explicitly list all of them in *`object_ids`* .
#### Parameters
| | | |
| --- | --- | --- |
| builder | a [GtkBuilder](gtkbuilder#GtkBuilder-struct) | |
| filename | the name of the file to parse | |
| object\_ids | nul-terminated array of objects to build. | [array zero-terminated=1][element-type utf8] |
| error | return location for an error, or `NULL`. | [allow-none] |
#### Returns
`TRUE` on success, `FALSE` if an error occurred
### gtk\_builder\_add\_objects\_from\_string ()
```
gboolean
gtk_builder_add_objects_from_string (*`[GtkBuilder](gtkbuilder#GtkBuilder-struct) *builder`*,
*`const char *buffer`*,
*`gssize length`*,
*`const char **object_ids`*,
*`GError **error`*);
```
Parses a string containing a GtkBuilder UI definition building only the requested objects and merges them with the current contents of *`builder`* .
Upon errors `FALSE` will be returned and *`error`* will be assigned a GError from the [GTK\_BUILDER\_ERROR](gtkbuilder#GTK-BUILDER-ERROR:CAPS) or G\_MARKUP\_ERROR domain.
If you are adding an object that depends on an object that is not its child (for instance a [GtkTreeView](gtktreeview#GtkTreeView-struct) that depends on its [GtkTreeModel](gtktreemodel#GtkTreeModel-struct)), you have to explicitly list all of them in *`object_ids`* .
#### Parameters
| | | |
| --- | --- | --- |
| builder | a [GtkBuilder](gtkbuilder#GtkBuilder-struct) | |
| buffer | the string to parse | |
| length | the length of *`buffer`* (may be -1 if *`buffer`* is nul-terminated) | |
| object\_ids | nul-terminated array of objects to build. | [array zero-terminated=1][element-type utf8] |
| error | return location for an error, or `NULL`. | [allow-none] |
#### Returns
`TRUE` on success, `FALSE` if an error occurred
### gtk\_builder\_add\_objects\_from\_resource ()
```
gboolean
gtk_builder_add_objects_from_resource (*`[GtkBuilder](gtkbuilder#GtkBuilder-struct) *builder`*,
*`const char *resource_path`*,
*`const char **object_ids`*,
*`GError **error`*);
```
Parses a resource file containing a GtkBuilder UI definition building only the requested objects and merges them with the current contents of *`builder`* .
Upon errors 0 will be returned and *`error`* will be assigned a GError from the [GTK\_BUILDER\_ERROR](gtkbuilder#GTK-BUILDER-ERROR:CAPS), G\_MARKUP\_ERROR or G\_RESOURCE\_ERROR domain.
If you are adding an object that depends on an object that is not its child (for instance a [GtkTreeView](gtktreeview#GtkTreeView-struct) that depends on its [GtkTreeModel](gtktreemodel#GtkTreeModel-struct)), you have to explicitly list all of them in *`object_ids`* .
#### Parameters
| | | |
| --- | --- | --- |
| builder | a [GtkBuilder](gtkbuilder#GtkBuilder-struct) | |
| resource\_path | the path of the resource file to parse | |
| object\_ids | nul-terminated array of objects to build. | [array zero-terminated=1][element-type utf8] |
| error | return location for an error, or `NULL`. | [allow-none] |
#### Returns
`TRUE` on success, `FALSE` if an error occurred
### gtk\_builder\_extend\_with\_template ()
```
gboolean
gtk_builder_extend_with_template (*`[GtkBuilder](gtkbuilder#GtkBuilder-struct) *builder`*,
*`GObject *object`*,
*`GType template_type`*,
*`const char *buffer`*,
*`gssize length`*,
*`GError **error`*);
```
Main private entry point for building composite container components from template XML.
This is exported purely to let gtk-builder-tool validate templates, applications have no need to call this function.
#### Parameters
| | | |
| --- | --- | --- |
| builder | a [GtkBuilder](gtkbuilder#GtkBuilder-struct) | |
| object | the object that is being extended | |
| template\_type | the type that the template is for | |
| buffer | the string to parse | |
| length | the length of *`buffer`* (may be -1 if *`buffer`* is nul-terminated) | |
| error | return location for an error, or `NULL`. | [allow-none] |
#### Returns
A positive value on success, 0 if an error occurred
### gtk\_builder\_get\_object ()
```
GObject *
gtk_builder_get_object (*`[GtkBuilder](gtkbuilder#GtkBuilder-struct) *builder`*,
*`const char *name`*);
```
Gets the object named *`name`* . Note that this function does not increment the reference count of the returned object.
#### Parameters
| | | |
| --- | --- | --- |
| builder | a [GtkBuilder](gtkbuilder#GtkBuilder-struct) | |
| name | name of object to get | |
#### Returns
the object named *`name`* or `NULL` if it could not be found in the object tree.
[nullable][transfer none]
### gtk\_builder\_get\_objects ()
```
GSList *
gtk_builder_get_objects (*`[GtkBuilder](gtkbuilder#GtkBuilder-struct) *builder`*);
```
Gets all objects that have been constructed by *`builder`* . Note that this function does not increment the reference counts of the returned objects.
#### Parameters
| | | |
| --- | --- | --- |
| builder | a [GtkBuilder](gtkbuilder#GtkBuilder-struct) | |
#### Returns
a newly-allocated GSList containing all the objects constructed by the [GtkBuilder](gtkbuilder#GtkBuilder-struct) instance. It should be freed by `g_slist_free()`.
[element-type GObject][transfer container]
### gtk\_builder\_expose\_object ()
```
void
gtk_builder_expose_object (*`[GtkBuilder](gtkbuilder#GtkBuilder-struct) *builder`*,
*`const char *name`*,
*`GObject *object`*);
```
Add *`object`* to the *`builder`* object pool so it can be referenced just like any other object built by builder.
#### Parameters
| | | |
| --- | --- | --- |
| builder | a [GtkBuilder](gtkbuilder#GtkBuilder-struct) | |
| name | the name of the object exposed to the builder | |
| object | the object to expose | |
### gtk\_builder\_set\_current\_object ()
```
void
gtk_builder_set_current_object (*`[GtkBuilder](gtkbuilder#GtkBuilder-struct) *builder`*,
*`GObject *current_object`*);
```
Sets the current object for the *`builder`* . The current object can be thought of as the `this` object that the builder is working for and will often be used as the default object when an object is optional.
gtk\_widget\_init\_template() for example will set the current object to the widget the template is inited for. For functions like [`gtk_builder_new_from_resource()`](gtkbuilder#gtk-builder-new-from-resource), the current object will be `NULL`.
#### Parameters
| | | |
| --- | --- | --- |
| builder | a [GtkBuilder](gtkbuilder#GtkBuilder-struct) | |
| current\_object | the new current object or `NULL` for none. | [nullable][transfer none] |
### gtk\_builder\_get\_current\_object ()
```
GObject *
gtk_builder_get_current_object (*`[GtkBuilder](gtkbuilder#GtkBuilder-struct) *builder`*);
```
Gets the current object set via [`gtk_builder_set_current_object()`](gtkbuilder#gtk-builder-set-current-object).
#### Parameters
| | | |
| --- | --- | --- |
| builder | a [GtkBuilder](gtkbuilder#GtkBuilder-struct) | |
#### Returns
the current object.
[nullable][transfer none]
### gtk\_builder\_set\_scope ()
```
void
gtk_builder_set_scope (*`[GtkBuilder](gtkbuilder#GtkBuilder-struct) *builder`*,
*`[GtkBuilderScope](gtkbuilderscope#GtkBuilderScope-struct) *scope`*);
```
Sets the scope the builder should operate in.
If *`scope`* is `NULL` a new [GtkBuilderCScope](gtkbuilderscope#GtkBuilderCScope-struct) will be created.
See the [GtkBuilderScope](gtkbuilderscope#GtkBuilderScope-struct) documentation for details.
#### Parameters
| | | |
| --- | --- | --- |
| builder | a [GtkBuilder](gtkbuilder#GtkBuilder-struct) | |
| scope | the scope to use or `NULL` for the default. | [nullable][transfer none] |
### gtk\_builder\_get\_scope ()
```
[GtkBuilderScope](gtkbuilderscope#GtkBuilderScope-struct) *
gtk_builder_get_scope (*`[GtkBuilder](gtkbuilder#GtkBuilder-struct) *builder`*);
```
Gets the scope in use that was set via [`gtk_builder_set_scope()`](gtkbuilder#gtk-builder-set-scope).
See the [GtkBuilderScope](gtkbuilderscope#GtkBuilderScope-struct) documentation for details.
#### Parameters
| | | |
| --- | --- | --- |
| builder | a [GtkBuilder](gtkbuilder#GtkBuilder-struct) | |
#### Returns
the current scope.
[transfer none]
### gtk\_builder\_set\_translation\_domain ()
```
void
gtk_builder_set_translation_domain (*`[GtkBuilder](gtkbuilder#GtkBuilder-struct) *builder`*,
*`const char *domain`*);
```
Sets the translation domain of *`builder`* . See [“translation-domain”](gtkbuilder#GtkBuilder--translation-domain).
#### Parameters
| | | |
| --- | --- | --- |
| builder | a [GtkBuilder](gtkbuilder#GtkBuilder-struct) | |
| domain | the translation domain or `NULL`. | [nullable] |
### gtk\_builder\_get\_translation\_domain ()
```
const char *
gtk_builder_get_translation_domain (*`[GtkBuilder](gtkbuilder#GtkBuilder-struct) *builder`*);
```
Gets the translation domain of *`builder`* .
#### Parameters
| | | |
| --- | --- | --- |
| builder | a [GtkBuilder](gtkbuilder#GtkBuilder-struct) | |
#### Returns
the translation domain or `NULL` in case it was never set or explicitly unset via [`gtk_builder_set_translation_domain()`](gtkbuilder#gtk-builder-set-translation-domain). This string is owned by the builder object and must not be modified or freed.
[transfer none][nullable]
### gtk\_builder\_get\_type\_from\_name ()
```
GType
gtk_builder_get_type_from_name (*`[GtkBuilder](gtkbuilder#GtkBuilder-struct) *builder`*,
*`const char *type_name`*);
```
Looks up a type by name, using the virtual function that [GtkBuilder](gtkbuilder#GtkBuilder-struct) has for that purpose. This is mainly used when implementing the [GtkBuildable](gtkbuildable#GtkBuildable-struct) interface on a type.
#### Parameters
| | | |
| --- | --- | --- |
| builder | a [GtkBuilder](gtkbuilder#GtkBuilder-struct) | |
| type\_name | type name to lookup | |
#### Returns
the GType found for *`type_name`* or G\_TYPE\_INVALID if no type was found
### gtk\_builder\_value\_from\_string ()
```
gboolean
gtk_builder_value_from_string (*`[GtkBuilder](gtkbuilder#GtkBuilder-struct) *builder`*,
*`GParamSpec *pspec`*,
*`const char *string`*,
*`GValue *value`*,
*`GError **error`*);
```
This function demarshals a value from a string. This function calls `g_value_init()` on the *`value`* argument, so it need not be initialised beforehand.
This function can handle char, uchar, boolean, int, uint, long, ulong, enum, flags, float, double, string, [GdkRGBA](https://developer-old.gnome.org/gtk4/html/gdk4-RGBA-Colors.html#GdkRGBA-struct) and [GtkAdjustment](gtkadjustment#GtkAdjustment-struct) type values. Support for [GtkWidget](gtkwidget#GtkWidget-struct) type values is still to come.
Upon errors `FALSE` will be returned and *`error`* will be assigned a GError from the [GTK\_BUILDER\_ERROR](gtkbuilder#GTK-BUILDER-ERROR:CAPS) domain.
#### Parameters
| | | |
| --- | --- | --- |
| builder | a [GtkBuilder](gtkbuilder#GtkBuilder-struct) | |
| pspec | the GParamSpec for the property | |
| string | the string representation of the value | |
| value | the GValue to store the result in. | [out] |
| error | return location for an error, or `NULL`. | [allow-none] |
#### Returns
`TRUE` on success
### gtk\_builder\_value\_from\_string\_type ()
```
gboolean
gtk_builder_value_from_string_type (*`[GtkBuilder](gtkbuilder#GtkBuilder-struct) *builder`*,
*`GType type`*,
*`const char *string`*,
*`GValue *value`*,
*`GError **error`*);
```
Like [`gtk_builder_value_from_string()`](gtkbuilder#gtk-builder-value-from-string), this function demarshals a value from a string, but takes a GType instead of GParamSpec. This function calls `g_value_init()` on the *`value`* argument, so it need not be initialised beforehand.
Upon errors `FALSE` will be returned and *`error`* will be assigned a GError from the [GTK\_BUILDER\_ERROR](gtkbuilder#GTK-BUILDER-ERROR:CAPS) domain.
#### Parameters
| | | |
| --- | --- | --- |
| builder | a [GtkBuilder](gtkbuilder#GtkBuilder-struct) | |
| type | the GType of the value | |
| string | the string representation of the value | |
| value | the GValue to store the result in. | [out] |
| error | return location for an error, or `NULL`. | [allow-none] |
#### Returns
`TRUE` on success
### GTK\_BUILDER\_WARN\_INVALID\_CHILD\_TYPE()
```
#define GTK_BUILDER_WARN_INVALID_CHILD_TYPE(object, type)
```
This macro should be used to emit a warning about and unexpected *`type`* value in a [GtkBuildable](gtkbuildable#GtkBuildable-struct) add\_child implementation.
#### Parameters
| | | |
| --- | --- | --- |
| object | the [GtkBuildable](gtkbuildable#GtkBuildable-struct) on which the warning occurred | |
| type | the unexpected type value | |
Types and Values
----------------
### GtkBuilder
```
typedef struct _GtkBuilder GtkBuilder;
```
### enum GtkBuilderClosureFlags
The list of flags that can be passed to [`gtk_builder_create_closure()`](gtkbuilder#gtk-builder-create-closure). New values may be added in the future for new features, so external implementations of GtkBuilderScopeInterface should test the flags for unknown values and raise a [`GTK_BUILDER_ERROR_INVALID_ATTRIBUTE`](gtkbuilder#GTK-BUILDER-ERROR-INVALID-ATTRIBUTE:CAPS) error when they encounter one.
#### Members
| | | |
| --- | --- | --- |
| GTK\_BUILDER\_CLOSURE\_SWAPPED | | |
### enum GtkBuilderError
Error codes that identify various errors that can occur while using [GtkBuilder](gtkbuilder#GtkBuilder-struct).
#### Members
| | | |
| --- | --- | --- |
| GTK\_BUILDER\_ERROR\_INVALID\_TYPE\_FUNCTION | A type-func attribute didn’t name a function that returns a GType. | |
| GTK\_BUILDER\_ERROR\_UNHANDLED\_TAG | The input contained a tag that [GtkBuilder](gtkbuilder#GtkBuilder-struct) can’t handle. | |
| GTK\_BUILDER\_ERROR\_MISSING\_ATTRIBUTE | An attribute that is required by [GtkBuilder](gtkbuilder#GtkBuilder-struct) was missing. | |
| GTK\_BUILDER\_ERROR\_INVALID\_ATTRIBUTE | [GtkBuilder](gtkbuilder#GtkBuilder-struct) found an attribute that it doesn’t understand. | |
| GTK\_BUILDER\_ERROR\_INVALID\_TAG | [GtkBuilder](gtkbuilder#GtkBuilder-struct) found a tag that it doesn’t understand. | |
| GTK\_BUILDER\_ERROR\_MISSING\_PROPERTY\_VALUE | A required property value was missing. | |
| GTK\_BUILDER\_ERROR\_INVALID\_VALUE | [GtkBuilder](gtkbuilder#GtkBuilder-struct) couldn’t parse some attribute value. | |
| GTK\_BUILDER\_ERROR\_VERSION\_MISMATCH | The input file requires a newer version of GTK. | |
| GTK\_BUILDER\_ERROR\_DUPLICATE\_ID | An object id occurred twice. | |
| GTK\_BUILDER\_ERROR\_OBJECT\_TYPE\_REFUSED | A specified object type is of the same type or derived from the type of the composite class being extended with builder XML. | |
| GTK\_BUILDER\_ERROR\_TEMPLATE\_MISMATCH | The wrong type was specified in a composite class’s template XML | |
| GTK\_BUILDER\_ERROR\_INVALID\_PROPERTY | The specified property is unknown for the object class. | |
| GTK\_BUILDER\_ERROR\_INVALID\_SIGNAL | The specified signal is unknown for the object class. | |
| GTK\_BUILDER\_ERROR\_INVALID\_ID | An object id is unknown. | |
| GTK\_BUILDER\_ERROR\_INVALID\_FUNCTION | A function could not be found. This often happens when symbols are set to be kept private. Compiling code with -rdynamic or using the `gmodule-export-2.0` pkgconfig module can fix this problem. | |
### GTK\_BUILDER\_ERROR
```
#define GTK_BUILDER_ERROR (gtk_builder_error_quark ())
```
Property Details
----------------
### The `“current-object”` property
```
“current-object” GObject *
```
The object the builder is evaluating for.
Owner: GtkBuilder
Flags: Read / Write
### The `“scope”` property
```
“scope” [GtkBuilderScope](gtkbuilderscope#GtkBuilderScope-struct) *
```
The scope the builder is operating in
Owner: GtkBuilder
Flags: Read / Write / Construct
### The `“translation-domain”` property
```
“translation-domain” char *
```
The translation domain used when translating property values that have been marked as translatable in interface descriptions. If the translation domain is `NULL`, [GtkBuilder](gtkbuilder#GtkBuilder-struct) uses `gettext()`, otherwise `g_dgettext()`.
Owner: GtkBuilder
Flags: Read / Write
Default value: NULL
| programming_docs |
gtk GtkImage GtkImage
========
GtkImage — A widget displaying an image
Functions
---------
| | |
| --- | --- |
| [GtkWidget](gtkwidget#GtkWidget-struct) \* | [gtk\_image\_new](gtkimage#gtk-image-new) () |
| [GtkWidget](gtkwidget#GtkWidget-struct) \* | [gtk\_image\_new\_from\_file](gtkimage#gtk-image-new-from-file) () |
| [GtkWidget](gtkwidget#GtkWidget-struct) \* | [gtk\_image\_new\_from\_resource](gtkimage#gtk-image-new-from-resource) () |
| [GtkWidget](gtkwidget#GtkWidget-struct) \* | [gtk\_image\_new\_from\_pixbuf](gtkimage#gtk-image-new-from-pixbuf) () |
| [GtkWidget](gtkwidget#GtkWidget-struct) \* | [gtk\_image\_new\_from\_paintable](gtkimage#gtk-image-new-from-paintable) () |
| [GtkWidget](gtkwidget#GtkWidget-struct) \* | [gtk\_image\_new\_from\_icon\_name](gtkimage#gtk-image-new-from-icon-name) () |
| [GtkWidget](gtkwidget#GtkWidget-struct) \* | [gtk\_image\_new\_from\_gicon](gtkimage#gtk-image-new-from-gicon) () |
| void | [gtk\_image\_clear](gtkimage#gtk-image-clear) () |
| void | [gtk\_image\_set\_from\_file](gtkimage#gtk-image-set-from-file) () |
| void | [gtk\_image\_set\_from\_resource](gtkimage#gtk-image-set-from-resource) () |
| void | [gtk\_image\_set\_from\_pixbuf](gtkimage#gtk-image-set-from-pixbuf) () |
| void | [gtk\_image\_set\_from\_paintable](gtkimage#gtk-image-set-from-paintable) () |
| void | [gtk\_image\_set\_from\_icon\_name](gtkimage#gtk-image-set-from-icon-name) () |
| void | [gtk\_image\_set\_from\_gicon](gtkimage#gtk-image-set-from-gicon) () |
| [GtkImageType](gtkimage#GtkImageType) | [gtk\_image\_get\_storage\_type](gtkimage#gtk-image-get-storage-type) () |
| [GdkPaintable](https://developer-old.gnome.org/gtk4/html/GdkPaintable.html#GdkPaintable-struct) \* | [gtk\_image\_get\_paintable](gtkimage#gtk-image-get-paintable) () |
| const char \* | [gtk\_image\_get\_icon\_name](gtkimage#gtk-image-get-icon-name) () |
| GIcon \* | [gtk\_image\_get\_gicon](gtkimage#gtk-image-get-gicon) () |
| void | [gtk\_image\_set\_pixel\_size](gtkimage#gtk-image-set-pixel-size) () |
| int | [gtk\_image\_get\_pixel\_size](gtkimage#gtk-image-get-pixel-size) () |
| void | [gtk\_image\_set\_icon\_size](gtkimage#gtk-image-set-icon-size) () |
| [GtkIconSize](gtk4-standard-enumerations#GtkIconSize) | [gtk\_image\_get\_icon\_size](gtkimage#gtk-image-get-icon-size) () |
Properties
----------
| | | |
| --- | --- | --- |
| char \* | [file](gtkimage#GtkImage--file) | Read / Write |
| GIcon \* | [gicon](gtkimage#GtkImage--gicon) | Read / Write |
| char \* | [icon-name](gtkimage#GtkImage--icon-name) | Read / Write |
| [GtkIconSize](gtk4-standard-enumerations#GtkIconSize) | [icon-size](gtkimage#GtkImage--icon-size) | Read / Write |
| [GdkPaintable](https://developer-old.gnome.org/gtk4/html/GdkPaintable.html#GdkPaintable-struct) \* | [paintable](gtkimage#GtkImage--paintable) | Read / Write |
| int | [pixel-size](gtkimage#GtkImage--pixel-size) | Read / Write |
| char \* | [resource](gtkimage#GtkImage--resource) | Read / Write |
| [GtkImageType](gtkimage#GtkImageType) | [storage-type](gtkimage#GtkImage--storage-type) | Read |
| gboolean | [use-fallback](gtkimage#GtkImage--use-fallback) | Read / Write |
Types and Values
----------------
| | |
| --- | --- |
| | [GtkImage](gtkimage#GtkImage-struct) |
| enum | [GtkImageType](gtkimage#GtkImageType) |
Object Hierarchy
----------------
```
GObject
╰── GInitiallyUnowned
╰── [GtkWidget](gtkwidget#GtkWidget-struct)
╰── GtkImage
```
Implemented Interfaces
----------------------
GtkImage implements [GtkAccessible](gtkaccessible#GtkAccessible-struct), [GtkBuildable](gtkbuildable#GtkBuildable-struct) and [GtkConstraintTarget](gtkconstraint#GtkConstraintTarget-struct).
Includes
--------
```
#include <gtk/gtk.h>
```
Description
-----------
The [GtkImage](gtkimage#GtkImage-struct) widget displays an image. Various kinds of object can be displayed as an image; most typically, you would load a [GdkTexture](https://developer-old.gnome.org/gtk4/html/gdk4-Textures.html#GdkTexture-struct) from a file, and then display that. There’s a convenience function to do this, [`gtk_image_new_from_file()`](gtkimage#gtk-image-new-from-file), used as follows:
```
GtkWidget *image;
image = gtk_image_new_from_file ("myfile.png");
```
| If the file isn’t loaded successfully, the image will contain a “broken image” icon similar to that used in many web browsers. If you want to handle errors in loading the file yourself, for example by displaying an error message, then load the image with [`gdk_texture_new_from_file()`](https://developer-old.gnome.org/gtk4/html/gdk4-Textures.html#gdk-texture-new-from-file), then create the [GtkImage](gtkimage#GtkImage-struct) with [`gtk_image_new_from_paintable()`](gtkimage#gtk-image-new-from-paintable).
Sometimes an application will want to avoid depending on external data files, such as image files. See the documentation of GResource for details. In this case, the [“resource”](gtkimage#GtkImage--resource), [`gtk_image_new_from_resource()`](gtkimage#gtk-image-new-from-resource) and [`gtk_image_set_from_resource()`](gtkimage#gtk-image-set-from-resource) should be used.
GtkImage displays its image as an icon, with a size that is determined by the application. See [GtkPicture](gtkpicture#GtkPicture-struct) if you want to show an image at is actual size.
### CSS nodes
GtkImage has a single CSS node with the name image. The style classes .normal-icons or .large-icons may appear, depending on the [“icon-size”](gtkimage#GtkImage--icon-size) property.
### Accessibility
GtkImage uses the [GTK\_ACCESSIBLE\_ROLE\_IMG](gtkaccessible#GTK-ACCESSIBLE-ROLE-IMG:CAPS) role.
Functions
---------
### gtk\_image\_new ()
```
[GtkWidget](gtkwidget#GtkWidget-struct) *
gtk_image_new (*`void`*);
```
Creates a new empty [GtkImage](gtkimage#GtkImage-struct) widget.
#### Returns
a newly created [GtkImage](gtkimage#GtkImage-struct) widget.
### gtk\_image\_new\_from\_file ()
```
[GtkWidget](gtkwidget#GtkWidget-struct) *
gtk_image_new_from_file (*`const char *filename`*);
```
Creates a new [GtkImage](gtkimage#GtkImage-struct) displaying the file *`filename`* . If the file isn’t found or can’t be loaded, the resulting [GtkImage](gtkimage#GtkImage-struct) will display a “broken image” icon. This function never returns `NULL`, it always returns a valid [GtkImage](gtkimage#GtkImage-struct) widget.
If you need to detect failures to load the file, use [`gdk_texture_new_from_file()`](https://developer-old.gnome.org/gtk4/html/gdk4-Textures.html#gdk-texture-new-from-file) to load the file yourself, then create the [GtkImage](gtkimage#GtkImage-struct) from the texture.
The storage type ([`gtk_image_get_storage_type()`](gtkimage#gtk-image-get-storage-type)) of the returned image is not defined, it will be whatever is appropriate for displaying the file.
#### Parameters
| | | |
| --- | --- | --- |
| filename | a filename. | [type filename] |
#### Returns
a new [GtkImage](gtkimage#GtkImage-struct)
### gtk\_image\_new\_from\_resource ()
```
[GtkWidget](gtkwidget#GtkWidget-struct) *
gtk_image_new_from_resource (*`const char *resource_path`*);
```
Creates a new [GtkImage](gtkimage#GtkImage-struct) displaying the resource file *`resource_path`* . If the file isn’t found or can’t be loaded, the resulting [GtkImage](gtkimage#GtkImage-struct) will display a “broken image” icon. This function never returns `NULL`, it always returns a valid [GtkImage](gtkimage#GtkImage-struct) widget.
If you need to detect failures to load the file, use [`gdk_pixbuf_new_from_file()`](https://developer-old.gnome.org/gdk-pixbuf/stable/gdk-pixbuf-File-Loading.html#gdk-pixbuf-new-from-file) to load the file yourself, then create the [GtkImage](gtkimage#GtkImage-struct) from the pixbuf.
The storage type ([`gtk_image_get_storage_type()`](gtkimage#gtk-image-get-storage-type)) of the returned image is not defined, it will be whatever is appropriate for displaying the file.
#### Parameters
| | | |
| --- | --- | --- |
| resource\_path | a resource path | |
#### Returns
a new [GtkImage](gtkimage#GtkImage-struct)
### gtk\_image\_new\_from\_pixbuf ()
```
[GtkWidget](gtkwidget#GtkWidget-struct) *
gtk_image_new_from_pixbuf (*`[GdkPixbuf](https://developer-old.gnome.org/gdk-pixbuf/stable/gdk-pixbuf-The-GdkPixbuf-Structure.html#GdkPixbuf-struct) *pixbuf`*);
```
Creates a new [GtkImage](gtkimage#GtkImage-struct) displaying *`pixbuf`* . The [GtkImage](gtkimage#GtkImage-struct) does not assume a reference to the pixbuf; you still need to unref it if you own references. [GtkImage](gtkimage#GtkImage-struct) will add its own reference rather than adopting yours.
This is a helper for [`gtk_image_new_from_paintable()`](gtkimage#gtk-image-new-from-paintable), and you can't get back the exact pixbuf once this is called, only a texture.
Note that this function just creates an [GtkImage](gtkimage#GtkImage-struct) from the pixbuf. The [GtkImage](gtkimage#GtkImage-struct) created will not react to state changes. Should you want that, you should use [`gtk_image_new_from_icon_name()`](gtkimage#gtk-image-new-from-icon-name).
#### Parameters
| | | |
| --- | --- | --- |
| pixbuf | a [GdkPixbuf](https://developer-old.gnome.org/gdk-pixbuf/stable/gdk-pixbuf-The-GdkPixbuf-Structure.html#GdkPixbuf-struct), or `NULL`. | [allow-none] |
#### Returns
a new [GtkImage](gtkimage#GtkImage-struct)
### gtk\_image\_new\_from\_paintable ()
```
[GtkWidget](gtkwidget#GtkWidget-struct) *
gtk_image_new_from_paintable (*`[GdkPaintable](https://developer-old.gnome.org/gtk4/html/GdkPaintable.html#GdkPaintable-struct) *paintable`*);
```
Creates a new [GtkImage](gtkimage#GtkImage-struct) displaying *`paintable`* . The [GtkImage](gtkimage#GtkImage-struct) does not assume a reference to the paintable; you still need to unref it if you own references. [GtkImage](gtkimage#GtkImage-struct) will add its own reference rather than adopting yours.
The [GtkImage](gtkimage#GtkImage-struct) will track changes to the *`paintable`* and update its size and contents in response to it.
#### Parameters
| | | |
| --- | --- | --- |
| paintable | a [GdkPaintable](https://developer-old.gnome.org/gtk4/html/GdkPaintable.html#GdkPaintable-struct), or `NULL`. | [allow-none] |
#### Returns
a new [GtkImage](gtkimage#GtkImage-struct)
### gtk\_image\_new\_from\_icon\_name ()
```
[GtkWidget](gtkwidget#GtkWidget-struct) *
gtk_image_new_from_icon_name (*`const char *icon_name`*);
```
Creates a [GtkImage](gtkimage#GtkImage-struct) displaying an icon from the current icon theme. If the icon name isn’t known, a “broken image” icon will be displayed instead. If the current icon theme is changed, the icon will be updated appropriately.
Note: Before 3.94, this function was taking an extra icon size argument. See [`gtk_image_set_icon_size()`](gtkimage#gtk-image-set-icon-size) for another way to set the icon size.
#### Parameters
| | | |
| --- | --- | --- |
| icon\_name | an icon name or `NULL`. | [nullable] |
#### Returns
a new [GtkImage](gtkimage#GtkImage-struct) displaying the themed icon
### gtk\_image\_new\_from\_gicon ()
```
[GtkWidget](gtkwidget#GtkWidget-struct) *
gtk_image_new_from_gicon (*`GIcon *icon`*);
```
Creates a [GtkImage](gtkimage#GtkImage-struct) displaying an icon from the current icon theme. If the icon name isn’t known, a “broken image” icon will be displayed instead. If the current icon theme is changed, the icon will be updated appropriately.
Note: Before 3.94, this function was taking an extra icon size argument. See [`gtk_image_set_icon_size()`](gtkimage#gtk-image-set-icon-size) for another way to set the icon size.
#### Parameters
| | | |
| --- | --- | --- |
| icon | an icon | |
#### Returns
a new [GtkImage](gtkimage#GtkImage-struct) displaying the themed icon
### gtk\_image\_clear ()
```
void
gtk_image_clear (*`[GtkImage](gtkimage#GtkImage-struct) *image`*);
```
Resets the image to be empty.
#### Parameters
| | | |
| --- | --- | --- |
| image | a [GtkImage](gtkimage#GtkImage-struct) | |
### gtk\_image\_set\_from\_file ()
```
void
gtk_image_set_from_file (*`[GtkImage](gtkimage#GtkImage-struct) *image`*,
*`const char *filename`*);
```
See [`gtk_image_new_from_file()`](gtkimage#gtk-image-new-from-file) for details.
#### Parameters
| | | |
| --- | --- | --- |
| image | a [GtkImage](gtkimage#GtkImage-struct) | |
| filename | a filename or `NULL`. | [type filename][allow-none] |
### gtk\_image\_set\_from\_resource ()
```
void
gtk_image_set_from_resource (*`[GtkImage](gtkimage#GtkImage-struct) *image`*,
*`const char *resource_path`*);
```
See [`gtk_image_new_from_resource()`](gtkimage#gtk-image-new-from-resource) for details.
#### Parameters
| | | |
| --- | --- | --- |
| image | a [GtkImage](gtkimage#GtkImage-struct) | |
| resource\_path | a resource path or `NULL`. | [allow-none] |
### gtk\_image\_set\_from\_pixbuf ()
```
void
gtk_image_set_from_pixbuf (*`[GtkImage](gtkimage#GtkImage-struct) *image`*,
*`[GdkPixbuf](https://developer-old.gnome.org/gdk-pixbuf/stable/gdk-pixbuf-The-GdkPixbuf-Structure.html#GdkPixbuf-struct) *pixbuf`*);
```
See [`gtk_image_new_from_pixbuf()`](gtkimage#gtk-image-new-from-pixbuf) for details.
Note: This is a helper for [`gtk_image_set_from_paintable()`](gtkimage#gtk-image-set-from-paintable), and you can't get back the exact pixbuf once this is called, only a paintable.
#### Parameters
| | | |
| --- | --- | --- |
| image | a [GtkImage](gtkimage#GtkImage-struct) | |
| pixbuf | a [GdkPixbuf](https://developer-old.gnome.org/gdk-pixbuf/stable/gdk-pixbuf-The-GdkPixbuf-Structure.html#GdkPixbuf-struct) or `NULL`. | [allow-none] |
### gtk\_image\_set\_from\_paintable ()
```
void
gtk_image_set_from_paintable (*`[GtkImage](gtkimage#GtkImage-struct) *image`*,
*`[GdkPaintable](https://developer-old.gnome.org/gtk4/html/GdkPaintable.html#GdkPaintable-struct) *paintable`*);
```
See [`gtk_image_new_from_paintable()`](gtkimage#gtk-image-new-from-paintable) for details.
#### Parameters
| | | |
| --- | --- | --- |
| image | a [GtkImage](gtkimage#GtkImage-struct) | |
| paintable | a [GdkPaintable](https://developer-old.gnome.org/gtk4/html/GdkPaintable.html#GdkPaintable-struct) or `NULL`. | [nullable] |
### gtk\_image\_set\_from\_icon\_name ()
```
void
gtk_image_set_from_icon_name (*`[GtkImage](gtkimage#GtkImage-struct) *image`*,
*`const char *icon_name`*);
```
See [`gtk_image_new_from_icon_name()`](gtkimage#gtk-image-new-from-icon-name) for details.
Note: Before 3.94, this function was taking an extra icon size argument. See [`gtk_image_set_icon_size()`](gtkimage#gtk-image-set-icon-size) for another way to set the icon size.
#### Parameters
| | | |
| --- | --- | --- |
| image | a [GtkImage](gtkimage#GtkImage-struct) | |
| icon\_name | an icon name or `NULL`. | [nullable] |
### gtk\_image\_set\_from\_gicon ()
```
void
gtk_image_set_from_gicon (*`[GtkImage](gtkimage#GtkImage-struct) *image`*,
*`GIcon *icon`*);
```
See [`gtk_image_new_from_gicon()`](gtkimage#gtk-image-new-from-gicon) for details.
Note: Before 3.94, this function was taking an extra icon size argument. See [`gtk_image_set_icon_size()`](gtkimage#gtk-image-set-icon-size) for another way to set the icon size.
#### Parameters
| | | |
| --- | --- | --- |
| image | a [GtkImage](gtkimage#GtkImage-struct) | |
| icon | an icon | |
### gtk\_image\_get\_storage\_type ()
```
[GtkImageType](gtkimage#GtkImageType)
gtk_image_get_storage_type (*`[GtkImage](gtkimage#GtkImage-struct) *image`*);
```
Gets the type of representation being used by the [GtkImage](gtkimage#GtkImage-struct) to store image data. If the [GtkImage](gtkimage#GtkImage-struct) has no image data, the return value will be [`GTK_IMAGE_EMPTY`](gtkimage#GTK-IMAGE-EMPTY:CAPS).
#### Parameters
| | | |
| --- | --- | --- |
| image | a [GtkImage](gtkimage#GtkImage-struct) | |
#### Returns
image representation being used
### gtk\_image\_get\_paintable ()
```
[GdkPaintable](https://developer-old.gnome.org/gtk4/html/GdkPaintable.html#GdkPaintable-struct) *
gtk_image_get_paintable (*`[GtkImage](gtkimage#GtkImage-struct) *image`*);
```
Gets the image [GdkPaintable](https://developer-old.gnome.org/gtk4/html/GdkPaintable.html#GdkPaintable-struct) being displayed by the [GtkImage](gtkimage#GtkImage-struct). The storage type of the image must be [`GTK_IMAGE_EMPTY`](gtkimage#GTK-IMAGE-EMPTY:CAPS) or [`GTK_IMAGE_PAINTABLE`](gtkimage#GTK-IMAGE-PAINTABLE:CAPS) (see [`gtk_image_get_storage_type()`](gtkimage#gtk-image-get-storage-type)). The caller of this function does not own a reference to the returned paintable.
#### Parameters
| | | |
| --- | --- | --- |
| image | a [GtkImage](gtkimage#GtkImage-struct) | |
#### Returns
the displayed paintable, or `NULL` if the image is empty.
[nullable][transfer none]
### gtk\_image\_get\_icon\_name ()
```
const char *
gtk_image_get_icon_name (*`[GtkImage](gtkimage#GtkImage-struct) *image`*);
```
Gets the icon name and size being displayed by the [GtkImage](gtkimage#GtkImage-struct). The storage type of the image must be [`GTK_IMAGE_EMPTY`](gtkimage#GTK-IMAGE-EMPTY:CAPS) or [`GTK_IMAGE_ICON_NAME`](gtkimage#GTK-IMAGE-ICON-NAME:CAPS) (see [`gtk_image_get_storage_type()`](gtkimage#gtk-image-get-storage-type)). The returned string is owned by the [GtkImage](gtkimage#GtkImage-struct) and should not be freed.
Note: This function was changed in 3.94 not to use out parameters anymore, but return the icon name directly. See [`gtk_image_get_icon_size()`](gtkimage#gtk-image-get-icon-size) for a way to get the icon size.
#### Parameters
| | | |
| --- | --- | --- |
| image | a [GtkImage](gtkimage#GtkImage-struct) | |
#### Returns
the icon name, or `NULL`.
[transfer none][allow-none]
### gtk\_image\_get\_gicon ()
```
GIcon *
gtk_image_get_gicon (*`[GtkImage](gtkimage#GtkImage-struct) *image`*);
```
Gets the GIcon and size being displayed by the [GtkImage](gtkimage#GtkImage-struct). The storage type of the image must be [`GTK_IMAGE_EMPTY`](gtkimage#GTK-IMAGE-EMPTY:CAPS) or [`GTK_IMAGE_GICON`](gtkimage#GTK-IMAGE-GICON:CAPS) (see [`gtk_image_get_storage_type()`](gtkimage#gtk-image-get-storage-type)). The caller of this function does not own a reference to the returned GIcon.
Note: This function was changed in 3.94 not to use out parameters anymore, but return the GIcon directly. See [`gtk_image_get_icon_size()`](gtkimage#gtk-image-get-icon-size) for a way to get the icon size.
#### Parameters
| | | |
| --- | --- | --- |
| image | a [GtkImage](gtkimage#GtkImage-struct) | |
#### Returns
a GIcon, or `NULL`.
[transfer none][allow-none]
### gtk\_image\_set\_pixel\_size ()
```
void
gtk_image_set_pixel_size (*`[GtkImage](gtkimage#GtkImage-struct) *image`*,
*`int pixel_size`*);
```
Sets the pixel size to use for named icons. If the pixel size is set to a value != -1, it is used instead of the icon size set by [`gtk_image_set_from_icon_name()`](gtkimage#gtk-image-set-from-icon-name).
#### Parameters
| | | |
| --- | --- | --- |
| image | a [GtkImage](gtkimage#GtkImage-struct) | |
| pixel\_size | the new pixel size | |
### gtk\_image\_get\_pixel\_size ()
```
int
gtk_image_get_pixel_size (*`[GtkImage](gtkimage#GtkImage-struct) *image`*);
```
Gets the pixel size used for named icons.
#### Parameters
| | | |
| --- | --- | --- |
| image | a [GtkImage](gtkimage#GtkImage-struct) | |
#### Returns
the pixel size used for named icons.
### gtk\_image\_set\_icon\_size ()
```
void
gtk_image_set_icon_size (*`[GtkImage](gtkimage#GtkImage-struct) *image`*,
*`[GtkIconSize](gtk4-standard-enumerations#GtkIconSize) icon_size`*);
```
Suggests an icon size to the theme for named icons.
#### Parameters
| | | |
| --- | --- | --- |
| image | a [GtkImage](gtkimage#GtkImage-struct) | |
| icon\_size | the new icon size | |
### gtk\_image\_get\_icon\_size ()
```
[GtkIconSize](gtk4-standard-enumerations#GtkIconSize)
gtk_image_get_icon_size (*`[GtkImage](gtkimage#GtkImage-struct) *image`*);
```
Gets the icon size used by the *`image`* when rendering icons.
#### Parameters
| | | |
| --- | --- | --- |
| image | a [GtkImage](gtkimage#GtkImage-struct) | |
#### Returns
the image size used by icons
Types and Values
----------------
### GtkImage
```
typedef struct _GtkImage GtkImage;
```
### enum GtkImageType
Describes the image data representation used by a [GtkImage](gtkimage#GtkImage-struct). If you want to get the image from the widget, you can only get the currently-stored representation. e.g. if the [`gtk_image_get_storage_type()`](gtkimage#gtk-image-get-storage-type) returns [GTK\_IMAGE\_PAINTABLE](gtkimage#GTK-IMAGE-PAINTABLE:CAPS), then you can call [`gtk_image_get_paintable()`](gtkimage#gtk-image-get-paintable). For empty images, you can request any storage type (call any of the "get" functions), but they will all return `NULL` values.
#### Members
| | | |
| --- | --- | --- |
| GTK\_IMAGE\_EMPTY | there is no image displayed by the widget | |
| GTK\_IMAGE\_ICON\_NAME | the widget contains a named icon | |
| GTK\_IMAGE\_GICON | the widget contains a GIcon | |
| GTK\_IMAGE\_PAINTABLE | the widget contains a [GdkPaintable](https://developer-old.gnome.org/gtk4/html/GdkPaintable.html#GdkPaintable-struct) | |
Property Details
----------------
### The `“file”` property
```
“file” char *
```
Filename to load and display.
Owner: GtkImage
Flags: Read / Write
Default value: NULL
### The `“gicon”` property
```
“gicon” GIcon *
```
The GIcon displayed in the GtkImage. For themed icons, If the icon theme is changed, the image will be updated automatically.
Owner: GtkImage
Flags: Read / Write
### The `“icon-name”` property
```
“icon-name” char *
```
The name of the icon in the icon theme. If the icon theme is changed, the image will be updated automatically.
Owner: GtkImage
Flags: Read / Write
Default value: NULL
### The `“icon-size”` property
```
“icon-size” [GtkIconSize](gtk4-standard-enumerations#GtkIconSize)
```
Symbolic size to use for icon set or named icon.
Owner: GtkImage
Flags: Read / Write
Default value: GTK\_ICON\_SIZE\_INHERIT
### The `“paintable”` property
```
“paintable” [GdkPaintable](https://developer-old.gnome.org/gtk4/html/GdkPaintable.html#GdkPaintable-struct) *
```
A GdkPaintable to display.
Owner: GtkImage
Flags: Read / Write
### The `“pixel-size”` property
```
“pixel-size” int
```
The "pixel-size" property can be used to specify a fixed size overriding the [“icon-size”](gtkimage#GtkImage--icon-size) property for images of type [`GTK_IMAGE_ICON_NAME`](gtkimage#GTK-IMAGE-ICON-NAME:CAPS).
Owner: GtkImage
Flags: Read / Write
Allowed values: >= -1
Default value: -1
### The `“resource”` property
```
“resource” char *
```
A path to a resource file to display.
Owner: GtkImage
Flags: Read / Write
Default value: NULL
### The `“storage-type”` property
```
“storage-type” [GtkImageType](gtkimage#GtkImageType)
```
The representation being used for image data.
Owner: GtkImage
Flags: Read
Default value: GTK\_IMAGE\_EMPTY
### The `“use-fallback”` property
```
“use-fallback” gboolean
```
Whether the icon displayed in the GtkImage will use standard icon names fallback. The value of this property is only relevant for images of type [`GTK_IMAGE_ICON_NAME`](gtkimage#GTK-IMAGE-ICON-NAME:CAPS) and [`GTK_IMAGE_GICON`](gtkimage#GTK-IMAGE-GICON:CAPS).
Owner: GtkImage
Flags: Read / Write
Default value: FALSE
| programming_docs |
gtk GtkCenterBox GtkCenterBox
============
GtkCenterBox — A centering container
Functions
---------
| | |
| --- | --- |
| [GtkWidget](gtkwidget#GtkWidget-struct) \* | [gtk\_center\_box\_new](gtkcenterbox#gtk-center-box-new) () |
| void | [gtk\_center\_box\_set\_start\_widget](gtkcenterbox#gtk-center-box-set-start-widget) () |
| void | [gtk\_center\_box\_set\_center\_widget](gtkcenterbox#gtk-center-box-set-center-widget) () |
| void | [gtk\_center\_box\_set\_end\_widget](gtkcenterbox#gtk-center-box-set-end-widget) () |
| [GtkWidget](gtkwidget#GtkWidget-struct) \* | [gtk\_center\_box\_get\_start\_widget](gtkcenterbox#gtk-center-box-get-start-widget) () |
| [GtkWidget](gtkwidget#GtkWidget-struct) \* | [gtk\_center\_box\_get\_center\_widget](gtkcenterbox#gtk-center-box-get-center-widget) () |
| [GtkWidget](gtkwidget#GtkWidget-struct) \* | [gtk\_center\_box\_get\_end\_widget](gtkcenterbox#gtk-center-box-get-end-widget) () |
| void | [gtk\_center\_box\_set\_baseline\_position](gtkcenterbox#gtk-center-box-set-baseline-position) () |
| [GtkBaselinePosition](gtk4-standard-enumerations#GtkBaselinePosition) | [gtk\_center\_box\_get\_baseline\_position](gtkcenterbox#gtk-center-box-get-baseline-position) () |
Properties
----------
| | | |
| --- | --- | --- |
| [GtkBaselinePosition](gtk4-standard-enumerations#GtkBaselinePosition) | [baseline-position](gtkcenterbox#GtkCenterBox--baseline-position) | Read / Write |
Types and Values
----------------
| | |
| --- | --- |
| | [GtkCenterBox](gtkcenterbox#GtkCenterBox-struct) |
Object Hierarchy
----------------
```
GObject
╰── GInitiallyUnowned
╰── [GtkWidget](gtkwidget#GtkWidget-struct)
╰── GtkCenterBox
```
Implemented Interfaces
----------------------
GtkCenterBox implements [GtkAccessible](gtkaccessible#GtkAccessible-struct), [GtkBuildable](gtkbuildable#GtkBuildable-struct), [GtkConstraintTarget](gtkconstraint#GtkConstraintTarget-struct) and [GtkOrientable](gtk4-orientable#GtkOrientable-struct).
Includes
--------
```
#include <gtk/gtk.h>
```
Description
-----------
The GtkCenterBox widget arranges three children in a horizontal or vertical arrangement, keeping the middle child centered as well as possible.
To add children to GtkCenterBox, use [`gtk_center_box_set_start_widget()`](gtkcenterbox#gtk-center-box-set-start-widget), [`gtk_center_box_set_center_widget()`](gtkcenterbox#gtk-center-box-set-center-widget) and [`gtk_center_box_set_end_widget()`](gtkcenterbox#gtk-center-box-set-end-widget).
The sizing and positioning of children can be influenced with the align and expand properties of the children.
### GtkCenterBox as GtkBuildable
The GtkCenterBox implementation of the [GtkBuildable](gtkbuildable#GtkBuildable-struct) interface supports placing children in the 3 positions by specifying “start”, “center” or “end” as the “type” attribute of a <child> element.
### CSS nodes
GtkCenterBox uses a single CSS node with the name “box”,
The first child of the [GtkCenterBox](https://developer-old.gnome.org/usr/share/gtk-doc/html/gtk4/gtk4-GtkCenterBox.html#GtkCenterBox) will be allocated depending on the text direction, i.e. in left-to-right layouts it will be allocated on the left and in right-to-left layouts on the right.
In vertical orientation, the nodes of the children are arranged from top to bottom.
### Accessibility
GtkCenterBox uses the [`GTK_ACCESSIBLE_ROLE_GROUP`](gtkaccessible#GTK-ACCESSIBLE-ROLE-GROUP:CAPS) role.
Functions
---------
### gtk\_center\_box\_new ()
```
[GtkWidget](gtkwidget#GtkWidget-struct) *
gtk_center_box_new (*`void`*);
```
Creates a new [GtkCenterBox](https://developer-old.gnome.org/usr/share/gtk-doc/html/gtk4/gtk4-GtkCenterBox.html#GtkCenterBox).
#### Returns
the new [GtkCenterBox](https://developer-old.gnome.org/usr/share/gtk-doc/html/gtk4/gtk4-GtkCenterBox.html#GtkCenterBox).
### gtk\_center\_box\_set\_start\_widget ()
```
void
gtk_center_box_set_start_widget (*`[GtkCenterBox](https://developer-old.gnome.org/usr/share/gtk-doc/html/gtk4/gtk4-GtkCenterBox.html#GtkCenterBox) *self`*,
*`[GtkWidget](gtkwidget#GtkWidget-struct) *child`*);
```
Sets the start widget. To remove the existing start widget, pass `NULL`.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkCenterBox](https://developer-old.gnome.org/usr/share/gtk-doc/html/gtk4/gtk4-GtkCenterBox.html#GtkCenterBox) | |
| child | the new start widget, or `NULL`. | [nullable] |
### gtk\_center\_box\_set\_center\_widget ()
```
void
gtk_center_box_set_center_widget (*`[GtkCenterBox](https://developer-old.gnome.org/usr/share/gtk-doc/html/gtk4/gtk4-GtkCenterBox.html#GtkCenterBox) *self`*,
*`[GtkWidget](gtkwidget#GtkWidget-struct) *child`*);
```
Sets the center widget. To remove the existing center widget, pas `NULL`.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkCenterBox](https://developer-old.gnome.org/usr/share/gtk-doc/html/gtk4/gtk4-GtkCenterBox.html#GtkCenterBox) | |
| child | the new center widget, or `NULL`. | [nullable] |
### gtk\_center\_box\_set\_end\_widget ()
```
void
gtk_center_box_set_end_widget (*`[GtkCenterBox](https://developer-old.gnome.org/usr/share/gtk-doc/html/gtk4/gtk4-GtkCenterBox.html#GtkCenterBox) *self`*,
*`[GtkWidget](gtkwidget#GtkWidget-struct) *child`*);
```
Sets the end widget. To remove the existing end widget, pass `NULL`.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkCenterBox](https://developer-old.gnome.org/usr/share/gtk-doc/html/gtk4/gtk4-GtkCenterBox.html#GtkCenterBox) | |
| child | the new end widget, or `NULL`. | [nullable] |
### gtk\_center\_box\_get\_start\_widget ()
```
[GtkWidget](gtkwidget#GtkWidget-struct) *
gtk_center_box_get_start_widget (*`[GtkCenterBox](https://developer-old.gnome.org/usr/share/gtk-doc/html/gtk4/gtk4-GtkCenterBox.html#GtkCenterBox) *self`*);
```
Gets the start widget, or `NULL` if there is none.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkCenterBox](https://developer-old.gnome.org/usr/share/gtk-doc/html/gtk4/gtk4-GtkCenterBox.html#GtkCenterBox) | |
#### Returns
the start widget.
[transfer none][nullable]
### gtk\_center\_box\_get\_center\_widget ()
```
[GtkWidget](gtkwidget#GtkWidget-struct) *
gtk_center_box_get_center_widget (*`[GtkCenterBox](https://developer-old.gnome.org/usr/share/gtk-doc/html/gtk4/gtk4-GtkCenterBox.html#GtkCenterBox) *self`*);
```
Gets the center widget, or `NULL` if there is none.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkCenterBox](https://developer-old.gnome.org/usr/share/gtk-doc/html/gtk4/gtk4-GtkCenterBox.html#GtkCenterBox) | |
#### Returns
the center widget.
[transfer none][nullable]
### gtk\_center\_box\_get\_end\_widget ()
```
[GtkWidget](gtkwidget#GtkWidget-struct) *
gtk_center_box_get_end_widget (*`[GtkCenterBox](https://developer-old.gnome.org/usr/share/gtk-doc/html/gtk4/gtk4-GtkCenterBox.html#GtkCenterBox) *self`*);
```
Gets the end widget, or `NULL` if there is none.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkCenterBox](https://developer-old.gnome.org/usr/share/gtk-doc/html/gtk4/gtk4-GtkCenterBox.html#GtkCenterBox) | |
#### Returns
the end widget.
[transfer none][nullable]
### gtk\_center\_box\_set\_baseline\_position ()
```
void
gtk_center_box_set_baseline_position (*`[GtkCenterBox](https://developer-old.gnome.org/usr/share/gtk-doc/html/gtk4/gtk4-GtkCenterBox.html#GtkCenterBox) *self`*,
*`[GtkBaselinePosition](gtk4-standard-enumerations#GtkBaselinePosition) position`*);
```
Sets the baseline position of a center box.
This affects only horizontal boxes with at least one baseline aligned child. If there is more vertical space available than requested, and the baseline is not allocated by the parent then *`position`* is used to allocate the baseline wrt. the extra space available.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkCenterBox](https://developer-old.gnome.org/usr/share/gtk-doc/html/gtk4/gtk4-GtkCenterBox.html#GtkCenterBox) | |
| position | a [GtkBaselinePosition](gtk4-standard-enumerations#GtkBaselinePosition) | |
### gtk\_center\_box\_get\_baseline\_position ()
```
[GtkBaselinePosition](gtk4-standard-enumerations#GtkBaselinePosition)
gtk_center_box_get_baseline_position (*`[GtkCenterBox](https://developer-old.gnome.org/usr/share/gtk-doc/html/gtk4/gtk4-GtkCenterBox.html#GtkCenterBox) *self`*);
```
Gets the value set by [`gtk_center_box_set_baseline_position()`](gtkcenterbox#gtk-center-box-set-baseline-position).
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkCenterBox](https://developer-old.gnome.org/usr/share/gtk-doc/html/gtk4/gtk4-GtkCenterBox.html#GtkCenterBox) | |
#### Returns
the baseline position
Types and Values
----------------
### GtkCenterBox
```
typedef struct _GtkCenterBox GtkCenterBox;
```
Property Details
----------------
### The `“baseline-position”` property
```
“baseline-position” [GtkBaselinePosition](gtk4-standard-enumerations#GtkBaselinePosition)
```
The position of the baseline aligned widgets if extra space is available.
Owner: GtkCenterBox
Flags: Read / Write
Default value: GTK\_BASELINE\_POSITION\_CENTER
See Also
--------
[GtkBox](gtkbox#GtkBox-struct)
gtk GtkSnapshot GtkSnapshot
===========
GtkSnapshot — Auxiliary object for snapshots
Functions
---------
| | |
| --- | --- |
| [GtkSnapshot](gtksnapshot#GtkSnapshot) \* | [gtk\_snapshot\_new](gtksnapshot#gtk-snapshot-new) () |
| [GskRenderNode](https://developer-old.gnome.org/gtk4/html/GskRenderNode.html#GskRenderNode-struct) \* | [gtk\_snapshot\_to\_node](gtksnapshot#gtk-snapshot-to-node) () |
| [GdkPaintable](https://developer-old.gnome.org/gtk4/html/GdkPaintable.html#GdkPaintable-struct) \* | [gtk\_snapshot\_to\_paintable](gtksnapshot#gtk-snapshot-to-paintable) () |
| [GskRenderNode](https://developer-old.gnome.org/gtk4/html/GskRenderNode.html#GskRenderNode-struct) \* | [gtk\_snapshot\_free\_to\_node](gtksnapshot#gtk-snapshot-free-to-node) () |
| [GdkPaintable](https://developer-old.gnome.org/gtk4/html/GdkPaintable.html#GdkPaintable-struct) \* | [gtk\_snapshot\_free\_to\_paintable](gtksnapshot#gtk-snapshot-free-to-paintable) () |
| void | [gtk\_snapshot\_push\_opacity](gtksnapshot#gtk-snapshot-push-opacity) () |
| void | [gtk\_snapshot\_push\_color\_matrix](gtksnapshot#gtk-snapshot-push-color-matrix) () |
| void | [gtk\_snapshot\_push\_repeat](gtksnapshot#gtk-snapshot-push-repeat) () |
| void | [gtk\_snapshot\_push\_clip](gtksnapshot#gtk-snapshot-push-clip) () |
| void | [gtk\_snapshot\_push\_rounded\_clip](gtksnapshot#gtk-snapshot-push-rounded-clip) () |
| void | [gtk\_snapshot\_push\_cross\_fade](gtksnapshot#gtk-snapshot-push-cross-fade) () |
| void | [gtk\_snapshot\_push\_blend](gtksnapshot#gtk-snapshot-push-blend) () |
| void | [gtk\_snapshot\_push\_blur](gtksnapshot#gtk-snapshot-push-blur) () |
| void | [gtk\_snapshot\_push\_shadow](gtksnapshot#gtk-snapshot-push-shadow) () |
| void | [gtk\_snapshot\_push\_debug](gtksnapshot#gtk-snapshot-push-debug) () |
| void | [gtk\_snapshot\_push\_gl\_shader](gtksnapshot#gtk-snapshot-push-gl-shader) () |
| void | [gtk\_snapshot\_pop](gtksnapshot#gtk-snapshot-pop) () |
| void | [gtk\_snapshot\_gl\_shader\_pop\_texture](gtksnapshot#gtk-snapshot-gl-shader-pop-texture) () |
| void | [gtk\_snapshot\_save](gtksnapshot#gtk-snapshot-save) () |
| void | [gtk\_snapshot\_restore](gtksnapshot#gtk-snapshot-restore) () |
| void | [gtk\_snapshot\_transform](gtksnapshot#gtk-snapshot-transform) () |
| void | [gtk\_snapshot\_transform\_matrix](gtksnapshot#gtk-snapshot-transform-matrix) () |
| void | [gtk\_snapshot\_translate](gtksnapshot#gtk-snapshot-translate) () |
| void | [gtk\_snapshot\_translate\_3d](gtksnapshot#gtk-snapshot-translate-3d) () |
| void | [gtk\_snapshot\_rotate](gtksnapshot#gtk-snapshot-rotate) () |
| void | [gtk\_snapshot\_rotate\_3d](gtksnapshot#gtk-snapshot-rotate-3d) () |
| void | [gtk\_snapshot\_scale](gtksnapshot#gtk-snapshot-scale) () |
| void | [gtk\_snapshot\_scale\_3d](gtksnapshot#gtk-snapshot-scale-3d) () |
| void | [gtk\_snapshot\_perspective](gtksnapshot#gtk-snapshot-perspective) () |
| void | [gtk\_snapshot\_append\_node](gtksnapshot#gtk-snapshot-append-node) () |
| [cairo\_t](https://developer-old.gnome.org/cairo/stable/cairo-cairo-t.html#cairo-t) \* | [gtk\_snapshot\_append\_cairo](gtksnapshot#gtk-snapshot-append-cairo) () |
| void | [gtk\_snapshot\_append\_texture](gtksnapshot#gtk-snapshot-append-texture) () |
| void | [gtk\_snapshot\_append\_color](gtksnapshot#gtk-snapshot-append-color) () |
| void | [gtk\_snapshot\_append\_layout](gtksnapshot#gtk-snapshot-append-layout) () |
| void | [gtk\_snapshot\_append\_linear\_gradient](gtksnapshot#gtk-snapshot-append-linear-gradient) () |
| void | [gtk\_snapshot\_append\_repeating\_linear\_gradient](gtksnapshot#gtk-snapshot-append-repeating-linear-gradient) () |
| void | [gtk\_snapshot\_append\_conic\_gradient](gtksnapshot#gtk-snapshot-append-conic-gradient) () |
| void | [gtk\_snapshot\_append\_border](gtksnapshot#gtk-snapshot-append-border) () |
| void | [gtk\_snapshot\_append\_inset\_shadow](gtksnapshot#gtk-snapshot-append-inset-shadow) () |
| void | [gtk\_snapshot\_append\_outset\_shadow](gtksnapshot#gtk-snapshot-append-outset-shadow) () |
| void | [gtk\_snapshot\_append\_radial\_gradient](gtksnapshot#gtk-snapshot-append-radial-gradient) () |
| void | [gtk\_snapshot\_append\_repeating\_radial\_gradient](gtksnapshot#gtk-snapshot-append-repeating-radial-gradient) () |
| void | [gtk\_snapshot\_render\_insertion\_cursor](gtksnapshot#gtk-snapshot-render-insertion-cursor) () |
| void | [gtk\_snapshot\_render\_background](gtksnapshot#gtk-snapshot-render-background) () |
| void | [gtk\_snapshot\_render\_frame](gtksnapshot#gtk-snapshot-render-frame) () |
| void | [gtk\_snapshot\_render\_focus](gtksnapshot#gtk-snapshot-render-focus) () |
| void | [gtk\_snapshot\_render\_layout](gtksnapshot#gtk-snapshot-render-layout) () |
Types and Values
----------------
| | |
| --- | --- |
| typedef | [GtkSnapshot](gtksnapshot#GtkSnapshot) |
Object Hierarchy
----------------
```
GObject
╰── [GdkSnapshot](https://developer-old.gnome.org/gtk4/html/GdkPaintable.html#GdkSnapshot-struct)
╰── GtkSnapshot
```
Includes
--------
```
#include <gtk/gtk.h>
```
Description
-----------
GtkSnapshot is an auxiliary object that assists in creating GskRenderNodes in the [`GdkPaintableInterface.snapshot()`](https://developer-old.gnome.org/gtk4/html/GdkPaintable.html#GdkPaintableInterface.snapshot) vfunc. It functions in a similar way to a cairo context, and maintains a stack of render nodes and their associated transformations.
The node at the top of the stack is the the one that gtk\_snapshot\_append\_… functions operate on. Use the gtk\_snapshot\_push\_… functions and [`gtk_snapshot_pop()`](gtksnapshot#gtk-snapshot-pop) to change the current node.
The typical way to obtain a GtkSnapshot object is as an argument to the [`GtkWidgetClass.snapshot()`](gtkwidget#GtkWidgetClass.snapshot) vfunc. If you need to create your own GtkSnapshot, use [`gtk_snapshot_new()`](gtksnapshot#gtk-snapshot-new).
Functions
---------
### gtk\_snapshot\_new ()
```
[GtkSnapshot](gtksnapshot#GtkSnapshot) *
gtk_snapshot_new (*`void`*);
```
Creates a new [GtkSnapshot](gtksnapshot#GtkSnapshot).
#### Returns
a newly-allocated [GtkSnapshot](gtksnapshot#GtkSnapshot)
### gtk\_snapshot\_to\_node ()
```
[GskRenderNode](https://developer-old.gnome.org/gtk4/html/GskRenderNode.html#GskRenderNode-struct) *
gtk_snapshot_to_node (*`[GtkSnapshot](gtksnapshot#GtkSnapshot) *snapshot`*);
```
Returns the render node that was constructed by *`snapshot`* . After calling this function, it is no longer possible to add more nodes to *`snapshot`* . The only function that should be called after this is `g_object_unref()`.
#### Parameters
| | | |
| --- | --- | --- |
| snapshot | a [GtkSnapshot](gtksnapshot#GtkSnapshot) | |
#### Returns
the constructed [GskRenderNode](https://developer-old.gnome.org/gtk4/html/GskRenderNode.html#GskRenderNode-struct).
[transfer full]
### gtk\_snapshot\_to\_paintable ()
```
[GdkPaintable](https://developer-old.gnome.org/gtk4/html/GdkPaintable.html#GdkPaintable-struct) *
gtk_snapshot_to_paintable (*`[GtkSnapshot](gtksnapshot#GtkSnapshot) *snapshot`*,
*`const [graphene\_size\_t](https://developer-old.gnome.org/usr/share/gtk-doc/html/graphene/graphene-Size.html#graphene-size-t) *size`*);
```
Returns a paintable encapsulating the render node that was constructed by *`snapshot`* . After calling this function, it is no longer possible to add more nodes to *`snapshot`* . The only function that should be called after this is `g_object_unref()`.
#### Parameters
| | | |
| --- | --- | --- |
| snapshot | a [GtkSnapshot](gtksnapshot#GtkSnapshot) | |
| size | The size of the resulting paintable or `NULL` to use the bounds of the snapshot. | [allow-none] |
#### Returns
a new [GdkPaintable](https://developer-old.gnome.org/gtk4/html/GdkPaintable.html#GdkPaintable-struct).
[transfer full]
### gtk\_snapshot\_free\_to\_node ()
```
[GskRenderNode](https://developer-old.gnome.org/gtk4/html/GskRenderNode.html#GskRenderNode-struct) *
gtk_snapshot_free_to_node (*`[GtkSnapshot](gtksnapshot#GtkSnapshot) *snapshot`*);
```
Returns the node that was constructed by *`snapshot`* and frees *`snapshot`* .
[skip]
#### Parameters
| | | |
| --- | --- | --- |
| snapshot | a [GtkSnapshot](gtksnapshot#GtkSnapshot). | [transfer full] |
#### Returns
a newly-created [GskRenderNode](https://developer-old.gnome.org/gtk4/html/GskRenderNode.html#GskRenderNode-struct).
[transfer full]
### gtk\_snapshot\_free\_to\_paintable ()
```
[GdkPaintable](https://developer-old.gnome.org/gtk4/html/GdkPaintable.html#GdkPaintable-struct) *
gtk_snapshot_free_to_paintable (*`[GtkSnapshot](gtksnapshot#GtkSnapshot) *snapshot`*,
*`const [graphene\_size\_t](https://developer-old.gnome.org/usr/share/gtk-doc/html/graphene/graphene-Size.html#graphene-size-t) *size`*);
```
Returns a paintable for the node that was constructed by *`snapshot`* and frees *`snapshot`* .
[skip]
#### Parameters
| | | |
| --- | --- | --- |
| snapshot | a [GtkSnapshot](gtksnapshot#GtkSnapshot). | [transfer full] |
| size | The size of the resulting paintable or `NULL` to use the bounds of the snapshot. | [allow-none] |
#### Returns
a newly-created [GdkPaintable](https://developer-old.gnome.org/gtk4/html/GdkPaintable.html#GdkPaintable-struct).
[transfer full]
### gtk\_snapshot\_push\_opacity ()
```
void
gtk_snapshot_push_opacity (*`[GtkSnapshot](gtksnapshot#GtkSnapshot) *snapshot`*,
*`double opacity`*);
```
Modifies the opacity of an image.
The image is recorded until the next call to [`gtk_snapshot_pop()`](gtksnapshot#gtk-snapshot-pop).
#### Parameters
| | | |
| --- | --- | --- |
| snapshot | a [GtkSnapshot](gtksnapshot#GtkSnapshot) | |
| opacity | the opacity to use | |
### gtk\_snapshot\_push\_color\_matrix ()
```
void
gtk_snapshot_push_color_matrix (*`[GtkSnapshot](gtksnapshot#GtkSnapshot) *snapshot`*,
*`const [graphene\_matrix\_t](https://developer-old.gnome.org/usr/share/gtk-doc/html/graphene/graphene-Matrix.html#graphene-matrix-t) *color_matrix`*,
*`const [graphene\_vec4\_t](https://developer-old.gnome.org/usr/share/gtk-doc/html/graphene/graphene-Vectors.html#graphene-vec4-t) *color_offset`*);
```
Modifies the colors of an image by applying an affine transformation in RGB space.
The image is recorded until the next call to [`gtk_snapshot_pop()`](gtksnapshot#gtk-snapshot-pop).
#### Parameters
| | | |
| --- | --- | --- |
| snapshot | a [GtkSnapshot](gtksnapshot#GtkSnapshot) | |
| color\_matrix | the color matrix to use | |
| color\_offset | the color offset to use | |
### gtk\_snapshot\_push\_repeat ()
```
void
gtk_snapshot_push_repeat (*`[GtkSnapshot](gtksnapshot#GtkSnapshot) *snapshot`*,
*`const [graphene\_rect\_t](https://developer-old.gnome.org/usr/share/gtk-doc/html/graphene/graphene-Rectangle.html#graphene-rect-t) *bounds`*,
*`const [graphene\_rect\_t](https://developer-old.gnome.org/usr/share/gtk-doc/html/graphene/graphene-Rectangle.html#graphene-rect-t) *child_bounds`*);
```
Creates a node that repeats the child node.
The child is recorded until the next call to [`gtk_snapshot_pop()`](gtksnapshot#gtk-snapshot-pop).
#### Parameters
| | | |
| --- | --- | --- |
| snapshot | a [GtkSnapshot](gtksnapshot#GtkSnapshot) | |
| bounds | the bounds within which to repeat | |
| child\_bounds | the bounds of the child or `NULL` to use the full size of the collected child node. | [nullable] |
### gtk\_snapshot\_push\_clip ()
```
void
gtk_snapshot_push_clip (*`[GtkSnapshot](gtksnapshot#GtkSnapshot) *snapshot`*,
*`const [graphene\_rect\_t](https://developer-old.gnome.org/usr/share/gtk-doc/html/graphene/graphene-Rectangle.html#graphene-rect-t) *bounds`*);
```
Clips an image to a rectangle.
The image is recorded until the next call to [`gtk_snapshot_pop()`](gtksnapshot#gtk-snapshot-pop).
#### Parameters
| | | |
| --- | --- | --- |
| snapshot | a [GtkSnapshot](gtksnapshot#GtkSnapshot) | |
| bounds | the rectangle to clip to | |
### gtk\_snapshot\_push\_rounded\_clip ()
```
void
gtk_snapshot_push_rounded_clip (*`[GtkSnapshot](gtksnapshot#GtkSnapshot) *snapshot`*,
*`const [GskRoundedRect](https://developer-old.gnome.org/gtk4/html/gsk4-GskRoundedRect.html#GskRoundedRect) *bounds`*);
```
Clips an image to a rounded rectangle.
The image is recorded until the next call to [`gtk_snapshot_pop()`](gtksnapshot#gtk-snapshot-pop).
#### Parameters
| | | |
| --- | --- | --- |
| snapshot | a [GtkSnapshot](gtksnapshot#GtkSnapshot) | |
| bounds | the rounded rectangle to clip to | |
### gtk\_snapshot\_push\_cross\_fade ()
```
void
gtk_snapshot_push_cross_fade (*`[GtkSnapshot](gtksnapshot#GtkSnapshot) *snapshot`*,
*`double progress`*);
```
Snapshots a cross-fade operation between two images with the given *`progress`* .
Until the first call to [`gtk_snapshot_pop()`](gtksnapshot#gtk-snapshot-pop), the start image will be snapshot. After that call, the end image will be recorded until the second call to [`gtk_snapshot_pop()`](gtksnapshot#gtk-snapshot-pop).
Calling this function requires 2 calls to [`gtk_snapshot_pop()`](gtksnapshot#gtk-snapshot-pop).
#### Parameters
| | | |
| --- | --- | --- |
| snapshot | a [GtkSnapshot](gtksnapshot#GtkSnapshot) | |
| progress | progress between 0.0 and 1.0 | |
### gtk\_snapshot\_push\_blend ()
```
void
gtk_snapshot_push_blend (*`[GtkSnapshot](gtksnapshot#GtkSnapshot) *snapshot`*,
*`[GskBlendMode](https://developer-old.gnome.org/gtk4/html/GskRenderNode.html#GskBlendMode) blend_mode`*);
```
Blends together 2 images with the given blend mode.
Until the first call to [`gtk_snapshot_pop()`](gtksnapshot#gtk-snapshot-pop), the bottom image for the blend operation will be recorded. After that call, the top image to be blended will be recorded until the second call to [`gtk_snapshot_pop()`](gtksnapshot#gtk-snapshot-pop).
Calling this function requires 2 subsequent calls to [`gtk_snapshot_pop()`](gtksnapshot#gtk-snapshot-pop).
#### Parameters
| | | |
| --- | --- | --- |
| snapshot | a [GtkSnapshot](gtksnapshot#GtkSnapshot) | |
| blend\_mode | blend mode to use | |
### gtk\_snapshot\_push\_blur ()
```
void
gtk_snapshot_push_blur (*`[GtkSnapshot](gtksnapshot#GtkSnapshot) *snapshot`*,
*`double radius`*);
```
Blurs an image.
The image is recorded until the next call to [`gtk_snapshot_pop()`](gtksnapshot#gtk-snapshot-pop).
#### Parameters
| | | |
| --- | --- | --- |
| snapshot | a [GtkSnapshot](gtksnapshot#GtkSnapshot) | |
| radius | the blur radius to use | |
### gtk\_snapshot\_push\_shadow ()
```
void
gtk_snapshot_push_shadow (*`[GtkSnapshot](gtksnapshot#GtkSnapshot) *snapshot`*,
*`const [GskShadow](https://developer-old.gnome.org/gtk4/html/GskRenderNode.html#GskShadow) *shadow`*,
*`gsize n_shadows`*);
```
Applies a shadow to an image.
The image is recorded until the next call to [`gtk_snapshot_pop()`](gtksnapshot#gtk-snapshot-pop).
#### Parameters
| | | |
| --- | --- | --- |
| snapshot | a [GtkSnapshot](gtksnapshot#GtkSnapshot) | |
| shadow | the first shadow specification | |
| n\_shadows | number of shadow specifications | |
### gtk\_snapshot\_push\_debug ()
```
void
gtk_snapshot_push_debug (*`[GtkSnapshot](gtksnapshot#GtkSnapshot) *snapshot`*,
*`const char *message`*,
*`...`*);
```
Inserts a debug node with a message. Debug nodes don't affect the rendering at all, but can be helpful in identifying parts of a render node tree dump, for example in the GTK inspector.
#### Parameters
| | | |
| --- | --- | --- |
| snapshot | a [GtkSnapshot](gtksnapshot#GtkSnapshot) | |
| message | a printf-style format string | |
| ... | arguments for *`message`* | |
### gtk\_snapshot\_push\_gl\_shader ()
```
void
gtk_snapshot_push_gl_shader (*`[GtkSnapshot](gtksnapshot#GtkSnapshot) *snapshot`*,
*`[GskGLShader](https://developer-old.gnome.org/gtk4/html/GskGLShader.html#GskGLShader-struct) *shader`*,
*`const [graphene\_rect\_t](https://developer-old.gnome.org/usr/share/gtk-doc/html/graphene/graphene-Rectangle.html#graphene-rect-t) *bounds`*,
*`GBytes *take_args`*);
```
Push a [GskGLShaderNode](https://developer-old.gnome.org/gtk4/html/GskRenderNode.html#GskGLShaderNode) with a specific [GskGLShader](https://developer-old.gnome.org/gtk4/html/GskGLShader.html#GskGLShader-struct) and a set of uniform values to use while rendering. Additionally this takes a list of *`n_children`* other nodes which will be passed to the [GskGLShaderNode](https://developer-old.gnome.org/gtk4/html/GskRenderNode.html#GskGLShaderNode).
The *`take_args`* argument is a block of data to use for uniform arguments, as per types and offsets defined by the *`shader`* . Normally this is generated by [`gsk_gl_shader_format_args()`](https://developer-old.gnome.org/gtk4/html/GskGLShader.html#gsk-gl-shader-format-args) or GskGLShaderArgBuilder. The snapshotter takes ownership of *`take_args`* , so the caller should not free it after this.
If the renderer doesn't support GL shaders, or if there is any problem when compiling the shader, then the node will draw pink. You should use [`gsk_gl_shader_compile()`](https://developer-old.gnome.org/gtk4/html/GskGLShader.html#gsk-gl-shader-compile) to ensure the *`shader`* will work for the renderer before using it.
If the shader requires textures (see [`gsk_gl_shader_get_n_textures()`](https://developer-old.gnome.org/gtk4/html/GskGLShader.html#gsk-gl-shader-get-n-textures)), then it is expected that you call [`gtk_snapshot_gl_shader_pop_texture()`](gtksnapshot#gtk-snapshot-gl-shader-pop-texture) the number of times that are required. Each of these calls will generate a node that is added as a child to the gl shader node, which in turn will render these offscreen and pass as a texture to the shader.
Once all textures (if any) are pop:ed, you must call the regular [`gtk_snapshot_pop()`](gtksnapshot#gtk-snapshot-pop).
If you want to use pre-existing textures as input to the shader rather than rendering new ones, use [`gtk_snapshot_append_texture()`](gtksnapshot#gtk-snapshot-append-texture) to push a texture node. These will be used directly rather than being re-rendered.
For details on how to write shaders, see [GskGLShader](https://developer-old.gnome.org/gtk4/html/GskGLShader.html#GskGLShader-struct).
#### Parameters
| | | |
| --- | --- | --- |
| snapshot | a [GtkSnapshot](gtksnapshot#GtkSnapshot) | |
| shader | The code to run | |
| bounds | the rectangle to render into | |
| take\_args | Data block with arguments for the shader. | [transfer full] |
### gtk\_snapshot\_pop ()
```
void
gtk_snapshot_pop (*`[GtkSnapshot](gtksnapshot#GtkSnapshot) *snapshot`*);
```
Removes the top element from the stack of render nodes, and appends it to the node underneath it.
#### Parameters
| | | |
| --- | --- | --- |
| snapshot | a [GtkSnapshot](gtksnapshot#GtkSnapshot) | |
### gtk\_snapshot\_gl\_shader\_pop\_texture ()
```
void
gtk_snapshot_gl_shader_pop_texture (*`[GtkSnapshot](gtksnapshot#GtkSnapshot) *snapshot`*);
```
Removes the top element from the stack of render nodes and adds it to the nearest GskGLShaderNode below it. This must be called the same number of times as the number of textures is needed for the shader in [`gtk_snapshot_push_gl_shader()`](gtksnapshot#gtk-snapshot-push-gl-shader).
#### Parameters
| | | |
| --- | --- | --- |
| snapshot | a [GtkSnapshot](gtksnapshot#GtkSnapshot) | |
### gtk\_snapshot\_save ()
```
void
gtk_snapshot_save (*`[GtkSnapshot](gtksnapshot#GtkSnapshot) *snapshot`*);
```
Makes a copy of the current state of *`snapshot`* and saves it on an internal stack of saved states for *`snapshot`* . When [`gtk_snapshot_restore()`](gtksnapshot#gtk-snapshot-restore) is called, *`snapshot`* will be restored to the saved state. Multiple calls to [`gtk_snapshot_save()`](gtksnapshot#gtk-snapshot-save) and [`gtk_snapshot_restore()`](gtksnapshot#gtk-snapshot-restore) can be nested; each call to [`gtk_snapshot_restore()`](gtksnapshot#gtk-snapshot-restore) restores the state from the matching paired [`gtk_snapshot_save()`](gtksnapshot#gtk-snapshot-save).
It is necessary to clear all saved states with corresponding calls to [`gtk_snapshot_restore()`](gtksnapshot#gtk-snapshot-restore).
#### Parameters
| | | |
| --- | --- | --- |
| snapshot | a [GtkSnapshot](gtksnapshot#GtkSnapshot) | |
### gtk\_snapshot\_restore ()
```
void
gtk_snapshot_restore (*`[GtkSnapshot](gtksnapshot#GtkSnapshot) *snapshot`*);
```
Restores *`snapshot`* to the state saved by a preceding call to [`gtk_snapshot_save()`](gtksnapshot#gtk-snapshot-save) and removes that state from the stack of saved states.
#### Parameters
| | | |
| --- | --- | --- |
| snapshot | a [GtkSnapshot](gtksnapshot#GtkSnapshot) | |
### gtk\_snapshot\_transform ()
```
void
gtk_snapshot_transform (*`[GtkSnapshot](gtksnapshot#GtkSnapshot) *snapshot`*,
*`[GskTransform](https://developer-old.gnome.org/gtk4/html/gsk4-GskTransform.html#GskTransform) *transform`*);
```
Transforms *`snapshot`* 's coordinate system with the given *`transform`* .
#### Parameters
| | | |
| --- | --- | --- |
| snapshot | a [GtkSnapshot](gtksnapshot#GtkSnapshot) | |
| transform | the transform to apply. | [allow-none] |
### gtk\_snapshot\_transform\_matrix ()
```
void
gtk_snapshot_transform_matrix (*`[GtkSnapshot](gtksnapshot#GtkSnapshot) *snapshot`*,
*`const [graphene\_matrix\_t](https://developer-old.gnome.org/usr/share/gtk-doc/html/graphene/graphene-Matrix.html#graphene-matrix-t) *matrix`*);
```
Transforms *`snapshot`* 's coordinate system with the given *`matrix`* .
#### Parameters
| | | |
| --- | --- | --- |
| snapshot | a [GtkSnapshot](gtksnapshot#GtkSnapshot) | |
| matrix | the matrix to multiply the transform with | |
### gtk\_snapshot\_translate ()
```
void
gtk_snapshot_translate (*`[GtkSnapshot](gtksnapshot#GtkSnapshot) *snapshot`*,
*`const [graphene\_point\_t](https://developer-old.gnome.org/usr/share/gtk-doc/html/graphene/graphene-Point.html#graphene-point-t) *point`*);
```
Translates *`snapshot`* 's coordinate system by *`point`* in 2-dimensional space.
#### Parameters
| | | |
| --- | --- | --- |
| snapshot | a [GtkSnapshot](gtksnapshot#GtkSnapshot) | |
| point | the point to translate the snapshot by | |
### gtk\_snapshot\_translate\_3d ()
```
void
gtk_snapshot_translate_3d (*`[GtkSnapshot](gtksnapshot#GtkSnapshot) *snapshot`*,
*`const [graphene\_point3d\_t](https://developer-old.gnome.org/usr/share/gtk-doc/html/graphene/graphene-Point3D.html#graphene-point3d-t) *point`*);
```
Translates *`snapshot`* 's coordinate system by *`point`* .
#### Parameters
| | | |
| --- | --- | --- |
| snapshot | a [GtkSnapshot](gtksnapshot#GtkSnapshot) | |
| point | the point to translate the snapshot by | |
### gtk\_snapshot\_rotate ()
```
void
gtk_snapshot_rotate (*`[GtkSnapshot](gtksnapshot#GtkSnapshot) *snapshot`*,
*`float angle`*);
```
Rotates @*`snapshot`* 's coordinate system by *`angle`* degrees in 2D space - or in 3D speak, rotates around the z axis.
#### Parameters
| | | |
| --- | --- | --- |
| snapshot | a [GtkSnapshot](gtksnapshot#GtkSnapshot) | |
| angle | the rotation angle, in degrees (clockwise) | |
### gtk\_snapshot\_rotate\_3d ()
```
void
gtk_snapshot_rotate_3d (*`[GtkSnapshot](gtksnapshot#GtkSnapshot) *snapshot`*,
*`float angle`*,
*`const [graphene\_vec3\_t](https://developer-old.gnome.org/usr/share/gtk-doc/html/graphene/graphene-Vectors.html#graphene-vec3-t) *axis`*);
```
Rotates *`snapshot`* 's coordinate system by *`angle`* degrees around *`axis`* .
For a rotation in 2D space, use [`gsk_transform_rotate()`](https://developer-old.gnome.org/gtk4/html/gsk4-GskTransform.html#gsk-transform-rotate).
#### Parameters
| | | |
| --- | --- | --- |
| snapshot | a [GtkSnapshot](gtksnapshot#GtkSnapshot) | |
| angle | the rotation angle, in degrees (clockwise) | |
| axis | The rotation axis | |
### gtk\_snapshot\_scale ()
```
void
gtk_snapshot_scale (*`[GtkSnapshot](gtksnapshot#GtkSnapshot) *snapshot`*,
*`float factor_x`*,
*`float factor_y`*);
```
Scales *`snapshot`* 's coordinate system in 2-dimensional space by the given factors.
Use [`gtk_snapshot_scale_3d()`](gtksnapshot#gtk-snapshot-scale-3d) to scale in all 3 dimensions.
#### Parameters
| | | |
| --- | --- | --- |
| snapshot | a [GtkSnapshot](gtksnapshot#GtkSnapshot) | |
| factor\_x | scaling factor on the X axis | |
| factor\_y | scaling factor on the Y axis | |
### gtk\_snapshot\_scale\_3d ()
```
void
gtk_snapshot_scale_3d (*`[GtkSnapshot](gtksnapshot#GtkSnapshot) *snapshot`*,
*`float factor_x`*,
*`float factor_y`*,
*`float factor_z`*);
```
Scales *`snapshot`* 's coordinate system by the given factors.
#### Parameters
| | | |
| --- | --- | --- |
| snapshot | a [GtkSnapshot](gtksnapshot#GtkSnapshot) | |
| factor\_x | scaling factor on the X axis | |
| factor\_y | scaling factor on the Y axis | |
| factor\_z | scaling factor on the Z axis | |
### gtk\_snapshot\_perspective ()
```
void
gtk_snapshot_perspective (*`[GtkSnapshot](gtksnapshot#GtkSnapshot) *snapshot`*,
*`float depth`*);
```
Applies a perspective projection transform.
See [`gsk_transform_perspective()`](https://developer-old.gnome.org/gtk4/html/gsk4-GskTransform.html#gsk-transform-perspective) for a discussion on the details.
#### Parameters
| | | |
| --- | --- | --- |
| snapshot | a [GtkSnapshot](gtksnapshot#GtkSnapshot) | |
| depth | distance of the z=0 plane | |
### gtk\_snapshot\_append\_node ()
```
void
gtk_snapshot_append_node (*`[GtkSnapshot](gtksnapshot#GtkSnapshot) *snapshot`*,
*`[GskRenderNode](https://developer-old.gnome.org/gtk4/html/GskRenderNode.html#GskRenderNode-struct) *node`*);
```
Appends *`node`* to the current render node of *`snapshot`* , without changing the current node. If *`snapshot`* does not have a current node yet, *`node`* will become the initial node.
#### Parameters
| | | |
| --- | --- | --- |
| snapshot | a [GtkSnapshot](gtksnapshot#GtkSnapshot) | |
| node | a [GskRenderNode](https://developer-old.gnome.org/gtk4/html/GskRenderNode.html#GskRenderNode-struct) | |
### gtk\_snapshot\_append\_cairo ()
```
[cairo\_t](https://developer-old.gnome.org/cairo/stable/cairo-cairo-t.html#cairo-t) *
gtk_snapshot_append_cairo (*`[GtkSnapshot](gtksnapshot#GtkSnapshot) *snapshot`*,
*`const [graphene\_rect\_t](https://developer-old.gnome.org/usr/share/gtk-doc/html/graphene/graphene-Rectangle.html#graphene-rect-t) *bounds`*);
```
Creates a new render node and appends it to the current render node of *`snapshot`* , without changing the current node.
#### Parameters
| | | |
| --- | --- | --- |
| snapshot | a [GtkSnapshot](gtksnapshot#GtkSnapshot) | |
| bounds | the bounds for the new node | |
#### Returns
a cairo\_t suitable for drawing the contents of the newly created render node
### gtk\_snapshot\_append\_texture ()
```
void
gtk_snapshot_append_texture (*`[GtkSnapshot](gtksnapshot#GtkSnapshot) *snapshot`*,
*`[GdkTexture](https://developer-old.gnome.org/gtk4/html/gdk4-Textures.html#GdkTexture-struct) *texture`*,
*`const [graphene\_rect\_t](https://developer-old.gnome.org/usr/share/gtk-doc/html/graphene/graphene-Rectangle.html#graphene-rect-t) *bounds`*);
```
Creates a new render node drawing the *`texture`* into the given *`bounds`* and appends it to the current render node of *`snapshot`* .
#### Parameters
| | | |
| --- | --- | --- |
| snapshot | a [GtkSnapshot](gtksnapshot#GtkSnapshot) | |
| texture | the [GdkTexture](https://developer-old.gnome.org/gtk4/html/gdk4-Textures.html#GdkTexture-struct) to render | |
| bounds | the bounds for the new node | |
### gtk\_snapshot\_append\_color ()
```
void
gtk_snapshot_append_color (*`[GtkSnapshot](gtksnapshot#GtkSnapshot) *snapshot`*,
*`const [GdkRGBA](https://developer-old.gnome.org/gtk4/html/gdk4-RGBA-Colors.html#GdkRGBA-struct) *color`*,
*`const [graphene\_rect\_t](https://developer-old.gnome.org/usr/share/gtk-doc/html/graphene/graphene-Rectangle.html#graphene-rect-t) *bounds`*);
```
Creates a new render node drawing the *`color`* into the given *`bounds`* and appends it to the current render node of *`snapshot`* .
You should try to avoid calling this function if *`color`* is transparent.
#### Parameters
| | | |
| --- | --- | --- |
| snapshot | a [GtkSnapshot](gtksnapshot#GtkSnapshot) | |
| color | the [GdkRGBA](https://developer-old.gnome.org/gtk4/html/gdk4-RGBA-Colors.html#GdkRGBA-struct) to draw | |
| bounds | the bounds for the new node | |
### gtk\_snapshot\_append\_layout ()
```
void
gtk_snapshot_append_layout (*`[GtkSnapshot](gtksnapshot#GtkSnapshot) *snapshot`*,
*`[PangoLayout](https://developer-old.gnome.org/pango/stable/pango-Layout-Objects.html#PangoLayout-struct) *layout`*,
*`const [GdkRGBA](https://developer-old.gnome.org/gtk4/html/gdk4-RGBA-Colors.html#GdkRGBA-struct) *color`*);
```
Creates render nodes for rendering *`layout`* in the given foregound *`color`* and appends them to the current node of *`snapshot`* without changing the current node.
#### Parameters
| | | |
| --- | --- | --- |
| snapshot | a [GtkSnapshot](gtksnapshot#GtkSnapshot) | |
| layout | the [PangoLayout](https://developer-old.gnome.org/pango/stable/pango-Layout-Objects.html#PangoLayout-struct) to render | |
| color | the foreground color to render the layout in | |
### gtk\_snapshot\_append\_linear\_gradient ()
```
void
gtk_snapshot_append_linear_gradient (*`[GtkSnapshot](gtksnapshot#GtkSnapshot) *snapshot`*,
*`const [graphene\_rect\_t](https://developer-old.gnome.org/usr/share/gtk-doc/html/graphene/graphene-Rectangle.html#graphene-rect-t) *bounds`*,
*`const [graphene\_point\_t](https://developer-old.gnome.org/usr/share/gtk-doc/html/graphene/graphene-Point.html#graphene-point-t) *start_point`*,
*`const [graphene\_point\_t](https://developer-old.gnome.org/usr/share/gtk-doc/html/graphene/graphene-Point.html#graphene-point-t) *end_point`*,
*`const [GskColorStop](https://developer-old.gnome.org/gtk4/html/GskRenderNode.html#GskColorStop) *stops`*,
*`gsize n_stops`*);
```
Appends a linear gradient node with the given stops to *`snapshot`* .
#### Parameters
| | | |
| --- | --- | --- |
| snapshot | a [GtkSnapshot](gtksnapshot#GtkSnapshot) | |
| bounds | the rectangle to render the linear gradient into | |
| start\_point | the point at which the linear gradient will begin | |
| end\_point | the point at which the linear gradient will finish | |
| stops | a pointer to an array of [GskColorStop](https://developer-old.gnome.org/gtk4/html/GskRenderNode.html#GskColorStop) defining the gradient. | [array length=n\_stops] |
| n\_stops | the number of elements in *`stops`* | |
### gtk\_snapshot\_append\_repeating\_linear\_gradient ()
```
void
gtk_snapshot_append_repeating_linear_gradient
(*`[GtkSnapshot](gtksnapshot#GtkSnapshot) *snapshot`*,
*`const [graphene\_rect\_t](https://developer-old.gnome.org/usr/share/gtk-doc/html/graphene/graphene-Rectangle.html#graphene-rect-t) *bounds`*,
*`const [graphene\_point\_t](https://developer-old.gnome.org/usr/share/gtk-doc/html/graphene/graphene-Point.html#graphene-point-t) *start_point`*,
*`const [graphene\_point\_t](https://developer-old.gnome.org/usr/share/gtk-doc/html/graphene/graphene-Point.html#graphene-point-t) *end_point`*,
*`const [GskColorStop](https://developer-old.gnome.org/gtk4/html/GskRenderNode.html#GskColorStop) *stops`*,
*`gsize n_stops`*);
```
Appends a repeating linear gradient node with the given stops to *`snapshot`* .
#### Parameters
| | | |
| --- | --- | --- |
| snapshot | a [GtkSnapshot](gtksnapshot#GtkSnapshot) | |
| bounds | the rectangle to render the linear gradient into | |
| start\_point | the point at which the linear gradient will begin | |
| end\_point | the point at which the linear gradient will finish | |
| stops | a pointer to an array of [GskColorStop](https://developer-old.gnome.org/gtk4/html/GskRenderNode.html#GskColorStop) defining the gradient. | [array length=n\_stops] |
| n\_stops | the number of elements in *`stops`* | |
### gtk\_snapshot\_append\_conic\_gradient ()
```
void
gtk_snapshot_append_conic_gradient (*`[GtkSnapshot](gtksnapshot#GtkSnapshot) *snapshot`*,
*`const [graphene\_rect\_t](https://developer-old.gnome.org/usr/share/gtk-doc/html/graphene/graphene-Rectangle.html#graphene-rect-t) *bounds`*,
*`const [graphene\_point\_t](https://developer-old.gnome.org/usr/share/gtk-doc/html/graphene/graphene-Point.html#graphene-point-t) *center`*,
*`float rotation`*,
*`const [GskColorStop](https://developer-old.gnome.org/gtk4/html/GskRenderNode.html#GskColorStop) *stops`*,
*`gsize n_stops`*);
```
Appends a conic gradient node with the given stops to *`snapshot`* .
#### Parameters
| | | |
| --- | --- | --- |
| snapshot | a [GtkSnapshot](gtksnapshot#GtkSnapshot) | |
| bounds | the rectangle to render the gradient into | |
| center | the center point of the conic gradient | |
| rotation | the clockwise rotation in degrees of the starting angle. 0 means the starting angle is the top. | |
| stops | a pointer to an array of [GskColorStop](https://developer-old.gnome.org/gtk4/html/GskRenderNode.html#GskColorStop) defining the gradient. | [array length=n\_stops] |
| n\_stops | the number of elements in *`stops`* | |
### gtk\_snapshot\_append\_border ()
```
void
gtk_snapshot_append_border (*`[GtkSnapshot](gtksnapshot#GtkSnapshot) *snapshot`*,
*`const [GskRoundedRect](https://developer-old.gnome.org/gtk4/html/gsk4-GskRoundedRect.html#GskRoundedRect) *outline`*,
*`const float border_width[4]`*,
*`const [GdkRGBA](https://developer-old.gnome.org/gtk4/html/gdk4-RGBA-Colors.html#GdkRGBA-struct) border_color[4]`*);
```
Appends a stroked border rectangle inside the given *`outline`* . The 4 sides of the border can have different widths and colors.
#### Parameters
| | | |
| --- | --- | --- |
| snapshot | a [GtkSnapshot](gtksnapshot#GtkSnapshot) | |
| outline | a [GskRoundedRect](https://developer-old.gnome.org/gtk4/html/gsk4-GskRoundedRect.html#GskRoundedRect) describing the outline of the border | |
| border\_width | the stroke width of the border on the top, right, bottom and left side respectively. | [array fixed-size=4] |
| border\_color | the color used on the top, right, bottom and left side. | [array fixed-size=4] |
### gtk\_snapshot\_append\_inset\_shadow ()
```
void
gtk_snapshot_append_inset_shadow (*`[GtkSnapshot](gtksnapshot#GtkSnapshot) *snapshot`*,
*`const [GskRoundedRect](https://developer-old.gnome.org/gtk4/html/gsk4-GskRoundedRect.html#GskRoundedRect) *outline`*,
*`const [GdkRGBA](https://developer-old.gnome.org/gtk4/html/gdk4-RGBA-Colors.html#GdkRGBA-struct) *color`*,
*`float dx`*,
*`float dy`*,
*`float spread`*,
*`float blur_radius`*);
```
Appends an inset shadow into the box given by *`outline`* .
#### Parameters
| | | |
| --- | --- | --- |
| snapshot | a [GtkSnapshot](gtksnapshot#GtkSnapshot) | |
| outline | outline of the region surrounded by shadow | |
| color | color of the shadow | |
| dx | horizontal offset of shadow | |
| dy | vertical offset of shadow | |
| spread | how far the shadow spreads towards the inside | |
| blur\_radius | how much blur to apply to the shadow | |
### gtk\_snapshot\_append\_outset\_shadow ()
```
void
gtk_snapshot_append_outset_shadow (*`[GtkSnapshot](gtksnapshot#GtkSnapshot) *snapshot`*,
*`const [GskRoundedRect](https://developer-old.gnome.org/gtk4/html/gsk4-GskRoundedRect.html#GskRoundedRect) *outline`*,
*`const [GdkRGBA](https://developer-old.gnome.org/gtk4/html/gdk4-RGBA-Colors.html#GdkRGBA-struct) *color`*,
*`float dx`*,
*`float dy`*,
*`float spread`*,
*`float blur_radius`*);
```
Appends an outset shadow node around the box given by *`outline`* .
#### Parameters
| | | |
| --- | --- | --- |
| snapshot | a [GtkSnapshot](gtksnapshot#GtkSnapshot) | |
| outline | outline of the region surrounded by shadow | |
| color | color of the shadow | |
| dx | horizontal offset of shadow | |
| dy | vertical offset of shadow | |
| spread | how far the shadow spreads towards the outside | |
| blur\_radius | how much blur to apply to the shadow | |
### gtk\_snapshot\_append\_radial\_gradient ()
```
void
gtk_snapshot_append_radial_gradient (*`[GtkSnapshot](gtksnapshot#GtkSnapshot) *snapshot`*,
*`const [graphene\_rect\_t](https://developer-old.gnome.org/usr/share/gtk-doc/html/graphene/graphene-Rectangle.html#graphene-rect-t) *bounds`*,
*`const [graphene\_point\_t](https://developer-old.gnome.org/usr/share/gtk-doc/html/graphene/graphene-Point.html#graphene-point-t) *center`*,
*`float hradius`*,
*`float vradius`*,
*`float start`*,
*`float end`*,
*`const [GskColorStop](https://developer-old.gnome.org/gtk4/html/GskRenderNode.html#GskColorStop) *stops`*,
*`gsize n_stops`*);
```
Appends a radial gradient node with the given stops to *`snapshot`* .
#### Parameters
| | | |
| --- | --- | --- |
| snapshot | a [GtkSnapshot](gtksnapshot#GtkSnapshot) | |
| bounds | the rectangle to render the readial gradient into | |
| center | the center point for the radial gradient | |
| hradius | the horizontal radius | |
| vradius | the vertical radius | |
| start | the start position (on the horizontal axis) | |
| end | the end position (on the horizontal axis) | |
| stops | a pointer to an array of [GskColorStop](https://developer-old.gnome.org/gtk4/html/GskRenderNode.html#GskColorStop) defining the gradient. | [array length=n\_stops] |
| n\_stops | the number of elements in *`stops`* | |
### gtk\_snapshot\_append\_repeating\_radial\_gradient ()
```
void
gtk_snapshot_append_repeating_radial_gradient
(*`[GtkSnapshot](gtksnapshot#GtkSnapshot) *snapshot`*,
*`const [graphene\_rect\_t](https://developer-old.gnome.org/usr/share/gtk-doc/html/graphene/graphene-Rectangle.html#graphene-rect-t) *bounds`*,
*`const [graphene\_point\_t](https://developer-old.gnome.org/usr/share/gtk-doc/html/graphene/graphene-Point.html#graphene-point-t) *center`*,
*`float hradius`*,
*`float vradius`*,
*`float start`*,
*`float end`*,
*`const [GskColorStop](https://developer-old.gnome.org/gtk4/html/GskRenderNode.html#GskColorStop) *stops`*,
*`gsize n_stops`*);
```
Appends a repeating radial gradient node with the given stops to *`snapshot`* .
#### Parameters
| | | |
| --- | --- | --- |
| snapshot | a [GtkSnapshot](gtksnapshot#GtkSnapshot) | |
| bounds | the rectangle to render the readial gradient into | |
| center | the center point for the radial gradient | |
| hradius | the horizontal radius | |
| vradius | the vertical radius | |
| start | the start position (on the horizontal axis) | |
| end | the end position (on the horizontal axis) | |
| stops | a pointer to an array of [GskColorStop](https://developer-old.gnome.org/gtk4/html/GskRenderNode.html#GskColorStop) defining the gradient. | [array length=n\_stops] |
| n\_stops | the number of elements in *`stops`* | |
### gtk\_snapshot\_render\_insertion\_cursor ()
```
void
gtk_snapshot_render_insertion_cursor (*`[GtkSnapshot](gtksnapshot#GtkSnapshot) *snapshot`*,
*`[GtkStyleContext](gtkstylecontext#GtkStyleContext-struct) *context`*,
*`double x`*,
*`double y`*,
*`[PangoLayout](https://developer-old.gnome.org/pango/stable/pango-Layout-Objects.html#PangoLayout-struct) *layout`*,
*`int index`*,
*`[PangoDirection](https://developer-old.gnome.org/pango/stable/pango-Bidirectional-Text.html#PangoDirection) direction`*);
```
Draws a text caret using *`snapshot`* at the specified index of *`layout`* .
#### Parameters
| | | |
| --- | --- | --- |
| snapshot | snapshot to render to | |
| context | a [GtkStyleContext](gtkstylecontext#GtkStyleContext-struct) | |
| x | X origin | |
| y | Y origin | |
| layout | the [PangoLayout](https://developer-old.gnome.org/pango/stable/pango-Layout-Objects.html#PangoLayout-struct) of the text | |
| index | the index in the [PangoLayout](https://developer-old.gnome.org/pango/stable/pango-Layout-Objects.html#PangoLayout-struct) | |
| direction | the [PangoDirection](https://developer-old.gnome.org/pango/stable/pango-Bidirectional-Text.html#PangoDirection) of the text | |
### gtk\_snapshot\_render\_background ()
```
void
gtk_snapshot_render_background (*`[GtkSnapshot](gtksnapshot#GtkSnapshot) *snapshot`*,
*`[GtkStyleContext](gtkstylecontext#GtkStyleContext-struct) *context`*,
*`double x`*,
*`double y`*,
*`double width`*,
*`double height`*);
```
Creates a render node for the CSS background according to *`context`* , and appends it to the current node of *`snapshot`* , without changing the current node.
#### Parameters
| | | |
| --- | --- | --- |
| snapshot | a [GtkSnapshot](gtksnapshot#GtkSnapshot) | |
| context | the [GtkStyleContext](gtkstylecontext#GtkStyleContext-struct) to use | |
| x | X origin of the rectangle | |
| y | Y origin of the rectangle | |
| width | rectangle width | |
| height | rectangle height | |
### gtk\_snapshot\_render\_frame ()
```
void
gtk_snapshot_render_frame (*`[GtkSnapshot](gtksnapshot#GtkSnapshot) *snapshot`*,
*`[GtkStyleContext](gtkstylecontext#GtkStyleContext-struct) *context`*,
*`double x`*,
*`double y`*,
*`double width`*,
*`double height`*);
```
Creates a render node for the CSS border according to *`context`* , and appends it to the current node of *`snapshot`* , without changing the current node.
#### Parameters
| | | |
| --- | --- | --- |
| snapshot | a [GtkSnapshot](gtksnapshot#GtkSnapshot) | |
| context | the [GtkStyleContext](gtkstylecontext#GtkStyleContext-struct) to use | |
| x | X origin of the rectangle | |
| y | Y origin of the rectangle | |
| width | rectangle width | |
| height | rectangle height | |
### gtk\_snapshot\_render\_focus ()
```
void
gtk_snapshot_render_focus (*`[GtkSnapshot](gtksnapshot#GtkSnapshot) *snapshot`*,
*`[GtkStyleContext](gtkstylecontext#GtkStyleContext-struct) *context`*,
*`double x`*,
*`double y`*,
*`double width`*,
*`double height`*);
```
Creates a render node for the focus outline according to *`context`* , and appends it to the current node of *`snapshot`* , without changing the current node.
#### Parameters
| | | |
| --- | --- | --- |
| snapshot | a [GtkSnapshot](gtksnapshot#GtkSnapshot) | |
| context | the [GtkStyleContext](gtkstylecontext#GtkStyleContext-struct) to use | |
| x | X origin of the rectangle | |
| y | Y origin of the rectangle | |
| width | rectangle width | |
| height | rectangle height | |
### gtk\_snapshot\_render\_layout ()
```
void
gtk_snapshot_render_layout (*`[GtkSnapshot](gtksnapshot#GtkSnapshot) *snapshot`*,
*`[GtkStyleContext](gtkstylecontext#GtkStyleContext-struct) *context`*,
*`double x`*,
*`double y`*,
*`[PangoLayout](https://developer-old.gnome.org/pango/stable/pango-Layout-Objects.html#PangoLayout-struct) *layout`*);
```
Creates a render node for rendering *`layout`* according to the style information in *`context`* , and appends it to the current node of *`snapshot`* , without changing the current node.
#### Parameters
| | | |
| --- | --- | --- |
| snapshot | a [GtkSnapshot](gtksnapshot#GtkSnapshot) | |
| context | the [GtkStyleContext](gtkstylecontext#GtkStyleContext-struct) to use | |
| x | X origin of the rectangle | |
| y | Y origin of the rectangle | |
| layout | the [PangoLayout](https://developer-old.gnome.org/pango/stable/pango-Layout-Objects.html#PangoLayout-struct) to render | |
Types and Values
----------------
### GtkSnapshot
```
typedef GdkSnapshot GtkSnapshot;
```
| programming_docs |
gtk GtkTextBuffer GtkTextBuffer
=============
GtkTextBuffer — Stores attributed text for display in a GtkTextView
Functions
---------
| | |
| --- | --- |
| [GtkTextBuffer](gtktextbuffer#GtkTextBuffer-struct) \* | [gtk\_text\_buffer\_new](gtktextbuffer#gtk-text-buffer-new) () |
| int | [gtk\_text\_buffer\_get\_line\_count](gtktextbuffer#gtk-text-buffer-get-line-count) () |
| int | [gtk\_text\_buffer\_get\_char\_count](gtktextbuffer#gtk-text-buffer-get-char-count) () |
| [GtkTextTagTable](gtktexttagtable#GtkTextTagTable-struct) \* | [gtk\_text\_buffer\_get\_tag\_table](gtktextbuffer#gtk-text-buffer-get-tag-table) () |
| void | [gtk\_text\_buffer\_insert](gtktextbuffer#gtk-text-buffer-insert) () |
| void | [gtk\_text\_buffer\_insert\_at\_cursor](gtktextbuffer#gtk-text-buffer-insert-at-cursor) () |
| gboolean | [gtk\_text\_buffer\_insert\_interactive](gtktextbuffer#gtk-text-buffer-insert-interactive) () |
| gboolean | [gtk\_text\_buffer\_insert\_interactive\_at\_cursor](gtktextbuffer#gtk-text-buffer-insert-interactive-at-cursor) () |
| void | [gtk\_text\_buffer\_insert\_range](gtktextbuffer#gtk-text-buffer-insert-range) () |
| gboolean | [gtk\_text\_buffer\_insert\_range\_interactive](gtktextbuffer#gtk-text-buffer-insert-range-interactive) () |
| void | [gtk\_text\_buffer\_insert\_with\_tags](gtktextbuffer#gtk-text-buffer-insert-with-tags) () |
| void | [gtk\_text\_buffer\_insert\_with\_tags\_by\_name](gtktextbuffer#gtk-text-buffer-insert-with-tags-by-name) () |
| void | [gtk\_text\_buffer\_insert\_markup](gtktextbuffer#gtk-text-buffer-insert-markup) () |
| void | [gtk\_text\_buffer\_insert\_paintable](gtktextbuffer#gtk-text-buffer-insert-paintable) () |
| void | [gtk\_text\_buffer\_delete](gtktextbuffer#gtk-text-buffer-delete) () |
| gboolean | [gtk\_text\_buffer\_delete\_interactive](gtktextbuffer#gtk-text-buffer-delete-interactive) () |
| gboolean | [gtk\_text\_buffer\_backspace](gtktextbuffer#gtk-text-buffer-backspace) () |
| void | [gtk\_text\_buffer\_set\_text](gtktextbuffer#gtk-text-buffer-set-text) () |
| char \* | [gtk\_text\_buffer\_get\_text](gtktextbuffer#gtk-text-buffer-get-text) () |
| char \* | [gtk\_text\_buffer\_get\_slice](gtktextbuffer#gtk-text-buffer-get-slice) () |
| void | [gtk\_text\_buffer\_insert\_child\_anchor](gtktextbuffer#gtk-text-buffer-insert-child-anchor) () |
| [GtkTextChildAnchor](gtktextview#GtkTextChildAnchor-struct) \* | [gtk\_text\_buffer\_create\_child\_anchor](gtktextbuffer#gtk-text-buffer-create-child-anchor) () |
| [GtkTextMark](gtktextmark#GtkTextMark-struct) \* | [gtk\_text\_buffer\_create\_mark](gtktextbuffer#gtk-text-buffer-create-mark) () |
| void | [gtk\_text\_buffer\_move\_mark](gtktextbuffer#gtk-text-buffer-move-mark) () |
| void | [gtk\_text\_buffer\_move\_mark\_by\_name](gtktextbuffer#gtk-text-buffer-move-mark-by-name) () |
| void | [gtk\_text\_buffer\_add\_mark](gtktextbuffer#gtk-text-buffer-add-mark) () |
| void | [gtk\_text\_buffer\_delete\_mark](gtktextbuffer#gtk-text-buffer-delete-mark) () |
| void | [gtk\_text\_buffer\_delete\_mark\_by\_name](gtktextbuffer#gtk-text-buffer-delete-mark-by-name) () |
| [GtkTextMark](gtktextmark#GtkTextMark-struct) \* | [gtk\_text\_buffer\_get\_mark](gtktextbuffer#gtk-text-buffer-get-mark) () |
| [GtkTextMark](gtktextmark#GtkTextMark-struct) \* | [gtk\_text\_buffer\_get\_insert](gtktextbuffer#gtk-text-buffer-get-insert) () |
| [GtkTextMark](gtktextmark#GtkTextMark-struct) \* | [gtk\_text\_buffer\_get\_selection\_bound](gtktextbuffer#gtk-text-buffer-get-selection-bound) () |
| gboolean | [gtk\_text\_buffer\_get\_has\_selection](gtktextbuffer#gtk-text-buffer-get-has-selection) () |
| void | [gtk\_text\_buffer\_place\_cursor](gtktextbuffer#gtk-text-buffer-place-cursor) () |
| void | [gtk\_text\_buffer\_select\_range](gtktextbuffer#gtk-text-buffer-select-range) () |
| void | [gtk\_text\_buffer\_apply\_tag](gtktextbuffer#gtk-text-buffer-apply-tag) () |
| void | [gtk\_text\_buffer\_remove\_tag](gtktextbuffer#gtk-text-buffer-remove-tag) () |
| void | [gtk\_text\_buffer\_apply\_tag\_by\_name](gtktextbuffer#gtk-text-buffer-apply-tag-by-name) () |
| void | [gtk\_text\_buffer\_remove\_tag\_by\_name](gtktextbuffer#gtk-text-buffer-remove-tag-by-name) () |
| void | [gtk\_text\_buffer\_remove\_all\_tags](gtktextbuffer#gtk-text-buffer-remove-all-tags) () |
| [GtkTextTag](gtktexttag#GtkTextTag-struct) \* | [gtk\_text\_buffer\_create\_tag](gtktextbuffer#gtk-text-buffer-create-tag) () |
| gboolean | [gtk\_text\_buffer\_get\_iter\_at\_line\_offset](gtktextbuffer#gtk-text-buffer-get-iter-at-line-offset) () |
| void | [gtk\_text\_buffer\_get\_iter\_at\_offset](gtktextbuffer#gtk-text-buffer-get-iter-at-offset) () |
| gboolean | [gtk\_text\_buffer\_get\_iter\_at\_line](gtktextbuffer#gtk-text-buffer-get-iter-at-line) () |
| gboolean | [gtk\_text\_buffer\_get\_iter\_at\_line\_index](gtktextbuffer#gtk-text-buffer-get-iter-at-line-index) () |
| void | [gtk\_text\_buffer\_get\_iter\_at\_mark](gtktextbuffer#gtk-text-buffer-get-iter-at-mark) () |
| void | [gtk\_text\_buffer\_get\_iter\_at\_child\_anchor](gtktextbuffer#gtk-text-buffer-get-iter-at-child-anchor) () |
| void | [gtk\_text\_buffer\_get\_start\_iter](gtktextbuffer#gtk-text-buffer-get-start-iter) () |
| void | [gtk\_text\_buffer\_get\_end\_iter](gtktextbuffer#gtk-text-buffer-get-end-iter) () |
| void | [gtk\_text\_buffer\_get\_bounds](gtktextbuffer#gtk-text-buffer-get-bounds) () |
| gboolean | [gtk\_text\_buffer\_get\_modified](gtktextbuffer#gtk-text-buffer-get-modified) () |
| void | [gtk\_text\_buffer\_set\_modified](gtktextbuffer#gtk-text-buffer-set-modified) () |
| gboolean | [gtk\_text\_buffer\_delete\_selection](gtktextbuffer#gtk-text-buffer-delete-selection) () |
| void | [gtk\_text\_buffer\_paste\_clipboard](gtktextbuffer#gtk-text-buffer-paste-clipboard) () |
| void | [gtk\_text\_buffer\_copy\_clipboard](gtktextbuffer#gtk-text-buffer-copy-clipboard) () |
| void | [gtk\_text\_buffer\_cut\_clipboard](gtktextbuffer#gtk-text-buffer-cut-clipboard) () |
| gboolean | [gtk\_text\_buffer\_get\_selection\_bounds](gtktextbuffer#gtk-text-buffer-get-selection-bounds) () |
| [GdkContentProvider](https://developer-old.gnome.org/gtk4/html/GdkContentProvider.html#GdkContentProvider-struct) \* | [gtk\_text\_buffer\_get\_selection\_content](gtktextbuffer#gtk-text-buffer-get-selection-content) () |
| void | [gtk\_text\_buffer\_begin\_user\_action](gtktextbuffer#gtk-text-buffer-begin-user-action) () |
| void | [gtk\_text\_buffer\_end\_user\_action](gtktextbuffer#gtk-text-buffer-end-user-action) () |
| void | [gtk\_text\_buffer\_add\_selection\_clipboard](gtktextbuffer#gtk-text-buffer-add-selection-clipboard) () |
| void | [gtk\_text\_buffer\_remove\_selection\_clipboard](gtktextbuffer#gtk-text-buffer-remove-selection-clipboard) () |
| gboolean | [gtk\_text\_buffer\_get\_can\_undo](gtktextbuffer#gtk-text-buffer-get-can-undo) () |
| gboolean | [gtk\_text\_buffer\_get\_can\_redo](gtktextbuffer#gtk-text-buffer-get-can-redo) () |
| gboolean | [gtk\_text\_buffer\_get\_enable\_undo](gtktextbuffer#gtk-text-buffer-get-enable-undo) () |
| void | [gtk\_text\_buffer\_set\_enable\_undo](gtktextbuffer#gtk-text-buffer-set-enable-undo) () |
| guint | [gtk\_text\_buffer\_get\_max\_undo\_levels](gtktextbuffer#gtk-text-buffer-get-max-undo-levels) () |
| void | [gtk\_text\_buffer\_set\_max\_undo\_levels](gtktextbuffer#gtk-text-buffer-set-max-undo-levels) () |
| void | [gtk\_text\_buffer\_undo](gtktextbuffer#gtk-text-buffer-undo) () |
| void | [gtk\_text\_buffer\_redo](gtktextbuffer#gtk-text-buffer-redo) () |
| void | [gtk\_text\_buffer\_begin\_irreversible\_action](gtktextbuffer#gtk-text-buffer-begin-irreversible-action) () |
| void | [gtk\_text\_buffer\_end\_irreversible\_action](gtktextbuffer#gtk-text-buffer-end-irreversible-action) () |
Properties
----------
| | | |
| --- | --- | --- |
| gboolean | [can-redo](gtktextbuffer#GtkTextBuffer--can-redo) | Read |
| gboolean | [can-undo](gtktextbuffer#GtkTextBuffer--can-undo) | Read |
| int | [cursor-position](gtktextbuffer#GtkTextBuffer--cursor-position) | Read |
| gboolean | [enable-undo](gtktextbuffer#GtkTextBuffer--enable-undo) | Read / Write |
| gboolean | [has-selection](gtktextbuffer#GtkTextBuffer--has-selection) | Read |
| [GtkTextTagTable](gtktexttagtable#GtkTextTagTable-struct) \* | [tag-table](gtktextbuffer#GtkTextBuffer--tag-table) | Read / Write / Construct Only |
| char \* | [text](gtktextbuffer#GtkTextBuffer--text) | Read / Write |
Signals
-------
| | | |
| --- | --- | --- |
| void | [apply-tag](gtktextbuffer#GtkTextBuffer-apply-tag) | Run Last |
| void | [begin-user-action](gtktextbuffer#GtkTextBuffer-begin-user-action) | Run Last |
| void | [changed](gtktextbuffer#GtkTextBuffer-changed) | Run Last |
| void | [delete-range](gtktextbuffer#GtkTextBuffer-delete-range) | Run Last |
| void | [end-user-action](gtktextbuffer#GtkTextBuffer-end-user-action) | Run Last |
| void | [insert-child-anchor](gtktextbuffer#GtkTextBuffer-insert-child-anchor) | Run Last |
| void | [insert-paintable](gtktextbuffer#GtkTextBuffer-insert-paintable) | Run Last |
| void | [insert-text](gtktextbuffer#GtkTextBuffer-insert-text) | Run Last |
| void | [mark-deleted](gtktextbuffer#GtkTextBuffer-mark-deleted) | Run Last |
| void | [mark-set](gtktextbuffer#GtkTextBuffer-mark-set) | Run Last |
| void | [modified-changed](gtktextbuffer#GtkTextBuffer-modified-changed) | Run Last |
| void | [paste-done](gtktextbuffer#GtkTextBuffer-paste-done) | Run Last |
| void | [redo](gtktextbuffer#GtkTextBuffer-redo) | Run Last |
| void | [remove-tag](gtktextbuffer#GtkTextBuffer-remove-tag) | Run Last |
| void | [undo](gtktextbuffer#GtkTextBuffer-undo) | Run Last |
Types and Values
----------------
| | |
| --- | --- |
| | [GtkTextBuffer](gtktextbuffer#GtkTextBuffer-struct) |
| struct | [GtkTextBufferClass](gtktextbuffer#GtkTextBufferClass) |
Object Hierarchy
----------------
```
GObject
╰── GtkTextBuffer
```
Includes
--------
```
#include <gtk/gtk.h>
```
Description
-----------
You may wish to begin by reading the [text widget conceptual overview](textwidgetobjects#TextWidget) which gives an overview of all the objects and data types related to the text widget and how they work together.
Functions
---------
### gtk\_text\_buffer\_new ()
```
[GtkTextBuffer](gtktextbuffer#GtkTextBuffer-struct) *
gtk_text_buffer_new (*`[GtkTextTagTable](gtktexttagtable#GtkTextTagTable-struct) *table`*);
```
Creates a new text buffer.
#### Parameters
| | | |
| --- | --- | --- |
| table | a tag table, or `NULL` to create a new one. | [allow-none] |
#### Returns
a new text buffer
### gtk\_text\_buffer\_get\_line\_count ()
```
int
gtk_text_buffer_get_line_count (*`[GtkTextBuffer](gtktextbuffer#GtkTextBuffer-struct) *buffer`*);
```
Obtains the number of lines in the buffer. This value is cached, so the function is very fast.
#### Parameters
| | | |
| --- | --- | --- |
| buffer | a [GtkTextBuffer](gtktextbuffer#GtkTextBuffer-struct) | |
#### Returns
number of lines in the buffer
### gtk\_text\_buffer\_get\_char\_count ()
```
int
gtk_text_buffer_get_char_count (*`[GtkTextBuffer](gtktextbuffer#GtkTextBuffer-struct) *buffer`*);
```
Gets the number of characters in the buffer; note that characters and bytes are not the same, you can’t e.g. expect the contents of the buffer in string form to be this many bytes long. The character count is cached, so this function is very fast.
#### Parameters
| | | |
| --- | --- | --- |
| buffer | a [GtkTextBuffer](gtktextbuffer#GtkTextBuffer-struct) | |
#### Returns
number of characters in the buffer
### gtk\_text\_buffer\_get\_tag\_table ()
```
[GtkTextTagTable](gtktexttagtable#GtkTextTagTable-struct) *
gtk_text_buffer_get_tag_table (*`[GtkTextBuffer](gtktextbuffer#GtkTextBuffer-struct) *buffer`*);
```
Get the [GtkTextTagTable](gtktexttagtable#GtkTextTagTable-struct) associated with this buffer.
#### Parameters
| | | |
| --- | --- | --- |
| buffer | a [GtkTextBuffer](gtktextbuffer#GtkTextBuffer-struct) | |
#### Returns
the buffer’s tag table.
[transfer none]
### gtk\_text\_buffer\_insert ()
```
void
gtk_text_buffer_insert (*`[GtkTextBuffer](gtktextbuffer#GtkTextBuffer-struct) *buffer`*,
*`[GtkTextIter](gtktextiter#GtkTextIter-struct) *iter`*,
*`const char *text`*,
*`int len`*);
```
Inserts *`len`* bytes of *`text`* at position *`iter`* . If *`len`* is -1, *`text`* must be nul-terminated and will be inserted in its entirety. Emits the “insert-text” signal; insertion actually occurs in the default handler for the signal. *`iter`* is invalidated when insertion occurs (because the buffer contents change), but the default signal handler revalidates it to point to the end of the inserted text.
#### Parameters
| | | |
| --- | --- | --- |
| buffer | a [GtkTextBuffer](gtktextbuffer#GtkTextBuffer-struct) | |
| iter | a position in the buffer | |
| text | text in UTF-8 format | |
| len | length of text in bytes, or -1 | |
### gtk\_text\_buffer\_insert\_at\_cursor ()
```
void
gtk_text_buffer_insert_at_cursor (*`[GtkTextBuffer](gtktextbuffer#GtkTextBuffer-struct) *buffer`*,
*`const char *text`*,
*`int len`*);
```
Simply calls [`gtk_text_buffer_insert()`](gtktextbuffer#gtk-text-buffer-insert), using the current cursor position as the insertion point.
#### Parameters
| | | |
| --- | --- | --- |
| buffer | a [GtkTextBuffer](gtktextbuffer#GtkTextBuffer-struct) | |
| text | text in UTF-8 format | |
| len | length of text, in bytes | |
### gtk\_text\_buffer\_insert\_interactive ()
```
gboolean
gtk_text_buffer_insert_interactive (*`[GtkTextBuffer](gtktextbuffer#GtkTextBuffer-struct) *buffer`*,
*`[GtkTextIter](gtktextiter#GtkTextIter-struct) *iter`*,
*`const char *text`*,
*`int len`*,
*`gboolean default_editable`*);
```
Like [`gtk_text_buffer_insert()`](gtktextbuffer#gtk-text-buffer-insert), but the insertion will not occur if *`iter`* is at a non-editable location in the buffer. Usually you want to prevent insertions at ineditable locations if the insertion results from a user action (is interactive).
*`default_editable`* indicates the editability of text that doesn't have a tag affecting editability applied to it. Typically the result of [`gtk_text_view_get_editable()`](gtktextview#gtk-text-view-get-editable) is appropriate here.
#### Parameters
| | | |
| --- | --- | --- |
| buffer | a [GtkTextBuffer](gtktextbuffer#GtkTextBuffer-struct) | |
| iter | a position in *`buffer`* | |
| text | some UTF-8 text | |
| len | length of text in bytes, or -1 | |
| default\_editable | default editability of buffer | |
#### Returns
whether text was actually inserted
### gtk\_text\_buffer\_insert\_interactive\_at\_cursor ()
```
gboolean
gtk_text_buffer_insert_interactive_at_cursor
(*`[GtkTextBuffer](gtktextbuffer#GtkTextBuffer-struct) *buffer`*,
*`const char *text`*,
*`int len`*,
*`gboolean default_editable`*);
```
Calls [`gtk_text_buffer_insert_interactive()`](gtktextbuffer#gtk-text-buffer-insert-interactive) at the cursor position.
*`default_editable`* indicates the editability of text that doesn't have a tag affecting editability applied to it. Typically the result of [`gtk_text_view_get_editable()`](gtktextview#gtk-text-view-get-editable) is appropriate here.
#### Parameters
| | | |
| --- | --- | --- |
| buffer | a [GtkTextBuffer](gtktextbuffer#GtkTextBuffer-struct) | |
| text | text in UTF-8 format | |
| len | length of text in bytes, or -1 | |
| default\_editable | default editability of buffer | |
#### Returns
whether text was actually inserted
### gtk\_text\_buffer\_insert\_range ()
```
void
gtk_text_buffer_insert_range (*`[GtkTextBuffer](gtktextbuffer#GtkTextBuffer-struct) *buffer`*,
*`[GtkTextIter](gtktextiter#GtkTextIter-struct) *iter`*,
*`const [GtkTextIter](gtktextiter#GtkTextIter-struct) *start`*,
*`const [GtkTextIter](gtktextiter#GtkTextIter-struct) *end`*);
```
Copies text, tags, and paintables between *`start`* and *`end`* (the order of *`start`* and *`end`* doesn’t matter) and inserts the copy at *`iter`* . Used instead of simply getting/inserting text because it preserves images and tags. If *`start`* and *`end`* are in a different buffer from *`buffer`* , the two buffers must share the same tag table.
Implemented via emissions of the insert\_text and apply\_tag signals, so expect those.
#### Parameters
| | | |
| --- | --- | --- |
| buffer | a [GtkTextBuffer](gtktextbuffer#GtkTextBuffer-struct) | |
| iter | a position in *`buffer`* | |
| start | a position in a [GtkTextBuffer](gtktextbuffer#GtkTextBuffer-struct) | |
| end | another position in the same buffer as *`start`* | |
### gtk\_text\_buffer\_insert\_range\_interactive ()
```
gboolean
gtk_text_buffer_insert_range_interactive
(*`[GtkTextBuffer](gtktextbuffer#GtkTextBuffer-struct) *buffer`*,
*`[GtkTextIter](gtktextiter#GtkTextIter-struct) *iter`*,
*`const [GtkTextIter](gtktextiter#GtkTextIter-struct) *start`*,
*`const [GtkTextIter](gtktextiter#GtkTextIter-struct) *end`*,
*`gboolean default_editable`*);
```
Same as [`gtk_text_buffer_insert_range()`](gtktextbuffer#gtk-text-buffer-insert-range), but does nothing if the insertion point isn’t editable. The *`default_editable`* parameter indicates whether the text is editable at *`iter`* if no tags enclosing *`iter`* affect editability. Typically the result of [`gtk_text_view_get_editable()`](gtktextview#gtk-text-view-get-editable) is appropriate here.
#### Parameters
| | | |
| --- | --- | --- |
| buffer | a [GtkTextBuffer](gtktextbuffer#GtkTextBuffer-struct) | |
| iter | a position in *`buffer`* | |
| start | a position in a [GtkTextBuffer](gtktextbuffer#GtkTextBuffer-struct) | |
| end | another position in the same buffer as *`start`* | |
| default\_editable | default editability of the buffer | |
#### Returns
whether an insertion was possible at *`iter`*
### gtk\_text\_buffer\_insert\_with\_tags ()
```
void
gtk_text_buffer_insert_with_tags (*`[GtkTextBuffer](gtktextbuffer#GtkTextBuffer-struct) *buffer`*,
*`[GtkTextIter](gtktextiter#GtkTextIter-struct) *iter`*,
*`const char *text`*,
*`int len`*,
*`[GtkTextTag](gtktexttag#GtkTextTag-struct) *first_tag`*,
*`...`*);
```
Inserts *`text`* into *`buffer`* at *`iter`* , applying the list of tags to the newly-inserted text. The last tag specified must be `NULL` to terminate the list. Equivalent to calling [`gtk_text_buffer_insert()`](gtktextbuffer#gtk-text-buffer-insert), then [`gtk_text_buffer_apply_tag()`](gtktextbuffer#gtk-text-buffer-apply-tag) on the inserted text; [`gtk_text_buffer_insert_with_tags()`](gtktextbuffer#gtk-text-buffer-insert-with-tags) is just a convenience function.
#### Parameters
| | | |
| --- | --- | --- |
| buffer | a [GtkTextBuffer](gtktextbuffer#GtkTextBuffer-struct) | |
| iter | an iterator in *`buffer`* | |
| text | UTF-8 text | |
| len | length of *`text`* , or -1 | |
| first\_tag | first tag to apply to *`text`* | |
| ... | `NULL`-terminated list of tags to apply | |
### gtk\_text\_buffer\_insert\_with\_tags\_by\_name ()
```
void
gtk_text_buffer_insert_with_tags_by_name
(*`[GtkTextBuffer](gtktextbuffer#GtkTextBuffer-struct) *buffer`*,
*`[GtkTextIter](gtktextiter#GtkTextIter-struct) *iter`*,
*`const char *text`*,
*`int len`*,
*`const char *first_tag_name`*,
*`...`*);
```
Same as [`gtk_text_buffer_insert_with_tags()`](gtktextbuffer#gtk-text-buffer-insert-with-tags), but allows you to pass in tag names instead of tag objects.
#### Parameters
| | | |
| --- | --- | --- |
| buffer | a [GtkTextBuffer](gtktextbuffer#GtkTextBuffer-struct) | |
| iter | position in *`buffer`* | |
| text | UTF-8 text | |
| len | length of *`text`* , or -1 | |
| first\_tag\_name | name of a tag to apply to *`text`* | |
| ... | more tag names | |
### gtk\_text\_buffer\_insert\_markup ()
```
void
gtk_text_buffer_insert_markup (*`[GtkTextBuffer](gtktextbuffer#GtkTextBuffer-struct) *buffer`*,
*`[GtkTextIter](gtktextiter#GtkTextIter-struct) *iter`*,
*`const char *markup`*,
*`int len`*);
```
Inserts the text in *`markup`* at position *`iter`* . *`markup`* will be inserted in its entirety and must be nul-terminated and valid UTF-8. Emits the [“insert-text”](gtktextbuffer#GtkTextBuffer-insert-text) signal, possibly multiple times; insertion actually occurs in the default handler for the signal. *`iter`* will point to the end of the inserted text on return.
#### Parameters
| | | |
| --- | --- | --- |
| buffer | a [GtkTextBuffer](gtktextbuffer#GtkTextBuffer-struct) | |
| iter | location to insert the markup | |
| markup | a nul-terminated UTF-8 string containing Pango markup | |
| len | length of *`markup`* in bytes, or -1 | |
### gtk\_text\_buffer\_insert\_paintable ()
```
void
gtk_text_buffer_insert_paintable (*`[GtkTextBuffer](gtktextbuffer#GtkTextBuffer-struct) *buffer`*,
*`[GtkTextIter](gtktextiter#GtkTextIter-struct) *iter`*,
*`[GdkPaintable](https://developer-old.gnome.org/gtk4/html/GdkPaintable.html#GdkPaintable-struct) *paintable`*);
```
Inserts an image into the text buffer at *`iter`* . The image will be counted as one character in character counts, and when obtaining the buffer contents as a string, will be represented by the Unicode “object replacement character” 0xFFFC. Note that the “slice” variants for obtaining portions of the buffer as a string include this character for paintable, but the “text” variants do not. e.g. see [`gtk_text_buffer_get_slice()`](gtktextbuffer#gtk-text-buffer-get-slice) and [`gtk_text_buffer_get_text()`](gtktextbuffer#gtk-text-buffer-get-text).
#### Parameters
| | | |
| --- | --- | --- |
| buffer | a [GtkTextBuffer](gtktextbuffer#GtkTextBuffer-struct) | |
| iter | location to insert the paintable | |
| paintable | a [GdkPaintable](https://developer-old.gnome.org/gtk4/html/GdkPaintable.html#GdkPaintable-struct) | |
### gtk\_text\_buffer\_delete ()
```
void
gtk_text_buffer_delete (*`[GtkTextBuffer](gtktextbuffer#GtkTextBuffer-struct) *buffer`*,
*`[GtkTextIter](gtktextiter#GtkTextIter-struct) *start`*,
*`[GtkTextIter](gtktextiter#GtkTextIter-struct) *end`*);
```
Deletes text between *`start`* and *`end`* . The order of *`start`* and *`end`* is not actually relevant; [`gtk_text_buffer_delete()`](gtktextbuffer#gtk-text-buffer-delete) will reorder them. This function actually emits the “delete-range” signal, and the default handler of that signal deletes the text. Because the buffer is modified, all outstanding iterators become invalid after calling this function; however, the *`start`* and *`end`* will be re-initialized to point to the location where text was deleted.
#### Parameters
| | | |
| --- | --- | --- |
| buffer | a [GtkTextBuffer](gtktextbuffer#GtkTextBuffer-struct) | |
| start | a position in *`buffer`* | |
| end | another position in *`buffer`* | |
### gtk\_text\_buffer\_delete\_interactive ()
```
gboolean
gtk_text_buffer_delete_interactive (*`[GtkTextBuffer](gtktextbuffer#GtkTextBuffer-struct) *buffer`*,
*`[GtkTextIter](gtktextiter#GtkTextIter-struct) *start_iter`*,
*`[GtkTextIter](gtktextiter#GtkTextIter-struct) *end_iter`*,
*`gboolean default_editable`*);
```
Deletes all editable text in the given range. Calls [`gtk_text_buffer_delete()`](gtktextbuffer#gtk-text-buffer-delete) for each editable sub-range of [*`start`* ,*`end`* ). *`start`* and *`end`* are revalidated to point to the location of the last deleted range, or left untouched if no text was deleted.
#### Parameters
| | | |
| --- | --- | --- |
| buffer | a [GtkTextBuffer](gtktextbuffer#GtkTextBuffer-struct) | |
| start\_iter | start of range to delete | |
| end\_iter | end of range | |
| default\_editable | whether the buffer is editable by default | |
#### Returns
whether some text was actually deleted
### gtk\_text\_buffer\_backspace ()
```
gboolean
gtk_text_buffer_backspace (*`[GtkTextBuffer](gtktextbuffer#GtkTextBuffer-struct) *buffer`*,
*`[GtkTextIter](gtktextiter#GtkTextIter-struct) *iter`*,
*`gboolean interactive`*,
*`gboolean default_editable`*);
```
Performs the appropriate action as if the user hit the delete key with the cursor at the position specified by *`iter`* . In the normal case a single character will be deleted, but when combining accents are involved, more than one character can be deleted, and when precomposed character and accent combinations are involved, less than one character will be deleted.
Because the buffer is modified, all outstanding iterators become invalid after calling this function; however, the *`iter`* will be re-initialized to point to the location where text was deleted.
#### Parameters
| | | |
| --- | --- | --- |
| buffer | a [GtkTextBuffer](gtktextbuffer#GtkTextBuffer-struct) | |
| iter | a position in *`buffer`* | |
| interactive | whether the deletion is caused by user interaction | |
| default\_editable | whether the buffer is editable by default | |
#### Returns
`TRUE` if the buffer was modified
### gtk\_text\_buffer\_set\_text ()
```
void
gtk_text_buffer_set_text (*`[GtkTextBuffer](gtktextbuffer#GtkTextBuffer-struct) *buffer`*,
*`const char *text`*,
*`int len`*);
```
Deletes current contents of *`buffer`* , and inserts *`text`* instead. If *`len`* is -1, *`text`* must be nul-terminated. *`text`* must be valid UTF-8.
#### Parameters
| | | |
| --- | --- | --- |
| buffer | a [GtkTextBuffer](gtktextbuffer#GtkTextBuffer-struct) | |
| text | UTF-8 text to insert | |
| len | length of *`text`* in bytes | |
### gtk\_text\_buffer\_get\_text ()
```
char *
gtk_text_buffer_get_text (*`[GtkTextBuffer](gtktextbuffer#GtkTextBuffer-struct) *buffer`*,
*`const [GtkTextIter](gtktextiter#GtkTextIter-struct) *start`*,
*`const [GtkTextIter](gtktextiter#GtkTextIter-struct) *end`*,
*`gboolean include_hidden_chars`*);
```
Returns the text in the range [*`start`* ,*`end`* ). Excludes undisplayed text (text marked with tags that set the invisibility attribute) if *`include_hidden_chars`* is `FALSE`. Does not include characters representing embedded images, so byte and character indexes into the returned string do not correspond to byte and character indexes into the buffer. Contrast with [`gtk_text_buffer_get_slice()`](gtktextbuffer#gtk-text-buffer-get-slice).
#### Parameters
| | | |
| --- | --- | --- |
| buffer | a [GtkTextBuffer](gtktextbuffer#GtkTextBuffer-struct) | |
| start | start of a range | |
| end | end of a range | |
| include\_hidden\_chars | whether to include invisible text | |
#### Returns
an allocated UTF-8 string.
[transfer full]
### gtk\_text\_buffer\_get\_slice ()
```
char *
gtk_text_buffer_get_slice (*`[GtkTextBuffer](gtktextbuffer#GtkTextBuffer-struct) *buffer`*,
*`const [GtkTextIter](gtktextiter#GtkTextIter-struct) *start`*,
*`const [GtkTextIter](gtktextiter#GtkTextIter-struct) *end`*,
*`gboolean include_hidden_chars`*);
```
Returns the text in the range [*`start`* ,*`end`* ). Excludes undisplayed text (text marked with tags that set the invisibility attribute) if *`include_hidden_chars`* is `FALSE`. The returned string includes a 0xFFFC character whenever the buffer contains embedded images, so byte and character indexes into the returned string do correspond to byte and character indexes into the buffer. Contrast with [`gtk_text_buffer_get_text()`](gtktextbuffer#gtk-text-buffer-get-text). Note that 0xFFFC can occur in normal text as well, so it is not a reliable indicator that a paintable or widget is in the buffer.
#### Parameters
| | | |
| --- | --- | --- |
| buffer | a [GtkTextBuffer](gtktextbuffer#GtkTextBuffer-struct) | |
| start | start of a range | |
| end | end of a range | |
| include\_hidden\_chars | whether to include invisible text | |
#### Returns
an allocated UTF-8 string.
[transfer full]
### gtk\_text\_buffer\_insert\_child\_anchor ()
```
void
gtk_text_buffer_insert_child_anchor (*`[GtkTextBuffer](gtktextbuffer#GtkTextBuffer-struct) *buffer`*,
*`[GtkTextIter](gtktextiter#GtkTextIter-struct) *iter`*,
*`[GtkTextChildAnchor](gtktextview#GtkTextChildAnchor-struct) *anchor`*);
```
Inserts a child widget anchor into the text buffer at *`iter`* . The anchor will be counted as one character in character counts, and when obtaining the buffer contents as a string, will be represented by the Unicode “object replacement character” 0xFFFC. Note that the “slice” variants for obtaining portions of the buffer as a string include this character for child anchors, but the “text” variants do not. E.g. see [`gtk_text_buffer_get_slice()`](gtktextbuffer#gtk-text-buffer-get-slice) and [`gtk_text_buffer_get_text()`](gtktextbuffer#gtk-text-buffer-get-text). Consider [`gtk_text_buffer_create_child_anchor()`](gtktextbuffer#gtk-text-buffer-create-child-anchor) as a more convenient alternative to this function. The buffer will add a reference to the anchor, so you can unref it after insertion.
#### Parameters
| | | |
| --- | --- | --- |
| buffer | a [GtkTextBuffer](gtktextbuffer#GtkTextBuffer-struct) | |
| iter | location to insert the anchor | |
| anchor | a [GtkTextChildAnchor](gtktextview#GtkTextChildAnchor-struct) | |
### gtk\_text\_buffer\_create\_child\_anchor ()
```
[GtkTextChildAnchor](gtktextview#GtkTextChildAnchor-struct) *
gtk_text_buffer_create_child_anchor (*`[GtkTextBuffer](gtktextbuffer#GtkTextBuffer-struct) *buffer`*,
*`[GtkTextIter](gtktextiter#GtkTextIter-struct) *iter`*);
```
This is a convenience function which simply creates a child anchor with [`gtk_text_child_anchor_new()`](gtktextview#gtk-text-child-anchor-new) and inserts it into the buffer with [`gtk_text_buffer_insert_child_anchor()`](gtktextbuffer#gtk-text-buffer-insert-child-anchor). The new anchor is owned by the buffer; no reference count is returned to the caller of [`gtk_text_buffer_create_child_anchor()`](gtktextbuffer#gtk-text-buffer-create-child-anchor).
#### Parameters
| | | |
| --- | --- | --- |
| buffer | a [GtkTextBuffer](gtktextbuffer#GtkTextBuffer-struct) | |
| iter | location in the buffer | |
#### Returns
the created child anchor.
[transfer none]
### gtk\_text\_buffer\_create\_mark ()
```
[GtkTextMark](gtktextmark#GtkTextMark-struct) *
gtk_text_buffer_create_mark (*`[GtkTextBuffer](gtktextbuffer#GtkTextBuffer-struct) *buffer`*,
*`const char *mark_name`*,
*`const [GtkTextIter](gtktextiter#GtkTextIter-struct) *where`*,
*`gboolean left_gravity`*);
```
Creates a mark at position *`where`* . If *`mark_name`* is `NULL`, the mark is anonymous; otherwise, the mark can be retrieved by name using [`gtk_text_buffer_get_mark()`](gtktextbuffer#gtk-text-buffer-get-mark). If a mark has left gravity, and text is inserted at the mark’s current location, the mark will be moved to the left of the newly-inserted text. If the mark has right gravity (*`left_gravity`* = `FALSE`), the mark will end up on the right of newly-inserted text. The standard left-to-right cursor is a mark with right gravity (when you type, the cursor stays on the right side of the text you’re typing).
The caller of this function does not own a reference to the returned [GtkTextMark](gtktextmark#GtkTextMark-struct), so you can ignore the return value if you like. Marks are owned by the buffer and go away when the buffer does.
Emits the [“mark-set”](gtktextbuffer#GtkTextBuffer-mark-set) signal as notification of the mark's initial placement.
#### Parameters
| | | |
| --- | --- | --- |
| buffer | a [GtkTextBuffer](gtktextbuffer#GtkTextBuffer-struct) | |
| mark\_name | name for mark, or `NULL`. | [allow-none] |
| where | location to place mark | |
| left\_gravity | whether the mark has left gravity | |
#### Returns
the new [GtkTextMark](gtktextmark#GtkTextMark-struct) object.
[transfer none]
### gtk\_text\_buffer\_move\_mark ()
```
void
gtk_text_buffer_move_mark (*`[GtkTextBuffer](gtktextbuffer#GtkTextBuffer-struct) *buffer`*,
*`[GtkTextMark](gtktextmark#GtkTextMark-struct) *mark`*,
*`const [GtkTextIter](gtktextiter#GtkTextIter-struct) *where`*);
```
Moves *`mark`* to the new location *`where`* . Emits the [“mark-set”](gtktextbuffer#GtkTextBuffer-mark-set) signal as notification of the move.
#### Parameters
| | | |
| --- | --- | --- |
| buffer | a [GtkTextBuffer](gtktextbuffer#GtkTextBuffer-struct) | |
| mark | a [GtkTextMark](gtktextmark#GtkTextMark-struct) | |
| where | new location for *`mark`* in *`buffer`* | |
### gtk\_text\_buffer\_move\_mark\_by\_name ()
```
void
gtk_text_buffer_move_mark_by_name (*`[GtkTextBuffer](gtktextbuffer#GtkTextBuffer-struct) *buffer`*,
*`const char *name`*,
*`const [GtkTextIter](gtktextiter#GtkTextIter-struct) *where`*);
```
Moves the mark named *`name`* (which must exist) to location *`where`* . See [`gtk_text_buffer_move_mark()`](gtktextbuffer#gtk-text-buffer-move-mark) for details.
#### Parameters
| | | |
| --- | --- | --- |
| buffer | a [GtkTextBuffer](gtktextbuffer#GtkTextBuffer-struct) | |
| name | name of a mark | |
| where | new location for mark | |
### gtk\_text\_buffer\_add\_mark ()
```
void
gtk_text_buffer_add_mark (*`[GtkTextBuffer](gtktextbuffer#GtkTextBuffer-struct) *buffer`*,
*`[GtkTextMark](gtktextmark#GtkTextMark-struct) *mark`*,
*`const [GtkTextIter](gtktextiter#GtkTextIter-struct) *where`*);
```
Adds the mark at position *`where`* . The mark must not be added to another buffer, and if its name is not `NULL` then there must not be another mark in the buffer with the same name.
Emits the [“mark-set”](gtktextbuffer#GtkTextBuffer-mark-set) signal as notification of the mark's initial placement.
#### Parameters
| | | |
| --- | --- | --- |
| buffer | a [GtkTextBuffer](gtktextbuffer#GtkTextBuffer-struct) | |
| mark | the mark to add | |
| where | location to place mark | |
### gtk\_text\_buffer\_delete\_mark ()
```
void
gtk_text_buffer_delete_mark (*`[GtkTextBuffer](gtktextbuffer#GtkTextBuffer-struct) *buffer`*,
*`[GtkTextMark](gtktextmark#GtkTextMark-struct) *mark`*);
```
Deletes *`mark`* , so that it’s no longer located anywhere in the buffer. Removes the reference the buffer holds to the mark, so if you haven’t called `g_object_ref()` on the mark, it will be freed. Even if the mark isn’t freed, most operations on *`mark`* become invalid, until it gets added to a buffer again with [`gtk_text_buffer_add_mark()`](gtktextbuffer#gtk-text-buffer-add-mark). Use [`gtk_text_mark_get_deleted()`](gtktextmark#gtk-text-mark-get-deleted) to find out if a mark has been removed from its buffer. The [“mark-deleted”](gtktextbuffer#GtkTextBuffer-mark-deleted) signal will be emitted as notification after the mark is deleted.
#### Parameters
| | | |
| --- | --- | --- |
| buffer | a [GtkTextBuffer](gtktextbuffer#GtkTextBuffer-struct) | |
| mark | a [GtkTextMark](gtktextmark#GtkTextMark-struct) in *`buffer`* | |
### gtk\_text\_buffer\_delete\_mark\_by\_name ()
```
void
gtk_text_buffer_delete_mark_by_name (*`[GtkTextBuffer](gtktextbuffer#GtkTextBuffer-struct) *buffer`*,
*`const char *name`*);
```
Deletes the mark named *`name`* ; the mark must exist. See [`gtk_text_buffer_delete_mark()`](gtktextbuffer#gtk-text-buffer-delete-mark) for details.
#### Parameters
| | | |
| --- | --- | --- |
| buffer | a [GtkTextBuffer](gtktextbuffer#GtkTextBuffer-struct) | |
| name | name of a mark in *`buffer`* | |
### gtk\_text\_buffer\_get\_mark ()
```
[GtkTextMark](gtktextmark#GtkTextMark-struct) *
gtk_text_buffer_get_mark (*`[GtkTextBuffer](gtktextbuffer#GtkTextBuffer-struct) *buffer`*,
*`const char *name`*);
```
Returns the mark named *`name`* in buffer *`buffer`* , or `NULL` if no such mark exists in the buffer.
#### Parameters
| | | |
| --- | --- | --- |
| buffer | a [GtkTextBuffer](gtktextbuffer#GtkTextBuffer-struct) | |
| name | a mark name | |
#### Returns
a [GtkTextMark](gtktextmark#GtkTextMark-struct), or `NULL`.
[nullable][transfer none]
### gtk\_text\_buffer\_get\_insert ()
```
[GtkTextMark](gtktextmark#GtkTextMark-struct) *
gtk_text_buffer_get_insert (*`[GtkTextBuffer](gtktextbuffer#GtkTextBuffer-struct) *buffer`*);
```
Returns the mark that represents the cursor (insertion point). Equivalent to calling [`gtk_text_buffer_get_mark()`](gtktextbuffer#gtk-text-buffer-get-mark) to get the mark named “insert”, but very slightly more efficient, and involves less typing.
#### Parameters
| | | |
| --- | --- | --- |
| buffer | a [GtkTextBuffer](gtktextbuffer#GtkTextBuffer-struct) | |
#### Returns
insertion point mark.
[transfer none]
### gtk\_text\_buffer\_get\_selection\_bound ()
```
[GtkTextMark](gtktextmark#GtkTextMark-struct) *
gtk_text_buffer_get_selection_bound (*`[GtkTextBuffer](gtktextbuffer#GtkTextBuffer-struct) *buffer`*);
```
Returns the mark that represents the selection bound. Equivalent to calling [`gtk_text_buffer_get_mark()`](gtktextbuffer#gtk-text-buffer-get-mark) to get the mark named “selection\_bound”, but very slightly more efficient, and involves less typing.
The currently-selected text in *`buffer`* is the region between the “selection\_bound” and “insert” marks. If “selection\_bound” and “insert” are in the same place, then there is no current selection. [`gtk_text_buffer_get_selection_bounds()`](gtktextbuffer#gtk-text-buffer-get-selection-bounds) is another convenient function for handling the selection, if you just want to know whether there’s a selection and what its bounds are.
#### Parameters
| | | |
| --- | --- | --- |
| buffer | a [GtkTextBuffer](gtktextbuffer#GtkTextBuffer-struct) | |
#### Returns
selection bound mark.
[transfer none]
### gtk\_text\_buffer\_get\_has\_selection ()
```
gboolean
gtk_text_buffer_get_has_selection (*`[GtkTextBuffer](gtktextbuffer#GtkTextBuffer-struct) *buffer`*);
```
Indicates whether the buffer has some text currently selected.
#### Parameters
| | | |
| --- | --- | --- |
| buffer | a [GtkTextBuffer](gtktextbuffer#GtkTextBuffer-struct) | |
#### Returns
`TRUE` if the there is text selected
### gtk\_text\_buffer\_place\_cursor ()
```
void
gtk_text_buffer_place_cursor (*`[GtkTextBuffer](gtktextbuffer#GtkTextBuffer-struct) *buffer`*,
*`const [GtkTextIter](gtktextiter#GtkTextIter-struct) *where`*);
```
This function moves the “insert” and “selection\_bound” marks simultaneously. If you move them to the same place in two steps with [`gtk_text_buffer_move_mark()`](gtktextbuffer#gtk-text-buffer-move-mark), you will temporarily select a region in between their old and new locations, which can be pretty inefficient since the temporarily-selected region will force stuff to be recalculated. This function moves them as a unit, which can be optimized.
#### Parameters
| | | |
| --- | --- | --- |
| buffer | a [GtkTextBuffer](gtktextbuffer#GtkTextBuffer-struct) | |
| where | where to put the cursor | |
### gtk\_text\_buffer\_select\_range ()
```
void
gtk_text_buffer_select_range (*`[GtkTextBuffer](gtktextbuffer#GtkTextBuffer-struct) *buffer`*,
*`const [GtkTextIter](gtktextiter#GtkTextIter-struct) *ins`*,
*`const [GtkTextIter](gtktextiter#GtkTextIter-struct) *bound`*);
```
This function moves the “insert” and “selection\_bound” marks simultaneously. If you move them in two steps with [`gtk_text_buffer_move_mark()`](gtktextbuffer#gtk-text-buffer-move-mark), you will temporarily select a region in between their old and new locations, which can be pretty inefficient since the temporarily-selected region will force stuff to be recalculated. This function moves them as a unit, which can be optimized.
#### Parameters
| | | |
| --- | --- | --- |
| buffer | a [GtkTextBuffer](gtktextbuffer#GtkTextBuffer-struct) | |
| ins | where to put the “insert” mark | |
| bound | where to put the “selection\_bound” mark | |
### gtk\_text\_buffer\_apply\_tag ()
```
void
gtk_text_buffer_apply_tag (*`[GtkTextBuffer](gtktextbuffer#GtkTextBuffer-struct) *buffer`*,
*`[GtkTextTag](gtktexttag#GtkTextTag-struct) *tag`*,
*`const [GtkTextIter](gtktextiter#GtkTextIter-struct) *start`*,
*`const [GtkTextIter](gtktextiter#GtkTextIter-struct) *end`*);
```
Emits the “apply-tag” signal on *`buffer`* . The default handler for the signal applies *`tag`* to the given range. *`start`* and *`end`* do not have to be in order.
#### Parameters
| | | |
| --- | --- | --- |
| buffer | a [GtkTextBuffer](gtktextbuffer#GtkTextBuffer-struct) | |
| tag | a [GtkTextTag](gtktexttag#GtkTextTag-struct) | |
| start | one bound of range to be tagged | |
| end | other bound of range to be tagged | |
### gtk\_text\_buffer\_remove\_tag ()
```
void
gtk_text_buffer_remove_tag (*`[GtkTextBuffer](gtktextbuffer#GtkTextBuffer-struct) *buffer`*,
*`[GtkTextTag](gtktexttag#GtkTextTag-struct) *tag`*,
*`const [GtkTextIter](gtktextiter#GtkTextIter-struct) *start`*,
*`const [GtkTextIter](gtktextiter#GtkTextIter-struct) *end`*);
```
Emits the “remove-tag” signal. The default handler for the signal removes all occurrences of *`tag`* from the given range. *`start`* and *`end`* don’t have to be in order.
#### Parameters
| | | |
| --- | --- | --- |
| buffer | a [GtkTextBuffer](gtktextbuffer#GtkTextBuffer-struct) | |
| tag | a [GtkTextTag](gtktexttag#GtkTextTag-struct) | |
| start | one bound of range to be untagged | |
| end | other bound of range to be untagged | |
### gtk\_text\_buffer\_apply\_tag\_by\_name ()
```
void
gtk_text_buffer_apply_tag_by_name (*`[GtkTextBuffer](gtktextbuffer#GtkTextBuffer-struct) *buffer`*,
*`const char *name`*,
*`const [GtkTextIter](gtktextiter#GtkTextIter-struct) *start`*,
*`const [GtkTextIter](gtktextiter#GtkTextIter-struct) *end`*);
```
Calls [`gtk_text_tag_table_lookup()`](gtktexttagtable#gtk-text-tag-table-lookup) on the buffer’s tag table to get a [GtkTextTag](gtktexttag#GtkTextTag-struct), then calls [`gtk_text_buffer_apply_tag()`](gtktextbuffer#gtk-text-buffer-apply-tag).
#### Parameters
| | | |
| --- | --- | --- |
| buffer | a [GtkTextBuffer](gtktextbuffer#GtkTextBuffer-struct) | |
| name | name of a named [GtkTextTag](gtktexttag#GtkTextTag-struct) | |
| start | one bound of range to be tagged | |
| end | other bound of range to be tagged | |
### gtk\_text\_buffer\_remove\_tag\_by\_name ()
```
void
gtk_text_buffer_remove_tag_by_name (*`[GtkTextBuffer](gtktextbuffer#GtkTextBuffer-struct) *buffer`*,
*`const char *name`*,
*`const [GtkTextIter](gtktextiter#GtkTextIter-struct) *start`*,
*`const [GtkTextIter](gtktextiter#GtkTextIter-struct) *end`*);
```
Calls [`gtk_text_tag_table_lookup()`](gtktexttagtable#gtk-text-tag-table-lookup) on the buffer’s tag table to get a [GtkTextTag](gtktexttag#GtkTextTag-struct), then calls [`gtk_text_buffer_remove_tag()`](gtktextbuffer#gtk-text-buffer-remove-tag).
#### Parameters
| | | |
| --- | --- | --- |
| buffer | a [GtkTextBuffer](gtktextbuffer#GtkTextBuffer-struct) | |
| name | name of a [GtkTextTag](gtktexttag#GtkTextTag-struct) | |
| start | one bound of range to be untagged | |
| end | other bound of range to be untagged | |
### gtk\_text\_buffer\_remove\_all\_tags ()
```
void
gtk_text_buffer_remove_all_tags (*`[GtkTextBuffer](gtktextbuffer#GtkTextBuffer-struct) *buffer`*,
*`const [GtkTextIter](gtktextiter#GtkTextIter-struct) *start`*,
*`const [GtkTextIter](gtktextiter#GtkTextIter-struct) *end`*);
```
Removes all tags in the range between *`start`* and *`end`* . Be careful with this function; it could remove tags added in code unrelated to the code you’re currently writing. That is, using this function is probably a bad idea if you have two or more unrelated code sections that add tags.
#### Parameters
| | | |
| --- | --- | --- |
| buffer | a [GtkTextBuffer](gtktextbuffer#GtkTextBuffer-struct) | |
| start | one bound of range to be untagged | |
| end | other bound of range to be untagged | |
### gtk\_text\_buffer\_create\_tag ()
```
[GtkTextTag](gtktexttag#GtkTextTag-struct) *
gtk_text_buffer_create_tag (*`[GtkTextBuffer](gtktextbuffer#GtkTextBuffer-struct) *buffer`*,
*`const char *tag_name`*,
*`const char *first_property_name`*,
*`...`*);
```
Creates a tag and adds it to the tag table for *`buffer`* . Equivalent to calling [`gtk_text_tag_new()`](gtktexttag#gtk-text-tag-new) and then adding the tag to the buffer’s tag table. The returned tag is owned by the buffer’s tag table, so the ref count will be equal to one.
If *`tag_name`* is `NULL`, the tag is anonymous.
If *`tag_name`* is non-`NULL`, a tag called *`tag_name`* must not already exist in the tag table for this buffer.
The *`first_property_name`* argument and subsequent arguments are a list of properties to set on the tag, as with `g_object_set()`.
#### Parameters
| | | |
| --- | --- | --- |
| buffer | a [GtkTextBuffer](gtktextbuffer#GtkTextBuffer-struct) | |
| tag\_name | name of the new tag, or `NULL`. | [allow-none] |
| first\_property\_name | name of first property to set, or `NULL`. | [allow-none] |
| ... | `NULL`-terminated list of property names and values | |
#### Returns
a new tag.
[transfer none]
### gtk\_text\_buffer\_get\_iter\_at\_line\_offset ()
```
gboolean
gtk_text_buffer_get_iter_at_line_offset
(*`[GtkTextBuffer](gtktextbuffer#GtkTextBuffer-struct) *buffer`*,
*`[GtkTextIter](gtktextiter#GtkTextIter-struct) *iter`*,
*`int line_number`*,
*`int char_offset`*);
```
Obtains an iterator pointing to *`char_offset`* within the given line. Note characters, not bytes; UTF-8 may encode one character as multiple bytes.
Before the 3.20 version, it was not allowed to pass an invalid location.
If *`line_number`* is greater than the number of lines in the *`buffer`* , the end iterator is returned. And if *`char_offset`* is off the end of the line, the iterator at the end of the line is returned.
#### Parameters
| | | |
| --- | --- | --- |
| buffer | a [GtkTextBuffer](gtktextbuffer#GtkTextBuffer-struct) | |
| iter | iterator to initialize. | [out] |
| line\_number | line number counting from 0 | |
| char\_offset | char offset from start of line | |
#### Returns
whether the exact position has been found
### gtk\_text\_buffer\_get\_iter\_at\_offset ()
```
void
gtk_text_buffer_get_iter_at_offset (*`[GtkTextBuffer](gtktextbuffer#GtkTextBuffer-struct) *buffer`*,
*`[GtkTextIter](gtktextiter#GtkTextIter-struct) *iter`*,
*`int char_offset`*);
```
Initializes *`iter`* to a position *`char_offset`* chars from the start of the entire buffer. If *`char_offset`* is -1 or greater than the number of characters in the buffer, *`iter`* is initialized to the end iterator, the iterator one past the last valid character in the buffer.
#### Parameters
| | | |
| --- | --- | --- |
| buffer | a [GtkTextBuffer](gtktextbuffer#GtkTextBuffer-struct) | |
| iter | iterator to initialize. | [out] |
| char\_offset | char offset from start of buffer, counting from 0, or -1 | |
### gtk\_text\_buffer\_get\_iter\_at\_line ()
```
gboolean
gtk_text_buffer_get_iter_at_line (*`[GtkTextBuffer](gtktextbuffer#GtkTextBuffer-struct) *buffer`*,
*`[GtkTextIter](gtktextiter#GtkTextIter-struct) *iter`*,
*`int line_number`*);
```
Initializes *`iter`* to the start of the given line. If *`line_number`* is greater than the number of lines in the *`buffer`* , the end iterator is returned.
#### Parameters
| | | |
| --- | --- | --- |
| buffer | a [GtkTextBuffer](gtktextbuffer#GtkTextBuffer-struct) | |
| iter | iterator to initialize. | [out] |
| line\_number | line number counting from 0 | |
#### Returns
whether the exact position has been found
### gtk\_text\_buffer\_get\_iter\_at\_line\_index ()
```
gboolean
gtk_text_buffer_get_iter_at_line_index
(*`[GtkTextBuffer](gtktextbuffer#GtkTextBuffer-struct) *buffer`*,
*`[GtkTextIter](gtktextiter#GtkTextIter-struct) *iter`*,
*`int line_number`*,
*`int byte_index`*);
```
Obtains an iterator pointing to *`byte_index`* within the given line. *`byte_index`* must be the start of a UTF-8 character. Note bytes, not characters; UTF-8 may encode one character as multiple bytes.
If *`line_number`* is greater than the number of lines in the *`buffer`* , the end iterator is returned. And if *`byte_index`* is off the end of the line, the iterator at the end of the line is returned.
#### Parameters
| | | |
| --- | --- | --- |
| buffer | a [GtkTextBuffer](gtktextbuffer#GtkTextBuffer-struct) | |
| iter | iterator to initialize. | [out] |
| line\_number | line number counting from 0 | |
| byte\_index | byte index from start of line | |
#### Returns
whether the exact position has been found
### gtk\_text\_buffer\_get\_iter\_at\_mark ()
```
void
gtk_text_buffer_get_iter_at_mark (*`[GtkTextBuffer](gtktextbuffer#GtkTextBuffer-struct) *buffer`*,
*`[GtkTextIter](gtktextiter#GtkTextIter-struct) *iter`*,
*`[GtkTextMark](gtktextmark#GtkTextMark-struct) *mark`*);
```
Initializes *`iter`* with the current position of *`mark`* .
#### Parameters
| | | |
| --- | --- | --- |
| buffer | a [GtkTextBuffer](gtktextbuffer#GtkTextBuffer-struct) | |
| iter | iterator to initialize. | [out] |
| mark | a [GtkTextMark](gtktextmark#GtkTextMark-struct) in *`buffer`* | |
### gtk\_text\_buffer\_get\_iter\_at\_child\_anchor ()
```
void
gtk_text_buffer_get_iter_at_child_anchor
(*`[GtkTextBuffer](gtktextbuffer#GtkTextBuffer-struct) *buffer`*,
*`[GtkTextIter](gtktextiter#GtkTextIter-struct) *iter`*,
*`[GtkTextChildAnchor](gtktextview#GtkTextChildAnchor-struct) *anchor`*);
```
Obtains the location of *`anchor`* within *`buffer`* .
#### Parameters
| | | |
| --- | --- | --- |
| buffer | a [GtkTextBuffer](gtktextbuffer#GtkTextBuffer-struct) | |
| iter | an iterator to be initialized. | [out] |
| anchor | a child anchor that appears in *`buffer`* | |
### gtk\_text\_buffer\_get\_start\_iter ()
```
void
gtk_text_buffer_get_start_iter (*`[GtkTextBuffer](gtktextbuffer#GtkTextBuffer-struct) *buffer`*,
*`[GtkTextIter](gtktextiter#GtkTextIter-struct) *iter`*);
```
Initialized *`iter`* with the first position in the text buffer. This is the same as using [`gtk_text_buffer_get_iter_at_offset()`](gtktextbuffer#gtk-text-buffer-get-iter-at-offset) to get the iter at character offset 0.
#### Parameters
| | | |
| --- | --- | --- |
| buffer | a [GtkTextBuffer](gtktextbuffer#GtkTextBuffer-struct) | |
| iter | iterator to initialize. | [out] |
### gtk\_text\_buffer\_get\_end\_iter ()
```
void
gtk_text_buffer_get_end_iter (*`[GtkTextBuffer](gtktextbuffer#GtkTextBuffer-struct) *buffer`*,
*`[GtkTextIter](gtktextiter#GtkTextIter-struct) *iter`*);
```
Initializes *`iter`* with the “end iterator,” one past the last valid character in the text buffer. If dereferenced with [`gtk_text_iter_get_char()`](gtktextiter#gtk-text-iter-get-char), the end iterator has a character value of 0. The entire buffer lies in the range from the first position in the buffer (call [`gtk_text_buffer_get_start_iter()`](gtktextbuffer#gtk-text-buffer-get-start-iter) to get character position 0) to the end iterator.
#### Parameters
| | | |
| --- | --- | --- |
| buffer | a [GtkTextBuffer](gtktextbuffer#GtkTextBuffer-struct) | |
| iter | iterator to initialize. | [out] |
### gtk\_text\_buffer\_get\_bounds ()
```
void
gtk_text_buffer_get_bounds (*`[GtkTextBuffer](gtktextbuffer#GtkTextBuffer-struct) *buffer`*,
*`[GtkTextIter](gtktextiter#GtkTextIter-struct) *start`*,
*`[GtkTextIter](gtktextiter#GtkTextIter-struct) *end`*);
```
Retrieves the first and last iterators in the buffer, i.e. the entire buffer lies within the range [*`start`* ,*`end`* ).
#### Parameters
| | | |
| --- | --- | --- |
| buffer | a [GtkTextBuffer](gtktextbuffer#GtkTextBuffer-struct) | |
| start | iterator to initialize with first position in the buffer. | [out] |
| end | iterator to initialize with the end iterator. | [out] |
### gtk\_text\_buffer\_get\_modified ()
```
gboolean
gtk_text_buffer_get_modified (*`[GtkTextBuffer](gtktextbuffer#GtkTextBuffer-struct) *buffer`*);
```
Indicates whether the buffer has been modified since the last call to [`gtk_text_buffer_set_modified()`](gtktextbuffer#gtk-text-buffer-set-modified) set the modification flag to `FALSE`. Used for example to enable a “save” function in a text editor.
#### Parameters
| | | |
| --- | --- | --- |
| buffer | a [GtkTextBuffer](gtktextbuffer#GtkTextBuffer-struct) | |
#### Returns
`TRUE` if the buffer has been modified
### gtk\_text\_buffer\_set\_modified ()
```
void
gtk_text_buffer_set_modified (*`[GtkTextBuffer](gtktextbuffer#GtkTextBuffer-struct) *buffer`*,
*`gboolean setting`*);
```
Used to keep track of whether the buffer has been modified since the last time it was saved. Whenever the buffer is saved to disk, call gtk\_text\_buffer\_set\_modified (*`buffer`* , FALSE). When the buffer is modified, it will automatically toggled on the modified bit again. When the modified bit flips, the buffer emits the [“modified-changed”](gtktextbuffer#GtkTextBuffer-modified-changed) signal.
#### Parameters
| | | |
| --- | --- | --- |
| buffer | a [GtkTextBuffer](gtktextbuffer#GtkTextBuffer-struct) | |
| setting | modification flag setting | |
### gtk\_text\_buffer\_delete\_selection ()
```
gboolean
gtk_text_buffer_delete_selection (*`[GtkTextBuffer](gtktextbuffer#GtkTextBuffer-struct) *buffer`*,
*`gboolean interactive`*,
*`gboolean default_editable`*);
```
Deletes the range between the “insert” and “selection\_bound” marks, that is, the currently-selected text. If *`interactive`* is `TRUE`, the editability of the selection will be considered (users can’t delete uneditable text).
#### Parameters
| | | |
| --- | --- | --- |
| buffer | a [GtkTextBuffer](gtktextbuffer#GtkTextBuffer-struct) | |
| interactive | whether the deletion is caused by user interaction | |
| default\_editable | whether the buffer is editable by default | |
#### Returns
whether there was a non-empty selection to delete
### gtk\_text\_buffer\_paste\_clipboard ()
```
void
gtk_text_buffer_paste_clipboard (*`[GtkTextBuffer](gtktextbuffer#GtkTextBuffer-struct) *buffer`*,
*`[GdkClipboard](https://developer-old.gnome.org/gtk4/html/gdk4-Clipboards.html#GdkClipboard-struct) *clipboard`*,
*`[GtkTextIter](gtktextiter#GtkTextIter-struct) *override_location`*,
*`gboolean default_editable`*);
```
Pastes the contents of a clipboard. If *`override_location`* is `NULL`, the pasted text will be inserted at the cursor position, or the buffer selection will be replaced if the selection is non-empty.
Note: pasting is asynchronous, that is, we’ll ask for the paste data and return, and at some point later after the main loop runs, the paste data will be inserted.
#### Parameters
| | | |
| --- | --- | --- |
| buffer | a [GtkTextBuffer](gtktextbuffer#GtkTextBuffer-struct) | |
| clipboard | the [GdkClipboard](https://developer-old.gnome.org/gtk4/html/gdk4-Clipboards.html#GdkClipboard-struct) to paste from | |
| override\_location | location to insert pasted text, or `NULL`. | [allow-none] |
| default\_editable | whether the buffer is editable by default | |
### gtk\_text\_buffer\_copy\_clipboard ()
```
void
gtk_text_buffer_copy_clipboard (*`[GtkTextBuffer](gtktextbuffer#GtkTextBuffer-struct) *buffer`*,
*`[GdkClipboard](https://developer-old.gnome.org/gtk4/html/gdk4-Clipboards.html#GdkClipboard-struct) *clipboard`*);
```
Copies the currently-selected text to a clipboard.
#### Parameters
| | | |
| --- | --- | --- |
| buffer | a [GtkTextBuffer](gtktextbuffer#GtkTextBuffer-struct) | |
| clipboard | the [GdkClipboard](https://developer-old.gnome.org/gtk4/html/gdk4-Clipboards.html#GdkClipboard-struct) object to copy to | |
### gtk\_text\_buffer\_cut\_clipboard ()
```
void
gtk_text_buffer_cut_clipboard (*`[GtkTextBuffer](gtktextbuffer#GtkTextBuffer-struct) *buffer`*,
*`[GdkClipboard](https://developer-old.gnome.org/gtk4/html/gdk4-Clipboards.html#GdkClipboard-struct) *clipboard`*,
*`gboolean default_editable`*);
```
Copies the currently-selected text to a clipboard, then deletes said text if it’s editable.
#### Parameters
| | | |
| --- | --- | --- |
| buffer | a [GtkTextBuffer](gtktextbuffer#GtkTextBuffer-struct) | |
| clipboard | the [GdkClipboard](https://developer-old.gnome.org/gtk4/html/gdk4-Clipboards.html#GdkClipboard-struct) object to cut to | |
| default\_editable | default editability of the buffer | |
### gtk\_text\_buffer\_get\_selection\_bounds ()
```
gboolean
gtk_text_buffer_get_selection_bounds (*`[GtkTextBuffer](gtktextbuffer#GtkTextBuffer-struct) *buffer`*,
*`[GtkTextIter](gtktextiter#GtkTextIter-struct) *start`*,
*`[GtkTextIter](gtktextiter#GtkTextIter-struct) *end`*);
```
Returns `TRUE` if some text is selected; places the bounds of the selection in *`start`* and *`end`* (if the selection has length 0, then *`start`* and *`end`* are filled in with the same value). *`start`* and *`end`* will be in ascending order. If *`start`* and *`end`* are NULL, then they are not filled in, but the return value still indicates whether text is selected.
#### Parameters
| | | |
| --- | --- | --- |
| buffer | a [GtkTextBuffer](gtktextbuffer#GtkTextBuffer-struct) a [GtkTextBuffer](gtktextbuffer#GtkTextBuffer-struct) | |
| start | iterator to initialize with selection start. | [out] |
| end | iterator to initialize with selection end. | [out] |
#### Returns
whether the selection has nonzero length
### gtk\_text\_buffer\_get\_selection\_content ()
```
[GdkContentProvider](https://developer-old.gnome.org/gtk4/html/GdkContentProvider.html#GdkContentProvider-struct) *
gtk_text_buffer_get_selection_content (*`[GtkTextBuffer](gtktextbuffer#GtkTextBuffer-struct) *buffer`*);
```
Get a content provider for this buffer. It can be used to make the content of *`buffer`* available in a [GdkClipboard](https://developer-old.gnome.org/gtk4/html/gdk4-Clipboards.html#GdkClipboard-struct), see [`gdk_clipboard_set_content()`](https://developer-old.gnome.org/gtk4/html/gdk4-Clipboards.html#gdk-clipboard-set-content).
#### Parameters
| | | |
| --- | --- | --- |
| buffer | a [GtkTextBuffer](gtktextbuffer#GtkTextBuffer-struct) | |
#### Returns
a new [GdkContentProvider](https://developer-old.gnome.org/gtk4/html/GdkContentProvider.html#GdkContentProvider-struct).
[transfer full]
### gtk\_text\_buffer\_begin\_user\_action ()
```
void
gtk_text_buffer_begin_user_action (*`[GtkTextBuffer](gtktextbuffer#GtkTextBuffer-struct) *buffer`*);
```
Called to indicate that the buffer operations between here and a call to [`gtk_text_buffer_end_user_action()`](gtktextbuffer#gtk-text-buffer-end-user-action) are part of a single user-visible operation. The operations between [`gtk_text_buffer_begin_user_action()`](gtktextbuffer#gtk-text-buffer-begin-user-action) and [`gtk_text_buffer_end_user_action()`](gtktextbuffer#gtk-text-buffer-end-user-action) can then be grouped when creating an undo stack. [GtkTextBuffer](gtktextbuffer#GtkTextBuffer-struct) maintains a count of calls to [`gtk_text_buffer_begin_user_action()`](gtktextbuffer#gtk-text-buffer-begin-user-action) that have not been closed with a call to [`gtk_text_buffer_end_user_action()`](gtktextbuffer#gtk-text-buffer-end-user-action), and emits the “begin-user-action” and “end-user-action” signals only for the outermost pair of calls. This allows you to build user actions from other user actions.
The “interactive” buffer mutation functions, such as [`gtk_text_buffer_insert_interactive()`](gtktextbuffer#gtk-text-buffer-insert-interactive), automatically call begin/end user action around the buffer operations they perform, so there's no need to add extra calls if you user action consists solely of a single call to one of those functions.
#### Parameters
| | | |
| --- | --- | --- |
| buffer | a [GtkTextBuffer](gtktextbuffer#GtkTextBuffer-struct) | |
### gtk\_text\_buffer\_end\_user\_action ()
```
void
gtk_text_buffer_end_user_action (*`[GtkTextBuffer](gtktextbuffer#GtkTextBuffer-struct) *buffer`*);
```
Should be paired with a call to [`gtk_text_buffer_begin_user_action()`](gtktextbuffer#gtk-text-buffer-begin-user-action). See that function for a full explanation.
#### Parameters
| | | |
| --- | --- | --- |
| buffer | a [GtkTextBuffer](gtktextbuffer#GtkTextBuffer-struct) | |
### gtk\_text\_buffer\_add\_selection\_clipboard ()
```
void
gtk_text_buffer_add_selection_clipboard
(*`[GtkTextBuffer](gtktextbuffer#GtkTextBuffer-struct) *buffer`*,
*`[GdkClipboard](https://developer-old.gnome.org/gtk4/html/gdk4-Clipboards.html#GdkClipboard-struct) *clipboard`*);
```
Adds *`clipboard`* to the list of clipboards in which the selection contents of *`buffer`* are available. In most cases, *`clipboard`* will be the [GdkClipboard](https://developer-old.gnome.org/gtk4/html/gdk4-Clipboards.html#GdkClipboard-struct) returned by [`gtk_widget_get_primary_clipboard()`](gtkwidget#gtk-widget-get-primary-clipboard) for a view of *`buffer`* .
#### Parameters
| | | |
| --- | --- | --- |
| buffer | a [GtkTextBuffer](gtktextbuffer#GtkTextBuffer-struct) | |
| clipboard | a [GdkClipboard](https://developer-old.gnome.org/gtk4/html/gdk4-Clipboards.html#GdkClipboard-struct) | |
### gtk\_text\_buffer\_remove\_selection\_clipboard ()
```
void
gtk_text_buffer_remove_selection_clipboard
(*`[GtkTextBuffer](gtktextbuffer#GtkTextBuffer-struct) *buffer`*,
*`[GdkClipboard](https://developer-old.gnome.org/gtk4/html/gdk4-Clipboards.html#GdkClipboard-struct) *clipboard`*);
```
Removes a [GdkClipboard](https://developer-old.gnome.org/gtk4/html/gdk4-Clipboards.html#GdkClipboard-struct) added with [`gtk_text_buffer_add_selection_clipboard()`](gtktextbuffer#gtk-text-buffer-add-selection-clipboard).
#### Parameters
| | | |
| --- | --- | --- |
| buffer | a [GtkTextBuffer](gtktextbuffer#GtkTextBuffer-struct) | |
| clipboard | a [GdkClipboard](https://developer-old.gnome.org/gtk4/html/gdk4-Clipboards.html#GdkClipboard-struct) added to *`buffer`* by [`gtk_text_buffer_add_selection_clipboard()`](gtktextbuffer#gtk-text-buffer-add-selection-clipboard) | |
### gtk\_text\_buffer\_get\_can\_undo ()
```
gboolean
gtk_text_buffer_get_can_undo (*`[GtkTextBuffer](gtktextbuffer#GtkTextBuffer-struct) *buffer`*);
```
Gets whether there is an undoable action in the history.
#### Parameters
| | | |
| --- | --- | --- |
| buffer | a [GtkTextBuffer](gtktextbuffer#GtkTextBuffer-struct) | |
#### Returns
`TRUE` if there is an undoable action
### gtk\_text\_buffer\_get\_can\_redo ()
```
gboolean
gtk_text_buffer_get_can_redo (*`[GtkTextBuffer](gtktextbuffer#GtkTextBuffer-struct) *buffer`*);
```
Gets whether there is a redoable action in the history.
#### Parameters
| | | |
| --- | --- | --- |
| buffer | a [GtkTextBuffer](gtktextbuffer#GtkTextBuffer-struct) | |
#### Returns
`TRUE` if there is an redoable action
### gtk\_text\_buffer\_get\_enable\_undo ()
```
gboolean
gtk_text_buffer_get_enable_undo (*`[GtkTextBuffer](gtktextbuffer#GtkTextBuffer-struct) *buffer`*);
```
Gets whether the buffer is saving modifications to the buffer to allow for undo and redo actions.
See [`gtk_text_buffer_begin_irreversible_action()`](gtktextbuffer#gtk-text-buffer-begin-irreversible-action) and [`gtk_text_buffer_end_irreversible_action()`](gtktextbuffer#gtk-text-buffer-end-irreversible-action) to create changes to the buffer that cannot be undone.
#### Parameters
| | | |
| --- | --- | --- |
| buffer | a [GtkTextBuffer](gtktextbuffer#GtkTextBuffer-struct) | |
### gtk\_text\_buffer\_set\_enable\_undo ()
```
void
gtk_text_buffer_set_enable_undo (*`[GtkTextBuffer](gtktextbuffer#GtkTextBuffer-struct) *buffer`*,
*`gboolean enable_undo`*);
```
Sets whether or not to enable undoable actions in the text buffer. If enabled, the user will be able to undo the last number of actions up to [`gtk_text_buffer_get_max_undo_levels()`](gtktextbuffer#gtk-text-buffer-get-max-undo-levels).
See [`gtk_text_buffer_begin_irreversible_action()`](gtktextbuffer#gtk-text-buffer-begin-irreversible-action) and [`gtk_text_buffer_end_irreversible_action()`](gtktextbuffer#gtk-text-buffer-end-irreversible-action) to create changes to the buffer that cannot be undone.
#### Parameters
| | | |
| --- | --- | --- |
| buffer | a [GtkTextBuffer](gtktextbuffer#GtkTextBuffer-struct) | |
| enable\_undo | `TRUE` to enable undo | |
### gtk\_text\_buffer\_get\_max\_undo\_levels ()
```
guint
gtk_text_buffer_get_max_undo_levels (*`[GtkTextBuffer](gtktextbuffer#GtkTextBuffer-struct) *buffer`*);
```
Gets the maximum number of undo levels to perform. If 0, unlimited undo actions may be performed. Note that this may have a memory usage impact as it requires storing an additional copy of the inserted or removed text within the text buffer.
#### Parameters
| | | |
| --- | --- | --- |
| buffer | a [GtkTextBuffer](gtktextbuffer#GtkTextBuffer-struct) | |
### gtk\_text\_buffer\_set\_max\_undo\_levels ()
```
void
gtk_text_buffer_set_max_undo_levels (*`[GtkTextBuffer](gtktextbuffer#GtkTextBuffer-struct) *buffer`*,
*`guint max_undo_levels`*);
```
Sets the maximum number of undo levels to perform. If 0, unlimited undo actions may be performed. Note that this may have a memory usage impact as it requires storing an additional copy of the inserted or removed text within the text buffer.
#### Parameters
| | | |
| --- | --- | --- |
| buffer | a [GtkTextBuffer](gtktextbuffer#GtkTextBuffer-struct) | |
| max\_undo\_levels | the maximum number of undo actions to perform | |
### gtk\_text\_buffer\_undo ()
```
void
gtk_text_buffer_undo (*`[GtkTextBuffer](gtktextbuffer#GtkTextBuffer-struct) *buffer`*);
```
Undoes the last undoable action on the buffer, if there is one.
#### Parameters
| | | |
| --- | --- | --- |
| buffer | a [GtkTextBuffer](gtktextbuffer#GtkTextBuffer-struct) | |
### gtk\_text\_buffer\_redo ()
```
void
gtk_text_buffer_redo (*`[GtkTextBuffer](gtktextbuffer#GtkTextBuffer-struct) *buffer`*);
```
Redoes the next redoable action on the buffer, if there is one.
#### Parameters
| | | |
| --- | --- | --- |
| buffer | a [GtkTextBuffer](gtktextbuffer#GtkTextBuffer-struct) | |
### gtk\_text\_buffer\_begin\_irreversible\_action ()
```
void
gtk_text_buffer_begin_irreversible_action
(*`[GtkTextBuffer](gtktextbuffer#GtkTextBuffer-struct) *buffer`*);
```
Denotes the beginning of an action that may not be undone. This will cause any previous operations in the undo/redo queue to be cleared.
This should be paired with a call to [`gtk_text_buffer_end_irreversible_action()`](gtktextbuffer#gtk-text-buffer-end-irreversible-action) after the irreversible action has completed.
You may nest calls to [`gtk_text_buffer_begin_irreversible_action()`](gtktextbuffer#gtk-text-buffer-begin-irreversible-action) and [`gtk_text_buffer_end_irreversible_action()`](gtktextbuffer#gtk-text-buffer-end-irreversible-action) pairs.
#### Parameters
| | | |
| --- | --- | --- |
| buffer | a [GtkTextBuffer](gtktextbuffer#GtkTextBuffer-struct) | |
### gtk\_text\_buffer\_end\_irreversible\_action ()
```
void
gtk_text_buffer_end_irreversible_action
(*`[GtkTextBuffer](gtktextbuffer#GtkTextBuffer-struct) *buffer`*);
```
Denotes the end of an action that may not be undone. This will cause any previous operations in the undo/redo queue to be cleared.
This should be called after completing modifications to the text buffer after [`gtk_text_buffer_begin_irreversible_action()`](gtktextbuffer#gtk-text-buffer-begin-irreversible-action) was called.
You may nest calls to [`gtk_text_buffer_begin_irreversible_action()`](gtktextbuffer#gtk-text-buffer-begin-irreversible-action) and [`gtk_text_buffer_end_irreversible_action()`](gtktextbuffer#gtk-text-buffer-end-irreversible-action) pairs.
#### Parameters
| | | |
| --- | --- | --- |
| buffer | a [GtkTextBuffer](gtktextbuffer#GtkTextBuffer-struct) | |
Types and Values
----------------
### GtkTextBuffer
```
typedef struct _GtkTextBuffer GtkTextBuffer;
```
### struct GtkTextBufferClass
```
struct GtkTextBufferClass {
GObjectClass parent_class;
void (* insert_text) (GtkTextBuffer *buffer,
GtkTextIter *pos,
const char *new_text,
int new_text_length);
void (* insert_paintable) (GtkTextBuffer *buffer,
GtkTextIter *iter,
GdkPaintable *paintable);
void (* insert_child_anchor) (GtkTextBuffer *buffer,
GtkTextIter *iter,
GtkTextChildAnchor *anchor);
void (* delete_range) (GtkTextBuffer *buffer,
GtkTextIter *start,
GtkTextIter *end);
void (* changed) (GtkTextBuffer *buffer);
void (* modified_changed) (GtkTextBuffer *buffer);
void (* mark_set) (GtkTextBuffer *buffer,
const GtkTextIter *location,
GtkTextMark *mark);
void (* mark_deleted) (GtkTextBuffer *buffer,
GtkTextMark *mark);
void (* apply_tag) (GtkTextBuffer *buffer,
GtkTextTag *tag,
const GtkTextIter *start,
const GtkTextIter *end);
void (* remove_tag) (GtkTextBuffer *buffer,
GtkTextTag *tag,
const GtkTextIter *start,
const GtkTextIter *end);
void (* begin_user_action) (GtkTextBuffer *buffer);
void (* end_user_action) (GtkTextBuffer *buffer);
void (* paste_done) (GtkTextBuffer *buffer,
GdkClipboard *clipboard);
void (* undo) (GtkTextBuffer *buffer);
void (* redo) (GtkTextBuffer *buffer);
};
```
The class structure for [GtkTextBuffer](gtktextbuffer#GtkTextBuffer-struct).
#### Members
| | | |
| --- | --- | --- |
| *`insert_text`* () | The class handler for the [“insert-text”](gtktextbuffer#GtkTextBuffer-insert-text) signal. | |
| *`insert_paintable`* () | The class handler for the [“insert-paintable”](gtktextbuffer#GtkTextBuffer-insert-paintable) signal. | |
| *`insert_child_anchor`* () | The class handler for the [“insert-child-anchor”](gtktextbuffer#GtkTextBuffer-insert-child-anchor) signal. | |
| *`delete_range`* () | The class handler for the [“delete-range”](gtktextbuffer#GtkTextBuffer-delete-range) signal. | |
| *`changed`* () | The class handler for the [“changed”](gtktextbuffer#GtkTextBuffer-changed) signal. | |
| *`modified_changed`* () | The class handler for the [“modified-changed”](gtktextbuffer#GtkTextBuffer-modified-changed) signal. | |
| *`mark_set`* () | The class handler for the [“mark-set”](gtktextbuffer#GtkTextBuffer-mark-set) signal. | |
| *`mark_deleted`* () | The class handler for the [“mark-deleted”](gtktextbuffer#GtkTextBuffer-mark-deleted) signal. | |
| *`apply_tag`* () | The class handler for the [“apply-tag”](gtktextbuffer#GtkTextBuffer-apply-tag) signal. | |
| *`remove_tag`* () | The class handler for the [“remove-tag”](gtktextbuffer#GtkTextBuffer-remove-tag) signal. | |
| *`begin_user_action`* () | The class handler for the [“begin-user-action”](gtktextbuffer#GtkTextBuffer-begin-user-action) signal. | |
| *`end_user_action`* () | The class handler for the [“end-user-action”](gtktextbuffer#GtkTextBuffer-end-user-action) signal. | |
| *`paste_done`* () | The class handler for the [“paste-done”](gtktextbuffer#GtkTextBuffer-paste-done) signal. | |
| *`undo`* () | The class handler for the [“undo”](gtktextbuffer#GtkTextBuffer-undo) signal | |
| *`redo`* () | The class handler for the [“redo”](gtktextbuffer#GtkTextBuffer-redo) signal | |
Property Details
----------------
### The `“can-redo”` property
```
“can-redo” gboolean
```
The [“can-redo”](gtktextbuffer#GtkTextBuffer--can-redo) property denotes that the buffer can reapply the last undone action.
Owner: GtkTextBuffer
Flags: Read
Default value: FALSE
### The `“can-undo”` property
```
“can-undo” gboolean
```
The [“can-undo”](gtktextbuffer#GtkTextBuffer--can-undo) property denotes that the buffer can undo the last applied action.
Owner: GtkTextBuffer
Flags: Read
Default value: FALSE
### The `“cursor-position”` property
```
“cursor-position” int
```
The position of the insert mark (as offset from the beginning of the buffer). It is useful for getting notified when the cursor moves.
Owner: GtkTextBuffer
Flags: Read
Allowed values: >= 0
Default value: 0
### The `“enable-undo”` property
```
“enable-undo” gboolean
```
The [“enable-undo”](gtktextbuffer#GtkTextBuffer--enable-undo) property denotes if support for undoing and redoing changes to the buffer is allowed.
Owner: GtkTextBuffer
Flags: Read / Write
Default value: TRUE
### The `“has-selection”` property
```
“has-selection” gboolean
```
Whether the buffer has some text currently selected.
Owner: GtkTextBuffer
Flags: Read
Default value: FALSE
### The `“tag-table”` property
```
“tag-table” [GtkTextTagTable](gtktexttagtable#GtkTextTagTable-struct) *
```
Text Tag Table.
Owner: GtkTextBuffer
Flags: Read / Write / Construct Only
### The `“text”` property
```
“text” char *
```
The text content of the buffer. Without child widgets and images, see [`gtk_text_buffer_get_text()`](gtktextbuffer#gtk-text-buffer-get-text) for more information.
Owner: GtkTextBuffer
Flags: Read / Write
Default value: ""
Signal Details
--------------
### The `“apply-tag”` signal
```
void
user_function ([GtkTextBuffer](gtktextbuffer#GtkTextBuffer-struct) *textbuffer,
[GtkTextTag](gtktexttag#GtkTextTag-struct) *tag,
[GtkTextIter](gtktextiter#GtkTextIter-struct) *start,
[GtkTextIter](gtktextiter#GtkTextIter-struct) *end,
gpointer user_data)
```
The [“apply-tag”](gtktextbuffer#GtkTextBuffer-apply-tag) signal is emitted to apply a tag to a range of text in a [GtkTextBuffer](gtktextbuffer#GtkTextBuffer-struct). Applying actually occurs in the default handler.
Note that if your handler runs before the default handler it must not invalidate the *`start`* and *`end`* iters (or has to revalidate them).
See also: [`gtk_text_buffer_apply_tag()`](gtktextbuffer#gtk-text-buffer-apply-tag), [`gtk_text_buffer_insert_with_tags()`](gtktextbuffer#gtk-text-buffer-insert-with-tags), [`gtk_text_buffer_insert_range()`](gtktextbuffer#gtk-text-buffer-insert-range).
#### Parameters
| | | |
| --- | --- | --- |
| textbuffer | the object which received the signal | |
| tag | the applied tag | |
| start | the start of the range the tag is applied to | |
| end | the end of the range the tag is applied to | |
| user\_data | user data set when the signal handler was connected. | |
Flags: Run Last
### The `“begin-user-action”` signal
```
void
user_function ([GtkTextBuffer](gtktextbuffer#GtkTextBuffer-struct) *textbuffer,
gpointer user_data)
```
The [“begin-user-action”](gtktextbuffer#GtkTextBuffer-begin-user-action) signal is emitted at the beginning of a single user-visible operation on a [GtkTextBuffer](gtktextbuffer#GtkTextBuffer-struct).
See also: [`gtk_text_buffer_begin_user_action()`](gtktextbuffer#gtk-text-buffer-begin-user-action), [`gtk_text_buffer_insert_interactive()`](gtktextbuffer#gtk-text-buffer-insert-interactive), [`gtk_text_buffer_insert_range_interactive()`](gtktextbuffer#gtk-text-buffer-insert-range-interactive), [`gtk_text_buffer_delete_interactive()`](gtktextbuffer#gtk-text-buffer-delete-interactive), [`gtk_text_buffer_backspace()`](gtktextbuffer#gtk-text-buffer-backspace), [`gtk_text_buffer_delete_selection()`](gtktextbuffer#gtk-text-buffer-delete-selection).
#### Parameters
| | | |
| --- | --- | --- |
| textbuffer | the object which received the signal | |
| user\_data | user data set when the signal handler was connected. | |
Flags: Run Last
### The `“changed”` signal
```
void
user_function ([GtkTextBuffer](gtktextbuffer#GtkTextBuffer-struct) *textbuffer,
gpointer user_data)
```
The [“changed”](gtktextbuffer#GtkTextBuffer-changed) signal is emitted when the content of a [GtkTextBuffer](gtktextbuffer#GtkTextBuffer-struct) has changed.
#### Parameters
| | | |
| --- | --- | --- |
| textbuffer | the object which received the signal | |
| user\_data | user data set when the signal handler was connected. | |
Flags: Run Last
### The `“delete-range”` signal
```
void
user_function ([GtkTextBuffer](gtktextbuffer#GtkTextBuffer-struct) *textbuffer,
[GtkTextIter](gtktextiter#GtkTextIter-struct) *start,
[GtkTextIter](gtktextiter#GtkTextIter-struct) *end,
gpointer user_data)
```
The [“delete-range”](gtktextbuffer#GtkTextBuffer-delete-range) signal is emitted to delete a range from a [GtkTextBuffer](gtktextbuffer#GtkTextBuffer-struct).
Note that if your handler runs before the default handler it must not invalidate the *`start`* and *`end`* iters (or has to revalidate them). The default signal handler revalidates the *`start`* and *`end`* iters to both point to the location where text was deleted. Handlers which run after the default handler (see `g_signal_connect_after()`) do not have access to the deleted text.
See also: [`gtk_text_buffer_delete()`](gtktextbuffer#gtk-text-buffer-delete).
#### Parameters
| | | |
| --- | --- | --- |
| textbuffer | the object which received the signal | |
| start | the start of the range to be deleted | |
| end | the end of the range to be deleted | |
| user\_data | user data set when the signal handler was connected. | |
Flags: Run Last
### The `“end-user-action”` signal
```
void
user_function ([GtkTextBuffer](gtktextbuffer#GtkTextBuffer-struct) *textbuffer,
gpointer user_data)
```
The [“end-user-action”](gtktextbuffer#GtkTextBuffer-end-user-action) signal is emitted at the end of a single user-visible operation on the [GtkTextBuffer](gtktextbuffer#GtkTextBuffer-struct).
See also: [`gtk_text_buffer_end_user_action()`](gtktextbuffer#gtk-text-buffer-end-user-action), [`gtk_text_buffer_insert_interactive()`](gtktextbuffer#gtk-text-buffer-insert-interactive), [`gtk_text_buffer_insert_range_interactive()`](gtktextbuffer#gtk-text-buffer-insert-range-interactive), [`gtk_text_buffer_delete_interactive()`](gtktextbuffer#gtk-text-buffer-delete-interactive), [`gtk_text_buffer_backspace()`](gtktextbuffer#gtk-text-buffer-backspace), [`gtk_text_buffer_delete_selection()`](gtktextbuffer#gtk-text-buffer-delete-selection), [`gtk_text_buffer_backspace()`](gtktextbuffer#gtk-text-buffer-backspace).
#### Parameters
| | | |
| --- | --- | --- |
| textbuffer | the object which received the signal | |
| user\_data | user data set when the signal handler was connected. | |
Flags: Run Last
### The `“insert-child-anchor”` signal
```
void
user_function ([GtkTextBuffer](gtktextbuffer#GtkTextBuffer-struct) *textbuffer,
[GtkTextIter](gtktextiter#GtkTextIter-struct) *location,
[GtkTextChildAnchor](gtktextview#GtkTextChildAnchor-struct) *anchor,
gpointer user_data)
```
The [“insert-child-anchor”](gtktextbuffer#GtkTextBuffer-insert-child-anchor) signal is emitted to insert a [GtkTextChildAnchor](gtktextview#GtkTextChildAnchor-struct) in a [GtkTextBuffer](gtktextbuffer#GtkTextBuffer-struct). Insertion actually occurs in the default handler.
Note that if your handler runs before the default handler it must not invalidate the *`location`* iter (or has to revalidate it). The default signal handler revalidates it to be placed after the inserted *`anchor`* .
See also: [`gtk_text_buffer_insert_child_anchor()`](gtktextbuffer#gtk-text-buffer-insert-child-anchor).
#### Parameters
| | | |
| --- | --- | --- |
| textbuffer | the object which received the signal | |
| location | position to insert *`anchor`* in *`textbuffer`* | |
| anchor | the [GtkTextChildAnchor](gtktextview#GtkTextChildAnchor-struct) to be inserted | |
| user\_data | user data set when the signal handler was connected. | |
Flags: Run Last
### The `“insert-paintable”` signal
```
void
user_function ([GtkTextBuffer](gtktextbuffer#GtkTextBuffer-struct) *textbuffer,
[GtkTextIter](gtktextiter#GtkTextIter-struct) *location,
[GdkPaintable](https://developer-old.gnome.org/gtk4/html/GdkPaintable.html#GdkPaintable-struct) *paintable,
gpointer user_data)
```
The [“insert-paintable”](gtktextbuffer#GtkTextBuffer-insert-paintable) signal is emitted to insert a [GdkPaintable](https://developer-old.gnome.org/gtk4/html/GdkPaintable.html#GdkPaintable-struct) in a [GtkTextBuffer](gtktextbuffer#GtkTextBuffer-struct). Insertion actually occurs in the default handler.
Note that if your handler runs before the default handler it must not invalidate the *`location`* iter (or has to revalidate it). The default signal handler revalidates it to be placed after the inserted *`paintable`* .
See also: [`gtk_text_buffer_insert_paintable()`](gtktextbuffer#gtk-text-buffer-insert-paintable).
#### Parameters
| | | |
| --- | --- | --- |
| textbuffer | the object which received the signal | |
| location | position to insert *`paintable`* in *`textbuffer`* | |
| paintable | the [GdkPaintable](https://developer-old.gnome.org/gtk4/html/GdkPaintable.html#GdkPaintable-struct) to be inserted | |
| user\_data | user data set when the signal handler was connected. | |
Flags: Run Last
### The `“insert-text”` signal
```
void
user_function ([GtkTextBuffer](gtktextbuffer#GtkTextBuffer-struct) *textbuffer,
[GtkTextIter](gtktextiter#GtkTextIter-struct) *location,
char *text,
int len,
gpointer user_data)
```
The ::insert-text signal is emitted to insert text in a [GtkTextBuffer](gtktextbuffer#GtkTextBuffer-struct). Insertion actually occurs in the default handler.
Note that if your handler runs before the default handler it must not invalidate the *`location`* iter (or has to revalidate it). The default signal handler revalidates it to point to the end of the inserted text.
See also: [`gtk_text_buffer_insert()`](gtktextbuffer#gtk-text-buffer-insert), [`gtk_text_buffer_insert_range()`](gtktextbuffer#gtk-text-buffer-insert-range).
#### Parameters
| | | |
| --- | --- | --- |
| textbuffer | the object which received the signal | |
| location | position to insert *`text`* in *`textbuffer`* | |
| text | the UTF-8 text to be inserted | |
| len | length of the inserted text in bytes | |
| user\_data | user data set when the signal handler was connected. | |
Flags: Run Last
### The `“mark-deleted”` signal
```
void
user_function ([GtkTextBuffer](gtktextbuffer#GtkTextBuffer-struct) *textbuffer,
[GtkTextMark](gtktextmark#GtkTextMark-struct) *mark,
gpointer user_data)
```
The [“mark-deleted”](gtktextbuffer#GtkTextBuffer-mark-deleted) signal is emitted as notification after a [GtkTextMark](gtktextmark#GtkTextMark-struct) is deleted.
See also: [`gtk_text_buffer_delete_mark()`](gtktextbuffer#gtk-text-buffer-delete-mark).
#### Parameters
| | | |
| --- | --- | --- |
| textbuffer | the object which received the signal | |
| mark | The mark that was deleted | |
| user\_data | user data set when the signal handler was connected. | |
Flags: Run Last
### The `“mark-set”` signal
```
void
user_function ([GtkTextBuffer](gtktextbuffer#GtkTextBuffer-struct) *textbuffer,
[GtkTextIter](gtktextiter#GtkTextIter-struct) *location,
[GtkTextMark](gtktextmark#GtkTextMark-struct) *mark,
gpointer user_data)
```
The [“mark-set”](gtktextbuffer#GtkTextBuffer-mark-set) signal is emitted as notification after a [GtkTextMark](gtktextmark#GtkTextMark-struct) is set.
See also: [`gtk_text_buffer_create_mark()`](gtktextbuffer#gtk-text-buffer-create-mark), [`gtk_text_buffer_move_mark()`](gtktextbuffer#gtk-text-buffer-move-mark).
#### Parameters
| | | |
| --- | --- | --- |
| textbuffer | the object which received the signal | |
| location | The location of *`mark`* in *`textbuffer`* | |
| mark | The mark that is set | |
| user\_data | user data set when the signal handler was connected. | |
Flags: Run Last
### The `“modified-changed”` signal
```
void
user_function ([GtkTextBuffer](gtktextbuffer#GtkTextBuffer-struct) *textbuffer,
gpointer user_data)
```
The [“modified-changed”](gtktextbuffer#GtkTextBuffer-modified-changed) signal is emitted when the modified bit of a [GtkTextBuffer](gtktextbuffer#GtkTextBuffer-struct) flips.
See also: [`gtk_text_buffer_set_modified()`](gtktextbuffer#gtk-text-buffer-set-modified).
#### Parameters
| | | |
| --- | --- | --- |
| textbuffer | the object which received the signal | |
| user\_data | user data set when the signal handler was connected. | |
Flags: Run Last
### The `“paste-done”` signal
```
void
user_function ([GtkTextBuffer](gtktextbuffer#GtkTextBuffer-struct) *textbuffer,
[GdkClipboard](https://developer-old.gnome.org/gtk4/html/gdk4-Clipboards.html#GdkClipboard-struct) *clipboard,
gpointer user_data)
```
The paste-done signal is emitted after paste operation has been completed. This is useful to properly scroll the view to the end of the pasted text. See [`gtk_text_buffer_paste_clipboard()`](gtktextbuffer#gtk-text-buffer-paste-clipboard) for more details.
#### Parameters
| | | |
| --- | --- | --- |
| textbuffer | the object which received the signal | |
| clipboard | the [GdkClipboard](https://developer-old.gnome.org/gtk4/html/gdk4-Clipboards.html#GdkClipboard-struct) pasted from | |
| user\_data | user data set when the signal handler was connected. | |
Flags: Run Last
### The `“redo”` signal
```
void
user_function ([GtkTextBuffer](gtktextbuffer#GtkTextBuffer-struct) *buffer,
gpointer user_data)
```
The "redo" signal is emitted when a request has been made to redo the previously undone operation.
#### Parameters
| | | |
| --- | --- | --- |
| buffer | a [GtkTextBuffer](gtktextbuffer#GtkTextBuffer-struct) | |
| user\_data | user data set when the signal handler was connected. | |
Flags: Run Last
### The `“remove-tag”` signal
```
void
user_function ([GtkTextBuffer](gtktextbuffer#GtkTextBuffer-struct) *textbuffer,
[GtkTextTag](gtktexttag#GtkTextTag-struct) *tag,
[GtkTextIter](gtktextiter#GtkTextIter-struct) *start,
[GtkTextIter](gtktextiter#GtkTextIter-struct) *end,
gpointer user_data)
```
The [“remove-tag”](gtktextbuffer#GtkTextBuffer-remove-tag) signal is emitted to remove all occurrences of *`tag`* from a range of text in a [GtkTextBuffer](gtktextbuffer#GtkTextBuffer-struct). Removal actually occurs in the default handler.
Note that if your handler runs before the default handler it must not invalidate the *`start`* and *`end`* iters (or has to revalidate them).
See also: [`gtk_text_buffer_remove_tag()`](gtktextbuffer#gtk-text-buffer-remove-tag).
#### Parameters
| | | |
| --- | --- | --- |
| textbuffer | the object which received the signal | |
| tag | the tag to be removed | |
| start | the start of the range the tag is removed from | |
| end | the end of the range the tag is removed from | |
| user\_data | user data set when the signal handler was connected. | |
Flags: Run Last
### The `“undo”` signal
```
void
user_function ([GtkTextBuffer](gtktextbuffer#GtkTextBuffer-struct) *buffer,
gpointer user_data)
```
The "undo" signal is emitted when a request has been made to undo the previous operation or set of operations that have been grouped together.
#### Parameters
| | | |
| --- | --- | --- |
| buffer | a [GtkTextBuffer](gtktextbuffer#GtkTextBuffer-struct) | |
| user\_data | user data set when the signal handler was connected. | |
Flags: Run Last
See Also
--------
[GtkTextView](gtktextview#GtkTextView-struct), [GtkTextIter](gtktextiter#GtkTextIter-struct), [GtkTextMark](gtktextmark#GtkTextMark-struct)
| programming_docs |
gtk Object Hierarchy Object Hierarchy
================
```
GObject
├── GInitiallyUnowned
│ ├── [GtkWidget](gtkwidget#GtkWidget-struct)
│ │ ├── [GtkWindow](gtkwindow#GtkWindow-struct)
│ │ │ ├── [GtkAboutDialog](gtkaboutdialog#GtkAboutDialog-struct)
│ │ │ ├── [GtkDialog](gtkdialog#GtkDialog-struct)
│ │ │ │ ├── [GtkAppChooserDialog](gtkappchooserdialog#GtkAppChooserDialog-struct)
│ │ │ │ ├── [GtkColorChooserDialog](gtkcolorchooserdialog#GtkColorChooserDialog-struct)
│ │ │ │ ├── [GtkFileChooserDialog](gtkfilechooserdialog#GtkFileChooserDialog-struct)
│ │ │ │ ├── [GtkFontChooserDialog](gtkfontchooserdialog#GtkFontChooserDialog-struct)
│ │ │ │ ├── [GtkMessageDialog](gtkmessagedialog#GtkMessageDialog-struct)
│ │ │ │ ├── [GtkPageSetupUnixDialog](gtkpagesetupunixdialog#GtkPageSetupUnixDialog-struct)
│ │ │ │ ╰── [GtkPrintUnixDialog](gtkprintunixdialog#GtkPrintUnixDialog-struct)
│ │ │ ├── [GtkApplicationWindow](gtkapplicationwindow#GtkApplicationWindow-struct)
│ │ │ ├── [GtkAssistant](gtkassistant#GtkAssistant-struct)
│ │ │ ╰── [GtkShortcutsWindow](gtkshortcutswindow#GtkShortcutsWindow-struct)
│ │ ├── [GtkActionBar](gtkactionbar#GtkActionBar-struct)
│ │ ├── [GtkAppChooserButton](gtkappchooserbutton#GtkAppChooserButton-struct)
│ │ ├── [GtkAppChooserWidget](gtkappchooserwidget#GtkAppChooserWidget-struct)
│ │ ├── [GtkAspectFrame](gtkaspectframe#GtkAspectFrame-struct)
│ │ ├── [GtkBox](gtkbox#GtkBox-struct)
│ │ │ ├── [GtkShortcutsSection](gtkshortcutssection#GtkShortcutsSection-struct)
│ │ │ ╰── [GtkShortcutsGroup](gtkshortcutsgroup#GtkShortcutsGroup-struct)
│ │ ├── [GtkButton](gtkbutton#GtkButton-struct)
│ │ │ ├── [GtkLinkButton](gtklinkbutton#GtkLinkButton-struct)
│ │ │ ├── [GtkLockButton](gtklockbutton#GtkLockButton-struct)
│ │ │ ╰── [GtkToggleButton](gtktogglebutton#GtkToggleButton-struct)
│ │ ├── [GtkCalendar](gtkcalendar#GtkCalendar-struct)
│ │ ├── [GtkCellView](gtkcellview#GtkCellView-struct)
│ │ ├── [GtkCenterBox](https://developer-old.gnome.org/usr/share/gtk-doc/html/gtk4/gtk4-GtkCenterBox.html#GtkCenterBox)
│ │ ├── [GtkCheckButton](gtkcheckbutton#GtkCheckButton-struct)
│ │ ├── [GtkColorButton](gtkcolorbutton#GtkColorButton-struct)
│ │ ├── [GtkColorChooserWidget](gtkcolorchooserwidget#GtkColorChooserWidget-struct)
│ │ ├── [GtkColumnView](gtkcolumnview#GtkColumnView-struct)
│ │ ├── [GtkComboBox](gtkcombobox#GtkComboBox-struct)
│ │ │ ╰── [GtkComboBoxText](gtkcomboboxtext#GtkComboBoxText-struct)
│ │ ├── [GtkDragIcon](gtkdragicon#GtkDragIcon-struct)
│ │ ├── [GtkDrawingArea](gtkdrawingarea#GtkDrawingArea-struct)
│ │ ├── [GtkDropDown](gtkdropdown#GtkDropDown-struct)
│ │ ├── [GtkEditableLabel](gtkeditablelabel#GtkEditableLabel-struct)
│ │ ├── [GtkPopover](gtkpopover#GtkPopover-struct)
│ │ │ ├── [GtkEmojiChooser](gtkemojichooser#GtkEmojiChooser-struct)
│ │ │ ╰── [GtkPopoverMenu](gtkpopovermenu#GtkPopoverMenu-struct)
│ │ ├── [GtkEntry](gtkentry#GtkEntry-struct)
│ │ ├── [GtkExpander](gtkexpander#GtkExpander-struct)
│ │ ├── [GtkFileChooserWidget](gtkfilechooserwidget#GtkFileChooserWidget-struct)
│ │ ├── [GtkFixed](gtkfixed#GtkFixed-struct)
│ │ ├── [GtkFlowBox](gtkflowbox#GtkFlowBox-struct)
│ │ ├── [GtkFlowBoxChild](gtkflowbox#GtkFlowBoxChild-struct)
│ │ ├── [GtkFontButton](gtkfontbutton#GtkFontButton-struct)
│ │ ├── [GtkFontChooserWidget](gtkfontchooserwidget#GtkFontChooserWidget-struct)
│ │ ├── [GtkFrame](gtkframe#GtkFrame-struct)
│ │ ├── [GtkGLArea](gtkglarea#GtkGLArea-struct)
│ │ ├── [GtkGrid](gtkgrid#GtkGrid-struct)
│ │ ├── GtkListBase
│ │ │ ├── [GtkGridView](gtkgridview#GtkGridView-struct)
│ │ │ ╰── [GtkListView](gtklistview#GtkListView-struct)
│ │ ├── [GtkHeaderBar](gtkheaderbar#GtkHeaderBar-struct)
│ │ ├── [GtkIconView](gtkiconview#GtkIconView-struct)
│ │ ├── [GtkImage](gtkimage#GtkImage-struct)
│ │ ├── [GtkInfoBar](gtkinfobar#GtkInfoBar-struct)
│ │ ├── [GtkLabel](gtklabel#GtkLabel-struct)
│ │ ├── [GtkListBox](gtklistbox#GtkListBox-struct)
│ │ ├── [GtkListBoxRow](gtklistbox#GtkListBoxRow-struct)
│ │ ├── [GtkMediaControls](gtkmediacontrols#GtkMediaControls-struct)
│ │ ├── [GtkMenuButton](gtkmenubutton#GtkMenuButton-struct)
│ │ ├── [GtkNotebook](gtknotebook#GtkNotebook-struct)
│ │ ├── [GtkOverlay](gtkoverlay#GtkOverlay-struct)
│ │ ├── [GtkPaned](gtkpaned#GtkPaned-struct)
│ │ ├── [GtkPasswordEntry](gtkpasswordentry#GtkPasswordEntry-struct)
│ │ ├── [GtkPicture](gtkpicture#GtkPicture-struct)
│ │ ├── [GtkPopoverMenuBar](gtkpopovermenubar#GtkPopoverMenuBar-struct)
│ │ ├── [GtkProgressBar](gtkprogressbar#GtkProgressBar-struct)
│ │ ├── [GtkRange](gtkrange#GtkRange-struct)
│ │ │ ╰── [GtkScale](gtkscale#GtkScale-struct)
│ │ ├── [GtkRevealer](gtkrevealer#GtkRevealer-struct)
│ │ ├── [GtkScaleButton](gtkscalebutton#GtkScaleButton-struct)
│ │ │ ╰── [GtkVolumeButton](gtkvolumebutton#GtkVolumeButton-struct)
│ │ ├── [GtkScrollbar](gtkscrollbar#GtkScrollbar-struct)
│ │ ├── [GtkScrolledWindow](gtkscrolledwindow#GtkScrolledWindow-struct)
│ │ ├── [GtkSearchBar](gtksearchbar#GtkSearchBar-struct)
│ │ ├── [GtkSearchEntry](gtksearchentry#GtkSearchEntry-struct)
│ │ ├── [GtkSeparator](gtkseparator#GtkSeparator-struct)
│ │ ├── [GtkShortcutLabel](gtkshortcutlabel#GtkShortcutLabel-struct)
│ │ ├── [GtkShortcutsShortcut](gtkshortcutsshortcut#GtkShortcutsShortcut-struct)
│ │ ├── [GtkSpinButton](gtkspinbutton#GtkSpinButton-struct)
│ │ ├── [GtkSpinner](gtkspinner#GtkSpinner-struct)
│ │ ├── [GtkStack](gtkstack#GtkStack-struct)
│ │ ├── [GtkStackSidebar](gtkstacksidebar#GtkStackSidebar-struct)
│ │ ├── [GtkStackSwitcher](gtkstackswitcher#GtkStackSwitcher-struct)
│ │ ├── [GtkStatusbar](gtkstatusbar#GtkStatusbar-struct)
│ │ ├── [GtkSwitch](gtkswitch#GtkSwitch-struct)
│ │ ├── [GtkLevelBar](gtklevelbar#GtkLevelBar-struct)
│ │ ├── [GtkText](gtktext#GtkText-struct)
│ │ ├── [GtkTextView](gtktextview#GtkTextView-struct)
│ │ ├── [GtkTreeExpander](gtktreeexpander#GtkTreeExpander-struct)
│ │ ├── [GtkTreeView](gtktreeview#GtkTreeView-struct)
│ │ ├── [GtkVideo](gtkvideo#GtkVideo-struct)
│ │ ├── [GtkViewport](gtkviewport#GtkViewport-struct)
│ │ ├── [GtkWindowControls](gtkwindowcontrols#GtkWindowControls-struct)
│ │ ╰── [GtkWindowHandle](gtkwindowhandle#GtkWindowHandle-struct)
│ ├── [GtkAdjustment](gtkadjustment#GtkAdjustment-struct)
│ ├── [GtkCellArea](gtkcellarea#GtkCellArea-struct)
│ │ ╰── [GtkCellAreaBox](gtkcellareabox#GtkCellAreaBox-struct)
│ ├── [GtkCellRenderer](gtkcellrenderer#GtkCellRenderer-struct)
│ │ ├── [GtkCellRendererText](gtkcellrenderertext#GtkCellRendererText-struct)
│ │ │ ├── [GtkCellRendererAccel](gtkcellrendereraccel#GtkCellRendererAccel-struct)
│ │ │ ├── [GtkCellRendererCombo](gtkcellrenderercombo#GtkCellRendererCombo-struct)
│ │ │ ╰── [GtkCellRendererSpin](gtkcellrendererspin#GtkCellRendererSpin-struct)
│ │ ├── [GtkCellRendererPixbuf](gtkcellrendererpixbuf#GtkCellRendererPixbuf-struct)
│ │ ├── [GtkCellRendererProgress](gtkcellrendererprogress#GtkCellRendererProgress-struct)
│ │ ├── [GtkCellRendererSpinner](gtkcellrendererspinner#GtkCellRendererSpinner-struct)
│ │ ╰── [GtkCellRendererToggle](gtkcellrenderertoggle#GtkCellRendererToggle-struct)
│ ╰── [GtkTreeViewColumn](gtktreeviewcolumn#GtkTreeViewColumn-struct)
├── [GtkFilter](gtkfilter#GtkFilter-struct)
│ ├── [GtkMultiFilter](gtkmultifilter#GtkMultiFilter-struct)
│ │ ├── [GtkAnyFilter](gtkmultifilter#GtkAnyFilter-struct)
│ │ ╰── [GtkEveryFilter](gtkmultifilter#GtkEveryFilter-struct)
│ ├── [GtkBoolFilter](https://developer-old.gnome.org/usr/share/gtk-doc/html/gtk4/gtk4-GtkBoolFilter.html#GtkBoolFilter)
│ ├── [GtkCustomFilter](gtkcustomfilter#GtkCustomFilter-struct)
│ ├── [GtkFileFilter](gtkfilefilter#GtkFileFilter-struct)
│ ╰── [GtkStringFilter](gtkstringfilter#GtkStringFilter-struct)
├── GApplication
│ ╰── [GtkApplication](gtkapplication#GtkApplication-struct)
├── [GtkAssistantPage](gtkassistant#GtkAssistantPage-struct)
├── [GtkATContext](gtkatcontext#GtkATContext-struct)
├── [GtkLayoutManager](gtklayoutmanager#GtkLayoutManager-struct)
│ ├── [GtkBinLayout](gtkbinlayout#GtkBinLayout-struct)
│ ├── [GtkBoxLayout](gtkboxlayout#GtkBoxLayout-struct)
│ ├── [GtkCenterLayout](gtkcenterlayout#GtkCenterLayout-struct)
│ ├── [GtkConstraintLayout](gtkconstraintlayout#GtkConstraintLayout-struct)
│ ├── [GtkCustomLayout](https://developer-old.gnome.org/usr/share/gtk-doc/html/gtk4/gtk4-GtkCustomLayout.html#GtkCustomLayout)
│ ├── [GtkFixedLayout](gtkfixedlayout#GtkFixedLayout-struct)
│ ├── [GtkGridLayout](gtkgridlayout#GtkGridLayout-struct)
│ ╰── [GtkOverlayLayout](gtkoverlaylayout#GtkOverlayLayout-struct)
├── [GtkBookmarkList](gtkbookmarklist#GtkBookmarkList-struct)
├── [GtkBuilderCScope](gtkbuilderscope#GtkBuilderCScope-struct)
├── [GtkBuilder](gtkbuilder#GtkBuilder-struct)
├── [GtkListItemFactory](gtklistitemfactory#GtkListItemFactory-struct)
│ ├── [GtkBuilderListItemFactory](gtkbuilderlistitemfactory#GtkBuilderListItemFactory-struct)
│ ╰── [GtkSignalListItemFactory](gtksignallistitemfactory#GtkSignalListItemFactory-struct)
├── [GtkCellAreaContext](gtkcellareacontext#GtkCellAreaContext-struct)
├── [GtkColumnViewColumn](gtkcolumnviewcolumn#GtkColumnViewColumn-struct)
├── [GtkConstraint](gtkconstraint#GtkConstraint-struct)
├── [GtkConstraintGuide](gtkconstraintguide#GtkConstraintGuide-struct)
├── [GtkCssProvider](gtkcssprovider#GtkCssProvider-struct)
├── [GtkSorter](gtksorter#GtkSorter-struct)
│ ├── [GtkCustomSorter](gtkcustomsorter#GtkCustomSorter-struct)
│ ├── [GtkMultiSorter](gtkmultisorter#GtkMultiSorter-struct)
│ ├── [GtkNumericSorter](gtknumericsorter#GtkNumericSorter-struct)
│ ├── [GtkStringSorter](gtkstringsorter#GtkStringSorter-struct)
│ ╰── [GtkTreeListRowSorter](gtktreelistrowsorter#GtkTreeListRowSorter-struct)
├── [GtkDirectoryList](gtkdirectorylist#GtkDirectoryList-struct)
├── [GtkEventController](gtkeventcontroller#GtkEventController-struct)
│ ├── [GtkGesture](gtkgesture#GtkGesture-struct)
│ │ ├── [GtkGestureSingle](gtkgesturesingle#GtkGestureSingle-struct)
│ │ │ ├── [GtkDragSource](gtkdragsource#GtkDragSource-struct)
│ │ │ ├── [GtkGestureClick](gtkgestureclick#GtkGestureClick-struct)
│ │ │ ├── [GtkGestureDrag](gtkgesturedrag#GtkGestureDrag-struct)
│ │ │ │ ╰── [GtkGesturePan](gtkgesturepan#GtkGesturePan-struct)
│ │ │ ├── [GtkGestureLongPress](gtkgesturelongpress#GtkGestureLongPress-struct)
│ │ │ ├── [GtkGestureStylus](gtkgesturestylus#GtkGestureStylus-struct)
│ │ │ ╰── [GtkGestureSwipe](gtkgestureswipe#GtkGestureSwipe-struct)
│ │ ├── [GtkGestureRotate](gtkgesturerotate#GtkGestureRotate-struct)
│ │ ╰── [GtkGestureZoom](gtkgesturezoom#GtkGestureZoom-struct)
│ ├── [GtkDropControllerMotion](https://developer-old.gnome.org/usr/share/gtk-doc/html/gtk4/gtk4-GtkDropControllerMotion.html#GtkDropControllerMotion)
│ ├── [GtkDropTargetAsync](gtkdroptargetasync#GtkDropTargetAsync-struct)
│ ├── [GtkDropTarget](gtkdroptarget#GtkDropTarget-struct)
│ ├── [GtkEventControllerKey](gtkeventcontrollerkey#GtkEventControllerKey-struct)
│ ├── [GtkEventControllerFocus](gtkeventcontrollerfocus#GtkEventControllerFocus-struct)
│ ├── [GtkEventControllerLegacy](gtkeventcontrollerlegacy#GtkEventControllerLegacy-struct)
│ ├── [GtkEventControllerMotion](gtkeventcontrollermotion#GtkEventControllerMotion-struct)
│ ├── [GtkEventControllerScroll](gtkeventcontrollerscroll#GtkEventControllerScroll-struct)
│ ├── [GtkPadController](gtkpadcontroller#GtkPadController-struct)
│ ╰── [GtkShortcutController](gtkshortcutcontroller#GtkShortcutController-struct)
├── [GtkEntryBuffer](gtkentrybuffer#GtkEntryBuffer-struct)
├── [GtkEntryCompletion](gtkentrycompletion#GtkEntryCompletion-struct)
├── [GtkNativeDialog](gtknativedialog#GtkNativeDialog-struct)
│ ╰── [GtkFileChooserNative](gtkfilechoosernative#GtkFileChooserNative-struct)
├── [GtkFilterListModel](gtkfilterlistmodel#GtkFilterListModel-struct)
├── [GtkFlattenListModel](gtkflattenlistmodel#GtkFlattenListModel-struct)
├── [GtkLayoutChild](gtklayoutchild#GtkLayoutChild-struct)
│ ├── [GtkGridLayoutChild](gtkgridlayout#GtkGridLayoutChild-struct)
│ ├── [GtkOverlayLayoutChild](gtkoverlaylayout#GtkOverlayLayoutChild-struct)
│ ├── [GtkConstraintLayoutChild](gtkconstraintlayout#GtkConstraintLayoutChild-struct)
│ ╰── [GtkFixedLayoutChild](gtkfixedlayout#GtkFixedLayoutChild-struct)
├── [GtkIconTheme](gtkicontheme#GtkIconTheme-struct)
├── [GtkIMContext](gtkimcontext#GtkIMContext-struct)
│ ├── [GtkIMContextSimple](gtkimcontextsimple#GtkIMContextSimple-struct)
│ ╰── [GtkIMMulticontext](gtkimmulticontext#GtkIMMulticontext-struct)
├── [GtkListItem](gtklistitem#GtkListItem-struct)
├── [GtkListStore](gtkliststore#GtkListStore-struct)
├── [GtkMapListModel](gtkmaplistmodel#GtkMapListModel-struct)
├── [GtkMediaStream](gtkmediastream#GtkMediaStream-struct)
│ ╰── [GtkMediaFile](gtkmediafile#GtkMediaFile-struct)
├── GMountOperation
│ ╰── [GtkMountOperation](gtk4-filesystem-utilities#GtkMountOperation-struct)
├── [GtkMultiSelection](gtkmultiselection#GtkMultiSelection-struct)
├── [GtkNoSelection](gtknoselection#GtkNoSelection-struct)
├── [GtkNotebookPage](gtknotebook#GtkNotebookPage-struct)
├── [GtkPageSetup](gtkpagesetup#GtkPageSetup-struct)
├── [GtkPrinter](gtkprinter#GtkPrinter-struct)
├── [GtkPrintContext](gtkprintcontext#GtkPrintContext-struct)
├── [GtkPrintJob](gtkprintjob#GtkPrintJob-struct)
├── [GtkPrintOperation](gtk4-high-level-printing-api#GtkPrintOperation-struct)
├── [GtkPrintSettings](gtkprintsettings#GtkPrintSettings-struct)
├── [GtkRecentManager](gtkrecentmanager#GtkRecentManager-struct)
├── [GtkSelectionFilterModel](gtkselectionfiltermodel#GtkSelectionFilterModel-struct)
├── [GtkSettings](gtksettings#GtkSettings-struct)
├── [GtkShortcut](gtkshortcut#GtkShortcut-struct)
├── [GtkSingleSelection](gtksingleselection#GtkSingleSelection-struct)
├── [GtkSizeGroup](gtksizegroup#GtkSizeGroup-struct)
├── [GtkSliceListModel](gtkslicelistmodel#GtkSliceListModel-struct)
├── [GdkSnapshot](https://developer-old.gnome.org/gtk4/html/GdkPaintable.html#GdkSnapshot-struct)
│ ╰── [GtkSnapshot](gtksnapshot#GtkSnapshot)
├── [GtkSortListModel](gtksortlistmodel#GtkSortListModel-struct)
├── [GtkStackPage](gtkstack#GtkStackPage-struct)
├── [GtkStringList](gtkstringlist#GtkStringList-struct)
├── [GtkStringObject](gtkstringlist#GtkStringObject-struct)
├── [GtkStyleContext](gtkstylecontext#GtkStyleContext-struct)
├── [GtkTextBuffer](gtktextbuffer#GtkTextBuffer-struct)
├── [GtkTextChildAnchor](gtktextview#GtkTextChildAnchor-struct)
├── [GtkTextMark](gtktextmark#GtkTextMark-struct)
├── [GtkTextTag](gtktexttag#GtkTextTag-struct)
├── [GtkTextTagTable](gtktexttagtable#GtkTextTagTable-struct)
├── [GtkTreeListModel](gtktreelistmodel#GtkTreeListModel-struct)
├── [GtkTreeListRow](gtktreelistmodel#GtkTreeListRow-struct)
├── [GtkTreeModelFilter](gtktreemodelfilter#GtkTreeModelFilter-struct)
├── [GtkTreeModelSort](gtktreemodelsort#GtkTreeModelSort-struct)
├── [GtkTreeSelection](gtktreeselection#GtkTreeSelection-struct)
├── [GtkTreeStore](gtktreestore#GtkTreeStore-struct)
├── [GtkWidgetPaintable](https://developer-old.gnome.org/usr/share/gtk-doc/html/gtk4/gtk4-GtkWidgetPaintable.html#GtkWidgetPaintable)
├── [GtkWindowGroup](gtkwindowgroup#GtkWindowGroup-struct)
├── [GtkTooltip](gtktooltip#GtkTooltip-struct)
├── [GtkShortcutAction](gtkshortcutaction#GtkShortcutAction-struct)
│ ├── [GtkSignalAction](gtkshortcutaction#GtkSignalAction-struct)
│ ├── [GtkNothingAction](gtkshortcutaction#GtkNothingAction-struct)
│ ├── [GtkNamedAction](gtkshortcutaction#GtkNamedAction-struct)
│ ╰── [GtkCallbackAction](gtkshortcutaction#GtkCallbackAction-struct)
├── [GtkShortcutTrigger](gtkshortcuttrigger#GtkShortcutTrigger-struct)
│ ├── [GtkKeyvalTrigger](gtkshortcuttrigger#GtkKeyvalTrigger-struct)
│ ├── [GtkNeverTrigger](gtkshortcuttrigger#GtkNeverTrigger-struct)
│ ╰── [GtkAlternativeTrigger](gtkshortcuttrigger#GtkAlternativeTrigger-struct)
╰── [GtkPrintBackend](gtkprinter#GtkPrintBackend-struct)
[GInterface](https://developer-old.gnome.org/gobject/stable/GTypeModule.html)
├── [GtkAccessible](gtkaccessible#GtkAccessible-struct)
├── [GtkBuildable](gtkbuildable#GtkBuildable-struct)
├── [GtkConstraintTarget](gtkconstraint#GtkConstraintTarget-struct)
├── [GtkNative](gtknative#GtkNative-struct)
├── [GtkShortcutManager](gtkshortcutmanager#GtkShortcutManager-struct)
├── [GtkRoot](gtkroot#GtkRoot-struct)
├── [GtkActionable](gtkactionable#GtkActionable-struct)
├── [GtkAppChooser](gtkappchooser#GtkAppChooser-struct)
├── [GtkOrientable](gtk4-orientable#GtkOrientable-struct)
├── [GtkBuilderScope](gtkbuilderscope#GtkBuilderScope-struct)
├── [GtkCellLayout](gtkcelllayout#GtkCellLayout-struct)
├── [GtkCellEditable](gtkcelleditable#GtkCellEditable-struct)
├── [GtkColorChooser](gtkcolorchooser#GtkColorChooser-struct)
├── [GtkScrollable](gtkscrollable#GtkScrollable-struct)
├── [GtkStyleProvider](gtkstyleprovider#GtkStyleProvider-struct)
├── [GtkEditable](gtkeditable#GtkEditable-struct)
├── [GtkFileChooser](gtkfilechooser#GtkFileChooser-struct)
├── [GtkFontChooser](gtkfontchooser#GtkFontChooser-struct)
├── [GtkTreeModel](gtktreemodel#GtkTreeModel-struct)
├── [GtkTreeDragSource](gtk4-gtktreeview-drag-and-drop#GtkTreeDragSource-struct)
├── [GtkTreeDragDest](gtk4-gtktreeview-drag-and-drop#GtkTreeDragDest-struct)
├── [GtkTreeSortable](gtktreesortable#GtkTreeSortable-struct)
├── [GtkSelectionModel](gtkselectionmodel#GtkSelectionModel-struct)
╰── [GtkPrintOperationPreview](gtk4-high-level-printing-api#GtkPrintOperationPreview-struct)
[GBoxed](https://developer-old.gnome.org/gobject/stable/gobject-Boxed-Types.html)
├── [GtkBitset](gtkbitset#GtkBitset-struct)
├── [GtkPaperSize](gtkpapersize#GtkPaperSize-struct)
├── [GtkTextIter](gtktextiter#GtkTextIter-struct)
├── [GtkTreeIter](gtktreemodel#GtkTreeIter-struct)
├── [GtkCssSection](gtkcssprovider#GtkCssSection-struct)
╰── [GtkTreePath](gtktreemodel#GtkTreePath-struct)
[GtkExpression](gtkexpression#GtkExpression-struct)
```
gtk GtkTreeModel GtkTreeModel
============
GtkTreeModel — The tree interface used by GtkTreeView
Functions
---------
| | |
| --- | --- |
| gboolean | ([\*GtkTreeModelForeachFunc](gtktreemodel#GtkTreeModelForeachFunc)) () |
| [GtkTreePath](gtktreemodel#GtkTreePath-struct) \* | [gtk\_tree\_path\_new](gtktreemodel#gtk-tree-path-new) () |
| [GtkTreePath](gtktreemodel#GtkTreePath-struct) \* | [gtk\_tree\_path\_new\_from\_string](gtktreemodel#gtk-tree-path-new-from-string) () |
| [GtkTreePath](gtktreemodel#GtkTreePath-struct) \* | [gtk\_tree\_path\_new\_from\_indices](gtktreemodel#gtk-tree-path-new-from-indices) () |
| [GtkTreePath](gtktreemodel#GtkTreePath-struct) \* | [gtk\_tree\_path\_new\_from\_indicesv](gtktreemodel#gtk-tree-path-new-from-indicesv) () |
| char \* | [gtk\_tree\_path\_to\_string](gtktreemodel#gtk-tree-path-to-string) () |
| [GtkTreePath](gtktreemodel#GtkTreePath-struct) \* | [gtk\_tree\_path\_new\_first](gtktreemodel#gtk-tree-path-new-first) () |
| void | [gtk\_tree\_path\_append\_index](gtktreemodel#gtk-tree-path-append-index) () |
| void | [gtk\_tree\_path\_prepend\_index](gtktreemodel#gtk-tree-path-prepend-index) () |
| int | [gtk\_tree\_path\_get\_depth](gtktreemodel#gtk-tree-path-get-depth) () |
| int \* | [gtk\_tree\_path\_get\_indices](gtktreemodel#gtk-tree-path-get-indices) () |
| int \* | [gtk\_tree\_path\_get\_indices\_with\_depth](gtktreemodel#gtk-tree-path-get-indices-with-depth) () |
| void | [gtk\_tree\_path\_free](gtktreemodel#gtk-tree-path-free) () |
| [GtkTreePath](gtktreemodel#GtkTreePath-struct) \* | [gtk\_tree\_path\_copy](gtktreemodel#gtk-tree-path-copy) () |
| int | [gtk\_tree\_path\_compare](gtktreemodel#gtk-tree-path-compare) () |
| void | [gtk\_tree\_path\_next](gtktreemodel#gtk-tree-path-next) () |
| gboolean | [gtk\_tree\_path\_prev](gtktreemodel#gtk-tree-path-prev) () |
| gboolean | [gtk\_tree\_path\_up](gtktreemodel#gtk-tree-path-up) () |
| void | [gtk\_tree\_path\_down](gtktreemodel#gtk-tree-path-down) () |
| gboolean | [gtk\_tree\_path\_is\_ancestor](gtktreemodel#gtk-tree-path-is-ancestor) () |
| gboolean | [gtk\_tree\_path\_is\_descendant](gtktreemodel#gtk-tree-path-is-descendant) () |
| [GtkTreeRowReference](gtktreemodel#GtkTreeRowReference) \* | [gtk\_tree\_row\_reference\_new](gtktreemodel#gtk-tree-row-reference-new) () |
| [GtkTreeRowReference](gtktreemodel#GtkTreeRowReference) \* | [gtk\_tree\_row\_reference\_new\_proxy](gtktreemodel#gtk-tree-row-reference-new-proxy) () |
| [GtkTreeModel](gtktreemodel#GtkTreeModel-struct) \* | [gtk\_tree\_row\_reference\_get\_model](gtktreemodel#gtk-tree-row-reference-get-model) () |
| [GtkTreePath](gtktreemodel#GtkTreePath-struct) \* | [gtk\_tree\_row\_reference\_get\_path](gtktreemodel#gtk-tree-row-reference-get-path) () |
| gboolean | [gtk\_tree\_row\_reference\_valid](gtktreemodel#gtk-tree-row-reference-valid) () |
| void | [gtk\_tree\_row\_reference\_free](gtktreemodel#gtk-tree-row-reference-free) () |
| [GtkTreeRowReference](gtktreemodel#GtkTreeRowReference) \* | [gtk\_tree\_row\_reference\_copy](gtktreemodel#gtk-tree-row-reference-copy) () |
| void | [gtk\_tree\_row\_reference\_inserted](gtktreemodel#gtk-tree-row-reference-inserted) () |
| void | [gtk\_tree\_row\_reference\_deleted](gtktreemodel#gtk-tree-row-reference-deleted) () |
| void | [gtk\_tree\_row\_reference\_reordered](gtktreemodel#gtk-tree-row-reference-reordered) () |
| [GtkTreeIter](gtktreemodel#GtkTreeIter-struct) \* | [gtk\_tree\_iter\_copy](gtktreemodel#gtk-tree-iter-copy) () |
| void | [gtk\_tree\_iter\_free](gtktreemodel#gtk-tree-iter-free) () |
| [GtkTreeModelFlags](gtktreemodel#GtkTreeModelFlags) | [gtk\_tree\_model\_get\_flags](gtktreemodel#gtk-tree-model-get-flags) () |
| int | [gtk\_tree\_model\_get\_n\_columns](gtktreemodel#gtk-tree-model-get-n-columns) () |
| GType | [gtk\_tree\_model\_get\_column\_type](gtktreemodel#gtk-tree-model-get-column-type) () |
| gboolean | [gtk\_tree\_model\_get\_iter](gtktreemodel#gtk-tree-model-get-iter) () |
| gboolean | [gtk\_tree\_model\_get\_iter\_from\_string](gtktreemodel#gtk-tree-model-get-iter-from-string) () |
| gboolean | [gtk\_tree\_model\_get\_iter\_first](gtktreemodel#gtk-tree-model-get-iter-first) () |
| [GtkTreePath](gtktreemodel#GtkTreePath-struct) \* | [gtk\_tree\_model\_get\_path](gtktreemodel#gtk-tree-model-get-path) () |
| void | [gtk\_tree\_model\_get\_value](gtktreemodel#gtk-tree-model-get-value) () |
| gboolean | [gtk\_tree\_model\_iter\_next](gtktreemodel#gtk-tree-model-iter-next) () |
| gboolean | [gtk\_tree\_model\_iter\_previous](gtktreemodel#gtk-tree-model-iter-previous) () |
| gboolean | [gtk\_tree\_model\_iter\_children](gtktreemodel#gtk-tree-model-iter-children) () |
| gboolean | [gtk\_tree\_model\_iter\_has\_child](gtktreemodel#gtk-tree-model-iter-has-child) () |
| int | [gtk\_tree\_model\_iter\_n\_children](gtktreemodel#gtk-tree-model-iter-n-children) () |
| gboolean | [gtk\_tree\_model\_iter\_nth\_child](gtktreemodel#gtk-tree-model-iter-nth-child) () |
| gboolean | [gtk\_tree\_model\_iter\_parent](gtktreemodel#gtk-tree-model-iter-parent) () |
| char \* | [gtk\_tree\_model\_get\_string\_from\_iter](gtktreemodel#gtk-tree-model-get-string-from-iter) () |
| void | [gtk\_tree\_model\_ref\_node](gtktreemodel#gtk-tree-model-ref-node) () |
| void | [gtk\_tree\_model\_unref\_node](gtktreemodel#gtk-tree-model-unref-node) () |
| void | [gtk\_tree\_model\_get](gtktreemodel#gtk-tree-model-get) () |
| void | [gtk\_tree\_model\_get\_valist](gtktreemodel#gtk-tree-model-get-valist) () |
| void | [gtk\_tree\_model\_foreach](gtktreemodel#gtk-tree-model-foreach) () |
| void | [gtk\_tree\_model\_row\_changed](gtktreemodel#gtk-tree-model-row-changed) () |
| void | [gtk\_tree\_model\_row\_inserted](gtktreemodel#gtk-tree-model-row-inserted) () |
| void | [gtk\_tree\_model\_row\_has\_child\_toggled](gtktreemodel#gtk-tree-model-row-has-child-toggled) () |
| void | [gtk\_tree\_model\_row\_deleted](gtktreemodel#gtk-tree-model-row-deleted) () |
| void | [gtk\_tree\_model\_rows\_reordered](gtktreemodel#gtk-tree-model-rows-reordered) () |
| void | [gtk\_tree\_model\_rows\_reordered\_with\_length](gtktreemodel#gtk-tree-model-rows-reordered-with-length) () |
Signals
-------
| | | |
| --- | --- | --- |
| void | [row-changed](gtktreemodel#GtkTreeModel-row-changed) | Run Last |
| void | [row-deleted](gtktreemodel#GtkTreeModel-row-deleted) | Run First |
| void | [row-has-child-toggled](gtktreemodel#GtkTreeModel-row-has-child-toggled) | Run Last |
| void | [row-inserted](gtktreemodel#GtkTreeModel-row-inserted) | Run First |
| void | [rows-reordered](gtktreemodel#GtkTreeModel-rows-reordered) | Run First |
Types and Values
----------------
| | |
| --- | --- |
| | [GtkTreeModel](gtktreemodel#GtkTreeModel-struct) |
| struct | [GtkTreeIter](gtktreemodel#GtkTreeIter-struct) |
| | [GtkTreePath](gtktreemodel#GtkTreePath-struct) |
| | [GtkTreeRowReference](gtktreemodel#GtkTreeRowReference) |
| struct | [GtkTreeModelIface](gtktreemodel#GtkTreeModelIface) |
| enum | [GtkTreeModelFlags](gtktreemodel#GtkTreeModelFlags) |
Object Hierarchy
----------------
```
[GBoxed](https://developer-old.gnome.org/gobject/stable/gobject-Boxed-Types.html)
├── GtkTreeIter
╰── GtkTreePath
[GInterface](https://developer-old.gnome.org/gobject/stable/GTypeModule.html)
╰── GtkTreeModel
```
Prerequisites
-------------
GtkTreeModel requires GObject.
Known Derived Interfaces
------------------------
GtkTreeModel is required by [GtkTreeSortable](gtktreesortable#GtkTreeSortable-struct).
Known Implementations
---------------------
GtkTreeModel is implemented by [GtkListStore](gtkliststore#GtkListStore-struct), [GtkTreeModelFilter](gtktreemodelfilter#GtkTreeModelFilter-struct), [GtkTreeModelSort](gtktreemodelsort#GtkTreeModelSort-struct) and [GtkTreeStore](gtktreestore#GtkTreeStore-struct).
Includes
--------
```
#include <gtk/gtk.h>
```
Description
-----------
The [GtkTreeModel](gtktreemodel#GtkTreeModel-struct) interface defines a generic tree interface for use by the [GtkTreeView](gtktreeview#GtkTreeView-struct) widget. It is an abstract interface, and is designed to be usable with any appropriate data structure. The programmer just has to implement this interface on their own data type for it to be viewable by a [GtkTreeView](gtktreeview#GtkTreeView-struct) widget.
The model is represented as a hierarchical tree of strongly-typed, columned data. In other words, the model can be seen as a tree where every node has different values depending on which column is being queried. The type of data found in a column is determined by using the GType system (ie. G\_TYPE\_INT, GTK\_TYPE\_BUTTON, G\_TYPE\_POINTER, etc). The types are homogeneous per column across all nodes. It is important to note that this interface only provides a way of examining a model and observing changes. The implementation of each individual model decides how and if changes are made.
In order to make life simpler for programmers who do not need to write their own specialized model, two generic models are provided — the [GtkTreeStore](gtktreestore#GtkTreeStore-struct) and the [GtkListStore](gtkliststore#GtkListStore-struct). To use these, the developer simply pushes data into these models as necessary. These models provide the data structure as well as all appropriate tree interfaces. As a result, implementing drag and drop, sorting, and storing data is trivial. For the vast majority of trees and lists, these two models are sufficient.
Models are accessed on a node/column level of granularity. One can query for the value of a model at a certain node and a certain column on that node. There are two structures used to reference a particular node in a model. They are the [GtkTreePath](gtktreemodel#GtkTreePath-struct) and the [GtkTreeIter](gtktreemodel#GtkTreeIter-struct) (“iter” is short for iterator). Most of the interface consists of operations on a [GtkTreeIter](gtktreemodel#GtkTreeIter-struct).
A path is essentially a potential node. It is a location on a model that may or may not actually correspond to a node on a specific model. The [GtkTreePath](gtktreemodel#GtkTreePath-struct) can be converted into either an array of unsigned integers or a string. The string form is a list of numbers separated by a colon. Each number refers to the offset at that level. Thus, the path `0` refers to the root node and the path `2:4` refers to the fifth child of the third node.
By contrast, a [GtkTreeIter](gtktreemodel#GtkTreeIter-struct) is a reference to a specific node on a specific model. It is a generic struct with an integer and three generic pointers. These are filled in by the model in a model-specific way. One can convert a path to an iterator by calling [`gtk_tree_model_get_iter()`](gtktreemodel#gtk-tree-model-get-iter). These iterators are the primary way of accessing a model and are similar to the iterators used by [GtkTextBuffer](gtktextbuffer#GtkTextBuffer-struct). They are generally statically allocated on the stack and only used for a short time. The model interface defines a set of operations using them for navigating the model.
It is expected that models fill in the iterator with private data. For example, the [GtkListStore](gtkliststore#GtkListStore-struct) model, which is internally a simple linked list, stores a list node in one of the pointers. The [GtkTreeModelSort](gtktreemodelsort#GtkTreeModelSort-struct) stores an array and an offset in two of the pointers. Additionally, there is an integer field. This field is generally filled with a unique stamp per model. This stamp is for catching errors resulting from using invalid iterators with a model.
The lifecycle of an iterator can be a little confusing at first. Iterators are expected to always be valid for as long as the model is unchanged (and doesn’t emit a signal). The model is considered to own all outstanding iterators and nothing needs to be done to free them from the user’s point of view. Additionally, some models guarantee that an iterator is valid for as long as the node it refers to is valid (most notably the [GtkTreeStore](gtktreestore#GtkTreeStore-struct) and [GtkListStore](gtkliststore#GtkListStore-struct)). Although generally uninteresting, as one always has to allow for the case where iterators do not persist beyond a signal, some very important performance enhancements were made in the sort model. As a result, the [GTK\_TREE\_MODEL\_ITERS\_PERSIST](gtktreemodel#GTK-TREE-MODEL-ITERS-PERSIST:CAPS) flag was added to indicate this behavior.
To help show some common operation of a model, some examples are provided. The first example shows three ways of getting the iter at the location `3:2:5`. While the first method shown is easier, the second is much more common, as you often get paths from callbacks.
#### Acquiring a [GtkTreeIter](gtktreemodel#GtkTreeIter-struct)
This second example shows a quick way of iterating through a list and getting a string and an integer from each row. The `populate_model()` function used below is not shown, as it is specific to the [GtkListStore](gtkliststore#GtkListStore-struct). For information on how to write such a function, see the [GtkListStore](gtkliststore#GtkListStore-struct) documentation.
#### Reading data from a [GtkTreeModel](gtktreemodel#GtkTreeModel-struct)
```
// Three ways of getting the iter pointing to the location
GtkTreePath *path;
GtkTreeIter iter;
GtkTreeIter parent_iter;
// get the iterator from a string
gtk_tree_model_get_iter_from_string (model,
&iter,
"3:2:5");
// get the iterator from a path
path = gtk_tree_path_new_from_string ("3:2:5");
gtk_tree_model_get_iter (model, &iter, path);
gtk_tree_path_free (path);
// walk the tree to find the iterator
gtk_tree_model_iter_nth_child (model, &iter,
NULL, 3);
parent_iter = iter;
gtk_tree_model_iter_nth_child (model, &iter,
&parent_iter, 2);
parent_iter = iter;
gtk_tree_model_iter_nth_child (model, &iter,
&parent_iter, 5);
```
| The [GtkTreeModel](gtktreemodel#GtkTreeModel-struct) interface contains two methods for reference counting: [`gtk_tree_model_ref_node()`](gtktreemodel#gtk-tree-model-ref-node) and [`gtk_tree_model_unref_node()`](gtktreemodel#gtk-tree-model-unref-node). These two methods are optional to implement. The reference counting is meant as a way for views to let models know when nodes are being displayed. [GtkTreeView](gtktreeview#GtkTreeView-struct) will take a reference on a node when it is visible, which means the node is either in the toplevel or expanded. Being displayed does not mean that the node is currently directly visible to the user in the viewport. Based on this reference counting scheme a caching model, for example, can decide whether or not to cache a node based on the reference count. A file-system based model would not want to keep the entire file hierarchy in memory, but just the folders that are currently expanded in every current view.
When working with reference counting, the following rules must be taken into account:
* Never take a reference on a node without owning a reference on its parent. This means that all parent nodes of a referenced node must be referenced as well.
* Outstanding references on a deleted node are not released. This is not possible because the node has already been deleted by the time the row-deleted signal is received.
* Models are not obligated to emit a signal on rows of which none of its siblings are referenced. To phrase this differently, signals are only required for levels in which nodes are referenced. For the root level however, signals must be emitted at all times (however the root level is always referenced when any view is attached).
Functions
---------
### GtkTreeModelForeachFunc ()
```
gboolean
(*GtkTreeModelForeachFunc) (*`[GtkTreeModel](gtktreemodel#GtkTreeModel-struct) *model`*,
*`[GtkTreePath](gtktreemodel#GtkTreePath-struct) *path`*,
*`[GtkTreeIter](gtktreemodel#GtkTreeIter-struct) *iter`*,
*`gpointer data`*);
```
Type of the callback passed to [`gtk_tree_model_foreach()`](gtktreemodel#gtk-tree-model-foreach) to iterate over the rows in a tree model.
#### Parameters
| | | |
| --- | --- | --- |
| model | the [GtkTreeModel](gtktreemodel#GtkTreeModel-struct) being iterated | |
| path | the current [GtkTreePath](gtktreemodel#GtkTreePath-struct) | |
| iter | the current [GtkTreeIter](gtktreemodel#GtkTreeIter-struct) | |
| data | The user data passed to [`gtk_tree_model_foreach()`](gtktreemodel#gtk-tree-model-foreach). | [closure] |
#### Returns
`TRUE` to stop iterating, `FALSE` to continue
### gtk\_tree\_path\_new ()
```
[GtkTreePath](gtktreemodel#GtkTreePath-struct) *
gtk_tree_path_new (*`void`*);
```
Creates a new [GtkTreePath](gtktreemodel#GtkTreePath-struct). This refers to a row.
#### Returns
A newly created [GtkTreePath](gtktreemodel#GtkTreePath-struct).
### gtk\_tree\_path\_new\_from\_string ()
```
[GtkTreePath](gtktreemodel#GtkTreePath-struct) *
gtk_tree_path_new_from_string (*`const char *path`*);
```
Creates a new [GtkTreePath](gtktreemodel#GtkTreePath-struct) initialized to *`path`* .
*`path`* is expected to be a colon separated list of numbers. For example, the string “10:4:0” would create a path of depth 3 pointing to the 11th child of the root node, the 5th child of that 11th child, and the 1st child of that 5th child. If an invalid path string is passed in, `NULL` is returned.
#### Parameters
| | | |
| --- | --- | --- |
| path | The string representation of a path | |
#### Returns
A newly-created [GtkTreePath](gtktreemodel#GtkTreePath-struct), or `NULL`.
[nullable]
### gtk\_tree\_path\_new\_from\_indices ()
```
[GtkTreePath](gtktreemodel#GtkTreePath-struct) *
gtk_tree_path_new_from_indices (*`int first_index`*,
*`...`*);
```
Creates a new path with *`first_index`* and *`varargs`* as indices.
#### Parameters
| | | |
| --- | --- | --- |
| first\_index | first integer | |
| ... | list of integers terminated by -1 | |
#### Returns
A newly created [GtkTreePath](gtktreemodel#GtkTreePath-struct)
### gtk\_tree\_path\_new\_from\_indicesv ()
```
[GtkTreePath](gtktreemodel#GtkTreePath-struct) *
gtk_tree_path_new_from_indicesv (*`int *indices`*,
*`gsize length`*);
```
Creates a new path with the given *`indices`* array of *`length`* .
[rename-to gtk\_tree\_path\_new\_from\_indices]
#### Parameters
| | | |
| --- | --- | --- |
| indices | array of indices. | [array length=length] |
| length | length of *`indices`* array | |
#### Returns
A newly created [GtkTreePath](gtktreemodel#GtkTreePath-struct)
### gtk\_tree\_path\_to\_string ()
```
char *
gtk_tree_path_to_string (*`[GtkTreePath](gtktreemodel#GtkTreePath-struct) *path`*);
```
Generates a string representation of the path.
This string is a “:” separated list of numbers. For example, “4:10:0:3” would be an acceptable return value for this string. If the path has depth 0, `NULL` is returned.
#### Parameters
| | | |
| --- | --- | --- |
| path | A [GtkTreePath](gtktreemodel#GtkTreePath-struct) | |
#### Returns
A newly-allocated string. Must be freed with `g_free()`.
[nullable]
### gtk\_tree\_path\_new\_first ()
```
[GtkTreePath](gtktreemodel#GtkTreePath-struct) *
gtk_tree_path_new_first (*`void`*);
```
Creates a new [GtkTreePath](gtktreemodel#GtkTreePath-struct).
The string representation of this path is “0”.
#### Returns
A new [GtkTreePath](gtktreemodel#GtkTreePath-struct)
### gtk\_tree\_path\_append\_index ()
```
void
gtk_tree_path_append_index (*`[GtkTreePath](gtktreemodel#GtkTreePath-struct) *path`*,
*`int index_`*);
```
Appends a new index to a path.
As a result, the depth of the path is increased.
#### Parameters
| | | |
| --- | --- | --- |
| path | a [GtkTreePath](gtktreemodel#GtkTreePath-struct) | |
| index\_ | the index | |
### gtk\_tree\_path\_prepend\_index ()
```
void
gtk_tree_path_prepend_index (*`[GtkTreePath](gtktreemodel#GtkTreePath-struct) *path`*,
*`int index_`*);
```
Prepends a new index to a path.
As a result, the depth of the path is increased.
#### Parameters
| | | |
| --- | --- | --- |
| path | a [GtkTreePath](gtktreemodel#GtkTreePath-struct) | |
| index\_ | the index | |
### gtk\_tree\_path\_get\_depth ()
```
int
gtk_tree_path_get_depth (*`[GtkTreePath](gtktreemodel#GtkTreePath-struct) *path`*);
```
Returns the current depth of *`path`* .
#### Parameters
| | | |
| --- | --- | --- |
| path | a [GtkTreePath](gtktreemodel#GtkTreePath-struct) | |
#### Returns
The depth of *`path`*
### gtk\_tree\_path\_get\_indices ()
```
int *
gtk_tree_path_get_indices (*`[GtkTreePath](gtktreemodel#GtkTreePath-struct) *path`*);
```
Returns the current indices of *`path`* .
This is an array of integers, each representing a node in a tree. This value should not be freed.
The length of the array can be obtained with [`gtk_tree_path_get_depth()`](gtktreemodel#gtk-tree-path-get-depth).
[skip]
#### Parameters
| | | |
| --- | --- | --- |
| path | a [GtkTreePath](gtktreemodel#GtkTreePath-struct) | |
#### Returns
The current indices, or `NULL`.
[nullable]
### gtk\_tree\_path\_get\_indices\_with\_depth ()
```
int *
gtk_tree_path_get_indices_with_depth (*`[GtkTreePath](gtktreemodel#GtkTreePath-struct) *path`*,
*`int *depth`*);
```
Returns the current indices of *`path`* .
This is an array of integers, each representing a node in a tree. It also returns the number of elements in the array. The array should not be freed.
[rename-to gtk\_tree\_path\_get\_indices]
#### Parameters
| | | |
| --- | --- | --- |
| path | a [GtkTreePath](gtktreemodel#GtkTreePath-struct) | |
| depth | return location for number of elements returned in the integer array, or `NULL`. | [out][allow-none] |
#### Returns
The current indices, or `NULL`.
[array length=depth][transfer none]
### gtk\_tree\_path\_free ()
```
void
gtk_tree_path_free (*`[GtkTreePath](gtktreemodel#GtkTreePath-struct) *path`*);
```
Frees *`path`* . If *`path`* is `NULL`, it simply returns.
#### Parameters
| | | |
| --- | --- | --- |
| path | a [GtkTreePath](gtktreemodel#GtkTreePath-struct). | [allow-none] |
### gtk\_tree\_path\_copy ()
```
[GtkTreePath](gtktreemodel#GtkTreePath-struct) *
gtk_tree_path_copy (*`const [GtkTreePath](gtktreemodel#GtkTreePath-struct) *path`*);
```
Creates a new [GtkTreePath](gtktreemodel#GtkTreePath-struct) as a copy of *`path`* .
#### Parameters
| | | |
| --- | --- | --- |
| path | a [GtkTreePath](gtktreemodel#GtkTreePath-struct) | |
#### Returns
a new [GtkTreePath](gtktreemodel#GtkTreePath-struct)
### gtk\_tree\_path\_compare ()
```
int
gtk_tree_path_compare (*`const [GtkTreePath](gtktreemodel#GtkTreePath-struct) *a`*,
*`const [GtkTreePath](gtktreemodel#GtkTreePath-struct) *b`*);
```
Compares two paths.
If *`a`* appears before *`b`* in a tree, then -1 is returned. If *`b`* appears before *`a`* , then 1 is returned. If the two nodes are equal, then 0 is returned.
#### Parameters
| | | |
| --- | --- | --- |
| a | a [GtkTreePath](gtktreemodel#GtkTreePath-struct) | |
| b | a [GtkTreePath](gtktreemodel#GtkTreePath-struct) to compare with | |
#### Returns
the relative positions of *`a`* and *`b`*
### gtk\_tree\_path\_next ()
```
void
gtk_tree_path_next (*`[GtkTreePath](gtktreemodel#GtkTreePath-struct) *path`*);
```
Moves the *`path`* to point to the next node at the current depth.
#### Parameters
| | | |
| --- | --- | --- |
| path | a [GtkTreePath](gtktreemodel#GtkTreePath-struct) | |
### gtk\_tree\_path\_prev ()
```
gboolean
gtk_tree_path_prev (*`[GtkTreePath](gtktreemodel#GtkTreePath-struct) *path`*);
```
Moves the *`path`* to point to the previous node at the current depth, if it exists.
#### Parameters
| | | |
| --- | --- | --- |
| path | a [GtkTreePath](gtktreemodel#GtkTreePath-struct) | |
#### Returns
`TRUE` if *`path`* has a previous node, and the move was made
### gtk\_tree\_path\_up ()
```
gboolean
gtk_tree_path_up (*`[GtkTreePath](gtktreemodel#GtkTreePath-struct) *path`*);
```
Moves the *`path`* to point to its parent node, if it has a parent.
#### Parameters
| | | |
| --- | --- | --- |
| path | a [GtkTreePath](gtktreemodel#GtkTreePath-struct) | |
#### Returns
`TRUE` if *`path`* has a parent, and the move was made
### gtk\_tree\_path\_down ()
```
void
gtk_tree_path_down (*`[GtkTreePath](gtktreemodel#GtkTreePath-struct) *path`*);
```
Moves *`path`* to point to the first child of the current path.
#### Parameters
| | | |
| --- | --- | --- |
| path | a [GtkTreePath](gtktreemodel#GtkTreePath-struct) | |
### gtk\_tree\_path\_is\_ancestor ()
```
gboolean
gtk_tree_path_is_ancestor (*`[GtkTreePath](gtktreemodel#GtkTreePath-struct) *path`*,
*`[GtkTreePath](gtktreemodel#GtkTreePath-struct) *descendant`*);
```
Returns `TRUE` if *`descendant`* is a descendant of *`path`* .
#### Parameters
| | | |
| --- | --- | --- |
| path | a [GtkTreePath](gtktreemodel#GtkTreePath-struct) | |
| descendant | another [GtkTreePath](gtktreemodel#GtkTreePath-struct) | |
#### Returns
`TRUE` if *`descendant`* is contained inside *`path`*
### gtk\_tree\_path\_is\_descendant ()
```
gboolean
gtk_tree_path_is_descendant (*`[GtkTreePath](gtktreemodel#GtkTreePath-struct) *path`*,
*`[GtkTreePath](gtktreemodel#GtkTreePath-struct) *ancestor`*);
```
Returns `TRUE` if *`path`* is a descendant of *`ancestor`* .
#### Parameters
| | | |
| --- | --- | --- |
| path | a [GtkTreePath](gtktreemodel#GtkTreePath-struct) | |
| ancestor | another [GtkTreePath](gtktreemodel#GtkTreePath-struct) | |
#### Returns
`TRUE` if *`ancestor`* contains *`path`* somewhere below it
### gtk\_tree\_row\_reference\_new ()
```
[GtkTreeRowReference](gtktreemodel#GtkTreeRowReference) *
gtk_tree_row_reference_new (*`[GtkTreeModel](gtktreemodel#GtkTreeModel-struct) *model`*,
*`[GtkTreePath](gtktreemodel#GtkTreePath-struct) *path`*);
```
Creates a row reference based on *`path`* .
This reference will keep pointing to the node pointed to by *`path`* , so long as it exists. Any changes that occur on *`model`* are propagated, and the path is updated appropriately. If *`path`* isn’t a valid path in *`model`* , then `NULL` is returned.
#### Parameters
| | | |
| --- | --- | --- |
| model | a [GtkTreeModel](gtktreemodel#GtkTreeModel-struct) | |
| path | a valid [GtkTreePath](gtktreemodel#GtkTreePath-struct) to monitor | |
#### Returns
a newly allocated [GtkTreeRowReference](gtktreemodel#GtkTreeRowReference), or `NULL`.
[nullable]
### gtk\_tree\_row\_reference\_new\_proxy ()
```
[GtkTreeRowReference](gtktreemodel#GtkTreeRowReference) *
gtk_tree_row_reference_new_proxy (*`GObject *proxy`*,
*`[GtkTreeModel](gtktreemodel#GtkTreeModel-struct) *model`*,
*`[GtkTreePath](gtktreemodel#GtkTreePath-struct) *path`*);
```
You do not need to use this function.
Creates a row reference based on *`path`* .
This reference will keep pointing to the node pointed to by *`path`* , so long as it exists. If *`path`* isn’t a valid path in *`model`* , then `NULL` is returned. However, unlike references created with [`gtk_tree_row_reference_new()`](gtktreemodel#gtk-tree-row-reference-new), it does not listen to the model for changes. The creator of the row reference must do this explicitly using [`gtk_tree_row_reference_inserted()`](gtktreemodel#gtk-tree-row-reference-inserted), [`gtk_tree_row_reference_deleted()`](gtktreemodel#gtk-tree-row-reference-deleted), [`gtk_tree_row_reference_reordered()`](gtktreemodel#gtk-tree-row-reference-reordered).
These functions must be called exactly once per proxy when the corresponding signal on the model is emitted. This single call updates all row references for that proxy. Since built-in GTK objects like [GtkTreeView](gtktreeview#GtkTreeView-struct) already use this mechanism internally, using them as the proxy object will produce unpredictable results. Further more, passing the same object as *`model`* and *`proxy`* doesn’t work for reasons of internal implementation.
This type of row reference is primarily meant by structures that need to carefully monitor exactly when a row reference updates itself, and is not generally needed by most applications.
#### Parameters
| | | |
| --- | --- | --- |
| proxy | a proxy GObject | |
| model | a [GtkTreeModel](gtktreemodel#GtkTreeModel-struct) | |
| path | a valid [GtkTreePath](gtktreemodel#GtkTreePath-struct) to monitor | |
#### Returns
a newly allocated [GtkTreeRowReference](gtktreemodel#GtkTreeRowReference), or `NULL`.
[nullable]
### gtk\_tree\_row\_reference\_get\_model ()
```
[GtkTreeModel](gtktreemodel#GtkTreeModel-struct) *
gtk_tree_row_reference_get_model (*`[GtkTreeRowReference](gtktreemodel#GtkTreeRowReference) *reference`*);
```
Returns the model that the row reference is monitoring.
#### Parameters
| | | |
| --- | --- | --- |
| reference | a [GtkTreeRowReference](gtktreemodel#GtkTreeRowReference) | |
#### Returns
the model.
[transfer none]
### gtk\_tree\_row\_reference\_get\_path ()
```
[GtkTreePath](gtktreemodel#GtkTreePath-struct) *
gtk_tree_row_reference_get_path (*`[GtkTreeRowReference](gtktreemodel#GtkTreeRowReference) *reference`*);
```
Returns a path that the row reference currently points to, or `NULL` if the path pointed to is no longer valid.
#### Parameters
| | | |
| --- | --- | --- |
| reference | a [GtkTreeRowReference](gtktreemodel#GtkTreeRowReference) | |
#### Returns
a current path, or `NULL`.
[nullable][transfer full]
### gtk\_tree\_row\_reference\_valid ()
```
gboolean
gtk_tree_row_reference_valid (*`[GtkTreeRowReference](gtktreemodel#GtkTreeRowReference) *reference`*);
```
Returns `TRUE` if the *`reference`* is non-`NULL` and refers to a current valid path.
#### Parameters
| | | |
| --- | --- | --- |
| reference | a [GtkTreeRowReference](gtktreemodel#GtkTreeRowReference), or `NULL`. | [allow-none] |
#### Returns
`TRUE` if *`reference`* points to a valid path
### gtk\_tree\_row\_reference\_free ()
```
void
gtk_tree_row_reference_free (*`[GtkTreeRowReference](gtktreemodel#GtkTreeRowReference) *reference`*);
```
Free’s *`reference`* . *`reference`* may be `NULL`
#### Parameters
| | | |
| --- | --- | --- |
| reference | a [GtkTreeRowReference](gtktreemodel#GtkTreeRowReference), or `NULL`. | [allow-none] |
### gtk\_tree\_row\_reference\_copy ()
```
[GtkTreeRowReference](gtktreemodel#GtkTreeRowReference) *
gtk_tree_row_reference_copy (*`[GtkTreeRowReference](gtktreemodel#GtkTreeRowReference) *reference`*);
```
Copies a [GtkTreeRowReference](gtktreemodel#GtkTreeRowReference).
#### Parameters
| | | |
| --- | --- | --- |
| reference | a [GtkTreeRowReference](gtktreemodel#GtkTreeRowReference) | |
#### Returns
a copy of *`reference`*
### gtk\_tree\_row\_reference\_inserted ()
```
void
gtk_tree_row_reference_inserted (*`GObject *proxy`*,
*`[GtkTreePath](gtktreemodel#GtkTreePath-struct) *path`*);
```
Lets a set of row reference created by [`gtk_tree_row_reference_new_proxy()`](gtktreemodel#gtk-tree-row-reference-new-proxy) know that the model emitted the [“row-inserted”](gtktreemodel#GtkTreeModel-row-inserted) signal.
#### Parameters
| | | |
| --- | --- | --- |
| proxy | a GObject | |
| path | the row position that was inserted | |
### gtk\_tree\_row\_reference\_deleted ()
```
void
gtk_tree_row_reference_deleted (*`GObject *proxy`*,
*`[GtkTreePath](gtktreemodel#GtkTreePath-struct) *path`*);
```
Lets a set of row reference created by [`gtk_tree_row_reference_new_proxy()`](gtktreemodel#gtk-tree-row-reference-new-proxy) know that the model emitted the [“row-deleted”](gtktreemodel#GtkTreeModel-row-deleted) signal.
#### Parameters
| | | |
| --- | --- | --- |
| proxy | a GObject | |
| path | the path position that was deleted | |
### gtk\_tree\_row\_reference\_reordered ()
```
void
gtk_tree_row_reference_reordered (*`GObject *proxy`*,
*`[GtkTreePath](gtktreemodel#GtkTreePath-struct) *path`*,
*`[GtkTreeIter](gtktreemodel#GtkTreeIter-struct) *iter`*,
*`int *new_order`*);
```
Lets a set of row reference created by [`gtk_tree_row_reference_new_proxy()`](gtktreemodel#gtk-tree-row-reference-new-proxy) know that the model emitted the [“rows-reordered”](gtktreemodel#GtkTreeModel-rows-reordered) signal.
[skip]
#### Parameters
| | | |
| --- | --- | --- |
| proxy | a GObject | |
| path | the parent path of the reordered signal | |
| iter | the iter pointing to the parent of the reordered | |
| new\_order | the new order of rows. | [array] |
### gtk\_tree\_iter\_copy ()
```
[GtkTreeIter](gtktreemodel#GtkTreeIter-struct) *
gtk_tree_iter_copy (*`[GtkTreeIter](gtktreemodel#GtkTreeIter-struct) *iter`*);
```
Creates a dynamically allocated tree iterator as a copy of *`iter`* .
This function is not intended for use in applications, because you can just copy the structs by value (`GtkTreeIter new_iter = iter;`). You must free this iter with [`gtk_tree_iter_free()`](gtktreemodel#gtk-tree-iter-free).
#### Parameters
| | | |
| --- | --- | --- |
| iter | a [GtkTreeIter](gtktreemodel#GtkTreeIter-struct) | |
#### Returns
a newly-allocated copy of *`iter`*
### gtk\_tree\_iter\_free ()
```
void
gtk_tree_iter_free (*`[GtkTreeIter](gtktreemodel#GtkTreeIter-struct) *iter`*);
```
Frees an iterator that has been allocated by [`gtk_tree_iter_copy()`](gtktreemodel#gtk-tree-iter-copy).
This function is mainly used for language bindings.
#### Parameters
| | | |
| --- | --- | --- |
| iter | a dynamically allocated tree iterator | |
### gtk\_tree\_model\_get\_flags ()
```
[GtkTreeModelFlags](gtktreemodel#GtkTreeModelFlags)
gtk_tree_model_get_flags (*`[GtkTreeModel](gtktreemodel#GtkTreeModel-struct) *tree_model`*);
```
Returns a set of flags supported by this interface.
The flags are a bitwise combination of [GtkTreeModelFlags](gtktreemodel#GtkTreeModelFlags). The flags supported should not change during the lifetime of the *`tree_model`* .
#### Parameters
| | | |
| --- | --- | --- |
| tree\_model | a [GtkTreeModel](gtktreemodel#GtkTreeModel-struct) | |
#### Returns
the flags supported by this interface
### gtk\_tree\_model\_get\_n\_columns ()
```
int
gtk_tree_model_get_n_columns (*`[GtkTreeModel](gtktreemodel#GtkTreeModel-struct) *tree_model`*);
```
Returns the number of columns supported by *`tree_model`* .
#### Parameters
| | | |
| --- | --- | --- |
| tree\_model | a [GtkTreeModel](gtktreemodel#GtkTreeModel-struct) | |
#### Returns
the number of columns
### gtk\_tree\_model\_get\_column\_type ()
```
GType
gtk_tree_model_get_column_type (*`[GtkTreeModel](gtktreemodel#GtkTreeModel-struct) *tree_model`*,
*`int index_`*);
```
Returns the type of the column.
#### Parameters
| | | |
| --- | --- | --- |
| tree\_model | a [GtkTreeModel](gtktreemodel#GtkTreeModel-struct) | |
| index\_ | the column index | |
#### Returns
the type of the column
### gtk\_tree\_model\_get\_iter ()
```
gboolean
gtk_tree_model_get_iter (*`[GtkTreeModel](gtktreemodel#GtkTreeModel-struct) *tree_model`*,
*`[GtkTreeIter](gtktreemodel#GtkTreeIter-struct) *iter`*,
*`[GtkTreePath](gtktreemodel#GtkTreePath-struct) *path`*);
```
Sets *`iter`* to a valid iterator pointing to *`path`* . If *`path`* does not exist, *`iter`* is set to an invalid iterator and `FALSE` is returned.
#### Parameters
| | | |
| --- | --- | --- |
| tree\_model | a [GtkTreeModel](gtktreemodel#GtkTreeModel-struct) | |
| iter | the uninitialized [GtkTreeIter](gtktreemodel#GtkTreeIter-struct). | [out] |
| path | the [GtkTreePath](gtktreemodel#GtkTreePath-struct) | |
#### Returns
`TRUE`, if *`iter`* was set
### gtk\_tree\_model\_get\_iter\_from\_string ()
```
gboolean
gtk_tree_model_get_iter_from_string (*`[GtkTreeModel](gtktreemodel#GtkTreeModel-struct) *tree_model`*,
*`[GtkTreeIter](gtktreemodel#GtkTreeIter-struct) *iter`*,
*`const char *path_string`*);
```
Sets *`iter`* to a valid iterator pointing to *`path_string`* , if it exists. Otherwise, *`iter`* is left invalid and `FALSE` is returned.
#### Parameters
| | | |
| --- | --- | --- |
| tree\_model | a [GtkTreeModel](gtktreemodel#GtkTreeModel-struct) | |
| iter | an uninitialized [GtkTreeIter](gtktreemodel#GtkTreeIter-struct). | [out] |
| path\_string | a string representation of a [GtkTreePath](gtktreemodel#GtkTreePath-struct) | |
#### Returns
`TRUE`, if *`iter`* was set
### gtk\_tree\_model\_get\_iter\_first ()
```
gboolean
gtk_tree_model_get_iter_first (*`[GtkTreeModel](gtktreemodel#GtkTreeModel-struct) *tree_model`*,
*`[GtkTreeIter](gtktreemodel#GtkTreeIter-struct) *iter`*);
```
Initializes *`iter`* with the first iterator in the tree (the one at the path "0") and returns `TRUE`. Returns `FALSE` if the tree is empty.
#### Parameters
| | | |
| --- | --- | --- |
| tree\_model | a [GtkTreeModel](gtktreemodel#GtkTreeModel-struct) | |
| iter | the uninitialized [GtkTreeIter](gtktreemodel#GtkTreeIter-struct). | [out] |
#### Returns
`TRUE`, if *`iter`* was set
### gtk\_tree\_model\_get\_path ()
```
[GtkTreePath](gtktreemodel#GtkTreePath-struct) *
gtk_tree_model_get_path (*`[GtkTreeModel](gtktreemodel#GtkTreeModel-struct) *tree_model`*,
*`[GtkTreeIter](gtktreemodel#GtkTreeIter-struct) *iter`*);
```
Returns a newly-created [GtkTreePath](gtktreemodel#GtkTreePath-struct) referenced by *`iter`* .
This path should be freed with [`gtk_tree_path_free()`](gtktreemodel#gtk-tree-path-free).
#### Parameters
| | | |
| --- | --- | --- |
| tree\_model | a [GtkTreeModel](gtktreemodel#GtkTreeModel-struct) | |
| iter | the [GtkTreeIter](gtktreemodel#GtkTreeIter-struct) | |
#### Returns
a newly-created [GtkTreePath](gtktreemodel#GtkTreePath-struct)
### gtk\_tree\_model\_get\_value ()
```
void
gtk_tree_model_get_value (*`[GtkTreeModel](gtktreemodel#GtkTreeModel-struct) *tree_model`*,
*`[GtkTreeIter](gtktreemodel#GtkTreeIter-struct) *iter`*,
*`int column`*,
*`GValue *value`*);
```
Initializes and sets *`value`* to that at *`column`* .
When done with *`value`* , `g_value_unset()` needs to be called to free any allocated memory.
#### Parameters
| | | |
| --- | --- | --- |
| tree\_model | a [GtkTreeModel](gtktreemodel#GtkTreeModel-struct) | |
| iter | the [GtkTreeIter](gtktreemodel#GtkTreeIter-struct) | |
| column | the column to lookup the value at | |
| value | an empty GValue to set. | [out][transfer none] |
### gtk\_tree\_model\_iter\_next ()
```
gboolean
gtk_tree_model_iter_next (*`[GtkTreeModel](gtktreemodel#GtkTreeModel-struct) *tree_model`*,
*`[GtkTreeIter](gtktreemodel#GtkTreeIter-struct) *iter`*);
```
Sets *`iter`* to point to the node following it at the current level.
If there is no next *`iter`* , `FALSE` is returned and *`iter`* is set to be invalid.
#### Parameters
| | | |
| --- | --- | --- |
| tree\_model | a [GtkTreeModel](gtktreemodel#GtkTreeModel-struct) | |
| iter | the [GtkTreeIter](gtktreemodel#GtkTreeIter-struct). | [in] |
#### Returns
`TRUE` if *`iter`* has been changed to the next node
### gtk\_tree\_model\_iter\_previous ()
```
gboolean
gtk_tree_model_iter_previous (*`[GtkTreeModel](gtktreemodel#GtkTreeModel-struct) *tree_model`*,
*`[GtkTreeIter](gtktreemodel#GtkTreeIter-struct) *iter`*);
```
Sets *`iter`* to point to the previous node at the current level.
If there is no previous *`iter`* , `FALSE` is returned and *`iter`* is set to be invalid.
#### Parameters
| | | |
| --- | --- | --- |
| tree\_model | a [GtkTreeModel](gtktreemodel#GtkTreeModel-struct) | |
| iter | the [GtkTreeIter](gtktreemodel#GtkTreeIter-struct). | [in] |
#### Returns
`TRUE` if *`iter`* has been changed to the previous node
### gtk\_tree\_model\_iter\_children ()
```
gboolean
gtk_tree_model_iter_children (*`[GtkTreeModel](gtktreemodel#GtkTreeModel-struct) *tree_model`*,
*`[GtkTreeIter](gtktreemodel#GtkTreeIter-struct) *iter`*,
*`[GtkTreeIter](gtktreemodel#GtkTreeIter-struct) *parent`*);
```
Sets *`iter`* to point to the first child of *`parent`* .
If *`parent`* has no children, `FALSE` is returned and *`iter`* is set to be invalid. *`parent`* will remain a valid node after this function has been called.
If *`parent`* is `NULL` returns the first node, equivalent to `gtk_tree_model_get_iter_first (tree_model, iter);`
#### Parameters
| | | |
| --- | --- | --- |
| tree\_model | a [GtkTreeModel](gtktreemodel#GtkTreeModel-struct) | |
| iter | the new [GtkTreeIter](gtktreemodel#GtkTreeIter-struct) to be set to the child. | [out] |
| parent | the [GtkTreeIter](gtktreemodel#GtkTreeIter-struct), or `NULL`. | [allow-none] |
#### Returns
`TRUE`, if *`iter`* has been set to the first child
### gtk\_tree\_model\_iter\_has\_child ()
```
gboolean
gtk_tree_model_iter_has_child (*`[GtkTreeModel](gtktreemodel#GtkTreeModel-struct) *tree_model`*,
*`[GtkTreeIter](gtktreemodel#GtkTreeIter-struct) *iter`*);
```
Returns `TRUE` if *`iter`* has children, `FALSE` otherwise.
#### Parameters
| | | |
| --- | --- | --- |
| tree\_model | a [GtkTreeModel](gtktreemodel#GtkTreeModel-struct) | |
| iter | the [GtkTreeIter](gtktreemodel#GtkTreeIter-struct) to test for children | |
#### Returns
`TRUE` if *`iter`* has children
### gtk\_tree\_model\_iter\_n\_children ()
```
int
gtk_tree_model_iter_n_children (*`[GtkTreeModel](gtktreemodel#GtkTreeModel-struct) *tree_model`*,
*`[GtkTreeIter](gtktreemodel#GtkTreeIter-struct) *iter`*);
```
Returns the number of children that *`iter`* has.
As a special case, if *`iter`* is `NULL`, then the number of toplevel nodes is returned.
#### Parameters
| | | |
| --- | --- | --- |
| tree\_model | a [GtkTreeModel](gtktreemodel#GtkTreeModel-struct) | |
| iter | the [GtkTreeIter](gtktreemodel#GtkTreeIter-struct), or `NULL`. | [allow-none] |
#### Returns
the number of children of *`iter`*
### gtk\_tree\_model\_iter\_nth\_child ()
```
gboolean
gtk_tree_model_iter_nth_child (*`[GtkTreeModel](gtktreemodel#GtkTreeModel-struct) *tree_model`*,
*`[GtkTreeIter](gtktreemodel#GtkTreeIter-struct) *iter`*,
*`[GtkTreeIter](gtktreemodel#GtkTreeIter-struct) *parent`*,
*`int n`*);
```
Sets *`iter`* to be the child of *`parent`* , using the given index.
The first index is 0. If *`n`* is too big, or *`parent`* has no children, *`iter`* is set to an invalid iterator and `FALSE` is returned. *`parent`* will remain a valid node after this function has been called. As a special case, if *`parent`* is `NULL`, then the *`n`* -th root node is set.
#### Parameters
| | | |
| --- | --- | --- |
| tree\_model | a [GtkTreeModel](gtktreemodel#GtkTreeModel-struct) | |
| iter | the [GtkTreeIter](gtktreemodel#GtkTreeIter-struct) to set to the nth child. | [out] |
| parent | the [GtkTreeIter](gtktreemodel#GtkTreeIter-struct) to get the child from, or `NULL`. | [allow-none] |
| n | the index of the desired child | |
#### Returns
`TRUE`, if *`parent`* has an *`n`* -th child
### gtk\_tree\_model\_iter\_parent ()
```
gboolean
gtk_tree_model_iter_parent (*`[GtkTreeModel](gtktreemodel#GtkTreeModel-struct) *tree_model`*,
*`[GtkTreeIter](gtktreemodel#GtkTreeIter-struct) *iter`*,
*`[GtkTreeIter](gtktreemodel#GtkTreeIter-struct) *child`*);
```
Sets *`iter`* to be the parent of *`child`* .
If *`child`* is at the toplevel, and doesn’t have a parent, then *`iter`* is set to an invalid iterator and `FALSE` is returned. *`child`* will remain a valid node after this function has been called.
*`iter`* will be initialized before the lookup is performed, so *`child`* and *`iter`* cannot point to the same memory location.
#### Parameters
| | | |
| --- | --- | --- |
| tree\_model | a [GtkTreeModel](gtktreemodel#GtkTreeModel-struct) | |
| iter | the new [GtkTreeIter](gtktreemodel#GtkTreeIter-struct) to set to the parent. | [out] |
| child | the [GtkTreeIter](gtktreemodel#GtkTreeIter-struct) | |
#### Returns
`TRUE`, if *`iter`* is set to the parent of *`child`*
### gtk\_tree\_model\_get\_string\_from\_iter ()
```
char *
gtk_tree_model_get_string_from_iter (*`[GtkTreeModel](gtktreemodel#GtkTreeModel-struct) *tree_model`*,
*`[GtkTreeIter](gtktreemodel#GtkTreeIter-struct) *iter`*);
```
Generates a string representation of the iter.
This string is a “:” separated list of numbers. For example, “4:10:0:3” would be an acceptable return value for this string.
#### Parameters
| | | |
| --- | --- | --- |
| tree\_model | a [GtkTreeModel](gtktreemodel#GtkTreeModel-struct) | |
| iter | a [GtkTreeIter](gtktreemodel#GtkTreeIter-struct) | |
#### Returns
a newly-allocated string. Must be freed with `g_free()`.
[nullable]
### gtk\_tree\_model\_ref\_node ()
```
void
gtk_tree_model_ref_node (*`[GtkTreeModel](gtktreemodel#GtkTreeModel-struct) *tree_model`*,
*`[GtkTreeIter](gtktreemodel#GtkTreeIter-struct) *iter`*);
```
Lets the tree ref the node.
This is an optional method for models to implement. To be more specific, models may ignore this call as it exists primarily for performance reasons.
This function is primarily meant as a way for views to let caching models know when nodes are being displayed (and hence, whether or not to cache that node). Being displayed means a node is in an expanded branch, regardless of whether the node is currently visible in the viewport. For example, a file-system based model would not want to keep the entire file-hierarchy in memory, just the sections that are currently being displayed by every current view.
A model should be expected to be able to get an iter independent of its reffed state.
#### Parameters
| | | |
| --- | --- | --- |
| tree\_model | a [GtkTreeModel](gtktreemodel#GtkTreeModel-struct) | |
| iter | the [GtkTreeIter](gtktreemodel#GtkTreeIter-struct) | |
### gtk\_tree\_model\_unref\_node ()
```
void
gtk_tree_model_unref_node (*`[GtkTreeModel](gtktreemodel#GtkTreeModel-struct) *tree_model`*,
*`[GtkTreeIter](gtktreemodel#GtkTreeIter-struct) *iter`*);
```
Lets the tree unref the node.
This is an optional method for models to implement. To be more specific, models may ignore this call as it exists primarily for performance reasons. For more information on what this means, see [`gtk_tree_model_ref_node()`](gtktreemodel#gtk-tree-model-ref-node).
Please note that nodes that are deleted are not unreffed.
#### Parameters
| | | |
| --- | --- | --- |
| tree\_model | a [GtkTreeModel](gtktreemodel#GtkTreeModel-struct) | |
| iter | the [GtkTreeIter](gtktreemodel#GtkTreeIter-struct) | |
### gtk\_tree\_model\_get ()
```
void
gtk_tree_model_get (*`[GtkTreeModel](gtktreemodel#GtkTreeModel-struct) *tree_model`*,
*`[GtkTreeIter](gtktreemodel#GtkTreeIter-struct) *iter`*,
*`...`*);
```
Gets the value of one or more cells in the row referenced by *`iter`* . The variable argument list should contain integer column numbers, each column number followed by a place to store the value being retrieved. The list is terminated by a -1. For example, to get a value from column 0 with type `G_TYPE_STRING`, you would write: `gtk_tree_model_get (model, iter, 0, &place_string_here, -1)`, where `place_string_here` is a gchararray to be filled with the string.
Returned values with type `G_TYPE_OBJECT` have to be unreferenced, values with type `G_TYPE_STRING` or `G_TYPE_BOXED` have to be freed. Other values are passed by value.
#### Parameters
| | | |
| --- | --- | --- |
| tree\_model | a [GtkTreeModel](gtktreemodel#GtkTreeModel-struct) | |
| iter | a row in *`tree_model`* | |
| ... | pairs of column number and value return locations, terminated by -1 | |
### gtk\_tree\_model\_get\_valist ()
```
void
gtk_tree_model_get_valist (*`[GtkTreeModel](gtktreemodel#GtkTreeModel-struct) *tree_model`*,
*`[GtkTreeIter](gtktreemodel#GtkTreeIter-struct) *iter`*,
*`va\_list var_args`*);
```
See [`gtk_tree_model_get()`](gtktreemodel#gtk-tree-model-get), this version takes a va\_list for language bindings to use.
#### Parameters
| | | |
| --- | --- | --- |
| tree\_model | a [GtkTreeModel](gtktreemodel#GtkTreeModel-struct) | |
| iter | a row in *`tree_model`* | |
| var\_args | va\_list of column/return location pairs | |
### gtk\_tree\_model\_foreach ()
```
void
gtk_tree_model_foreach (*`[GtkTreeModel](gtktreemodel#GtkTreeModel-struct) *model`*,
*`[GtkTreeModelForeachFunc](gtktreemodel#GtkTreeModelForeachFunc) func`*,
*`gpointer user_data`*);
```
Calls func on each node in model in a depth-first fashion.
If *`func`* returns `TRUE`, then the tree ceases to be walked, and [`gtk_tree_model_foreach()`](gtktreemodel#gtk-tree-model-foreach) returns.
#### Parameters
| | | |
| --- | --- | --- |
| model | a [GtkTreeModel](gtktreemodel#GtkTreeModel-struct) | |
| func | a function to be called on each row. | [scope call] |
| user\_data | user data to passed to *`func`* . | [closure] |
### gtk\_tree\_model\_row\_changed ()
```
void
gtk_tree_model_row_changed (*`[GtkTreeModel](gtktreemodel#GtkTreeModel-struct) *tree_model`*,
*`[GtkTreePath](gtktreemodel#GtkTreePath-struct) *path`*,
*`[GtkTreeIter](gtktreemodel#GtkTreeIter-struct) *iter`*);
```
Emits the [“row-changed”](gtktreemodel#GtkTreeModel-row-changed) signal on *`tree_model`* .
#### Parameters
| | | |
| --- | --- | --- |
| tree\_model | a [GtkTreeModel](gtktreemodel#GtkTreeModel-struct) | |
| path | a [GtkTreePath](gtktreemodel#GtkTreePath-struct) pointing to the changed row | |
| iter | a valid [GtkTreeIter](gtktreemodel#GtkTreeIter-struct) pointing to the changed row | |
### gtk\_tree\_model\_row\_inserted ()
```
void
gtk_tree_model_row_inserted (*`[GtkTreeModel](gtktreemodel#GtkTreeModel-struct) *tree_model`*,
*`[GtkTreePath](gtktreemodel#GtkTreePath-struct) *path`*,
*`[GtkTreeIter](gtktreemodel#GtkTreeIter-struct) *iter`*);
```
Emits the [“row-inserted”](gtktreemodel#GtkTreeModel-row-inserted) signal on *`tree_model`* .
#### Parameters
| | | |
| --- | --- | --- |
| tree\_model | a [GtkTreeModel](gtktreemodel#GtkTreeModel-struct) | |
| path | a [GtkTreePath](gtktreemodel#GtkTreePath-struct) pointing to the inserted row | |
| iter | a valid [GtkTreeIter](gtktreemodel#GtkTreeIter-struct) pointing to the inserted row | |
### gtk\_tree\_model\_row\_has\_child\_toggled ()
```
void
gtk_tree_model_row_has_child_toggled (*`[GtkTreeModel](gtktreemodel#GtkTreeModel-struct) *tree_model`*,
*`[GtkTreePath](gtktreemodel#GtkTreePath-struct) *path`*,
*`[GtkTreeIter](gtktreemodel#GtkTreeIter-struct) *iter`*);
```
Emits the [“row-has-child-toggled”](gtktreemodel#GtkTreeModel-row-has-child-toggled) signal on *`tree_model`* . This should be called by models after the child state of a node changes.
#### Parameters
| | | |
| --- | --- | --- |
| tree\_model | a [GtkTreeModel](gtktreemodel#GtkTreeModel-struct) | |
| path | a [GtkTreePath](gtktreemodel#GtkTreePath-struct) pointing to the changed row | |
| iter | a valid [GtkTreeIter](gtktreemodel#GtkTreeIter-struct) pointing to the changed row | |
### gtk\_tree\_model\_row\_deleted ()
```
void
gtk_tree_model_row_deleted (*`[GtkTreeModel](gtktreemodel#GtkTreeModel-struct) *tree_model`*,
*`[GtkTreePath](gtktreemodel#GtkTreePath-struct) *path`*);
```
Emits the [“row-deleted”](gtktreemodel#GtkTreeModel-row-deleted) signal on *`tree_model`* .
This should be called by models after a row has been removed. The location pointed to by *`path`* should be the location that the row previously was at. It may not be a valid location anymore.
Nodes that are deleted are not unreffed, this means that any outstanding references on the deleted node should not be released.
#### Parameters
| | | |
| --- | --- | --- |
| tree\_model | a [GtkTreeModel](gtktreemodel#GtkTreeModel-struct) | |
| path | a [GtkTreePath](gtktreemodel#GtkTreePath-struct) pointing to the previous location of the deleted row | |
### gtk\_tree\_model\_rows\_reordered ()
```
void
gtk_tree_model_rows_reordered (*`[GtkTreeModel](gtktreemodel#GtkTreeModel-struct) *tree_model`*,
*`[GtkTreePath](gtktreemodel#GtkTreePath-struct) *path`*,
*`[GtkTreeIter](gtktreemodel#GtkTreeIter-struct) *iter`*,
*`int *new_order`*);
```
Emits the [“rows-reordered”](gtktreemodel#GtkTreeModel-rows-reordered) signal on *`tree_model`* .
This should be called by models when their rows have been reordered.
[skip]
#### Parameters
| | | |
| --- | --- | --- |
| tree\_model | a [GtkTreeModel](gtktreemodel#GtkTreeModel-struct) | |
| path | a [GtkTreePath](gtktreemodel#GtkTreePath-struct) pointing to the tree node whose children have been reordered | |
| iter | a valid [GtkTreeIter](gtktreemodel#GtkTreeIter-struct) pointing to the node whose children have been reordered, or `NULL` if the depth of *`path`* is 0 | |
| new\_order | an array of integers mapping the current position of each child to its old position before the re-ordering, i.e. *`new_order`* `[newpos] = oldpos` | |
### gtk\_tree\_model\_rows\_reordered\_with\_length ()
```
void
gtk_tree_model_rows_reordered_with_length
(*`[GtkTreeModel](gtktreemodel#GtkTreeModel-struct) *tree_model`*,
*`[GtkTreePath](gtktreemodel#GtkTreePath-struct) *path`*,
*`[GtkTreeIter](gtktreemodel#GtkTreeIter-struct) *iter`*,
*`int *new_order`*,
*`int length`*);
```
Emits the [“rows-reordered”](gtktreemodel#GtkTreeModel-rows-reordered) signal on *`tree_model`* .
This should be called by models when their rows have been reordered.
[rename-to gtk\_tree\_model\_rows\_reordered]
#### Parameters
| | | |
| --- | --- | --- |
| tree\_model | a [GtkTreeModel](gtktreemodel#GtkTreeModel-struct) | |
| path | a [GtkTreePath](gtktreemodel#GtkTreePath-struct) pointing to the tree node whose children have been reordered | |
| iter | a valid [GtkTreeIter](gtktreemodel#GtkTreeIter-struct) pointing to the node whose children have been reordered, or `NULL` if the depth of *`path`* is 0. | [allow-none] |
| new\_order | an array of integers mapping the current position of each child to its old position before the re-ordering, i.e. *`new_order`* `[newpos] = oldpos`. | [array length=length] |
| length | length of *`new_order`* array | |
Types and Values
----------------
### GtkTreeModel
```
typedef struct _GtkTreeModel GtkTreeModel;
```
### struct GtkTreeIter
```
struct GtkTreeIter {
int stamp;
gpointer user_data;
gpointer user_data2;
gpointer user_data3;
};
```
The [GtkTreeIter](gtktreemodel#GtkTreeIter-struct) is the primary structure for accessing a [GtkTreeModel](gtktreemodel#GtkTreeModel-struct). Models are expected to put a unique integer in the *`stamp`* member, and put model-specific data in the three *`user_data`* members.
#### Members
| | | |
| --- | --- | --- |
| int *`stamp`*; | a unique stamp to catch invalid iterators | |
| gpointer *`user_data`*; | model-specific data | |
| gpointer *`user_data2`*; | model-specific data | |
| gpointer *`user_data3`*; | model-specific data | |
### GtkTreePath
```
typedef struct _GtkTreePath GtkTreePath;
```
### GtkTreeRowReference
```
typedef struct _GtkTreeRowReference GtkTreeRowReference;
```
A GtkTreeRowReference tracks model changes so that it always refers to the same row (a [GtkTreePath](gtktreemodel#GtkTreePath-struct) refers to a position, not a fixed row). Create a new GtkTreeRowReference with [`gtk_tree_row_reference_new()`](gtktreemodel#gtk-tree-row-reference-new).
### struct GtkTreeModelIface
```
struct GtkTreeModelIface {
/* Signals */
void (* row_changed) (GtkTreeModel *tree_model,
GtkTreePath *path,
GtkTreeIter *iter);
void (* row_inserted) (GtkTreeModel *tree_model,
GtkTreePath *path,
GtkTreeIter *iter);
void (* row_has_child_toggled) (GtkTreeModel *tree_model,
GtkTreePath *path,
GtkTreeIter *iter);
void (* row_deleted) (GtkTreeModel *tree_model,
GtkTreePath *path);
void (* rows_reordered) (GtkTreeModel *tree_model,
GtkTreePath *path,
GtkTreeIter *iter,
int *new_order);
/* Virtual Table */
GtkTreeModelFlags (* get_flags) (GtkTreeModel *tree_model);
int (* get_n_columns) (GtkTreeModel *tree_model);
GType (* get_column_type) (GtkTreeModel *tree_model,
int index_);
gboolean (* get_iter) (GtkTreeModel *tree_model,
GtkTreeIter *iter,
GtkTreePath *path);
GtkTreePath *(* get_path) (GtkTreeModel *tree_model,
GtkTreeIter *iter);
void (* get_value) (GtkTreeModel *tree_model,
GtkTreeIter *iter,
int column,
GValue *value);
gboolean (* iter_next) (GtkTreeModel *tree_model,
GtkTreeIter *iter);
gboolean (* iter_previous) (GtkTreeModel *tree_model,
GtkTreeIter *iter);
gboolean (* iter_children) (GtkTreeModel *tree_model,
GtkTreeIter *iter,
GtkTreeIter *parent);
gboolean (* iter_has_child) (GtkTreeModel *tree_model,
GtkTreeIter *iter);
int (* iter_n_children) (GtkTreeModel *tree_model,
GtkTreeIter *iter);
gboolean (* iter_nth_child) (GtkTreeModel *tree_model,
GtkTreeIter *iter,
GtkTreeIter *parent,
int n);
gboolean (* iter_parent) (GtkTreeModel *tree_model,
GtkTreeIter *iter,
GtkTreeIter *child);
void (* ref_node) (GtkTreeModel *tree_model,
GtkTreeIter *iter);
void (* unref_node) (GtkTreeModel *tree_model,
GtkTreeIter *iter);
};
```
#### Members
| | | |
| --- | --- | --- |
| *`row_changed`* () | Signal emitted when a row in the model has changed. | |
| *`row_inserted`* () | Signal emitted when a new row has been inserted in the model. | |
| *`row_has_child_toggled`* () | Signal emitted when a row has gotten the first child row or lost its last child row. | |
| *`row_deleted`* () | Signal emitted when a row has been deleted. | |
| *`rows_reordered`* () | Signal emitted when the children of a node in the GtkTreeModel have been reordered. | |
| *`get_flags`* () | Get [GtkTreeModelFlags](gtktreemodel#GtkTreeModelFlags) supported by this interface. | |
| *`get_n_columns`* () | Get the number of columns supported by the model. | |
| *`get_column_type`* () | Get the type of the column. | |
| *`get_iter`* () | Sets iter to a valid iterator pointing to path. | |
| *`get_path`* () | Gets a newly-created [GtkTreePath](gtktreemodel#GtkTreePath-struct) referenced by iter. | |
| *`get_value`* () | Initializes and sets value to that at column. | |
| *`iter_next`* () | Sets iter to point to the node following it at the current level. | |
| *`iter_previous`* () | Sets iter to point to the previous node at the current level. | |
| *`iter_children`* () | Sets iter to point to the first child of parent. | |
| *`iter_has_child`* () | `TRUE` if iter has children, `FALSE` otherwise. | |
| *`iter_n_children`* () | Gets the number of children that iter has. | |
| *`iter_nth_child`* () | Sets iter to be the child of parent, using the given index. | |
| *`iter_parent`* () | Sets iter to be the parent of child. | |
| *`ref_node`* () | Lets the tree ref the node. | |
| *`unref_node`* () | Lets the tree unref the node. | |
### enum GtkTreeModelFlags
These flags indicate various properties of a [GtkTreeModel](gtktreemodel#GtkTreeModel-struct).
They are returned by [`gtk_tree_model_get_flags()`](gtktreemodel#gtk-tree-model-get-flags), and must be static for the lifetime of the object. A more complete description of [GTK\_TREE\_MODEL\_ITERS\_PERSIST](gtktreemodel#GTK-TREE-MODEL-ITERS-PERSIST:CAPS) can be found in the overview of this section.
#### Members
| | | |
| --- | --- | --- |
| GTK\_TREE\_MODEL\_ITERS\_PERSIST | iterators survive all signals emitted by the tree | |
| GTK\_TREE\_MODEL\_LIST\_ONLY | the model is a list only, and never has children | |
Signal Details
--------------
### The `“row-changed”` signal
```
void
user_function ([GtkTreeModel](gtktreemodel#GtkTreeModel-struct) *tree_model,
[GtkTreePath](gtktreemodel#GtkTreePath-struct) *path,
[GtkTreeIter](gtktreemodel#GtkTreeIter-struct) *iter,
gpointer user_data)
```
This signal is emitted when a row in the model has changed.
#### Parameters
| | | |
| --- | --- | --- |
| tree\_model | the [GtkTreeModel](gtktreemodel#GtkTreeModel-struct) on which the signal is emitted | |
| path | a [GtkTreePath](gtktreemodel#GtkTreePath-struct) identifying the changed row | |
| iter | a valid [GtkTreeIter](gtktreemodel#GtkTreeIter-struct) pointing to the changed row | |
| user\_data | user data set when the signal handler was connected. | |
Flags: Run Last
### The `“row-deleted”` signal
```
void
user_function ([GtkTreeModel](gtktreemodel#GtkTreeModel-struct) *tree_model,
[GtkTreePath](gtktreemodel#GtkTreePath-struct) *path,
gpointer user_data)
```
This signal is emitted when a row has been deleted.
Note that no iterator is passed to the signal handler, since the row is already deleted.
This should be called by models after a row has been removed. The location pointed to by *`path`* should be the location that the row previously was at. It may not be a valid location anymore.
#### Parameters
| | | |
| --- | --- | --- |
| tree\_model | the [GtkTreeModel](gtktreemodel#GtkTreeModel-struct) on which the signal is emitted | |
| path | a [GtkTreePath](gtktreemodel#GtkTreePath-struct) identifying the row | |
| user\_data | user data set when the signal handler was connected. | |
Flags: Run First
### The `“row-has-child-toggled”` signal
```
void
user_function ([GtkTreeModel](gtktreemodel#GtkTreeModel-struct) *tree_model,
[GtkTreePath](gtktreemodel#GtkTreePath-struct) *path,
[GtkTreeIter](gtktreemodel#GtkTreeIter-struct) *iter,
gpointer user_data)
```
This signal is emitted when a row has gotten the first child row or lost its last child row.
#### Parameters
| | | |
| --- | --- | --- |
| tree\_model | the [GtkTreeModel](gtktreemodel#GtkTreeModel-struct) on which the signal is emitted | |
| path | a [GtkTreePath](gtktreemodel#GtkTreePath-struct) identifying the row | |
| iter | a valid [GtkTreeIter](gtktreemodel#GtkTreeIter-struct) pointing to the row | |
| user\_data | user data set when the signal handler was connected. | |
Flags: Run Last
### The `“row-inserted”` signal
```
void
user_function ([GtkTreeModel](gtktreemodel#GtkTreeModel-struct) *tree_model,
[GtkTreePath](gtktreemodel#GtkTreePath-struct) *path,
[GtkTreeIter](gtktreemodel#GtkTreeIter-struct) *iter,
gpointer user_data)
```
This signal is emitted when a new row has been inserted in the model.
Note that the row may still be empty at this point, since it is a common pattern to first insert an empty row, and then fill it with the desired values.
#### Parameters
| | | |
| --- | --- | --- |
| tree\_model | the [GtkTreeModel](gtktreemodel#GtkTreeModel-struct) on which the signal is emitted | |
| path | a [GtkTreePath](gtktreemodel#GtkTreePath-struct) identifying the new row | |
| iter | a valid [GtkTreeIter](gtktreemodel#GtkTreeIter-struct) pointing to the new row | |
| user\_data | user data set when the signal handler was connected. | |
Flags: Run First
### The `“rows-reordered”` signal
```
void
user_function ([GtkTreeModel](gtktreemodel#GtkTreeModel-struct) *tree_model,
[GtkTreePath](gtktreemodel#GtkTreePath-struct) *path,
[GtkTreeIter](gtktreemodel#GtkTreeIter-struct) *iter,
gpointer new_order,
gpointer user_data)
```
This signal is emitted when the children of a node in the [GtkTreeModel](gtktreemodel#GtkTreeModel-struct) have been reordered.
Note that this signal is not emitted when rows are reordered by DND, since this is implemented by removing and then reinserting the row.
[skip]
#### Parameters
| | | |
| --- | --- | --- |
| tree\_model | the [GtkTreeModel](gtktreemodel#GtkTreeModel-struct) on which the signal is emitted | |
| path | a [GtkTreePath](gtktreemodel#GtkTreePath-struct) identifying the tree node whose children have been reordered | |
| iter | a valid [GtkTreeIter](gtktreemodel#GtkTreeIter-struct) pointing to the node whose children have been reordered, or `NULL` if the depth of *`path`* is 0 | |
| new\_order | an array of integers mapping the current position of each child to its old position before the re-ordering, i.e. *`new_order`* `[newpos] = oldpos` | |
| user\_data | user data set when the signal handler was connected. | |
Flags: Run First
See Also
--------
[GtkTreeView](gtktreeview#GtkTreeView-struct), [GtkTreeStore](gtktreestore#GtkTreeStore-struct), [GtkListStore](gtkliststore#GtkListStore-struct), GtkTreeView drag-and-drop [GtkTreeSortable](gtktreesortable#GtkTreeSortable-struct)
| programming_docs |
gtk CSS in GTK CSS in GTK
==========
[CSS nodes](css#id-1.6.2.4) [The CSS nodes of a GtkScale](css#id-1.6.2.4.4) [Selectors](ch38s02) [GTK CSS Selectors](ch38s02#id-1.6.2.5.4) This chapter describes how GTK uses CSS for styling and layout. It is not meant to be an explanation of CSS from first principles, but focuses on listing supported CSS features and differences between Web CSS and GTK.
There is plenty of introductory documentation available that can be used to learn about CSS in general. In the tables below we include links to the official specs that can be used to look up the definition of individual selectors and properties.
GTK applies the style information found in style sheets by matching the selectors against a tree of nodes. Each node in the tree has a name, a state and possibly style classes. The children of each node are linearly ordered.
Every widget has one or more of these CSS nodes, and determines their name, state, style classes and how they are laid out as children and siblings in the overall node tree. The documentation for each widget explains what CSS nodes it has.
### The CSS nodes of a GtkScale
```
scale[.fine-tune]
├── marks.top
│ ├── mark
┊ ┊
│ ╰── mark
├── trough
│ ├── slider
│ ├── [highlight]
│ ╰── [fill]
╰── marks.bottom
├── mark
┊
╰── mark
```
gtk GtkCellRendererCombo GtkCellRendererCombo
====================
GtkCellRendererCombo — Renders a combobox in a cell
Functions
---------
| | |
| --- | --- |
| [GtkCellRenderer](gtkcellrenderer#GtkCellRenderer-struct) \* | [gtk\_cell\_renderer\_combo\_new](gtkcellrenderercombo#gtk-cell-renderer-combo-new) () |
Properties
----------
| | | |
| --- | --- | --- |
| gboolean | [has-entry](gtkcellrenderercombo#GtkCellRendererCombo--has-entry) | Read / Write |
| [GtkTreeModel](gtktreemodel#GtkTreeModel-struct) \* | [model](gtkcellrenderercombo#GtkCellRendererCombo--model) | Read / Write |
| int | [text-column](gtkcellrenderercombo#GtkCellRendererCombo--text-column) | Read / Write |
Signals
-------
| | | |
| --- | --- | --- |
| void | [changed](gtkcellrenderercombo#GtkCellRendererCombo-changed) | Run Last |
Types and Values
----------------
| | |
| --- | --- |
| | [GtkCellRendererCombo](gtkcellrenderercombo#GtkCellRendererCombo-struct) |
Object Hierarchy
----------------
```
GObject
╰── GInitiallyUnowned
╰── [GtkCellRenderer](gtkcellrenderer#GtkCellRenderer-struct)
╰── [GtkCellRendererText](gtkcellrenderertext#GtkCellRendererText-struct)
╰── GtkCellRendererCombo
```
Includes
--------
```
#include <gtk/gtk.h>
```
Description
-----------
[GtkCellRendererCombo](gtkcellrenderercombo#GtkCellRendererCombo-struct) renders text in a cell like [GtkCellRendererText](gtkcellrenderertext#GtkCellRendererText-struct) from which it is derived. But while [GtkCellRendererText](gtkcellrenderertext#GtkCellRendererText-struct) offers a simple entry to edit the text, [GtkCellRendererCombo](gtkcellrenderercombo#GtkCellRendererCombo-struct) offers a [GtkComboBox](gtkcombobox#GtkComboBox-struct) widget to edit the text. The values to display in the combo box are taken from the tree model specified in the [“model”](gtkcellrenderercombo#GtkCellRendererCombo--model) property.
The combo cell renderer takes care of adding a text cell renderer to the combo box and sets it to display the column specified by its [“text-column”](gtkcellrenderercombo#GtkCellRendererCombo--text-column) property. Further properties of the combo box can be set in a handler for the [“editing-started”](gtkcellrenderer#GtkCellRenderer-editing-started) signal.
Functions
---------
### gtk\_cell\_renderer\_combo\_new ()
```
[GtkCellRenderer](gtkcellrenderer#GtkCellRenderer-struct) *
gtk_cell_renderer_combo_new (*`void`*);
```
Creates a new [GtkCellRendererCombo](gtkcellrenderercombo#GtkCellRendererCombo-struct). Adjust how text is drawn using object properties. Object properties can be set globally (with `g_object_set()`). Also, with [GtkTreeViewColumn](gtktreeviewcolumn#GtkTreeViewColumn-struct), you can bind a property to a value in a [GtkTreeModel](gtktreemodel#GtkTreeModel-struct). For example, you can bind the “text” property on the cell renderer to a string value in the model, thus rendering a different string in each row of the [GtkTreeView](gtktreeview#GtkTreeView-struct).
#### Returns
the new cell renderer
Types and Values
----------------
### GtkCellRendererCombo
```
typedef struct _GtkCellRendererCombo GtkCellRendererCombo;
```
Property Details
----------------
### The `“has-entry”` property
```
“has-entry” gboolean
```
If `TRUE`, the cell renderer will include an entry and allow to enter values other than the ones in the popup list.
Owner: GtkCellRendererCombo
Flags: Read / Write
Default value: TRUE
### The `“model”` property
```
“model” [GtkTreeModel](gtktreemodel#GtkTreeModel-struct) *
```
Holds a tree model containing the possible values for the combo box. Use the text\_column property to specify the column holding the values.
Owner: GtkCellRendererCombo
Flags: Read / Write
### The `“text-column”` property
```
“text-column” int
```
Specifies the model column which holds the possible values for the combo box.
Note that this refers to the model specified in the model property, not the model backing the tree view to which this cell renderer is attached.
[GtkCellRendererCombo](gtkcellrenderercombo#GtkCellRendererCombo-struct) automatically adds a text cell renderer for this column to its combo box.
Owner: GtkCellRendererCombo
Flags: Read / Write
Allowed values: >= -1
Default value: -1
Signal Details
--------------
### The `“changed”` signal
```
void
user_function ([GtkCellRendererCombo](gtkcellrenderercombo#GtkCellRendererCombo-struct) *combo,
char *path_string,
[GtkTreeIter](gtktreemodel#GtkTreeIter-struct) *new_iter,
gpointer user_data)
```
This signal is emitted each time after the user selected an item in the combo box, either by using the mouse or the arrow keys. Contrary to GtkComboBox, GtkCellRendererCombo::changed is not emitted for changes made to a selected item in the entry. The argument *`new_iter`* corresponds to the newly selected item in the combo box and it is relative to the GtkTreeModel set via the model property on GtkCellRendererCombo.
Note that as soon as you change the model displayed in the tree view, the tree view will immediately cease the editing operating. This means that you most probably want to refrain from changing the model until the combo cell renderer emits the edited or editing\_canceled signal.
#### Parameters
| | | |
| --- | --- | --- |
| combo | the object on which the signal is emitted | |
| path\_string | a string of the path identifying the edited cell (relative to the tree view model) | |
| new\_iter | the new iter selected in the combo box (relative to the combo box model) | |
| user\_data | user data set when the signal handler was connected. | |
Flags: Run Last
gtk Hierarchical drawing Hierarchical drawing
====================
During the Paint phase GTK receives a single [“render”](https://developer-old.gnome.org/gtk4/html/GdkSurface.html#GdkSurface-render) signal on the toplevel surface. The signal handler will create a snapshot object (which is a helper for creating a scene graph) and call the [GtkWidget](gtkwidget#GtkWidget-struct)::`snapshot()` vfunc, which will propagate down the widget hierarchy. This lets each widget snapshot its content at the right place and time, correctly handling things like partial transparencies and overlapping widgets.
During the snapshotting of each widget, GTK automatically handles the CSS rendering according to the CSS box model. It snapshots first the background, then the border, then the widget content itself, and finally the outline.
To avoid excessive work when generating scene graphs, GTK caches render nodes. Each widget keeps a reference to its render node (which in turn, will refer to the render nodes of children, and grandchildren, and so on), and will reuse that node during the Paint phase. Invalidating a widget (by calling [`gtk_widget_queue_draw()`](gtkwidget#gtk-widget-queue-draw)) discards the cached render node, forcing the widget to regenerate it the next time it needs to produce a snapshot.
gtk GtkPasswordEntry GtkPasswordEntry
================
GtkPasswordEntry — An entry for secrets
Functions
---------
| | |
| --- | --- |
| [GtkWidget](gtkwidget#GtkWidget-struct) \* | [gtk\_password\_entry\_new](gtkpasswordentry#gtk-password-entry-new) () |
| void | [gtk\_password\_entry\_set\_show\_peek\_icon](gtkpasswordentry#gtk-password-entry-set-show-peek-icon) () |
| gboolean | [gtk\_password\_entry\_get\_show\_peek\_icon](gtkpasswordentry#gtk-password-entry-get-show-peek-icon) () |
| void | [gtk\_password\_entry\_set\_extra\_menu](gtkpasswordentry#gtk-password-entry-set-extra-menu) () |
| GMenuModel \* | [gtk\_password\_entry\_get\_extra\_menu](gtkpasswordentry#gtk-password-entry-get-extra-menu) () |
Properties
----------
| | | |
| --- | --- | --- |
| gboolean | [activates-default](gtkpasswordentry#GtkPasswordEntry--activates-default) | Read / Write |
| GMenuModel \* | [extra-menu](gtkpasswordentry#GtkPasswordEntry--extra-menu) | Read / Write |
| char \* | [placeholder-text](gtkpasswordentry#GtkPasswordEntry--placeholder-text) | Read / Write |
| gboolean | [show-peek-icon](gtkpasswordentry#GtkPasswordEntry--show-peek-icon) | Read / Write |
Signals
-------
| | | |
| --- | --- | --- |
| void | [activate](gtkpasswordentry#GtkPasswordEntry-activate) | Action |
Types and Values
----------------
| | |
| --- | --- |
| | [GtkPasswordEntry](gtkpasswordentry#GtkPasswordEntry-struct) |
Object Hierarchy
----------------
```
GObject
╰── GInitiallyUnowned
╰── [GtkWidget](gtkwidget#GtkWidget-struct)
╰── GtkPasswordEntry
```
Implemented Interfaces
----------------------
GtkPasswordEntry implements [GtkAccessible](gtkaccessible#GtkAccessible-struct), [GtkBuildable](gtkbuildable#GtkBuildable-struct), [GtkConstraintTarget](gtkconstraint#GtkConstraintTarget-struct) and [GtkEditable](gtkeditable#GtkEditable-struct).
Includes
--------
```
#include <gtk/gtk.h>
```
Description
-----------
[GtkPasswordEntry](gtkpasswordentry#GtkPasswordEntry-struct) is entry that has been tailored for entering secrets. It does not show its contents in clear text, does not allow to copy it to the clipboard, and it shows a warning when Caps Lock is engaged. If the underlying platform allows it, GtkPasswordEntry will also place the text in a non-pageable memory area, to avoid it being written out to disk by the operating system.
Optionally, it can offer a way to reveal the contents in clear text.
GtkPasswordEntry provides only minimal API and should be used with the [GtkEditable](gtkeditable#GtkEditable-struct) API.
### CSS Nodes
```
entry.password
╰── text
├── image.caps-lock-indicator
┊
```
| GtkPasswordEntry has a single CSS node with name entry that carries a .passwordstyle class. The text Css node below it has a child with name image and style class .caps-lock-indicator for the Caps Lock icon, and possibly other children.
### Accessibility
GtkPasswordEntry uses the [GTK\_ACCESSIBLE\_ROLE\_TEXT\_BOX](gtkaccessible#GTK-ACCESSIBLE-ROLE-TEXT-BOX:CAPS) role.
Functions
---------
### gtk\_password\_entry\_new ()
```
[GtkWidget](gtkwidget#GtkWidget-struct) *
gtk_password_entry_new (*`void`*);
```
Creates a [GtkPasswordEntry](gtkpasswordentry#GtkPasswordEntry-struct).
#### Returns
a new [GtkPasswordEntry](gtkpasswordentry#GtkPasswordEntry-struct)
### gtk\_password\_entry\_set\_show\_peek\_icon ()
```
void
gtk_password_entry_set_show_peek_icon (*`[GtkPasswordEntry](gtkpasswordentry#GtkPasswordEntry-struct) *entry`*,
*`gboolean show_peek_icon`*);
```
Sets whether the entry should have a clickable icon to show the contents of the entry in clear text.
Setting this to `FALSE` also hides the text again.
#### Parameters
| | | |
| --- | --- | --- |
| entry | a [GtkPasswordEntry](gtkpasswordentry#GtkPasswordEntry-struct) | |
| show\_peek\_icon | whether to show the peek icon | |
### gtk\_password\_entry\_get\_show\_peek\_icon ()
```
gboolean
gtk_password_entry_get_show_peek_icon (*`[GtkPasswordEntry](gtkpasswordentry#GtkPasswordEntry-struct) *entry`*);
```
Returns whether the entry is showing a clickable icon to reveal the contents of the entry in clear text.
#### Parameters
| | | |
| --- | --- | --- |
| entry | a [GtkPasswordEntry](gtkpasswordentry#GtkPasswordEntry-struct) | |
#### Returns
`TRUE` if an icon is shown
### gtk\_password\_entry\_set\_extra\_menu ()
```
void
gtk_password_entry_set_extra_menu (*`[GtkPasswordEntry](gtkpasswordentry#GtkPasswordEntry-struct) *entry`*,
*`GMenuModel *model`*);
```
Sets a menu model to add when constructing the context menu for *`entry`* .
#### Parameters
| | | |
| --- | --- | --- |
| entry | a [GtkPasswordEntry](gtkpasswordentry#GtkPasswordEntry-struct) | |
| model | a GMenuModel. | [allow-none] |
### gtk\_password\_entry\_get\_extra\_menu ()
```
GMenuModel *
gtk_password_entry_get_extra_menu (*`[GtkPasswordEntry](gtkpasswordentry#GtkPasswordEntry-struct) *entry`*);
```
Gets the menu model set with [`gtk_password_entry_set_extra_menu()`](gtkpasswordentry#gtk-password-entry-set-extra-menu).
#### Parameters
| | | |
| --- | --- | --- |
| entry | a [GtkText](gtktext#GtkText-struct) | |
#### Returns
(nullable): the menu model.
[transfer none]
Types and Values
----------------
### GtkPasswordEntry
```
typedef struct _GtkPasswordEntry GtkPasswordEntry;
```
Property Details
----------------
### The `“activates-default”` property
```
“activates-default” gboolean
```
Whether to activate the default widget (such as the default button in a dialog) when Enter is pressed.
Owner: GtkPasswordEntry
Flags: Read / Write
Default value: FALSE
### The `“extra-menu”` property
```
“extra-menu” GMenuModel *
```
A menu model whose contents will be appended to the context menu.
Owner: GtkPasswordEntry
Flags: Read / Write
### The `“placeholder-text”` property
```
“placeholder-text” char *
```
Show text in the entry when it’s empty and unfocused.
Owner: GtkPasswordEntry
Flags: Read / Write
Default value: NULL
### The `“show-peek-icon”` property
```
“show-peek-icon” gboolean
```
Whether to show an icon for revealing the content.
Owner: GtkPasswordEntry
Flags: Read / Write
Default value: FALSE
Signal Details
--------------
### The `“activate”` signal
```
void
user_function ([GtkPasswordEntry](gtkpasswordentry#GtkPasswordEntry-struct) *passwordentry,
gpointer user_data)
```
Flags: Action
gtk GtkSearchEntry GtkSearchEntry
==============
GtkSearchEntry — An entry which shows a search icon
Functions
---------
| | |
| --- | --- |
| [GtkWidget](gtkwidget#GtkWidget-struct) \* | [gtk\_search\_entry\_new](gtksearchentry#gtk-search-entry-new) () |
| void | [gtk\_search\_entry\_set\_key\_capture\_widget](gtksearchentry#gtk-search-entry-set-key-capture-widget) () |
| [GtkWidget](gtkwidget#GtkWidget-struct) \* | [gtk\_search\_entry\_get\_key\_capture\_widget](gtksearchentry#gtk-search-entry-get-key-capture-widget) () |
Properties
----------
| | | |
| --- | --- | --- |
| gboolean | [activates-default](gtksearchentry#GtkSearchEntry--activates-default) | Read / Write |
| char \* | [placeholder-text](gtksearchentry#GtkSearchEntry--placeholder-text) | Read / Write |
Signals
-------
| | | |
| --- | --- | --- |
| void | [activate](gtksearchentry#GtkSearchEntry-activate) | Action |
| void | [next-match](gtksearchentry#GtkSearchEntry-next-match) | Action |
| void | [previous-match](gtksearchentry#GtkSearchEntry-previous-match) | Action |
| void | [search-changed](gtksearchentry#GtkSearchEntry-search-changed) | Run Last |
| void | [search-started](gtksearchentry#GtkSearchEntry-search-started) | Run Last |
| void | [stop-search](gtksearchentry#GtkSearchEntry-stop-search) | Action |
Types and Values
----------------
| | |
| --- | --- |
| | [GtkSearchEntry](gtksearchentry#GtkSearchEntry-struct) |
Object Hierarchy
----------------
```
GObject
╰── GInitiallyUnowned
╰── [GtkWidget](gtkwidget#GtkWidget-struct)
╰── GtkSearchEntry
```
Implemented Interfaces
----------------------
GtkSearchEntry implements [GtkAccessible](gtkaccessible#GtkAccessible-struct), [GtkBuildable](gtkbuildable#GtkBuildable-struct), [GtkConstraintTarget](gtkconstraint#GtkConstraintTarget-struct) and [GtkEditable](gtkeditable#GtkEditable-struct).
Includes
--------
```
#include <gtk/gtk.h>
```
Description
-----------
[GtkSearchEntry](gtksearchentry#GtkSearchEntry-struct) is an entry widget that has been tailored for use as a search entry. The main aPI for interacting with a GtkSearchEntry as entry is the [GtkEditable](gtkeditable#GtkEditable-struct) interface.
It will show an inactive symbolic “find” icon when the search entry is empty, and a symbolic “clear” icon when there is text. Clicking on the “clear” icon will empty the search entry.
To make filtering appear more reactive, it is a good idea to not react to every change in the entry text immediately, but only after a short delay. To support this, [GtkSearchEntry](gtksearchentry#GtkSearchEntry-struct) emits the [“search-changed”](gtksearchentry#GtkSearchEntry-search-changed) signal which can be used instead of the [“changed”](gtkeditable#GtkEditable-changed) signal.
The [“previous-match”](gtksearchentry#GtkSearchEntry-previous-match), [“next-match”](gtksearchentry#GtkSearchEntry-next-match) and [“stop-search”](gtksearchentry#GtkSearchEntry-stop-search) signals can be used to implement moving between search results and ending the search.
Often, GtkSearchEntry will be fed events by means of being placed inside a [GtkSearchBar](gtksearchbar#GtkSearchBar-struct). If that is not the case, you can use [`gtk_search_entry_set_key_capture_widget()`](gtksearchentry#gtk-search-entry-set-key-capture-widget) to let it capture key input from another widget.
### CSS Nodes
```
entry.search
╰── text
```
| GtkSearchEntry has a single CSS node with name entry that carries a .sarch style class, and the text node is a child of that.
### Accessibility
GtkSearchEntry uses the [GTK\_ACCESSIBLE\_ROLE\_SEARCH\_BOX](gtkaccessible#GTK-ACCESSIBLE-ROLE-SEARCH-BOX:CAPS) role.
Functions
---------
### gtk\_search\_entry\_new ()
```
[GtkWidget](gtkwidget#GtkWidget-struct) *
gtk_search_entry_new (*`void`*);
```
Creates a [GtkSearchEntry](gtksearchentry#GtkSearchEntry-struct), with a find icon when the search field is empty, and a clear icon when it isn't.
#### Returns
a new [GtkSearchEntry](gtksearchentry#GtkSearchEntry-struct)
### gtk\_search\_entry\_set\_key\_capture\_widget ()
```
void
gtk_search_entry_set_key_capture_widget
(*`[GtkSearchEntry](gtksearchentry#GtkSearchEntry-struct) *entry`*,
*`[GtkWidget](gtkwidget#GtkWidget-struct) *widget`*);
```
Sets *`widget`* as the widget that *`entry`* will capture key events from.
Key events are consumed by the search entry to start or continue a search.
If the entry is part of a [GtkSearchBar](gtksearchbar#GtkSearchBar-struct), it is preferable to call [`gtk_search_bar_set_key_capture_widget()`](gtksearchbar#gtk-search-bar-set-key-capture-widget) instead, which will reveal the entry in addition to triggering the search entry.
#### Parameters
| | | |
| --- | --- | --- |
| entry | a [GtkSearchEntry](gtksearchentry#GtkSearchEntry-struct) | |
| widget | a [GtkWidget](gtkwidget#GtkWidget-struct). | [nullable][transfer none] |
### gtk\_search\_entry\_get\_key\_capture\_widget ()
```
[GtkWidget](gtkwidget#GtkWidget-struct) *
gtk_search_entry_get_key_capture_widget
(*`[GtkSearchEntry](gtksearchentry#GtkSearchEntry-struct) *entry`*);
```
Gets the widget that *`entry`* is capturing key events from.
#### Parameters
| | | |
| --- | --- | --- |
| entry | a [GtkSearchEntry](gtksearchentry#GtkSearchEntry-struct) | |
#### Returns
The key capture widget.
[transfer none]
Types and Values
----------------
### GtkSearchEntry
```
typedef struct _GtkSearchEntry GtkSearchEntry;
```
Property Details
----------------
### The `“activates-default”` property
```
“activates-default” gboolean
```
Whether to activate the default widget (such as the default button in a dialog) when Enter is pressed.
Owner: GtkSearchEntry
Flags: Read / Write
Default value: FALSE
### The `“placeholder-text”` property
```
“placeholder-text” char *
```
Show text in the entry when it’s empty and unfocused.
Owner: GtkSearchEntry
Flags: Read / Write
Default value: NULL
Signal Details
--------------
### The `“activate”` signal
```
void
user_function ([GtkSearchEntry](gtksearchentry#GtkSearchEntry-struct) *self,
gpointer user_data)
```
The ::activate signal is forwarded from the “activated” signal, which is a keybinding signal for all forms of the Enter key.
#### Parameters
| | | |
| --- | --- | --- |
| self | The widget on which the signal is emitted | |
| user\_data | user data set when the signal handler was connected. | |
Flags: Action
### The `“next-match”` signal
```
void
user_function ([GtkSearchEntry](gtksearchentry#GtkSearchEntry-struct) *entry,
gpointer user_data)
```
The ::next-match signal is a [keybinding signal](gtkshortcutaction#GtkSignalAction-struct) which gets emitted when the user initiates a move to the next match for the current search string.
Applications should connect to it, to implement moving between matches.
The default bindings for this signal is Ctrl-g.
#### Parameters
| | | |
| --- | --- | --- |
| entry | the entry on which the signal was emitted | |
| user\_data | user data set when the signal handler was connected. | |
Flags: Action
### The `“previous-match”` signal
```
void
user_function ([GtkSearchEntry](gtksearchentry#GtkSearchEntry-struct) *entry,
gpointer user_data)
```
The ::previous-match signal is a [keybinding signal](gtkshortcutaction#GtkSignalAction-struct) which gets emitted when the user initiates a move to the previous match for the current search string.
Applications should connect to it, to implement moving between matches.
The default bindings for this signal is Ctrl-Shift-g.
#### Parameters
| | | |
| --- | --- | --- |
| entry | the entry on which the signal was emitted | |
| user\_data | user data set when the signal handler was connected. | |
Flags: Action
### The `“search-changed”` signal
```
void
user_function ([GtkSearchEntry](gtksearchentry#GtkSearchEntry-struct) *entry,
gpointer user_data)
```
The [“search-changed”](gtksearchentry#GtkSearchEntry-search-changed) signal is emitted with a short delay of 150 milliseconds after the last change to the entry text.
#### Parameters
| | | |
| --- | --- | --- |
| entry | the entry on which the signal was emitted | |
| user\_data | user data set when the signal handler was connected. | |
Flags: Run Last
### The `“search-started”` signal
```
void
user_function ([GtkSearchEntry](gtksearchentry#GtkSearchEntry-struct) *entry,
gpointer user_data)
```
The ::search-started signal gets emitted when the user initiated a search on the entry.
#### Parameters
| | | |
| --- | --- | --- |
| entry | the entry on which the signal was emitted | |
| user\_data | user data set when the signal handler was connected. | |
Flags: Run Last
### The `“stop-search”` signal
```
void
user_function ([GtkSearchEntry](gtksearchentry#GtkSearchEntry-struct) *entry,
gpointer user_data)
```
The ::stop-search signal is a [keybinding signal](gtkshortcutaction#GtkSignalAction-struct) which gets emitted when the user stops a search via keyboard input.
Applications should connect to it, to implement hiding the search entry in this case.
The default bindings for this signal is Escape.
#### Parameters
| | | |
| --- | --- | --- |
| entry | the entry on which the signal was emitted | |
| user\_data | user data set when the signal handler was connected. | |
Flags: Action
| programming_docs |
gtk GtkBuildable GtkBuildable
============
GtkBuildable — Interface for objects that can be built by GtkBuilder
Functions
---------
| | |
| --- | --- |
| const char \* | [gtk\_buildable\_get\_buildable\_id](gtkbuildable#gtk-buildable-get-buildable-id) () |
| const char \* | [gtk\_buildable\_parse\_context\_get\_element](gtkbuildable#gtk-buildable-parse-context-get-element) () |
| GPtrArray \* | [gtk\_buildable\_parse\_context\_get\_element\_stack](gtkbuildable#gtk-buildable-parse-context-get-element-stack) () |
| void | [gtk\_buildable\_parse\_context\_get\_position](gtkbuildable#gtk-buildable-parse-context-get-position) () |
| gpointer | [gtk\_buildable\_parse\_context\_pop](gtkbuildable#gtk-buildable-parse-context-pop) () |
| void | [gtk\_buildable\_parse\_context\_push](gtkbuildable#gtk-buildable-parse-context-push) () |
Types and Values
----------------
| | |
| --- | --- |
| | [GtkBuildable](gtkbuildable#GtkBuildable-struct) |
| struct | [GtkBuildableIface](gtkbuildable#GtkBuildableIface) |
| struct | [GtkBuildableParser](gtkbuildable#GtkBuildableParser) |
Object Hierarchy
----------------
```
[GInterface](https://developer-old.gnome.org/gobject/stable/GTypeModule.html)
╰── GtkBuildable
```
Prerequisites
-------------
GtkBuildable requires GObject.
Known Implementations
---------------------
GtkBuildable is implemented by [GtkAboutDialog](gtkaboutdialog#GtkAboutDialog-struct), [GtkActionBar](gtkactionbar#GtkActionBar-struct), [GtkAnyFilter](gtkmultifilter#GtkAnyFilter-struct), [GtkAppChooserButton](gtkappchooserbutton#GtkAppChooserButton-struct), [GtkAppChooserDialog](gtkappchooserdialog#GtkAppChooserDialog-struct), [GtkAppChooserWidget](gtkappchooserwidget#GtkAppChooserWidget-struct), [GtkApplicationWindow](gtkapplicationwindow#GtkApplicationWindow-struct), [GtkAspectFrame](gtkaspectframe#GtkAspectFrame-struct), [GtkAssistant](gtkassistant#GtkAssistant-struct), [GtkBox](gtkbox#GtkBox-struct), [GtkButton](gtkbutton#GtkButton-struct), [GtkCalendar](gtkcalendar#GtkCalendar-struct), [GtkCellArea](gtkcellarea#GtkCellArea-struct), [GtkCellAreaBox](gtkcellareabox#GtkCellAreaBox-struct), [GtkCellView](gtkcellview#GtkCellView-struct), [GtkCenterBox](https://developer-old.gnome.org/usr/share/gtk-doc/html/gtk4/gtk4-GtkCenterBox.html#GtkCenterBox), [GtkCheckButton](gtkcheckbutton#GtkCheckButton-struct), [GtkColorButton](gtkcolorbutton#GtkColorButton-struct), [GtkColorChooserDialog](gtkcolorchooserdialog#GtkColorChooserDialog-struct), [GtkColorChooserWidget](gtkcolorchooserwidget#GtkColorChooserWidget-struct), [GtkColumnView](gtkcolumnview#GtkColumnView-struct), [GtkComboBox](gtkcombobox#GtkComboBox-struct), [GtkComboBoxText](gtkcomboboxtext#GtkComboBoxText-struct), [GtkConstraintLayout](gtkconstraintlayout#GtkConstraintLayout-struct), [GtkDialog](gtkdialog#GtkDialog-struct), [GtkDragIcon](gtkdragicon#GtkDragIcon-struct), [GtkDrawingArea](gtkdrawingarea#GtkDrawingArea-struct), [GtkDropDown](gtkdropdown#GtkDropDown-struct), [GtkEditableLabel](gtkeditablelabel#GtkEditableLabel-struct), [GtkEmojiChooser](gtkemojichooser#GtkEmojiChooser-struct), [GtkEntry](gtkentry#GtkEntry-struct), [GtkEntryCompletion](gtkentrycompletion#GtkEntryCompletion-struct), [GtkEveryFilter](gtkmultifilter#GtkEveryFilter-struct), [GtkExpander](gtkexpander#GtkExpander-struct), [GtkFileChooserDialog](gtkfilechooserdialog#GtkFileChooserDialog-struct), [GtkFileChooserWidget](gtkfilechooserwidget#GtkFileChooserWidget-struct), [GtkFileFilter](gtkfilefilter#GtkFileFilter-struct), [GtkFixed](gtkfixed#GtkFixed-struct), [GtkFlowBox](gtkflowbox#GtkFlowBox-struct), [GtkFlowBoxChild](gtkflowbox#GtkFlowBoxChild-struct), [GtkFontButton](gtkfontbutton#GtkFontButton-struct), [GtkFontChooserDialog](gtkfontchooserdialog#GtkFontChooserDialog-struct), [GtkFontChooserWidget](gtkfontchooserwidget#GtkFontChooserWidget-struct), [GtkFrame](gtkframe#GtkFrame-struct), [GtkGLArea](gtkglarea#GtkGLArea-struct), [GtkGrid](gtkgrid#GtkGrid-struct), [GtkGridView](gtkgridview#GtkGridView-struct), [GtkHeaderBar](gtkheaderbar#GtkHeaderBar-struct), [GtkIconView](gtkiconview#GtkIconView-struct), [GtkImage](gtkimage#GtkImage-struct), [GtkInfoBar](gtkinfobar#GtkInfoBar-struct), [GtkLabel](gtklabel#GtkLabel-struct), [GtkLevelBar](gtklevelbar#GtkLevelBar-struct), [GtkLinkButton](gtklinkbutton#GtkLinkButton-struct), [GtkListBox](gtklistbox#GtkListBox-struct), [GtkListBoxRow](gtklistbox#GtkListBoxRow-struct), [GtkListStore](gtkliststore#GtkListStore-struct), [GtkListView](gtklistview#GtkListView-struct), [GtkLockButton](gtklockbutton#GtkLockButton-struct), [GtkMediaControls](gtkmediacontrols#GtkMediaControls-struct), [GtkMenuButton](gtkmenubutton#GtkMenuButton-struct), [GtkMessageDialog](gtkmessagedialog#GtkMessageDialog-struct), [GtkMultiFilter](gtkmultifilter#GtkMultiFilter-struct), [GtkMultiSorter](gtkmultisorter#GtkMultiSorter-struct), [GtkNotebook](gtknotebook#GtkNotebook-struct), [GtkOverlay](gtkoverlay#GtkOverlay-struct), [GtkPageSetupUnixDialog](gtkpagesetupunixdialog#GtkPageSetupUnixDialog-struct), [GtkPaned](gtkpaned#GtkPaned-struct), [GtkPasswordEntry](gtkpasswordentry#GtkPasswordEntry-struct), [GtkPicture](gtkpicture#GtkPicture-struct), [GtkPopover](gtkpopover#GtkPopover-struct), [GtkPopoverMenu](gtkpopovermenu#GtkPopoverMenu-struct), [GtkPopoverMenuBar](gtkpopovermenubar#GtkPopoverMenuBar-struct), [GtkPrintUnixDialog](gtkprintunixdialog#GtkPrintUnixDialog-struct), [GtkProgressBar](gtkprogressbar#GtkProgressBar-struct), [GtkRange](gtkrange#GtkRange-struct), [GtkRevealer](gtkrevealer#GtkRevealer-struct), [GtkScale](gtkscale#GtkScale-struct), [GtkScaleButton](gtkscalebutton#GtkScaleButton-struct), [GtkScrollbar](gtkscrollbar#GtkScrollbar-struct), [GtkScrolledWindow](gtkscrolledwindow#GtkScrolledWindow-struct), [GtkSearchBar](gtksearchbar#GtkSearchBar-struct), [GtkSearchEntry](gtksearchentry#GtkSearchEntry-struct), [GtkSeparator](gtkseparator#GtkSeparator-struct), [GtkShortcutController](gtkshortcutcontroller#GtkShortcutController-struct), [GtkShortcutLabel](gtkshortcutlabel#GtkShortcutLabel-struct), [GtkShortcutsGroup](gtkshortcutsgroup#GtkShortcutsGroup-struct), [GtkShortcutsSection](gtkshortcutssection#GtkShortcutsSection-struct), [GtkShortcutsShortcut](gtkshortcutsshortcut#GtkShortcutsShortcut-struct), [GtkShortcutsWindow](gtkshortcutswindow#GtkShortcutsWindow-struct), [GtkSizeGroup](gtksizegroup#GtkSizeGroup-struct), [GtkSpinButton](gtkspinbutton#GtkSpinButton-struct), [GtkSpinner](gtkspinner#GtkSpinner-struct), [GtkStack](gtkstack#GtkStack-struct), [GtkStackSidebar](gtkstacksidebar#GtkStackSidebar-struct), [GtkStackSwitcher](gtkstackswitcher#GtkStackSwitcher-struct), [GtkStatusbar](gtkstatusbar#GtkStatusbar-struct), [GtkStringList](gtkstringlist#GtkStringList-struct), [GtkSwitch](gtkswitch#GtkSwitch-struct), [GtkText](gtktext#GtkText-struct), [GtkTextTagTable](gtktexttagtable#GtkTextTagTable-struct), [GtkTextView](gtktextview#GtkTextView-struct), [GtkToggleButton](gtktogglebutton#GtkToggleButton-struct), [GtkTreeExpander](gtktreeexpander#GtkTreeExpander-struct), [GtkTreeStore](gtktreestore#GtkTreeStore-struct), [GtkTreeView](gtktreeview#GtkTreeView-struct), [GtkTreeViewColumn](gtktreeviewcolumn#GtkTreeViewColumn-struct), [GtkVideo](gtkvideo#GtkVideo-struct), [GtkViewport](gtkviewport#GtkViewport-struct), [GtkVolumeButton](gtkvolumebutton#GtkVolumeButton-struct), [GtkWidget](gtkwidget#GtkWidget-struct), [GtkWindow](gtkwindow#GtkWindow-struct), [GtkWindowControls](gtkwindowcontrols#GtkWindowControls-struct) and [GtkWindowHandle](gtkwindowhandle#GtkWindowHandle-struct).
Includes
--------
```
#include <gtk/gtk.h>
```
Description
-----------
GtkBuildable allows objects to extend and customize their deserialization from GtkBuilder UI descriptions. The interface includes methods for setting names and properties of objects, parsing custom tags and constructing child objects.
The GtkBuildable interface is implemented by all widgets and many of the non-widget objects that are provided by GTK. The main user of this interface is [GtkBuilder](gtkbuilder#GtkBuilder-struct). There should be very little need for applications to call any of these functions directly.
An object only needs to implement this interface if it needs to extend the [GtkBuilder](gtkbuilder#GtkBuilder-struct) format or run any extra routines at deserialization time.
Functions
---------
### gtk\_buildable\_get\_buildable\_id ()
```
const char *
gtk_buildable_get_buildable_id (*`[GtkBuildable](gtkbuildable#GtkBuildable-struct) *buildable`*);
```
Gets the ID of the *`buildable`* object.
[GtkBuilder](gtkbuilder#GtkBuilder-struct) sets the name based on the GtkBuilder UI definition used to construct the *`buildable`* .
#### Parameters
| | | |
| --- | --- | --- |
| buildable | a [GtkBuildable](gtkbuildable#GtkBuildable-struct) | |
#### Returns
the ID set with `gtk_buildable_set_buildable_id()`
### gtk\_buildable\_parse\_context\_get\_element ()
```
const char *
gtk_buildable_parse_context_get_element
(GtkBuildableParseContext *context);
```
Retrieves the name of the currently open element.
If called from the start\_element or end\_element handlers this will give the element\_name as passed to those functions. For the parent elements, see [`gtk_buildable_parse_context_get_element_stack()`](gtkbuildable#gtk-buildable-parse-context-get-element-stack).
#### Parameters
| | | |
| --- | --- | --- |
| context | a GtkBuildablParseContext | |
#### Returns
the name of the currently open element, or `NULL`.
[nullable]
### gtk\_buildable\_parse\_context\_get\_element\_stack ()
```
GPtrArray *
gtk_buildable_parse_context_get_element_stack
(GtkBuildableParseContext *context);
```
Retrieves the element stack from the internal state of the parser.
The returned GPtrArray is an array of strings where the last item is the currently open tag (as would be returned by [`gtk_buildable_parse_context_get_element()`](gtkbuildable#gtk-buildable-parse-context-get-element)) and the previous item is its immediate parent.
This function is intended to be used in the start\_element and end\_element handlers where [`gtk_buildable_parse_context_get_element()`](gtkbuildable#gtk-buildable-parse-context-get-element) would merely return the name of the element that is being processed.
#### Parameters
| | | |
| --- | --- | --- |
| context | a GtkBuildableParseContext | |
#### Returns
the element stack, which must not be modified.
[transfer none][element-type utf8]
### gtk\_buildable\_parse\_context\_get\_position ()
```
void
gtk_buildable_parse_context_get_position
(GtkBuildableParseContext *context,
int *line_number,
int *char_number);
```
Retrieves the current line number and the number of the character on that line. Intended for use in error messages; there are no strict semantics for what constitutes the "current" line number other than "the best number we could come up with for error messages."
#### Parameters
| | | |
| --- | --- | --- |
| context | a GtkBuildableParseContext | |
| line\_number | return location for a line number, or `NULL`. | [out][optional] |
| char\_number | return location for a char-on-line number, or `NULL`. | [out][optional] |
### gtk\_buildable\_parse\_context\_pop ()
```
gpointer
gtk_buildable_parse_context_pop (GtkBuildableParseContext *context);
```
Completes the process of a temporary sub-parser redirection.
This function exists to collect the user\_data allocated by a matching call to [`gtk_buildable_parse_context_push()`](gtkbuildable#gtk-buildable-parse-context-push). It must be called in the end\_element handler corresponding to the start\_element handler during which [`gtk_buildable_parse_context_push()`](gtkbuildable#gtk-buildable-parse-context-push) was called. You must not call this function from the error callback -- the *`user_data`* is provided directly to the callback in that case.
This function is not intended to be directly called by users interested in invoking subparsers. Instead, it is intended to be used by the subparsers themselves to implement a higher-level interface.
#### Parameters
| | | |
| --- | --- | --- |
| context | a GtkBuildableParseContext | |
#### Returns
the user data passed to [`gtk_buildable_parse_context_push()`](gtkbuildable#gtk-buildable-parse-context-push)
### gtk\_buildable\_parse\_context\_push ()
```
void
gtk_buildable_parse_context_push (*`GtkBuildableParseContext *context`*,
*`const [GtkBuildableParser](gtkbuildable#GtkBuildableParser) *parser`*,
*`gpointer user_data`*);
```
Temporarily redirects markup data to a sub-parser.
This function may only be called from the start\_element handler of a [GtkBuildableParser](gtkbuildable#GtkBuildableParser). It must be matched with a corresponding call to [`gtk_buildable_parse_context_pop()`](gtkbuildable#gtk-buildable-parse-context-pop) in the matching end\_element handler (except in the case that the parser aborts due to an error).
All tags, text and other data between the matching tags is redirected to the subparser given by *`parser`* . *`user_data`* is used as the user\_data for that parser. *`user_data`* is also passed to the error callback in the event that an error occurs. This includes errors that occur in subparsers of the subparser.
The end tag matching the start tag for which this call was made is handled by the previous parser (which is given its own user\_data) which is why [`gtk_buildable_parse_context_pop()`](gtkbuildable#gtk-buildable-parse-context-pop) is provided to allow "one last access" to the *`user_data`* provided to this function. In the case of error, the *`user_data`* provided here is passed directly to the error callback of the subparser and [`gtk_buildable_parse_context_pop()`](gtkbuildable#gtk-buildable-parse-context-pop) should not be called. In either case, if *`user_data`* was allocated then it ought to be freed from both of these locations.
This function is not intended to be directly called by users interested in invoking subparsers. Instead, it is intended to be used by the subparsers themselves to implement a higher-level interface.
For an example of how to use this, see `g_markup_parse_context_push()` which has the same kind of API.
#### Parameters
| | | |
| --- | --- | --- |
| context | a GtkBuildableParseContext | |
| parser | a [GtkBuildableParser](gtkbuildable#GtkBuildableParser) | |
| user\_data | user data to pass to [GtkBuildableParser](gtkbuildable#GtkBuildableParser) functions | |
Types and Values
----------------
### GtkBuildable
```
typedef struct _GtkBuildable GtkBuildable;
```
### struct GtkBuildableIface
```
struct GtkBuildableIface {
GTypeInterface g_iface;
/* virtual table */
void (* set_id) (GtkBuildable *buildable,
const char *id);
const char * (* get_id) (GtkBuildable *buildable);
/**
* GtkBuildableIface::add_child:
* @buildable: a #GtkBuildable
* @builder: a #GtkBuilder
* @child: child to add
* @type: (nullable): kind of child or %NULL
*
* Adds a child to @buildable. @type is an optional string
* describing how the child should be added.
*/
void (* add_child) (GtkBuildable *buildable,
GtkBuilder *builder,
GObject *child,
const char *type);
void (* set_buildable_property) (GtkBuildable *buildable,
GtkBuilder *builder,
const char *name,
const GValue *value);
GObject * (* construct_child) (GtkBuildable *buildable,
GtkBuilder *builder,
const char *name);
/**
* GtkBuildableIface::custom_tag_start:
* @buildable: a #GtkBuildable
* @builder: a #GtkBuilder used to construct this object
* @child: (nullable): child object or %NULL for non-child tags
* @tagname: name of tag
* @parser: (out): a #GtkBuildableParser to fill in
* @data: (out): return location for user data that will be passed in
* to parser functions
*
* Called for each unknown element under `<child>`.
*
* Returns: %TRUE if an object has a custom implementation, %FALSE
* if it doesn't.
*/
gboolean (* custom_tag_start) (GtkBuildable *buildable,
GtkBuilder *builder,
GObject *child,
const char *tagname,
GtkBuildableParser *parser,
gpointer *data);
/**
* GtkBuildableIface::custom_tag_end:
* @buildable: A #GtkBuildable
* @builder: #GtkBuilder used to construct this object
* @child: (nullable): child object or %NULL for non-child tags
* @tagname: name of tag
* @data: user data that will be passed in to parser functions
*
* Called at the end of each custom element handled by
* the buildable.
*/
void (* custom_tag_end) (GtkBuildable *buildable,
GtkBuilder *builder,
GObject *child,
const char *tagname,
gpointer data);
/**
* GtkBuildableIface::custom_finished:
* @buildable: a #GtkBuildable
* @builder: a #GtkBuilder
* @child: (nullable): child object or %NULL for non-child tags
* @tagname: the name of the tag
* @data: user data created in custom_tag_start
*
* Similar to gtk_buildable_parser_finished() but is
* called once for each custom tag handled by the @buildable.
*/
void (* custom_finished) (GtkBuildable *buildable,
GtkBuilder *builder,
GObject *child,
const char *tagname,
gpointer data);
void (* parser_finished) (GtkBuildable *buildable,
GtkBuilder *builder);
/**
* GtkBuildableIface::get_internal_child:
* @buildable: a #GtkBuildable
* @builder: a #GtkBuilder
* @childname: name of child
*
* Retrieves the internal child called @childname of the @buildable object.
*
* Returns: (transfer none): the internal child of the buildable object
*/
GObject * (* get_internal_child) (GtkBuildable *buildable,
GtkBuilder *builder,
const char *childname);
};
```
The [GtkBuildableIface](gtkbuildable#GtkBuildableIface) interface contains method that are necessary to allow [GtkBuilder](gtkbuilder#GtkBuilder-struct) to construct an object from a [GtkBuilder](gtkbuilder#GtkBuilder-struct) UI definition.
#### Members
| | | |
| --- | --- | --- |
| *`set_id`* () | Stores the id attribute given in the GtkBuilder UI definition. [GtkWidget](gtkwidget#GtkWidget-struct) stores the name as object data. Implement this method if your object has some notion of “ID” and it makes sense to map the XML id attribute to it. | |
| *`get_id`* () | The getter corresponding to *`set_id`* . Implement this if you implement *`set_id`* . | |
| *`add_child`* () | Adds a child. The *`type`* parameter can be used to differentiate the kind of child. [GtkWidget](gtkwidget#GtkWidget-struct) implements this to add event controllers to the widget, [GtkNotebook](gtknotebook#GtkNotebook-struct) uses the *`type`* to distinguish between page labels (of type "page-label") and normal children. | |
| *`set_buildable_property`* () | Sets a property of a buildable object. It is normally not necessary to implement this, `g_object_set_property()` is used by default. [GtkWindow](gtkwindow#GtkWindow-struct) implements this to delay showing itself (i.e. setting the [“visible”](gtkwidget#GtkWidget--visible) property) until the whole interface is created. | |
| *`construct_child`* () | Constructs a child of a buildable that has been specified as “constructor” in the UI definition. This can be used to reference a widget created in a <ui> tag which is outside of the normal GtkBuilder UI definition hierarchy. A reference to the constructed object is returned and becomes owned by the caller. | |
| *`custom_tag_start`* () | Implement this if the buildable needs to parse content below <child>. To handle an element, the implementation must fill in the *`parser`* and *`user_data`* and return `TRUE`. [GtkWidget](gtkwidget#GtkWidget-struct) implements this to parse accessible attributes specified in <accessibility> elements. Note that *`user_data`* must be freed in *`custom_tag_end`* or *`custom_finished`* . | |
| *`custom_tag_end`* () | Called for the end tag of each custom element that is handled by the buildable (see *`custom_tag_start`* ). | |
| *`custom_finished`* () | Called for each custom tag handled by the buildable when the builder finishes parsing (see *`custom_tag_start`* ) | |
| *`parser_finished`* () | Called when a builder finishes the parsing of a UI definition. It is normally not necessary to implement this, unless you need to perform special cleanup actions. [GtkWindow](gtkwindow#GtkWindow-struct) sets the [“visible”](gtkwidget#GtkWidget--visible) property here. | |
| *`get_internal_child`* () | Returns an internal child of a buildable. [GtkDialog](gtkdialog#GtkDialog-struct) implements this to give access to its *`vbox`* , making it possible to add children to the vbox in a UI definition. Implement this if the buildable has internal children that may need to be accessed from a UI definition. | |
### struct GtkBuildableParser
```
struct GtkBuildableParser {
/* Called for open tags <foo bar="baz"> */
void (*start_element) (GtkBuildableParseContext *context,
const char *element_name,
const char **attribute_names,
const char **attribute_values,
gpointer user_data,
GError **error);
/* Called for close tags </foo> */
void (*end_element) (GtkBuildableParseContext *context,
const char *element_name,
gpointer user_data,
GError **error);
/* Called for character data */
/* text is not nul-terminated */
void (*text) (GtkBuildableParseContext *context,
const char *text,
gsize text_len,
gpointer user_data,
GError **error);
/* Called on error, including one set by other
* methods in the vtable. The GError should not be freed.
*/
void (*error) (GtkBuildableParseContext *context,
GError *error,
gpointer user_data);
};
```
A sub-parser for [GtkBuildable](gtkbuildable#GtkBuildable-struct) implementations.
#### Members
| | | |
| --- | --- | --- |
| *`start_element`* () | function called for open elements | |
| *`end_element`* () | function called for close elements | |
| *`text`* () | function called for character data | |
| *`error`* () | function called on error | |
| programming_docs |
gtk GtkFontChooser GtkFontChooser
==============
GtkFontChooser — Interface implemented by widgets displaying fonts
Functions
---------
| | |
| --- | --- |
| [PangoFontFamily](https://developer-old.gnome.org/pango/stable/pango-Fonts.html#PangoFontFamily-struct) \* | [gtk\_font\_chooser\_get\_font\_family](gtkfontchooser#gtk-font-chooser-get-font-family) () |
| [PangoFontFace](https://developer-old.gnome.org/pango/stable/pango-Fonts.html#PangoFontFace-struct) \* | [gtk\_font\_chooser\_get\_font\_face](gtkfontchooser#gtk-font-chooser-get-font-face) () |
| int | [gtk\_font\_chooser\_get\_font\_size](gtkfontchooser#gtk-font-chooser-get-font-size) () |
| char \* | [gtk\_font\_chooser\_get\_font](gtkfontchooser#gtk-font-chooser-get-font) () |
| void | [gtk\_font\_chooser\_set\_font](gtkfontchooser#gtk-font-chooser-set-font) () |
| [PangoFontDescription](https://developer-old.gnome.org/pango/stable/pango-Fonts.html#PangoFontDescription-struct) \* | [gtk\_font\_chooser\_get\_font\_desc](gtkfontchooser#gtk-font-chooser-get-font-desc) () |
| void | [gtk\_font\_chooser\_set\_font\_desc](gtkfontchooser#gtk-font-chooser-set-font-desc) () |
| char \* | [gtk\_font\_chooser\_get\_font\_features](gtkfontchooser#gtk-font-chooser-get-font-features) () |
| char \* | [gtk\_font\_chooser\_get\_language](gtkfontchooser#gtk-font-chooser-get-language) () |
| void | [gtk\_font\_chooser\_set\_language](gtkfontchooser#gtk-font-chooser-set-language) () |
| char \* | [gtk\_font\_chooser\_get\_preview\_text](gtkfontchooser#gtk-font-chooser-get-preview-text) () |
| void | [gtk\_font\_chooser\_set\_preview\_text](gtkfontchooser#gtk-font-chooser-set-preview-text) () |
| gboolean | [gtk\_font\_chooser\_get\_show\_preview\_entry](gtkfontchooser#gtk-font-chooser-get-show-preview-entry) () |
| void | [gtk\_font\_chooser\_set\_show\_preview\_entry](gtkfontchooser#gtk-font-chooser-set-show-preview-entry) () |
| [GtkFontChooserLevel](gtkfontchooser#GtkFontChooserLevel) | [gtk\_font\_chooser\_get\_level](gtkfontchooser#gtk-font-chooser-get-level) () |
| void | [gtk\_font\_chooser\_set\_level](gtkfontchooser#gtk-font-chooser-set-level) () |
| gboolean | ([\*GtkFontFilterFunc](gtkfontchooser#GtkFontFilterFunc)) () |
| void | [gtk\_font\_chooser\_set\_filter\_func](gtkfontchooser#gtk-font-chooser-set-filter-func) () |
| void | [gtk\_font\_chooser\_set\_font\_map](gtkfontchooser#gtk-font-chooser-set-font-map) () |
| [PangoFontMap](https://developer-old.gnome.org/pango/stable/pango-Fonts.html#PangoFontMap-struct) \* | [gtk\_font\_chooser\_get\_font\_map](gtkfontchooser#gtk-font-chooser-get-font-map) () |
Properties
----------
| | | |
| --- | --- | --- |
| char \* | [font](gtkfontchooser#GtkFontChooser--font) | Read / Write |
| [PangoFontDescription](https://developer-old.gnome.org/pango/stable/pango-Fonts.html#PangoFontDescription-struct) \* | [font-desc](gtkfontchooser#GtkFontChooser--font-desc) | Read / Write |
| char \* | [font-features](gtkfontchooser#GtkFontChooser--font-features) | Read |
| char \* | [language](gtkfontchooser#GtkFontChooser--language) | Read / Write |
| [GtkFontChooserLevel](gtkfontchooser#GtkFontChooserLevel) | [level](gtkfontchooser#GtkFontChooser--level) | Read / Write |
| char \* | [preview-text](gtkfontchooser#GtkFontChooser--preview-text) | Read / Write |
| gboolean | [show-preview-entry](gtkfontchooser#GtkFontChooser--show-preview-entry) | Read / Write |
Signals
-------
| | | |
| --- | --- | --- |
| void | [font-activated](gtkfontchooser#GtkFontChooser-font-activated) | Run First |
Types and Values
----------------
| | |
| --- | --- |
| | [GtkFontChooser](gtkfontchooser#GtkFontChooser-struct) |
| enum | [GtkFontChooserLevel](gtkfontchooser#GtkFontChooserLevel) |
Object Hierarchy
----------------
```
[GInterface](https://developer-old.gnome.org/gobject/stable/GTypeModule.html)
╰── GtkFontChooser
```
Prerequisites
-------------
GtkFontChooser requires GObject.
Known Implementations
---------------------
GtkFontChooser is implemented by [GtkFontButton](gtkfontbutton#GtkFontButton-struct), [GtkFontChooserDialog](gtkfontchooserdialog#GtkFontChooserDialog-struct) and [GtkFontChooserWidget](gtkfontchooserwidget#GtkFontChooserWidget-struct).
Includes
--------
```
#include <gtk/gtk.h>
```
Description
-----------
[GtkFontChooser](gtkfontchooser#GtkFontChooser-struct) is an interface that can be implemented by widgets displaying the list of fonts. In GTK, the main objects that implement this interface are [GtkFontChooserWidget](gtkfontchooserwidget#GtkFontChooserWidget-struct), [GtkFontChooserDialog](gtkfontchooserdialog#GtkFontChooserDialog-struct) and [GtkFontButton](gtkfontbutton#GtkFontButton-struct).
Functions
---------
### gtk\_font\_chooser\_get\_font\_family ()
```
[PangoFontFamily](https://developer-old.gnome.org/pango/stable/pango-Fonts.html#PangoFontFamily-struct) *
gtk_font_chooser_get_font_family (*`[GtkFontChooser](gtkfontchooser#GtkFontChooser-struct) *fontchooser`*);
```
Gets the [PangoFontFamily](https://developer-old.gnome.org/pango/stable/pango-Fonts.html#PangoFontFamily-struct) representing the selected font family. Font families are a collection of font faces.
If the selected font is not installed, returns `NULL`.
#### Parameters
| | | |
| --- | --- | --- |
| fontchooser | a [GtkFontChooser](gtkfontchooser#GtkFontChooser-struct) | |
#### Returns
A [PangoFontFamily](https://developer-old.gnome.org/pango/stable/pango-Fonts.html#PangoFontFamily-struct) representing the selected font family, or `NULL`. The returned object is owned by *`fontchooser`* and must not be modified or freed.
[nullable][transfer none]
### gtk\_font\_chooser\_get\_font\_face ()
```
[PangoFontFace](https://developer-old.gnome.org/pango/stable/pango-Fonts.html#PangoFontFace-struct) *
gtk_font_chooser_get_font_face (*`[GtkFontChooser](gtkfontchooser#GtkFontChooser-struct) *fontchooser`*);
```
Gets the [PangoFontFace](https://developer-old.gnome.org/pango/stable/pango-Fonts.html#PangoFontFace-struct) representing the selected font group details (i.e. family, slant, weight, width, etc).
If the selected font is not installed, returns `NULL`.
#### Parameters
| | | |
| --- | --- | --- |
| fontchooser | a [GtkFontChooser](gtkfontchooser#GtkFontChooser-struct) | |
#### Returns
A [PangoFontFace](https://developer-old.gnome.org/pango/stable/pango-Fonts.html#PangoFontFace-struct) representing the selected font group details, or `NULL`. The returned object is owned by *`fontchooser`* and must not be modified or freed.
[nullable][transfer none]
### gtk\_font\_chooser\_get\_font\_size ()
```
int
gtk_font_chooser_get_font_size (*`[GtkFontChooser](gtkfontchooser#GtkFontChooser-struct) *fontchooser`*);
```
The selected font size.
#### Parameters
| | | |
| --- | --- | --- |
| fontchooser | a [GtkFontChooser](gtkfontchooser#GtkFontChooser-struct) | |
#### Returns
A n integer representing the selected font size, or -1 if no font size is selected.
### gtk\_font\_chooser\_get\_font ()
```
char *
gtk_font_chooser_get_font (*`[GtkFontChooser](gtkfontchooser#GtkFontChooser-struct) *fontchooser`*);
```
Gets the currently-selected font name.
Note that this can be a different string than what you set with [`gtk_font_chooser_set_font()`](gtkfontchooser#gtk-font-chooser-set-font), as the font chooser widget may normalize font names and thus return a string with a different structure. For example, “Helvetica Italic Bold 12” could be normalized to “Helvetica Bold Italic 12”.
Use [`pango_font_description_equal()`](https://developer-old.gnome.org/pango/stable/pango-Fonts.html#pango-font-description-equal) if you want to compare two font descriptions.
#### Parameters
| | | |
| --- | --- | --- |
| fontchooser | a [GtkFontChooser](gtkfontchooser#GtkFontChooser-struct) | |
#### Returns
A string with the name of the current font, or `NULL` if no font is selected. You must free this string with `g_free()`.
[nullable][transfer full]
### gtk\_font\_chooser\_set\_font ()
```
void
gtk_font_chooser_set_font (*`[GtkFontChooser](gtkfontchooser#GtkFontChooser-struct) *fontchooser`*,
*`const char *fontname`*);
```
Sets the currently-selected font.
#### Parameters
| | | |
| --- | --- | --- |
| fontchooser | a [GtkFontChooser](gtkfontchooser#GtkFontChooser-struct) | |
| fontname | a font name like “Helvetica 12” or “Times Bold 18” | |
### gtk\_font\_chooser\_get\_font\_desc ()
```
[PangoFontDescription](https://developer-old.gnome.org/pango/stable/pango-Fonts.html#PangoFontDescription-struct) *
gtk_font_chooser_get_font_desc (*`[GtkFontChooser](gtkfontchooser#GtkFontChooser-struct) *fontchooser`*);
```
Gets the currently-selected font.
Note that this can be a different string than what you set with [`gtk_font_chooser_set_font()`](gtkfontchooser#gtk-font-chooser-set-font), as the font chooser widget may normalize font names and thus return a string with a different structure. For example, “Helvetica Italic Bold 12” could be normalized to “Helvetica Bold Italic 12”.
Use [`pango_font_description_equal()`](https://developer-old.gnome.org/pango/stable/pango-Fonts.html#pango-font-description-equal) if you want to compare two font descriptions.
#### Parameters
| | | |
| --- | --- | --- |
| fontchooser | a [GtkFontChooser](gtkfontchooser#GtkFontChooser-struct) | |
#### Returns
A [PangoFontDescription](https://developer-old.gnome.org/pango/stable/pango-Fonts.html#PangoFontDescription-struct) for the current font, or `NULL` if no font is selected.
[nullable][transfer full]
### gtk\_font\_chooser\_set\_font\_desc ()
```
void
gtk_font_chooser_set_font_desc (*`[GtkFontChooser](gtkfontchooser#GtkFontChooser-struct) *fontchooser`*,
*`const [PangoFontDescription](https://developer-old.gnome.org/pango/stable/pango-Fonts.html#PangoFontDescription-struct) *font_desc`*);
```
Sets the currently-selected font from *`font_desc`* .
#### Parameters
| | | |
| --- | --- | --- |
| fontchooser | a [GtkFontChooser](gtkfontchooser#GtkFontChooser-struct) | |
| font\_desc | a [PangoFontDescription](https://developer-old.gnome.org/pango/stable/pango-Fonts.html#PangoFontDescription-struct) | |
### gtk\_font\_chooser\_get\_font\_features ()
```
char *
gtk_font_chooser_get_font_features (*`[GtkFontChooser](gtkfontchooser#GtkFontChooser-struct) *fontchooser`*);
```
Gets the currently-selected font features.
#### Parameters
| | | |
| --- | --- | --- |
| fontchooser | a [GtkFontChooser](gtkfontchooser#GtkFontChooser-struct) | |
#### Returns
the currently selected font features
### gtk\_font\_chooser\_get\_language ()
```
char *
gtk_font_chooser_get_language (*`[GtkFontChooser](gtkfontchooser#GtkFontChooser-struct) *fontchooser`*);
```
Gets the language that is used for font features.
#### Parameters
| | | |
| --- | --- | --- |
| fontchooser | a [GtkFontChooser](gtkfontchooser#GtkFontChooser-struct) | |
#### Returns
the currently selected language
### gtk\_font\_chooser\_set\_language ()
```
void
gtk_font_chooser_set_language (*`[GtkFontChooser](gtkfontchooser#GtkFontChooser-struct) *fontchooser`*,
*`const char *language`*);
```
Sets the language to use for font features.
#### Parameters
| | | |
| --- | --- | --- |
| fontchooser | a [GtkFontChooser](gtkfontchooser#GtkFontChooser-struct) | |
| language | a language | |
### gtk\_font\_chooser\_get\_preview\_text ()
```
char *
gtk_font_chooser_get_preview_text (*`[GtkFontChooser](gtkfontchooser#GtkFontChooser-struct) *fontchooser`*);
```
Gets the text displayed in the preview area.
#### Parameters
| | | |
| --- | --- | --- |
| fontchooser | a [GtkFontChooser](gtkfontchooser#GtkFontChooser-struct) | |
#### Returns
the text displayed in the preview area.
[transfer full]
### gtk\_font\_chooser\_set\_preview\_text ()
```
void
gtk_font_chooser_set_preview_text (*`[GtkFontChooser](gtkfontchooser#GtkFontChooser-struct) *fontchooser`*,
*`const char *text`*);
```
Sets the text displayed in the preview area. The *`text`* is used to show how the selected font looks.
#### Parameters
| | | |
| --- | --- | --- |
| fontchooser | a [GtkFontChooser](gtkfontchooser#GtkFontChooser-struct) | |
| text | the text to display in the preview area. | [transfer none] |
### gtk\_font\_chooser\_get\_show\_preview\_entry ()
```
gboolean
gtk_font_chooser_get_show_preview_entry
(*`[GtkFontChooser](gtkfontchooser#GtkFontChooser-struct) *fontchooser`*);
```
Returns whether the preview entry is shown or not.
#### Parameters
| | | |
| --- | --- | --- |
| fontchooser | a [GtkFontChooser](gtkfontchooser#GtkFontChooser-struct) | |
#### Returns
`TRUE` if the preview entry is shown or `FALSE` if it is hidden.
### gtk\_font\_chooser\_set\_show\_preview\_entry ()
```
void
gtk_font_chooser_set_show_preview_entry
(*`[GtkFontChooser](gtkfontchooser#GtkFontChooser-struct) *fontchooser`*,
*`gboolean show_preview_entry`*);
```
Shows or hides the editable preview entry.
#### Parameters
| | | |
| --- | --- | --- |
| fontchooser | a [GtkFontChooser](gtkfontchooser#GtkFontChooser-struct) | |
| show\_preview\_entry | whether to show the editable preview entry or not | |
### gtk\_font\_chooser\_get\_level ()
```
[GtkFontChooserLevel](gtkfontchooser#GtkFontChooserLevel)
gtk_font_chooser_get_level (*`[GtkFontChooser](gtkfontchooser#GtkFontChooser-struct) *fontchooser`*);
```
Returns the current level of granularity for selecting fonts.
#### Parameters
| | | |
| --- | --- | --- |
| fontchooser | a [GtkFontChooser](gtkfontchooser#GtkFontChooser-struct) | |
#### Returns
the current granularity level
### gtk\_font\_chooser\_set\_level ()
```
void
gtk_font_chooser_set_level (*`[GtkFontChooser](gtkfontchooser#GtkFontChooser-struct) *fontchooser`*,
*`[GtkFontChooserLevel](gtkfontchooser#GtkFontChooserLevel) level`*);
```
Sets the desired level of granularity for selecting fonts.
#### Parameters
| | | |
| --- | --- | --- |
| fontchooser | a [GtkFontChooser](gtkfontchooser#GtkFontChooser-struct) | |
| level | the desired level of granularity | |
### GtkFontFilterFunc ()
```
gboolean
(*GtkFontFilterFunc) (*`const [PangoFontFamily](https://developer-old.gnome.org/pango/stable/pango-Fonts.html#PangoFontFamily-struct) *family`*,
*`const [PangoFontFace](https://developer-old.gnome.org/pango/stable/pango-Fonts.html#PangoFontFace-struct) *face`*,
*`gpointer data`*);
```
The type of function that is used for deciding what fonts get shown in a [GtkFontChooser](gtkfontchooser#GtkFontChooser-struct). See [`gtk_font_chooser_set_filter_func()`](gtkfontchooser#gtk-font-chooser-set-filter-func).
#### Parameters
| | | |
| --- | --- | --- |
| family | a [PangoFontFamily](https://developer-old.gnome.org/pango/stable/pango-Fonts.html#PangoFontFamily-struct) | |
| face | a [PangoFontFace](https://developer-old.gnome.org/pango/stable/pango-Fonts.html#PangoFontFace-struct) belonging to *`family`* | |
| data | user data passed to [`gtk_font_chooser_set_filter_func()`](gtkfontchooser#gtk-font-chooser-set-filter-func). | [closure] |
#### Returns
`TRUE` if the font should be displayed
### gtk\_font\_chooser\_set\_filter\_func ()
```
void
gtk_font_chooser_set_filter_func (*`[GtkFontChooser](gtkfontchooser#GtkFontChooser-struct) *fontchooser`*,
*`[GtkFontFilterFunc](gtkfontchooser#GtkFontFilterFunc) filter`*,
*`gpointer user_data`*,
*`GDestroyNotify destroy`*);
```
Adds a filter function that decides which fonts to display in the font chooser.
#### Parameters
| | | |
| --- | --- | --- |
| fontchooser | a [GtkFontChooser](gtkfontchooser#GtkFontChooser-struct) | |
| filter | a [GtkFontFilterFunc](gtkfontchooser#GtkFontFilterFunc), or `NULL`. | [allow-none] |
| user\_data | data to pass to *`filter`* . | [closure] |
| destroy | function to call to free *`data`* when it is no longer needed | |
### gtk\_font\_chooser\_set\_font\_map ()
```
void
gtk_font_chooser_set_font_map (*`[GtkFontChooser](gtkfontchooser#GtkFontChooser-struct) *fontchooser`*,
*`[PangoFontMap](https://developer-old.gnome.org/pango/stable/pango-Fonts.html#PangoFontMap-struct) *fontmap`*);
```
Sets a custom font map to use for this font chooser widget. A custom font map can be used to present application-specific fonts instead of or in addition to the normal system fonts.
Note that other GTK widgets will only be able to use the application-specific font if it is present in the font map they use:
```
FcConfig *config;
PangoFontMap *fontmap;
config = FcInitLoadConfigAndFonts ();
FcConfigAppFontAddFile (config, my_app_font_file);
fontmap = pango_cairo_font_map_new_for_font_type (CAIRO_FONT_TYPE_FT);
pango_fc_font_map_set_config (PANGO_FC_FONT_MAP (fontmap), config);
gtk_font_chooser_set_font_map (font_chooser, fontmap);
```
| #### Parameters
| | | |
| --- | --- | --- |
| fontchooser | a [GtkFontChooser](gtkfontchooser#GtkFontChooser-struct) | |
| fontmap | a [PangoFontMap](https://developer-old.gnome.org/pango/stable/pango-Fonts.html#PangoFontMap-struct). | [allow-none] |
### gtk\_font\_chooser\_get\_font\_map ()
```
[PangoFontMap](https://developer-old.gnome.org/pango/stable/pango-Fonts.html#PangoFontMap-struct) *
gtk_font_chooser_get_font_map (*`[GtkFontChooser](gtkfontchooser#GtkFontChooser-struct) *fontchooser`*);
```
Gets the custom font map of this font chooser widget, or `NULL` if it does not have one.
#### Parameters
| | | |
| --- | --- | --- |
| fontchooser | a [GtkFontChooser](gtkfontchooser#GtkFontChooser-struct) | |
#### Returns
a [PangoFontMap](https://developer-old.gnome.org/pango/stable/pango-Fonts.html#PangoFontMap-struct), or `NULL`.
[nullable][transfer full]
Types and Values
----------------
### GtkFontChooser
```
typedef struct _GtkFontChooser GtkFontChooser;
```
### enum GtkFontChooserLevel
This enumeration specifies the granularity of font selection that is desired in a font chooser.
This enumeration may be extended in the future; applications should ignore unknown values.
#### Members
| | | |
| --- | --- | --- |
| GTK\_FONT\_CHOOSER\_LEVEL\_FAMILY | Allow selecting a font family | |
| GTK\_FONT\_CHOOSER\_LEVEL\_STYLE | Allow selecting a specific font face | |
| GTK\_FONT\_CHOOSER\_LEVEL\_SIZE | Allow selecting a specific font size | |
| GTK\_FONT\_CHOOSER\_LEVEL\_VARIATIONS | Allow changing OpenType font variation axes | |
| GTK\_FONT\_CHOOSER\_LEVEL\_FEATURES | Allow selecting specific OpenType font features | |
Property Details
----------------
### The `“font”` property
```
“font” char *
```
The font description as a string, e.g. "Sans Italic 12".
Owner: GtkFontChooser
Flags: Read / Write
Default value: "Sans 10"
### The `“font-desc”` property
```
“font-desc” [PangoFontDescription](https://developer-old.gnome.org/pango/stable/pango-Fonts.html#PangoFontDescription-struct) *
```
The font description as a [PangoFontDescription](https://developer-old.gnome.org/pango/stable/pango-Fonts.html#PangoFontDescription-struct).
Owner: GtkFontChooser
Flags: Read / Write
### The `“font-features”` property
```
“font-features” char *
```
The selected font features, in a format that is compatible with CSS and with Pango attributes.
Owner: GtkFontChooser
Flags: Read
Default value: ""
### The `“language”` property
```
“language” char *
```
The language for which the [“font-features”](gtkfontchooser#GtkFontChooser--font-features) were selected, in a format that is compatible with CSS and with Pango attributes.
Owner: GtkFontChooser
Flags: Read / Write
Default value: ""
### The `“level”` property
```
“level” [GtkFontChooserLevel](gtkfontchooser#GtkFontChooserLevel)
```
The level of granularity to offer for selecting fonts.
Owner: GtkFontChooser
Flags: Read / Write
Default value: GTK\_FONT\_CHOOSER\_LEVEL\_STYLE | GTK\_FONT\_CHOOSER\_LEVEL\_SIZE
### The `“preview-text”` property
```
“preview-text” char *
```
The string with which to preview the font.
Owner: GtkFontChooser
Flags: Read / Write
Default value: "The quick brown fox jumps over the lazy dog."
### The `“show-preview-entry”` property
```
“show-preview-entry” gboolean
```
Whether to show an entry to change the preview text.
Owner: GtkFontChooser
Flags: Read / Write
Default value: TRUE
Signal Details
--------------
### The `“font-activated”` signal
```
void
user_function ([GtkFontChooser](gtkfontchooser#GtkFontChooser-struct) *self,
char *fontname,
gpointer user_data)
```
Emitted when a font is activated. This usually happens when the user double clicks an item, or an item is selected and the user presses one of the keys Space, Shift+Space, Return or Enter.
#### Parameters
| | | |
| --- | --- | --- |
| self | the object which received the signal | |
| fontname | the font name | |
| user\_data | user data set when the signal handler was connected. | |
Flags: Run First
See Also
--------
[GtkFontChooserDialog](gtkfontchooserdialog#GtkFontChooserDialog-struct), [GtkFontChooserWidget](gtkfontchooserwidget#GtkFontChooserWidget-struct), [GtkFontButton](gtkfontbutton#GtkFontButton-struct)
| programming_docs |
gtk Using GTK on Windows Using GTK on Windows
====================
[Windows-specific environment variables](gtk-windows#win32-envar) [GDK\_IGNORE\_WINTAB](gtk-windows#id-1.9.6.4.3) [GDK\_USE\_WINTAB](gtk-windows#id-1.9.6.4.4) [Windows-specific handling of cursors](win32-cursors) The Windows port of GTK is an implementation of GDK (and therefore GTK) on top of the Win32 API. When compiling GTK on Windows, this backend is the default.
More information about GTK on Windows, including detailed build instructions, binary downloads, etc, can be found [online](https://wiki.gnome.org/Projects/GTK/Win32).
The Win32 GDK backend can be influenced with some additional environment variables.
### GDK\_IGNORE\_WINTAB
If this variable is set, GTK doesn’t use the Wintab API for tablet support.
### GDK\_USE\_WINTAB
If this variable is set, GTK uses the Wintab API for tablet support. This is the default.
gtk GtkIMContextSimple GtkIMContextSimple
==================
GtkIMContextSimple — An input method context supporting table-based input methods
Functions
---------
| | |
| --- | --- |
| [GtkIMContext](gtkimcontext#GtkIMContext-struct) \* | [gtk\_im\_context\_simple\_new](gtkimcontextsimple#gtk-im-context-simple-new) () |
| void | [gtk\_im\_context\_simple\_add\_table](gtkimcontextsimple#gtk-im-context-simple-add-table) () |
| void | [gtk\_im\_context\_simple\_add\_compose\_file](gtkimcontextsimple#gtk-im-context-simple-add-compose-file) () |
Types and Values
----------------
| | |
| --- | --- |
| struct | [GtkIMContextSimple](gtkimcontextsimple#GtkIMContextSimple-struct) |
| #define | [GTK\_MAX\_COMPOSE\_LEN](gtkimcontextsimple#GTK-MAX-COMPOSE-LEN:CAPS) |
Object Hierarchy
----------------
```
GObject
╰── [GtkIMContext](gtkimcontext#GtkIMContext-struct)
╰── GtkIMContextSimple
```
Includes
--------
```
#include <gtk/gtk.h>
```
Description
-----------
GtkIMContextSimple is a simple input method context supporting table-based input methods. It has a built-in table of compose sequences that is derived from the X11 Compose files.
GtkIMContextSimple reads additional compose sequences from the first of the following files that is found: ~/.config/gtk-4.0/Compose, ~/.XCompose, /usr/share/X11/locale/$locale/Compose (for locales that have a nontrivial Compose file). The syntax of these files is described in the Compose(5) manual page.
#### Unicode characters
GtkIMContextSimple also supports numeric entry of Unicode characters by typing Ctrl-Shift-u, followed by a hexadecimal Unicode codepoint. For example, Ctrl-Shift-u 1 2 3 Enter yields U+0123 LATIN SMALL LETTER G WITH CEDILLA, i.e. ģ.
Functions
---------
### gtk\_im\_context\_simple\_new ()
```
[GtkIMContext](gtkimcontext#GtkIMContext-struct) *
gtk_im_context_simple_new (*`void`*);
```
Creates a new [GtkIMContextSimple](gtkimcontextsimple#GtkIMContextSimple-struct).
#### Returns
a new [GtkIMContextSimple](gtkimcontextsimple#GtkIMContextSimple-struct).
### gtk\_im\_context\_simple\_add\_table ()
```
void
gtk_im_context_simple_add_table (*`[GtkIMContextSimple](gtkimcontextsimple#GtkIMContextSimple-struct) *context_simple`*,
*`guint16 *data`*,
*`int max_seq_len`*,
*`int n_seqs`*);
```
Adds an additional table to search to the input context. Each row of the table consists of *`max_seq_len`* key symbols followed by two guint16 interpreted as the high and low words of a gunicode value. Tables are searched starting from the last added.
The table must be sorted in dictionary order on the numeric value of the key symbol fields. (Values beyond the length of the sequence should be zero.)
[skip]
#### Parameters
| | | |
| --- | --- | --- |
| context\_simple | A [GtkIMContextSimple](gtkimcontextsimple#GtkIMContextSimple-struct) | |
| data | the table. | [array] |
| max\_seq\_len | Maximum length of a sequence in the table (cannot be greater than [GTK\_MAX\_COMPOSE\_LEN](gtkimcontextsimple#GTK-MAX-COMPOSE-LEN:CAPS)) | |
| n\_seqs | number of sequences in the table | |
### gtk\_im\_context\_simple\_add\_compose\_file ()
```
void
gtk_im_context_simple_add_compose_file
(*`[GtkIMContextSimple](gtkimcontextsimple#GtkIMContextSimple-struct) *context_simple`*,
*`const char *compose_file`*);
```
Adds an additional table from the X11 compose file.
#### Parameters
| | | |
| --- | --- | --- |
| context\_simple | A [GtkIMContextSimple](gtkimcontextsimple#GtkIMContextSimple-struct) | |
| compose\_file | The path of compose file | |
Types and Values
----------------
### struct GtkIMContextSimple
```
struct GtkIMContextSimple;
```
### GTK\_MAX\_COMPOSE\_LEN
```
#define GTK_MAX_COMPOSE_LEN 7
```
The maximum length of sequences in compose tables.
gtk GtkGLArea GtkGLArea
=========
GtkGLArea — A widget for custom drawing with OpenGL
Functions
---------
| | |
| --- | --- |
| [GtkWidget](gtkwidget#GtkWidget-struct) \* | [gtk\_gl\_area\_new](gtkglarea#gtk-gl-area-new) () |
| [GdkGLContext](https://developer-old.gnome.org/gtk4/html/GdkGLContext.html#GdkGLContext-struct) \* | [gtk\_gl\_area\_get\_context](gtkglarea#gtk-gl-area-get-context) () |
| void | [gtk\_gl\_area\_make\_current](gtkglarea#gtk-gl-area-make-current) () |
| void | [gtk\_gl\_area\_queue\_render](gtkglarea#gtk-gl-area-queue-render) () |
| void | [gtk\_gl\_area\_attach\_buffers](gtkglarea#gtk-gl-area-attach-buffers) () |
| void | [gtk\_gl\_area\_set\_error](gtkglarea#gtk-gl-area-set-error) () |
| GError \* | [gtk\_gl\_area\_get\_error](gtkglarea#gtk-gl-area-get-error) () |
| void | [gtk\_gl\_area\_set\_has\_depth\_buffer](gtkglarea#gtk-gl-area-set-has-depth-buffer) () |
| gboolean | [gtk\_gl\_area\_get\_has\_depth\_buffer](gtkglarea#gtk-gl-area-get-has-depth-buffer) () |
| void | [gtk\_gl\_area\_set\_has\_stencil\_buffer](gtkglarea#gtk-gl-area-set-has-stencil-buffer) () |
| gboolean | [gtk\_gl\_area\_get\_has\_stencil\_buffer](gtkglarea#gtk-gl-area-get-has-stencil-buffer) () |
| void | [gtk\_gl\_area\_set\_auto\_render](gtkglarea#gtk-gl-area-set-auto-render) () |
| gboolean | [gtk\_gl\_area\_get\_auto\_render](gtkglarea#gtk-gl-area-get-auto-render) () |
| void | [gtk\_gl\_area\_get\_required\_version](gtkglarea#gtk-gl-area-get-required-version) () |
| void | [gtk\_gl\_area\_set\_required\_version](gtkglarea#gtk-gl-area-set-required-version) () |
| void | [gtk\_gl\_area\_set\_use\_es](gtkglarea#gtk-gl-area-set-use-es) () |
| gboolean | [gtk\_gl\_area\_get\_use\_es](gtkglarea#gtk-gl-area-get-use-es) () |
Properties
----------
| | | |
| --- | --- | --- |
| gboolean | [auto-render](gtkglarea#GtkGLArea--auto-render) | Read / Write |
| [GdkGLContext](https://developer-old.gnome.org/gtk4/html/GdkGLContext.html#GdkGLContext-struct) \* | [context](gtkglarea#GtkGLArea--context) | Read |
| gboolean | [has-depth-buffer](gtkglarea#GtkGLArea--has-depth-buffer) | Read / Write |
| gboolean | [has-stencil-buffer](gtkglarea#GtkGLArea--has-stencil-buffer) | Read / Write |
| gboolean | [use-es](gtkglarea#GtkGLArea--use-es) | Read / Write |
Signals
-------
| | | |
| --- | --- | --- |
| [GdkGLContext](https://developer-old.gnome.org/gtk4/html/GdkGLContext.html#GdkGLContext-struct)\* | [create-context](gtkglarea#GtkGLArea-create-context) | Run Last |
| gboolean | [render](gtkglarea#GtkGLArea-render) | Run Last |
| void | [resize](gtkglarea#GtkGLArea-resize) | Run Last |
Types and Values
----------------
| | |
| --- | --- |
| struct | [GtkGLArea](gtkglarea#GtkGLArea-struct) |
| struct | [GtkGLAreaClass](gtkglarea#GtkGLAreaClass) |
Object Hierarchy
----------------
```
GObject
╰── GInitiallyUnowned
╰── [GtkWidget](gtkwidget#GtkWidget-struct)
╰── GtkGLArea
```
Implemented Interfaces
----------------------
GtkGLArea implements [GtkAccessible](gtkaccessible#GtkAccessible-struct), [GtkBuildable](gtkbuildable#GtkBuildable-struct) and [GtkConstraintTarget](gtkconstraint#GtkConstraintTarget-struct).
Includes
--------
```
#include <gtk/gtk.h>
```
Description
-----------
[GtkGLArea](gtkglarea#GtkGLArea-struct) is a widget that allows drawing with OpenGL.
[GtkGLArea](gtkglarea#GtkGLArea-struct) sets up its own [GdkGLContext](https://developer-old.gnome.org/gtk4/html/GdkGLContext.html#GdkGLContext-struct) for the window it creates, and creates a custom GL framebuffer that the widget will do GL rendering onto. It also ensures that this framebuffer is the default GL rendering target when rendering.
In order to draw, you have to connect to the [“render”](gtkglarea#GtkGLArea-render) signal, or subclass [GtkGLArea](gtkglarea#GtkGLArea-struct) and override the *`GtkGLAreaClass.render()`* virtual function.
The [GtkGLArea](gtkglarea#GtkGLArea-struct) widget ensures that the [GdkGLContext](https://developer-old.gnome.org/gtk4/html/GdkGLContext.html#GdkGLContext-struct) is associated with the widget's drawing area, and it is kept updated when the size and position of the drawing area changes.
#### Drawing with GtkGLArea
The simplest way to draw using OpenGL commands in a [GtkGLArea](gtkglarea#GtkGLArea-struct) is to create a widget instance and connect to the [“render”](gtkglarea#GtkGLArea-render) signal:
The ``render()`` function will be called when the [GtkGLArea](gtkglarea#GtkGLArea-struct) is ready for you to draw its content:
If you need to initialize OpenGL state, e.g. buffer objects or shaders, you should use the [“realize”](gtkwidget#GtkWidget-realize) signal; you can use the [“unrealize”](gtkwidget#GtkWidget-unrealize) signal to clean up. Since the [GdkGLContext](https://developer-old.gnome.org/gtk4/html/GdkGLContext.html#GdkGLContext-struct) creation and initialization may fail, you will need to check for errors, using [`gtk_gl_area_get_error()`](gtkglarea#gtk-gl-area-get-error). An example of how to safely initialize the GL state is:
| If you need to change the options for creating the [GdkGLContext](https://developer-old.gnome.org/gtk4/html/GdkGLContext.html#GdkGLContext-struct) you should use the [“create-context”](gtkglarea#GtkGLArea-create-context) signal.
Functions
---------
### gtk\_gl\_area\_new ()
```
[GtkWidget](gtkwidget#GtkWidget-struct) *
gtk_gl_area_new (*`void`*);
```
Creates a new [GtkGLArea](gtkglarea#GtkGLArea-struct) widget.
#### Returns
a new [GtkGLArea](gtkglarea#GtkGLArea-struct)
### gtk\_gl\_area\_get\_context ()
```
[GdkGLContext](https://developer-old.gnome.org/gtk4/html/GdkGLContext.html#GdkGLContext-struct) *
gtk_gl_area_get_context (*`[GtkGLArea](gtkglarea#GtkGLArea-struct) *area`*);
```
Retrieves the [GdkGLContext](https://developer-old.gnome.org/gtk4/html/GdkGLContext.html#GdkGLContext-struct) used by *`area`* .
#### Parameters
| | | |
| --- | --- | --- |
| area | a [GtkGLArea](gtkglarea#GtkGLArea-struct) | |
#### Returns
the [GdkGLContext](https://developer-old.gnome.org/gtk4/html/GdkGLContext.html#GdkGLContext-struct).
[transfer none]
### gtk\_gl\_area\_make\_current ()
```
void
gtk_gl_area_make_current (*`[GtkGLArea](gtkglarea#GtkGLArea-struct) *area`*);
```
Ensures that the [GdkGLContext](https://developer-old.gnome.org/gtk4/html/GdkGLContext.html#GdkGLContext-struct) used by *`area`* is associated with the [GtkGLArea](gtkglarea#GtkGLArea-struct).
This function is automatically called before emitting the [“render”](gtkglarea#GtkGLArea-render) signal, and doesn't normally need to be called by application code.
#### Parameters
| | | |
| --- | --- | --- |
| area | a [GtkGLArea](gtkglarea#GtkGLArea-struct) | |
### gtk\_gl\_area\_queue\_render ()
```
void
gtk_gl_area_queue_render (*`[GtkGLArea](gtkglarea#GtkGLArea-struct) *area`*);
```
Marks the currently rendered data (if any) as invalid, and queues a redraw of the widget, ensuring that the [“render”](gtkglarea#GtkGLArea-render) signal is emitted during the draw.
This is only needed when the [`gtk_gl_area_set_auto_render()`](gtkglarea#gtk-gl-area-set-auto-render) has been called with a `FALSE` value. The default behaviour is to emit [“render”](gtkglarea#GtkGLArea-render) on each draw.
#### Parameters
| | | |
| --- | --- | --- |
| area | a [GtkGLArea](gtkglarea#GtkGLArea-struct) | |
### gtk\_gl\_area\_attach\_buffers ()
```
void
gtk_gl_area_attach_buffers (*`[GtkGLArea](gtkglarea#GtkGLArea-struct) *area`*);
```
Ensures that the *`area`* framebuffer object is made the current draw and read target, and that all the required buffers for the *`area`* are created and bound to the framebuffer.
This function is automatically called before emitting the [“render”](gtkglarea#GtkGLArea-render) signal, and doesn't normally need to be called by application code.
#### Parameters
| | | |
| --- | --- | --- |
| area | a [GtkGLArea](gtkglarea#GtkGLArea-struct) | |
### gtk\_gl\_area\_set\_error ()
```
void
gtk_gl_area_set_error (*`[GtkGLArea](gtkglarea#GtkGLArea-struct) *area`*,
*`const GError *error`*);
```
Sets an error on the area which will be shown instead of the GL rendering. This is useful in the [“create-context”](gtkglarea#GtkGLArea-create-context) signal if GL context creation fails.
#### Parameters
| | | |
| --- | --- | --- |
| area | a [GtkGLArea](gtkglarea#GtkGLArea-struct) | |
| error | a new GError, or `NULL` to unset the error. | [allow-none] |
### gtk\_gl\_area\_get\_error ()
```
GError *
gtk_gl_area_get_error (*`[GtkGLArea](gtkglarea#GtkGLArea-struct) *area`*);
```
Gets the current error set on the *`area`* .
#### Parameters
| | | |
| --- | --- | --- |
| area | a [GtkGLArea](gtkglarea#GtkGLArea-struct) | |
#### Returns
the GError or `NULL`.
[nullable][transfer none]
### gtk\_gl\_area\_set\_has\_depth\_buffer ()
```
void
gtk_gl_area_set_has_depth_buffer (*`[GtkGLArea](gtkglarea#GtkGLArea-struct) *area`*,
*`gboolean has_depth_buffer`*);
```
If *`has_depth_buffer`* is `TRUE` the widget will allocate and enable a depth buffer for the target framebuffer. Otherwise there will be none.
#### Parameters
| | | |
| --- | --- | --- |
| area | a [GtkGLArea](gtkglarea#GtkGLArea-struct) | |
| has\_depth\_buffer | `TRUE` to add a depth buffer | |
### gtk\_gl\_area\_get\_has\_depth\_buffer ()
```
gboolean
gtk_gl_area_get_has_depth_buffer (*`[GtkGLArea](gtkglarea#GtkGLArea-struct) *area`*);
```
Returns whether the area has a depth buffer.
#### Parameters
| | | |
| --- | --- | --- |
| area | a [GtkGLArea](gtkglarea#GtkGLArea-struct) | |
#### Returns
`TRUE` if the *`area`* has a depth buffer, `FALSE` otherwise
### gtk\_gl\_area\_set\_has\_stencil\_buffer ()
```
void
gtk_gl_area_set_has_stencil_buffer (*`[GtkGLArea](gtkglarea#GtkGLArea-struct) *area`*,
*`gboolean has_stencil_buffer`*);
```
If *`has_stencil_buffer`* is `TRUE` the widget will allocate and enable a stencil buffer for the target framebuffer. Otherwise there will be none.
#### Parameters
| | | |
| --- | --- | --- |
| area | a [GtkGLArea](gtkglarea#GtkGLArea-struct) | |
| has\_stencil\_buffer | `TRUE` to add a stencil buffer | |
### gtk\_gl\_area\_get\_has\_stencil\_buffer ()
```
gboolean
gtk_gl_area_get_has_stencil_buffer (*`[GtkGLArea](gtkglarea#GtkGLArea-struct) *area`*);
```
Returns whether the area has a stencil buffer.
#### Parameters
| | | |
| --- | --- | --- |
| area | a [GtkGLArea](gtkglarea#GtkGLArea-struct) | |
#### Returns
`TRUE` if the *`area`* has a stencil buffer, `FALSE` otherwise
### gtk\_gl\_area\_set\_auto\_render ()
```
void
gtk_gl_area_set_auto_render (*`[GtkGLArea](gtkglarea#GtkGLArea-struct) *area`*,
*`gboolean auto_render`*);
```
If *`auto_render`* is `TRUE` the [“render”](gtkglarea#GtkGLArea-render) signal will be emitted every time the widget draws. This is the default and is useful if drawing the widget is faster.
If *`auto_render`* is `FALSE` the data from previous rendering is kept around and will be used for drawing the widget the next time, unless the window is resized. In order to force a rendering [`gtk_gl_area_queue_render()`](gtkglarea#gtk-gl-area-queue-render) must be called. This mode is useful when the scene changes seldom, but takes a long time to redraw.
#### Parameters
| | | |
| --- | --- | --- |
| area | a [GtkGLArea](gtkglarea#GtkGLArea-struct) | |
| auto\_render | a boolean | |
### gtk\_gl\_area\_get\_auto\_render ()
```
gboolean
gtk_gl_area_get_auto_render (*`[GtkGLArea](gtkglarea#GtkGLArea-struct) *area`*);
```
Returns whether the area is in auto render mode or not.
#### Parameters
| | | |
| --- | --- | --- |
| area | a [GtkGLArea](gtkglarea#GtkGLArea-struct) | |
#### Returns
`TRUE` if the *`area`* is auto rendering, `FALSE` otherwise
### gtk\_gl\_area\_get\_required\_version ()
```
void
gtk_gl_area_get_required_version (*`[GtkGLArea](gtkglarea#GtkGLArea-struct) *area`*,
*`int *major`*,
*`int *minor`*);
```
Retrieves the required version of OpenGL set using [`gtk_gl_area_set_required_version()`](gtkglarea#gtk-gl-area-set-required-version).
#### Parameters
| | | |
| --- | --- | --- |
| area | a [GtkGLArea](gtkglarea#GtkGLArea-struct) | |
| major | return location for the required major version. | [out] |
| minor | return location for the required minor version. | [out] |
### gtk\_gl\_area\_set\_required\_version ()
```
void
gtk_gl_area_set_required_version (*`[GtkGLArea](gtkglarea#GtkGLArea-struct) *area`*,
*`int major`*,
*`int minor`*);
```
Sets the required version of OpenGL to be used when creating the context for the widget.
This function must be called before the area has been realized.
#### Parameters
| | | |
| --- | --- | --- |
| area | a [GtkGLArea](gtkglarea#GtkGLArea-struct) | |
| major | the major version | |
| minor | the minor version | |
### gtk\_gl\_area\_set\_use\_es ()
```
void
gtk_gl_area_set_use_es (*`[GtkGLArea](gtkglarea#GtkGLArea-struct) *area`*,
*`gboolean use_es`*);
```
Sets whether the *`area`* should create an OpenGL or an OpenGL ES context.
You should check the capabilities of the [GdkGLContext](https://developer-old.gnome.org/gtk4/html/GdkGLContext.html#GdkGLContext-struct) before drawing with either API.
#### Parameters
| | | |
| --- | --- | --- |
| area | a [GtkGLArea](gtkglarea#GtkGLArea-struct) | |
| use\_es | whether to use OpenGL or OpenGL ES | |
### gtk\_gl\_area\_get\_use\_es ()
```
gboolean
gtk_gl_area_get_use_es (*`[GtkGLArea](gtkglarea#GtkGLArea-struct) *area`*);
```
Retrieves the value set by [`gtk_gl_area_set_use_es()`](gtkglarea#gtk-gl-area-set-use-es).
#### Parameters
| | | |
| --- | --- | --- |
| area | a [GtkGLArea](gtkglarea#GtkGLArea-struct) | |
#### Returns
`TRUE` if the [GtkGLArea](gtkglarea#GtkGLArea-struct) should create an OpenGL ES context and `FALSE` otherwise
Types and Values
----------------
### struct GtkGLArea
```
struct GtkGLArea;
```
A [GtkWidget](gtkwidget#GtkWidget-struct) used for drawing with OpenGL.
### struct GtkGLAreaClass
```
struct GtkGLAreaClass {
gboolean (* render) (GtkGLArea *area,
GdkGLContext *context);
void (* resize) (GtkGLArea *area,
int width,
int height);
GdkGLContext * (* create_context) (GtkGLArea *area);
};
```
The `GtkGLAreaClass` structure contains only private data.
#### Members
| | | |
| --- | --- | --- |
| *`render`* () | class closure for the [“render”](gtkglarea#GtkGLArea-render) signal | |
| *`resize`* () | class closeure for the [“resize”](gtkglarea#GtkGLArea-resize) signal | |
| *`create_context`* () | class closure for the [“create-context”](gtkglarea#GtkGLArea-create-context) signal | |
Property Details
----------------
### The `“auto-render”` property
```
“auto-render” gboolean
```
If set to `TRUE` the [“render”](gtkglarea#GtkGLArea-render) signal will be emitted every time the widget draws. This is the default and is useful if drawing the widget is faster.
If set to `FALSE` the data from previous rendering is kept around and will be used for drawing the widget the next time, unless the window is resized. In order to force a rendering [`gtk_gl_area_queue_render()`](gtkglarea#gtk-gl-area-queue-render) must be called. This mode is useful when the scene changes seldom, but takes a long time to redraw.
Owner: GtkGLArea
Flags: Read / Write
Default value: TRUE
### The `“context”` property
```
“context” [GdkGLContext](https://developer-old.gnome.org/gtk4/html/GdkGLContext.html#GdkGLContext-struct) *
```
The [GdkGLContext](https://developer-old.gnome.org/gtk4/html/GdkGLContext.html#GdkGLContext-struct) used by the [GtkGLArea](gtkglarea#GtkGLArea-struct) widget.
The [GtkGLArea](gtkglarea#GtkGLArea-struct) widget is responsible for creating the [GdkGLContext](https://developer-old.gnome.org/gtk4/html/GdkGLContext.html#GdkGLContext-struct) instance. If you need to render with other kinds of buffers (stencil, depth, etc), use render buffers.
Owner: GtkGLArea
Flags: Read
### The `“has-depth-buffer”` property
```
“has-depth-buffer” gboolean
```
If set to `TRUE` the widget will allocate and enable a depth buffer for the target framebuffer.
Owner: GtkGLArea
Flags: Read / Write
Default value: FALSE
### The `“has-stencil-buffer”` property
```
“has-stencil-buffer” gboolean
```
If set to `TRUE` the widget will allocate and enable a stencil buffer for the target framebuffer.
Owner: GtkGLArea
Flags: Read / Write
Default value: FALSE
### The `“use-es”` property
```
“use-es” gboolean
```
If set to `TRUE` the widget will try to create a [GdkGLContext](https://developer-old.gnome.org/gtk4/html/GdkGLContext.html#GdkGLContext-struct) using OpenGL ES instead of OpenGL.
See also: [`gdk_gl_context_set_use_es()`](https://developer-old.gnome.org/gtk4/html/GdkGLContext.html#gdk-gl-context-set-use-es)
Owner: GtkGLArea
Flags: Read / Write
Default value: FALSE
Signal Details
--------------
### The `“create-context”` signal
```
[GdkGLContext](https://developer-old.gnome.org/gtk4/html/GdkGLContext.html#GdkGLContext-struct)*
user_function ([GtkGLArea](gtkglarea#GtkGLArea-struct) *area,
gpointer user_data)
```
The ::create-context signal is emitted when the widget is being realized, and allows you to override how the GL context is created. This is useful when you want to reuse an existing GL context, or if you want to try creating different kinds of GL options.
If context creation fails then the signal handler can use [`gtk_gl_area_set_error()`](gtkglarea#gtk-gl-area-set-error) to register a more detailed error of how the construction failed.
#### Parameters
| | | |
| --- | --- | --- |
| area | the [GtkGLArea](gtkglarea#GtkGLArea-struct) that emitted the signal | |
| error | location to store error information on failure. | [allow-none] |
| user\_data | user data set when the signal handler was connected. | |
#### Returns
a newly created [GdkGLContext](https://developer-old.gnome.org/gtk4/html/GdkGLContext.html#GdkGLContext-struct); the [GtkGLArea](gtkglarea#GtkGLArea-struct) widget will take ownership of the returned value.
[transfer full]
Flags: Run Last
### The `“render”` signal
```
gboolean
user_function ([GtkGLArea](gtkglarea#GtkGLArea-struct) *area,
[GdkGLContext](https://developer-old.gnome.org/gtk4/html/GdkGLContext.html#GdkGLContext-struct) *context,
gpointer user_data)
```
The ::render signal is emitted every time the contents of the [GtkGLArea](gtkglarea#GtkGLArea-struct) should be redrawn.
The *`context`* is bound to the *`area`* prior to emitting this function, and the buffers are painted to the window once the emission terminates.
#### Parameters
| | | |
| --- | --- | --- |
| area | the [GtkGLArea](gtkglarea#GtkGLArea-struct) that emitted the signal | |
| context | the [GdkGLContext](https://developer-old.gnome.org/gtk4/html/GdkGLContext.html#GdkGLContext-struct) used by *`area`* | |
| user\_data | user data set when the signal handler was connected. | |
#### Returns
`TRUE` to stop other handlers from being invoked for the event. `FALSE` to propagate the event further.
Flags: Run Last
### The `“resize”` signal
```
void
user_function ([GtkGLArea](gtkglarea#GtkGLArea-struct) *area,
int width,
int height,
gpointer user_data)
```
The ::resize signal is emitted once when the widget is realized, and then each time the widget is changed while realized. This is useful in order to keep GL state up to date with the widget size, like for instance camera properties which may depend on the width/height ratio.
The GL context for the area is guaranteed to be current when this signal is emitted.
The default handler sets up the GL viewport.
#### Parameters
| | | |
| --- | --- | --- |
| area | the [GtkGLArea](gtkglarea#GtkGLArea-struct) that emitted the signal | |
| width | the width of the viewport | |
| height | the height of the viewport | |
| user\_data | user data set when the signal handler was connected. | |
Flags: Run Last
| programming_docs |
gtk GtkPopover GtkPopover
==========
GtkPopover — Context dependent bubbles
Functions
---------
| | |
| --- | --- |
| [GtkWidget](gtkwidget#GtkWidget-struct) \* | [gtk\_popover\_new](gtkpopover#gtk-popover-new) () |
| void | [gtk\_popover\_popup](gtkpopover#gtk-popover-popup) () |
| void | [gtk\_popover\_popdown](gtkpopover#gtk-popover-popdown) () |
| void | [gtk\_popover\_present](gtkpopover#gtk-popover-present) () |
| void | [gtk\_popover\_set\_child](gtkpopover#gtk-popover-set-child) () |
| [GtkWidget](gtkwidget#GtkWidget-struct) \* | [gtk\_popover\_get\_child](gtkpopover#gtk-popover-get-child) () |
| void | [gtk\_popover\_set\_pointing\_to](gtkpopover#gtk-popover-set-pointing-to) () |
| gboolean | [gtk\_popover\_get\_pointing\_to](gtkpopover#gtk-popover-get-pointing-to) () |
| void | [gtk\_popover\_set\_position](gtkpopover#gtk-popover-set-position) () |
| [GtkPositionType](gtk4-standard-enumerations#GtkPositionType) | [gtk\_popover\_get\_position](gtkpopover#gtk-popover-get-position) () |
| void | [gtk\_popover\_set\_autohide](gtkpopover#gtk-popover-set-autohide) () |
| gboolean | [gtk\_popover\_get\_autohide](gtkpopover#gtk-popover-get-autohide) () |
| void | [gtk\_popover\_set\_has\_arrow](gtkpopover#gtk-popover-set-has-arrow) () |
| gboolean | [gtk\_popover\_get\_has\_arrow](gtkpopover#gtk-popover-get-has-arrow) () |
| void | [gtk\_popover\_set\_offset](gtkpopover#gtk-popover-set-offset) () |
| void | [gtk\_popover\_get\_offset](gtkpopover#gtk-popover-get-offset) () |
| void | [gtk\_popover\_set\_default\_widget](gtkpopover#gtk-popover-set-default-widget) () |
| void | [gtk\_popover\_set\_cascade\_popdown](gtkpopover#gtk-popover-set-cascade-popdown) () |
| gboolean | [gtk\_popover\_get\_cascade\_popdown](gtkpopover#gtk-popover-get-cascade-popdown) () |
| gboolean | [gtk\_popover\_get\_mnemonics\_visible](gtkpopover#gtk-popover-get-mnemonics-visible) () |
| void | [gtk\_popover\_set\_mnemonics\_visible](gtkpopover#gtk-popover-set-mnemonics-visible) () |
Properties
----------
| | | |
| --- | --- | --- |
| gboolean | [autohide](gtkpopover#GtkPopover--autohide) | Read / Write |
| gboolean | [cascade-popdown](gtkpopover#GtkPopover--cascade-popdown) | Read / Write |
| [GtkWidget](gtkwidget#GtkWidget-struct) \* | [child](gtkpopover#GtkPopover--child) | Read / Write |
| [GtkWidget](gtkwidget#GtkWidget-struct) \* | [default-widget](gtkpopover#GtkPopover--default-widget) | Read / Write |
| gboolean | [has-arrow](gtkpopover#GtkPopover--has-arrow) | Read / Write |
| gboolean | [mnemonics-visible](gtkpopover#GtkPopover--mnemonics-visible) | Read / Write |
| [GdkRectangle](https://developer-old.gnome.org/gtk4/html/gdk4-Rectangles-and-Regions.html#GdkRectangle-struct) \* | [pointing-to](gtkpopover#GtkPopover--pointing-to) | Read / Write |
| [GtkPositionType](gtk4-standard-enumerations#GtkPositionType) | [position](gtkpopover#GtkPopover--position) | Read / Write |
Signals
-------
| | | |
| --- | --- | --- |
| void | [activate-default](gtkpopover#GtkPopover-activate-default) | Action |
| void | [closed](gtkpopover#GtkPopover-closed) | Run Last |
Types and Values
----------------
| | |
| --- | --- |
| struct | [GtkPopover](gtkpopover#GtkPopover-struct) |
Object Hierarchy
----------------
```
GObject
╰── GInitiallyUnowned
╰── [GtkWidget](gtkwidget#GtkWidget-struct)
╰── GtkPopover
├── [GtkEmojiChooser](gtkemojichooser#GtkEmojiChooser-struct)
╰── [GtkPopoverMenu](gtkpopovermenu#GtkPopoverMenu-struct)
```
Implemented Interfaces
----------------------
GtkPopover implements [GtkAccessible](gtkaccessible#GtkAccessible-struct), [GtkBuildable](gtkbuildable#GtkBuildable-struct), [GtkConstraintTarget](gtkconstraint#GtkConstraintTarget-struct), [GtkShortcutManager](gtkshortcutmanager#GtkShortcutManager-struct) and [GtkNative](gtknative#GtkNative-struct).
Includes
--------
```
#include <gtk/gtk.h>
```
Description
-----------
GtkPopover is a bubble-like context window, primarily meant to provide context-dependent information or options. Popovers are attached to a widget, set with [`gtk_widget_set_parent()`](gtkwidget#gtk-widget-set-parent). By default they will point to the whole widget area, although this behavior can be changed through [`gtk_popover_set_pointing_to()`](gtkpopover#gtk-popover-set-pointing-to).
The position of a popover relative to the widget it is attached to can also be changed through [`gtk_popover_set_position()`](gtkpopover#gtk-popover-set-position).
By default, [GtkPopover](gtkpopover#GtkPopover-struct) performs a grab, in order to ensure input events get redirected to it while it is shown, and also so the popover is dismissed in the expected situations (clicks outside the popover, or the Escape key being pressed). If no such modal behavior is desired on a popover, [`gtk_popover_set_autohide()`](gtkpopover#gtk-popover-set-autohide) may be called on it to tweak its behavior.
#### GtkPopover as menu replacement
GtkPopover is often used to replace menus. The best was to do this is to use the [GtkPopoverMenu](gtkpopovermenu#GtkPopoverMenu-struct) subclass which supports being populated from a GMenuModel with [`gtk_popover_menu_new_from_model()`](gtkpopovermenu#gtk-popover-menu-new-from-model).
### CSS nodes
```
<section>
<attribute name="display-hint">horizontal-buttons</attribute>
<item>
<attribute name="label">Cut</attribute>
<attribute name="action">app.cut</attribute>
<attribute name="verb-icon">edit-cut-symbolic</attribute>
</item>
<item>
<attribute name="label">Copy</attribute>
<attribute name="action">app.copy</attribute>
<attribute name="verb-icon">edit-copy-symbolic</attribute>
</item>
<item>
<attribute name="label">Paste</attribute>
<attribute name="action">app.paste</attribute>
<attribute name="verb-icon">edit-paste-symbolic</attribute>
</item>
</section>
```
| The contents child node always gets the .background style class and the popover itself gets the .menu style class if the popover is menu-like (i.e. [GtkPopoverMenu](gtkpopovermenu#GtkPopoverMenu-struct)).
Particular uses of GtkPopover, such as touch selection popups or magnifiers in [GtkEntry](gtkentry#GtkEntry-struct) or [GtkTextView](gtktextview#GtkTextView-struct) get style classes like .touch-selection or .magnifier to differentiate from plain popovers.
When styling a popover directly, the popover node should usually not have any background.
Note that, in order to accomplish appropriate arrow visuals, [GtkPopover](gtkpopover#GtkPopover-struct) uses custom drawing for the arrow node. This makes it possible for the arrow to change its shape dynamically, but it also limits the possibilities of styling it using CSS. In particular, the arrow gets drawn over the content node's border so they look like one shape, which means that the border-width of the content node and the arrow node should be the same. The arrow also does not support any border shape other than solid, no border-radius, only one border width (border-bottom-width is used) and no box-shadow.
Functions
---------
### gtk\_popover\_new ()
```
[GtkWidget](gtkwidget#GtkWidget-struct) *
gtk_popover_new (*`void`*);
```
Creates a new popover.
#### Returns
the new popover
### gtk\_popover\_popup ()
```
void
gtk_popover_popup (*`[GtkPopover](gtkpopover#GtkPopover-struct) *popover`*);
```
Pops *`popover`* up. This is different than a [`gtk_widget_show()`](gtkwidget#gtk-widget-show) call in that it shows the popover with a transition. If you want to show the popover without a transition, use [`gtk_widget_show()`](gtkwidget#gtk-widget-show).
#### Parameters
| | | |
| --- | --- | --- |
| popover | a [GtkPopover](gtkpopover#GtkPopover-struct) | |
### gtk\_popover\_popdown ()
```
void
gtk_popover_popdown (*`[GtkPopover](gtkpopover#GtkPopover-struct) *popover`*);
```
Pops *`popover`* down.This is different than a [`gtk_widget_hide()`](gtkwidget#gtk-widget-hide) call in that it shows the popover with a transition. If you want to hide the popover without a transition, use [`gtk_widget_hide()`](gtkwidget#gtk-widget-hide).
#### Parameters
| | | |
| --- | --- | --- |
| popover | a [GtkPopover](gtkpopover#GtkPopover-struct) | |
### gtk\_popover\_present ()
```
void
gtk_popover_present (*`[GtkPopover](gtkpopover#GtkPopover-struct) *popover`*);
```
Presents the popover to the user.
#### Parameters
| | | |
| --- | --- | --- |
| popover | a [GtkPopover](gtkpopover#GtkPopover-struct) | |
### gtk\_popover\_set\_child ()
```
void
gtk_popover_set_child (*`[GtkPopover](gtkpopover#GtkPopover-struct) *popover`*,
*`[GtkWidget](gtkwidget#GtkWidget-struct) *child`*);
```
Sets the child widget of *`popover`* .
#### Parameters
| | | |
| --- | --- | --- |
| popover | a [GtkPopover](gtkpopover#GtkPopover-struct) | |
| child | the child widget. | [allow-none] |
### gtk\_popover\_get\_child ()
```
[GtkWidget](gtkwidget#GtkWidget-struct) *
gtk_popover_get_child (*`[GtkPopover](gtkpopover#GtkPopover-struct) *popover`*);
```
Gets the child widget of *`popover`* .
#### Parameters
| | | |
| --- | --- | --- |
| popover | a [GtkPopover](gtkpopover#GtkPopover-struct) | |
#### Returns
the child widget of *`popover`* .
[nullable][transfer none]
### gtk\_popover\_set\_pointing\_to ()
```
void
gtk_popover_set_pointing_to (*`[GtkPopover](gtkpopover#GtkPopover-struct) *popover`*,
*`const [GdkRectangle](https://developer-old.gnome.org/gtk4/html/gdk4-Rectangles-and-Regions.html#GdkRectangle-struct) *rect`*);
```
Sets the rectangle that *`popover`* will point to, in the coordinate space of the *`popover`* parent.
#### Parameters
| | | |
| --- | --- | --- |
| popover | a [GtkPopover](gtkpopover#GtkPopover-struct) | |
| rect | rectangle to point to | |
### gtk\_popover\_get\_pointing\_to ()
```
gboolean
gtk_popover_get_pointing_to (*`[GtkPopover](gtkpopover#GtkPopover-struct) *popover`*,
*`[GdkRectangle](https://developer-old.gnome.org/gtk4/html/gdk4-Rectangles-and-Regions.html#GdkRectangle-struct) *rect`*);
```
If a rectangle to point to has been set, this function will return `TRUE` and fill in *`rect`* with such rectangle, otherwise it will return `FALSE` and fill in *`rect`* with the attached widget coordinates.
#### Parameters
| | | |
| --- | --- | --- |
| popover | a [GtkPopover](gtkpopover#GtkPopover-struct) | |
| rect | location to store the rectangle. | [out] |
#### Returns
`TRUE` if a rectangle to point to was set.
### gtk\_popover\_set\_position ()
```
void
gtk_popover_set_position (*`[GtkPopover](gtkpopover#GtkPopover-struct) *popover`*,
*`[GtkPositionType](gtk4-standard-enumerations#GtkPositionType) position`*);
```
Sets the preferred position for *`popover`* to appear. If the *`popover`* is currently visible, it will be immediately updated.
This preference will be respected where possible, although on lack of space (eg. if close to the window edges), the [GtkPopover](gtkpopover#GtkPopover-struct) may choose to appear on the opposite side
#### Parameters
| | | |
| --- | --- | --- |
| popover | a [GtkPopover](gtkpopover#GtkPopover-struct) | |
| position | preferred popover position | |
### gtk\_popover\_get\_position ()
```
[GtkPositionType](gtk4-standard-enumerations#GtkPositionType)
gtk_popover_get_position (*`[GtkPopover](gtkpopover#GtkPopover-struct) *popover`*);
```
Returns the preferred position of *`popover`* .
#### Parameters
| | | |
| --- | --- | --- |
| popover | a [GtkPopover](gtkpopover#GtkPopover-struct) | |
#### Returns
The preferred position.
### gtk\_popover\_set\_autohide ()
```
void
gtk_popover_set_autohide (*`[GtkPopover](gtkpopover#GtkPopover-struct) *popover`*,
*`gboolean autohide`*);
```
Sets whether *`popover`* is modal.
A modal popover will grab the keyboard focus on it when being displayed. Clicking outside the popover area or pressing Esc will dismiss the popover.
Called this function on an already showing popup with a new autohide value different from the current one, will cause the popup to be hidden.
#### Parameters
| | | |
| --- | --- | --- |
| popover | a [GtkPopover](gtkpopover#GtkPopover-struct) | |
| autohide | TRUE to dismiss the popover on outside clicks | |
### gtk\_popover\_get\_autohide ()
```
gboolean
gtk_popover_get_autohide (*`[GtkPopover](gtkpopover#GtkPopover-struct) *popover`*);
```
Returns whether the popover is modal.
See [`gtk_popover_set_autohide()`](gtkpopover#gtk-popover-set-autohide) for the implications of this.
#### Parameters
| | | |
| --- | --- | --- |
| popover | a [GtkPopover](gtkpopover#GtkPopover-struct) | |
#### Returns
TRUE if *`popover`* is modal
### gtk\_popover\_set\_has\_arrow ()
```
void
gtk_popover_set_has_arrow (*`[GtkPopover](gtkpopover#GtkPopover-struct) *popover`*,
*`gboolean has_arrow`*);
```
Sets whether this popover should draw an arrow pointing at the widget it is relative to.
#### Parameters
| | | |
| --- | --- | --- |
| popover | a [GtkPopover](gtkpopover#GtkPopover-struct) | |
| has\_arrow | `TRUE` to draw an arrow | |
### gtk\_popover\_get\_has\_arrow ()
```
gboolean
gtk_popover_get_has_arrow (*`[GtkPopover](gtkpopover#GtkPopover-struct) *popover`*);
```
Gets whether this popover is showing an arrow pointing at the widget that it is relative to.
#### Parameters
| | | |
| --- | --- | --- |
| popover | a [GtkPopover](gtkpopover#GtkPopover-struct) | |
#### Returns
whether the popover has an arrow
### gtk\_popover\_set\_offset ()
```
void
gtk_popover_set_offset (*`[GtkPopover](gtkpopover#GtkPopover-struct) *popover`*,
*`int x_offset`*,
*`int y_offset`*);
```
Sets the offset to use when calculating the position of the popover.
These values are used when preparing the GtkPopupLayout for positioning the popover.
#### Parameters
| | | |
| --- | --- | --- |
| popover | a [GtkPopover](gtkpopover#GtkPopover-struct) | |
| x\_offset | the x offset to adjust the position by | |
| y\_offset | the y offset to adjust the position by | |
### gtk\_popover\_get\_offset ()
```
void
gtk_popover_get_offset (*`[GtkPopover](gtkpopover#GtkPopover-struct) *popover`*,
*`int *x_offset`*,
*`int *y_offset`*);
```
Gets the offset previous set with [`gtk_popover_set_offset()`](gtkpopover#gtk-popover-set-offset).
#### Parameters
| | | |
| --- | --- | --- |
| popover | a [GtkPopover](gtkpopover#GtkPopover-struct) | |
| x\_offset | a location for the x\_offset. | [out][nullable] |
| y\_offset | a location for the y\_offset. | [out][nullable] |
### gtk\_popover\_set\_default\_widget ()
```
void
gtk_popover_set_default_widget (*`[GtkPopover](gtkpopover#GtkPopover-struct) *popover`*,
*`[GtkWidget](gtkwidget#GtkWidget-struct) *widget`*);
```
The default widget is the widget that’s activated when the user presses Enter in a dialog (for example). This function sets or unsets the default widget for a [GtkPopover](gtkpopover#GtkPopover-struct).
#### Parameters
| | | |
| --- | --- | --- |
| popover | a [GtkPopover](gtkpopover#GtkPopover-struct) | |
| widget | a child widget of *`popover`* to set as the default, or `NULL` to unset the default widget for the popover. | [allow-none] |
### gtk\_popover\_set\_cascade\_popdown ()
```
void
gtk_popover_set_cascade_popdown (*`[GtkPopover](gtkpopover#GtkPopover-struct) *popover`*,
*`gboolean cascade_popdown`*);
```
If *`cascade_popdown`* is TRUE, the popover will be closed when a child modal popover is closed. If FALSE, *`popover`* will stay visible.
#### Parameters
| | | |
| --- | --- | --- |
| popover | A [GtkPopover](gtkpopover#GtkPopover-struct) | |
| cascade\_popdown | TRUE if the popover should follow a child closing | |
### gtk\_popover\_get\_cascade\_popdown ()
```
gboolean
gtk_popover_get_cascade_popdown (*`[GtkPopover](gtkpopover#GtkPopover-struct) *popover`*);
```
Returns whether the popover will close after a modal child is closed.
#### Parameters
| | | |
| --- | --- | --- |
| popover | a [GtkPopover](gtkpopover#GtkPopover-struct) | |
#### Returns
TRUE if *`popover`* will close after a modal child.
### gtk\_popover\_get\_mnemonics\_visible ()
```
gboolean
gtk_popover_get_mnemonics_visible (*`[GtkPopover](gtkpopover#GtkPopover-struct) *popover`*);
```
Gets the value of the [“mnemonics-visible”](gtkpopover#GtkPopover--mnemonics-visible) property.
#### Parameters
| | | |
| --- | --- | --- |
| popover | a [GtkPopover](gtkpopover#GtkPopover-struct) | |
#### Returns
`TRUE` if mnemonics are supposed to be visible in this popover
### gtk\_popover\_set\_mnemonics\_visible ()
```
void
gtk_popover_set_mnemonics_visible (*`[GtkPopover](gtkpopover#GtkPopover-struct) *popover`*,
*`gboolean mnemonics_visible`*);
```
Sets the [“mnemonics-visible”](gtkpopover#GtkPopover--mnemonics-visible) property.
#### Parameters
| | | |
| --- | --- | --- |
| popover | a [GtkPopover](gtkpopover#GtkPopover-struct) | |
| mnemonics\_visible | the new value | |
Types and Values
----------------
### struct GtkPopover
```
struct GtkPopover;
```
Property Details
----------------
### The `“autohide”` property
```
“autohide” gboolean
```
Whether to dismiss the popover on outside clicks.
Owner: GtkPopover
Flags: Read / Write
Default value: TRUE
### The `“cascade-popdown”` property
```
“cascade-popdown” gboolean
```
Whether the popover pops down after a child popover.
Owner: GtkPopover
Flags: Read / Write
Default value: FALSE
### The `“child”` property
```
“child” [GtkWidget](gtkwidget#GtkWidget-struct) *
```
The child widget.
Owner: GtkPopover
Flags: Read / Write
### The `“default-widget”` property
```
“default-widget” [GtkWidget](gtkwidget#GtkWidget-struct) *
```
The default widget.
Owner: GtkPopover
Flags: Read / Write
### The `“has-arrow”` property
```
“has-arrow” gboolean
```
Whether to draw an arrow.
Owner: GtkPopover
Flags: Read / Write
Default value: TRUE
### The `“mnemonics-visible”` property
```
“mnemonics-visible” gboolean
```
Whether mnemonics are currently visible in this popover.
Owner: GtkPopover
Flags: Read / Write
Default value: FALSE
### The `“pointing-to”` property
```
“pointing-to” [GdkRectangle](https://developer-old.gnome.org/gtk4/html/gdk4-Rectangles-and-Regions.html#GdkRectangle-struct) *
```
Rectangle the bubble window points to.
Owner: GtkPopover
Flags: Read / Write
### The `“position”` property
```
“position” [GtkPositionType](gtk4-standard-enumerations#GtkPositionType)
```
Position to place the bubble window.
Owner: GtkPopover
Flags: Read / Write
Default value: GTK\_POS\_BOTTOM
Signal Details
--------------
### The `“activate-default”` signal
```
void
user_function ([GtkPopover](gtkpopover#GtkPopover-struct) *self,
gpointer user_data)
```
The ::activate-default signal is a [keybinding signal](gtkshortcutaction#GtkSignalAction-struct) which gets emitted when the user activates the default widget of *`self`* .
#### Parameters
| | | |
| --- | --- | --- |
| self | the [GtkPopover](gtkpopover#GtkPopover-struct) which received the signal | |
| user\_data | user data set when the signal handler was connected. | |
Flags: Action
### The `“closed”` signal
```
void
user_function ([GtkPopover](gtkpopover#GtkPopover-struct) *self,
gpointer user_data)
```
The ::closed signal is emitted when the popover is closed.
#### Parameters
| | | |
| --- | --- | --- |
| self | the [GtkPopover](gtkpopover#GtkPopover-struct) which received the signal | |
| user\_data | user data set when the signal handler was connected. | |
Flags: Run Last
| programming_docs |
gtk GtkEventControllerFocus GtkEventControllerFocus
=======================
GtkEventControllerFocus — Event controller for focus
Functions
---------
| | |
| --- | --- |
| [GtkEventController](gtkeventcontroller#GtkEventController-struct) \* | [gtk\_event\_controller\_focus\_new](gtkeventcontrollerfocus#gtk-event-controller-focus-new) () |
| gboolean | [gtk\_event\_controller\_focus\_contains\_focus](gtkeventcontrollerfocus#gtk-event-controller-focus-contains-focus) () |
| gboolean | [gtk\_event\_controller\_focus\_is\_focus](gtkeventcontrollerfocus#gtk-event-controller-focus-is-focus) () |
Properties
----------
| | | |
| --- | --- | --- |
| gboolean | [contains-focus](gtkeventcontrollerfocus#GtkEventControllerFocus--contains-focus) | Read |
| gboolean | [is-focus](gtkeventcontrollerfocus#GtkEventControllerFocus--is-focus) | Read |
Signals
-------
| | | |
| --- | --- | --- |
| void | [enter](gtkeventcontrollerfocus#GtkEventControllerFocus-enter) | Run Last |
| void | [leave](gtkeventcontrollerfocus#GtkEventControllerFocus-leave) | Run Last |
Types and Values
----------------
| | |
| --- | --- |
| | [GtkEventControllerFocus](gtkeventcontrollerfocus#GtkEventControllerFocus-struct) |
Object Hierarchy
----------------
```
GObject
╰── [GtkEventController](gtkeventcontroller#GtkEventController-struct)
╰── GtkEventControllerFocus
```
Includes
--------
```
#include <gtk/gtk.h>
```
Description
-----------
[GtkEventControllerFocus](gtkeventcontrollerfocus#GtkEventControllerFocus-struct) is an event controller meant for situations where you need to know where the focus is.
Functions
---------
### gtk\_event\_controller\_focus\_new ()
```
[GtkEventController](gtkeventcontroller#GtkEventController-struct) *
gtk_event_controller_focus_new (*`void`*);
```
Creates a new event controller that will handle focus events.
#### Returns
a new [GtkEventControllerFocus](gtkeventcontrollerfocus#GtkEventControllerFocus-struct)
### gtk\_event\_controller\_focus\_contains\_focus ()
```
gboolean
gtk_event_controller_focus_contains_focus
(*`[GtkEventControllerFocus](gtkeventcontrollerfocus#GtkEventControllerFocus-struct) *self`*);
```
Returns the value of the GtkEventControllerFocus:contains-focus property.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkEventControllerFocus](gtkeventcontrollerfocus#GtkEventControllerFocus-struct) | |
#### Returns
`TRUE` if focus is within *`self`* or one of its children
### gtk\_event\_controller\_focus\_is\_focus ()
```
gboolean
gtk_event_controller_focus_is_focus (*`[GtkEventControllerFocus](gtkeventcontrollerfocus#GtkEventControllerFocus-struct) *self`*);
```
Returns the value of the GtkEventControllerFocus:is-focus property.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkEventControllerFocus](gtkeventcontrollerfocus#GtkEventControllerFocus-struct) | |
#### Returns
`TRUE` if focus is within *`self`* but not one of its children
Types and Values
----------------
### GtkEventControllerFocus
```
typedef struct _GtkEventControllerFocus GtkEventControllerFocus;
```
Property Details
----------------
### The `“contains-focus”` property
```
“contains-focus” gboolean
```
Whether focus is contain in the controllers widget. See See [“is-focus”](gtkeventcontrollerfocus#GtkEventControllerFocus--is-focus) for whether the focus is in the widget itself or inside a descendent.
When handling focus events, this property is updated before [“enter”](gtkeventcontrollerfocus#GtkEventControllerFocus-enter) or [“leave”](gtkeventcontrollerfocus#GtkEventControllerFocus-leave) are emitted.
Owner: GtkEventControllerFocus
Flags: Read
Default value: FALSE
### The `“is-focus”` property
```
“is-focus” gboolean
```
Whether focus is in the controllers widget itself, opposed to in a descendent widget. See also [“contains-focus”](gtkeventcontrollerfocus#GtkEventControllerFocus--contains-focus).
When handling focus events, this property is updated before [“enter”](gtkeventcontrollerfocus#GtkEventControllerFocus-enter) or [“leave”](gtkeventcontrollerfocus#GtkEventControllerFocus-leave) are emitted.
Owner: GtkEventControllerFocus
Flags: Read
Default value: FALSE
Signal Details
--------------
### The `“enter”` signal
```
void
user_function ([GtkEventControllerFocus](gtkeventcontrollerfocus#GtkEventControllerFocus-struct) *controller,
gpointer user_data)
```
This signal is emitted whenever the focus enters into the widget or one of its descendents.
Note that this means you may not get an ::enter signal even though the widget becomes the focus location, in certain cases (such as when the focus moves from a descendent of the widget to the widget itself). If you are interested in these cases, you can monitor the [“is-focus”](gtkeventcontrollerfocus#GtkEventControllerFocus--is-focus) property for changes.
#### Parameters
| | | |
| --- | --- | --- |
| controller | the object which received the signal | |
| user\_data | user data set when the signal handler was connected. | |
Flags: Run Last
### The `“leave”` signal
```
void
user_function ([GtkEventControllerFocus](gtkeventcontrollerfocus#GtkEventControllerFocus-struct) *controller,
gpointer user_data)
```
This signal is emitted whenever the focus leaves the widget hierarchy that is rooted at the widget that the controller is attached to.
Note that this means you may not get a ::leave signal even though the focus moves away from the widget, in certain cases (such as when the focus moves from the widget to a descendent). If you are interested in these cases, you can monitor the [“is-focus”](gtkeventcontrollerfocus#GtkEventControllerFocus--is-focus) property for changes.
#### Parameters
| | | |
| --- | --- | --- |
| controller | the object which received the signal | |
| user\_data | user data set when the signal handler was connected. | |
Flags: Run Last
See Also
--------
[GtkEventController](gtkeventcontroller#GtkEventController-struct)
gtk GtkCellRendererToggle GtkCellRendererToggle
=====================
GtkCellRendererToggle — Renders a toggle button in a cell
Functions
---------
| | |
| --- | --- |
| [GtkCellRenderer](gtkcellrenderer#GtkCellRenderer-struct) \* | [gtk\_cell\_renderer\_toggle\_new](gtkcellrenderertoggle#gtk-cell-renderer-toggle-new) () |
| gboolean | [gtk\_cell\_renderer\_toggle\_get\_radio](gtkcellrenderertoggle#gtk-cell-renderer-toggle-get-radio) () |
| void | [gtk\_cell\_renderer\_toggle\_set\_radio](gtkcellrenderertoggle#gtk-cell-renderer-toggle-set-radio) () |
| gboolean | [gtk\_cell\_renderer\_toggle\_get\_active](gtkcellrenderertoggle#gtk-cell-renderer-toggle-get-active) () |
| void | [gtk\_cell\_renderer\_toggle\_set\_active](gtkcellrenderertoggle#gtk-cell-renderer-toggle-set-active) () |
| gboolean | [gtk\_cell\_renderer\_toggle\_get\_activatable](gtkcellrenderertoggle#gtk-cell-renderer-toggle-get-activatable) () |
| void | [gtk\_cell\_renderer\_toggle\_set\_activatable](gtkcellrenderertoggle#gtk-cell-renderer-toggle-set-activatable) () |
Properties
----------
| | | |
| --- | --- | --- |
| gboolean | [activatable](gtkcellrenderertoggle#GtkCellRendererToggle--activatable) | Read / Write |
| gboolean | [active](gtkcellrenderertoggle#GtkCellRendererToggle--active) | Read / Write |
| gboolean | [inconsistent](gtkcellrenderertoggle#GtkCellRendererToggle--inconsistent) | Read / Write |
| gboolean | [radio](gtkcellrenderertoggle#GtkCellRendererToggle--radio) | Read / Write |
Signals
-------
| | | |
| --- | --- | --- |
| void | [toggled](gtkcellrenderertoggle#GtkCellRendererToggle-toggled) | Run Last |
Types and Values
----------------
| | |
| --- | --- |
| | [GtkCellRendererToggle](gtkcellrenderertoggle#GtkCellRendererToggle-struct) |
Object Hierarchy
----------------
```
GObject
╰── GInitiallyUnowned
╰── [GtkCellRenderer](gtkcellrenderer#GtkCellRenderer-struct)
╰── GtkCellRendererToggle
```
Includes
--------
```
#include <gtk/gtk.h>
```
Description
-----------
[GtkCellRendererToggle](gtkcellrenderertoggle#GtkCellRendererToggle-struct) renders a toggle button in a cell. The button is drawn as a radio or a checkbutton, depending on the [“radio”](gtkcellrenderertoggle#GtkCellRendererToggle--radio) property. When activated, it emits the [“toggled”](gtkcellrenderertoggle#GtkCellRendererToggle-toggled) signal.
Functions
---------
### gtk\_cell\_renderer\_toggle\_new ()
```
[GtkCellRenderer](gtkcellrenderer#GtkCellRenderer-struct) *
gtk_cell_renderer_toggle_new (*`void`*);
```
Creates a new [GtkCellRendererToggle](gtkcellrenderertoggle#GtkCellRendererToggle-struct). Adjust rendering parameters using object properties. Object properties can be set globally (with `g_object_set()`). Also, with [GtkTreeViewColumn](gtktreeviewcolumn#GtkTreeViewColumn-struct), you can bind a property to a value in a [GtkTreeModel](gtktreemodel#GtkTreeModel-struct). For example, you can bind the “active” property on the cell renderer to a boolean value in the model, thus causing the check button to reflect the state of the model.
#### Returns
the new cell renderer
### gtk\_cell\_renderer\_toggle\_get\_radio ()
```
gboolean
gtk_cell_renderer_toggle_get_radio (*`[GtkCellRendererToggle](gtkcellrenderertoggle#GtkCellRendererToggle-struct) *toggle`*);
```
Returns whether we’re rendering radio toggles rather than checkboxes.
#### Parameters
| | | |
| --- | --- | --- |
| toggle | a [GtkCellRendererToggle](gtkcellrenderertoggle#GtkCellRendererToggle-struct) | |
#### Returns
`TRUE` if we’re rendering radio toggles rather than checkboxes
### gtk\_cell\_renderer\_toggle\_set\_radio ()
```
void
gtk_cell_renderer_toggle_set_radio (*`[GtkCellRendererToggle](gtkcellrenderertoggle#GtkCellRendererToggle-struct) *toggle`*,
*`gboolean radio`*);
```
If *`radio`* is `TRUE`, the cell renderer renders a radio toggle (i.e. a toggle in a group of mutually-exclusive toggles). If `FALSE`, it renders a check toggle (a standalone boolean option). This can be set globally for the cell renderer, or changed just before rendering each cell in the model (for [GtkTreeView](gtktreeview#GtkTreeView-struct), you set up a per-row setting using [GtkTreeViewColumn](gtktreeviewcolumn#GtkTreeViewColumn-struct) to associate model columns with cell renderer properties).
#### Parameters
| | | |
| --- | --- | --- |
| toggle | a [GtkCellRendererToggle](gtkcellrenderertoggle#GtkCellRendererToggle-struct) | |
| radio | `TRUE` to make the toggle look like a radio button | |
### gtk\_cell\_renderer\_toggle\_get\_active ()
```
gboolean
gtk_cell_renderer_toggle_get_active (*`[GtkCellRendererToggle](gtkcellrenderertoggle#GtkCellRendererToggle-struct) *toggle`*);
```
Returns whether the cell renderer is active. See [`gtk_cell_renderer_toggle_set_active()`](gtkcellrenderertoggle#gtk-cell-renderer-toggle-set-active).
#### Parameters
| | | |
| --- | --- | --- |
| toggle | a [GtkCellRendererToggle](gtkcellrenderertoggle#GtkCellRendererToggle-struct) | |
#### Returns
`TRUE` if the cell renderer is active.
### gtk\_cell\_renderer\_toggle\_set\_active ()
```
void
gtk_cell_renderer_toggle_set_active (*`[GtkCellRendererToggle](gtkcellrenderertoggle#GtkCellRendererToggle-struct) *toggle`*,
*`gboolean setting`*);
```
Activates or deactivates a cell renderer.
#### Parameters
| | | |
| --- | --- | --- |
| toggle | a [GtkCellRendererToggle](gtkcellrenderertoggle#GtkCellRendererToggle-struct). | |
| setting | the value to set. | |
### gtk\_cell\_renderer\_toggle\_get\_activatable ()
```
gboolean
gtk_cell_renderer_toggle_get_activatable
(*`[GtkCellRendererToggle](gtkcellrenderertoggle#GtkCellRendererToggle-struct) *toggle`*);
```
Returns whether the cell renderer is activatable. See [`gtk_cell_renderer_toggle_set_activatable()`](gtkcellrenderertoggle#gtk-cell-renderer-toggle-set-activatable).
#### Parameters
| | | |
| --- | --- | --- |
| toggle | a [GtkCellRendererToggle](gtkcellrenderertoggle#GtkCellRendererToggle-struct) | |
#### Returns
`TRUE` if the cell renderer is activatable.
### gtk\_cell\_renderer\_toggle\_set\_activatable ()
```
void
gtk_cell_renderer_toggle_set_activatable
(*`[GtkCellRendererToggle](gtkcellrenderertoggle#GtkCellRendererToggle-struct) *toggle`*,
*`gboolean setting`*);
```
Makes the cell renderer activatable.
#### Parameters
| | | |
| --- | --- | --- |
| toggle | a [GtkCellRendererToggle](gtkcellrenderertoggle#GtkCellRendererToggle-struct). | |
| setting | the value to set. | |
Types and Values
----------------
### GtkCellRendererToggle
```
typedef struct _GtkCellRendererToggle GtkCellRendererToggle;
```
Property Details
----------------
### The `“activatable”` property
```
“activatable” gboolean
```
The toggle button can be activated.
Owner: GtkCellRendererToggle
Flags: Read / Write
Default value: TRUE
### The `“active”` property
```
“active” gboolean
```
The toggle state of the button.
Owner: GtkCellRendererToggle
Flags: Read / Write
Default value: FALSE
### The `“inconsistent”` property
```
“inconsistent” gboolean
```
The inconsistent state of the button.
Owner: GtkCellRendererToggle
Flags: Read / Write
Default value: FALSE
### The `“radio”` property
```
“radio” gboolean
```
Draw the toggle button as a radio button.
Owner: GtkCellRendererToggle
Flags: Read / Write
Default value: FALSE
Signal Details
--------------
### The `“toggled”` signal
```
void
user_function ([GtkCellRendererToggle](gtkcellrenderertoggle#GtkCellRendererToggle-struct) *cell_renderer,
char *path,
gpointer user_data)
```
The ::toggled signal is emitted when the cell is toggled.
It is the responsibility of the application to update the model with the correct value to store at *`path`* . Often this is simply the opposite of the value currently stored at *`path`* .
#### Parameters
| | | |
| --- | --- | --- |
| cell\_renderer | the object which received the signal | |
| path | string representation of [GtkTreePath](gtktreemodel#GtkTreePath-struct) describing the event location | |
| user\_data | user data set when the signal handler was connected. | |
Flags: Run Last
gtk GtkPadController GtkPadController
================
GtkPadController — Controller for drawing tablet pads
Functions
---------
| | |
| --- | --- |
| [GtkPadController](gtkpadcontroller#GtkPadController-struct) \* | [gtk\_pad\_controller\_new](gtkpadcontroller#gtk-pad-controller-new) () |
| void | [gtk\_pad\_controller\_set\_action\_entries](gtkpadcontroller#gtk-pad-controller-set-action-entries) () |
| void | [gtk\_pad\_controller\_set\_action](gtkpadcontroller#gtk-pad-controller-set-action) () |
Properties
----------
| | | |
| --- | --- | --- |
| GActionGroup \* | [action-group](gtkpadcontroller#GtkPadController--action-group) | Read / Write / Construct Only |
| [GdkDevice](https://developer-old.gnome.org/gtk4/html/GdkDevice.html#GdkDevice-struct) \* | [pad](gtkpadcontroller#GtkPadController--pad) | Read / Write / Construct Only |
Types and Values
----------------
| | |
| --- | --- |
| | [GtkPadController](gtkpadcontroller#GtkPadController-struct) |
| enum | [GtkPadActionType](gtkpadcontroller#GtkPadActionType) |
| struct | [GtkPadActionEntry](gtkpadcontroller#GtkPadActionEntry) |
Object Hierarchy
----------------
```
GObject
╰── [GtkEventController](gtkeventcontroller#GtkEventController-struct)
╰── GtkPadController
```
Includes
--------
```
#include <gtk/gtk.h>
```
Description
-----------
[GtkPadController](gtkpadcontroller#GtkPadController-struct) is an event controller for the pads found in drawing tablets (The collection of buttons and tactile sensors often found around the stylus-sensitive area).
These buttons and sensors have no implicit meaning, and by default they perform no action, this event controller is provided to map those to GAction objects, thus letting the application give those a more semantic meaning.
Buttons and sensors are not constrained to triggering a single action, some [`GDK_SOURCE_TABLET_PAD`](https://developer-old.gnome.org/gtk4/html/GdkDevice.html#GDK-SOURCE-TABLET-PAD:CAPS) devices feature multiple "modes", all these input elements have one current mode, which may determine the final action being triggered. Pad devices often divide buttons and sensors into groups, all elements in a group share the same current mode, but different groups may have different modes. See [`gdk_device_pad_get_n_groups()`](https://developer-old.gnome.org/gtk4/html/GdkDevicePad.html#gdk-device-pad-get-n-groups) and [`gdk_device_pad_get_group_n_modes()`](https://developer-old.gnome.org/gtk4/html/GdkDevicePad.html#gdk-device-pad-get-group-n-modes).
Each of the actions that a given button/strip/ring performs for a given mode is defined by [GtkPadActionEntry](gtkpadcontroller#GtkPadActionEntry), it contains an action name that will be looked up in the given GActionGroup and activated whenever the specified input element and mode are triggered.
A simple example of [GtkPadController](gtkpadcontroller#GtkPadController-struct) usage, assigning button 1 in all modes and pad devices to an "invert-selection" action:
```
GtkPadActionEntry *pad_actions[] = {
{ GTK_PAD_ACTION_BUTTON, 1, -1, "Invert selection", "pad-actions.invert-selection" },
…
};
…
action_group = g_simple_action_group_new ();
action = g_simple_action_new ("pad-actions.invert-selection", NULL);
g_signal_connect (action, "activate", on_invert_selection_activated, NULL);
g_action_map_add_action (G_ACTION_MAP (action_group), action);
…
pad_controller = gtk_pad_controller_new (action_group, NULL);
```
| The actions belonging to rings/strips will be activated with a parameter of type `G_VARIANT_TYPE_DOUBLE` bearing the value of the given axis, it is required that those are made stateful and accepting this GVariantType.
Functions
---------
### gtk\_pad\_controller\_new ()
```
[GtkPadController](gtkpadcontroller#GtkPadController-struct) *
gtk_pad_controller_new (*`GActionGroup *group`*,
*`[GdkDevice](https://developer-old.gnome.org/gtk4/html/GdkDevice.html#GdkDevice-struct) *pad`*);
```
Creates a new [GtkPadController](gtkpadcontroller#GtkPadController-struct) that will associate events from *`pad`* to actions. A `NULL` pad may be provided so the controller manages all pad devices generically, it is discouraged to mix [GtkPadController](gtkpadcontroller#GtkPadController-struct) objects with `NULL` and non-`NULL` *`pad`* argument on the same toplevel window, as execution order is not guaranteed.
The [GtkPadController](gtkpadcontroller#GtkPadController-struct) is created with no mapped actions. In order to map pad events to actions, use [`gtk_pad_controller_set_action_entries()`](gtkpadcontroller#gtk-pad-controller-set-action-entries) or [`gtk_pad_controller_set_action()`](gtkpadcontroller#gtk-pad-controller-set-action).
Be aware that pad events will only be delivered to [GtkWindows](gtkwindow#GtkWindow-struct), so adding a pad controller to any other type of widget will not have an effect.
#### Parameters
| | | |
| --- | --- | --- |
| group | GActionGroup to trigger actions from | |
| pad | A [`GDK_SOURCE_TABLET_PAD`](https://developer-old.gnome.org/gtk4/html/GdkDevice.html#GDK-SOURCE-TABLET-PAD:CAPS) device, or `NULL` to handle all pads. | [nullable] |
#### Returns
A newly created [GtkPadController](gtkpadcontroller#GtkPadController-struct)
### gtk\_pad\_controller\_set\_action\_entries ()
```
void
gtk_pad_controller_set_action_entries (*`[GtkPadController](gtkpadcontroller#GtkPadController-struct) *controller`*,
*`const [GtkPadActionEntry](gtkpadcontroller#GtkPadActionEntry) *entries`*,
*`int n_entries`*);
```
This is a convenience function to add a group of action entries on *`controller`* . See [GtkPadActionEntry](gtkpadcontroller#GtkPadActionEntry) and [`gtk_pad_controller_set_action()`](gtkpadcontroller#gtk-pad-controller-set-action).
#### Parameters
| | | |
| --- | --- | --- |
| controller | a [GtkPadController](gtkpadcontroller#GtkPadController-struct) | |
| entries | the action entries to set on *`controller`* . | [array length=n\_entries] |
| n\_entries | the number of elements in *`entries`* | |
### gtk\_pad\_controller\_set\_action ()
```
void
gtk_pad_controller_set_action (*`[GtkPadController](gtkpadcontroller#GtkPadController-struct) *controller`*,
*`[GtkPadActionType](gtkpadcontroller#GtkPadActionType) type`*,
*`int index`*,
*`int mode`*,
*`const char *label`*,
*`const char *action_name`*);
```
Adds an individual action to *`controller`* . This action will only be activated if the given button/ring/strip number in *`index`* is interacted while the current mode is *`mode`* . -1 may be used for simple cases, so the action is triggered on all modes.
The given *`label`* should be considered user-visible, so internationalization rules apply. Some windowing systems may be able to use those for user feedback.
#### Parameters
| | | |
| --- | --- | --- |
| controller | a [GtkPadController](gtkpadcontroller#GtkPadController-struct) | |
| type | the type of pad feature that will trigger this action | |
| index | the 0-indexed button/ring/strip number that will trigger this action | |
| mode | the mode that will trigger this action, or -1 for all modes. | |
| label | Human readable description of this action, this string should be deemed user-visible. | |
| action\_name | action name that will be activated in the GActionGroup | |
Types and Values
----------------
### GtkPadController
```
typedef struct _GtkPadController GtkPadController;
```
### enum GtkPadActionType
The type of a pad action.
#### Members
| | | |
| --- | --- | --- |
| GTK\_PAD\_ACTION\_BUTTON | Action is triggered by a pad button | |
| GTK\_PAD\_ACTION\_RING | Action is triggered by a pad ring | |
| GTK\_PAD\_ACTION\_STRIP | Action is triggered by a pad strip | |
### struct GtkPadActionEntry
```
struct GtkPadActionEntry {
GtkPadActionType type;
int index;
int mode;
const char *label;
const char *action_name;
};
```
Struct defining a pad action entry.
#### Members
| | | |
| --- | --- | --- |
| [GtkPadActionType](gtkpadcontroller#GtkPadActionType) *`type`*; | the type of pad feature that will trigger this action entry. | |
| int *`index`*; | the 0-indexed button/ring/strip number that will trigger this action entry. | |
| int *`mode`*; | the mode that will trigger this action entry, or -1 for all modes. | |
| const char \**`label`*; | Human readable description of this action entry, this string should be deemed user-visible. | |
| const char \**`action_name`*; | action name that will be activated in the GActionGroup. | |
Property Details
----------------
### The `“action-group”` property
```
“action-group” GActionGroup *
```
Action group to launch actions from.
Owner: GtkPadController
Flags: Read / Write / Construct Only
### The `“pad”` property
```
“pad” [GdkDevice](https://developer-old.gnome.org/gtk4/html/GdkDevice.html#GdkDevice-struct) *
```
Pad device to control.
Owner: GtkPadController
Flags: Read / Write / Construct Only
See Also
--------
[GtkEventController](gtkeventcontroller#GtkEventController-struct), [GdkDevicePad](https://developer-old.gnome.org/gtk4/html/GdkDevicePad.html#GdkDevicePad-struct)
| programming_docs |
gtk GtkCellArea GtkCellArea
===========
GtkCellArea — An abstract class for laying out GtkCellRenderers
Functions
---------
| | |
| --- | --- |
| gboolean | ([\*GtkCellCallback](gtkcellarea#GtkCellCallback)) () |
| gboolean | ([\*GtkCellAllocCallback](gtkcellarea#GtkCellAllocCallback)) () |
| #define | [GTK\_CELL\_AREA\_WARN\_INVALID\_CELL\_PROPERTY\_ID](gtkcellarea#GTK-CELL-AREA-WARN-INVALID-CELL-PROPERTY-ID:CAPS)() |
| void | [gtk\_cell\_area\_add](gtkcellarea#gtk-cell-area-add) () |
| void | [gtk\_cell\_area\_remove](gtkcellarea#gtk-cell-area-remove) () |
| gboolean | [gtk\_cell\_area\_has\_renderer](gtkcellarea#gtk-cell-area-has-renderer) () |
| void | [gtk\_cell\_area\_foreach](gtkcellarea#gtk-cell-area-foreach) () |
| void | [gtk\_cell\_area\_foreach\_alloc](gtkcellarea#gtk-cell-area-foreach-alloc) () |
| int | [gtk\_cell\_area\_event](gtkcellarea#gtk-cell-area-event) () |
| void | [gtk\_cell\_area\_snapshot](gtkcellarea#gtk-cell-area-snapshot) () |
| void | [gtk\_cell\_area\_get\_cell\_allocation](gtkcellarea#gtk-cell-area-get-cell-allocation) () |
| [GtkCellRenderer](gtkcellrenderer#GtkCellRenderer-struct) \* | [gtk\_cell\_area\_get\_cell\_at\_position](gtkcellarea#gtk-cell-area-get-cell-at-position) () |
| [GtkCellAreaContext](gtkcellareacontext#GtkCellAreaContext-struct) \* | [gtk\_cell\_area\_create\_context](gtkcellarea#gtk-cell-area-create-context) () |
| [GtkCellAreaContext](gtkcellareacontext#GtkCellAreaContext-struct) \* | [gtk\_cell\_area\_copy\_context](gtkcellarea#gtk-cell-area-copy-context) () |
| [GtkSizeRequestMode](gtkwidget#GtkSizeRequestMode) | [gtk\_cell\_area\_get\_request\_mode](gtkcellarea#gtk-cell-area-get-request-mode) () |
| void | [gtk\_cell\_area\_get\_preferred\_width](gtkcellarea#gtk-cell-area-get-preferred-width) () |
| void | [gtk\_cell\_area\_get\_preferred\_height\_for\_width](gtkcellarea#gtk-cell-area-get-preferred-height-for-width) () |
| void | [gtk\_cell\_area\_get\_preferred\_height](gtkcellarea#gtk-cell-area-get-preferred-height) () |
| void | [gtk\_cell\_area\_get\_preferred\_width\_for\_height](gtkcellarea#gtk-cell-area-get-preferred-width-for-height) () |
| const char \* | [gtk\_cell\_area\_get\_current\_path\_string](gtkcellarea#gtk-cell-area-get-current-path-string) () |
| void | [gtk\_cell\_area\_apply\_attributes](gtkcellarea#gtk-cell-area-apply-attributes) () |
| void | [gtk\_cell\_area\_attribute\_connect](gtkcellarea#gtk-cell-area-attribute-connect) () |
| void | [gtk\_cell\_area\_attribute\_disconnect](gtkcellarea#gtk-cell-area-attribute-disconnect) () |
| int | [gtk\_cell\_area\_attribute\_get\_column](gtkcellarea#gtk-cell-area-attribute-get-column) () |
| void | [gtk\_cell\_area\_class\_install\_cell\_property](gtkcellarea#gtk-cell-area-class-install-cell-property) () |
| GParamSpec \* | [gtk\_cell\_area\_class\_find\_cell\_property](gtkcellarea#gtk-cell-area-class-find-cell-property) () |
| GParamSpec \*\* | [gtk\_cell\_area\_class\_list\_cell\_properties](gtkcellarea#gtk-cell-area-class-list-cell-properties) () |
| void | [gtk\_cell\_area\_add\_with\_properties](gtkcellarea#gtk-cell-area-add-with-properties) () |
| void | [gtk\_cell\_area\_cell\_set](gtkcellarea#gtk-cell-area-cell-set) () |
| void | [gtk\_cell\_area\_cell\_get](gtkcellarea#gtk-cell-area-cell-get) () |
| void | [gtk\_cell\_area\_cell\_set\_valist](gtkcellarea#gtk-cell-area-cell-set-valist) () |
| void | [gtk\_cell\_area\_cell\_get\_valist](gtkcellarea#gtk-cell-area-cell-get-valist) () |
| void | [gtk\_cell\_area\_cell\_set\_property](gtkcellarea#gtk-cell-area-cell-set-property) () |
| void | [gtk\_cell\_area\_cell\_get\_property](gtkcellarea#gtk-cell-area-cell-get-property) () |
| gboolean | [gtk\_cell\_area\_is\_activatable](gtkcellarea#gtk-cell-area-is-activatable) () |
| gboolean | [gtk\_cell\_area\_activate](gtkcellarea#gtk-cell-area-activate) () |
| gboolean | [gtk\_cell\_area\_focus](gtkcellarea#gtk-cell-area-focus) () |
| void | [gtk\_cell\_area\_set\_focus\_cell](gtkcellarea#gtk-cell-area-set-focus-cell) () |
| [GtkCellRenderer](gtkcellrenderer#GtkCellRenderer-struct) \* | [gtk\_cell\_area\_get\_focus\_cell](gtkcellarea#gtk-cell-area-get-focus-cell) () |
| void | [gtk\_cell\_area\_add\_focus\_sibling](gtkcellarea#gtk-cell-area-add-focus-sibling) () |
| void | [gtk\_cell\_area\_remove\_focus\_sibling](gtkcellarea#gtk-cell-area-remove-focus-sibling) () |
| gboolean | [gtk\_cell\_area\_is\_focus\_sibling](gtkcellarea#gtk-cell-area-is-focus-sibling) () |
| const GList \* | [gtk\_cell\_area\_get\_focus\_siblings](gtkcellarea#gtk-cell-area-get-focus-siblings) () |
| [GtkCellRenderer](gtkcellrenderer#GtkCellRenderer-struct) \* | [gtk\_cell\_area\_get\_focus\_from\_sibling](gtkcellarea#gtk-cell-area-get-focus-from-sibling) () |
| [GtkCellRenderer](gtkcellrenderer#GtkCellRenderer-struct) \* | [gtk\_cell\_area\_get\_edited\_cell](gtkcellarea#gtk-cell-area-get-edited-cell) () |
| [GtkCellEditable](gtkcelleditable#GtkCellEditable-struct) \* | [gtk\_cell\_area\_get\_edit\_widget](gtkcellarea#gtk-cell-area-get-edit-widget) () |
| gboolean | [gtk\_cell\_area\_activate\_cell](gtkcellarea#gtk-cell-area-activate-cell) () |
| void | [gtk\_cell\_area\_stop\_editing](gtkcellarea#gtk-cell-area-stop-editing) () |
| void | [gtk\_cell\_area\_inner\_cell\_area](gtkcellarea#gtk-cell-area-inner-cell-area) () |
| void | [gtk\_cell\_area\_request\_renderer](gtkcellarea#gtk-cell-area-request-renderer) () |
Properties
----------
| | | |
| --- | --- | --- |
| [GtkCellEditable](gtkcelleditable#GtkCellEditable-struct) \* | [edit-widget](gtkcellarea#GtkCellArea--edit-widget) | Read |
| [GtkCellRenderer](gtkcellrenderer#GtkCellRenderer-struct) \* | [edited-cell](gtkcellarea#GtkCellArea--edited-cell) | Read |
| [GtkCellRenderer](gtkcellrenderer#GtkCellRenderer-struct) \* | [focus-cell](gtkcellarea#GtkCellArea--focus-cell) | Read / Write |
Signals
-------
| | | |
| --- | --- | --- |
| void | [add-editable](gtkcellarea#GtkCellArea-add-editable) | Run First |
| void | [apply-attributes](gtkcellarea#GtkCellArea-apply-attributes) | Run First |
| void | [focus-changed](gtkcellarea#GtkCellArea-focus-changed) | Run First |
| void | [remove-editable](gtkcellarea#GtkCellArea-remove-editable) | Run First |
Types and Values
----------------
| | |
| --- | --- |
| struct | [GtkCellArea](gtkcellarea#GtkCellArea-struct) |
| struct | [GtkCellAreaClass](gtkcellarea#GtkCellAreaClass) |
Object Hierarchy
----------------
```
GObject
╰── GInitiallyUnowned
╰── GtkCellArea
╰── [GtkCellAreaBox](gtkcellareabox#GtkCellAreaBox-struct)
```
Implemented Interfaces
----------------------
GtkCellArea implements [GtkCellLayout](gtkcelllayout#GtkCellLayout-struct) and [GtkBuildable](gtkbuildable#GtkBuildable-struct).
Includes
--------
```
#include <gtk/gtk.h>
```
Description
-----------
The [GtkCellArea](gtkcellarea#GtkCellArea-struct) is an abstract class for [GtkCellLayout](gtkcelllayout#GtkCellLayout-struct) widgets (also referred to as "layouting widgets") to interface with an arbitrary number of [GtkCellRenderers](gtkcellrenderer#GtkCellRenderer-struct) and interact with the user for a given [GtkTreeModel](gtktreemodel#GtkTreeModel-struct) row.
The cell area handles events, focus navigation, drawing and size requests and allocations for a given row of data.
Usually users dont have to interact with the [GtkCellArea](gtkcellarea#GtkCellArea-struct) directly unless they are implementing a cell-layouting widget themselves.
### Requesting area sizes
As outlined in GtkWidget’s geometry management section, GTK uses a height-for-width geometry management system to compute the sizes of widgets and user interfaces. [GtkCellArea](gtkcellarea#GtkCellArea-struct) uses the same semantics to calculate the size of an area for an arbitrary number of [GtkTreeModel](gtktreemodel#GtkTreeModel-struct) rows.
When requesting the size of a cell area one needs to calculate the size for a handful of rows, and this will be done differently by different layouting widgets. For instance a [GtkTreeViewColumn](gtktreeviewcolumn#GtkTreeViewColumn-struct) always lines up the areas from top to bottom while a [GtkIconView](gtkiconview#GtkIconView-struct) on the other hand might enforce that all areas received the same width and wrap the areas around, requesting height for more cell areas when allocated less width.
It’s also important for areas to maintain some cell alignments with areas rendered for adjacent rows (cells can appear “columnized” inside an area even when the size of cells are different in each row). For this reason the [GtkCellArea](gtkcellarea#GtkCellArea-struct) uses a [GtkCellAreaContext](gtkcellareacontext#GtkCellAreaContext-struct) object to store the alignments and sizes along the way (as well as the overall largest minimum and natural size for all the rows which have been calculated with the said context).
The [GtkCellAreaContext](gtkcellareacontext#GtkCellAreaContext-struct) is an opaque object specific to the [GtkCellArea](gtkcellarea#GtkCellArea-struct) which created it (see [`gtk_cell_area_create_context()`](gtkcellarea#gtk-cell-area-create-context)). The owning cell-layouting widget can create as many contexts as it wishes to calculate sizes of rows which should receive the same size in at least one orientation (horizontally or vertically), However, it’s important that the same [GtkCellAreaContext](gtkcellareacontext#GtkCellAreaContext-struct) which was used to request the sizes for a given [GtkTreeModel](gtktreemodel#GtkTreeModel-struct) row be used when rendering or processing events for that row.
In order to request the width of all the rows at the root level of a [GtkTreeModel](gtktreemodel#GtkTreeModel-struct) one would do the following:
Note that in this example it’s not important to observe the returned minimum and natural width of the area for each row unless the cell-layouting object is actually interested in the widths of individual rows. The overall width is however stored in the accompanying [GtkCellAreaContext](gtkcellareacontext#GtkCellAreaContext-struct) object and can be consulted at any time.
This can be useful since [GtkCellLayout](gtkcelllayout#GtkCellLayout-struct) widgets usually have to support requesting and rendering rows in treemodels with an exceedingly large amount of rows. The [GtkCellLayout](gtkcelllayout#GtkCellLayout-struct) widget in that case would calculate the required width of the rows in an idle or timeout source (see `g_timeout_add()`) and when the widget is requested its actual width in [`GtkWidgetClass.measure()`](gtkwidget#GtkWidgetClass.measure) it can simply consult the width accumulated so far in the [GtkCellAreaContext](gtkcellareacontext#GtkCellAreaContext-struct) object.
A simple example where rows are rendered from top to bottom and take up the full width of the layouting widget would look like:
In the above example the Foo widget has to make sure that some row sizes have been calculated (the amount of rows that Foo judged was appropriate to request space for in a single timeout iteration) before simply returning the amount of space required by the area via the [GtkCellAreaContext](gtkcellareacontext#GtkCellAreaContext-struct).
Requesting the height for width (or width for height) of an area is a similar task except in this case the [GtkCellAreaContext](gtkcellareacontext#GtkCellAreaContext-struct) does not store the data (actually, it does not know how much space the layouting widget plans to allocate it for every row. It’s up to the layouting widget to render each row of data with the appropriate height and width which was requested by the [GtkCellArea](gtkcellarea#GtkCellArea-struct)).
In order to request the height for width of all the rows at the root level of a [GtkTreeModel](gtktreemodel#GtkTreeModel-struct) one would do the following:
Note that in the above example we would need to cache the heights returned for each row so that we would know what sizes to render the areas for each row. However we would only want to really cache the heights if the request is intended for the layouting widgets real allocation.
In some cases the layouting widget is requested the height for an arbitrary for\_width, this is a special case for layouting widgets who need to request size for tens of thousands of rows. For this case it’s only important that the layouting widget calculate one reasonably sized chunk of rows and return that height synchronously. The reasoning here is that any layouting widget is at least capable of synchronously calculating enough height to fill the screen height (or scrolled window height) in response to a single call to [`GtkWidgetClass.measure()`](gtkwidget#GtkWidgetClass.measure). Returning a perfect height for width that is larger than the screen area is inconsequential since after the layouting receives an allocation from a scrolled window it simply continues to drive the scrollbar values while more and more height is required for the row heights that are calculated in the background.
### Rendering Areas
Once area sizes have been acquired at least for the rows in the visible area of the layouting widget they can be rendered at [`GtkWidgetClass.snapshot()`](gtkwidget#GtkWidgetClass.snapshot) time.
A crude example of how to render all the rows at the root level runs as follows:
Note that the cached height in this example really depends on how the layouting widget works. The layouting widget might decide to give every row its minimum or natural height or, if the model content is expected to fit inside the layouting widget without scrolling, it would make sense to calculate the allocation for each row at the time the widget is allocated using [`gtk_distribute_natural_allocation()`](gtkwidget#gtk-distribute-natural-allocation).
### Handling Events and Driving Keyboard Focus
Passing events to the area is as simple as handling events on any normal widget and then passing them to the [`gtk_cell_area_event()`](gtkcellarea#gtk-cell-area-event) API as they come in. Usually [GtkCellArea](gtkcellarea#GtkCellArea-struct) is only interested in button events, however some customized derived areas can be implemented who are interested in handling other events. Handling an event can trigger the [“focus-changed”](gtkcellarea#GtkCellArea-focus-changed) signal to fire; as well as [“add-editable”](gtkcellarea#GtkCellArea-add-editable) in the case that an editable cell was clicked and needs to start editing. You can call [`gtk_cell_area_stop_editing()`](gtkcellarea#gtk-cell-area-stop-editing) at any time to cancel any cell editing that is currently in progress.
The [GtkCellArea](gtkcellarea#GtkCellArea-struct) drives keyboard focus from cell to cell in a way similar to [GtkWidget](gtkwidget#GtkWidget-struct). For layouting widgets that support giving focus to cells it’s important to remember to pass [`GTK_CELL_RENDERER_FOCUSED`](gtkcellrenderer#GTK-CELL-RENDERER-FOCUSED:CAPS) to the area functions for the row that has focus and to tell the area to paint the focus at render time.
Layouting widgets that accept focus on cells should implement the [`GtkWidgetClass.focus()`](gtkwidget#GtkWidgetClass.focus) virtual method. The layouting widget is always responsible for knowing where [GtkTreeModel](gtktreemodel#GtkTreeModel-struct) rows are rendered inside the widget, so at [`GtkWidgetClass.focus()`](gtkwidget#GtkWidgetClass.focus) time the layouting widget should use the [GtkCellArea](gtkcellarea#GtkCellArea-struct) methods to navigate focus inside the area and then observe the GtkDirectionType to pass the focus to adjacent rows and areas.
A basic example of how the [`GtkWidgetClass.focus()`](gtkwidget#GtkWidgetClass.focus) virtual method should be implemented:
```
GtkTreeIter iter;
int minimum_width;
int natural_width;
valid = gtk_tree_model_get_iter_first (model, &iter);
while (valid)
{
gtk_cell_area_apply_attributes (area, model, &iter, FALSE, FALSE);
gtk_cell_area_get_preferred_width (area, context, widget, NULL, NULL);
valid = gtk_tree_model_iter_next (model, &iter);
}
gtk_cell_area_context_get_preferred_width (context, &minimum_width, &natural_width);
```
| Note that the layouting widget is responsible for matching the GtkDirectionType values to the way it lays out its cells.
### Cell Properties
The [GtkCellArea](gtkcellarea#GtkCellArea-struct) introduces cell properties for [GtkCellRenderers](gtkcellrenderer#GtkCellRenderer-struct). This provides some general interfaces for defining the relationship cell areas have with their cells. For instance in a [GtkCellAreaBox](gtkcellareabox#GtkCellAreaBox-struct) a cell might “expand” and receive extra space when the area is allocated more than its full natural request, or a cell might be configured to “align” with adjacent rows which were requested and rendered with the same [GtkCellAreaContext](gtkcellareacontext#GtkCellAreaContext-struct).
Use [`gtk_cell_area_class_install_cell_property()`](gtkcellarea#gtk-cell-area-class-install-cell-property) to install cell properties for a cell area class and [`gtk_cell_area_class_find_cell_property()`](gtkcellarea#gtk-cell-area-class-find-cell-property) or [`gtk_cell_area_class_list_cell_properties()`](gtkcellarea#gtk-cell-area-class-list-cell-properties) to get information about existing cell properties.
To set the value of a cell property, use [`gtk_cell_area_cell_set_property()`](gtkcellarea#gtk-cell-area-cell-set-property), [`gtk_cell_area_cell_set()`](gtkcellarea#gtk-cell-area-cell-set) or [`gtk_cell_area_cell_set_valist()`](gtkcellarea#gtk-cell-area-cell-set-valist). To obtain the value of a cell property, use [`gtk_cell_area_cell_get_property()`](gtkcellarea#gtk-cell-area-cell-get-property), [`gtk_cell_area_cell_get()`](gtkcellarea#gtk-cell-area-cell-get) or [`gtk_cell_area_cell_get_valist()`](gtkcellarea#gtk-cell-area-cell-get-valist).
Functions
---------
### GtkCellCallback ()
```
gboolean
(*GtkCellCallback) (*`[GtkCellRenderer](gtkcellrenderer#GtkCellRenderer-struct) *renderer`*,
*`gpointer data`*);
```
The type of the callback functions used for iterating over the cell renderers of a [GtkCellArea](gtkcellarea#GtkCellArea-struct), see [`gtk_cell_area_foreach()`](gtkcellarea#gtk-cell-area-foreach).
#### Parameters
| | | |
| --- | --- | --- |
| renderer | the cell renderer to operate on | |
| data | user-supplied data. | [closure] |
#### Returns
`TRUE` to stop iterating over cells.
### GtkCellAllocCallback ()
```
gboolean
(*GtkCellAllocCallback) (*`[GtkCellRenderer](gtkcellrenderer#GtkCellRenderer-struct) *renderer`*,
*`const [GdkRectangle](https://developer-old.gnome.org/gtk4/html/gdk4-Rectangles-and-Regions.html#GdkRectangle-struct) *cell_area`*,
*`const [GdkRectangle](https://developer-old.gnome.org/gtk4/html/gdk4-Rectangles-and-Regions.html#GdkRectangle-struct) *cell_background`*,
*`gpointer data`*);
```
The type of the callback functions used for iterating over the cell renderers and their allocated areas inside a [GtkCellArea](gtkcellarea#GtkCellArea-struct), see [`gtk_cell_area_foreach_alloc()`](gtkcellarea#gtk-cell-area-foreach-alloc).
#### Parameters
| | | |
| --- | --- | --- |
| renderer | the cell renderer to operate on | |
| cell\_area | the area allocated to *`renderer`* inside the rectangle provided to [`gtk_cell_area_foreach_alloc()`](gtkcellarea#gtk-cell-area-foreach-alloc). | |
| cell\_background | the background area for *`renderer`* inside the background area provided to [`gtk_cell_area_foreach_alloc()`](gtkcellarea#gtk-cell-area-foreach-alloc). | |
| data | user-supplied data. | [closure] |
#### Returns
`TRUE` to stop iterating over cells.
### GTK\_CELL\_AREA\_WARN\_INVALID\_CELL\_PROPERTY\_ID()
```
#define GTK_CELL_AREA_WARN_INVALID_CELL_PROPERTY_ID(object, property_id, pspec)
```
This macro should be used to emit a standard warning about unexpected properties in `set_cell_property()` and `get_cell_property()` implementations.
#### Parameters
| | | |
| --- | --- | --- |
| object | the GObject on which `set_cell_property()` or `get_cell_property()` was called | |
| property\_id | the numeric id of the property | |
| pspec | the GParamSpec of the property | |
### gtk\_cell\_area\_add ()
```
void
gtk_cell_area_add (*`[GtkCellArea](gtkcellarea#GtkCellArea-struct) *area`*,
*`[GtkCellRenderer](gtkcellrenderer#GtkCellRenderer-struct) *renderer`*);
```
Adds *`renderer`* to *`area`* with the default child cell properties.
#### Parameters
| | | |
| --- | --- | --- |
| area | a [GtkCellArea](gtkcellarea#GtkCellArea-struct) | |
| renderer | the [GtkCellRenderer](gtkcellrenderer#GtkCellRenderer-struct) to add to *`area`* | |
### gtk\_cell\_area\_remove ()
```
void
gtk_cell_area_remove (*`[GtkCellArea](gtkcellarea#GtkCellArea-struct) *area`*,
*`[GtkCellRenderer](gtkcellrenderer#GtkCellRenderer-struct) *renderer`*);
```
Removes *`renderer`* from *`area`* .
#### Parameters
| | | |
| --- | --- | --- |
| area | a [GtkCellArea](gtkcellarea#GtkCellArea-struct) | |
| renderer | the [GtkCellRenderer](gtkcellrenderer#GtkCellRenderer-struct) to remove from *`area`* | |
### gtk\_cell\_area\_has\_renderer ()
```
gboolean
gtk_cell_area_has_renderer (*`[GtkCellArea](gtkcellarea#GtkCellArea-struct) *area`*,
*`[GtkCellRenderer](gtkcellrenderer#GtkCellRenderer-struct) *renderer`*);
```
Checks if *`area`* contains *`renderer`* .
#### Parameters
| | | |
| --- | --- | --- |
| area | a [GtkCellArea](gtkcellarea#GtkCellArea-struct) | |
| renderer | the [GtkCellRenderer](gtkcellrenderer#GtkCellRenderer-struct) to check | |
#### Returns
`TRUE` if *`renderer`* is in the *`area`* .
### gtk\_cell\_area\_foreach ()
```
void
gtk_cell_area_foreach (*`[GtkCellArea](gtkcellarea#GtkCellArea-struct) *area`*,
*`[GtkCellCallback](gtkcellarea#GtkCellCallback) callback`*,
*`gpointer callback_data`*);
```
Calls *`callback`* for every [GtkCellRenderer](gtkcellrenderer#GtkCellRenderer-struct) in *`area`* .
#### Parameters
| | | |
| --- | --- | --- |
| area | a [GtkCellArea](gtkcellarea#GtkCellArea-struct) | |
| callback | the [GtkCellCallback](gtkcellarea#GtkCellCallback) to call. | [scope call] |
| callback\_data | user provided data pointer | |
### gtk\_cell\_area\_foreach\_alloc ()
```
void
gtk_cell_area_foreach_alloc (*`[GtkCellArea](gtkcellarea#GtkCellArea-struct) *area`*,
*`[GtkCellAreaContext](gtkcellareacontext#GtkCellAreaContext-struct) *context`*,
*`[GtkWidget](gtkwidget#GtkWidget-struct) *widget`*,
*`const [GdkRectangle](https://developer-old.gnome.org/gtk4/html/gdk4-Rectangles-and-Regions.html#GdkRectangle-struct) *cell_area`*,
*`const [GdkRectangle](https://developer-old.gnome.org/gtk4/html/gdk4-Rectangles-and-Regions.html#GdkRectangle-struct) *background_area`*,
*`[GtkCellAllocCallback](gtkcellarea#GtkCellAllocCallback) callback`*,
*`gpointer callback_data`*);
```
Calls *`callback`* for every [GtkCellRenderer](gtkcellrenderer#GtkCellRenderer-struct) in *`area`* with the allocated rectangle inside *`cell_area`* .
#### Parameters
| | | |
| --- | --- | --- |
| area | a [GtkCellArea](gtkcellarea#GtkCellArea-struct) | |
| context | the [GtkCellAreaContext](gtkcellareacontext#GtkCellAreaContext-struct) for this row of data. | |
| widget | the [GtkWidget](gtkwidget#GtkWidget-struct) that *`area`* is rendering to | |
| cell\_area | the *`widget`* relative coordinates and size for *`area`* | |
| background\_area | the *`widget`* relative coordinates of the background area | |
| callback | the [GtkCellAllocCallback](gtkcellarea#GtkCellAllocCallback) to call. | [scope call] |
| callback\_data | user provided data pointer | |
### gtk\_cell\_area\_event ()
```
int
gtk_cell_area_event (*`[GtkCellArea](gtkcellarea#GtkCellArea-struct) *area`*,
*`[GtkCellAreaContext](gtkcellareacontext#GtkCellAreaContext-struct) *context`*,
*`[GtkWidget](gtkwidget#GtkWidget-struct) *widget`*,
*`[GdkEvent](https://developer-old.gnome.org/gtk4/html/gdk4-Events.html#GdkEvent-struct) *event`*,
*`const [GdkRectangle](https://developer-old.gnome.org/gtk4/html/gdk4-Rectangles-and-Regions.html#GdkRectangle-struct) *cell_area`*,
*`[GtkCellRendererState](gtkcellrenderer#GtkCellRendererState) flags`*);
```
Delegates event handling to a [GtkCellArea](gtkcellarea#GtkCellArea-struct).
#### Parameters
| | | |
| --- | --- | --- |
| area | a [GtkCellArea](gtkcellarea#GtkCellArea-struct) | |
| context | the [GtkCellAreaContext](gtkcellareacontext#GtkCellAreaContext-struct) for this row of data. | |
| widget | the [GtkWidget](gtkwidget#GtkWidget-struct) that *`area`* is rendering to | |
| event | the [GdkEvent](https://developer-old.gnome.org/gtk4/html/gdk4-Events.html#GdkEvent-struct) to handle | |
| cell\_area | the *`widget`* relative coordinates for *`area`* | |
| flags | the [GtkCellRendererState](gtkcellrenderer#GtkCellRendererState) for *`area`* in this row. | |
#### Returns
`TRUE` if the event was handled by *`area`* .
### gtk\_cell\_area\_snapshot ()
```
void
gtk_cell_area_snapshot (*`[GtkCellArea](gtkcellarea#GtkCellArea-struct) *area`*,
*`[GtkCellAreaContext](gtkcellareacontext#GtkCellAreaContext-struct) *context`*,
*`[GtkWidget](gtkwidget#GtkWidget-struct) *widget`*,
*`[GtkSnapshot](gtksnapshot#GtkSnapshot) *snapshot`*,
*`const [GdkRectangle](https://developer-old.gnome.org/gtk4/html/gdk4-Rectangles-and-Regions.html#GdkRectangle-struct) *background_area`*,
*`const [GdkRectangle](https://developer-old.gnome.org/gtk4/html/gdk4-Rectangles-and-Regions.html#GdkRectangle-struct) *cell_area`*,
*`[GtkCellRendererState](gtkcellrenderer#GtkCellRendererState) flags`*,
*`gboolean paint_focus`*);
```
Snapshots *`area`* ’s cells according to *`area`* ’s layout onto at the given coordinates.
#### Parameters
| | | |
| --- | --- | --- |
| area | a [GtkCellArea](gtkcellarea#GtkCellArea-struct) | |
| context | the [GtkCellAreaContext](gtkcellareacontext#GtkCellAreaContext-struct) for this row of data. | |
| widget | the [GtkWidget](gtkwidget#GtkWidget-struct) that *`area`* is rendering to | |
| snapshot | the [GtkSnapshot](gtksnapshot#GtkSnapshot) to draw to | |
| background\_area | the *`widget`* relative coordinates for *`area`* ’s background | |
| cell\_area | the *`widget`* relative coordinates for *`area`* | |
| flags | the [GtkCellRendererState](gtkcellrenderer#GtkCellRendererState) for *`area`* in this row. | |
| paint\_focus | whether *`area`* should paint focus on focused cells for focused rows or not. | |
### gtk\_cell\_area\_get\_cell\_allocation ()
```
void
gtk_cell_area_get_cell_allocation (*`[GtkCellArea](gtkcellarea#GtkCellArea-struct) *area`*,
*`[GtkCellAreaContext](gtkcellareacontext#GtkCellAreaContext-struct) *context`*,
*`[GtkWidget](gtkwidget#GtkWidget-struct) *widget`*,
*`[GtkCellRenderer](gtkcellrenderer#GtkCellRenderer-struct) *renderer`*,
*`const [GdkRectangle](https://developer-old.gnome.org/gtk4/html/gdk4-Rectangles-and-Regions.html#GdkRectangle-struct) *cell_area`*,
*`[GdkRectangle](https://developer-old.gnome.org/gtk4/html/gdk4-Rectangles-and-Regions.html#GdkRectangle-struct) *allocation`*);
```
Derives the allocation of *`renderer`* inside *`area`* if *`area`* were to be renderered in *`cell_area`* .
#### Parameters
| | | |
| --- | --- | --- |
| area | a [GtkCellArea](gtkcellarea#GtkCellArea-struct) | |
| context | the [GtkCellAreaContext](gtkcellareacontext#GtkCellAreaContext-struct) used to hold sizes for *`area`* . | |
| widget | the [GtkWidget](gtkwidget#GtkWidget-struct) that *`area`* is rendering on | |
| renderer | the [GtkCellRenderer](gtkcellrenderer#GtkCellRenderer-struct) to get the allocation for | |
| cell\_area | the whole allocated area for *`area`* in *`widget`* for this row | |
| allocation | where to store the allocation for *`renderer`* . | [out] |
### gtk\_cell\_area\_get\_cell\_at\_position ()
```
[GtkCellRenderer](gtkcellrenderer#GtkCellRenderer-struct) *
gtk_cell_area_get_cell_at_position (*`[GtkCellArea](gtkcellarea#GtkCellArea-struct) *area`*,
*`[GtkCellAreaContext](gtkcellareacontext#GtkCellAreaContext-struct) *context`*,
*`[GtkWidget](gtkwidget#GtkWidget-struct) *widget`*,
*`const [GdkRectangle](https://developer-old.gnome.org/gtk4/html/gdk4-Rectangles-and-Regions.html#GdkRectangle-struct) *cell_area`*,
*`int x`*,
*`int y`*,
*`[GdkRectangle](https://developer-old.gnome.org/gtk4/html/gdk4-Rectangles-and-Regions.html#GdkRectangle-struct) *alloc_area`*);
```
Gets the [GtkCellRenderer](gtkcellrenderer#GtkCellRenderer-struct) at *`x`* and *`y`* coordinates inside *`area`* and optionally returns the full cell allocation for it inside *`cell_area`* .
#### Parameters
| | | |
| --- | --- | --- |
| area | a [GtkCellArea](gtkcellarea#GtkCellArea-struct) | |
| context | the [GtkCellAreaContext](gtkcellareacontext#GtkCellAreaContext-struct) used to hold sizes for *`area`* . | |
| widget | the [GtkWidget](gtkwidget#GtkWidget-struct) that *`area`* is rendering on | |
| cell\_area | the whole allocated area for *`area`* in *`widget`* for this row | |
| x | the x position | |
| y | the y position | |
| alloc\_area | where to store the inner allocated area of the returned cell renderer, or `NULL`. | [out][allow-none] |
#### Returns
the [GtkCellRenderer](gtkcellrenderer#GtkCellRenderer-struct) at *`x`* and *`y`* .
[transfer none]
### gtk\_cell\_area\_create\_context ()
```
[GtkCellAreaContext](gtkcellareacontext#GtkCellAreaContext-struct) *
gtk_cell_area_create_context (*`[GtkCellArea](gtkcellarea#GtkCellArea-struct) *area`*);
```
Creates a [GtkCellAreaContext](gtkcellareacontext#GtkCellAreaContext-struct) to be used with *`area`* for all purposes. [GtkCellAreaContext](gtkcellareacontext#GtkCellAreaContext-struct) stores geometry information for rows for which it was operated on, it is important to use the same context for the same row of data at all times (i.e. one should render and handle events with the same [GtkCellAreaContext](gtkcellareacontext#GtkCellAreaContext-struct) which was used to request the size of those rows of data).
#### Parameters
| | | |
| --- | --- | --- |
| area | a [GtkCellArea](gtkcellarea#GtkCellArea-struct) | |
#### Returns
a newly created [GtkCellAreaContext](gtkcellareacontext#GtkCellAreaContext-struct) which can be used with *`area`* .
[transfer full]
### gtk\_cell\_area\_copy\_context ()
```
[GtkCellAreaContext](gtkcellareacontext#GtkCellAreaContext-struct) *
gtk_cell_area_copy_context (*`[GtkCellArea](gtkcellarea#GtkCellArea-struct) *area`*,
*`[GtkCellAreaContext](gtkcellareacontext#GtkCellAreaContext-struct) *context`*);
```
This is sometimes needed for cases where rows need to share alignments in one orientation but may be separately grouped in the opposing orientation.
For instance, [GtkIconView](gtkiconview#GtkIconView-struct) creates all icons (rows) to have the same width and the cells theirin to have the same horizontal alignments. However each row of icons may have a separate collective height. [GtkIconView](gtkiconview#GtkIconView-struct) uses this to request the heights of each row based on a context which was already used to request all the row widths that are to be displayed.
#### Parameters
| | | |
| --- | --- | --- |
| area | a [GtkCellArea](gtkcellarea#GtkCellArea-struct) | |
| context | the [GtkCellAreaContext](gtkcellareacontext#GtkCellAreaContext-struct) to copy | |
#### Returns
a newly created [GtkCellAreaContext](gtkcellareacontext#GtkCellAreaContext-struct) copy of *`context`* .
[transfer full]
### gtk\_cell\_area\_get\_request\_mode ()
```
[GtkSizeRequestMode](gtkwidget#GtkSizeRequestMode)
gtk_cell_area_get_request_mode (*`[GtkCellArea](gtkcellarea#GtkCellArea-struct) *area`*);
```
Gets whether the area prefers a height-for-width layout or a width-for-height layout.
#### Parameters
| | | |
| --- | --- | --- |
| area | a [GtkCellArea](gtkcellarea#GtkCellArea-struct) | |
#### Returns
The [GtkSizeRequestMode](gtkwidget#GtkSizeRequestMode) preferred by *`area`* .
### gtk\_cell\_area\_get\_preferred\_width ()
```
void
gtk_cell_area_get_preferred_width (*`[GtkCellArea](gtkcellarea#GtkCellArea-struct) *area`*,
*`[GtkCellAreaContext](gtkcellareacontext#GtkCellAreaContext-struct) *context`*,
*`[GtkWidget](gtkwidget#GtkWidget-struct) *widget`*,
*`int *minimum_width`*,
*`int *natural_width`*);
```
Retrieves a cell area’s initial minimum and natural width.
*`area`* will store some geometrical information in *`context`* along the way; when requesting sizes over an arbitrary number of rows, it’s not important to check the *`minimum_width`* and *`natural_width`* of this call but rather to consult [`gtk_cell_area_context_get_preferred_width()`](gtkcellareacontext#gtk-cell-area-context-get-preferred-width) after a series of requests.
#### Parameters
| | | |
| --- | --- | --- |
| area | a [GtkCellArea](gtkcellarea#GtkCellArea-struct) | |
| context | the [GtkCellAreaContext](gtkcellareacontext#GtkCellAreaContext-struct) to perform this request with | |
| widget | the [GtkWidget](gtkwidget#GtkWidget-struct) where *`area`* will be rendering | |
| minimum\_width | location to store the minimum width, or `NULL`. | [out][allow-none] |
| natural\_width | location to store the natural width, or `NULL`. | [out][allow-none] |
### gtk\_cell\_area\_get\_preferred\_height\_for\_width ()
```
void
gtk_cell_area_get_preferred_height_for_width
(*`[GtkCellArea](gtkcellarea#GtkCellArea-struct) *area`*,
*`[GtkCellAreaContext](gtkcellareacontext#GtkCellAreaContext-struct) *context`*,
*`[GtkWidget](gtkwidget#GtkWidget-struct) *widget`*,
*`int width`*,
*`int *minimum_height`*,
*`int *natural_height`*);
```
Retrieves a cell area’s minimum and natural height if it would be given the specified *`width`* .
*`area`* stores some geometrical information in *`context`* along the way while calling [`gtk_cell_area_get_preferred_width()`](gtkcellarea#gtk-cell-area-get-preferred-width). It’s important to perform a series of [`gtk_cell_area_get_preferred_width()`](gtkcellarea#gtk-cell-area-get-preferred-width) requests with *`context`* first and then call [`gtk_cell_area_get_preferred_height_for_width()`](gtkcellarea#gtk-cell-area-get-preferred-height-for-width) on each cell area individually to get the height for width of each fully requested row.
If at some point, the width of a single row changes, it should be requested with [`gtk_cell_area_get_preferred_width()`](gtkcellarea#gtk-cell-area-get-preferred-width) again and then the full width of the requested rows checked again with [`gtk_cell_area_context_get_preferred_width()`](gtkcellareacontext#gtk-cell-area-context-get-preferred-width).
#### Parameters
| | | |
| --- | --- | --- |
| area | a [GtkCellArea](gtkcellarea#GtkCellArea-struct) | |
| context | the [GtkCellAreaContext](gtkcellareacontext#GtkCellAreaContext-struct) which has already been requested for widths. | |
| widget | the [GtkWidget](gtkwidget#GtkWidget-struct) where *`area`* will be rendering | |
| width | the width for which to check the height of this area | |
| minimum\_height | location to store the minimum height, or `NULL`. | [out][allow-none] |
| natural\_height | location to store the natural height, or `NULL`. | [out][allow-none] |
### gtk\_cell\_area\_get\_preferred\_height ()
```
void
gtk_cell_area_get_preferred_height (*`[GtkCellArea](gtkcellarea#GtkCellArea-struct) *area`*,
*`[GtkCellAreaContext](gtkcellareacontext#GtkCellAreaContext-struct) *context`*,
*`[GtkWidget](gtkwidget#GtkWidget-struct) *widget`*,
*`int *minimum_height`*,
*`int *natural_height`*);
```
Retrieves a cell area’s initial minimum and natural height.
*`area`* will store some geometrical information in *`context`* along the way; when requesting sizes over an arbitrary number of rows, it’s not important to check the *`minimum_height`* and *`natural_height`* of this call but rather to consult [`gtk_cell_area_context_get_preferred_height()`](gtkcellareacontext#gtk-cell-area-context-get-preferred-height) after a series of requests.
#### Parameters
| | | |
| --- | --- | --- |
| area | a [GtkCellArea](gtkcellarea#GtkCellArea-struct) | |
| context | the [GtkCellAreaContext](gtkcellareacontext#GtkCellAreaContext-struct) to perform this request with | |
| widget | the [GtkWidget](gtkwidget#GtkWidget-struct) where *`area`* will be rendering | |
| minimum\_height | location to store the minimum height, or `NULL`. | [out][allow-none] |
| natural\_height | location to store the natural height, or `NULL`. | [out][allow-none] |
### gtk\_cell\_area\_get\_preferred\_width\_for\_height ()
```
void
gtk_cell_area_get_preferred_width_for_height
(*`[GtkCellArea](gtkcellarea#GtkCellArea-struct) *area`*,
*`[GtkCellAreaContext](gtkcellareacontext#GtkCellAreaContext-struct) *context`*,
*`[GtkWidget](gtkwidget#GtkWidget-struct) *widget`*,
*`int height`*,
*`int *minimum_width`*,
*`int *natural_width`*);
```
Retrieves a cell area’s minimum and natural width if it would be given the specified *`height`* .
*`area`* stores some geometrical information in *`context`* along the way while calling [`gtk_cell_area_get_preferred_height()`](gtkcellarea#gtk-cell-area-get-preferred-height). It’s important to perform a series of [`gtk_cell_area_get_preferred_height()`](gtkcellarea#gtk-cell-area-get-preferred-height) requests with *`context`* first and then call [`gtk_cell_area_get_preferred_width_for_height()`](gtkcellarea#gtk-cell-area-get-preferred-width-for-height) on each cell area individually to get the height for width of each fully requested row.
If at some point, the height of a single row changes, it should be requested with [`gtk_cell_area_get_preferred_height()`](gtkcellarea#gtk-cell-area-get-preferred-height) again and then the full height of the requested rows checked again with [`gtk_cell_area_context_get_preferred_height()`](gtkcellareacontext#gtk-cell-area-context-get-preferred-height).
#### Parameters
| | | |
| --- | --- | --- |
| area | a [GtkCellArea](gtkcellarea#GtkCellArea-struct) | |
| context | the [GtkCellAreaContext](gtkcellareacontext#GtkCellAreaContext-struct) which has already been requested for widths. | |
| widget | the [GtkWidget](gtkwidget#GtkWidget-struct) where *`area`* will be rendering | |
| height | the height for which to check the width of this area | |
| minimum\_width | location to store the minimum width, or `NULL`. | [out][allow-none] |
| natural\_width | location to store the natural width, or `NULL`. | [out][allow-none] |
### gtk\_cell\_area\_get\_current\_path\_string ()
```
const char *
gtk_cell_area_get_current_path_string (*`[GtkCellArea](gtkcellarea#GtkCellArea-struct) *area`*);
```
Gets the current [GtkTreePath](gtktreemodel#GtkTreePath-struct) string for the currently applied [GtkTreeIter](gtktreemodel#GtkTreeIter-struct), this is implicitly updated when [`gtk_cell_area_apply_attributes()`](gtkcellarea#gtk-cell-area-apply-attributes) is called and can be used to interact with renderers from [GtkCellArea](gtkcellarea#GtkCellArea-struct) subclasses.
#### Parameters
| | | |
| --- | --- | --- |
| area | a [GtkCellArea](gtkcellarea#GtkCellArea-struct) | |
#### Returns
The current [GtkTreePath](gtktreemodel#GtkTreePath-struct) string for the current attributes applied to *`area`* . This string belongs to the area and should not be freed.
### gtk\_cell\_area\_apply\_attributes ()
```
void
gtk_cell_area_apply_attributes (*`[GtkCellArea](gtkcellarea#GtkCellArea-struct) *area`*,
*`[GtkTreeModel](gtktreemodel#GtkTreeModel-struct) *tree_model`*,
*`[GtkTreeIter](gtktreemodel#GtkTreeIter-struct) *iter`*,
*`gboolean is_expander`*,
*`gboolean is_expanded`*);
```
Applies any connected attributes to the renderers in *`area`* by pulling the values from *`tree_model`* .
#### Parameters
| | | |
| --- | --- | --- |
| area | a [GtkCellArea](gtkcellarea#GtkCellArea-struct) | |
| tree\_model | the [GtkTreeModel](gtktreemodel#GtkTreeModel-struct) to pull values from | |
| iter | the [GtkTreeIter](gtktreemodel#GtkTreeIter-struct) in *`tree_model`* to apply values for | |
| is\_expander | whether *`iter`* has children | |
| is\_expanded | whether *`iter`* is expanded in the view and children are visible | |
### gtk\_cell\_area\_attribute\_connect ()
```
void
gtk_cell_area_attribute_connect (*`[GtkCellArea](gtkcellarea#GtkCellArea-struct) *area`*,
*`[GtkCellRenderer](gtkcellrenderer#GtkCellRenderer-struct) *renderer`*,
*`const char *attribute`*,
*`int column`*);
```
Connects an *`attribute`* to apply values from *`column`* for the [GtkTreeModel](gtktreemodel#GtkTreeModel-struct) in use.
#### Parameters
| | | |
| --- | --- | --- |
| area | a [GtkCellArea](gtkcellarea#GtkCellArea-struct) | |
| renderer | the [GtkCellRenderer](gtkcellrenderer#GtkCellRenderer-struct) to connect an attribute for | |
| attribute | the attribute name | |
| column | the [GtkTreeModel](gtktreemodel#GtkTreeModel-struct) column to fetch attribute values from | |
### gtk\_cell\_area\_attribute\_disconnect ()
```
void
gtk_cell_area_attribute_disconnect (*`[GtkCellArea](gtkcellarea#GtkCellArea-struct) *area`*,
*`[GtkCellRenderer](gtkcellrenderer#GtkCellRenderer-struct) *renderer`*,
*`const char *attribute`*);
```
Disconnects *`attribute`* for the *`renderer`* in *`area`* so that attribute will no longer be updated with values from the model.
#### Parameters
| | | |
| --- | --- | --- |
| area | a [GtkCellArea](gtkcellarea#GtkCellArea-struct) | |
| renderer | the [GtkCellRenderer](gtkcellrenderer#GtkCellRenderer-struct) to disconnect an attribute for | |
| attribute | the attribute name | |
### gtk\_cell\_area\_attribute\_get\_column ()
```
int
gtk_cell_area_attribute_get_column (*`[GtkCellArea](gtkcellarea#GtkCellArea-struct) *area`*,
*`[GtkCellRenderer](gtkcellrenderer#GtkCellRenderer-struct) *renderer`*,
*`const char *attribute`*);
```
Returns the model column that an attribute has been mapped to, or -1 if the attribute is not mapped.
#### Parameters
| | | |
| --- | --- | --- |
| area | a [GtkCellArea](gtkcellarea#GtkCellArea-struct) | |
| renderer | a [GtkCellRenderer](gtkcellrenderer#GtkCellRenderer-struct) | |
| attribute | an attribute on the renderer | |
#### Returns
the model column, or -1
### gtk\_cell\_area\_class\_install\_cell\_property ()
```
void
gtk_cell_area_class_install_cell_property
(*`[GtkCellAreaClass](gtkcellarea#GtkCellAreaClass) *aclass`*,
*`guint property_id`*,
*`GParamSpec *pspec`*);
```
Installs a cell property on a cell area class.
#### Parameters
| | | |
| --- | --- | --- |
| aclass | a [GtkCellAreaClass](gtkcellarea#GtkCellAreaClass) | |
| property\_id | the id for the property | |
| pspec | the GParamSpec for the property | |
### gtk\_cell\_area\_class\_find\_cell\_property ()
```
GParamSpec *
gtk_cell_area_class_find_cell_property
(*`[GtkCellAreaClass](gtkcellarea#GtkCellAreaClass) *aclass`*,
*`const char *property_name`*);
```
Finds a cell property of a cell area class by name.
#### Parameters
| | | |
| --- | --- | --- |
| aclass | a [GtkCellAreaClass](gtkcellarea#GtkCellAreaClass) | |
| property\_name | the name of the child property to find | |
#### Returns
the GParamSpec of the child property or `NULL` if *`aclass`* has no child property with that name.
[transfer none]
### gtk\_cell\_area\_class\_list\_cell\_properties ()
```
GParamSpec **
gtk_cell_area_class_list_cell_properties
(*`[GtkCellAreaClass](gtkcellarea#GtkCellAreaClass) *aclass`*,
*`guint *n_properties`*);
```
Returns all cell properties of a cell area class.
#### Parameters
| | | |
| --- | --- | --- |
| aclass | a [GtkCellAreaClass](gtkcellarea#GtkCellAreaClass) | |
| n\_properties | location to return the number of cell properties found. | [out] |
#### Returns
a newly allocated `NULL`-terminated array of GParamSpec\*. The array must be freed with `g_free()`.
[array length=n\_properties][transfer container]
### gtk\_cell\_area\_add\_with\_properties ()
```
void
gtk_cell_area_add_with_properties (*`[GtkCellArea](gtkcellarea#GtkCellArea-struct) *area`*,
*`[GtkCellRenderer](gtkcellrenderer#GtkCellRenderer-struct) *renderer`*,
*`const char *first_prop_name`*,
*`...`*);
```
Adds *`renderer`* to *`area`* , setting cell properties at the same time. See [`gtk_cell_area_add()`](gtkcellarea#gtk-cell-area-add) and [`gtk_cell_area_cell_set()`](gtkcellarea#gtk-cell-area-cell-set) for more details.
#### Parameters
| | | |
| --- | --- | --- |
| area | a [GtkCellArea](gtkcellarea#GtkCellArea-struct) | |
| renderer | a [GtkCellRenderer](gtkcellrenderer#GtkCellRenderer-struct) to be placed inside *`area`* | |
| first\_prop\_name | the name of the first cell property to set | |
| ... | a `NULL`-terminated list of property names and values, starting with *`first_prop_name`* | |
### gtk\_cell\_area\_cell\_set ()
```
void
gtk_cell_area_cell_set (*`[GtkCellArea](gtkcellarea#GtkCellArea-struct) *area`*,
*`[GtkCellRenderer](gtkcellrenderer#GtkCellRenderer-struct) *renderer`*,
*`const char *first_prop_name`*,
*`...`*);
```
Sets one or more cell properties for *`cell`* in *`area`* .
#### Parameters
| | | |
| --- | --- | --- |
| area | a [GtkCellArea](gtkcellarea#GtkCellArea-struct) | |
| renderer | a [GtkCellRenderer](gtkcellrenderer#GtkCellRenderer-struct) which is a cell inside *`area`* | |
| first\_prop\_name | the name of the first cell property to set | |
| ... | a `NULL`-terminated list of property names and values, starting with *`first_prop_name`* | |
### gtk\_cell\_area\_cell\_get ()
```
void
gtk_cell_area_cell_get (*`[GtkCellArea](gtkcellarea#GtkCellArea-struct) *area`*,
*`[GtkCellRenderer](gtkcellrenderer#GtkCellRenderer-struct) *renderer`*,
*`const char *first_prop_name`*,
*`...`*);
```
Gets the values of one or more cell properties for *`renderer`* in *`area`* .
#### Parameters
| | | |
| --- | --- | --- |
| area | a [GtkCellArea](gtkcellarea#GtkCellArea-struct) | |
| renderer | a [GtkCellRenderer](gtkcellrenderer#GtkCellRenderer-struct) which is inside *`area`* | |
| first\_prop\_name | the name of the first cell property to get | |
| ... | return location for the first cell property, followed optionally by more name/return location pairs, followed by `NULL` | |
### gtk\_cell\_area\_cell\_set\_valist ()
```
void
gtk_cell_area_cell_set_valist (*`[GtkCellArea](gtkcellarea#GtkCellArea-struct) *area`*,
*`[GtkCellRenderer](gtkcellrenderer#GtkCellRenderer-struct) *renderer`*,
*`const char *first_property_name`*,
*`va\_list var_args`*);
```
Sets one or more cell properties for *`renderer`* in *`area`* .
#### Parameters
| | | |
| --- | --- | --- |
| area | a [GtkCellArea](gtkcellarea#GtkCellArea-struct) | |
| renderer | a [GtkCellRenderer](gtkcellrenderer#GtkCellRenderer-struct) which inside *`area`* | |
| first\_property\_name | the name of the first cell property to set | |
| var\_args | a `NULL`-terminated list of property names and values, starting with *`first_prop_name`* | |
### gtk\_cell\_area\_cell\_get\_valist ()
```
void
gtk_cell_area_cell_get_valist (*`[GtkCellArea](gtkcellarea#GtkCellArea-struct) *area`*,
*`[GtkCellRenderer](gtkcellrenderer#GtkCellRenderer-struct) *renderer`*,
*`const char *first_property_name`*,
*`va\_list var_args`*);
```
Gets the values of one or more cell properties for *`renderer`* in *`area`* .
#### Parameters
| | | |
| --- | --- | --- |
| area | a [GtkCellArea](gtkcellarea#GtkCellArea-struct) | |
| renderer | a [GtkCellRenderer](gtkcellrenderer#GtkCellRenderer-struct) inside *`area`* | |
| first\_property\_name | the name of the first property to get | |
| var\_args | return location for the first property, followed optionally by more name/return location pairs, followed by `NULL` | |
### gtk\_cell\_area\_cell\_set\_property ()
```
void
gtk_cell_area_cell_set_property (*`[GtkCellArea](gtkcellarea#GtkCellArea-struct) *area`*,
*`[GtkCellRenderer](gtkcellrenderer#GtkCellRenderer-struct) *renderer`*,
*`const char *property_name`*,
*`const GValue *value`*);
```
Sets a cell property for *`renderer`* in *`area`* .
#### Parameters
| | | |
| --- | --- | --- |
| area | a [GtkCellArea](gtkcellarea#GtkCellArea-struct) | |
| renderer | a [GtkCellRenderer](gtkcellrenderer#GtkCellRenderer-struct) inside *`area`* | |
| property\_name | the name of the cell property to set | |
| value | the value to set the cell property to | |
### gtk\_cell\_area\_cell\_get\_property ()
```
void
gtk_cell_area_cell_get_property (*`[GtkCellArea](gtkcellarea#GtkCellArea-struct) *area`*,
*`[GtkCellRenderer](gtkcellrenderer#GtkCellRenderer-struct) *renderer`*,
*`const char *property_name`*,
*`GValue *value`*);
```
Gets the value of a cell property for *`renderer`* in *`area`* .
#### Parameters
| | | |
| --- | --- | --- |
| area | a [GtkCellArea](gtkcellarea#GtkCellArea-struct) | |
| renderer | a [GtkCellRenderer](gtkcellrenderer#GtkCellRenderer-struct) inside *`area`* | |
| property\_name | the name of the property to get | |
| value | a location to return the value | |
### gtk\_cell\_area\_is\_activatable ()
```
gboolean
gtk_cell_area_is_activatable (*`[GtkCellArea](gtkcellarea#GtkCellArea-struct) *area`*);
```
Returns whether the area can do anything when activated, after applying new attributes to *`area`* .
#### Parameters
| | | |
| --- | --- | --- |
| area | a [GtkCellArea](gtkcellarea#GtkCellArea-struct) | |
#### Returns
whether *`area`* can do anything when activated.
### gtk\_cell\_area\_activate ()
```
gboolean
gtk_cell_area_activate (*`[GtkCellArea](gtkcellarea#GtkCellArea-struct) *area`*,
*`[GtkCellAreaContext](gtkcellareacontext#GtkCellAreaContext-struct) *context`*,
*`[GtkWidget](gtkwidget#GtkWidget-struct) *widget`*,
*`const [GdkRectangle](https://developer-old.gnome.org/gtk4/html/gdk4-Rectangles-and-Regions.html#GdkRectangle-struct) *cell_area`*,
*`[GtkCellRendererState](gtkcellrenderer#GtkCellRendererState) flags`*,
*`gboolean edit_only`*);
```
Activates *`area`* , usually by activating the currently focused cell, however some subclasses which embed widgets in the area can also activate a widget if it currently has the focus.
#### Parameters
| | | |
| --- | --- | --- |
| area | a [GtkCellArea](gtkcellarea#GtkCellArea-struct) | |
| context | the [GtkCellAreaContext](gtkcellareacontext#GtkCellAreaContext-struct) in context with the current row data | |
| widget | the [GtkWidget](gtkwidget#GtkWidget-struct) that *`area`* is rendering on | |
| cell\_area | the size and location of *`area`* relative to *`widget`* ’s allocation | |
| flags | the [GtkCellRendererState](gtkcellrenderer#GtkCellRendererState) flags for *`area`* for this row of data. | |
| edit\_only | if `TRUE` then only cell renderers that are [`GTK_CELL_RENDERER_MODE_EDITABLE`](gtkcellrenderer#GTK-CELL-RENDERER-MODE-EDITABLE:CAPS) will be activated. | |
#### Returns
Whether *`area`* was successfully activated.
### gtk\_cell\_area\_focus ()
```
gboolean
gtk_cell_area_focus (*`[GtkCellArea](gtkcellarea#GtkCellArea-struct) *area`*,
*`[GtkDirectionType](gtk4-standard-enumerations#GtkDirectionType) direction`*);
```
This should be called by the *`area`* ’s owning layout widget when focus is to be passed to *`area`* , or moved within *`area`* for a given *`direction`* and row data.
Implementing [GtkCellArea](gtkcellarea#GtkCellArea-struct) classes should implement this method to receive and navigate focus in its own way particular to how it lays out cells.
#### Parameters
| | | |
| --- | --- | --- |
| area | a [GtkCellArea](gtkcellarea#GtkCellArea-struct) | |
| direction | the [GtkDirectionType](gtk4-standard-enumerations#GtkDirectionType) | |
#### Returns
`TRUE` if focus remains inside *`area`* as a result of this call.
### gtk\_cell\_area\_set\_focus\_cell ()
```
void
gtk_cell_area_set_focus_cell (*`[GtkCellArea](gtkcellarea#GtkCellArea-struct) *area`*,
*`[GtkCellRenderer](gtkcellrenderer#GtkCellRenderer-struct) *renderer`*);
```
Explicitly sets the currently focused cell to *`renderer`* .
This is generally called by implementations of [`GtkCellAreaClass.focus()`](gtkcellarea#GtkCellAreaClass.focus) or [`GtkCellAreaClass.event()`](gtkcellarea#GtkCellAreaClass.event), however it can also be used to implement functions such as [`gtk_tree_view_set_cursor_on_cell()`](gtktreeview#gtk-tree-view-set-cursor-on-cell).
#### Parameters
| | | |
| --- | --- | --- |
| area | a [GtkCellArea](gtkcellarea#GtkCellArea-struct) | |
| renderer | the [GtkCellRenderer](gtkcellrenderer#GtkCellRenderer-struct) to give focus to | |
### gtk\_cell\_area\_get\_focus\_cell ()
```
[GtkCellRenderer](gtkcellrenderer#GtkCellRenderer-struct) *
gtk_cell_area_get_focus_cell (*`[GtkCellArea](gtkcellarea#GtkCellArea-struct) *area`*);
```
Retrieves the currently focused cell for *`area`*
#### Parameters
| | | |
| --- | --- | --- |
| area | a [GtkCellArea](gtkcellarea#GtkCellArea-struct) | |
#### Returns
the currently focused cell in *`area`* .
[transfer none]
### gtk\_cell\_area\_add\_focus\_sibling ()
```
void
gtk_cell_area_add_focus_sibling (*`[GtkCellArea](gtkcellarea#GtkCellArea-struct) *area`*,
*`[GtkCellRenderer](gtkcellrenderer#GtkCellRenderer-struct) *renderer`*,
*`[GtkCellRenderer](gtkcellrenderer#GtkCellRenderer-struct) *sibling`*);
```
Adds *`sibling`* to *`renderer`* ’s focusable area, focus will be drawn around *`renderer`* and all of its siblings if *`renderer`* can focus for a given row.
Events handled by focus siblings can also activate the given focusable *`renderer`* .
#### Parameters
| | | |
| --- | --- | --- |
| area | a [GtkCellArea](gtkcellarea#GtkCellArea-struct) | |
| renderer | the [GtkCellRenderer](gtkcellrenderer#GtkCellRenderer-struct) expected to have focus | |
| sibling | the [GtkCellRenderer](gtkcellrenderer#GtkCellRenderer-struct) to add to *`renderer`* ’s focus area | |
### gtk\_cell\_area\_remove\_focus\_sibling ()
```
void
gtk_cell_area_remove_focus_sibling (*`[GtkCellArea](gtkcellarea#GtkCellArea-struct) *area`*,
*`[GtkCellRenderer](gtkcellrenderer#GtkCellRenderer-struct) *renderer`*,
*`[GtkCellRenderer](gtkcellrenderer#GtkCellRenderer-struct) *sibling`*);
```
Removes *`sibling`* from *`renderer`* ’s focus sibling list (see [`gtk_cell_area_add_focus_sibling()`](gtkcellarea#gtk-cell-area-add-focus-sibling)).
#### Parameters
| | | |
| --- | --- | --- |
| area | a [GtkCellArea](gtkcellarea#GtkCellArea-struct) | |
| renderer | the [GtkCellRenderer](gtkcellrenderer#GtkCellRenderer-struct) expected to have focus | |
| sibling | the [GtkCellRenderer](gtkcellrenderer#GtkCellRenderer-struct) to remove from *`renderer`* ’s focus area | |
### gtk\_cell\_area\_is\_focus\_sibling ()
```
gboolean
gtk_cell_area_is_focus_sibling (*`[GtkCellArea](gtkcellarea#GtkCellArea-struct) *area`*,
*`[GtkCellRenderer](gtkcellrenderer#GtkCellRenderer-struct) *renderer`*,
*`[GtkCellRenderer](gtkcellrenderer#GtkCellRenderer-struct) *sibling`*);
```
Returns whether *`sibling`* is one of *`renderer`* ’s focus siblings (see [`gtk_cell_area_add_focus_sibling()`](gtkcellarea#gtk-cell-area-add-focus-sibling)).
#### Parameters
| | | |
| --- | --- | --- |
| area | a [GtkCellArea](gtkcellarea#GtkCellArea-struct) | |
| renderer | the [GtkCellRenderer](gtkcellrenderer#GtkCellRenderer-struct) expected to have focus | |
| sibling | the [GtkCellRenderer](gtkcellrenderer#GtkCellRenderer-struct) to check against *`renderer`* ’s sibling list | |
#### Returns
`TRUE` if *`sibling`* is a focus sibling of *`renderer`*
### gtk\_cell\_area\_get\_focus\_siblings ()
```
const GList *
gtk_cell_area_get_focus_siblings (*`[GtkCellArea](gtkcellarea#GtkCellArea-struct) *area`*,
*`[GtkCellRenderer](gtkcellrenderer#GtkCellRenderer-struct) *renderer`*);
```
Gets the focus sibling cell renderers for *`renderer`* .
#### Parameters
| | | |
| --- | --- | --- |
| area | a [GtkCellArea](gtkcellarea#GtkCellArea-struct) | |
| renderer | the [GtkCellRenderer](gtkcellrenderer#GtkCellRenderer-struct) expected to have focus | |
#### Returns
A GList of [GtkCellRenderers](gtkcellrenderer#GtkCellRenderer-struct). The returned list is internal and should not be freed.
[element-type GtkCellRenderer][transfer none]
### gtk\_cell\_area\_get\_focus\_from\_sibling ()
```
[GtkCellRenderer](gtkcellrenderer#GtkCellRenderer-struct) *
gtk_cell_area_get_focus_from_sibling (*`[GtkCellArea](gtkcellarea#GtkCellArea-struct) *area`*,
*`[GtkCellRenderer](gtkcellrenderer#GtkCellRenderer-struct) *renderer`*);
```
Gets the [GtkCellRenderer](gtkcellrenderer#GtkCellRenderer-struct) which is expected to be focusable for which *`renderer`* is, or may be a sibling.
This is handy for [GtkCellArea](gtkcellarea#GtkCellArea-struct) subclasses when handling events, after determining the renderer at the event location it can then chose to activate the focus cell for which the event cell may have been a sibling.
#### Parameters
| | | |
| --- | --- | --- |
| area | a [GtkCellArea](gtkcellarea#GtkCellArea-struct) | |
| renderer | the [GtkCellRenderer](gtkcellrenderer#GtkCellRenderer-struct) | |
#### Returns
the [GtkCellRenderer](gtkcellrenderer#GtkCellRenderer-struct) for which *`renderer`* is a sibling, or `NULL`.
[nullable][transfer none]
### gtk\_cell\_area\_get\_edited\_cell ()
```
[GtkCellRenderer](gtkcellrenderer#GtkCellRenderer-struct) *
gtk_cell_area_get_edited_cell (*`[GtkCellArea](gtkcellarea#GtkCellArea-struct) *area`*);
```
Gets the [GtkCellRenderer](gtkcellrenderer#GtkCellRenderer-struct) in *`area`* that is currently being edited.
#### Parameters
| | | |
| --- | --- | --- |
| area | a [GtkCellArea](gtkcellarea#GtkCellArea-struct) | |
#### Returns
The currently edited [GtkCellRenderer](gtkcellrenderer#GtkCellRenderer-struct).
[transfer none]
### gtk\_cell\_area\_get\_edit\_widget ()
```
[GtkCellEditable](gtkcelleditable#GtkCellEditable-struct) *
gtk_cell_area_get_edit_widget (*`[GtkCellArea](gtkcellarea#GtkCellArea-struct) *area`*);
```
Gets the [GtkCellEditable](gtkcelleditable#GtkCellEditable-struct) widget currently used to edit the currently edited cell.
#### Parameters
| | | |
| --- | --- | --- |
| area | a [GtkCellArea](gtkcellarea#GtkCellArea-struct) | |
#### Returns
The currently active [GtkCellEditable](gtkcelleditable#GtkCellEditable-struct) widget.
[transfer none]
### gtk\_cell\_area\_activate\_cell ()
```
gboolean
gtk_cell_area_activate_cell (*`[GtkCellArea](gtkcellarea#GtkCellArea-struct) *area`*,
*`[GtkWidget](gtkwidget#GtkWidget-struct) *widget`*,
*`[GtkCellRenderer](gtkcellrenderer#GtkCellRenderer-struct) *renderer`*,
*`[GdkEvent](https://developer-old.gnome.org/gtk4/html/gdk4-Events.html#GdkEvent-struct) *event`*,
*`const [GdkRectangle](https://developer-old.gnome.org/gtk4/html/gdk4-Rectangles-and-Regions.html#GdkRectangle-struct) *cell_area`*,
*`[GtkCellRendererState](gtkcellrenderer#GtkCellRendererState) flags`*);
```
This is used by [GtkCellArea](gtkcellarea#GtkCellArea-struct) subclasses when handling events to activate cells, the base [GtkCellArea](gtkcellarea#GtkCellArea-struct) class activates cells for keyboard events for free in its own GtkCellArea->`activate()` implementation.
#### Parameters
| | | |
| --- | --- | --- |
| area | a [GtkCellArea](gtkcellarea#GtkCellArea-struct) | |
| widget | the [GtkWidget](gtkwidget#GtkWidget-struct) that *`area`* is rendering onto | |
| renderer | the [GtkCellRenderer](gtkcellrenderer#GtkCellRenderer-struct) in *`area`* to activate | |
| event | the [GdkEvent](https://developer-old.gnome.org/gtk4/html/gdk4-Events.html#GdkEvent-struct) for which cell activation should occur | |
| cell\_area | the [GdkRectangle](https://developer-old.gnome.org/gtk4/html/gdk4-Rectangles-and-Regions.html#GdkRectangle-struct) in *`widget`* relative coordinates of *`renderer`* for the current row. | |
| flags | the [GtkCellRendererState](gtkcellrenderer#GtkCellRendererState) for *`renderer`* | |
#### Returns
whether cell activation was successful
### gtk\_cell\_area\_stop\_editing ()
```
void
gtk_cell_area_stop_editing (*`[GtkCellArea](gtkcellarea#GtkCellArea-struct) *area`*,
*`gboolean canceled`*);
```
Explicitly stops the editing of the currently edited cell.
If *`canceled`* is `TRUE`, the currently edited cell renderer will emit the ::editing-canceled signal, otherwise the the ::editing-done signal will be emitted on the current edit widget.
See [`gtk_cell_area_get_edited_cell()`](gtkcellarea#gtk-cell-area-get-edited-cell) and [`gtk_cell_area_get_edit_widget()`](gtkcellarea#gtk-cell-area-get-edit-widget).
#### Parameters
| | | |
| --- | --- | --- |
| area | a [GtkCellArea](gtkcellarea#GtkCellArea-struct) | |
| canceled | whether editing was canceled. | |
### gtk\_cell\_area\_inner\_cell\_area ()
```
void
gtk_cell_area_inner_cell_area (*`[GtkCellArea](gtkcellarea#GtkCellArea-struct) *area`*,
*`[GtkWidget](gtkwidget#GtkWidget-struct) *widget`*,
*`const [GdkRectangle](https://developer-old.gnome.org/gtk4/html/gdk4-Rectangles-and-Regions.html#GdkRectangle-struct) *cell_area`*,
*`[GdkRectangle](https://developer-old.gnome.org/gtk4/html/gdk4-Rectangles-and-Regions.html#GdkRectangle-struct) *inner_area`*);
```
This is a convenience function for [GtkCellArea](gtkcellarea#GtkCellArea-struct) implementations to get the inner area where a given [GtkCellRenderer](gtkcellrenderer#GtkCellRenderer-struct) will be rendered. It removes any padding previously added by [`gtk_cell_area_request_renderer()`](gtkcellarea#gtk-cell-area-request-renderer).
#### Parameters
| | | |
| --- | --- | --- |
| area | a [GtkCellArea](gtkcellarea#GtkCellArea-struct) | |
| widget | the [GtkWidget](gtkwidget#GtkWidget-struct) that *`area`* is rendering onto | |
| cell\_area | the *`widget`* relative coordinates where one of *`area`* ’s cells is to be placed | |
| inner\_area | the return location for the inner cell area. | [out] |
### gtk\_cell\_area\_request\_renderer ()
```
void
gtk_cell_area_request_renderer (*`[GtkCellArea](gtkcellarea#GtkCellArea-struct) *area`*,
*`[GtkCellRenderer](gtkcellrenderer#GtkCellRenderer-struct) *renderer`*,
*`[GtkOrientation](gtk4-standard-enumerations#GtkOrientation) orientation`*,
*`[GtkWidget](gtkwidget#GtkWidget-struct) *widget`*,
*`int for_size`*,
*`int *minimum_size`*,
*`int *natural_size`*);
```
This is a convenience function for [GtkCellArea](gtkcellarea#GtkCellArea-struct) implementations to request size for cell renderers. It’s important to use this function to request size and then use [`gtk_cell_area_inner_cell_area()`](gtkcellarea#gtk-cell-area-inner-cell-area) at render and event time since this function will add padding around the cell for focus painting.
#### Parameters
| | | |
| --- | --- | --- |
| area | a [GtkCellArea](gtkcellarea#GtkCellArea-struct) | |
| renderer | the [GtkCellRenderer](gtkcellrenderer#GtkCellRenderer-struct) to request size for | |
| orientation | the [GtkOrientation](gtk4-standard-enumerations#GtkOrientation) in which to request size | |
| widget | the [GtkWidget](gtkwidget#GtkWidget-struct) that *`area`* is rendering onto | |
| for\_size | the allocation contextual size to request for, or -1 if the base request for the orientation is to be returned. | |
| minimum\_size | location to store the minimum size, or `NULL`. | [out][allow-none] |
| natural\_size | location to store the natural size, or `NULL`. | [out][allow-none] |
Types and Values
----------------
### struct GtkCellArea
```
struct GtkCellArea;
```
### struct GtkCellAreaClass
```
struct GtkCellAreaClass {
/* Basic methods */
void (* add) (GtkCellArea *area,
GtkCellRenderer *renderer);
void (* remove) (GtkCellArea *area,
GtkCellRenderer *renderer);
void (* foreach) (GtkCellArea *area,
GtkCellCallback callback,
gpointer callback_data);
void (* foreach_alloc) (GtkCellArea *area,
GtkCellAreaContext *context,
GtkWidget *widget,
const GdkRectangle *cell_area,
const GdkRectangle *background_area,
GtkCellAllocCallback callback,
gpointer callback_data);
int (* event) (GtkCellArea *area,
GtkCellAreaContext *context,
GtkWidget *widget,
GdkEvent *event,
const GdkRectangle *cell_area,
GtkCellRendererState flags);
void (* snapshot) (GtkCellArea *area,
GtkCellAreaContext *context,
GtkWidget *widget,
GtkSnapshot *snapshot,
const GdkRectangle *background_area,
const GdkRectangle *cell_area,
GtkCellRendererState flags,
gboolean paint_focus);
void (* apply_attributes) (GtkCellArea *area,
GtkTreeModel *tree_model,
GtkTreeIter *iter,
gboolean is_expander,
gboolean is_expanded);
/* Geometry */
GtkCellAreaContext *(* create_context) (GtkCellArea *area);
GtkCellAreaContext *(* copy_context) (GtkCellArea *area,
GtkCellAreaContext *context);
GtkSizeRequestMode (* get_request_mode) (GtkCellArea *area);
void (* get_preferred_width) (GtkCellArea *area,
GtkCellAreaContext *context,
GtkWidget *widget,
int *minimum_width,
int *natural_width);
void (* get_preferred_height_for_width) (GtkCellArea *area,
GtkCellAreaContext *context,
GtkWidget *widget,
int width,
int *minimum_height,
int *natural_height);
void (* get_preferred_height) (GtkCellArea *area,
GtkCellAreaContext *context,
GtkWidget *widget,
int *minimum_height,
int *natural_height);
void (* get_preferred_width_for_height) (GtkCellArea *area,
GtkCellAreaContext *context,
GtkWidget *widget,
int height,
int *minimum_width,
int *natural_width);
/* Cell Properties */
void (* set_cell_property) (GtkCellArea *area,
GtkCellRenderer *renderer,
guint property_id,
const GValue *value,
GParamSpec *pspec);
void (* get_cell_property) (GtkCellArea *area,
GtkCellRenderer *renderer,
guint property_id,
GValue *value,
GParamSpec *pspec);
/* Focus */
gboolean (* focus) (GtkCellArea *area,
GtkDirectionType direction);
gboolean (* is_activatable) (GtkCellArea *area);
gboolean (* activate) (GtkCellArea *area,
GtkCellAreaContext *context,
GtkWidget *widget,
const GdkRectangle *cell_area,
GtkCellRendererState flags,
gboolean edit_only);
};
```
#### Members
| | | |
| --- | --- | --- |
| *`add`* () | adds a [GtkCellRenderer](gtkcellrenderer#GtkCellRenderer-struct) to the area. | |
| *`remove`* () | removes a [GtkCellRenderer](gtkcellrenderer#GtkCellRenderer-struct) from the area. | |
| *`foreach`* () | calls the [GtkCellCallback](gtkcellarea#GtkCellCallback) function on every [GtkCellRenderer](gtkcellrenderer#GtkCellRenderer-struct) in the area with the provided user data until the callback returns `TRUE`. | |
| *`foreach_alloc`* () | Calls the [GtkCellAllocCallback](gtkcellarea#GtkCellAllocCallback) function on every [GtkCellRenderer](gtkcellrenderer#GtkCellRenderer-struct) in the area with the allocated area for the cell and the provided user data until the callback returns `TRUE`. | |
| *`event`* () | Handle an event in the area, this is generally used to activate a cell at the event location for button events but can also be used to generically pass events to [GtkWidgets](gtkwidget#GtkWidget-struct) drawn onto the area. | |
| *`snapshot`* () | Actually snapshot the area’s cells to the specified rectangle, *`background_area`* should be correctly distributed to the cells corresponding background areas. | |
| *`apply_attributes`* () | Apply the cell attributes to the cells. This is implemented as a signal and generally [GtkCellArea](gtkcellarea#GtkCellArea-struct) subclasses don't need to implement it since it is handled by the base class. | |
| *`create_context`* () | Creates and returns a class specific [GtkCellAreaContext](gtkcellareacontext#GtkCellAreaContext-struct) to store cell alignment and allocation details for a said [GtkCellArea](gtkcellarea#GtkCellArea-struct) class. | |
| *`copy_context`* () | Creates a new [GtkCellAreaContext](gtkcellareacontext#GtkCellAreaContext-struct) in the same state as the passed *`context`* with any cell alignment data and allocations intact. | |
| *`get_request_mode`* () | This allows an area to tell its layouting widget whether it prefers to be allocated in [`GTK_SIZE_REQUEST_HEIGHT_FOR_WIDTH`](gtkwidget#GTK-SIZE-REQUEST-HEIGHT-FOR-WIDTH:CAPS) or [`GTK_SIZE_REQUEST_WIDTH_FOR_HEIGHT`](gtkwidget#GTK-SIZE-REQUEST-WIDTH-FOR-HEIGHT:CAPS) mode. | |
| *`get_preferred_width`* () | Calculates the minimum and natural width of the areas cells with the current attributes applied while considering the particular layouting details of the said [GtkCellArea](gtkcellarea#GtkCellArea-struct). While requests are performed over a series of rows, alignments and overall minimum and natural sizes should be stored in the corresponding [GtkCellAreaContext](gtkcellareacontext#GtkCellAreaContext-struct). | |
| *`get_preferred_height_for_width`* () | Calculates the minimum and natural height for the area if the passed *`context`* would be allocated the given width. When implementing this virtual method it is safe to assume that *`context`* has already stored the aligned cell widths for every [GtkTreeModel](gtktreemodel#GtkTreeModel-struct) row that *`context`* will be allocated for since this information was stored at [`GtkCellAreaClass.get_preferred_width()`](gtkcellarea#GtkCellAreaClass.get-preferred-width) time. This virtual method should also store any necessary alignments of cell heights for the case that the context is allocated a height. | |
| *`get_preferred_height`* () | Calculates the minimum and natural height of the areas cells with the current attributes applied. Essentially this is the same as [`GtkCellAreaClass.get_preferred_width()`](gtkcellarea#GtkCellAreaClass.get-preferred-width) only for areas that are being requested as [`GTK_SIZE_REQUEST_WIDTH_FOR_HEIGHT`](gtkwidget#GTK-SIZE-REQUEST-WIDTH-FOR-HEIGHT:CAPS). | |
| *`get_preferred_width_for_height`* () | Calculates the minimum and natural width for the area if the passed *`context`* would be allocated the given height. The same as [`GtkCellAreaClass.get_preferred_height_for_width()`](gtkcellarea#GtkCellAreaClass.get-preferred-height-for-width) only for handling requests in the [`GTK_SIZE_REQUEST_WIDTH_FOR_HEIGHT`](gtkwidget#GTK-SIZE-REQUEST-WIDTH-FOR-HEIGHT:CAPS) mode. | |
| *`set_cell_property`* () | This should be implemented to handle changes in child cell properties for a given [GtkCellRenderer](gtkcellrenderer#GtkCellRenderer-struct) that were previously installed on the [GtkCellAreaClass](gtkcellarea#GtkCellAreaClass) with [`gtk_cell_area_class_install_cell_property()`](gtkcellarea#gtk-cell-area-class-install-cell-property). | |
| *`get_cell_property`* () | This should be implemented to report the values of child cell properties for a given child [GtkCellRenderer](gtkcellrenderer#GtkCellRenderer-struct). | |
| *`focus`* () | This virtual method should be implemented to navigate focus from cell to cell inside the [GtkCellArea](gtkcellarea#GtkCellArea-struct). The [GtkCellArea](gtkcellarea#GtkCellArea-struct) should move focus from cell to cell inside the area and return `FALSE` if focus logically leaves the area with the following exceptions: When the area contains no activatable cells, the entire area receives focus. Focus should not be given to cells that are actually “focus siblings” of other sibling cells (see [`gtk_cell_area_get_focus_from_sibling()`](gtkcellarea#gtk-cell-area-get-focus-from-sibling)). Focus is set by calling [`gtk_cell_area_set_focus_cell()`](gtkcellarea#gtk-cell-area-set-focus-cell). | |
| *`is_activatable`* () | Returns whether the [GtkCellArea](gtkcellarea#GtkCellArea-struct) can respond to [`GtkCellAreaClass.activate()`](gtkcellarea#GtkCellAreaClass.activate), usually this does not need to be implemented since the base class takes care of this however it can be enhanced if the [GtkCellArea](gtkcellarea#GtkCellArea-struct) subclass can handle activation in other ways than activating its [GtkCellRenderers](gtkcellrenderer#GtkCellRenderer-struct). | |
| *`activate`* () | This is called when the layouting widget rendering the [GtkCellArea](gtkcellarea#GtkCellArea-struct) activates the focus cell (see [`gtk_cell_area_get_focus_cell()`](gtkcellarea#gtk-cell-area-get-focus-cell)). | |
Property Details
----------------
### The `“edit-widget”` property
```
“edit-widget” [GtkCellEditable](gtkcelleditable#GtkCellEditable-struct) *
```
The widget currently editing the edited cell
This property is read-only and only changes as a result of a call [`gtk_cell_area_activate_cell()`](gtkcellarea#gtk-cell-area-activate-cell).
Owner: GtkCellArea
Flags: Read
### The `“edited-cell”` property
```
“edited-cell” [GtkCellRenderer](gtkcellrenderer#GtkCellRenderer-struct) *
```
The cell in the area that is currently edited
This property is read-only and only changes as a result of a call [`gtk_cell_area_activate_cell()`](gtkcellarea#gtk-cell-area-activate-cell).
Owner: GtkCellArea
Flags: Read
### The `“focus-cell”` property
```
“focus-cell” [GtkCellRenderer](gtkcellrenderer#GtkCellRenderer-struct) *
```
The cell in the area that currently has focus
Owner: GtkCellArea
Flags: Read / Write
Signal Details
--------------
### The `“add-editable”` signal
```
void
user_function ([GtkCellArea](gtkcellarea#GtkCellArea-struct) *area,
[GtkCellRenderer](gtkcellrenderer#GtkCellRenderer-struct) *renderer,
[GtkCellEditable](gtkcelleditable#GtkCellEditable-struct) *editable,
[GdkRectangle](https://developer-old.gnome.org/gtk4/html/gdk4-Rectangles-and-Regions.html#GdkRectangle-struct) *cell_area,
char *path,
gpointer user_data)
```
Indicates that editing has started on *`renderer`* and that *`editable`* should be added to the owning cell-layouting widget at *`cell_area`* .
#### Parameters
| | | |
| --- | --- | --- |
| area | the [GtkCellArea](gtkcellarea#GtkCellArea-struct) where editing started | |
| renderer | the [GtkCellRenderer](gtkcellrenderer#GtkCellRenderer-struct) that started the edited | |
| editable | the [GtkCellEditable](gtkcelleditable#GtkCellEditable-struct) widget to add | |
| cell\_area | the [GtkWidget](gtkwidget#GtkWidget-struct) relative [GdkRectangle](https://developer-old.gnome.org/gtk4/html/gdk4-Rectangles-and-Regions.html#GdkRectangle-struct) coordinates where *`editable`* should be added | |
| path | the [GtkTreePath](gtktreemodel#GtkTreePath-struct) string this edit was initiated for | |
| user\_data | user data set when the signal handler was connected. | |
Flags: Run First
### The `“apply-attributes”` signal
```
void
user_function ([GtkCellArea](gtkcellarea#GtkCellArea-struct) *area,
[GtkTreeModel](gtktreemodel#GtkTreeModel-struct) *model,
[GtkTreeIter](gtktreemodel#GtkTreeIter-struct) *iter,
gboolean is_expander,
gboolean is_expanded,
gpointer user_data)
```
This signal is emitted whenever applying attributes to *`area`* from *`model`*
#### Parameters
| | | |
| --- | --- | --- |
| area | the [GtkCellArea](gtkcellarea#GtkCellArea-struct) to apply the attributes to | |
| model | the [GtkTreeModel](gtktreemodel#GtkTreeModel-struct) to apply the attributes from | |
| iter | the [GtkTreeIter](gtktreemodel#GtkTreeIter-struct) indicating which row to apply the attributes of | |
| is\_expander | whether the view shows children for this row | |
| is\_expanded | whether the view is currently showing the children of this row | |
| user\_data | user data set when the signal handler was connected. | |
Flags: Run First
### The `“focus-changed”` signal
```
void
user_function ([GtkCellArea](gtkcellarea#GtkCellArea-struct) *area,
[GtkCellRenderer](gtkcellrenderer#GtkCellRenderer-struct) *renderer,
char *path,
gpointer user_data)
```
Indicates that focus changed on this *`area`* . This signal is emitted either as a result of focus handling or event handling.
It's possible that the signal is emitted even if the currently focused renderer did not change, this is because focus may change to the same renderer in the same cell area for a different row of data.
#### Parameters
| | | |
| --- | --- | --- |
| area | the [GtkCellArea](gtkcellarea#GtkCellArea-struct) where focus changed | |
| renderer | the [GtkCellRenderer](gtkcellrenderer#GtkCellRenderer-struct) that has focus | |
| path | the current [GtkTreePath](gtktreemodel#GtkTreePath-struct) string set for *`area`* | |
| user\_data | user data set when the signal handler was connected. | |
Flags: Run First
### The `“remove-editable”` signal
```
void
user_function ([GtkCellArea](gtkcellarea#GtkCellArea-struct) *area,
[GtkCellRenderer](gtkcellrenderer#GtkCellRenderer-struct) *renderer,
[GtkCellEditable](gtkcelleditable#GtkCellEditable-struct) *editable,
gpointer user_data)
```
Indicates that editing finished on *`renderer`* and that *`editable`* should be removed from the owning cell-layouting widget.
#### Parameters
| | | |
| --- | --- | --- |
| area | the [GtkCellArea](gtkcellarea#GtkCellArea-struct) where editing finished | |
| renderer | the [GtkCellRenderer](gtkcellrenderer#GtkCellRenderer-struct) that finished editeding | |
| editable | the [GtkCellEditable](gtkcelleditable#GtkCellEditable-struct) widget to remove | |
| user\_data | user data set when the signal handler was connected. | |
Flags: Run First
| programming_docs |
gtk GtkMessageDialog GtkMessageDialog
================
GtkMessageDialog — A convenient message window
Functions
---------
| | |
| --- | --- |
| [GtkWidget](gtkwidget#GtkWidget-struct) \* | [gtk\_message\_dialog\_new](gtkmessagedialog#gtk-message-dialog-new) () |
| [GtkWidget](gtkwidget#GtkWidget-struct) \* | [gtk\_message\_dialog\_new\_with\_markup](gtkmessagedialog#gtk-message-dialog-new-with-markup) () |
| void | [gtk\_message\_dialog\_set\_markup](gtkmessagedialog#gtk-message-dialog-set-markup) () |
| void | [gtk\_message\_dialog\_format\_secondary\_text](gtkmessagedialog#gtk-message-dialog-format-secondary-text) () |
| void | [gtk\_message\_dialog\_format\_secondary\_markup](gtkmessagedialog#gtk-message-dialog-format-secondary-markup) () |
| [GtkWidget](gtkwidget#GtkWidget-struct) \* | [gtk\_message\_dialog\_get\_message\_area](gtkmessagedialog#gtk-message-dialog-get-message-area) () |
Properties
----------
| | | |
| --- | --- | --- |
| [GtkButtonsType](gtkmessagedialog#GtkButtonsType) | [buttons](gtkmessagedialog#GtkMessageDialog--buttons) | Write / Construct Only |
| [GtkWidget](gtkwidget#GtkWidget-struct) \* | [message-area](gtkmessagedialog#GtkMessageDialog--message-area) | Read |
| [GtkMessageType](gtkmessagedialog#GtkMessageType) | [message-type](gtkmessagedialog#GtkMessageDialog--message-type) | Read / Write / Construct |
| char \* | [secondary-text](gtkmessagedialog#GtkMessageDialog--secondary-text) | Read / Write |
| gboolean | [secondary-use-markup](gtkmessagedialog#GtkMessageDialog--secondary-use-markup) | Read / Write |
| char \* | [text](gtkmessagedialog#GtkMessageDialog--text) | Read / Write |
| gboolean | [use-markup](gtkmessagedialog#GtkMessageDialog--use-markup) | Read / Write |
Types and Values
----------------
| | |
| --- | --- |
| struct | [GtkMessageDialog](gtkmessagedialog#GtkMessageDialog-struct) |
| enum | [GtkMessageType](gtkmessagedialog#GtkMessageType) |
| enum | [GtkButtonsType](gtkmessagedialog#GtkButtonsType) |
Object Hierarchy
----------------
```
GObject
╰── GInitiallyUnowned
╰── [GtkWidget](gtkwidget#GtkWidget-struct)
╰── [GtkWindow](gtkwindow#GtkWindow-struct)
╰── [GtkDialog](gtkdialog#GtkDialog-struct)
╰── GtkMessageDialog
```
Implemented Interfaces
----------------------
GtkMessageDialog implements [GtkAccessible](gtkaccessible#GtkAccessible-struct), [GtkBuildable](gtkbuildable#GtkBuildable-struct), [GtkConstraintTarget](gtkconstraint#GtkConstraintTarget-struct), [GtkNative](gtknative#GtkNative-struct), [GtkShortcutManager](gtkshortcutmanager#GtkShortcutManager-struct) and [GtkRoot](gtkroot#GtkRoot-struct).
Includes
--------
```
#include <gtk/gtk.h>
```
Description
-----------
[GtkMessageDialog](gtkmessagedialog#GtkMessageDialog-struct) presents a dialog with some message text. It’s simply a convenience widget; you could construct the equivalent of [GtkMessageDialog](gtkmessagedialog#GtkMessageDialog-struct) from [GtkDialog](gtkdialog#GtkDialog-struct) without too much effort, but [GtkMessageDialog](gtkmessagedialog#GtkMessageDialog-struct) saves typing.
The easiest way to do a modal message dialog is to use the [`GTK_DIALOG_MODAL`](gtkdialog#GTK-DIALOG-MODAL:CAPS) flag, which will call [`gtk_window_set_modal()`](gtkwindow#gtk-window-set-modal) internally. The dialog will prevent interaction with the parent window until it's hidden or destroyed. You can use the [“response”](gtkdialog#GtkDialog-response) signal to know when the user dismissed the dialog.
An example for using a modal dialog:
You might do a non-modal [GtkMessageDialog](gtkmessagedialog#GtkMessageDialog-struct) simply by omitting the [`GTK_DIALOG_MODAL`](gtkdialog#GTK-DIALOG-MODAL:CAPS) flag:
### GtkMessageDialog as GtkBuildable
The GtkMessageDialog implementation of the GtkBuildable interface exposes the message area as an internal child with the name “message\_area”.
Functions
---------
### gtk\_message\_dialog\_new ()
```
[GtkWidget](gtkwidget#GtkWidget-struct) *
gtk_message_dialog_new (*`[GtkWindow](gtkwindow#GtkWindow-struct) *parent`*,
*`[GtkDialogFlags](gtkdialog#GtkDialogFlags) flags`*,
*`[GtkMessageType](gtkmessagedialog#GtkMessageType) type`*,
*`[GtkButtonsType](gtkmessagedialog#GtkButtonsType) buttons`*,
*`const char *message_format`*,
*`...`*);
```
Creates a new message dialog, which is a simple dialog with some text the user may want to see. When the user clicks a button a “response” signal is emitted with response IDs from [GtkResponseType](gtkdialog#GtkResponseType). See [GtkDialog](gtkdialog#GtkDialog-struct) for more details.
#### Parameters
| | | |
| --- | --- | --- |
| parent | transient parent, or `NULL` for none. | [allow-none] |
| flags | flags | |
| type | type of message | |
| buttons | set of buttons to use | |
| message\_format | printf()-style format string, or `NULL`. | [allow-none] |
| ... | arguments for *`message_format`* | |
#### Returns
a new [GtkMessageDialog](gtkmessagedialog#GtkMessageDialog-struct).
[transfer none]
### gtk\_message\_dialog\_new\_with\_markup ()
```
[GtkWidget](gtkwidget#GtkWidget-struct) *
gtk_message_dialog_new_with_markup (*`[GtkWindow](gtkwindow#GtkWindow-struct) *parent`*,
*`[GtkDialogFlags](gtkdialog#GtkDialogFlags) flags`*,
*`[GtkMessageType](gtkmessagedialog#GtkMessageType) type`*,
*`[GtkButtonsType](gtkmessagedialog#GtkButtonsType) buttons`*,
*`const char *message_format`*,
*`...`*);
```
Creates a new message dialog, which is a simple dialog with some text that is marked up with the Pango text markup language. When the user clicks a button a “response” signal is emitted with response IDs from [GtkResponseType](gtkdialog#GtkResponseType). See [GtkDialog](gtkdialog#GtkDialog-struct) for more details.
Special XML characters in the `printf()` arguments passed to this function will automatically be escaped as necessary. (See `g_markup_printf_escaped()` for how this is implemented.) Usually this is what you want, but if you have an existing Pango markup string that you want to use literally as the label, then you need to use [`gtk_message_dialog_set_markup()`](gtkmessagedialog#gtk-message-dialog-set-markup) instead, since you can’t pass the markup string either as the format (it might contain “%” characters) or as a string argument.
#### Parameters
| | | |
| --- | --- | --- |
| parent | transient parent, or `NULL` for none. | [allow-none] |
| flags | flags | |
| type | type of message | |
| buttons | set of buttons to use | |
| message\_format | printf()-style format string, or `NULL`. | [allow-none] |
| ... | arguments for *`message_format`* | |
#### Returns
a new [GtkMessageDialog](gtkmessagedialog#GtkMessageDialog-struct)
### gtk\_message\_dialog\_set\_markup ()
```
void
gtk_message_dialog_set_markup (*`[GtkMessageDialog](gtkmessagedialog#GtkMessageDialog-struct) *message_dialog`*,
*`const char *str`*);
```
Sets the text of the message dialog to be *`str`* , which is marked up with the Pango text markup language.
#### Parameters
| | | |
| --- | --- | --- |
| message\_dialog | a [GtkMessageDialog](gtkmessagedialog#GtkMessageDialog-struct) | |
| str | markup string (see Pango markup format) | |
### gtk\_message\_dialog\_format\_secondary\_text ()
```
void
gtk_message_dialog_format_secondary_text
(*`[GtkMessageDialog](gtkmessagedialog#GtkMessageDialog-struct) *message_dialog`*,
*`const char *message_format`*,
*`...`*);
```
Sets the secondary text of the message dialog to be *`message_format`* (with `printf()`-style).
#### Parameters
| | | |
| --- | --- | --- |
| message\_dialog | a [GtkMessageDialog](gtkmessagedialog#GtkMessageDialog-struct) | |
| message\_format | printf()-style format string, or `NULL`. | [allow-none] |
| ... | arguments for *`message_format`* | |
### gtk\_message\_dialog\_format\_secondary\_markup ()
```
void
gtk_message_dialog_format_secondary_markup
(*`[GtkMessageDialog](gtkmessagedialog#GtkMessageDialog-struct) *message_dialog`*,
*`const char *message_format`*,
*`...`*);
```
Sets the secondary text of the message dialog to be *`message_format`* (with `printf()`-style), which is marked up with the Pango text markup language.
Due to an oversight, this function does not escape special XML characters like [`gtk_message_dialog_new_with_markup()`](gtkmessagedialog#gtk-message-dialog-new-with-markup) does. Thus, if the arguments may contain special XML characters, you should use `g_markup_printf_escaped()` to escape it.
```
GtkDialogFlags flags = GTK_DIALOG_DESTROY_WITH_PARENT | GTK_DIALOG_MODAL;
dialog = gtk_message_dialog_new (parent_window,
flags,
GTK_MESSAGE_ERROR,
GTK_BUTTONS_CLOSE,
"Error reading “%s”: %s",
filename,
g_strerror (errno));
// Destroy the dialog when the user responds to it
// (e.g. clicks a button)
g_signal_connect (dialog, "response",
G_CALLBACK (gtk_window_destroy),
NULL);
```
| #### Parameters
| | | |
| --- | --- | --- |
| message\_dialog | a [GtkMessageDialog](gtkmessagedialog#GtkMessageDialog-struct) | |
| message\_format | printf()-style markup string (see Pango markup format), or `NULL` | |
| ... | arguments for *`message_format`* | |
### gtk\_message\_dialog\_get\_message\_area ()
```
[GtkWidget](gtkwidget#GtkWidget-struct) *
gtk_message_dialog_get_message_area (*`[GtkMessageDialog](gtkmessagedialog#GtkMessageDialog-struct) *message_dialog`*);
```
Returns the message area of the dialog. This is the box where the dialog’s primary and secondary labels are packed. You can add your own extra content to that box and it will appear below those labels. See [`gtk_dialog_get_content_area()`](gtkdialog#gtk-dialog-get-content-area) for the corresponding function in the parent [GtkDialog](gtkdialog#GtkDialog-struct).
#### Parameters
| | | |
| --- | --- | --- |
| message\_dialog | a [GtkMessageDialog](gtkmessagedialog#GtkMessageDialog-struct) | |
#### Returns
A [GtkBox](gtkbox#GtkBox-struct) corresponding to the “message area” in the *`message_dialog`* .
[transfer none]
Types and Values
----------------
### struct GtkMessageDialog
```
struct GtkMessageDialog;
```
### enum GtkMessageType
The type of message being displayed in the dialog.
#### Members
| | | |
| --- | --- | --- |
| GTK\_MESSAGE\_INFO | Informational message | |
| GTK\_MESSAGE\_WARNING | Non-fatal warning message | |
| GTK\_MESSAGE\_QUESTION | Question requiring a choice | |
| GTK\_MESSAGE\_ERROR | Fatal error message | |
| GTK\_MESSAGE\_OTHER | None of the above | |
### enum GtkButtonsType
Prebuilt sets of buttons for the dialog. If none of these choices are appropriate, simply use [`GTK_BUTTONS_NONE`](gtkmessagedialog#GTK-BUTTONS-NONE:CAPS) then call [`gtk_dialog_add_buttons()`](gtkdialog#gtk-dialog-add-buttons).
> Please note that [`GTK_BUTTONS_OK`](gtkmessagedialog#GTK-BUTTONS-OK:CAPS), [`GTK_BUTTONS_YES_NO`](gtkmessagedialog#GTK-BUTTONS-YES-NO:CAPS) and [`GTK_BUTTONS_OK_CANCEL`](gtkmessagedialog#GTK-BUTTONS-OK-CANCEL:CAPS) are discouraged by the [GNOME Human Interface Guidelines](http://library.gnome.org/devel/hig-book/stable/).
>
>
#### Members
| | | |
| --- | --- | --- |
| GTK\_BUTTONS\_NONE | no buttons at all | |
| GTK\_BUTTONS\_OK | an OK button | |
| GTK\_BUTTONS\_CLOSE | a Close button | |
| GTK\_BUTTONS\_CANCEL | a Cancel button | |
| GTK\_BUTTONS\_YES\_NO | Yes and No buttons | |
| GTK\_BUTTONS\_OK\_CANCEL | OK and Cancel buttons | |
Property Details
----------------
### The `“buttons”` property
```
“buttons” [GtkButtonsType](gtkmessagedialog#GtkButtonsType)
```
The buttons shown in the message dialog.
Owner: GtkMessageDialog
Flags: Write / Construct Only
Default value: GTK\_BUTTONS\_NONE
### The `“message-area”` property
```
“message-area” [GtkWidget](gtkwidget#GtkWidget-struct) *
```
The [GtkBox](gtkbox#GtkBox-struct) that corresponds to the message area of this dialog. See [`gtk_message_dialog_get_message_area()`](gtkmessagedialog#gtk-message-dialog-get-message-area) for a detailed description of this area.
Owner: GtkMessageDialog
Flags: Read
### The `“message-type”` property
```
“message-type” [GtkMessageType](gtkmessagedialog#GtkMessageType)
```
The type of the message.
Owner: GtkMessageDialog
Flags: Read / Write / Construct
Default value: GTK\_MESSAGE\_INFO
### The `“secondary-text”` property
```
“secondary-text” char *
```
The secondary text of the message dialog.
Owner: GtkMessageDialog
Flags: Read / Write
Default value: NULL
### The `“secondary-use-markup”` property
```
“secondary-use-markup” gboolean
```
`TRUE` if the secondary text of the dialog includes Pango markup. See [`pango_parse_markup()`](https://developer-old.gnome.org/pango/stable/pango-Markup.html#pango-parse-markup).
Owner: GtkMessageDialog
Flags: Read / Write
Default value: FALSE
### The `“text”` property
```
“text” char *
```
The primary text of the message dialog. If the dialog has a secondary text, this will appear as the title.
Owner: GtkMessageDialog
Flags: Read / Write
Default value: ""
### The `“use-markup”` property
```
“use-markup” gboolean
```
`TRUE` if the primary text of the dialog includes Pango markup. See [`pango_parse_markup()`](https://developer-old.gnome.org/pango/stable/pango-Markup.html#pango-parse-markup).
Owner: GtkMessageDialog
Flags: Read / Write
Default value: FALSE
See Also
--------
[GtkDialog](gtkdialog#GtkDialog-struct)
gtk GtkTreeView GtkTreeView
===========
GtkTreeView — A widget for displaying both trees and lists
Functions
---------
| | |
| --- | --- |
| gboolean | ([\*GtkTreeViewColumnDropFunc](gtktreeview#GtkTreeViewColumnDropFunc)) () |
| void | ([\*GtkTreeViewMappingFunc](gtktreeview#GtkTreeViewMappingFunc)) () |
| gboolean | ([\*GtkTreeViewSearchEqualFunc](gtktreeview#GtkTreeViewSearchEqualFunc)) () |
| [GtkWidget](gtkwidget#GtkWidget-struct) \* | [gtk\_tree\_view\_new](gtktreeview#gtk-tree-view-new) () |
| int | [gtk\_tree\_view\_get\_level\_indentation](gtktreeview#gtk-tree-view-get-level-indentation) () |
| gboolean | [gtk\_tree\_view\_get\_show\_expanders](gtktreeview#gtk-tree-view-get-show-expanders) () |
| void | [gtk\_tree\_view\_set\_level\_indentation](gtktreeview#gtk-tree-view-set-level-indentation) () |
| void | [gtk\_tree\_view\_set\_show\_expanders](gtktreeview#gtk-tree-view-set-show-expanders) () |
| [GtkWidget](gtkwidget#GtkWidget-struct) \* | [gtk\_tree\_view\_new\_with\_model](gtktreeview#gtk-tree-view-new-with-model) () |
| [GtkTreeModel](gtktreemodel#GtkTreeModel-struct) \* | [gtk\_tree\_view\_get\_model](gtktreeview#gtk-tree-view-get-model) () |
| void | [gtk\_tree\_view\_set\_model](gtktreeview#gtk-tree-view-set-model) () |
| [GtkTreeSelection](gtktreeselection#GtkTreeSelection-struct) \* | [gtk\_tree\_view\_get\_selection](gtktreeview#gtk-tree-view-get-selection) () |
| gboolean | [gtk\_tree\_view\_get\_headers\_visible](gtktreeview#gtk-tree-view-get-headers-visible) () |
| void | [gtk\_tree\_view\_set\_headers\_visible](gtktreeview#gtk-tree-view-set-headers-visible) () |
| void | [gtk\_tree\_view\_columns\_autosize](gtktreeview#gtk-tree-view-columns-autosize) () |
| gboolean | [gtk\_tree\_view\_get\_headers\_clickable](gtktreeview#gtk-tree-view-get-headers-clickable) () |
| void | [gtk\_tree\_view\_set\_headers\_clickable](gtktreeview#gtk-tree-view-set-headers-clickable) () |
| void | [gtk\_tree\_view\_set\_activate\_on\_single\_click](gtktreeview#gtk-tree-view-set-activate-on-single-click) () |
| gboolean | [gtk\_tree\_view\_get\_activate\_on\_single\_click](gtktreeview#gtk-tree-view-get-activate-on-single-click) () |
| int | [gtk\_tree\_view\_append\_column](gtktreeview#gtk-tree-view-append-column) () |
| int | [gtk\_tree\_view\_remove\_column](gtktreeview#gtk-tree-view-remove-column) () |
| int | [gtk\_tree\_view\_insert\_column](gtktreeview#gtk-tree-view-insert-column) () |
| int | [gtk\_tree\_view\_insert\_column\_with\_attributes](gtktreeview#gtk-tree-view-insert-column-with-attributes) () |
| int | [gtk\_tree\_view\_insert\_column\_with\_data\_func](gtktreeview#gtk-tree-view-insert-column-with-data-func) () |
| guint | [gtk\_tree\_view\_get\_n\_columns](gtktreeview#gtk-tree-view-get-n-columns) () |
| [GtkTreeViewColumn](gtktreeviewcolumn#GtkTreeViewColumn-struct) \* | [gtk\_tree\_view\_get\_column](gtktreeview#gtk-tree-view-get-column) () |
| GList \* | [gtk\_tree\_view\_get\_columns](gtktreeview#gtk-tree-view-get-columns) () |
| void | [gtk\_tree\_view\_move\_column\_after](gtktreeview#gtk-tree-view-move-column-after) () |
| void | [gtk\_tree\_view\_set\_expander\_column](gtktreeview#gtk-tree-view-set-expander-column) () |
| [GtkTreeViewColumn](gtktreeviewcolumn#GtkTreeViewColumn-struct) \* | [gtk\_tree\_view\_get\_expander\_column](gtktreeview#gtk-tree-view-get-expander-column) () |
| void | [gtk\_tree\_view\_set\_column\_drag\_function](gtktreeview#gtk-tree-view-set-column-drag-function) () |
| void | [gtk\_tree\_view\_scroll\_to\_point](gtktreeview#gtk-tree-view-scroll-to-point) () |
| void | [gtk\_tree\_view\_scroll\_to\_cell](gtktreeview#gtk-tree-view-scroll-to-cell) () |
| void | [gtk\_tree\_view\_set\_cursor](gtktreeview#gtk-tree-view-set-cursor) () |
| void | [gtk\_tree\_view\_set\_cursor\_on\_cell](gtktreeview#gtk-tree-view-set-cursor-on-cell) () |
| void | [gtk\_tree\_view\_get\_cursor](gtktreeview#gtk-tree-view-get-cursor) () |
| void | [gtk\_tree\_view\_row\_activated](gtktreeview#gtk-tree-view-row-activated) () |
| void | [gtk\_tree\_view\_expand\_all](gtktreeview#gtk-tree-view-expand-all) () |
| void | [gtk\_tree\_view\_collapse\_all](gtktreeview#gtk-tree-view-collapse-all) () |
| void | [gtk\_tree\_view\_expand\_to\_path](gtktreeview#gtk-tree-view-expand-to-path) () |
| gboolean | [gtk\_tree\_view\_expand\_row](gtktreeview#gtk-tree-view-expand-row) () |
| gboolean | [gtk\_tree\_view\_collapse\_row](gtktreeview#gtk-tree-view-collapse-row) () |
| void | [gtk\_tree\_view\_map\_expanded\_rows](gtktreeview#gtk-tree-view-map-expanded-rows) () |
| gboolean | [gtk\_tree\_view\_row\_expanded](gtktreeview#gtk-tree-view-row-expanded) () |
| void | [gtk\_tree\_view\_set\_reorderable](gtktreeview#gtk-tree-view-set-reorderable) () |
| gboolean | [gtk\_tree\_view\_get\_reorderable](gtktreeview#gtk-tree-view-get-reorderable) () |
| gboolean | [gtk\_tree\_view\_get\_path\_at\_pos](gtktreeview#gtk-tree-view-get-path-at-pos) () |
| gboolean | [gtk\_tree\_view\_is\_blank\_at\_pos](gtktreeview#gtk-tree-view-is-blank-at-pos) () |
| void | [gtk\_tree\_view\_get\_cell\_area](gtktreeview#gtk-tree-view-get-cell-area) () |
| void | [gtk\_tree\_view\_get\_background\_area](gtktreeview#gtk-tree-view-get-background-area) () |
| void | [gtk\_tree\_view\_get\_visible\_rect](gtktreeview#gtk-tree-view-get-visible-rect) () |
| gboolean | [gtk\_tree\_view\_get\_visible\_range](gtktreeview#gtk-tree-view-get-visible-range) () |
| void | [gtk\_tree\_view\_convert\_bin\_window\_to\_tree\_coords](gtktreeview#gtk-tree-view-convert-bin-window-to-tree-coords) () |
| void | [gtk\_tree\_view\_convert\_bin\_window\_to\_widget\_coords](gtktreeview#gtk-tree-view-convert-bin-window-to-widget-coords) () |
| void | [gtk\_tree\_view\_convert\_tree\_to\_bin\_window\_coords](gtktreeview#gtk-tree-view-convert-tree-to-bin-window-coords) () |
| void | [gtk\_tree\_view\_convert\_tree\_to\_widget\_coords](gtktreeview#gtk-tree-view-convert-tree-to-widget-coords) () |
| void | [gtk\_tree\_view\_convert\_widget\_to\_bin\_window\_coords](gtktreeview#gtk-tree-view-convert-widget-to-bin-window-coords) () |
| void | [gtk\_tree\_view\_convert\_widget\_to\_tree\_coords](gtktreeview#gtk-tree-view-convert-widget-to-tree-coords) () |
| void | [gtk\_tree\_view\_enable\_model\_drag\_dest](gtktreeview#gtk-tree-view-enable-model-drag-dest) () |
| void | [gtk\_tree\_view\_enable\_model\_drag\_source](gtktreeview#gtk-tree-view-enable-model-drag-source) () |
| void | [gtk\_tree\_view\_unset\_rows\_drag\_source](gtktreeview#gtk-tree-view-unset-rows-drag-source) () |
| void | [gtk\_tree\_view\_unset\_rows\_drag\_dest](gtktreeview#gtk-tree-view-unset-rows-drag-dest) () |
| void | [gtk\_tree\_view\_set\_drag\_dest\_row](gtktreeview#gtk-tree-view-set-drag-dest-row) () |
| void | [gtk\_tree\_view\_get\_drag\_dest\_row](gtktreeview#gtk-tree-view-get-drag-dest-row) () |
| gboolean | [gtk\_tree\_view\_get\_dest\_row\_at\_pos](gtktreeview#gtk-tree-view-get-dest-row-at-pos) () |
| [GdkPaintable](https://developer-old.gnome.org/gtk4/html/GdkPaintable.html#GdkPaintable-struct) \* | [gtk\_tree\_view\_create\_row\_drag\_icon](gtktreeview#gtk-tree-view-create-row-drag-icon) () |
| void | [gtk\_tree\_view\_set\_enable\_search](gtktreeview#gtk-tree-view-set-enable-search) () |
| gboolean | [gtk\_tree\_view\_get\_enable\_search](gtktreeview#gtk-tree-view-get-enable-search) () |
| int | [gtk\_tree\_view\_get\_search\_column](gtktreeview#gtk-tree-view-get-search-column) () |
| void | [gtk\_tree\_view\_set\_search\_column](gtktreeview#gtk-tree-view-set-search-column) () |
| [GtkTreeViewSearchEqualFunc](gtktreeview#GtkTreeViewSearchEqualFunc) | [gtk\_tree\_view\_get\_search\_equal\_func](gtktreeview#gtk-tree-view-get-search-equal-func) () |
| void | [gtk\_tree\_view\_set\_search\_equal\_func](gtktreeview#gtk-tree-view-set-search-equal-func) () |
| [GtkEditable](gtkeditable#GtkEditable-struct) \* | [gtk\_tree\_view\_get\_search\_entry](gtktreeview#gtk-tree-view-get-search-entry) () |
| void | [gtk\_tree\_view\_set\_search\_entry](gtktreeview#gtk-tree-view-set-search-entry) () |
| gboolean | [gtk\_tree\_view\_get\_fixed\_height\_mode](gtktreeview#gtk-tree-view-get-fixed-height-mode) () |
| void | [gtk\_tree\_view\_set\_fixed\_height\_mode](gtktreeview#gtk-tree-view-set-fixed-height-mode) () |
| gboolean | [gtk\_tree\_view\_get\_hover\_selection](gtktreeview#gtk-tree-view-get-hover-selection) () |
| void | [gtk\_tree\_view\_set\_hover\_selection](gtktreeview#gtk-tree-view-set-hover-selection) () |
| gboolean | [gtk\_tree\_view\_get\_hover\_expand](gtktreeview#gtk-tree-view-get-hover-expand) () |
| void | [gtk\_tree\_view\_set\_hover\_expand](gtktreeview#gtk-tree-view-set-hover-expand) () |
| gboolean | ([\*GtkTreeViewRowSeparatorFunc](gtktreeview#GtkTreeViewRowSeparatorFunc)) () |
| [GtkTreeViewRowSeparatorFunc](gtktreeview#GtkTreeViewRowSeparatorFunc) | [gtk\_tree\_view\_get\_row\_separator\_func](gtktreeview#gtk-tree-view-get-row-separator-func) () |
| void | [gtk\_tree\_view\_set\_row\_separator\_func](gtktreeview#gtk-tree-view-set-row-separator-func) () |
| gboolean | [gtk\_tree\_view\_get\_rubber\_banding](gtktreeview#gtk-tree-view-get-rubber-banding) () |
| void | [gtk\_tree\_view\_set\_rubber\_banding](gtktreeview#gtk-tree-view-set-rubber-banding) () |
| gboolean | [gtk\_tree\_view\_is\_rubber\_banding\_active](gtktreeview#gtk-tree-view-is-rubber-banding-active) () |
| gboolean | [gtk\_tree\_view\_get\_enable\_tree\_lines](gtktreeview#gtk-tree-view-get-enable-tree-lines) () |
| void | [gtk\_tree\_view\_set\_enable\_tree\_lines](gtktreeview#gtk-tree-view-set-enable-tree-lines) () |
| [GtkTreeViewGridLines](gtktreeview#GtkTreeViewGridLines) | [gtk\_tree\_view\_get\_grid\_lines](gtktreeview#gtk-tree-view-get-grid-lines) () |
| void | [gtk\_tree\_view\_set\_grid\_lines](gtktreeview#gtk-tree-view-set-grid-lines) () |
| void | [gtk\_tree\_view\_set\_tooltip\_row](gtktreeview#gtk-tree-view-set-tooltip-row) () |
| void | [gtk\_tree\_view\_set\_tooltip\_cell](gtktreeview#gtk-tree-view-set-tooltip-cell) () |
| gboolean | [gtk\_tree\_view\_get\_tooltip\_context](gtktreeview#gtk-tree-view-get-tooltip-context) () |
| int | [gtk\_tree\_view\_get\_tooltip\_column](gtktreeview#gtk-tree-view-get-tooltip-column) () |
| void | [gtk\_tree\_view\_set\_tooltip\_column](gtktreeview#gtk-tree-view-set-tooltip-column) () |
Properties
----------
| | | |
| --- | --- | --- |
| gboolean | [activate-on-single-click](gtktreeview#GtkTreeView--activate-on-single-click) | Read / Write |
| [GtkTreeViewGridLines](gtktreeview#GtkTreeViewGridLines) | [enable-grid-lines](gtktreeview#GtkTreeView--enable-grid-lines) | Read / Write |
| gboolean | [enable-search](gtktreeview#GtkTreeView--enable-search) | Read / Write |
| gboolean | [enable-tree-lines](gtktreeview#GtkTreeView--enable-tree-lines) | Read / Write |
| [GtkTreeViewColumn](gtktreeviewcolumn#GtkTreeViewColumn-struct) \* | [expander-column](gtktreeview#GtkTreeView--expander-column) | Read / Write |
| gboolean | [fixed-height-mode](gtktreeview#GtkTreeView--fixed-height-mode) | Read / Write |
| gboolean | [headers-clickable](gtktreeview#GtkTreeView--headers-clickable) | Read / Write |
| gboolean | [headers-visible](gtktreeview#GtkTreeView--headers-visible) | Read / Write |
| gboolean | [hover-expand](gtktreeview#GtkTreeView--hover-expand) | Read / Write |
| gboolean | [hover-selection](gtktreeview#GtkTreeView--hover-selection) | Read / Write |
| int | [level-indentation](gtktreeview#GtkTreeView--level-indentation) | Read / Write |
| [GtkTreeModel](gtktreemodel#GtkTreeModel-struct) \* | [model](gtktreeview#GtkTreeView--model) | Read / Write |
| gboolean | [reorderable](gtktreeview#GtkTreeView--reorderable) | Read / Write |
| gboolean | [rubber-banding](gtktreeview#GtkTreeView--rubber-banding) | Read / Write |
| int | [search-column](gtktreeview#GtkTreeView--search-column) | Read / Write |
| gboolean | [show-expanders](gtktreeview#GtkTreeView--show-expanders) | Read / Write |
| int | [tooltip-column](gtktreeview#GtkTreeView--tooltip-column) | Read / Write |
Signals
-------
| | | |
| --- | --- | --- |
| void | [columns-changed](gtktreeview#GtkTreeView-columns-changed) | Run Last |
| void | [cursor-changed](gtktreeview#GtkTreeView-cursor-changed) | Run Last |
| gboolean | [expand-collapse-cursor-row](gtktreeview#GtkTreeView-expand-collapse-cursor-row) | Action |
| gboolean | [move-cursor](gtktreeview#GtkTreeView-move-cursor) | Action |
| void | [row-activated](gtktreeview#GtkTreeView-row-activated) | Action |
| void | [row-collapsed](gtktreeview#GtkTreeView-row-collapsed) | Run Last |
| void | [row-expanded](gtktreeview#GtkTreeView-row-expanded) | Run Last |
| gboolean | [select-all](gtktreeview#GtkTreeView-select-all) | Action |
| gboolean | [select-cursor-parent](gtktreeview#GtkTreeView-select-cursor-parent) | Action |
| gboolean | [select-cursor-row](gtktreeview#GtkTreeView-select-cursor-row) | Action |
| gboolean | [start-interactive-search](gtktreeview#GtkTreeView-start-interactive-search) | Action |
| gboolean | [test-collapse-row](gtktreeview#GtkTreeView-test-collapse-row) | Run Last |
| gboolean | [test-expand-row](gtktreeview#GtkTreeView-test-expand-row) | Run Last |
| gboolean | [toggle-cursor-row](gtktreeview#GtkTreeView-toggle-cursor-row) | Action |
| gboolean | [unselect-all](gtktreeview#GtkTreeView-unselect-all) | Action |
Types and Values
----------------
| | |
| --- | --- |
| struct | [GtkTreeView](gtktreeview#GtkTreeView-struct) |
| enum | [GtkTreeViewDropPosition](gtktreeview#GtkTreeViewDropPosition) |
| enum | [GtkTreeViewGridLines](gtktreeview#GtkTreeViewGridLines) |
Object Hierarchy
----------------
```
GObject
╰── GInitiallyUnowned
╰── [GtkWidget](gtkwidget#GtkWidget-struct)
╰── GtkTreeView
```
Implemented Interfaces
----------------------
GtkTreeView implements [GtkAccessible](gtkaccessible#GtkAccessible-struct), [GtkBuildable](gtkbuildable#GtkBuildable-struct), [GtkConstraintTarget](gtkconstraint#GtkConstraintTarget-struct) and [GtkScrollable](gtkscrollable#GtkScrollable-struct).
Includes
--------
```
#include <gtk/gtk.h>
```
Description
-----------
Widget that displays any object that implements the [GtkTreeModel](gtktreemodel#GtkTreeModel-struct) interface.
Please refer to the [tree widget conceptual overview](treewidgetobjects#TreeWidget) for an overview of all the objects and data types related to the tree widget and how they work together.
Several different coordinate systems are exposed in the GtkTreeView API. These are:
Coordinate systems in GtkTreeView API:
* Widget coordinates: Coordinates relative to the widget (usually `widget->window`).
* Bin window coordinates: Coordinates relative to the window that GtkTreeView renders to.
* Tree coordinates: Coordinates relative to the entire scrollable area of GtkTreeView. These coordinates start at (0, 0) for row 0 of the tree.
Several functions are available for converting between the different coordinate systems. The most common translations are between widget and bin window coordinates and between bin window and tree coordinates. For the former you can use [`gtk_tree_view_convert_widget_to_bin_window_coords()`](gtktreeview#gtk-tree-view-convert-widget-to-bin-window-coords) (and vice versa), for the latter [`gtk_tree_view_convert_bin_window_to_tree_coords()`](gtktreeview#gtk-tree-view-convert-bin-window-to-tree-coords) (and vice versa).
### GtkTreeView as GtkBuildable
The GtkTreeView implementation of the GtkBuildable interface accepts [GtkTreeViewColumn](gtktreeviewcolumn#GtkTreeViewColumn-struct) objects as <child> elements and exposes the internal [GtkTreeSelection](gtktreeselection#GtkTreeSelection-struct) in UI definitions.
An example of a UI definition fragment with GtkTreeView:
### CSS nodes
```
<object class="GtkTreeView" id="treeview">
<property name="model">liststore1</property>
<child>
<object class="GtkTreeViewColumn" id="test-column">
<property name="title">Test</property>
<child>
<object class="GtkCellRendererText" id="test-renderer"/>
<attributes>
<attribute name="text">1</attribute>
</attributes>
</child>
</object>
</child>
<child internal-child="selection">
<object class="GtkTreeSelection" id="selection">
<signal name="changed" handler="on_treeview_selection_changed"/>
</object>
</child>
</object>
```
| GtkTreeView has a main CSS node with name treeview and style class .view. It has a subnode with name header, which is the parent for all the column header widgets' CSS nodes.
For rubberband selection, a subnode with name rubberband is used.
For the drop target location during DND, a subnode with name dndtarget is used.
Functions
---------
### GtkTreeViewColumnDropFunc ()
```
gboolean
(*GtkTreeViewColumnDropFunc) (*`[GtkTreeView](gtktreeview#GtkTreeView-struct) *tree_view`*,
*`[GtkTreeViewColumn](gtktreeviewcolumn#GtkTreeViewColumn-struct) *column`*,
*`[GtkTreeViewColumn](gtktreeviewcolumn#GtkTreeViewColumn-struct) *prev_column`*,
*`[GtkTreeViewColumn](gtktreeviewcolumn#GtkTreeViewColumn-struct) *next_column`*,
*`gpointer data`*);
```
Function type for determining whether *`column`* can be dropped in a particular spot (as determined by *`prev_column`* and *`next_column`* ). In left to right locales, *`prev_column`* is on the left of the potential drop spot, and *`next_column`* is on the right. In right to left mode, this is reversed. This function should return `TRUE` if the spot is a valid drop spot. Please note that returning `TRUE` does not actually indicate that the column drop was made, but is meant only to indicate a possible drop spot to the user.
#### Parameters
| | | |
| --- | --- | --- |
| tree\_view | A [GtkTreeView](gtktreeview#GtkTreeView-struct) | |
| column | The [GtkTreeViewColumn](gtktreeviewcolumn#GtkTreeViewColumn-struct) being dragged | |
| prev\_column | A [GtkTreeViewColumn](gtktreeviewcolumn#GtkTreeViewColumn-struct) on one side of *`column`* | |
| next\_column | A [GtkTreeViewColumn](gtktreeviewcolumn#GtkTreeViewColumn-struct) on the other side of *`column`* | |
| data | user data. | [closure] |
#### Returns
`TRUE`, if *`column`* can be dropped in this spot
### GtkTreeViewMappingFunc ()
```
void
(*GtkTreeViewMappingFunc) (*`[GtkTreeView](gtktreeview#GtkTreeView-struct) *tree_view`*,
*`[GtkTreePath](gtktreemodel#GtkTreePath-struct) *path`*,
*`gpointer user_data`*);
```
Function used for [`gtk_tree_view_map_expanded_rows()`](gtktreeview#gtk-tree-view-map-expanded-rows).
#### Parameters
| | | |
| --- | --- | --- |
| tree\_view | A [GtkTreeView](gtktreeview#GtkTreeView-struct) | |
| path | The path that’s expanded | |
| user\_data | user data | |
### GtkTreeViewSearchEqualFunc ()
```
gboolean
(*GtkTreeViewSearchEqualFunc) (*`[GtkTreeModel](gtktreemodel#GtkTreeModel-struct) *model`*,
*`int column`*,
*`const char *key`*,
*`[GtkTreeIter](gtktreemodel#GtkTreeIter-struct) *iter`*,
*`gpointer search_data`*);
```
A function used for checking whether a row in *`model`* matches a search key string entered by the user. Note the return value is reversed from what you would normally expect, though it has some similarity to `strcmp()` returning 0 for equal strings.
#### Parameters
| | | |
| --- | --- | --- |
| model | the [GtkTreeModel](gtktreemodel#GtkTreeModel-struct) being searched | |
| column | the search column set by [`gtk_tree_view_set_search_column()`](gtktreeview#gtk-tree-view-set-search-column) | |
| key | the key string to compare with | |
| iter | a [GtkTreeIter](gtktreemodel#GtkTreeIter-struct) pointing the row of *`model`* that should be compared with *`key`* . | |
| search\_data | user data from [`gtk_tree_view_set_search_equal_func()`](gtktreeview#gtk-tree-view-set-search-equal-func). | [closure] |
#### Returns
`FALSE` if the row matches, `TRUE` otherwise.
### gtk\_tree\_view\_new ()
```
[GtkWidget](gtkwidget#GtkWidget-struct) *
gtk_tree_view_new (*`void`*);
```
Creates a new [GtkTreeView](gtktreeview#GtkTreeView-struct) widget.
#### Returns
A newly created [GtkTreeView](gtktreeview#GtkTreeView-struct) widget.
### gtk\_tree\_view\_get\_level\_indentation ()
```
int
gtk_tree_view_get_level_indentation (*`[GtkTreeView](gtktreeview#GtkTreeView-struct) *tree_view`*);
```
Returns the amount, in pixels, of extra indentation for child levels in *`tree_view`* .
#### Parameters
| | | |
| --- | --- | --- |
| tree\_view | a [GtkTreeView](gtktreeview#GtkTreeView-struct). | |
#### Returns
the amount of extra indentation for child levels in *`tree_view`* . A return value of 0 means that this feature is disabled.
### gtk\_tree\_view\_get\_show\_expanders ()
```
gboolean
gtk_tree_view_get_show_expanders (*`[GtkTreeView](gtktreeview#GtkTreeView-struct) *tree_view`*);
```
Returns whether or not expanders are drawn in *`tree_view`* .
#### Parameters
| | | |
| --- | --- | --- |
| tree\_view | a [GtkTreeView](gtktreeview#GtkTreeView-struct). | |
#### Returns
`TRUE` if expanders are drawn in *`tree_view`* , `FALSE` otherwise.
### gtk\_tree\_view\_set\_level\_indentation ()
```
void
gtk_tree_view_set_level_indentation (*`[GtkTreeView](gtktreeview#GtkTreeView-struct) *tree_view`*,
*`int indentation`*);
```
Sets the amount of extra indentation for child levels to use in *`tree_view`* in addition to the default indentation. The value should be specified in pixels, a value of 0 disables this feature and in this case only the default indentation will be used. This does not have any visible effects for lists.
#### Parameters
| | | |
| --- | --- | --- |
| tree\_view | a [GtkTreeView](gtktreeview#GtkTreeView-struct) | |
| indentation | the amount, in pixels, of extra indentation in *`tree_view`* . | |
### gtk\_tree\_view\_set\_show\_expanders ()
```
void
gtk_tree_view_set_show_expanders (*`[GtkTreeView](gtktreeview#GtkTreeView-struct) *tree_view`*,
*`gboolean enabled`*);
```
Sets whether to draw and enable expanders and indent child rows in *`tree_view`* . When disabled there will be no expanders visible in trees and there will be no way to expand and collapse rows by default. Also note that hiding the expanders will disable the default indentation. You can set a custom indentation in this case using [`gtk_tree_view_set_level_indentation()`](gtktreeview#gtk-tree-view-set-level-indentation). This does not have any visible effects for lists.
#### Parameters
| | | |
| --- | --- | --- |
| tree\_view | a [GtkTreeView](gtktreeview#GtkTreeView-struct) | |
| enabled | `TRUE` to enable expander drawing, `FALSE` otherwise. | |
### gtk\_tree\_view\_new\_with\_model ()
```
[GtkWidget](gtkwidget#GtkWidget-struct) *
gtk_tree_view_new_with_model (*`[GtkTreeModel](gtktreemodel#GtkTreeModel-struct) *model`*);
```
Creates a new [GtkTreeView](gtktreeview#GtkTreeView-struct) widget with the model initialized to *`model`* .
#### Parameters
| | | |
| --- | --- | --- |
| model | the model. | |
#### Returns
A newly created [GtkTreeView](gtktreeview#GtkTreeView-struct) widget.
### gtk\_tree\_view\_get\_model ()
```
[GtkTreeModel](gtktreemodel#GtkTreeModel-struct) *
gtk_tree_view_get_model (*`[GtkTreeView](gtktreeview#GtkTreeView-struct) *tree_view`*);
```
Returns the model the [GtkTreeView](gtktreeview#GtkTreeView-struct) is based on. Returns `NULL` if the model is unset.
#### Parameters
| | | |
| --- | --- | --- |
| tree\_view | a [GtkTreeView](gtktreeview#GtkTreeView-struct) | |
#### Returns
A [GtkTreeModel](gtktreemodel#GtkTreeModel-struct), or `NULL` if none is currently being used.
[transfer none][nullable]
### gtk\_tree\_view\_set\_model ()
```
void
gtk_tree_view_set_model (*`[GtkTreeView](gtktreeview#GtkTreeView-struct) *tree_view`*,
*`[GtkTreeModel](gtktreemodel#GtkTreeModel-struct) *model`*);
```
Sets the model for a [GtkTreeView](gtktreeview#GtkTreeView-struct). If the *`tree_view`* already has a model set, it will remove it before setting the new model. If *`model`* is `NULL`, then it will unset the old model.
#### Parameters
| | | |
| --- | --- | --- |
| tree\_view | A [GtkTreeView](gtktreeview#GtkTreeView-struct). | |
| model | The model. | [allow-none] |
### gtk\_tree\_view\_get\_selection ()
```
[GtkTreeSelection](gtktreeselection#GtkTreeSelection-struct) *
gtk_tree_view_get_selection (*`[GtkTreeView](gtktreeview#GtkTreeView-struct) *tree_view`*);
```
Gets the [GtkTreeSelection](gtktreeselection#GtkTreeSelection-struct) associated with *`tree_view`* .
#### Parameters
| | | |
| --- | --- | --- |
| tree\_view | A [GtkTreeView](gtktreeview#GtkTreeView-struct). | |
#### Returns
A [GtkTreeSelection](gtktreeselection#GtkTreeSelection-struct) object.
[transfer none]
### gtk\_tree\_view\_get\_headers\_visible ()
```
gboolean
gtk_tree_view_get_headers_visible (*`[GtkTreeView](gtktreeview#GtkTreeView-struct) *tree_view`*);
```
Returns `TRUE` if the headers on the *`tree_view`* are visible.
#### Parameters
| | | |
| --- | --- | --- |
| tree\_view | A [GtkTreeView](gtktreeview#GtkTreeView-struct). | |
#### Returns
Whether the headers are visible or not.
### gtk\_tree\_view\_set\_headers\_visible ()
```
void
gtk_tree_view_set_headers_visible (*`[GtkTreeView](gtktreeview#GtkTreeView-struct) *tree_view`*,
*`gboolean headers_visible`*);
```
Sets the visibility state of the headers.
#### Parameters
| | | |
| --- | --- | --- |
| tree\_view | A [GtkTreeView](gtktreeview#GtkTreeView-struct). | |
| headers\_visible | `TRUE` if the headers are visible | |
### gtk\_tree\_view\_columns\_autosize ()
```
void
gtk_tree_view_columns_autosize (*`[GtkTreeView](gtktreeview#GtkTreeView-struct) *tree_view`*);
```
Resizes all columns to their optimal width. Only works after the treeview has been realized.
#### Parameters
| | | |
| --- | --- | --- |
| tree\_view | A [GtkTreeView](gtktreeview#GtkTreeView-struct). | |
### gtk\_tree\_view\_get\_headers\_clickable ()
```
gboolean
gtk_tree_view_get_headers_clickable (*`[GtkTreeView](gtktreeview#GtkTreeView-struct) *tree_view`*);
```
Returns whether all header columns are clickable.
#### Parameters
| | | |
| --- | --- | --- |
| tree\_view | A [GtkTreeView](gtktreeview#GtkTreeView-struct). | |
#### Returns
`TRUE` if all header columns are clickable, otherwise `FALSE`
### gtk\_tree\_view\_set\_headers\_clickable ()
```
void
gtk_tree_view_set_headers_clickable (*`[GtkTreeView](gtktreeview#GtkTreeView-struct) *tree_view`*,
*`gboolean setting`*);
```
Allow the column title buttons to be clicked.
#### Parameters
| | | |
| --- | --- | --- |
| tree\_view | A [GtkTreeView](gtktreeview#GtkTreeView-struct). | |
| setting | `TRUE` if the columns are clickable. | |
### gtk\_tree\_view\_set\_activate\_on\_single\_click ()
```
void
gtk_tree_view_set_activate_on_single_click
(*`[GtkTreeView](gtktreeview#GtkTreeView-struct) *tree_view`*,
*`gboolean single`*);
```
Cause the [“row-activated”](gtktreeview#GtkTreeView-row-activated) signal to be emitted on a single click instead of a double click.
#### Parameters
| | | |
| --- | --- | --- |
| tree\_view | a [GtkTreeView](gtktreeview#GtkTreeView-struct) | |
| single | `TRUE` to emit row-activated on a single click | |
### gtk\_tree\_view\_get\_activate\_on\_single\_click ()
```
gboolean
gtk_tree_view_get_activate_on_single_click
(*`[GtkTreeView](gtktreeview#GtkTreeView-struct) *tree_view`*);
```
Gets the setting set by [`gtk_tree_view_set_activate_on_single_click()`](gtktreeview#gtk-tree-view-set-activate-on-single-click).
#### Parameters
| | | |
| --- | --- | --- |
| tree\_view | a [GtkTreeView](gtktreeview#GtkTreeView-struct) | |
#### Returns
`TRUE` if row-activated will be emitted on a single click
### gtk\_tree\_view\_append\_column ()
```
int
gtk_tree_view_append_column (*`[GtkTreeView](gtktreeview#GtkTreeView-struct) *tree_view`*,
*`[GtkTreeViewColumn](gtktreeviewcolumn#GtkTreeViewColumn-struct) *column`*);
```
Appends *`column`* to the list of columns. If *`tree_view`* has “fixed\_height” mode enabled, then *`column`* must have its “sizing” property set to be GTK\_TREE\_VIEW\_COLUMN\_FIXED.
#### Parameters
| | | |
| --- | --- | --- |
| tree\_view | A [GtkTreeView](gtktreeview#GtkTreeView-struct). | |
| column | The [GtkTreeViewColumn](gtktreeviewcolumn#GtkTreeViewColumn-struct) to add. | |
#### Returns
The number of columns in *`tree_view`* after appending.
### gtk\_tree\_view\_remove\_column ()
```
int
gtk_tree_view_remove_column (*`[GtkTreeView](gtktreeview#GtkTreeView-struct) *tree_view`*,
*`[GtkTreeViewColumn](gtktreeviewcolumn#GtkTreeViewColumn-struct) *column`*);
```
Removes *`column`* from *`tree_view`* .
#### Parameters
| | | |
| --- | --- | --- |
| tree\_view | A [GtkTreeView](gtktreeview#GtkTreeView-struct). | |
| column | The [GtkTreeViewColumn](gtktreeviewcolumn#GtkTreeViewColumn-struct) to remove. | |
#### Returns
The number of columns in *`tree_view`* after removing.
### gtk\_tree\_view\_insert\_column ()
```
int
gtk_tree_view_insert_column (*`[GtkTreeView](gtktreeview#GtkTreeView-struct) *tree_view`*,
*`[GtkTreeViewColumn](gtktreeviewcolumn#GtkTreeViewColumn-struct) *column`*,
*`int position`*);
```
This inserts the *`column`* into the *`tree_view`* at *`position`* . If *`position`* is -1, then the column is inserted at the end. If *`tree_view`* has “fixed\_height” mode enabled, then *`column`* must have its “sizing” property set to be GTK\_TREE\_VIEW\_COLUMN\_FIXED.
#### Parameters
| | | |
| --- | --- | --- |
| tree\_view | A [GtkTreeView](gtktreeview#GtkTreeView-struct). | |
| column | The [GtkTreeViewColumn](gtktreeviewcolumn#GtkTreeViewColumn-struct) to be inserted. | |
| position | The position to insert *`column`* in. | |
#### Returns
The number of columns in *`tree_view`* after insertion.
### gtk\_tree\_view\_insert\_column\_with\_attributes ()
```
int
gtk_tree_view_insert_column_with_attributes
(*`[GtkTreeView](gtktreeview#GtkTreeView-struct) *tree_view`*,
*`int position`*,
*`const char *title`*,
*`[GtkCellRenderer](gtkcellrenderer#GtkCellRenderer-struct) *cell`*,
*`...`*);
```
Creates a new [GtkTreeViewColumn](gtktreeviewcolumn#GtkTreeViewColumn-struct) and inserts it into the *`tree_view`* at *`position`* . If *`position`* is -1, then the newly created column is inserted at the end. The column is initialized with the attributes given. If *`tree_view`* has “fixed\_height” mode enabled, then the new column will have its sizing property set to be GTK\_TREE\_VIEW\_COLUMN\_FIXED.
#### Parameters
| | | |
| --- | --- | --- |
| tree\_view | A [GtkTreeView](gtktreeview#GtkTreeView-struct) | |
| position | The position to insert the new column in | |
| title | The title to set the header to | |
| cell | The [GtkCellRenderer](gtkcellrenderer#GtkCellRenderer-struct) | |
| ... | A `NULL`-terminated list of attributes | |
#### Returns
The number of columns in *`tree_view`* after insertion.
### gtk\_tree\_view\_insert\_column\_with\_data\_func ()
```
int
gtk_tree_view_insert_column_with_data_func
(*`[GtkTreeView](gtktreeview#GtkTreeView-struct) *tree_view`*,
*`int position`*,
*`const char *title`*,
*`[GtkCellRenderer](gtkcellrenderer#GtkCellRenderer-struct) *cell`*,
*`[GtkTreeCellDataFunc](gtktreeviewcolumn#GtkTreeCellDataFunc) func`*,
*`gpointer data`*,
*`GDestroyNotify dnotify`*);
```
Convenience function that inserts a new column into the [GtkTreeView](gtktreeview#GtkTreeView-struct) with the given cell renderer and a [GtkTreeCellDataFunc](gtktreeviewcolumn#GtkTreeCellDataFunc) to set cell renderer attributes (normally using data from the model). See also [`gtk_tree_view_column_set_cell_data_func()`](gtktreeviewcolumn#gtk-tree-view-column-set-cell-data-func), [`gtk_tree_view_column_pack_start()`](gtktreeviewcolumn#gtk-tree-view-column-pack-start). If *`tree_view`* has “fixed\_height” mode enabled, then the new column will have its “sizing” property set to be GTK\_TREE\_VIEW\_COLUMN\_FIXED.
#### Parameters
| | | |
| --- | --- | --- |
| tree\_view | a [GtkTreeView](gtktreeview#GtkTreeView-struct) | |
| position | Position to insert, -1 for append | |
| title | column title | |
| cell | cell renderer for column | |
| func | function to set attributes of cell renderer | |
| data | data for *`func`* | |
| dnotify | destroy notifier for *`data`* | |
#### Returns
number of columns in the tree view post-insert
### gtk\_tree\_view\_get\_n\_columns ()
```
guint
gtk_tree_view_get_n_columns (*`[GtkTreeView](gtktreeview#GtkTreeView-struct) *tree_view`*);
```
Queries the number of columns in the given *`tree_view`* .
#### Parameters
| | | |
| --- | --- | --- |
| tree\_view | a [GtkTreeView](gtktreeview#GtkTreeView-struct) | |
#### Returns
The number of columns in the *`tree_view`*
### gtk\_tree\_view\_get\_column ()
```
[GtkTreeViewColumn](gtktreeviewcolumn#GtkTreeViewColumn-struct) *
gtk_tree_view_get_column (*`[GtkTreeView](gtktreeview#GtkTreeView-struct) *tree_view`*,
*`int n`*);
```
Gets the [GtkTreeViewColumn](gtktreeviewcolumn#GtkTreeViewColumn-struct) at the given position in the tree\_view.
#### Parameters
| | | |
| --- | --- | --- |
| tree\_view | A [GtkTreeView](gtktreeview#GtkTreeView-struct). | |
| n | The position of the column, counting from 0. | |
#### Returns
The [GtkTreeViewColumn](gtktreeviewcolumn#GtkTreeViewColumn-struct), or `NULL` if the position is outside the range of columns.
[nullable][transfer none]
### gtk\_tree\_view\_get\_columns ()
```
GList *
gtk_tree_view_get_columns (*`[GtkTreeView](gtktreeview#GtkTreeView-struct) *tree_view`*);
```
Returns a GList of all the [GtkTreeViewColumn](gtktreeviewcolumn#GtkTreeViewColumn-struct) s currently in *`tree_view`* . The returned list must be freed with `g_list_free()`.
#### Parameters
| | | |
| --- | --- | --- |
| tree\_view | A [GtkTreeView](gtktreeview#GtkTreeView-struct) | |
#### Returns
A list of [GtkTreeViewColumn](gtktreeviewcolumn#GtkTreeViewColumn-struct) s.
[element-type GtkTreeViewColumn][transfer container]
### gtk\_tree\_view\_move\_column\_after ()
```
void
gtk_tree_view_move_column_after (*`[GtkTreeView](gtktreeview#GtkTreeView-struct) *tree_view`*,
*`[GtkTreeViewColumn](gtktreeviewcolumn#GtkTreeViewColumn-struct) *column`*,
*`[GtkTreeViewColumn](gtktreeviewcolumn#GtkTreeViewColumn-struct) *base_column`*);
```
Moves *`column`* to be after to *`base_column`* . If *`base_column`* is `NULL`, then *`column`* is placed in the first position.
#### Parameters
| | | |
| --- | --- | --- |
| tree\_view | A [GtkTreeView](gtktreeview#GtkTreeView-struct) | |
| column | The [GtkTreeViewColumn](gtktreeviewcolumn#GtkTreeViewColumn-struct) to be moved. | |
| base\_column | The [GtkTreeViewColumn](gtktreeviewcolumn#GtkTreeViewColumn-struct) to be moved relative to, or `NULL`. | [allow-none] |
### gtk\_tree\_view\_set\_expander\_column ()
```
void
gtk_tree_view_set_expander_column (*`[GtkTreeView](gtktreeview#GtkTreeView-struct) *tree_view`*,
*`[GtkTreeViewColumn](gtktreeviewcolumn#GtkTreeViewColumn-struct) *column`*);
```
Sets the column to draw the expander arrow at. It must be in *`tree_view`* . If *`column`* is `NULL`, then the expander arrow is always at the first visible column.
If you do not want expander arrow to appear in your tree, set the expander column to a hidden column.
#### Parameters
| | | |
| --- | --- | --- |
| tree\_view | A [GtkTreeView](gtktreeview#GtkTreeView-struct) | |
| column | `NULL`, or the column to draw the expander arrow at. | [nullable] |
### gtk\_tree\_view\_get\_expander\_column ()
```
[GtkTreeViewColumn](gtktreeviewcolumn#GtkTreeViewColumn-struct) *
gtk_tree_view_get_expander_column (*`[GtkTreeView](gtktreeview#GtkTreeView-struct) *tree_view`*);
```
Returns the column that is the current expander column, or `NULL` if none has been set. This column has the expander arrow drawn next to it.
#### Parameters
| | | |
| --- | --- | --- |
| tree\_view | A [GtkTreeView](gtktreeview#GtkTreeView-struct) | |
#### Returns
The expander column.
[transfer none][nullable]
### gtk\_tree\_view\_set\_column\_drag\_function ()
```
void
gtk_tree_view_set_column_drag_function
(*`[GtkTreeView](gtktreeview#GtkTreeView-struct) *tree_view`*,
*`[GtkTreeViewColumnDropFunc](gtktreeview#GtkTreeViewColumnDropFunc) func`*,
*`gpointer user_data`*,
*`GDestroyNotify destroy`*);
```
Sets a user function for determining where a column may be dropped when dragged. This function is called on every column pair in turn at the beginning of a column drag to determine where a drop can take place. The arguments passed to *`func`* are: the *`tree_view`* , the [GtkTreeViewColumn](gtktreeviewcolumn#GtkTreeViewColumn-struct) being dragged, the two [GtkTreeViewColumn](gtktreeviewcolumn#GtkTreeViewColumn-struct) s determining the drop spot, and *`user_data`* . If either of the [GtkTreeViewColumn](gtktreeviewcolumn#GtkTreeViewColumn-struct) arguments for the drop spot are `NULL`, then they indicate an edge. If *`func`* is set to be `NULL`, then *`tree_view`* reverts to the default behavior of allowing all columns to be dropped everywhere.
#### Parameters
| | | |
| --- | --- | --- |
| tree\_view | A [GtkTreeView](gtktreeview#GtkTreeView-struct). | |
| func | A function to determine which columns are reorderable, or `NULL`. | [allow-none] |
| user\_data | User data to be passed to *`func`* , or `NULL`. | [closure] |
| destroy | Destroy notifier for *`user_data`* , or `NULL`. | [allow-none] |
### gtk\_tree\_view\_scroll\_to\_point ()
```
void
gtk_tree_view_scroll_to_point (*`[GtkTreeView](gtktreeview#GtkTreeView-struct) *tree_view`*,
*`int tree_x`*,
*`int tree_y`*);
```
Scrolls the tree view such that the top-left corner of the visible area is *`tree_x`* , *`tree_y`* , where *`tree_x`* and *`tree_y`* are specified in tree coordinates. The *`tree_view`* must be realized before this function is called. If it isn't, you probably want to be using [`gtk_tree_view_scroll_to_cell()`](gtktreeview#gtk-tree-view-scroll-to-cell).
If either *`tree_x`* or *`tree_y`* are -1, then that direction isn’t scrolled.
#### Parameters
| | | |
| --- | --- | --- |
| tree\_view | a [GtkTreeView](gtktreeview#GtkTreeView-struct) | |
| tree\_x | X coordinate of new top-left pixel of visible area, or -1 | |
| tree\_y | Y coordinate of new top-left pixel of visible area, or -1 | |
### gtk\_tree\_view\_scroll\_to\_cell ()
```
void
gtk_tree_view_scroll_to_cell (*`[GtkTreeView](gtktreeview#GtkTreeView-struct) *tree_view`*,
*`[GtkTreePath](gtktreemodel#GtkTreePath-struct) *path`*,
*`[GtkTreeViewColumn](gtktreeviewcolumn#GtkTreeViewColumn-struct) *column`*,
*`gboolean use_align`*,
*`float row_align`*,
*`float col_align`*);
```
Moves the alignments of *`tree_view`* to the position specified by *`column`* and *`path`* . If *`column`* is `NULL`, then no horizontal scrolling occurs. Likewise, if *`path`* is `NULL` no vertical scrolling occurs. At a minimum, one of *`column`* or *`path`* need to be non-`NULL`. *`row_align`* determines where the row is placed, and *`col_align`* determines where *`column`* is placed. Both are expected to be between 0.0 and 1.0. 0.0 means left/top alignment, 1.0 means right/bottom alignment, 0.5 means center.
If *`use_align`* is `FALSE`, then the alignment arguments are ignored, and the tree does the minimum amount of work to scroll the cell onto the screen. This means that the cell will be scrolled to the edge closest to its current position. If the cell is currently visible on the screen, nothing is done.
This function only works if the model is set, and *`path`* is a valid row on the model. If the model changes before the *`tree_view`* is realized, the centered path will be modified to reflect this change.
#### Parameters
| | | |
| --- | --- | --- |
| tree\_view | A [GtkTreeView](gtktreeview#GtkTreeView-struct). | |
| path | The path of the row to move to, or `NULL`. | [allow-none] |
| column | The [GtkTreeViewColumn](gtktreeviewcolumn#GtkTreeViewColumn-struct) to move horizontally to, or `NULL`. | [allow-none] |
| use\_align | whether to use alignment arguments, or `FALSE`. | |
| row\_align | The vertical alignment of the row specified by *`path`* . | |
| col\_align | The horizontal alignment of the column specified by *`column`* . | |
### gtk\_tree\_view\_set\_cursor ()
```
void
gtk_tree_view_set_cursor (*`[GtkTreeView](gtktreeview#GtkTreeView-struct) *tree_view`*,
*`[GtkTreePath](gtktreemodel#GtkTreePath-struct) *path`*,
*`[GtkTreeViewColumn](gtktreeviewcolumn#GtkTreeViewColumn-struct) *focus_column`*,
*`gboolean start_editing`*);
```
Sets the current keyboard focus to be at *`path`* , and selects it. This is useful when you want to focus the user’s attention on a particular row. If *`focus_column`* is not `NULL`, then focus is given to the column specified by it. Additionally, if *`focus_column`* is specified, and *`start_editing`* is `TRUE`, then editing should be started in the specified cell. This function is often followed by *`gtk_widget_grab_focus`* (*`tree_view`* ) in order to give keyboard focus to the widget. Please note that editing can only happen when the widget is realized.
If *`path`* is invalid for *`model`* , the current cursor (if any) will be unset and the function will return without failing.
#### Parameters
| | | |
| --- | --- | --- |
| tree\_view | A [GtkTreeView](gtktreeview#GtkTreeView-struct) | |
| path | A [GtkTreePath](gtktreemodel#GtkTreePath-struct) | |
| focus\_column | A [GtkTreeViewColumn](gtktreeviewcolumn#GtkTreeViewColumn-struct), or `NULL`. | [allow-none] |
| start\_editing | `TRUE` if the specified cell should start being edited. | |
### gtk\_tree\_view\_set\_cursor\_on\_cell ()
```
void
gtk_tree_view_set_cursor_on_cell (*`[GtkTreeView](gtktreeview#GtkTreeView-struct) *tree_view`*,
*`[GtkTreePath](gtktreemodel#GtkTreePath-struct) *path`*,
*`[GtkTreeViewColumn](gtktreeviewcolumn#GtkTreeViewColumn-struct) *focus_column`*,
*`[GtkCellRenderer](gtkcellrenderer#GtkCellRenderer-struct) *focus_cell`*,
*`gboolean start_editing`*);
```
Sets the current keyboard focus to be at *`path`* , and selects it. This is useful when you want to focus the user’s attention on a particular row. If *`focus_column`* is not `NULL`, then focus is given to the column specified by it. If *`focus_column`* and *`focus_cell`* are not `NULL`, and *`focus_column`* contains 2 or more editable or activatable cells, then focus is given to the cell specified by *`focus_cell`* . Additionally, if *`focus_column`* is specified, and *`start_editing`* is `TRUE`, then editing should be started in the specified cell. This function is often followed by *`gtk_widget_grab_focus`* (*`tree_view`* ) in order to give keyboard focus to the widget. Please note that editing can only happen when the widget is realized.
If *`path`* is invalid for *`model`* , the current cursor (if any) will be unset and the function will return without failing.
#### Parameters
| | | |
| --- | --- | --- |
| tree\_view | A [GtkTreeView](gtktreeview#GtkTreeView-struct) | |
| path | A [GtkTreePath](gtktreemodel#GtkTreePath-struct) | |
| focus\_column | A [GtkTreeViewColumn](gtktreeviewcolumn#GtkTreeViewColumn-struct), or `NULL`. | [allow-none] |
| focus\_cell | A [GtkCellRenderer](gtkcellrenderer#GtkCellRenderer-struct), or `NULL`. | [allow-none] |
| start\_editing | `TRUE` if the specified cell should start being edited. | |
### gtk\_tree\_view\_get\_cursor ()
```
void
gtk_tree_view_get_cursor (*`[GtkTreeView](gtktreeview#GtkTreeView-struct) *tree_view`*,
*`[GtkTreePath](gtktreemodel#GtkTreePath-struct) **path`*,
*`[GtkTreeViewColumn](gtktreeviewcolumn#GtkTreeViewColumn-struct) **focus_column`*);
```
Fills in *`path`* and *`focus_column`* with the current path and focus column. If the cursor isn’t currently set, then \**`path`* will be `NULL`. If no column currently has focus, then \**`focus_column`* will be `NULL`.
The returned [GtkTreePath](gtktreemodel#GtkTreePath-struct) must be freed with [`gtk_tree_path_free()`](gtktreemodel#gtk-tree-path-free) when you are done with it.
#### Parameters
| | | |
| --- | --- | --- |
| tree\_view | A [GtkTreeView](gtktreeview#GtkTreeView-struct) | |
| path | A pointer to be filled with the current cursor path, or `NULL`. | [out][transfer full][optional][nullable] |
| focus\_column | A pointer to be filled with the current focus column, or `NULL`. | [out][transfer none][optional][nullable] |
### gtk\_tree\_view\_row\_activated ()
```
void
gtk_tree_view_row_activated (*`[GtkTreeView](gtktreeview#GtkTreeView-struct) *tree_view`*,
*`[GtkTreePath](gtktreemodel#GtkTreePath-struct) *path`*,
*`[GtkTreeViewColumn](gtktreeviewcolumn#GtkTreeViewColumn-struct) *column`*);
```
Activates the cell determined by *`path`* and *`column`* .
#### Parameters
| | | |
| --- | --- | --- |
| tree\_view | A [GtkTreeView](gtktreeview#GtkTreeView-struct) | |
| path | The [GtkTreePath](gtktreemodel#GtkTreePath-struct) to be activated. | |
| column | The [GtkTreeViewColumn](gtktreeviewcolumn#GtkTreeViewColumn-struct) to be activated. | |
### gtk\_tree\_view\_expand\_all ()
```
void
gtk_tree_view_expand_all (*`[GtkTreeView](gtktreeview#GtkTreeView-struct) *tree_view`*);
```
Recursively expands all nodes in the *`tree_view`* .
#### Parameters
| | | |
| --- | --- | --- |
| tree\_view | A [GtkTreeView](gtktreeview#GtkTreeView-struct). | |
### gtk\_tree\_view\_collapse\_all ()
```
void
gtk_tree_view_collapse_all (*`[GtkTreeView](gtktreeview#GtkTreeView-struct) *tree_view`*);
```
Recursively collapses all visible, expanded nodes in *`tree_view`* .
#### Parameters
| | | |
| --- | --- | --- |
| tree\_view | A [GtkTreeView](gtktreeview#GtkTreeView-struct). | |
### gtk\_tree\_view\_expand\_to\_path ()
```
void
gtk_tree_view_expand_to_path (*`[GtkTreeView](gtktreeview#GtkTreeView-struct) *tree_view`*,
*`[GtkTreePath](gtktreemodel#GtkTreePath-struct) *path`*);
```
Expands the row at *`path`* . This will also expand all parent rows of *`path`* as necessary.
#### Parameters
| | | |
| --- | --- | --- |
| tree\_view | A [GtkTreeView](gtktreeview#GtkTreeView-struct). | |
| path | path to a row. | |
### gtk\_tree\_view\_expand\_row ()
```
gboolean
gtk_tree_view_expand_row (*`[GtkTreeView](gtktreeview#GtkTreeView-struct) *tree_view`*,
*`[GtkTreePath](gtktreemodel#GtkTreePath-struct) *path`*,
*`gboolean open_all`*);
```
Opens the row so its children are visible.
#### Parameters
| | | |
| --- | --- | --- |
| tree\_view | a [GtkTreeView](gtktreeview#GtkTreeView-struct) | |
| path | path to a row | |
| open\_all | whether to recursively expand, or just expand immediate children | |
#### Returns
`TRUE` if the row existed and had children
### gtk\_tree\_view\_collapse\_row ()
```
gboolean
gtk_tree_view_collapse_row (*`[GtkTreeView](gtktreeview#GtkTreeView-struct) *tree_view`*,
*`[GtkTreePath](gtktreemodel#GtkTreePath-struct) *path`*);
```
Collapses a row (hides its child rows, if they exist).
#### Parameters
| | | |
| --- | --- | --- |
| tree\_view | a [GtkTreeView](gtktreeview#GtkTreeView-struct) | |
| path | path to a row in the *`tree_view`* | |
#### Returns
`TRUE` if the row was collapsed.
### gtk\_tree\_view\_map\_expanded\_rows ()
```
void
gtk_tree_view_map_expanded_rows (*`[GtkTreeView](gtktreeview#GtkTreeView-struct) *tree_view`*,
*`[GtkTreeViewMappingFunc](gtktreeview#GtkTreeViewMappingFunc) func`*,
*`gpointer data`*);
```
Calls *`func`* on all expanded rows.
#### Parameters
| | | |
| --- | --- | --- |
| tree\_view | A [GtkTreeView](gtktreeview#GtkTreeView-struct) | |
| func | A function to be called. | [scope call] |
| data | User data to be passed to the function. | |
### gtk\_tree\_view\_row\_expanded ()
```
gboolean
gtk_tree_view_row_expanded (*`[GtkTreeView](gtktreeview#GtkTreeView-struct) *tree_view`*,
*`[GtkTreePath](gtktreemodel#GtkTreePath-struct) *path`*);
```
Returns `TRUE` if the node pointed to by *`path`* is expanded in *`tree_view`* .
#### Parameters
| | | |
| --- | --- | --- |
| tree\_view | A [GtkTreeView](gtktreeview#GtkTreeView-struct). | |
| path | A [GtkTreePath](gtktreemodel#GtkTreePath-struct) to test expansion state. | |
#### Returns
`TRUE` if path is expanded.
### gtk\_tree\_view\_set\_reorderable ()
```
void
gtk_tree_view_set_reorderable (*`[GtkTreeView](gtktreeview#GtkTreeView-struct) *tree_view`*,
*`gboolean reorderable`*);
```
This function is a convenience function to allow you to reorder models that support the [GtkTreeDragSourceIface](gtk4-gtktreeview-drag-and-drop#GtkTreeDragSourceIface) and the [GtkTreeDragDestIface](gtk4-gtktreeview-drag-and-drop#GtkTreeDragDestIface). Both [GtkTreeStore](gtktreestore#GtkTreeStore-struct) and [GtkListStore](gtkliststore#GtkListStore-struct) support these. If *`reorderable`* is `TRUE`, then the user can reorder the model by dragging and dropping rows. The developer can listen to these changes by connecting to the model’s [“row-inserted”](gtktreemodel#GtkTreeModel-row-inserted) and [“row-deleted”](gtktreemodel#GtkTreeModel-row-deleted) signals. The reordering is implemented by setting up the tree view as a drag source and destination. Therefore, drag and drop can not be used in a reorderable view for any other purpose.
This function does not give you any degree of control over the order -- any reordering is allowed. If more control is needed, you should probably handle drag and drop manually.
#### Parameters
| | | |
| --- | --- | --- |
| tree\_view | A [GtkTreeView](gtktreeview#GtkTreeView-struct). | |
| reorderable | `TRUE`, if the tree can be reordered. | |
### gtk\_tree\_view\_get\_reorderable ()
```
gboolean
gtk_tree_view_get_reorderable (*`[GtkTreeView](gtktreeview#GtkTreeView-struct) *tree_view`*);
```
Retrieves whether the user can reorder the tree via drag-and-drop. See [`gtk_tree_view_set_reorderable()`](gtktreeview#gtk-tree-view-set-reorderable).
#### Parameters
| | | |
| --- | --- | --- |
| tree\_view | a [GtkTreeView](gtktreeview#GtkTreeView-struct) | |
#### Returns
`TRUE` if the tree can be reordered.
### gtk\_tree\_view\_get\_path\_at\_pos ()
```
gboolean
gtk_tree_view_get_path_at_pos (*`[GtkTreeView](gtktreeview#GtkTreeView-struct) *tree_view`*,
*`int x`*,
*`int y`*,
*`[GtkTreePath](gtktreemodel#GtkTreePath-struct) **path`*,
*`[GtkTreeViewColumn](gtktreeviewcolumn#GtkTreeViewColumn-struct) **column`*,
*`int *cell_x`*,
*`int *cell_y`*);
```
Finds the path at the point (*`x`* , *`y`* ), relative to bin\_window coordinates. That is, *`x`* and *`y`* are relative to an events coordinates. Widget-relative coordinates must be converted using [`gtk_tree_view_convert_widget_to_bin_window_coords()`](gtktreeview#gtk-tree-view-convert-widget-to-bin-window-coords). It is primarily for things like popup menus. If *`path`* is non-`NULL`, then it will be filled with the [GtkTreePath](gtktreemodel#GtkTreePath-struct) at that point. This path should be freed with [`gtk_tree_path_free()`](gtktreemodel#gtk-tree-path-free). If *`column`* is non-`NULL`, then it will be filled with the column at that point. *`cell_x`* and *`cell_y`* return the coordinates relative to the cell background (i.e. the *`background_area`* passed to `gtk_cell_renderer_render()`). This function is only meaningful if *`tree_view`* is realized. Therefore this function will always return `FALSE` if *`tree_view`* is not realized or does not have a model.
For converting widget coordinates (eg. the ones you get from GtkWidget::query-tooltip), please see [`gtk_tree_view_convert_widget_to_bin_window_coords()`](gtktreeview#gtk-tree-view-convert-widget-to-bin-window-coords).
#### Parameters
| | | |
| --- | --- | --- |
| tree\_view | A [GtkTreeView](gtktreeview#GtkTreeView-struct). | |
| x | The x position to be identified (relative to bin\_window). | |
| y | The y position to be identified (relative to bin\_window). | |
| path | A pointer to a [GtkTreePath](gtktreemodel#GtkTreePath-struct) pointer to be filled in, or `NULL`. | [out][optional][nullable] |
| column | A pointer to a [GtkTreeViewColumn](gtktreeviewcolumn#GtkTreeViewColumn-struct) pointer to be filled in, or `NULL`. | [out][transfer none][optional][nullable] |
| cell\_x | A pointer where the X coordinate relative to the cell can be placed, or `NULL`. | [out][optional] |
| cell\_y | A pointer where the Y coordinate relative to the cell can be placed, or `NULL`. | [out][optional] |
#### Returns
`TRUE` if a row exists at that coordinate.
### gtk\_tree\_view\_is\_blank\_at\_pos ()
```
gboolean
gtk_tree_view_is_blank_at_pos (*`[GtkTreeView](gtktreeview#GtkTreeView-struct) *tree_view`*,
*`int x`*,
*`int y`*,
*`[GtkTreePath](gtktreemodel#GtkTreePath-struct) **path`*,
*`[GtkTreeViewColumn](gtktreeviewcolumn#GtkTreeViewColumn-struct) **column`*,
*`int *cell_x`*,
*`int *cell_y`*);
```
Determine whether the point (*`x`* , *`y`* ) in *`tree_view`* is blank, that is no cell content nor an expander arrow is drawn at the location. If so, the location can be considered as the background. You might wish to take special action on clicks on the background, such as clearing a current selection, having a custom context menu or starting rubber banding.
The *`x`* and *`y`* coordinate that are provided must be relative to bin\_window coordinates. Widget-relative coordinates must be converted using [`gtk_tree_view_convert_widget_to_bin_window_coords()`](gtktreeview#gtk-tree-view-convert-widget-to-bin-window-coords).
For converting widget coordinates (eg. the ones you get from GtkWidget::query-tooltip), please see [`gtk_tree_view_convert_widget_to_bin_window_coords()`](gtktreeview#gtk-tree-view-convert-widget-to-bin-window-coords).
The *`path`* , *`column`* , *`cell_x`* and *`cell_y`* arguments will be filled in likewise as for [`gtk_tree_view_get_path_at_pos()`](gtktreeview#gtk-tree-view-get-path-at-pos). Please see [`gtk_tree_view_get_path_at_pos()`](gtktreeview#gtk-tree-view-get-path-at-pos) for more information.
#### Parameters
| | | |
| --- | --- | --- |
| tree\_view | A [GtkTreeView](gtktreeview#GtkTreeView-struct) | |
| x | The x position to be identified (relative to bin\_window) | |
| y | The y position to be identified (relative to bin\_window) | |
| path | A pointer to a [GtkTreePath](gtktreemodel#GtkTreePath-struct) pointer to be filled in, or `NULL`. | [out][optional][nullable] |
| column | A pointer to a [GtkTreeViewColumn](gtktreeviewcolumn#GtkTreeViewColumn-struct) pointer to be filled in, or `NULL`. | [out][transfer none][optional][nullable] |
| cell\_x | A pointer where the X coordinate relative to the cell can be placed, or `NULL`. | [out][optional] |
| cell\_y | A pointer where the Y coordinate relative to the cell can be placed, or `NULL`. | [out][optional] |
#### Returns
`TRUE` if the area at the given coordinates is blank, `FALSE` otherwise.
### gtk\_tree\_view\_get\_cell\_area ()
```
void
gtk_tree_view_get_cell_area (*`[GtkTreeView](gtktreeview#GtkTreeView-struct) *tree_view`*,
*`[GtkTreePath](gtktreemodel#GtkTreePath-struct) *path`*,
*`[GtkTreeViewColumn](gtktreeviewcolumn#GtkTreeViewColumn-struct) *column`*,
*`[GdkRectangle](https://developer-old.gnome.org/gtk4/html/gdk4-Rectangles-and-Regions.html#GdkRectangle-struct) *rect`*);
```
Fills the bounding rectangle in bin\_window coordinates for the cell at the row specified by *`path`* and the column specified by *`column`* . If *`path`* is `NULL`, or points to a path not currently displayed, the *`y`* and *`height`* fields of the rectangle will be filled with 0. If *`column`* is `NULL`, the *`x`* and *`width`* fields will be filled with 0. The sum of all cell rects does not cover the entire tree; there are extra pixels in between rows, for example. The returned rectangle is equivalent to the *`cell_area`* passed to `gtk_cell_renderer_render()`. This function is only valid if *`tree_view`* is realized.
#### Parameters
| | | |
| --- | --- | --- |
| tree\_view | a [GtkTreeView](gtktreeview#GtkTreeView-struct) | |
| path | a [GtkTreePath](gtktreemodel#GtkTreePath-struct) for the row, or `NULL` to get only horizontal coordinates. | [allow-none] |
| column | a [GtkTreeViewColumn](gtktreeviewcolumn#GtkTreeViewColumn-struct) for the column, or `NULL` to get only vertical coordinates. | [allow-none] |
| rect | rectangle to fill with cell rect. | [out] |
### gtk\_tree\_view\_get\_background\_area ()
```
void
gtk_tree_view_get_background_area (*`[GtkTreeView](gtktreeview#GtkTreeView-struct) *tree_view`*,
*`[GtkTreePath](gtktreemodel#GtkTreePath-struct) *path`*,
*`[GtkTreeViewColumn](gtktreeviewcolumn#GtkTreeViewColumn-struct) *column`*,
*`[GdkRectangle](https://developer-old.gnome.org/gtk4/html/gdk4-Rectangles-and-Regions.html#GdkRectangle-struct) *rect`*);
```
Fills the bounding rectangle in bin\_window coordinates for the cell at the row specified by *`path`* and the column specified by *`column`* . If *`path`* is `NULL`, or points to a node not found in the tree, the *`y`* and *`height`* fields of the rectangle will be filled with 0. If *`column`* is `NULL`, the *`x`* and *`width`* fields will be filled with 0. The returned rectangle is equivalent to the *`background_area`* passed to `gtk_cell_renderer_render()`. These background areas tile to cover the entire bin window. Contrast with the *`cell_area`* , returned by [`gtk_tree_view_get_cell_area()`](gtktreeview#gtk-tree-view-get-cell-area), which returns only the cell itself, excluding surrounding borders and the tree expander area.
#### Parameters
| | | |
| --- | --- | --- |
| tree\_view | a [GtkTreeView](gtktreeview#GtkTreeView-struct) | |
| path | a [GtkTreePath](gtktreemodel#GtkTreePath-struct) for the row, or `NULL` to get only horizontal coordinates. | [allow-none] |
| column | a [GtkTreeViewColumn](gtktreeviewcolumn#GtkTreeViewColumn-struct) for the column, or `NULL` to get only vertical coordinates. | [allow-none] |
| rect | rectangle to fill with cell background rect. | [out] |
### gtk\_tree\_view\_get\_visible\_rect ()
```
void
gtk_tree_view_get_visible_rect (*`[GtkTreeView](gtktreeview#GtkTreeView-struct) *tree_view`*,
*`[GdkRectangle](https://developer-old.gnome.org/gtk4/html/gdk4-Rectangles-and-Regions.html#GdkRectangle-struct) *visible_rect`*);
```
Fills *`visible_rect`* with the currently-visible region of the buffer, in tree coordinates. Convert to bin\_window coordinates with [`gtk_tree_view_convert_tree_to_bin_window_coords()`](gtktreeview#gtk-tree-view-convert-tree-to-bin-window-coords). Tree coordinates start at 0,0 for row 0 of the tree, and cover the entire scrollable area of the tree.
#### Parameters
| | | |
| --- | --- | --- |
| tree\_view | a [GtkTreeView](gtktreeview#GtkTreeView-struct) | |
| visible\_rect | rectangle to fill. | [out] |
### gtk\_tree\_view\_get\_visible\_range ()
```
gboolean
gtk_tree_view_get_visible_range (*`[GtkTreeView](gtktreeview#GtkTreeView-struct) *tree_view`*,
*`[GtkTreePath](gtktreemodel#GtkTreePath-struct) **start_path`*,
*`[GtkTreePath](gtktreemodel#GtkTreePath-struct) **end_path`*);
```
Sets *`start_path`* and *`end_path`* to be the first and last visible path. Note that there may be invisible paths in between.
The paths should be freed with [`gtk_tree_path_free()`](gtktreemodel#gtk-tree-path-free) after use.
#### Parameters
| | | |
| --- | --- | --- |
| tree\_view | A [GtkTreeView](gtktreeview#GtkTreeView-struct) | |
| start\_path | Return location for start of region, or `NULL`. | [out][allow-none] |
| end\_path | Return location for end of region, or `NULL`. | [out][allow-none] |
#### Returns
`TRUE`, if valid paths were placed in *`start_path`* and *`end_path`* .
### gtk\_tree\_view\_convert\_bin\_window\_to\_tree\_coords ()
```
void
gtk_tree_view_convert_bin_window_to_tree_coords
(*`[GtkTreeView](gtktreeview#GtkTreeView-struct) *tree_view`*,
*`int bx`*,
*`int by`*,
*`int *tx`*,
*`int *ty`*);
```
Converts bin\_window coordinates to coordinates for the tree (the full scrollable area of the tree).
#### Parameters
| | | |
| --- | --- | --- |
| tree\_view | a [GtkTreeView](gtktreeview#GtkTreeView-struct) | |
| bx | X coordinate relative to bin\_window | |
| by | Y coordinate relative to bin\_window | |
| tx | return location for tree X coordinate. | [out] |
| ty | return location for tree Y coordinate. | [out] |
### gtk\_tree\_view\_convert\_bin\_window\_to\_widget\_coords ()
```
void
gtk_tree_view_convert_bin_window_to_widget_coords
(*`[GtkTreeView](gtktreeview#GtkTreeView-struct) *tree_view`*,
*`int bx`*,
*`int by`*,
*`int *wx`*,
*`int *wy`*);
```
Converts bin\_window coordinates to widget relative coordinates.
#### Parameters
| | | |
| --- | --- | --- |
| tree\_view | a [GtkTreeView](gtktreeview#GtkTreeView-struct) | |
| bx | bin\_window X coordinate | |
| by | bin\_window Y coordinate | |
| wx | return location for widget X coordinate. | [out] |
| wy | return location for widget Y coordinate. | [out] |
### gtk\_tree\_view\_convert\_tree\_to\_bin\_window\_coords ()
```
void
gtk_tree_view_convert_tree_to_bin_window_coords
(*`[GtkTreeView](gtktreeview#GtkTreeView-struct) *tree_view`*,
*`int tx`*,
*`int ty`*,
*`int *bx`*,
*`int *by`*);
```
Converts tree coordinates (coordinates in full scrollable area of the tree) to bin\_window coordinates.
#### Parameters
| | | |
| --- | --- | --- |
| tree\_view | a [GtkTreeView](gtktreeview#GtkTreeView-struct) | |
| tx | tree X coordinate | |
| ty | tree Y coordinate | |
| bx | return location for X coordinate relative to bin\_window. | [out] |
| by | return location for Y coordinate relative to bin\_window. | [out] |
### gtk\_tree\_view\_convert\_tree\_to\_widget\_coords ()
```
void
gtk_tree_view_convert_tree_to_widget_coords
(*`[GtkTreeView](gtktreeview#GtkTreeView-struct) *tree_view`*,
*`int tx`*,
*`int ty`*,
*`int *wx`*,
*`int *wy`*);
```
Converts tree coordinates (coordinates in full scrollable area of the tree) to widget coordinates.
#### Parameters
| | | |
| --- | --- | --- |
| tree\_view | a [GtkTreeView](gtktreeview#GtkTreeView-struct) | |
| tx | X coordinate relative to the tree | |
| ty | Y coordinate relative to the tree | |
| wx | return location for widget X coordinate. | [out] |
| wy | return location for widget Y coordinate. | [out] |
### gtk\_tree\_view\_convert\_widget\_to\_bin\_window\_coords ()
```
void
gtk_tree_view_convert_widget_to_bin_window_coords
(*`[GtkTreeView](gtktreeview#GtkTreeView-struct) *tree_view`*,
*`int wx`*,
*`int wy`*,
*`int *bx`*,
*`int *by`*);
```
Converts widget coordinates to coordinates for the bin\_window.
#### Parameters
| | | |
| --- | --- | --- |
| tree\_view | a [GtkTreeView](gtktreeview#GtkTreeView-struct) | |
| wx | X coordinate relative to the widget | |
| wy | Y coordinate relative to the widget | |
| bx | return location for bin\_window X coordinate. | [out] |
| by | return location for bin\_window Y coordinate. | [out] |
### gtk\_tree\_view\_convert\_widget\_to\_tree\_coords ()
```
void
gtk_tree_view_convert_widget_to_tree_coords
(*`[GtkTreeView](gtktreeview#GtkTreeView-struct) *tree_view`*,
*`int wx`*,
*`int wy`*,
*`int *tx`*,
*`int *ty`*);
```
Converts widget coordinates to coordinates for the tree (the full scrollable area of the tree).
#### Parameters
| | | |
| --- | --- | --- |
| tree\_view | a [GtkTreeView](gtktreeview#GtkTreeView-struct) | |
| wx | X coordinate relative to the widget | |
| wy | Y coordinate relative to the widget | |
| tx | return location for tree X coordinate. | [out] |
| ty | return location for tree Y coordinate. | [out] |
### gtk\_tree\_view\_enable\_model\_drag\_dest ()
```
void
gtk_tree_view_enable_model_drag_dest (*`[GtkTreeView](gtktreeview#GtkTreeView-struct) *tree_view`*,
*`[GdkContentFormats](https://developer-old.gnome.org/gtk4/html/gdk4-Content-Formats.html#GdkContentFormats-struct) *formats`*,
*`[GdkDragAction](https://developer-old.gnome.org/gtk4/html/gdk4-Drag-and-Drop.html#GdkDragAction) actions`*);
```
Turns *`tree_view`* into a drop destination for automatic DND. Calling this method sets [“reorderable”](gtktreeview#GtkTreeView--reorderable) to `FALSE`.
#### Parameters
| | | |
| --- | --- | --- |
| tree\_view | a [GtkTreeView](gtktreeview#GtkTreeView-struct) | |
| formats | the target formats that the drag will support | |
| actions | the bitmask of possible actions for a drag from this widget | |
### gtk\_tree\_view\_enable\_model\_drag\_source ()
```
void
gtk_tree_view_enable_model_drag_source
(*`[GtkTreeView](gtktreeview#GtkTreeView-struct) *tree_view`*,
*`[GdkModifierType](https://developer-old.gnome.org/gtk4/html/GdkSurface.html#GdkModifierType) start_button_mask`*,
*`[GdkContentFormats](https://developer-old.gnome.org/gtk4/html/gdk4-Content-Formats.html#GdkContentFormats-struct) *formats`*,
*`[GdkDragAction](https://developer-old.gnome.org/gtk4/html/gdk4-Drag-and-Drop.html#GdkDragAction) actions`*);
```
Turns *`tree_view`* into a drag source for automatic DND. Calling this method sets [“reorderable”](gtktreeview#GtkTreeView--reorderable) to `FALSE`.
#### Parameters
| | | |
| --- | --- | --- |
| tree\_view | a [GtkTreeView](gtktreeview#GtkTreeView-struct) | |
| start\_button\_mask | Mask of allowed buttons to start drag | |
| formats | the target formats that the drag will support | |
| actions | the bitmask of possible actions for a drag from this widget | |
### gtk\_tree\_view\_unset\_rows\_drag\_source ()
```
void
gtk_tree_view_unset_rows_drag_source (*`[GtkTreeView](gtktreeview#GtkTreeView-struct) *tree_view`*);
```
Undoes the effect of [`gtk_tree_view_enable_model_drag_source()`](gtktreeview#gtk-tree-view-enable-model-drag-source). Calling this method sets [“reorderable”](gtktreeview#GtkTreeView--reorderable) to `FALSE`.
#### Parameters
| | | |
| --- | --- | --- |
| tree\_view | a [GtkTreeView](gtktreeview#GtkTreeView-struct) | |
### gtk\_tree\_view\_unset\_rows\_drag\_dest ()
```
void
gtk_tree_view_unset_rows_drag_dest (*`[GtkTreeView](gtktreeview#GtkTreeView-struct) *tree_view`*);
```
Undoes the effect of [`gtk_tree_view_enable_model_drag_dest()`](gtktreeview#gtk-tree-view-enable-model-drag-dest). Calling this method sets [“reorderable”](gtktreeview#GtkTreeView--reorderable) to `FALSE`.
#### Parameters
| | | |
| --- | --- | --- |
| tree\_view | a [GtkTreeView](gtktreeview#GtkTreeView-struct) | |
### gtk\_tree\_view\_set\_drag\_dest\_row ()
```
void
gtk_tree_view_set_drag_dest_row (*`[GtkTreeView](gtktreeview#GtkTreeView-struct) *tree_view`*,
*`[GtkTreePath](gtktreemodel#GtkTreePath-struct) *path`*,
*`[GtkTreeViewDropPosition](gtktreeview#GtkTreeViewDropPosition) pos`*);
```
Sets the row that is highlighted for feedback. If *`path`* is `NULL`, an existing highlight is removed.
#### Parameters
| | | |
| --- | --- | --- |
| tree\_view | a [GtkTreeView](gtktreeview#GtkTreeView-struct) | |
| path | The path of the row to highlight, or `NULL`. | [allow-none] |
| pos | Specifies whether to drop before, after or into the row | |
### gtk\_tree\_view\_get\_drag\_dest\_row ()
```
void
gtk_tree_view_get_drag_dest_row (*`[GtkTreeView](gtktreeview#GtkTreeView-struct) *tree_view`*,
*`[GtkTreePath](gtktreemodel#GtkTreePath-struct) **path`*,
*`[GtkTreeViewDropPosition](gtktreeview#GtkTreeViewDropPosition) *pos`*);
```
Gets information about the row that is highlighted for feedback.
#### Parameters
| | | |
| --- | --- | --- |
| tree\_view | a [GtkTreeView](gtktreeview#GtkTreeView-struct) | |
| path | Return location for the path of the highlighted row, or `NULL`. | [out][optional][nullable] |
| pos | Return location for the drop position, or `NULL`. | [out][optional] |
### gtk\_tree\_view\_get\_dest\_row\_at\_pos ()
```
gboolean
gtk_tree_view_get_dest_row_at_pos (*`[GtkTreeView](gtktreeview#GtkTreeView-struct) *tree_view`*,
*`int drag_x`*,
*`int drag_y`*,
*`[GtkTreePath](gtktreemodel#GtkTreePath-struct) **path`*,
*`[GtkTreeViewDropPosition](gtktreeview#GtkTreeViewDropPosition) *pos`*);
```
Determines the destination row for a given position. *`drag_x`* and *`drag_y`* are expected to be in widget coordinates. This function is only meaningful if *`tree_view`* is realized. Therefore this function will always return `FALSE` if *`tree_view`* is not realized or does not have a model.
#### Parameters
| | | |
| --- | --- | --- |
| tree\_view | a [GtkTreeView](gtktreeview#GtkTreeView-struct) | |
| drag\_x | the position to determine the destination row for | |
| drag\_y | the position to determine the destination row for | |
| path | Return location for the path of the highlighted row, or `NULL`. | [out][optional][nullable] |
| pos | Return location for the drop position, or `NULL`. | [out][optional] |
#### Returns
whether there is a row at the given position, `TRUE` if this is indeed the case.
### gtk\_tree\_view\_create\_row\_drag\_icon ()
```
[GdkPaintable](https://developer-old.gnome.org/gtk4/html/GdkPaintable.html#GdkPaintable-struct) *
gtk_tree_view_create_row_drag_icon (*`[GtkTreeView](gtktreeview#GtkTreeView-struct) *tree_view`*,
*`[GtkTreePath](gtktreemodel#GtkTreePath-struct) *path`*);
```
Creates a [cairo\_surface\_t](https://developer-old.gnome.org/cairo/stable/cairo-cairo-surface-t.html#cairo-surface-t) representation of the row at *`path`* . This image is used for a drag icon.
#### Parameters
| | | |
| --- | --- | --- |
| tree\_view | a [GtkTreeView](gtktreeview#GtkTreeView-struct) | |
| path | a [GtkTreePath](gtktreemodel#GtkTreePath-struct) in *`tree_view`* | |
#### Returns
a newly-allocated surface of the drag icon.
[transfer full][nullable]
### gtk\_tree\_view\_set\_enable\_search ()
```
void
gtk_tree_view_set_enable_search (*`[GtkTreeView](gtktreeview#GtkTreeView-struct) *tree_view`*,
*`gboolean enable_search`*);
```
If *`enable_search`* is set, then the user can type in text to search through the tree interactively (this is sometimes called "typeahead find").
Note that even if this is `FALSE`, the user can still initiate a search using the “start-interactive-search” key binding.
#### Parameters
| | | |
| --- | --- | --- |
| tree\_view | A [GtkTreeView](gtktreeview#GtkTreeView-struct) | |
| enable\_search | `TRUE`, if the user can search interactively | |
### gtk\_tree\_view\_get\_enable\_search ()
```
gboolean
gtk_tree_view_get_enable_search (*`[GtkTreeView](gtktreeview#GtkTreeView-struct) *tree_view`*);
```
Returns whether or not the tree allows to start interactive searching by typing in text.
#### Parameters
| | | |
| --- | --- | --- |
| tree\_view | A [GtkTreeView](gtktreeview#GtkTreeView-struct) | |
#### Returns
whether or not to let the user search interactively
### gtk\_tree\_view\_get\_search\_column ()
```
int
gtk_tree_view_get_search_column (*`[GtkTreeView](gtktreeview#GtkTreeView-struct) *tree_view`*);
```
Gets the column searched on by the interactive search code.
#### Parameters
| | | |
| --- | --- | --- |
| tree\_view | A [GtkTreeView](gtktreeview#GtkTreeView-struct) | |
#### Returns
the column the interactive search code searches in.
### gtk\_tree\_view\_set\_search\_column ()
```
void
gtk_tree_view_set_search_column (*`[GtkTreeView](gtktreeview#GtkTreeView-struct) *tree_view`*,
*`int column`*);
```
Sets *`column`* as the column where the interactive search code should search in for the current model.
If the search column is set, users can use the “start-interactive-search” key binding to bring up search popup. The enable-search property controls whether simply typing text will also start an interactive search.
Note that *`column`* refers to a column of the current model. The search column is reset to -1 when the model is changed.
#### Parameters
| | | |
| --- | --- | --- |
| tree\_view | A [GtkTreeView](gtktreeview#GtkTreeView-struct) | |
| column | the column of the model to search in, or -1 to disable searching | |
### gtk\_tree\_view\_get\_search\_equal\_func ()
```
[GtkTreeViewSearchEqualFunc](gtktreeview#GtkTreeViewSearchEqualFunc)
gtk_tree_view_get_search_equal_func (*`[GtkTreeView](gtktreeview#GtkTreeView-struct) *tree_view`*);
```
Returns the compare function currently in use.
[skip]
#### Parameters
| | | |
| --- | --- | --- |
| tree\_view | A [GtkTreeView](gtktreeview#GtkTreeView-struct) | |
#### Returns
the currently used compare function for the search code.
### gtk\_tree\_view\_set\_search\_equal\_func ()
```
void
gtk_tree_view_set_search_equal_func (*`[GtkTreeView](gtktreeview#GtkTreeView-struct) *tree_view`*,
*`[GtkTreeViewSearchEqualFunc](gtktreeview#GtkTreeViewSearchEqualFunc) search_equal_func`*,
*`gpointer search_user_data`*,
*`GDestroyNotify search_destroy`*);
```
Sets the compare function for the interactive search capabilities; note that somewhat like `strcmp()` returning 0 for equality [GtkTreeViewSearchEqualFunc](gtktreeview#GtkTreeViewSearchEqualFunc) returns `FALSE` on matches.
#### Parameters
| | | |
| --- | --- | --- |
| tree\_view | A [GtkTreeView](gtktreeview#GtkTreeView-struct) | |
| search\_equal\_func | the compare function to use during the search | |
| search\_user\_data | user data to pass to *`search_equal_func`* , or `NULL`. | [allow-none] |
| search\_destroy | Destroy notifier for *`search_user_data`* , or `NULL`. | [allow-none] |
### gtk\_tree\_view\_get\_search\_entry ()
```
[GtkEditable](gtkeditable#GtkEditable-struct) *
gtk_tree_view_get_search_entry (*`[GtkTreeView](gtktreeview#GtkTreeView-struct) *tree_view`*);
```
Returns the [GtkEntry](gtkentry#GtkEntry-struct) which is currently in use as interactive search entry for *`tree_view`* . In case the built-in entry is being used, `NULL` will be returned.
#### Parameters
| | | |
| --- | --- | --- |
| tree\_view | A [GtkTreeView](gtktreeview#GtkTreeView-struct) | |
#### Returns
the entry currently in use as search entry.
[transfer none][nullable]
### gtk\_tree\_view\_set\_search\_entry ()
```
void
gtk_tree_view_set_search_entry (*`[GtkTreeView](gtktreeview#GtkTreeView-struct) *tree_view`*,
*`[GtkEditable](gtkeditable#GtkEditable-struct) *entry`*);
```
Sets the entry which the interactive search code will use for this *`tree_view`* . This is useful when you want to provide a search entry in our interface at all time at a fixed position. Passing `NULL` for *`entry`* will make the interactive search code use the built-in popup entry again.
#### Parameters
| | | |
| --- | --- | --- |
| tree\_view | A [GtkTreeView](gtktreeview#GtkTreeView-struct) | |
| entry | the entry the interactive search code of *`tree_view`* should use or `NULL`. | [allow-none] |
### gtk\_tree\_view\_get\_fixed\_height\_mode ()
```
gboolean
gtk_tree_view_get_fixed_height_mode (*`[GtkTreeView](gtktreeview#GtkTreeView-struct) *tree_view`*);
```
Returns whether fixed height mode is turned on for *`tree_view`* .
#### Parameters
| | | |
| --- | --- | --- |
| tree\_view | a [GtkTreeView](gtktreeview#GtkTreeView-struct) | |
#### Returns
`TRUE` if *`tree_view`* is in fixed height mode
### gtk\_tree\_view\_set\_fixed\_height\_mode ()
```
void
gtk_tree_view_set_fixed_height_mode (*`[GtkTreeView](gtktreeview#GtkTreeView-struct) *tree_view`*,
*`gboolean enable`*);
```
Enables or disables the fixed height mode of *`tree_view`* . Fixed height mode speeds up [GtkTreeView](gtktreeview#GtkTreeView-struct) by assuming that all rows have the same height. Only enable this option if all rows are the same height and all columns are of type [`GTK_TREE_VIEW_COLUMN_FIXED`](gtktreeviewcolumn#GTK-TREE-VIEW-COLUMN-FIXED:CAPS).
#### Parameters
| | | |
| --- | --- | --- |
| tree\_view | a [GtkTreeView](gtktreeview#GtkTreeView-struct) | |
| enable | `TRUE` to enable fixed height mode | |
### gtk\_tree\_view\_get\_hover\_selection ()
```
gboolean
gtk_tree_view_get_hover_selection (*`[GtkTreeView](gtktreeview#GtkTreeView-struct) *tree_view`*);
```
Returns whether hover selection mode is turned on for *`tree_view`* .
#### Parameters
| | | |
| --- | --- | --- |
| tree\_view | a [GtkTreeView](gtktreeview#GtkTreeView-struct) | |
#### Returns
`TRUE` if *`tree_view`* is in hover selection mode
### gtk\_tree\_view\_set\_hover\_selection ()
```
void
gtk_tree_view_set_hover_selection (*`[GtkTreeView](gtktreeview#GtkTreeView-struct) *tree_view`*,
*`gboolean hover`*);
```
Enables or disables the hover selection mode of *`tree_view`* . Hover selection makes the selected row follow the pointer. Currently, this works only for the selection modes [`GTK_SELECTION_SINGLE`](gtk4-standard-enumerations#GTK-SELECTION-SINGLE:CAPS) and [`GTK_SELECTION_BROWSE`](gtk4-standard-enumerations#GTK-SELECTION-BROWSE:CAPS).
#### Parameters
| | | |
| --- | --- | --- |
| tree\_view | a [GtkTreeView](gtktreeview#GtkTreeView-struct) | |
| hover | `TRUE` to enable hover selection mode | |
### gtk\_tree\_view\_get\_hover\_expand ()
```
gboolean
gtk_tree_view_get_hover_expand (*`[GtkTreeView](gtktreeview#GtkTreeView-struct) *tree_view`*);
```
Returns whether hover expansion mode is turned on for *`tree_view`* .
#### Parameters
| | | |
| --- | --- | --- |
| tree\_view | a [GtkTreeView](gtktreeview#GtkTreeView-struct) | |
#### Returns
`TRUE` if *`tree_view`* is in hover expansion mode
### gtk\_tree\_view\_set\_hover\_expand ()
```
void
gtk_tree_view_set_hover_expand (*`[GtkTreeView](gtktreeview#GtkTreeView-struct) *tree_view`*,
*`gboolean expand`*);
```
Enables or disables the hover expansion mode of *`tree_view`* . Hover expansion makes rows expand or collapse if the pointer moves over them.
#### Parameters
| | | |
| --- | --- | --- |
| tree\_view | a [GtkTreeView](gtktreeview#GtkTreeView-struct) | |
| expand | `TRUE` to enable hover selection mode | |
### GtkTreeViewRowSeparatorFunc ()
```
gboolean
(*GtkTreeViewRowSeparatorFunc) (*`[GtkTreeModel](gtktreemodel#GtkTreeModel-struct) *model`*,
*`[GtkTreeIter](gtktreemodel#GtkTreeIter-struct) *iter`*,
*`gpointer data`*);
```
Function type for determining whether the row pointed to by *`iter`* should be rendered as a separator. A common way to implement this is to have a boolean column in the model, whose values the [GtkTreeViewRowSeparatorFunc](gtktreeview#GtkTreeViewRowSeparatorFunc) returns.
#### Parameters
| | | |
| --- | --- | --- |
| model | the [GtkTreeModel](gtktreemodel#GtkTreeModel-struct) | |
| iter | a [GtkTreeIter](gtktreemodel#GtkTreeIter-struct) pointing at a row in *`model`* | |
| data | user data. | [closure] |
#### Returns
`TRUE` if the row is a separator
### gtk\_tree\_view\_get\_row\_separator\_func ()
```
[GtkTreeViewRowSeparatorFunc](gtktreeview#GtkTreeViewRowSeparatorFunc)
gtk_tree_view_get_row_separator_func (*`[GtkTreeView](gtktreeview#GtkTreeView-struct) *tree_view`*);
```
Returns the current row separator function.
[skip]
#### Parameters
| | | |
| --- | --- | --- |
| tree\_view | a [GtkTreeView](gtktreeview#GtkTreeView-struct) | |
#### Returns
the current row separator function.
### gtk\_tree\_view\_set\_row\_separator\_func ()
```
void
gtk_tree_view_set_row_separator_func (*`[GtkTreeView](gtktreeview#GtkTreeView-struct) *tree_view`*,
*`[GtkTreeViewRowSeparatorFunc](gtktreeview#GtkTreeViewRowSeparatorFunc) func`*,
*`gpointer data`*,
*`GDestroyNotify destroy`*);
```
Sets the row separator function, which is used to determine whether a row should be drawn as a separator. If the row separator function is `NULL`, no separators are drawn. This is the default value.
#### Parameters
| | | |
| --- | --- | --- |
| tree\_view | a [GtkTreeView](gtktreeview#GtkTreeView-struct) | |
| func | a [GtkTreeViewRowSeparatorFunc](gtktreeview#GtkTreeViewRowSeparatorFunc). | [allow-none] |
| data | user data to pass to *`func`* , or `NULL`. | [allow-none] |
| destroy | destroy notifier for *`data`* , or `NULL`. | [allow-none] |
### gtk\_tree\_view\_get\_rubber\_banding ()
```
gboolean
gtk_tree_view_get_rubber_banding (*`[GtkTreeView](gtktreeview#GtkTreeView-struct) *tree_view`*);
```
Returns whether rubber banding is turned on for *`tree_view`* . If the selection mode is [GTK\_SELECTION\_MULTIPLE](gtk4-standard-enumerations#GTK-SELECTION-MULTIPLE:CAPS), rubber banding will allow the user to select multiple rows by dragging the mouse.
#### Parameters
| | | |
| --- | --- | --- |
| tree\_view | a [GtkTreeView](gtktreeview#GtkTreeView-struct) | |
#### Returns
`TRUE` if rubber banding in *`tree_view`* is enabled.
### gtk\_tree\_view\_set\_rubber\_banding ()
```
void
gtk_tree_view_set_rubber_banding (*`[GtkTreeView](gtktreeview#GtkTreeView-struct) *tree_view`*,
*`gboolean enable`*);
```
Enables or disables rubber banding in *`tree_view`* . If the selection mode is [GTK\_SELECTION\_MULTIPLE](gtk4-standard-enumerations#GTK-SELECTION-MULTIPLE:CAPS), rubber banding will allow the user to select multiple rows by dragging the mouse.
#### Parameters
| | | |
| --- | --- | --- |
| tree\_view | a [GtkTreeView](gtktreeview#GtkTreeView-struct) | |
| enable | `TRUE` to enable rubber banding | |
### gtk\_tree\_view\_is\_rubber\_banding\_active ()
```
gboolean
gtk_tree_view_is_rubber_banding_active
(*`[GtkTreeView](gtktreeview#GtkTreeView-struct) *tree_view`*);
```
Returns whether a rubber banding operation is currently being done in *`tree_view`* .
#### Parameters
| | | |
| --- | --- | --- |
| tree\_view | a [GtkTreeView](gtktreeview#GtkTreeView-struct) | |
#### Returns
`TRUE` if a rubber banding operation is currently being done in *`tree_view`* .
### gtk\_tree\_view\_get\_enable\_tree\_lines ()
```
gboolean
gtk_tree_view_get_enable_tree_lines (*`[GtkTreeView](gtktreeview#GtkTreeView-struct) *tree_view`*);
```
Returns whether or not tree lines are drawn in *`tree_view`* .
#### Parameters
| | | |
| --- | --- | --- |
| tree\_view | a [GtkTreeView](gtktreeview#GtkTreeView-struct). | |
#### Returns
`TRUE` if tree lines are drawn in *`tree_view`* , `FALSE` otherwise.
### gtk\_tree\_view\_set\_enable\_tree\_lines ()
```
void
gtk_tree_view_set_enable_tree_lines (*`[GtkTreeView](gtktreeview#GtkTreeView-struct) *tree_view`*,
*`gboolean enabled`*);
```
Sets whether to draw lines interconnecting the expanders in *`tree_view`* . This does not have any visible effects for lists.
#### Parameters
| | | |
| --- | --- | --- |
| tree\_view | a [GtkTreeView](gtktreeview#GtkTreeView-struct) | |
| enabled | `TRUE` to enable tree line drawing, `FALSE` otherwise. | |
### gtk\_tree\_view\_get\_grid\_lines ()
```
[GtkTreeViewGridLines](gtktreeview#GtkTreeViewGridLines)
gtk_tree_view_get_grid_lines (*`[GtkTreeView](gtktreeview#GtkTreeView-struct) *tree_view`*);
```
Returns which grid lines are enabled in *`tree_view`* .
#### Parameters
| | | |
| --- | --- | --- |
| tree\_view | a [GtkTreeView](gtktreeview#GtkTreeView-struct) | |
#### Returns
a [GtkTreeViewGridLines](gtktreeview#GtkTreeViewGridLines) value indicating which grid lines are enabled.
### gtk\_tree\_view\_set\_grid\_lines ()
```
void
gtk_tree_view_set_grid_lines (*`[GtkTreeView](gtktreeview#GtkTreeView-struct) *tree_view`*,
*`[GtkTreeViewGridLines](gtktreeview#GtkTreeViewGridLines) grid_lines`*);
```
Sets which grid lines to draw in *`tree_view`* .
#### Parameters
| | | |
| --- | --- | --- |
| tree\_view | a [GtkTreeView](gtktreeview#GtkTreeView-struct) | |
| grid\_lines | a [GtkTreeViewGridLines](gtktreeview#GtkTreeViewGridLines) value indicating which grid lines to enable. | |
### gtk\_tree\_view\_set\_tooltip\_row ()
```
void
gtk_tree_view_set_tooltip_row (*`[GtkTreeView](gtktreeview#GtkTreeView-struct) *tree_view`*,
*`[GtkTooltip](gtktooltip#GtkTooltip-struct) *tooltip`*,
*`[GtkTreePath](gtktreemodel#GtkTreePath-struct) *path`*);
```
Sets the tip area of *`tooltip`* to be the area covered by the row at *`path`* . See also [`gtk_tree_view_set_tooltip_column()`](gtktreeview#gtk-tree-view-set-tooltip-column) for a simpler alternative. See also [`gtk_tooltip_set_tip_area()`](gtktooltip#gtk-tooltip-set-tip-area).
#### Parameters
| | | |
| --- | --- | --- |
| tree\_view | a [GtkTreeView](gtktreeview#GtkTreeView-struct) | |
| tooltip | a [GtkTooltip](gtktooltip#GtkTooltip-struct) | |
| path | a [GtkTreePath](gtktreemodel#GtkTreePath-struct) | |
### gtk\_tree\_view\_set\_tooltip\_cell ()
```
void
gtk_tree_view_set_tooltip_cell (*`[GtkTreeView](gtktreeview#GtkTreeView-struct) *tree_view`*,
*`[GtkTooltip](gtktooltip#GtkTooltip-struct) *tooltip`*,
*`[GtkTreePath](gtktreemodel#GtkTreePath-struct) *path`*,
*`[GtkTreeViewColumn](gtktreeviewcolumn#GtkTreeViewColumn-struct) *column`*,
*`[GtkCellRenderer](gtkcellrenderer#GtkCellRenderer-struct) *cell`*);
```
Sets the tip area of *`tooltip`* to the area *`path`* , *`column`* and *`cell`* have in common. For example if *`path`* is `NULL` and *`column`* is set, the tip area will be set to the full area covered by *`column`* . See also [`gtk_tooltip_set_tip_area()`](gtktooltip#gtk-tooltip-set-tip-area).
Note that if *`path`* is not specified and *`cell`* is set and part of a column containing the expander, the tooltip might not show and hide at the correct position. In such cases *`path`* must be set to the current node under the mouse cursor for this function to operate correctly.
See also [`gtk_tree_view_set_tooltip_column()`](gtktreeview#gtk-tree-view-set-tooltip-column) for a simpler alternative.
#### Parameters
| | | |
| --- | --- | --- |
| tree\_view | a [GtkTreeView](gtktreeview#GtkTreeView-struct) | |
| tooltip | a [GtkTooltip](gtktooltip#GtkTooltip-struct) | |
| path | a [GtkTreePath](gtktreemodel#GtkTreePath-struct) or `NULL`. | [allow-none] |
| column | a [GtkTreeViewColumn](gtktreeviewcolumn#GtkTreeViewColumn-struct) or `NULL`. | [allow-none] |
| cell | a [GtkCellRenderer](gtkcellrenderer#GtkCellRenderer-struct) or `NULL`. | [allow-none] |
### gtk\_tree\_view\_get\_tooltip\_context ()
```
gboolean
gtk_tree_view_get_tooltip_context (*`[GtkTreeView](gtktreeview#GtkTreeView-struct) *tree_view`*,
*`int x`*,
*`int y`*,
*`gboolean keyboard_tip`*,
*`[GtkTreeModel](gtktreemodel#GtkTreeModel-struct) **model`*,
*`[GtkTreePath](gtktreemodel#GtkTreePath-struct) **path`*,
*`[GtkTreeIter](gtktreemodel#GtkTreeIter-struct) *iter`*);
```
This function is supposed to be used in a [“query-tooltip”](gtkwidget#GtkWidget-query-tooltip) signal handler for [GtkTreeView](gtktreeview#GtkTreeView-struct). The *`x`* , *`y`* and *`keyboard_tip`* values which are received in the signal handler, should be passed to this function without modification.
The return value indicates whether there is a tree view row at the given coordinates (`TRUE`) or not (`FALSE`) for mouse tooltips. For keyboard tooltips the row returned will be the cursor row. When `TRUE`, then any of *`model`* , *`path`* and *`iter`* which have been provided will be set to point to that row and the corresponding model. *`x`* and *`y`* will always be converted to be relative to *`tree_view`* ’s bin\_window if *`keyboard_tooltip`* is `FALSE`.
#### Parameters
| | | |
| --- | --- | --- |
| tree\_view | a [GtkTreeView](gtktreeview#GtkTreeView-struct) | |
| x | the x coordinate (relative to widget coordinates) | |
| y | the y coordinate (relative to widget coordinates) | |
| keyboard\_tip | whether this is a keyboard tooltip or not | |
| model | a pointer to receive a [GtkTreeModel](gtktreemodel#GtkTreeModel-struct) or `NULL`. | [out][optional][nullable][transfer none] |
| path | a pointer to receive a [GtkTreePath](gtktreemodel#GtkTreePath-struct) or `NULL`. | [out][optional] |
| iter | a pointer to receive a [GtkTreeIter](gtktreemodel#GtkTreeIter-struct) or `NULL`. | [out][optional] |
#### Returns
whether or not the given tooltip context points to a row.
### gtk\_tree\_view\_get\_tooltip\_column ()
```
int
gtk_tree_view_get_tooltip_column (*`[GtkTreeView](gtktreeview#GtkTreeView-struct) *tree_view`*);
```
Returns the column of *`tree_view`* ’s model which is being used for displaying tooltips on *`tree_view`* ’s rows.
#### Parameters
| | | |
| --- | --- | --- |
| tree\_view | a [GtkTreeView](gtktreeview#GtkTreeView-struct) | |
#### Returns
the index of the tooltip column that is currently being used, or -1 if this is disabled.
### gtk\_tree\_view\_set\_tooltip\_column ()
```
void
gtk_tree_view_set_tooltip_column (*`[GtkTreeView](gtktreeview#GtkTreeView-struct) *tree_view`*,
*`int column`*);
```
If you only plan to have simple (text-only) tooltips on full rows, you can use this function to have [GtkTreeView](gtktreeview#GtkTreeView-struct) handle these automatically for you. *`column`* should be set to the column in *`tree_view`* ’s model containing the tooltip texts, or -1 to disable this feature.
When enabled, [“has-tooltip”](gtkwidget#GtkWidget--has-tooltip) will be set to `TRUE` and *`tree_view`* will connect a [“query-tooltip”](gtkwidget#GtkWidget-query-tooltip) signal handler.
Note that the signal handler sets the text with [`gtk_tooltip_set_markup()`](gtktooltip#gtk-tooltip-set-markup), so &, <, etc have to be escaped in the text.
#### Parameters
| | | |
| --- | --- | --- |
| tree\_view | a [GtkTreeView](gtktreeview#GtkTreeView-struct) | |
| column | an integer, which is a valid column number for *`tree_view`* ’s model | |
Types and Values
----------------
### struct GtkTreeView
```
struct GtkTreeView;
```
### enum GtkTreeViewDropPosition
An enum for determining where a dropped row goes.
#### Members
| | | |
| --- | --- | --- |
| GTK\_TREE\_VIEW\_DROP\_BEFORE | dropped row is inserted before | |
| GTK\_TREE\_VIEW\_DROP\_AFTER | dropped row is inserted after | |
| GTK\_TREE\_VIEW\_DROP\_INTO\_OR\_BEFORE | dropped row becomes a child or is inserted before | |
| GTK\_TREE\_VIEW\_DROP\_INTO\_OR\_AFTER | dropped row becomes a child or is inserted after | |
### enum GtkTreeViewGridLines
Used to indicate which grid lines to draw in a tree view.
#### Members
| | | |
| --- | --- | --- |
| GTK\_TREE\_VIEW\_GRID\_LINES\_NONE | No grid lines. | |
| GTK\_TREE\_VIEW\_GRID\_LINES\_HORIZONTAL | Horizontal grid lines. | |
| GTK\_TREE\_VIEW\_GRID\_LINES\_VERTICAL | Vertical grid lines. | |
| GTK\_TREE\_VIEW\_GRID\_LINES\_BOTH | Horizontal and vertical grid lines. | |
Property Details
----------------
### The `“activate-on-single-click”` property
```
“activate-on-single-click” gboolean
```
The activate-on-single-click property specifies whether the "row-activated" signal will be emitted after a single click.
Owner: GtkTreeView
Flags: Read / Write
Default value: FALSE
### The `“enable-grid-lines”` property
```
“enable-grid-lines” [GtkTreeViewGridLines](gtktreeview#GtkTreeViewGridLines)
```
Whether grid lines should be drawn in the tree view.
Owner: GtkTreeView
Flags: Read / Write
Default value: GTK\_TREE\_VIEW\_GRID\_LINES\_NONE
### The `“enable-search”` property
```
“enable-search” gboolean
```
View allows user to search through columns interactively.
Owner: GtkTreeView
Flags: Read / Write
Default value: TRUE
### The `“enable-tree-lines”` property
```
“enable-tree-lines” gboolean
```
Whether tree lines should be drawn in the tree view.
Owner: GtkTreeView
Flags: Read / Write
Default value: FALSE
### The `“expander-column”` property
```
“expander-column” [GtkTreeViewColumn](gtktreeviewcolumn#GtkTreeViewColumn-struct) *
```
Set the column for the expander column.
Owner: GtkTreeView
Flags: Read / Write
### The `“fixed-height-mode”` property
```
“fixed-height-mode” gboolean
```
Setting the ::fixed-height-mode property to `TRUE` speeds up [GtkTreeView](gtktreeview#GtkTreeView-struct) by assuming that all rows have the same height. Only enable this option if all rows are the same height. Please see [`gtk_tree_view_set_fixed_height_mode()`](gtktreeview#gtk-tree-view-set-fixed-height-mode) for more information on this option.
Owner: GtkTreeView
Flags: Read / Write
Default value: FALSE
### The `“headers-clickable”` property
```
“headers-clickable” gboolean
```
Column headers respond to click events.
Owner: GtkTreeView
Flags: Read / Write
Default value: TRUE
### The `“headers-visible”` property
```
“headers-visible” gboolean
```
Show the column header buttons.
Owner: GtkTreeView
Flags: Read / Write
Default value: TRUE
### The `“hover-expand”` property
```
“hover-expand” gboolean
```
Enables or disables the hover expansion mode of *`tree_view`* . Hover expansion makes rows expand or collapse if the pointer moves over them.
This mode is primarily intended for treeviews in popups, e.g. in [GtkComboBox](gtkcombobox#GtkComboBox-struct) or [GtkEntryCompletion](gtkentrycompletion#GtkEntryCompletion-struct).
Owner: GtkTreeView
Flags: Read / Write
Default value: FALSE
### The `“hover-selection”` property
```
“hover-selection” gboolean
```
Enables or disables the hover selection mode of *`tree_view`* . Hover selection makes the selected row follow the pointer. Currently, this works only for the selection modes [`GTK_SELECTION_SINGLE`](gtk4-standard-enumerations#GTK-SELECTION-SINGLE:CAPS) and [`GTK_SELECTION_BROWSE`](gtk4-standard-enumerations#GTK-SELECTION-BROWSE:CAPS).
This mode is primarily intended for treeviews in popups, e.g. in [GtkComboBox](gtkcombobox#GtkComboBox-struct) or [GtkEntryCompletion](gtkentrycompletion#GtkEntryCompletion-struct).
Owner: GtkTreeView
Flags: Read / Write
Default value: FALSE
### The `“level-indentation”` property
```
“level-indentation” int
```
Extra indentation for each level.
Owner: GtkTreeView
Flags: Read / Write
Allowed values: >= 0
Default value: 0
### The `“model”` property
```
“model” [GtkTreeModel](gtktreemodel#GtkTreeModel-struct) *
```
The model for the tree view.
Owner: GtkTreeView
Flags: Read / Write
### The `“reorderable”` property
```
“reorderable” gboolean
```
View is reorderable.
Owner: GtkTreeView
Flags: Read / Write
Default value: FALSE
### The `“rubber-banding”` property
```
“rubber-banding” gboolean
```
Whether to enable selection of multiple items by dragging the mouse pointer.
Owner: GtkTreeView
Flags: Read / Write
Default value: FALSE
### The `“search-column”` property
```
“search-column” int
```
Model column to search through during interactive search.
Owner: GtkTreeView
Flags: Read / Write
Allowed values: >= -1
Default value: -1
### The `“show-expanders”` property
```
“show-expanders” gboolean
```
`TRUE` if the view has expanders.
Owner: GtkTreeView
Flags: Read / Write
Default value: TRUE
### The `“tooltip-column”` property
```
“tooltip-column” int
```
The column in the model containing the tooltip texts for the rows.
Owner: GtkTreeView
Flags: Read / Write
Allowed values: >= -1
Default value: -1
Signal Details
--------------
### The `“columns-changed”` signal
```
void
user_function ([GtkTreeView](gtktreeview#GtkTreeView-struct) *tree_view,
gpointer user_data)
```
The number of columns of the treeview has changed.
#### Parameters
| | | |
| --- | --- | --- |
| tree\_view | the object on which the signal is emitted | |
| user\_data | user data set when the signal handler was connected. | |
Flags: Run Last
### The `“cursor-changed”` signal
```
void
user_function ([GtkTreeView](gtktreeview#GtkTreeView-struct) *tree_view,
gpointer user_data)
```
The position of the cursor (focused cell) has changed.
#### Parameters
| | | |
| --- | --- | --- |
| tree\_view | the object on which the signal is emitted | |
| user\_data | user data set when the signal handler was connected. | |
Flags: Run Last
### The `“expand-collapse-cursor-row”` signal
```
gboolean
user_function ([GtkTreeView](gtktreeview#GtkTreeView-struct) *treeview,
gboolean arg1,
gboolean arg2,
gboolean arg3,
gpointer user_data)
```
Flags: Action
### The `“move-cursor”` signal
```
gboolean
user_function ([GtkTreeView](gtktreeview#GtkTreeView-struct) *tree_view,
[GtkMovementStep](gtk4-standard-enumerations#GtkMovementStep) step,
int direction,
gboolean extend,
gboolean modify,
gpointer user_data)
```
The [“move-cursor”](gtktreeview#GtkTreeView-move-cursor) signal is a keybinding signal which gets emitted when the user presses one of the cursor keys.
Applications should not connect to it, but may emit it with `g_signal_emit_by_name()` if they need to control the cursor programmatically. In contrast to [`gtk_tree_view_set_cursor()`](gtktreeview#gtk-tree-view-set-cursor) and [`gtk_tree_view_set_cursor_on_cell()`](gtktreeview#gtk-tree-view-set-cursor-on-cell) when moving horizontally [“move-cursor”](gtktreeview#GtkTreeView-move-cursor) does not reset the current selection.
#### Parameters
| | | |
| --- | --- | --- |
| tree\_view | the object on which the signal is emitted. | |
| step | the granularity of the move, as a [GtkMovementStep](gtk4-standard-enumerations#GtkMovementStep). [`GTK_MOVEMENT_LOGICAL_POSITIONS`](gtk4-standard-enumerations#GTK-MOVEMENT-LOGICAL-POSITIONS:CAPS), [`GTK_MOVEMENT_VISUAL_POSITIONS`](gtk4-standard-enumerations#GTK-MOVEMENT-VISUAL-POSITIONS:CAPS), [`GTK_MOVEMENT_DISPLAY_LINES`](gtk4-standard-enumerations#GTK-MOVEMENT-DISPLAY-LINES:CAPS), [`GTK_MOVEMENT_PAGES`](gtk4-standard-enumerations#GTK-MOVEMENT-PAGES:CAPS) and [`GTK_MOVEMENT_BUFFER_ENDS`](gtk4-standard-enumerations#GTK-MOVEMENT-BUFFER-ENDS:CAPS) are supported. [`GTK_MOVEMENT_LOGICAL_POSITIONS`](gtk4-standard-enumerations#GTK-MOVEMENT-LOGICAL-POSITIONS:CAPS) and [`GTK_MOVEMENT_VISUAL_POSITIONS`](gtk4-standard-enumerations#GTK-MOVEMENT-VISUAL-POSITIONS:CAPS) are treated identically. | |
| direction | the direction to move: +1 to move forwards; -1 to move backwards. The resulting movement is undefined for all other values. | |
| extend | whether to extend the selection | |
| modify | whether to modify the selection | |
| user\_data | user data set when the signal handler was connected. | |
#### Returns
`TRUE` if *`step`* is supported, `FALSE` otherwise.
Flags: Action
### The `“row-activated”` signal
```
void
user_function ([GtkTreeView](gtktreeview#GtkTreeView-struct) *tree_view,
[GtkTreePath](gtktreemodel#GtkTreePath-struct) *path,
[GtkTreeViewColumn](gtktreeviewcolumn#GtkTreeViewColumn-struct) *column,
gpointer user_data)
```
The "row-activated" signal is emitted when the method [`gtk_tree_view_row_activated()`](gtktreeview#gtk-tree-view-row-activated) is called, when the user double clicks a treeview row with the "activate-on-single-click" property set to `FALSE`, or when the user single clicks a row when the "activate-on-single-click" property set to `TRUE`. It is also emitted when a non-editable row is selected and one of the keys: Space, Shift+Space, Return or Enter is pressed.
For selection handling refer to the [tree widget conceptual overview](treewidgetobjects#TreeWidget) as well as [GtkTreeSelection](gtktreeselection#GtkTreeSelection-struct).
#### Parameters
| | | |
| --- | --- | --- |
| tree\_view | the object on which the signal is emitted | |
| path | the [GtkTreePath](gtktreemodel#GtkTreePath-struct) for the activated row | |
| column | the [GtkTreeViewColumn](gtktreeviewcolumn#GtkTreeViewColumn-struct) in which the activation occurred | |
| user\_data | user data set when the signal handler was connected. | |
Flags: Action
### The `“row-collapsed”` signal
```
void
user_function ([GtkTreeView](gtktreeview#GtkTreeView-struct) *tree_view,
[GtkTreeIter](gtktreemodel#GtkTreeIter-struct) *iter,
[GtkTreePath](gtktreemodel#GtkTreePath-struct) *path,
gpointer user_data)
```
The given row has been collapsed (child nodes are hidden).
#### Parameters
| | | |
| --- | --- | --- |
| tree\_view | the object on which the signal is emitted | |
| iter | the tree iter of the collapsed row | |
| path | a tree path that points to the row | |
| user\_data | user data set when the signal handler was connected. | |
Flags: Run Last
### The `“row-expanded”` signal
```
void
user_function ([GtkTreeView](gtktreeview#GtkTreeView-struct) *tree_view,
[GtkTreeIter](gtktreemodel#GtkTreeIter-struct) *iter,
[GtkTreePath](gtktreemodel#GtkTreePath-struct) *path,
gpointer user_data)
```
The given row has been expanded (child nodes are shown).
#### Parameters
| | | |
| --- | --- | --- |
| tree\_view | the object on which the signal is emitted | |
| iter | the tree iter of the expanded row | |
| path | a tree path that points to the row | |
| user\_data | user data set when the signal handler was connected. | |
Flags: Run Last
### The `“select-all”` signal
```
gboolean
user_function ([GtkTreeView](gtktreeview#GtkTreeView-struct) *treeview,
gpointer user_data)
```
Flags: Action
### The `“select-cursor-parent”` signal
```
gboolean
user_function ([GtkTreeView](gtktreeview#GtkTreeView-struct) *treeview,
gpointer user_data)
```
Flags: Action
### The `“select-cursor-row”` signal
```
gboolean
user_function ([GtkTreeView](gtktreeview#GtkTreeView-struct) *treeview,
gboolean arg1,
gpointer user_data)
```
Flags: Action
### The `“start-interactive-search”` signal
```
gboolean
user_function ([GtkTreeView](gtktreeview#GtkTreeView-struct) *treeview,
gpointer user_data)
```
Flags: Action
### The `“test-collapse-row”` signal
```
gboolean
user_function ([GtkTreeView](gtktreeview#GtkTreeView-struct) *tree_view,
[GtkTreeIter](gtktreemodel#GtkTreeIter-struct) *iter,
[GtkTreePath](gtktreemodel#GtkTreePath-struct) *path,
gpointer user_data)
```
The given row is about to be collapsed (hide its children nodes). Use this signal if you need to control the collapsibility of individual rows.
#### Parameters
| | | |
| --- | --- | --- |
| tree\_view | the object on which the signal is emitted | |
| iter | the tree iter of the row to collapse | |
| path | a tree path that points to the row | |
| user\_data | user data set when the signal handler was connected. | |
#### Returns
`FALSE` to allow collapsing, `TRUE` to reject
Flags: Run Last
### The `“test-expand-row”` signal
```
gboolean
user_function ([GtkTreeView](gtktreeview#GtkTreeView-struct) *tree_view,
[GtkTreeIter](gtktreemodel#GtkTreeIter-struct) *iter,
[GtkTreePath](gtktreemodel#GtkTreePath-struct) *path,
gpointer user_data)
```
The given row is about to be expanded (show its children nodes). Use this signal if you need to control the expandability of individual rows.
#### Parameters
| | | |
| --- | --- | --- |
| tree\_view | the object on which the signal is emitted | |
| iter | the tree iter of the row to expand | |
| path | a tree path that points to the row | |
| user\_data | user data set when the signal handler was connected. | |
#### Returns
`FALSE` to allow expansion, `TRUE` to reject
Flags: Run Last
### The `“toggle-cursor-row”` signal
```
gboolean
user_function ([GtkTreeView](gtktreeview#GtkTreeView-struct) *treeview,
gpointer user_data)
```
Flags: Action
### The `“unselect-all”` signal
```
gboolean
user_function ([GtkTreeView](gtktreeview#GtkTreeView-struct) *treeview,
gpointer user_data)
```
Flags: Action
See Also
--------
[GtkTreeViewColumn](gtktreeviewcolumn#GtkTreeViewColumn-struct), [GtkTreeSelection](gtktreeselection#GtkTreeSelection-struct), [GtkTreeModel](gtktreemodel#GtkTreeModel-struct), GtkTreeView drag-and-drop, [GtkTreeSortable](gtktreesortable#GtkTreeSortable-struct), [GtkTreeModelSort](gtktreemodelsort#GtkTreeModelSort-struct), [GtkListStore](gtkliststore#GtkListStore-struct), [GtkTreeStore](gtktreestore#GtkTreeStore-struct), [GtkCellRenderer](gtkcellrenderer#GtkCellRenderer-struct), [GtkCellEditable](gtkcelleditable#GtkCellEditable-struct), [GtkCellRendererPixbuf](gtkcellrendererpixbuf#GtkCellRendererPixbuf-struct), [GtkCellRendererText](gtkcellrenderertext#GtkCellRendererText-struct), [GtkCellRendererToggle](gtkcellrenderertoggle#GtkCellRendererToggle-struct)
| programming_docs |
gtk GtkEventControllerMotion GtkEventControllerMotion
========================
GtkEventControllerMotion — Event controller for motion events
Functions
---------
| | |
| --- | --- |
| [GtkEventController](gtkeventcontroller#GtkEventController-struct) \* | [gtk\_event\_controller\_motion\_new](gtkeventcontrollermotion#gtk-event-controller-motion-new) () |
| gboolean | [gtk\_event\_controller\_motion\_contains\_pointer](gtkeventcontrollermotion#gtk-event-controller-motion-contains-pointer) () |
| gboolean | [gtk\_event\_controller\_motion\_is\_pointer](gtkeventcontrollermotion#gtk-event-controller-motion-is-pointer) () |
Properties
----------
| | | |
| --- | --- | --- |
| gboolean | [contains-pointer](gtkeventcontrollermotion#GtkEventControllerMotion--contains-pointer) | Read |
| gboolean | [is-pointer](gtkeventcontrollermotion#GtkEventControllerMotion--is-pointer) | Read |
Signals
-------
| | | |
| --- | --- | --- |
| void | [enter](gtkeventcontrollermotion#GtkEventControllerMotion-enter) | Run Last |
| void | [leave](gtkeventcontrollermotion#GtkEventControllerMotion-leave) | Run Last |
| void | [motion](gtkeventcontrollermotion#GtkEventControllerMotion-motion) | Run First |
Types and Values
----------------
| | |
| --- | --- |
| | [GtkEventControllerMotion](gtkeventcontrollermotion#GtkEventControllerMotion-struct) |
Object Hierarchy
----------------
```
GObject
╰── [GtkEventController](gtkeventcontroller#GtkEventController-struct)
╰── GtkEventControllerMotion
```
Includes
--------
```
#include <gtk/gtk.h>
```
Description
-----------
[GtkEventControllerMotion](gtkeventcontrollermotion#GtkEventControllerMotion-struct) is an event controller meant for situations where you need to track the position of the pointer.
Functions
---------
### gtk\_event\_controller\_motion\_new ()
```
[GtkEventController](gtkeventcontroller#GtkEventController-struct) *
gtk_event_controller_motion_new (*`void`*);
```
Creates a new event controller that will handle motion events.
#### Returns
a new [GtkEventControllerMotion](gtkeventcontrollermotion#GtkEventControllerMotion-struct)
### gtk\_event\_controller\_motion\_contains\_pointer ()
```
gboolean
gtk_event_controller_motion_contains_pointer
(*`[GtkEventControllerMotion](gtkeventcontrollermotion#GtkEventControllerMotion-struct) *self`*);
```
Returns the value of the GtkEventControllerMotion:contains-pointer property.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkEventControllerMotion](gtkeventcontrollermotion#GtkEventControllerMotion-struct) | |
#### Returns
`TRUE` if a pointer is within *`self`* or one of its children
### gtk\_event\_controller\_motion\_is\_pointer ()
```
gboolean
gtk_event_controller_motion_is_pointer
(*`[GtkEventControllerMotion](gtkeventcontrollermotion#GtkEventControllerMotion-struct) *self`*);
```
Returns the value of the GtkEventControllerMotion:is-pointer property.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkEventControllerMotion](gtkeventcontrollermotion#GtkEventControllerMotion-struct) | |
#### Returns
`TRUE` if a pointer is within *`self`* but not one of its children
Types and Values
----------------
### GtkEventControllerMotion
```
typedef struct _GtkEventControllerMotion GtkEventControllerMotion;
```
Property Details
----------------
### The `“contains-pointer”` property
```
“contains-pointer” gboolean
```
Whether the pointer is in the controllers widget or a descendant. See also [“is-pointer”](gtkeventcontrollermotion#GtkEventControllerMotion--is-pointer).
When handling crossing events, this property is updated before [“enter”](gtkeventcontrollermotion#GtkEventControllerMotion-enter) but after [“leave”](gtkeventcontrollermotion#GtkEventControllerMotion-leave) is emitted.
Owner: GtkEventControllerMotion
Flags: Read
Default value: FALSE
### The `“is-pointer”` property
```
“is-pointer” gboolean
```
Whether the pointer is in the controllers widget itself, as opposed to in a descendent widget. See also [“contains-pointer”](gtkeventcontrollermotion#GtkEventControllerMotion--contains-pointer).
When handling crossing events, this property is updated before [“enter”](gtkeventcontrollermotion#GtkEventControllerMotion-enter) but after [“leave”](gtkeventcontrollermotion#GtkEventControllerMotion-leave) is emitted.
Owner: GtkEventControllerMotion
Flags: Read
Default value: FALSE
Signal Details
--------------
### The `“enter”` signal
```
void
user_function ([GtkEventControllerMotion](gtkeventcontrollermotion#GtkEventControllerMotion-struct) *controller,
double x,
double y,
gpointer user_data)
```
Signals that the pointer has entered the widget.
#### Parameters
| | | |
| --- | --- | --- |
| controller | the object which received the signal | |
| x | coordinates of pointer location | |
| y | coordinates of pointer location | |
| user\_data | user data set when the signal handler was connected. | |
Flags: Run Last
### The `“leave”` signal
```
void
user_function ([GtkEventControllerMotion](gtkeventcontrollermotion#GtkEventControllerMotion-struct) *controller,
gpointer user_data)
```
Signals that the pointer has left the widget.
#### Parameters
| | | |
| --- | --- | --- |
| controller | the object which received the signal | |
| user\_data | user data set when the signal handler was connected. | |
Flags: Run Last
### The `“motion”` signal
```
void
user_function ([GtkEventControllerMotion](gtkeventcontrollermotion#GtkEventControllerMotion-struct) *controller,
double x,
double y,
gpointer user_data)
```
Emitted when the pointer moves inside the widget.
#### Parameters
| | | |
| --- | --- | --- |
| controller | The object that received the signal | |
| x | the x coordinate | |
| y | the y coordinate | |
| user\_data | user data set when the signal handler was connected. | |
Flags: Run First
See Also
--------
[GtkEventController](gtkeventcontroller#GtkEventController-struct)
gtk GtkCellRenderer GtkCellRenderer
===============
GtkCellRenderer — An object for rendering a single cell
Functions
---------
| | |
| --- | --- |
| void | [gtk\_cell\_renderer\_get\_aligned\_area](gtkcellrenderer#gtk-cell-renderer-get-aligned-area) () |
| void | [gtk\_cell\_renderer\_snapshot](gtkcellrenderer#gtk-cell-renderer-snapshot) () |
| gboolean | [gtk\_cell\_renderer\_activate](gtkcellrenderer#gtk-cell-renderer-activate) () |
| [GtkCellEditable](gtkcelleditable#GtkCellEditable-struct) \* | [gtk\_cell\_renderer\_start\_editing](gtkcellrenderer#gtk-cell-renderer-start-editing) () |
| void | [gtk\_cell\_renderer\_stop\_editing](gtkcellrenderer#gtk-cell-renderer-stop-editing) () |
| void | [gtk\_cell\_renderer\_get\_fixed\_size](gtkcellrenderer#gtk-cell-renderer-get-fixed-size) () |
| void | [gtk\_cell\_renderer\_set\_fixed\_size](gtkcellrenderer#gtk-cell-renderer-set-fixed-size) () |
| gboolean | [gtk\_cell\_renderer\_get\_visible](gtkcellrenderer#gtk-cell-renderer-get-visible) () |
| void | [gtk\_cell\_renderer\_set\_visible](gtkcellrenderer#gtk-cell-renderer-set-visible) () |
| gboolean | [gtk\_cell\_renderer\_get\_sensitive](gtkcellrenderer#gtk-cell-renderer-get-sensitive) () |
| void | [gtk\_cell\_renderer\_set\_sensitive](gtkcellrenderer#gtk-cell-renderer-set-sensitive) () |
| void | [gtk\_cell\_renderer\_get\_alignment](gtkcellrenderer#gtk-cell-renderer-get-alignment) () |
| void | [gtk\_cell\_renderer\_set\_alignment](gtkcellrenderer#gtk-cell-renderer-set-alignment) () |
| void | [gtk\_cell\_renderer\_get\_padding](gtkcellrenderer#gtk-cell-renderer-get-padding) () |
| void | [gtk\_cell\_renderer\_set\_padding](gtkcellrenderer#gtk-cell-renderer-set-padding) () |
| [GtkStateFlags](gtk4-standard-enumerations#GtkStateFlags) | [gtk\_cell\_renderer\_get\_state](gtkcellrenderer#gtk-cell-renderer-get-state) () |
| gboolean | [gtk\_cell\_renderer\_is\_activatable](gtkcellrenderer#gtk-cell-renderer-is-activatable) () |
| gboolean | [gtk\_cell\_renderer\_get\_is\_expanded](gtkcellrenderer#gtk-cell-renderer-get-is-expanded) () |
| gboolean | [gtk\_cell\_renderer\_get\_is\_expander](gtkcellrenderer#gtk-cell-renderer-get-is-expander) () |
| void | [gtk\_cell\_renderer\_set\_is\_expanded](gtkcellrenderer#gtk-cell-renderer-set-is-expanded) () |
| void | [gtk\_cell\_renderer\_set\_is\_expander](gtkcellrenderer#gtk-cell-renderer-set-is-expander) () |
| void | [gtk\_cell\_renderer\_get\_preferred\_height](gtkcellrenderer#gtk-cell-renderer-get-preferred-height) () |
| void | [gtk\_cell\_renderer\_get\_preferred\_height\_for\_width](gtkcellrenderer#gtk-cell-renderer-get-preferred-height-for-width) () |
| void | [gtk\_cell\_renderer\_get\_preferred\_size](gtkcellrenderer#gtk-cell-renderer-get-preferred-size) () |
| void | [gtk\_cell\_renderer\_get\_preferred\_width](gtkcellrenderer#gtk-cell-renderer-get-preferred-width) () |
| void | [gtk\_cell\_renderer\_get\_preferred\_width\_for\_height](gtkcellrenderer#gtk-cell-renderer-get-preferred-width-for-height) () |
| [GtkSizeRequestMode](gtkwidget#GtkSizeRequestMode) | [gtk\_cell\_renderer\_get\_request\_mode](gtkcellrenderer#gtk-cell-renderer-get-request-mode) () |
Properties
----------
| | | |
| --- | --- | --- |
| char \* | [cell-background](gtkcellrenderer#GtkCellRenderer--cell-background) | Write |
| [GdkRGBA](https://developer-old.gnome.org/gtk4/html/gdk4-RGBA-Colors.html#GdkRGBA-struct) \* | [cell-background-rgba](gtkcellrenderer#GtkCellRenderer--cell-background-rgba) | Read / Write |
| gboolean | [cell-background-set](gtkcellrenderer#GtkCellRenderer--cell-background-set) | Read / Write |
| gboolean | [editing](gtkcellrenderer#GtkCellRenderer--editing) | Read |
| int | [height](gtkcellrenderer#GtkCellRenderer--height) | Read / Write |
| gboolean | [is-expanded](gtkcellrenderer#GtkCellRenderer--is-expanded) | Read / Write |
| gboolean | [is-expander](gtkcellrenderer#GtkCellRenderer--is-expander) | Read / Write |
| [GtkCellRendererMode](gtkcellrenderer#GtkCellRendererMode) | [mode](gtkcellrenderer#GtkCellRenderer--mode) | Read / Write |
| gboolean | [sensitive](gtkcellrenderer#GtkCellRenderer--sensitive) | Read / Write |
| gboolean | [visible](gtkcellrenderer#GtkCellRenderer--visible) | Read / Write |
| int | [width](gtkcellrenderer#GtkCellRenderer--width) | Read / Write |
| float | [xalign](gtkcellrenderer#GtkCellRenderer--xalign) | Read / Write |
| guint | [xpad](gtkcellrenderer#GtkCellRenderer--xpad) | Read / Write |
| float | [yalign](gtkcellrenderer#GtkCellRenderer--yalign) | Read / Write |
| guint | [ypad](gtkcellrenderer#GtkCellRenderer--ypad) | Read / Write |
Signals
-------
| | | |
| --- | --- | --- |
| void | [editing-canceled](gtkcellrenderer#GtkCellRenderer-editing-canceled) | Run First |
| void | [editing-started](gtkcellrenderer#GtkCellRenderer-editing-started) | Run First |
Types and Values
----------------
| | |
| --- | --- |
| enum | [GtkCellRendererState](gtkcellrenderer#GtkCellRendererState) |
| enum | [GtkCellRendererMode](gtkcellrenderer#GtkCellRendererMode) |
| struct | [GtkCellRenderer](gtkcellrenderer#GtkCellRenderer-struct) |
| struct | [GtkCellRendererClass](gtkcellrenderer#GtkCellRendererClass) |
Object Hierarchy
----------------
```
GObject
╰── GInitiallyUnowned
╰── GtkCellRenderer
├── [GtkCellRendererText](gtkcellrenderertext#GtkCellRendererText-struct)
├── [GtkCellRendererPixbuf](gtkcellrendererpixbuf#GtkCellRendererPixbuf-struct)
├── [GtkCellRendererProgress](gtkcellrendererprogress#GtkCellRendererProgress-struct)
├── [GtkCellRendererSpinner](gtkcellrendererspinner#GtkCellRendererSpinner-struct)
╰── [GtkCellRendererToggle](gtkcellrenderertoggle#GtkCellRendererToggle-struct)
```
Includes
--------
```
#include <gtk/gtk.h>
```
Description
-----------
The [GtkCellRenderer](gtkcellrenderer#GtkCellRenderer-struct) is a base class of a set of objects used for rendering a cell to a [cairo\_t](https://developer-old.gnome.org/cairo/stable/cairo-cairo-t.html#cairo-t). These objects are used primarily by the [GtkTreeView](gtktreeview#GtkTreeView-struct) widget, though they aren’t tied to them in any specific way. It is worth noting that [GtkCellRenderer](gtkcellrenderer#GtkCellRenderer-struct) is not a [GtkWidget](gtkwidget#GtkWidget-struct) and cannot be treated as such.
The primary use of a [GtkCellRenderer](gtkcellrenderer#GtkCellRenderer-struct) is for drawing a certain graphical elements on a [cairo\_t](https://developer-old.gnome.org/cairo/stable/cairo-cairo-t.html#cairo-t). Typically, one cell renderer is used to draw many cells on the screen. To this extent, it isn’t expected that a CellRenderer keep any permanent state around. Instead, any state is set just prior to use using GObjects property system. Then, the cell is measured using [`gtk_cell_renderer_get_preferred_size()`](gtkcellrenderer#gtk-cell-renderer-get-preferred-size). Finally, the cell is rendered in the correct location using [`gtk_cell_renderer_snapshot()`](gtkcellrenderer#gtk-cell-renderer-snapshot).
There are a number of rules that must be followed when writing a new [GtkCellRenderer](gtkcellrenderer#GtkCellRenderer-struct). First and foremost, it’s important that a certain set of properties will always yield a cell renderer of the same size, barring a style change. The [GtkCellRenderer](gtkcellrenderer#GtkCellRenderer-struct) also has a number of generic properties that are expected to be honored by all children.
Beyond merely rendering a cell, cell renderers can optionally provide active user interface elements. A cell renderer can be “activatable” like [GtkCellRendererToggle](gtkcellrenderertoggle#GtkCellRendererToggle-struct), which toggles when it gets activated by a mouse click, or it can be “editable” like [GtkCellRendererText](gtkcellrenderertext#GtkCellRendererText-struct), which allows the user to edit the text using a widget implementing the [GtkCellEditable](gtkcelleditable#GtkCellEditable-struct) interface, e.g. [GtkEntry](gtkentry#GtkEntry-struct). To make a cell renderer activatable or editable, you have to implement the [GtkCellRendererClass.activate](gtkcellrenderer#GtkCellRendererClass.activate) or [GtkCellRendererClass.start\_editing](gtkcellrenderer#GtkCellRendererClass.start-editing) virtual functions, respectively.
Many properties of [GtkCellRenderer](gtkcellrenderer#GtkCellRenderer-struct) and its subclasses have a corresponding “set” property, e.g. “cell-background-set” corresponds to “cell-background”. These “set” properties reflect whether a property has been set or not. You should not set them independently.
Functions
---------
### gtk\_cell\_renderer\_get\_aligned\_area ()
```
void
gtk_cell_renderer_get_aligned_area (*`[GtkCellRenderer](gtkcellrenderer#GtkCellRenderer-struct) *cell`*,
*`[GtkWidget](gtkwidget#GtkWidget-struct) *widget`*,
*`[GtkCellRendererState](gtkcellrenderer#GtkCellRendererState) flags`*,
*`const [GdkRectangle](https://developer-old.gnome.org/gtk4/html/gdk4-Rectangles-and-Regions.html#GdkRectangle-struct) *cell_area`*,
*`[GdkRectangle](https://developer-old.gnome.org/gtk4/html/gdk4-Rectangles-and-Regions.html#GdkRectangle-struct) *aligned_area`*);
```
Gets the aligned area used by *`cell`* inside *`cell_area`* . Used for finding the appropriate edit and focus rectangle.
#### Parameters
| | | |
| --- | --- | --- |
| cell | a [GtkCellRenderer](gtkcellrenderer#GtkCellRenderer-struct) instance | |
| widget | the [GtkWidget](gtkwidget#GtkWidget-struct) this cell will be rendering to | |
| flags | render flags | |
| cell\_area | cell area which would be passed to `gtk_cell_renderer_render()` | |
| aligned\_area | the return location for the space inside *`cell_area`* that would actually be used to render. | [out] |
### gtk\_cell\_renderer\_snapshot ()
```
void
gtk_cell_renderer_snapshot (*`[GtkCellRenderer](gtkcellrenderer#GtkCellRenderer-struct) *cell`*,
*`[GtkSnapshot](gtksnapshot#GtkSnapshot) *snapshot`*,
*`[GtkWidget](gtkwidget#GtkWidget-struct) *widget`*,
*`const [GdkRectangle](https://developer-old.gnome.org/gtk4/html/gdk4-Rectangles-and-Regions.html#GdkRectangle-struct) *background_area`*,
*`const [GdkRectangle](https://developer-old.gnome.org/gtk4/html/gdk4-Rectangles-and-Regions.html#GdkRectangle-struct) *cell_area`*,
*`[GtkCellRendererState](gtkcellrenderer#GtkCellRendererState) flags`*);
```
Invokes the virtual render function of the [GtkCellRenderer](gtkcellrenderer#GtkCellRenderer-struct). The three passed-in rectangles are areas in *`cr`* . Most renderers will draw within *`cell_area`* ; the xalign, yalign, xpad, and ypad fields of the [GtkCellRenderer](gtkcellrenderer#GtkCellRenderer-struct) should be honored with respect to *`cell_area`* . *`background_area`* includes the blank space around the cell, and also the area containing the tree expander; so the *`background_area`* rectangles for all cells tile to cover the entire *`window`* .
#### Parameters
| | | |
| --- | --- | --- |
| cell | a [GtkCellRenderer](gtkcellrenderer#GtkCellRenderer-struct) | |
| snapshot | a [GtkSnapshot](gtksnapshot#GtkSnapshot) to draw to | |
| widget | the widget owning *`window`* | |
| background\_area | entire cell area (including tree expanders and maybe padding on the sides) | |
| cell\_area | area normally rendered by a cell renderer | |
| flags | flags that affect rendering | |
### gtk\_cell\_renderer\_activate ()
```
gboolean
gtk_cell_renderer_activate (*`[GtkCellRenderer](gtkcellrenderer#GtkCellRenderer-struct) *cell`*,
*`[GdkEvent](https://developer-old.gnome.org/gtk4/html/gdk4-Events.html#GdkEvent-struct) *event`*,
*`[GtkWidget](gtkwidget#GtkWidget-struct) *widget`*,
*`const char *path`*,
*`const [GdkRectangle](https://developer-old.gnome.org/gtk4/html/gdk4-Rectangles-and-Regions.html#GdkRectangle-struct) *background_area`*,
*`const [GdkRectangle](https://developer-old.gnome.org/gtk4/html/gdk4-Rectangles-and-Regions.html#GdkRectangle-struct) *cell_area`*,
*`[GtkCellRendererState](gtkcellrenderer#GtkCellRendererState) flags`*);
```
Passes an activate event to the cell renderer for possible processing. Some cell renderers may use events; for example, [GtkCellRendererToggle](gtkcellrenderertoggle#GtkCellRendererToggle-struct) toggles when it gets a mouse click.
#### Parameters
| | | |
| --- | --- | --- |
| cell | a [GtkCellRenderer](gtkcellrenderer#GtkCellRenderer-struct) | |
| event | a [GdkEvent](https://developer-old.gnome.org/gtk4/html/gdk4-Events.html#GdkEvent-struct) | |
| widget | widget that received the event | |
| path | widget-dependent string representation of the event location; e.g. for [GtkTreeView](gtktreeview#GtkTreeView-struct), a string representation of [GtkTreePath](gtktreemodel#GtkTreePath-struct) | |
| background\_area | background area as passed to `gtk_cell_renderer_render()` | |
| cell\_area | cell area as passed to `gtk_cell_renderer_render()` | |
| flags | render flags | |
#### Returns
`TRUE` if the event was consumed/handled
### gtk\_cell\_renderer\_start\_editing ()
```
[GtkCellEditable](gtkcelleditable#GtkCellEditable-struct) *
gtk_cell_renderer_start_editing (*`[GtkCellRenderer](gtkcellrenderer#GtkCellRenderer-struct) *cell`*,
*`[GdkEvent](https://developer-old.gnome.org/gtk4/html/gdk4-Events.html#GdkEvent-struct) *event`*,
*`[GtkWidget](gtkwidget#GtkWidget-struct) *widget`*,
*`const char *path`*,
*`const [GdkRectangle](https://developer-old.gnome.org/gtk4/html/gdk4-Rectangles-and-Regions.html#GdkRectangle-struct) *background_area`*,
*`const [GdkRectangle](https://developer-old.gnome.org/gtk4/html/gdk4-Rectangles-and-Regions.html#GdkRectangle-struct) *cell_area`*,
*`[GtkCellRendererState](gtkcellrenderer#GtkCellRendererState) flags`*);
```
Starts editing the contents of this *`cell`* , through a new [GtkCellEditable](gtkcelleditable#GtkCellEditable-struct) widget created by the [GtkCellRendererClass.start\_editing](gtkcellrenderer#GtkCellRendererClass.start-editing) virtual function.
#### Parameters
| | | |
| --- | --- | --- |
| cell | a [GtkCellRenderer](gtkcellrenderer#GtkCellRenderer-struct) | |
| event | a [GdkEvent](https://developer-old.gnome.org/gtk4/html/gdk4-Events.html#GdkEvent-struct). | [nullable] |
| widget | widget that received the event | |
| path | widget-dependent string representation of the event location; e.g. for [GtkTreeView](gtktreeview#GtkTreeView-struct), a string representation of [GtkTreePath](gtktreemodel#GtkTreePath-struct) | |
| background\_area | background area as passed to `gtk_cell_renderer_render()` | |
| cell\_area | cell area as passed to `gtk_cell_renderer_render()` | |
| flags | render flags | |
#### Returns
A new [GtkCellEditable](gtkcelleditable#GtkCellEditable-struct) for editing this *`cell`* , or `NULL` if editing is not possible.
[nullable][transfer none]
### gtk\_cell\_renderer\_stop\_editing ()
```
void
gtk_cell_renderer_stop_editing (*`[GtkCellRenderer](gtkcellrenderer#GtkCellRenderer-struct) *cell`*,
*`gboolean canceled`*);
```
Informs the cell renderer that the editing is stopped. If *`canceled`* is `TRUE`, the cell renderer will emit the [“editing-canceled”](gtkcellrenderer#GtkCellRenderer-editing-canceled) signal.
This function should be called by cell renderer implementations in response to the [“editing-done”](gtkcelleditable#GtkCellEditable-editing-done) signal of [GtkCellEditable](gtkcelleditable#GtkCellEditable-struct).
#### Parameters
| | | |
| --- | --- | --- |
| cell | A [GtkCellRenderer](gtkcellrenderer#GtkCellRenderer-struct) | |
| canceled | `TRUE` if the editing has been canceled | |
### gtk\_cell\_renderer\_get\_fixed\_size ()
```
void
gtk_cell_renderer_get_fixed_size (*`[GtkCellRenderer](gtkcellrenderer#GtkCellRenderer-struct) *cell`*,
*`int *width`*,
*`int *height`*);
```
Fills in *`width`* and *`height`* with the appropriate size of *`cell`* .
#### Parameters
| | | |
| --- | --- | --- |
| cell | A [GtkCellRenderer](gtkcellrenderer#GtkCellRenderer-struct) | |
| width | location to fill in with the fixed width of the cell, or `NULL`. | [out][allow-none] |
| height | location to fill in with the fixed height of the cell, or `NULL`. | [out][allow-none] |
### gtk\_cell\_renderer\_set\_fixed\_size ()
```
void
gtk_cell_renderer_set_fixed_size (*`[GtkCellRenderer](gtkcellrenderer#GtkCellRenderer-struct) *cell`*,
*`int width`*,
*`int height`*);
```
Sets the renderer size to be explicit, independent of the properties set.
#### Parameters
| | | |
| --- | --- | --- |
| cell | A [GtkCellRenderer](gtkcellrenderer#GtkCellRenderer-struct) | |
| width | the width of the cell renderer, or -1 | |
| height | the height of the cell renderer, or -1 | |
### gtk\_cell\_renderer\_get\_visible ()
```
gboolean
gtk_cell_renderer_get_visible (*`[GtkCellRenderer](gtkcellrenderer#GtkCellRenderer-struct) *cell`*);
```
Returns the cell renderer’s visibility.
#### Parameters
| | | |
| --- | --- | --- |
| cell | A [GtkCellRenderer](gtkcellrenderer#GtkCellRenderer-struct) | |
#### Returns
`TRUE` if the cell renderer is visible
### gtk\_cell\_renderer\_set\_visible ()
```
void
gtk_cell_renderer_set_visible (*`[GtkCellRenderer](gtkcellrenderer#GtkCellRenderer-struct) *cell`*,
*`gboolean visible`*);
```
Sets the cell renderer’s visibility.
#### Parameters
| | | |
| --- | --- | --- |
| cell | A [GtkCellRenderer](gtkcellrenderer#GtkCellRenderer-struct) | |
| visible | the visibility of the cell | |
### gtk\_cell\_renderer\_get\_sensitive ()
```
gboolean
gtk_cell_renderer_get_sensitive (*`[GtkCellRenderer](gtkcellrenderer#GtkCellRenderer-struct) *cell`*);
```
Returns the cell renderer’s sensitivity.
#### Parameters
| | | |
| --- | --- | --- |
| cell | A [GtkCellRenderer](gtkcellrenderer#GtkCellRenderer-struct) | |
#### Returns
`TRUE` if the cell renderer is sensitive
### gtk\_cell\_renderer\_set\_sensitive ()
```
void
gtk_cell_renderer_set_sensitive (*`[GtkCellRenderer](gtkcellrenderer#GtkCellRenderer-struct) *cell`*,
*`gboolean sensitive`*);
```
Sets the cell renderer’s sensitivity.
#### Parameters
| | | |
| --- | --- | --- |
| cell | A [GtkCellRenderer](gtkcellrenderer#GtkCellRenderer-struct) | |
| sensitive | the sensitivity of the cell | |
### gtk\_cell\_renderer\_get\_alignment ()
```
void
gtk_cell_renderer_get_alignment (*`[GtkCellRenderer](gtkcellrenderer#GtkCellRenderer-struct) *cell`*,
*`float *xalign`*,
*`float *yalign`*);
```
Fills in *`xalign`* and *`yalign`* with the appropriate values of *`cell`* .
#### Parameters
| | | |
| --- | --- | --- |
| cell | A [GtkCellRenderer](gtkcellrenderer#GtkCellRenderer-struct) | |
| xalign | location to fill in with the x alignment of the cell, or `NULL`. | [out][allow-none] |
| yalign | location to fill in with the y alignment of the cell, or `NULL`. | [out][allow-none] |
### gtk\_cell\_renderer\_set\_alignment ()
```
void
gtk_cell_renderer_set_alignment (*`[GtkCellRenderer](gtkcellrenderer#GtkCellRenderer-struct) *cell`*,
*`float xalign`*,
*`float yalign`*);
```
Sets the renderer’s alignment within its available space.
#### Parameters
| | | |
| --- | --- | --- |
| cell | A [GtkCellRenderer](gtkcellrenderer#GtkCellRenderer-struct) | |
| xalign | the x alignment of the cell renderer | |
| yalign | the y alignment of the cell renderer | |
### gtk\_cell\_renderer\_get\_padding ()
```
void
gtk_cell_renderer_get_padding (*`[GtkCellRenderer](gtkcellrenderer#GtkCellRenderer-struct) *cell`*,
*`int *xpad`*,
*`int *ypad`*);
```
Fills in *`xpad`* and *`ypad`* with the appropriate values of *`cell`* .
#### Parameters
| | | |
| --- | --- | --- |
| cell | A [GtkCellRenderer](gtkcellrenderer#GtkCellRenderer-struct) | |
| xpad | location to fill in with the x padding of the cell, or `NULL`. | [out][allow-none] |
| ypad | location to fill in with the y padding of the cell, or `NULL`. | [out][allow-none] |
### gtk\_cell\_renderer\_set\_padding ()
```
void
gtk_cell_renderer_set_padding (*`[GtkCellRenderer](gtkcellrenderer#GtkCellRenderer-struct) *cell`*,
*`int xpad`*,
*`int ypad`*);
```
Sets the renderer’s padding.
#### Parameters
| | | |
| --- | --- | --- |
| cell | A [GtkCellRenderer](gtkcellrenderer#GtkCellRenderer-struct) | |
| xpad | the x padding of the cell renderer | |
| ypad | the y padding of the cell renderer | |
### gtk\_cell\_renderer\_get\_state ()
```
[GtkStateFlags](gtk4-standard-enumerations#GtkStateFlags)
gtk_cell_renderer_get_state (*`[GtkCellRenderer](gtkcellrenderer#GtkCellRenderer-struct) *cell`*,
*`[GtkWidget](gtkwidget#GtkWidget-struct) *widget`*,
*`[GtkCellRendererState](gtkcellrenderer#GtkCellRendererState) cell_state`*);
```
Translates the cell renderer state to [GtkStateFlags](gtk4-standard-enumerations#GtkStateFlags), based on the cell renderer and widget sensitivity, and the given [GtkCellRendererState](gtkcellrenderer#GtkCellRendererState).
#### Parameters
| | | |
| --- | --- | --- |
| cell | a [GtkCellRenderer](gtkcellrenderer#GtkCellRenderer-struct), or `NULL`. | [nullable] |
| widget | a [GtkWidget](gtkwidget#GtkWidget-struct), or `NULL`. | [nullable] |
| cell\_state | cell renderer state | |
#### Returns
the widget state flags applying to *`cell`*
### gtk\_cell\_renderer\_is\_activatable ()
```
gboolean
gtk_cell_renderer_is_activatable (*`[GtkCellRenderer](gtkcellrenderer#GtkCellRenderer-struct) *cell`*);
```
Checks whether the cell renderer can do something when activated.
#### Parameters
| | | |
| --- | --- | --- |
| cell | A [GtkCellRenderer](gtkcellrenderer#GtkCellRenderer-struct) | |
#### Returns
`TRUE` if the cell renderer can do anything when activated
### gtk\_cell\_renderer\_get\_is\_expanded ()
```
gboolean
gtk_cell_renderer_get_is_expanded (*`[GtkCellRenderer](gtkcellrenderer#GtkCellRenderer-struct) *cell`*);
```
Checks whether the given [GtkCellRenderer](gtkcellrenderer#GtkCellRenderer-struct) is expanded.
#### Parameters
| | | |
| --- | --- | --- |
| cell | a [GtkCellRenderer](gtkcellrenderer#GtkCellRenderer-struct) | |
#### Returns
`TRUE` if the cell renderer is expanded
### gtk\_cell\_renderer\_get\_is\_expander ()
```
gboolean
gtk_cell_renderer_get_is_expander (*`[GtkCellRenderer](gtkcellrenderer#GtkCellRenderer-struct) *cell`*);
```
Checks whether the given [GtkCellRenderer](gtkcellrenderer#GtkCellRenderer-struct) is an expander.
#### Parameters
| | | |
| --- | --- | --- |
| cell | a [GtkCellRenderer](gtkcellrenderer#GtkCellRenderer-struct) | |
#### Returns
`TRUE` if *`cell`* is an expander, and `FALSE` otherwise
### gtk\_cell\_renderer\_set\_is\_expanded ()
```
void
gtk_cell_renderer_set_is_expanded (*`[GtkCellRenderer](gtkcellrenderer#GtkCellRenderer-struct) *cell`*,
*`gboolean is_expanded`*);
```
Sets whether the given [GtkCellRenderer](gtkcellrenderer#GtkCellRenderer-struct) is expanded.
#### Parameters
| | | |
| --- | --- | --- |
| cell | a [GtkCellRenderer](gtkcellrenderer#GtkCellRenderer-struct) | |
| is\_expanded | whether *`cell`* should be expanded | |
### gtk\_cell\_renderer\_set\_is\_expander ()
```
void
gtk_cell_renderer_set_is_expander (*`[GtkCellRenderer](gtkcellrenderer#GtkCellRenderer-struct) *cell`*,
*`gboolean is_expander`*);
```
Sets whether the given [GtkCellRenderer](gtkcellrenderer#GtkCellRenderer-struct) is an expander.
#### Parameters
| | | |
| --- | --- | --- |
| cell | a [GtkCellRenderer](gtkcellrenderer#GtkCellRenderer-struct) | |
| is\_expander | whether *`cell`* is an expander | |
### gtk\_cell\_renderer\_get\_preferred\_height ()
```
void
gtk_cell_renderer_get_preferred_height
(*`[GtkCellRenderer](gtkcellrenderer#GtkCellRenderer-struct) *cell`*,
*`[GtkWidget](gtkwidget#GtkWidget-struct) *widget`*,
*`int *minimum_size`*,
*`int *natural_size`*);
```
Retrieves a renderer’s natural size when rendered to *`widget`* .
#### Parameters
| | | |
| --- | --- | --- |
| cell | a [GtkCellRenderer](gtkcellrenderer#GtkCellRenderer-struct) instance | |
| widget | the [GtkWidget](gtkwidget#GtkWidget-struct) this cell will be rendering to | |
| minimum\_size | location to store the minimum size, or `NULL`. | [out][allow-none] |
| natural\_size | location to store the natural size, or `NULL`. | [out][allow-none] |
### gtk\_cell\_renderer\_get\_preferred\_height\_for\_width ()
```
void
gtk_cell_renderer_get_preferred_height_for_width
(*`[GtkCellRenderer](gtkcellrenderer#GtkCellRenderer-struct) *cell`*,
*`[GtkWidget](gtkwidget#GtkWidget-struct) *widget`*,
*`int width`*,
*`int *minimum_height`*,
*`int *natural_height`*);
```
Retrieves a cell renderers’s minimum and natural height if it were rendered to *`widget`* with the specified *`width`* .
#### Parameters
| | | |
| --- | --- | --- |
| cell | a [GtkCellRenderer](gtkcellrenderer#GtkCellRenderer-struct) instance | |
| widget | the [GtkWidget](gtkwidget#GtkWidget-struct) this cell will be rendering to | |
| width | the size which is available for allocation | |
| minimum\_height | location for storing the minimum size, or `NULL`. | [out][allow-none] |
| natural\_height | location for storing the preferred size, or `NULL`. | [out][allow-none] |
### gtk\_cell\_renderer\_get\_preferred\_size ()
```
void
gtk_cell_renderer_get_preferred_size (*`[GtkCellRenderer](gtkcellrenderer#GtkCellRenderer-struct) *cell`*,
*`[GtkWidget](gtkwidget#GtkWidget-struct) *widget`*,
*`[GtkRequisition](gtkwidget#GtkRequisition) *minimum_size`*,
*`[GtkRequisition](gtkwidget#GtkRequisition) *natural_size`*);
```
Retrieves the minimum and natural size of a cell taking into account the widget’s preference for height-for-width management.
#### Parameters
| | | |
| --- | --- | --- |
| cell | a [GtkCellRenderer](gtkcellrenderer#GtkCellRenderer-struct) instance | |
| widget | the [GtkWidget](gtkwidget#GtkWidget-struct) this cell will be rendering to | |
| minimum\_size | location for storing the minimum size, or `NULL`. | [out][allow-none] |
| natural\_size | location for storing the natural size, or `NULL`. | [out][allow-none] |
### gtk\_cell\_renderer\_get\_preferred\_width ()
```
void
gtk_cell_renderer_get_preferred_width (*`[GtkCellRenderer](gtkcellrenderer#GtkCellRenderer-struct) *cell`*,
*`[GtkWidget](gtkwidget#GtkWidget-struct) *widget`*,
*`int *minimum_size`*,
*`int *natural_size`*);
```
Retrieves a renderer’s natural size when rendered to *`widget`* .
#### Parameters
| | | |
| --- | --- | --- |
| cell | a [GtkCellRenderer](gtkcellrenderer#GtkCellRenderer-struct) instance | |
| widget | the [GtkWidget](gtkwidget#GtkWidget-struct) this cell will be rendering to | |
| minimum\_size | location to store the minimum size, or `NULL`. | [out][allow-none] |
| natural\_size | location to store the natural size, or `NULL`. | [out][allow-none] |
### gtk\_cell\_renderer\_get\_preferred\_width\_for\_height ()
```
void
gtk_cell_renderer_get_preferred_width_for_height
(*`[GtkCellRenderer](gtkcellrenderer#GtkCellRenderer-struct) *cell`*,
*`[GtkWidget](gtkwidget#GtkWidget-struct) *widget`*,
*`int height`*,
*`int *minimum_width`*,
*`int *natural_width`*);
```
Retrieves a cell renderers’s minimum and natural width if it were rendered to *`widget`* with the specified *`height`* .
#### Parameters
| | | |
| --- | --- | --- |
| cell | a [GtkCellRenderer](gtkcellrenderer#GtkCellRenderer-struct) instance | |
| widget | the [GtkWidget](gtkwidget#GtkWidget-struct) this cell will be rendering to | |
| height | the size which is available for allocation | |
| minimum\_width | location for storing the minimum size, or `NULL`. | [out][allow-none] |
| natural\_width | location for storing the preferred size, or `NULL`. | [out][allow-none] |
### gtk\_cell\_renderer\_get\_request\_mode ()
```
[GtkSizeRequestMode](gtkwidget#GtkSizeRequestMode)
gtk_cell_renderer_get_request_mode (*`[GtkCellRenderer](gtkcellrenderer#GtkCellRenderer-struct) *cell`*);
```
Gets whether the cell renderer prefers a height-for-width layout or a width-for-height layout.
#### Parameters
| | | |
| --- | --- | --- |
| cell | a [GtkCellRenderer](gtkcellrenderer#GtkCellRenderer-struct) instance | |
#### Returns
The [GtkSizeRequestMode](gtkwidget#GtkSizeRequestMode) preferred by this renderer.
Types and Values
----------------
### enum GtkCellRendererState
Tells how a cell is to be rendered.
#### Members
| | | |
| --- | --- | --- |
| GTK\_CELL\_RENDERER\_SELECTED | The cell is currently selected, and probably has a selection colored background to render to. | |
| GTK\_CELL\_RENDERER\_PRELIT | The mouse is hovering over the cell. | |
| GTK\_CELL\_RENDERER\_INSENSITIVE | The cell is drawn in an insensitive manner | |
| GTK\_CELL\_RENDERER\_SORTED | The cell is in a sorted row | |
| GTK\_CELL\_RENDERER\_FOCUSED | The cell is in the focus row. | |
| GTK\_CELL\_RENDERER\_EXPANDABLE | The cell is in a row that can be expanded | |
| GTK\_CELL\_RENDERER\_EXPANDED | The cell is in a row that is expanded | |
### enum GtkCellRendererMode
Identifies how the user can interact with a particular cell.
#### Members
| | | |
| --- | --- | --- |
| GTK\_CELL\_RENDERER\_MODE\_INERT | The cell is just for display and cannot be interacted with. Note that this doesn’t mean that eg. the row being drawn can’t be selected -- just that a particular element of it cannot be individually modified. | |
| GTK\_CELL\_RENDERER\_MODE\_ACTIVATABLE | The cell can be clicked. | |
| GTK\_CELL\_RENDERER\_MODE\_EDITABLE | The cell can be edited or otherwise modified. | |
### struct GtkCellRenderer
```
struct GtkCellRenderer;
```
### struct GtkCellRendererClass
```
struct GtkCellRendererClass {
/* vtable - not signals */
GtkSizeRequestMode (* get_request_mode) (GtkCellRenderer *cell);
void (* get_preferred_width) (GtkCellRenderer *cell,
GtkWidget *widget,
int *minimum_size,
int *natural_size);
void (* get_preferred_height_for_width) (GtkCellRenderer *cell,
GtkWidget *widget,
int width,
int *minimum_height,
int *natural_height);
void (* get_preferred_height) (GtkCellRenderer *cell,
GtkWidget *widget,
int *minimum_size,
int *natural_size);
void (* get_preferred_width_for_height) (GtkCellRenderer *cell,
GtkWidget *widget,
int height,
int *minimum_width,
int *natural_width);
void (* get_aligned_area) (GtkCellRenderer *cell,
GtkWidget *widget,
GtkCellRendererState flags,
const GdkRectangle *cell_area,
GdkRectangle *aligned_area);
void (* snapshot) (GtkCellRenderer *cell,
GtkSnapshot *snapshot,
GtkWidget *widget,
const GdkRectangle *background_area,
const GdkRectangle *cell_area,
GtkCellRendererState flags);
gboolean (* activate) (GtkCellRenderer *cell,
GdkEvent *event,
GtkWidget *widget,
const char *path,
const GdkRectangle *background_area,
const GdkRectangle *cell_area,
GtkCellRendererState flags);
GtkCellEditable * (* start_editing) (GtkCellRenderer *cell,
GdkEvent *event,
GtkWidget *widget,
const char *path,
const GdkRectangle *background_area,
const GdkRectangle *cell_area,
GtkCellRendererState flags);
/* Signals */
void (* editing_canceled) (GtkCellRenderer *cell);
void (* editing_started) (GtkCellRenderer *cell,
GtkCellEditable *editable,
const char *path);
};
```
#### Members
| | | |
| --- | --- | --- |
| *`get_request_mode`* () | Called to gets whether the cell renderer prefers a height-for-width layout or a width-for-height layout. | |
| *`get_preferred_width`* () | Called to get a renderer’s natural width. | |
| *`get_preferred_height_for_width`* () | Called to get a renderer’s natural height for width. | |
| *`get_preferred_height`* () | Called to get a renderer’s natural height. | |
| *`get_preferred_width_for_height`* () | Called to get a renderer’s natural width for height. | |
| *`get_aligned_area`* () | Called to get the aligned area used by *`cell`* inside *`cell_area`* . | |
| *`snapshot`* () | Called to snapshot the content of the [GtkCellRenderer](gtkcellrenderer#GtkCellRenderer-struct). | |
| *`activate`* () | Called to activate the content of the [GtkCellRenderer](gtkcellrenderer#GtkCellRenderer-struct). | |
| *`start_editing`* () | Called to initiate editing the content of the [GtkCellRenderer](gtkcellrenderer#GtkCellRenderer-struct). | |
| *`editing_canceled`* () | Signal gets emitted when the user cancels the process of editing a cell. | |
| *`editing_started`* () | Signal gets emitted when a cell starts to be edited. | |
Property Details
----------------
### The `“cell-background”` property
```
“cell-background” char *
```
Cell background color as a string.
Owner: GtkCellRenderer
Flags: Write
Default value: NULL
### The `“cell-background-rgba”` property
```
“cell-background-rgba” [GdkRGBA](https://developer-old.gnome.org/gtk4/html/gdk4-RGBA-Colors.html#GdkRGBA-struct) *
```
Cell background as a [GdkRGBA](https://developer-old.gnome.org/gtk4/html/gdk4-RGBA-Colors.html#GdkRGBA-struct)
Owner: GtkCellRenderer
Flags: Read / Write
### The `“cell-background-set”` property
```
“cell-background-set” gboolean
```
Whether the cell background color is set.
Owner: GtkCellRenderer
Flags: Read / Write
Default value: FALSE
### The `“editing”` property
```
“editing” gboolean
```
Whether the cell renderer is currently in editing mode.
Owner: GtkCellRenderer
Flags: Read
Default value: FALSE
### The `“height”` property
```
“height” int
```
The fixed height.
Owner: GtkCellRenderer
Flags: Read / Write
Allowed values: >= -1
Default value: -1
### The `“is-expanded”` property
```
“is-expanded” gboolean
```
Row is an expander row, and is expanded.
Owner: GtkCellRenderer
Flags: Read / Write
Default value: FALSE
### The `“is-expander”` property
```
“is-expander” gboolean
```
Row has children.
Owner: GtkCellRenderer
Flags: Read / Write
Default value: FALSE
### The `“mode”` property
```
“mode” [GtkCellRendererMode](gtkcellrenderer#GtkCellRendererMode)
```
Editable mode of the CellRenderer.
Owner: GtkCellRenderer
Flags: Read / Write
Default value: GTK\_CELL\_RENDERER\_MODE\_INERT
### The `“sensitive”` property
```
“sensitive” gboolean
```
Display the cell sensitive.
Owner: GtkCellRenderer
Flags: Read / Write
Default value: TRUE
### The `“visible”` property
```
“visible” gboolean
```
Display the cell.
Owner: GtkCellRenderer
Flags: Read / Write
Default value: TRUE
### The `“width”` property
```
“width” int
```
The fixed width.
Owner: GtkCellRenderer
Flags: Read / Write
Allowed values: >= -1
Default value: -1
### The `“xalign”` property
```
“xalign” float
```
The x-align.
Owner: GtkCellRenderer
Flags: Read / Write
Allowed values: [0,1]
Default value: 0.5
### The `“xpad”` property
```
“xpad” guint
```
The xpad.
Owner: GtkCellRenderer
Flags: Read / Write
Default value: 0
### The `“yalign”` property
```
“yalign” float
```
The y-align.
Owner: GtkCellRenderer
Flags: Read / Write
Allowed values: [0,1]
Default value: 0.5
### The `“ypad”` property
```
“ypad” guint
```
The ypad.
Owner: GtkCellRenderer
Flags: Read / Write
Default value: 0
Signal Details
--------------
### The `“editing-canceled”` signal
```
void
user_function ([GtkCellRenderer](gtkcellrenderer#GtkCellRenderer-struct) *renderer,
gpointer user_data)
```
This signal gets emitted when the user cancels the process of editing a cell. For example, an editable cell renderer could be written to cancel editing when the user presses Escape.
See also: [`gtk_cell_renderer_stop_editing()`](gtkcellrenderer#gtk-cell-renderer-stop-editing).
#### Parameters
| | | |
| --- | --- | --- |
| renderer | the object which received the signal | |
| user\_data | user data set when the signal handler was connected. | |
Flags: Run First
### The `“editing-started”` signal
```
void
user_function ([GtkCellRenderer](gtkcellrenderer#GtkCellRenderer-struct) *renderer,
[GtkCellEditable](gtkcelleditable#GtkCellEditable-struct) *editable,
char *path,
gpointer user_data)
```
This signal gets emitted when a cell starts to be edited. The intended use of this signal is to do special setup on *`editable`* , e.g. adding a [GtkEntryCompletion](gtkentrycompletion#GtkEntryCompletion-struct) or setting up additional columns in a [GtkComboBox](gtkcombobox#GtkComboBox-struct).
See [`gtk_cell_editable_start_editing()`](gtkcelleditable#gtk-cell-editable-start-editing) for information on the lifecycle of the *`editable`* and a way to do setup that doesn’t depend on the *`renderer`* .
Note that GTK doesn't guarantee that cell renderers will continue to use the same kind of widget for editing in future releases, therefore you should check the type of *`editable`* before doing any specific setup, as in the following example:
```
static void
text_editing_started (GtkCellRenderer *cell,
GtkCellEditable *editable,
const char *path,
gpointer data)
{
if (GTK_IS_ENTRY (editable))
{
GtkEntry *entry = GTK_ENTRY (editable);
// ... create a GtkEntryCompletion
gtk_entry_set_completion (entry, completion);
}
}
```
| #### Parameters
| | | |
| --- | --- | --- |
| renderer | the object which received the signal | |
| editable | the [GtkCellEditable](gtkcelleditable#GtkCellEditable-struct) | |
| path | the path identifying the edited cell | |
| user\_data | user data set when the signal handler was connected. | |
Flags: Run First
See Also
--------
[GtkCellEditable](gtkcelleditable#GtkCellEditable-struct)
| programming_docs |
gtk gtk4-widget-factory gtk4-widget-factory
===================
gtk4-widget-factory — Demonstrate GTK widgets
Synopsis
--------
`gtk4-widget-factory` [--help]
Description
-----------
**gtk4-widget-factory** is a collection of examples. Its purpose is to demonstrate many GTK widgets in a form that is useful to GTK theme developers.
The application shows widgets in different, typical combinations and states.
Options
-------
The following options are understood:
| | |
| --- | --- |
| `-h`, `--help` | Show help options |
| `--version` | Show program version |
gtk GtkFontChooserWidget GtkFontChooserWidget
====================
GtkFontChooserWidget — A widget for selecting fonts
Functions
---------
| | |
| --- | --- |
| [GtkWidget](gtkwidget#GtkWidget-struct) \* | [gtk\_font\_chooser\_widget\_new](gtkfontchooserwidget#gtk-font-chooser-widget-new) () |
Properties
----------
| | | |
| --- | --- | --- |
| GAction \* | [tweak-action](gtkfontchooserwidget#GtkFontChooserWidget--tweak-action) | Read |
Types and Values
----------------
| | |
| --- | --- |
| | [GtkFontChooserWidget](gtkfontchooserwidget#GtkFontChooserWidget-struct) |
Object Hierarchy
----------------
```
GObject
╰── GInitiallyUnowned
╰── [GtkWidget](gtkwidget#GtkWidget-struct)
╰── GtkFontChooserWidget
```
Implemented Interfaces
----------------------
GtkFontChooserWidget implements [GtkAccessible](gtkaccessible#GtkAccessible-struct), [GtkBuildable](gtkbuildable#GtkBuildable-struct), [GtkConstraintTarget](gtkconstraint#GtkConstraintTarget-struct) and [GtkFontChooser](gtkfontchooser#GtkFontChooser-struct).
Includes
--------
```
#include <gtk/gtk.h>
```
Description
-----------
The [GtkFontChooserWidget](gtkfontchooserwidget#GtkFontChooserWidget-struct) widget lists the available fonts, styles and sizes, allowing the user to select a font. It is used in the [GtkFontChooserDialog](gtkfontchooserdialog#GtkFontChooserDialog-struct) widget to provide a dialog box for selecting fonts.
To set the font which is initially selected, use [`gtk_font_chooser_set_font()`](gtkfontchooser#gtk-font-chooser-set-font) or [`gtk_font_chooser_set_font_desc()`](gtkfontchooser#gtk-font-chooser-set-font-desc).
To get the selected font use [`gtk_font_chooser_get_font()`](gtkfontchooser#gtk-font-chooser-get-font) or [`gtk_font_chooser_get_font_desc()`](gtkfontchooser#gtk-font-chooser-get-font-desc).
To change the text which is shown in the preview area, use [`gtk_font_chooser_set_preview_text()`](gtkfontchooser#gtk-font-chooser-set-preview-text).
### CSS nodes
GtkFontChooserWidget has a single CSS node with name fontchooser.
Functions
---------
### gtk\_font\_chooser\_widget\_new ()
```
[GtkWidget](gtkwidget#GtkWidget-struct) *
gtk_font_chooser_widget_new (*`void`*);
```
Creates a new [GtkFontChooserWidget](gtkfontchooserwidget#GtkFontChooserWidget-struct).
#### Returns
a new [GtkFontChooserWidget](gtkfontchooserwidget#GtkFontChooserWidget-struct)
Types and Values
----------------
### GtkFontChooserWidget
```
typedef struct _GtkFontChooserWidget GtkFontChooserWidget;
```
Property Details
----------------
### The `“tweak-action”` property
```
“tweak-action” GAction *
```
A toggle action that can be used to switch to the tweak page of the font chooser widget, which lets the user tweak the OpenType features and variation axes of the selected font.
The action will be enabled or disabled depending on whether the selected font has any features or axes.
Owner: GtkFontChooserWidget
Flags: Read
See Also
--------
[GtkFontChooserDialog](gtkfontchooserdialog#GtkFontChooserDialog-struct)
gtk GtkActionBar GtkActionBar
============
GtkActionBar — A full width bar for presenting contextual actions
Functions
---------
| | |
| --- | --- |
| [GtkWidget](gtkwidget#GtkWidget-struct) \* | [gtk\_action\_bar\_new](gtkactionbar#gtk-action-bar-new) () |
| void | [gtk\_action\_bar\_pack\_start](gtkactionbar#gtk-action-bar-pack-start) () |
| void | [gtk\_action\_bar\_pack\_end](gtkactionbar#gtk-action-bar-pack-end) () |
| void | [gtk\_action\_bar\_remove](gtkactionbar#gtk-action-bar-remove) () |
| [GtkWidget](gtkwidget#GtkWidget-struct) \* | [gtk\_action\_bar\_get\_center\_widget](gtkactionbar#gtk-action-bar-get-center-widget) () |
| void | [gtk\_action\_bar\_set\_center\_widget](gtkactionbar#gtk-action-bar-set-center-widget) () |
| gboolean | [gtk\_action\_bar\_get\_revealed](gtkactionbar#gtk-action-bar-get-revealed) () |
| void | [gtk\_action\_bar\_set\_revealed](gtkactionbar#gtk-action-bar-set-revealed) () |
Properties
----------
| | | |
| --- | --- | --- |
| gboolean | [revealed](gtkactionbar#GtkActionBar--revealed) | Read / Write |
Types and Values
----------------
| | |
| --- | --- |
| | [GtkActionBar](gtkactionbar#GtkActionBar-struct) |
Object Hierarchy
----------------
```
GObject
╰── GInitiallyUnowned
╰── [GtkWidget](gtkwidget#GtkWidget-struct)
╰── GtkActionBar
```
Implemented Interfaces
----------------------
GtkActionBar implements [GtkAccessible](gtkaccessible#GtkAccessible-struct), [GtkBuildable](gtkbuildable#GtkBuildable-struct) and [GtkConstraintTarget](gtkconstraint#GtkConstraintTarget-struct).
Includes
--------
```
#include <gtk/gtk.h>
```
Description
-----------
GtkActionBar is designed to present contextual actions. It is expected to be displayed below the content and expand horizontally to fill the area.
It allows placing children at the start or the end. In addition, it contains an internal centered box which is centered with respect to the full width of the box, even if the children at either side take up different amounts of space.
### CSS nodes
GtkActionBar has a single CSS node with name actionbar.
Functions
---------
### gtk\_action\_bar\_new ()
```
[GtkWidget](gtkwidget#GtkWidget-struct) *
gtk_action_bar_new (*`void`*);
```
Creates a new [GtkActionBar](gtkactionbar#GtkActionBar-struct) widget.
#### Returns
a new [GtkActionBar](gtkactionbar#GtkActionBar-struct)
### gtk\_action\_bar\_pack\_start ()
```
void
gtk_action_bar_pack_start (*`[GtkActionBar](gtkactionbar#GtkActionBar-struct) *action_bar`*,
*`[GtkWidget](gtkwidget#GtkWidget-struct) *child`*);
```
Adds *`child`* to *`action_bar`* , packed with reference to the start of the *`action_bar`* .
#### Parameters
| | | |
| --- | --- | --- |
| action\_bar | A [GtkActionBar](gtkactionbar#GtkActionBar-struct) | |
| child | the [GtkWidget](gtkwidget#GtkWidget-struct) to be added to *`action_bar`* | |
### gtk\_action\_bar\_pack\_end ()
```
void
gtk_action_bar_pack_end (*`[GtkActionBar](gtkactionbar#GtkActionBar-struct) *action_bar`*,
*`[GtkWidget](gtkwidget#GtkWidget-struct) *child`*);
```
Adds *`child`* to *`action_bar`* , packed with reference to the end of the *`action_bar`* .
#### Parameters
| | | |
| --- | --- | --- |
| action\_bar | A [GtkActionBar](gtkactionbar#GtkActionBar-struct) | |
| child | the [GtkWidget](gtkwidget#GtkWidget-struct) to be added to *`action_bar`* | |
### gtk\_action\_bar\_remove ()
```
void
gtk_action_bar_remove (*`[GtkActionBar](gtkactionbar#GtkActionBar-struct) *action_bar`*,
*`[GtkWidget](gtkwidget#GtkWidget-struct) *child`*);
```
Removes a child from *`action_bar`* .
#### Parameters
| | | |
| --- | --- | --- |
| action\_bar | a [GtkActionBar](gtkactionbar#GtkActionBar-struct) | |
| child | the [GtkWidget](gtkwidget#GtkWidget-struct) to be removed | |
### gtk\_action\_bar\_get\_center\_widget ()
```
[GtkWidget](gtkwidget#GtkWidget-struct) *
gtk_action_bar_get_center_widget (*`[GtkActionBar](gtkactionbar#GtkActionBar-struct) *action_bar`*);
```
Retrieves the center bar widget of the bar.
#### Parameters
| | | |
| --- | --- | --- |
| action\_bar | a [GtkActionBar](gtkactionbar#GtkActionBar-struct) | |
#### Returns
the center [GtkWidget](gtkwidget#GtkWidget-struct) or `NULL`.
[transfer none][nullable]
### gtk\_action\_bar\_set\_center\_widget ()
```
void
gtk_action_bar_set_center_widget (*`[GtkActionBar](gtkactionbar#GtkActionBar-struct) *action_bar`*,
*`[GtkWidget](gtkwidget#GtkWidget-struct) *center_widget`*);
```
Sets the center widget for the [GtkActionBar](gtkactionbar#GtkActionBar-struct).
#### Parameters
| | | |
| --- | --- | --- |
| action\_bar | a [GtkActionBar](gtkactionbar#GtkActionBar-struct) | |
| center\_widget | a widget to use for the center. | [allow-none] |
### gtk\_action\_bar\_get\_revealed ()
```
gboolean
gtk_action_bar_get_revealed (*`[GtkActionBar](gtkactionbar#GtkActionBar-struct) *action_bar`*);
```
Gets the value of the [“revealed”](gtkactionbar#GtkActionBar--revealed) property.
#### Parameters
| | | |
| --- | --- | --- |
| action\_bar | a [GtkActionBar](gtkactionbar#GtkActionBar-struct) | |
#### Returns
the current value of the [“revealed”](gtkactionbar#GtkActionBar--revealed) property.
### gtk\_action\_bar\_set\_revealed ()
```
void
gtk_action_bar_set_revealed (*`[GtkActionBar](gtkactionbar#GtkActionBar-struct) *action_bar`*,
*`gboolean revealed`*);
```
Sets the [“revealed”](gtkactionbar#GtkActionBar--revealed) property to *`revealed`* . Changing this will make *`action_bar`* reveal (`TRUE`) or conceal (`FALSE`) itself via a sliding transition.
Note: this does not show or hide *`action_bar`* in the [“visible”](gtkwidget#GtkWidget--visible) sense, so revealing has no effect if [“visible”](gtkwidget#GtkWidget--visible) is `FALSE`.
#### Parameters
| | | |
| --- | --- | --- |
| action\_bar | a [GtkActionBar](gtkactionbar#GtkActionBar-struct) | |
| revealed | The new value of the property | |
Types and Values
----------------
### GtkActionBar
```
typedef struct _GtkActionBar GtkActionBar;
```
Property Details
----------------
### The `“revealed”` property
```
“revealed” gboolean
```
Controls whether the action bar shows its contents or not.
Owner: GtkActionBar
Flags: Read / Write
Default value: TRUE
See Also
--------
[GtkBox](gtkbox#GtkBox-struct)
gtk GtkFileChooserNative GtkFileChooserNative
====================
GtkFileChooserNative — A native file chooser dialog, suitable for “File Open” or “File Save” commands
Functions
---------
| | |
| --- | --- |
| [GtkFileChooserNative](gtkfilechoosernative#GtkFileChooserNative-struct) \* | [gtk\_file\_chooser\_native\_new](gtkfilechoosernative#gtk-file-chooser-native-new) () |
| const char \* | [gtk\_file\_chooser\_native\_get\_accept\_label](gtkfilechoosernative#gtk-file-chooser-native-get-accept-label) () |
| void | [gtk\_file\_chooser\_native\_set\_accept\_label](gtkfilechoosernative#gtk-file-chooser-native-set-accept-label) () |
| const char \* | [gtk\_file\_chooser\_native\_get\_cancel\_label](gtkfilechoosernative#gtk-file-chooser-native-get-cancel-label) () |
| void | [gtk\_file\_chooser\_native\_set\_cancel\_label](gtkfilechoosernative#gtk-file-chooser-native-set-cancel-label) () |
Properties
----------
| | | |
| --- | --- | --- |
| char \* | [accept-label](gtkfilechoosernative#GtkFileChooserNative--accept-label) | Read / Write |
| char \* | [cancel-label](gtkfilechoosernative#GtkFileChooserNative--cancel-label) | Read / Write |
Types and Values
----------------
| | |
| --- | --- |
| | [GtkFileChooserNative](gtkfilechoosernative#GtkFileChooserNative-struct) |
Object Hierarchy
----------------
```
GObject
╰── [GtkNativeDialog](gtknativedialog#GtkNativeDialog-struct)
╰── GtkFileChooserNative
```
Implemented Interfaces
----------------------
GtkFileChooserNative implements [GtkFileChooser](gtkfilechooser#GtkFileChooser-struct).
Includes
--------
```
#include <gtk/gtk.h>
```
Description
-----------
[GtkFileChooserNative](gtkfilechoosernative#GtkFileChooserNative-struct) is an abstraction of a dialog box suitable for use with “File Open” or “File Save as” commands. By default, this just uses a [GtkFileChooserDialog](gtkfilechooserdialog#GtkFileChooserDialog-struct) to implement the actual dialog. However, on certain platforms, such as Windows and macOS, the native platform file chooser is used instead. When the application is running in a sandboxed environment without direct filesystem access (such as Flatpak), [GtkFileChooserNative](gtkfilechoosernative#GtkFileChooserNative-struct) may call the proper APIs (portals) to let the user choose a file and make it available to the application.
While the API of [GtkFileChooserNative](gtkfilechoosernative#GtkFileChooserNative-struct) closely mirrors [GtkFileChooserDialog](gtkfilechooserdialog#GtkFileChooserDialog-struct), the main difference is that there is no access to any [GtkWindow](gtkwindow#GtkWindow-struct) or [GtkWidget](gtkwidget#GtkWidget-struct) for the dialog. This is required, as there may not be one in the case of a platform native dialog.
Showing, hiding and running the dialog is handled by the [GtkNativeDialog](gtknativedialog#GtkNativeDialog-struct) functions.
Note that unlike [GtkFileChooserDialog](gtkfilechooserdialog#GtkFileChooserDialog-struct), [GtkFileChooserNative](gtkfilechoosernative#GtkFileChooserNative-struct) objects are not toplevel widgets, and GTK does not keep them alive. It is your responsibility to keep a reference until you are done with the object.
#### Typical usage
In the simplest of cases, you can the following code to use [GtkFileChooserDialog](gtkfilechooserdialog#GtkFileChooserDialog-struct) to select a file for opening:
To use a dialog for saving, you can use this:
```
static void
on_response (GtkNativeDialog *native,
int response)
{
if (response == GTK_RESPONSE_ACCEPT)
{
GtkFileChooser *chooser = GTK_FILE_CHOOSER (native);
GFile *file = gtk_file_chooser_get_file (chooser);
open_file (file);
g_object_unref (file);
}
g_object_unref (native);
}
// ...
GtkFileChooserNative *native;
GtkFileChooserAction action = GTK_FILE_CHOOSER_ACTION_OPEN;
native = gtk_file_chooser_native_new ("Open File",
parent_window,
action,
"_Open",
"_Cancel");
g_signal_connect (native, "response", G_CALLBACK (on_response), NULL);
gtk_native_dialog_show (GTK_NATIVE_DIALOG (native));
```
| For more information on how to best set up a file dialog, see [GtkFileChooserDialog](gtkfilechooserdialog#GtkFileChooserDialog-struct).
#### Response Codes
[GtkFileChooserNative](gtkfilechoosernative#GtkFileChooserNative-struct) inherits from [GtkNativeDialog](gtknativedialog#GtkNativeDialog-struct), which means it will return [GTK\_RESPONSE\_ACCEPT](gtkdialog#GTK-RESPONSE-ACCEPT:CAPS) if the user accepted, and [GTK\_RESPONSE\_CANCEL](gtkdialog#GTK-RESPONSE-CANCEL:CAPS) if he pressed cancel. It can also return [GTK\_RESPONSE\_DELETE\_EVENT](gtkdialog#GTK-RESPONSE-DELETE-EVENT:CAPS) if the window was unexpectedly closed.
#### Differences from [GtkFileChooserDialog](gtkfilechooserdialog#GtkFileChooserDialog-struct)
There are a few things in the GtkFileChooser API that are not possible to use with [GtkFileChooserNative](gtkfilechoosernative#GtkFileChooserNative-struct), as such use would prohibit the use of a native dialog.
No operations that change the dialog work while the dialog is visible. Set all the properties that are required before showing the dialog.
#### Win32 details
On windows the IFileDialog implementation (added in Windows Vista) is used. It supports many of the features that [GtkFileChooserDialog](gtkfilechooserdialog#GtkFileChooserDialog-struct) does, but there are some things it does not handle:
* Any [GtkFileFilter](gtkfilefilter#GtkFileFilter-struct) added using a mimetype
If any of these features are used the regular [GtkFileChooserDialog](gtkfilechooserdialog#GtkFileChooserDialog-struct) will be used in place of the native one.
#### Portal details
When the org.freedesktop.portal.FileChooser portal is available on the session bus, it is used to bring up an out-of-process file chooser. Depending on the kind of session the application is running in, this may or may not be a GTK file chooser.
#### macOS details
On macOS the NSSavePanel and NSOpenPanel classes are used to provide native file chooser dialogs. Some features provided by [GtkFileChooserDialog](gtkfilechooserdialog#GtkFileChooserDialog-struct) are not supported:
* Shortcut folders.
Functions
---------
### gtk\_file\_chooser\_native\_new ()
```
[GtkFileChooserNative](gtkfilechoosernative#GtkFileChooserNative-struct) *
gtk_file_chooser_native_new (*`const char *title`*,
*`[GtkWindow](gtkwindow#GtkWindow-struct) *parent`*,
*`[GtkFileChooserAction](gtkfilechooser#GtkFileChooserAction) action`*,
*`const char *accept_label`*,
*`const char *cancel_label`*);
```
Creates a new [GtkFileChooserNative](gtkfilechoosernative#GtkFileChooserNative-struct).
#### Parameters
| | | |
| --- | --- | --- |
| title | Title of the native, or `NULL`. | [allow-none] |
| parent | Transient parent of the native, or `NULL`. | [allow-none] |
| action | Open or save mode for the dialog | |
| accept\_label | text to go in the accept button, or `NULL` for the default. | [allow-none] |
| cancel\_label | text to go in the cancel button, or `NULL` for the default. | [allow-none] |
#### Returns
a new [GtkFileChooserNative](gtkfilechoosernative#GtkFileChooserNative-struct)
### gtk\_file\_chooser\_native\_get\_accept\_label ()
```
const char *
gtk_file_chooser_native_get_accept_label
(*`[GtkFileChooserNative](gtkfilechoosernative#GtkFileChooserNative-struct) *self`*);
```
Retrieves the custom label text for the accept button.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkFileChooserNative](gtkfilechoosernative#GtkFileChooserNative-struct) | |
#### Returns
The custom label, or `NULL` for the default. This string is owned by GTK+ and should not be modified or freed.
[nullable]
### gtk\_file\_chooser\_native\_set\_accept\_label ()
```
void
gtk_file_chooser_native_set_accept_label
(*`[GtkFileChooserNative](gtkfilechoosernative#GtkFileChooserNative-struct) *self`*,
*`const char *accept_label`*);
```
Sets the custom label text for the accept button.
If characters in *`label`* are preceded by an underscore, they are underlined. If you need a literal underscore character in a label, use “\_\_” (two underscores). The first underlined character represents a keyboard accelerator called a mnemonic. Pressing Alt and that key activates the button.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkFileChooserNative](gtkfilechoosernative#GtkFileChooserNative-struct) | |
| accept\_label | custom label or `NULL` for the default. | [allow-none] |
### gtk\_file\_chooser\_native\_get\_cancel\_label ()
```
const char *
gtk_file_chooser_native_get_cancel_label
(*`[GtkFileChooserNative](gtkfilechoosernative#GtkFileChooserNative-struct) *self`*);
```
Retrieves the custom label text for the cancel button.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkFileChooserNative](gtkfilechoosernative#GtkFileChooserNative-struct) | |
#### Returns
The custom label, or `NULL` for the default. This string is owned by GTK+ and should not be modified or freed.
[nullable]
### gtk\_file\_chooser\_native\_set\_cancel\_label ()
```
void
gtk_file_chooser_native_set_cancel_label
(*`[GtkFileChooserNative](gtkfilechoosernative#GtkFileChooserNative-struct) *self`*,
*`const char *cancel_label`*);
```
Sets the custom label text for the cancel button.
If characters in *`label`* are preceded by an underscore, they are underlined. If you need a literal underscore character in a label, use “\_\_” (two underscores). The first underlined character represents a keyboard accelerator called a mnemonic. Pressing Alt and that key activates the button.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkFileChooserNative](gtkfilechoosernative#GtkFileChooserNative-struct) | |
| cancel\_label | custom label or `NULL` for the default. | [allow-none] |
Types and Values
----------------
### GtkFileChooserNative
```
typedef struct _GtkFileChooserNative GtkFileChooserNative;
```
Property Details
----------------
### The `“accept-label”` property
```
“accept-label” char *
```
The text used for the label on the accept button in the dialog, or `NULL` to use the default text.
Owner: GtkFileChooserNative
Flags: Read / Write
Default value: NULL
### The `“cancel-label”` property
```
“cancel-label” char *
```
The text used for the label on the cancel button in the dialog, or `NULL` to use the default text.
Owner: GtkFileChooserNative
Flags: Read / Write
Default value: NULL
See Also
--------
[GtkFileChooser](gtkfilechooser#GtkFileChooser-struct), [GtkNativeDialog](gtknativedialog#GtkNativeDialog-struct), [GtkFileChooserDialog](gtkfilechooserdialog#GtkFileChooserDialog-struct)
| programming_docs |
gtk List-based Widgets List-based Widgets
==================
[List Widget Overview](listcontainers#ListWidget) [Terminology](listcontainers#id-1.4.5.2.6) [Behind the scenes](listcontainers#id-1.4.5.2.7) [Choosing the right model](listcontainers#model-choosing) [Displaying trees](listcontainers#displaying-trees) [List styles](listcontainers#list-styles) [Comparison to GtkTreeView](listcontainers#id-1.4.5.2.11) [GtkListItem](gtklistitem) — Object used to represent items of a list model [GtkListItemFactory](gtklistitemfactory) — Mapping list items to widgets [GtkSignalListItemFactory](gtksignallistitemfactory) — A listitem factory providing signals [GtkBuilderListItemFactory](gtkbuilderlistitemfactory) — A listitem factory using ui files [GtkListView](gtklistview) — A widget for displaying lists [GtkGridView](gtkgridview) — A widget for displaying grids [GtkColumnView](gtkcolumnview) — A widget for displaying lists in multiple columns [GtkColumnViewColumn](gtkcolumnviewcolumn) — The column added to GtkColumnView [GtkDropDown](gtkdropdown) — Choose an item from a list GTK provides powerful widgets to display and edit lists of data. This document gives an overview over the concepts and how they work together to allow developers to implement lists.
Lists are intended to be used whenever developers want to display many objects in roughly the same way.
Lists are perfectly fine to be used for very short list of only 2 or 3 elements, but generally scale fine to millions of items. Of course, the larger the list grows, the more care needs to be taken to choose the right data structures to keep things running well.
Lists are meant to be used with changing data, both with the items itself changing as well as the list adding and removing items. Of course, they work just as well with static data.
### Terminology
These terms are used throughout the documentation when talking about lists and you should be aware of what they refer to. These are often generic terms that have a specific meaning in this context.
***Views*** or ***list widgets*** are the widgets that hold and manage the lists. Examples of these widgets would be [GtkListView](gtklistview#GtkListView-struct) or [GtkGridView](gtkgridview#GtkGridView-struct).
Views display data from a ***model***. A model is a GListModel and models can be provided in 3 ways or combinations thereof:
* Many list models implementations already exist. There are models that provide specific data, like [GtkDirectoryList](gtkdirectorylist#GtkDirectoryList-struct). And there are models like GListStore that allow building lists manually.
* Wrapping list models like [GtkFilterListModel](gtkfilterlistmodel#GtkFilterListModel-struct) or [GtkSortListModel](gtksortlistmodel#GtkSortListModel-struct) modify, adapt or combine other models.
* Last but not least, developers are encouraged to create their own GListModel implementations. The interface is kept deliberately small to make this easy.
The same model can be used in multiple different views and wrapped with multiple different models at once.
The elements in a model are called ***items***. All items are GObjects.
Every item in a model has a ***position*** which is the unsigned integer that describes where in the model the item is located. The first item in a model is at position 0. The position of an item can of course change as other items are added or removed from the model.
It is important to be aware of the difference between items and positions because the mapping from position to item is not permanent, so developers should think about whether they want to track items or positions when working with models. Oftentimes some things are really hard to do one way but very easy the other way.
The other important part of a view is a ***factory***. Each factory is a [GtkListItemFactory](gtklistitemfactory#GtkListItemFactory-struct) implementation that takes care of mapping the items of the model to widgets that can be shown in the view.
The way factories do this is by creating a ***listitem*** for each item that is currently in use. Listitems are always [GtkListItem](gtklistitem#GtkListItem-struct) objects. They are only ever created by GTK and provide information about what item they are meant to display.
Different factory implementations use various different methods to allow developers to add the right widgets to listitems and to link those widgets with the item managed by the listitem. Finding a suitable factory implementation for the data displayed, the programming language and development environment is an important task that can simplify setting up the view tremendously.
Views support selections via a ***selection model***. A selection model is an implementation of the [GtkSelectionModel](gtkselectionmodel#GtkSelectionModel-struct) interface on top of the GListModel interface that allows marking each item in a model as either selected or not selected. Just like regular models, this can be implemented either by implementing [GtkSelectionModel](gtkselectionmodel#GtkSelectionModel-struct) directly or by wrapping a model with one of the GTK models provided for this purposes, such as [GtkNoSelection](gtknoselection#GtkNoSelection-struct) or [GtkSingleSelection](gtksingleselection#GtkSingleSelection-struct).
The behavior of selection models - ie which items they allow selecting and what effect this has on other items - is completely up to the selection model. As such, single-selections, multi-selections or sharing selection state between different selection models and/or views is possible. The selection state of an item is exposed in the listitem via the [“selected”](gtklistitem#GtkListItem--selected) property.
Views and listitems also support activation. Activation means that double clicking or pressing enter while inside a focused row will cause the view to emit and activation signal such as [“activate”](gtklistview#GtkListView-activate). This provides an easy way to set up lists, but can also be turned off on listitems if undesired.
Both selections and activation are supported among other things via widget actions. This allows developers to add widgets to their lists that cause selections to change or to trigger activation via the [GtkActionable](gtkactionable#GtkActionable-struct) interface. For a list of all supported actions see the relevant documentation.
### Behind the scenes
While for short lists it is not a problem to instantiate widgets for every item in the model, once lists grow to thousands or millions of elements, this gets less feasible. Because of this, the views only create a limited amount of listitems and recycle them by binding them to new items. In general, views try to keep listitems available only for the items that can actually be seen on screen.
While this behavior allows views to scale effortlessly to huge lists, it has a few implication on what can be done with views. For example, it is not possible to query a view for a listitem used for a certain position - there might not be one and even if there is, that listitem might soon be recycled for a new position.
It is also important that developers save state they care about in the item and do not rely on the widgets they created as those widgets can be recycled for a new position at any time causing any state to be lost.
Another important requirement for views is that they need to know which items are not visible so they can be recycled. Views achieve that by implementing the [GtkScrollable](gtkscrollable#GtkScrollable-struct) interface and expecting to be placed directly into a [GtkScrolledWindow](gtkscrolledwindow#GtkScrolledWindow-struct).
Of course, if you are only using models with few items, this is not important and you can treat views like any other widget. But if you use large lists and your performance suffers, you should be aware of this. Views also allow tuning the number of listitems they create such as with [`gtk_grid_view_set_max_columns()`](gtkgridview#gtk-grid-view-set-max-columns), and developers running into performance problems should definitely study the tradeoffs of those and experiment with them.
### Choosing the right model
GTK offers a wide variety of wrapping models which change or supplement an existing model (or models) in some way. But when it comes to storing your actual data, there are only a few ready-made choices available: GListStore and [GtkStringList](gtkstringlist#GtkStringList-struct).
GListStore is backed by a balanced tree and has performance characteristics that are expected for that data structure. It works reasonably well for dataset sizes in the 1,000,000 range, and can handle insertions and deletions. It uses a cached iter to make linear access to the items fast.
GtkStringList is not a general store - it can only handle strings. It is backed by an dynamically allocated array and has performance characteristics that are expected for that data structure. GtkStringList is a good fit for any place where you would otherwise use `char*[]` and works best if the dataset is not very dynamic.
If these models don’t fit your use case or scalability requirements, you should make a custom GListModel. It is a small interface and not very hard to implement.
For asymptotic performance comparisons between tree- and array-based implementations, see this [article](https://en.wikipedia.org/wiki/Dynamic_array#Performance).
### Displaying trees
While [GtkTreeView](gtktreeview#GtkTreeView-struct) provided built-in support for trees, the list widgets, and in particular GListModel do not. This was a design choice because the common use case is displaying lists and not trees and it greatly simplifies the API interface provided.
However, GTK provides functionality to make trees look and behave like lists for the people who still want to display lists. This is achieved by using the [GtkTreeListModel](gtktreelistmodel#GtkTreeListModel-struct) model to flatten a tree into a list. The [GtkTreeExpander](gtktreeexpander#GtkTreeExpander-struct) widget can then be used inside a listitem to allow users to expand and collapse rows and provide a similar experience to [GtkTreeView](gtktreeview#GtkTreeView-struct).
Developers should refer to those objects’ API reference for more discussion on the topic.
### List styles
One of the advantages of the new list widgets over [GtkTreeViews](gtktreeview#GtkTreeView-struct) and cell renderers is that they are fully themable using GTK CSS. This provides a lot of flexibility. The themes that ship with GTK provide a few predefined list styles that can be used in many situations:
**Figure 15. Rich list**
This style of list is low density, spacious and uses an outline focus ring. It is suitable for lists of controls, e.g. in preference dialogs or settings panels. Use the .rich-list style class.
**Figure 16. Navigation sidebar**
This style of list is medium density, using a full background to indicate focus and selection. Use the .navigation-sidebar style class.
**Figure 17. Data table**
This style of list is a high density table, similar in style to a traditional treeview. Individual cells can be selectable and editable. Use the .data-table style class.
### Comparison to GtkTreeView
Developers familiar with [GtkTreeView](gtktreeview#GtkTreeView-struct) may wonder how this way of doing lists compares to the way they know. This section will try to outline the similarities and differences between the two.
This new approach tries to provide roughly the same functionality as the old approach but often uses a very different approach to achieve these goals.
The main difference and one of the primary reasons for this new development is that items can be displayed using regular widgets and [GtkCellRenderer](gtkcellrenderer#GtkCellRenderer-struct) is no longer necessary. This allows all benefits that widgets provide, such as complex layout and animating widgets and not only makes cell renderers obsolete, but also [GtkCellArea](gtkcellarea#GtkCellArea-struct).
The other big difference is the massive change to the data model. [GtkTreeModel](gtktreemodel#GtkTreeModel-struct) was a rather complex interface for a tree data structure and GListModel was deliberately designed to be a simple data structure for lists only. (See above) for how to still do trees with this new model.) Another big change is that the new model allows for bulk changes via the “items-changed” signal while [GtkTreeModel](gtktreemodel#GtkTreeModel-struct) only allows a single item to change at once. The goal here is of course to encourage implementation of custom list models.
Another consequence of the new model is that it is now easily possible to refer to the contents of a row in the model directly by keeping the item, while [GtkTreeRowReference](gtktreemodel#GtkTreeRowReference) was a very slow mechanism to achieve the same. And because the items are real objects, developers can make them emit change signals causing listitems and their children to update, which wasn’t possible with [GtkTreeModel](gtktreemodel#GtkTreeModel-struct).
The selection handling is also different. While selections used to be managed via custom code in each widget, selection state is now meant to be managed by the selection models. In particular this allows for complex use cases with specialized requirements.
Finally here’s a quick list of equivalent functionality to look for when transitioning code for easy lookup:
| Old | New |
| --- | --- |
| [GtkTreeModel](gtktreemodel#GtkTreeModel-struct) | GListModel |
| [GtkTreePath](gtktreemodel#GtkTreePath-struct) | guint position, [GtkTreeListRow](gtktreelistmodel#GtkTreeListRow-struct) |
| [GtkTreeIter](gtktreemodel#GtkTreeIter-struct) | guint position |
| [GtkTreeRowReference](gtktreemodel#GtkTreeRowReference) | GObject item |
| [GtkListStore](gtkliststore#GtkListStore-struct) | GListStore |
| [GtkTreeStore](gtktreestore#GtkTreeStore-struct) | [GtkTreeListModel](gtktreelistmodel#GtkTreeListModel-struct), [GtkTreeExpander](gtktreeexpander#GtkTreeExpander-struct) |
| [GtkTreeSelection](gtktreeselection#GtkTreeSelection-struct) | [GtkSelectionModel](gtkselectionmodel#GtkSelectionModel-struct) |
| [GtkTreeViewColumn](gtktreeviewcolumn#GtkTreeViewColumn-struct) | [GtkColumnView](gtkcolumnview#GtkColumnView-struct) |
| [GtkTreeView](gtktreeview#GtkTreeView-struct) | [GtkListView](gtklistview#GtkListView-struct), [GtkColumnView](gtkcolumnview#GtkColumnView-struct) |
| [GtkCellView](gtkcellview#GtkCellView-struct) | GtkListItemWidget |
| [GtkComboBox](gtkcombobox#GtkComboBox-struct) | [GtkDropDown](gtkdropdown#GtkDropDown-struct) |
| [GtkIconView](gtkiconview#GtkIconView-struct) | [GtkGridView](gtkgridview#GtkGridView-struct) |
| [GtkTreeSortable](gtktreesortable#GtkTreeSortable-struct) | [GtkColumnView](gtkcolumnview#GtkColumnView-struct) |
| [GtkTreeModelSort](gtktreemodelsort#GtkTreeModelSort-struct) | [GtkSortListModel](gtksortlistmodel#GtkSortListModel-struct) |
| [GtkTreeModelFilter](gtktreemodelfilter#GtkTreeModelFilter-struct) | [GtkFilterListModel](gtkfilterlistmodel#GtkFilterListModel-struct) |
| [GtkCellLayout](gtkcelllayout#GtkCellLayout-struct) | [GtkListItemFactory](gtklistitemfactory#GtkListItemFactory-struct) |
| [GtkCellArea](gtkcellarea#GtkCellArea-struct) | [GtkWidget](gtkwidget#GtkWidget-struct) |
| [GtkCellRenderer](gtkcellrenderer#GtkCellRenderer-struct) | [GtkWidget](gtkwidget#GtkWidget-struct) |
gtk Built-in Actions Built-in Actions
================
GTK uses actions for its own purposes in a number places. These built-in actions can sometimes be activated by applications, and you should avoid naming conflicts with them when creating your own actions.
| | |
| --- | --- |
| default.activate | Activates the default widget in a context (typically a GtkWindow, GtkDialog or GtkPopover) |
| clipboard.cut, clipboard.copy, clipboard.paste | Clipboard operations on entries, text view and labels, typically used in the context menu |
| selection.delete, selection.select-all | Selection operations on entries, text view and labels |
| color.select, color.customize: | Operate on colors in a [GtkColorChooserWidget](gtkcolorchooserwidget#GtkColorChooserWidget-struct). These actions are |
unusual in that they have the non-trivial parameter type (dddd):
gtk GtkVolumeButton GtkVolumeButton
===============
GtkVolumeButton — A button which pops up a volume control
Functions
---------
| | |
| --- | --- |
| [GtkWidget](gtkwidget#GtkWidget-struct) \* | [gtk\_volume\_button\_new](gtkvolumebutton#gtk-volume-button-new) () |
Properties
----------
| | | |
| --- | --- | --- |
| gboolean | [use-symbolic](gtkvolumebutton#GtkVolumeButton--use-symbolic) | Read / Write / Construct |
Types and Values
----------------
| | |
| --- | --- |
| struct | [GtkVolumeButton](gtkvolumebutton#GtkVolumeButton-struct) |
Object Hierarchy
----------------
```
GObject
╰── GInitiallyUnowned
╰── [GtkWidget](gtkwidget#GtkWidget-struct)
╰── [GtkScaleButton](gtkscalebutton#GtkScaleButton-struct)
╰── GtkVolumeButton
```
Implemented Interfaces
----------------------
GtkVolumeButton implements [GtkAccessible](gtkaccessible#GtkAccessible-struct), [GtkBuildable](gtkbuildable#GtkBuildable-struct), [GtkConstraintTarget](gtkconstraint#GtkConstraintTarget-struct) and [GtkOrientable](gtk4-orientable#GtkOrientable-struct).
Includes
--------
```
#include <gtk/gtk.h>
```
Description
-----------
[GtkVolumeButton](gtkvolumebutton#GtkVolumeButton-struct) is a subclass of [GtkScaleButton](gtkscalebutton#GtkScaleButton-struct) that has been tailored for use as a volume control widget with suitable icons, tooltips and accessible labels.
Functions
---------
### gtk\_volume\_button\_new ()
```
[GtkWidget](gtkwidget#GtkWidget-struct) *
gtk_volume_button_new (*`void`*);
```
Creates a [GtkVolumeButton](gtkvolumebutton#GtkVolumeButton-struct), with a range between 0.0 and 1.0, with a stepping of 0.02. Volume values can be obtained and modified using the functions from [GtkScaleButton](gtkscalebutton#GtkScaleButton-struct).
#### Returns
a new [GtkVolumeButton](gtkvolumebutton#GtkVolumeButton-struct)
Types and Values
----------------
### struct GtkVolumeButton
```
struct GtkVolumeButton;
```
Property Details
----------------
### The `“use-symbolic”` property
```
“use-symbolic” gboolean
```
Whether to use symbolic icons as the icons. Note that if the symbolic icons are not available in your installed theme, then the normal (potentially colorful) icons will be used.
Owner: GtkVolumeButton
Flags: Read / Write / Construct
Default value: TRUE
gtk GtkShortcutManager GtkShortcutManager
==================
GtkShortcutManager — Interface for managing shortcuts
Types and Values
----------------
| | |
| --- | --- |
| | [GtkShortcutManager](gtkshortcutmanager#GtkShortcutManager-struct) |
| struct | [GtkShortcutManagerInterface](gtkshortcutmanager#GtkShortcutManagerInterface) |
Object Hierarchy
----------------
```
[GInterface](https://developer-old.gnome.org/gobject/stable/GTypeModule.html)
╰── GtkShortcutManager
```
Prerequisites
-------------
GtkShortcutManager requires GObject.
Known Implementations
---------------------
GtkShortcutManager is implemented by [GtkAboutDialog](gtkaboutdialog#GtkAboutDialog-struct), [GtkAppChooserDialog](gtkappchooserdialog#GtkAppChooserDialog-struct), [GtkApplicationWindow](gtkapplicationwindow#GtkApplicationWindow-struct), [GtkAssistant](gtkassistant#GtkAssistant-struct), [GtkColorChooserDialog](gtkcolorchooserdialog#GtkColorChooserDialog-struct), [GtkDialog](gtkdialog#GtkDialog-struct), [GtkEmojiChooser](gtkemojichooser#GtkEmojiChooser-struct), [GtkFileChooserDialog](gtkfilechooserdialog#GtkFileChooserDialog-struct), [GtkFontChooserDialog](gtkfontchooserdialog#GtkFontChooserDialog-struct), [GtkMessageDialog](gtkmessagedialog#GtkMessageDialog-struct), [GtkPageSetupUnixDialog](gtkpagesetupunixdialog#GtkPageSetupUnixDialog-struct), [GtkPopover](gtkpopover#GtkPopover-struct), [GtkPopoverMenu](gtkpopovermenu#GtkPopoverMenu-struct), [GtkPrintUnixDialog](gtkprintunixdialog#GtkPrintUnixDialog-struct), [GtkShortcutsWindow](gtkshortcutswindow#GtkShortcutsWindow-struct) and [GtkWindow](gtkwindow#GtkWindow-struct).
Includes
--------
```
#include <gtk/gtk.h>
```
Description
-----------
The GtkShortcutManager interface is used to implement shortcut scopes.
This is important for [GtkNative](gtknative#GtkNative-struct) widgets that have their own surface, since the event controllers that are used to implement managed and global scopes are limited to the same native.
Examples for widgets implementing [GtkShortcutManager](gtkshortcutmanager#GtkShortcutManager-struct) are [GtkWindow](gtkwindow#GtkWindow-struct) and [GtkPopover](gtkpopover#GtkPopover-struct).
Functions
---------
Types and Values
----------------
### GtkShortcutManager
```
typedef struct _GtkShortcutManager GtkShortcutManager;
```
This object is used to implement support for GtkShortcutScopes. Every widget that implements [GtkShortcutManager](gtkshortcutmanager#GtkShortcutManager-struct) will be used as a [`GTK_SHORTCUT_SCOPE_MANAGED`](gtkshortcutcontroller#GTK-SHORTCUT-SCOPE-MANAGED:CAPS).
### struct GtkShortcutManagerInterface
```
struct GtkShortcutManagerInterface {
void (* add_controller) (GtkShortcutManager *self,
GtkShortcutController *controller);
void (* remove_controller) (GtkShortcutManager *self,
GtkShortcutController *controller);
};
```
The list of functions that can be implemented for the [GtkShortcutManager](gtkshortcutmanager#GtkShortcutManager-struct) interface.
Note that no function is mandatory to implement, the default implementation will work fine.
#### Members
| | | |
| --- | --- | --- |
| *`add_controller`* () | Add a [GtkShortcutController](gtkshortcutcontroller#GtkShortcutController-struct) to be managed. | |
| *`remove_controller`* () | Remove a [GtkShortcutController](gtkshortcutcontroller#GtkShortcutController-struct) that had previously been added. | |
| programming_docs |
gtk GtkBinLayout GtkBinLayout
============
GtkBinLayout — A layout manager for bin-like widgets
Functions
---------
| | |
| --- | --- |
| [GtkLayoutManager](gtklayoutmanager#GtkLayoutManager-struct) \* | [gtk\_bin\_layout\_new](gtkbinlayout#gtk-bin-layout-new) () |
Types and Values
----------------
| | |
| --- | --- |
| | [GtkBinLayout](gtkbinlayout#GtkBinLayout-struct) |
Object Hierarchy
----------------
```
GObject
╰── [GtkLayoutManager](gtklayoutmanager#GtkLayoutManager-struct)
╰── GtkBinLayout
```
Includes
--------
```
#include <gtk/gtk.h>
```
Description
-----------
GtkBinLayout is a [GtkLayoutManager](gtklayoutmanager#GtkLayoutManager-struct) subclass useful for create "bins" of widgets. GtkBinLayout will stack each child of a widget on top of each other, using the [“hexpand”](gtkwidget#GtkWidget--hexpand), [“vexpand”](gtkwidget#GtkWidget--vexpand), [“halign”](gtkwidget#GtkWidget--halign), and [“valign”](gtkwidget#GtkWidget--valign) properties of each child to determine where they should be positioned.
Functions
---------
### gtk\_bin\_layout\_new ()
```
[GtkLayoutManager](gtklayoutmanager#GtkLayoutManager-struct) *
gtk_bin_layout_new (*`void`*);
```
Creates a new [GtkBinLayout](gtkbinlayout#GtkBinLayout-struct) instance.
#### Returns
the newly created [GtkBinLayout](gtkbinlayout#GtkBinLayout-struct)
Types and Values
----------------
### GtkBinLayout
```
typedef struct _GtkBinLayout GtkBinLayout;
```
gtk GtkAppChooserWidget GtkAppChooserWidget
===================
GtkAppChooserWidget — Application chooser widget that can be embedded in other widgets
Functions
---------
| | |
| --- | --- |
| [GtkWidget](gtkwidget#GtkWidget-struct) \* | [gtk\_app\_chooser\_widget\_new](gtkappchooserwidget#gtk-app-chooser-widget-new) () |
| void | [gtk\_app\_chooser\_widget\_set\_show\_default](gtkappchooserwidget#gtk-app-chooser-widget-set-show-default) () |
| gboolean | [gtk\_app\_chooser\_widget\_get\_show\_default](gtkappchooserwidget#gtk-app-chooser-widget-get-show-default) () |
| void | [gtk\_app\_chooser\_widget\_set\_show\_recommended](gtkappchooserwidget#gtk-app-chooser-widget-set-show-recommended) () |
| gboolean | [gtk\_app\_chooser\_widget\_get\_show\_recommended](gtkappchooserwidget#gtk-app-chooser-widget-get-show-recommended) () |
| void | [gtk\_app\_chooser\_widget\_set\_show\_fallback](gtkappchooserwidget#gtk-app-chooser-widget-set-show-fallback) () |
| gboolean | [gtk\_app\_chooser\_widget\_get\_show\_fallback](gtkappchooserwidget#gtk-app-chooser-widget-get-show-fallback) () |
| void | [gtk\_app\_chooser\_widget\_set\_show\_other](gtkappchooserwidget#gtk-app-chooser-widget-set-show-other) () |
| gboolean | [gtk\_app\_chooser\_widget\_get\_show\_other](gtkappchooserwidget#gtk-app-chooser-widget-get-show-other) () |
| void | [gtk\_app\_chooser\_widget\_set\_show\_all](gtkappchooserwidget#gtk-app-chooser-widget-set-show-all) () |
| gboolean | [gtk\_app\_chooser\_widget\_get\_show\_all](gtkappchooserwidget#gtk-app-chooser-widget-get-show-all) () |
| void | [gtk\_app\_chooser\_widget\_set\_default\_text](gtkappchooserwidget#gtk-app-chooser-widget-set-default-text) () |
| const char \* | [gtk\_app\_chooser\_widget\_get\_default\_text](gtkappchooserwidget#gtk-app-chooser-widget-get-default-text) () |
Properties
----------
| | | |
| --- | --- | --- |
| char \* | [default-text](gtkappchooserwidget#GtkAppChooserWidget--default-text) | Read / Write |
| gboolean | [show-all](gtkappchooserwidget#GtkAppChooserWidget--show-all) | Read / Write / Construct |
| gboolean | [show-default](gtkappchooserwidget#GtkAppChooserWidget--show-default) | Read / Write / Construct |
| gboolean | [show-fallback](gtkappchooserwidget#GtkAppChooserWidget--show-fallback) | Read / Write / Construct |
| gboolean | [show-other](gtkappchooserwidget#GtkAppChooserWidget--show-other) | Read / Write / Construct |
| gboolean | [show-recommended](gtkappchooserwidget#GtkAppChooserWidget--show-recommended) | Read / Write / Construct |
Signals
-------
| | | |
| --- | --- | --- |
| void | [application-activated](gtkappchooserwidget#GtkAppChooserWidget-application-activated) | Run First |
| void | [application-selected](gtkappchooserwidget#GtkAppChooserWidget-application-selected) | Run First |
Types and Values
----------------
| | |
| --- | --- |
| | [GtkAppChooserWidget](gtkappchooserwidget#GtkAppChooserWidget-struct) |
Object Hierarchy
----------------
```
GObject
╰── GInitiallyUnowned
╰── [GtkWidget](gtkwidget#GtkWidget-struct)
╰── GtkAppChooserWidget
```
Implemented Interfaces
----------------------
GtkAppChooserWidget implements [GtkAccessible](gtkaccessible#GtkAccessible-struct), [GtkBuildable](gtkbuildable#GtkBuildable-struct), [GtkConstraintTarget](gtkconstraint#GtkConstraintTarget-struct) and [GtkAppChooser](gtkappchooser#GtkAppChooser-struct).
Includes
--------
```
#include <gtk/gtk.h>
```
Description
-----------
[GtkAppChooserWidget](gtkappchooserwidget#GtkAppChooserWidget-struct) is a widget for selecting applications. It is the main building block for [GtkAppChooserDialog](gtkappchooserdialog#GtkAppChooserDialog-struct). Most applications only need to use the latter; but you can use this widget as part of a larger widget if you have special needs.
[GtkAppChooserWidget](gtkappchooserwidget#GtkAppChooserWidget-struct) offers detailed control over what applications are shown, using the [“show-default”](gtkappchooserwidget#GtkAppChooserWidget--show-default), [“show-recommended”](gtkappchooserwidget#GtkAppChooserWidget--show-recommended), [“show-fallback”](gtkappchooserwidget#GtkAppChooserWidget--show-fallback), [“show-other”](gtkappchooserwidget#GtkAppChooserWidget--show-other) and [“show-all”](gtkappchooserwidget#GtkAppChooserWidget--show-all) properties. See the [GtkAppChooser](gtkappchooser#GtkAppChooser-struct) documentation for more information about these groups of applications.
To keep track of the selected application, use the [“application-selected”](gtkappchooserwidget#GtkAppChooserWidget-application-selected) and [“application-activated”](gtkappchooserwidget#GtkAppChooserWidget-application-activated) signals.
### CSS nodes
GtkAppChooserWidget has a single CSS node with name appchooser.
Functions
---------
### gtk\_app\_chooser\_widget\_new ()
```
[GtkWidget](gtkwidget#GtkWidget-struct) *
gtk_app_chooser_widget_new (*`const char *content_type`*);
```
Creates a new [GtkAppChooserWidget](gtkappchooserwidget#GtkAppChooserWidget-struct) for applications that can handle content of the given type.
#### Parameters
| | | |
| --- | --- | --- |
| content\_type | the content type to show applications for | |
#### Returns
a newly created [GtkAppChooserWidget](gtkappchooserwidget#GtkAppChooserWidget-struct)
### gtk\_app\_chooser\_widget\_set\_show\_default ()
```
void
gtk_app_chooser_widget_set_show_default
(*`[GtkAppChooserWidget](gtkappchooserwidget#GtkAppChooserWidget-struct) *self`*,
*`gboolean setting`*);
```
Sets whether the app chooser should show the default handler for the content type in a separate section.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkAppChooserWidget](gtkappchooserwidget#GtkAppChooserWidget-struct) | |
| setting | the new value for [“show-default”](gtkappchooserwidget#GtkAppChooserWidget--show-default) | |
### gtk\_app\_chooser\_widget\_get\_show\_default ()
```
gboolean
gtk_app_chooser_widget_get_show_default
(*`[GtkAppChooserWidget](gtkappchooserwidget#GtkAppChooserWidget-struct) *self`*);
```
Returns the current value of the [“show-default”](gtkappchooserwidget#GtkAppChooserWidget--show-default) property.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkAppChooserWidget](gtkappchooserwidget#GtkAppChooserWidget-struct) | |
#### Returns
the value of [“show-default”](gtkappchooserwidget#GtkAppChooserWidget--show-default)
### gtk\_app\_chooser\_widget\_set\_show\_recommended ()
```
void
gtk_app_chooser_widget_set_show_recommended
(*`[GtkAppChooserWidget](gtkappchooserwidget#GtkAppChooserWidget-struct) *self`*,
*`gboolean setting`*);
```
Sets whether the app chooser should show recommended applications for the content type in a separate section.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkAppChooserWidget](gtkappchooserwidget#GtkAppChooserWidget-struct) | |
| setting | the new value for [“show-recommended”](gtkappchooserwidget#GtkAppChooserWidget--show-recommended) | |
### gtk\_app\_chooser\_widget\_get\_show\_recommended ()
```
gboolean
gtk_app_chooser_widget_get_show_recommended
(*`[GtkAppChooserWidget](gtkappchooserwidget#GtkAppChooserWidget-struct) *self`*);
```
Returns the current value of the [“show-recommended”](gtkappchooserwidget#GtkAppChooserWidget--show-recommended) property.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkAppChooserWidget](gtkappchooserwidget#GtkAppChooserWidget-struct) | |
#### Returns
the value of [“show-recommended”](gtkappchooserwidget#GtkAppChooserWidget--show-recommended)
### gtk\_app\_chooser\_widget\_set\_show\_fallback ()
```
void
gtk_app_chooser_widget_set_show_fallback
(*`[GtkAppChooserWidget](gtkappchooserwidget#GtkAppChooserWidget-struct) *self`*,
*`gboolean setting`*);
```
Sets whether the app chooser should show related applications for the content type in a separate section.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkAppChooserWidget](gtkappchooserwidget#GtkAppChooserWidget-struct) | |
| setting | the new value for [“show-fallback”](gtkappchooserwidget#GtkAppChooserWidget--show-fallback) | |
### gtk\_app\_chooser\_widget\_get\_show\_fallback ()
```
gboolean
gtk_app_chooser_widget_get_show_fallback
(*`[GtkAppChooserWidget](gtkappchooserwidget#GtkAppChooserWidget-struct) *self`*);
```
Returns the current value of the [“show-fallback”](gtkappchooserwidget#GtkAppChooserWidget--show-fallback) property.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkAppChooserWidget](gtkappchooserwidget#GtkAppChooserWidget-struct) | |
#### Returns
the value of [“show-fallback”](gtkappchooserwidget#GtkAppChooserWidget--show-fallback)
### gtk\_app\_chooser\_widget\_set\_show\_other ()
```
void
gtk_app_chooser_widget_set_show_other (*`[GtkAppChooserWidget](gtkappchooserwidget#GtkAppChooserWidget-struct) *self`*,
*`gboolean setting`*);
```
Sets whether the app chooser should show applications which are unrelated to the content type.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkAppChooserWidget](gtkappchooserwidget#GtkAppChooserWidget-struct) | |
| setting | the new value for [“show-other”](gtkappchooserwidget#GtkAppChooserWidget--show-other) | |
### gtk\_app\_chooser\_widget\_get\_show\_other ()
```
gboolean
gtk_app_chooser_widget_get_show_other (*`[GtkAppChooserWidget](gtkappchooserwidget#GtkAppChooserWidget-struct) *self`*);
```
Returns the current value of the [“show-other”](gtkappchooserwidget#GtkAppChooserWidget--show-other) property.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkAppChooserWidget](gtkappchooserwidget#GtkAppChooserWidget-struct) | |
#### Returns
the value of [“show-other”](gtkappchooserwidget#GtkAppChooserWidget--show-other)
### gtk\_app\_chooser\_widget\_set\_show\_all ()
```
void
gtk_app_chooser_widget_set_show_all (*`[GtkAppChooserWidget](gtkappchooserwidget#GtkAppChooserWidget-struct) *self`*,
*`gboolean setting`*);
```
Sets whether the app chooser should show all applications in a flat list.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkAppChooserWidget](gtkappchooserwidget#GtkAppChooserWidget-struct) | |
| setting | the new value for [“show-all”](gtkappchooserwidget#GtkAppChooserWidget--show-all) | |
### gtk\_app\_chooser\_widget\_get\_show\_all ()
```
gboolean
gtk_app_chooser_widget_get_show_all (*`[GtkAppChooserWidget](gtkappchooserwidget#GtkAppChooserWidget-struct) *self`*);
```
Returns the current value of the [“show-all”](gtkappchooserwidget#GtkAppChooserWidget--show-all) property.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkAppChooserWidget](gtkappchooserwidget#GtkAppChooserWidget-struct) | |
#### Returns
the value of [“show-all”](gtkappchooserwidget#GtkAppChooserWidget--show-all)
### gtk\_app\_chooser\_widget\_set\_default\_text ()
```
void
gtk_app_chooser_widget_set_default_text
(*`[GtkAppChooserWidget](gtkappchooserwidget#GtkAppChooserWidget-struct) *self`*,
*`const char *text`*);
```
Sets the text that is shown if there are not applications that can handle the content type.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkAppChooserWidget](gtkappchooserwidget#GtkAppChooserWidget-struct) | |
| text | the new value for [“default-text”](gtkappchooserwidget#GtkAppChooserWidget--default-text) | |
### gtk\_app\_chooser\_widget\_get\_default\_text ()
```
const char *
gtk_app_chooser_widget_get_default_text
(*`[GtkAppChooserWidget](gtkappchooserwidget#GtkAppChooserWidget-struct) *self`*);
```
Returns the text that is shown if there are not applications that can handle the content type.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkAppChooserWidget](gtkappchooserwidget#GtkAppChooserWidget-struct) | |
#### Returns
the value of [“default-text”](gtkappchooserwidget#GtkAppChooserWidget--default-text).
[nullable]
Types and Values
----------------
### GtkAppChooserWidget
```
typedef struct _GtkAppChooserWidget GtkAppChooserWidget;
```
Property Details
----------------
### The `“default-text”` property
```
“default-text” char *
```
The [“default-text”](gtkappchooserwidget#GtkAppChooserWidget--default-text) property determines the text that appears in the widget when there are no applications for the given content type. See also [`gtk_app_chooser_widget_set_default_text()`](gtkappchooserwidget#gtk-app-chooser-widget-set-default-text).
Owner: GtkAppChooserWidget
Flags: Read / Write
Default value: NULL
### The `“show-all”` property
```
“show-all” gboolean
```
If the [“show-all”](gtkappchooserwidget#GtkAppChooserWidget--show-all) property is `TRUE`, the app chooser presents all applications in a single list, without subsections for default, recommended or related applications.
Owner: GtkAppChooserWidget
Flags: Read / Write / Construct
Default value: FALSE
### The `“show-default”` property
```
“show-default” gboolean
```
The ::show-default property determines whether the app chooser should show the default handler for the content type in a separate section. If `FALSE`, the default handler is listed among the recommended applications.
Owner: GtkAppChooserWidget
Flags: Read / Write / Construct
Default value: FALSE
### The `“show-fallback”` property
```
“show-fallback” gboolean
```
The [“show-fallback”](gtkappchooserwidget#GtkAppChooserWidget--show-fallback) property determines whether the app chooser should show a section for fallback applications. If `FALSE`, the fallback applications are listed among the other applications.
Owner: GtkAppChooserWidget
Flags: Read / Write / Construct
Default value: FALSE
### The `“show-other”` property
```
“show-other” gboolean
```
The [“show-other”](gtkappchooserwidget#GtkAppChooserWidget--show-other) property determines whether the app chooser should show a section for other applications.
Owner: GtkAppChooserWidget
Flags: Read / Write / Construct
Default value: FALSE
### The `“show-recommended”` property
```
“show-recommended” gboolean
```
The [“show-recommended”](gtkappchooserwidget#GtkAppChooserWidget--show-recommended) property determines whether the app chooser should show a section for recommended applications. If `FALSE`, the recommended applications are listed among the other applications.
Owner: GtkAppChooserWidget
Flags: Read / Write / Construct
Default value: TRUE
Signal Details
--------------
### The `“application-activated”` signal
```
void
user_function ([GtkAppChooserWidget](gtkappchooserwidget#GtkAppChooserWidget-struct) *self,
GAppInfo *application,
gpointer user_data)
```
Emitted when an application item is activated from the widget's list.
This usually happens when the user double clicks an item, or an item is selected and the user presses one of the keys Space, Shift+Space, Return or Enter.
#### Parameters
| | | |
| --- | --- | --- |
| self | the object which received the signal | |
| application | the activated GAppInfo | |
| user\_data | user data set when the signal handler was connected. | |
Flags: Run First
### The `“application-selected”` signal
```
void
user_function ([GtkAppChooserWidget](gtkappchooserwidget#GtkAppChooserWidget-struct) *self,
GAppInfo *application,
gpointer user_data)
```
Emitted when an application item is selected from the widget's list.
#### Parameters
| | | |
| --- | --- | --- |
| self | the object which received the signal | |
| application | the selected GAppInfo | |
| user\_data | user data set when the signal handler was connected. | |
Flags: Run First
gtk GtkSelectionModel GtkSelectionModel
=================
GtkSelectionModel — An extension of the list model interface that handles selections
Functions
---------
| | |
| --- | --- |
| gboolean | [gtk\_selection\_model\_is\_selected](gtkselectionmodel#gtk-selection-model-is-selected) () |
| [GtkBitset](gtkbitset#GtkBitset-struct) \* | [gtk\_selection\_model\_get\_selection](gtkselectionmodel#gtk-selection-model-get-selection) () |
| [GtkBitset](gtkbitset#GtkBitset-struct) \* | [gtk\_selection\_model\_get\_selection\_in\_range](gtkselectionmodel#gtk-selection-model-get-selection-in-range) () |
| gboolean | [gtk\_selection\_model\_select\_item](gtkselectionmodel#gtk-selection-model-select-item) () |
| gboolean | [gtk\_selection\_model\_unselect\_item](gtkselectionmodel#gtk-selection-model-unselect-item) () |
| gboolean | [gtk\_selection\_model\_select\_range](gtkselectionmodel#gtk-selection-model-select-range) () |
| gboolean | [gtk\_selection\_model\_unselect\_range](gtkselectionmodel#gtk-selection-model-unselect-range) () |
| gboolean | [gtk\_selection\_model\_select\_all](gtkselectionmodel#gtk-selection-model-select-all) () |
| gboolean | [gtk\_selection\_model\_unselect\_all](gtkselectionmodel#gtk-selection-model-unselect-all) () |
| gboolean | [gtk\_selection\_model\_set\_selection](gtkselectionmodel#gtk-selection-model-set-selection) () |
| void | [gtk\_selection\_model\_selection\_changed](gtkselectionmodel#gtk-selection-model-selection-changed) () |
Signals
-------
| | | |
| --- | --- | --- |
| void | [selection-changed](gtkselectionmodel#GtkSelectionModel-selection-changed) | Run Last |
Types and Values
----------------
| | |
| --- | --- |
| | [GtkSelectionModel](gtkselectionmodel#GtkSelectionModel-struct) |
Object Hierarchy
----------------
```
[GInterface](https://developer-old.gnome.org/gobject/stable/GTypeModule.html)
╰── GtkSelectionModel
```
Prerequisites
-------------
GtkSelectionModel requires GListModel and GObject.
Known Implementations
---------------------
GtkSelectionModel is implemented by [GtkMultiSelection](gtkmultiselection#GtkMultiSelection-struct), [GtkNoSelection](gtknoselection#GtkNoSelection-struct) and [GtkSingleSelection](gtksingleselection#GtkSingleSelection-struct).
Includes
--------
```
#include <gtk/gtk.h>
```
Description
-----------
[GtkSelectionModel](gtkselectionmodel#GtkSelectionModel-struct) is an interface that extends the GListModel interface by adding support for selections. This support is then used by widgets using list models to add the ability to select and unselect various items.
GTK provides default implementations of the most common selection modes such as [GtkSingleSelection](gtksingleselection#GtkSingleSelection-struct), so you will only need to implement this interface if you want detailed control about how selections should be handled.
A [GtkSelectionModel](gtkselectionmodel#GtkSelectionModel-struct) supports a single boolean per item indicating if an item is selected or not. This can be queried via [`gtk_selection_model_is_selected()`](gtkselectionmodel#gtk-selection-model-is-selected). When the selected state of one or more items changes, the model will emit the [“selection-changed”](gtkselectionmodel#GtkSelectionModel-selection-changed) signal by calling the [`gtk_selection_model_selection_changed()`](gtkselectionmodel#gtk-selection-model-selection-changed) function. The positions given in that signal may have their selection state changed, though that is not a requirement. If new items added to the model via the “items-changed” signal are selected or not is up to the implementation.
Note that items added via “items-changed” may already be selected and no [“selection-changed”](gtkselectionmodel#GtkSelectionModel-selection-changed) will be emitted for them. So to track which items are selected, it is necessary to listen to both signals.
Additionally, the interface can expose functionality to select and unselect items. If these functions are implemented, GTK's list widgets will allow users to select and unselect items. However, [GtkSelectionModels](gtkselectionmodel#GtkSelectionModel-struct) are free to only implement them partially or not at all. In that case the widgets will not support the unimplemented operations.
When selecting or unselecting is supported by a model, the return values of the selection functions do \*not\* indicate if selection or unselection happened. They are only meant to indicate complete failure, like when this mode of selecting is not supported by the model.
Selections may happen asynchronously, so the only reliable way to find out when an item was selected is to listen to the signals that indicate selection.
Functions
---------
### gtk\_selection\_model\_is\_selected ()
```
gboolean
gtk_selection_model_is_selected (*`[GtkSelectionModel](gtkselectionmodel#GtkSelectionModel-struct) *model`*,
*`guint position`*);
```
Checks if the given item is selected.
#### Parameters
| | | |
| --- | --- | --- |
| model | a [GtkSelectionModel](gtkselectionmodel#GtkSelectionModel-struct) | |
| position | the position of the item to query | |
#### Returns
`TRUE` if the item is selected
### gtk\_selection\_model\_get\_selection ()
```
[GtkBitset](gtkbitset#GtkBitset-struct) *
gtk_selection_model_get_selection (*`[GtkSelectionModel](gtkselectionmodel#GtkSelectionModel-struct) *model`*);
```
Gets the set containing all currently selected items in the model.
This function may be slow, so if you are only interested in single item, consider using [`gtk_selection_model_is_selected()`](gtkselectionmodel#gtk-selection-model-is-selected) or if you are only interested in a few consider [`gtk_selection_model_get_selection_in_range()`](gtkselectionmodel#gtk-selection-model-get-selection-in-range).
#### Parameters
| | | |
| --- | --- | --- |
| model | a [GtkSelectionModel](gtkselectionmodel#GtkSelectionModel-struct) | |
#### Returns
a [GtkBitset](gtkbitset#GtkBitset-struct) containing all the values currently selected in *`model`* . If no items are selected, the bitset is empty. The bitset must not be modified.
[transfer full]
### gtk\_selection\_model\_get\_selection\_in\_range ()
```
[GtkBitset](gtkbitset#GtkBitset-struct) *
gtk_selection_model_get_selection_in_range
(*`[GtkSelectionModel](gtkselectionmodel#GtkSelectionModel-struct) *model`*,
*`guint position`*,
*`guint n_items`*);
```
Gets a set containing a set where the values in the range `[position,
position + n_items)` match the selected state of the items in that range. All values outside that range are undefined.
This function is an optimization for [`gtk_selection_model_get_selection()`](gtkselectionmodel#gtk-selection-model-get-selection) when you are only interested in part of the model's selected state. A common use case is in response to the [“selection-changed”](gtkselectionmodel#GtkSelectionModel-selection-changed) signal.
#### Parameters
| | | |
| --- | --- | --- |
| model | a [GtkSelectionModel](gtkselectionmodel#GtkSelectionModel-struct) | |
| position | start of the queired range | |
| n\_items | number of items in the queried range | |
#### Returns
A [GtkBitset](gtkbitset#GtkBitset-struct) that matches the selection state for the given state with all other values being undefined. The bitset must not be modified.
### gtk\_selection\_model\_select\_item ()
```
gboolean
gtk_selection_model_select_item (*`[GtkSelectionModel](gtkselectionmodel#GtkSelectionModel-struct) *model`*,
*`guint position`*,
*`gboolean unselect_rest`*);
```
Requests to select an item in the model.
#### Parameters
| | | |
| --- | --- | --- |
| model | a [GtkSelectionModel](gtkselectionmodel#GtkSelectionModel-struct) | |
| position | the position of the item to select | |
| unselect\_rest | whether previously selected items should be unselected | |
#### Returns
`TRUE` if this action was supported and no fallback should be tried. This does not mean the item was selected.
### gtk\_selection\_model\_unselect\_item ()
```
gboolean
gtk_selection_model_unselect_item (*`[GtkSelectionModel](gtkselectionmodel#GtkSelectionModel-struct) *model`*,
*`guint position`*);
```
Requests to unselect an item in the model.
#### Parameters
| | | |
| --- | --- | --- |
| model | a [GtkSelectionModel](gtkselectionmodel#GtkSelectionModel-struct) | |
| position | the position of the item to unselect | |
#### Returns
`TRUE` if this action was supported and no fallback should be tried. This does not mean the item was unselected.
### gtk\_selection\_model\_select\_range ()
```
gboolean
gtk_selection_model_select_range (*`[GtkSelectionModel](gtkselectionmodel#GtkSelectionModel-struct) *model`*,
*`guint position`*,
*`guint n_items`*,
*`gboolean unselect_rest`*);
```
Requests to select a range of items in the model.
#### Parameters
| | | |
| --- | --- | --- |
| model | a [GtkSelectionModel](gtkselectionmodel#GtkSelectionModel-struct) | |
| position | the first item to select | |
| n\_items | the number of items to select | |
| unselect\_rest | whether previously selected items should be unselected | |
#### Returns
`TRUE` if this action was supported and no fallback should be tried. This does not mean the range was selected.
### gtk\_selection\_model\_unselect\_range ()
```
gboolean
gtk_selection_model_unselect_range (*`[GtkSelectionModel](gtkselectionmodel#GtkSelectionModel-struct) *model`*,
*`guint position`*,
*`guint n_items`*);
```
Requests to unselect a range of items in the model.
#### Parameters
| | | |
| --- | --- | --- |
| model | a [GtkSelectionModel](gtkselectionmodel#GtkSelectionModel-struct) | |
| position | the first item to unselect | |
| n\_items | the number of items to unselect | |
#### Returns
`TRUE` if this action was supported and no fallback should be tried. This does not mean the range was unselected.
### gtk\_selection\_model\_select\_all ()
```
gboolean
gtk_selection_model_select_all (*`[GtkSelectionModel](gtkselectionmodel#GtkSelectionModel-struct) *model`*);
```
Requests to select all items in the model.
#### Parameters
| | | |
| --- | --- | --- |
| model | a [GtkSelectionModel](gtkselectionmodel#GtkSelectionModel-struct) | |
#### Returns
`TRUE` if this action was supported and no fallback should be tried. This does not mean that all items are now selected.
### gtk\_selection\_model\_unselect\_all ()
```
gboolean
gtk_selection_model_unselect_all (*`[GtkSelectionModel](gtkselectionmodel#GtkSelectionModel-struct) *model`*);
```
Requests to unselect all items in the model.
#### Parameters
| | | |
| --- | --- | --- |
| model | a [GtkSelectionModel](gtkselectionmodel#GtkSelectionModel-struct) | |
#### Returns
`TRUE` if this action was supported and no fallback should be tried. This does not mean that all items are now unselected.
### gtk\_selection\_model\_set\_selection ()
```
gboolean
gtk_selection_model_set_selection (*`[GtkSelectionModel](gtkselectionmodel#GtkSelectionModel-struct) *model`*,
*`[GtkBitset](gtkbitset#GtkBitset-struct) *selected`*,
*`[GtkBitset](gtkbitset#GtkBitset-struct) *mask`*);
```
This is the most advanced selection updating method that allows the most fine-grained control over selection changes. If you can, you should try the simpler versions, as implementations are more likely to implement support for those.
Requests that the selection state of all positions set in *`mask`* be updated to the respective value in the *`selected`* bitmask.
In pseudocode, it would look something like this:
```
for (i = 0; i < n_items; i++)
{
// don't change values not in the mask
if (!gtk_bitset_contains (mask, i))
continue;
if (gtk_bitset_contains (selected, i))
select_item (i);
else
unselect_item (i);
}
gtk_selection_model_selection_changed (model, first_changed_item, n_changed_items);
```
| *`mask`* and *`selected`* must not be modified. They may refer to the same bitset, which would mean that every item in the set should be selected.
#### Parameters
| | | |
| --- | --- | --- |
| model | a [GtkSelectionModel](gtkselectionmodel#GtkSelectionModel-struct) | |
| selected | bitmask specifying if items should be selected or unselected | |
| mask | bitmask specifying which items should be updated | |
#### Returns
`TRUE` if this action was supported and no fallback should be tried. This does not mean that all items were updated according to the inputs.
### gtk\_selection\_model\_selection\_changed ()
```
void
gtk_selection_model_selection_changed (*`[GtkSelectionModel](gtkselectionmodel#GtkSelectionModel-struct) *model`*,
*`guint position`*,
*`guint n_items`*);
```
Helper function for implementations of [GtkSelectionModel](gtkselectionmodel#GtkSelectionModel-struct). Call this when a the selection changes to emit the [“selection-changed”](gtkselectionmodel#GtkSelectionModel-selection-changed) signal.
#### Parameters
| | | |
| --- | --- | --- |
| model | a [GtkSelectionModel](gtkselectionmodel#GtkSelectionModel-struct) | |
| position | the first changed item | |
| n\_items | the number of changed items | |
Types and Values
----------------
### GtkSelectionModel
```
typedef struct _GtkSelectionModel GtkSelectionModel;
```
Signal Details
--------------
### The `“selection-changed”` signal
```
void
user_function ([GtkSelectionModel](gtkselectionmodel#GtkSelectionModel-struct) *model,
guint position,
guint n_items,
gpointer user_data)
```
Emitted when the selection state of some of the items in *`model`* changes.
Note that this signal does not specify the new selection state of the items, they need to be queried manually. It is also not necessary for a model to change the selection state of any of the items in the selection model, though it would be rather useless to emit such a signal.
#### Parameters
| | | |
| --- | --- | --- |
| model | a [GtkSelectionModel](gtkselectionmodel#GtkSelectionModel-struct) | |
| position | The first item that may have changed | |
| n\_items | number of items with changes | |
| user\_data | user data set when the signal handler was connected. | |
Flags: Run Last
See Also
--------
GListModel, [GtkSingleSelection](gtksingleselection#GtkSingleSelection-struct)
| programming_docs |
gtk Packing Packing
=======
When creating an application, you’ll want to put more than one widget inside a window. When you do so, it becomes important to control how each widget is positioned and sized. This is where packing comes in.
GTK comes with a large variety of *layout containers* whose purpose it is to control the layout of the child widgets that are added to them. See Layout containers for an overview.
The following example shows how the GtkGrid container lets you arrange several buttons:
**Figure 3. Grid packing**
### Packing buttons
Create a new file with the following content named `example-2.c`.
```
#include <gtk/gtk.h>
static void
print_hello (GtkWidget *widget,
gpointer data)
{
g_print ("Hello World\n");
}
static void
activate (GtkApplication *app,
gpointer user_data)
{
GtkWidget *window;
GtkWidget *grid;
GtkWidget *button;
/* create a new window, and set its title */
window = gtk_application_window_new (app);
gtk_window_set_title (GTK_WINDOW (window), "Window");
/* Here we construct the container that is going pack our buttons */
grid = [`gtk_grid_new()`](gtkgrid#gtk-grid-new);
/* Pack the container in the window */
gtk_window_set_child (GTK_WINDOW (window), grid);
button = gtk_button_new_with_label ("Button 1");
g_signal_connect (button, "clicked", G_CALLBACK (print_hello), NULL);
/* Place the first button in the grid cell (0, 0), and make it fill
* just 1 cell horizontally and vertically (ie no spanning)
*/
gtk_grid_attach (GTK_GRID (grid), button, 0, 0, 1, 1);
button = gtk_button_new_with_label ("Button 2");
g_signal_connect (button, "clicked", G_CALLBACK (print_hello), NULL);
/* Place the second button in the grid cell (1, 0), and make it fill
* just 1 cell horizontally and vertically (ie no spanning)
*/
gtk_grid_attach (GTK_GRID (grid), button, 1, 0, 1, 1);
button = gtk_button_new_with_label ("Quit");
g_signal_connect_swapped (button, "clicked", G_CALLBACK (gtk_window_destroy), window);
/* Place the Quit button in the grid cell (0, 1), and make it
* span 2 columns.
*/
gtk_grid_attach (GTK_GRID (grid), button, 0, 1, 2, 1);
gtk_widget_show (window);
}
int
main (int argc,
char **argv)
{
GtkApplication *app;
int status;
app = gtk_application_new ("org.gtk.example", G_APPLICATION_FLAGS_NONE);
g_signal_connect (app, "activate", G_CALLBACK (activate), NULL);
status = g_application_run (G_APPLICATION (app), argc, argv);
g_object_unref (app);
return status;
}
```
You can compile the program above with GCC using:
```
gcc `pkg-config --cflags gtk4` -o example-2 example-2.c `pkg-config --libs gtk4`
```
gtk GtkWidgetPaintable GtkWidgetPaintable
==================
GtkWidgetPaintable — Drawing a widget elsewhere
Functions
---------
| | |
| --- | --- |
| [GdkPaintable](https://developer-old.gnome.org/gtk4/html/GdkPaintable.html#GdkPaintable-struct) \* | [gtk\_widget\_paintable\_new](gtkwidgetpaintable#gtk-widget-paintable-new) () |
| [GtkWidget](gtkwidget#GtkWidget-struct) \* | [gtk\_widget\_paintable\_get\_widget](gtkwidgetpaintable#gtk-widget-paintable-get-widget) () |
| void | [gtk\_widget\_paintable\_set\_widget](gtkwidgetpaintable#gtk-widget-paintable-set-widget) () |
Properties
----------
| | | |
| --- | --- | --- |
| [GtkWidget](gtkwidget#GtkWidget-struct) \* | [widget](gtkwidgetpaintable#GtkWidgetPaintable--widget) | Read / Write |
Types and Values
----------------
| | |
| --- | --- |
| | [GtkWidgetPaintable](gtkwidgetpaintable#GtkWidgetPaintable-struct) |
Object Hierarchy
----------------
```
GObject
╰── GtkWidgetPaintable
```
Implemented Interfaces
----------------------
GtkWidgetPaintable implements [GdkPaintable](https://developer-old.gnome.org/gtk4/html/GdkPaintable.html#GdkPaintable-struct).
Includes
--------
```
#include <gtk/gtk.h>
```
Description
-----------
GtkWidgetPaintable is an implementation of the [GdkPaintable](https://developer-old.gnome.org/gtk4/html/GdkPaintable.html#GdkPaintable-struct) interface that allows displaying the contents of a [GtkWidget](gtkwidget#GtkWidget-struct).
GtkWidgetPaintable will also take care of the widget not being in a state where it can be drawn (like when it isn't shown) and just draw nothing or where it does not have a size (like when it is hidden) and report no size in that case.
Of course, GtkWidgetPaintable allows you to monitor widgets for size changes by emitting the [“invalidate-size”](https://developer-old.gnome.org/gtk4/html/GdkPaintable.html#GdkPaintable-invalidate-size) signal whenever the size of the widget changes as well as for visual changes by emitting the [“invalidate-contents”](https://developer-old.gnome.org/gtk4/html/GdkPaintable.html#GdkPaintable-invalidate-contents) signal whenever the widget changes.
You can of course use a GtkWidgetPaintable everywhere a [GdkPaintable](https://developer-old.gnome.org/gtk4/html/GdkPaintable.html#GdkPaintable-struct) is allowed, including using it on a [GtkPicture](gtkpicture#GtkPicture-struct) (or one of its parents) that it was set on itself via [`gtk_picture_set_paintable()`](gtkpicture#gtk-picture-set-paintable). The paintable will take care of recursion when this happens. If you do this however, ensure the [“can-shrink”](gtkpicture#GtkPicture--can-shrink) property is set to `TRUE` or you might end up with an infinitely growing widget.
Functions
---------
### gtk\_widget\_paintable\_new ()
```
[GdkPaintable](https://developer-old.gnome.org/gtk4/html/GdkPaintable.html#GdkPaintable-struct) *
gtk_widget_paintable_new (*`[GtkWidget](gtkwidget#GtkWidget-struct) *widget`*);
```
Creates a new widget paintable observing the given widget.
#### Parameters
| | | |
| --- | --- | --- |
| widget | a [GtkWidget](gtkwidget#GtkWidget-struct) or `NULL`. | [allow-none][transfer none] |
#### Returns
a new [GtkWidgetPaintable](https://developer-old.gnome.org/usr/share/gtk-doc/html/gtk4/gtk4-GtkWidgetPaintable.html#GtkWidgetPaintable).
[transfer full][type GtkWidgetPaintable]
### gtk\_widget\_paintable\_get\_widget ()
```
[GtkWidget](gtkwidget#GtkWidget-struct) *
gtk_widget_paintable_get_widget (*`[GtkWidgetPaintable](https://developer-old.gnome.org/usr/share/gtk-doc/html/gtk4/gtk4-GtkWidgetPaintable.html#GtkWidgetPaintable) *self`*);
```
Returns the widget that is observed or `NULL` if none.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkWidgetPaintable](https://developer-old.gnome.org/usr/share/gtk-doc/html/gtk4/gtk4-GtkWidgetPaintable.html#GtkWidgetPaintable) | |
#### Returns
the observed widget.
[transfer none][nullable]
### gtk\_widget\_paintable\_set\_widget ()
```
void
gtk_widget_paintable_set_widget (*`[GtkWidgetPaintable](https://developer-old.gnome.org/usr/share/gtk-doc/html/gtk4/gtk4-GtkWidgetPaintable.html#GtkWidgetPaintable) *self`*,
*`[GtkWidget](gtkwidget#GtkWidget-struct) *widget`*);
```
Sets the widget that should be observed.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkWidgetPaintable](https://developer-old.gnome.org/usr/share/gtk-doc/html/gtk4/gtk4-GtkWidgetPaintable.html#GtkWidgetPaintable) | |
| widget | the widget to observe or `NULL`. | [allow-none] |
Types and Values
----------------
### GtkWidgetPaintable
```
typedef struct _GtkWidgetPaintable GtkWidgetPaintable;
```
Property Details
----------------
### The `“widget”` property
```
“widget” [GtkWidget](gtkwidget#GtkWidget-struct) *
```
The observed widget or `NULL` if none.
Owner: GtkWidgetPaintable
Flags: Read / Write
See Also
--------
[GtkWidget](gtkwidget#GtkWidget-struct), [GdkPaintable](https://developer-old.gnome.org/gtk4/html/GdkPaintable.html#GdkPaintable-struct)
gtk GtkTreeListModel GtkTreeListModel
================
GtkTreeListModel — A list model that can create child models on demand
Functions
---------
| | |
| --- | --- |
| GListModel \* | ([\*GtkTreeListModelCreateModelFunc](gtktreelistmodel#GtkTreeListModelCreateModelFunc)) () |
| [GtkTreeListModel](gtktreelistmodel#GtkTreeListModel-struct) \* | [gtk\_tree\_list\_model\_new](gtktreelistmodel#gtk-tree-list-model-new) () |
| GListModel \* | [gtk\_tree\_list\_model\_get\_model](gtktreelistmodel#gtk-tree-list-model-get-model) () |
| gboolean | [gtk\_tree\_list\_model\_get\_passthrough](gtktreelistmodel#gtk-tree-list-model-get-passthrough) () |
| void | [gtk\_tree\_list\_model\_set\_autoexpand](gtktreelistmodel#gtk-tree-list-model-set-autoexpand) () |
| gboolean | [gtk\_tree\_list\_model\_get\_autoexpand](gtktreelistmodel#gtk-tree-list-model-get-autoexpand) () |
| [GtkTreeListRow](gtktreelistmodel#GtkTreeListRow-struct) \* | [gtk\_tree\_list\_model\_get\_child\_row](gtktreelistmodel#gtk-tree-list-model-get-child-row) () |
| [GtkTreeListRow](gtktreelistmodel#GtkTreeListRow-struct) \* | [gtk\_tree\_list\_model\_get\_row](gtktreelistmodel#gtk-tree-list-model-get-row) () |
Properties
----------
| | | |
| --- | --- | --- |
| gboolean | [autoexpand](gtktreelistmodel#GtkTreeListModel--autoexpand) | Read / Write |
| GListModel \* | [model](gtktreelistmodel#GtkTreeListModel--model) | Read |
| gboolean | [passthrough](gtktreelistmodel#GtkTreeListModel--passthrough) | Read / Write / Construct Only |
| GListModel \* | [children](gtktreelistmodel#GtkTreeListRow--children) | Read |
| guint | [depth](gtktreelistmodel#GtkTreeListRow--depth) | Read |
| gboolean | [expandable](gtktreelistmodel#GtkTreeListRow--expandable) | Read |
| gboolean | [expanded](gtktreelistmodel#GtkTreeListRow--expanded) | Read / Write |
| GObject \* | [item](gtktreelistmodel#GtkTreeListRow--item) | Read |
Types and Values
----------------
| | |
| --- | --- |
| | [GtkTreeListModel](gtktreelistmodel#GtkTreeListModel-struct) |
| | [GtkTreeListRow](gtktreelistmodel#GtkTreeListRow-struct) |
Object Hierarchy
----------------
```
GObject
├── GtkTreeListModel
╰── GtkTreeListRow
```
Implemented Interfaces
----------------------
GtkTreeListModel implements GListModel.
Includes
--------
```
#include <gtk/gtk.h>
```
Description
-----------
[GtkTreeListModel](gtktreelistmodel#GtkTreeListModel-struct) is a GListModel implementation that can expand rows by creating new child list models on demand.
Functions
---------
### GtkTreeListModelCreateModelFunc ()
```
GListModel *
(*GtkTreeListModelCreateModelFunc) (gpointer item,
gpointer user_data);
```
Prototype of the function called to create new child models when [`gtk_tree_list_row_set_expanded()`](gtktreelistrow#gtk-tree-list-row-set-expanded) is called.
This function can return `NULL` to indicate that *`item`* is guaranteed to be a leaf node and will never have children. If it does not have children but may get children later, it should return an empty model that is filled once children arrive.
#### Parameters
| | | |
| --- | --- | --- |
| item | The item that is being expanded. | [type GObject] |
| user\_data | User data passed when registering the function | |
#### Returns
The model tracking the children of *`item`* or `NULL` if *`item`* can never have children.
[nullable][transfer full]
### gtk\_tree\_list\_model\_new ()
```
[GtkTreeListModel](gtktreelistmodel#GtkTreeListModel-struct) *
gtk_tree_list_model_new (*`GListModel *root`*,
*`gboolean passthrough`*,
*`gboolean autoexpand`*,
*`[GtkTreeListModelCreateModelFunc](gtktreelistmodel#GtkTreeListModelCreateModelFunc) create_func`*,
*`gpointer user_data`*,
*`GDestroyNotify user_destroy`*);
```
Creates a new empty [GtkTreeListModel](gtktreelistmodel#GtkTreeListModel-struct) displaying *`root`* with all rows collapsed.
#### Parameters
| | | |
| --- | --- | --- |
| root | The GListModel to use as root. | [transfer full] |
| passthrough | `TRUE` to pass through items from the models | |
| autoexpand | `TRUE` to set the autoexpand property and expand the *`root`* model | |
| create\_func | Function to call to create the GListModel for the children of an item | |
| user\_data | Data to pass to *`create_func`* . | [closure] |
| user\_destroy | Function to call to free *`user_data`* | |
#### Returns
a newly created [GtkTreeListModel](gtktreelistmodel#GtkTreeListModel-struct).
### gtk\_tree\_list\_model\_get\_model ()
```
GListModel *
gtk_tree_list_model_get_model (*`[GtkTreeListModel](gtktreelistmodel#GtkTreeListModel-struct) *self`*);
```
Gets the root model that *`self`* was created with.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkTreeListModel](gtktreelistmodel#GtkTreeListModel-struct) | |
#### Returns
the root model.
[transfer none]
### gtk\_tree\_list\_model\_get\_passthrough ()
```
gboolean
gtk_tree_list_model_get_passthrough (*`[GtkTreeListModel](gtktreelistmodel#GtkTreeListModel-struct) *self`*);
```
If this function returns `FALSE`, the GListModel functions for *`self`* return custom [GtkTreeListRow](gtktreelistmodel#GtkTreeListRow-struct) objects. You need to call [`gtk_tree_list_row_get_item()`](gtktreelistrow#gtk-tree-list-row-get-item) on these objects to get the original item.
If `TRUE`, the values of the child models are passed through in their original state. You then need to call [`gtk_tree_list_model_get_row()`](gtktreelistmodel#gtk-tree-list-model-get-row) to get the custom [GtkTreeListRows](gtktreelistmodel#GtkTreeListRow-struct).
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkTreeListModel](gtktreelistmodel#GtkTreeListModel-struct) | |
#### Returns
`TRUE` if the model is passing through original row items
### gtk\_tree\_list\_model\_set\_autoexpand ()
```
void
gtk_tree_list_model_set_autoexpand (*`[GtkTreeListModel](gtktreelistmodel#GtkTreeListModel-struct) *self`*,
*`gboolean autoexpand`*);
```
If set to `TRUE`, the model will recursively expand all rows that get added to the model. This can be either rows added by changes to the underlying models or via [`gtk_tree_list_row_set_expanded()`](gtktreelistrow#gtk-tree-list-row-set-expanded).
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkTreeListModel](gtktreelistmodel#GtkTreeListModel-struct) | |
| autoexpand | `TRUE` to make the model autoexpand its rows | |
### gtk\_tree\_list\_model\_get\_autoexpand ()
```
gboolean
gtk_tree_list_model_get_autoexpand (*`[GtkTreeListModel](gtktreelistmodel#GtkTreeListModel-struct) *self`*);
```
Gets whether the model is set to automatically expand new rows that get added. This can be either rows added by changes to the underlying models or via [`gtk_tree_list_row_set_expanded()`](gtktreelistrow#gtk-tree-list-row-set-expanded).
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkTreeListModel](gtktreelistmodel#GtkTreeListModel-struct) | |
#### Returns
`TRUE` if the model is set to autoexpand
### gtk\_tree\_list\_model\_get\_child\_row ()
```
[GtkTreeListRow](gtktreelistmodel#GtkTreeListRow-struct) *
gtk_tree_list_model_get_child_row (*`[GtkTreeListModel](gtktreelistmodel#GtkTreeListModel-struct) *self`*,
*`guint position`*);
```
Gets the row item corresponding to the child at index *`position`* for *`self`* 's root model.
If *`position`* is greater than the number of children in the root model, `NULL` is returned.
Do not confuse this function with [`gtk_tree_list_model_get_row()`](gtktreelistmodel#gtk-tree-list-model-get-row).
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkTreeListModel](gtktreelistmodel#GtkTreeListModel-struct) | |
| position | position of the child to get | |
#### Returns
the child in *`position`* .
[nullable][transfer full]
### gtk\_tree\_list\_model\_get\_row ()
```
[GtkTreeListRow](gtktreelistmodel#GtkTreeListRow-struct) *
gtk_tree_list_model_get_row (*`[GtkTreeListModel](gtktreelistmodel#GtkTreeListModel-struct) *self`*,
*`guint position`*);
```
Gets the row object for the given row. If *`position`* is greater than the number of items in *`self`* , `NULL` is returned.
The row object can be used to expand and collapse rows as well as to inspect its position in the tree. See its documentation for details.
This row object is persistent and will refer to the current item as long as the row is present in *`self`* , independent of other rows being added or removed.
If *`self`* is set to not be passthrough, this function is equivalent to calling `g_list_model_get_item()`.
Do not confuse this function with [`gtk_tree_list_model_get_child_row()`](gtktreelistmodel#gtk-tree-list-model-get-child-row).
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkTreeListModel](gtktreelistmodel#GtkTreeListModel-struct) | |
| position | the position of the row to fetch | |
#### Returns
The row item.
[nullable][transfer full]
Types and Values
----------------
### GtkTreeListModel
```
typedef struct _GtkTreeListModel GtkTreeListModel;
```
### GtkTreeListRow
```
typedef struct _GtkTreeListRow GtkTreeListRow;
```
Property Details
----------------
### The `“autoexpand”` property
```
“autoexpand” gboolean
```
If all rows should be expanded by default
Owner: GtkTreeListModel
Flags: Read / Write
Default value: FALSE
### The `“model”` property
```
“model” GListModel *
```
The root model displayed
Owner: GtkTreeListModel
Flags: Read
### The `“passthrough”` property
```
“passthrough” gboolean
```
If `FALSE`, the GListModel functions for this object return custom [GtkTreeListRow](gtktreelistmodel#GtkTreeListRow-struct) objects. If `TRUE`, the values of the child models are pass through unmodified.
Owner: GtkTreeListModel
Flags: Read / Write / Construct Only
Default value: FALSE
### The `“children”` property
```
“children” GListModel *
```
The model holding the row's children.
Owner: GtkTreeListRow
Flags: Read
### The `“depth”` property
```
“depth” guint
```
The depth in the tree of this row
Owner: GtkTreeListRow
Flags: Read
Default value: 0
### The `“expandable”` property
```
“expandable” gboolean
```
If this row can ever be expanded
Owner: GtkTreeListRow
Flags: Read
Default value: FALSE
### The `“expanded”` property
```
“expanded” gboolean
```
If this row is currently expanded
Owner: GtkTreeListRow
Flags: Read / Write
Default value: FALSE
### The `“item”` property
```
“item” GObject *
```
The item held in this row
Owner: GtkTreeListRow
Flags: Read
See Also
--------
GListModel
gtk GtkPaperSize GtkPaperSize
============
GtkPaperSize — Support for named paper sizes
Functions
---------
| | |
| --- | --- |
| [GtkPaperSize](gtkpapersize#GtkPaperSize-struct) \* | [gtk\_paper\_size\_new](gtkpapersize#gtk-paper-size-new) () |
| [GtkPaperSize](gtkpapersize#GtkPaperSize-struct) \* | [gtk\_paper\_size\_new\_from\_ppd](gtkpapersize#gtk-paper-size-new-from-ppd) () |
| [GtkPaperSize](gtkpapersize#GtkPaperSize-struct) \* | [gtk\_paper\_size\_new\_from\_ipp](gtkpapersize#gtk-paper-size-new-from-ipp) () |
| [GtkPaperSize](gtkpapersize#GtkPaperSize-struct) \* | [gtk\_paper\_size\_new\_custom](gtkpapersize#gtk-paper-size-new-custom) () |
| [GtkPaperSize](gtkpapersize#GtkPaperSize-struct) \* | [gtk\_paper\_size\_copy](gtkpapersize#gtk-paper-size-copy) () |
| void | [gtk\_paper\_size\_free](gtkpapersize#gtk-paper-size-free) () |
| gboolean | [gtk\_paper\_size\_is\_equal](gtkpapersize#gtk-paper-size-is-equal) () |
| GList \* | [gtk\_paper\_size\_get\_paper\_sizes](gtkpapersize#gtk-paper-size-get-paper-sizes) () |
| const char \* | [gtk\_paper\_size\_get\_name](gtkpapersize#gtk-paper-size-get-name) () |
| const char \* | [gtk\_paper\_size\_get\_display\_name](gtkpapersize#gtk-paper-size-get-display-name) () |
| const char \* | [gtk\_paper\_size\_get\_ppd\_name](gtkpapersize#gtk-paper-size-get-ppd-name) () |
| double | [gtk\_paper\_size\_get\_width](gtkpapersize#gtk-paper-size-get-width) () |
| double | [gtk\_paper\_size\_get\_height](gtkpapersize#gtk-paper-size-get-height) () |
| gboolean | [gtk\_paper\_size\_is\_ipp](gtkpapersize#gtk-paper-size-is-ipp) () |
| gboolean | [gtk\_paper\_size\_is\_custom](gtkpapersize#gtk-paper-size-is-custom) () |
| void | [gtk\_paper\_size\_set\_size](gtkpapersize#gtk-paper-size-set-size) () |
| double | [gtk\_paper\_size\_get\_default\_top\_margin](gtkpapersize#gtk-paper-size-get-default-top-margin) () |
| double | [gtk\_paper\_size\_get\_default\_bottom\_margin](gtkpapersize#gtk-paper-size-get-default-bottom-margin) () |
| double | [gtk\_paper\_size\_get\_default\_left\_margin](gtkpapersize#gtk-paper-size-get-default-left-margin) () |
| double | [gtk\_paper\_size\_get\_default\_right\_margin](gtkpapersize#gtk-paper-size-get-default-right-margin) () |
| const char \* | [gtk\_paper\_size\_get\_default](gtkpapersize#gtk-paper-size-get-default) () |
| [GtkPaperSize](gtkpapersize#GtkPaperSize-struct) \* | [gtk\_paper\_size\_new\_from\_key\_file](gtkpapersize#gtk-paper-size-new-from-key-file) () |
| [GtkPaperSize](gtkpapersize#GtkPaperSize-struct) \* | [gtk\_paper\_size\_new\_from\_gvariant](gtkpapersize#gtk-paper-size-new-from-gvariant) () |
| void | [gtk\_paper\_size\_to\_key\_file](gtkpapersize#gtk-paper-size-to-key-file) () |
| GVariant \* | [gtk\_paper\_size\_to\_gvariant](gtkpapersize#gtk-paper-size-to-gvariant) () |
Types and Values
----------------
| | |
| --- | --- |
| | [GtkPaperSize](gtkpapersize#GtkPaperSize-struct) |
| enum | [GtkUnit](gtkpapersize#GtkUnit) |
| #define | [GTK\_UNIT\_PIXEL](gtkpapersize#GTK-UNIT-PIXEL:CAPS) |
| #define | [GTK\_PAPER\_NAME\_A3](gtkpapersize#GTK-PAPER-NAME-A3:CAPS) |
| #define | [GTK\_PAPER\_NAME\_A4](gtkpapersize#GTK-PAPER-NAME-A4:CAPS) |
| #define | [GTK\_PAPER\_NAME\_A5](gtkpapersize#GTK-PAPER-NAME-A5:CAPS) |
| #define | [GTK\_PAPER\_NAME\_B5](gtkpapersize#GTK-PAPER-NAME-B5:CAPS) |
| #define | [GTK\_PAPER\_NAME\_LETTER](gtkpapersize#GTK-PAPER-NAME-LETTER:CAPS) |
| #define | [GTK\_PAPER\_NAME\_EXECUTIVE](gtkpapersize#GTK-PAPER-NAME-EXECUTIVE:CAPS) |
| #define | [GTK\_PAPER\_NAME\_LEGAL](gtkpapersize#GTK-PAPER-NAME-LEGAL:CAPS) |
Object Hierarchy
----------------
```
[GBoxed](https://developer-old.gnome.org/gobject/stable/gobject-Boxed-Types.html)
╰── GtkPaperSize
```
Includes
--------
```
#include <gtk/gtk.h>
```
Description
-----------
GtkPaperSize handles paper sizes. It uses the standard called [PWG 5101.1-2002 PWG: Standard for Media Standardized Names](http://www.pwg.org/standards.html) to name the paper sizes (and to get the data for the page sizes). In addition to standard paper sizes, GtkPaperSize allows to construct custom paper sizes with arbitrary dimensions.
The [GtkPaperSize](gtkpapersize#GtkPaperSize-struct) object stores not only the dimensions (width and height) of a paper size and its name, it also provides default print margins.
Functions
---------
### gtk\_paper\_size\_new ()
```
[GtkPaperSize](gtkpapersize#GtkPaperSize-struct) *
gtk_paper_size_new (*`const char *name`*);
```
Creates a new [GtkPaperSize](gtkpapersize#GtkPaperSize-struct) object by parsing a [PWG 5101.1-2002](ftp://ftp.pwg.org/pub/pwg/candidates/cs-pwgmsn10-20020226-5101.1.pdf) paper name.
If *`name`* is `NULL`, the default paper size is returned, see [`gtk_paper_size_get_default()`](gtkpapersize#gtk-paper-size-get-default).
#### Parameters
| | | |
| --- | --- | --- |
| name | a paper size name, or `NULL`. | [allow-none] |
#### Returns
a new [GtkPaperSize](gtkpapersize#GtkPaperSize-struct), use [`gtk_paper_size_free()`](gtkpapersize#gtk-paper-size-free) to free it
### gtk\_paper\_size\_new\_from\_ppd ()
```
[GtkPaperSize](gtkpapersize#GtkPaperSize-struct) *
gtk_paper_size_new_from_ppd (*`const char *ppd_name`*,
*`const char *ppd_display_name`*,
*`double width`*,
*`double height`*);
```
Creates a new [GtkPaperSize](gtkpapersize#GtkPaperSize-struct) object by using PPD information.
If *`ppd_name`* is not a recognized PPD paper name, *`ppd_display_name`* , *`width`* and *`height`* are used to construct a custom [GtkPaperSize](gtkpapersize#GtkPaperSize-struct) object.
#### Parameters
| | | |
| --- | --- | --- |
| ppd\_name | a PPD paper name | |
| ppd\_display\_name | the corresponding human-readable name | |
| width | the paper width, in points | |
| height | the paper height in points | |
#### Returns
a new [GtkPaperSize](gtkpapersize#GtkPaperSize-struct), use [`gtk_paper_size_free()`](gtkpapersize#gtk-paper-size-free) to free it
### gtk\_paper\_size\_new\_from\_ipp ()
```
[GtkPaperSize](gtkpapersize#GtkPaperSize-struct) *
gtk_paper_size_new_from_ipp (*`const char *ipp_name`*,
*`double width`*,
*`double height`*);
```
Creates a new [GtkPaperSize](gtkpapersize#GtkPaperSize-struct) object by using IPP information.
If *`ipp_name`* is not a recognized paper name, *`width`* and *`height`* are used to construct a custom [GtkPaperSize](gtkpapersize#GtkPaperSize-struct) object.
#### Parameters
| | | |
| --- | --- | --- |
| ipp\_name | an IPP paper name | |
| width | the paper width, in points | |
| height | the paper height in points | |
#### Returns
a new [GtkPaperSize](gtkpapersize#GtkPaperSize-struct), use [`gtk_paper_size_free()`](gtkpapersize#gtk-paper-size-free) to free it
### gtk\_paper\_size\_new\_custom ()
```
[GtkPaperSize](gtkpapersize#GtkPaperSize-struct) *
gtk_paper_size_new_custom (*`const char *name`*,
*`const char *display_name`*,
*`double width`*,
*`double height`*,
*`[GtkUnit](gtkpapersize#GtkUnit) unit`*);
```
Creates a new [GtkPaperSize](gtkpapersize#GtkPaperSize-struct) object with the given parameters.
#### Parameters
| | | |
| --- | --- | --- |
| name | the paper name | |
| display\_name | the human-readable name | |
| width | the paper width, in units of *`unit`* | |
| height | the paper height, in units of *`unit`* | |
| unit | the unit for *`width`* and *`height`* . not [`GTK_UNIT_NONE`](gtkpapersize#GTK-UNIT-NONE:CAPS). | |
#### Returns
a new [GtkPaperSize](gtkpapersize#GtkPaperSize-struct) object, use [`gtk_paper_size_free()`](gtkpapersize#gtk-paper-size-free) to free it
### gtk\_paper\_size\_copy ()
```
[GtkPaperSize](gtkpapersize#GtkPaperSize-struct) *
gtk_paper_size_copy (*`[GtkPaperSize](gtkpapersize#GtkPaperSize-struct) *other`*);
```
Copies an existing [GtkPaperSize](gtkpapersize#GtkPaperSize-struct).
#### Parameters
| | | |
| --- | --- | --- |
| other | a [GtkPaperSize](gtkpapersize#GtkPaperSize-struct) | |
#### Returns
a copy of *`other`*
### gtk\_paper\_size\_free ()
```
void
gtk_paper_size_free (*`[GtkPaperSize](gtkpapersize#GtkPaperSize-struct) *size`*);
```
Free the given [GtkPaperSize](gtkpapersize#GtkPaperSize-struct) object.
#### Parameters
| | | |
| --- | --- | --- |
| size | a [GtkPaperSize](gtkpapersize#GtkPaperSize-struct) | |
### gtk\_paper\_size\_is\_equal ()
```
gboolean
gtk_paper_size_is_equal (*`[GtkPaperSize](gtkpapersize#GtkPaperSize-struct) *size1`*,
*`[GtkPaperSize](gtkpapersize#GtkPaperSize-struct) *size2`*);
```
Compares two [GtkPaperSize](gtkpapersize#GtkPaperSize-struct) objects.
#### Parameters
| | | |
| --- | --- | --- |
| size1 | a [GtkPaperSize](gtkpapersize#GtkPaperSize-struct) object | |
| size2 | another [GtkPaperSize](gtkpapersize#GtkPaperSize-struct) object | |
#### Returns
`TRUE`, if *`size1`* and *`size2`* represent the same paper size
### gtk\_paper\_size\_get\_paper\_sizes ()
```
GList *
gtk_paper_size_get_paper_sizes (gboolean include_custom);
```
Creates a list of known paper sizes.
#### Parameters
| | | |
| --- | --- | --- |
| include\_custom | whether to include custom paper sizes as defined in the page setup dialog | |
#### Returns
a newly allocated list of newly allocated [GtkPaperSize](gtkpapersize#GtkPaperSize-struct) objects.
[element-type GtkPaperSize][transfer full]
### gtk\_paper\_size\_get\_name ()
```
const char *
gtk_paper_size_get_name (*`[GtkPaperSize](gtkpapersize#GtkPaperSize-struct) *size`*);
```
Gets the name of the [GtkPaperSize](gtkpapersize#GtkPaperSize-struct).
#### Parameters
| | | |
| --- | --- | --- |
| size | a [GtkPaperSize](gtkpapersize#GtkPaperSize-struct) object | |
#### Returns
the name of *`size`*
### gtk\_paper\_size\_get\_display\_name ()
```
const char *
gtk_paper_size_get_display_name (*`[GtkPaperSize](gtkpapersize#GtkPaperSize-struct) *size`*);
```
Gets the human-readable name of the [GtkPaperSize](gtkpapersize#GtkPaperSize-struct).
#### Parameters
| | | |
| --- | --- | --- |
| size | a [GtkPaperSize](gtkpapersize#GtkPaperSize-struct) object | |
#### Returns
the human-readable name of *`size`*
### gtk\_paper\_size\_get\_ppd\_name ()
```
const char *
gtk_paper_size_get_ppd_name (*`[GtkPaperSize](gtkpapersize#GtkPaperSize-struct) *size`*);
```
Gets the PPD name of the [GtkPaperSize](gtkpapersize#GtkPaperSize-struct), which may be `NULL`.
#### Parameters
| | | |
| --- | --- | --- |
| size | a [GtkPaperSize](gtkpapersize#GtkPaperSize-struct) object | |
#### Returns
the PPD name of *`size`*
### gtk\_paper\_size\_get\_width ()
```
double
gtk_paper_size_get_width (*`[GtkPaperSize](gtkpapersize#GtkPaperSize-struct) *size`*,
*`[GtkUnit](gtkpapersize#GtkUnit) unit`*);
```
Gets the paper width of the [GtkPaperSize](gtkpapersize#GtkPaperSize-struct), in units of *`unit`* .
#### Parameters
| | | |
| --- | --- | --- |
| size | a [GtkPaperSize](gtkpapersize#GtkPaperSize-struct) object | |
| unit | the unit for the return value, not [`GTK_UNIT_NONE`](gtkpapersize#GTK-UNIT-NONE:CAPS) | |
#### Returns
the paper width
### gtk\_paper\_size\_get\_height ()
```
double
gtk_paper_size_get_height (*`[GtkPaperSize](gtkpapersize#GtkPaperSize-struct) *size`*,
*`[GtkUnit](gtkpapersize#GtkUnit) unit`*);
```
Gets the paper height of the [GtkPaperSize](gtkpapersize#GtkPaperSize-struct), in units of *`unit`* .
#### Parameters
| | | |
| --- | --- | --- |
| size | a [GtkPaperSize](gtkpapersize#GtkPaperSize-struct) object | |
| unit | the unit for the return value, not [`GTK_UNIT_NONE`](gtkpapersize#GTK-UNIT-NONE:CAPS) | |
#### Returns
the paper height
### gtk\_paper\_size\_is\_ipp ()
```
gboolean
gtk_paper_size_is_ipp (*`[GtkPaperSize](gtkpapersize#GtkPaperSize-struct) *size`*);
```
Returns `TRUE` if *`size`* is an IPP standard paper size.
#### Parameters
| | | |
| --- | --- | --- |
| size | a [GtkPaperSize](gtkpapersize#GtkPaperSize-struct) object | |
#### Returns
whether *`size`* is not an IPP custom paper size.
### gtk\_paper\_size\_is\_custom ()
```
gboolean
gtk_paper_size_is_custom (*`[GtkPaperSize](gtkpapersize#GtkPaperSize-struct) *size`*);
```
Returns `TRUE` if *`size`* is not a standard paper size.
#### Parameters
| | | |
| --- | --- | --- |
| size | a [GtkPaperSize](gtkpapersize#GtkPaperSize-struct) object | |
#### Returns
whether *`size`* is a custom paper size.
### gtk\_paper\_size\_set\_size ()
```
void
gtk_paper_size_set_size (*`[GtkPaperSize](gtkpapersize#GtkPaperSize-struct) *size`*,
*`double width`*,
*`double height`*,
*`[GtkUnit](gtkpapersize#GtkUnit) unit`*);
```
Changes the dimensions of a *`size`* to *`width`* x *`height`* .
#### Parameters
| | | |
| --- | --- | --- |
| size | a custom [GtkPaperSize](gtkpapersize#GtkPaperSize-struct) object | |
| width | the new width in units of *`unit`* | |
| height | the new height in units of *`unit`* | |
| unit | the unit for *`width`* and *`height`* | |
### gtk\_paper\_size\_get\_default\_top\_margin ()
```
double
gtk_paper_size_get_default_top_margin (*`[GtkPaperSize](gtkpapersize#GtkPaperSize-struct) *size`*,
*`[GtkUnit](gtkpapersize#GtkUnit) unit`*);
```
Gets the default top margin for the [GtkPaperSize](gtkpapersize#GtkPaperSize-struct).
#### Parameters
| | | |
| --- | --- | --- |
| size | a [GtkPaperSize](gtkpapersize#GtkPaperSize-struct) object | |
| unit | the unit for the return value, not [`GTK_UNIT_NONE`](gtkpapersize#GTK-UNIT-NONE:CAPS) | |
#### Returns
the default top margin
### gtk\_paper\_size\_get\_default\_bottom\_margin ()
```
double
gtk_paper_size_get_default_bottom_margin
(*`[GtkPaperSize](gtkpapersize#GtkPaperSize-struct) *size`*,
*`[GtkUnit](gtkpapersize#GtkUnit) unit`*);
```
Gets the default bottom margin for the [GtkPaperSize](gtkpapersize#GtkPaperSize-struct).
#### Parameters
| | | |
| --- | --- | --- |
| size | a [GtkPaperSize](gtkpapersize#GtkPaperSize-struct) object | |
| unit | the unit for the return value, not [`GTK_UNIT_NONE`](gtkpapersize#GTK-UNIT-NONE:CAPS) | |
#### Returns
the default bottom margin
### gtk\_paper\_size\_get\_default\_left\_margin ()
```
double
gtk_paper_size_get_default_left_margin
(*`[GtkPaperSize](gtkpapersize#GtkPaperSize-struct) *size`*,
*`[GtkUnit](gtkpapersize#GtkUnit) unit`*);
```
Gets the default left margin for the [GtkPaperSize](gtkpapersize#GtkPaperSize-struct).
#### Parameters
| | | |
| --- | --- | --- |
| size | a [GtkPaperSize](gtkpapersize#GtkPaperSize-struct) object | |
| unit | the unit for the return value, not [`GTK_UNIT_NONE`](gtkpapersize#GTK-UNIT-NONE:CAPS) | |
#### Returns
the default left margin
### gtk\_paper\_size\_get\_default\_right\_margin ()
```
double
gtk_paper_size_get_default_right_margin
(*`[GtkPaperSize](gtkpapersize#GtkPaperSize-struct) *size`*,
*`[GtkUnit](gtkpapersize#GtkUnit) unit`*);
```
Gets the default right margin for the [GtkPaperSize](gtkpapersize#GtkPaperSize-struct).
#### Parameters
| | | |
| --- | --- | --- |
| size | a [GtkPaperSize](gtkpapersize#GtkPaperSize-struct) object | |
| unit | the unit for the return value, not [`GTK_UNIT_NONE`](gtkpapersize#GTK-UNIT-NONE:CAPS) | |
#### Returns
the default right margin
### gtk\_paper\_size\_get\_default ()
```
const char *
gtk_paper_size_get_default (void);
```
Returns the name of the default paper size, which depends on the current locale.
#### Returns
the name of the default paper size. The string is owned by GTK and should not be modified.
### gtk\_paper\_size\_new\_from\_key\_file ()
```
[GtkPaperSize](gtkpapersize#GtkPaperSize-struct) *
gtk_paper_size_new_from_key_file (*`GKeyFile *key_file`*,
*`const char *group_name`*,
*`GError **error`*);
```
Reads a paper size from the group *`group_name`* in the key file *`key_file`* .
#### Parameters
| | | |
| --- | --- | --- |
| key\_file | the GKeyFile to retrieve the papersize from | |
| group\_name | the name of the group in the key file to read, or `NULL` to read the first group. | [nullable] |
| error | return location for an error, or `NULL`. | [allow-none] |
#### Returns
a new [GtkPaperSize](gtkpapersize#GtkPaperSize-struct) object with the restored paper size, or `NULL` if an error occurred
### gtk\_paper\_size\_new\_from\_gvariant ()
```
[GtkPaperSize](gtkpapersize#GtkPaperSize-struct) *
gtk_paper_size_new_from_gvariant (*`GVariant *variant`*);
```
Deserialize a paper size from an a{sv} variant in the format produced by [`gtk_paper_size_to_gvariant()`](gtkpapersize#gtk-paper-size-to-gvariant).
#### Parameters
| | | |
| --- | --- | --- |
| variant | an a{sv} GVariant | |
#### Returns
a new [GtkPaperSize](gtkpapersize#GtkPaperSize-struct) object.
[transfer full]
### gtk\_paper\_size\_to\_key\_file ()
```
void
gtk_paper_size_to_key_file (*`[GtkPaperSize](gtkpapersize#GtkPaperSize-struct) *size`*,
*`GKeyFile *key_file`*,
*`const char *group_name`*);
```
This function adds the paper size from *`size`* to *`key_file`* .
#### Parameters
| | | |
| --- | --- | --- |
| size | a [GtkPaperSize](gtkpapersize#GtkPaperSize-struct) | |
| key\_file | the GKeyFile to save the paper size to | |
| group\_name | the group to add the settings to in *`key_file`* | |
### gtk\_paper\_size\_to\_gvariant ()
```
GVariant *
gtk_paper_size_to_gvariant (*`[GtkPaperSize](gtkpapersize#GtkPaperSize-struct) *paper_size`*);
```
Serialize a paper size to an a{sv} variant.
#### Parameters
| | | |
| --- | --- | --- |
| paper\_size | a [GtkPaperSize](gtkpapersize#GtkPaperSize-struct) | |
#### Returns
a new, floating, GVariant.
[transfer none]
Types and Values
----------------
### GtkPaperSize
```
typedef struct _GtkPaperSize GtkPaperSize;
```
### enum GtkUnit
See also [`gtk_print_settings_set_paper_width()`](gtkprintsettings#gtk-print-settings-set-paper-width).
#### Members
| | | |
| --- | --- | --- |
| GTK\_UNIT\_NONE | No units. | |
| GTK\_UNIT\_POINTS | Dimensions in points. | |
| GTK\_UNIT\_INCH | Dimensions in inches. | |
| GTK\_UNIT\_MM | Dimensions in millimeters | |
### GTK\_UNIT\_PIXEL
```
#define GTK_UNIT_PIXEL GTK_UNIT_NONE
```
### GTK\_PAPER\_NAME\_A3
```
#define GTK_PAPER_NAME_A3 "iso_a3"
```
Name for the A3 paper size.
### GTK\_PAPER\_NAME\_A4
```
#define GTK_PAPER_NAME_A4 "iso_a4"
```
Name for the A4 paper size.
### GTK\_PAPER\_NAME\_A5
```
#define GTK_PAPER_NAME_A5 "iso_a5"
```
Name for the A5 paper size.
### GTK\_PAPER\_NAME\_B5
```
#define GTK_PAPER_NAME_B5 "iso_b5"
```
Name for the B5 paper size.
### GTK\_PAPER\_NAME\_LETTER
```
#define GTK_PAPER_NAME_LETTER "na_letter"
```
Name for the Letter paper size.
### GTK\_PAPER\_NAME\_EXECUTIVE
```
#define GTK_PAPER_NAME_EXECUTIVE "na_executive"
```
Name for the Executive paper size.
### GTK\_PAPER\_NAME\_LEGAL
```
#define GTK_PAPER_NAME_LEGAL "na_legal"
```
Name for the Legal paper size.
See Also
--------
[GtkPageSetup](gtkpagesetup#GtkPageSetup-struct)
| programming_docs |
gtk GtkScrollable GtkScrollable
=============
GtkScrollable — An interface for scrollable widgets
Functions
---------
| | |
| --- | --- |
| [GtkAdjustment](gtkadjustment#GtkAdjustment-struct) \* | [gtk\_scrollable\_get\_hadjustment](gtkscrollable#gtk-scrollable-get-hadjustment) () |
| void | [gtk\_scrollable\_set\_hadjustment](gtkscrollable#gtk-scrollable-set-hadjustment) () |
| [GtkAdjustment](gtkadjustment#GtkAdjustment-struct) \* | [gtk\_scrollable\_get\_vadjustment](gtkscrollable#gtk-scrollable-get-vadjustment) () |
| void | [gtk\_scrollable\_set\_vadjustment](gtkscrollable#gtk-scrollable-set-vadjustment) () |
| [GtkScrollablePolicy](gtkscrollable#GtkScrollablePolicy) | [gtk\_scrollable\_get\_hscroll\_policy](gtkscrollable#gtk-scrollable-get-hscroll-policy) () |
| void | [gtk\_scrollable\_set\_hscroll\_policy](gtkscrollable#gtk-scrollable-set-hscroll-policy) () |
| [GtkScrollablePolicy](gtkscrollable#GtkScrollablePolicy) | [gtk\_scrollable\_get\_vscroll\_policy](gtkscrollable#gtk-scrollable-get-vscroll-policy) () |
| void | [gtk\_scrollable\_set\_vscroll\_policy](gtkscrollable#gtk-scrollable-set-vscroll-policy) () |
| gboolean | [gtk\_scrollable\_get\_border](gtkscrollable#gtk-scrollable-get-border) () |
Properties
----------
| | | |
| --- | --- | --- |
| [GtkAdjustment](gtkadjustment#GtkAdjustment-struct) \* | [hadjustment](gtkscrollable#GtkScrollable--hadjustment) | Read / Write / Construct |
| [GtkScrollablePolicy](gtkscrollable#GtkScrollablePolicy) | [hscroll-policy](gtkscrollable#GtkScrollable--hscroll-policy) | Read / Write |
| [GtkAdjustment](gtkadjustment#GtkAdjustment-struct) \* | [vadjustment](gtkscrollable#GtkScrollable--vadjustment) | Read / Write / Construct |
| [GtkScrollablePolicy](gtkscrollable#GtkScrollablePolicy) | [vscroll-policy](gtkscrollable#GtkScrollable--vscroll-policy) | Read / Write |
Types and Values
----------------
| | |
| --- | --- |
| | [GtkScrollable](gtkscrollable#GtkScrollable-struct) |
| enum | [GtkScrollablePolicy](gtkscrollable#GtkScrollablePolicy) |
Object Hierarchy
----------------
```
[GInterface](https://developer-old.gnome.org/gobject/stable/GTypeModule.html)
╰── GtkScrollable
```
Prerequisites
-------------
GtkScrollable requires GObject.
Known Implementations
---------------------
GtkScrollable is implemented by [GtkColumnView](gtkcolumnview#GtkColumnView-struct), [GtkGridView](gtkgridview#GtkGridView-struct), [GtkIconView](gtkiconview#GtkIconView-struct), [GtkListView](gtklistview#GtkListView-struct), [GtkTextView](gtktextview#GtkTextView-struct), [GtkTreeView](gtktreeview#GtkTreeView-struct) and [GtkViewport](gtkviewport#GtkViewport-struct).
Includes
--------
```
#include <gtk/gtk.h>
```
Description
-----------
[GtkScrollable](gtkscrollable#GtkScrollable-struct) is an interface that is implemented by widgets with native scrolling ability.
To implement this interface you should override the [“hadjustment”](gtkscrollable#GtkScrollable--hadjustment) and [“vadjustment”](gtkscrollable#GtkScrollable--vadjustment) properties.
#### Creating a scrollable widget
All scrollable widgets should do the following.
* When a parent widget sets the scrollable child widget’s adjustments, the widget should populate the adjustments’ [“lower”](gtkadjustment#GtkAdjustment--lower), [“upper”](gtkadjustment#GtkAdjustment--upper), [“step-increment”](gtkadjustment#GtkAdjustment--step-increment), [“page-increment”](gtkadjustment#GtkAdjustment--page-increment) and [“page-size”](gtkadjustment#GtkAdjustment--page-size) properties and connect to the [“value-changed”](gtkadjustment#GtkAdjustment-value-changed) signal.
* Because its preferred size is the size for a fully expanded widget, the scrollable widget must be able to cope with underallocations. This means that it must accept any value passed to its [`GtkWidgetClass.size_allocate()`](gtkwidget#GtkWidgetClass.size-allocate) function.
* When the parent allocates space to the scrollable child widget, the widget should update the adjustments’ properties with new values.
* When any of the adjustments emits the [“value-changed”](gtkadjustment#GtkAdjustment-value-changed) signal, the scrollable widget should scroll its contents.
Functions
---------
### gtk\_scrollable\_get\_hadjustment ()
```
[GtkAdjustment](gtkadjustment#GtkAdjustment-struct) *
gtk_scrollable_get_hadjustment (*`[GtkScrollable](gtkscrollable#GtkScrollable-struct) *scrollable`*);
```
Retrieves the [GtkAdjustment](gtkadjustment#GtkAdjustment-struct) used for horizontal scrolling.
#### Parameters
| | | |
| --- | --- | --- |
| scrollable | a [GtkScrollable](gtkscrollable#GtkScrollable-struct) | |
#### Returns
horizontal [GtkAdjustment](gtkadjustment#GtkAdjustment-struct).
[transfer none]
### gtk\_scrollable\_set\_hadjustment ()
```
void
gtk_scrollable_set_hadjustment (*`[GtkScrollable](gtkscrollable#GtkScrollable-struct) *scrollable`*,
*`[GtkAdjustment](gtkadjustment#GtkAdjustment-struct) *hadjustment`*);
```
Sets the horizontal adjustment of the [GtkScrollable](gtkscrollable#GtkScrollable-struct).
#### Parameters
| | | |
| --- | --- | --- |
| scrollable | a [GtkScrollable](gtkscrollable#GtkScrollable-struct) | |
| hadjustment | a [GtkAdjustment](gtkadjustment#GtkAdjustment-struct). | [allow-none] |
### gtk\_scrollable\_get\_vadjustment ()
```
[GtkAdjustment](gtkadjustment#GtkAdjustment-struct) *
gtk_scrollable_get_vadjustment (*`[GtkScrollable](gtkscrollable#GtkScrollable-struct) *scrollable`*);
```
Retrieves the [GtkAdjustment](gtkadjustment#GtkAdjustment-struct) used for vertical scrolling.
#### Parameters
| | | |
| --- | --- | --- |
| scrollable | a [GtkScrollable](gtkscrollable#GtkScrollable-struct) | |
#### Returns
vertical [GtkAdjustment](gtkadjustment#GtkAdjustment-struct).
[transfer none]
### gtk\_scrollable\_set\_vadjustment ()
```
void
gtk_scrollable_set_vadjustment (*`[GtkScrollable](gtkscrollable#GtkScrollable-struct) *scrollable`*,
*`[GtkAdjustment](gtkadjustment#GtkAdjustment-struct) *vadjustment`*);
```
Sets the vertical adjustment of the [GtkScrollable](gtkscrollable#GtkScrollable-struct).
#### Parameters
| | | |
| --- | --- | --- |
| scrollable | a [GtkScrollable](gtkscrollable#GtkScrollable-struct) | |
| vadjustment | a [GtkAdjustment](gtkadjustment#GtkAdjustment-struct). | [allow-none] |
### gtk\_scrollable\_get\_hscroll\_policy ()
```
[GtkScrollablePolicy](gtkscrollable#GtkScrollablePolicy)
gtk_scrollable_get_hscroll_policy (*`[GtkScrollable](gtkscrollable#GtkScrollable-struct) *scrollable`*);
```
Gets the horizontal [GtkScrollablePolicy](gtkscrollable#GtkScrollablePolicy).
#### Parameters
| | | |
| --- | --- | --- |
| scrollable | a [GtkScrollable](gtkscrollable#GtkScrollable-struct) | |
#### Returns
The horizontal [GtkScrollablePolicy](gtkscrollable#GtkScrollablePolicy).
### gtk\_scrollable\_set\_hscroll\_policy ()
```
void
gtk_scrollable_set_hscroll_policy (*`[GtkScrollable](gtkscrollable#GtkScrollable-struct) *scrollable`*,
*`[GtkScrollablePolicy](gtkscrollable#GtkScrollablePolicy) policy`*);
```
Sets the [GtkScrollablePolicy](gtkscrollable#GtkScrollablePolicy) to determine whether horizontal scrolling should start below the minimum width or below the natural width.
#### Parameters
| | | |
| --- | --- | --- |
| scrollable | a [GtkScrollable](gtkscrollable#GtkScrollable-struct) | |
| policy | the horizontal [GtkScrollablePolicy](gtkscrollable#GtkScrollablePolicy) | |
### gtk\_scrollable\_get\_vscroll\_policy ()
```
[GtkScrollablePolicy](gtkscrollable#GtkScrollablePolicy)
gtk_scrollable_get_vscroll_policy (*`[GtkScrollable](gtkscrollable#GtkScrollable-struct) *scrollable`*);
```
Gets the vertical [GtkScrollablePolicy](gtkscrollable#GtkScrollablePolicy).
#### Parameters
| | | |
| --- | --- | --- |
| scrollable | a [GtkScrollable](gtkscrollable#GtkScrollable-struct) | |
#### Returns
The vertical [GtkScrollablePolicy](gtkscrollable#GtkScrollablePolicy).
### gtk\_scrollable\_set\_vscroll\_policy ()
```
void
gtk_scrollable_set_vscroll_policy (*`[GtkScrollable](gtkscrollable#GtkScrollable-struct) *scrollable`*,
*`[GtkScrollablePolicy](gtkscrollable#GtkScrollablePolicy) policy`*);
```
Sets the [GtkScrollablePolicy](gtkscrollable#GtkScrollablePolicy) to determine whether vertical scrolling should start below the minimum height or below the natural height.
#### Parameters
| | | |
| --- | --- | --- |
| scrollable | a [GtkScrollable](gtkscrollable#GtkScrollable-struct) | |
| policy | the vertical [GtkScrollablePolicy](gtkscrollable#GtkScrollablePolicy) | |
### gtk\_scrollable\_get\_border ()
```
gboolean
gtk_scrollable_get_border (*`[GtkScrollable](gtkscrollable#GtkScrollable-struct) *scrollable`*,
*`[GtkBorder](gtkstylecontext#GtkBorder) *border`*);
```
Returns the size of a non-scrolling border around the outside of the scrollable. An example for this would be treeview headers. GTK can use this information to display overlaid graphics, like the overshoot indication, at the right position.
#### Parameters
| | | |
| --- | --- | --- |
| scrollable | a [GtkScrollable](gtkscrollable#GtkScrollable-struct) | |
| border | return location for the results. | [out caller-allocates] |
#### Returns
`TRUE` if *`border`* has been set
Types and Values
----------------
### GtkScrollable
```
typedef struct _GtkScrollable GtkScrollable;
```
### enum GtkScrollablePolicy
Defines the policy to be used in a scrollable widget when updating the scrolled window adjustments in a given orientation.
#### Members
| | | |
| --- | --- | --- |
| GTK\_SCROLL\_MINIMUM | Scrollable adjustments are based on the minimum size | |
| GTK\_SCROLL\_NATURAL | Scrollable adjustments are based on the natural size | |
Property Details
----------------
### The `“hadjustment”` property
```
“hadjustment” [GtkAdjustment](gtkadjustment#GtkAdjustment-struct) *
```
Horizontal [GtkAdjustment](gtkadjustment#GtkAdjustment-struct) of the scrollable widget. This adjustment is shared between the scrollable widget and its parent.
Owner: GtkScrollable
Flags: Read / Write / Construct
### The `“hscroll-policy”` property
```
“hscroll-policy” [GtkScrollablePolicy](gtkscrollable#GtkScrollablePolicy)
```
Determines whether horizontal scrolling should start once the scrollable widget is allocated less than its minimum width or less than its natural width.
Owner: GtkScrollable
Flags: Read / Write
Default value: GTK\_SCROLL\_MINIMUM
### The `“vadjustment”` property
```
“vadjustment” [GtkAdjustment](gtkadjustment#GtkAdjustment-struct) *
```
Vertical [GtkAdjustment](gtkadjustment#GtkAdjustment-struct) of the scrollable widget. This adjustment is shared between the scrollable widget and its parent.
Owner: GtkScrollable
Flags: Read / Write / Construct
### The `“vscroll-policy”` property
```
“vscroll-policy” [GtkScrollablePolicy](gtkscrollable#GtkScrollablePolicy)
```
Determines whether vertical scrolling should start once the scrollable widget is allocated less than its minimum height or less than its natural height.
Owner: GtkScrollable
Flags: Read / Write
Default value: GTK\_SCROLL\_MINIMUM
gtk Understanding the X11 architecture Understanding the X11 architecture
==================================
People coming from a Windows or MacOS background often find certain aspects of the X Window System surprising. This section introduces some basic X concepts at a high level. For more details, the book most people use is called the “Xlib Programming Manual” by Adrian Nye; this book is volume one in the O’Reilly X Window System series.
Standards are another important resource if you’re poking in low-level X11 details, in particular the ICCCM and the Extended Window Manager Hints specifications. [freedesktop.org](http://www.freedesktop.org/standards/) has links to many relevant specifications.
The GDK manual covers using Xlib in a GTK program.
### Server, client, window manager
Other window systems typically put all their functionality in the application itself. With X, each application involves three different programs: the *X server*, the application (called a *client* because it’s a client of the X server), and a special client called the *window manager*.
The X server is in charge of managing resources, processing drawing requests, and dispatching events such as keyboard and mouse events to interested applications. So client applications can ask the X server to create a window, draw a circle, or move windows around.
The window manager is in charge of rendering the frame or borders around windows; it also has final say on the size of each window, and window states such as minimized, maximized, and so forth. On Windows and MacOS the application handles most of this. On X11, if you wish to modify the window’s state, or change its frame, you must ask the window manager to do so on your behalf, using an established [convention](http://www.freedesktop.org/standards/).
GTK has functions for asking the window manager to do various things; see for example [`gtk_window_minimize()`](gtkwindow#gtk-window-minimize) or [`gtk_window_maximize()`](gtkwindow#gtk-window-maximize). Keep in mind that most window managers *will* ignore certain requests from time to time, in the interests of good user interface.
gtk GtkPrintSettings GtkPrintSettings
================
GtkPrintSettings — Stores print settings
Functions
---------
| | |
| --- | --- |
| void | ([\*GtkPrintSettingsFunc](gtkprintsettings#GtkPrintSettingsFunc)) () |
| [GtkPrintSettings](gtkprintsettings#GtkPrintSettings-struct) \* | [gtk\_print\_settings\_new](gtkprintsettings#gtk-print-settings-new) () |
| [GtkPrintSettings](gtkprintsettings#GtkPrintSettings-struct) \* | [gtk\_print\_settings\_copy](gtkprintsettings#gtk-print-settings-copy) () |
| gboolean | [gtk\_print\_settings\_has\_key](gtkprintsettings#gtk-print-settings-has-key) () |
| const char \* | [gtk\_print\_settings\_get](gtkprintsettings#gtk-print-settings-get) () |
| void | [gtk\_print\_settings\_set](gtkprintsettings#gtk-print-settings-set) () |
| void | [gtk\_print\_settings\_unset](gtkprintsettings#gtk-print-settings-unset) () |
| void | [gtk\_print\_settings\_foreach](gtkprintsettings#gtk-print-settings-foreach) () |
| gboolean | [gtk\_print\_settings\_get\_bool](gtkprintsettings#gtk-print-settings-get-bool) () |
| void | [gtk\_print\_settings\_set\_bool](gtkprintsettings#gtk-print-settings-set-bool) () |
| double | [gtk\_print\_settings\_get\_double](gtkprintsettings#gtk-print-settings-get-double) () |
| double | [gtk\_print\_settings\_get\_double\_with\_default](gtkprintsettings#gtk-print-settings-get-double-with-default) () |
| void | [gtk\_print\_settings\_set\_double](gtkprintsettings#gtk-print-settings-set-double) () |
| double | [gtk\_print\_settings\_get\_length](gtkprintsettings#gtk-print-settings-get-length) () |
| void | [gtk\_print\_settings\_set\_length](gtkprintsettings#gtk-print-settings-set-length) () |
| int | [gtk\_print\_settings\_get\_int](gtkprintsettings#gtk-print-settings-get-int) () |
| int | [gtk\_print\_settings\_get\_int\_with\_default](gtkprintsettings#gtk-print-settings-get-int-with-default) () |
| void | [gtk\_print\_settings\_set\_int](gtkprintsettings#gtk-print-settings-set-int) () |
| const char \* | [gtk\_print\_settings\_get\_printer](gtkprintsettings#gtk-print-settings-get-printer) () |
| void | [gtk\_print\_settings\_set\_printer](gtkprintsettings#gtk-print-settings-set-printer) () |
| [GtkPageOrientation](gtkprintsettings#GtkPageOrientation) | [gtk\_print\_settings\_get\_orientation](gtkprintsettings#gtk-print-settings-get-orientation) () |
| void | [gtk\_print\_settings\_set\_orientation](gtkprintsettings#gtk-print-settings-set-orientation) () |
| [GtkPaperSize](gtkpapersize#GtkPaperSize-struct) \* | [gtk\_print\_settings\_get\_paper\_size](gtkprintsettings#gtk-print-settings-get-paper-size) () |
| void | [gtk\_print\_settings\_set\_paper\_size](gtkprintsettings#gtk-print-settings-set-paper-size) () |
| double | [gtk\_print\_settings\_get\_paper\_width](gtkprintsettings#gtk-print-settings-get-paper-width) () |
| void | [gtk\_print\_settings\_set\_paper\_width](gtkprintsettings#gtk-print-settings-set-paper-width) () |
| double | [gtk\_print\_settings\_get\_paper\_height](gtkprintsettings#gtk-print-settings-get-paper-height) () |
| void | [gtk\_print\_settings\_set\_paper\_height](gtkprintsettings#gtk-print-settings-set-paper-height) () |
| gboolean | [gtk\_print\_settings\_get\_use\_color](gtkprintsettings#gtk-print-settings-get-use-color) () |
| void | [gtk\_print\_settings\_set\_use\_color](gtkprintsettings#gtk-print-settings-set-use-color) () |
| gboolean | [gtk\_print\_settings\_get\_collate](gtkprintsettings#gtk-print-settings-get-collate) () |
| void | [gtk\_print\_settings\_set\_collate](gtkprintsettings#gtk-print-settings-set-collate) () |
| gboolean | [gtk\_print\_settings\_get\_reverse](gtkprintsettings#gtk-print-settings-get-reverse) () |
| void | [gtk\_print\_settings\_set\_reverse](gtkprintsettings#gtk-print-settings-set-reverse) () |
| [GtkPrintDuplex](gtkprintsettings#GtkPrintDuplex) | [gtk\_print\_settings\_get\_duplex](gtkprintsettings#gtk-print-settings-get-duplex) () |
| void | [gtk\_print\_settings\_set\_duplex](gtkprintsettings#gtk-print-settings-set-duplex) () |
| [GtkPrintQuality](gtkprintsettings#GtkPrintQuality) | [gtk\_print\_settings\_get\_quality](gtkprintsettings#gtk-print-settings-get-quality) () |
| void | [gtk\_print\_settings\_set\_quality](gtkprintsettings#gtk-print-settings-set-quality) () |
| int | [gtk\_print\_settings\_get\_n\_copies](gtkprintsettings#gtk-print-settings-get-n-copies) () |
| void | [gtk\_print\_settings\_set\_n\_copies](gtkprintsettings#gtk-print-settings-set-n-copies) () |
| int | [gtk\_print\_settings\_get\_number\_up](gtkprintsettings#gtk-print-settings-get-number-up) () |
| void | [gtk\_print\_settings\_set\_number\_up](gtkprintsettings#gtk-print-settings-set-number-up) () |
| [GtkNumberUpLayout](gtkprintsettings#GtkNumberUpLayout) | [gtk\_print\_settings\_get\_number\_up\_layout](gtkprintsettings#gtk-print-settings-get-number-up-layout) () |
| void | [gtk\_print\_settings\_set\_number\_up\_layout](gtkprintsettings#gtk-print-settings-set-number-up-layout) () |
| int | [gtk\_print\_settings\_get\_resolution](gtkprintsettings#gtk-print-settings-get-resolution) () |
| void | [gtk\_print\_settings\_set\_resolution](gtkprintsettings#gtk-print-settings-set-resolution) () |
| void | [gtk\_print\_settings\_set\_resolution\_xy](gtkprintsettings#gtk-print-settings-set-resolution-xy) () |
| int | [gtk\_print\_settings\_get\_resolution\_x](gtkprintsettings#gtk-print-settings-get-resolution-x) () |
| int | [gtk\_print\_settings\_get\_resolution\_y](gtkprintsettings#gtk-print-settings-get-resolution-y) () |
| double | [gtk\_print\_settings\_get\_printer\_lpi](gtkprintsettings#gtk-print-settings-get-printer-lpi) () |
| void | [gtk\_print\_settings\_set\_printer\_lpi](gtkprintsettings#gtk-print-settings-set-printer-lpi) () |
| double | [gtk\_print\_settings\_get\_scale](gtkprintsettings#gtk-print-settings-get-scale) () |
| void | [gtk\_print\_settings\_set\_scale](gtkprintsettings#gtk-print-settings-set-scale) () |
| [GtkPrintPages](gtkprintsettings#GtkPrintPages) | [gtk\_print\_settings\_get\_print\_pages](gtkprintsettings#gtk-print-settings-get-print-pages) () |
| void | [gtk\_print\_settings\_set\_print\_pages](gtkprintsettings#gtk-print-settings-set-print-pages) () |
| [GtkPageRange](gtkprintsettings#GtkPageRange) \* | [gtk\_print\_settings\_get\_page\_ranges](gtkprintsettings#gtk-print-settings-get-page-ranges) () |
| void | [gtk\_print\_settings\_set\_page\_ranges](gtkprintsettings#gtk-print-settings-set-page-ranges) () |
| [GtkPageSet](gtkprintsettings#GtkPageSet) | [gtk\_print\_settings\_get\_page\_set](gtkprintsettings#gtk-print-settings-get-page-set) () |
| void | [gtk\_print\_settings\_set\_page\_set](gtkprintsettings#gtk-print-settings-set-page-set) () |
| const char \* | [gtk\_print\_settings\_get\_default\_source](gtkprintsettings#gtk-print-settings-get-default-source) () |
| void | [gtk\_print\_settings\_set\_default\_source](gtkprintsettings#gtk-print-settings-set-default-source) () |
| const char \* | [gtk\_print\_settings\_get\_media\_type](gtkprintsettings#gtk-print-settings-get-media-type) () |
| void | [gtk\_print\_settings\_set\_media\_type](gtkprintsettings#gtk-print-settings-set-media-type) () |
| const char \* | [gtk\_print\_settings\_get\_dither](gtkprintsettings#gtk-print-settings-get-dither) () |
| void | [gtk\_print\_settings\_set\_dither](gtkprintsettings#gtk-print-settings-set-dither) () |
| const char \* | [gtk\_print\_settings\_get\_finishings](gtkprintsettings#gtk-print-settings-get-finishings) () |
| void | [gtk\_print\_settings\_set\_finishings](gtkprintsettings#gtk-print-settings-set-finishings) () |
| const char \* | [gtk\_print\_settings\_get\_output\_bin](gtkprintsettings#gtk-print-settings-get-output-bin) () |
| void | [gtk\_print\_settings\_set\_output\_bin](gtkprintsettings#gtk-print-settings-set-output-bin) () |
| [GtkPrintSettings](gtkprintsettings#GtkPrintSettings-struct) \* | [gtk\_print\_settings\_new\_from\_file](gtkprintsettings#gtk-print-settings-new-from-file) () |
| [GtkPrintSettings](gtkprintsettings#GtkPrintSettings-struct) \* | [gtk\_print\_settings\_new\_from\_key\_file](gtkprintsettings#gtk-print-settings-new-from-key-file) () |
| [GtkPrintSettings](gtkprintsettings#GtkPrintSettings-struct) \* | [gtk\_print\_settings\_new\_from\_gvariant](gtkprintsettings#gtk-print-settings-new-from-gvariant) () |
| gboolean | [gtk\_print\_settings\_load\_file](gtkprintsettings#gtk-print-settings-load-file) () |
| gboolean | [gtk\_print\_settings\_load\_key\_file](gtkprintsettings#gtk-print-settings-load-key-file) () |
| gboolean | [gtk\_print\_settings\_to\_file](gtkprintsettings#gtk-print-settings-to-file) () |
| void | [gtk\_print\_settings\_to\_key\_file](gtkprintsettings#gtk-print-settings-to-key-file) () |
| GVariant \* | [gtk\_print\_settings\_to\_gvariant](gtkprintsettings#gtk-print-settings-to-gvariant) () |
Types and Values
----------------
| | |
| --- | --- |
| | [GtkPrintSettings](gtkprintsettings#GtkPrintSettings-struct) |
| #define | [GTK\_PRINT\_SETTINGS\_PRINTER](gtkprintsettings#GTK-PRINT-SETTINGS-PRINTER:CAPS) |
| enum | [GtkPageOrientation](gtkprintsettings#GtkPageOrientation) |
| #define | [GTK\_PRINT\_SETTINGS\_ORIENTATION](gtkprintsettings#GTK-PRINT-SETTINGS-ORIENTATION:CAPS) |
| #define | [GTK\_PRINT\_SETTINGS\_PAPER\_FORMAT](gtkprintsettings#GTK-PRINT-SETTINGS-PAPER-FORMAT:CAPS) |
| #define | [GTK\_PRINT\_SETTINGS\_PAPER\_WIDTH](gtkprintsettings#GTK-PRINT-SETTINGS-PAPER-WIDTH:CAPS) |
| #define | [GTK\_PRINT\_SETTINGS\_PAPER\_HEIGHT](gtkprintsettings#GTK-PRINT-SETTINGS-PAPER-HEIGHT:CAPS) |
| #define | [GTK\_PRINT\_SETTINGS\_USE\_COLOR](gtkprintsettings#GTK-PRINT-SETTINGS-USE-COLOR:CAPS) |
| #define | [GTK\_PRINT\_SETTINGS\_COLLATE](gtkprintsettings#GTK-PRINT-SETTINGS-COLLATE:CAPS) |
| #define | [GTK\_PRINT\_SETTINGS\_REVERSE](gtkprintsettings#GTK-PRINT-SETTINGS-REVERSE:CAPS) |
| enum | [GtkPrintDuplex](gtkprintsettings#GtkPrintDuplex) |
| #define | [GTK\_PRINT\_SETTINGS\_DUPLEX](gtkprintsettings#GTK-PRINT-SETTINGS-DUPLEX:CAPS) |
| enum | [GtkPrintQuality](gtkprintsettings#GtkPrintQuality) |
| #define | [GTK\_PRINT\_SETTINGS\_QUALITY](gtkprintsettings#GTK-PRINT-SETTINGS-QUALITY:CAPS) |
| #define | [GTK\_PRINT\_SETTINGS\_N\_COPIES](gtkprintsettings#GTK-PRINT-SETTINGS-N-COPIES:CAPS) |
| #define | [GTK\_PRINT\_SETTINGS\_NUMBER\_UP](gtkprintsettings#GTK-PRINT-SETTINGS-NUMBER-UP:CAPS) |
| enum | [GtkNumberUpLayout](gtkprintsettings#GtkNumberUpLayout) |
| #define | [GTK\_PRINT\_SETTINGS\_NUMBER\_UP\_LAYOUT](gtkprintsettings#GTK-PRINT-SETTINGS-NUMBER-UP-LAYOUT:CAPS) |
| #define | [GTK\_PRINT\_SETTINGS\_RESOLUTION](gtkprintsettings#GTK-PRINT-SETTINGS-RESOLUTION:CAPS) |
| #define | [GTK\_PRINT\_SETTINGS\_RESOLUTION\_X](gtkprintsettings#GTK-PRINT-SETTINGS-RESOLUTION-X:CAPS) |
| #define | [GTK\_PRINT\_SETTINGS\_RESOLUTION\_Y](gtkprintsettings#GTK-PRINT-SETTINGS-RESOLUTION-Y:CAPS) |
| #define | [GTK\_PRINT\_SETTINGS\_PRINTER\_LPI](gtkprintsettings#GTK-PRINT-SETTINGS-PRINTER-LPI:CAPS) |
| #define | [GTK\_PRINT\_SETTINGS\_SCALE](gtkprintsettings#GTK-PRINT-SETTINGS-SCALE:CAPS) |
| enum | [GtkPrintPages](gtkprintsettings#GtkPrintPages) |
| #define | [GTK\_PRINT\_SETTINGS\_PRINT\_PAGES](gtkprintsettings#GTK-PRINT-SETTINGS-PRINT-PAGES:CAPS) |
| struct | [GtkPageRange](gtkprintsettings#GtkPageRange) |
| #define | [GTK\_PRINT\_SETTINGS\_PAGE\_RANGES](gtkprintsettings#GTK-PRINT-SETTINGS-PAGE-RANGES:CAPS) |
| enum | [GtkPageSet](gtkprintsettings#GtkPageSet) |
| #define | [GTK\_PRINT\_SETTINGS\_PAGE\_SET](gtkprintsettings#GTK-PRINT-SETTINGS-PAGE-SET:CAPS) |
| #define | [GTK\_PRINT\_SETTINGS\_DEFAULT\_SOURCE](gtkprintsettings#GTK-PRINT-SETTINGS-DEFAULT-SOURCE:CAPS) |
| #define | [GTK\_PRINT\_SETTINGS\_MEDIA\_TYPE](gtkprintsettings#GTK-PRINT-SETTINGS-MEDIA-TYPE:CAPS) |
| #define | [GTK\_PRINT\_SETTINGS\_DITHER](gtkprintsettings#GTK-PRINT-SETTINGS-DITHER:CAPS) |
| #define | [GTK\_PRINT\_SETTINGS\_FINISHINGS](gtkprintsettings#GTK-PRINT-SETTINGS-FINISHINGS:CAPS) |
| #define | [GTK\_PRINT\_SETTINGS\_OUTPUT\_BIN](gtkprintsettings#GTK-PRINT-SETTINGS-OUTPUT-BIN:CAPS) |
| #define | [GTK\_PRINT\_SETTINGS\_OUTPUT\_DIR](gtkprintsettings#GTK-PRINT-SETTINGS-OUTPUT-DIR:CAPS) |
| #define | [GTK\_PRINT\_SETTINGS\_OUTPUT\_BASENAME](gtkprintsettings#GTK-PRINT-SETTINGS-OUTPUT-BASENAME:CAPS) |
| #define | [GTK\_PRINT\_SETTINGS\_OUTPUT\_FILE\_FORMAT](gtkprintsettings#GTK-PRINT-SETTINGS-OUTPUT-FILE-FORMAT:CAPS) |
| #define | [GTK\_PRINT\_SETTINGS\_OUTPUT\_URI](gtkprintsettings#GTK-PRINT-SETTINGS-OUTPUT-URI:CAPS) |
| #define | [GTK\_PRINT\_SETTINGS\_WIN32\_DRIVER\_EXTRA](gtkprintsettings#GTK-PRINT-SETTINGS-WIN32-DRIVER-EXTRA:CAPS) |
| #define | [GTK\_PRINT\_SETTINGS\_WIN32\_DRIVER\_VERSION](gtkprintsettings#GTK-PRINT-SETTINGS-WIN32-DRIVER-VERSION:CAPS) |
Object Hierarchy
----------------
```
GObject
╰── GtkPrintSettings
```
Includes
--------
```
#include <gtk/gtk.h>
```
Description
-----------
A GtkPrintSettings object represents the settings of a print dialog in a system-independent way. The main use for this object is that once you’ve printed you can get a settings object that represents the settings the user chose, and the next time you print you can pass that object in so that the user doesn’t have to re-set all his settings.
Its also possible to enumerate the settings so that you can easily save the settings for the next time your app runs, or even store them in a document. The predefined keys try to use shared values as much as possible so that moving such a document between systems still works.
Functions
---------
### GtkPrintSettingsFunc ()
```
void
(*GtkPrintSettingsFunc) (const char *key,
const char *value,
gpointer user_data);
```
### gtk\_print\_settings\_new ()
```
[GtkPrintSettings](gtkprintsettings#GtkPrintSettings-struct) *
gtk_print_settings_new (*`void`*);
```
Creates a new [GtkPrintSettings](gtkprintsettings#GtkPrintSettings-struct) object.
#### Returns
a new [GtkPrintSettings](gtkprintsettings#GtkPrintSettings-struct) object
### gtk\_print\_settings\_copy ()
```
[GtkPrintSettings](gtkprintsettings#GtkPrintSettings-struct) *
gtk_print_settings_copy (*`[GtkPrintSettings](gtkprintsettings#GtkPrintSettings-struct) *other`*);
```
Copies a [GtkPrintSettings](gtkprintsettings#GtkPrintSettings-struct) object.
#### Parameters
| | | |
| --- | --- | --- |
| other | a [GtkPrintSettings](gtkprintsettings#GtkPrintSettings-struct) | |
#### Returns
a newly allocated copy of *`other`* .
[transfer full]
### gtk\_print\_settings\_has\_key ()
```
gboolean
gtk_print_settings_has_key (*`[GtkPrintSettings](gtkprintsettings#GtkPrintSettings-struct) *settings`*,
*`const char *key`*);
```
Returns `TRUE`, if a value is associated with *`key`* .
#### Parameters
| | | |
| --- | --- | --- |
| settings | a [GtkPrintSettings](gtkprintsettings#GtkPrintSettings-struct) | |
| key | a key | |
#### Returns
`TRUE`, if *`key`* has a value
### gtk\_print\_settings\_get ()
```
const char *
gtk_print_settings_get (*`[GtkPrintSettings](gtkprintsettings#GtkPrintSettings-struct) *settings`*,
*`const char *key`*);
```
Looks up the string value associated with *`key`* .
#### Parameters
| | | |
| --- | --- | --- |
| settings | a [GtkPrintSettings](gtkprintsettings#GtkPrintSettings-struct) | |
| key | a key | |
#### Returns
the string value for *`key`*
### gtk\_print\_settings\_set ()
```
void
gtk_print_settings_set (*`[GtkPrintSettings](gtkprintsettings#GtkPrintSettings-struct) *settings`*,
*`const char *key`*,
*`const char *value`*);
```
Associates *`value`* with *`key`* .
#### Parameters
| | | |
| --- | --- | --- |
| settings | a [GtkPrintSettings](gtkprintsettings#GtkPrintSettings-struct) | |
| key | a key | |
| value | a string value, or `NULL`. | [allow-none] |
### gtk\_print\_settings\_unset ()
```
void
gtk_print_settings_unset (*`[GtkPrintSettings](gtkprintsettings#GtkPrintSettings-struct) *settings`*,
*`const char *key`*);
```
Removes any value associated with *`key`* . This has the same effect as setting the value to `NULL`.
#### Parameters
| | | |
| --- | --- | --- |
| settings | a [GtkPrintSettings](gtkprintsettings#GtkPrintSettings-struct) | |
| key | a key | |
### gtk\_print\_settings\_foreach ()
```
void
gtk_print_settings_foreach (*`[GtkPrintSettings](gtkprintsettings#GtkPrintSettings-struct) *settings`*,
*`[GtkPrintSettingsFunc](gtkprintsettings#GtkPrintSettingsFunc) func`*,
*`gpointer user_data`*);
```
Calls *`func`* for each key-value pair of *`settings`* .
#### Parameters
| | | |
| --- | --- | --- |
| settings | a [GtkPrintSettings](gtkprintsettings#GtkPrintSettings-struct) | |
| func | the function to call. | [scope call] |
| user\_data | user data for *`func`* . | [closure] |
### gtk\_print\_settings\_get\_bool ()
```
gboolean
gtk_print_settings_get_bool (*`[GtkPrintSettings](gtkprintsettings#GtkPrintSettings-struct) *settings`*,
*`const char *key`*);
```
Returns the boolean represented by the value that is associated with *`key`* .
The string “true” represents `TRUE`, any other string `FALSE`.
#### Parameters
| | | |
| --- | --- | --- |
| settings | a [GtkPrintSettings](gtkprintsettings#GtkPrintSettings-struct) | |
| key | a key | |
#### Returns
`TRUE`, if *`key`* maps to a true value.
### gtk\_print\_settings\_set\_bool ()
```
void
gtk_print_settings_set_bool (*`[GtkPrintSettings](gtkprintsettings#GtkPrintSettings-struct) *settings`*,
*`const char *key`*,
*`gboolean value`*);
```
Sets *`key`* to a boolean value.
#### Parameters
| | | |
| --- | --- | --- |
| settings | a [GtkPrintSettings](gtkprintsettings#GtkPrintSettings-struct) | |
| key | a key | |
| value | a boolean | |
### gtk\_print\_settings\_get\_double ()
```
double
gtk_print_settings_get_double (*`[GtkPrintSettings](gtkprintsettings#GtkPrintSettings-struct) *settings`*,
*`const char *key`*);
```
Returns the double value associated with *`key`* , or 0.
#### Parameters
| | | |
| --- | --- | --- |
| settings | a [GtkPrintSettings](gtkprintsettings#GtkPrintSettings-struct) | |
| key | a key | |
#### Returns
the double value of *`key`*
### gtk\_print\_settings\_get\_double\_with\_default ()
```
double
gtk_print_settings_get_double_with_default
(*`[GtkPrintSettings](gtkprintsettings#GtkPrintSettings-struct) *settings`*,
*`const char *key`*,
*`double def`*);
```
Returns the floating point number represented by the value that is associated with *`key`* , or *`default_val`* if the value does not represent a floating point number.
Floating point numbers are parsed with `g_ascii_strtod()`.
#### Parameters
| | | |
| --- | --- | --- |
| settings | a [GtkPrintSettings](gtkprintsettings#GtkPrintSettings-struct) | |
| key | a key | |
| def | the default value | |
#### Returns
the floating point number associated with *`key`*
### gtk\_print\_settings\_set\_double ()
```
void
gtk_print_settings_set_double (*`[GtkPrintSettings](gtkprintsettings#GtkPrintSettings-struct) *settings`*,
*`const char *key`*,
*`double value`*);
```
Sets *`key`* to a double value.
#### Parameters
| | | |
| --- | --- | --- |
| settings | a [GtkPrintSettings](gtkprintsettings#GtkPrintSettings-struct) | |
| key | a key | |
| value | a double value | |
### gtk\_print\_settings\_get\_length ()
```
double
gtk_print_settings_get_length (*`[GtkPrintSettings](gtkprintsettings#GtkPrintSettings-struct) *settings`*,
*`const char *key`*,
*`[GtkUnit](gtkpapersize#GtkUnit) unit`*);
```
Returns the value associated with *`key`* , interpreted as a length. The returned value is converted to *`units`* .
#### Parameters
| | | |
| --- | --- | --- |
| settings | a [GtkPrintSettings](gtkprintsettings#GtkPrintSettings-struct) | |
| key | a key | |
| unit | the unit of the return value | |
#### Returns
the length value of *`key`* , converted to *`unit`*
### gtk\_print\_settings\_set\_length ()
```
void
gtk_print_settings_set_length (*`[GtkPrintSettings](gtkprintsettings#GtkPrintSettings-struct) *settings`*,
*`const char *key`*,
*`double value`*,
*`[GtkUnit](gtkpapersize#GtkUnit) unit`*);
```
Associates a length in units of *`unit`* with *`key`* .
#### Parameters
| | | |
| --- | --- | --- |
| settings | a [GtkPrintSettings](gtkprintsettings#GtkPrintSettings-struct) | |
| key | a key | |
| value | a length | |
| unit | the unit of *`length`* | |
### gtk\_print\_settings\_get\_int ()
```
int
gtk_print_settings_get_int (*`[GtkPrintSettings](gtkprintsettings#GtkPrintSettings-struct) *settings`*,
*`const char *key`*);
```
Returns the integer value of *`key`* , or 0.
#### Parameters
| | | |
| --- | --- | --- |
| settings | a [GtkPrintSettings](gtkprintsettings#GtkPrintSettings-struct) | |
| key | a key | |
#### Returns
the integer value of *`key`*
### gtk\_print\_settings\_get\_int\_with\_default ()
```
int
gtk_print_settings_get_int_with_default
(*`[GtkPrintSettings](gtkprintsettings#GtkPrintSettings-struct) *settings`*,
*`const char *key`*,
*`int def`*);
```
Returns the value of *`key`* , interpreted as an integer, or the default value.
#### Parameters
| | | |
| --- | --- | --- |
| settings | a [GtkPrintSettings](gtkprintsettings#GtkPrintSettings-struct) | |
| key | a key | |
| def | the default value | |
#### Returns
the integer value of *`key`*
### gtk\_print\_settings\_set\_int ()
```
void
gtk_print_settings_set_int (*`[GtkPrintSettings](gtkprintsettings#GtkPrintSettings-struct) *settings`*,
*`const char *key`*,
*`int value`*);
```
Sets *`key`* to an integer value.
#### Parameters
| | | |
| --- | --- | --- |
| settings | a [GtkPrintSettings](gtkprintsettings#GtkPrintSettings-struct) | |
| key | a key | |
| value | an integer | |
### gtk\_print\_settings\_get\_printer ()
```
const char *
gtk_print_settings_get_printer (*`[GtkPrintSettings](gtkprintsettings#GtkPrintSettings-struct) *settings`*);
```
Convenience function to obtain the value of [`GTK_PRINT_SETTINGS_PRINTER`](gtkprintsettings#GTK-PRINT-SETTINGS-PRINTER:CAPS).
#### Parameters
| | | |
| --- | --- | --- |
| settings | a [GtkPrintSettings](gtkprintsettings#GtkPrintSettings-struct) | |
#### Returns
the printer name
### gtk\_print\_settings\_set\_printer ()
```
void
gtk_print_settings_set_printer (*`[GtkPrintSettings](gtkprintsettings#GtkPrintSettings-struct) *settings`*,
*`const char *printer`*);
```
Convenience function to set [`GTK_PRINT_SETTINGS_PRINTER`](gtkprintsettings#GTK-PRINT-SETTINGS-PRINTER:CAPS) to *`printer`* .
#### Parameters
| | | |
| --- | --- | --- |
| settings | a [GtkPrintSettings](gtkprintsettings#GtkPrintSettings-struct) | |
| printer | the printer name | |
### gtk\_print\_settings\_get\_orientation ()
```
[GtkPageOrientation](gtkprintsettings#GtkPageOrientation)
gtk_print_settings_get_orientation (*`[GtkPrintSettings](gtkprintsettings#GtkPrintSettings-struct) *settings`*);
```
Get the value of [`GTK_PRINT_SETTINGS_ORIENTATION`](gtkprintsettings#GTK-PRINT-SETTINGS-ORIENTATION:CAPS), converted to a [GtkPageOrientation](gtkprintsettings#GtkPageOrientation).
#### Parameters
| | | |
| --- | --- | --- |
| settings | a [GtkPrintSettings](gtkprintsettings#GtkPrintSettings-struct) | |
#### Returns
the orientation
### gtk\_print\_settings\_set\_orientation ()
```
void
gtk_print_settings_set_orientation (*`[GtkPrintSettings](gtkprintsettings#GtkPrintSettings-struct) *settings`*,
*`[GtkPageOrientation](gtkprintsettings#GtkPageOrientation) orientation`*);
```
Sets the value of [`GTK_PRINT_SETTINGS_ORIENTATION`](gtkprintsettings#GTK-PRINT-SETTINGS-ORIENTATION:CAPS).
#### Parameters
| | | |
| --- | --- | --- |
| settings | a [GtkPrintSettings](gtkprintsettings#GtkPrintSettings-struct) | |
| orientation | a page orientation | |
### gtk\_print\_settings\_get\_paper\_size ()
```
[GtkPaperSize](gtkpapersize#GtkPaperSize-struct) *
gtk_print_settings_get_paper_size (*`[GtkPrintSettings](gtkprintsettings#GtkPrintSettings-struct) *settings`*);
```
Gets the value of [`GTK_PRINT_SETTINGS_PAPER_FORMAT`](gtkprintsettings#GTK-PRINT-SETTINGS-PAPER-FORMAT:CAPS), converted to a [GtkPaperSize](gtkpapersize#GtkPaperSize-struct).
#### Parameters
| | | |
| --- | --- | --- |
| settings | a [GtkPrintSettings](gtkprintsettings#GtkPrintSettings-struct) | |
#### Returns
the paper size
### gtk\_print\_settings\_set\_paper\_size ()
```
void
gtk_print_settings_set_paper_size (*`[GtkPrintSettings](gtkprintsettings#GtkPrintSettings-struct) *settings`*,
*`[GtkPaperSize](gtkpapersize#GtkPaperSize-struct) *paper_size`*);
```
Sets the value of [`GTK_PRINT_SETTINGS_PAPER_FORMAT`](gtkprintsettings#GTK-PRINT-SETTINGS-PAPER-FORMAT:CAPS), [`GTK_PRINT_SETTINGS_PAPER_WIDTH`](gtkprintsettings#GTK-PRINT-SETTINGS-PAPER-WIDTH:CAPS) and [`GTK_PRINT_SETTINGS_PAPER_HEIGHT`](gtkprintsettings#GTK-PRINT-SETTINGS-PAPER-HEIGHT:CAPS).
#### Parameters
| | | |
| --- | --- | --- |
| settings | a [GtkPrintSettings](gtkprintsettings#GtkPrintSettings-struct) | |
| paper\_size | a paper size | |
### gtk\_print\_settings\_get\_paper\_width ()
```
double
gtk_print_settings_get_paper_width (*`[GtkPrintSettings](gtkprintsettings#GtkPrintSettings-struct) *settings`*,
*`[GtkUnit](gtkpapersize#GtkUnit) unit`*);
```
Gets the value of [`GTK_PRINT_SETTINGS_PAPER_WIDTH`](gtkprintsettings#GTK-PRINT-SETTINGS-PAPER-WIDTH:CAPS), converted to *`unit`* .
#### Parameters
| | | |
| --- | --- | --- |
| settings | a [GtkPrintSettings](gtkprintsettings#GtkPrintSettings-struct) | |
| unit | the unit for the return value | |
#### Returns
the paper width, in units of *`unit`*
### gtk\_print\_settings\_set\_paper\_width ()
```
void
gtk_print_settings_set_paper_width (*`[GtkPrintSettings](gtkprintsettings#GtkPrintSettings-struct) *settings`*,
*`double width`*,
*`[GtkUnit](gtkpapersize#GtkUnit) unit`*);
```
Sets the value of [`GTK_PRINT_SETTINGS_PAPER_WIDTH`](gtkprintsettings#GTK-PRINT-SETTINGS-PAPER-WIDTH:CAPS).
#### Parameters
| | | |
| --- | --- | --- |
| settings | a [GtkPrintSettings](gtkprintsettings#GtkPrintSettings-struct) | |
| width | the paper width | |
| unit | the units of *`width`* | |
### gtk\_print\_settings\_get\_paper\_height ()
```
double
gtk_print_settings_get_paper_height (*`[GtkPrintSettings](gtkprintsettings#GtkPrintSettings-struct) *settings`*,
*`[GtkUnit](gtkpapersize#GtkUnit) unit`*);
```
Gets the value of [`GTK_PRINT_SETTINGS_PAPER_HEIGHT`](gtkprintsettings#GTK-PRINT-SETTINGS-PAPER-HEIGHT:CAPS), converted to *`unit`* .
#### Parameters
| | | |
| --- | --- | --- |
| settings | a [GtkPrintSettings](gtkprintsettings#GtkPrintSettings-struct) | |
| unit | the unit for the return value | |
#### Returns
the paper height, in units of *`unit`*
### gtk\_print\_settings\_set\_paper\_height ()
```
void
gtk_print_settings_set_paper_height (*`[GtkPrintSettings](gtkprintsettings#GtkPrintSettings-struct) *settings`*,
*`double height`*,
*`[GtkUnit](gtkpapersize#GtkUnit) unit`*);
```
Sets the value of [`GTK_PRINT_SETTINGS_PAPER_HEIGHT`](gtkprintsettings#GTK-PRINT-SETTINGS-PAPER-HEIGHT:CAPS).
#### Parameters
| | | |
| --- | --- | --- |
| settings | a [GtkPrintSettings](gtkprintsettings#GtkPrintSettings-struct) | |
| height | the paper height | |
| unit | the units of *`height`* | |
### gtk\_print\_settings\_get\_use\_color ()
```
gboolean
gtk_print_settings_get_use_color (*`[GtkPrintSettings](gtkprintsettings#GtkPrintSettings-struct) *settings`*);
```
Gets the value of [`GTK_PRINT_SETTINGS_USE_COLOR`](gtkprintsettings#GTK-PRINT-SETTINGS-USE-COLOR:CAPS).
#### Parameters
| | | |
| --- | --- | --- |
| settings | a [GtkPrintSettings](gtkprintsettings#GtkPrintSettings-struct) | |
#### Returns
whether to use color
### gtk\_print\_settings\_set\_use\_color ()
```
void
gtk_print_settings_set_use_color (*`[GtkPrintSettings](gtkprintsettings#GtkPrintSettings-struct) *settings`*,
*`gboolean use_color`*);
```
Sets the value of [`GTK_PRINT_SETTINGS_USE_COLOR`](gtkprintsettings#GTK-PRINT-SETTINGS-USE-COLOR:CAPS).
#### Parameters
| | | |
| --- | --- | --- |
| settings | a [GtkPrintSettings](gtkprintsettings#GtkPrintSettings-struct) | |
| use\_color | whether to use color | |
### gtk\_print\_settings\_get\_collate ()
```
gboolean
gtk_print_settings_get_collate (*`[GtkPrintSettings](gtkprintsettings#GtkPrintSettings-struct) *settings`*);
```
Gets the value of [`GTK_PRINT_SETTINGS_COLLATE`](gtkprintsettings#GTK-PRINT-SETTINGS-COLLATE:CAPS).
#### Parameters
| | | |
| --- | --- | --- |
| settings | a [GtkPrintSettings](gtkprintsettings#GtkPrintSettings-struct) | |
#### Returns
whether to collate the printed pages
### gtk\_print\_settings\_set\_collate ()
```
void
gtk_print_settings_set_collate (*`[GtkPrintSettings](gtkprintsettings#GtkPrintSettings-struct) *settings`*,
*`gboolean collate`*);
```
Sets the value of [`GTK_PRINT_SETTINGS_COLLATE`](gtkprintsettings#GTK-PRINT-SETTINGS-COLLATE:CAPS).
#### Parameters
| | | |
| --- | --- | --- |
| settings | a [GtkPrintSettings](gtkprintsettings#GtkPrintSettings-struct) | |
| collate | whether to collate the output | |
### gtk\_print\_settings\_get\_reverse ()
```
gboolean
gtk_print_settings_get_reverse (*`[GtkPrintSettings](gtkprintsettings#GtkPrintSettings-struct) *settings`*);
```
Gets the value of [`GTK_PRINT_SETTINGS_REVERSE`](gtkprintsettings#GTK-PRINT-SETTINGS-REVERSE:CAPS).
#### Parameters
| | | |
| --- | --- | --- |
| settings | a [GtkPrintSettings](gtkprintsettings#GtkPrintSettings-struct) | |
#### Returns
whether to reverse the order of the printed pages
### gtk\_print\_settings\_set\_reverse ()
```
void
gtk_print_settings_set_reverse (*`[GtkPrintSettings](gtkprintsettings#GtkPrintSettings-struct) *settings`*,
*`gboolean reverse`*);
```
Sets the value of [`GTK_PRINT_SETTINGS_REVERSE`](gtkprintsettings#GTK-PRINT-SETTINGS-REVERSE:CAPS).
#### Parameters
| | | |
| --- | --- | --- |
| settings | a [GtkPrintSettings](gtkprintsettings#GtkPrintSettings-struct) | |
| reverse | whether to reverse the output | |
### gtk\_print\_settings\_get\_duplex ()
```
[GtkPrintDuplex](gtkprintsettings#GtkPrintDuplex)
gtk_print_settings_get_duplex (*`[GtkPrintSettings](gtkprintsettings#GtkPrintSettings-struct) *settings`*);
```
Gets the value of [`GTK_PRINT_SETTINGS_DUPLEX`](gtkprintsettings#GTK-PRINT-SETTINGS-DUPLEX:CAPS).
#### Parameters
| | | |
| --- | --- | --- |
| settings | a [GtkPrintSettings](gtkprintsettings#GtkPrintSettings-struct) | |
#### Returns
whether to print the output in duplex.
### gtk\_print\_settings\_set\_duplex ()
```
void
gtk_print_settings_set_duplex (*`[GtkPrintSettings](gtkprintsettings#GtkPrintSettings-struct) *settings`*,
*`[GtkPrintDuplex](gtkprintsettings#GtkPrintDuplex) duplex`*);
```
Sets the value of [`GTK_PRINT_SETTINGS_DUPLEX`](gtkprintsettings#GTK-PRINT-SETTINGS-DUPLEX:CAPS).
#### Parameters
| | | |
| --- | --- | --- |
| settings | a [GtkPrintSettings](gtkprintsettings#GtkPrintSettings-struct) | |
| duplex | a [GtkPrintDuplex](gtkprintsettings#GtkPrintDuplex) value | |
### gtk\_print\_settings\_get\_quality ()
```
[GtkPrintQuality](gtkprintsettings#GtkPrintQuality)
gtk_print_settings_get_quality (*`[GtkPrintSettings](gtkprintsettings#GtkPrintSettings-struct) *settings`*);
```
Gets the value of [`GTK_PRINT_SETTINGS_QUALITY`](gtkprintsettings#GTK-PRINT-SETTINGS-QUALITY:CAPS).
#### Parameters
| | | |
| --- | --- | --- |
| settings | a [GtkPrintSettings](gtkprintsettings#GtkPrintSettings-struct) | |
#### Returns
the print quality
### gtk\_print\_settings\_set\_quality ()
```
void
gtk_print_settings_set_quality (*`[GtkPrintSettings](gtkprintsettings#GtkPrintSettings-struct) *settings`*,
*`[GtkPrintQuality](gtkprintsettings#GtkPrintQuality) quality`*);
```
Sets the value of [`GTK_PRINT_SETTINGS_QUALITY`](gtkprintsettings#GTK-PRINT-SETTINGS-QUALITY:CAPS).
#### Parameters
| | | |
| --- | --- | --- |
| settings | a [GtkPrintSettings](gtkprintsettings#GtkPrintSettings-struct) | |
| quality | a [GtkPrintQuality](gtkprintsettings#GtkPrintQuality) value | |
### gtk\_print\_settings\_get\_n\_copies ()
```
int
gtk_print_settings_get_n_copies (*`[GtkPrintSettings](gtkprintsettings#GtkPrintSettings-struct) *settings`*);
```
Gets the value of [`GTK_PRINT_SETTINGS_N_COPIES`](gtkprintsettings#GTK-PRINT-SETTINGS-N-COPIES:CAPS).
#### Parameters
| | | |
| --- | --- | --- |
| settings | a [GtkPrintSettings](gtkprintsettings#GtkPrintSettings-struct) | |
#### Returns
the number of copies to print
### gtk\_print\_settings\_set\_n\_copies ()
```
void
gtk_print_settings_set_n_copies (*`[GtkPrintSettings](gtkprintsettings#GtkPrintSettings-struct) *settings`*,
*`int num_copies`*);
```
Sets the value of [`GTK_PRINT_SETTINGS_N_COPIES`](gtkprintsettings#GTK-PRINT-SETTINGS-N-COPIES:CAPS).
#### Parameters
| | | |
| --- | --- | --- |
| settings | a [GtkPrintSettings](gtkprintsettings#GtkPrintSettings-struct) | |
| num\_copies | the number of copies | |
### gtk\_print\_settings\_get\_number\_up ()
```
int
gtk_print_settings_get_number_up (*`[GtkPrintSettings](gtkprintsettings#GtkPrintSettings-struct) *settings`*);
```
Gets the value of [`GTK_PRINT_SETTINGS_NUMBER_UP`](gtkprintsettings#GTK-PRINT-SETTINGS-NUMBER-UP:CAPS).
#### Parameters
| | | |
| --- | --- | --- |
| settings | a [GtkPrintSettings](gtkprintsettings#GtkPrintSettings-struct) | |
#### Returns
the number of pages per sheet
### gtk\_print\_settings\_set\_number\_up ()
```
void
gtk_print_settings_set_number_up (*`[GtkPrintSettings](gtkprintsettings#GtkPrintSettings-struct) *settings`*,
*`int number_up`*);
```
Sets the value of [`GTK_PRINT_SETTINGS_NUMBER_UP`](gtkprintsettings#GTK-PRINT-SETTINGS-NUMBER-UP:CAPS).
#### Parameters
| | | |
| --- | --- | --- |
| settings | a [GtkPrintSettings](gtkprintsettings#GtkPrintSettings-struct) | |
| number\_up | the number of pages per sheet | |
### gtk\_print\_settings\_get\_number\_up\_layout ()
```
[GtkNumberUpLayout](gtkprintsettings#GtkNumberUpLayout)
gtk_print_settings_get_number_up_layout
(*`[GtkPrintSettings](gtkprintsettings#GtkPrintSettings-struct) *settings`*);
```
Gets the value of [`GTK_PRINT_SETTINGS_NUMBER_UP_LAYOUT`](gtkprintsettings#GTK-PRINT-SETTINGS-NUMBER-UP-LAYOUT:CAPS).
#### Parameters
| | | |
| --- | --- | --- |
| settings | a [GtkPrintSettings](gtkprintsettings#GtkPrintSettings-struct) | |
#### Returns
layout of page in number-up mode
### gtk\_print\_settings\_set\_number\_up\_layout ()
```
void
gtk_print_settings_set_number_up_layout
(*`[GtkPrintSettings](gtkprintsettings#GtkPrintSettings-struct) *settings`*,
*`[GtkNumberUpLayout](gtkprintsettings#GtkNumberUpLayout) number_up_layout`*);
```
Sets the value of [`GTK_PRINT_SETTINGS_NUMBER_UP_LAYOUT`](gtkprintsettings#GTK-PRINT-SETTINGS-NUMBER-UP-LAYOUT:CAPS).
#### Parameters
| | | |
| --- | --- | --- |
| settings | a [GtkPrintSettings](gtkprintsettings#GtkPrintSettings-struct) | |
| number\_up\_layout | a [GtkNumberUpLayout](gtkprintsettings#GtkNumberUpLayout) value | |
### gtk\_print\_settings\_get\_resolution ()
```
int
gtk_print_settings_get_resolution (*`[GtkPrintSettings](gtkprintsettings#GtkPrintSettings-struct) *settings`*);
```
Gets the value of [`GTK_PRINT_SETTINGS_RESOLUTION`](gtkprintsettings#GTK-PRINT-SETTINGS-RESOLUTION:CAPS).
#### Parameters
| | | |
| --- | --- | --- |
| settings | a [GtkPrintSettings](gtkprintsettings#GtkPrintSettings-struct) | |
#### Returns
the resolution in dpi
### gtk\_print\_settings\_set\_resolution ()
```
void
gtk_print_settings_set_resolution (*`[GtkPrintSettings](gtkprintsettings#GtkPrintSettings-struct) *settings`*,
*`int resolution`*);
```
Sets the values of [`GTK_PRINT_SETTINGS_RESOLUTION`](gtkprintsettings#GTK-PRINT-SETTINGS-RESOLUTION:CAPS), [`GTK_PRINT_SETTINGS_RESOLUTION_X`](gtkprintsettings#GTK-PRINT-SETTINGS-RESOLUTION-X:CAPS) and [`GTK_PRINT_SETTINGS_RESOLUTION_Y`](gtkprintsettings#GTK-PRINT-SETTINGS-RESOLUTION-Y:CAPS).
#### Parameters
| | | |
| --- | --- | --- |
| settings | a [GtkPrintSettings](gtkprintsettings#GtkPrintSettings-struct) | |
| resolution | the resolution in dpi | |
### gtk\_print\_settings\_set\_resolution\_xy ()
```
void
gtk_print_settings_set_resolution_xy (*`[GtkPrintSettings](gtkprintsettings#GtkPrintSettings-struct) *settings`*,
*`int resolution_x`*,
*`int resolution_y`*);
```
Sets the values of [`GTK_PRINT_SETTINGS_RESOLUTION`](gtkprintsettings#GTK-PRINT-SETTINGS-RESOLUTION:CAPS), [`GTK_PRINT_SETTINGS_RESOLUTION_X`](gtkprintsettings#GTK-PRINT-SETTINGS-RESOLUTION-X:CAPS) and [`GTK_PRINT_SETTINGS_RESOLUTION_Y`](gtkprintsettings#GTK-PRINT-SETTINGS-RESOLUTION-Y:CAPS).
#### Parameters
| | | |
| --- | --- | --- |
| settings | a [GtkPrintSettings](gtkprintsettings#GtkPrintSettings-struct) | |
| resolution\_x | the horizontal resolution in dpi | |
| resolution\_y | the vertical resolution in dpi | |
### gtk\_print\_settings\_get\_resolution\_x ()
```
int
gtk_print_settings_get_resolution_x (*`[GtkPrintSettings](gtkprintsettings#GtkPrintSettings-struct) *settings`*);
```
Gets the value of [`GTK_PRINT_SETTINGS_RESOLUTION_X`](gtkprintsettings#GTK-PRINT-SETTINGS-RESOLUTION-X:CAPS).
#### Parameters
| | | |
| --- | --- | --- |
| settings | a [GtkPrintSettings](gtkprintsettings#GtkPrintSettings-struct) | |
#### Returns
the horizontal resolution in dpi
### gtk\_print\_settings\_get\_resolution\_y ()
```
int
gtk_print_settings_get_resolution_y (*`[GtkPrintSettings](gtkprintsettings#GtkPrintSettings-struct) *settings`*);
```
Gets the value of [`GTK_PRINT_SETTINGS_RESOLUTION_Y`](gtkprintsettings#GTK-PRINT-SETTINGS-RESOLUTION-Y:CAPS).
#### Parameters
| | | |
| --- | --- | --- |
| settings | a [GtkPrintSettings](gtkprintsettings#GtkPrintSettings-struct) | |
#### Returns
the vertical resolution in dpi
### gtk\_print\_settings\_get\_printer\_lpi ()
```
double
gtk_print_settings_get_printer_lpi (*`[GtkPrintSettings](gtkprintsettings#GtkPrintSettings-struct) *settings`*);
```
Gets the value of [`GTK_PRINT_SETTINGS_PRINTER_LPI`](gtkprintsettings#GTK-PRINT-SETTINGS-PRINTER-LPI:CAPS).
#### Parameters
| | | |
| --- | --- | --- |
| settings | a [GtkPrintSettings](gtkprintsettings#GtkPrintSettings-struct) | |
#### Returns
the resolution in lpi (lines per inch)
### gtk\_print\_settings\_set\_printer\_lpi ()
```
void
gtk_print_settings_set_printer_lpi (*`[GtkPrintSettings](gtkprintsettings#GtkPrintSettings-struct) *settings`*,
*`double lpi`*);
```
Sets the value of [`GTK_PRINT_SETTINGS_PRINTER_LPI`](gtkprintsettings#GTK-PRINT-SETTINGS-PRINTER-LPI:CAPS).
#### Parameters
| | | |
| --- | --- | --- |
| settings | a [GtkPrintSettings](gtkprintsettings#GtkPrintSettings-struct) | |
| lpi | the resolution in lpi (lines per inch) | |
### gtk\_print\_settings\_get\_scale ()
```
double
gtk_print_settings_get_scale (*`[GtkPrintSettings](gtkprintsettings#GtkPrintSettings-struct) *settings`*);
```
Gets the value of [`GTK_PRINT_SETTINGS_SCALE`](gtkprintsettings#GTK-PRINT-SETTINGS-SCALE:CAPS).
#### Parameters
| | | |
| --- | --- | --- |
| settings | a [GtkPrintSettings](gtkprintsettings#GtkPrintSettings-struct) | |
#### Returns
the scale in percent
### gtk\_print\_settings\_set\_scale ()
```
void
gtk_print_settings_set_scale (*`[GtkPrintSettings](gtkprintsettings#GtkPrintSettings-struct) *settings`*,
*`double scale`*);
```
Sets the value of [`GTK_PRINT_SETTINGS_SCALE`](gtkprintsettings#GTK-PRINT-SETTINGS-SCALE:CAPS).
#### Parameters
| | | |
| --- | --- | --- |
| settings | a [GtkPrintSettings](gtkprintsettings#GtkPrintSettings-struct) | |
| scale | the scale in percent | |
### gtk\_print\_settings\_get\_print\_pages ()
```
[GtkPrintPages](gtkprintsettings#GtkPrintPages)
gtk_print_settings_get_print_pages (*`[GtkPrintSettings](gtkprintsettings#GtkPrintSettings-struct) *settings`*);
```
Gets the value of [`GTK_PRINT_SETTINGS_PRINT_PAGES`](gtkprintsettings#GTK-PRINT-SETTINGS-PRINT-PAGES:CAPS).
#### Parameters
| | | |
| --- | --- | --- |
| settings | a [GtkPrintSettings](gtkprintsettings#GtkPrintSettings-struct) | |
#### Returns
which pages to print
### gtk\_print\_settings\_set\_print\_pages ()
```
void
gtk_print_settings_set_print_pages (*`[GtkPrintSettings](gtkprintsettings#GtkPrintSettings-struct) *settings`*,
*`[GtkPrintPages](gtkprintsettings#GtkPrintPages) pages`*);
```
Sets the value of [`GTK_PRINT_SETTINGS_PRINT_PAGES`](gtkprintsettings#GTK-PRINT-SETTINGS-PRINT-PAGES:CAPS).
#### Parameters
| | | |
| --- | --- | --- |
| settings | a [GtkPrintSettings](gtkprintsettings#GtkPrintSettings-struct) | |
| pages | a [GtkPrintPages](gtkprintsettings#GtkPrintPages) value | |
### gtk\_print\_settings\_get\_page\_ranges ()
```
[GtkPageRange](gtkprintsettings#GtkPageRange) *
gtk_print_settings_get_page_ranges (*`[GtkPrintSettings](gtkprintsettings#GtkPrintSettings-struct) *settings`*,
*`int *num_ranges`*);
```
Gets the value of [`GTK_PRINT_SETTINGS_PAGE_RANGES`](gtkprintsettings#GTK-PRINT-SETTINGS-PAGE-RANGES:CAPS).
#### Parameters
| | | |
| --- | --- | --- |
| settings | a [GtkPrintSettings](gtkprintsettings#GtkPrintSettings-struct) | |
| num\_ranges | return location for the length of the returned array. | [out] |
#### Returns
an array of GtkPageRanges. Use `g_free()` to free the array when it is no longer needed.
[array length=num\_ranges][transfer full]
### gtk\_print\_settings\_set\_page\_ranges ()
```
void
gtk_print_settings_set_page_ranges (*`[GtkPrintSettings](gtkprintsettings#GtkPrintSettings-struct) *settings`*,
*`[GtkPageRange](gtkprintsettings#GtkPageRange) *page_ranges`*,
*`int num_ranges`*);
```
Sets the value of [`GTK_PRINT_SETTINGS_PAGE_RANGES`](gtkprintsettings#GTK-PRINT-SETTINGS-PAGE-RANGES:CAPS).
#### Parameters
| | | |
| --- | --- | --- |
| settings | a [GtkPrintSettings](gtkprintsettings#GtkPrintSettings-struct) | |
| page\_ranges | an array of GtkPageRanges. | [array length=num\_ranges] |
| num\_ranges | the length of *`page_ranges`* | |
### gtk\_print\_settings\_get\_page\_set ()
```
[GtkPageSet](gtkprintsettings#GtkPageSet)
gtk_print_settings_get_page_set (*`[GtkPrintSettings](gtkprintsettings#GtkPrintSettings-struct) *settings`*);
```
Gets the value of [`GTK_PRINT_SETTINGS_PAGE_SET`](gtkprintsettings#GTK-PRINT-SETTINGS-PAGE-SET:CAPS).
#### Parameters
| | | |
| --- | --- | --- |
| settings | a [GtkPrintSettings](gtkprintsettings#GtkPrintSettings-struct) | |
#### Returns
the set of pages to print
### gtk\_print\_settings\_set\_page\_set ()
```
void
gtk_print_settings_set_page_set (*`[GtkPrintSettings](gtkprintsettings#GtkPrintSettings-struct) *settings`*,
*`[GtkPageSet](gtkprintsettings#GtkPageSet) page_set`*);
```
Sets the value of [`GTK_PRINT_SETTINGS_PAGE_SET`](gtkprintsettings#GTK-PRINT-SETTINGS-PAGE-SET:CAPS).
#### Parameters
| | | |
| --- | --- | --- |
| settings | a [GtkPrintSettings](gtkprintsettings#GtkPrintSettings-struct) | |
| page\_set | a [GtkPageSet](gtkprintsettings#GtkPageSet) value | |
### gtk\_print\_settings\_get\_default\_source ()
```
const char *
gtk_print_settings_get_default_source (*`[GtkPrintSettings](gtkprintsettings#GtkPrintSettings-struct) *settings`*);
```
Gets the value of [`GTK_PRINT_SETTINGS_DEFAULT_SOURCE`](gtkprintsettings#GTK-PRINT-SETTINGS-DEFAULT-SOURCE:CAPS).
#### Parameters
| | | |
| --- | --- | --- |
| settings | a [GtkPrintSettings](gtkprintsettings#GtkPrintSettings-struct) | |
#### Returns
the default source
### gtk\_print\_settings\_set\_default\_source ()
```
void
gtk_print_settings_set_default_source (*`[GtkPrintSettings](gtkprintsettings#GtkPrintSettings-struct) *settings`*,
*`const char *default_source`*);
```
Sets the value of [`GTK_PRINT_SETTINGS_DEFAULT_SOURCE`](gtkprintsettings#GTK-PRINT-SETTINGS-DEFAULT-SOURCE:CAPS).
#### Parameters
| | | |
| --- | --- | --- |
| settings | a [GtkPrintSettings](gtkprintsettings#GtkPrintSettings-struct) | |
| default\_source | the default source | |
### gtk\_print\_settings\_get\_media\_type ()
```
const char *
gtk_print_settings_get_media_type (*`[GtkPrintSettings](gtkprintsettings#GtkPrintSettings-struct) *settings`*);
```
Gets the value of [`GTK_PRINT_SETTINGS_MEDIA_TYPE`](gtkprintsettings#GTK-PRINT-SETTINGS-MEDIA-TYPE:CAPS).
The set of media types is defined in PWG 5101.1-2002 PWG.
#### Parameters
| | | |
| --- | --- | --- |
| settings | a [GtkPrintSettings](gtkprintsettings#GtkPrintSettings-struct) | |
#### Returns
the media type
### gtk\_print\_settings\_set\_media\_type ()
```
void
gtk_print_settings_set_media_type (*`[GtkPrintSettings](gtkprintsettings#GtkPrintSettings-struct) *settings`*,
*`const char *media_type`*);
```
Sets the value of [`GTK_PRINT_SETTINGS_MEDIA_TYPE`](gtkprintsettings#GTK-PRINT-SETTINGS-MEDIA-TYPE:CAPS).
The set of media types is defined in PWG 5101.1-2002 PWG.
#### Parameters
| | | |
| --- | --- | --- |
| settings | a [GtkPrintSettings](gtkprintsettings#GtkPrintSettings-struct) | |
| media\_type | the media type | |
### gtk\_print\_settings\_get\_dither ()
```
const char *
gtk_print_settings_get_dither (*`[GtkPrintSettings](gtkprintsettings#GtkPrintSettings-struct) *settings`*);
```
Gets the value of [`GTK_PRINT_SETTINGS_DITHER`](gtkprintsettings#GTK-PRINT-SETTINGS-DITHER:CAPS).
#### Parameters
| | | |
| --- | --- | --- |
| settings | a [GtkPrintSettings](gtkprintsettings#GtkPrintSettings-struct) | |
#### Returns
the dithering that is used
### gtk\_print\_settings\_set\_dither ()
```
void
gtk_print_settings_set_dither (*`[GtkPrintSettings](gtkprintsettings#GtkPrintSettings-struct) *settings`*,
*`const char *dither`*);
```
Sets the value of [`GTK_PRINT_SETTINGS_DITHER`](gtkprintsettings#GTK-PRINT-SETTINGS-DITHER:CAPS).
#### Parameters
| | | |
| --- | --- | --- |
| settings | a [GtkPrintSettings](gtkprintsettings#GtkPrintSettings-struct) | |
| dither | the dithering that is used | |
### gtk\_print\_settings\_get\_finishings ()
```
const char *
gtk_print_settings_get_finishings (*`[GtkPrintSettings](gtkprintsettings#GtkPrintSettings-struct) *settings`*);
```
Gets the value of [`GTK_PRINT_SETTINGS_FINISHINGS`](gtkprintsettings#GTK-PRINT-SETTINGS-FINISHINGS:CAPS).
#### Parameters
| | | |
| --- | --- | --- |
| settings | a [GtkPrintSettings](gtkprintsettings#GtkPrintSettings-struct) | |
#### Returns
the finishings
### gtk\_print\_settings\_set\_finishings ()
```
void
gtk_print_settings_set_finishings (*`[GtkPrintSettings](gtkprintsettings#GtkPrintSettings-struct) *settings`*,
*`const char *finishings`*);
```
Sets the value of [`GTK_PRINT_SETTINGS_FINISHINGS`](gtkprintsettings#GTK-PRINT-SETTINGS-FINISHINGS:CAPS).
#### Parameters
| | | |
| --- | --- | --- |
| settings | a [GtkPrintSettings](gtkprintsettings#GtkPrintSettings-struct) | |
| finishings | the finishings | |
### gtk\_print\_settings\_get\_output\_bin ()
```
const char *
gtk_print_settings_get_output_bin (*`[GtkPrintSettings](gtkprintsettings#GtkPrintSettings-struct) *settings`*);
```
Gets the value of [`GTK_PRINT_SETTINGS_OUTPUT_BIN`](gtkprintsettings#GTK-PRINT-SETTINGS-OUTPUT-BIN:CAPS).
#### Parameters
| | | |
| --- | --- | --- |
| settings | a [GtkPrintSettings](gtkprintsettings#GtkPrintSettings-struct) | |
#### Returns
the output bin
### gtk\_print\_settings\_set\_output\_bin ()
```
void
gtk_print_settings_set_output_bin (*`[GtkPrintSettings](gtkprintsettings#GtkPrintSettings-struct) *settings`*,
*`const char *output_bin`*);
```
Sets the value of [`GTK_PRINT_SETTINGS_OUTPUT_BIN`](gtkprintsettings#GTK-PRINT-SETTINGS-OUTPUT-BIN:CAPS).
#### Parameters
| | | |
| --- | --- | --- |
| settings | a [GtkPrintSettings](gtkprintsettings#GtkPrintSettings-struct) | |
| output\_bin | the output bin | |
### gtk\_print\_settings\_new\_from\_file ()
```
[GtkPrintSettings](gtkprintsettings#GtkPrintSettings-struct) *
gtk_print_settings_new_from_file (*`const char *file_name`*,
*`GError **error`*);
```
Reads the print settings from *`file_name`* . Returns a new [GtkPrintSettings](gtkprintsettings#GtkPrintSettings-struct) object with the restored settings, or `NULL` if an error occurred. If the file could not be loaded then error is set to either a GFileError or GKeyFileError. See [`gtk_print_settings_to_file()`](gtkprintsettings#gtk-print-settings-to-file).
#### Parameters
| | | |
| --- | --- | --- |
| file\_name | the filename to read the settings from. | [type filename] |
| error | return location for errors, or `NULL`. | [allow-none] |
#### Returns
the restored [GtkPrintSettings](gtkprintsettings#GtkPrintSettings-struct)
### gtk\_print\_settings\_new\_from\_key\_file ()
```
[GtkPrintSettings](gtkprintsettings#GtkPrintSettings-struct) *
gtk_print_settings_new_from_key_file (*`GKeyFile *key_file`*,
*`const char *group_name`*,
*`GError **error`*);
```
Reads the print settings from the group *`group_name`* in *`key_file`* . Returns a new [GtkPrintSettings](gtkprintsettings#GtkPrintSettings-struct) object with the restored settings, or `NULL` if an error occurred. If the file could not be loaded then error is set to either a GFileError or GKeyFileError.
#### Parameters
| | | |
| --- | --- | --- |
| key\_file | the GKeyFile to retrieve the settings from | |
| group\_name | the name of the group to use, or `NULL` to use the default “Print Settings”. | [allow-none] |
| error | return location for errors, or `NULL`. | [allow-none] |
#### Returns
the restored [GtkPrintSettings](gtkprintsettings#GtkPrintSettings-struct)
### gtk\_print\_settings\_new\_from\_gvariant ()
```
[GtkPrintSettings](gtkprintsettings#GtkPrintSettings-struct) *
gtk_print_settings_new_from_gvariant (*`GVariant *variant`*);
```
Deserialize print settings from an a{sv} variant in the format produced by [`gtk_print_settings_to_gvariant()`](gtkprintsettings#gtk-print-settings-to-gvariant).
#### Parameters
| | | |
| --- | --- | --- |
| variant | an a{sv} GVariant | |
#### Returns
a new [GtkPrintSettings](gtkprintsettings#GtkPrintSettings-struct) object.
[transfer full]
### gtk\_print\_settings\_load\_file ()
```
gboolean
gtk_print_settings_load_file (*`[GtkPrintSettings](gtkprintsettings#GtkPrintSettings-struct) *settings`*,
*`const char *file_name`*,
*`GError **error`*);
```
Reads the print settings from *`file_name`* . If the file could not be loaded then error is set to either a GFileError or GKeyFileError. See [`gtk_print_settings_to_file()`](gtkprintsettings#gtk-print-settings-to-file).
#### Parameters
| | | |
| --- | --- | --- |
| settings | a [GtkPrintSettings](gtkprintsettings#GtkPrintSettings-struct) | |
| file\_name | the filename to read the settings from. | [type filename] |
| error | return location for errors, or `NULL`. | [allow-none] |
#### Returns
`TRUE` on success
### gtk\_print\_settings\_load\_key\_file ()
```
gboolean
gtk_print_settings_load_key_file (*`[GtkPrintSettings](gtkprintsettings#GtkPrintSettings-struct) *settings`*,
*`GKeyFile *key_file`*,
*`const char *group_name`*,
*`GError **error`*);
```
Reads the print settings from the group *`group_name`* in *`key_file`* . If the file could not be loaded then error is set to either a GFileError or GKeyFileError.
#### Parameters
| | | |
| --- | --- | --- |
| settings | a [GtkPrintSettings](gtkprintsettings#GtkPrintSettings-struct) | |
| key\_file | the GKeyFile to retrieve the settings from | |
| group\_name | the name of the group to use, or `NULL` to use the default “Print Settings”. | [allow-none] |
| error | return location for errors, or `NULL`. | [allow-none] |
#### Returns
`TRUE` on success
### gtk\_print\_settings\_to\_file ()
```
gboolean
gtk_print_settings_to_file (*`[GtkPrintSettings](gtkprintsettings#GtkPrintSettings-struct) *settings`*,
*`const char *file_name`*,
*`GError **error`*);
```
This function saves the print settings from *`settings`* to *`file_name`* . If the file could not be loaded then error is set to either a GFileError or GKeyFileError.
#### Parameters
| | | |
| --- | --- | --- |
| settings | a [GtkPrintSettings](gtkprintsettings#GtkPrintSettings-struct) | |
| file\_name | the file to save to. | [type filename] |
| error | return location for errors, or `NULL`. | [allow-none] |
#### Returns
`TRUE` on success
### gtk\_print\_settings\_to\_key\_file ()
```
void
gtk_print_settings_to_key_file (*`[GtkPrintSettings](gtkprintsettings#GtkPrintSettings-struct) *settings`*,
*`GKeyFile *key_file`*,
*`const char *group_name`*);
```
This function adds the print settings from *`settings`* to *`key_file`* .
#### Parameters
| | | |
| --- | --- | --- |
| settings | a [GtkPrintSettings](gtkprintsettings#GtkPrintSettings-struct) | |
| key\_file | the GKeyFile to save the print settings to | |
| group\_name | the group to add the settings to in *`key_file`* , or `NULL` to use the default “Print Settings”. | [nullable] |
### gtk\_print\_settings\_to\_gvariant ()
```
GVariant *
gtk_print_settings_to_gvariant (*`[GtkPrintSettings](gtkprintsettings#GtkPrintSettings-struct) *settings`*);
```
Serialize print settings to an a{sv} variant.
#### Parameters
| | | |
| --- | --- | --- |
| settings | a [GtkPrintSettings](gtkprintsettings#GtkPrintSettings-struct) | |
#### Returns
a new, floating, GVariant.
[transfer none]
Types and Values
----------------
### GtkPrintSettings
```
typedef struct _GtkPrintSettings GtkPrintSettings;
```
### GTK\_PRINT\_SETTINGS\_PRINTER
```
#define GTK_PRINT_SETTINGS_PRINTER "printer"
```
### enum GtkPageOrientation
See also [`gtk_print_settings_set_orientation()`](gtkprintsettings#gtk-print-settings-set-orientation).
#### Members
| | | |
| --- | --- | --- |
| GTK\_PAGE\_ORIENTATION\_PORTRAIT | Portrait mode. | |
| GTK\_PAGE\_ORIENTATION\_LANDSCAPE | Landscape mode. | |
| GTK\_PAGE\_ORIENTATION\_REVERSE\_PORTRAIT | Reverse portrait mode. | |
| GTK\_PAGE\_ORIENTATION\_REVERSE\_LANDSCAPE | Reverse landscape mode. | |
### GTK\_PRINT\_SETTINGS\_ORIENTATION
```
#define GTK_PRINT_SETTINGS_ORIENTATION "orientation"
```
### GTK\_PRINT\_SETTINGS\_PAPER\_FORMAT
```
#define GTK_PRINT_SETTINGS_PAPER_FORMAT "paper-format"
```
### GTK\_PRINT\_SETTINGS\_PAPER\_WIDTH
```
#define GTK_PRINT_SETTINGS_PAPER_WIDTH "paper-width"
```
### GTK\_PRINT\_SETTINGS\_PAPER\_HEIGHT
```
#define GTK_PRINT_SETTINGS_PAPER_HEIGHT "paper-height"
```
### GTK\_PRINT\_SETTINGS\_USE\_COLOR
```
#define GTK_PRINT_SETTINGS_USE_COLOR "use-color"
```
### GTK\_PRINT\_SETTINGS\_COLLATE
```
#define GTK_PRINT_SETTINGS_COLLATE "collate"
```
### GTK\_PRINT\_SETTINGS\_REVERSE
```
#define GTK_PRINT_SETTINGS_REVERSE "reverse"
```
### enum GtkPrintDuplex
See also [`gtk_print_settings_set_duplex()`](gtkprintsettings#gtk-print-settings-set-duplex).
#### Members
| | | |
| --- | --- | --- |
| GTK\_PRINT\_DUPLEX\_SIMPLEX | No duplex. | |
| GTK\_PRINT\_DUPLEX\_HORIZONTAL | Horizontal duplex. | |
| GTK\_PRINT\_DUPLEX\_VERTICAL | Vertical duplex. | |
### GTK\_PRINT\_SETTINGS\_DUPLEX
```
#define GTK_PRINT_SETTINGS_DUPLEX "duplex"
```
### enum GtkPrintQuality
See also [`gtk_print_settings_set_quality()`](gtkprintsettings#gtk-print-settings-set-quality).
#### Members
| | | |
| --- | --- | --- |
| GTK\_PRINT\_QUALITY\_LOW | Low quality. | |
| GTK\_PRINT\_QUALITY\_NORMAL | Normal quality. | |
| GTK\_PRINT\_QUALITY\_HIGH | High quality. | |
| GTK\_PRINT\_QUALITY\_DRAFT | Draft quality. | |
### GTK\_PRINT\_SETTINGS\_QUALITY
```
#define GTK_PRINT_SETTINGS_QUALITY "quality"
```
### GTK\_PRINT\_SETTINGS\_N\_COPIES
```
#define GTK_PRINT_SETTINGS_N_COPIES "n-copies"
```
### GTK\_PRINT\_SETTINGS\_NUMBER\_UP
```
#define GTK_PRINT_SETTINGS_NUMBER_UP "number-up"
```
### enum GtkNumberUpLayout
Used to determine the layout of pages on a sheet when printing multiple pages per sheet.
#### Members
| | | |
| --- | --- | --- |
| GTK\_NUMBER\_UP\_LAYOUT\_LEFT\_TO\_RIGHT\_TOP\_TO\_BOTTOM | | |
| GTK\_NUMBER\_UP\_LAYOUT\_LEFT\_TO\_RIGHT\_BOTTOM\_TO\_TOP | | |
| GTK\_NUMBER\_UP\_LAYOUT\_RIGHT\_TO\_LEFT\_TOP\_TO\_BOTTOM | | |
| GTK\_NUMBER\_UP\_LAYOUT\_RIGHT\_TO\_LEFT\_BOTTOM\_TO\_TOP | | |
| GTK\_NUMBER\_UP\_LAYOUT\_TOP\_TO\_BOTTOM\_LEFT\_TO\_RIGHT | | |
| GTK\_NUMBER\_UP\_LAYOUT\_TOP\_TO\_BOTTOM\_RIGHT\_TO\_LEFT | | |
| GTK\_NUMBER\_UP\_LAYOUT\_BOTTOM\_TO\_TOP\_LEFT\_TO\_RIGHT | | |
| GTK\_NUMBER\_UP\_LAYOUT\_BOTTOM\_TO\_TOP\_RIGHT\_TO\_LEFT | | |
### GTK\_PRINT\_SETTINGS\_NUMBER\_UP\_LAYOUT
```
#define GTK_PRINT_SETTINGS_NUMBER_UP_LAYOUT "number-up-layout"
```
### GTK\_PRINT\_SETTINGS\_RESOLUTION
```
#define GTK_PRINT_SETTINGS_RESOLUTION "resolution"
```
### GTK\_PRINT\_SETTINGS\_RESOLUTION\_X
```
#define GTK_PRINT_SETTINGS_RESOLUTION_X "resolution-x"
```
### GTK\_PRINT\_SETTINGS\_RESOLUTION\_Y
```
#define GTK_PRINT_SETTINGS_RESOLUTION_Y "resolution-y"
```
### GTK\_PRINT\_SETTINGS\_PRINTER\_LPI
```
#define GTK_PRINT_SETTINGS_PRINTER_LPI "printer-lpi"
```
### GTK\_PRINT\_SETTINGS\_SCALE
```
#define GTK_PRINT_SETTINGS_SCALE "scale"
```
### enum GtkPrintPages
See also [`gtk_print_job_set_pages()`](gtkprintjob#gtk-print-job-set-pages)
#### Members
| | | |
| --- | --- | --- |
| GTK\_PRINT\_PAGES\_ALL | All pages. | |
| GTK\_PRINT\_PAGES\_CURRENT | Current page. | |
| GTK\_PRINT\_PAGES\_RANGES | Range of pages. | |
| GTK\_PRINT\_PAGES\_SELECTION | Selected pages. | |
### GTK\_PRINT\_SETTINGS\_PRINT\_PAGES
```
#define GTK_PRINT_SETTINGS_PRINT_PAGES "print-pages"
```
### struct GtkPageRange
```
struct GtkPageRange {
int start;
int end;
};
```
See also [`gtk_print_settings_set_page_ranges()`](gtkprintsettings#gtk-print-settings-set-page-ranges).
#### Members
| | | |
| --- | --- | --- |
| int *`start`*; | start of page range. | |
| int *`end`*; | end of page range. | |
### GTK\_PRINT\_SETTINGS\_PAGE\_RANGES
```
#define GTK_PRINT_SETTINGS_PAGE_RANGES "page-ranges"
```
### enum GtkPageSet
See also [`gtk_print_job_set_page_set()`](gtkprintjob#gtk-print-job-set-page-set).
#### Members
| | | |
| --- | --- | --- |
| GTK\_PAGE\_SET\_ALL | All pages. | |
| GTK\_PAGE\_SET\_EVEN | Even pages. | |
| GTK\_PAGE\_SET\_ODD | Odd pages. | |
### GTK\_PRINT\_SETTINGS\_PAGE\_SET
```
#define GTK_PRINT_SETTINGS_PAGE_SET "page-set"
```
### GTK\_PRINT\_SETTINGS\_DEFAULT\_SOURCE
```
#define GTK_PRINT_SETTINGS_DEFAULT_SOURCE "default-source"
```
### GTK\_PRINT\_SETTINGS\_MEDIA\_TYPE
```
#define GTK_PRINT_SETTINGS_MEDIA_TYPE "media-type"
```
### GTK\_PRINT\_SETTINGS\_DITHER
```
#define GTK_PRINT_SETTINGS_DITHER "dither"
```
### GTK\_PRINT\_SETTINGS\_FINISHINGS
```
#define GTK_PRINT_SETTINGS_FINISHINGS "finishings"
```
### GTK\_PRINT\_SETTINGS\_OUTPUT\_BIN
```
#define GTK_PRINT_SETTINGS_OUTPUT_BIN "output-bin"
```
### GTK\_PRINT\_SETTINGS\_OUTPUT\_DIR
```
#define GTK_PRINT_SETTINGS_OUTPUT_DIR "output-dir"
```
The key used by the “Print to file” printer to store the directory to which the output should be written.
### GTK\_PRINT\_SETTINGS\_OUTPUT\_BASENAME
```
#define GTK_PRINT_SETTINGS_OUTPUT_BASENAME "output-basename"
```
The key used by the “Print to file” printer to store the file name of the output without the path to the directory and the file extension.
### GTK\_PRINT\_SETTINGS\_OUTPUT\_FILE\_FORMAT
```
#define GTK_PRINT_SETTINGS_OUTPUT_FILE_FORMAT "output-file-format"
```
The key used by the “Print to file” printer to store the format of the output. The supported values are “PS” and “PDF”.
### GTK\_PRINT\_SETTINGS\_OUTPUT\_URI
```
#define GTK_PRINT_SETTINGS_OUTPUT_URI "output-uri"
```
The key used by the “Print to file” printer to store the URI to which the output should be written. GTK itself supports only “file://” URIs.
### GTK\_PRINT\_SETTINGS\_WIN32\_DRIVER\_EXTRA
```
#define GTK_PRINT_SETTINGS_WIN32_DRIVER_EXTRA "win32-driver-extra"
```
### GTK\_PRINT\_SETTINGS\_WIN32\_DRIVER\_VERSION
```
#define GTK_PRINT_SETTINGS_WIN32_DRIVER_VERSION "win32-driver-version"
```
| programming_docs |
gtk GtkTextMark GtkTextMark
===========
GtkTextMark — A position in the buffer preserved across buffer modifications
Functions
---------
| | |
| --- | --- |
| [GtkTextMark](gtktextmark#GtkTextMark-struct) \* | [gtk\_text\_mark\_new](gtktextmark#gtk-text-mark-new) () |
| void | [gtk\_text\_mark\_set\_visible](gtktextmark#gtk-text-mark-set-visible) () |
| gboolean | [gtk\_text\_mark\_get\_visible](gtktextmark#gtk-text-mark-get-visible) () |
| gboolean | [gtk\_text\_mark\_get\_deleted](gtktextmark#gtk-text-mark-get-deleted) () |
| const char \* | [gtk\_text\_mark\_get\_name](gtktextmark#gtk-text-mark-get-name) () |
| [GtkTextBuffer](gtktextbuffer#GtkTextBuffer-struct) \* | [gtk\_text\_mark\_get\_buffer](gtktextmark#gtk-text-mark-get-buffer) () |
| gboolean | [gtk\_text\_mark\_get\_left\_gravity](gtktextmark#gtk-text-mark-get-left-gravity) () |
Properties
----------
| | | |
| --- | --- | --- |
| gboolean | [left-gravity](gtktextmark#GtkTextMark--left-gravity) | Read / Write / Construct Only |
| char \* | [name](gtktextmark#GtkTextMark--name) | Read / Write / Construct Only |
Types and Values
----------------
| | |
| --- | --- |
| struct | [GtkTextMark](gtktextmark#GtkTextMark-struct) |
Object Hierarchy
----------------
```
GObject
╰── GtkTextMark
```
Includes
--------
```
#include <gtk/gtk.h>
```
Description
-----------
You may wish to begin by reading the [text widget conceptual overview](textwidgetobjects#TextWidget) which gives an overview of all the objects and data types related to the text widget and how they work together.
A [GtkTextMark](gtktextmark#GtkTextMark-struct) is like a bookmark in a text buffer; it preserves a position in the text. You can convert the mark to an iterator using [`gtk_text_buffer_get_iter_at_mark()`](gtktextbuffer#gtk-text-buffer-get-iter-at-mark). Unlike iterators, marks remain valid across buffer mutations, because their behavior is defined when text is inserted or deleted. When text containing a mark is deleted, the mark remains in the position originally occupied by the deleted text. When text is inserted at a mark, a mark with “left gravity” will be moved to the beginning of the newly-inserted text, and a mark with “right gravity” will be moved to the end.
Note that “left” and “right” here refer to logical direction (left is the toward the start of the buffer); in some languages such as Hebrew the logically-leftmost text is not actually on the left when displayed.
Marks are reference counted, but the reference count only controls the validity of the memory; marks can be deleted from the buffer at any time with [`gtk_text_buffer_delete_mark()`](gtktextbuffer#gtk-text-buffer-delete-mark). Once deleted from the buffer, a mark is essentially useless.
Marks optionally have names; these can be convenient to avoid passing the [GtkTextMark](gtktextmark#GtkTextMark-struct) object around.
Marks are typically created using the [`gtk_text_buffer_create_mark()`](gtktextbuffer#gtk-text-buffer-create-mark) function.
Functions
---------
### gtk\_text\_mark\_new ()
```
[GtkTextMark](gtktextmark#GtkTextMark-struct) *
gtk_text_mark_new (*`const char *name`*,
*`gboolean left_gravity`*);
```
Creates a text mark. Add it to a buffer using [`gtk_text_buffer_add_mark()`](gtktextbuffer#gtk-text-buffer-add-mark). If *`name`* is `NULL`, the mark is anonymous; otherwise, the mark can be retrieved by name using [`gtk_text_buffer_get_mark()`](gtktextbuffer#gtk-text-buffer-get-mark). If a mark has left gravity, and text is inserted at the mark’s current location, the mark will be moved to the left of the newly-inserted text. If the mark has right gravity (*`left_gravity`* = `FALSE`), the mark will end up on the right of newly-inserted text. The standard left-to-right cursor is a mark with right gravity (when you type, the cursor stays on the right side of the text you’re typing).
#### Parameters
| | | |
| --- | --- | --- |
| name | mark name or `NULL`. | [allow-none] |
| left\_gravity | whether the mark should have left gravity | |
#### Returns
new [GtkTextMark](gtktextmark#GtkTextMark-struct)
### gtk\_text\_mark\_set\_visible ()
```
void
gtk_text_mark_set_visible (*`[GtkTextMark](gtktextmark#GtkTextMark-struct) *mark`*,
*`gboolean setting`*);
```
Sets the visibility of *`mark`* ; the insertion point is normally visible, i.e. you can see it as a vertical bar. Also, the text widget uses a visible mark to indicate where a drop will occur when dragging-and-dropping text. Most other marks are not visible. Marks are not visible by default.
#### Parameters
| | | |
| --- | --- | --- |
| mark | a [GtkTextMark](gtktextmark#GtkTextMark-struct) | |
| setting | visibility of mark | |
### gtk\_text\_mark\_get\_visible ()
```
gboolean
gtk_text_mark_get_visible (*`[GtkTextMark](gtktextmark#GtkTextMark-struct) *mark`*);
```
Returns `TRUE` if the mark is visible (i.e. a cursor is displayed for it).
#### Parameters
| | | |
| --- | --- | --- |
| mark | a [GtkTextMark](gtktextmark#GtkTextMark-struct) | |
#### Returns
`TRUE` if visible
### gtk\_text\_mark\_get\_deleted ()
```
gboolean
gtk_text_mark_get_deleted (*`[GtkTextMark](gtktextmark#GtkTextMark-struct) *mark`*);
```
Returns `TRUE` if the mark has been removed from its buffer with [`gtk_text_buffer_delete_mark()`](gtktextbuffer#gtk-text-buffer-delete-mark). See [`gtk_text_buffer_add_mark()`](gtktextbuffer#gtk-text-buffer-add-mark) for a way to add it to a buffer again.
#### Parameters
| | | |
| --- | --- | --- |
| mark | a [GtkTextMark](gtktextmark#GtkTextMark-struct) | |
#### Returns
whether the mark is deleted
### gtk\_text\_mark\_get\_name ()
```
const char *
gtk_text_mark_get_name (*`[GtkTextMark](gtktextmark#GtkTextMark-struct) *mark`*);
```
Returns the mark name; returns NULL for anonymous marks.
#### Parameters
| | | |
| --- | --- | --- |
| mark | a [GtkTextMark](gtktextmark#GtkTextMark-struct) | |
#### Returns
mark name.
[nullable]
### gtk\_text\_mark\_get\_buffer ()
```
[GtkTextBuffer](gtktextbuffer#GtkTextBuffer-struct) *
gtk_text_mark_get_buffer (*`[GtkTextMark](gtktextmark#GtkTextMark-struct) *mark`*);
```
Gets the buffer this mark is located inside, or `NULL` if the mark is deleted.
#### Parameters
| | | |
| --- | --- | --- |
| mark | a [GtkTextMark](gtktextmark#GtkTextMark-struct) | |
#### Returns
the mark’s [GtkTextBuffer](gtktextbuffer#GtkTextBuffer-struct).
[transfer none]
### gtk\_text\_mark\_get\_left\_gravity ()
```
gboolean
gtk_text_mark_get_left_gravity (*`[GtkTextMark](gtktextmark#GtkTextMark-struct) *mark`*);
```
Determines whether the mark has left gravity.
#### Parameters
| | | |
| --- | --- | --- |
| mark | a [GtkTextMark](gtktextmark#GtkTextMark-struct) | |
#### Returns
`TRUE` if the mark has left gravity, `FALSE` otherwise
Types and Values
----------------
### struct GtkTextMark
```
struct GtkTextMark;
```
Property Details
----------------
### The `“left-gravity”` property
```
“left-gravity” gboolean
```
Whether the mark has left gravity. When text is inserted at the mark’s current location, if the mark has left gravity it will be moved to the left of the newly-inserted text, otherwise to the right.
Owner: GtkTextMark
Flags: Read / Write / Construct Only
Default value: FALSE
### The `“name”` property
```
“name” char *
```
The name of the mark or `NULL` if the mark is anonymous.
Owner: GtkTextMark
Flags: Read / Write / Construct Only
Default value: NULL
gtk gtk4-builder-tool gtk4-builder-tool
=================
gtk4-builder-tool — GtkBuilder file utility
Synopsis
--------
`gtk4-builder-tool` [*`COMMAND`*] [*`OPTION`*...] *`FILE`*
Description
-----------
**gtk4-builder-tool** can perform various operations on GtkBuilder .ui files.
The `validate` command validates the .ui file and reports errors to stderr.
The `enumerate` command lists all the named objects that are created in the .ui file.
The `preview` command displays the .ui file. This command accepts options to specify the ID of the toplevel object and a .css file to use.
The `simplify` command simplifies the .ui file by removing properties that are set to their default values and writes the resulting XML to stdout, or back to the input file.
When the `--3to4` is specified, `simplify` interprets the input as a GTK 3 ui file and attempts to convert it to GTK 4 equivalents. It performs various conversions, such as renaming properties, translating child properties to layout properties, rewriting the setup for GtkNotebook, GtkStack, GtkAssistant or changing toolbars into boxes.
You should always test the modified .ui files produced by gtk4-builder-tool before using them in production.
Note in particular that the conversion done with `--3to4` is meant as a starting point for a port from GTK 3 to GTK 4. It is expected that you will have to do manual fixups after the initial conversion.
Simplify Options
----------------
The `simplify` command accepts the following options:
| | |
| --- | --- |
| `--replace` | Write the content back to the .ui file instead of stdout. |
| `--3to4` | Transform a GTK 3 ui file to GTK 4 |
Preview Options
---------------
The `preview` command accepts the following options:
| | |
| --- | --- |
| `--id= ID` | The ID of the object to preview. If not specified, gtk4-builder-tool will choose a suitable object on its own. |
| `--css= FILE` | Load style information from the given .css file. |
gtk GtkATContext GtkATContext
============
GtkATContext — An object communicating to Assistive Technologies
Functions
---------
| | |
| --- | --- |
| [GtkAccessible](gtkaccessible#GtkAccessible-struct) \* | [gtk\_at\_context\_get\_accessible](gtkatcontext#gtk-at-context-get-accessible) () |
| [GtkAccessibleRole](gtkaccessible#GtkAccessibleRole) | [gtk\_at\_context\_get\_accessible\_role](gtkatcontext#gtk-at-context-get-accessible-role) () |
| [GtkATContext](gtkatcontext#GtkATContext-struct) \* | [gtk\_at\_context\_create](gtkatcontext#gtk-at-context-create) () |
Properties
----------
| | | |
| --- | --- | --- |
| [GtkAccessible](gtkaccessible#GtkAccessible-struct) \* | [accessible](gtkatcontext#GtkATContext--accessible) | Read / Write / Construct Only |
| [GtkAccessibleRole](gtkaccessible#GtkAccessibleRole) | [accessible-role](gtkatcontext#GtkATContext--accessible-role) | Read / Write / Construct |
| [GdkDisplay](https://developer-old.gnome.org/gtk4/html/GdkDisplay.html#GdkDisplay-struct) \* | [display](gtkatcontext#GtkATContext--display) | Read / Write |
Signals
-------
| | | |
| --- | --- | --- |
| void | [state-change](gtkatcontext#GtkATContext-state-change) | Run First |
Types and Values
----------------
| | |
| --- | --- |
| | [GtkATContext](gtkatcontext#GtkATContext-struct) |
Object Hierarchy
----------------
```
GObject
╰── GtkATContext
```
Includes
--------
```
#include <gtk/gtk.h>
```
Description
-----------
GtkATContext is an abstract class provided by GTK to communicate to platform-specific assistive technologies API.
Each platform supported by GTK implements a [GtkATContext](gtkatcontext#GtkATContext-struct) subclass, and is responsible for updating the accessible state in response to state changes in [GtkAccessible](gtkaccessible#GtkAccessible-struct).
Functions
---------
### gtk\_at\_context\_get\_accessible ()
```
[GtkAccessible](gtkaccessible#GtkAccessible-struct) *
gtk_at_context_get_accessible (*`[GtkATContext](gtkatcontext#GtkATContext-struct) *self`*);
```
Retrieves the [GtkAccessible](gtkaccessible#GtkAccessible-struct) using this context.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkATContext](gtkatcontext#GtkATContext-struct) | |
#### Returns
a [GtkAccessible](gtkaccessible#GtkAccessible-struct).
[transfer none]
### gtk\_at\_context\_get\_accessible\_role ()
```
[GtkAccessibleRole](gtkaccessible#GtkAccessibleRole)
gtk_at_context_get_accessible_role (*`[GtkATContext](gtkatcontext#GtkATContext-struct) *self`*);
```
Retrieves the accessible role of this context.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkATContext](gtkatcontext#GtkATContext-struct) | |
#### Returns
a [GtkAccessibleRole](gtkaccessible#GtkAccessibleRole)
### gtk\_at\_context\_create ()
```
[GtkATContext](gtkatcontext#GtkATContext-struct) *
gtk_at_context_create (*`[GtkAccessibleRole](gtkaccessible#GtkAccessibleRole) accessible_role`*,
*`[GtkAccessible](gtkaccessible#GtkAccessible-struct) *accessible`*,
*`[GdkDisplay](https://developer-old.gnome.org/gtk4/html/GdkDisplay.html#GdkDisplay-struct) *display`*);
```
Creates a new [GtkATContext](gtkatcontext#GtkATContext-struct) instance for the given accessible role, accessible instance, and display connection.
The [GtkATContext](gtkatcontext#GtkATContext-struct) implementation being instantiated will depend on the platform.
[constructor]
#### Parameters
| | | |
| --- | --- | --- |
| accessible\_role | the accessible role used by the [GtkATContext](gtkatcontext#GtkATContext-struct) | |
| accessible | the [GtkAccessible](gtkaccessible#GtkAccessible-struct) implementation using the [GtkATContext](gtkatcontext#GtkATContext-struct) | |
| display | the [GdkDisplay](https://developer-old.gnome.org/gtk4/html/GdkDisplay.html#GdkDisplay-struct) used by the [GtkATContext](gtkatcontext#GtkATContext-struct) | |
#### Returns
the [GtkATContext](gtkatcontext#GtkATContext-struct).
[nullable][transfer full]
Types and Values
----------------
### GtkATContext
```
typedef struct _GtkATContext GtkATContext;
```
Property Details
----------------
### The `“accessible”` property
```
“accessible” [GtkAccessible](gtkaccessible#GtkAccessible-struct) *
```
The [GtkAccessible](gtkaccessible#GtkAccessible-struct) that created the [GtkATContext](gtkatcontext#GtkATContext-struct) instance.
Owner: GtkATContext
Flags: Read / Write / Construct Only
### The `“accessible-role”` property
```
“accessible-role” [GtkAccessibleRole](gtkaccessible#GtkAccessibleRole)
```
The accessible role used by the AT context.
Depending on the given role, different states and properties can be set or retrieved.
Owner: GtkATContext
Flags: Read / Write / Construct
Default value: GTK\_ACCESSIBLE\_ROLE\_NONE
### The `“display”` property
```
“display” [GdkDisplay](https://developer-old.gnome.org/gtk4/html/GdkDisplay.html#GdkDisplay-struct) *
```
The [GdkDisplay](https://developer-old.gnome.org/gtk4/html/GdkDisplay.html#GdkDisplay-struct) for the [GtkATContext](gtkatcontext#GtkATContext-struct).
Owner: GtkATContext
Flags: Read / Write
Signal Details
--------------
### The `“state-change”` signal
```
void
user_function ([GtkATContext](gtkatcontext#GtkATContext-struct) *self,
gpointer user_data)
```
Emitted when the attributes of the accessible for the [GtkATContext](gtkatcontext#GtkATContext-struct) instance change.
#### Parameters
| | | |
| --- | --- | --- |
| self | the [GtkATContext](gtkatcontext#GtkATContext-struct) | |
| user\_data | user data set when the signal handler was connected. | |
Flags: Run First
gtk Compiling the GTK Libraries Compiling the GTK Libraries
===========================
[Building GTK](gtk-building#id-1.9.2.2) [Build types](build-types) [Debug builds](build-types#id-1.9.2.3.3) [Release builds](build-types#id-1.9.2.3.4) [Dependencies](dependencies) [Building and testing GTK](building) [Extra Configuration Options](extra-configuration-options) [`x11-backend`, `win32-backend`, `broadway-backend`, `wayland-backend` and `macos-backend`](extra-configuration-options#id-1.9.2.6.5) [`vulkan`](extra-configuration-options#id-1.9.2.6.6) [`xinerama`](extra-configuration-options#id-1.9.2.6.7) [`media`](extra-configuration-options#id-1.9.2.6.8) [`print`](extra-configuration-options#id-1.9.2.6.9) [`cloudproviders`](extra-configuration-options#id-1.9.2.6.10) [`sysprof`](extra-configuration-options#id-1.9.2.6.11) [`tracker`](extra-configuration-options#id-1.9.2.6.12) [`colord`](extra-configuration-options#id-1.9.2.6.13) [`gtk_doc` and `man-pages`](extra-configuration-options#id-1.9.2.6.14) [`introspection`](extra-configuration-options#id-1.9.2.6.15) [`build-tests`, `install-tests`, `demos`](extra-configuration-options#id-1.9.2.6.16) Before we get into the details of how to compile GTK, we should mention that in many cases, binary packages of GTK prebuilt for your operating system will be available, either from your operating system vendor or from independent sources. If such a set of packages is available, installing it will get you programming with GTK much faster than building it yourself. In fact, you may well already have GTK installed on your system already.
In order to build GTK, you will need *meson* installed on your system. On Linux, and other UNIX-like operating systems, you will also need *ninja*. This guide does not cover how to install these two requirements, but you can refer to the [Meson website](http://mesonbuild.com) for more information. The [Ninja](https://ninja-build.org) build tool is also usable on various operating systems, so we will refer to it in the examples.
If you are building GTK from a source distribution or from a Git clone, you will need to use *meson* to configure the project. The most commonly useful argument is the `--prefix` one, which determines where the files will go once installed. To install GTK under a prefix like `/opt/gtk` you would run Meson as:
```
meson setup --prefix /opt/gtk builddir
```
Meson will create the `builddir` directory and place all the build artefacts there.
You can get a list of all available options for the build by running `meson configure`.
After Meson successfully configured the build directory, you then can run the build, using Ninja:
```
cd builddir
ninja
ninja install
```
If you don’t have permission to write to the directory you are installing in, you may have to change to root temporarily before running `ninja install`.
Several environment variables are useful to pass to set before running *meson*. `CPPFLAGS` contains options to pass to the C compiler, and is used to tell the compiler where to look for include files. The `LDFLAGS` variable is used in a similar fashion for the linker. Finally the `PKG_CONFIG_PATH` environment variable contains a search path that `pkg-config` (see below) uses when looking for files describing how to compile programs using different libraries. If you were installing GTK and it’s dependencies into `/opt/gtk`, you might want to set these variables as:
```
CPPFLAGS="-I/opt/gtk/include"
LDFLAGS="-L/opt/gtk/lib"
PKG_CONFIG_PATH="/opt/gtk/lib/pkgconfig"
export CPPFLAGS LDFLAGS PKG_CONFIG_PATH
```
You may also need to set the `LD_LIBRARY_PATH` environment variable so the systems dynamic linker can find the newly installed libraries, and the `PATH` environment program so that utility binaries installed by the various libraries will be found.
```
LD_LIBRARY_PATH="/opt/gtk/lib"
PATH="/opt/gtk/bin:$PATH"
export LD_LIBRARY_PATH PATH
```
gtk GtkShortcutsSection GtkShortcutsSection
===================
GtkShortcutsSection — Represents an application mode in a GtkShortcutsWindow
Properties
----------
| | | |
| --- | --- | --- |
| guint | [max-height](gtkshortcutssection#GtkShortcutsSection--max-height) | Read / Write |
| char \* | [section-name](gtkshortcutssection#GtkShortcutsSection--section-name) | Read / Write |
| char \* | [title](gtkshortcutssection#GtkShortcutsSection--title) | Read / Write |
| char \* | [view-name](gtkshortcutssection#GtkShortcutsSection--view-name) | Read / Write |
Signals
-------
| | | |
| --- | --- | --- |
| gboolean | [change-current-page](gtkshortcutssection#GtkShortcutsSection-change-current-page) | Action |
Types and Values
----------------
| | |
| --- | --- |
| | [GtkShortcutsSection](gtkshortcutssection#GtkShortcutsSection-struct) |
Object Hierarchy
----------------
```
GObject
╰── GInitiallyUnowned
╰── [GtkWidget](gtkwidget#GtkWidget-struct)
╰── [GtkBox](gtkbox#GtkBox-struct)
╰── GtkShortcutsSection
```
Implemented Interfaces
----------------------
GtkShortcutsSection implements [GtkAccessible](gtkaccessible#GtkAccessible-struct), [GtkBuildable](gtkbuildable#GtkBuildable-struct), [GtkConstraintTarget](gtkconstraint#GtkConstraintTarget-struct) and [GtkOrientable](gtk4-orientable#GtkOrientable-struct).
Includes
--------
```
#include <gtk/gtk.h>
```
Description
-----------
A GtkShortcutsSection collects all the keyboard shortcuts and gestures for a major application mode. If your application needs multiple sections, you should give each section a unique [“section-name”](gtkshortcutssection#GtkShortcutsSection--section-name) and a [“title”](gtkshortcutssection#GtkShortcutsSection--title) that can be shown in the section selector of the GtkShortcutsWindow.
The [“max-height”](gtkshortcutssection#GtkShortcutsSection--max-height) property can be used to influence how the groups in the section are distributed over pages and columns.
This widget is only meant to be used with [GtkShortcutsWindow](gtkshortcutswindow#GtkShortcutsWindow-struct).
Functions
---------
Types and Values
----------------
### GtkShortcutsSection
```
typedef struct _GtkShortcutsSection GtkShortcutsSection;
```
Property Details
----------------
### The `“max-height”` property
```
“max-height” guint
```
The maximum number of lines to allow per column. This property can be used to influence how the groups in this section are distributed across pages and columns. The default value of 15 should work in most cases.
Owner: GtkShortcutsSection
Flags: Read / Write
Default value: 15
### The `“section-name”` property
```
“section-name” char *
```
A unique name to identify this section among the sections added to the GtkShortcutsWindow. Setting the [“section-name”](gtkshortcutswindow#GtkShortcutsWindow--section-name) property to this string will make this section shown in the GtkShortcutsWindow.
Owner: GtkShortcutsSection
Flags: Read / Write
Default value: NULL
### The `“title”` property
```
“title” char *
```
The string to show in the section selector of the GtkShortcutsWindow for this section. If there is only one section, you don't need to set a title, since the section selector will not be shown in this case.
Owner: GtkShortcutsSection
Flags: Read / Write
Default value: NULL
### The `“view-name”` property
```
“view-name” char *
```
A view name to filter the groups in this section by. See [“view”](gtkshortcutsgroup#GtkShortcutsGroup--view).
Applications are expected to use the [“view-name”](gtkshortcutswindow#GtkShortcutsWindow--view-name) property for this purpose.
Owner: GtkShortcutsSection
Flags: Read / Write
Default value: NULL
Signal Details
--------------
### The `“change-current-page”` signal
```
gboolean
user_function ([GtkShortcutsSection](gtkshortcutssection#GtkShortcutsSection-struct) *shortcutssection,
int arg1,
gpointer user_data)
```
Flags: Action
| programming_docs |
gtk GtkVideo GtkVideo
========
GtkVideo — A widget for displaying video
Functions
---------
| | |
| --- | --- |
| [GtkWidget](gtkwidget#GtkWidget-struct) \* | [gtk\_video\_new](gtkvideo#gtk-video-new) () |
| [GtkWidget](gtkwidget#GtkWidget-struct) \* | [gtk\_video\_new\_for\_media\_stream](gtkvideo#gtk-video-new-for-media-stream) () |
| [GtkWidget](gtkwidget#GtkWidget-struct) \* | [gtk\_video\_new\_for\_file](gtkvideo#gtk-video-new-for-file) () |
| [GtkWidget](gtkwidget#GtkWidget-struct) \* | [gtk\_video\_new\_for\_filename](gtkvideo#gtk-video-new-for-filename) () |
| [GtkWidget](gtkwidget#GtkWidget-struct) \* | [gtk\_video\_new\_for\_resource](gtkvideo#gtk-video-new-for-resource) () |
| [GtkMediaStream](gtkmediastream#GtkMediaStream-struct) \* | [gtk\_video\_get\_media\_stream](gtkvideo#gtk-video-get-media-stream) () |
| void | [gtk\_video\_set\_media\_stream](gtkvideo#gtk-video-set-media-stream) () |
| GFile \* | [gtk\_video\_get\_file](gtkvideo#gtk-video-get-file) () |
| void | [gtk\_video\_set\_file](gtkvideo#gtk-video-set-file) () |
| void | [gtk\_video\_set\_filename](gtkvideo#gtk-video-set-filename) () |
| void | [gtk\_video\_set\_resource](gtkvideo#gtk-video-set-resource) () |
| gboolean | [gtk\_video\_get\_autoplay](gtkvideo#gtk-video-get-autoplay) () |
| void | [gtk\_video\_set\_autoplay](gtkvideo#gtk-video-set-autoplay) () |
| gboolean | [gtk\_video\_get\_loop](gtkvideo#gtk-video-get-loop) () |
| void | [gtk\_video\_set\_loop](gtkvideo#gtk-video-set-loop) () |
Properties
----------
| | | |
| --- | --- | --- |
| gboolean | [autoplay](gtkvideo#GtkVideo--autoplay) | Read / Write |
| GFile \* | [file](gtkvideo#GtkVideo--file) | Read / Write |
| gboolean | [loop](gtkvideo#GtkVideo--loop) | Read / Write |
| [GtkMediaStream](gtkmediastream#GtkMediaStream-struct) \* | [media-stream](gtkvideo#GtkVideo--media-stream) | Read / Write |
Types and Values
----------------
| | |
| --- | --- |
| | [GtkVideo](gtkvideo#GtkVideo-struct) |
Object Hierarchy
----------------
```
GObject
╰── GInitiallyUnowned
╰── [GtkWidget](gtkwidget#GtkWidget-struct)
╰── GtkVideo
```
Implemented Interfaces
----------------------
GtkVideo implements [GtkAccessible](gtkaccessible#GtkAccessible-struct), [GtkBuildable](gtkbuildable#GtkBuildable-struct) and [GtkConstraintTarget](gtkconstraint#GtkConstraintTarget-struct).
Includes
--------
```
#include <gtk/gtk.h>
```
Description
-----------
GtkVideo is a widget to show a [GtkMediaStream](gtkmediastream#GtkMediaStream-struct) with media controls as provided by [GtkMediaControls](gtkmediacontrols#GtkMediaControls-struct). If you just want to display a video without controls, you can treat it like any other paintable and for example put it into a [GtkPicture](gtkpicture#GtkPicture-struct).
GtkVideo aims to cover use cases such as previews, embedded animations, etc. It supports autoplay, looping, and simple media controls. It does not have support for video overlays, multichannel audio, device selection, or input. If you are writing a full-fledged video player, you may want to use the [GdkPaintable](https://developer-old.gnome.org/gtk4/html/GdkPaintable.html#GdkPaintable-struct) API and a media framework such as Gstreamer directly.
Functions
---------
### gtk\_video\_new ()
```
[GtkWidget](gtkwidget#GtkWidget-struct) *
gtk_video_new (*`void`*);
```
Creates a new empty [GtkVideo](gtkvideo#GtkVideo-struct).
#### Returns
a new [GtkVideo](gtkvideo#GtkVideo-struct)
### gtk\_video\_new\_for\_media\_stream ()
```
[GtkWidget](gtkwidget#GtkWidget-struct) *
gtk_video_new_for_media_stream (*`[GtkMediaStream](gtkmediastream#GtkMediaStream-struct) *stream`*);
```
Creates a [GtkVideo](gtkvideo#GtkVideo-struct) to play back the given *`stream`* .
#### Parameters
| | | |
| --- | --- | --- |
| stream | a [GtkMediaStream](gtkmediastream#GtkMediaStream-struct). | [allow-none] |
#### Returns
a new [GtkVideo](gtkvideo#GtkVideo-struct)
### gtk\_video\_new\_for\_file ()
```
[GtkWidget](gtkwidget#GtkWidget-struct) *
gtk_video_new_for_file (*`GFile *file`*);
```
Creates a [GtkVideo](gtkvideo#GtkVideo-struct) to play back the given *`file`* .
#### Parameters
| | | |
| --- | --- | --- |
| file | a GFile. | [allow-none] |
#### Returns
a new [GtkVideo](gtkvideo#GtkVideo-struct)
### gtk\_video\_new\_for\_filename ()
```
[GtkWidget](gtkwidget#GtkWidget-struct) *
gtk_video_new_for_filename (*`const char *filename`*);
```
Creates a [GtkVideo](gtkvideo#GtkVideo-struct) to play back the given *`filename`* .
This is a utility function that calls [`gtk_video_new_for_file()`](gtkvideo#gtk-video-new-for-file), See that function for details.
#### Parameters
| | | |
| --- | --- | --- |
| filename | filename to play back. | [allow-none][type filename] |
#### Returns
a new [GtkVideo](gtkvideo#GtkVideo-struct)
### gtk\_video\_new\_for\_resource ()
```
[GtkWidget](gtkwidget#GtkWidget-struct) *
gtk_video_new_for_resource (*`const char *resource_path`*);
```
Creates a [GtkVideo](gtkvideo#GtkVideo-struct) to play back the resource at the given *`resource_path`* .
This is a utility function that calls [`gtk_video_new_for_file()`](gtkvideo#gtk-video-new-for-file),
#### Parameters
| | | |
| --- | --- | --- |
| resource\_path | resource path to play back. | [allow-none] |
#### Returns
a new [GtkVideo](gtkvideo#GtkVideo-struct)
### gtk\_video\_get\_media\_stream ()
```
[GtkMediaStream](gtkmediastream#GtkMediaStream-struct) *
gtk_video_get_media_stream (*`[GtkVideo](gtkvideo#GtkVideo-struct) *self`*);
```
Gets the media stream managed by *`self`* or `NULL` if none.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkVideo](gtkvideo#GtkVideo-struct) | |
#### Returns
The media stream managed by *`self`* .
[nullable][transfer none]
### gtk\_video\_set\_media\_stream ()
```
void
gtk_video_set_media_stream (*`[GtkVideo](gtkvideo#GtkVideo-struct) *self`*,
*`[GtkMediaStream](gtkmediastream#GtkMediaStream-struct) *stream`*);
```
Sets the media stream to be played back. *`self`* will take full control of managing the media stream. If you want to manage a media stream yourself, consider using a [GtkImage](gtkimage#GtkImage-struct) for display.
If you want to display a file, consider using [`gtk_video_set_file()`](gtkvideo#gtk-video-set-file) instead.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkVideo](gtkvideo#GtkVideo-struct) | |
| stream | The media stream to play or `NULL` to unset. | [allow-none] |
### gtk\_video\_get\_file ()
```
GFile *
gtk_video_get_file (*`[GtkVideo](gtkvideo#GtkVideo-struct) *self`*);
```
Gets the file played by *`self`* or `NULL` if not playing back a file.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkVideo](gtkvideo#GtkVideo-struct) | |
#### Returns
The file played by *`self`* .
[nullable][transfer none]
### gtk\_video\_set\_file ()
```
void
gtk_video_set_file (*`[GtkVideo](gtkvideo#GtkVideo-struct) *self`*,
*`GFile *file`*);
```
Makes *`self`* play the given *`file`* .
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkVideo](gtkvideo#GtkVideo-struct) | |
| file | the file to play. | [allow-none] |
### gtk\_video\_set\_filename ()
```
void
gtk_video_set_filename (*`[GtkVideo](gtkvideo#GtkVideo-struct) *self`*,
*`const char *filename`*);
```
Makes *`self`* play the given *`filename`* .
This is a utility function that calls [`gtk_video_set_file()`](gtkvideo#gtk-video-set-file),
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkVideo](gtkvideo#GtkVideo-struct) | |
| filename | the filename to play. | [allow-none] |
### gtk\_video\_set\_resource ()
```
void
gtk_video_set_resource (*`[GtkVideo](gtkvideo#GtkVideo-struct) *self`*,
*`const char *resource_path`*);
```
Makes *`self`* play the resource at the given *`resource_path`* .
This is a utility function that calls [`gtk_video_set_file()`](gtkvideo#gtk-video-set-file),
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkVideo](gtkvideo#GtkVideo-struct) | |
| resource\_path | the resource to set. | [allow-none] |
### gtk\_video\_get\_autoplay ()
```
gboolean
gtk_video_get_autoplay (*`[GtkVideo](gtkvideo#GtkVideo-struct) *self`*);
```
Returns `TRUE` if videos have been set to loop via [`gtk_video_set_loop()`](gtkvideo#gtk-video-set-loop).
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkVideo](gtkvideo#GtkVideo-struct) | |
#### Returns
`TRUE` if streams should autoplay
### gtk\_video\_set\_autoplay ()
```
void
gtk_video_set_autoplay (*`[GtkVideo](gtkvideo#GtkVideo-struct) *self`*,
*`gboolean autoplay`*);
```
Sets whether *`self`* automatically starts playback when it becomes visible or when a new file gets loaded.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkVideo](gtkvideo#GtkVideo-struct) | |
| autoplay | whether media streams should autoplay | |
### gtk\_video\_get\_loop ()
```
gboolean
gtk_video_get_loop (*`[GtkVideo](gtkvideo#GtkVideo-struct) *self`*);
```
Returns `TRUE` if videos have been set to loop via [`gtk_video_set_loop()`](gtkvideo#gtk-video-set-loop).
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkVideo](gtkvideo#GtkVideo-struct) | |
#### Returns
`TRUE` if streams should loop
### gtk\_video\_set\_loop ()
```
void
gtk_video_set_loop (*`[GtkVideo](gtkvideo#GtkVideo-struct) *self`*,
*`gboolean loop`*);
```
Sets whether new files loaded by *`self`* should be set to loop.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkVideo](gtkvideo#GtkVideo-struct) | |
| loop | whether media streams should loop | |
Types and Values
----------------
### GtkVideo
```
typedef struct _GtkVideo GtkVideo;
```
Property Details
----------------
### The `“autoplay”` property
```
“autoplay” gboolean
```
If the video should automatically begin playing.
Owner: GtkVideo
Flags: Read / Write
Default value: FALSE
### The `“file”` property
```
“file” GFile *
```
The file played by this video if the video is playing a file.
Owner: GtkVideo
Flags: Read / Write
### The `“loop”` property
```
“loop” gboolean
```
If new media files should be set to loop.
Owner: GtkVideo
Flags: Read / Write
Default value: FALSE
### The `“media-stream”` property
```
“media-stream” [GtkMediaStream](gtkmediastream#GtkMediaStream-struct) *
```
The media-stream played
Owner: GtkVideo
Flags: Read / Write
See Also
--------
[GtkMediaControls](gtkmediacontrols#GtkMediaControls-struct), [GtkMediaStream](gtkmediastream#GtkMediaStream-struct)
gtk GtkCssProvider GtkCssProvider
==============
GtkCssProvider — CSS-like styling for widgets
Functions
---------
| | |
| --- | --- |
| void | [gtk\_css\_provider\_load\_named](gtkcssprovider#gtk-css-provider-load-named) () |
| void | [gtk\_css\_provider\_load\_from\_data](gtkcssprovider#gtk-css-provider-load-from-data) () |
| void | [gtk\_css\_provider\_load\_from\_file](gtkcssprovider#gtk-css-provider-load-from-file) () |
| void | [gtk\_css\_provider\_load\_from\_path](gtkcssprovider#gtk-css-provider-load-from-path) () |
| void | [gtk\_css\_provider\_load\_from\_resource](gtkcssprovider#gtk-css-provider-load-from-resource) () |
| [GtkCssProvider](gtkcssprovider#GtkCssProvider-struct) \* | [gtk\_css\_provider\_new](gtkcssprovider#gtk-css-provider-new) () |
| char \* | [gtk\_css\_provider\_to\_string](gtkcssprovider#gtk-css-provider-to-string) () |
| [GtkCssSection](gtkcssprovider#GtkCssSection-struct) \* | [gtk\_css\_section\_new](gtkcssprovider#gtk-css-section-new) () |
| [GtkCssSection](gtkcssprovider#GtkCssSection-struct) \* | [gtk\_css\_section\_ref](gtkcssprovider#gtk-css-section-ref) () |
| void | [gtk\_css\_section\_unref](gtkcssprovider#gtk-css-section-unref) () |
| void | [gtk\_css\_section\_print](gtkcssprovider#gtk-css-section-print) () |
| char \* | [gtk\_css\_section\_to\_string](gtkcssprovider#gtk-css-section-to-string) () |
| GFile \* | [gtk\_css\_section\_get\_file](gtkcssprovider#gtk-css-section-get-file) () |
| [GtkCssSection](gtkcssprovider#GtkCssSection-struct) \* | [gtk\_css\_section\_get\_parent](gtkcssprovider#gtk-css-section-get-parent) () |
| const [GtkCssLocation](gtkcssprovider#GtkCssLocation) \* | [gtk\_css\_section\_get\_start\_location](gtkcssprovider#gtk-css-section-get-start-location) () |
| const [GtkCssLocation](gtkcssprovider#GtkCssLocation) \* | [gtk\_css\_section\_get\_end\_location](gtkcssprovider#gtk-css-section-get-end-location) () |
Signals
-------
| | | |
| --- | --- | --- |
| void | [parsing-error](gtkcssprovider#GtkCssProvider-parsing-error) | Run Last |
Types and Values
----------------
| | |
| --- | --- |
| struct | [GtkCssProvider](gtkcssprovider#GtkCssProvider-struct) |
| #define | [GTK\_CSS\_PARSER\_ERROR](gtkcssprovider#GTK-CSS-PARSER-ERROR:CAPS) |
| enum | [GtkCssParserError](gtkcssprovider#GtkCssParserError) |
| enum | [GtkCssParserWarning](gtkcssprovider#GtkCssParserWarning) |
| struct | [GtkCssLocation](gtkcssprovider#GtkCssLocation) |
| | [GtkCssSection](gtkcssprovider#GtkCssSection-struct) |
Object Hierarchy
----------------
```
[GBoxed](https://developer-old.gnome.org/gobject/stable/gobject-Boxed-Types.html)
╰── GtkCssSection
GObject
╰── GtkCssProvider
```
Implemented Interfaces
----------------------
GtkCssProvider implements [GtkStyleProvider](gtkstyleprovider#GtkStyleProvider-struct).
Includes
--------
```
#include <gtk/gtk.h>
```
Description
-----------
GtkCssProvider is an object implementing the [GtkStyleProvider](gtkstyleprovider#GtkStyleProvider-struct) interface. It is able to parse CSS-like input in order to style widgets.
An application can make GTK parse a specific CSS style sheet by calling [`gtk_css_provider_load_from_file()`](gtkcssprovider#gtk-css-provider-load-from-file) or [`gtk_css_provider_load_from_resource()`](gtkcssprovider#gtk-css-provider-load-from-resource) and adding the provider with [`gtk_style_context_add_provider()`](gtkstylecontext#gtk-style-context-add-provider) or [`gtk_style_context_add_provider_for_display()`](gtkstylecontext#gtk-style-context-add-provider-for-display).
In addition, certain files will be read when GTK is initialized. First, the file `$XDG_CONFIG_HOME/gtk-4.0/gtk.css` is loaded if it exists. Then, GTK loads the first existing file among `XDG_DATA_HOME/themes/THEME/gtk-VERSION/gtk-VARIANT.css`, `$HOME/.themes/THEME/gtk-VERSION/gtk-VARIANT.css`, `$XDG_DATA_DIRS/themes/THEME/gtk-VERSION/gtk-VARIANT.css` and `DATADIR/share/themes/THEME/gtk-VERSION/gtk-VARIANT.css`, where `THEME` is the name of the current theme (see the [“gtk-theme-name”](gtksettings#GtkSettings--gtk-theme-name) setting), VARIANT is the variant to load (see the [“gtk-application-prefer-dark-theme”](gtksettings#GtkSettings--gtk-application-prefer-dark-theme) setting), `DATADIR` is the prefix configured when GTK was compiled (unless overridden by the `GTK_DATA_PREFIX` environment variable), and `VERSION` is the GTK version number. If no file is found for the current version, GTK tries older versions all the way back to 4.0.
Functions
---------
### gtk\_css\_provider\_load\_named ()
```
void
gtk_css_provider_load_named (*`[GtkCssProvider](gtkcssprovider#GtkCssProvider-struct) *provider`*,
*`const char *name`*,
*`const char *variant`*);
```
Loads a theme from the usual theme paths. The actual process of finding the theme might change between releases, but it is guaranteed that this function uses the same mechanism to load the theme that GTK uses for loading its own theme.
#### Parameters
| | | |
| --- | --- | --- |
| provider | a [GtkCssProvider](gtkcssprovider#GtkCssProvider-struct) | |
| name | A theme name | |
| variant | variant to load, for example, "dark", or `NULL` for the default. | [allow-none] |
### gtk\_css\_provider\_load\_from\_data ()
```
void
gtk_css_provider_load_from_data (*`[GtkCssProvider](gtkcssprovider#GtkCssProvider-struct) *css_provider`*,
*`const char *data`*,
*`gssize length`*);
```
Loads *`data`* into *`css_provider`* , and by doing so clears any previously loaded information.
#### Parameters
| | | |
| --- | --- | --- |
| css\_provider | a [GtkCssProvider](gtkcssprovider#GtkCssProvider-struct) | |
| data | CSS data loaded in memory. | [array length=length][element-type guint8] |
| length | the length of *`data`* in bytes, or -1 for NUL terminated strings. If *`length`* is not -1, the code will assume it is not NUL terminated and will potentially do a copy. | |
### gtk\_css\_provider\_load\_from\_file ()
```
void
gtk_css_provider_load_from_file (*`[GtkCssProvider](gtkcssprovider#GtkCssProvider-struct) *css_provider`*,
*`GFile *file`*);
```
Loads the data contained in *`file`* into *`css_provider`* , making it clear any previously loaded information.
#### Parameters
| | | |
| --- | --- | --- |
| css\_provider | a [GtkCssProvider](gtkcssprovider#GtkCssProvider-struct) | |
| file | GFile pointing to a file to load | |
### gtk\_css\_provider\_load\_from\_path ()
```
void
gtk_css_provider_load_from_path (*`[GtkCssProvider](gtkcssprovider#GtkCssProvider-struct) *css_provider`*,
*`const char *path`*);
```
Loads the data contained in *`path`* into *`css_provider`* , making it clear any previously loaded information.
#### Parameters
| | | |
| --- | --- | --- |
| css\_provider | a [GtkCssProvider](gtkcssprovider#GtkCssProvider-struct) | |
| path | the path of a filename to load, in the GLib filename encoding | |
### gtk\_css\_provider\_load\_from\_resource ()
```
void
gtk_css_provider_load_from_resource (*`[GtkCssProvider](gtkcssprovider#GtkCssProvider-struct) *css_provider`*,
*`const char *resource_path`*);
```
Loads the data contained in the resource at *`resource_path`* into the [GtkCssProvider](gtkcssprovider#GtkCssProvider-struct), clearing any previously loaded information.
To track errors while loading CSS, connect to the [“parsing-error”](gtkcssprovider#GtkCssProvider-parsing-error) signal.
#### Parameters
| | | |
| --- | --- | --- |
| css\_provider | a [GtkCssProvider](gtkcssprovider#GtkCssProvider-struct) | |
| resource\_path | a GResource resource path | |
### gtk\_css\_provider\_new ()
```
[GtkCssProvider](gtkcssprovider#GtkCssProvider-struct) *
gtk_css_provider_new (*`void`*);
```
Returns a newly created [GtkCssProvider](gtkcssprovider#GtkCssProvider-struct).
#### Returns
A new [GtkCssProvider](gtkcssprovider#GtkCssProvider-struct)
### gtk\_css\_provider\_to\_string ()
```
char *
gtk_css_provider_to_string (*`[GtkCssProvider](gtkcssprovider#GtkCssProvider-struct) *provider`*);
```
Converts the *`provider`* into a string representation in CSS format.
Using [`gtk_css_provider_load_from_data()`](gtkcssprovider#gtk-css-provider-load-from-data) with the return value from this function on a new provider created with [`gtk_css_provider_new()`](gtkcssprovider#gtk-css-provider-new) will basically create a duplicate of this *`provider`* .
#### Parameters
| | | |
| --- | --- | --- |
| provider | the provider to write to a string | |
#### Returns
a new string representing the *`provider`* .
### gtk\_css\_section\_new ()
```
[GtkCssSection](gtkcssprovider#GtkCssSection-struct) *
gtk_css_section_new (*`GFile *file`*,
*`const [GtkCssLocation](gtkcssprovider#GtkCssLocation) *start`*,
*`const [GtkCssLocation](gtkcssprovider#GtkCssLocation) *end`*);
```
Creates a new [GtkCssSection](gtkcssprovider#GtkCssSection-struct) referring to the section in the given *`file`* from the *`start`* location to the *`end`* location.
[constructor]
#### Parameters
| | | |
| --- | --- | --- |
| file | The file this section refers to. | [nullable][transfer none] |
| start | The start location | |
| end | The end location | |
#### Returns
a new [GtkCssSection](gtkcssprovider#GtkCssSection-struct)
### gtk\_css\_section\_ref ()
```
[GtkCssSection](gtkcssprovider#GtkCssSection-struct) *
gtk_css_section_ref (*`[GtkCssSection](gtkcssprovider#GtkCssSection-struct) *section`*);
```
Increments the reference count on *`section`* .
#### Parameters
| | | |
| --- | --- | --- |
| section | a [GtkCssSection](gtkcssprovider#GtkCssSection-struct) | |
#### Returns
*`section`* itself.
### gtk\_css\_section\_unref ()
```
void
gtk_css_section_unref (*`[GtkCssSection](gtkcssprovider#GtkCssSection-struct) *section`*);
```
Decrements the reference count on *`section`* , freeing the structure if the reference count reaches 0.
#### Parameters
| | | |
| --- | --- | --- |
| section | a [GtkCssSection](gtkcssprovider#GtkCssSection-struct) | |
### gtk\_css\_section\_print ()
```
void
gtk_css_section_print (*`const [GtkCssSection](gtkcssprovider#GtkCssSection-struct) *section`*,
*`GString *string`*);
```
Prints the *`section`* into *`string`* in a human-readable form. This is a form like `gtk.css:32:1-23` to denote line 32, characters 1 to 23 in the file gtk.css.
#### Parameters
| | | |
| --- | --- | --- |
| section | a section | |
| string | a GString to print to | |
### gtk\_css\_section\_to\_string ()
```
char *
gtk_css_section_to_string (*`const [GtkCssSection](gtkcssprovider#GtkCssSection-struct) *section`*);
```
Prints the section into a human-readable text form using [`gtk_css_section_print()`](gtkcssprovider#gtk-css-section-print).
#### Parameters
| | | |
| --- | --- | --- |
| section | a [GtkCssSection](gtkcssprovider#GtkCssSection-struct) | |
#### Returns
A new string.
[transfer full]
### gtk\_css\_section\_get\_file ()
```
GFile *
gtk_css_section_get_file (*`const [GtkCssSection](gtkcssprovider#GtkCssSection-struct) *section`*);
```
Gets the file that *`section`* was parsed from. If no such file exists, for example because the CSS was loaded via *`[`gtk_css_provider_load_from_data()`](gtkcssprovider#gtk-css-provider-load-from-data)`* , then `NULL` is returned.
#### Parameters
| | | |
| --- | --- | --- |
| section | the section | |
#### Returns
the GFile that *`section`* was parsed from or `NULL` if *`section`* was parsed from other data.
[transfer none]
### gtk\_css\_section\_get\_parent ()
```
[GtkCssSection](gtkcssprovider#GtkCssSection-struct) *
gtk_css_section_get_parent (*`const [GtkCssSection](gtkcssprovider#GtkCssSection-struct) *section`*);
```
Gets the parent section for the given *`section`* . The parent section is the section that contains this *`section`* . A special case are sections of type GTK\_CSS\_SECTION\_DOCUMENT. Their parent will either be `NULL` if they are the original CSS document that was loaded by [`gtk_css_provider_load_from_file()`](gtkcssprovider#gtk-css-provider-load-from-file) or a section of type GTK\_CSS\_SECTION\_IMPORT if it was loaded with an import rule from a different file.
#### Parameters
| | | |
| --- | --- | --- |
| section | the section | |
#### Returns
the parent section or `NULL` if none.
[nullable][transfer none]
### gtk\_css\_section\_get\_start\_location ()
```
const [GtkCssLocation](gtkcssprovider#GtkCssLocation) *
gtk_css_section_get_start_location (*`const [GtkCssSection](gtkcssprovider#GtkCssSection-struct) *section`*);
```
Returns the location in the CSS document where this section starts.
#### Parameters
| | | |
| --- | --- | --- |
| section | the section | |
#### Returns
The start location of this section.
[transfer none][not nullable]
### gtk\_css\_section\_get\_end\_location ()
```
const [GtkCssLocation](gtkcssprovider#GtkCssLocation) *
gtk_css_section_get_end_location (*`const [GtkCssSection](gtkcssprovider#GtkCssSection-struct) *section`*);
```
Returns the location in the CSS document where this section ends.
#### Parameters
| | | |
| --- | --- | --- |
| section | the section | |
#### Returns
The end location of this section.
[transfer none][not nullable]
Types and Values
----------------
### struct GtkCssProvider
```
struct GtkCssProvider;
```
### GTK\_CSS\_PARSER\_ERROR
```
#define GTK_CSS_PARSER_ERROR (gtk_css_parser_error_quark ())
```
Domain for GtkCssParser errors.
### enum GtkCssParserError
Errors that can occur while parsing CSS.
These errors are unexpected and will cause parts of the given CSS to be ignored.
#### Members
| | | |
| --- | --- | --- |
| GTK\_CSS\_PARSER\_ERROR\_FAILED | Unknown failure. | |
| GTK\_CSS\_PARSER\_ERROR\_SYNTAX | The given text does not form valid syntax | |
| GTK\_CSS\_PARSER\_ERROR\_IMPORT | Failed to import a resource | |
| GTK\_CSS\_PARSER\_ERROR\_NAME | The given name has not been defined | |
| GTK\_CSS\_PARSER\_ERROR\_UNKNOWN\_VALUE | The given value is not correct | |
### enum GtkCssParserWarning
Warnings that can occur while parsing CSS.
Unlike [GtkCssParserErrors](gtkcssprovider#GtkCssParserError), warnings do not cause the parser to skip any input, but they indicate issues that should be fixed.
#### Members
| | | |
| --- | --- | --- |
| GTK\_CSS\_PARSER\_WARNING\_DEPRECATED | The given construct is deprecated and will be removed in a future version | |
| GTK\_CSS\_PARSER\_WARNING\_SYNTAX | A syntax construct was used that should be avoided | |
| GTK\_CSS\_PARSER\_WARNING\_UNIMPLEMENTED | A feature is not implemented | |
### struct GtkCssLocation
```
struct GtkCssLocation {
gsize bytes;
gsize chars;
gsize lines;
gsize line_bytes;
gsize line_chars;
};
```
[GtkCssLocation](gtkcssprovider#GtkCssLocation) is used to present a location in a file - or other source of data parsed by the CSS engine.
The *`bytes`* and *`line_bytes`* offsets are meant to be used to programmatically match data. The *`lines`* and *`line_chars`* offsets can be used for printing the location in a file.
Note that the *`lines`* parameter starts from 0 and is increased whenever a CSS line break is encountered. (CSS defines the C character sequences "\r\n", "\r", "\n" and "\f" as newlines.) If your document uses different rules for line breaking, you might want run into problems here.
#### Members
| | | |
| --- | --- | --- |
| gsize *`bytes`*; | number of bytes parsed since the beginning | |
| gsize *`chars`*; | number of characters parsed since the beginning | |
| gsize *`lines`*; | number of full lines that have been parsed If you want to display this as a line number, you need to add 1 to this. | |
| gsize *`line_bytes`*; | Number of bytes parsed since the last line break | |
| gsize *`line_chars`*; | Number of characters parsed since the last line break | |
### GtkCssSection
```
typedef struct _GtkCssSection GtkCssSection;
```
Defines a part of a CSS document. Because sections are nested into one another, you can use [`gtk_css_section_get_parent()`](gtkcssprovider#gtk-css-section-get-parent) to get the containing region.
Signal Details
--------------
### The `“parsing-error”` signal
```
void
user_function ([GtkCssProvider](gtkcssprovider#GtkCssProvider-struct) *provider,
[GtkCssSection](gtkcssprovider#GtkCssSection-struct) *section,
GError *error,
gpointer user_data)
```
Signals that a parsing error occurred. the *`path`* , *`line`* and *`position`* describe the actual location of the error as accurately as possible.
Parsing errors are never fatal, so the parsing will resume after the error. Errors may however cause parts of the given data or even all of it to not be parsed at all. So it is a useful idea to check that the parsing succeeds by connecting to this signal.
Note that this signal may be emitted at any time as the css provider may opt to defer parsing parts or all of the input to a later time than when a loading function was called.
#### Parameters
| | | |
| --- | --- | --- |
| provider | the provider that had a parsing error | |
| section | section the error happened in | |
| error | The parsing error | |
| user\_data | user data set when the signal handler was connected. | |
Flags: Run Last
See Also
--------
[GtkStyleContext](gtkstylecontext#GtkStyleContext-struct), [GtkStyleProvider](gtkstyleprovider#GtkStyleProvider-struct)
| programming_docs |
gtk GtkFrame GtkFrame
========
GtkFrame — A widget with a decorative frame and optional label
Functions
---------
| | |
| --- | --- |
| [GtkWidget](gtkwidget#GtkWidget-struct) \* | [gtk\_frame\_new](gtkframe#gtk-frame-new) () |
| void | [gtk\_frame\_set\_child](gtkframe#gtk-frame-set-child) () |
| [GtkWidget](gtkwidget#GtkWidget-struct) \* | [gtk\_frame\_get\_child](gtkframe#gtk-frame-get-child) () |
| void | [gtk\_frame\_set\_label](gtkframe#gtk-frame-set-label) () |
| const char \* | [gtk\_frame\_get\_label](gtkframe#gtk-frame-get-label) () |
| void | [gtk\_frame\_set\_label\_widget](gtkframe#gtk-frame-set-label-widget) () |
| [GtkWidget](gtkwidget#GtkWidget-struct) \* | [gtk\_frame\_get\_label\_widget](gtkframe#gtk-frame-get-label-widget) () |
| void | [gtk\_frame\_set\_label\_align](gtkframe#gtk-frame-set-label-align) () |
| float | [gtk\_frame\_get\_label\_align](gtkframe#gtk-frame-get-label-align) () |
Properties
----------
| | | |
| --- | --- | --- |
| [GtkWidget](gtkwidget#GtkWidget-struct) \* | [child](gtkframe#GtkFrame--child) | Read / Write |
| char \* | [label](gtkframe#GtkFrame--label) | Read / Write |
| [GtkWidget](gtkwidget#GtkWidget-struct) \* | [label-widget](gtkframe#GtkFrame--label-widget) | Read / Write |
| float | [label-xalign](gtkframe#GtkFrame--label-xalign) | Read / Write |
Types and Values
----------------
| | |
| --- | --- |
| struct | [GtkFrame](gtkframe#GtkFrame-struct) |
| struct | [GtkFrameClass](gtkframe#GtkFrameClass) |
Object Hierarchy
----------------
```
GObject
╰── GInitiallyUnowned
╰── [GtkWidget](gtkwidget#GtkWidget-struct)
╰── GtkFrame
```
Implemented Interfaces
----------------------
GtkFrame implements [GtkAccessible](gtkaccessible#GtkAccessible-struct), [GtkBuildable](gtkbuildable#GtkBuildable-struct) and [GtkConstraintTarget](gtkconstraint#GtkConstraintTarget-struct).
Includes
--------
```
#include <gtk/gtk.h>
```
Description
-----------
The frame widget is a widget that surrounds its child with a decorative frame and an optional label. If present, the label is drawn inside the top edge of the frame. The horizontal position of the label can be controlled with [`gtk_frame_set_label_align()`](gtkframe#gtk-frame-set-label-align).
GtkFrame clips its child. You can use this to add rounded corners to widgets, but be aware that it also cuts off shadows.
### GtkFrame as GtkBuildable
The GtkFrame implementation of the GtkBuildable interface supports placing a child in the label position by specifying “label” as the “type” attribute of a <child> element. A normal content child can be specified without specifying a <child> type attribute.
An example of a UI definition fragment with GtkFrame:
### CSS nodes
```
<object class="GtkFrame">
<child type="label">
<object class="GtkLabel" id="frame_label"/>
</child>
<child>
<object class="GtkEntry" id="frame_content"/>
</child>
</object>
```
| GtkFrame has a main CSS node with name “frame”, which is used to draw the visible border. You can set the appearance of the border using CSS properties like “border-style” on this node.
Functions
---------
### gtk\_frame\_new ()
```
[GtkWidget](gtkwidget#GtkWidget-struct) *
gtk_frame_new (*`const char *label`*);
```
Creates a new [GtkFrame](gtkframe#GtkFrame-struct), with optional label *`label`* . If *`label`* is `NULL`, the label is omitted.
#### Parameters
| | | |
| --- | --- | --- |
| label | the text to use as the label of the frame. | [allow-none] |
#### Returns
a new [GtkFrame](gtkframe#GtkFrame-struct) widget
### gtk\_frame\_set\_child ()
```
void
gtk_frame_set_child (*`[GtkFrame](gtkframe#GtkFrame-struct) *frame`*,
*`[GtkWidget](gtkwidget#GtkWidget-struct) *child`*);
```
Sets the child widget of *`frame`* .
#### Parameters
| | | |
| --- | --- | --- |
| frame | a [GtkFrame](gtkframe#GtkFrame-struct) | |
| child | the child widget. | [allow-none] |
### gtk\_frame\_get\_child ()
```
[GtkWidget](gtkwidget#GtkWidget-struct) *
gtk_frame_get_child (*`[GtkFrame](gtkframe#GtkFrame-struct) *frame`*);
```
Gets the child widget of *`frame`* .
#### Parameters
| | | |
| --- | --- | --- |
| frame | a [GtkFrame](gtkframe#GtkFrame-struct) | |
#### Returns
the child widget of *`frame`* .
[nullable][transfer none]
### gtk\_frame\_set\_label ()
```
void
gtk_frame_set_label (*`[GtkFrame](gtkframe#GtkFrame-struct) *frame`*,
*`const char *label`*);
```
Removes the current [“label-widget”](gtkframe#GtkFrame--label-widget). If *`label`* is not `NULL`, creates a new [GtkLabel](gtklabel#GtkLabel-struct) with that text and adds it as the [“label-widget”](gtkframe#GtkFrame--label-widget).
#### Parameters
| | | |
| --- | --- | --- |
| frame | a [GtkFrame](gtkframe#GtkFrame-struct) | |
| label | the text to use as the label of the frame. | [allow-none] |
### gtk\_frame\_get\_label ()
```
const char *
gtk_frame_get_label (*`[GtkFrame](gtkframe#GtkFrame-struct) *frame`*);
```
If the frame’s label widget is a [GtkLabel](gtklabel#GtkLabel-struct), returns the text in the label widget. (The frame will have a [GtkLabel](gtklabel#GtkLabel-struct) for the label widget if a non-`NULL` argument was passed to [`gtk_frame_new()`](gtkframe#gtk-frame-new).)
#### Parameters
| | | |
| --- | --- | --- |
| frame | a [GtkFrame](gtkframe#GtkFrame-struct) | |
#### Returns
the text in the label, or `NULL` if there was no label widget or the label widget was not a [GtkLabel](gtklabel#GtkLabel-struct). This string is owned by GTK+ and must not be modified or freed.
[nullable]
### gtk\_frame\_set\_label\_widget ()
```
void
gtk_frame_set_label_widget (*`[GtkFrame](gtkframe#GtkFrame-struct) *frame`*,
*`[GtkWidget](gtkwidget#GtkWidget-struct) *label_widget`*);
```
Sets the [“label-widget”](gtkframe#GtkFrame--label-widget) for the frame. This is the widget that will appear embedded in the top edge of the frame as a title.
#### Parameters
| | | |
| --- | --- | --- |
| frame | a [GtkFrame](gtkframe#GtkFrame-struct) | |
| label\_widget | the new label widget. | [nullable] |
### gtk\_frame\_get\_label\_widget ()
```
[GtkWidget](gtkwidget#GtkWidget-struct) *
gtk_frame_get_label_widget (*`[GtkFrame](gtkframe#GtkFrame-struct) *frame`*);
```
Retrieves the label widget for the frame. See [`gtk_frame_set_label_widget()`](gtkframe#gtk-frame-set-label-widget).
#### Parameters
| | | |
| --- | --- | --- |
| frame | a [GtkFrame](gtkframe#GtkFrame-struct) | |
#### Returns
the label widget, or `NULL` if there is none.
[nullable][transfer none]
### gtk\_frame\_set\_label\_align ()
```
void
gtk_frame_set_label_align (*`[GtkFrame](gtkframe#GtkFrame-struct) *frame`*,
*`float xalign`*);
```
Sets the X alignment of the frame widget’s label. The default value for a newly created frame is 0.0.
#### Parameters
| | | |
| --- | --- | --- |
| frame | a [GtkFrame](gtkframe#GtkFrame-struct) | |
| xalign | The position of the label along the top edge of the widget. A value of 0.0 represents left alignment; 1.0 represents right alignment. | |
### gtk\_frame\_get\_label\_align ()
```
float
gtk_frame_get_label_align (*`[GtkFrame](gtkframe#GtkFrame-struct) *frame`*);
```
Retrieves the X alignment of the frame’s label. See [`gtk_frame_set_label_align()`](gtkframe#gtk-frame-set-label-align).
#### Parameters
| | | |
| --- | --- | --- |
| frame | a [GtkFrame](gtkframe#GtkFrame-struct) | |
Types and Values
----------------
### struct GtkFrame
```
struct GtkFrame;
```
### struct GtkFrameClass
```
struct GtkFrameClass {
GtkWidgetClass parent_class;
void (*compute_child_allocation) (GtkFrame *frame,
GtkAllocation *allocation);
};
```
#### Members
| | | |
| --- | --- | --- |
| *`compute_child_allocation`* () | | |
Property Details
----------------
### The `“child”` property
```
“child” [GtkWidget](gtkwidget#GtkWidget-struct) *
```
The child widget.
Owner: GtkFrame
Flags: Read / Write
### The `“label”` property
```
“label” char *
```
Text of the frame’s label.
Owner: GtkFrame
Flags: Read / Write
Default value: NULL
### The `“label-widget”` property
```
“label-widget” [GtkWidget](gtkwidget#GtkWidget-struct) *
```
A widget to display in place of the usual frame label.
Owner: GtkFrame
Flags: Read / Write
### The `“label-xalign”` property
```
“label-xalign” float
```
The horizontal alignment of the label.
Owner: GtkFrame
Flags: Read / Write
Allowed values: [0,1]
Default value: 0
gtk Settings Settings
========
Settings — Sharing settings between applications
Functions
---------
| | |
| --- | --- |
| [GtkSettings](gtksettings#GtkSettings-struct) \* | [gtk\_settings\_get\_default](gtksettings#gtk-settings-get-default) () |
| [GtkSettings](gtksettings#GtkSettings-struct) \* | [gtk\_settings\_get\_for\_display](gtksettings#gtk-settings-get-for-display) () |
| void | [gtk\_settings\_reset\_property](gtksettings#gtk-settings-reset-property) () |
Properties
----------
| | | |
| --- | --- | --- |
| gboolean | [gtk-alternative-button-order](gtksettings#GtkSettings--gtk-alternative-button-order) | Read / Write |
| gboolean | [gtk-alternative-sort-arrows](gtksettings#GtkSettings--gtk-alternative-sort-arrows) | Read / Write |
| gboolean | [gtk-application-prefer-dark-theme](gtksettings#GtkSettings--gtk-application-prefer-dark-theme) | Read / Write |
| double | [gtk-cursor-aspect-ratio](gtksettings#GtkSettings--gtk-cursor-aspect-ratio) | Read / Write |
| gboolean | [gtk-cursor-blink](gtksettings#GtkSettings--gtk-cursor-blink) | Read / Write |
| int | [gtk-cursor-blink-time](gtksettings#GtkSettings--gtk-cursor-blink-time) | Read / Write |
| int | [gtk-cursor-blink-timeout](gtksettings#GtkSettings--gtk-cursor-blink-timeout) | Read / Write |
| char \* | [gtk-cursor-theme-name](gtksettings#GtkSettings--gtk-cursor-theme-name) | Read / Write |
| int | [gtk-cursor-theme-size](gtksettings#GtkSettings--gtk-cursor-theme-size) | Read / Write |
| char \* | [gtk-decoration-layout](gtksettings#GtkSettings--gtk-decoration-layout) | Read / Write |
| gboolean | [gtk-dialogs-use-header](gtksettings#GtkSettings--gtk-dialogs-use-header) | Read / Write |
| int | [gtk-dnd-drag-threshold](gtksettings#GtkSettings--gtk-dnd-drag-threshold) | Read / Write |
| int | [gtk-double-click-distance](gtksettings#GtkSettings--gtk-double-click-distance) | Read / Write |
| int | [gtk-double-click-time](gtksettings#GtkSettings--gtk-double-click-time) | Read / Write |
| gboolean | [gtk-enable-accels](gtksettings#GtkSettings--gtk-enable-accels) | Read / Write |
| gboolean | [gtk-enable-animations](gtksettings#GtkSettings--gtk-enable-animations) | Read / Write |
| gboolean | [gtk-enable-event-sounds](gtksettings#GtkSettings--gtk-enable-event-sounds) | Read / Write |
| gboolean | [gtk-enable-input-feedback-sounds](gtksettings#GtkSettings--gtk-enable-input-feedback-sounds) | Read / Write |
| gboolean | [gtk-enable-primary-paste](gtksettings#GtkSettings--gtk-enable-primary-paste) | Read / Write |
| guint | [gtk-entry-password-hint-timeout](gtksettings#GtkSettings--gtk-entry-password-hint-timeout) | Read / Write |
| gboolean | [gtk-entry-select-on-focus](gtksettings#GtkSettings--gtk-entry-select-on-focus) | Read / Write |
| gboolean | [gtk-error-bell](gtksettings#GtkSettings--gtk-error-bell) | Read / Write |
| char \* | [gtk-font-name](gtksettings#GtkSettings--gtk-font-name) | Read / Write |
| guint | [gtk-fontconfig-timestamp](gtksettings#GtkSettings--gtk-fontconfig-timestamp) | Read / Write |
| char \* | [gtk-icon-theme-name](gtksettings#GtkSettings--gtk-icon-theme-name) | Read / Write |
| char \* | [gtk-im-module](gtksettings#GtkSettings--gtk-im-module) | Read / Write |
| gboolean | [gtk-keynav-use-caret](gtksettings#GtkSettings--gtk-keynav-use-caret) | Read / Write |
| gboolean | [gtk-label-select-on-focus](gtksettings#GtkSettings--gtk-label-select-on-focus) | Read / Write |
| guint | [gtk-long-press-time](gtksettings#GtkSettings--gtk-long-press-time) | Read / Write |
| gboolean | [gtk-overlay-scrolling](gtksettings#GtkSettings--gtk-overlay-scrolling) | Read / Write |
| gboolean | [gtk-primary-button-warps-slider](gtksettings#GtkSettings--gtk-primary-button-warps-slider) | Read / Write |
| char \* | [gtk-print-backends](gtksettings#GtkSettings--gtk-print-backends) | Read / Write |
| char \* | [gtk-print-preview-command](gtksettings#GtkSettings--gtk-print-preview-command) | Read / Write |
| gboolean | [gtk-recent-files-enabled](gtksettings#GtkSettings--gtk-recent-files-enabled) | Read / Write |
| int | [gtk-recent-files-max-age](gtksettings#GtkSettings--gtk-recent-files-max-age) | Read / Write |
| gboolean | [gtk-shell-shows-app-menu](gtksettings#GtkSettings--gtk-shell-shows-app-menu) | Read / Write |
| gboolean | [gtk-shell-shows-desktop](gtksettings#GtkSettings--gtk-shell-shows-desktop) | Read / Write |
| gboolean | [gtk-shell-shows-menubar](gtksettings#GtkSettings--gtk-shell-shows-menubar) | Read / Write |
| char \* | [gtk-sound-theme-name](gtksettings#GtkSettings--gtk-sound-theme-name) | Read / Write |
| gboolean | [gtk-split-cursor](gtksettings#GtkSettings--gtk-split-cursor) | Read / Write |
| char \* | [gtk-theme-name](gtksettings#GtkSettings--gtk-theme-name) | Read / Write |
| char \* | [gtk-titlebar-double-click](gtksettings#GtkSettings--gtk-titlebar-double-click) | Read / Write |
| char \* | [gtk-titlebar-middle-click](gtksettings#GtkSettings--gtk-titlebar-middle-click) | Read / Write |
| char \* | [gtk-titlebar-right-click](gtksettings#GtkSettings--gtk-titlebar-right-click) | Read / Write |
| int | [gtk-xft-antialias](gtksettings#GtkSettings--gtk-xft-antialias) | Read / Write |
| int | [gtk-xft-dpi](gtksettings#GtkSettings--gtk-xft-dpi) | Read / Write |
| int | [gtk-xft-hinting](gtksettings#GtkSettings--gtk-xft-hinting) | Read / Write |
| char \* | [gtk-xft-hintstyle](gtksettings#GtkSettings--gtk-xft-hintstyle) | Read / Write |
| char \* | [gtk-xft-rgba](gtksettings#GtkSettings--gtk-xft-rgba) | Read / Write |
Types and Values
----------------
| | |
| --- | --- |
| | [GtkSettings](gtksettings#GtkSettings-struct) |
| struct | [GtkSettingsValue](gtksettings#GtkSettingsValue) |
| enum | [GtkSystemSetting](gtksettings#GtkSystemSetting) |
Object Hierarchy
----------------
```
GObject
╰── GtkSettings
```
Implemented Interfaces
----------------------
GtkSettings implements [GtkStyleProvider](gtkstyleprovider#GtkStyleProvider-struct).
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](http://www.freedesktop.org/wiki/Specifications/xsettings-spec) 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()`](gtksettings#gtk-settings-get-for-display), but in many cases, it is more convenient to use [`gtk_widget_get_settings()`](gtkwidget#gtk-widget-get-settings).
Functions
---------
### gtk\_settings\_get\_default ()
```
[GtkSettings](gtksettings#GtkSettings-struct) *
gtk_settings_get_default (*`void`*);
```
Gets the [GtkSettings](gtksettings#GtkSettings-struct) object for the default display, creating it if necessary. See [`gtk_settings_get_for_display()`](gtksettings#gtk-settings-get-for-display).
#### Returns
a [GtkSettings](gtksettings#GtkSettings-struct) object. If there is no default display, then returns `NULL`.
[nullable][transfer none]
### gtk\_settings\_get\_for\_display ()
```
[GtkSettings](gtksettings#GtkSettings-struct) *
gtk_settings_get_for_display (*`[GdkDisplay](https://developer-old.gnome.org/gtk4/html/GdkDisplay.html#GdkDisplay-struct) *display`*);
```
Gets the [GtkSettings](gtksettings#GtkSettings-struct) object for *`display`* , creating it if necessary.
#### Parameters
| | | |
| --- | --- | --- |
| display | a [GdkDisplay](https://developer-old.gnome.org/gtk4/html/GdkDisplay.html#GdkDisplay-struct). | |
#### Returns
a [GtkSettings](gtksettings#GtkSettings-struct) object.
[transfer none]
### gtk\_settings\_reset\_property ()
```
void
gtk_settings_reset_property (*`[GtkSettings](gtksettings#GtkSettings-struct) *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](gtksettings#GtkSettings-struct) 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](gtksettings#GtkSettings-struct) properties.
More values may be added over time.
#### Members
| | | |
| --- | --- | --- |
| GTK\_SYSTEM\_SETTING\_DPI | the [“gtk-xft-dpi”](gtksettings#GtkSettings--gtk-xft-dpi) setting has changed | |
| GTK\_SYSTEM\_SETTING\_FONT\_NAME | The [“gtk-font-name”](gtksettings#GtkSettings--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”](gtksettings#GtkSettings--gtk-xft-antialias), [“gtk-xft-hinting”](gtksettings#GtkSettings--gtk-xft-hinting), [“gtk-xft-hintstyle”](gtksettings#GtkSettings--gtk-xft-hintstyle), [“gtk-xft-rgba”](gtksettings#GtkSettings--gtk-xft-rgba) or [“gtk-fontconfig-timestamp”](gtksettings#GtkSettings--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”](gtksettings#GtkSettings--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”](gtksettings#GtkSettings--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”](gtkheaderbar#GtkHeaderBar--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](http://www.freedesktop.org/wiki/Specifications/sound-theme-spec) 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](http://www.freedesktop.org/wiki/Specifications/sound-theme-spec) 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()`](https://developer-old.gnome.org/gtk4/html/GdkSurface.html#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](gtkimcontext#GtkIMContext-struct).
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](gtkrange#GtkRange-struct) 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()`](gtkprintsettings#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](http://www.freedesktop.org/wiki/Specifications/sound-theme-spec) 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
| programming_docs |
gtk GtkLayoutManager GtkLayoutManager
================
GtkLayoutManager — Base class for layout manager
Functions
---------
| | |
| --- | --- |
| void | [gtk\_layout\_manager\_measure](gtklayoutmanager#gtk-layout-manager-measure) () |
| void | [gtk\_layout\_manager\_allocate](gtklayoutmanager#gtk-layout-manager-allocate) () |
| [GtkSizeRequestMode](gtkwidget#GtkSizeRequestMode) | [gtk\_layout\_manager\_get\_request\_mode](gtklayoutmanager#gtk-layout-manager-get-request-mode) () |
| [GtkWidget](gtkwidget#GtkWidget-struct) \* | [gtk\_layout\_manager\_get\_widget](gtklayoutmanager#gtk-layout-manager-get-widget) () |
| [GtkLayoutChild](gtklayoutchild#GtkLayoutChild-struct) \* | [gtk\_layout\_manager\_get\_layout\_child](gtklayoutmanager#gtk-layout-manager-get-layout-child) () |
| void | [gtk\_layout\_manager\_layout\_changed](gtklayoutmanager#gtk-layout-manager-layout-changed) () |
Types and Values
----------------
| | |
| --- | --- |
| | [GtkLayoutManager](gtklayoutmanager#GtkLayoutManager-struct) |
| struct | [GtkLayoutManagerClass](gtklayoutmanager#GtkLayoutManagerClass) |
Object Hierarchy
----------------
```
GObject
╰── GtkLayoutManager
├── [GtkBinLayout](gtkbinlayout#GtkBinLayout-struct)
├── [GtkBoxLayout](gtkboxlayout#GtkBoxLayout-struct)
├── [GtkCenterLayout](gtkcenterlayout#GtkCenterLayout-struct)
├── [GtkConstraintLayout](gtkconstraintlayout#GtkConstraintLayout-struct)
├── [GtkCustomLayout](https://developer-old.gnome.org/usr/share/gtk-doc/html/gtk4/gtk4-GtkCustomLayout.html#GtkCustomLayout)
├── [GtkFixedLayout](gtkfixedlayout#GtkFixedLayout-struct)
├── [GtkGridLayout](gtkgridlayout#GtkGridLayout-struct)
╰── [GtkOverlayLayout](gtkoverlaylayout#GtkOverlayLayout-struct)
```
Includes
--------
```
#include <gtk/gtk.h>
```
Description
-----------
Layout managers are delegate classes that handle the preferred size and the allocation of a container widget.
You typically subclass [GtkLayoutManager](gtklayoutmanager#GtkLayoutManager-struct) if you want to implement a layout policy for the children of a widget, or if you want to determine the size of a widget depending on its contents.
Each [GtkWidget](gtkwidget#GtkWidget-struct) can only have a [GtkLayoutManager](gtklayoutmanager#GtkLayoutManager-struct) instance associated to it at any given time; it is possible, though, to replace the layout manager instance using [`gtk_widget_set_layout_manager()`](gtkwidget#gtk-widget-set-layout-manager).
#### Layout properties
A layout manager can expose properties for controlling the layout of each child, by creating an object type derived from [GtkLayoutChild](gtklayoutchild#GtkLayoutChild-struct) and installing the properties on it as normal GObject properties.
Each [GtkLayoutChild](gtklayoutchild#GtkLayoutChild-struct) instance storing the layout properties for a specific child is created through the [`gtk_layout_manager_get_layout_child()`](gtklayoutmanager#gtk-layout-manager-get-layout-child) method; a [GtkLayoutManager](gtklayoutmanager#GtkLayoutManager-struct) controls the creation of its [GtkLayoutChild](gtklayoutchild#GtkLayoutChild-struct) instances by overriding the GtkLayoutManagerClass.create\_layout\_child() virtual function. The typical implementation should look like:
```
static GtkLayoutChild *
create_layout_child (GtkLayoutManager *manager,
GtkWidget *container,
GtkWidget *child)
{
return g_object_new (your_layout_child_get_type (),
"layout-manager", manager,
"child-widget", child,
NULL);
}
```
| The [“layout-manager”](gtklayoutchild#GtkLayoutChild--layout-manager) and [“child-widget”](gtklayoutchild#GtkLayoutChild--child-widget) properties on the newly created [GtkLayoutChild](gtklayoutchild#GtkLayoutChild-struct) instance are mandatory. The [GtkLayoutManager](gtklayoutmanager#GtkLayoutManager-struct) will cache the newly created [GtkLayoutChild](gtklayoutchild#GtkLayoutChild-struct) instance until the widget is removed from its parent, or the parent removes the layout manager.
Each [GtkLayoutManager](gtklayoutmanager#GtkLayoutManager-struct) instance creating a [GtkLayoutChild](gtklayoutchild#GtkLayoutChild-struct) should use [`gtk_layout_manager_get_layout_child()`](gtklayoutmanager#gtk-layout-manager-get-layout-child) every time it needs to query the layout properties; each [GtkLayoutChild](gtklayoutchild#GtkLayoutChild-struct) instance should call [`gtk_layout_manager_layout_changed()`](gtklayoutmanager#gtk-layout-manager-layout-changed) every time a property is updated, in order to queue a new size measuring and allocation.
Functions
---------
### gtk\_layout\_manager\_measure ()
```
void
gtk_layout_manager_measure (*`[GtkLayoutManager](gtklayoutmanager#GtkLayoutManager-struct) *manager`*,
*`[GtkWidget](gtkwidget#GtkWidget-struct) *widget`*,
*`[GtkOrientation](gtk4-standard-enumerations#GtkOrientation) orientation`*,
*`int for_size`*,
*`int *minimum`*,
*`int *natural`*,
*`int *minimum_baseline`*,
*`int *natural_baseline`*);
```
Measures the size of the *`widget`* using *`manager`* , for the given *`orientation`* and size.
See GtkWidget's geometry management section for more details.
#### Parameters
| | | |
| --- | --- | --- |
| manager | a [GtkLayoutManager](gtklayoutmanager#GtkLayoutManager-struct) | |
| widget | the [GtkWidget](gtkwidget#GtkWidget-struct) using *`manager`* | |
| orientation | the orientation to measure | |
| for\_size | Size for the opposite of *`orientation`* ; for instance, if the *`orientation`* is [`GTK_ORIENTATION_HORIZONTAL`](gtk4-standard-enumerations#GTK-ORIENTATION-HORIZONTAL:CAPS), this is the height of the widget; if the *`orientation`* is [`GTK_ORIENTATION_VERTICAL`](gtk4-standard-enumerations#GTK-ORIENTATION-VERTICAL:CAPS), this is the width of the widget. This allows to measure the height for the given width, and the width for the given height. Use -1 if the size is not known | |
| minimum | the minimum size for the given size and orientation. | [out][optional] |
| natural | the natural, or preferred size for the given size and orientation. | [out][optional] |
| minimum\_baseline | the baseline position for the minimum size. | [out][optional] |
| natural\_baseline | the baseline position for the natural size. | [out][optional] |
### gtk\_layout\_manager\_allocate ()
```
void
gtk_layout_manager_allocate (*`[GtkLayoutManager](gtklayoutmanager#GtkLayoutManager-struct) *manager`*,
*`[GtkWidget](gtkwidget#GtkWidget-struct) *widget`*,
*`int width`*,
*`int height`*,
*`int baseline`*);
```
This function assigns the given *`width`* , *`height`* , and *`baseline`* to a *`widget`* , and computes the position and sizes of the children of the *`widget`* using the layout management policy of *`manager`* .
#### Parameters
| | | |
| --- | --- | --- |
| manager | a [GtkLayoutManager](gtklayoutmanager#GtkLayoutManager-struct) | |
| widget | the [GtkWidget](gtkwidget#GtkWidget-struct) using *`manager`* | |
| width | the new width of the *`widget`* | |
| height | the new height of the *`widget`* | |
| baseline | the baseline position of the *`widget`* , or -1 | |
### gtk\_layout\_manager\_get\_request\_mode ()
```
[GtkSizeRequestMode](gtkwidget#GtkSizeRequestMode)
gtk_layout_manager_get_request_mode (*`[GtkLayoutManager](gtklayoutmanager#GtkLayoutManager-struct) *manager`*);
```
Retrieves the request mode of *`manager`* .
#### Parameters
| | | |
| --- | --- | --- |
| manager | a [GtkLayoutManager](gtklayoutmanager#GtkLayoutManager-struct) | |
#### Returns
a [GtkSizeRequestMode](gtkwidget#GtkSizeRequestMode)
### gtk\_layout\_manager\_get\_widget ()
```
[GtkWidget](gtkwidget#GtkWidget-struct) *
gtk_layout_manager_get_widget (*`[GtkLayoutManager](gtklayoutmanager#GtkLayoutManager-struct) *manager`*);
```
Retrieves the [GtkWidget](gtkwidget#GtkWidget-struct) using the given [GtkLayoutManager](gtklayoutmanager#GtkLayoutManager-struct).
#### Parameters
| | | |
| --- | --- | --- |
| manager | a [GtkLayoutManager](gtklayoutmanager#GtkLayoutManager-struct) | |
#### Returns
a [GtkWidget](gtkwidget#GtkWidget-struct).
[transfer none][nullable]
### gtk\_layout\_manager\_get\_layout\_child ()
```
[GtkLayoutChild](gtklayoutchild#GtkLayoutChild-struct) *
gtk_layout_manager_get_layout_child (*`[GtkLayoutManager](gtklayoutmanager#GtkLayoutManager-struct) *manager`*,
*`[GtkWidget](gtkwidget#GtkWidget-struct) *child`*);
```
Retrieves a [GtkLayoutChild](gtklayoutchild#GtkLayoutChild-struct) instance for the [GtkLayoutManager](gtklayoutmanager#GtkLayoutManager-struct), creating one if necessary.
The *`child`* widget must be a child of the widget using *`manager`* .
The [GtkLayoutChild](gtklayoutchild#GtkLayoutChild-struct) instance is owned by the [GtkLayoutManager](gtklayoutmanager#GtkLayoutManager-struct), and is guaranteed to exist as long as *`child`* is a child of the [GtkWidget](gtkwidget#GtkWidget-struct) using the given [GtkLayoutManager](gtklayoutmanager#GtkLayoutManager-struct).
#### Parameters
| | | |
| --- | --- | --- |
| manager | a [GtkLayoutManager](gtklayoutmanager#GtkLayoutManager-struct) | |
| child | a [GtkWidget](gtkwidget#GtkWidget-struct) | |
#### Returns
a [GtkLayoutChild](gtklayoutchild#GtkLayoutChild-struct).
[transfer none]
### gtk\_layout\_manager\_layout\_changed ()
```
void
gtk_layout_manager_layout_changed (*`[GtkLayoutManager](gtklayoutmanager#GtkLayoutManager-struct) *manager`*);
```
Queues a resize on the [GtkWidget](gtkwidget#GtkWidget-struct) using *`manager`* , if any.
This function should be called by subclasses of [GtkLayoutManager](gtklayoutmanager#GtkLayoutManager-struct) in response to changes to their layout management policies.
#### Parameters
| | | |
| --- | --- | --- |
| manager | a [GtkLayoutManager](gtklayoutmanager#GtkLayoutManager-struct) | |
Types and Values
----------------
### GtkLayoutManager
```
typedef struct _GtkLayoutManager GtkLayoutManager;
```
### struct GtkLayoutManagerClass
```
struct GtkLayoutManagerClass {
GtkSizeRequestMode (* get_request_mode) (GtkLayoutManager *manager,
GtkWidget *widget);
void (* measure) (GtkLayoutManager *manager,
GtkWidget *widget,
GtkOrientation orientation,
int for_size,
int *minimum,
int *natural,
int *minimum_baseline,
int *natural_baseline);
void (* allocate) (GtkLayoutManager *manager,
GtkWidget *widget,
int width,
int height,
int baseline);
GType layout_child_type;
/**
* GtkLayoutManagerClass::create_layout_child:
* @manager: the #GtkLayoutManager
* @widget: the widget using the @manager
* @for_child: the child of @widget
*
* Create a #GtkLayoutChild instance for the given @for_child widget.
*
* Returns: (transfer full): a #GtkLayoutChild
*/
GtkLayoutChild * (* create_layout_child) (GtkLayoutManager *manager,
GtkWidget *widget,
GtkWidget *for_child);
void (* root) (GtkLayoutManager *manager);
void (* unroot) (GtkLayoutManager *manager);
};
```
The `GtkLayoutManagerClass` structure contains only private data, and should only be accessed through the provided API, or when subclassing [GtkLayoutManager](gtklayoutmanager#GtkLayoutManager-struct).
#### Members
| | | |
| --- | --- | --- |
| *`get_request_mode`* () | a virtual function, used to return the preferred request mode for the layout manager; for instance, "width for height" or "height for width"; see [GtkSizeRequestMode](gtkwidget#GtkSizeRequestMode) | |
| *`measure`* () | a virtual function, used to measure the minimum and preferred sizes of the widget using the layout manager for a given orientation | |
| *`allocate`* () | a virtual function, used to allocate the size of the widget using the layout manager | |
| GType *`layout_child_type`*; | the type of [GtkLayoutChild](gtklayoutchild#GtkLayoutChild-struct) used by this layout manager | |
| *`create_layout_child`* () | a virtual function, used to create a [GtkLayoutChild](gtklayoutchild#GtkLayoutChild-struct) meta object for the layout properties | |
| *`root`* () | a virtual function, called when the widget using the layout manager is attached to a [GtkRoot](gtkroot#GtkRoot-struct) | |
| *`unroot`* () | a virtual function, called when the widget using the layout manager is detached from a [GtkRoot](gtkroot#GtkRoot-struct) | |
gtk GtkProgressBar GtkProgressBar
==============
GtkProgressBar — A widget which indicates progress visually
Functions
---------
| | |
| --- | --- |
| [GtkWidget](gtkwidget#GtkWidget-struct) \* | [gtk\_progress\_bar\_new](gtkprogressbar#gtk-progress-bar-new) () |
| void | [gtk\_progress\_bar\_pulse](gtkprogressbar#gtk-progress-bar-pulse) () |
| void | [gtk\_progress\_bar\_set\_fraction](gtkprogressbar#gtk-progress-bar-set-fraction) () |
| double | [gtk\_progress\_bar\_get\_fraction](gtkprogressbar#gtk-progress-bar-get-fraction) () |
| void | [gtk\_progress\_bar\_set\_inverted](gtkprogressbar#gtk-progress-bar-set-inverted) () |
| gboolean | [gtk\_progress\_bar\_get\_inverted](gtkprogressbar#gtk-progress-bar-get-inverted) () |
| void | [gtk\_progress\_bar\_set\_show\_text](gtkprogressbar#gtk-progress-bar-set-show-text) () |
| gboolean | [gtk\_progress\_bar\_get\_show\_text](gtkprogressbar#gtk-progress-bar-get-show-text) () |
| void | [gtk\_progress\_bar\_set\_text](gtkprogressbar#gtk-progress-bar-set-text) () |
| const char \* | [gtk\_progress\_bar\_get\_text](gtkprogressbar#gtk-progress-bar-get-text) () |
| void | [gtk\_progress\_bar\_set\_ellipsize](gtkprogressbar#gtk-progress-bar-set-ellipsize) () |
| [PangoEllipsizeMode](https://developer-old.gnome.org/pango/stable/pango-Layout-Objects.html#PangoEllipsizeMode) | [gtk\_progress\_bar\_get\_ellipsize](gtkprogressbar#gtk-progress-bar-get-ellipsize) () |
| void | [gtk\_progress\_bar\_set\_pulse\_step](gtkprogressbar#gtk-progress-bar-set-pulse-step) () |
| double | [gtk\_progress\_bar\_get\_pulse\_step](gtkprogressbar#gtk-progress-bar-get-pulse-step) () |
Properties
----------
| | | |
| --- | --- | --- |
| [PangoEllipsizeMode](https://developer-old.gnome.org/pango/stable/pango-Layout-Objects.html#PangoEllipsizeMode) | [ellipsize](gtkprogressbar#GtkProgressBar--ellipsize) | Read / Write |
| double | [fraction](gtkprogressbar#GtkProgressBar--fraction) | Read / Write |
| gboolean | [inverted](gtkprogressbar#GtkProgressBar--inverted) | Read / Write |
| double | [pulse-step](gtkprogressbar#GtkProgressBar--pulse-step) | Read / Write |
| gboolean | [show-text](gtkprogressbar#GtkProgressBar--show-text) | Read / Write |
| char \* | [text](gtkprogressbar#GtkProgressBar--text) | Read / Write |
Types and Values
----------------
| | |
| --- | --- |
| | [GtkProgressBar](gtkprogressbar#GtkProgressBar-struct) |
Object Hierarchy
----------------
```
GObject
╰── GInitiallyUnowned
╰── [GtkWidget](gtkwidget#GtkWidget-struct)
╰── GtkProgressBar
```
Implemented Interfaces
----------------------
GtkProgressBar implements [GtkAccessible](gtkaccessible#GtkAccessible-struct), [GtkBuildable](gtkbuildable#GtkBuildable-struct), [GtkConstraintTarget](gtkconstraint#GtkConstraintTarget-struct) and [GtkOrientable](gtk4-orientable#GtkOrientable-struct).
Includes
--------
```
#include <gtk/gtk.h>
```
Description
-----------
The [GtkProgressBar](gtkprogressbar#GtkProgressBar-struct) is typically used to display the progress of a long running operation. It provides a visual clue that processing is underway. The GtkProgressBar can be used in two different modes: percentage mode and activity mode.
When an application can determine how much work needs to take place (e.g. read a fixed number of bytes from a file) and can monitor its progress, it can use the GtkProgressBar in percentage mode and the user sees a growing bar indicating the percentage of the work that has been completed. In this mode, the application is required to call [`gtk_progress_bar_set_fraction()`](gtkprogressbar#gtk-progress-bar-set-fraction) periodically to update the progress bar.
When an application has no accurate way of knowing the amount of work to do, it can use the [GtkProgressBar](gtkprogressbar#GtkProgressBar-struct) in activity mode, which shows activity by a block moving back and forth within the progress area. In this mode, the application is required to call [`gtk_progress_bar_pulse()`](gtkprogressbar#gtk-progress-bar-pulse) periodically to update the progress bar.
There is quite a bit of flexibility provided to control the appearance of the [GtkProgressBar](gtkprogressbar#GtkProgressBar-struct). Functions are provided to control the orientation of the bar, optional text can be displayed along with the bar, and the step size used in activity mode can be set.
### CSS nodes
```
progressbar[.osd]
├── [text]
╰── trough[.empty][.full]
╰── progress[.pulse]
```
| GtkProgressBar has a main CSS node with name progressbar and subnodes with names text and trough, of which the latter has a subnode named progress. The text subnode is only present if text is shown. The progress subnode has the style class .pulse when in activity mode. It gets the style classes .left, .right, .top or .bottom added when the progress 'touches' the corresponding end of the GtkProgressBar. The .osd class on the progressbar node is for use in overlays like the one Epiphany has for page loading progress.
### Accessibility
GtkProgressBar uses the [GTK\_ACCESSIBLE\_ROLE\_PROGRESS\_BAR](gtkaccessible#GTK-ACCESSIBLE-ROLE-PROGRESS-BAR:CAPS) role.
Functions
---------
### gtk\_progress\_bar\_new ()
```
[GtkWidget](gtkwidget#GtkWidget-struct) *
gtk_progress_bar_new (*`void`*);
```
Creates a new [GtkProgressBar](gtkprogressbar#GtkProgressBar-struct).
#### Returns
a [GtkProgressBar](gtkprogressbar#GtkProgressBar-struct).
### gtk\_progress\_bar\_pulse ()
```
void
gtk_progress_bar_pulse (*`[GtkProgressBar](gtkprogressbar#GtkProgressBar-struct) *pbar`*);
```
Indicates that some progress has been made, but you don’t know how much. Causes the progress bar to enter “activity mode,” where a block bounces back and forth. Each call to [`gtk_progress_bar_pulse()`](gtkprogressbar#gtk-progress-bar-pulse) causes the block to move by a little bit (the amount of movement per pulse is determined by [`gtk_progress_bar_set_pulse_step()`](gtkprogressbar#gtk-progress-bar-set-pulse-step)).
#### Parameters
| | | |
| --- | --- | --- |
| pbar | a [GtkProgressBar](gtkprogressbar#GtkProgressBar-struct) | |
### gtk\_progress\_bar\_set\_fraction ()
```
void
gtk_progress_bar_set_fraction (*`[GtkProgressBar](gtkprogressbar#GtkProgressBar-struct) *pbar`*,
*`double fraction`*);
```
Causes the progress bar to “fill in” the given fraction of the bar. The fraction should be between 0.0 and 1.0, inclusive.
#### Parameters
| | | |
| --- | --- | --- |
| pbar | a [GtkProgressBar](gtkprogressbar#GtkProgressBar-struct) | |
| fraction | fraction of the task that’s been completed | |
### gtk\_progress\_bar\_get\_fraction ()
```
double
gtk_progress_bar_get_fraction (*`[GtkProgressBar](gtkprogressbar#GtkProgressBar-struct) *pbar`*);
```
Returns the current fraction of the task that’s been completed.
#### Parameters
| | | |
| --- | --- | --- |
| pbar | a [GtkProgressBar](gtkprogressbar#GtkProgressBar-struct) | |
#### Returns
a fraction from 0.0 to 1.0
### gtk\_progress\_bar\_set\_inverted ()
```
void
gtk_progress_bar_set_inverted (*`[GtkProgressBar](gtkprogressbar#GtkProgressBar-struct) *pbar`*,
*`gboolean inverted`*);
```
Progress bars normally grow from top to bottom or left to right. Inverted progress bars grow in the opposite direction.
#### Parameters
| | | |
| --- | --- | --- |
| pbar | a [GtkProgressBar](gtkprogressbar#GtkProgressBar-struct) | |
| inverted | `TRUE` to invert the progress bar | |
### gtk\_progress\_bar\_get\_inverted ()
```
gboolean
gtk_progress_bar_get_inverted (*`[GtkProgressBar](gtkprogressbar#GtkProgressBar-struct) *pbar`*);
```
Gets the value set by [`gtk_progress_bar_set_inverted()`](gtkprogressbar#gtk-progress-bar-set-inverted).
#### Parameters
| | | |
| --- | --- | --- |
| pbar | a [GtkProgressBar](gtkprogressbar#GtkProgressBar-struct) | |
#### Returns
`TRUE` if the progress bar is inverted
### gtk\_progress\_bar\_set\_show\_text ()
```
void
gtk_progress_bar_set_show_text (*`[GtkProgressBar](gtkprogressbar#GtkProgressBar-struct) *pbar`*,
*`gboolean show_text`*);
```
Sets whether the progress bar will show text next to the bar. The shown text is either the value of the [“text”](gtkprogressbar#GtkProgressBar--text) property or, if that is `NULL`, the [“fraction”](gtkprogressbar#GtkProgressBar--fraction) value, as a percentage.
To make a progress bar that is styled and sized suitably for containing text (even if the actual text is blank), set [“show-text”](gtkprogressbar#GtkProgressBar--show-text) to `TRUE` and [“text”](gtkprogressbar#GtkProgressBar--text) to the empty string (not `NULL`).
#### Parameters
| | | |
| --- | --- | --- |
| pbar | a [GtkProgressBar](gtkprogressbar#GtkProgressBar-struct) | |
| show\_text | whether to show text | |
### gtk\_progress\_bar\_get\_show\_text ()
```
gboolean
gtk_progress_bar_get_show_text (*`[GtkProgressBar](gtkprogressbar#GtkProgressBar-struct) *pbar`*);
```
Gets the value of the [“show-text”](gtkprogressbar#GtkProgressBar--show-text) property. See [`gtk_progress_bar_set_show_text()`](gtkprogressbar#gtk-progress-bar-set-show-text).
#### Parameters
| | | |
| --- | --- | --- |
| pbar | a [GtkProgressBar](gtkprogressbar#GtkProgressBar-struct) | |
#### Returns
`TRUE` if text is shown in the progress bar
### gtk\_progress\_bar\_set\_text ()
```
void
gtk_progress_bar_set_text (*`[GtkProgressBar](gtkprogressbar#GtkProgressBar-struct) *pbar`*,
*`const char *text`*);
```
Causes the given *`text`* to appear next to the progress bar.
If *`text`* is `NULL` and [“show-text”](gtkprogressbar#GtkProgressBar--show-text) is `TRUE`, the current value of [“fraction”](gtkprogressbar#GtkProgressBar--fraction) will be displayed as a percentage.
If *`text`* is non-`NULL` and [“show-text”](gtkprogressbar#GtkProgressBar--show-text) is `TRUE`, the text will be displayed. In this case, it will not display the progress percentage. If *`text`* is the empty string, the progress bar will still be styled and sized suitably for containing text, as long as [“show-text”](gtkprogressbar#GtkProgressBar--show-text) is `TRUE`.
#### Parameters
| | | |
| --- | --- | --- |
| pbar | a [GtkProgressBar](gtkprogressbar#GtkProgressBar-struct) | |
| text | a UTF-8 string, or `NULL`. | [allow-none] |
### gtk\_progress\_bar\_get\_text ()
```
const char *
gtk_progress_bar_get_text (*`[GtkProgressBar](gtkprogressbar#GtkProgressBar-struct) *pbar`*);
```
Retrieves the text that is displayed with the progress bar, if any, otherwise `NULL`. The return value is a reference to the text, not a copy of it, so will become invalid if you change the text in the progress bar.
#### Parameters
| | | |
| --- | --- | --- |
| pbar | a [GtkProgressBar](gtkprogressbar#GtkProgressBar-struct) | |
#### Returns
text, or `NULL`; this string is owned by the widget and should not be modified or freed.
[nullable]
### gtk\_progress\_bar\_set\_ellipsize ()
```
void
gtk_progress_bar_set_ellipsize (*`[GtkProgressBar](gtkprogressbar#GtkProgressBar-struct) *pbar`*,
*`[PangoEllipsizeMode](https://developer-old.gnome.org/pango/stable/pango-Layout-Objects.html#PangoEllipsizeMode) mode`*);
```
Sets the mode used to ellipsize (add an ellipsis: "...") the text if there is not enough space to render the entire string.
#### Parameters
| | | |
| --- | --- | --- |
| pbar | a [GtkProgressBar](gtkprogressbar#GtkProgressBar-struct) | |
| mode | a [PangoEllipsizeMode](https://developer-old.gnome.org/pango/stable/pango-Layout-Objects.html#PangoEllipsizeMode) | |
### gtk\_progress\_bar\_get\_ellipsize ()
```
[PangoEllipsizeMode](https://developer-old.gnome.org/pango/stable/pango-Layout-Objects.html#PangoEllipsizeMode)
gtk_progress_bar_get_ellipsize (*`[GtkProgressBar](gtkprogressbar#GtkProgressBar-struct) *pbar`*);
```
Returns the ellipsizing position of the progress bar. See [`gtk_progress_bar_set_ellipsize()`](gtkprogressbar#gtk-progress-bar-set-ellipsize).
#### Parameters
| | | |
| --- | --- | --- |
| pbar | a [GtkProgressBar](gtkprogressbar#GtkProgressBar-struct) | |
#### Returns
[PangoEllipsizeMode](https://developer-old.gnome.org/pango/stable/pango-Layout-Objects.html#PangoEllipsizeMode)
### gtk\_progress\_bar\_set\_pulse\_step ()
```
void
gtk_progress_bar_set_pulse_step (*`[GtkProgressBar](gtkprogressbar#GtkProgressBar-struct) *pbar`*,
*`double fraction`*);
```
Sets the fraction of total progress bar length to move the bouncing block for each call to [`gtk_progress_bar_pulse()`](gtkprogressbar#gtk-progress-bar-pulse).
#### Parameters
| | | |
| --- | --- | --- |
| pbar | a [GtkProgressBar](gtkprogressbar#GtkProgressBar-struct) | |
| fraction | fraction between 0.0 and 1.0 | |
### gtk\_progress\_bar\_get\_pulse\_step ()
```
double
gtk_progress_bar_get_pulse_step (*`[GtkProgressBar](gtkprogressbar#GtkProgressBar-struct) *pbar`*);
```
Retrieves the pulse step set with [`gtk_progress_bar_set_pulse_step()`](gtkprogressbar#gtk-progress-bar-set-pulse-step).
#### Parameters
| | | |
| --- | --- | --- |
| pbar | a [GtkProgressBar](gtkprogressbar#GtkProgressBar-struct) | |
#### Returns
a fraction from 0.0 to 1.0
Types and Values
----------------
### GtkProgressBar
```
typedef struct _GtkProgressBar GtkProgressBar;
```
Property Details
----------------
### The `“ellipsize”` property
```
“ellipsize” [PangoEllipsizeMode](https://developer-old.gnome.org/pango/stable/pango-Layout-Objects.html#PangoEllipsizeMode)
```
The preferred place to ellipsize the string, if the progress bar does not have enough room to display the entire string, specified as a [PangoEllipsizeMode](https://developer-old.gnome.org/pango/stable/pango-Layout-Objects.html#PangoEllipsizeMode).
Note that setting this property to a value other than [`PANGO_ELLIPSIZE_NONE`](https://developer-old.gnome.org/pango/stable/pango-Layout-Objects.html#PANGO-ELLIPSIZE-NONE:CAPS) has the side-effect that the progress bar requests only enough space to display the ellipsis ("..."). Another means to set a progress bar's width is [`gtk_widget_set_size_request()`](gtkwidget#gtk-widget-set-size-request).
Owner: GtkProgressBar
Flags: Read / Write
Default value: PANGO\_ELLIPSIZE\_NONE
### The `“fraction”` property
```
“fraction” double
```
The fraction of total work that has been completed.
Owner: GtkProgressBar
Flags: Read / Write
Allowed values: [0,1]
Default value: 0
### The `“inverted”` property
```
“inverted” gboolean
```
Invert the direction in which the progress bar grows.
Owner: GtkProgressBar
Flags: Read / Write
Default value: FALSE
### The `“pulse-step”` property
```
“pulse-step” double
```
The fraction of total progress to move the bouncing block when pulsed.
Owner: GtkProgressBar
Flags: Read / Write
Allowed values: [0,1]
Default value: 0.1
### The `“show-text”` property
```
“show-text” gboolean
```
Sets whether the progress bar will show a text in addition to the bar itself. The shown text is either the value of the [“text”](gtkprogressbar#GtkProgressBar--text) property or, if that is `NULL`, the [“fraction”](gtkprogressbar#GtkProgressBar--fraction) value, as a percentage.
To make a progress bar that is styled and sized suitably for showing text (even if the actual text is blank), set [“show-text”](gtkprogressbar#GtkProgressBar--show-text) to `TRUE` and [“text”](gtkprogressbar#GtkProgressBar--text) to the empty string (not `NULL`).
Owner: GtkProgressBar
Flags: Read / Write
Default value: FALSE
### The `“text”` property
```
“text” char *
```
Text to be displayed in the progress bar.
Owner: GtkProgressBar
Flags: Read / Write
Default value: NULL
| programming_docs |
gtk GtkCellAreaBox GtkCellAreaBox
==============
GtkCellAreaBox — A cell area that renders GtkCellRenderers into a row or a column
Functions
---------
| | |
| --- | --- |
| [GtkCellArea](gtkcellarea#GtkCellArea-struct) \* | [gtk\_cell\_area\_box\_new](gtkcellareabox#gtk-cell-area-box-new) () |
| void | [gtk\_cell\_area\_box\_pack\_start](gtkcellareabox#gtk-cell-area-box-pack-start) () |
| void | [gtk\_cell\_area\_box\_pack\_end](gtkcellareabox#gtk-cell-area-box-pack-end) () |
| int | [gtk\_cell\_area\_box\_get\_spacing](gtkcellareabox#gtk-cell-area-box-get-spacing) () |
| void | [gtk\_cell\_area\_box\_set\_spacing](gtkcellareabox#gtk-cell-area-box-set-spacing) () |
Properties
----------
| | | |
| --- | --- | --- |
| int | [spacing](gtkcellareabox#GtkCellAreaBox--spacing) | Read / Write |
Child Properties
----------------
| | | |
| --- | --- | --- |
| gboolean | [align](gtkcellareabox#GtkCellAreaBox--c-align) | Read / Write |
| gboolean | [expand](gtkcellareabox#GtkCellAreaBox--c-expand) | Read / Write |
| gboolean | [fixed-size](gtkcellareabox#GtkCellAreaBox--c-fixed-size) | Read / Write |
| [GtkPackType](gtk4-standard-enumerations#GtkPackType) | [pack-type](gtkcellareabox#GtkCellAreaBox--c-pack-type) | Read / Write |
Types and Values
----------------
| | |
| --- | --- |
| | [GtkCellAreaBox](gtkcellareabox#GtkCellAreaBox-struct) |
Object Hierarchy
----------------
```
GObject
╰── GInitiallyUnowned
╰── [GtkCellArea](gtkcellarea#GtkCellArea-struct)
╰── GtkCellAreaBox
```
Implemented Interfaces
----------------------
GtkCellAreaBox implements [GtkCellLayout](gtkcelllayout#GtkCellLayout-struct), [GtkBuildable](gtkbuildable#GtkBuildable-struct) and [GtkOrientable](gtk4-orientable#GtkOrientable-struct).
Includes
--------
```
#include <gtk/gtk.h>
```
Description
-----------
The [GtkCellAreaBox](gtkcellareabox#GtkCellAreaBox-struct) renders cell renderers into a row or a column depending on its [GtkOrientation](gtk4-standard-enumerations#GtkOrientation).
GtkCellAreaBox uses a notion of packing. Packing refers to adding cell renderers with reference to a particular position in a [GtkCellAreaBox](gtkcellareabox#GtkCellAreaBox-struct). There are two reference positions: the start and the end of the box. When the [GtkCellAreaBox](gtkcellareabox#GtkCellAreaBox-struct) is oriented in the [`GTK_ORIENTATION_VERTICAL`](gtk4-standard-enumerations#GTK-ORIENTATION-VERTICAL:CAPS) orientation, the start is defined as the top of the box and the end is defined as the bottom. In the [`GTK_ORIENTATION_HORIZONTAL`](gtk4-standard-enumerations#GTK-ORIENTATION-HORIZONTAL:CAPS) orientation start is defined as the left side and the end is defined as the right side.
Alignments of [GtkCellRenderers](gtkcellrenderer#GtkCellRenderer-struct) rendered in adjacent rows can be configured by configuring the [GtkCellAreaBox](gtkcellareabox#GtkCellAreaBox-struct) align child cell property with [`gtk_cell_area_cell_set_property()`](gtkcellarea#gtk-cell-area-cell-set-property) or by specifying the "align" argument to [`gtk_cell_area_box_pack_start()`](gtkcellareabox#gtk-cell-area-box-pack-start) and [`gtk_cell_area_box_pack_end()`](gtkcellareabox#gtk-cell-area-box-pack-end).
Functions
---------
### gtk\_cell\_area\_box\_new ()
```
[GtkCellArea](gtkcellarea#GtkCellArea-struct) *
gtk_cell_area_box_new (*`void`*);
```
Creates a new [GtkCellAreaBox](gtkcellareabox#GtkCellAreaBox-struct).
#### Returns
a newly created [GtkCellAreaBox](gtkcellareabox#GtkCellAreaBox-struct)
### gtk\_cell\_area\_box\_pack\_start ()
```
void
gtk_cell_area_box_pack_start (*`[GtkCellAreaBox](gtkcellareabox#GtkCellAreaBox-struct) *box`*,
*`[GtkCellRenderer](gtkcellrenderer#GtkCellRenderer-struct) *renderer`*,
*`gboolean expand`*,
*`gboolean align`*,
*`gboolean fixed`*);
```
Adds *`renderer`* to *`box`* , packed with reference to the start of *`box`* .
The *`renderer`* is packed after any other [GtkCellRenderer](gtkcellrenderer#GtkCellRenderer-struct) packed with reference to the start of *`box`* .
#### Parameters
| | | |
| --- | --- | --- |
| box | a [GtkCellAreaBox](gtkcellareabox#GtkCellAreaBox-struct) | |
| renderer | the [GtkCellRenderer](gtkcellrenderer#GtkCellRenderer-struct) to add | |
| expand | whether *`renderer`* should receive extra space when the area receives more than its natural size | |
| align | whether *`renderer`* should be aligned in adjacent rows | |
| fixed | whether *`renderer`* should have the same size in all rows | |
### gtk\_cell\_area\_box\_pack\_end ()
```
void
gtk_cell_area_box_pack_end (*`[GtkCellAreaBox](gtkcellareabox#GtkCellAreaBox-struct) *box`*,
*`[GtkCellRenderer](gtkcellrenderer#GtkCellRenderer-struct) *renderer`*,
*`gboolean expand`*,
*`gboolean align`*,
*`gboolean fixed`*);
```
Adds *`renderer`* to *`box`* , packed with reference to the end of *`box`* .
The *`renderer`* is packed after (away from end of) any other [GtkCellRenderer](gtkcellrenderer#GtkCellRenderer-struct) packed with reference to the end of *`box`* .
#### Parameters
| | | |
| --- | --- | --- |
| box | a [GtkCellAreaBox](gtkcellareabox#GtkCellAreaBox-struct) | |
| renderer | the [GtkCellRenderer](gtkcellrenderer#GtkCellRenderer-struct) to add | |
| expand | whether *`renderer`* should receive extra space when the area receives more than its natural size | |
| align | whether *`renderer`* should be aligned in adjacent rows | |
| fixed | whether *`renderer`* should have the same size in all rows | |
### gtk\_cell\_area\_box\_get\_spacing ()
```
int
gtk_cell_area_box_get_spacing (*`[GtkCellAreaBox](gtkcellareabox#GtkCellAreaBox-struct) *box`*);
```
Gets the spacing added between cell renderers.
#### Parameters
| | | |
| --- | --- | --- |
| box | a [GtkCellAreaBox](gtkcellareabox#GtkCellAreaBox-struct) | |
#### Returns
the space added between cell renderers in *`box`* .
### gtk\_cell\_area\_box\_set\_spacing ()
```
void
gtk_cell_area_box_set_spacing (*`[GtkCellAreaBox](gtkcellareabox#GtkCellAreaBox-struct) *box`*,
*`int spacing`*);
```
Sets the spacing to add between cell renderers in *`box`* .
#### Parameters
| | | |
| --- | --- | --- |
| box | a [GtkCellAreaBox](gtkcellareabox#GtkCellAreaBox-struct) | |
| spacing | the space to add between [GtkCellRenderers](gtkcellrenderer#GtkCellRenderer-struct) | |
Types and Values
----------------
### GtkCellAreaBox
```
typedef struct _GtkCellAreaBox GtkCellAreaBox;
```
Property Details
----------------
### The `“spacing”` property
```
“spacing” int
```
The amount of space to reserve between cells.
Owner: GtkCellAreaBox
Flags: Read / Write
Allowed values: >= 0
Default value: 0
Child Property Details
----------------------
### The `“align”` child property
```
“align” gboolean
```
Whether the cell renderer should be aligned in adjacent rows.
Owner: GtkCellAreaBox
Flags: Read / Write
Default value: FALSE
### The `“expand”` child property
```
“expand” gboolean
```
Whether the cell renderer should receive extra space when the area receives more than its natural size.
Owner: GtkCellAreaBox
Flags: Read / Write
Default value: FALSE
### The `“fixed-size”` child property
```
“fixed-size” gboolean
```
Whether the cell renderer should require the same size for all rows for which it was requested.
Owner: GtkCellAreaBox
Flags: Read / Write
Default value: TRUE
### The `“pack-type”` child property
```
“pack-type” [GtkPackType](gtk4-standard-enumerations#GtkPackType)
```
A GtkPackType indicating whether the cell renderer is packed with reference to the start or end of the area.
Owner: GtkCellAreaBox
Flags: Read / Write
Default value: GTK\_PACK\_START
gtk Standard Enumerations Standard Enumerations
=====================
Standard Enumerations — Public enumerated types used throughout GTK
Functions
---------
| | |
| --- | --- |
| [GtkOrdering](gtk4-standard-enumerations#GtkOrdering) | [gtk\_ordering\_from\_cmpfunc](gtk4-standard-enumerations#gtk-ordering-from-cmpfunc) () |
Types and Values
----------------
| | |
| --- | --- |
| enum | [GtkBaselinePosition](gtk4-standard-enumerations#GtkBaselinePosition) |
| enum | [GtkDeleteType](gtk4-standard-enumerations#GtkDeleteType) |
| enum | [GtkDirectionType](gtk4-standard-enumerations#GtkDirectionType) |
| enum | [GtkJustification](gtk4-standard-enumerations#GtkJustification) |
| enum | [GtkMovementStep](gtk4-standard-enumerations#GtkMovementStep) |
| enum | [GtkOrdering](gtk4-standard-enumerations#GtkOrdering) |
| enum | [GtkOrientation](gtk4-standard-enumerations#GtkOrientation) |
| enum | [GtkPackType](gtk4-standard-enumerations#GtkPackType) |
| enum | [GtkPositionType](gtk4-standard-enumerations#GtkPositionType) |
| enum | [GtkScrollStep](gtk4-standard-enumerations#GtkScrollStep) |
| enum | [GtkScrollType](gtk4-standard-enumerations#GtkScrollType) |
| enum | [GtkSelectionMode](gtk4-standard-enumerations#GtkSelectionMode) |
| enum | [GtkStateFlags](gtk4-standard-enumerations#GtkStateFlags) |
| enum | [GtkSortType](gtk4-standard-enumerations#GtkSortType) |
| enum | [GtkIconSize](gtk4-standard-enumerations#GtkIconSize) |
Includes
--------
```
#include <gtk/gtk.h>
```
Description
-----------
Functions
---------
### gtk\_ordering\_from\_cmpfunc ()
```
[GtkOrdering](gtk4-standard-enumerations#GtkOrdering)
gtk_ordering_from_cmpfunc (*`int cmpfunc_result`*);
```
Converts the result of a GCompareFunc like `strcmp()` to a [GtkOrdering](gtk4-standard-enumerations#GtkOrdering).
#### Parameters
| | | |
| --- | --- | --- |
| cmpfunc\_result | Result of a comparison function | |
#### Returns
the corresponding [GtkOrdering](gtk4-standard-enumerations#GtkOrdering)
Types and Values
----------------
### enum GtkBaselinePosition
Whenever a container has some form of natural row it may align children in that row along a common typographical baseline. If the amount of vertical space in the row is taller than the total requested height of the baseline-aligned children then it can use a [GtkBaselinePosition](gtk4-standard-enumerations#GtkBaselinePosition) to select where to put the baseline inside the extra available space.
#### Members
| | | |
| --- | --- | --- |
| GTK\_BASELINE\_POSITION\_TOP | Align the baseline at the top | |
| GTK\_BASELINE\_POSITION\_CENTER | Center the baseline | |
| GTK\_BASELINE\_POSITION\_BOTTOM | Align the baseline at the bottom | |
### enum GtkDeleteType
See also: “delete-from-cursor”.
#### Members
| | | |
| --- | --- | --- |
| GTK\_DELETE\_CHARS | Delete characters. | |
| GTK\_DELETE\_WORD\_ENDS | Delete only the portion of the word to the left/right of cursor if we’re in the middle of a word. | |
| GTK\_DELETE\_WORDS | Delete words. | |
| GTK\_DELETE\_DISPLAY\_LINES | Delete display-lines. Display-lines refers to the visible lines, with respect to the current line breaks. As opposed to paragraphs, which are defined by line breaks in the input. | |
| GTK\_DELETE\_DISPLAY\_LINE\_ENDS | Delete only the portion of the display-line to the left/right of cursor. | |
| GTK\_DELETE\_PARAGRAPH\_ENDS | Delete to the end of the paragraph. Like C-k in Emacs (or its reverse). | |
| GTK\_DELETE\_PARAGRAPHS | Delete entire line. Like C-k in pico. | |
| GTK\_DELETE\_WHITESPACE | Delete only whitespace. Like M-\ in Emacs. | |
### enum GtkDirectionType
Focus movement types.
#### Members
| | | |
| --- | --- | --- |
| GTK\_DIR\_TAB\_FORWARD | Move forward. | |
| GTK\_DIR\_TAB\_BACKWARD | Move backward. | |
| GTK\_DIR\_UP | Move up. | |
| GTK\_DIR\_DOWN | Move down. | |
| GTK\_DIR\_LEFT | Move left. | |
| GTK\_DIR\_RIGHT | Move right. | |
### enum GtkJustification
Used for justifying the text inside a [GtkLabel](gtklabel#GtkLabel-struct) widget.
#### Members
| | | |
| --- | --- | --- |
| GTK\_JUSTIFY\_LEFT | The text is placed at the left edge of the label. | |
| GTK\_JUSTIFY\_RIGHT | The text is placed at the right edge of the label. | |
| GTK\_JUSTIFY\_CENTER | The text is placed in the center of the label. | |
| GTK\_JUSTIFY\_FILL | The text is placed is distributed across the label. | |
### enum GtkMovementStep
#### Members
| | | |
| --- | --- | --- |
| GTK\_MOVEMENT\_LOGICAL\_POSITIONS | Move forward or back by graphemes | |
| GTK\_MOVEMENT\_VISUAL\_POSITIONS | Move left or right by graphemes | |
| GTK\_MOVEMENT\_WORDS | Move forward or back by words | |
| GTK\_MOVEMENT\_DISPLAY\_LINES | Move up or down lines (wrapped lines) | |
| GTK\_MOVEMENT\_DISPLAY\_LINE\_ENDS | Move to either end of a line | |
| GTK\_MOVEMENT\_PARAGRAPHS | Move up or down paragraphs (newline-ended lines) | |
| GTK\_MOVEMENT\_PARAGRAPH\_ENDS | Move to either end of a paragraph | |
| GTK\_MOVEMENT\_PAGES | Move by pages | |
| GTK\_MOVEMENT\_BUFFER\_ENDS | Move to ends of the buffer | |
| GTK\_MOVEMENT\_HORIZONTAL\_PAGES | Move horizontally by pages | |
### enum GtkOrdering
Describes the way two values can be compared.
These values can be used with a GCompareFunc. However, a GCompareFunc is allowed to return any integer values. For converting such a value to a [GtkOrdering](gtk4-standard-enumerations#GtkOrdering), use [`gtk_ordering_from_cmpfunc()`](gtk4-standard-enumerations#gtk-ordering-from-cmpfunc).
#### Members
| | | |
| --- | --- | --- |
| GTK\_ORDERING\_SMALLER | the first value is smaller than the second | |
| GTK\_ORDERING\_EQUAL | the two values are equal | |
| GTK\_ORDERING\_LARGER | the first value is larger than the second | |
### enum GtkOrientation
Represents the orientation of widgets and other objects which can be switched between horizontal and vertical orientation on the fly, like [GtkBox](gtkbox#GtkBox-struct) or [GtkGesturePan](gtkgesturepan#GtkGesturePan-struct).
#### Members
| | | |
| --- | --- | --- |
| GTK\_ORIENTATION\_HORIZONTAL | The element is in horizontal orientation. | |
| GTK\_ORIENTATION\_VERTICAL | The element is in vertical orientation. | |
### enum GtkPackType
Represents the packing location of a children in its parent. See [GtkWindowControls](gtkwindowcontrols#GtkWindowControls-struct) for example.
#### Members
| | | |
| --- | --- | --- |
| GTK\_PACK\_START | The child is packed into the start of the widget | |
| GTK\_PACK\_END | The child is packed into the end of the widget | |
### enum GtkPositionType
Describes which edge of a widget a certain feature is positioned at, e.g. the tabs of a [GtkNotebook](gtknotebook#GtkNotebook-struct), or the label of a [GtkScale](gtkscale#GtkScale-struct).
#### Members
| | | |
| --- | --- | --- |
| GTK\_POS\_LEFT | The feature is at the left edge. | |
| GTK\_POS\_RIGHT | The feature is at the right edge. | |
| GTK\_POS\_TOP | The feature is at the top edge. | |
| GTK\_POS\_BOTTOM | The feature is at the bottom edge. | |
### enum GtkScrollStep
#### Members
| | | |
| --- | --- | --- |
| GTK\_SCROLL\_STEPS | Scroll in steps. | |
| GTK\_SCROLL\_PAGES | Scroll by pages. | |
| GTK\_SCROLL\_ENDS | Scroll to ends. | |
| GTK\_SCROLL\_HORIZONTAL\_STEPS | Scroll in horizontal steps. | |
| GTK\_SCROLL\_HORIZONTAL\_PAGES | Scroll by horizontal pages. | |
| GTK\_SCROLL\_HORIZONTAL\_ENDS | Scroll to the horizontal ends. | |
### enum GtkScrollType
Scrolling types.
#### Members
| | | |
| --- | --- | --- |
| GTK\_SCROLL\_NONE | No scrolling. | |
| GTK\_SCROLL\_JUMP | Jump to new location. | |
| GTK\_SCROLL\_STEP\_BACKWARD | Step backward. | |
| GTK\_SCROLL\_STEP\_FORWARD | Step forward. | |
| GTK\_SCROLL\_PAGE\_BACKWARD | Page backward. | |
| GTK\_SCROLL\_PAGE\_FORWARD | Page forward. | |
| GTK\_SCROLL\_STEP\_UP | Step up. | |
| GTK\_SCROLL\_STEP\_DOWN | Step down. | |
| GTK\_SCROLL\_PAGE\_UP | Page up. | |
| GTK\_SCROLL\_PAGE\_DOWN | Page down. | |
| GTK\_SCROLL\_STEP\_LEFT | Step to the left. | |
| GTK\_SCROLL\_STEP\_RIGHT | Step to the right. | |
| GTK\_SCROLL\_PAGE\_LEFT | Page to the left. | |
| GTK\_SCROLL\_PAGE\_RIGHT | Page to the right. | |
| GTK\_SCROLL\_START | Scroll to start. | |
| GTK\_SCROLL\_END | Scroll to end. | |
### enum GtkSelectionMode
Used to control what selections users are allowed to make.
#### Members
| | | |
| --- | --- | --- |
| GTK\_SELECTION\_NONE | No selection is possible. | |
| GTK\_SELECTION\_SINGLE | Zero or one element may be selected. | |
| GTK\_SELECTION\_BROWSE | Exactly one element is selected. In some circumstances, such as initially or during a search operation, it’s possible for no element to be selected with [`GTK_SELECTION_BROWSE`](gtk4-standard-enumerations#GTK-SELECTION-BROWSE:CAPS). What is really enforced is that the user can’t deselect a currently selected element except by selecting another element. | |
| GTK\_SELECTION\_MULTIPLE | Any number of elements may be selected. The Ctrl key may be used to enlarge the selection, and Shift key to select between the focus and the child pointed to. Some widgets may also allow Click-drag to select a range of elements. | |
### enum GtkStateFlags
Describes a widget state. Widget states are used to match the widget against CSS pseudo-classes. Note that GTK extends the regular CSS classes and sometimes uses different names.
#### Members
| | | |
| --- | --- | --- |
| GTK\_STATE\_FLAG\_NORMAL | State during normal operation | |
| GTK\_STATE\_FLAG\_ACTIVE | Widget is active | |
| GTK\_STATE\_FLAG\_PRELIGHT | Widget has a mouse pointer over it | |
| GTK\_STATE\_FLAG\_SELECTED | Widget is selected | |
| GTK\_STATE\_FLAG\_INSENSITIVE | Widget is insensitive | |
| GTK\_STATE\_FLAG\_INCONSISTENT | Widget is inconsistent | |
| GTK\_STATE\_FLAG\_FOCUSED | Widget has the keyboard focus | |
| GTK\_STATE\_FLAG\_BACKDROP | Widget is in a background toplevel window | |
| GTK\_STATE\_FLAG\_DIR\_LTR | Widget is in left-to-right text direction | |
| GTK\_STATE\_FLAG\_DIR\_RTL | Widget is in right-to-left text direction | |
| GTK\_STATE\_FLAG\_LINK | Widget is a link | |
| GTK\_STATE\_FLAG\_VISITED | The location the widget points to has already been visited | |
| GTK\_STATE\_FLAG\_CHECKED | Widget is checked | |
| GTK\_STATE\_FLAG\_DROP\_ACTIVE | Widget is highlighted as a drop target for DND | |
| GTK\_STATE\_FLAG\_FOCUS\_VISIBLE | Widget has the visible focus | |
| GTK\_STATE\_FLAG\_FOCUS\_WITHIN | Widget contains the keyboard focus | |
### enum GtkSortType
Determines the direction of a sort.
#### Members
| | | |
| --- | --- | --- |
| GTK\_SORT\_ASCENDING | Sorting is in ascending order. | |
| GTK\_SORT\_DESCENDING | Sorting is in descending order. | |
### enum GtkIconSize
Built-in icon sizes.
Icon sizes default to being inherited. Where they cannot be inherited, text size is the default.
All widgets which use GtkIconSize set the normal-icons or large-icons style classes correspondingly, and let themes determine the actual size to be used with the -gtk-icon-size CSS property.
#### Members
| | | |
| --- | --- | --- |
| GTK\_ICON\_SIZE\_INHERIT | Keep the size of the parent element | |
| GTK\_ICON\_SIZE\_NORMAL | Size similar to text size | |
| GTK\_ICON\_SIZE\_LARGE | Large size, for example in an icon view | |
gtk GtkTreeListRow GtkTreeListRow
==============
GtkTreeListRow — A row in a GtkTreeListModel
Functions
---------
| | |
| --- | --- |
| gpointer | [gtk\_tree\_list\_row\_get\_item](gtktreelistrow#gtk-tree-list-row-get-item) () |
| void | [gtk\_tree\_list\_row\_set\_expanded](gtktreelistrow#gtk-tree-list-row-set-expanded) () |
| gboolean | [gtk\_tree\_list\_row\_get\_expanded](gtktreelistrow#gtk-tree-list-row-get-expanded) () |
| gboolean | [gtk\_tree\_list\_row\_is\_expandable](gtktreelistrow#gtk-tree-list-row-is-expandable) () |
| guint | [gtk\_tree\_list\_row\_get\_position](gtktreelistrow#gtk-tree-list-row-get-position) () |
| guint | [gtk\_tree\_list\_row\_get\_depth](gtktreelistrow#gtk-tree-list-row-get-depth) () |
| GListModel \* | [gtk\_tree\_list\_row\_get\_children](gtktreelistrow#gtk-tree-list-row-get-children) () |
| [GtkTreeListRow](gtktreelistmodel#GtkTreeListRow-struct) \* | [gtk\_tree\_list\_row\_get\_parent](gtktreelistrow#gtk-tree-list-row-get-parent) () |
| [GtkTreeListRow](gtktreelistmodel#GtkTreeListRow-struct) \* | [gtk\_tree\_list\_row\_get\_child\_row](gtktreelistrow#gtk-tree-list-row-get-child-row) () |
Includes
--------
```
#include <gtk/gtk.h>
```
Description
-----------
[GtkTreeListRow](gtktreelistmodel#GtkTreeListRow-struct) is the object used by [GtkTreeListModel](gtktreelistmodel#GtkTreeListModel-struct) to represent items. It allows navigating the model as a tree and modify the state of rows.
[GtkTreeListRow](gtktreelistmodel#GtkTreeListRow-struct) instances are created by a [GtkTreeListModel](gtktreelistmodel#GtkTreeListModel-struct) only when the [“passthrough”](gtktreelistmodel#GtkTreeListModel--passthrough) property is not set.
There are various support objects that can make use of [GtkTreeListRow](gtktreelistmodel#GtkTreeListRow-struct) objects, such as the [GtkTreeExpander](gtktreeexpander#GtkTreeExpander-struct) widget that allows displaying an icon to expand or collapse a row or [GtkTreeListRowSorter](gtktreelistrowsorter#GtkTreeListRowSorter-struct) that makes it possible to sort trees properly.
Functions
---------
### gtk\_tree\_list\_row\_get\_item ()
```
gpointer
gtk_tree_list_row_get_item (*`[GtkTreeListRow](gtktreelistmodel#GtkTreeListRow-struct) *self`*);
```
Gets the item corresponding to this row,
The value returned by this function never changes until the row is destroyed.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkTreeListRow](gtktreelistmodel#GtkTreeListRow-struct) | |
#### Returns
The item of this row or `NULL` when the row was destroyed.
[nullable][type GObject][transfer full]
### gtk\_tree\_list\_row\_set\_expanded ()
```
void
gtk_tree_list_row_set_expanded (*`[GtkTreeListRow](gtktreelistmodel#GtkTreeListRow-struct) *self`*,
*`gboolean expanded`*);
```
Expands or collapses a row.
If a row is expanded, the model of calling the [GtkTreeListModelCreateModelFunc](gtktreelistmodel#GtkTreeListModelCreateModelFunc) for the row's item will be inserted after this row. If a row is collapsed, those items will be removed from the model.
If the row is not expandable, this function does nothing.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkTreeListRow](gtktreelistmodel#GtkTreeListRow-struct) | |
| expanded | `TRUE` if the row should be expanded | |
### gtk\_tree\_list\_row\_get\_expanded ()
```
gboolean
gtk_tree_list_row_get_expanded (*`[GtkTreeListRow](gtktreelistmodel#GtkTreeListRow-struct) *self`*);
```
Gets if a row is currently expanded.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkTreeListRow](gtktreelistmodel#GtkTreeListRow-struct) | |
#### Returns
`TRUE` if the row is expanded
### gtk\_tree\_list\_row\_is\_expandable ()
```
gboolean
gtk_tree_list_row_is_expandable (*`[GtkTreeListRow](gtktreelistmodel#GtkTreeListRow-struct) *self`*);
```
Checks if a row can be expanded. This does not mean that the row is actually expanded, this can be checked with [`gtk_tree_list_row_get_expanded()`](gtktreelistrow#gtk-tree-list-row-get-expanded)
If a row is expandable never changes until the row is destroyed.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkTreeListRow](gtktreelistmodel#GtkTreeListRow-struct) | |
#### Returns
`TRUE` if the row is expandable
### gtk\_tree\_list\_row\_get\_position ()
```
guint
gtk_tree_list_row_get_position (*`[GtkTreeListRow](gtktreelistmodel#GtkTreeListRow-struct) *self`*);
```
Returns the position in the [GtkTreeListModel](gtktreelistmodel#GtkTreeListModel-struct) that *`self`* occupies at the moment.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkTreeListRow](gtktreelistmodel#GtkTreeListRow-struct) | |
#### Returns
The position in the model
### gtk\_tree\_list\_row\_get\_depth ()
```
guint
gtk_tree_list_row_get_depth (*`[GtkTreeListRow](gtktreelistmodel#GtkTreeListRow-struct) *self`*);
```
Gets the depth of this row. Rows that correspond to items in the root model have a depth of zero, rows corresponding to items of models of direct children of the root model have a depth of 1 and so on.
The depth of a row never changes until the row is destroyed.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkTreeListRow](gtktreelistmodel#GtkTreeListRow-struct) | |
#### Returns
The depth of this row
### gtk\_tree\_list\_row\_get\_children ()
```
GListModel *
gtk_tree_list_row_get_children (*`[GtkTreeListRow](gtktreelistmodel#GtkTreeListRow-struct) *self`*);
```
If the row is expanded, gets the model holding the children of *`self`* .
This model is the model created by the [GtkTreeListModelCreateModelFunc](gtktreelistmodel#GtkTreeListModelCreateModelFunc) and contains the original items, no matter what value [“passthrough”](gtktreelistmodel#GtkTreeListModel--passthrough) is set to.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkTreeListRow](gtktreelistmodel#GtkTreeListRow-struct) | |
#### Returns
The model containing the children.
[nullable][transfer none]
### gtk\_tree\_list\_row\_get\_parent ()
```
[GtkTreeListRow](gtktreelistmodel#GtkTreeListRow-struct) *
gtk_tree_list_row_get_parent (*`[GtkTreeListRow](gtktreelistmodel#GtkTreeListRow-struct) *self`*);
```
Gets the row representing the parent for *`self`* . That is the row that would need to be collapsed to make this row disappear.
If *`self`* is a row corresponding to the root model, `NULL` is returned.
The value returned by this function never changes until the row is destroyed.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkTreeListRow](gtktreelistmodel#GtkTreeListRow-struct) | |
#### Returns
The parent of *`self`* .
[nullable][transfer full]
### gtk\_tree\_list\_row\_get\_child\_row ()
```
[GtkTreeListRow](gtktreelistmodel#GtkTreeListRow-struct) *
gtk_tree_list_row_get_child_row (*`[GtkTreeListRow](gtktreelistmodel#GtkTreeListRow-struct) *self`*,
*`guint position`*);
```
If *`self`* is not expanded or *`position`* is greater than the number of children, `NULL` is returned.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkTreeListRow](gtktreelistmodel#GtkTreeListRow-struct) | |
| position | position of the child to get | |
#### Returns
the child in *`position`* .
[nullable][transfer full]
See Also
--------
[GtkTreeListModel](gtktreelistmodel#GtkTreeListModel-struct)
| programming_docs |
gtk Hello, World Hello, World
============
In the long tradition of programming languages and libraries, this example is called *Hello, World*.
**Figure 2. Hello, world**
### Hello World in C
Create a new file with the following content named `example-1.c`.
```
#include <gtk/gtk.h>
static void
print_hello (GtkWidget *widget,
gpointer data)
{
g_print ("Hello World\n");
}
static void
activate (GtkApplication *app,
gpointer user_data)
{
GtkWidget *window;
GtkWidget *button;
GtkWidget *box;
window = gtk_application_window_new (app);
gtk_window_set_title (GTK_WINDOW (window), "Window");
gtk_window_set_default_size (GTK_WINDOW (window), 200, 200);
box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
gtk_window_set_child (GTK_WINDOW (window), box);
button = gtk_button_new_with_label ("Hello World");
g_signal_connect (button, "clicked", G_CALLBACK (print_hello), NULL);
g_signal_connect_swapped (button, "clicked", G_CALLBACK (gtk_window_destroy), window);
gtk_box_append (GTK_BOX (box), button);
gtk_widget_show (window);
}
int
main (int argc,
char **argv)
{
GtkApplication *app;
int status;
app = gtk_application_new ("org.gtk.example", G_APPLICATION_FLAGS_NONE);
g_signal_connect (app, "activate", G_CALLBACK (activate), NULL);
status = g_application_run (G_APPLICATION (app), argc, argv);
g_object_unref (app);
return status;
}
```
You can compile the program above with GCC using:
```
gcc `pkg-config --cflags gtk4` -o example-1 example-1.c `pkg-config --libs gtk4`
```
As seen above, example-1.c builds further upon example-0.c by adding a button to our window, with the label “Hello World”. Two new GtkWidget pointers are declared to accomplish this, `button` and `box`. The box variable is created to store a GtkBox, which is GTK’s way of controlling the size and layout of buttons.
The GtkBox is created with [`gtk_box_new()`](gtkbox#gtk-box-new) which takes a GtkOrientation enum as parameter. The buttons which this box will contain can either be laid out horizontally or vertically. This does not matter in this particular case, as we are dealing with only one button. After initializing box with the newly created GtkBox, the code adds the box widget to the window widget using [`gtk_window_set_child()`](gtkwindow#gtk-window-set-child).
Next the `button` variable is initialized in similar manner. [`gtk_button_new_with_label()`](gtkbutton#gtk-button-new-with-label) is called which returns a GtkButton to be stored in `button`. Afterwards `button` is added to our `box`.
Using `g_signal_connect()`, the button is connected to a function in our app called `print_hello()`, so that when the button is clicked, GTK will call this function. As the `print_hello()` function does not use any data as input, NULL is passed to it. `print_hello()` calls `g_print()` with the string “Hello World” which will print Hello World in a terminal if the GTK application was started from one.
After connecting `print_hello()`, another signal is connected to the “clicked” state of the button using `g_signal_connect_swapped()`. This functions is similar to a `g_signal_connect()` with the difference lying in how the callback function is treated. `g_signal_connect_swapped()` allows you to specify what the callback function should take as parameter by letting you pass it as data. In this case the function being called back is [`gtk_window_destroy()`](gtkwindow#gtk-window-destroy) and the `window` pointer is passed to it. This has the effect that when the button is clicked, the whole GTK window is destroyed. In contrast if a normal `g_signal_connect()` were used to connect the “clicked” signal with [`gtk_window_destroy()`](gtkwindow#gtk-window-destroy), then the function would be called on `button` (which would not go well, since the function expects a GtkWindow as argument).
More information about creating buttons can be found [here](https://wiki.gnome.org/HowDoI/Buttons).
The rest of the code in `example-1.c` is identical to `example-0.c`. The next section will elaborate further on how to add several GtkWidgets to your GTK application.
gtk GtkStatusbar GtkStatusbar
============
GtkStatusbar — Report messages of minor importance to the user
Functions
---------
| | |
| --- | --- |
| [GtkWidget](gtkwidget#GtkWidget-struct) \* | [gtk\_statusbar\_new](gtkstatusbar#gtk-statusbar-new) () |
| guint | [gtk\_statusbar\_get\_context\_id](gtkstatusbar#gtk-statusbar-get-context-id) () |
| guint | [gtk\_statusbar\_push](gtkstatusbar#gtk-statusbar-push) () |
| void | [gtk\_statusbar\_pop](gtkstatusbar#gtk-statusbar-pop) () |
| void | [gtk\_statusbar\_remove](gtkstatusbar#gtk-statusbar-remove) () |
| void | [gtk\_statusbar\_remove\_all](gtkstatusbar#gtk-statusbar-remove-all) () |
| const char \* | [gtk\_statusbar\_get\_message](gtkstatusbar#gtk-statusbar-get-message) () |
Signals
-------
| | | |
| --- | --- | --- |
| void | [text-popped](gtkstatusbar#GtkStatusbar-text-popped) | Run Last |
| void | [text-pushed](gtkstatusbar#GtkStatusbar-text-pushed) | Run Last |
Types and Values
----------------
| | |
| --- | --- |
| | [GtkStatusbar](gtkstatusbar#GtkStatusbar-struct) |
Object Hierarchy
----------------
```
GObject
╰── GInitiallyUnowned
╰── [GtkWidget](gtkwidget#GtkWidget-struct)
╰── GtkStatusbar
```
Implemented Interfaces
----------------------
GtkStatusbar implements [GtkAccessible](gtkaccessible#GtkAccessible-struct), [GtkBuildable](gtkbuildable#GtkBuildable-struct) and [GtkConstraintTarget](gtkconstraint#GtkConstraintTarget-struct).
Includes
--------
```
#include <gtk/gtk.h>
```
Description
-----------
A [GtkStatusbar](gtkstatusbar#GtkStatusbar-struct) is usually placed along the bottom of an application's main [GtkWindow](gtkwindow#GtkWindow-struct). It may provide a regular commentary of the application's status (as is usually the case in a web browser, for example), or may be used to simply output a message when the status changes, (when an upload is complete in an FTP client, for example).
Status bars in GTK+ maintain a stack of messages. The message at the top of the each bar’s stack is the one that will currently be displayed.
Any messages added to a statusbar’s stack must specify a context id that is used to uniquely identify the source of a message. This context id can be generated by [`gtk_statusbar_get_context_id()`](gtkstatusbar#gtk-statusbar-get-context-id), given a message and the statusbar that it will be added to. Note that messages are stored in a stack, and when choosing which message to display, the stack structure is adhered to, regardless of the context identifier of a message.
One could say that a statusbar maintains one stack of messages for display purposes, but allows multiple message producers to maintain sub-stacks of the messages they produced (via context ids).
Status bars are created using [`gtk_statusbar_new()`](gtkstatusbar#gtk-statusbar-new).
Messages are added to the bar’s stack with [`gtk_statusbar_push()`](gtkstatusbar#gtk-statusbar-push).
The message at the top of the stack can be removed using [`gtk_statusbar_pop()`](gtkstatusbar#gtk-statusbar-pop). A message can be removed from anywhere in the stack if its message id was recorded at the time it was added. This is done using [`gtk_statusbar_remove()`](gtkstatusbar#gtk-statusbar-remove).
### CSS node
GtkStatusbar has a single CSS node with name statusbar.
Functions
---------
### gtk\_statusbar\_new ()
```
[GtkWidget](gtkwidget#GtkWidget-struct) *
gtk_statusbar_new (*`void`*);
```
Creates a new [GtkStatusbar](gtkstatusbar#GtkStatusbar-struct) ready for messages.
#### Returns
the new [GtkStatusbar](gtkstatusbar#GtkStatusbar-struct)
### gtk\_statusbar\_get\_context\_id ()
```
guint
gtk_statusbar_get_context_id (*`[GtkStatusbar](gtkstatusbar#GtkStatusbar-struct) *statusbar`*,
*`const char *context_description`*);
```
Returns a new context identifier, given a description of the actual context. Note that the description is not shown in the UI.
#### Parameters
| | | |
| --- | --- | --- |
| statusbar | a [GtkStatusbar](gtkstatusbar#GtkStatusbar-struct) | |
| context\_description | textual description of what context the new message is being used in | |
#### Returns
an integer id
### gtk\_statusbar\_push ()
```
guint
gtk_statusbar_push (*`[GtkStatusbar](gtkstatusbar#GtkStatusbar-struct) *statusbar`*,
*`guint context_id`*,
*`const char *text`*);
```
Pushes a new message onto a statusbar’s stack.
#### Parameters
| | | |
| --- | --- | --- |
| statusbar | a [GtkStatusbar](gtkstatusbar#GtkStatusbar-struct) | |
| context\_id | the message’s context id, as returned by [`gtk_statusbar_get_context_id()`](gtkstatusbar#gtk-statusbar-get-context-id) | |
| text | the message to add to the statusbar | |
#### Returns
a message id that can be used with [`gtk_statusbar_remove()`](gtkstatusbar#gtk-statusbar-remove).
### gtk\_statusbar\_pop ()
```
void
gtk_statusbar_pop (*`[GtkStatusbar](gtkstatusbar#GtkStatusbar-struct) *statusbar`*,
*`guint context_id`*);
```
Removes the first message in the [GtkStatusbar](gtkstatusbar#GtkStatusbar-struct)’s stack with the given context id.
Note that this may not change the displayed message, if the message at the top of the stack has a different context id.
#### Parameters
| | | |
| --- | --- | --- |
| statusbar | a [GtkStatusbar](gtkstatusbar#GtkStatusbar-struct) | |
| context\_id | a context identifier | |
### gtk\_statusbar\_remove ()
```
void
gtk_statusbar_remove (*`[GtkStatusbar](gtkstatusbar#GtkStatusbar-struct) *statusbar`*,
*`guint context_id`*,
*`guint message_id`*);
```
Forces the removal of a message from a statusbar’s stack. The exact *`context_id`* and *`message_id`* must be specified.
#### Parameters
| | | |
| --- | --- | --- |
| statusbar | a [GtkStatusbar](gtkstatusbar#GtkStatusbar-struct) | |
| context\_id | a context identifier | |
| message\_id | a message identifier, as returned by [`gtk_statusbar_push()`](gtkstatusbar#gtk-statusbar-push) | |
### gtk\_statusbar\_remove\_all ()
```
void
gtk_statusbar_remove_all (*`[GtkStatusbar](gtkstatusbar#GtkStatusbar-struct) *statusbar`*,
*`guint context_id`*);
```
Forces the removal of all messages from a statusbar's stack with the exact *`context_id`* .
#### Parameters
| | | |
| --- | --- | --- |
| statusbar | a [GtkStatusbar](gtkstatusbar#GtkStatusbar-struct) | |
| context\_id | a context identifier | |
### gtk\_statusbar\_get\_message ()
```
const char *
gtk_statusbar_get_message (*`[GtkStatusbar](gtkstatusbar#GtkStatusbar-struct) *statusbar`*);
```
Retrieves the contents of the label in [GtkStatusbar](gtkstatusbar#GtkStatusbar-struct).
#### Parameters
| | | |
| --- | --- | --- |
| statusbar | a [GtkStatusbar](gtkstatusbar#GtkStatusbar-struct) | |
#### Returns
the contents of the statusbar.
[transfer none]
Types and Values
----------------
### GtkStatusbar
```
typedef struct _GtkStatusbar GtkStatusbar;
```
Signal Details
--------------
### The `“text-popped”` signal
```
void
user_function ([GtkStatusbar](gtkstatusbar#GtkStatusbar-struct) *statusbar,
guint context_id,
char *text,
gpointer user_data)
```
Is emitted whenever a new message is popped off a statusbar's stack.
#### Parameters
| | | |
| --- | --- | --- |
| statusbar | the object which received the signal | |
| context\_id | the context id of the relevant message/statusbar | |
| text | the message that was just popped | |
| user\_data | user data set when the signal handler was connected. | |
Flags: Run Last
### The `“text-pushed”` signal
```
void
user_function ([GtkStatusbar](gtkstatusbar#GtkStatusbar-struct) *statusbar,
guint context_id,
char *text,
gpointer user_data)
```
Is emitted whenever a new message gets pushed onto a statusbar's stack.
#### Parameters
| | | |
| --- | --- | --- |
| statusbar | the object which received the signal | |
| context\_id | the context id of the relevant message/statusbar | |
| text | the message that was pushed | |
| user\_data | user data set when the signal handler was connected. | |
Flags: Run Last
gtk GtkExpression GtkExpression
=============
GtkExpression — Expressions to values
Functions
---------
| | |
| --- | --- |
| void | ([\*GtkExpressionNotify](gtkexpression#GtkExpressionNotify)) () |
| [GtkExpression](gtkexpression#GtkExpression-struct) \* | [gtk\_expression\_ref](gtkexpression#gtk-expression-ref) () |
| void | [gtk\_expression\_unref](gtkexpression#gtk-expression-unref) () |
| GType | [gtk\_expression\_get\_value\_type](gtkexpression#gtk-expression-get-value-type) () |
| gboolean | [gtk\_expression\_is\_static](gtkexpression#gtk-expression-is-static) () |
| gboolean | [gtk\_expression\_evaluate](gtkexpression#gtk-expression-evaluate) () |
| [GtkExpressionWatch](gtkexpression#GtkExpressionWatch) \* | [gtk\_expression\_watch](gtkexpression#gtk-expression-watch) () |
| [GtkExpressionWatch](gtkexpression#GtkExpressionWatch) \* | [gtk\_expression\_bind](gtkexpression#gtk-expression-bind) () |
| [GtkExpressionWatch](gtkexpression#GtkExpressionWatch) \* | [gtk\_expression\_watch\_ref](gtkexpression#gtk-expression-watch-ref) () |
| void | [gtk\_expression\_watch\_unref](gtkexpression#gtk-expression-watch-unref) () |
| gboolean | [gtk\_expression\_watch\_evaluate](gtkexpression#gtk-expression-watch-evaluate) () |
| void | [gtk\_expression\_watch\_unwatch](gtkexpression#gtk-expression-watch-unwatch) () |
| [GtkExpression](gtkexpression#GtkExpression-struct) \* | [gtk\_property\_expression\_new](gtkexpression#gtk-property-expression-new) () |
| [GtkExpression](gtkexpression#GtkExpression-struct) \* | [gtk\_property\_expression\_new\_for\_pspec](gtkexpression#gtk-property-expression-new-for-pspec) () |
| [GtkExpression](gtkexpression#GtkExpression-struct) \* | [gtk\_property\_expression\_get\_expression](gtkexpression#gtk-property-expression-get-expression) () |
| GParamSpec \* | [gtk\_property\_expression\_get\_pspec](gtkexpression#gtk-property-expression-get-pspec) () |
| [GtkExpression](gtkexpression#GtkExpression-struct) \* | [gtk\_constant\_expression\_new](gtkexpression#gtk-constant-expression-new) () |
| [GtkExpression](gtkexpression#GtkExpression-struct) \* | [gtk\_constant\_expression\_new\_for\_value](gtkexpression#gtk-constant-expression-new-for-value) () |
| const GValue \* | [gtk\_constant\_expression\_get\_value](gtkexpression#gtk-constant-expression-get-value) () |
| [GtkExpression](gtkexpression#GtkExpression-struct) \* | [gtk\_object\_expression\_new](gtkexpression#gtk-object-expression-new) () |
| GObject \* | [gtk\_object\_expression\_get\_object](gtkexpression#gtk-object-expression-get-object) () |
| [GtkExpression](gtkexpression#GtkExpression-struct) \* | [gtk\_closure\_expression\_new](gtkexpression#gtk-closure-expression-new) () |
| [GtkExpression](gtkexpression#GtkExpression-struct) \* | [gtk\_cclosure\_expression\_new](gtkexpression#gtk-cclosure-expression-new) () |
| #define | [GTK\_VALUE\_HOLDS\_EXPRESSION](gtkexpression#GTK-VALUE-HOLDS-EXPRESSION:CAPS)() |
| void | [gtk\_value\_set\_expression](gtkexpression#gtk-value-set-expression) () |
| void | [gtk\_value\_take\_expression](gtkexpression#gtk-value-take-expression) () |
| [GtkExpression](gtkexpression#GtkExpression-struct) \* | [gtk\_value\_get\_expression](gtkexpression#gtk-value-get-expression) () |
| [GtkExpression](gtkexpression#GtkExpression-struct) \* | [gtk\_value\_dup\_expression](gtkexpression#gtk-value-dup-expression) () |
| GParamSpec \* | [gtk\_param\_spec\_expression](gtkexpression#gtk-param-spec-expression) () |
Types and Values
----------------
| | |
| --- | --- |
| | [GtkExpression](gtkexpression#GtkExpression-struct) |
| | [GtkExpressionWatch](gtkexpression#GtkExpressionWatch) |
| | [GtkParamSpecExpression](gtkexpression#GtkParamSpecExpression) |
Object Hierarchy
----------------
```
GtkExpression
```
Includes
--------
```
#include <gtk/gtk.h>
```
Description
-----------
GtkExpression provides a way to describe references to values.
An important aspect of expressions is that the value can be obtained from a source that is several steps away. For example, an expression may describe ‘the value of property A of *`object1`* , which is itself the value of a property of *`object2`* ’. And *`object1`* may not even exist yet at the time that the expression is created. This is contrast to GObject property bindings, which can only create direct connections between the properties of two objects that must both exist for the duration of the binding.
An expression needs to be "evaluated" to obtain the value that it currently refers to. An evaluation always happens in the context of a current object called `this` (it mirrors the behavior of object-oriented languages), which may or may not influence the result of the evaluation. Use [`gtk_expression_evaluate()`](gtkexpression#gtk-expression-evaluate) for evaluating an expression.
Various methods for defining expressions exist, from simple constants via [`gtk_constant_expression_new()`](gtkexpression#gtk-constant-expression-new) to looking up properties in a GObject (even recursively) via [`gtk_property_expression_new()`](gtkexpression#gtk-property-expression-new) or providing custom functions to transform and combine expressions via [`gtk_closure_expression_new()`](gtkexpression#gtk-closure-expression-new).
Here is an example of a complex expression:
when evaluated with `this` being a GtkListItem, it will obtain the "item" property from the GtkListItem, and then obtain the "name" property from the resulting object (which is assumed to be of type GTK\_TYPE\_COLOR).
A more concise way to describe this would be
The most likely place where you will encounter expressions is in the context of list models and list widgets using them. For example, [GtkDropDown](gtkdropdown#GtkDropDown-struct) is evaluating a GtkExpression to obtain strings from the items in its model that it can then use to match against the contents of its search entry. [GtkStringFilter](gtkstringfilter#GtkStringFilter-struct) is using a GtkExpression for similar reasons.
By default, expressions are not paying attention to changes and evaluation is just a snapshot of the current state at a given time. To get informed about changes, an expression needs to be "watched" via a [GtkExpressionWatch](gtkexpression#GtkExpressionWatch), which will cause a callback to be called whenever the value of the expression may have changed. [`gtk_expression_watch()`](gtkexpression#gtk-expression-watch) starts watching an expression, and [`gtk_expression_watch_unwatch()`](gtkexpression#gtk-expression-watch-unwatch) stops.
Watches can be created for automatically updating the property of an object, similar to GObject's GBinding mechanism, by using [`gtk_expression_bind()`](gtkexpression#gtk-expression-bind).
### GtkExpression in GObject properties
In order to use a [GtkExpression](gtkexpression#GtkExpression-struct) as a GObject property, you must use the [`gtk_param_spec_expression()`](gtkexpression#gtk-param-spec-expression) when creating a GParamSpec to install in the GObject class being defined; for instance:
When implementing the `GObjectClass.set_property()` and `GObjectClass.get_property()` virtual functions, you must use [`gtk_value_get_expression()`](gtkexpression#gtk-value-get-expression), to retrieve the stored [GtkExpression](gtkexpression#GtkExpression-struct) from the GValue container, and [`gtk_value_set_expression()`](gtkexpression#gtk-value-set-expression), to store the [GtkExpression](gtkexpression#GtkExpression-struct) into the GValue; for instance:
### GtkExpression in .ui files
GtkBuilder has support for creating expressions. The syntax here can be used where a [GtkExpression](gtkexpression#GtkExpression-struct) object is needed like in a <property> tag for an expression property, or in a <binding> tag to bind a property to an expression.
To create an property expression, use the <lookup> element. It can have a `type` attribute to specify the object type, and a `name` attribute to specify the property to look up. The content of <lookup> can either be an element specfiying the expression to use the object, or a string that specifies the name of the object to use.
Example:
To create a constant expression, use the <constant> element. If the type attribute is specified, the element content is interpreted as a value of that type. Otherwise, it is assumed to be an object.
Example:
To create a closure expression, use the <closure> element. The `type` and `function` attributes specify what function to use for the closure, the content of the element contains the expressions for the parameters.
Example:
```
color_expr = gtk_property_expression_new (GTK_TYPE_LIST_ITEM,
NULL, "item");
expression = gtk_property_expression_new (GTK_TYPE_COLOR,
color_expr, "name");
```
| Functions
---------
### GtkExpressionNotify ()
```
void
(*GtkExpressionNotify) (gpointer user_data);
```
Callback called by [`gtk_expression_watch()`](gtkexpression#gtk-expression-watch) when the expression value changes.
#### Parameters
| | | |
| --- | --- | --- |
| user\_data | data passed to [`gtk_expression_watch()`](gtkexpression#gtk-expression-watch) | |
### gtk\_expression\_ref ()
```
[GtkExpression](gtkexpression#GtkExpression-struct) *
gtk_expression_ref (*`[GtkExpression](gtkexpression#GtkExpression-struct) *self`*);
```
Acquires a reference on the given [GtkExpression](gtkexpression#GtkExpression-struct).
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkExpression](gtkexpression#GtkExpression-struct). | [allow-none] |
#### Returns
the [GtkExpression](gtkexpression#GtkExpression-struct) with an additional reference.
[transfer none]
### gtk\_expression\_unref ()
```
void
gtk_expression_unref (*`[GtkExpression](gtkexpression#GtkExpression-struct) *self`*);
```
Releases a reference on the given [GtkExpression](gtkexpression#GtkExpression-struct).
If the reference was the last, the resources associated to the *`self`* are freed.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkExpression](gtkexpression#GtkExpression-struct). | [allow-none] |
### gtk\_expression\_get\_value\_type ()
```
GType
gtk_expression_get_value_type (*`[GtkExpression](gtkexpression#GtkExpression-struct) *self`*);
```
Gets the GType that this expression evaluates to. This type is constant and will not change over the lifetime of this expression.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkExpression](gtkexpression#GtkExpression-struct) | |
#### Returns
The type returned from [`gtk_expression_evaluate()`](gtkexpression#gtk-expression-evaluate)
### gtk\_expression\_is\_static ()
```
gboolean
gtk_expression_is_static (*`[GtkExpression](gtkexpression#GtkExpression-struct) *self`*);
```
Checks if the expression is static.
A static expression will never change its result when [`gtk_expression_evaluate()`](gtkexpression#gtk-expression-evaluate) is called on it with the same arguments.
That means a call to [`gtk_expression_watch()`](gtkexpression#gtk-expression-watch) is not necessary because it will never trigger a notify.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkExpression](gtkexpression#GtkExpression-struct) | |
#### Returns
`TRUE` if the expression is static
### gtk\_expression\_evaluate ()
```
gboolean
gtk_expression_evaluate (*`[GtkExpression](gtkexpression#GtkExpression-struct) *self`*,
*`gpointer this_`*,
*`GValue *value`*);
```
Evaluates the given expression and on success stores the result in *`value`* . The GType of *`value`* will be the type given by [`gtk_expression_get_value_type()`](gtkexpression#gtk-expression-get-value-type).
It is possible that expressions cannot be evaluated - for example when the expression references objects that have been destroyed or set to `NULL`. In that case *`value`* will remain empty and `FALSE` will be returned.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkExpression](gtkexpression#GtkExpression-struct) | |
| this\_ | the this argument for the evaluation. | [transfer none][type GObject][nullable] |
| value | an empty GValue | |
#### Returns
`TRUE` if the expression could be evaluated
### gtk\_expression\_watch ()
```
[GtkExpressionWatch](gtkexpression#GtkExpressionWatch) *
gtk_expression_watch (*`[GtkExpression](gtkexpression#GtkExpression-struct) *self`*,
*`gpointer this_`*,
*`[GtkExpressionNotify](gtkexpression#GtkExpressionNotify) notify`*,
*`gpointer user_data`*,
*`GDestroyNotify user_destroy`*);
```
Installs a watch for the given *`expression`* that calls the *`notify`* function whenever the evaluation of *`self`* may have changed.
GTK cannot guarantee that the evaluation did indeed change when the *`notify`* gets invoked, but it guarantees the opposite: When it did in fact change, the *`notify`* will be invoked.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkExpression](gtkexpression#GtkExpression-struct) | |
| this\_ | the `this` argument to watch. | [transfer none][type GObject][nullable] |
| notify | callback to invoke when the expression changes. | [closure user\_data] |
| user\_data | user data to pass to *`notify`* callback | |
| user\_destroy | destroy notify for *`user_data`* | |
#### Returns
The newly installed watch. Note that the only reference held to the watch will be released when the watch is unwatched which can happen automatically, and not just via [`gtk_expression_watch_unwatch()`](gtkexpression#gtk-expression-watch-unwatch). You should call [`gtk_expression_watch_ref()`](gtkexpression#gtk-expression-watch-ref) if you want to keep the watch around.
[transfer none]
### gtk\_expression\_bind ()
```
[GtkExpressionWatch](gtkexpression#GtkExpressionWatch) *
gtk_expression_bind (*`[GtkExpression](gtkexpression#GtkExpression-struct) *self`*,
*`gpointer target`*,
*`const char *property`*,
*`gpointer this_`*);
```
Bind *`target`* 's property named *`property`* to *`self`* .
The value that *`self`* evaluates to is set via `g_object_set()` on *`target`* . This is repeated whenever *`self`* changes to ensure that the object's property stays synchronized with *`self`* .
If *`self`* 's evaluation fails, *`target`* 's *`property`* is not updated. You can ensure that this doesn't happen by using a fallback expression.
Note that this function takes ownership of *`self`* . If you want to keep it around, you should [`gtk_expression_ref()`](gtkexpression#gtk-expression-ref) it beforehand.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkExpression](gtkexpression#GtkExpression-struct). | [transfer full] |
| target | the target object to bind to. | [transfer none][type GObject] |
| property | name of the property on *`target`* to bind to | |
| this\_ | the this argument for the evaluation of *`self`* . | [transfer none][type GObject][nullable] |
#### Returns
a [GtkExpressionWatch](gtkexpression#GtkExpressionWatch).
[transfer none]
### gtk\_expression\_watch\_ref ()
```
[GtkExpressionWatch](gtkexpression#GtkExpressionWatch) *
gtk_expression_watch_ref (*`[GtkExpressionWatch](gtkexpression#GtkExpressionWatch) *watch`*);
```
Acquires a reference on the given [GtkExpressionWatch](gtkexpression#GtkExpressionWatch).
#### Parameters
| | | |
| --- | --- | --- |
| watch | a [GtkExpressionWatch](gtkexpression#GtkExpressionWatch). | [allow-none] |
#### Returns
the [GtkExpression](gtkexpression#GtkExpression-struct) with an additional reference.
[transfer none]
### gtk\_expression\_watch\_unref ()
```
void
gtk_expression_watch_unref (*`[GtkExpressionWatch](gtkexpression#GtkExpressionWatch) *watch`*);
```
Releases a reference on the given [GtkExpressionWatch](gtkexpression#GtkExpressionWatch).
If the reference was the last, the resources associated to *`self`* are freed.
#### Parameters
| | | |
| --- | --- | --- |
| watch | a [GtkExpressionWatch](gtkexpression#GtkExpressionWatch). | [allow-none] |
### gtk\_expression\_watch\_evaluate ()
```
gboolean
gtk_expression_watch_evaluate (*`[GtkExpressionWatch](gtkexpression#GtkExpressionWatch) *watch`*,
*`GValue *value`*);
```
Evaluates the watched expression and on success stores the result in *`value`* .
This is equivalent to calling [`gtk_expression_evaluate()`](gtkexpression#gtk-expression-evaluate) with the expression and this pointer originally used to create *`watch`* .
#### Parameters
| | | |
| --- | --- | --- |
| watch | a [GtkExpressionWatch](gtkexpression#GtkExpressionWatch) | |
| value | an empty GValue to be set | |
#### Returns
`TRUE` if the expression could be evaluated and *`value`* was set
### gtk\_expression\_watch\_unwatch ()
```
void
gtk_expression_watch_unwatch (*`[GtkExpressionWatch](gtkexpression#GtkExpressionWatch) *watch`*);
```
Stops watching an expression that was established via [`gtk_expression_watch()`](gtkexpression#gtk-expression-watch).
#### Parameters
| | | |
| --- | --- | --- |
| watch | watch to release. | [transfer none] |
### gtk\_property\_expression\_new ()
```
[GtkExpression](gtkexpression#GtkExpression-struct) *
gtk_property_expression_new (*`GType this_type`*,
*`[GtkExpression](gtkexpression#GtkExpression-struct) *expression`*,
*`const char *property_name`*);
```
Creates an expression that looks up a property via the given *`expression`* or the `this` argument when *`expression`* is `NULL`.
If the resulting object conforms to *`this_type`* , its property named *`property_name`* will be queried. Otherwise, this expression's evaluation will fail.
The given *`this_type`* must have a property with *`property_name`* .
#### Parameters
| | | |
| --- | --- | --- |
| this\_type | The type to expect for the this type | |
| expression | Expression to evaluate to get the object to query or `NULL` to query the `this` object. | [nullable][transfer full] |
| property\_name | name of the property | |
#### Returns
a new [GtkExpression](gtkexpression#GtkExpression-struct)
### gtk\_property\_expression\_new\_for\_pspec ()
```
[GtkExpression](gtkexpression#GtkExpression-struct) *
gtk_property_expression_new_for_pspec (*`[GtkExpression](gtkexpression#GtkExpression-struct) *expression`*,
*`GParamSpec *pspec`*);
```
Creates an expression that looks up a property via the given *`expression`* or the `this` argument when *`expression`* is `NULL`.
If the resulting object conforms to *`this_type`* , its property specified by *`pspec`* will be queried. Otherwise, this expression's evaluation will fail.
#### Parameters
| | | |
| --- | --- | --- |
| expression | Expression to evaluate to get the object to query or `NULL` to query the `this` object. | [nullable][transfer full] |
| pspec | the GParamSpec for the property to query | |
#### Returns
a new [GtkExpression](gtkexpression#GtkExpression-struct)
### gtk\_property\_expression\_get\_expression ()
```
[GtkExpression](gtkexpression#GtkExpression-struct) *
gtk_property_expression_get_expression
(*`[GtkExpression](gtkexpression#GtkExpression-struct) *expression`*);
```
Gets the expression specifying the object of a property expression.
#### Parameters
| | | |
| --- | --- | --- |
| expression | a property [GtkExpression](gtkexpression#GtkExpression-struct). | [type GtkPropertyExpression] |
#### Returns
the object expression.
[transfer none]
### gtk\_property\_expression\_get\_pspec ()
```
GParamSpec *
gtk_property_expression_get_pspec (*`[GtkExpression](gtkexpression#GtkExpression-struct) *expression`*);
```
Gets the GParamSpec specifying the property of a property expression.
#### Parameters
| | | |
| --- | --- | --- |
| expression | a property [GtkExpression](gtkexpression#GtkExpression-struct). | [type GtkPropertyExpression] |
#### Returns
the GParamSpec.
[transfer none]
### gtk\_constant\_expression\_new ()
```
[GtkExpression](gtkexpression#GtkExpression-struct) *
gtk_constant_expression_new (*`GType value_type`*,
*`...`*);
```
Creates a GtkExpression that evaluates to the object given by the arguments.
#### Parameters
| | | |
| --- | --- | --- |
| value\_type | The type of the object | |
| ... | arguments to create the object from | |
#### Returns
a new [GtkExpression](gtkexpression#GtkExpression-struct)
### gtk\_constant\_expression\_new\_for\_value ()
```
[GtkExpression](gtkexpression#GtkExpression-struct) *
gtk_constant_expression_new_for_value (*`const GValue *value`*);
```
Creates an expression that always evaluates to the given *`value`* .
#### Parameters
| | | |
| --- | --- | --- |
| value | a GValue | |
#### Returns
a new [GtkExpression](gtkexpression#GtkExpression-struct)
### gtk\_constant\_expression\_get\_value ()
```
const GValue *
gtk_constant_expression_get_value (*`[GtkExpression](gtkexpression#GtkExpression-struct) *expression`*);
```
Gets the value that a constant expression evaluates to.
#### Parameters
| | | |
| --- | --- | --- |
| expression | a constant [GtkExpression](gtkexpression#GtkExpression-struct). | [type GtkConstantExpression] |
#### Returns
the value.
[transfer none]
### gtk\_object\_expression\_new ()
```
[GtkExpression](gtkexpression#GtkExpression-struct) *
gtk_object_expression_new (*`GObject *object`*);
```
Creates an expression evaluating to the given *`object`* with a weak reference. Once the *`object`* is disposed, it will fail to evaluate. This expression is meant to break reference cycles.
If you want to keep a reference to *`object`* , use [`gtk_constant_expression_new()`](gtkexpression#gtk-constant-expression-new).
#### Parameters
| | | |
| --- | --- | --- |
| object | object to watch. | [transfer none] |
#### Returns
a new [GtkExpression](gtkexpression#GtkExpression-struct)
### gtk\_object\_expression\_get\_object ()
```
GObject *
gtk_object_expression_get_object (*`[GtkExpression](gtkexpression#GtkExpression-struct) *expression`*);
```
Gets the object that the expression evaluates to.
#### Parameters
| | | |
| --- | --- | --- |
| expression | an object [GtkExpression](gtkexpression#GtkExpression-struct). | [type GtkObjectExpression] |
#### Returns
the object, or `NULL`.
[transfer none][nullable]
### gtk\_closure\_expression\_new ()
```
[GtkExpression](gtkexpression#GtkExpression-struct) *
gtk_closure_expression_new (*`GType value_type`*,
*`GClosure *closure`*,
*`guint n_params`*,
*`[GtkExpression](gtkexpression#GtkExpression-struct) **params`*);
```
Creates a GtkExpression that calls *`closure`* when it is evaluated. *`closure`* is called with the *`this`* object and the results of evaluating the *`params`* expressions.
#### Parameters
| | | |
| --- | --- | --- |
| value\_type | the type of the value that this expression evaluates to | |
| closure | closure to call when evaluating this expression. If closure is floating, it is adopted | |
| n\_params | the number of params needed for evaluating *`closure`* | |
| params | expressions for each parameter. | [nullable][array length=n\_params][transfer full] |
#### Returns
a new [GtkExpression](gtkexpression#GtkExpression-struct)
### gtk\_cclosure\_expression\_new ()
```
[GtkExpression](gtkexpression#GtkExpression-struct) *
gtk_cclosure_expression_new (*`GType value_type`*,
*`GClosureMarshal marshal`*,
*`guint n_params`*,
*`[GtkExpression](gtkexpression#GtkExpression-struct) **params`*,
*`GCallback callback_func`*,
*`gpointer user_data`*,
*`GClosureNotify user_destroy`*);
```
This function is a variant of [`gtk_closure_expression_new()`](gtkexpression#gtk-closure-expression-new) that creates a GClosure by calling `g_cclosure_new()` with the given *`callback_func`* , *`user_data`* and *`user_destroy`* .
#### Parameters
| | | |
| --- | --- | --- |
| value\_type | the type of the value that this expression evaluates to | |
| marshal | marshaller used for creating a closure. | [scope call][nullable] |
| n\_params | the number of params needed for evaluating *`closure`* | |
| params | expressions for each parameter. | [array length=n\_params][transfer full] |
| callback\_func | callback used for creating a closure. | [scope notified][closure user\_data][destroy user\_destroy] |
| user\_data | user data used for creating a closure. | [nullable] |
| user\_destroy | destroy notify for *`user_data`* . | [nullable] |
#### Returns
a new [GtkExpression](gtkexpression#GtkExpression-struct)
### GTK\_VALUE\_HOLDS\_EXPRESSION()
```
#define GTK_VALUE_HOLDS_EXPRESSION(value) (G_VALUE_HOLDS ((value), GTK_TYPE_EXPRESSION))
```
Evaluates to `TRUE` if *`value`* was initialized with `GTK_TYPE_EXPRESSION`.
#### Parameters
| | | |
| --- | --- | --- |
| value | a GValue | |
### gtk\_value\_set\_expression ()
```
void
gtk_value_set_expression (*`GValue *value`*,
*`[GtkExpression](gtkexpression#GtkExpression-struct) *expression`*);
```
Stores the given [GtkExpression](gtkexpression#GtkExpression-struct) inside *`value`* .
The GValue will acquire a reference to the *`expression`* .
#### Parameters
| | | |
| --- | --- | --- |
| value | a GValue initialized with type `GTK_TYPE_EXPRESSION` | |
| expression | a [GtkExpression](gtkexpression#GtkExpression-struct) | |
### gtk\_value\_take\_expression ()
```
void
gtk_value_take_expression (*`GValue *value`*,
*`[GtkExpression](gtkexpression#GtkExpression-struct) *expression`*);
```
Stores the given [GtkExpression](gtkexpression#GtkExpression-struct) inside *`value`* .
This function transfers the ownership of the *`expression`* to the GValue.
#### Parameters
| | | |
| --- | --- | --- |
| value | a GValue initialized with type `GTK_TYPE_EXPRESSION` | |
| expression | a [GtkExpression](gtkexpression#GtkExpression-struct). | [transfer full][nullable] |
### gtk\_value\_get\_expression ()
```
[GtkExpression](gtkexpression#GtkExpression-struct) *
gtk_value_get_expression (*`const GValue *value`*);
```
Retrieves the [GtkExpression](gtkexpression#GtkExpression-struct) stored inside the given *`value`* .
#### Parameters
| | | |
| --- | --- | --- |
| value | a GValue initialized with type `GTK_TYPE_EXPRESSION` | |
#### Returns
a [GtkExpression](gtkexpression#GtkExpression-struct).
[transfer none][nullable]
### gtk\_value\_dup\_expression ()
```
[GtkExpression](gtkexpression#GtkExpression-struct) *
gtk_value_dup_expression (*`const GValue *value`*);
```
Retrieves the [GtkExpression](gtkexpression#GtkExpression-struct) stored inside the given *`value`* , and acquires a reference to it.
#### Parameters
| | | |
| --- | --- | --- |
| value | a GValue initialized with type `GTK_TYPE_EXPRESSION` | |
#### Returns
a [GtkExpression](gtkexpression#GtkExpression-struct).
[transfer full][nullable]
### gtk\_param\_spec\_expression ()
```
GParamSpec *
gtk_param_spec_expression (const char *name,
const char *nick,
const char *blurb,
GParamFlags flags);
```
Creates a new GParamSpec instance for a property holding a [GtkExpression](gtkexpression#GtkExpression-struct).
See `g_param_spec_internal()` for details on the property strings.
#### Parameters
| | | |
| --- | --- | --- |
| name | canonical name of the property | |
| nick | a user-readable name for the property | |
| blurb | a user-readable description of the property | |
| flags | flags for the property | |
#### Returns
a newly created property specification.
[transfer full]
Types and Values
----------------
### GtkExpression
```
typedef struct _GtkExpression GtkExpression;
```
The `GtkExpression` structure contains only private data.
### GtkExpressionWatch
```
typedef struct _GtkExpressionWatch GtkExpressionWatch;
```
### GtkParamSpecExpression
```
typedef struct {
} GtkParamSpecExpression;
```
A GParamSpec for properties holding a [GtkExpression](gtkexpression#GtkExpression-struct).
| programming_docs |
gtk GtkCellLayout GtkCellLayout
=============
GtkCellLayout — An interface for packing cells
Functions
---------
| | |
| --- | --- |
| void | ([\*GtkCellLayoutDataFunc](gtkcelllayout#GtkCellLayoutDataFunc)) () |
| void | [gtk\_cell\_layout\_pack\_start](gtkcelllayout#gtk-cell-layout-pack-start) () |
| void | [gtk\_cell\_layout\_pack\_end](gtkcelllayout#gtk-cell-layout-pack-end) () |
| [GtkCellArea](gtkcellarea#GtkCellArea-struct) \* | [gtk\_cell\_layout\_get\_area](gtkcelllayout#gtk-cell-layout-get-area) () |
| GList \* | [gtk\_cell\_layout\_get\_cells](gtkcelllayout#gtk-cell-layout-get-cells) () |
| void | [gtk\_cell\_layout\_reorder](gtkcelllayout#gtk-cell-layout-reorder) () |
| void | [gtk\_cell\_layout\_clear](gtkcelllayout#gtk-cell-layout-clear) () |
| void | [gtk\_cell\_layout\_set\_attributes](gtkcelllayout#gtk-cell-layout-set-attributes) () |
| void | [gtk\_cell\_layout\_add\_attribute](gtkcelllayout#gtk-cell-layout-add-attribute) () |
| void | [gtk\_cell\_layout\_set\_cell\_data\_func](gtkcelllayout#gtk-cell-layout-set-cell-data-func) () |
| void | [gtk\_cell\_layout\_clear\_attributes](gtkcelllayout#gtk-cell-layout-clear-attributes) () |
Types and Values
----------------
| | |
| --- | --- |
| | [GtkCellLayout](gtkcelllayout#GtkCellLayout-struct) |
| struct | [GtkCellLayoutIface](gtkcelllayout#GtkCellLayoutIface) |
Object Hierarchy
----------------
```
[GInterface](https://developer-old.gnome.org/gobject/stable/GTypeModule.html)
╰── GtkCellLayout
```
Prerequisites
-------------
GtkCellLayout requires GObject.
Known Implementations
---------------------
GtkCellLayout is implemented by [GtkCellArea](gtkcellarea#GtkCellArea-struct), [GtkCellAreaBox](gtkcellareabox#GtkCellAreaBox-struct), [GtkCellView](gtkcellview#GtkCellView-struct), [GtkComboBox](gtkcombobox#GtkComboBox-struct), [GtkComboBoxText](gtkcomboboxtext#GtkComboBoxText-struct), [GtkEntryCompletion](gtkentrycompletion#GtkEntryCompletion-struct), [GtkIconView](gtkiconview#GtkIconView-struct) and [GtkTreeViewColumn](gtktreeviewcolumn#GtkTreeViewColumn-struct).
Includes
--------
```
#include <gtk/gtk.h>
```
Description
-----------
[GtkCellLayout](gtkcelllayout#GtkCellLayout-struct) is an interface to be implemented by all objects which want to provide a [GtkTreeViewColumn](gtktreeviewcolumn#GtkTreeViewColumn-struct) like API for packing cells, setting attributes and data funcs.
One of the notable features provided by implementations of GtkCellLayout are attributes. Attributes let you set the properties in flexible ways. They can just be set to constant values like regular properties. But they can also be mapped to a column of the underlying tree model with [`gtk_cell_layout_set_attributes()`](gtkcelllayout#gtk-cell-layout-set-attributes), which means that the value of the attribute can change from cell to cell as they are rendered by the cell renderer. Finally, it is possible to specify a function with [`gtk_cell_layout_set_cell_data_func()`](gtkcelllayout#gtk-cell-layout-set-cell-data-func) that is called to determine the value of the attribute for each cell that is rendered.
### GtkCellLayouts as GtkBuildable
Implementations of GtkCellLayout which also implement the GtkBuildable interface ([GtkCellView](gtkcellview#GtkCellView-struct), [GtkIconView](gtkiconview#GtkIconView-struct), [GtkComboBox](gtkcombobox#GtkComboBox-struct), [GtkEntryCompletion](gtkentrycompletion#GtkEntryCompletion-struct), [GtkTreeViewColumn](gtktreeviewcolumn#GtkTreeViewColumn-struct)) accept GtkCellRenderer objects as <child> elements in UI definitions. They support a custom <attributes> element for their children, which can contain multiple <attribute> elements. Each <attribute> element has a name attribute which specifies a property of the cell renderer; the content of the element is the attribute value.
This is an example of a UI definition fragment specifying attributes:
Furthermore for implementations of GtkCellLayout that use a [GtkCellArea](gtkcellarea#GtkCellArea-struct) to lay out cells (all GtkCellLayouts in GTK use a GtkCellArea) cell properties can also be defined in the format by specifying the custom <cell-packing> attribute which can contain multiple <property> elements defined in the normal way.
Here is a UI definition fragment specifying cell properties:
### Subclassing GtkCellLayout implementations
When subclassing a widget that implements [GtkCellLayout](gtkcelllayout#GtkCellLayout-struct) like [GtkIconView](gtkiconview#GtkIconView-struct) or [GtkComboBox](gtkcombobox#GtkComboBox-struct), there are some considerations related to the fact that these widgets internally use a [GtkCellArea](gtkcellarea#GtkCellArea-struct). The cell area is exposed as a construct-only property by these widgets. This means that it is possible to e.g. do
to use a custom cell area with a combo box. But construct properties are only initialized after instance `init()` functions have run, which means that using functions which rely on the existence of the cell area in your subclass’ `init()` function will cause the default cell area to be instantiated. In this case, a provided construct property value will be ignored (with a warning, to alert you to the problem).
```
<object class="GtkCellView">
<child>
<object class="GtkCellRendererText"/>
<attributes>
<attribute name="text">0</attribute>
</attributes>
</child>"
</object>
```
| If supporting alternative cell areas with your derived widget is not important, then this does not have to concern you. If you want to support alternative cell areas, you can do so by moving the problematic calls out of `init()` and into a `constructor()` for your class.
Functions
---------
### GtkCellLayoutDataFunc ()
```
void
(*GtkCellLayoutDataFunc) (*`[GtkCellLayout](gtkcelllayout#GtkCellLayout-struct) *cell_layout`*,
*`[GtkCellRenderer](gtkcellrenderer#GtkCellRenderer-struct) *cell`*,
*`[GtkTreeModel](gtktreemodel#GtkTreeModel-struct) *tree_model`*,
*`[GtkTreeIter](gtktreemodel#GtkTreeIter-struct) *iter`*,
*`gpointer data`*);
```
A function which should set the value of *`cell_layout`* ’s cell renderer(s) as appropriate.
#### Parameters
| | | |
| --- | --- | --- |
| cell\_layout | a [GtkCellLayout](gtkcelllayout#GtkCellLayout-struct) | |
| cell | the cell renderer whose value is to be set | |
| tree\_model | the model | |
| iter | a [GtkTreeIter](gtktreemodel#GtkTreeIter-struct) indicating the row to set the value for | |
| data | user data passed to [`gtk_cell_layout_set_cell_data_func()`](gtkcelllayout#gtk-cell-layout-set-cell-data-func). | [closure] |
### gtk\_cell\_layout\_pack\_start ()
```
void
gtk_cell_layout_pack_start (*`[GtkCellLayout](gtkcelllayout#GtkCellLayout-struct) *cell_layout`*,
*`[GtkCellRenderer](gtkcellrenderer#GtkCellRenderer-struct) *cell`*,
*`gboolean expand`*);
```
Packs the *`cell`* into the beginning of *`cell_layout`* . If *`expand`* is `FALSE`, then the *`cell`* is allocated no more space than it needs. Any unused space is divided evenly between cells for which *`expand`* is `TRUE`.
Note that reusing the same cell renderer is not supported.
#### Parameters
| | | |
| --- | --- | --- |
| cell\_layout | a [GtkCellLayout](gtkcelllayout#GtkCellLayout-struct) | |
| cell | a [GtkCellRenderer](gtkcellrenderer#GtkCellRenderer-struct) | |
| expand | `TRUE` if *`cell`* is to be given extra space allocated to *`cell_layout`* | |
### gtk\_cell\_layout\_pack\_end ()
```
void
gtk_cell_layout_pack_end (*`[GtkCellLayout](gtkcelllayout#GtkCellLayout-struct) *cell_layout`*,
*`[GtkCellRenderer](gtkcellrenderer#GtkCellRenderer-struct) *cell`*,
*`gboolean expand`*);
```
Adds the *`cell`* to the end of *`cell_layout`* . If *`expand`* is `FALSE`, then the *`cell`* is allocated no more space than it needs. Any unused space is divided evenly between cells for which *`expand`* is `TRUE`.
Note that reusing the same cell renderer is not supported.
#### Parameters
| | | |
| --- | --- | --- |
| cell\_layout | a [GtkCellLayout](gtkcelllayout#GtkCellLayout-struct) | |
| cell | a [GtkCellRenderer](gtkcellrenderer#GtkCellRenderer-struct) | |
| expand | `TRUE` if *`cell`* is to be given extra space allocated to *`cell_layout`* | |
### gtk\_cell\_layout\_get\_area ()
```
[GtkCellArea](gtkcellarea#GtkCellArea-struct) *
gtk_cell_layout_get_area (*`[GtkCellLayout](gtkcelllayout#GtkCellLayout-struct) *cell_layout`*);
```
Returns the underlying [GtkCellArea](gtkcellarea#GtkCellArea-struct) which might be *`cell_layout`* if called on a [GtkCellArea](gtkcellarea#GtkCellArea-struct) or might be `NULL` if no [GtkCellArea](gtkcellarea#GtkCellArea-struct) is used by *`cell_layout`* .
#### Parameters
| | | |
| --- | --- | --- |
| cell\_layout | a [GtkCellLayout](gtkcelllayout#GtkCellLayout-struct) | |
#### Returns
the cell area used by *`cell_layout`* , or `NULL` in case no cell area is used.
[transfer none][nullable]
### gtk\_cell\_layout\_get\_cells ()
```
GList *
gtk_cell_layout_get_cells (*`[GtkCellLayout](gtkcelllayout#GtkCellLayout-struct) *cell_layout`*);
```
Returns the cell renderers which have been added to *`cell_layout`* .
#### Parameters
| | | |
| --- | --- | --- |
| cell\_layout | a [GtkCellLayout](gtkcelllayout#GtkCellLayout-struct) | |
#### Returns
a list of cell renderers. The list, but not the renderers has been newly allocated and should be freed with `g_list_free()` when no longer needed.
[element-type GtkCellRenderer][transfer container]
### gtk\_cell\_layout\_reorder ()
```
void
gtk_cell_layout_reorder (*`[GtkCellLayout](gtkcelllayout#GtkCellLayout-struct) *cell_layout`*,
*`[GtkCellRenderer](gtkcellrenderer#GtkCellRenderer-struct) *cell`*,
*`int position`*);
```
Re-inserts *`cell`* at *`position`* .
Note that *`cell`* has already to be packed into *`cell_layout`* for this to function properly.
#### Parameters
| | | |
| --- | --- | --- |
| cell\_layout | a [GtkCellLayout](gtkcelllayout#GtkCellLayout-struct) | |
| cell | a [GtkCellRenderer](gtkcellrenderer#GtkCellRenderer-struct) to reorder | |
| position | new position to insert *`cell`* at | |
### gtk\_cell\_layout\_clear ()
```
void
gtk_cell_layout_clear (*`[GtkCellLayout](gtkcelllayout#GtkCellLayout-struct) *cell_layout`*);
```
Unsets all the mappings on all renderers on *`cell_layout`* and removes all renderers from *`cell_layout`* .
#### Parameters
| | | |
| --- | --- | --- |
| cell\_layout | a [GtkCellLayout](gtkcelllayout#GtkCellLayout-struct) | |
### gtk\_cell\_layout\_set\_attributes ()
```
void
gtk_cell_layout_set_attributes (*`[GtkCellLayout](gtkcelllayout#GtkCellLayout-struct) *cell_layout`*,
*`[GtkCellRenderer](gtkcellrenderer#GtkCellRenderer-struct) *cell`*,
*`...`*);
```
Sets the attributes in list as the attributes of *`cell_layout`* .
The attributes should be in attribute/column order, as in [`gtk_cell_layout_add_attribute()`](gtkcelllayout#gtk-cell-layout-add-attribute). All existing attributes are removed, and replaced with the new attributes.
#### Parameters
| | | |
| --- | --- | --- |
| cell\_layout | a [GtkCellLayout](gtkcelllayout#GtkCellLayout-struct) | |
| cell | a [GtkCellRenderer](gtkcellrenderer#GtkCellRenderer-struct) | |
| ... | a `NULL`-terminated list of attributes | |
### gtk\_cell\_layout\_add\_attribute ()
```
void
gtk_cell_layout_add_attribute (*`[GtkCellLayout](gtkcelllayout#GtkCellLayout-struct) *cell_layout`*,
*`[GtkCellRenderer](gtkcellrenderer#GtkCellRenderer-struct) *cell`*,
*`const char *attribute`*,
*`int column`*);
```
Adds an attribute mapping to the list in *`cell_layout`* .
The *`column`* is the column of the model to get a value from, and the *`attribute`* is the parameter on *`cell`* to be set from the value. So for example if column 2 of the model contains strings, you could have the “text” attribute of a [GtkCellRendererText](gtkcellrenderertext#GtkCellRendererText-struct) get its values from column 2.
#### Parameters
| | | |
| --- | --- | --- |
| cell\_layout | a [GtkCellLayout](gtkcelllayout#GtkCellLayout-struct) | |
| cell | a [GtkCellRenderer](gtkcellrenderer#GtkCellRenderer-struct) | |
| attribute | an attribute on the renderer | |
| column | the column position on the model to get the attribute from | |
### gtk\_cell\_layout\_set\_cell\_data\_func ()
```
void
gtk_cell_layout_set_cell_data_func (*`[GtkCellLayout](gtkcelllayout#GtkCellLayout-struct) *cell_layout`*,
*`[GtkCellRenderer](gtkcellrenderer#GtkCellRenderer-struct) *cell`*,
*`[GtkCellLayoutDataFunc](gtkcelllayout#GtkCellLayoutDataFunc) func`*,
*`gpointer func_data`*,
*`GDestroyNotify destroy`*);
```
Sets the [GtkCellLayoutDataFunc](gtkcelllayout#GtkCellLayoutDataFunc) to use for *`cell_layout`* .
This function is used instead of the standard attributes mapping for setting the column value, and should set the value of *`cell_layout`* ’s cell renderer(s) as appropriate.
*`func`* may be `NULL` to remove a previously set function.
#### Parameters
| | | |
| --- | --- | --- |
| cell\_layout | a [GtkCellLayout](gtkcelllayout#GtkCellLayout-struct) | |
| cell | a [GtkCellRenderer](gtkcellrenderer#GtkCellRenderer-struct) | |
| func | the [GtkCellLayoutDataFunc](gtkcelllayout#GtkCellLayoutDataFunc) to use, or `NULL`. | [allow-none] |
| func\_data | user data for *`func`* . | [closure] |
| destroy | destroy notify for *`func_data`* | |
### gtk\_cell\_layout\_clear\_attributes ()
```
void
gtk_cell_layout_clear_attributes (*`[GtkCellLayout](gtkcelllayout#GtkCellLayout-struct) *cell_layout`*,
*`[GtkCellRenderer](gtkcellrenderer#GtkCellRenderer-struct) *cell`*);
```
Clears all existing attributes previously set with [`gtk_cell_layout_set_attributes()`](gtkcelllayout#gtk-cell-layout-set-attributes).
#### Parameters
| | | |
| --- | --- | --- |
| cell\_layout | a [GtkCellLayout](gtkcelllayout#GtkCellLayout-struct) | |
| cell | a [GtkCellRenderer](gtkcellrenderer#GtkCellRenderer-struct) to clear the attribute mapping on | |
Types and Values
----------------
### GtkCellLayout
```
typedef struct _GtkCellLayout GtkCellLayout;
```
### struct GtkCellLayoutIface
```
struct GtkCellLayoutIface {
/* Virtual Table */
void (* pack_start) (GtkCellLayout *cell_layout,
GtkCellRenderer *cell,
gboolean expand);
void (* pack_end) (GtkCellLayout *cell_layout,
GtkCellRenderer *cell,
gboolean expand);
void (* clear) (GtkCellLayout *cell_layout);
void (* add_attribute) (GtkCellLayout *cell_layout,
GtkCellRenderer *cell,
const char *attribute,
int column);
void (* set_cell_data_func) (GtkCellLayout *cell_layout,
GtkCellRenderer *cell,
GtkCellLayoutDataFunc func,
gpointer func_data,
GDestroyNotify destroy);
void (* clear_attributes) (GtkCellLayout *cell_layout,
GtkCellRenderer *cell);
void (* reorder) (GtkCellLayout *cell_layout,
GtkCellRenderer *cell,
int position);
GList* (* get_cells) (GtkCellLayout *cell_layout);
GtkCellArea *(* get_area) (GtkCellLayout *cell_layout);
};
```
#### Members
| | | |
| --- | --- | --- |
| *`pack_start`* () | Packs the cell into the beginning of cell\_layout. | |
| *`pack_end`* () | Adds the cell to the end of cell\_layout. | |
| *`clear`* () | Unsets all the mappings on all renderers on cell\_layout and removes all renderers from cell\_layout. | |
| *`add_attribute`* () | Adds an attribute mapping to the list in cell\_layout. | |
| *`set_cell_data_func`* () | Sets the [GtkCellLayoutDataFunc](gtkcelllayout#GtkCellLayoutDataFunc) to use for cell\_layout. | |
| *`clear_attributes`* () | Clears all existing attributes previously set with [`gtk_cell_layout_set_attributes()`](gtkcelllayout#gtk-cell-layout-set-attributes). | |
| *`reorder`* () | Re-inserts cell at position. | |
| *`get_cells`* () | Get the cell renderers which have been added to cell\_layout. | |
| *`get_area`* () | Get the underlying [GtkCellArea](gtkcellarea#GtkCellArea-struct) which might be cell\_layout if called on a [GtkCellArea](gtkcellarea#GtkCellArea-struct) or might be NULL if no [GtkCellArea](gtkcellarea#GtkCellArea-struct) is used by cell\_layout. | |
gtk GtkDropTargetAsync GtkDropTargetAsync
==================
GtkDropTargetAsync — Event controller to receive DND drops
Functions
---------
| | |
| --- | --- |
| [GtkDropTargetAsync](gtkdroptargetasync#GtkDropTargetAsync-struct) \* | [gtk\_drop\_target\_async\_new](gtkdroptargetasync#gtk-drop-target-async-new) () |
| void | [gtk\_drop\_target\_async\_set\_formats](gtkdroptargetasync#gtk-drop-target-async-set-formats) () |
| [GdkContentFormats](https://developer-old.gnome.org/gtk4/html/gdk4-Content-Formats.html#GdkContentFormats-struct) \* | [gtk\_drop\_target\_async\_get\_formats](gtkdroptargetasync#gtk-drop-target-async-get-formats) () |
| void | [gtk\_drop\_target\_async\_set\_actions](gtkdroptargetasync#gtk-drop-target-async-set-actions) () |
| [GdkDragAction](https://developer-old.gnome.org/gtk4/html/gdk4-Drag-and-Drop.html#GdkDragAction) | [gtk\_drop\_target\_async\_get\_actions](gtkdroptargetasync#gtk-drop-target-async-get-actions) () |
| void | [gtk\_drop\_target\_async\_reject\_drop](gtkdroptargetasync#gtk-drop-target-async-reject-drop) () |
Properties
----------
| | | |
| --- | --- | --- |
| [GdkDragAction](https://developer-old.gnome.org/gtk4/html/gdk4-Drag-and-Drop.html#GdkDragAction) | [actions](gtkdroptargetasync#GtkDropTargetAsync--actions) | Read / Write |
| [GdkContentFormats](https://developer-old.gnome.org/gtk4/html/gdk4-Content-Formats.html#GdkContentFormats-struct) \* | [formats](gtkdroptargetasync#GtkDropTargetAsync--formats) | Read / Write |
Signals
-------
| | | |
| --- | --- | --- |
| gboolean | [accept](gtkdroptargetasync#GtkDropTargetAsync-accept) | Run Last |
| [GdkDragAction](https://developer-old.gnome.org/gtk4/html/gdk4-Drag-and-Drop.html#GdkDragAction) | [drag-enter](gtkdroptargetasync#GtkDropTargetAsync-drag-enter) | Run Last |
| void | [drag-leave](gtkdroptargetasync#GtkDropTargetAsync-drag-leave) | Run Last |
| [GdkDragAction](https://developer-old.gnome.org/gtk4/html/gdk4-Drag-and-Drop.html#GdkDragAction) | [drag-motion](gtkdroptargetasync#GtkDropTargetAsync-drag-motion) | Run Last |
| gboolean | [drop](gtkdroptargetasync#GtkDropTargetAsync-drop) | Run Last |
Types and Values
----------------
| | |
| --- | --- |
| | [GtkDropTargetAsync](gtkdroptargetasync#GtkDropTargetAsync-struct) |
Object Hierarchy
----------------
```
GObject
╰── [GtkEventController](gtkeventcontroller#GtkEventController-struct)
╰── GtkDropTargetAsync
```
Includes
--------
```
#include <gtk/gtk.h>
```
Description
-----------
GtkDropTargetAsync is an auxiliary object that can be used to receive Drag-and-Drop operations. It is the more complete but also more complex method of handling drop operations compared to [GtkDropTarget](gtkdroptarget#GtkDropTarget-struct) and you should only use it if [GtkDropTarget](gtkdroptarget#GtkDropTarget-struct) doesn't provide all the features you need.
To use a [GtkDropTargetAsync](gtkdroptargetasync#GtkDropTargetAsync-struct) to receive drops on a widget, you create a [GtkDropTargetAsync](gtkdroptargetasync#GtkDropTargetAsync-struct) object, configure which data formats and actions you support, connect to its signals, and then attach it to the widget with [`gtk_widget_add_controller()`](gtkwidget#gtk-widget-add-controller).
During a drag operation, the first signal that a GtkDropTargetAsync emits is [“accept”](gtkdroptargetasync#GtkDropTargetAsync-accept), which is meant to determine whether the target is a possible drop site for the ongoing drop. The default handler for the ::accept signal accepts the drop if it finds a compatible data format and an action that is supported on both sides.
If it is, and the widget becomes a target, you will receive a [“drag-enter”](gtkdroptargetasync#GtkDropTargetAsync-drag-enter) signal, followed by [“drag-motion”](gtkdroptargetasync#GtkDropTargetAsync-drag-motion) signals as the pointer moves, optionally a [“drop”](gtkdroptargetasync#GtkDropTargetAsync-drop) signal when a drop happens, and finally a [“drag-leave”](gtkdroptargetasync#GtkDropTargetAsync-drag-leave) signal when the pointer moves off the widget.
The ::drag-enter and ::drag-motion handler return a [GdkDragAction](https://developer-old.gnome.org/gtk4/html/gdk4-Drag-and-Drop.html#GdkDragAction) to update the status of the ongoing operation. The ::drop handler should decide if it ultimately accepts the drop and if it does, it should initiate the data transfer and finish the operation by calling [`gdk_drop_finish()`](https://developer-old.gnome.org/gtk4/html/gdk4-Drag-and-Drop.html#gdk-drop-finish).
Between the ::drag-enter and ::drag-leave signals the widget is a current drop target, and will receive the [`GTK_STATE_FLAG_DROP_ACTIVE`](gtk4-standard-enumerations#GTK-STATE-FLAG-DROP-ACTIVE:CAPS) state, which can be used by themes to style the widget as a drop target.
Functions
---------
### gtk\_drop\_target\_async\_new ()
```
[GtkDropTargetAsync](gtkdroptargetasync#GtkDropTargetAsync-struct) *
gtk_drop_target_async_new (*`[GdkContentFormats](https://developer-old.gnome.org/gtk4/html/gdk4-Content-Formats.html#GdkContentFormats-struct) *formats`*,
*`[GdkDragAction](https://developer-old.gnome.org/gtk4/html/gdk4-Drag-and-Drop.html#GdkDragAction) actions`*);
```
Creates a new [GtkDropTargetAsync](gtkdroptargetasync#GtkDropTargetAsync-struct) object.
#### Parameters
| | | |
| --- | --- | --- |
| formats | the supported data formats. | [nullable][transfer full] |
| actions | the supported actions | |
#### Returns
the new [GtkDropTargetAsync](gtkdroptargetasync#GtkDropTargetAsync-struct)
### gtk\_drop\_target\_async\_set\_formats ()
```
void
gtk_drop_target_async_set_formats (*`[GtkDropTargetAsync](gtkdroptargetasync#GtkDropTargetAsync-struct) *self`*,
*`[GdkContentFormats](https://developer-old.gnome.org/gtk4/html/gdk4-Content-Formats.html#GdkContentFormats-struct) *formats`*);
```
Sets the data formats that this drop target will accept.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkDropTargetAsync](gtkdroptargetasync#GtkDropTargetAsync-struct) | |
| formats | the supported data formats or `NULL` for any format. | [nullable] |
### gtk\_drop\_target\_async\_get\_formats ()
```
[GdkContentFormats](https://developer-old.gnome.org/gtk4/html/gdk4-Content-Formats.html#GdkContentFormats-struct) *
gtk_drop_target_async_get_formats (*`[GtkDropTargetAsync](gtkdroptargetasync#GtkDropTargetAsync-struct) *self`*);
```
Gets the data formats that this drop target accepts.
If the result is `NULL`, all formats are expected to be supported.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkDropTargetAsync](gtkdroptargetasync#GtkDropTargetAsync-struct) | |
#### Returns
the supported data formats.
[nullable]
### gtk\_drop\_target\_async\_set\_actions ()
```
void
gtk_drop_target_async_set_actions (*`[GtkDropTargetAsync](gtkdroptargetasync#GtkDropTargetAsync-struct) *self`*,
*`[GdkDragAction](https://developer-old.gnome.org/gtk4/html/gdk4-Drag-and-Drop.html#GdkDragAction) actions`*);
```
Sets the actions that this drop target supports.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkDropTargetAsync](gtkdroptargetasync#GtkDropTargetAsync-struct) | |
| actions | the supported actions | |
### gtk\_drop\_target\_async\_get\_actions ()
```
[GdkDragAction](https://developer-old.gnome.org/gtk4/html/gdk4-Drag-and-Drop.html#GdkDragAction)
gtk_drop_target_async_get_actions (*`[GtkDropTargetAsync](gtkdroptargetasync#GtkDropTargetAsync-struct) *self`*);
```
Gets the actions that this drop target supports.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkDropTargetAsync](gtkdroptargetasync#GtkDropTargetAsync-struct) | |
#### Returns
the actions that this drop target supports
### gtk\_drop\_target\_async\_reject\_drop ()
```
void
gtk_drop_target_async_reject_drop (*`[GtkDropTargetAsync](gtkdroptargetasync#GtkDropTargetAsync-struct) *self`*,
*`[GdkDrop](https://developer-old.gnome.org/gtk4/html/gdk4-Drag-and-Drop.html#GdkDrop-struct) *drop`*);
```
Sets the *`drop`* as not accepted on this drag site.
This function should be used when delaying the decision on whether to accept a drag or not until after reading the data.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkDropTargetAsync](gtkdroptargetasync#GtkDropTargetAsync-struct) | |
| drop | the [GdkDrop](https://developer-old.gnome.org/gtk4/html/gdk4-Drag-and-Drop.html#GdkDrop-struct) of an ongoing drag operation | |
Types and Values
----------------
### GtkDropTargetAsync
```
typedef struct _GtkDropTargetAsync GtkDropTargetAsync;
```
Property Details
----------------
### The `“actions”` property
```
“actions” [GdkDragAction](https://developer-old.gnome.org/gtk4/html/gdk4-Drag-and-Drop.html#GdkDragAction)
```
The [GdkDragActions](https://developer-old.gnome.org/gtk4/html/gdk4-Drag-and-Drop.html#GdkDragAction) that this drop target supports
Owner: GtkDropTargetAsync
Flags: Read / Write
### The `“formats”` property
```
“formats” [GdkContentFormats](https://developer-old.gnome.org/gtk4/html/gdk4-Content-Formats.html#GdkContentFormats-struct) *
```
The [GdkContentFormats](https://developer-old.gnome.org/gtk4/html/gdk4-Content-Formats.html#GdkContentFormats-struct) that determines the supported data formats
Owner: GtkDropTargetAsync
Flags: Read / Write
Signal Details
--------------
### The `“accept”` signal
```
gboolean
user_function ([GtkDropTargetAsync](gtkdroptargetasync#GtkDropTargetAsync-struct) *self,
[GdkDrop](https://developer-old.gnome.org/gtk4/html/gdk4-Drag-and-Drop.html#GdkDrop-struct) *drop,
gpointer user_data)
```
The ::accept signal is emitted on the drop site when a drop operation is about to begin.
If the drop is not accepted, `FALSE` will be returned and the drop target will ignore the drop. If `TRUE` is returned, the drop is accepted for now but may be rejected later via a call to `gtk_drop_target_async_reject()` or ultimately by returning `FALSE` from [“drop”](gtkdroptargetasync#GtkDropTargetAsync-drop).
The default handler for this signal decides whether to accept the drop based on the formats provided by the *`drop`* .
If the decision whether the drop will be accepted or rejected needs further processing, such as inspecting the data, this function should return `TRUE` and proceed as is *`drop`* was accepted and if it decides to reject the drop later, it should call [`gtk_drop_target_async_reject_drop()`](gtkdroptargetasync#gtk-drop-target-async-reject-drop).
#### Parameters
| | | |
| --- | --- | --- |
| self | the [GtkDropTargetAsync](gtkdroptargetasync#GtkDropTargetAsync-struct) | |
| drop | the [GdkDrop](https://developer-old.gnome.org/gtk4/html/gdk4-Drag-and-Drop.html#GdkDrop-struct) | |
| user\_data | user data set when the signal handler was connected. | |
#### Returns
`TRUE` if *`drop`* is accepted
Flags: Run Last
### The `“drag-enter”` signal
```
[GdkDragAction](https://developer-old.gnome.org/gtk4/html/gdk4-Drag-and-Drop.html#GdkDragAction)
user_function ([GtkDropTargetAsync](gtkdroptargetasync#GtkDropTargetAsync-struct) *self,
[GdkDrop](https://developer-old.gnome.org/gtk4/html/gdk4-Drag-and-Drop.html#GdkDrop-struct) *drop,
double x,
double y,
gpointer user_data)
```
The ::drag-enter signal is emitted on the drop site when the pointer enters the widget. It can be used to set up custom highlighting.
#### Parameters
| | | |
| --- | --- | --- |
| self | the [GtkDropTargetAsync](gtkdroptargetasync#GtkDropTargetAsync-struct) | |
| drop | the [GdkDrop](https://developer-old.gnome.org/gtk4/html/gdk4-Drag-and-Drop.html#GdkDrop-struct) | |
| x | the x coordinate of the current pointer position | |
| y | the y coordinate of the current pointer position | |
| user\_data | user data set when the signal handler was connected. | |
#### Returns
Preferred action for this drag operation.
Flags: Run Last
### The `“drag-leave”` signal
```
void
user_function ([GtkDropTargetAsync](gtkdroptargetasync#GtkDropTargetAsync-struct) *self,
[GdkDrop](https://developer-old.gnome.org/gtk4/html/gdk4-Drag-and-Drop.html#GdkDrop-struct) *drop,
gpointer user_data)
```
The ::drag-leave signal is emitted on the drop site when the pointer leaves the widget. Its main purpose it to undo things done in [“drag-enter”](gtkdroptargetasync#GtkDropTargetAsync-drag-enter).
#### Parameters
| | | |
| --- | --- | --- |
| self | the [GtkDropTargetAsync](gtkdroptargetasync#GtkDropTargetAsync-struct) | |
| drop | the [GdkDrop](https://developer-old.gnome.org/gtk4/html/gdk4-Drag-and-Drop.html#GdkDrop-struct) | |
| user\_data | user data set when the signal handler was connected. | |
Flags: Run Last
### The `“drag-motion”` signal
```
[GdkDragAction](https://developer-old.gnome.org/gtk4/html/gdk4-Drag-and-Drop.html#GdkDragAction)
user_function ([GtkDropTargetAsync](gtkdroptargetasync#GtkDropTargetAsync-struct) *self,
[GdkDrop](https://developer-old.gnome.org/gtk4/html/gdk4-Drag-and-Drop.html#GdkDrop-struct) *drop,
double x,
double y,
gpointer user_data)
```
The ::drag-motion signal is emitted while the pointer is moving over the drop target.
#### Parameters
| | | |
| --- | --- | --- |
| self | the [GtkDropTargetAsync](gtkdroptargetasync#GtkDropTargetAsync-struct) | |
| drop | the [GdkDrop](https://developer-old.gnome.org/gtk4/html/gdk4-Drag-and-Drop.html#GdkDrop-struct) | |
| x | the x coordinate of the current pointer position | |
| y | the y coordinate of the current pointer position | |
| user\_data | user data set when the signal handler was connected. | |
#### Returns
Preferred action for this drag operation.
Flags: Run Last
### The `“drop”` signal
```
gboolean
user_function ([GtkDropTargetAsync](gtkdroptargetasync#GtkDropTargetAsync-struct) *self,
[GdkDrop](https://developer-old.gnome.org/gtk4/html/gdk4-Drag-and-Drop.html#GdkDrop-struct) *drop,
double x,
double y,
gpointer user_data)
```
The ::drop signal is emitted on the drop site when the user drops the data onto the widget. The signal handler must determine whether the pointer position is in a drop zone or not. If it is not in a drop zone, it returns `FALSE` and no further processing is necessary.
Otherwise, the handler returns `TRUE`. In this case, this handler will accept the drop. The handler must ensure that [`gdk_drop_finish()`](https://developer-old.gnome.org/gtk4/html/gdk4-Drag-and-Drop.html#gdk-drop-finish) is called to let the source know that the drop is done. The call to [`gdk_drop_finish()`](https://developer-old.gnome.org/gtk4/html/gdk4-Drag-and-Drop.html#gdk-drop-finish) must only be done when all data has been received.
To receive the data, use one of the read functions provides by [GdkDrop](https://developer-old.gnome.org/gtk4/html/gdk4-Drag-and-Drop.html#GdkDrop-struct) such as [`gdk_drop_read_async()`](https://developer-old.gnome.org/gtk4/html/gdk4-Drag-and-Drop.html#gdk-drop-read-async) or [`gdk_drop_read_value_async()`](https://developer-old.gnome.org/gtk4/html/gdk4-Drag-and-Drop.html#gdk-drop-read-value-async).
#### Parameters
| | | |
| --- | --- | --- |
| self | the [GtkDropTargetAsync](gtkdroptargetasync#GtkDropTargetAsync-struct) | |
| drop | the [GdkDrop](https://developer-old.gnome.org/gtk4/html/gdk4-Drag-and-Drop.html#GdkDrop-struct) | |
| x | the x coordinate of the current pointer position | |
| y | the y coordinate of the current pointer position | |
| user\_data | user data set when the signal handler was connected. | |
#### Returns
whether the drop is accepted at the given pointer position
Flags: Run Last
See Also
--------
[GtkDropTarget](gtkdroptarget#GtkDropTarget-struct)
| programming_docs |
gtk GtkLayoutChild GtkLayoutChild
==============
GtkLayoutChild — An object containing layout properties
Functions
---------
| | |
| --- | --- |
| [GtkLayoutManager](gtklayoutmanager#GtkLayoutManager-struct) \* | [gtk\_layout\_child\_get\_layout\_manager](gtklayoutchild#gtk-layout-child-get-layout-manager) () |
| [GtkWidget](gtkwidget#GtkWidget-struct) \* | [gtk\_layout\_child\_get\_child\_widget](gtklayoutchild#gtk-layout-child-get-child-widget) () |
Properties
----------
| | | |
| --- | --- | --- |
| [GtkWidget](gtkwidget#GtkWidget-struct) \* | [child-widget](gtklayoutchild#GtkLayoutChild--child-widget) | Read / Write / Construct Only |
| [GtkLayoutManager](gtklayoutmanager#GtkLayoutManager-struct) \* | [layout-manager](gtklayoutchild#GtkLayoutChild--layout-manager) | Read / Write / Construct Only |
Types and Values
----------------
| | |
| --- | --- |
| | [GtkLayoutChild](gtklayoutchild#GtkLayoutChild-struct) |
| struct | [GtkLayoutChildClass](gtklayoutchild#GtkLayoutChildClass) |
Object Hierarchy
----------------
```
GObject
╰── GtkLayoutChild
├── [GtkGridLayoutChild](gtkgridlayout#GtkGridLayoutChild-struct)
├── [GtkOverlayLayoutChild](gtkoverlaylayout#GtkOverlayLayoutChild-struct)
├── [GtkConstraintLayoutChild](gtkconstraintlayout#GtkConstraintLayoutChild-struct)
╰── [GtkFixedLayoutChild](gtkfixedlayout#GtkFixedLayoutChild-struct)
```
Includes
--------
```
#include <gtk/gtk.h>
```
Description
-----------
[GtkLayoutChild](gtklayoutchild#GtkLayoutChild-struct) is the base class for objects that are meant to hold layout properties. If a [GtkLayoutManager](gtklayoutmanager#GtkLayoutManager-struct) has per-child properties, like their packing type, or the horizontal and vertical span, or the icon name, then the layout manager should use a [GtkLayoutChild](gtklayoutchild#GtkLayoutChild-struct) implementation to store those properties.
A [GtkLayoutChild](gtklayoutchild#GtkLayoutChild-struct) instance is only ever valid while a widget is part of a layout.
Functions
---------
### gtk\_layout\_child\_get\_layout\_manager ()
```
[GtkLayoutManager](gtklayoutmanager#GtkLayoutManager-struct) *
gtk_layout_child_get_layout_manager (*`[GtkLayoutChild](gtklayoutchild#GtkLayoutChild-struct) *layout_child`*);
```
Retrieves the [GtkLayoutManager](gtklayoutmanager#GtkLayoutManager-struct) instance that created the given *`layout_child`* .
#### Parameters
| | | |
| --- | --- | --- |
| layout\_child | a [GtkLayoutChild](gtklayoutchild#GtkLayoutChild-struct) | |
#### Returns
a [GtkLayoutManager](gtklayoutmanager#GtkLayoutManager-struct).
[transfer none]
### gtk\_layout\_child\_get\_child\_widget ()
```
[GtkWidget](gtkwidget#GtkWidget-struct) *
gtk_layout_child_get_child_widget (*`[GtkLayoutChild](gtklayoutchild#GtkLayoutChild-struct) *layout_child`*);
```
Retrieves the [GtkWidget](gtkwidget#GtkWidget-struct) associated to the given *`layout_child`* .
#### Parameters
| | | |
| --- | --- | --- |
| layout\_child | a [GtkLayoutChild](gtklayoutchild#GtkLayoutChild-struct) | |
#### Returns
a [GtkWidget](gtkwidget#GtkWidget-struct).
[transfer none]
Types and Values
----------------
### GtkLayoutChild
```
typedef struct _GtkLayoutChild GtkLayoutChild;
```
### struct GtkLayoutChildClass
```
struct GtkLayoutChildClass {
};
```
Property Details
----------------
### The `“child-widget”` property
```
“child-widget” [GtkWidget](gtkwidget#GtkWidget-struct) *
```
The widget that is associated to the [GtkLayoutChild](gtklayoutchild#GtkLayoutChild-struct) instance.
Owner: GtkLayoutChild
Flags: Read / Write / Construct Only
### The `“layout-manager”` property
```
“layout-manager” [GtkLayoutManager](gtklayoutmanager#GtkLayoutManager-struct) *
```
The layout manager that created the [GtkLayoutChild](gtklayoutchild#GtkLayoutChild-struct) instance.
Owner: GtkLayoutChild
Flags: Read / Write / Construct Only
gtk Activation Activation
==========
When a widget with a connected action is activated, GTK finds the action to activate by walking up the widget hierarchy, looking for a matching action, ending up at the GtkApplication.
gtk GtkListStore GtkListStore
============
GtkListStore — A list-like data structure that can be used with the GtkTreeView
Functions
---------
| | |
| --- | --- |
| [GtkListStore](gtkliststore#GtkListStore-struct) \* | [gtk\_list\_store\_new](gtkliststore#gtk-list-store-new) () |
| [GtkListStore](gtkliststore#GtkListStore-struct) \* | [gtk\_list\_store\_newv](gtkliststore#gtk-list-store-newv) () |
| void | [gtk\_list\_store\_set\_column\_types](gtkliststore#gtk-list-store-set-column-types) () |
| void | [gtk\_list\_store\_set](gtkliststore#gtk-list-store-set) () |
| void | [gtk\_list\_store\_set\_valist](gtkliststore#gtk-list-store-set-valist) () |
| void | [gtk\_list\_store\_set\_value](gtkliststore#gtk-list-store-set-value) () |
| void | [gtk\_list\_store\_set\_valuesv](gtkliststore#gtk-list-store-set-valuesv) () |
| gboolean | [gtk\_list\_store\_remove](gtkliststore#gtk-list-store-remove) () |
| void | [gtk\_list\_store\_insert](gtkliststore#gtk-list-store-insert) () |
| void | [gtk\_list\_store\_insert\_before](gtkliststore#gtk-list-store-insert-before) () |
| void | [gtk\_list\_store\_insert\_after](gtkliststore#gtk-list-store-insert-after) () |
| void | [gtk\_list\_store\_insert\_with\_values](gtkliststore#gtk-list-store-insert-with-values) () |
| void | [gtk\_list\_store\_insert\_with\_valuesv](gtkliststore#gtk-list-store-insert-with-valuesv) () |
| void | [gtk\_list\_store\_prepend](gtkliststore#gtk-list-store-prepend) () |
| void | [gtk\_list\_store\_append](gtkliststore#gtk-list-store-append) () |
| void | [gtk\_list\_store\_clear](gtkliststore#gtk-list-store-clear) () |
| gboolean | [gtk\_list\_store\_iter\_is\_valid](gtkliststore#gtk-list-store-iter-is-valid) () |
| void | [gtk\_list\_store\_reorder](gtkliststore#gtk-list-store-reorder) () |
| void | [gtk\_list\_store\_swap](gtkliststore#gtk-list-store-swap) () |
| void | [gtk\_list\_store\_move\_before](gtkliststore#gtk-list-store-move-before) () |
| void | [gtk\_list\_store\_move\_after](gtkliststore#gtk-list-store-move-after) () |
Types and Values
----------------
| | |
| --- | --- |
| struct | [GtkListStore](gtkliststore#GtkListStore-struct) |
Object Hierarchy
----------------
```
GObject
╰── GtkListStore
```
Implemented Interfaces
----------------------
GtkListStore implements [GtkTreeModel](gtktreemodel#GtkTreeModel-struct), [GtkTreeDragSource](gtk4-gtktreeview-drag-and-drop#GtkTreeDragSource-struct), [GtkTreeDragDest](gtk4-gtktreeview-drag-and-drop#GtkTreeDragDest-struct), [GtkTreeSortable](gtktreesortable#GtkTreeSortable-struct) and [GtkBuildable](gtkbuildable#GtkBuildable-struct).
Includes
--------
```
#include <gtk/gtk.h>
```
Description
-----------
The [GtkListStore](gtkliststore#GtkListStore-struct) object is a list model for use with a [GtkTreeView](gtktreeview#GtkTreeView-struct) widget. It implements the [GtkTreeModel](gtktreemodel#GtkTreeModel-struct) interface, and consequentialy, can use all of the methods available there. It also implements the [GtkTreeSortable](gtktreesortable#GtkTreeSortable-struct) interface so it can be sorted by the view. Finally, it also implements the tree drag and drop interfaces.
The [GtkListStore](gtkliststore#GtkListStore-struct) can accept most GObject types as a column type, though it can’t accept all custom types. Internally, it will keep a copy of data passed in (such as a string or a boxed pointer). Columns that accept GObjects are handled a little differently. The [GtkListStore](gtkliststore#GtkListStore-struct) will keep a reference to the object instead of copying the value. As a result, if the object is modified, it is up to the application writer to call [`gtk_tree_model_row_changed()`](gtktreemodel#gtk-tree-model-row-changed) to emit the [“row\_changed”](gtktreemodel#GtkTreeModel-row-changed) signal. This most commonly affects lists with GdkTextures stored.
An example for creating a simple list store:
### Performance Considerations
Internally, the [GtkListStore](gtkliststore#GtkListStore-struct) was originally implemented with a linked list with a tail pointer. As a result, it was fast at data insertion and deletion, and not fast at random data access. The [GtkListStore](gtkliststore#GtkListStore-struct) sets the [GTK\_TREE\_MODEL\_ITERS\_PERSIST](gtktreemodel#GTK-TREE-MODEL-ITERS-PERSIST:CAPS) flag, which means that [GtkTreeIters](gtktreemodel#GtkTreeIter-struct) can be cached while the row exists. Thus, if access to a particular row is needed often and your code is expected to run on older versions of GTK, it is worth keeping the iter around.
### Atomic Operations
It is important to note that only the methods [`gtk_list_store_insert_with_values()`](gtkliststore#gtk-list-store-insert-with-values) and [`gtk_list_store_insert_with_valuesv()`](gtkliststore#gtk-list-store-insert-with-valuesv) are atomic, in the sense that the row is being appended to the store and the values filled in in a single operation with regard to [GtkTreeModel](gtktreemodel#GtkTreeModel-struct) signaling. In contrast, using e.g. [`gtk_list_store_append()`](gtkliststore#gtk-list-store-append) and then [`gtk_list_store_set()`](gtkliststore#gtk-list-store-set) will first create a row, which triggers the [“row-inserted”](gtktreemodel#GtkTreeModel-row-inserted) signal on [GtkListStore](gtkliststore#GtkListStore-struct). The row, however, is still empty, and any signal handler connecting to [“row-inserted”](gtktreemodel#GtkTreeModel-row-inserted) on this particular store should be prepared for the situation that the row might be empty. This is especially important if you are wrapping the [GtkListStore](gtkliststore#GtkListStore-struct) inside a [GtkTreeModelFilter](gtktreemodelfilter#GtkTreeModelFilter-struct) and are using a [GtkTreeModelFilterVisibleFunc](gtktreemodelfilter#GtkTreeModelFilterVisibleFunc). Using any of the non-atomic operations to append rows to the [GtkListStore](gtkliststore#GtkListStore-struct) will cause the [GtkTreeModelFilterVisibleFunc](gtktreemodelfilter#GtkTreeModelFilterVisibleFunc) to be visited with an empty row first; the function must be prepared for that.
### GtkListStore as GtkBuildable
The GtkListStore implementation of the GtkBuildable interface allows to specify the model columns with a <columns> element that may contain multiple <column> elements, each specifying one model column. The “type” attribute specifies the data type for the column.
Additionally, it is possible to specify content for the list store in the UI definition, with the <data> element. It can contain multiple <row> elements, each specifying to content for one row of the list model. Inside a <row>, the <col> elements specify the content for individual cells.
Note that it is probably more common to define your models in the code, and one might consider it a layering violation to specify the content of a list store in a UI definition, data, not presentation, and common wisdom is to separate the two, as far as possible.
An example of a UI Definition fragment for a list store:
Functions
---------
### gtk\_list\_store\_new ()
```
[GtkListStore](gtkliststore#GtkListStore-struct) *
gtk_list_store_new (*`int n_columns`*,
*`...`*);
```
Creates a new list store as with *`n_columns`* columns each of the types passed in. Note that only types derived from standard GObject fundamental types are supported.
As an example, `gtk_list_store_new (3, G_TYPE_INT, G_TYPE_STRING,
GDK_TYPE_TEXTURE);` will create a new [GtkListStore](gtkliststore#GtkListStore-struct) with three columns, of type int, string and [GdkTexture](https://developer-old.gnome.org/gtk4/html/gdk4-Textures.html#GdkTexture-struct), respectively.
#### Parameters
| | | |
| --- | --- | --- |
| n\_columns | number of columns in the list store | |
| ... | all GType types for the columns, from first to last | |
#### Returns
a new [GtkListStore](gtkliststore#GtkListStore-struct)
### gtk\_list\_store\_newv ()
```
[GtkListStore](gtkliststore#GtkListStore-struct) *
gtk_list_store_newv (*`int n_columns`*,
*`GType *types`*);
```
Non-vararg creation function. Used primarily by language bindings.
[rename-to gtk\_list\_store\_new]
#### Parameters
| | | |
| --- | --- | --- |
| n\_columns | number of columns in the list store | |
| types | an array of GType types for the columns, from first to last. | [array length=n\_columns] |
#### Returns
a new [GtkListStore](gtkliststore#GtkListStore-struct).
[transfer full]
### gtk\_list\_store\_set\_column\_types ()
```
void
gtk_list_store_set_column_types (*`[GtkListStore](gtkliststore#GtkListStore-struct) *list_store`*,
*`int n_columns`*,
*`GType *types`*);
```
This function is meant primarily for GObjects that inherit from [GtkListStore](gtkliststore#GtkListStore-struct), and should only be used when constructing a new [GtkListStore](gtkliststore#GtkListStore-struct). It will not function after a row has been added, or a method on the [GtkTreeModel](gtktreemodel#GtkTreeModel-struct) interface is called.
#### Parameters
| | | |
| --- | --- | --- |
| list\_store | A [GtkListStore](gtkliststore#GtkListStore-struct) | |
| n\_columns | Number of columns for the list store | |
| types | An array length n of GTypes. | [array length=n\_columns] |
### gtk\_list\_store\_set ()
```
void
gtk_list_store_set (*`[GtkListStore](gtkliststore#GtkListStore-struct) *list_store`*,
*`[GtkTreeIter](gtktreemodel#GtkTreeIter-struct) *iter`*,
*`...`*);
```
Sets the value of one or more cells in the row referenced by *`iter`* . The variable argument list should contain integer column numbers, each column number followed by the value to be set. The list is terminated by a -1. For example, to set column 0 with type `G_TYPE_STRING` to “Foo”, you would write `gtk_list_store_set (store, iter,
0, "Foo", -1)`.
The value will be referenced by the store if it is a `G_TYPE_OBJECT`, and it will be copied if it is a `G_TYPE_STRING` or `G_TYPE_BOXED`.
#### Parameters
| | | |
| --- | --- | --- |
| list\_store | a [GtkListStore](gtkliststore#GtkListStore-struct) | |
| iter | row iterator | |
| ... | pairs of column number and value, terminated with -1 | |
### gtk\_list\_store\_set\_valist ()
```
void
gtk_list_store_set_valist (*`[GtkListStore](gtkliststore#GtkListStore-struct) *list_store`*,
*`[GtkTreeIter](gtktreemodel#GtkTreeIter-struct) *iter`*,
*`va\_list var_args`*);
```
See [`gtk_list_store_set()`](gtkliststore#gtk-list-store-set); this version takes a va\_list for use by language bindings.
#### Parameters
| | | |
| --- | --- | --- |
| list\_store | A [GtkListStore](gtkliststore#GtkListStore-struct) | |
| iter | A valid [GtkTreeIter](gtktreemodel#GtkTreeIter-struct) for the row being modified | |
| var\_args | va\_list of column/value pairs | |
### gtk\_list\_store\_set\_value ()
```
void
gtk_list_store_set_value (*`[GtkListStore](gtkliststore#GtkListStore-struct) *list_store`*,
*`[GtkTreeIter](gtktreemodel#GtkTreeIter-struct) *iter`*,
*`int column`*,
*`GValue *value`*);
```
Sets the data in the cell specified by *`iter`* and *`column`* . The type of *`value`* must be convertible to the type of the column.
#### Parameters
| | | |
| --- | --- | --- |
| list\_store | A [GtkListStore](gtkliststore#GtkListStore-struct) | |
| iter | A valid [GtkTreeIter](gtktreemodel#GtkTreeIter-struct) for the row being modified | |
| column | column number to modify | |
| value | new value for the cell | |
### gtk\_list\_store\_set\_valuesv ()
```
void
gtk_list_store_set_valuesv (*`[GtkListStore](gtkliststore#GtkListStore-struct) *list_store`*,
*`[GtkTreeIter](gtktreemodel#GtkTreeIter-struct) *iter`*,
*`int *columns`*,
*`GValue *values`*,
*`int n_values`*);
```
A variant of [`gtk_list_store_set_valist()`](gtkliststore#gtk-list-store-set-valist) which takes the columns and values as two arrays, instead of varargs. This function is mainly intended for language-bindings and in case the number of columns to change is not known until run-time.
[rename-to gtk\_list\_store\_set]
#### Parameters
| | | |
| --- | --- | --- |
| list\_store | A [GtkListStore](gtkliststore#GtkListStore-struct) | |
| iter | A valid [GtkTreeIter](gtktreemodel#GtkTreeIter-struct) for the row being modified | |
| columns | an array of column numbers. | [array length=n\_values] |
| values | an array of GValues. | [array length=n\_values] |
| n\_values | the length of the *`columns`* and *`values`* arrays | |
### gtk\_list\_store\_remove ()
```
gboolean
gtk_list_store_remove (*`[GtkListStore](gtkliststore#GtkListStore-struct) *list_store`*,
*`[GtkTreeIter](gtktreemodel#GtkTreeIter-struct) *iter`*);
```
Removes the given row from the list store. After being removed, *`iter`* is set to be the next valid row, or invalidated if it pointed to the last row in *`list_store`* .
#### Parameters
| | | |
| --- | --- | --- |
| list\_store | A [GtkListStore](gtkliststore#GtkListStore-struct) | |
| iter | A valid [GtkTreeIter](gtktreemodel#GtkTreeIter-struct) | |
#### Returns
`TRUE` if *`iter`* is valid, `FALSE` if not.
### gtk\_list\_store\_insert ()
```
void
gtk_list_store_insert (*`[GtkListStore](gtkliststore#GtkListStore-struct) *list_store`*,
*`[GtkTreeIter](gtktreemodel#GtkTreeIter-struct) *iter`*,
*`int position`*);
```
Creates a new row at *`position`* . *`iter`* will be changed to point to this new row. If *`position`* is -1 or is larger than the number of rows on the list, then the new row will be appended to the list. The row will be empty after this function is called. To fill in values, you need to call [`gtk_list_store_set()`](gtkliststore#gtk-list-store-set) or [`gtk_list_store_set_value()`](gtkliststore#gtk-list-store-set-value).
#### Parameters
| | | |
| --- | --- | --- |
| list\_store | A [GtkListStore](gtkliststore#GtkListStore-struct) | |
| iter | An unset [GtkTreeIter](gtktreemodel#GtkTreeIter-struct) to set to the new row. | [out] |
| position | position to insert the new row, or -1 for last | |
### gtk\_list\_store\_insert\_before ()
```
void
gtk_list_store_insert_before (*`[GtkListStore](gtkliststore#GtkListStore-struct) *list_store`*,
*`[GtkTreeIter](gtktreemodel#GtkTreeIter-struct) *iter`*,
*`[GtkTreeIter](gtktreemodel#GtkTreeIter-struct) *sibling`*);
```
Inserts a new row before *`sibling`* . If *`sibling`* is `NULL`, then the row will be appended to the end of the list. *`iter`* will be changed to point to this new row. The row will be empty after this function is called. To fill in values, you need to call [`gtk_list_store_set()`](gtkliststore#gtk-list-store-set) or [`gtk_list_store_set_value()`](gtkliststore#gtk-list-store-set-value).
#### Parameters
| | | |
| --- | --- | --- |
| list\_store | A [GtkListStore](gtkliststore#GtkListStore-struct) | |
| iter | An unset [GtkTreeIter](gtktreemodel#GtkTreeIter-struct) to set to the new row. | [out] |
| sibling | A valid [GtkTreeIter](gtktreemodel#GtkTreeIter-struct), or `NULL`. | [allow-none] |
### gtk\_list\_store\_insert\_after ()
```
void
gtk_list_store_insert_after (*`[GtkListStore](gtkliststore#GtkListStore-struct) *list_store`*,
*`[GtkTreeIter](gtktreemodel#GtkTreeIter-struct) *iter`*,
*`[GtkTreeIter](gtktreemodel#GtkTreeIter-struct) *sibling`*);
```
Inserts a new row after *`sibling`* . If *`sibling`* is `NULL`, then the row will be prepended to the beginning of the list. *`iter`* will be changed to point to this new row. The row will be empty after this function is called. To fill in values, you need to call [`gtk_list_store_set()`](gtkliststore#gtk-list-store-set) or [`gtk_list_store_set_value()`](gtkliststore#gtk-list-store-set-value).
#### Parameters
| | | |
| --- | --- | --- |
| list\_store | A [GtkListStore](gtkliststore#GtkListStore-struct) | |
| iter | An unset [GtkTreeIter](gtktreemodel#GtkTreeIter-struct) to set to the new row. | [out] |
| sibling | A valid [GtkTreeIter](gtktreemodel#GtkTreeIter-struct), or `NULL`. | [allow-none] |
### gtk\_list\_store\_insert\_with\_values ()
```
void
gtk_list_store_insert_with_values (*`[GtkListStore](gtkliststore#GtkListStore-struct) *list_store`*,
*`[GtkTreeIter](gtktreemodel#GtkTreeIter-struct) *iter`*,
*`int position`*,
*`...`*);
```
Creates a new row at *`position`* . *`iter`* will be changed to point to this new row. If *`position`* is -1, or larger than the number of rows in the list, then the new row will be appended to the list. The row will be filled with the values given to this function.
Calling `gtk_list_store_insert_with_values (list_store, iter, position...)` has the same effect as calling
```
enum {
COLUMN_STRING,
COLUMN_INT,
COLUMN_BOOLEAN,
N_COLUMNS
};
{
GtkListStore *list_store;
GtkTreePath *path;
GtkTreeIter iter;
int i;
list_store = gtk_list_store_new (N_COLUMNS,
G_TYPE_STRING,
G_TYPE_INT,
G_TYPE_BOOLEAN);
for (i = 0; i < 10; i++)
{
char *some_data;
some_data = get_some_data (i);
// Add a new row to the model
gtk_list_store_append (list_store, &iter);
gtk_list_store_set (list_store, &iter,
COLUMN_STRING, some_data,
COLUMN_INT, i,
COLUMN_BOOLEAN, FALSE,
-1);
// As the store will keep a copy of the string internally,
// we free some_data.
g_free (some_data);
}
// Modify a particular row
path = gtk_tree_path_new_from_string ("4");
gtk_tree_model_get_iter (GTK_TREE_MODEL (list_store),
&iter,
path);
gtk_tree_path_free (path);
gtk_list_store_set (list_store, &iter,
COLUMN_BOOLEAN, TRUE,
-1);
}
```
| with the difference that the former will only emit a row\_inserted signal, while the latter will emit row\_inserted, row\_changed and, if the list store is sorted, rows\_reordered. Since emitting the rows\_reordered signal repeatedly can affect the performance of the program, [`gtk_list_store_insert_with_values()`](gtkliststore#gtk-list-store-insert-with-values) should generally be preferred when inserting rows in a sorted list store.
#### Parameters
| | | |
| --- | --- | --- |
| list\_store | A [GtkListStore](gtkliststore#GtkListStore-struct) | |
| iter | An unset [GtkTreeIter](gtktreemodel#GtkTreeIter-struct) to set to the new row, or `NULL`. | [out][allow-none] |
| position | position to insert the new row, or -1 to append after existing rows | |
| ... | pairs of column number and value, terminated with -1 | |
### gtk\_list\_store\_insert\_with\_valuesv ()
```
void
gtk_list_store_insert_with_valuesv (*`[GtkListStore](gtkliststore#GtkListStore-struct) *list_store`*,
*`[GtkTreeIter](gtktreemodel#GtkTreeIter-struct) *iter`*,
*`int position`*,
*`int *columns`*,
*`GValue *values`*,
*`int n_values`*);
```
A variant of [`gtk_list_store_insert_with_values()`](gtkliststore#gtk-list-store-insert-with-values) which takes the columns and values as two arrays, instead of varargs. This function is mainly intended for language-bindings.
#### Parameters
| | | |
| --- | --- | --- |
| list\_store | A [GtkListStore](gtkliststore#GtkListStore-struct) | |
| iter | An unset [GtkTreeIter](gtktreemodel#GtkTreeIter-struct) to set to the new row, or `NULL`. | [out][allow-none] |
| position | position to insert the new row, or -1 for last | |
| columns | an array of column numbers. | [array length=n\_values] |
| values | an array of GValues. | [array length=n\_values] |
| n\_values | the length of the *`columns`* and *`values`* arrays | |
### gtk\_list\_store\_prepend ()
```
void
gtk_list_store_prepend (*`[GtkListStore](gtkliststore#GtkListStore-struct) *list_store`*,
*`[GtkTreeIter](gtktreemodel#GtkTreeIter-struct) *iter`*);
```
Prepends a new row to *`list_store`* . *`iter`* will be changed to point to this new row. The row will be empty after this function is called. To fill in values, you need to call [`gtk_list_store_set()`](gtkliststore#gtk-list-store-set) or [`gtk_list_store_set_value()`](gtkliststore#gtk-list-store-set-value).
#### Parameters
| | | |
| --- | --- | --- |
| list\_store | A [GtkListStore](gtkliststore#GtkListStore-struct) | |
| iter | An unset [GtkTreeIter](gtktreemodel#GtkTreeIter-struct) to set to the prepend row. | [out] |
### gtk\_list\_store\_append ()
```
void
gtk_list_store_append (*`[GtkListStore](gtkliststore#GtkListStore-struct) *list_store`*,
*`[GtkTreeIter](gtktreemodel#GtkTreeIter-struct) *iter`*);
```
Appends a new row to *`list_store`* . *`iter`* will be changed to point to this new row. The row will be empty after this function is called. To fill in values, you need to call [`gtk_list_store_set()`](gtkliststore#gtk-list-store-set) or [`gtk_list_store_set_value()`](gtkliststore#gtk-list-store-set-value).
#### Parameters
| | | |
| --- | --- | --- |
| list\_store | A [GtkListStore](gtkliststore#GtkListStore-struct) | |
| iter | An unset [GtkTreeIter](gtktreemodel#GtkTreeIter-struct) to set to the appended row. | [out] |
### gtk\_list\_store\_clear ()
```
void
gtk_list_store_clear (*`[GtkListStore](gtkliststore#GtkListStore-struct) *list_store`*);
```
Removes all rows from the list store.
#### Parameters
| | | |
| --- | --- | --- |
| list\_store | a [GtkListStore](gtkliststore#GtkListStore-struct). | |
### gtk\_list\_store\_iter\_is\_valid ()
```
gboolean
gtk_list_store_iter_is_valid (*`[GtkListStore](gtkliststore#GtkListStore-struct) *list_store`*,
*`[GtkTreeIter](gtktreemodel#GtkTreeIter-struct) *iter`*);
```
> This function is slow. Only use it for debugging and/or testing purposes.
>
>
Checks if the given iter is a valid iter for this [GtkListStore](gtkliststore#GtkListStore-struct).
#### Parameters
| | | |
| --- | --- | --- |
| list\_store | A [GtkListStore](gtkliststore#GtkListStore-struct). | |
| iter | A [GtkTreeIter](gtktreemodel#GtkTreeIter-struct). | |
#### Returns
`TRUE` if the iter is valid, `FALSE` if the iter is invalid.
### gtk\_list\_store\_reorder ()
```
void
gtk_list_store_reorder (*`[GtkListStore](gtkliststore#GtkListStore-struct) *store`*,
*`int *new_order`*);
```
Reorders *`store`* to follow the order indicated by *`new_order`* . Note that this function only works with unsorted stores.
#### Parameters
| | | |
| --- | --- | --- |
| store | A [GtkListStore](gtkliststore#GtkListStore-struct). | |
| new\_order | an array of integers mapping the new position of each child to its old position before the re-ordering, i.e. *`new_order`* `[newpos] = oldpos`. It must have exactly as many items as the list store’s length. | [array zero-terminated=1] |
### gtk\_list\_store\_swap ()
```
void
gtk_list_store_swap (*`[GtkListStore](gtkliststore#GtkListStore-struct) *store`*,
*`[GtkTreeIter](gtktreemodel#GtkTreeIter-struct) *a`*,
*`[GtkTreeIter](gtktreemodel#GtkTreeIter-struct) *b`*);
```
Swaps *`a`* and *`b`* in *`store`* . Note that this function only works with unsorted stores.
#### Parameters
| | | |
| --- | --- | --- |
| store | A [GtkListStore](gtkliststore#GtkListStore-struct). | |
| a | A [GtkTreeIter](gtktreemodel#GtkTreeIter-struct). | |
| b | Another [GtkTreeIter](gtktreemodel#GtkTreeIter-struct). | |
### gtk\_list\_store\_move\_before ()
```
void
gtk_list_store_move_before (*`[GtkListStore](gtkliststore#GtkListStore-struct) *store`*,
*`[GtkTreeIter](gtktreemodel#GtkTreeIter-struct) *iter`*,
*`[GtkTreeIter](gtktreemodel#GtkTreeIter-struct) *position`*);
```
Moves *`iter`* in *`store`* to the position before *`position`* . Note that this function only works with unsorted stores. If *`position`* is `NULL`, *`iter`* will be moved to the end of the list.
#### Parameters
| | | |
| --- | --- | --- |
| store | A [GtkListStore](gtkliststore#GtkListStore-struct). | |
| iter | A [GtkTreeIter](gtktreemodel#GtkTreeIter-struct). | |
| position | A [GtkTreeIter](gtktreemodel#GtkTreeIter-struct), or `NULL`. | [allow-none] |
### gtk\_list\_store\_move\_after ()
```
void
gtk_list_store_move_after (*`[GtkListStore](gtkliststore#GtkListStore-struct) *store`*,
*`[GtkTreeIter](gtktreemodel#GtkTreeIter-struct) *iter`*,
*`[GtkTreeIter](gtktreemodel#GtkTreeIter-struct) *position`*);
```
Moves *`iter`* in *`store`* to the position after *`position`* . Note that this function only works with unsorted stores. If *`position`* is `NULL`, *`iter`* will be moved to the start of the list.
#### Parameters
| | | |
| --- | --- | --- |
| store | A [GtkListStore](gtkliststore#GtkListStore-struct). | |
| iter | A [GtkTreeIter](gtktreemodel#GtkTreeIter-struct). | |
| position | A [GtkTreeIter](gtktreemodel#GtkTreeIter-struct) or `NULL`. | [allow-none] |
Types and Values
----------------
### struct GtkListStore
```
struct GtkListStore;
```
See Also
--------
[GtkTreeModel](gtktreemodel#GtkTreeModel-struct), [GtkTreeStore](gtktreestore#GtkTreeStore-struct)
| programming_docs |
gtk GtkDropTarget GtkDropTarget
=============
GtkDropTarget — Event controller to receive DND drops
Functions
---------
| | |
| --- | --- |
| [GtkDropTarget](gtkdroptarget#GtkDropTarget-struct) \* | [gtk\_drop\_target\_new](gtkdroptarget#gtk-drop-target-new) () |
| void | [gtk\_drop\_target\_set\_gtypes](gtkdroptarget#gtk-drop-target-set-gtypes) () |
| const GType \* | [gtk\_drop\_target\_get\_gtypes](gtkdroptarget#gtk-drop-target-get-gtypes) () |
| [GdkContentFormats](https://developer-old.gnome.org/gtk4/html/gdk4-Content-Formats.html#GdkContentFormats-struct) \* | [gtk\_drop\_target\_get\_formats](gtkdroptarget#gtk-drop-target-get-formats) () |
| void | [gtk\_drop\_target\_set\_actions](gtkdroptarget#gtk-drop-target-set-actions) () |
| [GdkDragAction](https://developer-old.gnome.org/gtk4/html/gdk4-Drag-and-Drop.html#GdkDragAction) | [gtk\_drop\_target\_get\_actions](gtkdroptarget#gtk-drop-target-get-actions) () |
| void | [gtk\_drop\_target\_set\_preload](gtkdroptarget#gtk-drop-target-set-preload) () |
| gboolean | [gtk\_drop\_target\_get\_preload](gtkdroptarget#gtk-drop-target-get-preload) () |
| [GdkDrop](https://developer-old.gnome.org/gtk4/html/gdk4-Drag-and-Drop.html#GdkDrop-struct) \* | [gtk\_drop\_target\_get\_drop](gtkdroptarget#gtk-drop-target-get-drop) () |
| const GValue \* | [gtk\_drop\_target\_get\_value](gtkdroptarget#gtk-drop-target-get-value) () |
| void | [gtk\_drop\_target\_reject](gtkdroptarget#gtk-drop-target-reject) () |
Properties
----------
| | | |
| --- | --- | --- |
| [GdkDragAction](https://developer-old.gnome.org/gtk4/html/gdk4-Drag-and-Drop.html#GdkDragAction) | [actions](gtkdroptarget#GtkDropTarget--actions) | Read / Write |
| [GdkDrop](https://developer-old.gnome.org/gtk4/html/gdk4-Drag-and-Drop.html#GdkDrop-struct) \* | [drop](gtkdroptarget#GtkDropTarget--drop) | Read |
| [GdkContentFormats](https://developer-old.gnome.org/gtk4/html/gdk4-Content-Formats.html#GdkContentFormats-struct) \* | [formats](gtkdroptarget#GtkDropTarget--formats) | Read |
| gboolean | [preload](gtkdroptarget#GtkDropTarget--preload) | Read / Write |
| GValue \* | [value](gtkdroptarget#GtkDropTarget--value) | Read |
Signals
-------
| | | |
| --- | --- | --- |
| gboolean | [accept](gtkdroptarget#GtkDropTarget-accept) | Run Last |
| gboolean | [drop](gtkdroptarget#GtkDropTarget-drop) | Run Last |
| [GdkDragAction](https://developer-old.gnome.org/gtk4/html/gdk4-Drag-and-Drop.html#GdkDragAction) | [enter](gtkdroptarget#GtkDropTarget-enter) | Run Last |
| void | [leave](gtkdroptarget#GtkDropTarget-leave) | Run Last |
| [GdkDragAction](https://developer-old.gnome.org/gtk4/html/gdk4-Drag-and-Drop.html#GdkDragAction) | [motion](gtkdroptarget#GtkDropTarget-motion) | Run Last |
Types and Values
----------------
| | |
| --- | --- |
| | [GtkDropTarget](gtkdroptarget#GtkDropTarget-struct) |
Object Hierarchy
----------------
```
GObject
╰── [GtkEventController](gtkeventcontroller#GtkEventController-struct)
╰── GtkDropTarget
```
Includes
--------
```
#include <gtk/gtk.h>
```
Description
-----------
GtkDropTarget is an event controller implementing a simple way to receive Drag-and-Drop operations.
The most basic way to use a [GtkDropTarget](gtkdroptarget#GtkDropTarget-struct) to receive drops on a widget is to create it via [`gtk_drop_target_new()`](gtkdroptarget#gtk-drop-target-new) passing in the GType of the data you want to receive and connect to the [“drop”](gtkdroptarget#GtkDropTarget-drop) signal to receive the data:
```
static gboolean
on_drop (GtkDropTarget *target,
const GValue *value,
double x,
double y,
gpointer data)
{
MyWidget *self = data;
// Call the appropriate setter depending on the type of data
// that we received
if (G_VALUE_HOLDS (value, G_TYPE_FILE))
my_widget_set_file (self, g_value_get_object (value));
else if (G_VALUE_HOLDS (value, GDK_TYPE_PIXBUF))
my_widget_set_pixbuf (self, g_value_get_object (value));
else
return FALSE;
return TRUE;
}
static void
my_widget_init (MyWidget *self)
{
GtkDropTarget *target =
gtk_drop_target_new (G_TYPE_INVALID, GDK_ACTION_COPY);
// This widget accepts two types of drop types: GFile objects
// and GdkPixbuf objects
gtk_drop_target_set_gtypes (target, (GTypes [2]) {
G_TYPE_FILE,
GDK_TYPE_PIXBUF,
}, 2);
gtk_widget_add_controller (GTK_WIDGET (self), GTK_EVENT_CONTROLLER (target));
}
```
| [GtkDropTarget](gtkdroptarget#GtkDropTarget-struct) supports more options, such as:
* rejecting potential drops via the [“accept”](gtkdroptarget#GtkDropTarget-accept) signal and the [`gtk_drop_target_reject()`](gtkdroptarget#gtk-drop-target-reject) function to let other drop targets handle the drop
* tracking an ongoing drag operation before the drop via the [“enter”](gtkdroptarget#GtkDropTarget-enter), [“motion”](gtkdroptarget#GtkDropTarget-motion) and [“leave”](gtkdroptarget#GtkDropTarget-leave) signals
* configuring how to receive data by setting the [“preload”](gtkdroptarget#GtkDropTarget--preload) property and listening for its availability via the [“value”](gtkdroptarget#GtkDropTarget--value) property
However, [GtkDropTarget](gtkdroptarget#GtkDropTarget-struct) is ultimately modeled in a synchronous way and only supports data transferred via GType. If you want full control over an ongoing drop, the [GtkDropTargetAsync](gtkdroptargetasync#GtkDropTargetAsync-struct) object gives you this ability.
While a pointer is dragged over the drop target's widget and the drop has not been rejected, that widget will receive the [`GTK_STATE_FLAG_DROP_ACTIVE`](gtk4-standard-enumerations#GTK-STATE-FLAG-DROP-ACTIVE:CAPS) state, which can be used to style the widget.
Functions
---------
### gtk\_drop\_target\_new ()
```
[GtkDropTarget](gtkdroptarget#GtkDropTarget-struct) *
gtk_drop_target_new (*`GType type`*,
*`[GdkDragAction](https://developer-old.gnome.org/gtk4/html/gdk4-Drag-and-Drop.html#GdkDragAction) actions`*);
```
Creates a new [GtkDropTarget](gtkdroptarget#GtkDropTarget-struct) object.
If the drop target should support more than 1 type, pass `G_TYPE_INVALID` for *`type`* and then call [`gtk_drop_target_set_gtypes()`](gtkdroptarget#gtk-drop-target-set-gtypes).
#### Parameters
| | | |
| --- | --- | --- |
| type | The supported type or `G_TYPE_INVALID` | |
| actions | the supported actions | |
#### Returns
the new [GtkDropTarget](gtkdroptarget#GtkDropTarget-struct)
### gtk\_drop\_target\_set\_gtypes ()
```
void
gtk_drop_target_set_gtypes (*`[GtkDropTarget](gtkdroptarget#GtkDropTarget-struct) *self`*,
*`GType *types`*,
*`gsize n_types`*);
```
Sets the supported GTypes for this drop target.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkDropTarget](gtkdroptarget#GtkDropTarget-struct) | |
| types | all supported GTypes that can be dropped. | [nullable][transfer none][array length=n\_types] |
| n\_types | number of *`types`* | |
### gtk\_drop\_target\_get\_gtypes ()
```
const GType *
gtk_drop_target_get_gtypes (*`[GtkDropTarget](gtkdroptarget#GtkDropTarget-struct) *self`*,
*`gsize *n_types`*);
```
Gets the list of supported GTypes for *`self`* . If no type have been set, `NULL` will be returned.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkDropTarget](gtkdroptarget#GtkDropTarget-struct) | |
| n\_types | optional pointer to take the number of GTypes contained in the return value. | [out][optional] |
#### Returns
`G_TYPE_INVALID`-terminated array of types included in *`formats`* or `NULL` if none.
[transfer none][nullable][array length=n\_types]
### gtk\_drop\_target\_get\_formats ()
```
[GdkContentFormats](https://developer-old.gnome.org/gtk4/html/gdk4-Content-Formats.html#GdkContentFormats-struct) *
gtk_drop_target_get_formats (*`[GtkDropTarget](gtkdroptarget#GtkDropTarget-struct) *self`*);
```
Gets the data formats that this drop target accepts.
If the result is `NULL`, all formats are expected to be supported.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkDropTarget](gtkdroptarget#GtkDropTarget-struct) | |
#### Returns
the supported data formats.
[nullable]
### gtk\_drop\_target\_set\_actions ()
```
void
gtk_drop_target_set_actions (*`[GtkDropTarget](gtkdroptarget#GtkDropTarget-struct) *self`*,
*`[GdkDragAction](https://developer-old.gnome.org/gtk4/html/gdk4-Drag-and-Drop.html#GdkDragAction) actions`*);
```
Sets the actions that this drop target supports.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkDropTarget](gtkdroptarget#GtkDropTarget-struct) | |
| actions | the supported actions | |
### gtk\_drop\_target\_get\_actions ()
```
[GdkDragAction](https://developer-old.gnome.org/gtk4/html/gdk4-Drag-and-Drop.html#GdkDragAction)
gtk_drop_target_get_actions (*`[GtkDropTarget](gtkdroptarget#GtkDropTarget-struct) *self`*);
```
Gets the actions that this drop target supports.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkDropTarget](gtkdroptarget#GtkDropTarget-struct) | |
#### Returns
the actions that this drop target supports
### gtk\_drop\_target\_set\_preload ()
```
void
gtk_drop_target_set_preload (*`[GtkDropTarget](gtkdroptarget#GtkDropTarget-struct) *self`*,
*`gboolean preload`*);
```
Sets the GtkDropTarget:preload property.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkDropTarget](gtkdroptarget#GtkDropTarget-struct) | |
| preload | `TRUE` to preload drop data | |
### gtk\_drop\_target\_get\_preload ()
```
gboolean
gtk_drop_target_get_preload (*`[GtkDropTarget](gtkdroptarget#GtkDropTarget-struct) *self`*);
```
Gets the value of the GtkDropTarget:preload property.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkDropTarget](gtkdroptarget#GtkDropTarget-struct) | |
#### Returns
`TRUE` if drop data should be preloaded
### gtk\_drop\_target\_get\_drop ()
```
[GdkDrop](https://developer-old.gnome.org/gtk4/html/gdk4-Drag-and-Drop.html#GdkDrop-struct) *
gtk_drop_target_get_drop (*`[GtkDropTarget](gtkdroptarget#GtkDropTarget-struct) *self`*);
```
Gets the currently handled drop operation.
If no drop operation is going on, `NULL` is returned.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkDropTarget](gtkdroptarget#GtkDropTarget-struct) | |
#### Returns
The current drop.
[nullable][transfer none]
### gtk\_drop\_target\_get\_value ()
```
const GValue *
gtk_drop_target_get_value (*`[GtkDropTarget](gtkdroptarget#GtkDropTarget-struct) *self`*);
```
Gets the value of the GtkDropTarget:value property.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkDropTarget](gtkdroptarget#GtkDropTarget-struct) | |
#### Returns
The current drop data.
[nullable][transfer none]
### gtk\_drop\_target\_reject ()
```
void
gtk_drop_target_reject (*`[GtkDropTarget](gtkdroptarget#GtkDropTarget-struct) *self`*);
```
Rejects the ongoing drop operation.
If no drop operation is ongoing - when GdkDropTarget:drop returns `NULL` - this function does nothing.
This function should be used when delaying the decision on whether to accept a drag or not until after reading the data.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkDropTarget](gtkdroptarget#GtkDropTarget-struct) | |
Types and Values
----------------
### GtkDropTarget
```
typedef struct _GtkDropTarget GtkDropTarget;
```
Property Details
----------------
### The `“actions”` property
```
“actions” [GdkDragAction](https://developer-old.gnome.org/gtk4/html/gdk4-Drag-and-Drop.html#GdkDragAction)
```
The [GdkDragActions](https://developer-old.gnome.org/gtk4/html/gdk4-Drag-and-Drop.html#GdkDragAction) that this drop target supports
Owner: GtkDropTarget
Flags: Read / Write
### The `“drop”` property
```
“drop” [GdkDrop](https://developer-old.gnome.org/gtk4/html/gdk4-Drag-and-Drop.html#GdkDrop-struct) *
```
The [GdkDrop](https://developer-old.gnome.org/gtk4/html/gdk4-Drag-and-Drop.html#GdkDrop-struct) that is currently being performed
Owner: GtkDropTarget
Flags: Read
### The `“formats”` property
```
“formats” [GdkContentFormats](https://developer-old.gnome.org/gtk4/html/gdk4-Content-Formats.html#GdkContentFormats-struct) *
```
The [GdkContentFormats](https://developer-old.gnome.org/gtk4/html/gdk4-Content-Formats.html#GdkContentFormats-struct) that determine the supported data formats
Owner: GtkDropTarget
Flags: Read
### The `“preload”` property
```
“preload” gboolean
```
Whether the drop data should be preloaded when the pointer is only hovering over the widget but has not been released.
Setting this property allows finer grained reaction to an ongoing drop at the cost of loading more data.
The default value for this property is `FALSE` to avoid downloading huge amounts of data by accident. For example, if somebody drags a full document of gigabytes of text from a text editor across a widget with a preloading drop target, this data will be downloaded, even if the data is ultimately dropped elsewhere.
For a lot of data formats, the amount of data is very small (like `GDK_TYPE_RGBA`), so enabling this property does not hurt at all. And for local-only drag'n'drop operations, no data transfer is done, so enabling it there is free.
Owner: GtkDropTarget
Flags: Read / Write
Default value: FALSE
### The `“value”` property
```
“value” GValue *
```
The value for this drop operation or `NULL` if the data has not been loaded yet or no drop operation is going on.
Data may be available before the [“drop”](gtkdroptarget#GtkDropTarget-drop) signal gets emitted - for example when the [“preload”](gtkdroptarget#GtkDropTarget--preload) property is set. You can use the “notify” signal to be notified of available data.
Owner: GtkDropTarget
Flags: Read
Signal Details
--------------
### The `“accept”` signal
```
gboolean
user_function ([GtkDropTarget](gtkdroptarget#GtkDropTarget-struct) *self,
[GdkDrop](https://developer-old.gnome.org/gtk4/html/gdk4-Drag-and-Drop.html#GdkDrop-struct) *drop,
gpointer user_data)
```
The ::accept signal is emitted on the drop site when a drop operation is about to begin. If the drop is not accepted, `FALSE` will be returned and the drop target will ignore the drop. If `TRUE` is returned, the drop is accepted for now but may be rejected later via a call to [`gtk_drop_target_reject()`](gtkdroptarget#gtk-drop-target-reject) or ultimately by returning `FALSE` from [“drop”](gtkdroptarget#GtkDropTarget-drop).
The default handler for this signal decides whether to accept the drop based on the formats provided by the *`drop`* .
If the decision whether the drop will be accepted or rejected depends on the data, this function should return `TRUE`, the [“preload”](gtkdroptarget#GtkDropTarget--preload) property should be set and the value should be inspected via the “value” signal, calling [`gtk_drop_target_reject()`](gtkdroptarget#gtk-drop-target-reject) if required.
#### Parameters
| | | |
| --- | --- | --- |
| self | the [GtkDropTarget](gtkdroptarget#GtkDropTarget-struct) | |
| drop | the [GdkDrop](https://developer-old.gnome.org/gtk4/html/gdk4-Drag-and-Drop.html#GdkDrop-struct) | |
| user\_data | user data set when the signal handler was connected. | |
#### Returns
`TRUE` if *`drop`* is accepted
Flags: Run Last
### The `“drop”` signal
```
gboolean
user_function ([GtkDropTarget](gtkdroptarget#GtkDropTarget-struct) *self,
GValue *value,
double x,
double y,
gpointer user_data)
```
The ::drop signal is emitted on the drop site when the user drops the data onto the widget. The signal handler must determine whether the pointer position is in a drop zone or not. If it is not in a drop zone, it returns `FALSE` and no further processing is necessary.
Otherwise, the handler returns `TRUE`. In this case, this handler will accept the drop. The handler is responsible for rading the given *`value`* and performing the drop operation.
#### Parameters
| | | |
| --- | --- | --- |
| self | the [GtkDropTarget](gtkdroptarget#GtkDropTarget-struct) | |
| value | the GValue being dropped | |
| x | the x coordinate of the current pointer position | |
| y | the y coordinate of the current pointer position | |
| user\_data | user data set when the signal handler was connected. | |
#### Returns
whether the drop was accepted at the given pointer position
Flags: Run Last
### The `“enter”` signal
```
[GdkDragAction](https://developer-old.gnome.org/gtk4/html/gdk4-Drag-and-Drop.html#GdkDragAction)
user_function ([GtkDropTarget](gtkdroptarget#GtkDropTarget-struct) *self,
double x,
double y,
gpointer user_data)
```
The ::enter signal is emitted on the drop site when the pointer enters the widget. It can be used to set up custom highlighting.
#### Parameters
| | | |
| --- | --- | --- |
| self | the [GtkDropTarget](gtkdroptarget#GtkDropTarget-struct) | |
| x | the x coordinate of the current pointer position | |
| y | the y coordinate of the current pointer position | |
| user\_data | user data set when the signal handler was connected. | |
#### Returns
Preferred action for this drag operation or 0 if dropping is not supported at the current *`x`* ,*`y`* location.
Flags: Run Last
### The `“leave”` signal
```
void
user_function ([GtkDropTarget](gtkdroptarget#GtkDropTarget-struct) *self,
gpointer user_data)
```
The ::leave signal is emitted on the drop site when the pointer leaves the widget. Its main purpose it to undo things done in [“enter”](gtkdroptarget#GtkDropTarget-enter).
#### Parameters
| | | |
| --- | --- | --- |
| self | the [GtkDropTarget](gtkdroptarget#GtkDropTarget-struct) | |
| user\_data | user data set when the signal handler was connected. | |
Flags: Run Last
### The `“motion”` signal
```
[GdkDragAction](https://developer-old.gnome.org/gtk4/html/gdk4-Drag-and-Drop.html#GdkDragAction)
user_function ([GtkDropTarget](gtkdroptarget#GtkDropTarget-struct) *self,
double x,
double y,
gpointer user_data)
```
The ::motion signal is emitted while the pointer is moving over the drop target.
#### Parameters
| | | |
| --- | --- | --- |
| self | the [GtkDropTarget](gtkdroptarget#GtkDropTarget-struct) | |
| x | the x coordinate of the current pointer position | |
| y | the y coordinate of the current pointer position | |
| user\_data | user data set when the signal handler was connected. | |
#### Returns
Preferred action for this drag operation or 0 if dropping is not supported at the current *`x`* ,*`y`* location.
Flags: Run Last
See Also
--------
[GdkDrop](https://developer-old.gnome.org/gtk4/html/gdk4-Drag-and-Drop.html#GdkDrop-struct), [GtkDropTargetAsync](gtkdroptargetasync#GtkDropTargetAsync-struct)
gtk GtkGestureSwipe GtkGestureSwipe
===============
GtkGestureSwipe — Swipe gesture
Functions
---------
| | |
| --- | --- |
| [GtkGesture](gtkgesture#GtkGesture-struct) \* | [gtk\_gesture\_swipe\_new](gtkgestureswipe#gtk-gesture-swipe-new) () |
| gboolean | [gtk\_gesture\_swipe\_get\_velocity](gtkgestureswipe#gtk-gesture-swipe-get-velocity) () |
Signals
-------
| | | |
| --- | --- | --- |
| void | [swipe](gtkgestureswipe#GtkGestureSwipe-swipe) | Run Last |
Types and Values
----------------
| | |
| --- | --- |
| | [GtkGestureSwipe](gtkgestureswipe#GtkGestureSwipe-struct) |
Object Hierarchy
----------------
```
GObject
╰── [GtkEventController](gtkeventcontroller#GtkEventController-struct)
╰── [GtkGesture](gtkgesture#GtkGesture-struct)
╰── [GtkGestureSingle](gtkgesturesingle#GtkGestureSingle-struct)
╰── GtkGestureSwipe
```
Includes
--------
```
#include <gtk/gtk.h>
```
Description
-----------
[GtkGestureSwipe](gtkgestureswipe#GtkGestureSwipe-struct) is a [GtkGesture](gtkgesture#GtkGesture-struct) implementation able to recognize swipes, after a press/move/.../move/release sequence happens, the [“swipe”](gtkgestureswipe#GtkGestureSwipe-swipe) signal will be emitted, providing the velocity and directionality of the sequence at the time it was lifted.
If the velocity is desired in intermediate points, [`gtk_gesture_swipe_get_velocity()`](gtkgestureswipe#gtk-gesture-swipe-get-velocity) can be called on eg. a [“update”](gtkgesture#GtkGesture-update) handler.
All velocities are reported in pixels/sec units.
Functions
---------
### gtk\_gesture\_swipe\_new ()
```
[GtkGesture](gtkgesture#GtkGesture-struct) *
gtk_gesture_swipe_new (*`void`*);
```
Returns a newly created [GtkGesture](gtkgesture#GtkGesture-struct) that recognizes swipes.
#### Returns
a newly created [GtkGestureSwipe](gtkgestureswipe#GtkGestureSwipe-struct)
### gtk\_gesture\_swipe\_get\_velocity ()
```
gboolean
gtk_gesture_swipe_get_velocity (*`[GtkGestureSwipe](gtkgestureswipe#GtkGestureSwipe-struct) *gesture`*,
*`double *velocity_x`*,
*`double *velocity_y`*);
```
If the gesture is recognized, this function returns `TRUE` and fill in *`velocity_x`* and *`velocity_y`* with the recorded velocity, as per the last event(s) processed.
#### Parameters
| | | |
| --- | --- | --- |
| gesture | a [GtkGestureSwipe](gtkgestureswipe#GtkGestureSwipe-struct) | |
| velocity\_x | return value for the velocity in the X axis, in pixels/sec. | [out] |
| velocity\_y | return value for the velocity in the Y axis, in pixels/sec. | [out] |
#### Returns
whether velocity could be calculated
Types and Values
----------------
### GtkGestureSwipe
```
typedef struct _GtkGestureSwipe GtkGestureSwipe;
```
Signal Details
--------------
### The `“swipe”` signal
```
void
user_function ([GtkGestureSwipe](gtkgestureswipe#GtkGestureSwipe-struct) *gesture,
double velocity_x,
double velocity_y,
gpointer user_data)
```
This signal is emitted when the recognized gesture is finished, velocity and direction are a product of previously recorded events.
#### Parameters
| | | |
| --- | --- | --- |
| gesture | object which received the signal | |
| velocity\_x | velocity in the X axis, in pixels/sec | |
| velocity\_y | velocity in the Y axis, in pixels/sec | |
| user\_data | user data set when the signal handler was connected. | |
Flags: Run Last
| programming_docs |
gtk GtkShortcutLabel GtkShortcutLabel
================
GtkShortcutLabel — Displays a keyboard shortcut
Functions
---------
| | |
| --- | --- |
| [GtkWidget](gtkwidget#GtkWidget-struct) \* | [gtk\_shortcut\_label\_new](gtkshortcutlabel#gtk-shortcut-label-new) () |
| const char \* | [gtk\_shortcut\_label\_get\_accelerator](gtkshortcutlabel#gtk-shortcut-label-get-accelerator) () |
| void | [gtk\_shortcut\_label\_set\_accelerator](gtkshortcutlabel#gtk-shortcut-label-set-accelerator) () |
| const char \* | [gtk\_shortcut\_label\_get\_disabled\_text](gtkshortcutlabel#gtk-shortcut-label-get-disabled-text) () |
| void | [gtk\_shortcut\_label\_set\_disabled\_text](gtkshortcutlabel#gtk-shortcut-label-set-disabled-text) () |
Properties
----------
| | | |
| --- | --- | --- |
| char \* | [accelerator](gtkshortcutlabel#GtkShortcutLabel--accelerator) | Read / Write |
| char \* | [disabled-text](gtkshortcutlabel#GtkShortcutLabel--disabled-text) | Read / Write |
Types and Values
----------------
| | |
| --- | --- |
| | [GtkShortcutLabel](gtkshortcutlabel#GtkShortcutLabel-struct) |
Object Hierarchy
----------------
```
GObject
╰── GInitiallyUnowned
╰── [GtkWidget](gtkwidget#GtkWidget-struct)
╰── GtkShortcutLabel
```
Implemented Interfaces
----------------------
GtkShortcutLabel implements [GtkAccessible](gtkaccessible#GtkAccessible-struct), [GtkBuildable](gtkbuildable#GtkBuildable-struct) and [GtkConstraintTarget](gtkconstraint#GtkConstraintTarget-struct).
Includes
--------
```
#include <gtk/gtk.h>
```
Description
-----------
[GtkShortcutLabel](gtkshortcutlabel#GtkShortcutLabel-struct) is a widget that represents a single keyboard shortcut or gesture in the user interface.
Functions
---------
### gtk\_shortcut\_label\_new ()
```
[GtkWidget](gtkwidget#GtkWidget-struct) *
gtk_shortcut_label_new (*`const char *accelerator`*);
```
Creates a new [GtkShortcutLabel](gtkshortcutlabel#GtkShortcutLabel-struct) with *`accelerator`* set.
#### Parameters
| | | |
| --- | --- | --- |
| accelerator | the initial accelerator | |
#### Returns
a newly-allocated [GtkShortcutLabel](gtkshortcutlabel#GtkShortcutLabel-struct).
[transfer full]
### gtk\_shortcut\_label\_get\_accelerator ()
```
const char *
gtk_shortcut_label_get_accelerator (*`[GtkShortcutLabel](gtkshortcutlabel#GtkShortcutLabel-struct) *self`*);
```
Retrieves the current accelerator of *`self`* .
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkShortcutLabel](gtkshortcutlabel#GtkShortcutLabel-struct) | |
#### Returns
the current accelerator.
[transfer none][nullable]
### gtk\_shortcut\_label\_set\_accelerator ()
```
void
gtk_shortcut_label_set_accelerator (*`[GtkShortcutLabel](gtkshortcutlabel#GtkShortcutLabel-struct) *self`*,
*`const char *accelerator`*);
```
Sets the accelerator to be displayed by *`self`* .
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkShortcutLabel](gtkshortcutlabel#GtkShortcutLabel-struct) | |
| accelerator | the new accelerator | |
### gtk\_shortcut\_label\_get\_disabled\_text ()
```
const char *
gtk_shortcut_label_get_disabled_text (*`[GtkShortcutLabel](gtkshortcutlabel#GtkShortcutLabel-struct) *self`*);
```
Retrieves the text that is displayed when no accelerator is set.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkShortcutLabel](gtkshortcutlabel#GtkShortcutLabel-struct) | |
#### Returns
the current text displayed when no accelerator is set.
[transfer none][nullable]
### gtk\_shortcut\_label\_set\_disabled\_text ()
```
void
gtk_shortcut_label_set_disabled_text (*`[GtkShortcutLabel](gtkshortcutlabel#GtkShortcutLabel-struct) *self`*,
*`const char *disabled_text`*);
```
Sets the text to be displayed by *`self`* when no accelerator is set.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkShortcutLabel](gtkshortcutlabel#GtkShortcutLabel-struct) | |
| disabled\_text | the text to be displayed when no accelerator is set | |
Types and Values
----------------
### GtkShortcutLabel
```
typedef struct _GtkShortcutLabel GtkShortcutLabel;
```
Property Details
----------------
### The `“accelerator”` property
```
“accelerator” char *
```
The accelerator that *`self`* displays. See [“accelerator”](gtkshortcutsshortcut#GtkShortcutsShortcut--accelerator) for the accepted syntax.
Owner: GtkShortcutLabel
Flags: Read / Write
Default value: NULL
### The `“disabled-text”` property
```
“disabled-text” char *
```
The text that is displayed when no accelerator is set.
Owner: GtkShortcutLabel
Flags: Read / Write
Default value: NULL
See Also
--------
[GtkCellRendererAccel](gtkcellrendereraccel#GtkCellRendererAccel-struct)
gtk GtkCellView GtkCellView
===========
GtkCellView — A widget displaying a single row of a GtkTreeModel
Functions
---------
| | |
| --- | --- |
| [GtkWidget](gtkwidget#GtkWidget-struct) \* | [gtk\_cell\_view\_new](gtkcellview#gtk-cell-view-new) () |
| [GtkWidget](gtkwidget#GtkWidget-struct) \* | [gtk\_cell\_view\_new\_with\_context](gtkcellview#gtk-cell-view-new-with-context) () |
| [GtkWidget](gtkwidget#GtkWidget-struct) \* | [gtk\_cell\_view\_new\_with\_text](gtkcellview#gtk-cell-view-new-with-text) () |
| [GtkWidget](gtkwidget#GtkWidget-struct) \* | [gtk\_cell\_view\_new\_with\_markup](gtkcellview#gtk-cell-view-new-with-markup) () |
| [GtkWidget](gtkwidget#GtkWidget-struct) \* | [gtk\_cell\_view\_new\_with\_texture](gtkcellview#gtk-cell-view-new-with-texture) () |
| void | [gtk\_cell\_view\_set\_model](gtkcellview#gtk-cell-view-set-model) () |
| [GtkTreeModel](gtktreemodel#GtkTreeModel-struct) \* | [gtk\_cell\_view\_get\_model](gtkcellview#gtk-cell-view-get-model) () |
| void | [gtk\_cell\_view\_set\_displayed\_row](gtkcellview#gtk-cell-view-set-displayed-row) () |
| [GtkTreePath](gtktreemodel#GtkTreePath-struct) \* | [gtk\_cell\_view\_get\_displayed\_row](gtkcellview#gtk-cell-view-get-displayed-row) () |
| void | [gtk\_cell\_view\_set\_draw\_sensitive](gtkcellview#gtk-cell-view-set-draw-sensitive) () |
| gboolean | [gtk\_cell\_view\_get\_draw\_sensitive](gtkcellview#gtk-cell-view-get-draw-sensitive) () |
| void | [gtk\_cell\_view\_set\_fit\_model](gtkcellview#gtk-cell-view-set-fit-model) () |
| gboolean | [gtk\_cell\_view\_get\_fit\_model](gtkcellview#gtk-cell-view-get-fit-model) () |
Properties
----------
| | | |
| --- | --- | --- |
| [GtkCellArea](gtkcellarea#GtkCellArea-struct) \* | [cell-area](gtkcellview#GtkCellView--cell-area) | Read / Write / Construct Only |
| [GtkCellAreaContext](gtkcellareacontext#GtkCellAreaContext-struct) \* | [cell-area-context](gtkcellview#GtkCellView--cell-area-context) | Read / Write / Construct Only |
| gboolean | [draw-sensitive](gtkcellview#GtkCellView--draw-sensitive) | Read / Write |
| gboolean | [fit-model](gtkcellview#GtkCellView--fit-model) | Read / Write |
| [GtkTreeModel](gtktreemodel#GtkTreeModel-struct) \* | [model](gtkcellview#GtkCellView--model) | Read / Write |
Types and Values
----------------
| | |
| --- | --- |
| | [GtkCellView](gtkcellview#GtkCellView-struct) |
Object Hierarchy
----------------
```
GObject
╰── GInitiallyUnowned
╰── [GtkWidget](gtkwidget#GtkWidget-struct)
╰── GtkCellView
```
Implemented Interfaces
----------------------
GtkCellView implements [GtkAccessible](gtkaccessible#GtkAccessible-struct), [GtkBuildable](gtkbuildable#GtkBuildable-struct), [GtkConstraintTarget](gtkconstraint#GtkConstraintTarget-struct), [GtkCellLayout](gtkcelllayout#GtkCellLayout-struct) and [GtkOrientable](gtk4-orientable#GtkOrientable-struct).
Includes
--------
```
#include <gtk/gtk.h>
```
Description
-----------
A [GtkCellView](gtkcellview#GtkCellView-struct) displays a single row of a [GtkTreeModel](gtktreemodel#GtkTreeModel-struct) using a [GtkCellArea](gtkcellarea#GtkCellArea-struct) and [GtkCellAreaContext](gtkcellareacontext#GtkCellAreaContext-struct). A [GtkCellAreaContext](gtkcellareacontext#GtkCellAreaContext-struct) can be provided to the [GtkCellView](gtkcellview#GtkCellView-struct) at construction time in order to keep the cellview in context of a group of cell views, this ensures that the renderers displayed will be properly aligned with each other (like the aligned cells in the menus of [GtkComboBox](gtkcombobox#GtkComboBox-struct)).
[GtkCellView](gtkcellview#GtkCellView-struct) is [GtkOrientable](gtk4-orientable#GtkOrientable-struct) in order to decide in which orientation the underlying [GtkCellAreaContext](gtkcellareacontext#GtkCellAreaContext-struct) should be allocated. Taking the [GtkComboBox](gtkcombobox#GtkComboBox-struct) menu as an example, cellviews should be oriented horizontally if the menus are listed top-to-bottom and thus all share the same width but may have separate individual heights (left-to-right menus should be allocated vertically since they all share the same height but may have variable widths).
### CSS nodes
GtkCellView has a single CSS node with name cellview.
Functions
---------
### gtk\_cell\_view\_new ()
```
[GtkWidget](gtkwidget#GtkWidget-struct) *
gtk_cell_view_new (*`void`*);
```
Creates a new [GtkCellView](gtkcellview#GtkCellView-struct) widget.
#### Returns
A newly created [GtkCellView](gtkcellview#GtkCellView-struct) widget.
### gtk\_cell\_view\_new\_with\_context ()
```
[GtkWidget](gtkwidget#GtkWidget-struct) *
gtk_cell_view_new_with_context (*`[GtkCellArea](gtkcellarea#GtkCellArea-struct) *area`*,
*`[GtkCellAreaContext](gtkcellareacontext#GtkCellAreaContext-struct) *context`*);
```
Creates a new [GtkCellView](gtkcellview#GtkCellView-struct) widget with a specific [GtkCellArea](gtkcellarea#GtkCellArea-struct) to layout cells and a specific [GtkCellAreaContext](gtkcellareacontext#GtkCellAreaContext-struct).
Specifying the same context for a handful of cells lets the underlying area synchronize the geometry for those cells, in this way alignments with cellviews for other rows are possible.
#### Parameters
| | | |
| --- | --- | --- |
| area | the [GtkCellArea](gtkcellarea#GtkCellArea-struct) to layout cells | |
| context | the [GtkCellAreaContext](gtkcellareacontext#GtkCellAreaContext-struct) in which to calculate cell geometry | |
#### Returns
A newly created [GtkCellView](gtkcellview#GtkCellView-struct) widget.
### gtk\_cell\_view\_new\_with\_text ()
```
[GtkWidget](gtkwidget#GtkWidget-struct) *
gtk_cell_view_new_with_text (*`const char *text`*);
```
Creates a new [GtkCellView](gtkcellview#GtkCellView-struct) widget, adds a [GtkCellRendererText](gtkcellrenderertext#GtkCellRendererText-struct) to it, and makes it show *`text`* .
#### Parameters
| | | |
| --- | --- | --- |
| text | the text to display in the cell view | |
#### Returns
A newly created [GtkCellView](gtkcellview#GtkCellView-struct) widget.
### gtk\_cell\_view\_new\_with\_markup ()
```
[GtkWidget](gtkwidget#GtkWidget-struct) *
gtk_cell_view_new_with_markup (*`const char *markup`*);
```
Creates a new [GtkCellView](gtkcellview#GtkCellView-struct) widget, adds a [GtkCellRendererText](gtkcellrenderertext#GtkCellRendererText-struct) to it, and makes it show *`markup`* . The text can be marked up with the Pango text markup language.
#### Parameters
| | | |
| --- | --- | --- |
| markup | the text to display in the cell view | |
#### Returns
A newly created [GtkCellView](gtkcellview#GtkCellView-struct) widget.
### gtk\_cell\_view\_new\_with\_texture ()
```
[GtkWidget](gtkwidget#GtkWidget-struct) *
gtk_cell_view_new_with_texture (*`[GdkTexture](https://developer-old.gnome.org/gtk4/html/gdk4-Textures.html#GdkTexture-struct) *texture`*);
```
Creates a new [GtkCellView](gtkcellview#GtkCellView-struct) widget, adds a [GtkCellRendererPixbuf](gtkcellrendererpixbuf#GtkCellRendererPixbuf-struct) to it, and makes it show *`texture`* .
#### Parameters
| | | |
| --- | --- | --- |
| texture | the image to display in the cell view | |
#### Returns
A newly created [GtkCellView](gtkcellview#GtkCellView-struct) widget.
### gtk\_cell\_view\_set\_model ()
```
void
gtk_cell_view_set_model (*`[GtkCellView](gtkcellview#GtkCellView-struct) *cell_view`*,
*`[GtkTreeModel](gtktreemodel#GtkTreeModel-struct) *model`*);
```
Sets the model for *`cell_view`* . If *`cell_view`* already has a model set, it will remove it before setting the new model. If *`model`* is `NULL`, then it will unset the old model.
#### Parameters
| | | |
| --- | --- | --- |
| cell\_view | a [GtkCellView](gtkcellview#GtkCellView-struct) | |
| model | a [GtkTreeModel](gtktreemodel#GtkTreeModel-struct). | [allow-none] |
### gtk\_cell\_view\_get\_model ()
```
[GtkTreeModel](gtktreemodel#GtkTreeModel-struct) *
gtk_cell_view_get_model (*`[GtkCellView](gtkcellview#GtkCellView-struct) *cell_view`*);
```
Returns the model for *`cell_view`* . If no model is used `NULL` is returned.
#### Parameters
| | | |
| --- | --- | --- |
| cell\_view | a [GtkCellView](gtkcellview#GtkCellView-struct) | |
#### Returns
a [GtkTreeModel](gtktreemodel#GtkTreeModel-struct) used or `NULL`.
[nullable][transfer none]
### gtk\_cell\_view\_set\_displayed\_row ()
```
void
gtk_cell_view_set_displayed_row (*`[GtkCellView](gtkcellview#GtkCellView-struct) *cell_view`*,
*`[GtkTreePath](gtktreemodel#GtkTreePath-struct) *path`*);
```
Sets the row of the model that is currently displayed by the [GtkCellView](gtkcellview#GtkCellView-struct). If the path is unset, then the contents of the cellview “stick” at their last value; this is not normally a desired result, but may be a needed intermediate state if say, the model for the [GtkCellView](gtkcellview#GtkCellView-struct) becomes temporarily empty.
#### Parameters
| | | |
| --- | --- | --- |
| cell\_view | a [GtkCellView](gtkcellview#GtkCellView-struct) | |
| path | a [GtkTreePath](gtktreemodel#GtkTreePath-struct) or `NULL` to unset. | [allow-none] |
### gtk\_cell\_view\_get\_displayed\_row ()
```
[GtkTreePath](gtktreemodel#GtkTreePath-struct) *
gtk_cell_view_get_displayed_row (*`[GtkCellView](gtkcellview#GtkCellView-struct) *cell_view`*);
```
Returns a [GtkTreePath](gtktreemodel#GtkTreePath-struct) referring to the currently displayed row. If no row is currently displayed, `NULL` is returned.
#### Parameters
| | | |
| --- | --- | --- |
| cell\_view | a [GtkCellView](gtkcellview#GtkCellView-struct) | |
#### Returns
the currently displayed row or `NULL`.
[nullable][transfer full]
### gtk\_cell\_view\_set\_draw\_sensitive ()
```
void
gtk_cell_view_set_draw_sensitive (*`[GtkCellView](gtkcellview#GtkCellView-struct) *cell_view`*,
*`gboolean draw_sensitive`*);
```
Sets whether *`cell_view`* should draw all of its cells in a sensitive state, this is used by [GtkComboBox](gtkcombobox#GtkComboBox-struct) menus to ensure that rows with insensitive cells that contain children appear sensitive in the parent menu item.
#### Parameters
| | | |
| --- | --- | --- |
| cell\_view | a [GtkCellView](gtkcellview#GtkCellView-struct) | |
| draw\_sensitive | whether to draw all cells in a sensitive state. | |
### gtk\_cell\_view\_get\_draw\_sensitive ()
```
gboolean
gtk_cell_view_get_draw_sensitive (*`[GtkCellView](gtkcellview#GtkCellView-struct) *cell_view`*);
```
Gets whether *`cell_view`* is configured to draw all of its cells in a sensitive state.
#### Parameters
| | | |
| --- | --- | --- |
| cell\_view | a [GtkCellView](gtkcellview#GtkCellView-struct) | |
#### Returns
whether *`cell_view`* draws all of its cells in a sensitive state
### gtk\_cell\_view\_set\_fit\_model ()
```
void
gtk_cell_view_set_fit_model (*`[GtkCellView](gtkcellview#GtkCellView-struct) *cell_view`*,
*`gboolean fit_model`*);
```
Sets whether *`cell_view`* should request space to fit the entire [GtkTreeModel](gtktreemodel#GtkTreeModel-struct).
This is used by [GtkComboBox](gtkcombobox#GtkComboBox-struct) to ensure that the cell view displayed on the combo box’s button always gets enough space and does not resize when selection changes.
#### Parameters
| | | |
| --- | --- | --- |
| cell\_view | a [GtkCellView](gtkcellview#GtkCellView-struct) | |
| fit\_model | whether *`cell_view`* should request space for the whole model. | |
### gtk\_cell\_view\_get\_fit\_model ()
```
gboolean
gtk_cell_view_get_fit_model (*`[GtkCellView](gtkcellview#GtkCellView-struct) *cell_view`*);
```
Gets whether *`cell_view`* is configured to request space to fit the entire [GtkTreeModel](gtktreemodel#GtkTreeModel-struct).
#### Parameters
| | | |
| --- | --- | --- |
| cell\_view | a [GtkCellView](gtkcellview#GtkCellView-struct) | |
#### Returns
whether *`cell_view`* requests space to fit the entire [GtkTreeModel](gtktreemodel#GtkTreeModel-struct).
Types and Values
----------------
### GtkCellView
```
typedef struct _GtkCellView GtkCellView;
```
Property Details
----------------
### The `“cell-area”` property
```
“cell-area” [GtkCellArea](gtkcellarea#GtkCellArea-struct) *
```
The [GtkCellArea](gtkcellarea#GtkCellArea-struct) rendering cells
If no area is specified when creating the cell view with [`gtk_cell_view_new_with_context()`](gtkcellview#gtk-cell-view-new-with-context) a horizontally oriented [GtkCellAreaBox](gtkcellareabox#GtkCellAreaBox-struct) will be used.
since 3.0
Owner: GtkCellView
Flags: Read / Write / Construct Only
### The `“cell-area-context”` property
```
“cell-area-context” [GtkCellAreaContext](gtkcellareacontext#GtkCellAreaContext-struct) *
```
The [GtkCellAreaContext](gtkcellareacontext#GtkCellAreaContext-struct) used to compute the geometry of the cell view.
A group of cell views can be assigned the same context in order to ensure the sizes and cell alignments match across all the views with the same context.
[GtkComboBox](gtkcombobox#GtkComboBox-struct) menus uses this to assign the same context to all cell views in the menu items for a single menu (each submenu creates its own context since the size of each submenu does not depend on parent or sibling menus).
since 3.0
Owner: GtkCellView
Flags: Read / Write / Construct Only
### The `“draw-sensitive”` property
```
“draw-sensitive” gboolean
```
Whether all cells should be draw as sensitive for this view regardless of the actual cell properties (used to make menus with submenus appear sensitive when the items in submenus might be insensitive).
since 3.0
Owner: GtkCellView
Flags: Read / Write
Default value: FALSE
### The `“fit-model”` property
```
“fit-model” gboolean
```
Whether the view should request enough space to always fit the size of every row in the model (used by the combo box to ensure the combo box size doesn't change when different items are selected).
since 3.0
Owner: GtkCellView
Flags: Read / Write
Default value: FALSE
### The `“model”` property
```
“model” [GtkTreeModel](gtktreemodel#GtkTreeModel-struct) *
```
The model for cell view
since 2.10
Owner: GtkCellView
Flags: Read / Write
gtk GtkColorChooserWidget GtkColorChooserWidget
=====================
GtkColorChooserWidget — A widget for choosing colors
Functions
---------
| | |
| --- | --- |
| [GtkWidget](gtkwidget#GtkWidget-struct) \* | [gtk\_color\_chooser\_widget\_new](gtkcolorchooserwidget#gtk-color-chooser-widget-new) () |
Properties
----------
| | | |
| --- | --- | --- |
| gboolean | [show-editor](gtkcolorchooserwidget#GtkColorChooserWidget--show-editor) | Read / Write |
Actions
-------
| | | |
| --- | --- | --- |
| | color.customize | (dddd) |
| | color.select | (dddd) |
Types and Values
----------------
| | |
| --- | --- |
| | [GtkColorChooserWidget](gtkcolorchooserwidget#GtkColorChooserWidget-struct) |
Object Hierarchy
----------------
```
GObject
╰── GInitiallyUnowned
╰── [GtkWidget](gtkwidget#GtkWidget-struct)
╰── GtkColorChooserWidget
```
Implemented Interfaces
----------------------
GtkColorChooserWidget implements [GtkAccessible](gtkaccessible#GtkAccessible-struct), [GtkBuildable](gtkbuildable#GtkBuildable-struct), [GtkConstraintTarget](gtkconstraint#GtkConstraintTarget-struct) and [GtkColorChooser](gtkcolorchooser#GtkColorChooser-struct).
Includes
--------
```
#include <gtk/gtk.h>
```
Description
-----------
The [GtkColorChooserWidget](gtkcolorchooserwidget#GtkColorChooserWidget-struct) widget lets the user select a color. By default, the chooser presents a predefined palette of colors, plus a small number of settable custom colors. It is also possible to select a different color with the single-color editor. To enter the single-color editing mode, use the context menu of any color of the palette, or use the '+' button to add a new custom color.
The chooser automatically remembers the last selection, as well as custom colors.
To change the initially selected color, use [`gtk_color_chooser_set_rgba()`](gtkcolorchooser#gtk-color-chooser-set-rgba). To get the selected color use [`gtk_color_chooser_get_rgba()`](gtkcolorchooser#gtk-color-chooser-get-rgba).
The [GtkColorChooserWidget](gtkcolorchooserwidget#GtkColorChooserWidget-struct) is used in the [GtkColorChooserDialog](gtkcolorchooserdialog#GtkColorChooserDialog-struct) to provide a dialog for selecting colors.
### CSS names
GtkColorChooserWidget has a single CSS node with name colorchooser.
Functions
---------
### gtk\_color\_chooser\_widget\_new ()
```
[GtkWidget](gtkwidget#GtkWidget-struct) *
gtk_color_chooser_widget_new (*`void`*);
```
Creates a new [GtkColorChooserWidget](gtkcolorchooserwidget#GtkColorChooserWidget-struct).
#### Returns
a new [GtkColorChooserWidget](gtkcolorchooserwidget#GtkColorChooserWidget-struct)
Types and Values
----------------
### GtkColorChooserWidget
```
typedef struct _GtkColorChooserWidget GtkColorChooserWidget;
```
Property Details
----------------
### The `“show-editor”` property
```
“show-editor” gboolean
```
The ::show-editor property is `TRUE` when the color chooser is showing the single-color editor. It can be set to switch the color chooser into single-color editing mode.
Owner: GtkColorChooserWidget
Flags: Read / Write
Default value: FALSE
Action Details
--------------
### The `“color.customize”` action
Activates the color editor for the given color.
Parameter type: (dddd)
#### Parameters
| | | |
| --- | --- | --- |
| red | the red value, between 0 and 1 | |
| green | the green value, between 0 and 1 | |
| blue | the blue value, between 0 and 1 | |
| alpha | the alpha value, between 0 and 1 | |
### The `“color.select”` action
Emits the [“color-activated”](gtkcolorchooser#GtkColorChooser-color-activated) signal for the given color.
Parameter type: (dddd)
#### Parameters
| | | |
| --- | --- | --- |
| red | the red value, between 0 and 1 | |
| green | the green value, between 0 and 1 | |
| blue | the blue value, between 0 and 1 | |
| alpha | the alpha value, between 0 and 1 | |
See Also
--------
[GtkColorChooserDialog](gtkcolorchooserdialog#GtkColorChooserDialog-struct)
| programming_docs |
gtk GtkNative GtkNative
=========
GtkNative — Interface for widgets having surfaces
Functions
---------
| | |
| --- | --- |
| [GtkNative](gtknative#GtkNative-struct) \* | [gtk\_native\_get\_for\_surface](gtknative#gtk-native-get-for-surface) () |
| [GdkSurface](https://developer-old.gnome.org/gtk4/html/GdkSurface.html#GdkSurface-struct) \* | [gtk\_native\_get\_surface](gtknative#gtk-native-get-surface) () |
| [GskRenderer](https://developer-old.gnome.org/gtk4/html/GskRenderer.html#GskRenderer-struct) \* | [gtk\_native\_get\_renderer](gtknative#gtk-native-get-renderer) () |
| void | [gtk\_native\_get\_surface\_transform](gtknative#gtk-native-get-surface-transform) () |
| void | [gtk\_native\_realize](gtknative#gtk-native-realize) () |
| void | [gtk\_native\_unrealize](gtknative#gtk-native-unrealize) () |
Types and Values
----------------
| | |
| --- | --- |
| | [GtkNative](gtknative#GtkNative-struct) |
Object Hierarchy
----------------
```
[GInterface](https://developer-old.gnome.org/gobject/stable/GTypeModule.html)
╰── GtkNative
```
Prerequisites
-------------
GtkNative requires [GtkWidget](gtkwidget#GtkWidget-struct).
Known Derived Interfaces
------------------------
GtkNative is required by [GtkRoot](gtkroot#GtkRoot-struct).
Known Implementations
---------------------
GtkNative is implemented by [GtkAboutDialog](gtkaboutdialog#GtkAboutDialog-struct), [GtkAppChooserDialog](gtkappchooserdialog#GtkAppChooserDialog-struct), [GtkApplicationWindow](gtkapplicationwindow#GtkApplicationWindow-struct), [GtkAssistant](gtkassistant#GtkAssistant-struct), [GtkColorChooserDialog](gtkcolorchooserdialog#GtkColorChooserDialog-struct), [GtkDialog](gtkdialog#GtkDialog-struct), [GtkDragIcon](gtkdragicon#GtkDragIcon-struct), [GtkEmojiChooser](gtkemojichooser#GtkEmojiChooser-struct), [GtkFileChooserDialog](gtkfilechooserdialog#GtkFileChooserDialog-struct), [GtkFontChooserDialog](gtkfontchooserdialog#GtkFontChooserDialog-struct), [GtkMessageDialog](gtkmessagedialog#GtkMessageDialog-struct), [GtkPageSetupUnixDialog](gtkpagesetupunixdialog#GtkPageSetupUnixDialog-struct), [GtkPopover](gtkpopover#GtkPopover-struct), [GtkPopoverMenu](gtkpopovermenu#GtkPopoverMenu-struct), [GtkPrintUnixDialog](gtkprintunixdialog#GtkPrintUnixDialog-struct), [GtkShortcutsWindow](gtkshortcutswindow#GtkShortcutsWindow-struct) and [GtkWindow](gtkwindow#GtkWindow-struct).
Includes
--------
```
#include <gtk/gtk.h>
```
Description
-----------
[GtkNative](gtknative#GtkNative-struct) is the interface implemented by all widgets that can provide a GdkSurface for widgets to render on.
The obvious example of a [GtkNative](gtknative#GtkNative-struct) is [GtkWindow](gtkwindow#GtkWindow-struct).
Functions
---------
### gtk\_native\_get\_for\_surface ()
```
[GtkNative](gtknative#GtkNative-struct) *
gtk_native_get_for_surface (*`[GdkSurface](https://developer-old.gnome.org/gtk4/html/GdkSurface.html#GdkSurface-struct) *surface`*);
```
Finds the GtkNative associated with the surface.
#### Parameters
| | | |
| --- | --- | --- |
| surface | a [GdkSurface](https://developer-old.gnome.org/gtk4/html/GdkSurface.html#GdkSurface-struct) | |
#### Returns
the [GtkNative](gtknative#GtkNative-struct) that is associated with *`surface`* .
[transfer none]
### gtk\_native\_get\_surface ()
```
[GdkSurface](https://developer-old.gnome.org/gtk4/html/GdkSurface.html#GdkSurface-struct) *
gtk_native_get_surface (*`[GtkNative](gtknative#GtkNative-struct) *self`*);
```
Returns the surface of this [GtkNative](gtknative#GtkNative-struct).
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkNative](gtknative#GtkNative-struct) | |
#### Returns
the surface of *`self`* .
[transfer none]
### gtk\_native\_get\_renderer ()
```
[GskRenderer](https://developer-old.gnome.org/gtk4/html/GskRenderer.html#GskRenderer-struct) *
gtk_native_get_renderer (*`[GtkNative](gtknative#GtkNative-struct) *self`*);
```
Returns the renderer that is used for this [GtkNative](gtknative#GtkNative-struct).
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkNative](gtknative#GtkNative-struct) | |
#### Returns
the renderer for *`self`* .
[transfer none]
### gtk\_native\_get\_surface\_transform ()
```
void
gtk_native_get_surface_transform (*`[GtkNative](gtknative#GtkNative-struct) *self`*,
*`double *x`*,
*`double *y`*);
```
Retrieves the surface transform of *`self`* . This is the translation from *`self`* 's surface coordinates into *`self`* 's widget coordinates.
#### Parameters
| | | |
| --- | --- | --- |
| self | a *`GtkNative`* | |
| x | return location for the x coordinate. | [out] |
| y | return location for the y coordinate. | [out] |
### gtk\_native\_realize ()
```
void
gtk_native_realize (*`[GtkNative](gtknative#GtkNative-struct) *self`*);
```
Realizes a [GtkNative](gtknative#GtkNative-struct).
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkNative](gtknative#GtkNative-struct) | |
### gtk\_native\_unrealize ()
```
void
gtk_native_unrealize (*`[GtkNative](gtknative#GtkNative-struct) *self`*);
```
Unrealizes a [GtkNative](gtknative#GtkNative-struct).
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkNative](gtknative#GtkNative-struct) | |
Types and Values
----------------
### GtkNative
```
typedef struct _GtkNative GtkNative;
```
See Also
--------
[GtkRoot](gtkroot#GtkRoot-struct)
gtk Event controllers and gestures Event controllers and gestures
==============================
Event controllers are standalone objects that can perform specific actions upon received [GdkEvents](https://developer-old.gnome.org/gtk4/html/gdk4-Events.html#GdkEvent-struct). These are tied to a [GtkWidget](gtkwidget#GtkWidget-struct), and can be told of the event propagation phase at which they will manage the events.
Gestures are a set of specific controllers that are prepared to handle pointer and/or touch events, each gesture implementation attempts to recognize specific actions out the received events, notifying of the state/progress accordingly to let the widget react to those. On multi-touch gestures, every interacting touch sequence will be tracked independently.
Since gestures are “simple” units, it is not uncommon to tie several together to perform higher level actions, grouped gestures handle the same event sequences simultaneously, and those sequences share a same state across all grouped gestures. Some examples of grouping may be:
* A “drag” and a “swipe” gestures may want grouping. The former will report events as the dragging happens, the latter will tell the swipe X/Y velocities only after recognition has finished.
* Grouping a “drag” gesture with a “pan” gesture will only effectively allow dragging in the panning orientation, as both gestures share state.
* If “press” and “long press” are wanted simultaneously, those would need grouping.
Shortcuts are handled by [GtkShortcutController](gtkshortcutcontroller#GtkShortcutController-struct), which is a complex event handler that can either activate shortcuts itself, or propagate them to another controller, depending on its [“scope”](gtkshortcutcontroller#GtkShortcutController--scope).
gtk GtkCheckButton GtkCheckButton
==============
GtkCheckButton — Create widgets with a discrete toggle button
Functions
---------
| | |
| --- | --- |
| [GtkWidget](gtkwidget#GtkWidget-struct) \* | [gtk\_check\_button\_new](gtkcheckbutton#gtk-check-button-new) () |
| [GtkWidget](gtkwidget#GtkWidget-struct) \* | [gtk\_check\_button\_new\_with\_label](gtkcheckbutton#gtk-check-button-new-with-label) () |
| [GtkWidget](gtkwidget#GtkWidget-struct) \* | [gtk\_check\_button\_new\_with\_mnemonic](gtkcheckbutton#gtk-check-button-new-with-mnemonic) () |
| const char \* | [gtk\_check\_button\_get\_label](gtkcheckbutton#gtk-check-button-get-label) () |
| void | [gtk\_check\_button\_set\_label](gtkcheckbutton#gtk-check-button-set-label) () |
| gboolean | [gtk\_check\_button\_get\_use\_underline](gtkcheckbutton#gtk-check-button-get-use-underline) () |
| void | [gtk\_check\_button\_set\_use\_underline](gtkcheckbutton#gtk-check-button-set-use-underline) () |
| void | [gtk\_check\_button\_set\_group](gtkcheckbutton#gtk-check-button-set-group) () |
| gboolean | [gtk\_check\_button\_get\_active](gtkcheckbutton#gtk-check-button-get-active) () |
| void | [gtk\_check\_button\_set\_active](gtkcheckbutton#gtk-check-button-set-active) () |
| gboolean | [gtk\_check\_button\_get\_inconsistent](gtkcheckbutton#gtk-check-button-get-inconsistent) () |
| void | [gtk\_check\_button\_set\_inconsistent](gtkcheckbutton#gtk-check-button-set-inconsistent) () |
Properties
----------
| | | |
| --- | --- | --- |
| gboolean | [active](gtkcheckbutton#GtkCheckButton--active) | Read / Write |
| [GtkCheckButton](gtkcheckbutton#GtkCheckButton-struct) \* | [group](gtkcheckbutton#GtkCheckButton--group) | Write |
| gboolean | [inconsistent](gtkcheckbutton#GtkCheckButton--inconsistent) | Read / Write |
| char \* | [label](gtkcheckbutton#GtkCheckButton--label) | Read / Write |
| gboolean | [use-underline](gtkcheckbutton#GtkCheckButton--use-underline) | Read / Write |
Signals
-------
| | | |
| --- | --- | --- |
| void | [toggled](gtkcheckbutton#GtkCheckButton-toggled) | Run First |
Types and Values
----------------
| | |
| --- | --- |
| struct | [GtkCheckButton](gtkcheckbutton#GtkCheckButton-struct) |
Object Hierarchy
----------------
```
GObject
╰── GInitiallyUnowned
╰── [GtkWidget](gtkwidget#GtkWidget-struct)
╰── GtkCheckButton
```
Implemented Interfaces
----------------------
GtkCheckButton implements [GtkAccessible](gtkaccessible#GtkAccessible-struct), [GtkBuildable](gtkbuildable#GtkBuildable-struct), [GtkConstraintTarget](gtkconstraint#GtkConstraintTarget-struct) and [GtkActionable](gtkactionable#GtkActionable-struct).
Includes
--------
```
#include <gtk/gtk.h>
```
Description
-----------
A [GtkCheckButton](gtkcheckbutton#GtkCheckButton-struct) places a label next to an indicator.
### CSS nodes
```
checkbutton[.text-button]
├── check
╰── [label]
```
| A [GtkCheckButton](gtkcheckbutton#GtkCheckButton-struct) has a main node with name checkbutton. If the [“label”](gtkcheckbutton#GtkCheckButton--label) property is set, it contains a label child. The indicator node is named check when no group is set, and radio if the checkbutton is grouped together with other checkbuttons.
### Accessibility
GtkCheckButton uses the [GTK\_ACCESSIBLE\_ROLE\_CHECKBOX](gtkaccessible#GTK-ACCESSIBLE-ROLE-CHECKBOX:CAPS) role.
Functions
---------
### gtk\_check\_button\_new ()
```
[GtkWidget](gtkwidget#GtkWidget-struct) *
gtk_check_button_new (*`void`*);
```
Creates a new [GtkCheckButton](gtkcheckbutton#GtkCheckButton-struct).
#### Returns
a [GtkWidget](gtkwidget#GtkWidget-struct).
### gtk\_check\_button\_new\_with\_label ()
```
[GtkWidget](gtkwidget#GtkWidget-struct) *
gtk_check_button_new_with_label (*`const char *label`*);
```
Creates a new [GtkCheckButton](gtkcheckbutton#GtkCheckButton-struct) with a [GtkLabel](gtklabel#GtkLabel-struct) next to it, if *`label`* is non-`NULL`.
#### Parameters
| | | |
| --- | --- | --- |
| label | the text for the check button. | [nullable] |
#### Returns
a new [GtkCheckButton](gtkcheckbutton#GtkCheckButton-struct)
### gtk\_check\_button\_new\_with\_mnemonic ()
```
[GtkWidget](gtkwidget#GtkWidget-struct) *
gtk_check_button_new_with_mnemonic (*`const char *label`*);
```
Creates a new [GtkCheckButton](gtkcheckbutton#GtkCheckButton-struct) containing a label. Underscores in *`label`* indicate the mnemonic for the check button.
#### Parameters
| | | |
| --- | --- | --- |
| label | The text of the button, with an underscore in front of the mnemonic character. | [nullable] |
#### Returns
a new [GtkCheckButton](gtkcheckbutton#GtkCheckButton-struct)
### gtk\_check\_button\_get\_label ()
```
const char *
gtk_check_button_get_label (*`[GtkCheckButton](gtkcheckbutton#GtkCheckButton-struct) *self`*);
```
Returns the label of the checkbutton.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkCheckButton](gtkcheckbutton#GtkCheckButton-struct) | |
#### Returns
The label *`self`* shows next to the indicator. If no label is shown, `NULL` will be returned.
[nullable][transfer none]
### gtk\_check\_button\_set\_label ()
```
void
gtk_check_button_set_label (*`[GtkCheckButton](gtkcheckbutton#GtkCheckButton-struct) *self`*,
*`const char *label`*);
```
Sets the text of *`self`* . If [“use-underline”](gtkcheckbutton#GtkCheckButton--use-underline) is `TRUE`, the underscore in *`label`* is interpreted as mnemonic indicator, see [`gtk_check_button_set_use_underline()`](gtkcheckbutton#gtk-check-button-set-use-underline) for details on this behavior.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkCheckButton](gtkcheckbutton#GtkCheckButton-struct) | |
| label | The text shown next to the indicator, or `NULL` to show no text. | [nullable] |
### gtk\_check\_button\_get\_use\_underline ()
```
gboolean
gtk_check_button_get_use_underline (*`[GtkCheckButton](gtkcheckbutton#GtkCheckButton-struct) *self`*);
```
Returns the current value of the [“use-underline”](gtkcheckbutton#GtkCheckButton--use-underline) property.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkCheckButton](gtkcheckbutton#GtkCheckButton-struct) | |
#### Returns
The value of the [“use-underline”](gtkcheckbutton#GtkCheckButton--use-underline) property. See [`gtk_check_button_set_use_underline()`](gtkcheckbutton#gtk-check-button-set-use-underline) for details on how to set a new value.
### gtk\_check\_button\_set\_use\_underline ()
```
void
gtk_check_button_set_use_underline (*`[GtkCheckButton](gtkcheckbutton#GtkCheckButton-struct) *self`*,
*`gboolean setting`*);
```
Sets the new value of the [“use-underline”](gtkcheckbutton#GtkCheckButton--use-underline) property. See also [`gtk_check_button_get_use_underline()`](gtkcheckbutton#gtk-check-button-get-use-underline).
If *`setting`* is `TRUE`, an underscore character in *`self`* 's label indicates a mnemonic accelerator key. This behavior is similar to [“use-underline”](gtklabel#GtkLabel--use-underline).
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkCheckButton](gtkcheckbutton#GtkCheckButton-struct) | |
| setting | the new value to set | |
### gtk\_check\_button\_set\_group ()
```
void
gtk_check_button_set_group (*`[GtkCheckButton](gtkcheckbutton#GtkCheckButton-struct) *self`*,
*`[GtkCheckButton](gtkcheckbutton#GtkCheckButton-struct) *group`*);
```
Adds *`self`* to the group of *`group`* . In a group of multiple check buttons, only one button can be active at a time.
Setting the group of a check button also changes the css name of the indicator widget's CSS node to 'radio'.
The behavior of a checkbutton in a group is also commonly known as a 'radio button'.
Note that the same effect can be achieved via the [GtkActionable](gtkactionable#GtkActionable-struct) api, by using the same action with parameter type and state type 's' for all buttons in the group, and giving each button its own target value.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkCheckButton](gtkcheckbutton#GtkCheckButton-struct) | |
| group | another [GtkCheckButton](gtkcheckbutton#GtkCheckButton-struct) to form a group with. | [nullable][transfer none] |
### gtk\_check\_button\_get\_active ()
```
gboolean
gtk_check_button_get_active (*`[GtkCheckButton](gtkcheckbutton#GtkCheckButton-struct) *self`*);
```
Returns the current value of the [“active”](gtkcheckbutton#GtkCheckButton--active) property.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkCheckButton](gtkcheckbutton#GtkCheckButton-struct) | |
#### Returns
The value of the [“active”](gtkcheckbutton#GtkCheckButton--active) property. See [`gtk_check_button_set_active()`](gtkcheckbutton#gtk-check-button-set-active) for details on how to set a new value.
### gtk\_check\_button\_set\_active ()
```
void
gtk_check_button_set_active (*`[GtkCheckButton](gtkcheckbutton#GtkCheckButton-struct) *self`*,
*`gboolean setting`*);
```
Sets the new value of the [“active”](gtkcheckbutton#GtkCheckButton--active) property. See also [`gtk_check_button_get_active()`](gtkcheckbutton#gtk-check-button-get-active).
Setting [“active”](gtkcheckbutton#GtkCheckButton--active) to `TRUE` will add the `:checked:` state to both the checkbutton and the indicator CSS node.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkCheckButton](gtkcheckbutton#GtkCheckButton-struct) | |
| setting | the new value to set | |
### gtk\_check\_button\_get\_inconsistent ()
```
gboolean
gtk_check_button_get_inconsistent (*`[GtkCheckButton](gtkcheckbutton#GtkCheckButton-struct) *check_button`*);
```
Returns whether the check button is in an inconsistent state.
#### Parameters
| | | |
| --- | --- | --- |
| check\_button | a [GtkCheckButton](gtkcheckbutton#GtkCheckButton-struct) | |
#### Returns
`TRUE` if *`check_button`* is currently in an 'in between' state, `FALSE` otherwise.
### gtk\_check\_button\_set\_inconsistent ()
```
void
gtk_check_button_set_inconsistent (*`[GtkCheckButton](gtkcheckbutton#GtkCheckButton-struct) *check_button`*,
*`gboolean inconsistent`*);
```
If the user has selected a range of elements (such as some text or spreadsheet cells) that are affected by a check button, and the current values in that range are inconsistent, you may want to display the toggle in an "in between" state. Normally you would turn off the inconsistent state again if the user checks the check button. This has to be done manually, gtk\_check\_button\_set\_inconsistent only affects visual appearance, not the semantics of the button.
#### Parameters
| | | |
| --- | --- | --- |
| check\_button | a [GtkCheckButton](gtkcheckbutton#GtkCheckButton-struct) | |
| inconsistent | `TRUE` if state is inconsistent | |
Types and Values
----------------
### struct GtkCheckButton
```
struct GtkCheckButton;
```
Property Details
----------------
### The `“active”` property
```
“active” gboolean
```
If the toggle button should be pressed in.
Owner: GtkCheckButton
Flags: Read / Write
Default value: FALSE
### The `“group”` property
```
“group” [GtkCheckButton](gtkcheckbutton#GtkCheckButton-struct) *
```
The check button whose group this widget belongs to.
Owner: GtkCheckButton
Flags: Write
### The `“inconsistent”` property
```
“inconsistent” gboolean
```
If the check button is in an “in between” state.
Owner: GtkCheckButton
Flags: Read / Write
Default value: FALSE
### The `“label”` property
```
“label” char *
```
Text of the label widget inside the button, if the button contains a label widget.
Owner: GtkCheckButton
Flags: Read / Write
Default value: NULL
### The `“use-underline”` property
```
“use-underline” gboolean
```
If set, an underline in the text indicates the next character should be used for the mnemonic accelerator key.
Owner: GtkCheckButton
Flags: Read / Write
Default value: FALSE
Signal Details
--------------
### The `“toggled”` signal
```
void
user_function ([GtkCheckButton](gtkcheckbutton#GtkCheckButton-struct) *checkbutton,
gpointer user_data)
```
Emitted when the buttons's [“active”](gtkcheckbutton#GtkCheckButton--active) flag changes.
#### Parameters
| | | |
| --- | --- | --- |
| user\_data | user data set when the signal handler was connected. | |
Flags: Run First
See Also
--------
[GtkButton](gtkbutton#GtkButton-struct), [GtkToggleButton](gtktogglebutton#GtkToggleButton-struct)
| programming_docs |
gtk GtkGestureSingle GtkGestureSingle
================
GtkGestureSingle — Base class for mouse/single-touch gestures
Functions
---------
| | |
| --- | --- |
| gboolean | [gtk\_gesture\_single\_get\_exclusive](gtkgesturesingle#gtk-gesture-single-get-exclusive) () |
| void | [gtk\_gesture\_single\_set\_exclusive](gtkgesturesingle#gtk-gesture-single-set-exclusive) () |
| gboolean | [gtk\_gesture\_single\_get\_touch\_only](gtkgesturesingle#gtk-gesture-single-get-touch-only) () |
| void | [gtk\_gesture\_single\_set\_touch\_only](gtkgesturesingle#gtk-gesture-single-set-touch-only) () |
| guint | [gtk\_gesture\_single\_get\_button](gtkgesturesingle#gtk-gesture-single-get-button) () |
| void | [gtk\_gesture\_single\_set\_button](gtkgesturesingle#gtk-gesture-single-set-button) () |
| guint | [gtk\_gesture\_single\_get\_current\_button](gtkgesturesingle#gtk-gesture-single-get-current-button) () |
| [GdkEventSequence](https://developer-old.gnome.org/gtk4/html/gdk4-Events.html#GdkEventSequence) \* | [gtk\_gesture\_single\_get\_current\_sequence](gtkgesturesingle#gtk-gesture-single-get-current-sequence) () |
Properties
----------
| | | |
| --- | --- | --- |
| guint | [button](gtkgesturesingle#GtkGestureSingle--button) | Read / Write |
| gboolean | [exclusive](gtkgesturesingle#GtkGestureSingle--exclusive) | Read / Write |
| gboolean | [touch-only](gtkgesturesingle#GtkGestureSingle--touch-only) | Read / Write |
Types and Values
----------------
| | |
| --- | --- |
| | [GtkGestureSingle](gtkgesturesingle#GtkGestureSingle-struct) |
Object Hierarchy
----------------
```
GObject
╰── [GtkEventController](gtkeventcontroller#GtkEventController-struct)
╰── [GtkGesture](gtkgesture#GtkGesture-struct)
╰── GtkGestureSingle
├── [GtkDragSource](gtkdragsource#GtkDragSource-struct)
├── [GtkGestureClick](gtkgestureclick#GtkGestureClick-struct)
├── [GtkGestureDrag](gtkgesturedrag#GtkGestureDrag-struct)
├── [GtkGestureLongPress](gtkgesturelongpress#GtkGestureLongPress-struct)
├── [GtkGestureStylus](gtkgesturestylus#GtkGestureStylus-struct)
╰── [GtkGestureSwipe](gtkgestureswipe#GtkGestureSwipe-struct)
```
Includes
--------
```
#include <gtk/gtk.h>
```
Description
-----------
[GtkGestureSingle](gtkgesturesingle#GtkGestureSingle-struct) is a subclass of [GtkGesture](gtkgesture#GtkGesture-struct), optimized (although not restricted) for dealing with mouse and single-touch gestures. Under interaction, these gestures stick to the first interacting sequence, which is accessible through [`gtk_gesture_single_get_current_sequence()`](gtkgesturesingle#gtk-gesture-single-get-current-sequence) while the gesture is being interacted with.
By default gestures react to both [`GDK_BUTTON_PRIMARY`](https://developer-old.gnome.org/gtk4/html/gdk4-Events.html#GDK-BUTTON-PRIMARY:CAPS) and touch events, [`gtk_gesture_single_set_touch_only()`](gtkgesturesingle#gtk-gesture-single-set-touch-only) can be used to change the touch behavior. Callers may also specify a different mouse button number to interact with through [`gtk_gesture_single_set_button()`](gtkgesturesingle#gtk-gesture-single-set-button), or react to any mouse button by setting 0. While the gesture is active, the button being currently pressed can be known through [`gtk_gesture_single_get_current_button()`](gtkgesturesingle#gtk-gesture-single-get-current-button).
Functions
---------
### gtk\_gesture\_single\_get\_exclusive ()
```
gboolean
gtk_gesture_single_get_exclusive (*`[GtkGestureSingle](gtkgesturesingle#GtkGestureSingle-struct) *gesture`*);
```
Gets whether a gesture is exclusive. For more information, see [`gtk_gesture_single_set_exclusive()`](gtkgesturesingle#gtk-gesture-single-set-exclusive).
#### Parameters
| | | |
| --- | --- | --- |
| gesture | a [GtkGestureSingle](gtkgesturesingle#GtkGestureSingle-struct) | |
#### Returns
Whether the gesture is exclusive
### gtk\_gesture\_single\_set\_exclusive ()
```
void
gtk_gesture_single_set_exclusive (*`[GtkGestureSingle](gtkgesturesingle#GtkGestureSingle-struct) *gesture`*,
*`gboolean exclusive`*);
```
Sets whether *`gesture`* is exclusive. An exclusive gesture will only handle pointer and "pointer emulated" touch events, so at any given time, there is only one sequence able to interact with those.
#### Parameters
| | | |
| --- | --- | --- |
| gesture | a [GtkGestureSingle](gtkgesturesingle#GtkGestureSingle-struct) | |
| exclusive | `TRUE` to make *`gesture`* exclusive | |
### gtk\_gesture\_single\_get\_touch\_only ()
```
gboolean
gtk_gesture_single_get_touch_only (*`[GtkGestureSingle](gtkgesturesingle#GtkGestureSingle-struct) *gesture`*);
```
Returns `TRUE` if the gesture is only triggered by touch events.
#### Parameters
| | | |
| --- | --- | --- |
| gesture | a [GtkGestureSingle](gtkgesturesingle#GtkGestureSingle-struct) | |
#### Returns
`TRUE` if the gesture only handles touch events
### gtk\_gesture\_single\_set\_touch\_only ()
```
void
gtk_gesture_single_set_touch_only (*`[GtkGestureSingle](gtkgesturesingle#GtkGestureSingle-struct) *gesture`*,
*`gboolean touch_only`*);
```
If *`touch_only`* is `TRUE`, *`gesture`* will only handle events of type [GDK\_TOUCH\_BEGIN](https://developer-old.gnome.org/gtk4/html/gdk4-Events.html#GDK-TOUCH-BEGIN:CAPS), [GDK\_TOUCH\_UPDATE](https://developer-old.gnome.org/gtk4/html/gdk4-Events.html#GDK-TOUCH-UPDATE:CAPS) or [GDK\_TOUCH\_END](https://developer-old.gnome.org/gtk4/html/gdk4-Events.html#GDK-TOUCH-END:CAPS). If `FALSE`, mouse events will be handled too.
#### Parameters
| | | |
| --- | --- | --- |
| gesture | a [GtkGestureSingle](gtkgesturesingle#GtkGestureSingle-struct) | |
| touch\_only | whether *`gesture`* handles only touch events | |
### gtk\_gesture\_single\_get\_button ()
```
guint
gtk_gesture_single_get_button (*`[GtkGestureSingle](gtkgesturesingle#GtkGestureSingle-struct) *gesture`*);
```
Returns the button number *`gesture`* listens for, or 0 if *`gesture`* reacts to any button press.
#### Parameters
| | | |
| --- | --- | --- |
| gesture | a [GtkGestureSingle](gtkgesturesingle#GtkGestureSingle-struct) | |
#### Returns
The button number, or 0 for any button
### gtk\_gesture\_single\_set\_button ()
```
void
gtk_gesture_single_set_button (*`[GtkGestureSingle](gtkgesturesingle#GtkGestureSingle-struct) *gesture`*,
*`guint button`*);
```
Sets the button number *`gesture`* listens to. If non-0, every button press from a different button number will be ignored. Touch events implicitly match with button 1.
#### Parameters
| | | |
| --- | --- | --- |
| gesture | a [GtkGestureSingle](gtkgesturesingle#GtkGestureSingle-struct) | |
| button | button number to listen to, or 0 for any button | |
### gtk\_gesture\_single\_get\_current\_button ()
```
guint
gtk_gesture_single_get_current_button (*`[GtkGestureSingle](gtkgesturesingle#GtkGestureSingle-struct) *gesture`*);
```
Returns the button number currently interacting with *`gesture`* , or 0 if there is none.
#### Parameters
| | | |
| --- | --- | --- |
| gesture | a [GtkGestureSingle](gtkgesturesingle#GtkGestureSingle-struct) | |
#### Returns
The current button number
### gtk\_gesture\_single\_get\_current\_sequence ()
```
[GdkEventSequence](https://developer-old.gnome.org/gtk4/html/gdk4-Events.html#GdkEventSequence) *
gtk_gesture_single_get_current_sequence
(*`[GtkGestureSingle](gtkgesturesingle#GtkGestureSingle-struct) *gesture`*);
```
Returns the event sequence currently interacting with *`gesture`* . This is only meaningful if [`gtk_gesture_is_active()`](gtkgesture#gtk-gesture-is-active) returns `TRUE`.
#### Parameters
| | | |
| --- | --- | --- |
| gesture | a [GtkGestureSingle](gtkgesturesingle#GtkGestureSingle-struct) | |
#### Returns
the current sequence.
[nullable]
Types and Values
----------------
### GtkGestureSingle
```
typedef struct _GtkGestureSingle GtkGestureSingle;
```
Property Details
----------------
### The `“button”` property
```
“button” guint
```
Mouse button number to listen to, or 0 to listen for any button.
Owner: GtkGestureSingle
Flags: Read / Write
Default value: 1
### The `“exclusive”` property
```
“exclusive” gboolean
```
Whether the gesture is exclusive. Exclusive gestures only listen to pointer and pointer emulated events.
Owner: GtkGestureSingle
Flags: Read / Write
Default value: FALSE
### The `“touch-only”` property
```
“touch-only” gboolean
```
Whether the gesture handles only touch events.
Owner: GtkGestureSingle
Flags: Read / Write
Default value: FALSE
gtk GtkEditable GtkEditable
===========
GtkEditable — Interface for text-editing widgets
Functions
---------
| | |
| --- | --- |
| const char \* | [gtk\_editable\_get\_text](gtkeditable#gtk-editable-get-text) () |
| void | [gtk\_editable\_set\_text](gtkeditable#gtk-editable-set-text) () |
| char \* | [gtk\_editable\_get\_chars](gtkeditable#gtk-editable-get-chars) () |
| void | [gtk\_editable\_insert\_text](gtkeditable#gtk-editable-insert-text) () |
| void | [gtk\_editable\_delete\_text](gtkeditable#gtk-editable-delete-text) () |
| gboolean | [gtk\_editable\_get\_selection\_bounds](gtkeditable#gtk-editable-get-selection-bounds) () |
| void | [gtk\_editable\_select\_region](gtkeditable#gtk-editable-select-region) () |
| void | [gtk\_editable\_delete\_selection](gtkeditable#gtk-editable-delete-selection) () |
| void | [gtk\_editable\_set\_position](gtkeditable#gtk-editable-set-position) () |
| int | [gtk\_editable\_get\_position](gtkeditable#gtk-editable-get-position) () |
| void | [gtk\_editable\_set\_editable](gtkeditable#gtk-editable-set-editable) () |
| gboolean | [gtk\_editable\_get\_editable](gtkeditable#gtk-editable-get-editable) () |
| void | [gtk\_editable\_set\_alignment](gtkeditable#gtk-editable-set-alignment) () |
| float | [gtk\_editable\_get\_alignment](gtkeditable#gtk-editable-get-alignment) () |
| int | [gtk\_editable\_get\_width\_chars](gtkeditable#gtk-editable-get-width-chars) () |
| void | [gtk\_editable\_set\_width\_chars](gtkeditable#gtk-editable-set-width-chars) () |
| int | [gtk\_editable\_get\_max\_width\_chars](gtkeditable#gtk-editable-get-max-width-chars) () |
| void | [gtk\_editable\_set\_max\_width\_chars](gtkeditable#gtk-editable-set-max-width-chars) () |
| gboolean | [gtk\_editable\_get\_enable\_undo](gtkeditable#gtk-editable-get-enable-undo) () |
| void | [gtk\_editable\_set\_enable\_undo](gtkeditable#gtk-editable-set-enable-undo) () |
| guint | [gtk\_editable\_install\_properties](gtkeditable#gtk-editable-install-properties) () |
| [GtkEditable](gtkeditable#GtkEditable-struct) \* | [gtk\_editable\_get\_delegate](gtkeditable#gtk-editable-get-delegate) () |
| void | [gtk\_editable\_init\_delegate](gtkeditable#gtk-editable-init-delegate) () |
| void | [gtk\_editable\_finish\_delegate](gtkeditable#gtk-editable-finish-delegate) () |
| gboolean | [gtk\_editable\_delegate\_set\_property](gtkeditable#gtk-editable-delegate-set-property) () |
| gboolean | [gtk\_editable\_delegate\_get\_property](gtkeditable#gtk-editable-delegate-get-property) () |
Properties
----------
| | | |
| --- | --- | --- |
| int | [cursor-position](gtkeditable#GtkEditable--cursor-position) | Read |
| gboolean | [editable](gtkeditable#GtkEditable--editable) | Read / Write |
| gboolean | [enable-undo](gtkeditable#GtkEditable--enable-undo) | Read / Write |
| int | [max-width-chars](gtkeditable#GtkEditable--max-width-chars) | Read / Write |
| int | [selection-bound](gtkeditable#GtkEditable--selection-bound) | Read |
| char \* | [text](gtkeditable#GtkEditable--text) | Read / Write |
| int | [width-chars](gtkeditable#GtkEditable--width-chars) | Read / Write |
| float | [xalign](gtkeditable#GtkEditable--xalign) | Read / Write |
Signals
-------
| | | |
| --- | --- | --- |
| void | [changed](gtkeditable#GtkEditable-changed) | Run Last |
| void | [delete-text](gtkeditable#GtkEditable-delete-text) | Run Last |
| void | [insert-text](gtkeditable#GtkEditable-insert-text) | Run Last |
Types and Values
----------------
| | |
| --- | --- |
| | [GtkEditable](gtkeditable#GtkEditable-struct) |
| struct | [GtkEditableInterface](gtkeditable#GtkEditableInterface) |
| enum | [GtkEditableProperties](gtkeditable#GtkEditableProperties) |
Object Hierarchy
----------------
```
[GInterface](https://developer-old.gnome.org/gobject/stable/GTypeModule.html)
╰── GtkEditable
```
Prerequisites
-------------
GtkEditable requires [GtkWidget](gtkwidget#GtkWidget-struct).
Known Implementations
---------------------
GtkEditable is implemented by [GtkEditableLabel](gtkeditablelabel#GtkEditableLabel-struct), [GtkEntry](gtkentry#GtkEntry-struct), [GtkPasswordEntry](gtkpasswordentry#GtkPasswordEntry-struct), [GtkSearchEntry](gtksearchentry#GtkSearchEntry-struct), [GtkSpinButton](gtkspinbutton#GtkSpinButton-struct) and [GtkText](gtktext#GtkText-struct).
Includes
--------
```
#include <gtk/gtk.h>
```
Description
-----------
The [GtkEditable](gtkeditable#GtkEditable-struct) interface is an interface which should be implemented by text editing widgets, such as [GtkEntry](gtkentry#GtkEntry-struct) and [GtkSpinButton](gtkspinbutton#GtkSpinButton-struct). It contains functions for generically manipulating an editable widget, a large number of action signals used for key bindings, and several signals that an application can connect to modify the behavior of a widget.
As an example of the latter usage, by connecting the following handler to [“insert-text”](gtkeditable#GtkEditable-insert-text), an application can convert all entry into a widget into uppercase.
#### Forcing entry to uppercase.
#### Implementing GtkEditable
The most likely scenario for implementing GtkEditable on your own widget is that you will embed a [GtkText](gtktext#GtkText-struct) inside a complex widget, and want to delegate the editable functionality to that text widget. GtkEditable provides some utility functions to make this easy.
In your class\_init function, call [`gtk_editable_install_properties()`](gtkeditable#gtk-editable-install-properties), passing the first available property ID:
In your interface\_init function for the GtkEditable interface, provide an implementation for the get\_delegate vfunc that returns your text widget:
You don't need to provide any other vfuncs. The default implementations work by forwarding to the delegate that the `GtkEditableInterface.get_delegate()` vfunc returns.
In your instance\_init function, create your text widget, and then call [`gtk_editable_init_delegate()`](gtkeditable#gtk-editable-init-delegate):
In your dispose function, call [`gtk_editable_finish_delegate()`](gtkeditable#gtk-editable-finish-delegate) before destroying your text widget:
Finally, use [`gtk_editable_delegate_set_property()`](gtkeditable#gtk-editable-delegate-set-property) in your `set_property` function (and similar for `get_property`), to set the editable properties:
```
#include <ctype.h>
void
insert_text_handler (GtkEditable *editable,
const char *text,
int length,
int *position,
gpointer data)
{
char *result = g_utf8_strup (text, length);
g_signal_handlers_block_by_func (editable,
(gpointer) insert_text_handler, data);
gtk_editable_insert_text (editable, result, length, position);
g_signal_handlers_unblock_by_func (editable,
(gpointer) insert_text_handler, data);
g_signal_stop_emission_by_name (editable, "insert_text");
g_free (result);
}
```
| It is important to note that if you create a GtkEditable that uses a delegate, the low level [“insert-text”](gtkeditable#GtkEditable-insert-text) and [“delete-text”](gtkeditable#GtkEditable-delete-text) signals will be propagated from the "wrapper" editable to the delegate, but they will not be propagated from the delegate to the "wrapper" editable, as they would cause an infinite recursion. If you wish to connect to the [“insert-text”](gtkeditable#GtkEditable-insert-text) and [“delete-text”](gtkeditable#GtkEditable-delete-text) signals, you will need to connect to them on the delegate obtained via [`gtk_editable_get_delegate()`](gtkeditable#gtk-editable-get-delegate).
Functions
---------
### gtk\_editable\_get\_text ()
```
const char *
gtk_editable_get_text (*`[GtkEditable](gtkeditable#GtkEditable-struct) *editable`*);
```
Retrieves the contents of *`editable`* . The returned string is owned by GTK and must not be modified or freed.
#### Parameters
| | | |
| --- | --- | --- |
| editable | a [GtkEditable](gtkeditable#GtkEditable-struct) | |
#### Returns
a pointer to the contents of the editable.
[transfer none]
### gtk\_editable\_set\_text ()
```
void
gtk_editable_set_text (*`[GtkEditable](gtkeditable#GtkEditable-struct) *editable`*,
*`const char *text`*);
```
Sets the text in the editable to the given value, replacing the current contents.
#### Parameters
| | | |
| --- | --- | --- |
| editable | a [GtkEditable](gtkeditable#GtkEditable-struct) | |
| text | the text to set | |
### gtk\_editable\_get\_chars ()
```
char *
gtk_editable_get_chars (*`[GtkEditable](gtkeditable#GtkEditable-struct) *editable`*,
*`int start_pos`*,
*`int end_pos`*);
```
Retrieves a sequence of characters. The characters that are retrieved are those characters at positions from *`start_pos`* up to, but not including *`end_pos`* . If *`end_pos`* is negative, then the characters retrieved are those characters from *`start_pos`* to the end of the text.
Note that positions are specified in characters, not bytes.
#### Parameters
| | | |
| --- | --- | --- |
| editable | a [GtkEditable](gtkeditable#GtkEditable-struct) | |
| start\_pos | start of text | |
| end\_pos | end of text | |
#### Returns
a pointer to the contents of the widget as a string. This string is allocated by the [GtkEditable](gtkeditable#GtkEditable-struct) implementation and should be freed by the caller.
[transfer full]
### gtk\_editable\_insert\_text ()
```
void
gtk_editable_insert_text (*`[GtkEditable](gtkeditable#GtkEditable-struct) *editable`*,
*`const char *text`*,
*`int length`*,
*`int *position`*);
```
Inserts *`length`* bytes of *`text`* into the contents of the widget, at position *`position`* .
Note that the position is in characters, not in bytes. The function updates *`position`* to point after the newly inserted text.
[virtual do\_insert\_text]
#### Parameters
| | | |
| --- | --- | --- |
| editable | a [GtkEditable](gtkeditable#GtkEditable-struct) | |
| text | the text to append | |
| length | the length of the text in bytes, or -1 | |
| position | location of the position text will be inserted at. | [inout] |
### gtk\_editable\_delete\_text ()
```
void
gtk_editable_delete_text (*`[GtkEditable](gtkeditable#GtkEditable-struct) *editable`*,
*`int start_pos`*,
*`int end_pos`*);
```
Deletes a sequence of characters. The characters that are deleted are those characters at positions from *`start_pos`* up to, but not including *`end_pos`* . If *`end_pos`* is negative, then the characters deleted are those from *`start_pos`* to the end of the text.
Note that the positions are specified in characters, not bytes.
[virtual do\_delete\_text]
#### Parameters
| | | |
| --- | --- | --- |
| editable | a [GtkEditable](gtkeditable#GtkEditable-struct) | |
| start\_pos | start position | |
| end\_pos | end position | |
### gtk\_editable\_get\_selection\_bounds ()
```
gboolean
gtk_editable_get_selection_bounds (*`[GtkEditable](gtkeditable#GtkEditable-struct) *editable`*,
*`int *start_pos`*,
*`int *end_pos`*);
```
Retrieves the selection bound of the editable.
*`start_pos`* will be filled with the start of the selection and *`end_pos`* with end. If no text was selected both will be identical and `FALSE` will be returned.
Note that positions are specified in characters, not bytes.
#### Parameters
| | | |
| --- | --- | --- |
| editable | a [GtkEditable](gtkeditable#GtkEditable-struct) | |
| start\_pos | location to store the starting position, or `NULL`. | [out][allow-none] |
| end\_pos | location to store the end position, or `NULL`. | [out][allow-none] |
#### Returns
`TRUE` if there is a non-empty selection, `FALSE` otherwise
### gtk\_editable\_select\_region ()
```
void
gtk_editable_select_region (*`[GtkEditable](gtkeditable#GtkEditable-struct) *editable`*,
*`int start_pos`*,
*`int end_pos`*);
```
Selects a region of text.
The characters that are selected are those characters at positions from *`start_pos`* up to, but not including *`end_pos`* . If *`end_pos`* is negative, then the characters selected are those characters from *`start_pos`* to the end of the text.
Note that positions are specified in characters, not bytes.
[virtual set\_selection\_bounds]
#### Parameters
| | | |
| --- | --- | --- |
| editable | a [GtkEditable](gtkeditable#GtkEditable-struct) | |
| start\_pos | start of region | |
| end\_pos | end of region | |
### gtk\_editable\_delete\_selection ()
```
void
gtk_editable_delete_selection (*`[GtkEditable](gtkeditable#GtkEditable-struct) *editable`*);
```
Deletes the currently selected text of the editable. This call doesn’t do anything if there is no selected text.
#### Parameters
| | | |
| --- | --- | --- |
| editable | a [GtkEditable](gtkeditable#GtkEditable-struct) | |
### gtk\_editable\_set\_position ()
```
void
gtk_editable_set_position (*`[GtkEditable](gtkeditable#GtkEditable-struct) *editable`*,
*`int position`*);
```
Sets the cursor position in the editable to the given value.
The cursor is displayed before the character with the given (base 0) index in the contents of the editable. The value must be less than or equal to the number of characters in the editable. A value of -1 indicates that the position should be set after the last character of the editable. Note that *`position`* is in characters, not in bytes.
#### Parameters
| | | |
| --- | --- | --- |
| editable | a [GtkEditable](gtkeditable#GtkEditable-struct) | |
| position | the position of the cursor | |
### gtk\_editable\_get\_position ()
```
int
gtk_editable_get_position (*`[GtkEditable](gtkeditable#GtkEditable-struct) *editable`*);
```
Retrieves the current position of the cursor relative to the start of the content of the editable.
Note that this position is in characters, not in bytes.
#### Parameters
| | | |
| --- | --- | --- |
| editable | a [GtkEditable](gtkeditable#GtkEditable-struct) | |
#### Returns
the cursor position
### gtk\_editable\_set\_editable ()
```
void
gtk_editable_set_editable (*`[GtkEditable](gtkeditable#GtkEditable-struct) *editable`*,
*`gboolean is_editable`*);
```
Determines if the user can edit the text in the editable widget or not.
#### Parameters
| | | |
| --- | --- | --- |
| editable | a [GtkEditable](gtkeditable#GtkEditable-struct) | |
| is\_editable | `TRUE` if the user is allowed to edit the text in the widget | |
### gtk\_editable\_get\_editable ()
```
gboolean
gtk_editable_get_editable (*`[GtkEditable](gtkeditable#GtkEditable-struct) *editable`*);
```
Retrieves whether *`editable`* is editable. See [`gtk_editable_set_editable()`](gtkeditable#gtk-editable-set-editable).
#### Parameters
| | | |
| --- | --- | --- |
| editable | a [GtkEditable](gtkeditable#GtkEditable-struct) | |
#### Returns
`TRUE` if *`editable`* is editable.
### gtk\_editable\_set\_alignment ()
```
void
gtk_editable_set_alignment (*`[GtkEditable](gtkeditable#GtkEditable-struct) *editable`*,
*`float xalign`*);
```
Sets the alignment for the contents of the editable.
This controls the horizontal positioning of the contents when the displayed text is shorter than the width of the editable.
#### Parameters
| | | |
| --- | --- | --- |
| editable | a [GtkEditable](gtkeditable#GtkEditable-struct) | |
| xalign | The horizontal alignment, from 0 (left) to 1 (right). Reversed for RTL layouts | |
### gtk\_editable\_get\_alignment ()
```
float
gtk_editable_get_alignment (*`[GtkEditable](gtkeditable#GtkEditable-struct) *editable`*);
```
Gets the value set by [`gtk_editable_set_alignment()`](gtkeditable#gtk-editable-set-alignment).
#### Parameters
| | | |
| --- | --- | --- |
| editable | a [GtkEditable](gtkeditable#GtkEditable-struct) | |
#### Returns
the alignment
### gtk\_editable\_get\_width\_chars ()
```
int
gtk_editable_get_width_chars (*`[GtkEditable](gtkeditable#GtkEditable-struct) *editable`*);
```
Gets the value set by [`gtk_editable_set_width_chars()`](gtkeditable#gtk-editable-set-width-chars).
#### Parameters
| | | |
| --- | --- | --- |
| editable | a [GtkEditable](gtkeditable#GtkEditable-struct) | |
#### Returns
number of chars to request space for, or negative if unset
### gtk\_editable\_set\_width\_chars ()
```
void
gtk_editable_set_width_chars (*`[GtkEditable](gtkeditable#GtkEditable-struct) *editable`*,
*`int n_chars`*);
```
Changes the size request of the editable to be about the right size for *`n_chars`* characters.
Note that it changes the size request, the size can still be affected by how you pack the widget into containers. If *`n_chars`* is -1, the size reverts to the default size.
#### Parameters
| | | |
| --- | --- | --- |
| editable | a [GtkEditable](gtkeditable#GtkEditable-struct) | |
| n\_chars | width in chars | |
### gtk\_editable\_get\_max\_width\_chars ()
```
int
gtk_editable_get_max_width_chars (*`[GtkEditable](gtkeditable#GtkEditable-struct) *editable`*);
```
Retrieves the desired maximum width of *`editable`* , in characters. See [`gtk_editable_set_max_width_chars()`](gtkeditable#gtk-editable-set-max-width-chars).
#### Parameters
| | | |
| --- | --- | --- |
| editable | a [GtkEditable](gtkeditable#GtkEditable-struct) | |
#### Returns
the maximum width of the entry, in characters
### gtk\_editable\_set\_max\_width\_chars ()
```
void
gtk_editable_set_max_width_chars (*`[GtkEditable](gtkeditable#GtkEditable-struct) *editable`*,
*`int n_chars`*);
```
Sets the desired maximum width in characters of *`editable`* .
#### Parameters
| | | |
| --- | --- | --- |
| editable | a [GtkEditable](gtkeditable#GtkEditable-struct) | |
| n\_chars | the new desired maximum width, in characters | |
### gtk\_editable\_get\_enable\_undo ()
```
gboolean
gtk_editable_get_enable_undo (*`[GtkEditable](gtkeditable#GtkEditable-struct) *editable`*);
```
Gets if undo/redo actions are enabled for *`editable`*
#### Parameters
| | | |
| --- | --- | --- |
| editable | a [GtkEditable](gtkeditable#GtkEditable-struct) | |
#### Returns
`TRUE` if undo is enabled
### gtk\_editable\_set\_enable\_undo ()
```
void
gtk_editable_set_enable_undo (*`[GtkEditable](gtkeditable#GtkEditable-struct) *editable`*,
*`gboolean enable_undo`*);
```
If enabled, changes to *`editable`* will be saved for undo/redo actions.
This results in an additional copy of text changes and are not stored in secure memory. As such, undo is forcefully disabled when [“visibility”](gtktext#GtkText--visibility) is set to `FALSE`.
#### Parameters
| | | |
| --- | --- | --- |
| editable | a [GtkEditable](gtkeditable#GtkEditable-struct) | |
| enable\_undo | if undo/redo should be enabled | |
### gtk\_editable\_install\_properties ()
```
guint
gtk_editable_install_properties (GObjectClass *object_class,
guint first_prop);
```
Installs the GtkEditable properties for *`class`* .
This is a helper function that should be called in class\_init, after installing your own properties.
To handle the properties in your set\_property and get\_property functions, you can either use [`gtk_editable_delegate_set_property()`](gtkeditable#gtk-editable-delegate-set-property) and [`gtk_editable_delegate_get_property()`](gtkeditable#gtk-editable-delegate-get-property) (if you are using a delegate), or remember the *`first_prop`* offset and add it to the values in the [GtkEditableProperties](gtkeditable#GtkEditableProperties) enumeration to get the property IDs for these properties.
#### Parameters
| | | |
| --- | --- | --- |
| object\_class | a GObjectClass | |
| first\_prop | property ID to use for the first property | |
#### Returns
the number of properties that were installed
### gtk\_editable\_get\_delegate ()
```
[GtkEditable](gtkeditable#GtkEditable-struct) *
gtk_editable_get_delegate (*`[GtkEditable](gtkeditable#GtkEditable-struct) *editable`*);
```
Gets the [GtkEditable](gtkeditable#GtkEditable-struct) that *`editable`* is delegating its implementation to. Typically, the delegate is a [GtkText](gtktext#GtkText-struct) widget.
#### Parameters
| | | |
| --- | --- | --- |
| editable | a [GtkEditable](gtkeditable#GtkEditable-struct) | |
#### Returns
the delegate [GtkEditable](gtkeditable#GtkEditable-struct).
[nullable][transfer none]
### gtk\_editable\_init\_delegate ()
```
void
gtk_editable_init_delegate (*`[GtkEditable](gtkeditable#GtkEditable-struct) *editable`*);
```
Sets up a delegate for [GtkEditable](gtkeditable#GtkEditable-struct), assuming that the get\_delegate vfunc in the [GtkEditable](gtkeditable#GtkEditable-struct) interface has been set up for the *`editable`* 's type.
This is a helper function that should be called in instance init, after creating the delegate object.
#### Parameters
| | | |
| --- | --- | --- |
| editable | a [GtkEditable](gtkeditable#GtkEditable-struct) | |
### gtk\_editable\_finish\_delegate ()
```
void
gtk_editable_finish_delegate (*`[GtkEditable](gtkeditable#GtkEditable-struct) *editable`*);
```
Undoes the setup done by [`gtk_editable_init_delegate()`](gtkeditable#gtk-editable-init-delegate).
This is a helper function that should be called from dispose, before removing the delegate object.
#### Parameters
| | | |
| --- | --- | --- |
| editable | a [GtkEditable](gtkeditable#GtkEditable-struct) | |
### gtk\_editable\_delegate\_set\_property ()
```
gboolean
gtk_editable_delegate_set_property (GObject *object,
guint prop_id,
const GValue *value,
GParamSpec *pspec);
```
Sets a property on the [GtkEditable](gtkeditable#GtkEditable-struct) delegate for *`object`* .
This is a helper function that should be called in set\_property, before handling your own properties.
#### Parameters
| | | |
| --- | --- | --- |
| object | a GObject | |
| prop\_id | a property ID | |
| value | value to set | |
| pspec | the GParamSpec for the property | |
#### Returns
`TRUE` if the property was found
### gtk\_editable\_delegate\_get\_property ()
```
gboolean
gtk_editable_delegate_get_property (GObject *object,
guint prop_id,
GValue *value,
GParamSpec *pspec);
```
Gets a property of the [GtkEditable](gtkeditable#GtkEditable-struct) delegate for *`object`* .
This is helper function that should be called in get\_property, before handling your own properties.
#### Parameters
| | | |
| --- | --- | --- |
| object | a GObject | |
| prop\_id | a property ID | |
| value | value to set | |
| pspec | the GParamSpec for the property | |
#### Returns
`TRUE` if the property was found
Types and Values
----------------
### GtkEditable
```
typedef struct _GtkEditable GtkEditable;
```
### struct GtkEditableInterface
```
struct GtkEditableInterface {
GTypeInterface base_iface;
/* signals */
void (* insert_text) (GtkEditable *editable,
const char *text,
int length,
int *position);
void (* delete_text) (GtkEditable *editable,
int start_pos,
int end_pos);
void (* changed) (GtkEditable *editable);
/* vtable */
const char * (* get_text) (GtkEditable *editable);
void (* do_insert_text) (GtkEditable *editable,
const char *text,
int length,
int *position);
void (* do_delete_text) (GtkEditable *editable,
int start_pos,
int end_pos);
gboolean (* get_selection_bounds) (GtkEditable *editable,
int *start_pos,
int *end_pos);
void (* set_selection_bounds) (GtkEditable *editable,
int start_pos,
int end_pos);
GtkEditable * (* get_delegate) (GtkEditable *editable);
};
```
### enum GtkEditableProperties
#### Members
| | | |
| --- | --- | --- |
| GTK\_EDITABLE\_PROP\_TEXT | | |
| GTK\_EDITABLE\_PROP\_CURSOR\_POSITION | | |
| GTK\_EDITABLE\_PROP\_SELECTION\_BOUND | | |
| GTK\_EDITABLE\_PROP\_EDITABLE | | |
| GTK\_EDITABLE\_PROP\_WIDTH\_CHARS | | |
| GTK\_EDITABLE\_PROP\_MAX\_WIDTH\_CHARS | | |
| GTK\_EDITABLE\_PROP\_XALIGN | | |
| GTK\_EDITABLE\_PROP\_ENABLE\_UNDO | | |
| GTK\_EDITABLE\_NUM\_PROPERTIES | | |
Property Details
----------------
### The `“cursor-position”` property
```
“cursor-position” int
```
The current position of the insertion cursor in chars.
Owner: GtkEditable
Flags: Read
Allowed values: [0,65535]
Default value: 0
### The `“editable”` property
```
“editable” gboolean
```
Whether the entry contents can be edited.
Owner: GtkEditable
Flags: Read / Write
Default value: TRUE
### The `“enable-undo”` property
```
“enable-undo” gboolean
```
If undo/redo should be enabled for the editable.
Owner: GtkEditable
Flags: Read / Write
Default value: TRUE
### The `“max-width-chars”` property
```
“max-width-chars” int
```
The desired maximum width of the entry, in characters.
Owner: GtkEditable
Flags: Read / Write
Allowed values: >= -1
Default value: -1
### The `“selection-bound”` property
```
“selection-bound” int
```
The position of the opposite end of the selection from the cursor in chars.
Owner: GtkEditable
Flags: Read
Allowed values: [0,65535]
Default value: 0
### The `“text”` property
```
“text” char *
```
The contents of the entry.
Owner: GtkEditable
Flags: Read / Write
Default value: ""
### The `“width-chars”` property
```
“width-chars” int
```
Number of characters to leave space for in the entry.
Owner: GtkEditable
Flags: Read / Write
Allowed values: >= -1
Default value: -1
### The `“xalign”` property
```
“xalign” float
```
The horizontal alignment, from 0 (left) to 1 (right). Reversed for RTL layouts.
Owner: GtkEditable
Flags: Read / Write
Allowed values: [0,1]
Default value: 0
Signal Details
--------------
### The `“changed”` signal
```
void
user_function ([GtkEditable](gtkeditable#GtkEditable-struct) *editable,
gpointer user_data)
```
The ::changed signal is emitted at the end of a single user-visible operation on the contents of the [GtkEditable](gtkeditable#GtkEditable-struct).
E.g., a paste operation that replaces the contents of the selection will cause only one signal emission (even though it is implemented by first deleting the selection, then inserting the new content, and may cause multiple ::notify::text signals to be emitted).
#### Parameters
| | | |
| --- | --- | --- |
| editable | the object which received the signal | |
| user\_data | user data set when the signal handler was connected. | |
Flags: Run Last
### The `“delete-text”` signal
```
void
user_function ([GtkEditable](gtkeditable#GtkEditable-struct) *editable,
int start_pos,
int end_pos,
gpointer user_data)
```
This signal is emitted when text is deleted from the widget by the user. The default handler for this signal will normally be responsible for deleting the text, so by connecting to this signal and then stopping the signal with `g_signal_stop_emission()`, it is possible to modify the range of deleted text, or prevent it from being deleted entirely. The *`start_pos`* and *`end_pos`* parameters are interpreted as for [`gtk_editable_delete_text()`](gtkeditable#gtk-editable-delete-text).
#### Parameters
| | | |
| --- | --- | --- |
| editable | the object which received the signal | |
| start\_pos | the starting position | |
| end\_pos | the end position | |
| user\_data | user data set when the signal handler was connected. | |
Flags: Run Last
### The `“insert-text”` signal
```
void
user_function ([GtkEditable](gtkeditable#GtkEditable-struct) *editable,
char *text,
int length,
gpointer position,
gpointer user_data)
```
This signal is emitted when text is inserted into the widget by the user. The default handler for this signal will normally be responsible for inserting the text, so by connecting to this signal and then stopping the signal with `g_signal_stop_emission()`, it is possible to modify the inserted text, or prevent it from being inserted entirely.
#### Parameters
| | | |
| --- | --- | --- |
| editable | the object which received the signal | |
| text | the new text to insert | |
| length | the length of the new text, in bytes, or -1 if new\_text is nul-terminated | |
| position | the position, in characters, at which to insert the new text. this is an in-out parameter. After the signal emission is finished, it should point after the newly inserted text. | [inout][type int] |
| user\_data | user data set when the signal handler was connected. | |
Flags: Run Last
| programming_docs |
gtk GtkPrintContext GtkPrintContext
===============
GtkPrintContext — Encapsulates context for drawing pages
Functions
---------
| | |
| --- | --- |
| [cairo\_t](https://developer-old.gnome.org/cairo/stable/cairo-cairo-t.html#cairo-t) \* | [gtk\_print\_context\_get\_cairo\_context](gtkprintcontext#gtk-print-context-get-cairo-context) () |
| void | [gtk\_print\_context\_set\_cairo\_context](gtkprintcontext#gtk-print-context-set-cairo-context) () |
| [GtkPageSetup](gtkpagesetup#GtkPageSetup-struct) \* | [gtk\_print\_context\_get\_page\_setup](gtkprintcontext#gtk-print-context-get-page-setup) () |
| double | [gtk\_print\_context\_get\_width](gtkprintcontext#gtk-print-context-get-width) () |
| double | [gtk\_print\_context\_get\_height](gtkprintcontext#gtk-print-context-get-height) () |
| double | [gtk\_print\_context\_get\_dpi\_x](gtkprintcontext#gtk-print-context-get-dpi-x) () |
| double | [gtk\_print\_context\_get\_dpi\_y](gtkprintcontext#gtk-print-context-get-dpi-y) () |
| [PangoFontMap](https://developer-old.gnome.org/pango/stable/pango-Fonts.html#PangoFontMap-struct) \* | [gtk\_print\_context\_get\_pango\_fontmap](gtkprintcontext#gtk-print-context-get-pango-fontmap) () |
| [PangoContext](https://developer-old.gnome.org/pango/stable/pango-Contexts.html#PangoContext-struct) \* | [gtk\_print\_context\_create\_pango\_context](gtkprintcontext#gtk-print-context-create-pango-context) () |
| [PangoLayout](https://developer-old.gnome.org/pango/stable/pango-Layout-Objects.html#PangoLayout-struct) \* | [gtk\_print\_context\_create\_pango\_layout](gtkprintcontext#gtk-print-context-create-pango-layout) () |
| gboolean | [gtk\_print\_context\_get\_hard\_margins](gtkprintcontext#gtk-print-context-get-hard-margins) () |
Types and Values
----------------
| | |
| --- | --- |
| | [GtkPrintContext](gtkprintcontext#GtkPrintContext-struct) |
Object Hierarchy
----------------
```
GObject
╰── GtkPrintContext
```
Includes
--------
```
#include <gtk/gtk.h>
```
Description
-----------
A GtkPrintContext encapsulates context information that is required when drawing pages for printing, such as the cairo context and important parameters like page size and resolution. It also lets you easily create [PangoLayout](https://developer-old.gnome.org/pango/stable/pango-Layout-Objects.html#PangoLayout-struct) and [PangoContext](https://developer-old.gnome.org/pango/stable/pango-Contexts.html#PangoContext-struct) objects that match the font metrics of the cairo surface.
GtkPrintContext objects gets passed to the [“begin-print”](gtk4-high-level-printing-api#GtkPrintOperation-begin-print), [“end-print”](gtk4-high-level-printing-api#GtkPrintOperation-end-print), [“request-page-setup”](gtk4-high-level-printing-api#GtkPrintOperation-request-page-setup) and [“draw-page”](gtk4-high-level-printing-api#GtkPrintOperation-draw-page) signals on the [GtkPrintOperation](gtk4-high-level-printing-api#GtkPrintOperation-struct).
#### Using GtkPrintContext in a [“draw-page”](gtk4-high-level-printing-api#GtkPrintOperation-draw-page) callback
```
static void
draw_page (GtkPrintOperation *operation,
GtkPrintContext *context,
int page_nr)
{
cairo_t *cr;
PangoLayout *layout;
PangoFontDescription *desc;
cr = gtk_print_context_get_cairo_context (context);
// Draw a red rectangle, as wide as the paper (inside the margins)
cairo_set_source_rgb (cr, 1.0, 0, 0);
cairo_rectangle (cr, 0, 0, gtk_print_context_get_width (context), 50);
cairo_fill (cr);
// Draw some lines
cairo_move_to (cr, 20, 10);
cairo_line_to (cr, 40, 20);
cairo_arc (cr, 60, 60, 20, 0, M_PI);
cairo_line_to (cr, 80, 20);
cairo_set_source_rgb (cr, 0, 0, 0);
cairo_set_line_width (cr, 5);
cairo_set_line_cap (cr, CAIRO_LINE_CAP_ROUND);
cairo_set_line_join (cr, CAIRO_LINE_JOIN_ROUND);
cairo_stroke (cr);
// Draw some text
layout = gtk_print_context_create_pango_layout (context);
pango_layout_set_text (layout, "Hello World! Printing is easy", -1);
desc = pango_font_description_from_string ("sans 28");
pango_layout_set_font_description (layout, desc);
pango_font_description_free (desc);
cairo_move_to (cr, 30, 20);
pango_cairo_layout_path (cr, layout);
// Font Outline
cairo_set_source_rgb (cr, 0.93, 1.0, 0.47);
cairo_set_line_width (cr, 0.5);
cairo_stroke_preserve (cr);
// Font Fill
cairo_set_source_rgb (cr, 0, 0.0, 1.0);
cairo_fill (cr);
g_object_unref (layout);
}
```
| Functions
---------
### gtk\_print\_context\_get\_cairo\_context ()
```
[cairo\_t](https://developer-old.gnome.org/cairo/stable/cairo-cairo-t.html#cairo-t) *
gtk_print_context_get_cairo_context (*`[GtkPrintContext](gtkprintcontext#GtkPrintContext-struct) *context`*);
```
Obtains the cairo context that is associated with the [GtkPrintContext](gtkprintcontext#GtkPrintContext-struct).
#### Parameters
| | | |
| --- | --- | --- |
| context | a [GtkPrintContext](gtkprintcontext#GtkPrintContext-struct) | |
#### Returns
the cairo context of *`context`* .
[transfer none]
### gtk\_print\_context\_set\_cairo\_context ()
```
void
gtk_print_context_set_cairo_context (*`[GtkPrintContext](gtkprintcontext#GtkPrintContext-struct) *context`*,
*`[cairo\_t](https://developer-old.gnome.org/cairo/stable/cairo-cairo-t.html#cairo-t) *cr`*,
*`double dpi_x`*,
*`double dpi_y`*);
```
Sets a new cairo context on a print context.
This function is intended to be used when implementing an internal print preview, it is not needed for printing, since GTK itself creates a suitable cairo context in that case.
#### Parameters
| | | |
| --- | --- | --- |
| context | a [GtkPrintContext](gtkprintcontext#GtkPrintContext-struct) | |
| cr | the cairo context | |
| dpi\_x | the horizontal resolution to use with *`cr`* | |
| dpi\_y | the vertical resolution to use with *`cr`* | |
### gtk\_print\_context\_get\_page\_setup ()
```
[GtkPageSetup](gtkpagesetup#GtkPageSetup-struct) *
gtk_print_context_get_page_setup (*`[GtkPrintContext](gtkprintcontext#GtkPrintContext-struct) *context`*);
```
Obtains the [GtkPageSetup](gtkpagesetup#GtkPageSetup-struct) that determines the page dimensions of the [GtkPrintContext](gtkprintcontext#GtkPrintContext-struct).
#### Parameters
| | | |
| --- | --- | --- |
| context | a [GtkPrintContext](gtkprintcontext#GtkPrintContext-struct) | |
#### Returns
the page setup of *`context`* .
[transfer none]
### gtk\_print\_context\_get\_width ()
```
double
gtk_print_context_get_width (*`[GtkPrintContext](gtkprintcontext#GtkPrintContext-struct) *context`*);
```
Obtains the width of the [GtkPrintContext](gtkprintcontext#GtkPrintContext-struct), in pixels.
#### Parameters
| | | |
| --- | --- | --- |
| context | a [GtkPrintContext](gtkprintcontext#GtkPrintContext-struct) | |
#### Returns
the width of *`context`*
### gtk\_print\_context\_get\_height ()
```
double
gtk_print_context_get_height (*`[GtkPrintContext](gtkprintcontext#GtkPrintContext-struct) *context`*);
```
Obtains the height of the [GtkPrintContext](gtkprintcontext#GtkPrintContext-struct), in pixels.
#### Parameters
| | | |
| --- | --- | --- |
| context | a [GtkPrintContext](gtkprintcontext#GtkPrintContext-struct) | |
#### Returns
the height of *`context`*
### gtk\_print\_context\_get\_dpi\_x ()
```
double
gtk_print_context_get_dpi_x (*`[GtkPrintContext](gtkprintcontext#GtkPrintContext-struct) *context`*);
```
Obtains the horizontal resolution of the [GtkPrintContext](gtkprintcontext#GtkPrintContext-struct), in dots per inch.
#### Parameters
| | | |
| --- | --- | --- |
| context | a [GtkPrintContext](gtkprintcontext#GtkPrintContext-struct) | |
#### Returns
the horizontal resolution of *`context`*
### gtk\_print\_context\_get\_dpi\_y ()
```
double
gtk_print_context_get_dpi_y (*`[GtkPrintContext](gtkprintcontext#GtkPrintContext-struct) *context`*);
```
Obtains the vertical resolution of the [GtkPrintContext](gtkprintcontext#GtkPrintContext-struct), in dots per inch.
#### Parameters
| | | |
| --- | --- | --- |
| context | a [GtkPrintContext](gtkprintcontext#GtkPrintContext-struct) | |
#### Returns
the vertical resolution of *`context`*
### gtk\_print\_context\_get\_pango\_fontmap ()
```
[PangoFontMap](https://developer-old.gnome.org/pango/stable/pango-Fonts.html#PangoFontMap-struct) *
gtk_print_context_get_pango_fontmap (*`[GtkPrintContext](gtkprintcontext#GtkPrintContext-struct) *context`*);
```
Returns a [PangoFontMap](https://developer-old.gnome.org/pango/stable/pango-Fonts.html#PangoFontMap-struct) that is suitable for use with the [GtkPrintContext](gtkprintcontext#GtkPrintContext-struct).
#### Parameters
| | | |
| --- | --- | --- |
| context | a [GtkPrintContext](gtkprintcontext#GtkPrintContext-struct) | |
#### Returns
the font map of *`context`* .
[transfer none]
### gtk\_print\_context\_create\_pango\_context ()
```
[PangoContext](https://developer-old.gnome.org/pango/stable/pango-Contexts.html#PangoContext-struct) *
gtk_print_context_create_pango_context
(*`[GtkPrintContext](gtkprintcontext#GtkPrintContext-struct) *context`*);
```
Creates a new [PangoContext](https://developer-old.gnome.org/pango/stable/pango-Contexts.html#PangoContext-struct) that can be used with the [GtkPrintContext](gtkprintcontext#GtkPrintContext-struct).
#### Parameters
| | | |
| --- | --- | --- |
| context | a [GtkPrintContext](gtkprintcontext#GtkPrintContext-struct) | |
#### Returns
a new Pango context for *`context`* .
[transfer full]
### gtk\_print\_context\_create\_pango\_layout ()
```
[PangoLayout](https://developer-old.gnome.org/pango/stable/pango-Layout-Objects.html#PangoLayout-struct) *
gtk_print_context_create_pango_layout (*`[GtkPrintContext](gtkprintcontext#GtkPrintContext-struct) *context`*);
```
Creates a new [PangoLayout](https://developer-old.gnome.org/pango/stable/pango-Layout-Objects.html#PangoLayout-struct) that is suitable for use with the [GtkPrintContext](gtkprintcontext#GtkPrintContext-struct).
#### Parameters
| | | |
| --- | --- | --- |
| context | a [GtkPrintContext](gtkprintcontext#GtkPrintContext-struct) | |
#### Returns
a new Pango layout for *`context`* .
[transfer full]
### gtk\_print\_context\_get\_hard\_margins ()
```
gboolean
gtk_print_context_get_hard_margins (*`[GtkPrintContext](gtkprintcontext#GtkPrintContext-struct) *context`*,
*`double *top`*,
*`double *bottom`*,
*`double *left`*,
*`double *right`*);
```
Obtains the hardware printer margins of the [GtkPrintContext](gtkprintcontext#GtkPrintContext-struct), in units.
#### Parameters
| | | |
| --- | --- | --- |
| context | a [GtkPrintContext](gtkprintcontext#GtkPrintContext-struct) | |
| top | top hardware printer margin. | [out] |
| bottom | bottom hardware printer margin. | [out] |
| left | left hardware printer margin. | [out] |
| right | right hardware printer margin. | [out] |
#### Returns
`TRUE` if the hard margins were retrieved
Types and Values
----------------
### GtkPrintContext
```
typedef struct _GtkPrintContext GtkPrintContext;
```
gtk GtkAppChooser GtkAppChooser
=============
GtkAppChooser — Interface implemented by widgets for choosing an application
Functions
---------
| | |
| --- | --- |
| GAppInfo \* | [gtk\_app\_chooser\_get\_app\_info](gtkappchooser#gtk-app-chooser-get-app-info) () |
| char \* | [gtk\_app\_chooser\_get\_content\_type](gtkappchooser#gtk-app-chooser-get-content-type) () |
| void | [gtk\_app\_chooser\_refresh](gtkappchooser#gtk-app-chooser-refresh) () |
Properties
----------
| | | |
| --- | --- | --- |
| char \* | [content-type](gtkappchooser#GtkAppChooser--content-type) | Read / Write / Construct Only |
Types and Values
----------------
| | |
| --- | --- |
| | [GtkAppChooser](gtkappchooser#GtkAppChooser-struct) |
Object Hierarchy
----------------
```
[GInterface](https://developer-old.gnome.org/gobject/stable/GTypeModule.html)
╰── GtkAppChooser
```
Prerequisites
-------------
GtkAppChooser requires [GtkWidget](gtkwidget#GtkWidget-struct).
Known Implementations
---------------------
GtkAppChooser is implemented by [GtkAppChooserButton](gtkappchooserbutton#GtkAppChooserButton-struct), [GtkAppChooserDialog](gtkappchooserdialog#GtkAppChooserDialog-struct) and [GtkAppChooserWidget](gtkappchooserwidget#GtkAppChooserWidget-struct).
Includes
--------
```
#include <gtk/gtk.h>
```
Description
-----------
[GtkAppChooser](gtkappchooser#GtkAppChooser-struct) is an interface that can be implemented by widgets which allow the user to choose an application (typically for the purpose of opening a file). The main objects that implement this interface are [GtkAppChooserWidget](gtkappchooserwidget#GtkAppChooserWidget-struct), [GtkAppChooserDialog](gtkappchooserdialog#GtkAppChooserDialog-struct) and [GtkAppChooserButton](gtkappchooserbutton#GtkAppChooserButton-struct).
Applications are represented by GIO GAppInfo objects here. GIO has a concept of recommended and fallback applications for a given content type. Recommended applications are those that claim to handle the content type itself, while fallback also includes applications that handle a more generic content type. GIO also knows the default and last-used application for a given content type. The [GtkAppChooserWidget](gtkappchooserwidget#GtkAppChooserWidget-struct) provides detailed control over whether the shown list of applications should include default, recommended or fallback applications.
To obtain the application that has been selected in a [GtkAppChooser](gtkappchooser#GtkAppChooser-struct), use [`gtk_app_chooser_get_app_info()`](gtkappchooser#gtk-app-chooser-get-app-info).
Functions
---------
### gtk\_app\_chooser\_get\_app\_info ()
```
GAppInfo *
gtk_app_chooser_get_app_info (*`[GtkAppChooser](gtkappchooser#GtkAppChooser-struct) *self`*);
```
Returns the currently selected application.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkAppChooser](gtkappchooser#GtkAppChooser-struct) | |
#### Returns
a GAppInfo for the currently selected application, or `NULL` if none is selected. Free with `g_object_unref()`.
[nullable][transfer full]
### gtk\_app\_chooser\_get\_content\_type ()
```
char *
gtk_app_chooser_get_content_type (*`[GtkAppChooser](gtkappchooser#GtkAppChooser-struct) *self`*);
```
Returns the current value of the [“content-type”](gtkappchooser#GtkAppChooser--content-type) property.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkAppChooser](gtkappchooser#GtkAppChooser-struct) | |
#### Returns
the content type of *`self`* . Free with `g_free()`
### gtk\_app\_chooser\_refresh ()
```
void
gtk_app_chooser_refresh (*`[GtkAppChooser](gtkappchooser#GtkAppChooser-struct) *self`*);
```
Reloads the list of applications.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkAppChooser](gtkappchooser#GtkAppChooser-struct) | |
Types and Values
----------------
### GtkAppChooser
```
typedef struct _GtkAppChooser GtkAppChooser;
```
Property Details
----------------
### The `“content-type”` property
```
“content-type” char *
```
The content type of the [GtkAppChooser](gtkappchooser#GtkAppChooser-struct) object.
See GContentType for more information about content types.
Owner: GtkAppChooser
Flags: Read / Write / Construct Only
Default value: NULL
See Also
--------
GAppInfo
gtk GtkHeaderBar GtkHeaderBar
============
GtkHeaderBar — A box with a centered child
Functions
---------
| | |
| --- | --- |
| [GtkWidget](gtkwidget#GtkWidget-struct) \* | [gtk\_header\_bar\_new](gtkheaderbar#gtk-header-bar-new) () |
| void | [gtk\_header\_bar\_set\_title\_widget](gtkheaderbar#gtk-header-bar-set-title-widget) () |
| [GtkWidget](gtkwidget#GtkWidget-struct) \* | [gtk\_header\_bar\_get\_title\_widget](gtkheaderbar#gtk-header-bar-get-title-widget) () |
| void | [gtk\_header\_bar\_pack\_start](gtkheaderbar#gtk-header-bar-pack-start) () |
| void | [gtk\_header\_bar\_pack\_end](gtkheaderbar#gtk-header-bar-pack-end) () |
| void | [gtk\_header\_bar\_remove](gtkheaderbar#gtk-header-bar-remove) () |
| void | [gtk\_header\_bar\_set\_show\_title\_buttons](gtkheaderbar#gtk-header-bar-set-show-title-buttons) () |
| gboolean | [gtk\_header\_bar\_get\_show\_title\_buttons](gtkheaderbar#gtk-header-bar-get-show-title-buttons) () |
| void | [gtk\_header\_bar\_set\_decoration\_layout](gtkheaderbar#gtk-header-bar-set-decoration-layout) () |
| const char \* | [gtk\_header\_bar\_get\_decoration\_layout](gtkheaderbar#gtk-header-bar-get-decoration-layout) () |
Properties
----------
| | | |
| --- | --- | --- |
| char \* | [decoration-layout](gtkheaderbar#GtkHeaderBar--decoration-layout) | Read / Write |
| gboolean | [show-title-buttons](gtkheaderbar#GtkHeaderBar--show-title-buttons) | Read / Write |
| [GtkWidget](gtkwidget#GtkWidget-struct) \* | [title-widget](gtkheaderbar#GtkHeaderBar--title-widget) | Read / Write |
Types and Values
----------------
| | |
| --- | --- |
| | [GtkHeaderBar](gtkheaderbar#GtkHeaderBar-struct) |
Object Hierarchy
----------------
```
GObject
╰── GInitiallyUnowned
╰── [GtkWidget](gtkwidget#GtkWidget-struct)
╰── GtkHeaderBar
```
Implemented Interfaces
----------------------
GtkHeaderBar implements [GtkAccessible](gtkaccessible#GtkAccessible-struct), [GtkBuildable](gtkbuildable#GtkBuildable-struct) and [GtkConstraintTarget](gtkconstraint#GtkConstraintTarget-struct).
Includes
--------
```
#include <gtk/gtk.h>
```
Description
-----------
GtkHeaderBar is similar to a horizontal [GtkBox](gtkbox#GtkBox-struct). It allows children to be placed at the start or the end. In addition, it allows the window title to be displayed. The title will be centered with respect to the width of the box, even if the children at either side take up different amounts of space.
GtkHeaderBar can add typical window frame controls, such as minimize, maximize and close buttons, or the window icon.
For these reasons, GtkHeaderBar is the natural choice for use as the custom titlebar widget of a [GtkWindow](gtkwindow#GtkWindow-struct) (see [`gtk_window_set_titlebar()`](gtkwindow#gtk-window-set-titlebar)), as it gives features typical of titlebars while allowing the addition of child widgets.
The GtkHeaderBar implementation of the [GtkBuildable](gtkbuildable#GtkBuildable-struct) interface supports adding children at the start or end sides by specifying “start” or “end” as the “type” attribute of a <child> element, or setting the title widget by specifying “title” value.
By default the GtkHeaderBar uses a [GtkLabel](gtklabel#GtkLabel-struct) displaying the title of the window it is contained in as the title widget, equivalent to the following UI definition:
### CSS nodes
```
<object class="GtkHeaderBar">
<property name="title-widget">
<object class="GtkLabel">
<property name="label" translatable="yes">Label</property>
<property name="single-line-mode">True</property>
<property name="ellipsize">end</property>
<property name="width-chars">5</property>
<style>
<class name="title"/>
</style>
</object>
</property>
</object>
```
| A [GtkHeaderBar](gtkheaderbar#GtkHeaderBar-struct)'s CSS node is called `headerbar`. It contains a `windowhandle` subnode, which contains a `box` subnode, which contains two `box` subnodes at the start and end of the header bar, as well as a center node that represents the title.
Each of the boxes contains a `windowcontrols` subnode, see [GtkWindowControls](gtkwindowcontrols#GtkWindowControls-struct) for details, as well as other children.
### Accessibility
GtkHeaderBar uses the [`GTK_ACCESSIBLE_ROLE_GROUP`](gtkaccessible#GTK-ACCESSIBLE-ROLE-GROUP:CAPS) role.
Functions
---------
### gtk\_header\_bar\_new ()
```
[GtkWidget](gtkwidget#GtkWidget-struct) *
gtk_header_bar_new (*`void`*);
```
Creates a new [GtkHeaderBar](gtkheaderbar#GtkHeaderBar-struct) widget.
#### Returns
a new [GtkHeaderBar](gtkheaderbar#GtkHeaderBar-struct)
### gtk\_header\_bar\_set\_title\_widget ()
```
void
gtk_header_bar_set_title_widget (*`[GtkHeaderBar](gtkheaderbar#GtkHeaderBar-struct) *bar`*,
*`[GtkWidget](gtkwidget#GtkWidget-struct) *title_widget`*);
```
Sets the title for the [GtkHeaderBar](gtkheaderbar#GtkHeaderBar-struct).
When set to `NULL`, the headerbar will display the title of the window it is contained in.
The title should help a user identify the current view. To achieve the same style as the builtin title, use the “title” style class.
You should set the title widget to `NULL`, for the window title label to be visible again.
#### Parameters
| | | |
| --- | --- | --- |
| bar | a [GtkHeaderBar](gtkheaderbar#GtkHeaderBar-struct) | |
| title\_widget | a widget to use for a title. | [allow-none] |
### gtk\_header\_bar\_get\_title\_widget ()
```
[GtkWidget](gtkwidget#GtkWidget-struct) *
gtk_header_bar_get_title_widget (*`[GtkHeaderBar](gtkheaderbar#GtkHeaderBar-struct) *bar`*);
```
Retrieves the title widget of the header. See [`gtk_header_bar_set_title_widget()`](gtkheaderbar#gtk-header-bar-set-title-widget).
#### Parameters
| | | |
| --- | --- | --- |
| bar | a [GtkHeaderBar](gtkheaderbar#GtkHeaderBar-struct) | |
#### Returns
the title widget of the header, or `NULL` if none has been set explicitly.
[nullable][transfer none]
### gtk\_header\_bar\_pack\_start ()
```
void
gtk_header_bar_pack_start (*`[GtkHeaderBar](gtkheaderbar#GtkHeaderBar-struct) *bar`*,
*`[GtkWidget](gtkwidget#GtkWidget-struct) *child`*);
```
Adds *`child`* to *`bar`* , packed with reference to the start of the *`bar`* .
#### Parameters
| | | |
| --- | --- | --- |
| bar | A [GtkHeaderBar](gtkheaderbar#GtkHeaderBar-struct) | |
| child | the [GtkWidget](gtkwidget#GtkWidget-struct) to be added to *`bar`* | |
### gtk\_header\_bar\_pack\_end ()
```
void
gtk_header_bar_pack_end (*`[GtkHeaderBar](gtkheaderbar#GtkHeaderBar-struct) *bar`*,
*`[GtkWidget](gtkwidget#GtkWidget-struct) *child`*);
```
Adds *`child`* to *`bar`* , packed with reference to the end of the *`bar`* .
#### Parameters
| | | |
| --- | --- | --- |
| bar | A [GtkHeaderBar](gtkheaderbar#GtkHeaderBar-struct) | |
| child | the [GtkWidget](gtkwidget#GtkWidget-struct) to be added to *`bar`* | |
### gtk\_header\_bar\_remove ()
```
void
gtk_header_bar_remove (*`[GtkHeaderBar](gtkheaderbar#GtkHeaderBar-struct) *bar`*,
*`[GtkWidget](gtkwidget#GtkWidget-struct) *child`*);
```
Removes a child from *`bar`* , after it has been added with [`gtk_header_bar_pack_start()`](gtkheaderbar#gtk-header-bar-pack-start), [`gtk_header_bar_pack_end()`](gtkheaderbar#gtk-header-bar-pack-end) or [`gtk_header_bar_set_title_widget()`](gtkheaderbar#gtk-header-bar-set-title-widget).
#### Parameters
| | | |
| --- | --- | --- |
| bar | a [GtkHeaderBar](gtkheaderbar#GtkHeaderBar-struct) | |
| child | the child to remove | |
### gtk\_header\_bar\_set\_show\_title\_buttons ()
```
void
gtk_header_bar_set_show_title_buttons (*`[GtkHeaderBar](gtkheaderbar#GtkHeaderBar-struct) *bar`*,
*`gboolean setting`*);
```
Sets whether this header bar shows the standard window title buttons including close, maximize, and minimize.
#### Parameters
| | | |
| --- | --- | --- |
| bar | a [GtkHeaderBar](gtkheaderbar#GtkHeaderBar-struct) | |
| setting | `TRUE` to show standard title buttons | |
### gtk\_header\_bar\_get\_show\_title\_buttons ()
```
gboolean
gtk_header_bar_get_show_title_buttons (*`[GtkHeaderBar](gtkheaderbar#GtkHeaderBar-struct) *bar`*);
```
Returns whether this header bar shows the standard window title buttons.
#### Parameters
| | | |
| --- | --- | --- |
| bar | a [GtkHeaderBar](gtkheaderbar#GtkHeaderBar-struct) | |
#### Returns
`TRUE` if title buttons are shown
### gtk\_header\_bar\_set\_decoration\_layout ()
```
void
gtk_header_bar_set_decoration_layout (*`[GtkHeaderBar](gtkheaderbar#GtkHeaderBar-struct) *bar`*,
*`const char *layout`*);
```
Sets the decoration layout for this header bar, overriding the [“gtk-decoration-layout”](gtksettings#GtkSettings--gtk-decoration-layout) setting.
There can be valid reasons for overriding the setting, such as a header bar design that does not allow for buttons to take room on the right, or only offers room for a single close button. Split header bars are another example for overriding the setting.
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 and icon (the window icon).
For example, “icon:minimize,maximize,close” specifies a icon on the left, and minimize, maximize and close buttons on the right.
#### Parameters
| | | |
| --- | --- | --- |
| bar | a [GtkHeaderBar](gtkheaderbar#GtkHeaderBar-struct) | |
| layout | a decoration layout, or `NULL` to unset the layout. | [allow-none] |
### gtk\_header\_bar\_get\_decoration\_layout ()
```
const char *
gtk_header_bar_get_decoration_layout (*`[GtkHeaderBar](gtkheaderbar#GtkHeaderBar-struct) *bar`*);
```
Gets the decoration layout set with [`gtk_header_bar_set_decoration_layout()`](gtkheaderbar#gtk-header-bar-set-decoration-layout).
#### Parameters
| | | |
| --- | --- | --- |
| bar | a [GtkHeaderBar](gtkheaderbar#GtkHeaderBar-struct) | |
#### Returns
the decoration layout.
[nullable]
Types and Values
----------------
### GtkHeaderBar
```
typedef struct _GtkHeaderBar GtkHeaderBar;
```
Property Details
----------------
### The `“decoration-layout”` property
```
“decoration-layout” char *
```
The decoration layout for buttons. If this property is not set, the [“gtk-decoration-layout”](gtksettings#GtkSettings--gtk-decoration-layout) setting is used.
See [`gtk_header_bar_set_decoration_layout()`](gtkheaderbar#gtk-header-bar-set-decoration-layout) for information about the format of this string.
Owner: GtkHeaderBar
Flags: Read / Write
Default value: NULL
### The `“show-title-buttons”` property
```
“show-title-buttons” gboolean
```
Whether to show title buttons like close, minimize, maximize.
Which buttons are actually shown and where is determined by the [“decoration-layout”](gtkheaderbar#GtkHeaderBar--decoration-layout) property, and by the state of the window (e.g. a close button will not be shown if the window can't be closed).
Owner: GtkHeaderBar
Flags: Read / Write
Default value: TRUE
### The `“title-widget”` property
```
“title-widget” [GtkWidget](gtkwidget#GtkWidget-struct) *
```
Title widget to display.
Owner: GtkHeaderBar
Flags: Read / Write
See Also
--------
[GtkBox](gtkbox#GtkBox-struct), [GtkActionBar](gtkactionbar#GtkActionBar-struct)
| programming_docs |
gtk GtkEventControllerScroll GtkEventControllerScroll
========================
GtkEventControllerScroll — Event controller for scroll events
Functions
---------
| | |
| --- | --- |
| [GtkEventController](gtkeventcontroller#GtkEventController-struct) \* | [gtk\_event\_controller\_scroll\_new](gtkeventcontrollerscroll#gtk-event-controller-scroll-new) () |
| void | [gtk\_event\_controller\_scroll\_set\_flags](gtkeventcontrollerscroll#gtk-event-controller-scroll-set-flags) () |
| [GtkEventControllerScrollFlags](gtkeventcontrollerscroll#GtkEventControllerScrollFlags) | [gtk\_event\_controller\_scroll\_get\_flags](gtkeventcontrollerscroll#gtk-event-controller-scroll-get-flags) () |
Properties
----------
| | | |
| --- | --- | --- |
| [GtkEventControllerScrollFlags](gtkeventcontrollerscroll#GtkEventControllerScrollFlags) | [flags](gtkeventcontrollerscroll#GtkEventControllerScroll--flags) | Read / Write |
Signals
-------
| | | |
| --- | --- | --- |
| void | [decelerate](gtkeventcontrollerscroll#GtkEventControllerScroll-decelerate) | Run First |
| gboolean | [scroll](gtkeventcontrollerscroll#GtkEventControllerScroll-scroll) | Run Last |
| void | [scroll-begin](gtkeventcontrollerscroll#GtkEventControllerScroll-scroll-begin) | Run First |
| void | [scroll-end](gtkeventcontrollerscroll#GtkEventControllerScroll-scroll-end) | Run First |
Types and Values
----------------
| | |
| --- | --- |
| | [GtkEventControllerScroll](gtkeventcontrollerscroll#GtkEventControllerScroll-struct) |
| enum | [GtkEventControllerScrollFlags](gtkeventcontrollerscroll#GtkEventControllerScrollFlags) |
Object Hierarchy
----------------
```
GObject
╰── [GtkEventController](gtkeventcontroller#GtkEventController-struct)
╰── GtkEventControllerScroll
```
Includes
--------
```
#include <gtk/gtk.h>
```
Description
-----------
[GtkEventControllerScroll](gtkeventcontrollerscroll#GtkEventControllerScroll-struct) is an event controller meant to handle scroll events from mice and touchpads. It is capable of handling both discrete and continuous scroll events, abstracting them both on the [“scroll”](gtkeventcontrollerscroll#GtkEventControllerScroll-scroll) signal (deltas in the discrete case are multiples of 1).
In the case of continuous scroll events, [GtkEventControllerScroll](gtkeventcontrollerscroll#GtkEventControllerScroll-struct) encloses all [“scroll”](gtkeventcontrollerscroll#GtkEventControllerScroll-scroll) events between two [“scroll-begin”](gtkeventcontrollerscroll#GtkEventControllerScroll-scroll-begin) and [“scroll-end”](gtkeventcontrollerscroll#GtkEventControllerScroll-scroll-end) signals.
The behavior of the event controller can be modified by the flags given at creation time, or modified at a later point through [`gtk_event_controller_scroll_set_flags()`](gtkeventcontrollerscroll#gtk-event-controller-scroll-set-flags) (e.g. because the scrolling conditions of the widget changed).
The controller can be set up to emit motion for either/both vertical and horizontal scroll events through [GTK\_EVENT\_CONTROLLER\_SCROLL\_VERTICAL](gtkeventcontrollerscroll#GTK-EVENT-CONTROLLER-SCROLL-VERTICAL:CAPS), [GTK\_EVENT\_CONTROLLER\_SCROLL\_HORIZONTAL](gtkeventcontrollerscroll#GTK-EVENT-CONTROLLER-SCROLL-HORIZONTAL:CAPS) and [GTK\_EVENT\_CONTROLLER\_SCROLL\_BOTH\_AXES](gtkeventcontrollerscroll#GTK-EVENT-CONTROLLER-SCROLL-BOTH-AXES:CAPS). If any axis is disabled, the respective [“scroll”](gtkeventcontrollerscroll#GtkEventControllerScroll-scroll) delta will be 0. Vertical scroll events will be translated to horizontal motion for the devices incapable of horizontal scrolling.
The event controller can also be forced to emit discrete events on all devices through [GTK\_EVENT\_CONTROLLER\_SCROLL\_DISCRETE](gtkeventcontrollerscroll#GTK-EVENT-CONTROLLER-SCROLL-DISCRETE:CAPS). This can be used to implement discrete actions triggered through scroll events (e.g. switching across combobox options).
The [GTK\_EVENT\_CONTROLLER\_SCROLL\_KINETIC](gtkeventcontrollerscroll#GTK-EVENT-CONTROLLER-SCROLL-KINETIC:CAPS) flag toggles the emission of the [“decelerate”](gtkeventcontrollerscroll#GtkEventControllerScroll-decelerate) signal, emitted at the end of scrolling with two X/Y velocity arguments that are consistent with the motion that was received.
Functions
---------
### gtk\_event\_controller\_scroll\_new ()
```
[GtkEventController](gtkeventcontroller#GtkEventController-struct) *
gtk_event_controller_scroll_new (*`[GtkEventControllerScrollFlags](gtkeventcontrollerscroll#GtkEventControllerScrollFlags) flags`*);
```
Creates a new event controller that will handle scroll events.
#### Parameters
| | | |
| --- | --- | --- |
| flags | behavior flags | |
#### Returns
a new [GtkEventControllerScroll](gtkeventcontrollerscroll#GtkEventControllerScroll-struct)
### gtk\_event\_controller\_scroll\_set\_flags ()
```
void
gtk_event_controller_scroll_set_flags (*`[GtkEventControllerScroll](gtkeventcontrollerscroll#GtkEventControllerScroll-struct) *scroll`*,
*`[GtkEventControllerScrollFlags](gtkeventcontrollerscroll#GtkEventControllerScrollFlags) flags`*);
```
Sets the flags conditioning scroll controller behavior.
#### Parameters
| | | |
| --- | --- | --- |
| scroll | a [GtkEventControllerScroll](gtkeventcontrollerscroll#GtkEventControllerScroll-struct) | |
| flags | behavior flags | |
### gtk\_event\_controller\_scroll\_get\_flags ()
```
[GtkEventControllerScrollFlags](gtkeventcontrollerscroll#GtkEventControllerScrollFlags)
gtk_event_controller_scroll_get_flags (*`[GtkEventControllerScroll](gtkeventcontrollerscroll#GtkEventControllerScroll-struct) *scroll`*);
```
Gets the flags conditioning the scroll controller behavior.
#### Parameters
| | | |
| --- | --- | --- |
| scroll | a [GtkEventControllerScroll](gtkeventcontrollerscroll#GtkEventControllerScroll-struct) | |
#### Returns
the controller flags.
Types and Values
----------------
### GtkEventControllerScroll
```
typedef struct _GtkEventControllerScroll GtkEventControllerScroll;
```
### enum GtkEventControllerScrollFlags
Describes the behavior of a [GtkEventControllerScroll](gtkeventcontrollerscroll#GtkEventControllerScroll-struct).
#### Members
| | | |
| --- | --- | --- |
| GTK\_EVENT\_CONTROLLER\_SCROLL\_NONE | Don't emit scroll. | |
| GTK\_EVENT\_CONTROLLER\_SCROLL\_VERTICAL | Emit scroll with vertical deltas. | |
| GTK\_EVENT\_CONTROLLER\_SCROLL\_HORIZONTAL | Emit scroll with horizontal deltas. | |
| GTK\_EVENT\_CONTROLLER\_SCROLL\_DISCRETE | Only emit deltas that are multiples of 1. | |
| GTK\_EVENT\_CONTROLLER\_SCROLL\_KINETIC | Emit [“decelerate”](gtkeventcontrollerscroll#GtkEventControllerScroll-decelerate) after continuous scroll finishes. | |
| GTK\_EVENT\_CONTROLLER\_SCROLL\_BOTH\_AXES | Emit scroll on both axes. | |
Property Details
----------------
### The `“flags”` property
```
“flags” [GtkEventControllerScrollFlags](gtkeventcontrollerscroll#GtkEventControllerScrollFlags)
```
The flags affecting event controller behavior
Owner: GtkEventControllerScroll
Flags: Read / Write
Signal Details
--------------
### The `“decelerate”` signal
```
void
user_function ([GtkEventControllerScroll](gtkeventcontrollerscroll#GtkEventControllerScroll-struct) *controller,
double vel_x,
double vel_y,
gpointer user_data)
```
Emitted after scroll is finished if the [GTK\_EVENT\_CONTROLLER\_SCROLL\_KINETIC](gtkeventcontrollerscroll#GTK-EVENT-CONTROLLER-SCROLL-KINETIC:CAPS) flag is set. *`vel_x`* and *`vel_y`* express the initial velocity that was imprinted by the scroll events. *`vel_x`* and *`vel_y`* are expressed in pixels/ms.
#### Parameters
| | | |
| --- | --- | --- |
| controller | The object that received the signal | |
| vel\_x | X velocity | |
| vel\_y | Y velocity | |
| user\_data | user data set when the signal handler was connected. | |
Flags: Run First
### The `“scroll”` signal
```
gboolean
user_function ([GtkEventControllerScroll](gtkeventcontrollerscroll#GtkEventControllerScroll-struct) *controller,
double dx,
double dy,
gpointer user_data)
```
Signals that the widget should scroll by the amount specified by *`dx`* and *`dy`* .
#### Parameters
| | | |
| --- | --- | --- |
| controller | The object that received the signal | |
| dx | X delta | |
| dy | Y delta | |
| user\_data | user data set when the signal handler was connected. | |
#### Returns
`TRUE` if the scroll event was handled, `FALSE` otherwise.
Flags: Run Last
### The `“scroll-begin”` signal
```
void
user_function ([GtkEventControllerScroll](gtkeventcontrollerscroll#GtkEventControllerScroll-struct) *controller,
gpointer user_data)
```
Signals that a new scrolling operation has begun. It will only be emitted on devices capable of it.
#### Parameters
| | | |
| --- | --- | --- |
| controller | The object that received the signal | |
| user\_data | user data set when the signal handler was connected. | |
Flags: Run First
### The `“scroll-end”` signal
```
void
user_function ([GtkEventControllerScroll](gtkeventcontrollerscroll#GtkEventControllerScroll-struct) *controller,
gpointer user_data)
```
Signals that a new scrolling operation has finished. It will only be emitted on devices capable of it.
#### Parameters
| | | |
| --- | --- | --- |
| controller | The object that received the signal | |
| user\_data | user data set when the signal handler was connected. | |
Flags: Run First
See Also
--------
[GtkEventController](gtkeventcontroller#GtkEventController-struct)
gtk GtkTreeStore GtkTreeStore
============
GtkTreeStore — A tree-like data structure that can be used with the GtkTreeView
Functions
---------
| | |
| --- | --- |
| [GtkTreeStore](gtktreestore#GtkTreeStore-struct) \* | [gtk\_tree\_store\_new](gtktreestore#gtk-tree-store-new) () |
| [GtkTreeStore](gtktreestore#GtkTreeStore-struct) \* | [gtk\_tree\_store\_newv](gtktreestore#gtk-tree-store-newv) () |
| void | [gtk\_tree\_store\_set\_column\_types](gtktreestore#gtk-tree-store-set-column-types) () |
| void | [gtk\_tree\_store\_set\_value](gtktreestore#gtk-tree-store-set-value) () |
| void | [gtk\_tree\_store\_set](gtktreestore#gtk-tree-store-set) () |
| void | [gtk\_tree\_store\_set\_valist](gtktreestore#gtk-tree-store-set-valist) () |
| void | [gtk\_tree\_store\_set\_valuesv](gtktreestore#gtk-tree-store-set-valuesv) () |
| gboolean | [gtk\_tree\_store\_remove](gtktreestore#gtk-tree-store-remove) () |
| void | [gtk\_tree\_store\_insert](gtktreestore#gtk-tree-store-insert) () |
| void | [gtk\_tree\_store\_insert\_before](gtktreestore#gtk-tree-store-insert-before) () |
| void | [gtk\_tree\_store\_insert\_after](gtktreestore#gtk-tree-store-insert-after) () |
| void | [gtk\_tree\_store\_insert\_with\_values](gtktreestore#gtk-tree-store-insert-with-values) () |
| void | [gtk\_tree\_store\_insert\_with\_valuesv](gtktreestore#gtk-tree-store-insert-with-valuesv) () |
| void | [gtk\_tree\_store\_prepend](gtktreestore#gtk-tree-store-prepend) () |
| void | [gtk\_tree\_store\_append](gtktreestore#gtk-tree-store-append) () |
| gboolean | [gtk\_tree\_store\_is\_ancestor](gtktreestore#gtk-tree-store-is-ancestor) () |
| int | [gtk\_tree\_store\_iter\_depth](gtktreestore#gtk-tree-store-iter-depth) () |
| void | [gtk\_tree\_store\_clear](gtktreestore#gtk-tree-store-clear) () |
| gboolean | [gtk\_tree\_store\_iter\_is\_valid](gtktreestore#gtk-tree-store-iter-is-valid) () |
| void | [gtk\_tree\_store\_reorder](gtktreestore#gtk-tree-store-reorder) () |
| void | [gtk\_tree\_store\_swap](gtktreestore#gtk-tree-store-swap) () |
| void | [gtk\_tree\_store\_move\_before](gtktreestore#gtk-tree-store-move-before) () |
| void | [gtk\_tree\_store\_move\_after](gtktreestore#gtk-tree-store-move-after) () |
Types and Values
----------------
| | |
| --- | --- |
| struct | [GtkTreeStore](gtktreestore#GtkTreeStore-struct) |
Object Hierarchy
----------------
```
GObject
╰── GtkTreeStore
```
Implemented Interfaces
----------------------
GtkTreeStore implements [GtkTreeModel](gtktreemodel#GtkTreeModel-struct), [GtkTreeDragSource](gtk4-gtktreeview-drag-and-drop#GtkTreeDragSource-struct), [GtkTreeDragDest](gtk4-gtktreeview-drag-and-drop#GtkTreeDragDest-struct), [GtkTreeSortable](gtktreesortable#GtkTreeSortable-struct) and [GtkBuildable](gtkbuildable#GtkBuildable-struct).
Includes
--------
```
#include <gtk/gtk.h>
```
Description
-----------
The [GtkTreeStore](gtktreestore#GtkTreeStore-struct) object is a list model for use with a [GtkTreeView](gtktreeview#GtkTreeView-struct) widget. It implements the [GtkTreeModel](gtktreemodel#GtkTreeModel-struct) interface, and consequently, can use all of the methods available there. It also implements the [GtkTreeSortable](gtktreesortable#GtkTreeSortable-struct) interface so it can be sorted by the view. Finally, it also implements the tree drag and drop interfaces.
### GtkTreeStore as GtkBuildable
The GtkTreeStore implementation of the [GtkBuildable](gtkbuildable#GtkBuildable-struct) interface allows to specify the model columns with a <columns> element that may contain multiple <column> elements, each specifying one model column. The “type” attribute specifies the data type for the column.
An example of a UI Definition fragment for a tree store:
Functions
---------
### gtk\_tree\_store\_new ()
```
[GtkTreeStore](gtktreestore#GtkTreeStore-struct) *
gtk_tree_store_new (*`int n_columns`*,
*`...`*);
```
Creates a new tree store as with *`n_columns`* columns each of the types passed in. Note that only types derived from standard GObject fundamental types are supported.
As an example, `gtk_tree_store_new (3, G_TYPE_INT, G_TYPE_STRING,
GDK_TYPE_TEXTURE);` will create a new [GtkTreeStore](gtktreestore#GtkTreeStore-struct) with three columns, of type int, gchararray, and [GdkTexture](https://developer-old.gnome.org/gtk4/html/gdk4-Textures.html#GdkTexture-struct) respectively.
#### Parameters
| | | |
| --- | --- | --- |
| n\_columns | number of columns in the tree store | |
| ... | all GType types for the columns, from first to last | |
#### Returns
a new [GtkTreeStore](gtktreestore#GtkTreeStore-struct)
### gtk\_tree\_store\_newv ()
```
[GtkTreeStore](gtktreestore#GtkTreeStore-struct) *
gtk_tree_store_newv (*`int n_columns`*,
*`GType *types`*);
```
Non vararg creation function. Used primarily by language bindings.
[rename-to gtk\_tree\_store\_new]
#### Parameters
| | | |
| --- | --- | --- |
| n\_columns | number of columns in the tree store | |
| types | an array of GType types for the columns, from first to last. | [array length=n\_columns] |
#### Returns
a new [GtkTreeStore](gtktreestore#GtkTreeStore-struct).
[transfer full]
### gtk\_tree\_store\_set\_column\_types ()
```
void
gtk_tree_store_set_column_types (*`[GtkTreeStore](gtktreestore#GtkTreeStore-struct) *tree_store`*,
*`int n_columns`*,
*`GType *types`*);
```
This function is meant primarily for GObjects that inherit from [GtkTreeStore](gtktreestore#GtkTreeStore-struct), and should only be used when constructing a new [GtkTreeStore](gtktreestore#GtkTreeStore-struct). It will not function after a row has been added, or a method on the [GtkTreeModel](gtktreemodel#GtkTreeModel-struct) interface is called.
#### Parameters
| | | |
| --- | --- | --- |
| tree\_store | A [GtkTreeStore](gtktreestore#GtkTreeStore-struct) | |
| n\_columns | Number of columns for the tree store | |
| types | An array of GType types, one for each column. | [array length=n\_columns] |
### gtk\_tree\_store\_set\_value ()
```
void
gtk_tree_store_set_value (*`[GtkTreeStore](gtktreestore#GtkTreeStore-struct) *tree_store`*,
*`[GtkTreeIter](gtktreemodel#GtkTreeIter-struct) *iter`*,
*`int column`*,
*`GValue *value`*);
```
Sets the data in the cell specified by *`iter`* and *`column`* . The type of *`value`* must be convertible to the type of the column.
#### Parameters
| | | |
| --- | --- | --- |
| tree\_store | a [GtkTreeStore](gtktreestore#GtkTreeStore-struct) | |
| iter | A valid [GtkTreeIter](gtktreemodel#GtkTreeIter-struct) for the row being modified | |
| column | column number to modify | |
| value | new value for the cell | |
### gtk\_tree\_store\_set ()
```
void
gtk_tree_store_set (*`[GtkTreeStore](gtktreestore#GtkTreeStore-struct) *tree_store`*,
*`[GtkTreeIter](gtktreemodel#GtkTreeIter-struct) *iter`*,
*`...`*);
```
Sets the value of one or more cells in the row referenced by *`iter`* . The variable argument list should contain integer column numbers, each column number followed by the value to be set. The list is terminated by a -1. For example, to set column 0 with type `G_TYPE_STRING` to “Foo”, you would write `gtk_tree_store_set (store, iter, 0, "Foo", -1)`.
The value will be referenced by the store if it is a `G_TYPE_OBJECT`, and it will be copied if it is a `G_TYPE_STRING` or `G_TYPE_BOXED`.
#### Parameters
| | | |
| --- | --- | --- |
| tree\_store | A [GtkTreeStore](gtktreestore#GtkTreeStore-struct) | |
| iter | A valid [GtkTreeIter](gtktreemodel#GtkTreeIter-struct) for the row being modified | |
| ... | pairs of column number and value, terminated with -1 | |
### gtk\_tree\_store\_set\_valist ()
```
void
gtk_tree_store_set_valist (*`[GtkTreeStore](gtktreestore#GtkTreeStore-struct) *tree_store`*,
*`[GtkTreeIter](gtktreemodel#GtkTreeIter-struct) *iter`*,
*`va\_list var_args`*);
```
See [`gtk_tree_store_set()`](gtktreestore#gtk-tree-store-set); this version takes a va\_list for use by language bindings.
#### Parameters
| | | |
| --- | --- | --- |
| tree\_store | A [GtkTreeStore](gtktreestore#GtkTreeStore-struct) | |
| iter | A valid [GtkTreeIter](gtktreemodel#GtkTreeIter-struct) for the row being modified | |
| var\_args | va\_list of column/value pairs | |
### gtk\_tree\_store\_set\_valuesv ()
```
void
gtk_tree_store_set_valuesv (*`[GtkTreeStore](gtktreestore#GtkTreeStore-struct) *tree_store`*,
*`[GtkTreeIter](gtktreemodel#GtkTreeIter-struct) *iter`*,
*`int *columns`*,
*`GValue *values`*,
*`int n_values`*);
```
A variant of [`gtk_tree_store_set_valist()`](gtktreestore#gtk-tree-store-set-valist) which takes the columns and values as two arrays, instead of varargs. This function is mainly intended for language bindings or in case the number of columns to change is not known until run-time.
[rename-to gtk\_tree\_store\_set]
#### Parameters
| | | |
| --- | --- | --- |
| tree\_store | A [GtkTreeStore](gtktreestore#GtkTreeStore-struct) | |
| iter | A valid [GtkTreeIter](gtktreemodel#GtkTreeIter-struct) for the row being modified | |
| columns | an array of column numbers. | [array length=n\_values] |
| values | an array of GValues. | [array length=n\_values] |
| n\_values | the length of the *`columns`* and *`values`* arrays | |
### gtk\_tree\_store\_remove ()
```
gboolean
gtk_tree_store_remove (*`[GtkTreeStore](gtktreestore#GtkTreeStore-struct) *tree_store`*,
*`[GtkTreeIter](gtktreemodel#GtkTreeIter-struct) *iter`*);
```
Removes *`iter`* from *`tree_store`* . After being removed, *`iter`* is set to the next valid row at that level, or invalidated if it previously pointed to the last one.
#### Parameters
| | | |
| --- | --- | --- |
| tree\_store | A [GtkTreeStore](gtktreestore#GtkTreeStore-struct) | |
| iter | A valid [GtkTreeIter](gtktreemodel#GtkTreeIter-struct) | |
#### Returns
`TRUE` if *`iter`* is still valid, `FALSE` if not.
### gtk\_tree\_store\_insert ()
```
void
gtk_tree_store_insert (*`[GtkTreeStore](gtktreestore#GtkTreeStore-struct) *tree_store`*,
*`[GtkTreeIter](gtktreemodel#GtkTreeIter-struct) *iter`*,
*`[GtkTreeIter](gtktreemodel#GtkTreeIter-struct) *parent`*,
*`int position`*);
```
Creates a new row at *`position`* . If parent is non-`NULL`, then the row will be made a child of *`parent`* . Otherwise, the row will be created at the toplevel. If *`position`* is -1 or is larger than the number of rows at that level, then the new row will be inserted to the end of the list. *`iter`* will be changed to point to this new row. The row will be empty after this function is called. To fill in values, you need to call [`gtk_tree_store_set()`](gtktreestore#gtk-tree-store-set) or [`gtk_tree_store_set_value()`](gtktreestore#gtk-tree-store-set-value).
#### Parameters
| | | |
| --- | --- | --- |
| tree\_store | A [GtkTreeStore](gtktreestore#GtkTreeStore-struct) | |
| iter | An unset [GtkTreeIter](gtktreemodel#GtkTreeIter-struct) to set to the new row. | [out] |
| parent | A valid [GtkTreeIter](gtktreemodel#GtkTreeIter-struct), or `NULL`. | [allow-none] |
| position | position to insert the new row, or -1 for last | |
### gtk\_tree\_store\_insert\_before ()
```
void
gtk_tree_store_insert_before (*`[GtkTreeStore](gtktreestore#GtkTreeStore-struct) *tree_store`*,
*`[GtkTreeIter](gtktreemodel#GtkTreeIter-struct) *iter`*,
*`[GtkTreeIter](gtktreemodel#GtkTreeIter-struct) *parent`*,
*`[GtkTreeIter](gtktreemodel#GtkTreeIter-struct) *sibling`*);
```
Inserts a new row before *`sibling`* . If *`sibling`* is `NULL`, then the row will be appended to *`parent`* ’s children. If *`parent`* and *`sibling`* are `NULL`, then the row will be appended to the toplevel. If both *`sibling`* and *`parent`* are set, then *`parent`* must be the parent of *`sibling`* . When *`sibling`* is set, *`parent`* is optional.
*`iter`* will be changed to point to this new row. The row will be empty after this function is called. To fill in values, you need to call [`gtk_tree_store_set()`](gtktreestore#gtk-tree-store-set) or [`gtk_tree_store_set_value()`](gtktreestore#gtk-tree-store-set-value).
#### Parameters
| | | |
| --- | --- | --- |
| tree\_store | A [GtkTreeStore](gtktreestore#GtkTreeStore-struct) | |
| iter | An unset [GtkTreeIter](gtktreemodel#GtkTreeIter-struct) to set to the new row. | [out] |
| parent | A valid [GtkTreeIter](gtktreemodel#GtkTreeIter-struct), or `NULL`. | [allow-none] |
| sibling | A valid [GtkTreeIter](gtktreemodel#GtkTreeIter-struct), or `NULL`. | [allow-none] |
### gtk\_tree\_store\_insert\_after ()
```
void
gtk_tree_store_insert_after (*`[GtkTreeStore](gtktreestore#GtkTreeStore-struct) *tree_store`*,
*`[GtkTreeIter](gtktreemodel#GtkTreeIter-struct) *iter`*,
*`[GtkTreeIter](gtktreemodel#GtkTreeIter-struct) *parent`*,
*`[GtkTreeIter](gtktreemodel#GtkTreeIter-struct) *sibling`*);
```
Inserts a new row after *`sibling`* . If *`sibling`* is `NULL`, then the row will be prepended to *`parent`* ’s children. If *`parent`* and *`sibling`* are `NULL`, then the row will be prepended to the toplevel. If both *`sibling`* and *`parent`* are set, then *`parent`* must be the parent of *`sibling`* . When *`sibling`* is set, *`parent`* is optional.
*`iter`* will be changed to point to this new row. The row will be empty after this function is called. To fill in values, you need to call [`gtk_tree_store_set()`](gtktreestore#gtk-tree-store-set) or [`gtk_tree_store_set_value()`](gtktreestore#gtk-tree-store-set-value).
#### Parameters
| | | |
| --- | --- | --- |
| tree\_store | A [GtkTreeStore](gtktreestore#GtkTreeStore-struct) | |
| iter | An unset [GtkTreeIter](gtktreemodel#GtkTreeIter-struct) to set to the new row. | [out] |
| parent | A valid [GtkTreeIter](gtktreemodel#GtkTreeIter-struct), or `NULL`. | [allow-none] |
| sibling | A valid [GtkTreeIter](gtktreemodel#GtkTreeIter-struct), or `NULL`. | [allow-none] |
### gtk\_tree\_store\_insert\_with\_values ()
```
void
gtk_tree_store_insert_with_values (*`[GtkTreeStore](gtktreestore#GtkTreeStore-struct) *tree_store`*,
*`[GtkTreeIter](gtktreemodel#GtkTreeIter-struct) *iter`*,
*`[GtkTreeIter](gtktreemodel#GtkTreeIter-struct) *parent`*,
*`int position`*,
*`...`*);
```
Creates a new row at *`position`* . *`iter`* will be changed to point to this new row. If *`position`* is -1, or larger than the number of rows on the list, then the new row will be appended to the list. The row will be filled with the values given to this function.
Calling `gtk_tree_store_insert_with_values (tree_store, iter, position, ...)` has the same effect as calling
```
<object class="GtkTreeStore">
<columns>
<column type="gchararray"/>
<column type="gchararray"/>
<column type="gint"/>
</columns>
</object>
```
| with the different that the former will only emit a row\_inserted signal, while the latter will emit row\_inserted, row\_changed and if the tree store is sorted, rows\_reordered. Since emitting the rows\_reordered signal repeatedly can affect the performance of the program, [`gtk_tree_store_insert_with_values()`](gtktreestore#gtk-tree-store-insert-with-values) should generally be preferred when inserting rows in a sorted tree store.
#### Parameters
| | | |
| --- | --- | --- |
| tree\_store | A [GtkTreeStore](gtktreestore#GtkTreeStore-struct) | |
| iter | An unset [GtkTreeIter](gtktreemodel#GtkTreeIter-struct) to set the new row, or `NULL`. | [out][allow-none] |
| parent | A valid [GtkTreeIter](gtktreemodel#GtkTreeIter-struct), or `NULL`. | [allow-none] |
| position | position to insert the new row, or -1 to append after existing rows | |
| ... | pairs of column number and value, terminated with -1 | |
### gtk\_tree\_store\_insert\_with\_valuesv ()
```
void
gtk_tree_store_insert_with_valuesv (*`[GtkTreeStore](gtktreestore#GtkTreeStore-struct) *tree_store`*,
*`[GtkTreeIter](gtktreemodel#GtkTreeIter-struct) *iter`*,
*`[GtkTreeIter](gtktreemodel#GtkTreeIter-struct) *parent`*,
*`int position`*,
*`int *columns`*,
*`GValue *values`*,
*`int n_values`*);
```
A variant of [`gtk_tree_store_insert_with_values()`](gtktreestore#gtk-tree-store-insert-with-values) which takes the columns and values as two arrays, instead of varargs. This function is mainly intended for language bindings.
[rename-to gtk\_tree\_store\_insert\_with\_values]
#### Parameters
| | | |
| --- | --- | --- |
| tree\_store | A [GtkTreeStore](gtktreestore#GtkTreeStore-struct) | |
| iter | An unset [GtkTreeIter](gtktreemodel#GtkTreeIter-struct) to set the new row, or `NULL`. | [out][allow-none] |
| parent | A valid [GtkTreeIter](gtktreemodel#GtkTreeIter-struct), or `NULL`. | [allow-none] |
| position | position to insert the new row, or -1 for last | |
| columns | an array of column numbers. | [array length=n\_values] |
| values | an array of GValues. | [array length=n\_values] |
| n\_values | the length of the *`columns`* and *`values`* arrays | |
### gtk\_tree\_store\_prepend ()
```
void
gtk_tree_store_prepend (*`[GtkTreeStore](gtktreestore#GtkTreeStore-struct) *tree_store`*,
*`[GtkTreeIter](gtktreemodel#GtkTreeIter-struct) *iter`*,
*`[GtkTreeIter](gtktreemodel#GtkTreeIter-struct) *parent`*);
```
Prepends a new row to *`tree_store`* . If *`parent`* is non-`NULL`, then it will prepend the new row before the first child of *`parent`* , otherwise it will prepend a row to the top level. *`iter`* will be changed to point to this new row. The row will be empty after this function is called. To fill in values, you need to call [`gtk_tree_store_set()`](gtktreestore#gtk-tree-store-set) or [`gtk_tree_store_set_value()`](gtktreestore#gtk-tree-store-set-value).
#### Parameters
| | | |
| --- | --- | --- |
| tree\_store | A [GtkTreeStore](gtktreestore#GtkTreeStore-struct) | |
| iter | An unset [GtkTreeIter](gtktreemodel#GtkTreeIter-struct) to set to the prepended row. | [out] |
| parent | A valid [GtkTreeIter](gtktreemodel#GtkTreeIter-struct), or `NULL`. | [allow-none] |
### gtk\_tree\_store\_append ()
```
void
gtk_tree_store_append (*`[GtkTreeStore](gtktreestore#GtkTreeStore-struct) *tree_store`*,
*`[GtkTreeIter](gtktreemodel#GtkTreeIter-struct) *iter`*,
*`[GtkTreeIter](gtktreemodel#GtkTreeIter-struct) *parent`*);
```
Appends a new row to *`tree_store`* . If *`parent`* is non-`NULL`, then it will append the new row after the last child of *`parent`* , otherwise it will append a row to the top level. *`iter`* will be changed to point to this new row. The row will be empty after this function is called. To fill in values, you need to call [`gtk_tree_store_set()`](gtktreestore#gtk-tree-store-set) or [`gtk_tree_store_set_value()`](gtktreestore#gtk-tree-store-set-value).
#### Parameters
| | | |
| --- | --- | --- |
| tree\_store | A [GtkTreeStore](gtktreestore#GtkTreeStore-struct) | |
| iter | An unset [GtkTreeIter](gtktreemodel#GtkTreeIter-struct) to set to the appended row. | [out] |
| parent | A valid [GtkTreeIter](gtktreemodel#GtkTreeIter-struct), or `NULL`. | [allow-none] |
### gtk\_tree\_store\_is\_ancestor ()
```
gboolean
gtk_tree_store_is_ancestor (*`[GtkTreeStore](gtktreestore#GtkTreeStore-struct) *tree_store`*,
*`[GtkTreeIter](gtktreemodel#GtkTreeIter-struct) *iter`*,
*`[GtkTreeIter](gtktreemodel#GtkTreeIter-struct) *descendant`*);
```
Returns `TRUE` if *`iter`* is an ancestor of *`descendant`* . That is, *`iter`* is the parent (or grandparent or great-grandparent) of *`descendant`* .
#### Parameters
| | | |
| --- | --- | --- |
| tree\_store | A [GtkTreeStore](gtktreestore#GtkTreeStore-struct) | |
| iter | A valid [GtkTreeIter](gtktreemodel#GtkTreeIter-struct) | |
| descendant | A valid [GtkTreeIter](gtktreemodel#GtkTreeIter-struct) | |
#### Returns
`TRUE`, if *`iter`* is an ancestor of *`descendant`*
### gtk\_tree\_store\_iter\_depth ()
```
int
gtk_tree_store_iter_depth (*`[GtkTreeStore](gtktreestore#GtkTreeStore-struct) *tree_store`*,
*`[GtkTreeIter](gtktreemodel#GtkTreeIter-struct) *iter`*);
```
Returns the depth of *`iter`* . This will be 0 for anything on the root level, 1 for anything down a level, etc.
#### Parameters
| | | |
| --- | --- | --- |
| tree\_store | A [GtkTreeStore](gtktreestore#GtkTreeStore-struct) | |
| iter | A valid [GtkTreeIter](gtktreemodel#GtkTreeIter-struct) | |
#### Returns
The depth of *`iter`*
### gtk\_tree\_store\_clear ()
```
void
gtk_tree_store_clear (*`[GtkTreeStore](gtktreestore#GtkTreeStore-struct) *tree_store`*);
```
Removes all rows from *`tree_store`*
#### Parameters
| | | |
| --- | --- | --- |
| tree\_store | a [GtkTreeStore](gtktreestore#GtkTreeStore-struct) | |
### gtk\_tree\_store\_iter\_is\_valid ()
```
gboolean
gtk_tree_store_iter_is_valid (*`[GtkTreeStore](gtktreestore#GtkTreeStore-struct) *tree_store`*,
*`[GtkTreeIter](gtktreemodel#GtkTreeIter-struct) *iter`*);
```
WARNING: This function is slow. Only use it for debugging and/or testing purposes.
Checks if the given iter is a valid iter for this [GtkTreeStore](gtktreestore#GtkTreeStore-struct).
#### Parameters
| | | |
| --- | --- | --- |
| tree\_store | A [GtkTreeStore](gtktreestore#GtkTreeStore-struct). | |
| iter | A [GtkTreeIter](gtktreemodel#GtkTreeIter-struct). | |
#### Returns
`TRUE` if the iter is valid, `FALSE` if the iter is invalid.
### gtk\_tree\_store\_reorder ()
```
void
gtk_tree_store_reorder (*`[GtkTreeStore](gtktreestore#GtkTreeStore-struct) *tree_store`*,
*`[GtkTreeIter](gtktreemodel#GtkTreeIter-struct) *parent`*,
*`int *new_order`*);
```
Reorders the children of *`parent`* in *`tree_store`* to follow the order indicated by *`new_order`* . Note that this function only works with unsorted stores.
[skip]
#### Parameters
| | | |
| --- | --- | --- |
| tree\_store | A [GtkTreeStore](gtktreestore#GtkTreeStore-struct) | |
| parent | A [GtkTreeIter](gtktreemodel#GtkTreeIter-struct), or `NULL`. | [nullable] |
| new\_order | an array of integers mapping the new position of each child to its old position before the re-ordering, i.e. *`new_order`* `[newpos] = oldpos`. | [array] |
### gtk\_tree\_store\_swap ()
```
void
gtk_tree_store_swap (*`[GtkTreeStore](gtktreestore#GtkTreeStore-struct) *tree_store`*,
*`[GtkTreeIter](gtktreemodel#GtkTreeIter-struct) *a`*,
*`[GtkTreeIter](gtktreemodel#GtkTreeIter-struct) *b`*);
```
Swaps *`a`* and *`b`* in the same level of *`tree_store`* . Note that this function only works with unsorted stores.
#### Parameters
| | | |
| --- | --- | --- |
| tree\_store | A [GtkTreeStore](gtktreestore#GtkTreeStore-struct). | |
| a | A [GtkTreeIter](gtktreemodel#GtkTreeIter-struct). | |
| b | Another [GtkTreeIter](gtktreemodel#GtkTreeIter-struct). | |
### gtk\_tree\_store\_move\_before ()
```
void
gtk_tree_store_move_before (*`[GtkTreeStore](gtktreestore#GtkTreeStore-struct) *tree_store`*,
*`[GtkTreeIter](gtktreemodel#GtkTreeIter-struct) *iter`*,
*`[GtkTreeIter](gtktreemodel#GtkTreeIter-struct) *position`*);
```
Moves *`iter`* in *`tree_store`* to the position before *`position`* . *`iter`* and *`position`* should be in the same level. Note that this function only works with unsorted stores. If *`position`* is `NULL`, *`iter`* will be moved to the end of the level.
#### Parameters
| | | |
| --- | --- | --- |
| tree\_store | A [GtkTreeStore](gtktreestore#GtkTreeStore-struct). | |
| iter | A [GtkTreeIter](gtktreemodel#GtkTreeIter-struct). | |
| position | A [GtkTreeIter](gtktreemodel#GtkTreeIter-struct) or `NULL`. | [allow-none] |
### gtk\_tree\_store\_move\_after ()
```
void
gtk_tree_store_move_after (*`[GtkTreeStore](gtktreestore#GtkTreeStore-struct) *tree_store`*,
*`[GtkTreeIter](gtktreemodel#GtkTreeIter-struct) *iter`*,
*`[GtkTreeIter](gtktreemodel#GtkTreeIter-struct) *position`*);
```
Moves *`iter`* in *`tree_store`* to the position after *`position`* . *`iter`* and *`position`* should be in the same level. Note that this function only works with unsorted stores. If *`position`* is `NULL`, *`iter`* will be moved to the start of the level.
#### Parameters
| | | |
| --- | --- | --- |
| tree\_store | A [GtkTreeStore](gtktreestore#GtkTreeStore-struct). | |
| iter | A [GtkTreeIter](gtktreemodel#GtkTreeIter-struct). | |
| position | A [GtkTreeIter](gtktreemodel#GtkTreeIter-struct). | [allow-none] |
Types and Values
----------------
### struct GtkTreeStore
```
struct GtkTreeStore;
```
See Also
--------
[GtkTreeModel](gtktreemodel#GtkTreeModel-struct)
| programming_docs |
gtk GtkColumnView GtkColumnView
=============
GtkColumnView — A widget for displaying lists in multiple columns
Functions
---------
| | |
| --- | --- |
| [GtkWidget](gtkwidget#GtkWidget-struct) \* | [gtk\_column\_view\_new](gtkcolumnview#gtk-column-view-new) () |
| void | [gtk\_column\_view\_append\_column](gtkcolumnview#gtk-column-view-append-column) () |
| void | [gtk\_column\_view\_insert\_column](gtkcolumnview#gtk-column-view-insert-column) () |
| void | [gtk\_column\_view\_remove\_column](gtkcolumnview#gtk-column-view-remove-column) () |
| GListModel \* | [gtk\_column\_view\_get\_columns](gtkcolumnview#gtk-column-view-get-columns) () |
| [GtkSelectionModel](gtkselectionmodel#GtkSelectionModel-struct) \* | [gtk\_column\_view\_get\_model](gtkcolumnview#gtk-column-view-get-model) () |
| void | [gtk\_column\_view\_set\_model](gtkcolumnview#gtk-column-view-set-model) () |
| [GtkSorter](gtksorter#GtkSorter-struct) \* | [gtk\_column\_view\_get\_sorter](gtkcolumnview#gtk-column-view-get-sorter) () |
| gboolean | [gtk\_column\_view\_get\_show\_row\_separators](gtkcolumnview#gtk-column-view-get-show-row-separators) () |
| void | [gtk\_column\_view\_set\_show\_row\_separators](gtkcolumnview#gtk-column-view-set-show-row-separators) () |
| gboolean | [gtk\_column\_view\_get\_show\_column\_separators](gtkcolumnview#gtk-column-view-get-show-column-separators) () |
| void | [gtk\_column\_view\_set\_show\_column\_separators](gtkcolumnview#gtk-column-view-set-show-column-separators) () |
| void | [gtk\_column\_view\_sort\_by\_column](gtkcolumnview#gtk-column-view-sort-by-column) () |
| void | [gtk\_column\_view\_set\_single\_click\_activate](gtkcolumnview#gtk-column-view-set-single-click-activate) () |
| gboolean | [gtk\_column\_view\_get\_single\_click\_activate](gtkcolumnview#gtk-column-view-get-single-click-activate) () |
| void | [gtk\_column\_view\_set\_reorderable](gtkcolumnview#gtk-column-view-set-reorderable) () |
| gboolean | [gtk\_column\_view\_get\_reorderable](gtkcolumnview#gtk-column-view-get-reorderable) () |
| void | [gtk\_column\_view\_set\_enable\_rubberband](gtkcolumnview#gtk-column-view-set-enable-rubberband) () |
| gboolean | [gtk\_column\_view\_get\_enable\_rubberband](gtkcolumnview#gtk-column-view-get-enable-rubberband) () |
Properties
----------
| | | |
| --- | --- | --- |
| GListModel \* | [columns](gtkcolumnview#GtkColumnView--columns) | Read |
| gboolean | [enable-rubberband](gtkcolumnview#GtkColumnView--enable-rubberband) | Read / Write |
| [GtkSelectionModel](gtkselectionmodel#GtkSelectionModel-struct) \* | [model](gtkcolumnview#GtkColumnView--model) | Read / Write |
| gboolean | [reorderable](gtkcolumnview#GtkColumnView--reorderable) | Read / Write |
| gboolean | [show-column-separators](gtkcolumnview#GtkColumnView--show-column-separators) | Read / Write |
| gboolean | [show-row-separators](gtkcolumnview#GtkColumnView--show-row-separators) | Read / Write |
| gboolean | [single-click-activate](gtkcolumnview#GtkColumnView--single-click-activate) | Read / Write |
| [GtkSorter](gtksorter#GtkSorter-struct) \* | [sorter](gtkcolumnview#GtkColumnView--sorter) | Read |
Signals
-------
| | | |
| --- | --- | --- |
| void | [activate](gtkcolumnview#GtkColumnView-activate) | Run Last |
Types and Values
----------------
| | |
| --- | --- |
| | [GtkColumnView](gtkcolumnview#GtkColumnView-struct) |
Object Hierarchy
----------------
```
GObject
╰── GInitiallyUnowned
╰── [GtkWidget](gtkwidget#GtkWidget-struct)
╰── GtkColumnView
```
Implemented Interfaces
----------------------
GtkColumnView implements [GtkAccessible](gtkaccessible#GtkAccessible-struct), [GtkBuildable](gtkbuildable#GtkBuildable-struct), [GtkConstraintTarget](gtkconstraint#GtkConstraintTarget-struct) and [GtkScrollable](gtkscrollable#GtkScrollable-struct).
Includes
--------
```
#include <gtk/gtk.h>
```
Description
-----------
GtkColumnView is a widget to present a view into a large dynamic list of items using multiple columns with headers.
GtkColumnView uses the factories of its columns to generate a cell widget for each column, for each visible item and displays them together as the row for this item. The [“show-row-separators”](gtkcolumnview#GtkColumnView--show-row-separators) and [“show-column-separators”](gtkcolumnview#GtkColumnView--show-column-separators) properties offer a simple way to display separators between the rows or columns.
GtkColumnView allows the user to select items according to the selection characteristics of the model. For models that allow multiple selected items, it is possible to turn on \*rubberband selection\*, using [“enable-rubberband”](gtkcolumnview#GtkColumnView--enable-rubberband).
The column view supports sorting that can be customized by the user by clicking on column headers. To set this up, the [GtkSorter](gtksorter#GtkSorter-struct) returned by [`gtk_column_view_get_sorter()`](gtkcolumnview#gtk-column-view-get-sorter) must be attached to a sort model for the data that the view is showing, and the columns must have sorters attached to them by calling [`gtk_column_view_column_set_sorter()`](gtkcolumnviewcolumn#gtk-column-view-column-set-sorter). The initial sort order can be set with [`gtk_column_view_sort_by_column()`](gtkcolumnview#gtk-column-view-sort-by-column).
The column view also supports interactive resizing and reordering of columns, via Drag-and-Drop of the column headers. This can be enabled or disabled with the [“reorderable”](gtkcolumnview#GtkColumnView--reorderable) and [“resizable”](gtkcolumnviewcolumn#GtkColumnViewColumn--resizable) properties.
To learn more about the list widget framework, see the [overview](#ListWidget).
### CSS nodes
GtkColumnView uses a single CSS node named columnview. It may carry the .column-separators style class, when [“show-column-separators”](gtkcolumnview#GtkColumnView--show-column-separators) property is set. Header widets appear below a node with name header. The rows are contained in a GtkListView widget, so there is a listview node with the same structure as for a standalone GtkListView widget. If [“show-row-separators”](gtkcolumnview#GtkColumnView--show-row-separators) is set, it will be passed on to the list view, causing its CSS node to carry the .separators style class. For rubberband selection, a node with name rubberband is used.
The main columnview node may also carry style classes to select the style of [list presentation](listcontainers#list-styles): .rich-list, .navigation-sidebar or .data-table.
### Accessibility
GtkColumnView uses the [GTK\_ACCESSIBLE\_ROLE\_TREE\_GRID](gtkaccessible#GTK-ACCESSIBLE-ROLE-TREE-GRID:CAPS) role, header title widgets are using the [GTK\_ACCESSIBLE\_ROLE\_COLUMN\_HEADER](gtkaccessible#GTK-ACCESSIBLE-ROLE-COLUMN-HEADER:CAPS) role. The row widgets are using the [GTK\_ACCESSIBLE\_ROLE\_ROW](gtkaccessible#GTK-ACCESSIBLE-ROLE-ROW:CAPS) role, and individual cells are using the [GTK\_ACCESSIBLE\_ROLE\_GRID\_CELL](gtkaccessible#GTK-ACCESSIBLE-ROLE-GRID-CELL:CAPS) role
Functions
---------
### gtk\_column\_view\_new ()
```
[GtkWidget](gtkwidget#GtkWidget-struct) *
gtk_column_view_new (*`[GtkSelectionModel](gtkselectionmodel#GtkSelectionModel-struct) *model`*);
```
Creates a new [GtkColumnView](gtkcolumnview#GtkColumnView-struct).
You most likely want to call [`gtk_column_view_append_column()`](gtkcolumnview#gtk-column-view-append-column) to add columns next.
#### Parameters
| | | |
| --- | --- | --- |
| model | the list model to use, or `NULL`. | [allow-none][transfer full] |
#### Returns
a new [GtkColumnView](gtkcolumnview#GtkColumnView-struct)
### gtk\_column\_view\_append\_column ()
```
void
gtk_column_view_append_column (*`[GtkColumnView](gtkcolumnview#GtkColumnView-struct) *self`*,
*`[GtkColumnViewColumn](gtkcolumnviewcolumn#GtkColumnViewColumn-struct) *column`*);
```
Appends the *`column`* to the end of the columns in *`self`* .
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkColumnView](gtkcolumnview#GtkColumnView-struct) | |
| column | a [GtkColumnViewColumn](gtkcolumnviewcolumn#GtkColumnViewColumn-struct) that hasn't been added to a [GtkColumnView](gtkcolumnview#GtkColumnView-struct) yet | |
### gtk\_column\_view\_insert\_column ()
```
void
gtk_column_view_insert_column (*`[GtkColumnView](gtkcolumnview#GtkColumnView-struct) *self`*,
*`guint position`*,
*`[GtkColumnViewColumn](gtkcolumnviewcolumn#GtkColumnViewColumn-struct) *column`*);
```
Inserts a column at the given position in the columns of *`self`* .
If *`column`* is already a column of *`self`* , it will be repositioned.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkColumnView](gtkcolumnview#GtkColumnView-struct) | |
| position | the position to insert *`column`* at | |
| column | the [GtkColumnViewColumn](gtkcolumnviewcolumn#GtkColumnViewColumn-struct) to insert | |
### gtk\_column\_view\_remove\_column ()
```
void
gtk_column_view_remove_column (*`[GtkColumnView](gtkcolumnview#GtkColumnView-struct) *self`*,
*`[GtkColumnViewColumn](gtkcolumnviewcolumn#GtkColumnViewColumn-struct) *column`*);
```
Removes the *`column`* from the list of columns of *`self`* .
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkColumnView](gtkcolumnview#GtkColumnView-struct) | |
| column | a [GtkColumnViewColumn](gtkcolumnviewcolumn#GtkColumnViewColumn-struct) that's part of *`self`* | |
### gtk\_column\_view\_get\_columns ()
```
GListModel *
gtk_column_view_get_columns (*`[GtkColumnView](gtkcolumnview#GtkColumnView-struct) *self`*);
```
Gets the list of columns in this column view. This list is constant over the lifetime of *`self`* and can be used to monitor changes to the columns of *`self`* by connecting to the “items-changed” signal.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkColumnView](gtkcolumnview#GtkColumnView-struct) | |
#### Returns
The list managing the columns.
[transfer none]
### gtk\_column\_view\_get\_model ()
```
[GtkSelectionModel](gtkselectionmodel#GtkSelectionModel-struct) *
gtk_column_view_get_model (*`[GtkColumnView](gtkcolumnview#GtkColumnView-struct) *self`*);
```
Gets the model that's currently used to read the items displayed.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkColumnView](gtkcolumnview#GtkColumnView-struct) | |
#### Returns
The model in use.
[nullable][transfer none]
### gtk\_column\_view\_set\_model ()
```
void
gtk_column_view_set_model (*`[GtkColumnView](gtkcolumnview#GtkColumnView-struct) *self`*,
*`[GtkSelectionModel](gtkselectionmodel#GtkSelectionModel-struct) *model`*);
```
Sets the [GtkSelectionModel](gtkselectionmodel#GtkSelectionModel-struct) to use.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkColumnView](gtkcolumnview#GtkColumnView-struct) | |
| model | the model to use or `NULL` for none. | [allow-none][transfer none] |
### gtk\_column\_view\_get\_sorter ()
```
[GtkSorter](gtksorter#GtkSorter-struct) *
gtk_column_view_get_sorter (*`[GtkColumnView](gtkcolumnview#GtkColumnView-struct) *self`*);
```
Returns a special sorter that reflects the users sorting choices in the column view.
To allow users to customizable sorting by clicking on column headers, this sorter needs to be set on the sort model underneath the model that is displayed by the view.
See [`gtk_column_view_column_set_sorter()`](gtkcolumnviewcolumn#gtk-column-view-column-set-sorter) for setting up per-column sorting.
Here is an example:
```
columnview[.column-separators][.rich-list][.navigation-sidebar][.data-table]
├── header
│ ├── <column header>
┊ ┊
│ ╰── <column header>
│
├── listview
│
┊
╰── [rubberband]
```
| #### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkColumnView](gtkcolumnview#GtkColumnView-struct) | |
#### Returns
the [GtkSorter](gtksorter#GtkSorter-struct) of *`self`* .
[nullable][transfer none]
### gtk\_column\_view\_get\_show\_row\_separators ()
```
gboolean
gtk_column_view_get_show_row_separators
(*`[GtkColumnView](gtkcolumnview#GtkColumnView-struct) *self`*);
```
Returns whether the list should show separators between rows.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkColumnView](gtkcolumnview#GtkColumnView-struct) | |
#### Returns
`TRUE` if the list shows separators
### gtk\_column\_view\_set\_show\_row\_separators ()
```
void
gtk_column_view_set_show_row_separators
(*`[GtkColumnView](gtkcolumnview#GtkColumnView-struct) *self`*,
*`gboolean show_row_separators`*);
```
Sets whether the list should show separators between rows.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkColumnView](gtkcolumnview#GtkColumnView-struct) | |
| show\_row\_separators | `TRUE` to show row separators | |
### gtk\_column\_view\_get\_show\_column\_separators ()
```
gboolean
gtk_column_view_get_show_column_separators
(*`[GtkColumnView](gtkcolumnview#GtkColumnView-struct) *self`*);
```
Returns whether the list should show separators between columns.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkColumnView](gtkcolumnview#GtkColumnView-struct) | |
#### Returns
`TRUE` if the list shows column separators
### gtk\_column\_view\_set\_show\_column\_separators ()
```
void
gtk_column_view_set_show_column_separators
(*`[GtkColumnView](gtkcolumnview#GtkColumnView-struct) *self`*,
*`gboolean show_column_separators`*);
```
Sets whether the list should show separators between columns.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkColumnView](gtkcolumnview#GtkColumnView-struct) | |
| show\_column\_separators | `TRUE` to show column separators | |
### gtk\_column\_view\_sort\_by\_column ()
```
void
gtk_column_view_sort_by_column (*`[GtkColumnView](gtkcolumnview#GtkColumnView-struct) *self`*,
*`[GtkColumnViewColumn](gtkcolumnviewcolumn#GtkColumnViewColumn-struct) *column`*,
*`[GtkSortType](gtk4-standard-enumerations#GtkSortType) direction`*);
```
Sets the sorting of the view.
This function should be used to set up the initial sorting. At runtime, users can change the sorting of a column view by clicking on the list headers.
This call only has an effect if the sorter returned by [`gtk_column_view_get_sorter()`](gtkcolumnview#gtk-column-view-get-sorter) is set on a sort model, and [`gtk_column_view_column_set_sorter()`](gtkcolumnviewcolumn#gtk-column-view-column-set-sorter) has been called on *`column`* to associate a sorter with the column.
If *`column`* is `NULL`, the view will be unsorted.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkColumnView](gtkcolumnview#GtkColumnView-struct) | |
| column | the [GtkColumnViewColumn](gtkcolumnviewcolumn#GtkColumnViewColumn-struct) to sort by, or `NULL`. | [allow-none] |
| direction | the direction to sort in | |
### gtk\_column\_view\_set\_single\_click\_activate ()
```
void
gtk_column_view_set_single_click_activate
(*`[GtkColumnView](gtkcolumnview#GtkColumnView-struct) *self`*,
*`gboolean single_click_activate`*);
```
Sets whether rows should be activated on single click and selected on hover.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkColumnView](gtkcolumnview#GtkColumnView-struct) | |
| single\_click\_activate | `TRUE` to activate items on single click | |
### gtk\_column\_view\_get\_single\_click\_activate ()
```
gboolean
gtk_column_view_get_single_click_activate
(*`[GtkColumnView](gtkcolumnview#GtkColumnView-struct) *self`*);
```
Returns whether rows will be activated on single click and selected on hover.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkColumnView](gtkcolumnview#GtkColumnView-struct) | |
#### Returns
`TRUE` if rows are activated on single click
### gtk\_column\_view\_set\_reorderable ()
```
void
gtk_column_view_set_reorderable (*`[GtkColumnView](gtkcolumnview#GtkColumnView-struct) *self`*,
*`gboolean reorderable`*);
```
Sets whether columns should be reorderable by dragging.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkColumnView](gtkcolumnview#GtkColumnView-struct) | |
| reorderable | whether columns should be reorderable | |
### gtk\_column\_view\_get\_reorderable ()
```
gboolean
gtk_column_view_get_reorderable (*`[GtkColumnView](gtkcolumnview#GtkColumnView-struct) *self`*);
```
Returns whether columns are reorderable.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkColumnView](gtkcolumnview#GtkColumnView-struct) | |
#### Returns
`TRUE` if columns are reorderable
### gtk\_column\_view\_set\_enable\_rubberband ()
```
void
gtk_column_view_set_enable_rubberband (*`[GtkColumnView](gtkcolumnview#GtkColumnView-struct) *self`*,
*`gboolean enable_rubberband`*);
```
Sets whether selections can be changed by dragging with the mouse.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkColumnView](gtkcolumnview#GtkColumnView-struct) | |
| enable\_rubberband | `TRUE` to enable rubberband selection | |
### gtk\_column\_view\_get\_enable\_rubberband ()
```
gboolean
gtk_column_view_get_enable_rubberband (*`[GtkColumnView](gtkcolumnview#GtkColumnView-struct) *self`*);
```
Returns whether rows can be selected by dragging with the mouse.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkColumnView](gtkcolumnview#GtkColumnView-struct) | |
#### Returns
`TRUE` if rubberband selection is enabled
Types and Values
----------------
### GtkColumnView
```
typedef struct _GtkColumnView GtkColumnView;
```
GtkColumnView is the simple list implementation for GTK's list widgets.
Property Details
----------------
### The `“columns”` property
```
“columns” GListModel *
```
The list of columns
Owner: GtkColumnView
Flags: Read
### The `“enable-rubberband”` property
```
“enable-rubberband” gboolean
```
Allow rubberband selection
Owner: GtkColumnView
Flags: Read / Write
Default value: FALSE
### The `“model”` property
```
“model” [GtkSelectionModel](gtkselectionmodel#GtkSelectionModel-struct) *
```
Model for the items displayed
Owner: GtkColumnView
Flags: Read / Write
### The `“reorderable”` property
```
“reorderable” gboolean
```
Whether columns are reorderable
Owner: GtkColumnView
Flags: Read / Write
Default value: TRUE
### The `“show-column-separators”` property
```
“show-column-separators” gboolean
```
Show separators between columns
Owner: GtkColumnView
Flags: Read / Write
Default value: FALSE
### The `“show-row-separators”` property
```
“show-row-separators” gboolean
```
Show separators between rows
Owner: GtkColumnView
Flags: Read / Write
Default value: FALSE
### The `“single-click-activate”` property
```
“single-click-activate” gboolean
```
Activate rows on single click and select them on hover
Owner: GtkColumnView
Flags: Read / Write
Default value: FALSE
### The `“sorter”` property
```
“sorter” [GtkSorter](gtksorter#GtkSorter-struct) *
```
Sorter with the sorting choices of the user
Owner: GtkColumnView
Flags: Read
Signal Details
--------------
### The `“activate”` signal
```
void
user_function ([GtkColumnView](gtkcolumnview#GtkColumnView-struct) *self,
guint position,
gpointer user_data)
```
The ::activate signal is emitted when a row has been activated by the user, usually via activating the GtkListBase|list.activate-item action.
This allows for a convenient way to handle activation in a columnview. See [`gtk_list_item_set_activatable()`](gtklistitem#gtk-list-item-set-activatable) for details on how to use this signal.
#### Parameters
| | | |
| --- | --- | --- |
| self | The [GtkColumnView](gtkcolumnview#GtkColumnView-struct) | |
| position | position of item to activate | |
| user\_data | user data set when the signal handler was connected. | |
Flags: Run Last
See Also
--------
[GtkColumnViewColumn](gtkcolumnviewcolumn#GtkColumnViewColumn-struct), [GtkTreeView](gtktreeview#GtkTreeView-struct)
| programming_docs |
gtk gtk4-update-icon-cache gtk4-update-icon-cache
======================
gtk4-update-icon-cache — Icon theme caching utility
Synopsis
--------
`gtk4-update-icon-cache` [--force] [--ignore-theme-index] [ --index-only | --include-image-data ] [--source *`NAME`* ] [--quiet] [--validate] *`PATH`*
Description
-----------
**gtk4-update-icon-cache** creates mmapable cache files for icon themes.
It expects to be given the *`PATH`* to an icon theme directory containing an `index.theme`, e.g. `/usr/share/icons/hicolor`, and writes a `icon-theme.cache` containing cached information about the icons in the directory tree below the given directory.
GTK can use the cache files created by **gtk4-update-icon-cache** to avoid a lot of system call and disk seek overhead when the application starts. Since the format of the cache files allows them to be shared across multiple processes, for instance using the POSIX **mmap()** system call, the overall memory consumption is reduced as well.
Options
-------
| | |
| --- | --- |
| --force, -f | Overwrite an existing cache file even if it appears to be up-to-date. |
| --ignore-theme-index, -t | Don't check for the existence of `index.theme` in the icon theme directory. Without this option, **gtk4-update-icon-cache** refuses to create an icon cache in a directory which does not appear to be the toplevel directory of an icon theme. |
| --index-only, -i | Don't include image data in the cache. |
| --include-image-data | Include image data in the cache. |
| --source, -c | Output a C header file declaring a constant *`NAME`* with the contents of the icon cache. |
| --quiet, -q | Turn off verbose output. |
| --validate, -v | Validate existing icon cache. |
gtk GtkFixed GtkFixed
========
GtkFixed — A container which allows you to position widgets at fixed coordinates
Functions
---------
| | |
| --- | --- |
| [GtkWidget](gtkwidget#GtkWidget-struct) \* | [gtk\_fixed\_new](gtkfixed#gtk-fixed-new) () |
| void | [gtk\_fixed\_put](gtkfixed#gtk-fixed-put) () |
| void | [gtk\_fixed\_remove](gtkfixed#gtk-fixed-remove) () |
| void | [gtk\_fixed\_move](gtkfixed#gtk-fixed-move) () |
| void | [gtk\_fixed\_get\_child\_position](gtkfixed#gtk-fixed-get-child-position) () |
| [GskTransform](https://developer-old.gnome.org/gtk4/html/gsk4-GskTransform.html#GskTransform) \* | [gtk\_fixed\_get\_child\_transform](gtkfixed#gtk-fixed-get-child-transform) () |
| void | [gtk\_fixed\_set\_child\_transform](gtkfixed#gtk-fixed-set-child-transform) () |
Types and Values
----------------
| | |
| --- | --- |
| struct | [GtkFixed](gtkfixed#GtkFixed-struct) |
Object Hierarchy
----------------
```
GObject
╰── GInitiallyUnowned
╰── [GtkWidget](gtkwidget#GtkWidget-struct)
╰── GtkFixed
```
Implemented Interfaces
----------------------
GtkFixed implements [GtkAccessible](gtkaccessible#GtkAccessible-struct), [GtkBuildable](gtkbuildable#GtkBuildable-struct) and [GtkConstraintTarget](gtkconstraint#GtkConstraintTarget-struct).
Includes
--------
```
#include <gtk/gtk.h>
```
Description
-----------
The [GtkFixed](gtkfixed#GtkFixed-struct) widget is a container which can place child widgets at fixed positions and with fixed sizes, given in pixels. [GtkFixed](gtkfixed#GtkFixed-struct) performs no automatic layout management.
For most applications, you should not use this container! It keeps you from having to learn about the other GTK+ containers, but it results in broken applications. With [GtkFixed](gtkfixed#GtkFixed-struct), the following things will result in truncated text, overlapping widgets, and other display bugs:
* Themes, which may change widget sizes.
* Fonts other than the one you used to write the app will of course change the size of widgets containing text; keep in mind that users may use a larger font because of difficulty reading the default, or they may be using a different OS that provides different fonts.
* Translation of text into other languages changes its size. Also, display of non-English text will use a different font in many cases.
In addition, [GtkFixed](gtkfixed#GtkFixed-struct) does not pay attention to text direction and thus may produce unwanted results if your app is run under right-to-left languages such as Hebrew or Arabic. That is: normally GTK will order containers appropriately for the text direction, e.g. to put labels to the right of the thing they label when using an RTL language, but it can’t do that with [GtkFixed](gtkfixed#GtkFixed-struct). So if you need to reorder widgets depending on the text direction, you would need to manually detect it and adjust child positions accordingly.
Finally, fixed positioning makes it kind of annoying to add/remove GUI elements, since you have to reposition all the other elements. This is a long-term maintenance problem for your application.
If you know none of these things are an issue for your application, and prefer the simplicity of [GtkFixed](gtkfixed#GtkFixed-struct), by all means use the widget. But you should be aware of the tradeoffs.
Functions
---------
### gtk\_fixed\_new ()
```
[GtkWidget](gtkwidget#GtkWidget-struct) *
gtk_fixed_new (*`void`*);
```
Creates a new [GtkFixed](gtkfixed#GtkFixed-struct).
#### Returns
a new [GtkFixed](gtkfixed#GtkFixed-struct).
### gtk\_fixed\_put ()
```
void
gtk_fixed_put (*`[GtkFixed](gtkfixed#GtkFixed-struct) *fixed`*,
*`[GtkWidget](gtkwidget#GtkWidget-struct) *widget`*,
*`double x`*,
*`double y`*);
```
Adds a widget to a [GtkFixed](gtkfixed#GtkFixed-struct) container and assigns a translation transformation to the given *`x`* and *`y`* coordinates to it.
#### Parameters
| | | |
| --- | --- | --- |
| fixed | a [GtkFixed](gtkfixed#GtkFixed-struct). | |
| widget | the widget to add. | |
| x | the horizontal position to place the widget at. | |
| y | the vertical position to place the widget at. | |
### gtk\_fixed\_remove ()
```
void
gtk_fixed_remove (*`[GtkFixed](gtkfixed#GtkFixed-struct) *fixed`*,
*`[GtkWidget](gtkwidget#GtkWidget-struct) *widget`*);
```
Removes a child from *`fixed`* , after it has been added with [`gtk_fixed_put()`](gtkfixed#gtk-fixed-put).
#### Parameters
| | | |
| --- | --- | --- |
| fixed | a [GtkFixed](gtkfixed#GtkFixed-struct) | |
| widget | the child widget to remove | |
### gtk\_fixed\_move ()
```
void
gtk_fixed_move (*`[GtkFixed](gtkfixed#GtkFixed-struct) *fixed`*,
*`[GtkWidget](gtkwidget#GtkWidget-struct) *widget`*,
*`double x`*,
*`double y`*);
```
Sets a translation transformation to the given *`x`* and *`y`* coordinates to the child *`widget`* of the given [GtkFixed](gtkfixed#GtkFixed-struct) container.
#### Parameters
| | | |
| --- | --- | --- |
| fixed | a [GtkFixed](gtkfixed#GtkFixed-struct). | |
| widget | the child widget. | |
| x | the horizontal position to move the widget to. | |
| y | the vertical position to move the widget to. | |
### gtk\_fixed\_get\_child\_position ()
```
void
gtk_fixed_get_child_position (*`[GtkFixed](gtkfixed#GtkFixed-struct) *fixed`*,
*`[GtkWidget](gtkwidget#GtkWidget-struct) *widget`*,
*`double *x`*,
*`double *y`*);
```
Retrieves the translation transformation of the given child [GtkWidget](gtkwidget#GtkWidget-struct) in the given [GtkFixed](gtkfixed#GtkFixed-struct) container.
See also: [`gtk_fixed_get_child_transform()`](gtkfixed#gtk-fixed-get-child-transform).
#### Parameters
| | | |
| --- | --- | --- |
| fixed | a [GtkFixed](gtkfixed#GtkFixed-struct) | |
| widget | a child of *`fixed`* | |
| x | the horizontal position of the *`widget`* . | [out] |
| y | the vertical position of the *`widget`* . | [out] |
### gtk\_fixed\_get\_child\_transform ()
```
[GskTransform](https://developer-old.gnome.org/gtk4/html/gsk4-GskTransform.html#GskTransform) *
gtk_fixed_get_child_transform (*`[GtkFixed](gtkfixed#GtkFixed-struct) *fixed`*,
*`[GtkWidget](gtkwidget#GtkWidget-struct) *widget`*);
```
Retrieves the transformation for *`widget`* set using [`gtk_fixed_set_child_transform()`](gtkfixed#gtk-fixed-set-child-transform).
#### Parameters
| | | |
| --- | --- | --- |
| fixed | a [GtkFixed](gtkfixed#GtkFixed-struct) | |
| widget | a [GtkWidget](gtkwidget#GtkWidget-struct), child of *`fixed`* | |
#### Returns
a [GskTransform](https://developer-old.gnome.org/gtk4/html/gsk4-GskTransform.html#GskTransform) or `NULL` in case no transform has been set on *`widget`* .
[transfer none][nullable]
### gtk\_fixed\_set\_child\_transform ()
```
void
gtk_fixed_set_child_transform (*`[GtkFixed](gtkfixed#GtkFixed-struct) *fixed`*,
*`[GtkWidget](gtkwidget#GtkWidget-struct) *widget`*,
*`[GskTransform](https://developer-old.gnome.org/gtk4/html/gsk4-GskTransform.html#GskTransform) *transform`*);
```
Sets the transformation for *`widget`* .
This is a convenience function that retrieves the [GtkFixedLayoutChild](gtkfixedlayout#GtkFixedLayoutChild-struct) instance associated to *`widget`* and calls [`gtk_fixed_layout_child_set_transform()`](gtkfixedlayout#gtk-fixed-layout-child-set-transform).
#### Parameters
| | | |
| --- | --- | --- |
| fixed | a [GtkFixed](gtkfixed#GtkFixed-struct) | |
| widget | a [GtkWidget](gtkwidget#GtkWidget-struct), child of *`fixed`* | |
| transform | the transformation assigned to *`widget`* or `NULL` to reset *`widget`* 's transform. | [nullable] |
Types and Values
----------------
### struct GtkFixed
```
struct GtkFixed;
```
gtk GtkGestureDrag GtkGestureDrag
==============
GtkGestureDrag — Drag gesture
Functions
---------
| | |
| --- | --- |
| [GtkGesture](gtkgesture#GtkGesture-struct) \* | [gtk\_gesture\_drag\_new](gtkgesturedrag#gtk-gesture-drag-new) () |
| gboolean | [gtk\_gesture\_drag\_get\_start\_point](gtkgesturedrag#gtk-gesture-drag-get-start-point) () |
| gboolean | [gtk\_gesture\_drag\_get\_offset](gtkgesturedrag#gtk-gesture-drag-get-offset) () |
Signals
-------
| | | |
| --- | --- | --- |
| void | [drag-begin](gtkgesturedrag#GtkGestureDrag-drag-begin) | Run Last |
| void | [drag-end](gtkgesturedrag#GtkGestureDrag-drag-end) | Run Last |
| void | [drag-update](gtkgesturedrag#GtkGestureDrag-drag-update) | Run Last |
Types and Values
----------------
| | |
| --- | --- |
| | [GtkGestureDrag](gtkgesturedrag#GtkGestureDrag-struct) |
Object Hierarchy
----------------
```
GObject
╰── [GtkEventController](gtkeventcontroller#GtkEventController-struct)
╰── [GtkGesture](gtkgesture#GtkGesture-struct)
╰── [GtkGestureSingle](gtkgesturesingle#GtkGestureSingle-struct)
╰── GtkGestureDrag
╰── [GtkGesturePan](gtkgesturepan#GtkGesturePan-struct)
```
Includes
--------
```
#include <gtk/gtk.h>
```
Description
-----------
[GtkGestureDrag](gtkgesturedrag#GtkGestureDrag-struct) is a [GtkGesture](gtkgesture#GtkGesture-struct) implementation that recognizes drag operations. The drag operation itself can be tracked throughout the [“drag-begin”](gtkgesturedrag#GtkGestureDrag-drag-begin), [“drag-update”](gtkgesturedrag#GtkGestureDrag-drag-update) and [“drag-end”](gtkgesturedrag#GtkGestureDrag-drag-end) signals, or the relevant coordinates be extracted through [`gtk_gesture_drag_get_offset()`](gtkgesturedrag#gtk-gesture-drag-get-offset) and [`gtk_gesture_drag_get_start_point()`](gtkgesturedrag#gtk-gesture-drag-get-start-point).
Functions
---------
### gtk\_gesture\_drag\_new ()
```
[GtkGesture](gtkgesture#GtkGesture-struct) *
gtk_gesture_drag_new (*`void`*);
```
Returns a newly created [GtkGesture](gtkgesture#GtkGesture-struct) that recognizes drags.
#### Returns
a newly created [GtkGestureDrag](gtkgesturedrag#GtkGestureDrag-struct)
### gtk\_gesture\_drag\_get\_start\_point ()
```
gboolean
gtk_gesture_drag_get_start_point (*`[GtkGestureDrag](gtkgesturedrag#GtkGestureDrag-struct) *gesture`*,
*`double *x`*,
*`double *y`*);
```
If the *`gesture`* is active, this function returns `TRUE` and fills in *`x`* and *`y`* with the drag start coordinates, in window-relative coordinates.
#### Parameters
| | | |
| --- | --- | --- |
| gesture | a [GtkGesture](gtkgesture#GtkGesture-struct) | |
| x | X coordinate for the drag start point. | [out][nullable] |
| y | Y coordinate for the drag start point. | [out][nullable] |
#### Returns
`TRUE` if the gesture is active
### gtk\_gesture\_drag\_get\_offset ()
```
gboolean
gtk_gesture_drag_get_offset (*`[GtkGestureDrag](gtkgesturedrag#GtkGestureDrag-struct) *gesture`*,
*`double *x`*,
*`double *y`*);
```
If the *`gesture`* is active, this function returns `TRUE` and fills in *`x`* and *`y`* with the coordinates of the current point, as an offset to the starting drag point.
#### Parameters
| | | |
| --- | --- | --- |
| gesture | a [GtkGesture](gtkgesture#GtkGesture-struct) | |
| x | X offset for the current point. | [out][nullable] |
| y | Y offset for the current point. | [out][nullable] |
#### Returns
`TRUE` if the gesture is active
Types and Values
----------------
### GtkGestureDrag
```
typedef struct _GtkGestureDrag GtkGestureDrag;
```
Signal Details
--------------
### The `“drag-begin”` signal
```
void
user_function ([GtkGestureDrag](gtkgesturedrag#GtkGestureDrag-struct) *gesture,
double start_x,
double start_y,
gpointer user_data)
```
This signal is emitted whenever dragging starts.
#### Parameters
| | | |
| --- | --- | --- |
| gesture | the object which received the signal | |
| start\_x | X coordinate, relative to the widget allocation | |
| start\_y | Y coordinate, relative to the widget allocation | |
| user\_data | user data set when the signal handler was connected. | |
Flags: Run Last
### The `“drag-end”` signal
```
void
user_function ([GtkGestureDrag](gtkgesturedrag#GtkGestureDrag-struct) *gesture,
double offset_x,
double offset_y,
gpointer user_data)
```
This signal is emitted whenever the dragging is finished.
#### Parameters
| | | |
| --- | --- | --- |
| gesture | the object which received the signal | |
| offset\_x | X offset, relative to the start point | |
| offset\_y | Y offset, relative to the start point | |
| user\_data | user data set when the signal handler was connected. | |
Flags: Run Last
### The `“drag-update”` signal
```
void
user_function ([GtkGestureDrag](gtkgesturedrag#GtkGestureDrag-struct) *gesture,
double offset_x,
double offset_y,
gpointer user_data)
```
This signal is emitted whenever the dragging point moves.
#### Parameters
| | | |
| --- | --- | --- |
| gesture | the object which received the signal | |
| offset\_x | X offset, relative to the start point | |
| offset\_y | Y offset, relative to the start point | |
| user\_data | user data set when the signal handler was connected. | |
Flags: Run Last
See Also
--------
[GtkGestureSwipe](gtkgestureswipe#GtkGestureSwipe-struct)
gtk gtk4-launch gtk4-launch
===========
gtk4-launch — Launch an application
Synopsis
--------
`gtk4-launch` [OPTION...] APPLICATION [URI...]
Description
-----------
**gtk4-launch** launches an application using the given name. The application is started with proper startup notification on a default display, unless specified otherwise.
**gtk4-launch** takes at least one argument, the name of the application to launch. The name should match application desktop file name, as residing in /usr/share/application, with or without the '.desktop' suffix.
If called with more than one argument, the rest of them besides the application name are considered URI locations and are passed as arguments to the launched application.
Options
-------
The following options are understood:
| | |
| --- | --- |
| `-?`, `--help` | Prints a short help text and exits. |
| | |
| --- | --- |
| `--version` | Prints the program version and exits. |
gtk The scene graph The scene graph
===============
The first step in “drawing” a window is that GTK creates *render nodes* for all the widgets in the window. The render nodes are combined into a tree that you can think of as a *scene graph* describing your window contents.
Render nodes belong to the GSK layer, and there are various kinds of them, for the various kinds of drawing primitives you are likely to need when translating widget content and CSS styling. Typical examples are text nodes, gradient nodes, texture nodes or clip nodes.
In the past, all drawing in GTK happened via cairo. It is still possible to use cairo for drawing your custom widget contents, by using a cairo render node.
A GSK *renderer* takes these render nodes, transforms them into rendering commands for the drawing API it targets, and arranges for the resulting drawing to be associated with the right surface. GSK has renderers for OpenGL, Vulkan and cairo.
gtk GtkShortcut GtkShortcut
===========
GtkShortcut — An object describing a keyboard shortcut
Functions
---------
| | |
| --- | --- |
| [GtkShortcut](gtkshortcut#GtkShortcut-struct) \* | [gtk\_shortcut\_new](gtkshortcut#gtk-shortcut-new) () |
| [GtkShortcut](gtkshortcut#GtkShortcut-struct) \* | [gtk\_shortcut\_new\_with\_arguments](gtkshortcut#gtk-shortcut-new-with-arguments) () |
| [GtkShortcutTrigger](gtkshortcuttrigger#GtkShortcutTrigger-struct) \* | [gtk\_shortcut\_get\_trigger](gtkshortcut#gtk-shortcut-get-trigger) () |
| void | [gtk\_shortcut\_set\_trigger](gtkshortcut#gtk-shortcut-set-trigger) () |
| [GtkShortcutAction](gtkshortcutaction#GtkShortcutAction-struct) \* | [gtk\_shortcut\_get\_action](gtkshortcut#gtk-shortcut-get-action) () |
| void | [gtk\_shortcut\_set\_action](gtkshortcut#gtk-shortcut-set-action) () |
| GVariant \* | [gtk\_shortcut\_get\_arguments](gtkshortcut#gtk-shortcut-get-arguments) () |
| void | [gtk\_shortcut\_set\_arguments](gtkshortcut#gtk-shortcut-set-arguments) () |
Properties
----------
| | | |
| --- | --- | --- |
| [GtkShortcutAction](gtkshortcutaction#GtkShortcutAction-struct) \* | [action](gtkshortcut#GtkShortcut--action) | Read / Write |
| GVariant \* | [arguments](gtkshortcut#GtkShortcut--arguments) | Read / Write |
| [GtkShortcutTrigger](gtkshortcuttrigger#GtkShortcutTrigger-struct) \* | [trigger](gtkshortcut#GtkShortcut--trigger) | Read / Write |
Types and Values
----------------
| | |
| --- | --- |
| | [GtkShortcut](gtkshortcut#GtkShortcut-struct) |
Object Hierarchy
----------------
```
GObject
╰── GtkShortcut
```
Includes
--------
```
#include <gtk/gtk.h>
```
Description
-----------
GtkShortcut is the low level object used for managing keyboard shortcuts.
It contains a description of how to trigger the shortcut via a [GtkShortcutTrigger](gtkshortcuttrigger#GtkShortcutTrigger-struct) and a way to activate the shortcut on a widget via [GtkShortcutAction](gtkshortcutaction#GtkShortcutAction-struct).
The actual work is usually done via [GtkShortcutController](gtkshortcutcontroller#GtkShortcutController-struct), which decides if and when to activate a shortcut. Using that controller directly however is rarely necessary as various higher level convenience APIs exist on [GtkWidgets](gtkwidget#GtkWidget-struct) that make it easier to use shortcuts in GTK.
[GtkShortcut](gtkshortcut#GtkShortcut-struct) does provide functionality to make it easy for users to work with shortcuts, either by providing informational strings for display purposes or by allowing shortcuts to be configured.
Functions
---------
### gtk\_shortcut\_new ()
```
[GtkShortcut](gtkshortcut#GtkShortcut-struct) *
gtk_shortcut_new (*`[GtkShortcutTrigger](gtkshortcuttrigger#GtkShortcutTrigger-struct) *trigger`*,
*`[GtkShortcutAction](gtkshortcutaction#GtkShortcutAction-struct) *action`*);
```
Creates a new [GtkShortcut](gtkshortcut#GtkShortcut-struct) that is triggered by *`trigger`* and then activates *`action`* .
#### Parameters
| | | |
| --- | --- | --- |
| trigger | The trigger that will trigger the shortcut. | [transfer full][nullable] |
| action | The action that will be activated upon triggering. | [transfer full][nullable] |
#### Returns
a new [GtkShortcut](gtkshortcut#GtkShortcut-struct)
### gtk\_shortcut\_new\_with\_arguments ()
```
[GtkShortcut](gtkshortcut#GtkShortcut-struct) *
gtk_shortcut_new_with_arguments (*`[GtkShortcutTrigger](gtkshortcuttrigger#GtkShortcutTrigger-struct) *trigger`*,
*`[GtkShortcutAction](gtkshortcutaction#GtkShortcutAction-struct) *action`*,
*`const char *format_string`*,
*`...`*);
```
Creates a new [GtkShortcut](gtkshortcut#GtkShortcut-struct) that is triggered by *`trigger`* and then activates *`action`* with arguments given by *`format_string`* .
[skip]
#### Parameters
| | | |
| --- | --- | --- |
| trigger | The trigger that will trigger the shortcut. | [transfer full][nullable] |
| action | The action that will be activated upon triggering. | [transfer full][nullable] |
| format\_string | GVariant format string for arguments or `NULL` for no arguments. | [allow-none] |
| ... | arguments, as given by format string. | |
#### Returns
a new [GtkShortcut](gtkshortcut#GtkShortcut-struct)
### gtk\_shortcut\_get\_trigger ()
```
[GtkShortcutTrigger](gtkshortcuttrigger#GtkShortcutTrigger-struct) *
gtk_shortcut_get_trigger (*`[GtkShortcut](gtkshortcut#GtkShortcut-struct) *self`*);
```
Gets the trigger used to trigger *`self`* .
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkShortcut](gtkshortcut#GtkShortcut-struct) | |
#### Returns
the trigger used.
[transfer none][nullable]
### gtk\_shortcut\_set\_trigger ()
```
void
gtk_shortcut_set_trigger (*`[GtkShortcut](gtkshortcut#GtkShortcut-struct) *self`*,
*`[GtkShortcutTrigger](gtkshortcuttrigger#GtkShortcutTrigger-struct) *trigger`*);
```
Sets the new trigger for *`self`* to be *`trigger`* .
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkShortcut](gtkshortcut#GtkShortcut-struct) | |
| trigger | The new trigger. If the *`trigger`* is `NULL`, the never trigger will be used. | [transfer full][nullable] |
### gtk\_shortcut\_get\_action ()
```
[GtkShortcutAction](gtkshortcutaction#GtkShortcutAction-struct) *
gtk_shortcut_get_action (*`[GtkShortcut](gtkshortcut#GtkShortcut-struct) *self`*);
```
Gets the action that is activated by this shortcut.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkShortcut](gtkshortcut#GtkShortcut-struct) | |
#### Returns
the action.
[transfer none][nullable]
### gtk\_shortcut\_set\_action ()
```
void
gtk_shortcut_set_action (*`[GtkShortcut](gtkshortcut#GtkShortcut-struct) *self`*,
*`[GtkShortcutAction](gtkshortcutaction#GtkShortcutAction-struct) *action`*);
```
Sets the new action for *`self`* to be *`action`* .
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkShortcut](gtkshortcut#GtkShortcut-struct) | |
| action | The new action. If the *`action`* is `NULL`, the nothing action will be used. | [transfer full][nullable] |
### gtk\_shortcut\_get\_arguments ()
```
GVariant *
gtk_shortcut_get_arguments (*`[GtkShortcut](gtkshortcut#GtkShortcut-struct) *self`*);
```
Gets the arguments that are passed when activating the shortcut.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkShortcut](gtkshortcut#GtkShortcut-struct) | |
#### Returns
the arguments.
[transfer none][nullable]
### gtk\_shortcut\_set\_arguments ()
```
void
gtk_shortcut_set_arguments (*`[GtkShortcut](gtkshortcut#GtkShortcut-struct) *self`*,
*`GVariant *args`*);
```
Sets the arguments to pass when activating the shortcut.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkShortcut](gtkshortcut#GtkShortcut-struct) | |
| args | arguments to pass when activating *`self`* . | [nullable] |
Types and Values
----------------
### GtkShortcut
```
typedef struct _GtkShortcut GtkShortcut;
```
Property Details
----------------
### The `“action”` property
```
“action” [GtkShortcutAction](gtkshortcutaction#GtkShortcutAction-struct) *
```
The action that gets activated by this shortcut.
Owner: GtkShortcut
Flags: Read / Write
### The `“arguments”` property
```
“arguments” GVariant *
```
Arguments passed to activation.
Owner: GtkShortcut
Flags: Read / Write
Allowed values: GVariant<\*>
Default value: NULL
### The `“trigger”` property
```
“trigger” [GtkShortcutTrigger](gtkshortcuttrigger#GtkShortcutTrigger-struct) *
```
The trigger that triggers this shortcut.
Owner: GtkShortcut
Flags: Read / Write
See Also
--------
[GtkShortcutController](gtkshortcutcontroller#GtkShortcutController-struct), [GtkShortcutAction](gtkshortcutaction#GtkShortcutAction-struct), [GtkShortcutTrigger](gtkshortcuttrigger#GtkShortcutTrigger-struct)
| programming_docs |
gtk Windows-specific handling of cursors Windows-specific handling of cursors
====================================
By default the “system” cursor theme is used. This makes GTK prefer cursors that Windows currently uses, falling back to Adwaita cursors and (as the last resort) built-in X cursors.
When any other cursor theme is used, GTK will prefer cursors from that theme, falling back to Windows cursors and built-in X cursors.
Theme can be changed by setting `gtk-cursor-theme-name` GTK setting. Users can override GTK settings in the `settings.ini` file or at runtime in the GTK Inspector.
Themes are loaded from normal Windows variants of the XDG locations: ``HOME`%/icons/THEME/cursors`, ``APPDATA`%/icons/THEME/cursors`, `RUNTIME_PREFIX/share/icons/THEME/cursors`
The `gtk-cursor-theme-size` setting is ignored, GTK will use the cursor size that Windows tells it to use.
gtk GtkTreeViewColumn GtkTreeViewColumn
=================
GtkTreeViewColumn — A visible column in a GtkTreeView widget
Functions
---------
| | |
| --- | --- |
| void | ([\*GtkTreeCellDataFunc](gtktreeviewcolumn#GtkTreeCellDataFunc)) () |
| [GtkTreeViewColumn](gtktreeviewcolumn#GtkTreeViewColumn-struct) \* | [gtk\_tree\_view\_column\_new](gtktreeviewcolumn#gtk-tree-view-column-new) () |
| [GtkTreeViewColumn](gtktreeviewcolumn#GtkTreeViewColumn-struct) \* | [gtk\_tree\_view\_column\_new\_with\_area](gtktreeviewcolumn#gtk-tree-view-column-new-with-area) () |
| [GtkTreeViewColumn](gtktreeviewcolumn#GtkTreeViewColumn-struct) \* | [gtk\_tree\_view\_column\_new\_with\_attributes](gtktreeviewcolumn#gtk-tree-view-column-new-with-attributes) () |
| void | [gtk\_tree\_view\_column\_pack\_start](gtktreeviewcolumn#gtk-tree-view-column-pack-start) () |
| void | [gtk\_tree\_view\_column\_pack\_end](gtktreeviewcolumn#gtk-tree-view-column-pack-end) () |
| void | [gtk\_tree\_view\_column\_clear](gtktreeviewcolumn#gtk-tree-view-column-clear) () |
| void | [gtk\_tree\_view\_column\_add\_attribute](gtktreeviewcolumn#gtk-tree-view-column-add-attribute) () |
| void | [gtk\_tree\_view\_column\_set\_attributes](gtktreeviewcolumn#gtk-tree-view-column-set-attributes) () |
| void | [gtk\_tree\_view\_column\_set\_cell\_data\_func](gtktreeviewcolumn#gtk-tree-view-column-set-cell-data-func) () |
| void | [gtk\_tree\_view\_column\_clear\_attributes](gtktreeviewcolumn#gtk-tree-view-column-clear-attributes) () |
| void | [gtk\_tree\_view\_column\_set\_spacing](gtktreeviewcolumn#gtk-tree-view-column-set-spacing) () |
| int | [gtk\_tree\_view\_column\_get\_spacing](gtktreeviewcolumn#gtk-tree-view-column-get-spacing) () |
| void | [gtk\_tree\_view\_column\_set\_visible](gtktreeviewcolumn#gtk-tree-view-column-set-visible) () |
| gboolean | [gtk\_tree\_view\_column\_get\_visible](gtktreeviewcolumn#gtk-tree-view-column-get-visible) () |
| void | [gtk\_tree\_view\_column\_set\_resizable](gtktreeviewcolumn#gtk-tree-view-column-set-resizable) () |
| gboolean | [gtk\_tree\_view\_column\_get\_resizable](gtktreeviewcolumn#gtk-tree-view-column-get-resizable) () |
| void | [gtk\_tree\_view\_column\_set\_sizing](gtktreeviewcolumn#gtk-tree-view-column-set-sizing) () |
| [GtkTreeViewColumnSizing](gtktreeviewcolumn#GtkTreeViewColumnSizing) | [gtk\_tree\_view\_column\_get\_sizing](gtktreeviewcolumn#gtk-tree-view-column-get-sizing) () |
| int | [gtk\_tree\_view\_column\_get\_width](gtktreeviewcolumn#gtk-tree-view-column-get-width) () |
| int | [gtk\_tree\_view\_column\_get\_fixed\_width](gtktreeviewcolumn#gtk-tree-view-column-get-fixed-width) () |
| void | [gtk\_tree\_view\_column\_set\_fixed\_width](gtktreeviewcolumn#gtk-tree-view-column-set-fixed-width) () |
| void | [gtk\_tree\_view\_column\_set\_min\_width](gtktreeviewcolumn#gtk-tree-view-column-set-min-width) () |
| int | [gtk\_tree\_view\_column\_get\_min\_width](gtktreeviewcolumn#gtk-tree-view-column-get-min-width) () |
| void | [gtk\_tree\_view\_column\_set\_max\_width](gtktreeviewcolumn#gtk-tree-view-column-set-max-width) () |
| int | [gtk\_tree\_view\_column\_get\_max\_width](gtktreeviewcolumn#gtk-tree-view-column-get-max-width) () |
| void | [gtk\_tree\_view\_column\_clicked](gtktreeviewcolumn#gtk-tree-view-column-clicked) () |
| void | [gtk\_tree\_view\_column\_set\_title](gtktreeviewcolumn#gtk-tree-view-column-set-title) () |
| const char \* | [gtk\_tree\_view\_column\_get\_title](gtktreeviewcolumn#gtk-tree-view-column-get-title) () |
| void | [gtk\_tree\_view\_column\_set\_expand](gtktreeviewcolumn#gtk-tree-view-column-set-expand) () |
| gboolean | [gtk\_tree\_view\_column\_get\_expand](gtktreeviewcolumn#gtk-tree-view-column-get-expand) () |
| void | [gtk\_tree\_view\_column\_set\_clickable](gtktreeviewcolumn#gtk-tree-view-column-set-clickable) () |
| gboolean | [gtk\_tree\_view\_column\_get\_clickable](gtktreeviewcolumn#gtk-tree-view-column-get-clickable) () |
| void | [gtk\_tree\_view\_column\_set\_widget](gtktreeviewcolumn#gtk-tree-view-column-set-widget) () |
| [GtkWidget](gtkwidget#GtkWidget-struct) \* | [gtk\_tree\_view\_column\_get\_widget](gtktreeviewcolumn#gtk-tree-view-column-get-widget) () |
| [GtkWidget](gtkwidget#GtkWidget-struct) \* | [gtk\_tree\_view\_column\_get\_button](gtktreeviewcolumn#gtk-tree-view-column-get-button) () |
| void | [gtk\_tree\_view\_column\_set\_alignment](gtktreeviewcolumn#gtk-tree-view-column-set-alignment) () |
| float | [gtk\_tree\_view\_column\_get\_alignment](gtktreeviewcolumn#gtk-tree-view-column-get-alignment) () |
| void | [gtk\_tree\_view\_column\_set\_reorderable](gtktreeviewcolumn#gtk-tree-view-column-set-reorderable) () |
| gboolean | [gtk\_tree\_view\_column\_get\_reorderable](gtktreeviewcolumn#gtk-tree-view-column-get-reorderable) () |
| void | [gtk\_tree\_view\_column\_set\_sort\_column\_id](gtktreeviewcolumn#gtk-tree-view-column-set-sort-column-id) () |
| int | [gtk\_tree\_view\_column\_get\_sort\_column\_id](gtktreeviewcolumn#gtk-tree-view-column-get-sort-column-id) () |
| void | [gtk\_tree\_view\_column\_set\_sort\_indicator](gtktreeviewcolumn#gtk-tree-view-column-set-sort-indicator) () |
| gboolean | [gtk\_tree\_view\_column\_get\_sort\_indicator](gtktreeviewcolumn#gtk-tree-view-column-get-sort-indicator) () |
| void | [gtk\_tree\_view\_column\_set\_sort\_order](gtktreeviewcolumn#gtk-tree-view-column-set-sort-order) () |
| [GtkSortType](gtk4-standard-enumerations#GtkSortType) | [gtk\_tree\_view\_column\_get\_sort\_order](gtktreeviewcolumn#gtk-tree-view-column-get-sort-order) () |
| void | [gtk\_tree\_view\_column\_cell\_set\_cell\_data](gtktreeviewcolumn#gtk-tree-view-column-cell-set-cell-data) () |
| void | [gtk\_tree\_view\_column\_cell\_get\_size](gtktreeviewcolumn#gtk-tree-view-column-cell-get-size) () |
| gboolean | [gtk\_tree\_view\_column\_cell\_get\_position](gtktreeviewcolumn#gtk-tree-view-column-cell-get-position) () |
| gboolean | [gtk\_tree\_view\_column\_cell\_is\_visible](gtktreeviewcolumn#gtk-tree-view-column-cell-is-visible) () |
| void | [gtk\_tree\_view\_column\_focus\_cell](gtktreeviewcolumn#gtk-tree-view-column-focus-cell) () |
| void | [gtk\_tree\_view\_column\_queue\_resize](gtktreeviewcolumn#gtk-tree-view-column-queue-resize) () |
| [GtkWidget](gtkwidget#GtkWidget-struct) \* | [gtk\_tree\_view\_column\_get\_tree\_view](gtktreeviewcolumn#gtk-tree-view-column-get-tree-view) () |
| int | [gtk\_tree\_view\_column\_get\_x\_offset](gtktreeviewcolumn#gtk-tree-view-column-get-x-offset) () |
Properties
----------
| | | |
| --- | --- | --- |
| float | [alignment](gtktreeviewcolumn#GtkTreeViewColumn--alignment) | Read / Write |
| [GtkCellArea](gtkcellarea#GtkCellArea-struct) \* | [cell-area](gtktreeviewcolumn#GtkTreeViewColumn--cell-area) | Read / Write / Construct Only |
| gboolean | [clickable](gtktreeviewcolumn#GtkTreeViewColumn--clickable) | Read / Write |
| gboolean | [expand](gtktreeviewcolumn#GtkTreeViewColumn--expand) | Read / Write |
| int | [fixed-width](gtktreeviewcolumn#GtkTreeViewColumn--fixed-width) | Read / Write |
| int | [max-width](gtktreeviewcolumn#GtkTreeViewColumn--max-width) | Read / Write |
| int | [min-width](gtktreeviewcolumn#GtkTreeViewColumn--min-width) | Read / Write |
| gboolean | [reorderable](gtktreeviewcolumn#GtkTreeViewColumn--reorderable) | Read / Write |
| gboolean | [resizable](gtktreeviewcolumn#GtkTreeViewColumn--resizable) | Read / Write |
| [GtkTreeViewColumnSizing](gtktreeviewcolumn#GtkTreeViewColumnSizing) | [sizing](gtktreeviewcolumn#GtkTreeViewColumn--sizing) | Read / Write |
| int | [sort-column-id](gtktreeviewcolumn#GtkTreeViewColumn--sort-column-id) | Read / Write |
| gboolean | [sort-indicator](gtktreeviewcolumn#GtkTreeViewColumn--sort-indicator) | Read / Write |
| [GtkSortType](gtk4-standard-enumerations#GtkSortType) | [sort-order](gtktreeviewcolumn#GtkTreeViewColumn--sort-order) | Read / Write |
| int | [spacing](gtktreeviewcolumn#GtkTreeViewColumn--spacing) | Read / Write |
| char \* | [title](gtktreeviewcolumn#GtkTreeViewColumn--title) | Read / Write |
| gboolean | [visible](gtktreeviewcolumn#GtkTreeViewColumn--visible) | Read / Write |
| [GtkWidget](gtkwidget#GtkWidget-struct) \* | [widget](gtktreeviewcolumn#GtkTreeViewColumn--widget) | Read / Write |
| int | [width](gtktreeviewcolumn#GtkTreeViewColumn--width) | Read |
| int | [x-offset](gtktreeviewcolumn#GtkTreeViewColumn--x-offset) | Read |
Signals
-------
| | | |
| --- | --- | --- |
| void | [clicked](gtktreeviewcolumn#GtkTreeViewColumn-clicked) | Run Last |
Types and Values
----------------
| | |
| --- | --- |
| enum | [GtkTreeViewColumnSizing](gtktreeviewcolumn#GtkTreeViewColumnSizing) |
| | [GtkTreeViewColumn](gtktreeviewcolumn#GtkTreeViewColumn-struct) |
Object Hierarchy
----------------
```
GObject
╰── GInitiallyUnowned
╰── GtkTreeViewColumn
```
Implemented Interfaces
----------------------
GtkTreeViewColumn implements [GtkCellLayout](gtkcelllayout#GtkCellLayout-struct) and [GtkBuildable](gtkbuildable#GtkBuildable-struct).
Includes
--------
```
#include <gtk/gtk.h>
```
Description
-----------
The GtkTreeViewColumn object represents a visible column in a [GtkTreeView](gtktreeview#GtkTreeView-struct) widget. It allows to set properties of the column header, and functions as a holding pen for the cell renderers which determine how the data in the column is displayed.
Please refer to the [tree widget conceptual overview](treewidgetobjects#TreeWidget) for an overview of all the objects and data types related to the tree widget and how they work together.
Functions
---------
### GtkTreeCellDataFunc ()
```
void
(*GtkTreeCellDataFunc) (*`[GtkTreeViewColumn](gtktreeviewcolumn#GtkTreeViewColumn-struct) *tree_column`*,
*`[GtkCellRenderer](gtkcellrenderer#GtkCellRenderer-struct) *cell`*,
*`[GtkTreeModel](gtktreemodel#GtkTreeModel-struct) *tree_model`*,
*`[GtkTreeIter](gtktreemodel#GtkTreeIter-struct) *iter`*,
*`gpointer data`*);
```
A function to set the properties of a cell instead of just using the straight mapping between the cell and the model. This is useful for customizing the cell renderer. For example, a function might get an integer from the *`tree_model`* , and render it to the “text” attribute of “cell” by converting it to its written equivalent. This is set by calling [`gtk_tree_view_column_set_cell_data_func()`](gtktreeviewcolumn#gtk-tree-view-column-set-cell-data-func)
#### Parameters
| | | |
| --- | --- | --- |
| tree\_column | A [GtkTreeViewColumn](gtktreeviewcolumn#GtkTreeViewColumn-struct) | |
| cell | The [GtkCellRenderer](gtkcellrenderer#GtkCellRenderer-struct) that is being rendered by *`tree_column`* | |
| tree\_model | The [GtkTreeModel](gtktreemodel#GtkTreeModel-struct) being rendered | |
| iter | A [GtkTreeIter](gtktreemodel#GtkTreeIter-struct) of the current row rendered | |
| data | user data. | [closure] |
### gtk\_tree\_view\_column\_new ()
```
[GtkTreeViewColumn](gtktreeviewcolumn#GtkTreeViewColumn-struct) *
gtk_tree_view_column_new (*`void`*);
```
Creates a new [GtkTreeViewColumn](gtktreeviewcolumn#GtkTreeViewColumn-struct).
#### Returns
A newly created [GtkTreeViewColumn](gtktreeviewcolumn#GtkTreeViewColumn-struct).
### gtk\_tree\_view\_column\_new\_with\_area ()
```
[GtkTreeViewColumn](gtktreeviewcolumn#GtkTreeViewColumn-struct) *
gtk_tree_view_column_new_with_area (*`[GtkCellArea](gtkcellarea#GtkCellArea-struct) *area`*);
```
Creates a new [GtkTreeViewColumn](gtktreeviewcolumn#GtkTreeViewColumn-struct) using *`area`* to render its cells.
#### Parameters
| | | |
| --- | --- | --- |
| area | the [GtkCellArea](gtkcellarea#GtkCellArea-struct) that the newly created column should use to layout cells. | |
#### Returns
A newly created [GtkTreeViewColumn](gtktreeviewcolumn#GtkTreeViewColumn-struct).
### gtk\_tree\_view\_column\_new\_with\_attributes ()
```
[GtkTreeViewColumn](gtktreeviewcolumn#GtkTreeViewColumn-struct) *
gtk_tree_view_column_new_with_attributes
(*`const char *title`*,
*`[GtkCellRenderer](gtkcellrenderer#GtkCellRenderer-struct) *cell`*,
*`...`*);
```
Creates a new [GtkTreeViewColumn](gtktreeviewcolumn#GtkTreeViewColumn-struct) with a number of default values. This is equivalent to calling [`gtk_tree_view_column_set_title()`](gtktreeviewcolumn#gtk-tree-view-column-set-title), [`gtk_tree_view_column_pack_start()`](gtktreeviewcolumn#gtk-tree-view-column-pack-start), and [`gtk_tree_view_column_set_attributes()`](gtktreeviewcolumn#gtk-tree-view-column-set-attributes) on the newly created [GtkTreeViewColumn](gtktreeviewcolumn#GtkTreeViewColumn-struct).
Here’s a simple example:
```
enum { TEXT_COLUMN, COLOR_COLUMN, N_COLUMNS };
// ...
{
GtkTreeViewColumn *column;
GtkCellRenderer *renderer = gtk_cell_renderer_text_new ();
column = gtk_tree_view_column_new_with_attributes ("Title",
renderer,
"text", TEXT_COLUMN,
"foreground", COLOR_COLUMN,
NULL);
}
```
| #### Parameters
| | | |
| --- | --- | --- |
| title | The title to set the header to | |
| cell | The [GtkCellRenderer](gtkcellrenderer#GtkCellRenderer-struct) | |
| ... | A `NULL`-terminated list of attributes | |
#### Returns
A newly created [GtkTreeViewColumn](gtktreeviewcolumn#GtkTreeViewColumn-struct).
### gtk\_tree\_view\_column\_pack\_start ()
```
void
gtk_tree_view_column_pack_start (*`[GtkTreeViewColumn](gtktreeviewcolumn#GtkTreeViewColumn-struct) *tree_column`*,
*`[GtkCellRenderer](gtkcellrenderer#GtkCellRenderer-struct) *cell`*,
*`gboolean expand`*);
```
Packs the *`cell`* into the beginning of the column. If *`expand`* is `FALSE`, then the *`cell`* is allocated no more space than it needs. Any unused space is divided evenly between cells for which *`expand`* is `TRUE`.
#### Parameters
| | | |
| --- | --- | --- |
| tree\_column | A [GtkTreeViewColumn](gtktreeviewcolumn#GtkTreeViewColumn-struct). | |
| cell | The [GtkCellRenderer](gtkcellrenderer#GtkCellRenderer-struct). | |
| expand | `TRUE` if *`cell`* is to be given extra space allocated to *`tree_column`* . | |
### gtk\_tree\_view\_column\_pack\_end ()
```
void
gtk_tree_view_column_pack_end (*`[GtkTreeViewColumn](gtktreeviewcolumn#GtkTreeViewColumn-struct) *tree_column`*,
*`[GtkCellRenderer](gtkcellrenderer#GtkCellRenderer-struct) *cell`*,
*`gboolean expand`*);
```
Adds the *`cell`* to end of the column. If *`expand`* is `FALSE`, then the *`cell`* is allocated no more space than it needs. Any unused space is divided evenly between cells for which *`expand`* is `TRUE`.
#### Parameters
| | | |
| --- | --- | --- |
| tree\_column | A [GtkTreeViewColumn](gtktreeviewcolumn#GtkTreeViewColumn-struct). | |
| cell | The [GtkCellRenderer](gtkcellrenderer#GtkCellRenderer-struct). | |
| expand | `TRUE` if *`cell`* is to be given extra space allocated to *`tree_column`* . | |
### gtk\_tree\_view\_column\_clear ()
```
void
gtk_tree_view_column_clear (*`[GtkTreeViewColumn](gtktreeviewcolumn#GtkTreeViewColumn-struct) *tree_column`*);
```
Unsets all the mappings on all renderers on the *`tree_column`* .
#### Parameters
| | | |
| --- | --- | --- |
| tree\_column | A [GtkTreeViewColumn](gtktreeviewcolumn#GtkTreeViewColumn-struct) | |
### gtk\_tree\_view\_column\_add\_attribute ()
```
void
gtk_tree_view_column_add_attribute (*`[GtkTreeViewColumn](gtktreeviewcolumn#GtkTreeViewColumn-struct) *tree_column`*,
*`[GtkCellRenderer](gtkcellrenderer#GtkCellRenderer-struct) *cell_renderer`*,
*`const char *attribute`*,
*`int column`*);
```
Adds an attribute mapping to the list in *`tree_column`* . The *`column`* is the column of the model to get a value from, and the *`attribute`* is the parameter on *`cell_renderer`* to be set from the value. So for example if column 2 of the model contains strings, you could have the “text” attribute of a [GtkCellRendererText](gtkcellrenderertext#GtkCellRendererText-struct) get its values from column 2.
#### Parameters
| | | |
| --- | --- | --- |
| tree\_column | A [GtkTreeViewColumn](gtktreeviewcolumn#GtkTreeViewColumn-struct). | |
| cell\_renderer | the [GtkCellRenderer](gtkcellrenderer#GtkCellRenderer-struct) to set attributes on | |
| attribute | An attribute on the renderer | |
| column | The column position on the model to get the attribute from. | |
### gtk\_tree\_view\_column\_set\_attributes ()
```
void
gtk_tree_view_column_set_attributes (*`[GtkTreeViewColumn](gtktreeviewcolumn#GtkTreeViewColumn-struct) *tree_column`*,
*`[GtkCellRenderer](gtkcellrenderer#GtkCellRenderer-struct) *cell_renderer`*,
*`...`*);
```
Sets the attributes in the list as the attributes of *`tree_column`* . The attributes should be in attribute/column order, as in [`gtk_tree_view_column_add_attribute()`](gtktreeviewcolumn#gtk-tree-view-column-add-attribute). All existing attributes are removed, and replaced with the new attributes.
#### Parameters
| | | |
| --- | --- | --- |
| tree\_column | A [GtkTreeViewColumn](gtktreeviewcolumn#GtkTreeViewColumn-struct) | |
| cell\_renderer | the [GtkCellRenderer](gtkcellrenderer#GtkCellRenderer-struct) we’re setting the attributes of | |
| ... | A `NULL`-terminated list of attributes | |
### gtk\_tree\_view\_column\_set\_cell\_data\_func ()
```
void
gtk_tree_view_column_set_cell_data_func
(*`[GtkTreeViewColumn](gtktreeviewcolumn#GtkTreeViewColumn-struct) *tree_column`*,
*`[GtkCellRenderer](gtkcellrenderer#GtkCellRenderer-struct) *cell_renderer`*,
*`[GtkTreeCellDataFunc](gtktreeviewcolumn#GtkTreeCellDataFunc) func`*,
*`gpointer func_data`*,
*`GDestroyNotify destroy`*);
```
Sets the [GtkTreeCellDataFunc](gtktreeviewcolumn#GtkTreeCellDataFunc) to use for the column. This function is used instead of the standard attributes mapping for setting the column value, and should set the value of *`tree_column`* 's cell renderer as appropriate. *`func`* may be `NULL` to remove an older one.
#### Parameters
| | | |
| --- | --- | --- |
| tree\_column | A [GtkTreeViewColumn](gtktreeviewcolumn#GtkTreeViewColumn-struct) | |
| cell\_renderer | A [GtkCellRenderer](gtkcellrenderer#GtkCellRenderer-struct) | |
| func | The [GtkTreeCellDataFunc](gtktreeviewcolumn#GtkTreeCellDataFunc) to use. | [allow-none] |
| func\_data | The user data for *`func`* . | [closure] |
| destroy | The destroy notification for *`func_data`* | |
### gtk\_tree\_view\_column\_clear\_attributes ()
```
void
gtk_tree_view_column_clear_attributes (*`[GtkTreeViewColumn](gtktreeviewcolumn#GtkTreeViewColumn-struct) *tree_column`*,
*`[GtkCellRenderer](gtkcellrenderer#GtkCellRenderer-struct) *cell_renderer`*);
```
Clears all existing attributes previously set with [`gtk_tree_view_column_set_attributes()`](gtktreeviewcolumn#gtk-tree-view-column-set-attributes).
#### Parameters
| | | |
| --- | --- | --- |
| tree\_column | a [GtkTreeViewColumn](gtktreeviewcolumn#GtkTreeViewColumn-struct) | |
| cell\_renderer | a [GtkCellRenderer](gtkcellrenderer#GtkCellRenderer-struct) to clear the attribute mapping on. | |
### gtk\_tree\_view\_column\_set\_spacing ()
```
void
gtk_tree_view_column_set_spacing (*`[GtkTreeViewColumn](gtktreeviewcolumn#GtkTreeViewColumn-struct) *tree_column`*,
*`int spacing`*);
```
Sets the spacing field of *`tree_column`* , which is the number of pixels to place between cell renderers packed into it.
#### Parameters
| | | |
| --- | --- | --- |
| tree\_column | A [GtkTreeViewColumn](gtktreeviewcolumn#GtkTreeViewColumn-struct). | |
| spacing | distance between cell renderers in pixels. | |
### gtk\_tree\_view\_column\_get\_spacing ()
```
int
gtk_tree_view_column_get_spacing (*`[GtkTreeViewColumn](gtktreeviewcolumn#GtkTreeViewColumn-struct) *tree_column`*);
```
Returns the spacing of *`tree_column`* .
#### Parameters
| | | |
| --- | --- | --- |
| tree\_column | A [GtkTreeViewColumn](gtktreeviewcolumn#GtkTreeViewColumn-struct). | |
#### Returns
the spacing of *`tree_column`* .
### gtk\_tree\_view\_column\_set\_visible ()
```
void
gtk_tree_view_column_set_visible (*`[GtkTreeViewColumn](gtktreeviewcolumn#GtkTreeViewColumn-struct) *tree_column`*,
*`gboolean visible`*);
```
Sets the visibility of *`tree_column`* .
#### Parameters
| | | |
| --- | --- | --- |
| tree\_column | A [GtkTreeViewColumn](gtktreeviewcolumn#GtkTreeViewColumn-struct). | |
| visible | `TRUE` if the *`tree_column`* is visible. | |
### gtk\_tree\_view\_column\_get\_visible ()
```
gboolean
gtk_tree_view_column_get_visible (*`[GtkTreeViewColumn](gtktreeviewcolumn#GtkTreeViewColumn-struct) *tree_column`*);
```
Returns `TRUE` if *`tree_column`* is visible.
#### Parameters
| | | |
| --- | --- | --- |
| tree\_column | A [GtkTreeViewColumn](gtktreeviewcolumn#GtkTreeViewColumn-struct). | |
#### Returns
whether the column is visible or not. If it is visible, then the tree will show the column.
### gtk\_tree\_view\_column\_set\_resizable ()
```
void
gtk_tree_view_column_set_resizable (*`[GtkTreeViewColumn](gtktreeviewcolumn#GtkTreeViewColumn-struct) *tree_column`*,
*`gboolean resizable`*);
```
If *`resizable`* is `TRUE`, then the user can explicitly resize the column by grabbing the outer edge of the column button. If resizable is `TRUE` and sizing mode of the column is [GTK\_TREE\_VIEW\_COLUMN\_AUTOSIZE](gtktreeviewcolumn#GTK-TREE-VIEW-COLUMN-AUTOSIZE:CAPS), then the sizing mode is changed to [GTK\_TREE\_VIEW\_COLUMN\_GROW\_ONLY](gtktreeviewcolumn#GTK-TREE-VIEW-COLUMN-GROW-ONLY:CAPS).
#### Parameters
| | | |
| --- | --- | --- |
| tree\_column | A [GtkTreeViewColumn](gtktreeviewcolumn#GtkTreeViewColumn-struct) | |
| resizable | `TRUE`, if the column can be resized | |
### gtk\_tree\_view\_column\_get\_resizable ()
```
gboolean
gtk_tree_view_column_get_resizable (*`[GtkTreeViewColumn](gtktreeviewcolumn#GtkTreeViewColumn-struct) *tree_column`*);
```
Returns `TRUE` if the *`tree_column`* can be resized by the end user.
#### Parameters
| | | |
| --- | --- | --- |
| tree\_column | A [GtkTreeViewColumn](gtktreeviewcolumn#GtkTreeViewColumn-struct) | |
#### Returns
`TRUE`, if the *`tree_column`* can be resized.
### gtk\_tree\_view\_column\_set\_sizing ()
```
void
gtk_tree_view_column_set_sizing (*`[GtkTreeViewColumn](gtktreeviewcolumn#GtkTreeViewColumn-struct) *tree_column`*,
*`[GtkTreeViewColumnSizing](gtktreeviewcolumn#GtkTreeViewColumnSizing) type`*);
```
Sets the growth behavior of *`tree_column`* to *`type`* .
#### Parameters
| | | |
| --- | --- | --- |
| tree\_column | A [GtkTreeViewColumn](gtktreeviewcolumn#GtkTreeViewColumn-struct). | |
| type | The [GtkTreeViewColumnSizing](gtktreeviewcolumn#GtkTreeViewColumnSizing). | |
### gtk\_tree\_view\_column\_get\_sizing ()
```
[GtkTreeViewColumnSizing](gtktreeviewcolumn#GtkTreeViewColumnSizing)
gtk_tree_view_column_get_sizing (*`[GtkTreeViewColumn](gtktreeviewcolumn#GtkTreeViewColumn-struct) *tree_column`*);
```
Returns the current type of *`tree_column`* .
#### Parameters
| | | |
| --- | --- | --- |
| tree\_column | A [GtkTreeViewColumn](gtktreeviewcolumn#GtkTreeViewColumn-struct). | |
#### Returns
The type of *`tree_column`* .
### gtk\_tree\_view\_column\_get\_width ()
```
int
gtk_tree_view_column_get_width (*`[GtkTreeViewColumn](gtktreeviewcolumn#GtkTreeViewColumn-struct) *tree_column`*);
```
Returns the current size of *`tree_column`* in pixels.
#### Parameters
| | | |
| --- | --- | --- |
| tree\_column | A [GtkTreeViewColumn](gtktreeviewcolumn#GtkTreeViewColumn-struct). | |
#### Returns
The current width of *`tree_column`* .
### gtk\_tree\_view\_column\_get\_fixed\_width ()
```
int
gtk_tree_view_column_get_fixed_width (*`[GtkTreeViewColumn](gtktreeviewcolumn#GtkTreeViewColumn-struct) *tree_column`*);
```
Gets the fixed width of the column. This may not be the actual displayed width of the column; for that, use [`gtk_tree_view_column_get_width()`](gtktreeviewcolumn#gtk-tree-view-column-get-width).
#### Parameters
| | | |
| --- | --- | --- |
| tree\_column | A [GtkTreeViewColumn](gtktreeviewcolumn#GtkTreeViewColumn-struct). | |
#### Returns
The fixed width of the column.
### gtk\_tree\_view\_column\_set\_fixed\_width ()
```
void
gtk_tree_view_column_set_fixed_width (*`[GtkTreeViewColumn](gtktreeviewcolumn#GtkTreeViewColumn-struct) *tree_column`*,
*`int fixed_width`*);
```
If *`fixed_width`* is not -1, sets the fixed width of *`tree_column`* ; otherwise unsets it. The effective value of *`fixed_width`* is clamped between the minimum and maximum width of the column; however, the value stored in the “fixed-width” property is not clamped. If the column sizing is [GTK\_TREE\_VIEW\_COLUMN\_GROW\_ONLY](gtktreeviewcolumn#GTK-TREE-VIEW-COLUMN-GROW-ONLY:CAPS) or [GTK\_TREE\_VIEW\_COLUMN\_AUTOSIZE](gtktreeviewcolumn#GTK-TREE-VIEW-COLUMN-AUTOSIZE:CAPS), setting a fixed width overrides the automatically calculated width. Note that *`fixed_width`* is only a hint to GTK; the width actually allocated to the column may be greater or less than requested.
Along with “expand”, the “fixed-width” property changes when the column is resized by the user.
#### Parameters
| | | |
| --- | --- | --- |
| tree\_column | A [GtkTreeViewColumn](gtktreeviewcolumn#GtkTreeViewColumn-struct). | |
| fixed\_width | The new fixed width, in pixels, or -1. | |
### gtk\_tree\_view\_column\_set\_min\_width ()
```
void
gtk_tree_view_column_set_min_width (*`[GtkTreeViewColumn](gtktreeviewcolumn#GtkTreeViewColumn-struct) *tree_column`*,
*`int min_width`*);
```
Sets the minimum width of the *`tree_column`* . If *`min_width`* is -1, then the minimum width is unset.
#### Parameters
| | | |
| --- | --- | --- |
| tree\_column | A [GtkTreeViewColumn](gtktreeviewcolumn#GtkTreeViewColumn-struct). | |
| min\_width | The minimum width of the column in pixels, or -1. | |
### gtk\_tree\_view\_column\_get\_min\_width ()
```
int
gtk_tree_view_column_get_min_width (*`[GtkTreeViewColumn](gtktreeviewcolumn#GtkTreeViewColumn-struct) *tree_column`*);
```
Returns the minimum width in pixels of the *`tree_column`* , or -1 if no minimum width is set.
#### Parameters
| | | |
| --- | --- | --- |
| tree\_column | A [GtkTreeViewColumn](gtktreeviewcolumn#GtkTreeViewColumn-struct). | |
#### Returns
The minimum width of the *`tree_column`* .
### gtk\_tree\_view\_column\_set\_max\_width ()
```
void
gtk_tree_view_column_set_max_width (*`[GtkTreeViewColumn](gtktreeviewcolumn#GtkTreeViewColumn-struct) *tree_column`*,
*`int max_width`*);
```
Sets the maximum width of the *`tree_column`* . If *`max_width`* is -1, then the maximum width is unset. Note, the column can actually be wider than max width if it’s the last column in a view. In this case, the column expands to fill any extra space.
#### Parameters
| | | |
| --- | --- | --- |
| tree\_column | A [GtkTreeViewColumn](gtktreeviewcolumn#GtkTreeViewColumn-struct). | |
| max\_width | The maximum width of the column in pixels, or -1. | |
### gtk\_tree\_view\_column\_get\_max\_width ()
```
int
gtk_tree_view_column_get_max_width (*`[GtkTreeViewColumn](gtktreeviewcolumn#GtkTreeViewColumn-struct) *tree_column`*);
```
Returns the maximum width in pixels of the *`tree_column`* , or -1 if no maximum width is set.
#### Parameters
| | | |
| --- | --- | --- |
| tree\_column | A [GtkTreeViewColumn](gtktreeviewcolumn#GtkTreeViewColumn-struct). | |
#### Returns
The maximum width of the *`tree_column`* .
### gtk\_tree\_view\_column\_clicked ()
```
void
gtk_tree_view_column_clicked (*`[GtkTreeViewColumn](gtktreeviewcolumn#GtkTreeViewColumn-struct) *tree_column`*);
```
Emits the “clicked” signal on the column. This function will only work if *`tree_column`* is clickable.
#### Parameters
| | | |
| --- | --- | --- |
| tree\_column | a [GtkTreeViewColumn](gtktreeviewcolumn#GtkTreeViewColumn-struct) | |
### gtk\_tree\_view\_column\_set\_title ()
```
void
gtk_tree_view_column_set_title (*`[GtkTreeViewColumn](gtktreeviewcolumn#GtkTreeViewColumn-struct) *tree_column`*,
*`const char *title`*);
```
Sets the title of the *`tree_column`* . If a custom widget has been set, then this value is ignored.
#### Parameters
| | | |
| --- | --- | --- |
| tree\_column | A [GtkTreeViewColumn](gtktreeviewcolumn#GtkTreeViewColumn-struct). | |
| title | The title of the *`tree_column`* . | |
### gtk\_tree\_view\_column\_get\_title ()
```
const char *
gtk_tree_view_column_get_title (*`[GtkTreeViewColumn](gtktreeviewcolumn#GtkTreeViewColumn-struct) *tree_column`*);
```
Returns the title of the widget.
#### Parameters
| | | |
| --- | --- | --- |
| tree\_column | A [GtkTreeViewColumn](gtktreeviewcolumn#GtkTreeViewColumn-struct). | |
#### Returns
the title of the column. This string should not be modified or freed.
### gtk\_tree\_view\_column\_set\_expand ()
```
void
gtk_tree_view_column_set_expand (*`[GtkTreeViewColumn](gtktreeviewcolumn#GtkTreeViewColumn-struct) *tree_column`*,
*`gboolean expand`*);
```
Sets the column to take available extra space. This space is shared equally amongst all columns that have the expand set to `TRUE`. If no column has this option set, then the last column gets all extra space. By default, every column is created with this `FALSE`.
Along with “fixed-width”, the “expand” property changes when the column is resized by the user.
#### Parameters
| | | |
| --- | --- | --- |
| tree\_column | A [GtkTreeViewColumn](gtktreeviewcolumn#GtkTreeViewColumn-struct). | |
| expand | `TRUE` if the column should expand to fill available space. | |
### gtk\_tree\_view\_column\_get\_expand ()
```
gboolean
gtk_tree_view_column_get_expand (*`[GtkTreeViewColumn](gtktreeviewcolumn#GtkTreeViewColumn-struct) *tree_column`*);
```
Returns `TRUE` if the column expands to fill available space.
#### Parameters
| | | |
| --- | --- | --- |
| tree\_column | A [GtkTreeViewColumn](gtktreeviewcolumn#GtkTreeViewColumn-struct). | |
#### Returns
`TRUE` if the column expands to fill available space.
### gtk\_tree\_view\_column\_set\_clickable ()
```
void
gtk_tree_view_column_set_clickable (*`[GtkTreeViewColumn](gtktreeviewcolumn#GtkTreeViewColumn-struct) *tree_column`*,
*`gboolean clickable`*);
```
Sets the header to be active if *`clickable`* is `TRUE`. When the header is active, then it can take keyboard focus, and can be clicked.
#### Parameters
| | | |
| --- | --- | --- |
| tree\_column | A [GtkTreeViewColumn](gtktreeviewcolumn#GtkTreeViewColumn-struct). | |
| clickable | `TRUE` if the header is active. | |
### gtk\_tree\_view\_column\_get\_clickable ()
```
gboolean
gtk_tree_view_column_get_clickable (*`[GtkTreeViewColumn](gtktreeviewcolumn#GtkTreeViewColumn-struct) *tree_column`*);
```
Returns `TRUE` if the user can click on the header for the column.
#### Parameters
| | | |
| --- | --- | --- |
| tree\_column | a [GtkTreeViewColumn](gtktreeviewcolumn#GtkTreeViewColumn-struct) | |
#### Returns
`TRUE` if user can click the column header.
### gtk\_tree\_view\_column\_set\_widget ()
```
void
gtk_tree_view_column_set_widget (*`[GtkTreeViewColumn](gtktreeviewcolumn#GtkTreeViewColumn-struct) *tree_column`*,
*`[GtkWidget](gtkwidget#GtkWidget-struct) *widget`*);
```
Sets the widget in the header to be *`widget`* . If widget is `NULL`, then the header button is set with a [GtkLabel](gtklabel#GtkLabel-struct) set to the title of *`tree_column`* .
#### Parameters
| | | |
| --- | --- | --- |
| tree\_column | A [GtkTreeViewColumn](gtktreeviewcolumn#GtkTreeViewColumn-struct). | |
| widget | A child [GtkWidget](gtkwidget#GtkWidget-struct), or `NULL`. | [allow-none] |
### gtk\_tree\_view\_column\_get\_widget ()
```
[GtkWidget](gtkwidget#GtkWidget-struct) *
gtk_tree_view_column_get_widget (*`[GtkTreeViewColumn](gtktreeviewcolumn#GtkTreeViewColumn-struct) *tree_column`*);
```
Returns the [GtkWidget](gtkwidget#GtkWidget-struct) in the button on the column header. If a custom widget has not been set then `NULL` is returned.
#### Parameters
| | | |
| --- | --- | --- |
| tree\_column | A [GtkTreeViewColumn](gtktreeviewcolumn#GtkTreeViewColumn-struct). | |
#### Returns
The [GtkWidget](gtkwidget#GtkWidget-struct) in the column header, or `NULL`.
[nullable][transfer none]
### gtk\_tree\_view\_column\_get\_button ()
```
[GtkWidget](gtkwidget#GtkWidget-struct) *
gtk_tree_view_column_get_button (*`[GtkTreeViewColumn](gtktreeviewcolumn#GtkTreeViewColumn-struct) *tree_column`*);
```
Returns the button used in the treeview column header
#### Parameters
| | | |
| --- | --- | --- |
| tree\_column | A [GtkTreeViewColumn](gtktreeviewcolumn#GtkTreeViewColumn-struct) | |
#### Returns
The button for the column header.
[transfer none]
### gtk\_tree\_view\_column\_set\_alignment ()
```
void
gtk_tree_view_column_set_alignment (*`[GtkTreeViewColumn](gtktreeviewcolumn#GtkTreeViewColumn-struct) *tree_column`*,
*`float xalign`*);
```
Sets the alignment of the title or custom widget inside the column header. The alignment determines its location inside the button -- 0.0 for left, 0.5 for center, 1.0 for right.
#### Parameters
| | | |
| --- | --- | --- |
| tree\_column | A [GtkTreeViewColumn](gtktreeviewcolumn#GtkTreeViewColumn-struct). | |
| xalign | The alignment, which is between [0.0 and 1.0] inclusive. | |
### gtk\_tree\_view\_column\_get\_alignment ()
```
float
gtk_tree_view_column_get_alignment (*`[GtkTreeViewColumn](gtktreeviewcolumn#GtkTreeViewColumn-struct) *tree_column`*);
```
Returns the current x alignment of *`tree_column`* . This value can range between 0.0 and 1.0.
#### Parameters
| | | |
| --- | --- | --- |
| tree\_column | A [GtkTreeViewColumn](gtktreeviewcolumn#GtkTreeViewColumn-struct). | |
#### Returns
The current alignent of *`tree_column`* .
### gtk\_tree\_view\_column\_set\_reorderable ()
```
void
gtk_tree_view_column_set_reorderable (*`[GtkTreeViewColumn](gtktreeviewcolumn#GtkTreeViewColumn-struct) *tree_column`*,
*`gboolean reorderable`*);
```
If *`reorderable`* is `TRUE`, then the column can be reordered by the end user dragging the header.
#### Parameters
| | | |
| --- | --- | --- |
| tree\_column | A [GtkTreeViewColumn](gtktreeviewcolumn#GtkTreeViewColumn-struct) | |
| reorderable | `TRUE`, if the column can be reordered. | |
### gtk\_tree\_view\_column\_get\_reorderable ()
```
gboolean
gtk_tree_view_column_get_reorderable (*`[GtkTreeViewColumn](gtktreeviewcolumn#GtkTreeViewColumn-struct) *tree_column`*);
```
Returns `TRUE` if the *`tree_column`* can be reordered by the user.
#### Parameters
| | | |
| --- | --- | --- |
| tree\_column | A [GtkTreeViewColumn](gtktreeviewcolumn#GtkTreeViewColumn-struct) | |
#### Returns
`TRUE` if the *`tree_column`* can be reordered by the user.
### gtk\_tree\_view\_column\_set\_sort\_column\_id ()
```
void
gtk_tree_view_column_set_sort_column_id
(*`[GtkTreeViewColumn](gtktreeviewcolumn#GtkTreeViewColumn-struct) *tree_column`*,
*`int sort_column_id`*);
```
Sets the logical *`sort_column_id`* that this column sorts on when this column is selected for sorting. Doing so makes the column header clickable.
#### Parameters
| | | |
| --- | --- | --- |
| tree\_column | a [GtkTreeViewColumn](gtktreeviewcolumn#GtkTreeViewColumn-struct) | |
| sort\_column\_id | The *`sort_column_id`* of the model to sort on. | |
### gtk\_tree\_view\_column\_get\_sort\_column\_id ()
```
int
gtk_tree_view_column_get_sort_column_id
(*`[GtkTreeViewColumn](gtktreeviewcolumn#GtkTreeViewColumn-struct) *tree_column`*);
```
Gets the logical *`sort_column_id`* that the model sorts on when this column is selected for sorting. See [`gtk_tree_view_column_set_sort_column_id()`](gtktreeviewcolumn#gtk-tree-view-column-set-sort-column-id).
#### Parameters
| | | |
| --- | --- | --- |
| tree\_column | a [GtkTreeViewColumn](gtktreeviewcolumn#GtkTreeViewColumn-struct) | |
#### Returns
the current *`sort_column_id`* for this column, or -1 if this column can’t be used for sorting.
### gtk\_tree\_view\_column\_set\_sort\_indicator ()
```
void
gtk_tree_view_column_set_sort_indicator
(*`[GtkTreeViewColumn](gtktreeviewcolumn#GtkTreeViewColumn-struct) *tree_column`*,
*`gboolean setting`*);
```
Call this function with a *`setting`* of `TRUE` to display an arrow in the header button indicating the column is sorted. Call [`gtk_tree_view_column_set_sort_order()`](gtktreeviewcolumn#gtk-tree-view-column-set-sort-order) to change the direction of the arrow.
#### Parameters
| | | |
| --- | --- | --- |
| tree\_column | a [GtkTreeViewColumn](gtktreeviewcolumn#GtkTreeViewColumn-struct) | |
| setting | `TRUE` to display an indicator that the column is sorted | |
### gtk\_tree\_view\_column\_get\_sort\_indicator ()
```
gboolean
gtk_tree_view_column_get_sort_indicator
(*`[GtkTreeViewColumn](gtktreeviewcolumn#GtkTreeViewColumn-struct) *tree_column`*);
```
Gets the value set by [`gtk_tree_view_column_set_sort_indicator()`](gtktreeviewcolumn#gtk-tree-view-column-set-sort-indicator).
#### Parameters
| | | |
| --- | --- | --- |
| tree\_column | a [GtkTreeViewColumn](gtktreeviewcolumn#GtkTreeViewColumn-struct) | |
#### Returns
whether the sort indicator arrow is displayed
### gtk\_tree\_view\_column\_set\_sort\_order ()
```
void
gtk_tree_view_column_set_sort_order (*`[GtkTreeViewColumn](gtktreeviewcolumn#GtkTreeViewColumn-struct) *tree_column`*,
*`[GtkSortType](gtk4-standard-enumerations#GtkSortType) order`*);
```
Changes the appearance of the sort indicator.
This does not actually sort the model. Use [`gtk_tree_view_column_set_sort_column_id()`](gtktreeviewcolumn#gtk-tree-view-column-set-sort-column-id) if you want automatic sorting support. This function is primarily for custom sorting behavior, and should be used in conjunction with [`gtk_tree_sortable_set_sort_column_id()`](gtktreesortable#gtk-tree-sortable-set-sort-column-id) to do that. For custom models, the mechanism will vary.
The sort indicator changes direction to indicate normal sort or reverse sort. Note that you must have the sort indicator enabled to see anything when calling this function; see [`gtk_tree_view_column_set_sort_indicator()`](gtktreeviewcolumn#gtk-tree-view-column-set-sort-indicator).
#### Parameters
| | | |
| --- | --- | --- |
| tree\_column | a [GtkTreeViewColumn](gtktreeviewcolumn#GtkTreeViewColumn-struct) | |
| order | sort order that the sort indicator should indicate | |
### gtk\_tree\_view\_column\_get\_sort\_order ()
```
[GtkSortType](gtk4-standard-enumerations#GtkSortType)
gtk_tree_view_column_get_sort_order (*`[GtkTreeViewColumn](gtktreeviewcolumn#GtkTreeViewColumn-struct) *tree_column`*);
```
Gets the value set by [`gtk_tree_view_column_set_sort_order()`](gtktreeviewcolumn#gtk-tree-view-column-set-sort-order).
#### Parameters
| | | |
| --- | --- | --- |
| tree\_column | a [GtkTreeViewColumn](gtktreeviewcolumn#GtkTreeViewColumn-struct) | |
#### Returns
the sort order the sort indicator is indicating
### gtk\_tree\_view\_column\_cell\_set\_cell\_data ()
```
void
gtk_tree_view_column_cell_set_cell_data
(*`[GtkTreeViewColumn](gtktreeviewcolumn#GtkTreeViewColumn-struct) *tree_column`*,
*`[GtkTreeModel](gtktreemodel#GtkTreeModel-struct) *tree_model`*,
*`[GtkTreeIter](gtktreemodel#GtkTreeIter-struct) *iter`*,
*`gboolean is_expander`*,
*`gboolean is_expanded`*);
```
Sets the cell renderer based on the *`tree_model`* and *`iter`* . That is, for every attribute mapping in *`tree_column`* , it will get a value from the set column on the *`iter`* , and use that value to set the attribute on the cell renderer. This is used primarily by the [GtkTreeView](gtktreeview#GtkTreeView-struct).
#### Parameters
| | | |
| --- | --- | --- |
| tree\_column | A [GtkTreeViewColumn](gtktreeviewcolumn#GtkTreeViewColumn-struct). | |
| tree\_model | The [GtkTreeModel](gtktreemodel#GtkTreeModel-struct) to get the cell renderers attributes from. | |
| iter | The [GtkTreeIter](gtktreemodel#GtkTreeIter-struct) to get the cell renderer’s attributes from. | |
| is\_expander | `TRUE`, if the row has children | |
| is\_expanded | `TRUE`, if the row has visible children | |
### gtk\_tree\_view\_column\_cell\_get\_size ()
```
void
gtk_tree_view_column_cell_get_size (*`[GtkTreeViewColumn](gtktreeviewcolumn#GtkTreeViewColumn-struct) *tree_column`*,
*`int *x_offset`*,
*`int *y_offset`*,
*`int *width`*,
*`int *height`*);
```
Obtains the width and height needed to render the column. This is used primarily by the [GtkTreeView](gtktreeview#GtkTreeView-struct).
#### Parameters
| | | |
| --- | --- | --- |
| tree\_column | A [GtkTreeViewColumn](gtktreeviewcolumn#GtkTreeViewColumn-struct). | |
| x\_offset | location to return x offset of a cell relative to *`cell_area`* , or `NULL`. | [out][optional] |
| y\_offset | location to return y offset of a cell relative to *`cell_area`* , or `NULL`. | [out][optional] |
| width | location to return width needed to render a cell, or `NULL`. | [out][optional] |
| height | location to return height needed to render a cell, or `NULL`. | [out][optional] |
### gtk\_tree\_view\_column\_cell\_get\_position ()
```
gboolean
gtk_tree_view_column_cell_get_position
(*`[GtkTreeViewColumn](gtktreeviewcolumn#GtkTreeViewColumn-struct) *tree_column`*,
*`[GtkCellRenderer](gtkcellrenderer#GtkCellRenderer-struct) *cell_renderer`*,
*`int *x_offset`*,
*`int *width`*);
```
Obtains the horizontal position and size of a cell in a column. If the cell is not found in the column, *`start_pos`* and *`width`* are not changed and `FALSE` is returned.
#### Parameters
| | | |
| --- | --- | --- |
| tree\_column | a [GtkTreeViewColumn](gtktreeviewcolumn#GtkTreeViewColumn-struct) | |
| cell\_renderer | a [GtkCellRenderer](gtkcellrenderer#GtkCellRenderer-struct) | |
| x\_offset | return location for the horizontal position of *`cell`* within *`tree_column`* , may be `NULL`. | [out][allow-none] |
| width | return location for the width of *`cell`* , may be `NULL`. | [out][allow-none] |
#### Returns
`TRUE` if *`cell`* belongs to *`tree_column`* .
### gtk\_tree\_view\_column\_cell\_is\_visible ()
```
gboolean
gtk_tree_view_column_cell_is_visible (*`[GtkTreeViewColumn](gtktreeviewcolumn#GtkTreeViewColumn-struct) *tree_column`*);
```
Returns `TRUE` if any of the cells packed into the *`tree_column`* are visible. For this to be meaningful, you must first initialize the cells with [`gtk_tree_view_column_cell_set_cell_data()`](gtktreeviewcolumn#gtk-tree-view-column-cell-set-cell-data)
#### Parameters
| | | |
| --- | --- | --- |
| tree\_column | A [GtkTreeViewColumn](gtktreeviewcolumn#GtkTreeViewColumn-struct) | |
#### Returns
`TRUE`, if any of the cells packed into the *`tree_column`* are currently visible
### gtk\_tree\_view\_column\_focus\_cell ()
```
void
gtk_tree_view_column_focus_cell (*`[GtkTreeViewColumn](gtktreeviewcolumn#GtkTreeViewColumn-struct) *tree_column`*,
*`[GtkCellRenderer](gtkcellrenderer#GtkCellRenderer-struct) *cell`*);
```
Sets the current keyboard focus to be at *`cell`* , if the column contains 2 or more editable and activatable cells.
#### Parameters
| | | |
| --- | --- | --- |
| tree\_column | A [GtkTreeViewColumn](gtktreeviewcolumn#GtkTreeViewColumn-struct) | |
| cell | A [GtkCellRenderer](gtkcellrenderer#GtkCellRenderer-struct) | |
### gtk\_tree\_view\_column\_queue\_resize ()
```
void
gtk_tree_view_column_queue_resize (*`[GtkTreeViewColumn](gtktreeviewcolumn#GtkTreeViewColumn-struct) *tree_column`*);
```
Flags the column, and the cell renderers added to this column, to have their sizes renegotiated.
#### Parameters
| | | |
| --- | --- | --- |
| tree\_column | A [GtkTreeViewColumn](gtktreeviewcolumn#GtkTreeViewColumn-struct) | |
### gtk\_tree\_view\_column\_get\_tree\_view ()
```
[GtkWidget](gtkwidget#GtkWidget-struct) *
gtk_tree_view_column_get_tree_view (*`[GtkTreeViewColumn](gtktreeviewcolumn#GtkTreeViewColumn-struct) *tree_column`*);
```
Returns the [GtkTreeView](gtktreeview#GtkTreeView-struct) wherein *`tree_column`* has been inserted. If *`column`* is currently not inserted in any tree view, `NULL` is returned.
#### Parameters
| | | |
| --- | --- | --- |
| tree\_column | A [GtkTreeViewColumn](gtktreeviewcolumn#GtkTreeViewColumn-struct) | |
#### Returns
The tree view wherein *`column`* has been inserted if any, `NULL` otherwise.
[nullable][transfer none]
### gtk\_tree\_view\_column\_get\_x\_offset ()
```
int
gtk_tree_view_column_get_x_offset (*`[GtkTreeViewColumn](gtktreeviewcolumn#GtkTreeViewColumn-struct) *tree_column`*);
```
Returns the current X offset of *`tree_column`* in pixels.
#### Parameters
| | | |
| --- | --- | --- |
| tree\_column | A [GtkTreeViewColumn](gtktreeviewcolumn#GtkTreeViewColumn-struct). | |
#### Returns
The current X offset of *`tree_column`* .
Types and Values
----------------
### enum GtkTreeViewColumnSizing
The sizing method the column uses to determine its width. Please note that [`GTK_TREE_VIEW_COLUMN_AUTOSIZE`](gtktreeviewcolumn#GTK-TREE-VIEW-COLUMN-AUTOSIZE:CAPS) are inefficient for large views, and can make columns appear choppy.
#### Members
| | | |
| --- | --- | --- |
| GTK\_TREE\_VIEW\_COLUMN\_GROW\_ONLY | Columns only get bigger in reaction to changes in the model | |
| GTK\_TREE\_VIEW\_COLUMN\_AUTOSIZE | Columns resize to be the optimal size every time the model changes. | |
| GTK\_TREE\_VIEW\_COLUMN\_FIXED | Columns are a fixed numbers of pixels wide. | |
### GtkTreeViewColumn
```
typedef struct _GtkTreeViewColumn GtkTreeViewColumn;
```
Property Details
----------------
### The `“alignment”` property
```
“alignment” float
```
X Alignment of the column header text or widget.
Owner: GtkTreeViewColumn
Flags: Read / Write
Allowed values: [0,1]
Default value: 0
### The `“cell-area”` property
```
“cell-area” [GtkCellArea](gtkcellarea#GtkCellArea-struct) *
```
The [GtkCellArea](gtkcellarea#GtkCellArea-struct) used to layout cell renderers for this column.
If no area is specified when creating the tree view column with [`gtk_tree_view_column_new_with_area()`](gtktreeviewcolumn#gtk-tree-view-column-new-with-area) a horizontally oriented [GtkCellAreaBox](gtkcellareabox#GtkCellAreaBox-struct) will be used.
Owner: GtkTreeViewColumn
Flags: Read / Write / Construct Only
### The `“clickable”` property
```
“clickable” gboolean
```
Whether the header can be clicked.
Owner: GtkTreeViewColumn
Flags: Read / Write
Default value: FALSE
### The `“expand”` property
```
“expand” gboolean
```
Column gets share of extra width allocated to the widget.
Owner: GtkTreeViewColumn
Flags: Read / Write
Default value: FALSE
### The `“fixed-width”` property
```
“fixed-width” int
```
Current fixed width of the column.
Owner: GtkTreeViewColumn
Flags: Read / Write
Allowed values: >= -1
Default value: -1
### The `“max-width”` property
```
“max-width” int
```
Maximum allowed width of the column.
Owner: GtkTreeViewColumn
Flags: Read / Write
Allowed values: >= -1
Default value: -1
### The `“min-width”` property
```
“min-width” int
```
Minimum allowed width of the column.
Owner: GtkTreeViewColumn
Flags: Read / Write
Allowed values: >= -1
Default value: -1
### The `“reorderable”` property
```
“reorderable” gboolean
```
Whether the column can be reordered around the headers.
Owner: GtkTreeViewColumn
Flags: Read / Write
Default value: FALSE
### The `“resizable”` property
```
“resizable” gboolean
```
Column is user-resizable.
Owner: GtkTreeViewColumn
Flags: Read / Write
Default value: FALSE
### The `“sizing”` property
```
“sizing” [GtkTreeViewColumnSizing](gtktreeviewcolumn#GtkTreeViewColumnSizing)
```
Resize mode of the column.
Owner: GtkTreeViewColumn
Flags: Read / Write
Default value: GTK\_TREE\_VIEW\_COLUMN\_GROW\_ONLY
### The `“sort-column-id”` property
```
“sort-column-id” int
```
Logical sort column ID this column sorts on when selected for sorting. Setting the sort column ID makes the column header clickable. Set to -1 to make the column unsortable.
Owner: GtkTreeViewColumn
Flags: Read / Write
Allowed values: >= -1
Default value: -1
### The `“sort-indicator”` property
```
“sort-indicator” gboolean
```
Whether to show a sort indicator.
Owner: GtkTreeViewColumn
Flags: Read / Write
Default value: FALSE
### The `“sort-order”` property
```
“sort-order” [GtkSortType](gtk4-standard-enumerations#GtkSortType)
```
Sort direction the sort indicator should indicate.
Owner: GtkTreeViewColumn
Flags: Read / Write
Default value: GTK\_SORT\_ASCENDING
### The `“spacing”` property
```
“spacing” int
```
Space which is inserted between cells.
Owner: GtkTreeViewColumn
Flags: Read / Write
Allowed values: >= 0
Default value: 0
### The `“title”` property
```
“title” char *
```
Title to appear in column header.
Owner: GtkTreeViewColumn
Flags: Read / Write
Default value: ""
### The `“visible”` property
```
“visible” gboolean
```
Whether to display the column.
Owner: GtkTreeViewColumn
Flags: Read / Write
Default value: TRUE
### The `“widget”` property
```
“widget” [GtkWidget](gtkwidget#GtkWidget-struct) *
```
Widget to put in column header button instead of column title.
Owner: GtkTreeViewColumn
Flags: Read / Write
### The `“width”` property
```
“width” int
```
Current width of the column.
Owner: GtkTreeViewColumn
Flags: Read
Allowed values: >= 0
Default value: 0
### The `“x-offset”` property
```
“x-offset” int
```
Current X position of the column.
Owner: GtkTreeViewColumn
Flags: Read
Allowed values: >= -2147483647
Default value: 0
Signal Details
--------------
### The `“clicked”` signal
```
void
user_function ([GtkTreeViewColumn](gtktreeviewcolumn#GtkTreeViewColumn-struct) *column,
gpointer user_data)
```
Emitted when the column's header has been clicked.
#### Parameters
| | | |
| --- | --- | --- |
| column | the [GtkTreeViewColumn](gtktreeviewcolumn#GtkTreeViewColumn-struct) that emitted the signal | |
| user\_data | user data set when the signal handler was connected. | |
Flags: Run Last
See Also
--------
[GtkTreeView](gtktreeview#GtkTreeView-struct), [GtkTreeSelection](gtktreeselection#GtkTreeSelection-struct), [GtkTreeModel](gtktreemodel#GtkTreeModel-struct), [GtkTreeSortable](gtktreesortable#GtkTreeSortable-struct), [GtkTreeModelSort](gtktreemodelsort#GtkTreeModelSort-struct), [GtkListStore](gtkliststore#GtkListStore-struct), [GtkTreeStore](gtktreestore#GtkTreeStore-struct), [GtkCellRenderer](gtkcellrenderer#GtkCellRenderer-struct), [GtkCellEditable](gtkcelleditable#GtkCellEditable-struct), [GtkCellRendererPixbuf](gtkcellrendererpixbuf#GtkCellRendererPixbuf-struct), [GtkCellRendererText](gtkcellrenderertext#GtkCellRendererText-struct), [GtkCellRendererToggle](gtkcellrenderertoggle#GtkCellRendererToggle-struct), GtkTreeView drag-and-drop
| programming_docs |
gtk GtkConstraintLayout GtkConstraintLayout
===================
GtkConstraintLayout — A layout manager using constraints
Functions
---------
| | |
| --- | --- |
| [GtkLayoutManager](gtklayoutmanager#GtkLayoutManager-struct) \* | [gtk\_constraint\_layout\_new](gtkconstraintlayout#gtk-constraint-layout-new) () |
| void | [gtk\_constraint\_layout\_add\_constraint](gtkconstraintlayout#gtk-constraint-layout-add-constraint) () |
| void | [gtk\_constraint\_layout\_remove\_constraint](gtkconstraintlayout#gtk-constraint-layout-remove-constraint) () |
| void | [gtk\_constraint\_layout\_remove\_all\_constraints](gtkconstraintlayout#gtk-constraint-layout-remove-all-constraints) () |
| void | [gtk\_constraint\_layout\_add\_guide](gtkconstraintlayout#gtk-constraint-layout-add-guide) () |
| void | [gtk\_constraint\_layout\_remove\_guide](gtkconstraintlayout#gtk-constraint-layout-remove-guide) () |
| GList \* | [gtk\_constraint\_layout\_add\_constraints\_from\_description](gtkconstraintlayout#gtk-constraint-layout-add-constraints-from-description) () |
| GList \* | [gtk\_constraint\_layout\_add\_constraints\_from\_descriptionv](gtkconstraintlayout#gtk-constraint-layout-add-constraints-from-descriptionv) () |
| GListModel \* | [gtk\_constraint\_layout\_observe\_constraints](gtkconstraintlayout#gtk-constraint-layout-observe-constraints) () |
| GListModel \* | [gtk\_constraint\_layout\_observe\_guides](gtkconstraintlayout#gtk-constraint-layout-observe-guides) () |
Types and Values
----------------
| | |
| --- | --- |
| | [GtkConstraintLayout](gtkconstraintlayout#GtkConstraintLayout-struct) |
| | [GtkConstraintLayoutChild](gtkconstraintlayout#GtkConstraintLayoutChild-struct) |
| enum | [GtkConstraintVflParserError](gtkconstraintlayout#GtkConstraintVflParserError) |
Object Hierarchy
----------------
```
GObject
├── [GtkLayoutChild](gtklayoutchild#GtkLayoutChild-struct)
│ ╰── GtkConstraintLayoutChild
╰── [GtkLayoutManager](gtklayoutmanager#GtkLayoutManager-struct)
╰── GtkConstraintLayout
```
Implemented Interfaces
----------------------
GtkConstraintLayout implements [GtkBuildable](gtkbuildable#GtkBuildable-struct).
Includes
--------
```
#include <gtk/gtk.h>
```
Description
-----------
GtkConstraintLayout is a layout manager that uses relations between widget attributes, expressed via [GtkConstraint](gtkconstraint#GtkConstraint-struct) instances, to measure and allocate widgets.
### How do constraints work
Constraints are objects defining the relationship between attributes of a widget; you can read the description of the [GtkConstraint](gtkconstraint#GtkConstraint-struct) class to have a more in depth definition.
By taking multiple constraints and applying them to the children of a widget using [GtkConstraintLayout](gtkconstraintlayout#GtkConstraintLayout-struct), it's possible to describe complex layout policies; each constraint applied to a child or to the parent widgets contributes to the full description of the layout, in terms of parameters for resolving the value of each attribute.
It is important to note that a layout is defined by the totality of constraints; removing a child, or a constraint, from an existing layout without changing the remaining constraints may result in an unstable or unsolvable layout.
Constraints have an implicit "reading order"; you should start describing each edge of each child, as well as their relationship with the parent container, from the top left (or top right, in RTL languages), horizontally first, and then vertically.
A constraint-based layout with too few constraints can become "unstable", that is: have more than one solution. The behavior of an unstable layout is undefined.
A constraint-based layout with conflicting constraints may be unsolvable, and lead to an unstable layout. You can use the [“strength”](gtkconstraint#GtkConstraint--strength) property of [GtkConstraint](gtkconstraint#GtkConstraint-struct) to "nudge" the layout towards a solution.
### GtkConstraintLayout as GtkBuildable
GtkConstraintLayout implements the [GtkBuildable](gtkbuildable#GtkBuildable-struct) interface and has a custom "constraints" element which allows describing constraints in a GtkBuilder UI file.
An example of a UI definition fragment specifying a constraint:
The definition above will add two constraints to the GtkConstraintLayout:
* a required constraint between the leading edge of "button" and the leading edge of the widget using the constraint layout, plus 12 pixels
* a strong, constant constraint making the width of "button" greater than, or equal to 250 pixels
The "target" and "target-attribute" attributes are required.
The "source" and "source-attribute" attributes of the "constraint" element are optional; if they are not specified, the constraint is assumed to be a constant.
The "relation" attribute is optional; if not specified, the constraint is assumed to be an equality.
The "strength" attribute is optional; if not specified, the constraint is assumed to be required.
The "source" and "target" attributes can be set to "super" to indicate that the constraint target is the widget using the GtkConstraintLayout.
There can be "constant" and "multiplier" attributes.
Additionally, the "constraints" element can also contain a description of the GtkConstraintGuides used by the layout:
The "guide" element has the following optional attributes:
* "min-width", "nat-width", and "max-width", describe the minimum, natural, and maximum width of the guide, respectively
* "min-height", "nat-height", and "max-height", describe the minimum, natural, and maximum height of the guide, respectively
* "strength" describes the strength of the constraint on the natural size of the guide; if not specified, the constraint is assumed to have a medium strength
* "name" describes a name for the guide, useful when debugging
### Using the Visual Format Language
Complex constraints can be described using a compact syntax called VFL, or \*Visual Format Language\*.
The Visual Format Language describes all the constraints on a row or column, typically starting from the leading edge towards the trailing one. Each element of the layout is composed by "views", which identify a [GtkConstraintTarget](gtkconstraint#GtkConstraintTarget-struct).
For instance:
Describes a constraint that binds the trailing edge of "button" to the leading edge of "textField", leaving a default space between the two.
Using VFL is also possible to specify predicates that describe constraints on attributes like width and height:
The default orientation for a VFL description is horizontal, unless otherwise specified:
It's also possible to specify multiple predicates, as well as their strength:
Finally, it's also possible to use simple arithmetic operators:
Functions
---------
### gtk\_constraint\_layout\_new ()
```
[GtkLayoutManager](gtklayoutmanager#GtkLayoutManager-struct) *
gtk_constraint_layout_new (*`void`*);
```
Creates a new [GtkConstraintLayout](gtkconstraintlayout#GtkConstraintLayout-struct) layout manager.
#### Returns
the newly created [GtkConstraintLayout](gtkconstraintlayout#GtkConstraintLayout-struct)
### gtk\_constraint\_layout\_add\_constraint ()
```
void
gtk_constraint_layout_add_constraint (*`[GtkConstraintLayout](gtkconstraintlayout#GtkConstraintLayout-struct) *layout`*,
*`[GtkConstraint](gtkconstraint#GtkConstraint-struct) *constraint`*);
```
Adds a [GtkConstraint](gtkconstraint#GtkConstraint-struct) to the layout manager.
The [“source”](gtkconstraint#GtkConstraint--source) and [“target”](gtkconstraint#GtkConstraint--target) properties of *`constraint`* can be:
* set to `NULL` to indicate that the constraint refers to the widget using *`layout`*
* set to the [GtkWidget](gtkwidget#GtkWidget-struct) using *`layout`*
* set to a child of the [GtkWidget](gtkwidget#GtkWidget-struct) using *`layout`*
* set to a guide that is part of *`layout`*
The *`layout`* acquires the ownership of *`constraint`* after calling this function.
#### Parameters
| | | |
| --- | --- | --- |
| layout | a [GtkConstraintLayout](gtkconstraintlayout#GtkConstraintLayout-struct) | |
| constraint | a [GtkConstraint](gtkconstraint#GtkConstraint-struct). | [transfer full] |
### gtk\_constraint\_layout\_remove\_constraint ()
```
void
gtk_constraint_layout_remove_constraint
(*`[GtkConstraintLayout](gtkconstraintlayout#GtkConstraintLayout-struct) *layout`*,
*`[GtkConstraint](gtkconstraint#GtkConstraint-struct) *constraint`*);
```
Removes *`constraint`* from the layout manager, so that it no longer influences the layout.
#### Parameters
| | | |
| --- | --- | --- |
| layout | a [GtkConstraintLayout](gtkconstraintlayout#GtkConstraintLayout-struct) | |
| constraint | a [GtkConstraint](gtkconstraint#GtkConstraint-struct) | |
### gtk\_constraint\_layout\_remove\_all\_constraints ()
```
void
gtk_constraint_layout_remove_all_constraints
(*`[GtkConstraintLayout](gtkconstraintlayout#GtkConstraintLayout-struct) *layout`*);
```
Removes all constraints from the layout manager.
#### Parameters
| | | |
| --- | --- | --- |
| layout | a [GtkConstraintLayout](gtkconstraintlayout#GtkConstraintLayout-struct) | |
### gtk\_constraint\_layout\_add\_guide ()
```
void
gtk_constraint_layout_add_guide (*`[GtkConstraintLayout](gtkconstraintlayout#GtkConstraintLayout-struct) *layout`*,
*`[GtkConstraintGuide](gtkconstraintguide#GtkConstraintGuide-struct) *guide`*);
```
Adds a guide to *`layout`* . A guide can be used as the source or target of constraints, like a widget, but it is not visible.
The *`layout`* acquires the ownership of *`guide`* after calling this function.
#### Parameters
| | | |
| --- | --- | --- |
| layout | a [GtkConstraintLayout](gtkconstraintlayout#GtkConstraintLayout-struct) | |
| guide | a [GtkConstraintGuide](gtkconstraintguide#GtkConstraintGuide-struct) object. | [transfer full] |
### gtk\_constraint\_layout\_remove\_guide ()
```
void
gtk_constraint_layout_remove_guide (*`[GtkConstraintLayout](gtkconstraintlayout#GtkConstraintLayout-struct) *layout`*,
*`[GtkConstraintGuide](gtkconstraintguide#GtkConstraintGuide-struct) *guide`*);
```
Removes *`guide`* from the layout manager, so that it no longer influences the layout.
#### Parameters
| | | |
| --- | --- | --- |
| layout | a [GtkConstraintLayout](gtkconstraintlayout#GtkConstraintLayout-struct) | |
| guide | a [GtkConstraintGuide](gtkconstraintguide#GtkConstraintGuide-struct) object | |
### gtk\_constraint\_layout\_add\_constraints\_from\_description ()
```
GList *
gtk_constraint_layout_add_constraints_from_description
(*`[GtkConstraintLayout](gtkconstraintlayout#GtkConstraintLayout-struct) *layout`*,
*`const char * const lines[]`*,
*`gsize n_lines`*,
*`int hspacing`*,
*`int vspacing`*,
*`GError **error`*,
*`const char *first_view`*,
*`...`*);
```
Creates a list of constraints they formal description using a compact description syntax called VFL, or "Visual Format Language".
This function is a convenience wrapper around [`gtk_constraint_layout_add_constraints_from_descriptionv()`](gtkconstraintlayout#gtk-constraint-layout-add-constraints-from-descriptionv), using variadic arguments to populate the view/target map.
#### Parameters
| | | |
| --- | --- | --- |
| layout | a [GtkConstraintLayout](gtkconstraintlayout#GtkConstraintLayout-struct) | |
| lines | an array of Visual Format Language lines defining a set of constraints. | [array length=n\_lines] |
| n\_lines | the number of lines | |
| hspacing | default horizontal spacing value, or -1 for the fallback value | |
| vspacing | default vertical spacing value, or -1 for the fallback value | |
| error | return location for a GError | |
| first\_view | the name of a view in the VFL description, followed by the [GtkConstraintTarget](gtkconstraint#GtkConstraintTarget-struct) to which it maps | |
| ... | a `NULL`-terminated list of view names and [GtkConstraintTargets](gtkconstraint#GtkConstraintTarget-struct) | |
#### Returns
the list of [GtkConstraints](gtkconstraint#GtkConstraint-struct) that were added to the layout.
[transfer container][element-type GtkConstraint]
### gtk\_constraint\_layout\_add\_constraints\_from\_descriptionv ()
```
GList *
gtk_constraint_layout_add_constraints_from_descriptionv
(*`[GtkConstraintLayout](gtkconstraintlayout#GtkConstraintLayout-struct) *layout`*,
*`const char * const lines[]`*,
*`gsize n_lines`*,
*`int hspacing`*,
*`int vspacing`*,
*`GHashTable *views`*,
*`GError **error`*);
```
Creates a list of constraints from a formal description using a compact description syntax called VFL, or "Visual Format Language".
The Visual Format Language is based on Apple's AutoLayout [VFL](https://developer.apple.com/library/content/documentation/UserExperience/Conceptual/AutolayoutPG/VisualFormatLanguage.html).
The *`views`* dictionary is used to match [GtkConstraintTargets](gtkconstraint#GtkConstraintTarget-struct) to the symbolic view name inside the VFL.
The VFL grammar is:
\*\*Note\*\*: The VFL grammar used by GTK is slightly different than the one defined by Apple, as it can use symbolic values for the constraint's strength instead of numeric values; additionally, GTK allows adding simple arithmetic operations inside predicates.
Examples of VFL descriptions are:
```
<object class="GtkConstraintLayout">
<constraints>
<constraint target="button" target-attribute="start"
relation="eq"
source="super" source-attribute="start"
constant="12"
strength="required" />
<constraint target="button" target-attribute="width"
relation="ge"
constant="250"
strength="strong" />
</constraints>
</object>
```
| [rename-to gtk\_constraint\_layout\_add\_constraints\_from\_description]
#### Parameters
| | | |
| --- | --- | --- |
| layout | a [GtkConstraintLayout](gtkconstraintlayout#GtkConstraintLayout-struct) | |
| lines | an array of Visual Format Language lines defining a set of constraints. | [array length=n\_lines] |
| n\_lines | the number of lines | |
| hspacing | default horizontal spacing value, or -1 for the fallback value | |
| vspacing | default vertical spacing value, or -1 for the fallback value | |
| views | a dictionary of [ name, target ] pairs; the `name` keys map to the view names in the VFL lines, while the `target` values map to children of the widget using a [GtkConstraintLayout](gtkconstraintlayout#GtkConstraintLayout-struct), or guides. | [element-type utf8 Gtk.ConstraintTarget] |
| error | return location for a GError | |
#### Returns
the list of [GtkConstraints](gtkconstraint#GtkConstraint-struct) that were added to the layout.
[transfer container][element-type GtkConstraint]
### gtk\_constraint\_layout\_observe\_constraints ()
```
GListModel *
gtk_constraint_layout_observe_constraints
(*`[GtkConstraintLayout](gtkconstraintlayout#GtkConstraintLayout-struct) *layout`*);
```
Returns a GListModel to track the constraints that are part of *`layout`* .
Calling this function will enable extra internal bookkeeping to track constraints and emit signals on the returned listmodel. It may slow down operations a lot.
Applications should try hard to avoid calling this function because of the slowdowns.
#### Parameters
| | | |
| --- | --- | --- |
| layout | a [GtkConstraintLayout](gtkconstraintlayout#GtkConstraintLayout-struct) | |
#### Returns
a GListModel tracking *`layout`* 's constraints.
[transfer full][attributes element-type=GtkConstraint]
### gtk\_constraint\_layout\_observe\_guides ()
```
GListModel *
gtk_constraint_layout_observe_guides (*`[GtkConstraintLayout](gtkconstraintlayout#GtkConstraintLayout-struct) *layout`*);
```
Returns a GListModel to track the guides that are part of *`layout`* .
Calling this function will enable extra internal bookkeeping to track guides and emit signals on the returned listmodel. It may slow down operations a lot.
Applications should try hard to avoid calling this function because of the slowdowns.
#### Parameters
| | | |
| --- | --- | --- |
| layout | a [GtkConstraintLayout](gtkconstraintlayout#GtkConstraintLayout-struct) | |
#### Returns
a GListModel tracking *`layout`* 's guides.
[transfer full][attributes element-type=GtkConstraintGuide]
Types and Values
----------------
### GtkConstraintLayout
```
typedef struct _GtkConstraintLayout GtkConstraintLayout;
```
A layout manager using [GtkConstraint](gtkconstraint#GtkConstraint-struct) to describe relations between widgets.
### GtkConstraintLayoutChild
```
typedef struct _GtkConstraintLayoutChild GtkConstraintLayoutChild;
```
A [GtkLayoutChild](gtklayoutchild#GtkLayoutChild-struct) in a [GtkConstraintLayout](gtkconstraintlayout#GtkConstraintLayout-struct).
### enum GtkConstraintVflParserError
Domain for VFL parsing errors.
#### Members
| | | |
| --- | --- | --- |
| GTK\_CONSTRAINT\_VFL\_PARSER\_ERROR\_INVALID\_SYMBOL | Invalid or unknown symbol | |
| GTK\_CONSTRAINT\_VFL\_PARSER\_ERROR\_INVALID\_ATTRIBUTE | Invalid or unknown attribute | |
| GTK\_CONSTRAINT\_VFL\_PARSER\_ERROR\_INVALID\_VIEW | Invalid or unknown view | |
| GTK\_CONSTRAINT\_VFL\_PARSER\_ERROR\_INVALID\_METRIC | Invalid or unknown metric | |
| GTK\_CONSTRAINT\_VFL\_PARSER\_ERROR\_INVALID\_PRIORITY | Invalid or unknown priority | |
| GTK\_CONSTRAINT\_VFL\_PARSER\_ERROR\_INVALID\_RELATION | Invalid or unknown relation | |
gtk GtkDialog GtkDialog
=========
GtkDialog — Create popup windows
Functions
---------
| | |
| --- | --- |
| [GtkWidget](gtkwidget#GtkWidget-struct) \* | [gtk\_dialog\_new](gtkdialog#gtk-dialog-new) () |
| [GtkWidget](gtkwidget#GtkWidget-struct) \* | [gtk\_dialog\_new\_with\_buttons](gtkdialog#gtk-dialog-new-with-buttons) () |
| void | [gtk\_dialog\_response](gtkdialog#gtk-dialog-response) () |
| [GtkWidget](gtkwidget#GtkWidget-struct) \* | [gtk\_dialog\_add\_button](gtkdialog#gtk-dialog-add-button) () |
| void | [gtk\_dialog\_add\_buttons](gtkdialog#gtk-dialog-add-buttons) () |
| void | [gtk\_dialog\_add\_action\_widget](gtkdialog#gtk-dialog-add-action-widget) () |
| void | [gtk\_dialog\_set\_default\_response](gtkdialog#gtk-dialog-set-default-response) () |
| void | [gtk\_dialog\_set\_response\_sensitive](gtkdialog#gtk-dialog-set-response-sensitive) () |
| int | [gtk\_dialog\_get\_response\_for\_widget](gtkdialog#gtk-dialog-get-response-for-widget) () |
| [GtkWidget](gtkwidget#GtkWidget-struct) \* | [gtk\_dialog\_get\_widget\_for\_response](gtkdialog#gtk-dialog-get-widget-for-response) () |
| [GtkWidget](gtkwidget#GtkWidget-struct) \* | [gtk\_dialog\_get\_content\_area](gtkdialog#gtk-dialog-get-content-area) () |
| [GtkWidget](gtkwidget#GtkWidget-struct) \* | [gtk\_dialog\_get\_header\_bar](gtkdialog#gtk-dialog-get-header-bar) () |
Properties
----------
| | | |
| --- | --- | --- |
| int | [use-header-bar](gtkdialog#GtkDialog--use-header-bar) | Read / Write / Construct Only |
Signals
-------
| | | |
| --- | --- | --- |
| void | [close](gtkdialog#GtkDialog-close) | Action |
| void | [response](gtkdialog#GtkDialog-response) | Run Last |
Types and Values
----------------
| | |
| --- | --- |
| struct | [GtkDialog](gtkdialog#GtkDialog-struct) |
| struct | [GtkDialogClass](gtkdialog#GtkDialogClass) |
| enum | [GtkDialogFlags](gtkdialog#GtkDialogFlags) |
| enum | [GtkResponseType](gtkdialog#GtkResponseType) |
Object Hierarchy
----------------
```
GObject
╰── GInitiallyUnowned
╰── [GtkWidget](gtkwidget#GtkWidget-struct)
╰── [GtkWindow](gtkwindow#GtkWindow-struct)
╰── GtkDialog
├── [GtkAppChooserDialog](gtkappchooserdialog#GtkAppChooserDialog-struct)
├── [GtkColorChooserDialog](gtkcolorchooserdialog#GtkColorChooserDialog-struct)
├── [GtkFileChooserDialog](gtkfilechooserdialog#GtkFileChooserDialog-struct)
├── [GtkFontChooserDialog](gtkfontchooserdialog#GtkFontChooserDialog-struct)
├── [GtkMessageDialog](gtkmessagedialog#GtkMessageDialog-struct)
├── [GtkPageSetupUnixDialog](gtkpagesetupunixdialog#GtkPageSetupUnixDialog-struct)
╰── [GtkPrintUnixDialog](gtkprintunixdialog#GtkPrintUnixDialog-struct)
```
Implemented Interfaces
----------------------
GtkDialog implements [GtkAccessible](gtkaccessible#GtkAccessible-struct), [GtkBuildable](gtkbuildable#GtkBuildable-struct), [GtkConstraintTarget](gtkconstraint#GtkConstraintTarget-struct), [GtkNative](gtknative#GtkNative-struct), [GtkShortcutManager](gtkshortcutmanager#GtkShortcutManager-struct) and [GtkRoot](gtkroot#GtkRoot-struct).
Includes
--------
```
#include <gtk/gtk.h>
```
Description
-----------
Dialogs are a convenient way to prompt the user for a small amount of input, e.g. to display a message, ask a question, or anything else that does not require extensive effort on the user’s part.
The main area of a GtkDialog is called the "content area", and is yours to populate with widgets such a [GtkLabel](gtklabel#GtkLabel-struct) or [GtkEntry](gtkentry#GtkEntry-struct), to present your information, questions, or tasks to the user. In addition, dialogs allow you to add "action widgets". Most commonly, action widgets are buttons. Depending on the platform, action widgets may be presented in the header bar at the top of the window, or at the bottom of the window. To add action widgets, use GtkDialog using [`gtk_dialog_new_with_buttons()`](gtkdialog#gtk-dialog-new-with-buttons), [`gtk_dialog_add_button()`](gtkdialog#gtk-dialog-add-button), [`gtk_dialog_add_buttons()`](gtkdialog#gtk-dialog-add-buttons), or [`gtk_dialog_add_action_widget()`](gtkdialog#gtk-dialog-add-action-widget).
Clicking a button that was added as an action widget will emit the [“response”](gtkdialog#GtkDialog-response) signal with a response ID that you specified. GTK will never assign a meaning to positive response IDs; these are entirely user-defined. But for convenience, you can use the response IDs in the [GtkResponseType](gtkdialog#GtkResponseType) enumeration (these all have values less than zero). If a dialog receives a delete event, the [“response”](gtkdialog#GtkDialog-response) signal will be emitted with the [GTK\_RESPONSE\_DELETE\_EVENT](gtkdialog#GTK-RESPONSE-DELETE-EVENT:CAPS) response ID.
Dialogs are created with a call to [`gtk_dialog_new()`](gtkdialog#gtk-dialog-new) or [`gtk_dialog_new_with_buttons()`](gtkdialog#gtk-dialog-new-with-buttons). [`gtk_dialog_new_with_buttons()`](gtkdialog#gtk-dialog-new-with-buttons) is recommended; it allows you to set the dialog title, some convenient flags, and add simple buttons.
A “modal” dialog (that is, one which freezes the rest of the application from user input), can be created by calling [`gtk_window_set_modal()`](gtkwindow#gtk-window-set-modal) on the dialog. Use the `GTK_WINDOW()` macro to cast the widget returned from [`gtk_dialog_new()`](gtkdialog#gtk-dialog-new) into a [GtkWindow](gtkwindow#GtkWindow-struct). When using [`gtk_dialog_new_with_buttons()`](gtkdialog#gtk-dialog-new-with-buttons) you can also pass the [GTK\_DIALOG\_MODAL](gtkdialog#GTK-DIALOG-MODAL:CAPS) flag to make a dialog modal.
For the simple dialog in the following example, a [GtkMessageDialog](gtkmessagedialog#GtkMessageDialog-struct) would save some effort. But you’d need to create the dialog contents manually if you had more than a simple message in the dialog.
An example for simple GtkDialog usage:
### GtkDialog as GtkBuildable
The GtkDialog implementation of the [GtkBuildable](gtkbuildable#GtkBuildable-struct) interface exposes the *`content_area`* as an internal child with the name “content\_area”.
GtkDialog supports a custom <action-widgets> element, which can contain multiple <action-widget> elements. The “response” attribute specifies a numeric response, and the content of the element is the id of widget (which should be a child of the dialogs *`action_area`* ). To mark a response as default, set the “default“ attribute of the <action-widget> element to true.
GtkDialog supports adding action widgets by specifying “action“ as the “type“ attribute of a <child> element. The widget will be added either to the action area or the headerbar of the dialog, depending on the “use-header-bar“ property. The response id has to be associated with the action widget using the <action-widgets> element.
An example of a [GtkDialog](gtkdialog#GtkDialog-struct) UI definition fragment:
### Accessibility
GtkDialog uses the [GTK\_ACCESSIBLE\_ROLE\_DIALOG](gtkaccessible#GTK-ACCESSIBLE-ROLE-DIALOG:CAPS) role.
Functions
---------
### gtk\_dialog\_new ()
```
[GtkWidget](gtkwidget#GtkWidget-struct) *
gtk_dialog_new (*`void`*);
```
Creates a new dialog box.
Widgets should not be packed into this [GtkWindow](gtkwindow#GtkWindow-struct) directly, but into the *`content_area`* and *`action_area`* , as described above.
#### Returns
the new dialog as a [GtkWidget](gtkwidget#GtkWidget-struct)
### gtk\_dialog\_new\_with\_buttons ()
```
[GtkWidget](gtkwidget#GtkWidget-struct) *
gtk_dialog_new_with_buttons (*`const char *title`*,
*`[GtkWindow](gtkwindow#GtkWindow-struct) *parent`*,
*`[GtkDialogFlags](gtkdialog#GtkDialogFlags) flags`*,
*`const char *first_button_text`*,
*`...`*);
```
Creates a new [GtkDialog](gtkdialog#GtkDialog-struct) with title *`title`* (or `NULL` for the default title; see [`gtk_window_set_title()`](gtkwindow#gtk-window-set-title)) and transient parent *`parent`* (or `NULL` for none; see [`gtk_window_set_transient_for()`](gtkwindow#gtk-window-set-transient-for)). The *`flags`* argument can be used to make the dialog modal ([GTK\_DIALOG\_MODAL](gtkdialog#GTK-DIALOG-MODAL:CAPS)) and/or to have it destroyed along with its transient parent ([GTK\_DIALOG\_DESTROY\_WITH\_PARENT](gtkdialog#GTK-DIALOG-DESTROY-WITH-PARENT:CAPS)). After *`flags`* , button text/response ID pairs should be listed, with a `NULL` pointer ending the list. Button text can be arbitrary text. A response ID can be any positive number, or one of the values in the [GtkResponseType](gtkdialog#GtkResponseType) enumeration. If the user clicks one of these dialog buttons, [GtkDialog](gtkdialog#GtkDialog-struct) will emit the [“response”](gtkdialog#GtkDialog-response) signal with the corresponding response ID. If a [GtkDialog](gtkdialog#GtkDialog-struct) receives a delete event, it will emit ::response with a response ID of [GTK\_RESPONSE\_DELETE\_EVENT](gtkdialog#GTK-RESPONSE-DELETE-EVENT:CAPS). However, destroying a dialog does not emit the ::response signal; so be careful relying on ::response when using the [GTK\_DIALOG\_DESTROY\_WITH\_PARENT](gtkdialog#GTK-DIALOG-DESTROY-WITH-PARENT:CAPS) flag. Buttons are from left to right, so the first button in the list will be the leftmost button in the dialog.
Here’s a simple example:
```
// Function to open a dialog box with a message
void
quick_message (GtkWindow *parent, char *message)
{
GtkWidget *dialog, *label, *content_area;
GtkDialogFlags flags;
// Create the widgets
flags = GTK_DIALOG_DESTROY_WITH_PARENT;
dialog = gtk_dialog_new_with_buttons ("Message",
parent,
flags,
_("_OK"),
GTK_RESPONSE_NONE,
NULL);
content_area = gtk_dialog_get_content_area (GTK_DIALOG (dialog));
label = gtk_label_new (message);
// Ensure that the dialog box is destroyed when the user responds
g_signal_connect_swapped (dialog,
"response",
G_CALLBACK (gtk_window_destroy),
dialog);
// Add the label, and show everything we’ve added
gtk_box_append (GTK_BOX (content_area), label);
gtk_widget_show (dialog);
}
```
| #### Parameters
| | | |
| --- | --- | --- |
| title | Title of the dialog, or `NULL`. | [allow-none] |
| parent | Transient parent of the dialog, or `NULL`. | [allow-none] |
| flags | from [GtkDialogFlags](gtkdialog#GtkDialogFlags) | |
| first\_button\_text | text to go in first button, or `NULL`. | [allow-none] |
| ... | response ID for first button, then additional buttons, ending with `NULL` | |
#### Returns
a new [GtkDialog](gtkdialog#GtkDialog-struct)
### gtk\_dialog\_response ()
```
void
gtk_dialog_response (*`[GtkDialog](gtkdialog#GtkDialog-struct) *dialog`*,
*`int response_id`*);
```
Emits the [“response”](gtkdialog#GtkDialog-response) signal with the given response ID.
Used to indicate that the user has responded to the dialog in some way.
#### Parameters
| | | |
| --- | --- | --- |
| dialog | a [GtkDialog](gtkdialog#GtkDialog-struct) | |
| response\_id | response ID | |
### gtk\_dialog\_add\_button ()
```
[GtkWidget](gtkwidget#GtkWidget-struct) *
gtk_dialog_add_button (*`[GtkDialog](gtkdialog#GtkDialog-struct) *dialog`*,
*`const char *button_text`*,
*`int response_id`*);
```
Adds a button with the given text and sets things up so that clicking the button will emit the [“response”](gtkdialog#GtkDialog-response) signal with the given *`response_id`* . The button is appended to the end of the dialog’s action area. The button widget is returned, but usually you don’t need it.
#### Parameters
| | | |
| --- | --- | --- |
| dialog | a [GtkDialog](gtkdialog#GtkDialog-struct) | |
| button\_text | text of button | |
| response\_id | response ID for the button | |
#### Returns
the [GtkButton](gtkbutton#GtkButton-struct) widget that was added.
[transfer none]
### gtk\_dialog\_add\_buttons ()
```
void
gtk_dialog_add_buttons (*`[GtkDialog](gtkdialog#GtkDialog-struct) *dialog`*,
*`const char *first_button_text`*,
*`...`*);
```
Adds more buttons, same as calling [`gtk_dialog_add_button()`](gtkdialog#gtk-dialog-add-button) repeatedly. The variable argument list should be `NULL`-terminated as with [`gtk_dialog_new_with_buttons()`](gtkdialog#gtk-dialog-new-with-buttons). Each button must have both text and response ID.
#### Parameters
| | | |
| --- | --- | --- |
| dialog | a [GtkDialog](gtkdialog#GtkDialog-struct) | |
| first\_button\_text | button text | |
| ... | response ID for first button, then more text-response\_id pairs | |
### gtk\_dialog\_add\_action\_widget ()
```
void
gtk_dialog_add_action_widget (*`[GtkDialog](gtkdialog#GtkDialog-struct) *dialog`*,
*`[GtkWidget](gtkwidget#GtkWidget-struct) *child`*,
*`int response_id`*);
```
Adds an activatable widget to the action area of a [GtkDialog](gtkdialog#GtkDialog-struct), connecting a signal handler that will emit the [“response”](gtkdialog#GtkDialog-response) signal on the dialog when the widget is activated. The widget is appended to the end of the dialog’s action area. If you want to add a non-activatable widget, simply pack it into the *`action_area`* field of the [GtkDialog](gtkdialog#GtkDialog-struct) struct.
#### Parameters
| | | |
| --- | --- | --- |
| dialog | a [GtkDialog](gtkdialog#GtkDialog-struct) | |
| child | an activatable widget | |
| response\_id | response ID for *`child`* | |
### gtk\_dialog\_set\_default\_response ()
```
void
gtk_dialog_set_default_response (*`[GtkDialog](gtkdialog#GtkDialog-struct) *dialog`*,
*`int response_id`*);
```
Sets the last widget in the dialog’s action area with the given *`response_id`* as the default widget for the dialog. Pressing “Enter” normally activates the default widget.
#### Parameters
| | | |
| --- | --- | --- |
| dialog | a [GtkDialog](gtkdialog#GtkDialog-struct) | |
| response\_id | a response ID | |
### gtk\_dialog\_set\_response\_sensitive ()
```
void
gtk_dialog_set_response_sensitive (*`[GtkDialog](gtkdialog#GtkDialog-struct) *dialog`*,
*`int response_id`*,
*`gboolean setting`*);
```
Calls `gtk_widget_set_sensitive (widget, @setting)` for each widget in the dialog’s action area with the given *`response_id`* . A convenient way to sensitize/desensitize dialog buttons.
#### Parameters
| | | |
| --- | --- | --- |
| dialog | a [GtkDialog](gtkdialog#GtkDialog-struct) | |
| response\_id | a response ID | |
| setting | `TRUE` for sensitive | |
### gtk\_dialog\_get\_response\_for\_widget ()
```
int
gtk_dialog_get_response_for_widget (*`[GtkDialog](gtkdialog#GtkDialog-struct) *dialog`*,
*`[GtkWidget](gtkwidget#GtkWidget-struct) *widget`*);
```
Gets the response id of a widget in the action area of a dialog.
#### Parameters
| | | |
| --- | --- | --- |
| dialog | a [GtkDialog](gtkdialog#GtkDialog-struct) | |
| widget | a widget in the action area of *`dialog`* | |
#### Returns
the response id of *`widget`* , or [`GTK_RESPONSE_NONE`](gtkdialog#GTK-RESPONSE-NONE:CAPS) if *`widget`* doesn’t have a response id set.
### gtk\_dialog\_get\_widget\_for\_response ()
```
[GtkWidget](gtkwidget#GtkWidget-struct) *
gtk_dialog_get_widget_for_response (*`[GtkDialog](gtkdialog#GtkDialog-struct) *dialog`*,
*`int response_id`*);
```
Gets the widget button that uses the given response ID in the action area of a dialog.
#### Parameters
| | | |
| --- | --- | --- |
| dialog | a [GtkDialog](gtkdialog#GtkDialog-struct) | |
| response\_id | the response ID used by the *`dialog`* widget | |
#### Returns
the *`widget`* button that uses the given *`response_id`* , or `NULL`.
[nullable][transfer none]
### gtk\_dialog\_get\_content\_area ()
```
[GtkWidget](gtkwidget#GtkWidget-struct) *
gtk_dialog_get_content_area (*`[GtkDialog](gtkdialog#GtkDialog-struct) *dialog`*);
```
Returns the content area of *`dialog`* .
#### Parameters
| | | |
| --- | --- | --- |
| dialog | a [GtkDialog](gtkdialog#GtkDialog-struct) | |
#### Returns
the content area [GtkBox](gtkbox#GtkBox-struct).
[type Gtk.Box][transfer none]
### gtk\_dialog\_get\_header\_bar ()
```
[GtkWidget](gtkwidget#GtkWidget-struct) *
gtk_dialog_get_header_bar (*`[GtkDialog](gtkdialog#GtkDialog-struct) *dialog`*);
```
Returns the header bar of *`dialog`* . Note that the headerbar is only used by the dialog if the [“use-header-bar”](gtkdialog#GtkDialog--use-header-bar) property is `TRUE`.
#### Parameters
| | | |
| --- | --- | --- |
| dialog | a [GtkDialog](gtkdialog#GtkDialog-struct) | |
#### Returns
the header bar.
[type Gtk.HeaderBar][transfer none]
Types and Values
----------------
### struct GtkDialog
```
struct GtkDialog;
```
The [GtkDialog](gtkdialog#GtkDialog-struct) contains only private fields and should not be directly accessed.
### struct GtkDialogClass
```
struct GtkDialogClass {
GtkWindowClass parent_class;
void (* response) (GtkDialog *dialog, int response_id);
/* Keybinding signals */
void (* close) (GtkDialog *dialog);
};
```
#### Members
| | | |
| --- | --- | --- |
| *`response`* () | Signal emitted when an action widget is activated. | |
| *`close`* () | Signal emitted when the user uses a keybinding to close the dialog. | |
### enum GtkDialogFlags
Flags used to influence dialog construction.
#### Members
| | | |
| --- | --- | --- |
| GTK\_DIALOG\_MODAL | Make the constructed dialog modal, see [`gtk_window_set_modal()`](gtkwindow#gtk-window-set-modal) | |
| GTK\_DIALOG\_DESTROY\_WITH\_PARENT | Destroy the dialog when its parent is destroyed, see [`gtk_window_set_destroy_with_parent()`](gtkwindow#gtk-window-set-destroy-with-parent) | |
| GTK\_DIALOG\_USE\_HEADER\_BAR | Create dialog with actions in header bar instead of action area | |
### enum GtkResponseType
Predefined values for use as response ids in [`gtk_dialog_add_button()`](gtkdialog#gtk-dialog-add-button). All predefined values are negative; GTK leaves values of 0 or greater for application-defined response ids.
#### Members
| | | |
| --- | --- | --- |
| GTK\_RESPONSE\_NONE | Returned if an action widget has no response id, or if the dialog gets programmatically hidden or destroyed | |
| GTK\_RESPONSE\_REJECT | Generic response id, not used by GTK dialogs | |
| GTK\_RESPONSE\_ACCEPT | Generic response id, not used by GTK dialogs | |
| GTK\_RESPONSE\_DELETE\_EVENT | Returned if the dialog is deleted | |
| GTK\_RESPONSE\_OK | Returned by OK buttons in GTK dialogs | |
| GTK\_RESPONSE\_CANCEL | Returned by Cancel buttons in GTK dialogs | |
| GTK\_RESPONSE\_CLOSE | Returned by Close buttons in GTK dialogs | |
| GTK\_RESPONSE\_YES | Returned by Yes buttons in GTK dialogs | |
| GTK\_RESPONSE\_NO | Returned by No buttons in GTK dialogs | |
| GTK\_RESPONSE\_APPLY | Returned by Apply buttons in GTK dialogs | |
| GTK\_RESPONSE\_HELP | Returned by Help buttons in GTK dialogs | |
Property Details
----------------
### The `“use-header-bar”` property
```
“use-header-bar” int
```
`TRUE` if the dialog uses a [GtkHeaderBar](gtkheaderbar#GtkHeaderBar-struct) for action buttons instead of the action-area.
For technical reasons, this property is declared as an integer property, but you should only set it to `TRUE` or `FALSE`.
Owner: GtkDialog
Flags: Read / Write / Construct Only
Allowed values: [-1,1]
Default value: -1
Signal Details
--------------
### The `“close”` signal
```
void
user_function ([GtkDialog](gtkdialog#GtkDialog-struct) *dialog,
gpointer user_data)
```
The ::close signal is a [keybinding signal](gtkshortcutaction#GtkSignalAction-struct) which gets emitted when the user uses a keybinding to close the dialog.
The default binding for this signal is the Escape key.
#### Parameters
| | | |
| --- | --- | --- |
| user\_data | user data set when the signal handler was connected. | |
Flags: Action
### The `“response”` signal
```
void
user_function ([GtkDialog](gtkdialog#GtkDialog-struct) *dialog,
int response_id,
gpointer user_data)
```
Emitted when an action widget is clicked, the dialog receives a delete event, or the application programmer calls [`gtk_dialog_response()`](gtkdialog#gtk-dialog-response). On a delete event, the response ID is [GTK\_RESPONSE\_DELETE\_EVENT](gtkdialog#GTK-RESPONSE-DELETE-EVENT:CAPS). Otherwise, it depends on which action widget was clicked.
#### Parameters
| | | |
| --- | --- | --- |
| dialog | the object on which the signal is emitted | |
| response\_id | the response ID | |
| user\_data | user data set when the signal handler was connected. | |
Flags: Run Last
See Also
--------
[GtkWindow](gtkwindow#GtkWindow-struct), [GtkMessageDialog](gtkmessagedialog#GtkMessageDialog-struct)
| programming_docs |
gtk GtkListBox GtkListBox
==========
GtkListBox — A list container
Functions
---------
| | |
| --- | --- |
| gboolean | ([\*GtkListBoxFilterFunc](gtklistbox#GtkListBoxFilterFunc)) () |
| int | ([\*GtkListBoxSortFunc](gtklistbox#GtkListBoxSortFunc)) () |
| void | ([\*GtkListBoxUpdateHeaderFunc](gtklistbox#GtkListBoxUpdateHeaderFunc)) () |
| [GtkWidget](gtkwidget#GtkWidget-struct) \* | [gtk\_list\_box\_new](gtklistbox#gtk-list-box-new) () |
| void | [gtk\_list\_box\_prepend](gtklistbox#gtk-list-box-prepend) () |
| void | [gtk\_list\_box\_append](gtklistbox#gtk-list-box-append) () |
| void | [gtk\_list\_box\_insert](gtklistbox#gtk-list-box-insert) () |
| void | [gtk\_list\_box\_remove](gtklistbox#gtk-list-box-remove) () |
| void | [gtk\_list\_box\_select\_row](gtklistbox#gtk-list-box-select-row) () |
| void | [gtk\_list\_box\_unselect\_row](gtklistbox#gtk-list-box-unselect-row) () |
| void | [gtk\_list\_box\_select\_all](gtklistbox#gtk-list-box-select-all) () |
| void | [gtk\_list\_box\_unselect\_all](gtklistbox#gtk-list-box-unselect-all) () |
| [GtkListBoxRow](gtklistbox#GtkListBoxRow-struct) \* | [gtk\_list\_box\_get\_selected\_row](gtklistbox#gtk-list-box-get-selected-row) () |
| void | ([\*GtkListBoxForeachFunc](gtklistbox#GtkListBoxForeachFunc)) () |
| void | [gtk\_list\_box\_selected\_foreach](gtklistbox#gtk-list-box-selected-foreach) () |
| GList \* | [gtk\_list\_box\_get\_selected\_rows](gtklistbox#gtk-list-box-get-selected-rows) () |
| void | [gtk\_list\_box\_set\_show\_separators](gtklistbox#gtk-list-box-set-show-separators) () |
| gboolean | [gtk\_list\_box\_get\_show\_separators](gtklistbox#gtk-list-box-get-show-separators) () |
| void | [gtk\_list\_box\_set\_selection\_mode](gtklistbox#gtk-list-box-set-selection-mode) () |
| [GtkSelectionMode](gtk4-standard-enumerations#GtkSelectionMode) | [gtk\_list\_box\_get\_selection\_mode](gtklistbox#gtk-list-box-get-selection-mode) () |
| void | [gtk\_list\_box\_set\_activate\_on\_single\_click](gtklistbox#gtk-list-box-set-activate-on-single-click) () |
| gboolean | [gtk\_list\_box\_get\_activate\_on\_single\_click](gtklistbox#gtk-list-box-get-activate-on-single-click) () |
| [GtkAdjustment](gtkadjustment#GtkAdjustment-struct) \* | [gtk\_list\_box\_get\_adjustment](gtklistbox#gtk-list-box-get-adjustment) () |
| void | [gtk\_list\_box\_set\_adjustment](gtklistbox#gtk-list-box-set-adjustment) () |
| void | [gtk\_list\_box\_set\_placeholder](gtklistbox#gtk-list-box-set-placeholder) () |
| [GtkListBoxRow](gtklistbox#GtkListBoxRow-struct) \* | [gtk\_list\_box\_get\_row\_at\_index](gtklistbox#gtk-list-box-get-row-at-index) () |
| [GtkListBoxRow](gtklistbox#GtkListBoxRow-struct) \* | [gtk\_list\_box\_get\_row\_at\_y](gtklistbox#gtk-list-box-get-row-at-y) () |
| void | [gtk\_list\_box\_invalidate\_filter](gtklistbox#gtk-list-box-invalidate-filter) () |
| void | [gtk\_list\_box\_invalidate\_headers](gtklistbox#gtk-list-box-invalidate-headers) () |
| void | [gtk\_list\_box\_invalidate\_sort](gtklistbox#gtk-list-box-invalidate-sort) () |
| void | [gtk\_list\_box\_set\_filter\_func](gtklistbox#gtk-list-box-set-filter-func) () |
| void | [gtk\_list\_box\_set\_header\_func](gtklistbox#gtk-list-box-set-header-func) () |
| void | [gtk\_list\_box\_set\_sort\_func](gtklistbox#gtk-list-box-set-sort-func) () |
| void | [gtk\_list\_box\_drag\_highlight\_row](gtklistbox#gtk-list-box-drag-highlight-row) () |
| void | [gtk\_list\_box\_drag\_unhighlight\_row](gtklistbox#gtk-list-box-drag-unhighlight-row) () |
| [GtkWidget](gtkwidget#GtkWidget-struct) \* | ([\*GtkListBoxCreateWidgetFunc](gtklistbox#GtkListBoxCreateWidgetFunc)) () |
| void | [gtk\_list\_box\_bind\_model](gtklistbox#gtk-list-box-bind-model) () |
| [GtkWidget](gtkwidget#GtkWidget-struct) \* | [gtk\_list\_box\_row\_new](gtklistbox#gtk-list-box-row-new) () |
| void | [gtk\_list\_box\_row\_changed](gtklistbox#gtk-list-box-row-changed) () |
| gboolean | [gtk\_list\_box\_row\_is\_selected](gtklistbox#gtk-list-box-row-is-selected) () |
| [GtkWidget](gtkwidget#GtkWidget-struct) \* | [gtk\_list\_box\_row\_get\_child](gtklistbox#gtk-list-box-row-get-child) () |
| void | [gtk\_list\_box\_row\_set\_child](gtklistbox#gtk-list-box-row-set-child) () |
| [GtkWidget](gtkwidget#GtkWidget-struct) \* | [gtk\_list\_box\_row\_get\_header](gtklistbox#gtk-list-box-row-get-header) () |
| void | [gtk\_list\_box\_row\_set\_header](gtklistbox#gtk-list-box-row-set-header) () |
| int | [gtk\_list\_box\_row\_get\_index](gtklistbox#gtk-list-box-row-get-index) () |
| void | [gtk\_list\_box\_row\_set\_activatable](gtklistbox#gtk-list-box-row-set-activatable) () |
| gboolean | [gtk\_list\_box\_row\_get\_activatable](gtklistbox#gtk-list-box-row-get-activatable) () |
| void | [gtk\_list\_box\_row\_set\_selectable](gtklistbox#gtk-list-box-row-set-selectable) () |
| gboolean | [gtk\_list\_box\_row\_get\_selectable](gtklistbox#gtk-list-box-row-get-selectable) () |
Properties
----------
| | | |
| --- | --- | --- |
| gboolean | [accept-unpaired-release](gtklistbox#GtkListBox--accept-unpaired-release) | Read / Write |
| gboolean | [activate-on-single-click](gtklistbox#GtkListBox--activate-on-single-click) | Read / Write |
| [GtkSelectionMode](gtk4-standard-enumerations#GtkSelectionMode) | [selection-mode](gtklistbox#GtkListBox--selection-mode) | Read / Write |
| gboolean | [show-separators](gtklistbox#GtkListBox--show-separators) | Read / Write |
| gboolean | [activatable](gtklistbox#GtkListBoxRow--activatable) | Read / Write |
| [GtkWidget](gtkwidget#GtkWidget-struct) \* | [child](gtklistbox#GtkListBoxRow--child) | Read / Write |
| gboolean | [selectable](gtklistbox#GtkListBoxRow--selectable) | Read / Write |
Signals
-------
| | | |
| --- | --- | --- |
| void | [activate-cursor-row](gtklistbox#GtkListBox-activate-cursor-row) | Action |
| void | [move-cursor](gtklistbox#GtkListBox-move-cursor) | Action |
| void | [row-activated](gtklistbox#GtkListBox-row-activated) | Run Last |
| void | [row-selected](gtklistbox#GtkListBox-row-selected) | Run Last |
| void | [select-all](gtklistbox#GtkListBox-select-all) | Action |
| void | [selected-rows-changed](gtklistbox#GtkListBox-selected-rows-changed) | Run First |
| void | [toggle-cursor-row](gtklistbox#GtkListBox-toggle-cursor-row) | Action |
| void | [unselect-all](gtklistbox#GtkListBox-unselect-all) | Action |
| void | [activate](gtklistbox#GtkListBoxRow-activate) | Action |
Types and Values
----------------
| | |
| --- | --- |
| | [GtkListBox](gtklistbox#GtkListBox-struct) |
| struct | [GtkListBoxRow](gtklistbox#GtkListBoxRow-struct) |
| struct | [GtkListBoxRowClass](gtklistbox#GtkListBoxRowClass) |
Object Hierarchy
----------------
```
GObject
╰── GInitiallyUnowned
╰── [GtkWidget](gtkwidget#GtkWidget-struct)
├── GtkListBox
╰── GtkListBoxRow
```
Implemented Interfaces
----------------------
GtkListBox implements [GtkAccessible](gtkaccessible#GtkAccessible-struct), [GtkBuildable](gtkbuildable#GtkBuildable-struct) and [GtkConstraintTarget](gtkconstraint#GtkConstraintTarget-struct).
GtkListBoxRow implements [GtkAccessible](gtkaccessible#GtkAccessible-struct), [GtkBuildable](gtkbuildable#GtkBuildable-struct), [GtkConstraintTarget](gtkconstraint#GtkConstraintTarget-struct) and [GtkActionable](gtkactionable#GtkActionable-struct).
Includes
--------
```
#include <gtk/gtk.h>
```
Description
-----------
A GtkListBox is a vertical container that contains GtkListBoxRow children. These rows can by dynamically sorted and filtered, and headers can be added dynamically depending on the row content. It also allows keyboard and mouse navigation and selection like a typical list.
Using GtkListBox is often an alternative to [GtkTreeView](gtktreeview#GtkTreeView-struct), especially when the list contents has a more complicated layout than what is allowed by a [GtkCellRenderer](gtkcellrenderer#GtkCellRenderer-struct), or when the contents is interactive (i.e. has a button in it).
Although a [GtkListBox](gtklistbox#GtkListBox-struct) must have only [GtkListBoxRow](gtklistbox#GtkListBoxRow-struct) children you can add any kind of widget to it via [`gtk_list_box_prepend()`](gtklistbox#gtk-list-box-prepend), [`gtk_list_box_append()`](gtklistbox#gtk-list-box-append) and [`gtk_list_box_insert()`](gtklistbox#gtk-list-box-insert) and a [GtkListBoxRow](gtklistbox#GtkListBoxRow-struct) widget will automatically be inserted between the list and the widget.
[GtkListBoxRows](gtklistbox#GtkListBoxRow-struct) can be marked as activatable or selectable. If a row is activatable, [“row-activated”](gtklistbox#GtkListBox-row-activated) will be emitted for it when the user tries to activate it. If it is selectable, the row will be marked as selected when the user tries to select it.
### GtkListBox as GtkBuildable
The GtkListBox implementation of the [GtkBuildable](gtkbuildable#GtkBuildable-struct) interface supports setting a child as the placeholder by specifying “placeholder” as the “type” attribute of a <child> element. See [`gtk_list_box_set_placeholder()`](gtklistbox#gtk-list-box-set-placeholder) for info.
### CSS nodes
```
list[.separators][.rich-list][.navigation-sidebar]
╰── row[.activatable]
```
| GtkListBox uses a single CSS node named list. It may carry the .separators style class, when the [“show-separators”](gtklistbox#GtkListBox--show-separators) property is set. Each GtkListBoxRow uses a single CSS node named row. The row nodes get the .activatable style class added when appropriate.
The main list node may also carry style classes to select the style of [list presentation](listcontainers#list-styles): .rich-list, .navigation-sidebar or .data-table.
### Accessibility
GtkListBox uses the [GTK\_ACCESSIBLE\_ROLE\_LIST](gtkaccessible#GTK-ACCESSIBLE-ROLE-LIST:CAPS) role and GtkListBoxRow uses the [GTK\_ACCESSIBLE\_ROLE\_LIST\_ITEM](gtkaccessible#GTK-ACCESSIBLE-ROLE-LIST-ITEM:CAPS) role.
Functions
---------
### GtkListBoxFilterFunc ()
```
gboolean
(*GtkListBoxFilterFunc) (*`[GtkListBoxRow](gtklistbox#GtkListBoxRow-struct) *row`*,
*`gpointer user_data`*);
```
Will be called whenever the row changes or is added and lets you control if the row should be visible or not.
#### Parameters
| | | |
| --- | --- | --- |
| row | the row that may be filtered | |
| user\_data | user data. | [closure] |
#### Returns
`TRUE` if the row should be visible, `FALSE` otherwise
### GtkListBoxSortFunc ()
```
int
(*GtkListBoxSortFunc) (*`[GtkListBoxRow](gtklistbox#GtkListBoxRow-struct) *row1`*,
*`[GtkListBoxRow](gtklistbox#GtkListBoxRow-struct) *row2`*,
*`gpointer user_data`*);
```
Compare two rows to determine which should be first.
#### Parameters
| | | |
| --- | --- | --- |
| row1 | the first row | |
| row2 | the second row | |
| user\_data | user data. | [closure] |
#### Returns
< 0 if *`row1`* should be before *`row2`* , 0 if they are equal and > 0 otherwise
### GtkListBoxUpdateHeaderFunc ()
```
void
(*GtkListBoxUpdateHeaderFunc) (*`[GtkListBoxRow](gtklistbox#GtkListBoxRow-struct) *row`*,
*`[GtkListBoxRow](gtklistbox#GtkListBoxRow-struct) *before`*,
*`gpointer user_data`*);
```
Whenever *`row`* changes or which row is before *`row`* changes this is called, which lets you update the header on *`row`* . You may remove or set a new one via [`gtk_list_box_row_set_header()`](gtklistbox#gtk-list-box-row-set-header) or just change the state of the current header widget.
#### Parameters
| | | |
| --- | --- | --- |
| row | the row to update | |
| before | the row before *`row`* , or `NULL` if it is first. | [allow-none] |
| user\_data | user data. | [closure] |
### gtk\_list\_box\_new ()
```
[GtkWidget](gtkwidget#GtkWidget-struct) *
gtk_list_box_new (*`void`*);
```
Creates a new [GtkListBox](gtklistbox#GtkListBox-struct) container.
#### Returns
a new [GtkListBox](gtklistbox#GtkListBox-struct)
### gtk\_list\_box\_prepend ()
```
void
gtk_list_box_prepend (*`[GtkListBox](gtklistbox#GtkListBox-struct) *box`*,
*`[GtkWidget](gtkwidget#GtkWidget-struct) *child`*);
```
Prepend a widget to the list. If a sort function is set, the widget will actually be inserted at the calculated position.
#### Parameters
| | | |
| --- | --- | --- |
| box | a [GtkListBox](gtklistbox#GtkListBox-struct) | |
| child | the [GtkWidget](gtkwidget#GtkWidget-struct) to add | |
### gtk\_list\_box\_append ()
```
void
gtk_list_box_append (*`[GtkListBox](gtklistbox#GtkListBox-struct) *box`*,
*`[GtkWidget](gtkwidget#GtkWidget-struct) *child`*);
```
Append a widget to the list. If a sort function is set, the widget will actually be inserted at the calculated position.
#### Parameters
| | | |
| --- | --- | --- |
| box | a [GtkListBox](gtklistbox#GtkListBox-struct) | |
| child | the [GtkWidget](gtkwidget#GtkWidget-struct) to add | |
### gtk\_list\_box\_insert ()
```
void
gtk_list_box_insert (*`[GtkListBox](gtklistbox#GtkListBox-struct) *box`*,
*`[GtkWidget](gtkwidget#GtkWidget-struct) *child`*,
*`int position`*);
```
Insert the *`child`* into the *`box`* at *`position`* . If a sort function is set, the widget will actually be inserted at the calculated position.
If *`position`* is -1, or larger than the total number of items in the *`box`* , then the *`child`* will be appended to the end.
#### Parameters
| | | |
| --- | --- | --- |
| box | a [GtkListBox](gtklistbox#GtkListBox-struct) | |
| child | the [GtkWidget](gtkwidget#GtkWidget-struct) to add | |
| position | the position to insert *`child`* in | |
### gtk\_list\_box\_remove ()
```
void
gtk_list_box_remove (*`[GtkListBox](gtklistbox#GtkListBox-struct) *box`*,
*`[GtkWidget](gtkwidget#GtkWidget-struct) *child`*);
```
Removes a child from *`box`* .
#### Parameters
| | | |
| --- | --- | --- |
| box | a [GtkListBox](gtklistbox#GtkListBox-struct) | |
| child | the child to remove | |
### gtk\_list\_box\_select\_row ()
```
void
gtk_list_box_select_row (*`[GtkListBox](gtklistbox#GtkListBox-struct) *box`*,
*`[GtkListBoxRow](gtklistbox#GtkListBoxRow-struct) *row`*);
```
Make *`row`* the currently selected row.
#### Parameters
| | | |
| --- | --- | --- |
| box | a [GtkListBox](gtklistbox#GtkListBox-struct) | |
| row | The row to select or `NULL`. | [allow-none] |
### gtk\_list\_box\_unselect\_row ()
```
void
gtk_list_box_unselect_row (*`[GtkListBox](gtklistbox#GtkListBox-struct) *box`*,
*`[GtkListBoxRow](gtklistbox#GtkListBoxRow-struct) *row`*);
```
Unselects a single row of *`box`* , if the selection mode allows it.
#### Parameters
| | | |
| --- | --- | --- |
| box | a [GtkListBox](gtklistbox#GtkListBox-struct) | |
| row | the row to unselected | |
### gtk\_list\_box\_select\_all ()
```
void
gtk_list_box_select_all (*`[GtkListBox](gtklistbox#GtkListBox-struct) *box`*);
```
Select all children of *`box`* , if the selection mode allows it.
#### Parameters
| | | |
| --- | --- | --- |
| box | a [GtkListBox](gtklistbox#GtkListBox-struct) | |
### gtk\_list\_box\_unselect\_all ()
```
void
gtk_list_box_unselect_all (*`[GtkListBox](gtklistbox#GtkListBox-struct) *box`*);
```
Unselect all children of *`box`* , if the selection mode allows it.
#### Parameters
| | | |
| --- | --- | --- |
| box | a [GtkListBox](gtklistbox#GtkListBox-struct) | |
### gtk\_list\_box\_get\_selected\_row ()
```
[GtkListBoxRow](gtklistbox#GtkListBoxRow-struct) *
gtk_list_box_get_selected_row (*`[GtkListBox](gtklistbox#GtkListBox-struct) *box`*);
```
Gets the selected row.
Note that the box may allow multiple selection, in which case you should use [`gtk_list_box_selected_foreach()`](gtklistbox#gtk-list-box-selected-foreach) to find all selected rows.
#### Parameters
| | | |
| --- | --- | --- |
| box | a [GtkListBox](gtklistbox#GtkListBox-struct) | |
#### Returns
the selected row.
[transfer none]
### GtkListBoxForeachFunc ()
```
void
(*GtkListBoxForeachFunc) (*`[GtkListBox](gtklistbox#GtkListBox-struct) *box`*,
*`[GtkListBoxRow](gtklistbox#GtkListBoxRow-struct) *row`*,
*`gpointer user_data`*);
```
A function used by [`gtk_list_box_selected_foreach()`](gtklistbox#gtk-list-box-selected-foreach). It will be called on every selected child of the *`box`* .
#### Parameters
| | | |
| --- | --- | --- |
| box | a [GtkListBox](gtklistbox#GtkListBox-struct) | |
| row | a [GtkListBoxRow](gtklistbox#GtkListBoxRow-struct) | |
| user\_data | user data. | [closure] |
### gtk\_list\_box\_selected\_foreach ()
```
void
gtk_list_box_selected_foreach (*`[GtkListBox](gtklistbox#GtkListBox-struct) *box`*,
*`[GtkListBoxForeachFunc](gtklistbox#GtkListBoxForeachFunc) func`*,
*`gpointer data`*);
```
Calls a function for each selected child.
Note that the selection cannot be modified from within this function.
#### Parameters
| | | |
| --- | --- | --- |
| box | a [GtkListBox](gtklistbox#GtkListBox-struct) | |
| func | the function to call for each selected child. | [scope call] |
| data | user data to pass to the function | |
### gtk\_list\_box\_get\_selected\_rows ()
```
GList *
gtk_list_box_get_selected_rows (*`[GtkListBox](gtklistbox#GtkListBox-struct) *box`*);
```
Creates a list of all selected children.
#### Parameters
| | | |
| --- | --- | --- |
| box | a [GtkListBox](gtklistbox#GtkListBox-struct) | |
#### Returns
A GList containing the [GtkWidget](gtkwidget#GtkWidget-struct) for each selected child. Free with `g_list_free()` when done.
[element-type GtkListBoxRow][transfer container]
### gtk\_list\_box\_set\_show\_separators ()
```
void
gtk_list_box_set_show_separators (*`[GtkListBox](gtklistbox#GtkListBox-struct) *box`*,
*`gboolean show_separators`*);
```
Sets whether the list box should show separators between rows.
#### Parameters
| | | |
| --- | --- | --- |
| box | a [GtkListBox](gtklistbox#GtkListBox-struct) | |
| show\_separators | `TRUE` to show separators | |
### gtk\_list\_box\_get\_show\_separators ()
```
gboolean
gtk_list_box_get_show_separators (*`[GtkListBox](gtklistbox#GtkListBox-struct) *box`*);
```
Returns whether the list box should show separators between rows.
#### Parameters
| | | |
| --- | --- | --- |
| box | a [GtkListBox](gtklistbox#GtkListBox-struct) | |
#### Returns
`TRUE` if the list box shows separators
### gtk\_list\_box\_set\_selection\_mode ()
```
void
gtk_list_box_set_selection_mode (*`[GtkListBox](gtklistbox#GtkListBox-struct) *box`*,
*`[GtkSelectionMode](gtk4-standard-enumerations#GtkSelectionMode) mode`*);
```
Sets how selection works in the listbox. See [GtkSelectionMode](gtk4-standard-enumerations#GtkSelectionMode) for details.
#### Parameters
| | | |
| --- | --- | --- |
| box | a [GtkListBox](gtklistbox#GtkListBox-struct) | |
| mode | The [GtkSelectionMode](gtk4-standard-enumerations#GtkSelectionMode) | |
### gtk\_list\_box\_get\_selection\_mode ()
```
[GtkSelectionMode](gtk4-standard-enumerations#GtkSelectionMode)
gtk_list_box_get_selection_mode (*`[GtkListBox](gtklistbox#GtkListBox-struct) *box`*);
```
Gets the selection mode of the listbox.
#### Parameters
| | | |
| --- | --- | --- |
| box | a [GtkListBox](gtklistbox#GtkListBox-struct) | |
#### Returns
a [GtkSelectionMode](gtk4-standard-enumerations#GtkSelectionMode)
### gtk\_list\_box\_set\_activate\_on\_single\_click ()
```
void
gtk_list_box_set_activate_on_single_click
(*`[GtkListBox](gtklistbox#GtkListBox-struct) *box`*,
*`gboolean single`*);
```
If *`single`* is `TRUE`, rows will be activated when you click on them, otherwise you need to double-click.
#### Parameters
| | | |
| --- | --- | --- |
| box | a [GtkListBox](gtklistbox#GtkListBox-struct) | |
| single | a boolean | |
### gtk\_list\_box\_get\_activate\_on\_single\_click ()
```
gboolean
gtk_list_box_get_activate_on_single_click
(*`[GtkListBox](gtklistbox#GtkListBox-struct) *box`*);
```
Returns whether rows activate on single clicks.
#### Parameters
| | | |
| --- | --- | --- |
| box | a [GtkListBox](gtklistbox#GtkListBox-struct) | |
#### Returns
`TRUE` if rows are activated on single click, `FALSE` otherwise
### gtk\_list\_box\_get\_adjustment ()
```
[GtkAdjustment](gtkadjustment#GtkAdjustment-struct) *
gtk_list_box_get_adjustment (*`[GtkListBox](gtklistbox#GtkListBox-struct) *box`*);
```
Gets the adjustment (if any) that the widget uses to for vertical scrolling.
#### Parameters
| | | |
| --- | --- | --- |
| box | a [GtkListBox](gtklistbox#GtkListBox-struct) | |
#### Returns
the adjustment.
[transfer none]
### gtk\_list\_box\_set\_adjustment ()
```
void
gtk_list_box_set_adjustment (*`[GtkListBox](gtklistbox#GtkListBox-struct) *box`*,
*`[GtkAdjustment](gtkadjustment#GtkAdjustment-struct) *adjustment`*);
```
Sets the adjustment (if any) that the widget uses to for vertical scrolling. For instance, this is used to get the page size for PageUp/Down key handling.
In the normal case when the *`box`* is packed inside a [GtkScrolledWindow](gtkscrolledwindow#GtkScrolledWindow-struct) the adjustment from that will be picked up automatically, so there is no need to manually do that.
#### Parameters
| | | |
| --- | --- | --- |
| box | a [GtkListBox](gtklistbox#GtkListBox-struct) | |
| adjustment | the adjustment, or `NULL`. | [allow-none] |
### gtk\_list\_box\_set\_placeholder ()
```
void
gtk_list_box_set_placeholder (*`[GtkListBox](gtklistbox#GtkListBox-struct) *box`*,
*`[GtkWidget](gtkwidget#GtkWidget-struct) *placeholder`*);
```
Sets the placeholder widget that is shown in the list when it doesn't display any visible children.
#### Parameters
| | | |
| --- | --- | --- |
| box | a [GtkListBox](gtklistbox#GtkListBox-struct) | |
| placeholder | a [GtkWidget](gtkwidget#GtkWidget-struct) or `NULL`. | [allow-none] |
### gtk\_list\_box\_get\_row\_at\_index ()
```
[GtkListBoxRow](gtklistbox#GtkListBoxRow-struct) *
gtk_list_box_get_row_at_index (*`[GtkListBox](gtklistbox#GtkListBox-struct) *box`*,
*`int index_`*);
```
Gets the n-th child in the list (not counting headers). If *`_index`* is negative or larger than the number of items in the list, `NULL` is returned.
#### Parameters
| | | |
| --- | --- | --- |
| box | a [GtkListBox](gtklistbox#GtkListBox-struct) | |
| index\_ | the index of the row | |
#### Returns
the child [GtkWidget](gtkwidget#GtkWidget-struct) or `NULL`.
[transfer none][nullable]
### gtk\_list\_box\_get\_row\_at\_y ()
```
[GtkListBoxRow](gtklistbox#GtkListBoxRow-struct) *
gtk_list_box_get_row_at_y (*`[GtkListBox](gtklistbox#GtkListBox-struct) *box`*,
*`int y`*);
```
Gets the row at the *`y`* position.
#### Parameters
| | | |
| --- | --- | --- |
| box | a [GtkListBox](gtklistbox#GtkListBox-struct) | |
| y | position | |
#### Returns
the row or `NULL` in case no row exists for the given y coordinate.
[transfer none][nullable]
### gtk\_list\_box\_invalidate\_filter ()
```
void
gtk_list_box_invalidate_filter (*`[GtkListBox](gtklistbox#GtkListBox-struct) *box`*);
```
Update the filtering for all rows. Call this when result of the filter function on the *`box`* is changed due to an external factor. For instance, this would be used if the filter function just looked for a specific search string and the entry with the search string has changed.
#### Parameters
| | | |
| --- | --- | --- |
| box | a [GtkListBox](gtklistbox#GtkListBox-struct) | |
### gtk\_list\_box\_invalidate\_headers ()
```
void
gtk_list_box_invalidate_headers (*`[GtkListBox](gtklistbox#GtkListBox-struct) *box`*);
```
Update the separators for all rows. Call this when result of the header function on the *`box`* is changed due to an external factor.
#### Parameters
| | | |
| --- | --- | --- |
| box | a [GtkListBox](gtklistbox#GtkListBox-struct) | |
### gtk\_list\_box\_invalidate\_sort ()
```
void
gtk_list_box_invalidate_sort (*`[GtkListBox](gtklistbox#GtkListBox-struct) *box`*);
```
Update the sorting for all rows. Call this when result of the sort function on the *`box`* is changed due to an external factor.
#### Parameters
| | | |
| --- | --- | --- |
| box | a [GtkListBox](gtklistbox#GtkListBox-struct) | |
### gtk\_list\_box\_set\_filter\_func ()
```
void
gtk_list_box_set_filter_func (*`[GtkListBox](gtklistbox#GtkListBox-struct) *box`*,
*`[GtkListBoxFilterFunc](gtklistbox#GtkListBoxFilterFunc) filter_func`*,
*`gpointer user_data`*,
*`GDestroyNotify destroy`*);
```
By setting a filter function on the *`box`* one can decide dynamically which of the rows to show. For instance, to implement a search function on a list that filters the original list to only show the matching rows.
The *`filter_func`* will be called for each row after the call, and it will continue to be called each time a row changes (via [`gtk_list_box_row_changed()`](gtklistbox#gtk-list-box-row-changed)) or when [`gtk_list_box_invalidate_filter()`](gtklistbox#gtk-list-box-invalidate-filter) is called.
Note that using a filter function is incompatible with using a model (see [`gtk_list_box_bind_model()`](gtklistbox#gtk-list-box-bind-model)).
#### Parameters
| | | |
| --- | --- | --- |
| box | a [GtkListBox](gtklistbox#GtkListBox-struct) | |
| filter\_func | callback that lets you filter which rows to show. | [allow-none] |
| user\_data | user data passed to *`filter_func`* . | [closure] |
| destroy | destroy notifier for *`user_data`* | |
### gtk\_list\_box\_set\_header\_func ()
```
void
gtk_list_box_set_header_func (*`[GtkListBox](gtklistbox#GtkListBox-struct) *box`*,
*`[GtkListBoxUpdateHeaderFunc](gtklistbox#GtkListBoxUpdateHeaderFunc) update_header`*,
*`gpointer user_data`*,
*`GDestroyNotify destroy`*);
```
By setting a header function on the *`box`* one can dynamically add headers in front of rows, depending on the contents of the row and its position in the list. For instance, one could use it to add headers in front of the first item of a new kind, in a list sorted by the kind.
The *`update_header`* can look at the current header widget using [`gtk_list_box_row_get_header()`](gtklistbox#gtk-list-box-row-get-header) and either update the state of the widget as needed, or set a new one using [`gtk_list_box_row_set_header()`](gtklistbox#gtk-list-box-row-set-header). If no header is needed, set the header to `NULL`.
Note that you may get many calls *`update_header`* to this for a particular row when e.g. changing things that don’t affect the header. In this case it is important for performance to not blindly replace an existing header with an identical one.
The *`update_header`* function will be called for each row after the call, and it will continue to be called each time a row changes (via [`gtk_list_box_row_changed()`](gtklistbox#gtk-list-box-row-changed)) and when the row before changes (either by [`gtk_list_box_row_changed()`](gtklistbox#gtk-list-box-row-changed) on the previous row, or when the previous row becomes a different row). It is also called for all rows when [`gtk_list_box_invalidate_headers()`](gtklistbox#gtk-list-box-invalidate-headers) is called.
#### Parameters
| | | |
| --- | --- | --- |
| box | a [GtkListBox](gtklistbox#GtkListBox-struct) | |
| update\_header | callback that lets you add row headers. | [allow-none] |
| user\_data | user data passed to *`update_header`* . | [closure] |
| destroy | destroy notifier for *`user_data`* | |
### gtk\_list\_box\_set\_sort\_func ()
```
void
gtk_list_box_set_sort_func (*`[GtkListBox](gtklistbox#GtkListBox-struct) *box`*,
*`[GtkListBoxSortFunc](gtklistbox#GtkListBoxSortFunc) sort_func`*,
*`gpointer user_data`*,
*`GDestroyNotify destroy`*);
```
By setting a sort function on the *`box`* one can dynamically reorder the rows of the list, based on the contents of the rows.
The *`sort_func`* will be called for each row after the call, and will continue to be called each time a row changes (via [`gtk_list_box_row_changed()`](gtklistbox#gtk-list-box-row-changed)) and when [`gtk_list_box_invalidate_sort()`](gtklistbox#gtk-list-box-invalidate-sort) is called.
Note that using a sort function is incompatible with using a model (see [`gtk_list_box_bind_model()`](gtklistbox#gtk-list-box-bind-model)).
#### Parameters
| | | |
| --- | --- | --- |
| box | a [GtkListBox](gtklistbox#GtkListBox-struct) | |
| sort\_func | the sort function. | [allow-none] |
| user\_data | user data passed to *`sort_func`* . | [closure] |
| destroy | destroy notifier for *`user_data`* | |
### gtk\_list\_box\_drag\_highlight\_row ()
```
void
gtk_list_box_drag_highlight_row (*`[GtkListBox](gtklistbox#GtkListBox-struct) *box`*,
*`[GtkListBoxRow](gtklistbox#GtkListBoxRow-struct) *row`*);
```
This is a helper function for implementing DnD onto a [GtkListBox](gtklistbox#GtkListBox-struct). The passed in *`row`* will be highlighted by setting the [GTK\_STATE\_FLAG\_DROP\_ACTIVE](gtk4-standard-enumerations#GTK-STATE-FLAG-DROP-ACTIVE:CAPS) state and any previously highlighted row will be unhighlighted.
The row will also be unhighlighted when the widget gets a drag leave event.
#### Parameters
| | | |
| --- | --- | --- |
| box | a [GtkListBox](gtklistbox#GtkListBox-struct) | |
| row | a [GtkListBoxRow](gtklistbox#GtkListBoxRow-struct) | |
### gtk\_list\_box\_drag\_unhighlight\_row ()
```
void
gtk_list_box_drag_unhighlight_row (*`[GtkListBox](gtklistbox#GtkListBox-struct) *box`*);
```
If a row has previously been highlighted via [`gtk_list_box_drag_highlight_row()`](gtklistbox#gtk-list-box-drag-highlight-row) it will have the highlight removed.
#### Parameters
| | | |
| --- | --- | --- |
| box | a [GtkListBox](gtklistbox#GtkListBox-struct) | |
### GtkListBoxCreateWidgetFunc ()
```
[GtkWidget](gtkwidget#GtkWidget-struct) *
(*GtkListBoxCreateWidgetFunc) (*`gpointer item`*,
*`gpointer user_data`*);
```
Called for list boxes that are bound to a GListModel with [`gtk_list_box_bind_model()`](gtklistbox#gtk-list-box-bind-model) for each item that gets added to the model.
#### Parameters
| | | |
| --- | --- | --- |
| item | the item from the model for which to create a widget for. | [type GObject] |
| user\_data | user data. | [closure] |
#### Returns
a [GtkWidget](gtkwidget#GtkWidget-struct) that represents *`item`* .
[transfer full]
### gtk\_list\_box\_bind\_model ()
```
void
gtk_list_box_bind_model (*`[GtkListBox](gtklistbox#GtkListBox-struct) *box`*,
*`GListModel *model`*,
*`[GtkListBoxCreateWidgetFunc](gtklistbox#GtkListBoxCreateWidgetFunc) create_widget_func`*,
*`gpointer user_data`*,
*`GDestroyNotify user_data_free_func`*);
```
Binds *`model`* to *`box`* .
If *`box`* was already bound to a model, that previous binding is destroyed.
The contents of *`box`* are cleared and then filled with widgets that represent items from *`model`* . *`box`* is updated whenever *`model`* changes. If *`model`* is `NULL`, *`box`* is left empty.
It is undefined to add or remove widgets directly (for example, with [`gtk_list_box_insert()`](gtklistbox#gtk-list-box-insert)) while *`box`* is bound to a model.
Note that using a model is incompatible with the filtering and sorting functionality in GtkListBox. When using a model, filtering and sorting should be implemented by the model.
#### Parameters
| | | |
| --- | --- | --- |
| box | a [GtkListBox](gtklistbox#GtkListBox-struct) | |
| model | the GListModel to be bound to *`box`* . | [nullable] |
| create\_widget\_func | a function that creates widgets for items or `NULL` in case you also passed `NULL` as *`model`* . | [nullable] |
| user\_data | user data passed to *`create_widget_func`* . | [closure] |
| user\_data\_free\_func | function for freeing *`user_data`* | |
### gtk\_list\_box\_row\_new ()
```
[GtkWidget](gtkwidget#GtkWidget-struct) *
gtk_list_box_row_new (*`void`*);
```
Creates a new [GtkListBoxRow](gtklistbox#GtkListBoxRow-struct), to be used as a child of a [GtkListBox](gtklistbox#GtkListBox-struct).
#### Returns
a new [GtkListBoxRow](gtklistbox#GtkListBoxRow-struct)
### gtk\_list\_box\_row\_changed ()
```
void
gtk_list_box_row_changed (*`[GtkListBoxRow](gtklistbox#GtkListBoxRow-struct) *row`*);
```
Marks *`row`* as changed, causing any state that depends on this to be updated. This affects sorting, filtering and headers.
Note that calls to this method must be in sync with the data used for the row functions. For instance, if the list is mirroring some external data set, and \*two\* rows changed in the external data set then when you call [`gtk_list_box_row_changed()`](gtklistbox#gtk-list-box-row-changed) on the first row the sort function must only read the new data for the first of the two changed rows, otherwise the resorting of the rows will be wrong.
This generally means that if you don’t fully control the data model you have to duplicate the data that affects the listbox row functions into the row widgets themselves. Another alternative is to call [`gtk_list_box_invalidate_sort()`](gtklistbox#gtk-list-box-invalidate-sort) on any model change, but that is more expensive.
#### Parameters
| | | |
| --- | --- | --- |
| row | a [GtkListBoxRow](gtklistbox#GtkListBoxRow-struct) | |
### gtk\_list\_box\_row\_is\_selected ()
```
gboolean
gtk_list_box_row_is_selected (*`[GtkListBoxRow](gtklistbox#GtkListBoxRow-struct) *row`*);
```
Returns whether the child is currently selected in its [GtkListBox](gtklistbox#GtkListBox-struct) container.
#### Parameters
| | | |
| --- | --- | --- |
| row | a [GtkListBoxRow](gtklistbox#GtkListBoxRow-struct) | |
#### Returns
`TRUE` if *`row`* is selected
### gtk\_list\_box\_row\_get\_child ()
```
[GtkWidget](gtkwidget#GtkWidget-struct) *
gtk_list_box_row_get_child (*`[GtkListBoxRow](gtklistbox#GtkListBoxRow-struct) *row`*);
```
Gets the child widget of *`row`* .
#### Parameters
| | | |
| --- | --- | --- |
| row | a [GtkListBoxRow](gtklistbox#GtkListBoxRow-struct) | |
#### Returns
the child widget of *`row`* .
[nullable][transfer none]
### gtk\_list\_box\_row\_set\_child ()
```
void
gtk_list_box_row_set_child (*`[GtkListBoxRow](gtklistbox#GtkListBoxRow-struct) *row`*,
*`[GtkWidget](gtkwidget#GtkWidget-struct) *child`*);
```
Sets the child widget of *`self`* .
#### Parameters
| | | |
| --- | --- | --- |
| row | a [GtkListBoxRow](gtklistbox#GtkListBoxRow-struct) | |
| child | the child widget. | [allow-none] |
### gtk\_list\_box\_row\_get\_header ()
```
[GtkWidget](gtkwidget#GtkWidget-struct) *
gtk_list_box_row_get_header (*`[GtkListBoxRow](gtklistbox#GtkListBoxRow-struct) *row`*);
```
Returns the current header of the *`row`* . This can be used in a [GtkListBoxUpdateHeaderFunc](gtklistbox#GtkListBoxUpdateHeaderFunc) to see if there is a header set already, and if so to update the state of it.
#### Parameters
| | | |
| --- | --- | --- |
| row | a [GtkListBoxRow](gtklistbox#GtkListBoxRow-struct) | |
#### Returns
the current header, or `NULL` if none.
[transfer none][nullable]
### gtk\_list\_box\_row\_set\_header ()
```
void
gtk_list_box_row_set_header (*`[GtkListBoxRow](gtklistbox#GtkListBoxRow-struct) *row`*,
*`[GtkWidget](gtkwidget#GtkWidget-struct) *header`*);
```
Sets the current header of the *`row`* . This is only allowed to be called from a [GtkListBoxUpdateHeaderFunc](gtklistbox#GtkListBoxUpdateHeaderFunc). It will replace any existing header in the row, and be shown in front of the row in the listbox.
#### Parameters
| | | |
| --- | --- | --- |
| row | a [GtkListBoxRow](gtklistbox#GtkListBoxRow-struct) | |
| header | the header, or `NULL`. | [allow-none] |
### gtk\_list\_box\_row\_get\_index ()
```
int
gtk_list_box_row_get_index (*`[GtkListBoxRow](gtklistbox#GtkListBoxRow-struct) *row`*);
```
Gets the current index of the *`row`* in its [GtkListBox](gtklistbox#GtkListBox-struct) container.
#### Parameters
| | | |
| --- | --- | --- |
| row | a [GtkListBoxRow](gtklistbox#GtkListBoxRow-struct) | |
#### Returns
the index of the *`row`* , or -1 if the *`row`* is not in a listbox
### gtk\_list\_box\_row\_set\_activatable ()
```
void
gtk_list_box_row_set_activatable (*`[GtkListBoxRow](gtklistbox#GtkListBoxRow-struct) *row`*,
*`gboolean activatable`*);
```
Set the [“activatable”](gtklistbox#GtkListBoxRow--activatable) property for this row.
#### Parameters
| | | |
| --- | --- | --- |
| row | a [GtkListBoxRow](gtklistbox#GtkListBoxRow-struct) | |
| activatable | `TRUE` to mark the row as activatable | |
### gtk\_list\_box\_row\_get\_activatable ()
```
gboolean
gtk_list_box_row_get_activatable (*`[GtkListBoxRow](gtklistbox#GtkListBoxRow-struct) *row`*);
```
Gets the value of the [“activatable”](gtklistbox#GtkListBoxRow--activatable) property for this row.
#### Parameters
| | | |
| --- | --- | --- |
| row | a [GtkListBoxRow](gtklistbox#GtkListBoxRow-struct) | |
#### Returns
`TRUE` if the row is activatable
### gtk\_list\_box\_row\_set\_selectable ()
```
void
gtk_list_box_row_set_selectable (*`[GtkListBoxRow](gtklistbox#GtkListBoxRow-struct) *row`*,
*`gboolean selectable`*);
```
Set the [“selectable”](gtklistbox#GtkListBoxRow--selectable) property for this row.
#### Parameters
| | | |
| --- | --- | --- |
| row | a [GtkListBoxRow](gtklistbox#GtkListBoxRow-struct) | |
| selectable | `TRUE` to mark the row as selectable | |
### gtk\_list\_box\_row\_get\_selectable ()
```
gboolean
gtk_list_box_row_get_selectable (*`[GtkListBoxRow](gtklistbox#GtkListBoxRow-struct) *row`*);
```
Gets the value of the [“selectable”](gtklistbox#GtkListBoxRow--selectable) property for this row.
#### Parameters
| | | |
| --- | --- | --- |
| row | a [GtkListBoxRow](gtklistbox#GtkListBoxRow-struct) | |
#### Returns
`TRUE` if the row is selectable
Types and Values
----------------
### GtkListBox
```
typedef struct _GtkListBox GtkListBox;
```
### struct GtkListBoxRow
```
struct GtkListBoxRow;
```
### struct GtkListBoxRowClass
```
struct GtkListBoxRowClass {
GtkWidgetClass parent_class;
void (* activate) (GtkListBoxRow *row);
};
```
#### Members
| | | |
| --- | --- | --- |
| *`activate`* () | | |
Property Details
----------------
### The `“accept-unpaired-release”` property
```
“accept-unpaired-release” gboolean
```
Accept unpaired release.
Owner: GtkListBox
Flags: Read / Write
Default value: FALSE
### The `“activate-on-single-click”` property
```
“activate-on-single-click” gboolean
```
Activate row on a single click.
Owner: GtkListBox
Flags: Read / Write
Default value: TRUE
### The `“selection-mode”` property
```
“selection-mode” [GtkSelectionMode](gtk4-standard-enumerations#GtkSelectionMode)
```
The selection mode.
Owner: GtkListBox
Flags: Read / Write
Default value: GTK\_SELECTION\_SINGLE
### The `“show-separators”` property
```
“show-separators” gboolean
```
Show separators between rows.
Owner: GtkListBox
Flags: Read / Write
Default value: FALSE
### The `“activatable”` property
```
“activatable” gboolean
```
The property determines whether the [“row-activated”](gtklistbox#GtkListBox-row-activated) signal will be emitted for this row.
Owner: GtkListBoxRow
Flags: Read / Write
Default value: TRUE
### The `“child”` property
```
“child” [GtkWidget](gtkwidget#GtkWidget-struct) *
```
The child widget.
Owner: GtkListBoxRow
Flags: Read / Write
### The `“selectable”` property
```
“selectable” gboolean
```
The property determines whether this row can be selected.
Owner: GtkListBoxRow
Flags: Read / Write
Default value: TRUE
Signal Details
--------------
### The `“activate-cursor-row”` signal
```
void
user_function ([GtkListBox](gtklistbox#GtkListBox-struct) *listbox,
gpointer user_data)
```
Flags: Action
### The `“move-cursor”` signal
```
void
user_function ([GtkListBox](gtklistbox#GtkListBox-struct) *listbox,
[GtkMovementStep](gtk4-standard-enumerations#GtkMovementStep) arg1,
int arg2,
gboolean arg3,
gboolean arg4,
gpointer user_data)
```
Flags: Action
### The `“row-activated”` signal
```
void
user_function ([GtkListBox](gtklistbox#GtkListBox-struct) *box,
[GtkListBoxRow](gtklistbox#GtkListBoxRow-struct) *row,
gpointer user_data)
```
The ::row-activated signal is emitted when a row has been activated by the user.
#### Parameters
| | | |
| --- | --- | --- |
| box | the [GtkListBox](gtklistbox#GtkListBox-struct) | |
| row | the activated row | |
| user\_data | user data set when the signal handler was connected. | |
Flags: Run Last
### The `“row-selected”` signal
```
void
user_function ([GtkListBox](gtklistbox#GtkListBox-struct) *box,
[GtkListBoxRow](gtklistbox#GtkListBoxRow-struct) *row,
gpointer user_data)
```
The ::row-selected signal is emitted when a new row is selected, or (with a `NULL` *`row`* ) when the selection is cleared.
When the *`box`* is using [GTK\_SELECTION\_MULTIPLE](gtk4-standard-enumerations#GTK-SELECTION-MULTIPLE:CAPS), this signal will not give you the full picture of selection changes, and you should use the [“selected-rows-changed”](gtklistbox#GtkListBox-selected-rows-changed) signal instead.
#### Parameters
| | | |
| --- | --- | --- |
| box | the [GtkListBox](gtklistbox#GtkListBox-struct) | |
| row | the selected row. | [nullable] |
| user\_data | user data set when the signal handler was connected. | |
Flags: Run Last
### The `“select-all”` signal
```
void
user_function ([GtkListBox](gtklistbox#GtkListBox-struct) *box,
gpointer user_data)
```
The ::select-all signal is a [keybinding signal](gtkshortcutaction#GtkSignalAction-struct) which gets emitted to select all children of the box, if the selection mode permits it.
The default bindings for this signal is Ctrl-a.
#### Parameters
| | | |
| --- | --- | --- |
| box | the [GtkListBox](gtklistbox#GtkListBox-struct) on which the signal is emitted | |
| user\_data | user data set when the signal handler was connected. | |
Flags: Action
### The `“selected-rows-changed”` signal
```
void
user_function ([GtkListBox](gtklistbox#GtkListBox-struct) *box,
gpointer user_data)
```
The ::selected-rows-changed signal is emitted when the set of selected rows changes.
#### Parameters
| | | |
| --- | --- | --- |
| box | the [GtkListBox](gtklistbox#GtkListBox-struct) on which the signal is emitted | |
| user\_data | user data set when the signal handler was connected. | |
Flags: Run First
### The `“toggle-cursor-row”` signal
```
void
user_function ([GtkListBox](gtklistbox#GtkListBox-struct) *listbox,
gpointer user_data)
```
Flags: Action
### The `“unselect-all”` signal
```
void
user_function ([GtkListBox](gtklistbox#GtkListBox-struct) *box,
gpointer user_data)
```
The ::unselect-all signal is a [keybinding signal](gtkshortcutaction#GtkSignalAction-struct) which gets emitted to unselect all children of the box, if the selection mode permits it.
The default bindings for this signal is Ctrl-Shift-a.
#### Parameters
| | | |
| --- | --- | --- |
| box | the [GtkListBox](gtklistbox#GtkListBox-struct) on which the signal is emitted | |
| user\_data | user data set when the signal handler was connected. | |
Flags: Action
### The `“activate”` signal
```
void
user_function ([GtkListBoxRow](gtklistbox#GtkListBoxRow-struct) *listboxrow,
gpointer user_data)
```
This is a keybinding signal, which will cause this row to be activated.
If you want to be notified when the user activates a row (by key or not), use the [“row-activated”](gtklistbox#GtkListBox-row-activated) signal on the row’s parent [GtkListBox](gtklistbox#GtkListBox-struct).
#### Parameters
| | | |
| --- | --- | --- |
| user\_data | user data set when the signal handler was connected. | |
Flags: Action
See Also
--------
[GtkScrolledWindow](gtkscrolledwindow#GtkScrolledWindow-struct)
| programming_docs |
gtk GtkEntryCompletion GtkEntryCompletion
==================
GtkEntryCompletion — Completion functionality for GtkEntry
Functions
---------
| | |
| --- | --- |
| gboolean | ([\*GtkEntryCompletionMatchFunc](gtkentrycompletion#GtkEntryCompletionMatchFunc)) () |
| [GtkEntryCompletion](gtkentrycompletion#GtkEntryCompletion-struct) \* | [gtk\_entry\_completion\_new](gtkentrycompletion#gtk-entry-completion-new) () |
| [GtkEntryCompletion](gtkentrycompletion#GtkEntryCompletion-struct) \* | [gtk\_entry\_completion\_new\_with\_area](gtkentrycompletion#gtk-entry-completion-new-with-area) () |
| [GtkWidget](gtkwidget#GtkWidget-struct) \* | [gtk\_entry\_completion\_get\_entry](gtkentrycompletion#gtk-entry-completion-get-entry) () |
| void | [gtk\_entry\_completion\_set\_model](gtkentrycompletion#gtk-entry-completion-set-model) () |
| [GtkTreeModel](gtktreemodel#GtkTreeModel-struct) \* | [gtk\_entry\_completion\_get\_model](gtkentrycompletion#gtk-entry-completion-get-model) () |
| void | [gtk\_entry\_completion\_set\_match\_func](gtkentrycompletion#gtk-entry-completion-set-match-func) () |
| void | [gtk\_entry\_completion\_set\_minimum\_key\_length](gtkentrycompletion#gtk-entry-completion-set-minimum-key-length) () |
| int | [gtk\_entry\_completion\_get\_minimum\_key\_length](gtkentrycompletion#gtk-entry-completion-get-minimum-key-length) () |
| char \* | [gtk\_entry\_completion\_compute\_prefix](gtkentrycompletion#gtk-entry-completion-compute-prefix) () |
| void | [gtk\_entry\_completion\_complete](gtkentrycompletion#gtk-entry-completion-complete) () |
| const char \* | [gtk\_entry\_completion\_get\_completion\_prefix](gtkentrycompletion#gtk-entry-completion-get-completion-prefix) () |
| void | [gtk\_entry\_completion\_insert\_prefix](gtkentrycompletion#gtk-entry-completion-insert-prefix) () |
| void | [gtk\_entry\_completion\_set\_text\_column](gtkentrycompletion#gtk-entry-completion-set-text-column) () |
| int | [gtk\_entry\_completion\_get\_text\_column](gtkentrycompletion#gtk-entry-completion-get-text-column) () |
| void | [gtk\_entry\_completion\_set\_inline\_completion](gtkentrycompletion#gtk-entry-completion-set-inline-completion) () |
| gboolean | [gtk\_entry\_completion\_get\_inline\_completion](gtkentrycompletion#gtk-entry-completion-get-inline-completion) () |
| void | [gtk\_entry\_completion\_set\_inline\_selection](gtkentrycompletion#gtk-entry-completion-set-inline-selection) () |
| gboolean | [gtk\_entry\_completion\_get\_inline\_selection](gtkentrycompletion#gtk-entry-completion-get-inline-selection) () |
| void | [gtk\_entry\_completion\_set\_popup\_completion](gtkentrycompletion#gtk-entry-completion-set-popup-completion) () |
| gboolean | [gtk\_entry\_completion\_get\_popup\_completion](gtkentrycompletion#gtk-entry-completion-get-popup-completion) () |
| void | [gtk\_entry\_completion\_set\_popup\_set\_width](gtkentrycompletion#gtk-entry-completion-set-popup-set-width) () |
| gboolean | [gtk\_entry\_completion\_get\_popup\_set\_width](gtkentrycompletion#gtk-entry-completion-get-popup-set-width) () |
| void | [gtk\_entry\_completion\_set\_popup\_single\_match](gtkentrycompletion#gtk-entry-completion-set-popup-single-match) () |
| gboolean | [gtk\_entry\_completion\_get\_popup\_single\_match](gtkentrycompletion#gtk-entry-completion-get-popup-single-match) () |
Properties
----------
| | | |
| --- | --- | --- |
| [GtkCellArea](gtkcellarea#GtkCellArea-struct) \* | [cell-area](gtkentrycompletion#GtkEntryCompletion--cell-area) | Read / Write / Construct Only |
| gboolean | [inline-completion](gtkentrycompletion#GtkEntryCompletion--inline-completion) | Read / Write |
| gboolean | [inline-selection](gtkentrycompletion#GtkEntryCompletion--inline-selection) | Read / Write |
| int | [minimum-key-length](gtkentrycompletion#GtkEntryCompletion--minimum-key-length) | Read / Write |
| [GtkTreeModel](gtktreemodel#GtkTreeModel-struct) \* | [model](gtkentrycompletion#GtkEntryCompletion--model) | Read / Write |
| gboolean | [popup-completion](gtkentrycompletion#GtkEntryCompletion--popup-completion) | Read / Write |
| gboolean | [popup-set-width](gtkentrycompletion#GtkEntryCompletion--popup-set-width) | Read / Write |
| gboolean | [popup-single-match](gtkentrycompletion#GtkEntryCompletion--popup-single-match) | Read / Write |
| int | [text-column](gtkentrycompletion#GtkEntryCompletion--text-column) | Read / Write |
Signals
-------
| | | |
| --- | --- | --- |
| gboolean | [cursor-on-match](gtkentrycompletion#GtkEntryCompletion-cursor-on-match) | Run Last |
| gboolean | [insert-prefix](gtkentrycompletion#GtkEntryCompletion-insert-prefix) | Run Last |
| gboolean | [match-selected](gtkentrycompletion#GtkEntryCompletion-match-selected) | Run Last |
| void | [no-matches](gtkentrycompletion#GtkEntryCompletion-no-matches) | Run Last |
Types and Values
----------------
| | |
| --- | --- |
| | [GtkEntryCompletion](gtkentrycompletion#GtkEntryCompletion-struct) |
Object Hierarchy
----------------
```
GObject
╰── GtkEntryCompletion
```
Implemented Interfaces
----------------------
GtkEntryCompletion implements [GtkCellLayout](gtkcelllayout#GtkCellLayout-struct) and [GtkBuildable](gtkbuildable#GtkBuildable-struct).
Includes
--------
```
#include <gtk/gtk.h>
```
Description
-----------
[GtkEntryCompletion](gtkentrycompletion#GtkEntryCompletion-struct) is an auxiliary object to be used in conjunction with [GtkEntry](gtkentry#GtkEntry-struct) to provide the completion functionality. It implements the [GtkCellLayout](gtkcelllayout#GtkCellLayout-struct) interface, to allow the user to add extra cells to the [GtkTreeView](gtktreeview#GtkTreeView-struct) with completion matches.
“Completion functionality” means that when the user modifies the text in the entry, [GtkEntryCompletion](gtkentrycompletion#GtkEntryCompletion-struct) checks which rows in the model match the current content of the entry, and displays a list of matches. By default, the matching is done by comparing the entry text case-insensitively against the text column of the model (see [`gtk_entry_completion_set_text_column()`](gtkentrycompletion#gtk-entry-completion-set-text-column)), but this can be overridden with a custom match function (see [`gtk_entry_completion_set_match_func()`](gtkentrycompletion#gtk-entry-completion-set-match-func)).
When the user selects a completion, the content of the entry is updated. By default, the content of the entry is replaced by the text column of the model, but this can be overridden by connecting to the [“match-selected”](gtkentrycompletion#GtkEntryCompletion-match-selected) signal and updating the entry in the signal handler. Note that you should return `TRUE` from the signal handler to suppress the default behaviour.
To add completion functionality to an entry, use [`gtk_entry_set_completion()`](gtkentry#gtk-entry-set-completion).
GtkEntryCompletion uses a [GtkTreeModelFilter](gtktreemodelfilter#GtkTreeModelFilter-struct) model to represent the subset of the entire model that is currently matching. While the GtkEntryCompletion signals [“match-selected”](gtkentrycompletion#GtkEntryCompletion-match-selected) and [“cursor-on-match”](gtkentrycompletion#GtkEntryCompletion-cursor-on-match) take the original model and an iter pointing to that model as arguments, other callbacks and signals (such as [GtkCellLayoutDataFuncs](gtkcelllayout#GtkCellLayoutDataFunc) or [“apply-attributes”](gtkcellarea#GtkCellArea-apply-attributes)) will generally take the filter model as argument. As long as you are only calling [`gtk_tree_model_get()`](gtktreemodel#gtk-tree-model-get), this will make no difference to you. If for some reason, you need the original model, use [`gtk_tree_model_filter_get_model()`](gtktreemodelfilter#gtk-tree-model-filter-get-model). Don’t forget to use [`gtk_tree_model_filter_convert_iter_to_child_iter()`](gtktreemodelfilter#gtk-tree-model-filter-convert-iter-to-child-iter) to obtain a matching iter.
Functions
---------
### GtkEntryCompletionMatchFunc ()
```
gboolean
(*GtkEntryCompletionMatchFunc) (*`[GtkEntryCompletion](gtkentrycompletion#GtkEntryCompletion-struct) *completion`*,
*`const char *key`*,
*`[GtkTreeIter](gtktreemodel#GtkTreeIter-struct) *iter`*,
*`gpointer user_data`*);
```
A function which decides whether the row indicated by *`iter`* matches a given *`key`* , and should be displayed as a possible completion for *`key`* . Note that *`key`* is normalized and case-folded (see `g_utf8_normalize()` and `g_utf8_casefold()`). If this is not appropriate, match functions have access to the unmodified key via `gtk_editable_get_text (GTK_EDITABLE ([`gtk_entry_completion_get_entry()`](gtkentrycompletion#gtk-entry-completion-get-entry)))`.
#### Parameters
| | | |
| --- | --- | --- |
| completion | the [GtkEntryCompletion](gtkentrycompletion#GtkEntryCompletion-struct) | |
| key | the string to match, normalized and case-folded | |
| iter | a [GtkTreeIter](gtktreemodel#GtkTreeIter-struct) indicating the row to match | |
| user\_data | user data given to [`gtk_entry_completion_set_match_func()`](gtkentrycompletion#gtk-entry-completion-set-match-func) | |
#### Returns
`TRUE` if *`iter`* should be displayed as a possible completion for *`key`*
### gtk\_entry\_completion\_new ()
```
[GtkEntryCompletion](gtkentrycompletion#GtkEntryCompletion-struct) *
gtk_entry_completion_new (*`void`*);
```
Creates a new [GtkEntryCompletion](gtkentrycompletion#GtkEntryCompletion-struct) object.
#### Returns
A newly created [GtkEntryCompletion](gtkentrycompletion#GtkEntryCompletion-struct) object
### gtk\_entry\_completion\_new\_with\_area ()
```
[GtkEntryCompletion](gtkentrycompletion#GtkEntryCompletion-struct) *
gtk_entry_completion_new_with_area (*`[GtkCellArea](gtkcellarea#GtkCellArea-struct) *area`*);
```
Creates a new [GtkEntryCompletion](gtkentrycompletion#GtkEntryCompletion-struct) object using the specified *`area`* to layout cells in the underlying [GtkTreeViewColumn](gtktreeviewcolumn#GtkTreeViewColumn-struct) for the drop-down menu.
#### Parameters
| | | |
| --- | --- | --- |
| area | the [GtkCellArea](gtkcellarea#GtkCellArea-struct) used to layout cells | |
#### Returns
A newly created [GtkEntryCompletion](gtkentrycompletion#GtkEntryCompletion-struct) object
### gtk\_entry\_completion\_get\_entry ()
```
[GtkWidget](gtkwidget#GtkWidget-struct) *
gtk_entry_completion_get_entry (*`[GtkEntryCompletion](gtkentrycompletion#GtkEntryCompletion-struct) *completion`*);
```
Gets the entry *`completion`* has been attached to.
#### Parameters
| | | |
| --- | --- | --- |
| completion | a [GtkEntryCompletion](gtkentrycompletion#GtkEntryCompletion-struct) | |
#### Returns
The entry *`completion`* has been attached to.
[transfer none]
### gtk\_entry\_completion\_set\_model ()
```
void
gtk_entry_completion_set_model (*`[GtkEntryCompletion](gtkentrycompletion#GtkEntryCompletion-struct) *completion`*,
*`[GtkTreeModel](gtktreemodel#GtkTreeModel-struct) *model`*);
```
Sets the model for a [GtkEntryCompletion](gtkentrycompletion#GtkEntryCompletion-struct). If *`completion`* already has a model set, it will remove it before setting the new model. If model is `NULL`, then it will unset the model.
#### Parameters
| | | |
| --- | --- | --- |
| completion | a [GtkEntryCompletion](gtkentrycompletion#GtkEntryCompletion-struct) | |
| model | the [GtkTreeModel](gtktreemodel#GtkTreeModel-struct). | [allow-none] |
### gtk\_entry\_completion\_get\_model ()
```
[GtkTreeModel](gtktreemodel#GtkTreeModel-struct) *
gtk_entry_completion_get_model (*`[GtkEntryCompletion](gtkentrycompletion#GtkEntryCompletion-struct) *completion`*);
```
Returns the model the [GtkEntryCompletion](gtkentrycompletion#GtkEntryCompletion-struct) is using as data source. Returns `NULL` if the model is unset.
#### Parameters
| | | |
| --- | --- | --- |
| completion | a [GtkEntryCompletion](gtkentrycompletion#GtkEntryCompletion-struct) | |
#### Returns
A [GtkTreeModel](gtktreemodel#GtkTreeModel-struct), or `NULL` if none is currently being used.
[nullable][transfer none]
### gtk\_entry\_completion\_set\_match\_func ()
```
void
gtk_entry_completion_set_match_func (*`[GtkEntryCompletion](gtkentrycompletion#GtkEntryCompletion-struct) *completion`*,
*`[GtkEntryCompletionMatchFunc](gtkentrycompletion#GtkEntryCompletionMatchFunc) func`*,
*`gpointer func_data`*,
*`GDestroyNotify func_notify`*);
```
Sets the match function for *`completion`* to be *`func`* . The match function is used to determine if a row should or should not be in the completion list.
#### Parameters
| | | |
| --- | --- | --- |
| completion | a [GtkEntryCompletion](gtkentrycompletion#GtkEntryCompletion-struct) | |
| func | the [GtkEntryCompletionMatchFunc](gtkentrycompletion#GtkEntryCompletionMatchFunc) to use | |
| func\_data | user data for *`func`* | |
| func\_notify | destroy notify for *`func_data`* . | |
### gtk\_entry\_completion\_set\_minimum\_key\_length ()
```
void
gtk_entry_completion_set_minimum_key_length
(*`[GtkEntryCompletion](gtkentrycompletion#GtkEntryCompletion-struct) *completion`*,
*`int length`*);
```
Requires the length of the search key for *`completion`* to be at least *`length`* . This is useful for long lists, where completing using a small key takes a lot of time and will come up with meaningless results anyway (ie, a too large dataset).
#### Parameters
| | | |
| --- | --- | --- |
| completion | a [GtkEntryCompletion](gtkentrycompletion#GtkEntryCompletion-struct) | |
| length | the minimum length of the key in order to start completing | |
### gtk\_entry\_completion\_get\_minimum\_key\_length ()
```
int
gtk_entry_completion_get_minimum_key_length
(*`[GtkEntryCompletion](gtkentrycompletion#GtkEntryCompletion-struct) *completion`*);
```
Returns the minimum key length as set for *`completion`* .
#### Parameters
| | | |
| --- | --- | --- |
| completion | a [GtkEntryCompletion](gtkentrycompletion#GtkEntryCompletion-struct) | |
#### Returns
The currently used minimum key length
### gtk\_entry\_completion\_compute\_prefix ()
```
char *
gtk_entry_completion_compute_prefix (*`[GtkEntryCompletion](gtkentrycompletion#GtkEntryCompletion-struct) *completion`*,
*`const char *key`*);
```
Computes the common prefix that is shared by all rows in *`completion`* that start with *`key`* . If no row matches *`key`* , `NULL` will be returned. Note that a text column must have been set for this function to work, see [`gtk_entry_completion_set_text_column()`](gtkentrycompletion#gtk-entry-completion-set-text-column) for details.
#### Parameters
| | | |
| --- | --- | --- |
| completion | the entry completion | |
| key | The text to complete for | |
#### Returns
The common prefix all rows starting with *`key`* or `NULL` if no row matches *`key`* .
[nullable][transfer full]
### gtk\_entry\_completion\_complete ()
```
void
gtk_entry_completion_complete (*`[GtkEntryCompletion](gtkentrycompletion#GtkEntryCompletion-struct) *completion`*);
```
Requests a completion operation, or in other words a refiltering of the current list with completions, using the current key. The completion list view will be updated accordingly.
#### Parameters
| | | |
| --- | --- | --- |
| completion | a [GtkEntryCompletion](gtkentrycompletion#GtkEntryCompletion-struct) | |
### gtk\_entry\_completion\_get\_completion\_prefix ()
```
const char *
gtk_entry_completion_get_completion_prefix
(*`[GtkEntryCompletion](gtkentrycompletion#GtkEntryCompletion-struct) *completion`*);
```
Get the original text entered by the user that triggered the completion or `NULL` if there’s no completion ongoing.
#### Parameters
| | | |
| --- | --- | --- |
| completion | a [GtkEntryCompletion](gtkentrycompletion#GtkEntryCompletion-struct) | |
#### Returns
the prefix for the current completion.
[nullable]
### gtk\_entry\_completion\_insert\_prefix ()
```
void
gtk_entry_completion_insert_prefix (*`[GtkEntryCompletion](gtkentrycompletion#GtkEntryCompletion-struct) *completion`*);
```
Requests a prefix insertion.
#### Parameters
| | | |
| --- | --- | --- |
| completion | a [GtkEntryCompletion](gtkentrycompletion#GtkEntryCompletion-struct) | |
### gtk\_entry\_completion\_set\_text\_column ()
```
void
gtk_entry_completion_set_text_column (*`[GtkEntryCompletion](gtkentrycompletion#GtkEntryCompletion-struct) *completion`*,
*`int column`*);
```
Convenience function for setting up the most used case of this code: a completion list with just strings. This function will set up *`completion`* to have a list displaying all (and just) strings in the completion list, and to get those strings from *`column`* in the model of *`completion`* .
This functions creates and adds a [GtkCellRendererText](gtkcellrenderertext#GtkCellRendererText-struct) for the selected column. If you need to set the text column, but don't want the cell renderer, use `g_object_set()` to set the [“text-column”](gtkentrycompletion#GtkEntryCompletion--text-column) property directly.
#### Parameters
| | | |
| --- | --- | --- |
| completion | a [GtkEntryCompletion](gtkentrycompletion#GtkEntryCompletion-struct) | |
| column | the column in the model of *`completion`* to get strings from | |
### gtk\_entry\_completion\_get\_text\_column ()
```
int
gtk_entry_completion_get_text_column (*`[GtkEntryCompletion](gtkentrycompletion#GtkEntryCompletion-struct) *completion`*);
```
Returns the column in the model of *`completion`* to get strings from.
#### Parameters
| | | |
| --- | --- | --- |
| completion | a [GtkEntryCompletion](gtkentrycompletion#GtkEntryCompletion-struct) | |
#### Returns
the column containing the strings
### gtk\_entry\_completion\_set\_inline\_completion ()
```
void
gtk_entry_completion_set_inline_completion
(*`[GtkEntryCompletion](gtkentrycompletion#GtkEntryCompletion-struct) *completion`*,
*`gboolean inline_completion`*);
```
Sets whether the common prefix of the possible completions should be automatically inserted in the entry.
#### Parameters
| | | |
| --- | --- | --- |
| completion | a [GtkEntryCompletion](gtkentrycompletion#GtkEntryCompletion-struct) | |
| inline\_completion | `TRUE` to do inline completion | |
### gtk\_entry\_completion\_get\_inline\_completion ()
```
gboolean
gtk_entry_completion_get_inline_completion
(*`[GtkEntryCompletion](gtkentrycompletion#GtkEntryCompletion-struct) *completion`*);
```
Returns whether the common prefix of the possible completions should be automatically inserted in the entry.
#### Parameters
| | | |
| --- | --- | --- |
| completion | a [GtkEntryCompletion](gtkentrycompletion#GtkEntryCompletion-struct) | |
#### Returns
`TRUE` if inline completion is turned on
### gtk\_entry\_completion\_set\_inline\_selection ()
```
void
gtk_entry_completion_set_inline_selection
(*`[GtkEntryCompletion](gtkentrycompletion#GtkEntryCompletion-struct) *completion`*,
*`gboolean inline_selection`*);
```
Sets whether it is possible to cycle through the possible completions inside the entry.
#### Parameters
| | | |
| --- | --- | --- |
| completion | a [GtkEntryCompletion](gtkentrycompletion#GtkEntryCompletion-struct) | |
| inline\_selection | `TRUE` to do inline selection | |
### gtk\_entry\_completion\_get\_inline\_selection ()
```
gboolean
gtk_entry_completion_get_inline_selection
(*`[GtkEntryCompletion](gtkentrycompletion#GtkEntryCompletion-struct) *completion`*);
```
Returns `TRUE` if inline-selection mode is turned on.
#### Parameters
| | | |
| --- | --- | --- |
| completion | a [GtkEntryCompletion](gtkentrycompletion#GtkEntryCompletion-struct) | |
#### Returns
`TRUE` if inline-selection mode is on
### gtk\_entry\_completion\_set\_popup\_completion ()
```
void
gtk_entry_completion_set_popup_completion
(*`[GtkEntryCompletion](gtkentrycompletion#GtkEntryCompletion-struct) *completion`*,
*`gboolean popup_completion`*);
```
Sets whether the completions should be presented in a popup window.
#### Parameters
| | | |
| --- | --- | --- |
| completion | a [GtkEntryCompletion](gtkentrycompletion#GtkEntryCompletion-struct) | |
| popup\_completion | `TRUE` to do popup completion | |
### gtk\_entry\_completion\_get\_popup\_completion ()
```
gboolean
gtk_entry_completion_get_popup_completion
(*`[GtkEntryCompletion](gtkentrycompletion#GtkEntryCompletion-struct) *completion`*);
```
Returns whether the completions should be presented in a popup window.
#### Parameters
| | | |
| --- | --- | --- |
| completion | a [GtkEntryCompletion](gtkentrycompletion#GtkEntryCompletion-struct) | |
#### Returns
`TRUE` if popup completion is turned on
### gtk\_entry\_completion\_set\_popup\_set\_width ()
```
void
gtk_entry_completion_set_popup_set_width
(*`[GtkEntryCompletion](gtkentrycompletion#GtkEntryCompletion-struct) *completion`*,
*`gboolean popup_set_width`*);
```
Sets whether the completion popup window will be resized to be the same width as the entry.
#### Parameters
| | | |
| --- | --- | --- |
| completion | a [GtkEntryCompletion](gtkentrycompletion#GtkEntryCompletion-struct) | |
| popup\_set\_width | `TRUE` to make the width of the popup the same as the entry | |
### gtk\_entry\_completion\_get\_popup\_set\_width ()
```
gboolean
gtk_entry_completion_get_popup_set_width
(*`[GtkEntryCompletion](gtkentrycompletion#GtkEntryCompletion-struct) *completion`*);
```
Returns whether the completion popup window will be resized to the width of the entry.
#### Parameters
| | | |
| --- | --- | --- |
| completion | a [GtkEntryCompletion](gtkentrycompletion#GtkEntryCompletion-struct) | |
#### Returns
`TRUE` if the popup window will be resized to the width of the entry
### gtk\_entry\_completion\_set\_popup\_single\_match ()
```
void
gtk_entry_completion_set_popup_single_match
(*`[GtkEntryCompletion](gtkentrycompletion#GtkEntryCompletion-struct) *completion`*,
*`gboolean popup_single_match`*);
```
Sets whether the completion popup window will appear even if there is only a single match. You may want to set this to `FALSE` if you are using [inline completion](gtkentrycompletion#GtkEntryCompletion--inline-completion).
#### Parameters
| | | |
| --- | --- | --- |
| completion | a [GtkEntryCompletion](gtkentrycompletion#GtkEntryCompletion-struct) | |
| popup\_single\_match | `TRUE` if the popup should appear even for a single match | |
### gtk\_entry\_completion\_get\_popup\_single\_match ()
```
gboolean
gtk_entry_completion_get_popup_single_match
(*`[GtkEntryCompletion](gtkentrycompletion#GtkEntryCompletion-struct) *completion`*);
```
Returns whether the completion popup window will appear even if there is only a single match.
#### Parameters
| | | |
| --- | --- | --- |
| completion | a [GtkEntryCompletion](gtkentrycompletion#GtkEntryCompletion-struct) | |
#### Returns
`TRUE` if the popup window will appear regardless of the number of matches
Types and Values
----------------
### GtkEntryCompletion
```
typedef struct _GtkEntryCompletion GtkEntryCompletion;
```
Property Details
----------------
### The `“cell-area”` property
```
“cell-area” [GtkCellArea](gtkcellarea#GtkCellArea-struct) *
```
The [GtkCellArea](gtkcellarea#GtkCellArea-struct) used to layout cell renderers in the treeview column.
If no area is specified when creating the entry completion with [`gtk_entry_completion_new_with_area()`](gtkentrycompletion#gtk-entry-completion-new-with-area) a horizontally oriented [GtkCellAreaBox](gtkcellareabox#GtkCellAreaBox-struct) will be used.
Owner: GtkEntryCompletion
Flags: Read / Write / Construct Only
### The `“inline-completion”` property
```
“inline-completion” gboolean
```
Determines whether the common prefix of the possible completions should be inserted automatically in the entry. Note that this requires text-column to be set, even if you are using a custom match function.
Owner: GtkEntryCompletion
Flags: Read / Write
Default value: FALSE
### The `“inline-selection”` property
```
“inline-selection” gboolean
```
Determines whether the possible completions on the popup will appear in the entry as you navigate through them.
Owner: GtkEntryCompletion
Flags: Read / Write
Default value: FALSE
### The `“minimum-key-length”` property
```
“minimum-key-length” int
```
Minimum length of the search key in order to look up matches.
Owner: GtkEntryCompletion
Flags: Read / Write
Allowed values: >= 0
Default value: 1
### The `“model”` property
```
“model” [GtkTreeModel](gtktreemodel#GtkTreeModel-struct) *
```
The model to find matches in.
Owner: GtkEntryCompletion
Flags: Read / Write
### The `“popup-completion”` property
```
“popup-completion” gboolean
```
Determines whether the possible completions should be shown in a popup window.
Owner: GtkEntryCompletion
Flags: Read / Write
Default value: TRUE
### The `“popup-set-width”` property
```
“popup-set-width” gboolean
```
Determines whether the completions popup window will be resized to the width of the entry.
Owner: GtkEntryCompletion
Flags: Read / Write
Default value: TRUE
### The `“popup-single-match”` property
```
“popup-single-match” gboolean
```
Determines whether the completions popup window will shown for a single possible completion. You probably want to set this to `FALSE` if you are using [inline completion](gtkentrycompletion#GtkEntryCompletion--inline-completion).
Owner: GtkEntryCompletion
Flags: Read / Write
Default value: TRUE
### The `“text-column”` property
```
“text-column” int
```
The column of the model containing the strings. Note that the strings must be UTF-8.
Owner: GtkEntryCompletion
Flags: Read / Write
Allowed values: >= -1
Default value: -1
Signal Details
--------------
### The `“cursor-on-match”` signal
```
gboolean
user_function ([GtkEntryCompletion](gtkentrycompletion#GtkEntryCompletion-struct) *widget,
[GtkTreeModel](gtktreemodel#GtkTreeModel-struct) *model,
[GtkTreeIter](gtktreemodel#GtkTreeIter-struct) *iter,
gpointer user_data)
```
Gets emitted when a match from the cursor is on a match of the list. The default behaviour is to replace the contents of the entry with the contents of the text column in the row pointed to by *`iter`* .
Note that *`model`* is the model that was passed to [`gtk_entry_completion_set_model()`](gtkentrycompletion#gtk-entry-completion-set-model).
#### Parameters
| | | |
| --- | --- | --- |
| widget | the object which received the signal | |
| model | the [GtkTreeModel](gtktreemodel#GtkTreeModel-struct) containing the matches | |
| iter | a [GtkTreeIter](gtktreemodel#GtkTreeIter-struct) positioned at the selected match | |
| user\_data | user data set when the signal handler was connected. | |
#### Returns
`TRUE` if the signal has been handled
Flags: Run Last
### The `“insert-prefix”` signal
```
gboolean
user_function ([GtkEntryCompletion](gtkentrycompletion#GtkEntryCompletion-struct) *widget,
char *prefix,
gpointer user_data)
```
Gets emitted when the inline autocompletion is triggered. The default behaviour is to make the entry display the whole prefix and select the newly inserted part.
Applications may connect to this signal in order to insert only a smaller part of the *`prefix`* into the entry - e.g. the entry used in the [GtkFileChooser](gtkfilechooser#GtkFileChooser-struct) inserts only the part of the prefix up to the next '/'.
#### Parameters
| | | |
| --- | --- | --- |
| widget | the object which received the signal | |
| prefix | the common prefix of all possible completions | |
| user\_data | user data set when the signal handler was connected. | |
#### Returns
`TRUE` if the signal has been handled
Flags: Run Last
### The `“match-selected”` signal
```
gboolean
user_function ([GtkEntryCompletion](gtkentrycompletion#GtkEntryCompletion-struct) *widget,
[GtkTreeModel](gtktreemodel#GtkTreeModel-struct) *model,
[GtkTreeIter](gtktreemodel#GtkTreeIter-struct) *iter,
gpointer user_data)
```
Gets emitted when a match from the list is selected. The default behaviour is to replace the contents of the entry with the contents of the text column in the row pointed to by *`iter`* .
Note that *`model`* is the model that was passed to [`gtk_entry_completion_set_model()`](gtkentrycompletion#gtk-entry-completion-set-model).
#### Parameters
| | | |
| --- | --- | --- |
| widget | the object which received the signal | |
| model | the [GtkTreeModel](gtktreemodel#GtkTreeModel-struct) containing the matches | |
| iter | a [GtkTreeIter](gtktreemodel#GtkTreeIter-struct) positioned at the selected match | |
| user\_data | user data set when the signal handler was connected. | |
#### Returns
`TRUE` if the signal has been handled
Flags: Run Last
### The `“no-matches”` signal
```
void
user_function ([GtkEntryCompletion](gtkentrycompletion#GtkEntryCompletion-struct) *widget,
gpointer user_data)
```
Gets emitted when the filter model has zero number of rows in completion\_complete method. (In other words when GtkEntryCompletion is out of suggestions)
#### Parameters
| | | |
| --- | --- | --- |
| widget | the object which received the signal | |
| user\_data | user data set when the signal handler was connected. | |
Flags: Run Last
| programming_docs |
gtk GtkTextTag GtkTextTag
==========
GtkTextTag — A tag that can be applied to text in a GtkTextBuffer
Functions
---------
| | |
| --- | --- |
| [GtkTextTag](gtktexttag#GtkTextTag-struct) \* | [gtk\_text\_tag\_new](gtktexttag#gtk-text-tag-new) () |
| int | [gtk\_text\_tag\_get\_priority](gtktexttag#gtk-text-tag-get-priority) () |
| void | [gtk\_text\_tag\_set\_priority](gtktexttag#gtk-text-tag-set-priority) () |
| void | [gtk\_text\_tag\_changed](gtktexttag#gtk-text-tag-changed) () |
Properties
----------
| | | |
| --- | --- | --- |
| gboolean | [accumulative-margin](gtktexttag#GtkTextTag--accumulative-margin) | Read / Write |
| gboolean | [allow-breaks](gtktexttag#GtkTextTag--allow-breaks) | Read / Write |
| gboolean | [allow-breaks-set](gtktexttag#GtkTextTag--allow-breaks-set) | Read / Write |
| char \* | [background](gtktexttag#GtkTextTag--background) | Write |
| gboolean | [background-full-height](gtktexttag#GtkTextTag--background-full-height) | Read / Write |
| gboolean | [background-full-height-set](gtktexttag#GtkTextTag--background-full-height-set) | Read / Write |
| [GdkRGBA](https://developer-old.gnome.org/gtk4/html/gdk4-RGBA-Colors.html#GdkRGBA-struct) \* | [background-rgba](gtktexttag#GtkTextTag--background-rgba) | Read / Write |
| gboolean | [background-set](gtktexttag#GtkTextTag--background-set) | Read / Write |
| [GtkTextDirection](gtkwidget#GtkTextDirection) | [direction](gtktexttag#GtkTextTag--direction) | Read / Write |
| gboolean | [editable](gtktexttag#GtkTextTag--editable) | Read / Write |
| gboolean | [editable-set](gtktexttag#GtkTextTag--editable-set) | Read / Write |
| gboolean | [fallback](gtktexttag#GtkTextTag--fallback) | Read / Write |
| gboolean | [fallback-set](gtktexttag#GtkTextTag--fallback-set) | Read / Write |
| char \* | [family](gtktexttag#GtkTextTag--family) | Read / Write |
| gboolean | [family-set](gtktexttag#GtkTextTag--family-set) | Read / Write |
| char \* | [font](gtktexttag#GtkTextTag--font) | Read / Write |
| [PangoFontDescription](https://developer-old.gnome.org/pango/stable/pango-Fonts.html#PangoFontDescription-struct) \* | [font-desc](gtktexttag#GtkTextTag--font-desc) | Read / Write |
| char \* | [font-features](gtktexttag#GtkTextTag--font-features) | Read / Write |
| gboolean | [font-features-set](gtktexttag#GtkTextTag--font-features-set) | Read / Write |
| char \* | [foreground](gtktexttag#GtkTextTag--foreground) | Write |
| [GdkRGBA](https://developer-old.gnome.org/gtk4/html/gdk4-RGBA-Colors.html#GdkRGBA-struct) \* | [foreground-rgba](gtktexttag#GtkTextTag--foreground-rgba) | Read / Write |
| gboolean | [foreground-set](gtktexttag#GtkTextTag--foreground-set) | Read / Write |
| int | [indent](gtktexttag#GtkTextTag--indent) | Read / Write |
| gboolean | [indent-set](gtktexttag#GtkTextTag--indent-set) | Read / Write |
| gboolean | [insert-hyphens](gtktexttag#GtkTextTag--insert-hyphens) | Read / Write |
| gboolean | [insert-hyphens-set](gtktexttag#GtkTextTag--insert-hyphens-set) | Read / Write |
| gboolean | [invisible](gtktexttag#GtkTextTag--invisible) | Read / Write |
| gboolean | [invisible-set](gtktexttag#GtkTextTag--invisible-set) | Read / Write |
| [GtkJustification](gtk4-standard-enumerations#GtkJustification) | [justification](gtktexttag#GtkTextTag--justification) | Read / Write |
| gboolean | [justification-set](gtktexttag#GtkTextTag--justification-set) | Read / Write |
| char \* | [language](gtktexttag#GtkTextTag--language) | Read / Write |
| gboolean | [language-set](gtktexttag#GtkTextTag--language-set) | Read / Write |
| int | [left-margin](gtktexttag#GtkTextTag--left-margin) | Read / Write |
| gboolean | [left-margin-set](gtktexttag#GtkTextTag--left-margin-set) | Read / Write |
| int | [letter-spacing](gtktexttag#GtkTextTag--letter-spacing) | Read / Write |
| gboolean | [letter-spacing-set](gtktexttag#GtkTextTag--letter-spacing-set) | Read / Write |
| char \* | [name](gtktexttag#GtkTextTag--name) | Read / Write / Construct Only |
| [PangoOverline](https://developer-old.gnome.org/pango/stable/pango-Text-Attributes.html#PangoOverline) | [overline](gtktexttag#GtkTextTag--overline) | Read / Write |
| [GdkRGBA](https://developer-old.gnome.org/gtk4/html/gdk4-RGBA-Colors.html#GdkRGBA-struct) \* | [overline-rgba](gtktexttag#GtkTextTag--overline-rgba) | Read / Write |
| gboolean | [overline-rgba-set](gtktexttag#GtkTextTag--overline-rgba-set) | Read / Write |
| gboolean | [overline-set](gtktexttag#GtkTextTag--overline-set) | Read / Write |
| char \* | [paragraph-background](gtktexttag#GtkTextTag--paragraph-background) | Write |
| [GdkRGBA](https://developer-old.gnome.org/gtk4/html/gdk4-RGBA-Colors.html#GdkRGBA-struct) \* | [paragraph-background-rgba](gtktexttag#GtkTextTag--paragraph-background-rgba) | Read / Write |
| gboolean | [paragraph-background-set](gtktexttag#GtkTextTag--paragraph-background-set) | Read / Write |
| int | [pixels-above-lines](gtktexttag#GtkTextTag--pixels-above-lines) | Read / Write |
| gboolean | [pixels-above-lines-set](gtktexttag#GtkTextTag--pixels-above-lines-set) | Read / Write |
| int | [pixels-below-lines](gtktexttag#GtkTextTag--pixels-below-lines) | Read / Write |
| gboolean | [pixels-below-lines-set](gtktexttag#GtkTextTag--pixels-below-lines-set) | Read / Write |
| int | [pixels-inside-wrap](gtktexttag#GtkTextTag--pixels-inside-wrap) | Read / Write |
| gboolean | [pixels-inside-wrap-set](gtktexttag#GtkTextTag--pixels-inside-wrap-set) | Read / Write |
| int | [right-margin](gtktexttag#GtkTextTag--right-margin) | Read / Write |
| gboolean | [right-margin-set](gtktexttag#GtkTextTag--right-margin-set) | Read / Write |
| int | [rise](gtktexttag#GtkTextTag--rise) | Read / Write |
| gboolean | [rise-set](gtktexttag#GtkTextTag--rise-set) | Read / Write |
| double | [scale](gtktexttag#GtkTextTag--scale) | Read / Write |
| gboolean | [scale-set](gtktexttag#GtkTextTag--scale-set) | Read / Write |
| [PangoShowFlags](https://developer-old.gnome.org/pango/stable/pango-Text-Attributes.html#PangoShowFlags) | [show-spaces](gtktexttag#GtkTextTag--show-spaces) | Read / Write |
| gboolean | [show-spaces-set](gtktexttag#GtkTextTag--show-spaces-set) | Read / Write |
| int | [size](gtktexttag#GtkTextTag--size) | Read / Write |
| double | [size-points](gtktexttag#GtkTextTag--size-points) | Read / Write |
| gboolean | [size-set](gtktexttag#GtkTextTag--size-set) | Read / Write |
| [PangoStretch](https://developer-old.gnome.org/pango/stable/pango-Fonts.html#PangoStretch) | [stretch](gtktexttag#GtkTextTag--stretch) | Read / Write |
| gboolean | [stretch-set](gtktexttag#GtkTextTag--stretch-set) | Read / Write |
| gboolean | [strikethrough](gtktexttag#GtkTextTag--strikethrough) | Read / Write |
| [GdkRGBA](https://developer-old.gnome.org/gtk4/html/gdk4-RGBA-Colors.html#GdkRGBA-struct) \* | [strikethrough-rgba](gtktexttag#GtkTextTag--strikethrough-rgba) | Read / Write |
| gboolean | [strikethrough-rgba-set](gtktexttag#GtkTextTag--strikethrough-rgba-set) | Read / Write |
| gboolean | [strikethrough-set](gtktexttag#GtkTextTag--strikethrough-set) | Read / Write |
| [PangoStyle](https://developer-old.gnome.org/pango/stable/pango-Fonts.html#PangoStyle) | [style](gtktexttag#GtkTextTag--style) | Read / Write |
| gboolean | [style-set](gtktexttag#GtkTextTag--style-set) | Read / Write |
| [PangoTabArray](https://developer-old.gnome.org/pango/stable/pango-Tab-Stops.html#PangoTabArray-struct) \* | [tabs](gtktexttag#GtkTextTag--tabs) | Read / Write |
| gboolean | [tabs-set](gtktexttag#GtkTextTag--tabs-set) | Read / Write |
| [PangoUnderline](https://developer-old.gnome.org/pango/stable/pango-Text-Attributes.html#PangoUnderline) | [underline](gtktexttag#GtkTextTag--underline) | Read / Write |
| [GdkRGBA](https://developer-old.gnome.org/gtk4/html/gdk4-RGBA-Colors.html#GdkRGBA-struct) \* | [underline-rgba](gtktexttag#GtkTextTag--underline-rgba) | Read / Write |
| gboolean | [underline-rgba-set](gtktexttag#GtkTextTag--underline-rgba-set) | Read / Write |
| gboolean | [underline-set](gtktexttag#GtkTextTag--underline-set) | Read / Write |
| [PangoVariant](https://developer-old.gnome.org/pango/stable/pango-Fonts.html#PangoVariant) | [variant](gtktexttag#GtkTextTag--variant) | Read / Write |
| gboolean | [variant-set](gtktexttag#GtkTextTag--variant-set) | Read / Write |
| int | [weight](gtktexttag#GtkTextTag--weight) | Read / Write |
| gboolean | [weight-set](gtktexttag#GtkTextTag--weight-set) | Read / Write |
| [GtkWrapMode](gtktextview#GtkWrapMode) | [wrap-mode](gtktexttag#GtkTextTag--wrap-mode) | Read / Write |
| gboolean | [wrap-mode-set](gtktexttag#GtkTextTag--wrap-mode-set) | Read / Write |
Types and Values
----------------
| | |
| --- | --- |
| struct | [GtkTextTag](gtktexttag#GtkTextTag-struct) |
Object Hierarchy
----------------
```
GObject
╰── GtkTextTag
```
Includes
--------
```
#include <gtk/gtk.h>
```
Description
-----------
You may wish to begin by reading the [text widget conceptual overview](textwidgetobjects#TextWidget) which gives an overview of all the objects and data types related to the text widget and how they work together.
Tags should be in the [GtkTextTagTable](gtktexttagtable#GtkTextTagTable-struct) for a given [GtkTextBuffer](gtktextbuffer#GtkTextBuffer-struct) before using them with that buffer.
gtk\_text\_buffer\_create\_tag() is the best way to create tags. See “gtk4-demo” for numerous examples.
For each property of [GtkTextTag](gtktexttag#GtkTextTag-struct), there is a “set” property, e.g. “font-set” corresponds to “font”. These “set” properties reflect whether a property has been set or not. They are maintained by GTK+ and you should not set them independently.
Functions
---------
### gtk\_text\_tag\_new ()
```
[GtkTextTag](gtktexttag#GtkTextTag-struct) *
gtk_text_tag_new (*`const char *name`*);
```
Creates a [GtkTextTag](gtktexttag#GtkTextTag-struct). Configure the tag using object arguments, i.e. using `g_object_set()`.
#### Parameters
| | | |
| --- | --- | --- |
| name | tag name, or `NULL`. | [allow-none] |
#### Returns
a new [GtkTextTag](gtktexttag#GtkTextTag-struct)
### gtk\_text\_tag\_get\_priority ()
```
int
gtk_text_tag_get_priority (*`[GtkTextTag](gtktexttag#GtkTextTag-struct) *tag`*);
```
Get the tag priority.
#### Parameters
| | | |
| --- | --- | --- |
| tag | a [GtkTextTag](gtktexttag#GtkTextTag-struct) | |
#### Returns
The tag’s priority.
### gtk\_text\_tag\_set\_priority ()
```
void
gtk_text_tag_set_priority (*`[GtkTextTag](gtktexttag#GtkTextTag-struct) *tag`*,
*`int priority`*);
```
Sets the priority of a [GtkTextTag](gtktexttag#GtkTextTag-struct). Valid priorities start at 0 and go to one less than [`gtk_text_tag_table_get_size()`](gtktexttagtable#gtk-text-tag-table-get-size). Each tag in a table has a unique priority; setting the priority of one tag shifts the priorities of all the other tags in the table to maintain a unique priority for each tag. Higher priority tags “win” if two tags both set the same text attribute. When adding a tag to a tag table, it will be assigned the highest priority in the table by default; so normally the precedence of a set of tags is the order in which they were added to the table, or created with [`gtk_text_buffer_create_tag()`](gtktextbuffer#gtk-text-buffer-create-tag), which adds the tag to the buffer’s table automatically.
#### Parameters
| | | |
| --- | --- | --- |
| tag | a [GtkTextTag](gtktexttag#GtkTextTag-struct) | |
| priority | the new priority | |
### gtk\_text\_tag\_changed ()
```
void
gtk_text_tag_changed (*`[GtkTextTag](gtktexttag#GtkTextTag-struct) *tag`*,
*`gboolean size_changed`*);
```
Emits the [“tag-changed”](gtktexttagtable#GtkTextTagTable-tag-changed) signal on the [GtkTextTagTable](gtktexttagtable#GtkTextTagTable-struct) where the tag is included.
The signal is already emitted when setting a [GtkTextTag](gtktexttag#GtkTextTag-struct) property. This function is useful for a [GtkTextTag](gtktexttag#GtkTextTag-struct) subclass.
#### Parameters
| | | |
| --- | --- | --- |
| tag | a [GtkTextTag](gtktexttag#GtkTextTag-struct). | |
| size\_changed | whether the change affects the [GtkTextView](gtktextview#GtkTextView-struct) layout. | |
Types and Values
----------------
### struct GtkTextTag
```
struct GtkTextTag;
```
Property Details
----------------
### The `“accumulative-margin”` property
```
“accumulative-margin” gboolean
```
Whether the margins accumulate or override each other.
When set to `TRUE` the margins of this tag are added to the margins of any other non-accumulative margins present. When set to `FALSE` the margins override one another (the default).
Owner: GtkTextTag
Flags: Read / Write
Default value: FALSE
### The `“allow-breaks”` property
```
“allow-breaks” gboolean
```
Whether breaks are allowed.
Owner: GtkTextTag
Flags: Read / Write
Default value: TRUE
### The `“allow-breaks-set”` property
```
“allow-breaks-set” gboolean
```
Whether this tag affects line breaks.
Owner: GtkTextTag
Flags: Read / Write
Default value: FALSE
### The `“background”` property
```
“background” char *
```
Background color as a string.
Owner: GtkTextTag
Flags: Write
Default value: NULL
### The `“background-full-height”` property
```
“background-full-height” gboolean
```
Whether the background color fills the entire line height or only the height of the tagged characters.
Owner: GtkTextTag
Flags: Read / Write
Default value: FALSE
### The `“background-full-height-set”` property
```
“background-full-height-set” gboolean
```
Whether this tag affects background height.
Owner: GtkTextTag
Flags: Read / Write
Default value: FALSE
### The `“background-rgba”` property
```
“background-rgba” [GdkRGBA](https://developer-old.gnome.org/gtk4/html/gdk4-RGBA-Colors.html#GdkRGBA-struct) *
```
Background color as a [GdkRGBA](https://developer-old.gnome.org/gtk4/html/gdk4-RGBA-Colors.html#GdkRGBA-struct).
Owner: GtkTextTag
Flags: Read / Write
### The `“background-set”` property
```
“background-set” gboolean
```
Whether this tag affects the background color.
Owner: GtkTextTag
Flags: Read / Write
Default value: FALSE
### The `“direction”` property
```
“direction” [GtkTextDirection](gtkwidget#GtkTextDirection)
```
Text direction, e.g. right-to-left or left-to-right.
Owner: GtkTextTag
Flags: Read / Write
Default value: GTK\_TEXT\_DIR\_NONE
### The `“editable”` property
```
“editable” gboolean
```
Whether the text can be modified by the user.
Owner: GtkTextTag
Flags: Read / Write
Default value: TRUE
### The `“editable-set”` property
```
“editable-set” gboolean
```
Whether this tag affects text editability.
Owner: GtkTextTag
Flags: Read / Write
Default value: FALSE
### The `“fallback”` property
```
“fallback” gboolean
```
Whether font fallback is enabled.
When set to `TRUE`, other fonts will be substituted where the current font is missing glyphs.
Owner: GtkTextTag
Flags: Read / Write
Default value: TRUE
### The `“fallback-set”` property
```
“fallback-set” gboolean
```
Whether this tag affects font fallback.
Owner: GtkTextTag
Flags: Read / Write
Default value: FALSE
### The `“family”` property
```
“family” char *
```
Name of the font family, e.g. Sans, Helvetica, Times, Monospace.
Owner: GtkTextTag
Flags: Read / Write
Default value: NULL
### The `“family-set”` property
```
“family-set” gboolean
```
Whether this tag affects the font family.
Owner: GtkTextTag
Flags: Read / Write
Default value: FALSE
### The `“font”` property
```
“font” char *
```
Font description as string, e.g. \"Sans Italic 12\".
Note that the initial value of this property depends on the internals of [PangoFontDescription](https://developer-old.gnome.org/pango/stable/pango-Fonts.html#PangoFontDescription-struct).
Owner: GtkTextTag
Flags: Read / Write
Default value: NULL
### The `“font-desc”` property
```
“font-desc” [PangoFontDescription](https://developer-old.gnome.org/pango/stable/pango-Fonts.html#PangoFontDescription-struct) *
```
Font description as a PangoFontDescription struct.
Owner: GtkTextTag
Flags: Read / Write
### The `“font-features”` property
```
“font-features” char *
```
OpenType font features, as a string.
Owner: GtkTextTag
Flags: Read / Write
Default value: NULL
### The `“font-features-set”` property
```
“font-features-set” gboolean
```
Whether this tag affects font features.
Owner: GtkTextTag
Flags: Read / Write
Default value: FALSE
### The `“foreground”` property
```
“foreground” char *
```
Foreground color as a string.
Owner: GtkTextTag
Flags: Write
Default value: NULL
### The `“foreground-rgba”` property
```
“foreground-rgba” [GdkRGBA](https://developer-old.gnome.org/gtk4/html/gdk4-RGBA-Colors.html#GdkRGBA-struct) *
```
Foreground color as a [GdkRGBA](https://developer-old.gnome.org/gtk4/html/gdk4-RGBA-Colors.html#GdkRGBA-struct).
Owner: GtkTextTag
Flags: Read / Write
### The `“foreground-set”` property
```
“foreground-set” gboolean
```
Whether this tag affects the foreground color.
Owner: GtkTextTag
Flags: Read / Write
Default value: FALSE
### The `“indent”` property
```
“indent” int
```
Amount to indent the paragraph, in pixels.
Owner: GtkTextTag
Flags: Read / Write
Default value: 0
### The `“indent-set”` property
```
“indent-set” gboolean
```
Whether this tag affects indentation.
Owner: GtkTextTag
Flags: Read / Write
Default value: FALSE
### The `“insert-hyphens”` property
```
“insert-hyphens” gboolean
```
Whether to insert hyphens at breaks.
Owner: GtkTextTag
Flags: Read / Write
Default value: TRUE
### The `“insert-hyphens-set”` property
```
“insert-hyphens-set” gboolean
```
Whether this tag affects insertion of hyphens.
Owner: GtkTextTag
Flags: Read / Write
Default value: FALSE
### The `“invisible”` property
```
“invisible” gboolean
```
Whether this text is hidden.
Note that there may still be problems with the support for invisible text, in particular when navigating programmatically inside a buffer containing invisible segments.
Owner: GtkTextTag
Flags: Read / Write
Default value: FALSE
### The `“invisible-set”` property
```
“invisible-set” gboolean
```
Whether this tag affects text visibility.
Owner: GtkTextTag
Flags: Read / Write
Default value: FALSE
### The `“justification”` property
```
“justification” [GtkJustification](gtk4-standard-enumerations#GtkJustification)
```
Left, right, or center justification.
Owner: GtkTextTag
Flags: Read / Write
Default value: GTK\_JUSTIFY\_LEFT
### The `“justification-set”` property
```
“justification-set” gboolean
```
Whether this tag affects paragraph justification.
Owner: GtkTextTag
Flags: Read / Write
Default value: FALSE
### The `“language”` property
```
“language” char *
```
The language this text is in, as an ISO code. Pango can use this as a hint when rendering the text. If not set, an appropriate default will be used.
Note that the initial value of this property depends on the current locale, see also [`gtk_get_default_language()`](gtk4-general#gtk-get-default-language).
Owner: GtkTextTag
Flags: Read / Write
Default value: NULL
### The `“language-set”` property
```
“language-set” gboolean
```
Whether this tag affects the language the text is rendered as.
Owner: GtkTextTag
Flags: Read / Write
Default value: FALSE
### The `“left-margin”` property
```
“left-margin” int
```
Width of the left margin in pixels.
Owner: GtkTextTag
Flags: Read / Write
Allowed values: >= 0
Default value: 0
### The `“left-margin-set”` property
```
“left-margin-set” gboolean
```
Whether this tag affects the left margin.
Owner: GtkTextTag
Flags: Read / Write
Default value: FALSE
### The `“letter-spacing”` property
```
“letter-spacing” int
```
Extra spacing between graphemes, in Pango units.
Owner: GtkTextTag
Flags: Read / Write
Allowed values: >= 0
Default value: 0
### The `“letter-spacing-set”` property
```
“letter-spacing-set” gboolean
```
Whether this tag affects letter spacing.
Owner: GtkTextTag
Flags: Read / Write
Default value: FALSE
### The `“name”` property
```
“name” char *
```
Name used to refer to the text tag. NULL for anonymous tags.
Owner: GtkTextTag
Flags: Read / Write / Construct Only
Default value: NULL
### The `“overline”` property
```
“overline” [PangoOverline](https://developer-old.gnome.org/pango/stable/pango-Text-Attributes.html#PangoOverline)
```
Style of overline for this text.
Owner: GtkTextTag
Flags: Read / Write
Default value: PANGO\_OVERLINE\_NONE
### The `“overline-rgba”` property
```
“overline-rgba” [GdkRGBA](https://developer-old.gnome.org/gtk4/html/gdk4-RGBA-Colors.html#GdkRGBA-struct) *
```
Color of overline for this text.
Owner: GtkTextTag
Flags: Read / Write
### The `“overline-rgba-set”` property
```
“overline-rgba-set” gboolean
```
Whether this tag affects overlining color.
Owner: GtkTextTag
Flags: Read / Write
Default value: FALSE
### The `“overline-set”` property
```
“overline-set” gboolean
```
Whether this tag affects overlining.
Owner: GtkTextTag
Flags: Read / Write
Default value: FALSE
### The `“paragraph-background”` property
```
“paragraph-background” char *
```
The paragraph background color as a string.
Owner: GtkTextTag
Flags: Write
Default value: NULL
### The `“paragraph-background-rgba”` property
```
“paragraph-background-rgba” [GdkRGBA](https://developer-old.gnome.org/gtk4/html/gdk4-RGBA-Colors.html#GdkRGBA-struct) *
```
The paragraph background color as a [GdkRGBA](https://developer-old.gnome.org/gtk4/html/gdk4-RGBA-Colors.html#GdkRGBA-struct).
Owner: GtkTextTag
Flags: Read / Write
### The `“paragraph-background-set”` property
```
“paragraph-background-set” gboolean
```
Whether this tag affects the paragraph background color.
Owner: GtkTextTag
Flags: Read / Write
Default value: FALSE
### The `“pixels-above-lines”` property
```
“pixels-above-lines” int
```
Pixels of blank space above paragraphs.
Owner: GtkTextTag
Flags: Read / Write
Allowed values: >= 0
Default value: 0
### The `“pixels-above-lines-set”` property
```
“pixels-above-lines-set” gboolean
```
Whether this tag affects the number of pixels above lines.
Owner: GtkTextTag
Flags: Read / Write
Default value: FALSE
### The `“pixels-below-lines”` property
```
“pixels-below-lines” int
```
Pixels of blank space below paragraphs.
Owner: GtkTextTag
Flags: Read / Write
Allowed values: >= 0
Default value: 0
### The `“pixels-below-lines-set”` property
```
“pixels-below-lines-set” gboolean
```
Whether this tag affects the number of pixels above lines.
Owner: GtkTextTag
Flags: Read / Write
Default value: FALSE
### The `“pixels-inside-wrap”` property
```
“pixels-inside-wrap” int
```
Pixels of blank space between wrapped lines in a paragraph.
Owner: GtkTextTag
Flags: Read / Write
Allowed values: >= 0
Default value: 0
### The `“pixels-inside-wrap-set”` property
```
“pixels-inside-wrap-set” gboolean
```
Whether this tag affects the number of pixels between wrapped lines.
Owner: GtkTextTag
Flags: Read / Write
Default value: FALSE
### The `“right-margin”` property
```
“right-margin” int
```
Width of the right margin in pixels.
Owner: GtkTextTag
Flags: Read / Write
Allowed values: >= 0
Default value: 0
### The `“right-margin-set”` property
```
“right-margin-set” gboolean
```
Whether this tag affects the right margin.
Owner: GtkTextTag
Flags: Read / Write
Default value: FALSE
### The `“rise”` property
```
“rise” int
```
Offset of text above the baseline (below the baseline if rise is negative) in Pango units.
Owner: GtkTextTag
Flags: Read / Write
Default value: 0
### The `“rise-set”` property
```
“rise-set” gboolean
```
Whether this tag affects the rise.
Owner: GtkTextTag
Flags: Read / Write
Default value: FALSE
### The `“scale”` property
```
“scale” double
```
Font size as a scale factor relative to the default font size. This properly adapts to theme changes etc. so is recommended. Pango predefines some scales such as PANGO\_SCALE\_X\_LARGE.
Owner: GtkTextTag
Flags: Read / Write
Allowed values: >= 0
Default value: 1
### The `“scale-set”` property
```
“scale-set” gboolean
```
Whether this tag scales the font size by a factor.
Owner: GtkTextTag
Flags: Read / Write
Default value: FALSE
### The `“show-spaces”` property
```
“show-spaces” [PangoShowFlags](https://developer-old.gnome.org/pango/stable/pango-Text-Attributes.html#PangoShowFlags)
```
How to render invisible characters.
Owner: GtkTextTag
Flags: Read / Write
### The `“show-spaces-set”` property
```
“show-spaces-set” gboolean
```
Whether this tag affects rendering of invisible characters.
Owner: GtkTextTag
Flags: Read / Write
Default value: FALSE
### The `“size”` property
```
“size” int
```
Font size in Pango units.
Owner: GtkTextTag
Flags: Read / Write
Allowed values: >= 0
Default value: 0
### The `“size-points”` property
```
“size-points” double
```
Font size in points.
Owner: GtkTextTag
Flags: Read / Write
Allowed values: >= 0
Default value: 0
### The `“size-set”` property
```
“size-set” gboolean
```
Whether this tag affects the font size.
Owner: GtkTextTag
Flags: Read / Write
Default value: FALSE
### The `“stretch”` property
```
“stretch” [PangoStretch](https://developer-old.gnome.org/pango/stable/pango-Fonts.html#PangoStretch)
```
Font stretch as a PangoStretch, e.g. PANGO\_STRETCH\_CONDENSED.
Owner: GtkTextTag
Flags: Read / Write
Default value: PANGO\_STRETCH\_NORMAL
### The `“stretch-set”` property
```
“stretch-set” gboolean
```
Whether this tag affects the font stretch.
Owner: GtkTextTag
Flags: Read / Write
Default value: FALSE
### The `“strikethrough”` property
```
“strikethrough” gboolean
```
Whether to strike through the text.
Owner: GtkTextTag
Flags: Read / Write
Default value: FALSE
### The `“strikethrough-rgba”` property
```
“strikethrough-rgba” [GdkRGBA](https://developer-old.gnome.org/gtk4/html/gdk4-RGBA-Colors.html#GdkRGBA-struct) *
```
This property modifies the color of strikeouts. If not set, strikeouts will use the foreground color.
Owner: GtkTextTag
Flags: Read / Write
### The `“strikethrough-rgba-set”` property
```
“strikethrough-rgba-set” gboolean
```
If the [“strikethrough-rgba”](gtktexttag#GtkTextTag--strikethrough-rgba) property has been set.
Owner: GtkTextTag
Flags: Read / Write
Default value: FALSE
### The `“strikethrough-set”` property
```
“strikethrough-set” gboolean
```
Whether this tag affects strikethrough.
Owner: GtkTextTag
Flags: Read / Write
Default value: FALSE
### The `“style”` property
```
“style” [PangoStyle](https://developer-old.gnome.org/pango/stable/pango-Fonts.html#PangoStyle)
```
Font style as a PangoStyle, e.g. PANGO\_STYLE\_ITALIC.
Owner: GtkTextTag
Flags: Read / Write
Default value: PANGO\_STYLE\_NORMAL
### The `“style-set”` property
```
“style-set” gboolean
```
Whether this tag affects the font style.
Owner: GtkTextTag
Flags: Read / Write
Default value: FALSE
### The `“tabs”` property
```
“tabs” [PangoTabArray](https://developer-old.gnome.org/pango/stable/pango-Tab-Stops.html#PangoTabArray-struct) *
```
Custom tabs for this text.
Owner: GtkTextTag
Flags: Read / Write
### The `“tabs-set”` property
```
“tabs-set” gboolean
```
Whether this tag affects tabs.
Owner: GtkTextTag
Flags: Read / Write
Default value: FALSE
### The `“underline”` property
```
“underline” [PangoUnderline](https://developer-old.gnome.org/pango/stable/pango-Text-Attributes.html#PangoUnderline)
```
Style of underline for this text.
Owner: GtkTextTag
Flags: Read / Write
Default value: PANGO\_UNDERLINE\_NONE
### The `“underline-rgba”` property
```
“underline-rgba” [GdkRGBA](https://developer-old.gnome.org/gtk4/html/gdk4-RGBA-Colors.html#GdkRGBA-struct) *
```
This property modifies the color of underlines. If not set, underlines will use the foreground color.
If [“underline”](gtktexttag#GtkTextTag--underline) is set to [`PANGO_UNDERLINE_ERROR`](https://developer-old.gnome.org/pango/stable/pango-Text-Attributes.html#PANGO-UNDERLINE-ERROR:CAPS), an alternate color may be applied instead of the foreground. Setting this property will always override those defaults.
Owner: GtkTextTag
Flags: Read / Write
### The `“underline-rgba-set”` property
```
“underline-rgba-set” gboolean
```
If the [“underline-rgba”](gtktexttag#GtkTextTag--underline-rgba) property has been set.
Owner: GtkTextTag
Flags: Read / Write
Default value: FALSE
### The `“underline-set”` property
```
“underline-set” gboolean
```
Whether this tag affects underlining.
Owner: GtkTextTag
Flags: Read / Write
Default value: FALSE
### The `“variant”` property
```
“variant” [PangoVariant](https://developer-old.gnome.org/pango/stable/pango-Fonts.html#PangoVariant)
```
Font variant as a PangoVariant, e.g. PANGO\_VARIANT\_SMALL\_CAPS.
Owner: GtkTextTag
Flags: Read / Write
Default value: PANGO\_VARIANT\_NORMAL
### The `“variant-set”` property
```
“variant-set” gboolean
```
Whether this tag affects the font variant.
Owner: GtkTextTag
Flags: Read / Write
Default value: FALSE
### The `“weight”` property
```
“weight” int
```
Font weight as an integer, see predefined values in PangoWeight; for example, PANGO\_WEIGHT\_BOLD.
Owner: GtkTextTag
Flags: Read / Write
Allowed values: >= 0
Default value: 400
### The `“weight-set”` property
```
“weight-set” gboolean
```
Whether this tag affects the font weight.
Owner: GtkTextTag
Flags: Read / Write
Default value: FALSE
### The `“wrap-mode”` property
```
“wrap-mode” [GtkWrapMode](gtktextview#GtkWrapMode)
```
Whether to wrap lines never, at word boundaries, or at character boundaries.
Owner: GtkTextTag
Flags: Read / Write
Default value: GTK\_WRAP\_NONE
### The `“wrap-mode-set”` property
```
“wrap-mode-set” gboolean
```
Whether this tag affects line wrap mode.
Owner: GtkTextTag
Flags: Read / Write
Default value: FALSE
| programming_docs |
gtk GtkComboBox GtkComboBox
===========
GtkComboBox — A widget used to choose from a list of items
Functions
---------
| | |
| --- | --- |
| [GtkWidget](gtkwidget#GtkWidget-struct) \* | [gtk\_combo\_box\_new](gtkcombobox#gtk-combo-box-new) () |
| [GtkWidget](gtkwidget#GtkWidget-struct) \* | [gtk\_combo\_box\_new\_with\_entry](gtkcombobox#gtk-combo-box-new-with-entry) () |
| [GtkWidget](gtkwidget#GtkWidget-struct) \* | [gtk\_combo\_box\_new\_with\_model](gtkcombobox#gtk-combo-box-new-with-model) () |
| [GtkWidget](gtkwidget#GtkWidget-struct) \* | [gtk\_combo\_box\_new\_with\_model\_and\_entry](gtkcombobox#gtk-combo-box-new-with-model-and-entry) () |
| int | [gtk\_combo\_box\_get\_active](gtkcombobox#gtk-combo-box-get-active) () |
| void | [gtk\_combo\_box\_set\_active](gtkcombobox#gtk-combo-box-set-active) () |
| gboolean | [gtk\_combo\_box\_get\_active\_iter](gtkcombobox#gtk-combo-box-get-active-iter) () |
| void | [gtk\_combo\_box\_set\_active\_iter](gtkcombobox#gtk-combo-box-set-active-iter) () |
| int | [gtk\_combo\_box\_get\_id\_column](gtkcombobox#gtk-combo-box-get-id-column) () |
| void | [gtk\_combo\_box\_set\_id\_column](gtkcombobox#gtk-combo-box-set-id-column) () |
| const char \* | [gtk\_combo\_box\_get\_active\_id](gtkcombobox#gtk-combo-box-get-active-id) () |
| gboolean | [gtk\_combo\_box\_set\_active\_id](gtkcombobox#gtk-combo-box-set-active-id) () |
| [GtkTreeModel](gtktreemodel#GtkTreeModel-struct) \* | [gtk\_combo\_box\_get\_model](gtkcombobox#gtk-combo-box-get-model) () |
| void | [gtk\_combo\_box\_set\_model](gtkcombobox#gtk-combo-box-set-model) () |
| void | [gtk\_combo\_box\_popup](gtkcombobox#gtk-combo-box-popup) () |
| void | [gtk\_combo\_box\_popup\_for\_device](gtkcombobox#gtk-combo-box-popup-for-device) () |
| void | [gtk\_combo\_box\_popdown](gtkcombobox#gtk-combo-box-popdown) () |
| [GtkTreeViewRowSeparatorFunc](gtktreeview#GtkTreeViewRowSeparatorFunc) | [gtk\_combo\_box\_get\_row\_separator\_func](gtkcombobox#gtk-combo-box-get-row-separator-func) () |
| void | [gtk\_combo\_box\_set\_row\_separator\_func](gtkcombobox#gtk-combo-box-set-row-separator-func) () |
| void | [gtk\_combo\_box\_set\_button\_sensitivity](gtkcombobox#gtk-combo-box-set-button-sensitivity) () |
| [GtkSensitivityType](gtkcombobox#GtkSensitivityType) | [gtk\_combo\_box\_get\_button\_sensitivity](gtkcombobox#gtk-combo-box-get-button-sensitivity) () |
| gboolean | [gtk\_combo\_box\_get\_has\_entry](gtkcombobox#gtk-combo-box-get-has-entry) () |
| void | [gtk\_combo\_box\_set\_entry\_text\_column](gtkcombobox#gtk-combo-box-set-entry-text-column) () |
| int | [gtk\_combo\_box\_get\_entry\_text\_column](gtkcombobox#gtk-combo-box-get-entry-text-column) () |
| void | [gtk\_combo\_box\_set\_popup\_fixed\_width](gtkcombobox#gtk-combo-box-set-popup-fixed-width) () |
| gboolean | [gtk\_combo\_box\_get\_popup\_fixed\_width](gtkcombobox#gtk-combo-box-get-popup-fixed-width) () |
| void | [gtk\_combo\_box\_set\_child](gtkcombobox#gtk-combo-box-set-child) () |
| [GtkWidget](gtkwidget#GtkWidget-struct) \* | [gtk\_combo\_box\_get\_child](gtkcombobox#gtk-combo-box-get-child) () |
Properties
----------
| | | |
| --- | --- | --- |
| int | [active](gtkcombobox#GtkComboBox--active) | Read / Write |
| char \* | [active-id](gtkcombobox#GtkComboBox--active-id) | Read / Write |
| [GtkSensitivityType](gtkcombobox#GtkSensitivityType) | [button-sensitivity](gtkcombobox#GtkComboBox--button-sensitivity) | Read / Write |
| [GtkWidget](gtkwidget#GtkWidget-struct) \* | [child](gtkcombobox#GtkComboBox--child) | Read / Write |
| int | [entry-text-column](gtkcombobox#GtkComboBox--entry-text-column) | Read / Write |
| gboolean | [has-entry](gtkcombobox#GtkComboBox--has-entry) | Read / Write / Construct Only |
| gboolean | [has-frame](gtkcombobox#GtkComboBox--has-frame) | Read / Write |
| int | [id-column](gtkcombobox#GtkComboBox--id-column) | Read / Write |
| [GtkTreeModel](gtktreemodel#GtkTreeModel-struct) \* | [model](gtkcombobox#GtkComboBox--model) | Read / Write |
| gboolean | [popup-fixed-width](gtkcombobox#GtkComboBox--popup-fixed-width) | Read / Write |
| gboolean | [popup-shown](gtkcombobox#GtkComboBox--popup-shown) | Read |
Signals
-------
| | | |
| --- | --- | --- |
| void | [changed](gtkcombobox#GtkComboBox-changed) | Run Last |
| char\* | [format-entry-text](gtkcombobox#GtkComboBox-format-entry-text) | Run Last |
| void | [move-active](gtkcombobox#GtkComboBox-move-active) | Action |
| gboolean | [popdown](gtkcombobox#GtkComboBox-popdown) | Action |
| void | [popup](gtkcombobox#GtkComboBox-popup) | Action |
Types and Values
----------------
| | |
| --- | --- |
| struct | [GtkComboBox](gtkcombobox#GtkComboBox-struct) |
| struct | [GtkComboBoxClass](gtkcombobox#GtkComboBoxClass) |
| enum | [GtkSensitivityType](gtkcombobox#GtkSensitivityType) |
Object Hierarchy
----------------
```
GObject
╰── GInitiallyUnowned
╰── [GtkWidget](gtkwidget#GtkWidget-struct)
╰── GtkComboBox
╰── [GtkComboBoxText](gtkcomboboxtext#GtkComboBoxText-struct)
```
Implemented Interfaces
----------------------
GtkComboBox implements [GtkAccessible](gtkaccessible#GtkAccessible-struct), [GtkBuildable](gtkbuildable#GtkBuildable-struct), [GtkConstraintTarget](gtkconstraint#GtkConstraintTarget-struct), [GtkCellLayout](gtkcelllayout#GtkCellLayout-struct) and [GtkCellEditable](gtkcelleditable#GtkCellEditable-struct).
Includes
--------
```
#include <gtk/gtk.h>
```
Description
-----------
A GtkComboBox is a widget that allows the user to choose from a list of valid choices. The GtkComboBox displays the selected choice. When activated, the GtkComboBox displays a popup which allows the user to make a new choice. The style in which the selected value is displayed, and the style of the popup is determined by the current theme. It may be similar to a Windows-style combo box.
The GtkComboBox uses the model-view pattern; the list of valid choices is specified in the form of a tree model, and the display of the choices can be adapted to the data in the model by using cell renderers, as you would in a tree view. This is possible since GtkComboBox implements the [GtkCellLayout](gtkcelllayout#GtkCellLayout-struct) interface. The tree model holding the valid choices is not restricted to a flat list, it can be a real tree, and the popup will reflect the tree structure.
To allow the user to enter values not in the model, the “has-entry” property allows the GtkComboBox to contain a [GtkEntry](gtkentry#GtkEntry-struct). This entry can be accessed by calling [`gtk_combo_box_get_child()`](gtkcombobox#gtk-combo-box-get-child) on the combo box.
For a simple list of textual choices, the model-view API of GtkComboBox can be a bit overwhelming. In this case, [GtkComboBoxText](gtkcomboboxtext#GtkComboBoxText-struct) offers a simple alternative. Both GtkComboBox and [GtkComboBoxText](gtkcomboboxtext#GtkComboBoxText-struct) can contain an entry.
### CSS nodes
A normal combobox contains a box with the .linked class, a button with the .combo class and inside those buttons, there are a cellview and an arrow.
A GtkComboBox with an entry has a single CSS node with name combobox. It contains a box with the .linked class. That box contains an entry and a button, both with the .combo class added. The button also contains another node with name arrow.
### Accessibility
GtkComboBox uses the [GTK\_ACCESSIBLE\_ROLE\_COMBO\_BOX](gtkaccessible#GTK-ACCESSIBLE-ROLE-COMBO-BOX:CAPS) role.
Functions
---------
### gtk\_combo\_box\_new ()
```
[GtkWidget](gtkwidget#GtkWidget-struct) *
gtk_combo_box_new (*`void`*);
```
Creates a new empty [GtkComboBox](gtkcombobox#GtkComboBox-struct).
#### Returns
A new [GtkComboBox](gtkcombobox#GtkComboBox-struct).
### gtk\_combo\_box\_new\_with\_entry ()
```
[GtkWidget](gtkwidget#GtkWidget-struct) *
gtk_combo_box_new_with_entry (*`void`*);
```
Creates a new empty [GtkComboBox](gtkcombobox#GtkComboBox-struct) with an entry.
#### Returns
A new [GtkComboBox](gtkcombobox#GtkComboBox-struct).
### gtk\_combo\_box\_new\_with\_model ()
```
[GtkWidget](gtkwidget#GtkWidget-struct) *
gtk_combo_box_new_with_model (*`[GtkTreeModel](gtktreemodel#GtkTreeModel-struct) *model`*);
```
Creates a new [GtkComboBox](gtkcombobox#GtkComboBox-struct) with the model initialized to *`model`* .
#### Parameters
| | | |
| --- | --- | --- |
| model | A [GtkTreeModel](gtktreemodel#GtkTreeModel-struct). | |
#### Returns
A new [GtkComboBox](gtkcombobox#GtkComboBox-struct).
### gtk\_combo\_box\_new\_with\_model\_and\_entry ()
```
[GtkWidget](gtkwidget#GtkWidget-struct) *
gtk_combo_box_new_with_model_and_entry
(*`[GtkTreeModel](gtktreemodel#GtkTreeModel-struct) *model`*);
```
Creates a new empty [GtkComboBox](gtkcombobox#GtkComboBox-struct) with an entry and with the model initialized to *`model`* .
#### Parameters
| | | |
| --- | --- | --- |
| model | A [GtkTreeModel](gtktreemodel#GtkTreeModel-struct) | |
#### Returns
A new [GtkComboBox](gtkcombobox#GtkComboBox-struct)
### gtk\_combo\_box\_get\_active ()
```
int
gtk_combo_box_get_active (*`[GtkComboBox](gtkcombobox#GtkComboBox-struct) *combo_box`*);
```
Returns the index of the currently active item, or -1 if there’s no active item. If the model is a non-flat treemodel, and the active item is not an immediate child of the root of the tree, this function returns `gtk_tree_path_get_indices (path)[0]`, where `path` is the [GtkTreePath](gtktreemodel#GtkTreePath-struct) of the active item.
#### Parameters
| | | |
| --- | --- | --- |
| combo\_box | A [GtkComboBox](gtkcombobox#GtkComboBox-struct) | |
#### Returns
An integer which is the index of the currently active item, or -1 if there’s no active item.
### gtk\_combo\_box\_set\_active ()
```
void
gtk_combo_box_set_active (*`[GtkComboBox](gtkcombobox#GtkComboBox-struct) *combo_box`*,
*`int index_`*);
```
Sets the active item of *`combo_box`* to be the item at *`index`* .
#### Parameters
| | | |
| --- | --- | --- |
| combo\_box | A [GtkComboBox](gtkcombobox#GtkComboBox-struct) | |
| index\_ | An index in the model passed during construction, or -1 to have no active item | |
### gtk\_combo\_box\_get\_active\_iter ()
```
gboolean
gtk_combo_box_get_active_iter (*`[GtkComboBox](gtkcombobox#GtkComboBox-struct) *combo_box`*,
*`[GtkTreeIter](gtktreemodel#GtkTreeIter-struct) *iter`*);
```
Sets *`iter`* to point to the currently active item, if any item is active. Otherwise, *`iter`* is left unchanged.
#### Parameters
| | | |
| --- | --- | --- |
| combo\_box | A [GtkComboBox](gtkcombobox#GtkComboBox-struct) | |
| iter | A [GtkTreeIter](gtktreemodel#GtkTreeIter-struct). | [out] |
#### Returns
`TRUE` if *`iter`* was set, `FALSE` otherwise
### gtk\_combo\_box\_set\_active\_iter ()
```
void
gtk_combo_box_set_active_iter (*`[GtkComboBox](gtkcombobox#GtkComboBox-struct) *combo_box`*,
*`[GtkTreeIter](gtktreemodel#GtkTreeIter-struct) *iter`*);
```
Sets the current active item to be the one referenced by *`iter`* , or unsets the active item if *`iter`* is `NULL`.
#### Parameters
| | | |
| --- | --- | --- |
| combo\_box | A [GtkComboBox](gtkcombobox#GtkComboBox-struct) | |
| iter | The [GtkTreeIter](gtktreemodel#GtkTreeIter-struct), or `NULL`. | [allow-none] |
### gtk\_combo\_box\_get\_id\_column ()
```
int
gtk_combo_box_get_id_column (*`[GtkComboBox](gtkcombobox#GtkComboBox-struct) *combo_box`*);
```
Returns the column which *`combo_box`* is using to get string IDs for values from.
#### Parameters
| | | |
| --- | --- | --- |
| combo\_box | A [GtkComboBox](gtkcombobox#GtkComboBox-struct) | |
#### Returns
A column in the data source model of *`combo_box`* .
### gtk\_combo\_box\_set\_id\_column ()
```
void
gtk_combo_box_set_id_column (*`[GtkComboBox](gtkcombobox#GtkComboBox-struct) *combo_box`*,
*`int id_column`*);
```
Sets the model column which *`combo_box`* should use to get string IDs for values from. The column *`id_column`* in the model of *`combo_box`* must be of type `G_TYPE_STRING`.
#### Parameters
| | | |
| --- | --- | --- |
| combo\_box | A [GtkComboBox](gtkcombobox#GtkComboBox-struct) | |
| id\_column | A column in *`model`* to get string IDs for values from | |
### gtk\_combo\_box\_get\_active\_id ()
```
const char *
gtk_combo_box_get_active_id (*`[GtkComboBox](gtkcombobox#GtkComboBox-struct) *combo_box`*);
```
Returns the ID of the active row of *`combo_box`* . This value is taken from the active row and the column specified by the [“id-column”](gtkcombobox#GtkComboBox--id-column) property of *`combo_box`* (see [`gtk_combo_box_set_id_column()`](gtkcombobox#gtk-combo-box-set-id-column)).
The returned value is an interned string which means that you can compare the pointer by value to other interned strings and that you must not free it.
If the [“id-column”](gtkcombobox#GtkComboBox--id-column) property of *`combo_box`* is not set, or if no row is active, or if the active row has a `NULL` ID value, then `NULL` is returned.
#### Parameters
| | | |
| --- | --- | --- |
| combo\_box | a [GtkComboBox](gtkcombobox#GtkComboBox-struct) | |
#### Returns
the ID of the active row, or `NULL`.
[nullable]
### gtk\_combo\_box\_set\_active\_id ()
```
gboolean
gtk_combo_box_set_active_id (*`[GtkComboBox](gtkcombobox#GtkComboBox-struct) *combo_box`*,
*`const char *active_id`*);
```
Changes the active row of *`combo_box`* to the one that has an ID equal to *`active_id`* , or unsets the active row if *`active_id`* is `NULL`. Rows having a `NULL` ID string cannot be made active by this function.
If the [“id-column”](gtkcombobox#GtkComboBox--id-column) property of *`combo_box`* is unset or if no row has the given ID then the function does nothing and returns `FALSE`.
#### Parameters
| | | |
| --- | --- | --- |
| combo\_box | a [GtkComboBox](gtkcombobox#GtkComboBox-struct) | |
| active\_id | the ID of the row to select, or `NULL`. | [allow-none] |
#### Returns
`TRUE` if a row with a matching ID was found. If a `NULL` *`active_id`* was given to unset the active row, the function always returns `TRUE`.
### gtk\_combo\_box\_get\_model ()
```
[GtkTreeModel](gtktreemodel#GtkTreeModel-struct) *
gtk_combo_box_get_model (*`[GtkComboBox](gtkcombobox#GtkComboBox-struct) *combo_box`*);
```
Returns the [GtkTreeModel](gtktreemodel#GtkTreeModel-struct) which is acting as data source for *`combo_box`* .
#### Parameters
| | | |
| --- | --- | --- |
| combo\_box | A [GtkComboBox](gtkcombobox#GtkComboBox-struct) | |
#### Returns
A [GtkTreeModel](gtktreemodel#GtkTreeModel-struct) which was passed during construction.
[nullable][transfer none]
### gtk\_combo\_box\_set\_model ()
```
void
gtk_combo_box_set_model (*`[GtkComboBox](gtkcombobox#GtkComboBox-struct) *combo_box`*,
*`[GtkTreeModel](gtktreemodel#GtkTreeModel-struct) *model`*);
```
Sets the model used by *`combo_box`* to be *`model`* . Will unset a previously set model (if applicable). If model is `NULL`, then it will unset the model.
Note that this function does not clear the cell renderers, you have to call [`gtk_cell_layout_clear()`](gtkcelllayout#gtk-cell-layout-clear) yourself if you need to set up different cell renderers for the new model.
#### Parameters
| | | |
| --- | --- | --- |
| combo\_box | A [GtkComboBox](gtkcombobox#GtkComboBox-struct) | |
| model | A [GtkTreeModel](gtktreemodel#GtkTreeModel-struct). | [allow-none] |
### gtk\_combo\_box\_popup ()
```
void
gtk_combo_box_popup (*`[GtkComboBox](gtkcombobox#GtkComboBox-struct) *combo_box`*);
```
Pops up the menu or dropdown list of *`combo_box`* .
This function is mostly intended for use by accessibility technologies; applications should have little use for it.
Before calling this, *`combo_box`* must be mapped, or nothing will happen.
#### Parameters
| | | |
| --- | --- | --- |
| combo\_box | a [GtkComboBox](gtkcombobox#GtkComboBox-struct) | |
### gtk\_combo\_box\_popup\_for\_device ()
```
void
gtk_combo_box_popup_for_device (*`[GtkComboBox](gtkcombobox#GtkComboBox-struct) *combo_box`*,
*`[GdkDevice](https://developer-old.gnome.org/gtk4/html/GdkDevice.html#GdkDevice-struct) *device`*);
```
Pops up the menu of *`combo_box`* . Note that currently this does not do anything with the device, as it was previously only used for list-mode combo boxes, and those were removed in GTK 4. However, it is retained in case similar functionality is added back later.
#### Parameters
| | | |
| --- | --- | --- |
| combo\_box | a [GtkComboBox](gtkcombobox#GtkComboBox-struct) | |
| device | a [GdkDevice](https://developer-old.gnome.org/gtk4/html/GdkDevice.html#GdkDevice-struct) | |
### gtk\_combo\_box\_popdown ()
```
void
gtk_combo_box_popdown (*`[GtkComboBox](gtkcombobox#GtkComboBox-struct) *combo_box`*);
```
Hides the menu or dropdown list of *`combo_box`* .
This function is mostly intended for use by accessibility technologies; applications should have little use for it.
#### Parameters
| | | |
| --- | --- | --- |
| combo\_box | a [GtkComboBox](gtkcombobox#GtkComboBox-struct) | |
### gtk\_combo\_box\_get\_row\_separator\_func ()
```
[GtkTreeViewRowSeparatorFunc](gtktreeview#GtkTreeViewRowSeparatorFunc)
gtk_combo_box_get_row_separator_func (*`[GtkComboBox](gtkcombobox#GtkComboBox-struct) *combo_box`*);
```
Returns the current row separator function.
[skip]
#### Parameters
| | | |
| --- | --- | --- |
| combo\_box | a [GtkComboBox](gtkcombobox#GtkComboBox-struct) | |
#### Returns
the current row separator function.
[nullable]
### gtk\_combo\_box\_set\_row\_separator\_func ()
```
void
gtk_combo_box_set_row_separator_func (*`[GtkComboBox](gtkcombobox#GtkComboBox-struct) *combo_box`*,
*`[GtkTreeViewRowSeparatorFunc](gtktreeview#GtkTreeViewRowSeparatorFunc) func`*,
*`gpointer data`*,
*`GDestroyNotify destroy`*);
```
Sets the row separator function, which is used to determine whether a row should be drawn as a separator. If the row separator function is `NULL`, no separators are drawn. This is the default value.
#### Parameters
| | | |
| --- | --- | --- |
| combo\_box | a [GtkComboBox](gtkcombobox#GtkComboBox-struct) | |
| func | a [GtkTreeViewRowSeparatorFunc](gtktreeview#GtkTreeViewRowSeparatorFunc). | [nullable] |
| data | user data to pass to *`func`* , or `NULL`. | [allow-none] |
| destroy | destroy notifier for *`data`* , or `NULL`. | [allow-none] |
### gtk\_combo\_box\_set\_button\_sensitivity ()
```
void
gtk_combo_box_set_button_sensitivity (*`[GtkComboBox](gtkcombobox#GtkComboBox-struct) *combo_box`*,
*`[GtkSensitivityType](gtkcombobox#GtkSensitivityType) sensitivity`*);
```
Sets whether the dropdown button of the combo box should be always sensitive ([`GTK_SENSITIVITY_ON`](gtkcombobox#GTK-SENSITIVITY-ON:CAPS)), never sensitive ([`GTK_SENSITIVITY_OFF`](gtkcombobox#GTK-SENSITIVITY-OFF:CAPS)) or only if there is at least one item to display ([`GTK_SENSITIVITY_AUTO`](gtkcombobox#GTK-SENSITIVITY-AUTO:CAPS)).
#### Parameters
| | | |
| --- | --- | --- |
| combo\_box | a [GtkComboBox](gtkcombobox#GtkComboBox-struct) | |
| sensitivity | specify the sensitivity of the dropdown button | |
### gtk\_combo\_box\_get\_button\_sensitivity ()
```
[GtkSensitivityType](gtkcombobox#GtkSensitivityType)
gtk_combo_box_get_button_sensitivity (*`[GtkComboBox](gtkcombobox#GtkComboBox-struct) *combo_box`*);
```
Returns whether the combo box sets the dropdown button sensitive or not when there are no items in the model.
#### Parameters
| | | |
| --- | --- | --- |
| combo\_box | a [GtkComboBox](gtkcombobox#GtkComboBox-struct) | |
#### Returns
[`GTK_SENSITIVITY_ON`](gtkcombobox#GTK-SENSITIVITY-ON:CAPS) if the dropdown button is sensitive when the model is empty, [`GTK_SENSITIVITY_OFF`](gtkcombobox#GTK-SENSITIVITY-OFF:CAPS) if the button is always insensitive or [`GTK_SENSITIVITY_AUTO`](gtkcombobox#GTK-SENSITIVITY-AUTO:CAPS) if it is only sensitive as long as the model has one item to be selected.
### gtk\_combo\_box\_get\_has\_entry ()
```
gboolean
gtk_combo_box_get_has_entry (*`[GtkComboBox](gtkcombobox#GtkComboBox-struct) *combo_box`*);
```
Returns whether the combo box has an entry.
#### Parameters
| | | |
| --- | --- | --- |
| combo\_box | a [GtkComboBox](gtkcombobox#GtkComboBox-struct) | |
#### Returns
whether there is an entry in *`combo_box`* .
### gtk\_combo\_box\_set\_entry\_text\_column ()
```
void
gtk_combo_box_set_entry_text_column (*`[GtkComboBox](gtkcombobox#GtkComboBox-struct) *combo_box`*,
*`int text_column`*);
```
Sets the model column which *`combo_box`* should use to get strings from to be *`text_column`* . The column *`text_column`* in the model of *`combo_box`* must be of type `G_TYPE_STRING`.
This is only relevant if *`combo_box`* has been created with [“has-entry”](gtkcombobox#GtkComboBox--has-entry) as `TRUE`.
#### Parameters
| | | |
| --- | --- | --- |
| combo\_box | A [GtkComboBox](gtkcombobox#GtkComboBox-struct) | |
| text\_column | A column in *`model`* to get the strings from for the internal entry | |
### gtk\_combo\_box\_get\_entry\_text\_column ()
```
int
gtk_combo_box_get_entry_text_column (*`[GtkComboBox](gtkcombobox#GtkComboBox-struct) *combo_box`*);
```
Returns the column which *`combo_box`* is using to get the strings from to display in the internal entry.
#### Parameters
| | | |
| --- | --- | --- |
| combo\_box | A [GtkComboBox](gtkcombobox#GtkComboBox-struct). | |
#### Returns
A column in the data source model of *`combo_box`* .
### gtk\_combo\_box\_set\_popup\_fixed\_width ()
```
void
gtk_combo_box_set_popup_fixed_width (*`[GtkComboBox](gtkcombobox#GtkComboBox-struct) *combo_box`*,
*`gboolean fixed`*);
```
Specifies whether the popup’s width should be a fixed width matching the allocated width of the combo box.
#### Parameters
| | | |
| --- | --- | --- |
| combo\_box | a [GtkComboBox](gtkcombobox#GtkComboBox-struct) | |
| fixed | whether to use a fixed popup width | |
### gtk\_combo\_box\_get\_popup\_fixed\_width ()
```
gboolean
gtk_combo_box_get_popup_fixed_width (*`[GtkComboBox](gtkcombobox#GtkComboBox-struct) *combo_box`*);
```
Gets whether the popup uses a fixed width matching the allocated width of the combo box.
#### Parameters
| | | |
| --- | --- | --- |
| combo\_box | a [GtkComboBox](gtkcombobox#GtkComboBox-struct) | |
#### Returns
`TRUE` if the popup uses a fixed width
### gtk\_combo\_box\_set\_child ()
```
void
gtk_combo_box_set_child (*`[GtkComboBox](gtkcombobox#GtkComboBox-struct) *combo_box`*,
*`[GtkWidget](gtkwidget#GtkWidget-struct) *child`*);
```
Sets the child widget of *`combo_box`* .
#### Parameters
| | | |
| --- | --- | --- |
| combo\_box | a [GtkComboBox](gtkcombobox#GtkComboBox-struct) | |
| child | the child widget. | [allow-none] |
### gtk\_combo\_box\_get\_child ()
```
[GtkWidget](gtkwidget#GtkWidget-struct) *
gtk_combo_box_get_child (*`[GtkComboBox](gtkcombobox#GtkComboBox-struct) *combo_box`*);
```
Gets the child widget of *`combo_box`* .
#### Parameters
| | | |
| --- | --- | --- |
| combo\_box | a [GtkComboBox](gtkcombobox#GtkComboBox-struct) | |
#### Returns
the child widget of *`combo_box`* .
[nullable][transfer none]
Types and Values
----------------
### struct GtkComboBox
```
struct GtkComboBox;
```
### struct GtkComboBoxClass
```
struct GtkComboBoxClass {
GtkWidgetClass parent_class;
/* signals */
void (* changed) (GtkComboBox *combo_box);
char *(* format_entry_text) (GtkComboBox *combo_box,
const char *path);
};
```
#### Members
| | | |
| --- | --- | --- |
| *`changed`* () | Signal is emitted when the active item is changed. | |
| *`format_entry_text`* () | Signal which allows you to change how the text displayed in a combo box’s entry is displayed. | |
### enum GtkSensitivityType
Determines how GTK handles the sensitivity of various controls, such as combo box buttons.
#### Members
| | | |
| --- | --- | --- |
| GTK\_SENSITIVITY\_AUTO | The control is made insensitive if no action can be triggered | |
| GTK\_SENSITIVITY\_ON | The control is always sensitive | |
| GTK\_SENSITIVITY\_OFF | The control is always insensitive | |
Property Details
----------------
### The `“active”` property
```
“active” int
```
The item which is currently active. If the model is a non-flat treemodel, and the active item is not an immediate child of the root of the tree, this property has the value `gtk_tree_path_get_indices (path)[0]`, where `path` is the [GtkTreePath](gtktreemodel#GtkTreePath-struct) of the active item.
Owner: GtkComboBox
Flags: Read / Write
Allowed values: >= -1
Default value: -1
### The `“active-id”` property
```
“active-id” char *
```
The value of the ID column of the active row.
Owner: GtkComboBox
Flags: Read / Write
Default value: NULL
### The `“button-sensitivity”` property
```
“button-sensitivity” [GtkSensitivityType](gtkcombobox#GtkSensitivityType)
```
Whether the dropdown button is sensitive when the model is empty.
Owner: GtkComboBox
Flags: Read / Write
Default value: GTK\_SENSITIVITY\_AUTO
### The `“child”` property
```
“child” [GtkWidget](gtkwidget#GtkWidget-struct) *
```
The child\_widget.
Owner: GtkComboBox
Flags: Read / Write
### The `“entry-text-column”` property
```
“entry-text-column” int
```
The column in the combo box's model to associate with strings from the entry if the combo was created with [“has-entry”](gtkcombobox#GtkComboBox--has-entry) = `TRUE`.
Owner: GtkComboBox
Flags: Read / Write
Allowed values: >= -1
Default value: -1
### The `“has-entry”` property
```
“has-entry” gboolean
```
Whether the combo box has an entry.
Owner: GtkComboBox
Flags: Read / Write / Construct Only
Default value: FALSE
### The `“has-frame”` property
```
“has-frame” gboolean
```
The has-frame property controls whether a frame is drawn around the entry.
Owner: GtkComboBox
Flags: Read / Write
Default value: TRUE
### The `“id-column”` property
```
“id-column” int
```
The column in the combo box's model that provides string IDs for the values in the model, if != -1.
Owner: GtkComboBox
Flags: Read / Write
Allowed values: >= -1
Default value: -1
### The `“model”` property
```
“model” [GtkTreeModel](gtktreemodel#GtkTreeModel-struct) *
```
The model from which the combo box takes the values shown in the list.
Owner: GtkComboBox
Flags: Read / Write
### The `“popup-fixed-width”` property
```
“popup-fixed-width” gboolean
```
Whether the popup's width should be a fixed width matching the allocated width of the combo box.
Owner: GtkComboBox
Flags: Read / Write
Default value: TRUE
### The `“popup-shown”` property
```
“popup-shown” gboolean
```
Whether the combo boxes dropdown is popped up. Note that this property is mainly useful, because it allows you to connect to notify::popup-shown.
Owner: GtkComboBox
Flags: Read
Default value: FALSE
Signal Details
--------------
### The `“changed”` signal
```
void
user_function ([GtkComboBox](gtkcombobox#GtkComboBox-struct) *widget,
gpointer user_data)
```
The changed signal is emitted when the active item is changed. The can be due to the user selecting a different item from the list, or due to a call to [`gtk_combo_box_set_active_iter()`](gtkcombobox#gtk-combo-box-set-active-iter). It will also be emitted while typing into the entry of a combo box with an entry.
#### Parameters
| | | |
| --- | --- | --- |
| widget | the object which received the signal | |
| user\_data | user data set when the signal handler was connected. | |
Flags: Run Last
### The `“format-entry-text”` signal
```
char*
user_function ([GtkComboBox](gtkcombobox#GtkComboBox-struct) *combo,
char *path,
gpointer user_data)
```
For combo boxes that are created with an entry (See GtkComboBox:has-entry).
A signal which allows you to change how the text displayed in a combo box's entry is displayed.
Connect a signal handler which returns an allocated string representing *`path`* . That string will then be used to set the text in the combo box's entry. The default signal handler uses the text from the GtkComboBox::entry-text-column model column.
Here's an example signal handler which fetches data from the model and displays it in the entry.
```
combobox
├── box.linked
│ ╰── button.combo
│ ╰── box
│ ├── cellview
│ ╰── arrow
╰── window.popup
```
| #### Parameters
| | | |
| --- | --- | --- |
| combo | the object which received the signal | |
| path | the GtkTreePath string from the combo box's current model to format text for | |
| user\_data | user data set when the signal handler was connected. | |
#### Returns
a newly allocated string representing *`path`* for the current GtkComboBox model.
[transfer full]
Flags: Run Last
### The `“move-active”` signal
```
void
user_function ([GtkComboBox](gtkcombobox#GtkComboBox-struct) *widget,
[GtkScrollType](gtk4-standard-enumerations#GtkScrollType) scroll_type,
gpointer user_data)
```
The ::move-active signal is a [keybinding signal](gtkshortcutaction#GtkSignalAction-struct) which gets emitted to move the active selection.
#### Parameters
| | | |
| --- | --- | --- |
| widget | the object that received the signal | |
| scroll\_type | a [GtkScrollType](gtk4-standard-enumerations#GtkScrollType) | |
| user\_data | user data set when the signal handler was connected. | |
Flags: Action
### The `“popdown”` signal
```
gboolean
user_function ([GtkComboBox](gtkcombobox#GtkComboBox-struct) *button,
gpointer user_data)
```
The ::popdown signal is a [keybinding signal](gtkshortcutaction#GtkSignalAction-struct) which gets emitted to popdown the combo box list.
The default bindings for this signal are Alt+Up and Escape.
#### Parameters
| | | |
| --- | --- | --- |
| button | the object which received the signal | |
| user\_data | user data set when the signal handler was connected. | |
Flags: Action
### The `“popup”` signal
```
void
user_function ([GtkComboBox](gtkcombobox#GtkComboBox-struct) *widget,
gpointer user_data)
```
The ::popup signal is a [keybinding signal](gtkshortcutaction#GtkSignalAction-struct) which gets emitted to popup the combo box list.
The default binding for this signal is Alt+Down.
#### Parameters
| | | |
| --- | --- | --- |
| widget | the object that received the signal | |
| user\_data | user data set when the signal handler was connected. | |
Flags: Action
See Also
--------
[GtkComboBoxText](gtkcomboboxtext#GtkComboBoxText-struct), [GtkTreeModel](gtktreemodel#GtkTreeModel-struct), [GtkCellRenderer](gtkcellrenderer#GtkCellRenderer-struct)
| programming_docs |
gtk GtkShortcutsWindow GtkShortcutsWindow
==================
GtkShortcutsWindow — Toplevel which shows help for shortcuts
Properties
----------
| | | |
| --- | --- | --- |
| char \* | [section-name](gtkshortcutswindow#GtkShortcutsWindow--section-name) | Read / Write |
| char \* | [view-name](gtkshortcutswindow#GtkShortcutsWindow--view-name) | Read / Write |
Signals
-------
| | | |
| --- | --- | --- |
| void | [close](gtkshortcutswindow#GtkShortcutsWindow-close) | Action |
| void | [search](gtkshortcutswindow#GtkShortcutsWindow-search) | Action |
Types and Values
----------------
| | |
| --- | --- |
| | [GtkShortcutsWindow](gtkshortcutswindow#GtkShortcutsWindow-struct) |
Object Hierarchy
----------------
```
GObject
╰── GInitiallyUnowned
╰── [GtkWidget](gtkwidget#GtkWidget-struct)
╰── [GtkWindow](gtkwindow#GtkWindow-struct)
╰── GtkShortcutsWindow
```
Implemented Interfaces
----------------------
GtkShortcutsWindow implements [GtkAccessible](gtkaccessible#GtkAccessible-struct), [GtkBuildable](gtkbuildable#GtkBuildable-struct), [GtkConstraintTarget](gtkconstraint#GtkConstraintTarget-struct), [GtkNative](gtknative#GtkNative-struct), [GtkShortcutManager](gtkshortcutmanager#GtkShortcutManager-struct) and [GtkRoot](gtkroot#GtkRoot-struct).
Includes
--------
```
#include <gtk/gtk.h>
```
Description
-----------
A GtkShortcutsWindow shows brief information about the keyboard shortcuts and gestures of an application. The shortcuts can be grouped, and you can have multiple sections in this window, corresponding to the major modes of your application.
Additionally, the shortcuts can be filtered by the current view, to avoid showing information that is not relevant in the current application context.
The recommended way to construct a GtkShortcutsWindow is with GtkBuilder, by populating a [GtkShortcutsWindow](gtkshortcutswindow#GtkShortcutsWindow-struct) with one or more [GtkShortcutsSection](gtkshortcutssection#GtkShortcutsSection-struct) objects, which contain [GtkShortcutsGroups](gtkshortcutsgroup#GtkShortcutsGroup-struct) that in turn contain objects of class [GtkShortcutsShortcut](gtkshortcutsshortcut#GtkShortcutsShortcut-struct).
### A simple example:
This example has as single section. As you can see, the shortcut groups are arranged in columns, and spread across several pages if there are too many to find on a single page.
The .ui file for this example can be found [here](https://gitlab.gnome.org/GNOME/gtk/tree/master/demos/gtk-demo/shortcuts-gedit.ui).
### An example with multiple views:
This example shows a [GtkShortcutsWindow](gtkshortcutswindow#GtkShortcutsWindow-struct) that has been configured to show only the shortcuts relevant to the "stopwatch" view.
The .ui file for this example can be found [here](https://gitlab.gnome.org/GNOME/gtk/tree/master/demos/gtk-demo/shortcuts-clocks.ui).
### An example with multiple sections:
This example shows a [GtkShortcutsWindow](gtkshortcutswindow#GtkShortcutsWindow-struct) with two sections, "Editor Shortcuts" and "Terminal Shortcuts".
The .ui file for this example can be found [here](https://gitlab.gnome.org/GNOME/gtk/tree/master/demos/gtk-demo/shortcuts-builder.ui).
Functions
---------
Types and Values
----------------
### GtkShortcutsWindow
```
typedef struct _GtkShortcutsWindow GtkShortcutsWindow;
```
Property Details
----------------
### The `“section-name”` property
```
“section-name” char *
```
The name of the section to show.
This should be the section-name of one of the [GtkShortcutsSection](gtkshortcutssection#GtkShortcutsSection-struct) objects that are in this shortcuts window.
Owner: GtkShortcutsWindow
Flags: Read / Write
Default value: "internal-search"
### The `“view-name”` property
```
“view-name” char *
```
The view name by which to filter the contents.
This should correspond to the [“view”](gtkshortcutsgroup#GtkShortcutsGroup--view) property of some of the [GtkShortcutsGroup](gtkshortcutsgroup#GtkShortcutsGroup-struct) objects that are inside this shortcuts window.
Set this to `NULL` to show all groups.
Owner: GtkShortcutsWindow
Flags: Read / Write
Default value: NULL
Signal Details
--------------
### The `“close”` signal
```
void
user_function ([GtkShortcutsWindow](gtkshortcutswindow#GtkShortcutsWindow-struct) *shortcutswindow,
gpointer user_data)
```
The ::close signal is a [keybinding signal](gtkshortcutaction#GtkSignalAction-struct) which gets emitted when the user uses a keybinding to close the window.
The default binding for this signal is the Escape key.
#### Parameters
| | | |
| --- | --- | --- |
| user\_data | user data set when the signal handler was connected. | |
Flags: Action
### The `“search”` signal
```
void
user_function ([GtkShortcutsWindow](gtkshortcutswindow#GtkShortcutsWindow-struct) *shortcutswindow,
gpointer user_data)
```
The ::search signal is a [keybinding signal](gtkshortcutaction#GtkSignalAction-struct) which gets emitted when the user uses a keybinding to start a search.
The default binding for this signal is Control-F.
#### Parameters
| | | |
| --- | --- | --- |
| user\_data | user data set when the signal handler was connected. | |
Flags: Action
gtk GtkTreeView drag-and-drop GtkTreeView drag-and-drop
=========================
GtkTreeView drag-and-drop — Interfaces for drag-and-drop support in GtkTreeView
Functions
---------
| | |
| --- | --- |
| gboolean | [gtk\_tree\_drag\_source\_drag\_data\_delete](gtk4-gtktreeview-drag-and-drop#gtk-tree-drag-source-drag-data-delete) () |
| [GdkContentProvider](https://developer-old.gnome.org/gtk4/html/GdkContentProvider.html#GdkContentProvider-struct) \* | [gtk\_tree\_drag\_source\_drag\_data\_get](gtk4-gtktreeview-drag-and-drop#gtk-tree-drag-source-drag-data-get) () |
| gboolean | [gtk\_tree\_drag\_source\_row\_draggable](gtk4-gtktreeview-drag-and-drop#gtk-tree-drag-source-row-draggable) () |
| gboolean | [gtk\_tree\_drag\_dest\_drag\_data\_received](gtk4-gtktreeview-drag-and-drop#gtk-tree-drag-dest-drag-data-received) () |
| gboolean | [gtk\_tree\_drag\_dest\_row\_drop\_possible](gtk4-gtktreeview-drag-and-drop#gtk-tree-drag-dest-row-drop-possible) () |
| [GdkContentProvider](https://developer-old.gnome.org/gtk4/html/GdkContentProvider.html#GdkContentProvider-struct) \* | [gtk\_tree\_create\_row\_drag\_content](gtk4-gtktreeview-drag-and-drop#gtk-tree-create-row-drag-content) () |
| gboolean | [gtk\_tree\_get\_row\_drag\_data](gtk4-gtktreeview-drag-and-drop#gtk-tree-get-row-drag-data) () |
Types and Values
----------------
| | |
| --- | --- |
| | [GtkTreeDragSource](gtk4-gtktreeview-drag-and-drop#GtkTreeDragSource-struct) |
| struct | [GtkTreeDragSourceIface](gtk4-gtktreeview-drag-and-drop#GtkTreeDragSourceIface) |
| | [GtkTreeDragDest](gtk4-gtktreeview-drag-and-drop#GtkTreeDragDest-struct) |
| struct | [GtkTreeDragDestIface](gtk4-gtktreeview-drag-and-drop#GtkTreeDragDestIface) |
| #define | [GTK\_TYPE\_TREE\_ROW\_DATA](gtk4-gtktreeview-drag-and-drop#GTK-TYPE-TREE-ROW-DATA:CAPS) |
Object Hierarchy
----------------
```
[GInterface](https://developer-old.gnome.org/gobject/stable/GTypeModule.html)
├── GtkTreeDragDest
╰── GtkTreeDragSource
```
Known Implementations
---------------------
GtkTreeDragSource is implemented by [GtkListStore](gtkliststore#GtkListStore-struct), [GtkTreeModelFilter](gtktreemodelfilter#GtkTreeModelFilter-struct), [GtkTreeModelSort](gtktreemodelsort#GtkTreeModelSort-struct) and [GtkTreeStore](gtktreestore#GtkTreeStore-struct).
GtkTreeDragDest is implemented by [GtkListStore](gtkliststore#GtkListStore-struct) and [GtkTreeStore](gtktreestore#GtkTreeStore-struct).
Includes
--------
```
#include <gtk/gtk.h>
```
Description
-----------
GTK supports Drag-and-Drop in tree views with a high-level and a low-level API.
The low-level API consists of the GTK DND API, augmented by some treeview utility functions: [`gtk_tree_view_set_drag_dest_row()`](gtktreeview#gtk-tree-view-set-drag-dest-row), [`gtk_tree_view_get_drag_dest_row()`](gtktreeview#gtk-tree-view-get-drag-dest-row), [`gtk_tree_view_get_dest_row_at_pos()`](gtktreeview#gtk-tree-view-get-dest-row-at-pos), [`gtk_tree_view_create_row_drag_icon()`](gtktreeview#gtk-tree-view-create-row-drag-icon), `gtk_tree_set_row_drag_data()` and [`gtk_tree_get_row_drag_data()`](gtk4-gtktreeview-drag-and-drop#gtk-tree-get-row-drag-data). This API leaves a lot of flexibility, but nothing is done automatically, and implementing advanced features like hover-to-open-rows or autoscrolling on top of this API is a lot of work.
On the other hand, if you write to the high-level API, then all the bookkeeping of rows is done for you, as well as things like hover-to-open and auto-scroll, but your models have to implement the [GtkTreeDragSource](gtk4-gtktreeview-drag-and-drop#GtkTreeDragSource-struct) and [GtkTreeDragDest](gtk4-gtktreeview-drag-and-drop#GtkTreeDragDest-struct) interfaces.
Functions
---------
### gtk\_tree\_drag\_source\_drag\_data\_delete ()
```
gboolean
gtk_tree_drag_source_drag_data_delete (*`[GtkTreeDragSource](gtk4-gtktreeview-drag-and-drop#GtkTreeDragSource-struct) *drag_source`*,
*`[GtkTreePath](gtktreemodel#GtkTreePath-struct) *path`*);
```
Asks the [GtkTreeDragSource](gtk4-gtktreeview-drag-and-drop#GtkTreeDragSource-struct) to delete the row at *`path`* , because it was moved somewhere else via drag-and-drop. Returns `FALSE` if the deletion fails because *`path`* no longer exists, or for some model-specific reason. Should robustly handle a *`path`* no longer found in the model!
#### Parameters
| | | |
| --- | --- | --- |
| drag\_source | a [GtkTreeDragSource](gtk4-gtktreeview-drag-and-drop#GtkTreeDragSource-struct) | |
| path | row that was being dragged | |
#### Returns
`TRUE` if the row was successfully deleted
### gtk\_tree\_drag\_source\_drag\_data\_get ()
```
[GdkContentProvider](https://developer-old.gnome.org/gtk4/html/GdkContentProvider.html#GdkContentProvider-struct) *
gtk_tree_drag_source_drag_data_get (*`[GtkTreeDragSource](gtk4-gtktreeview-drag-and-drop#GtkTreeDragSource-struct) *drag_source`*,
*`[GtkTreePath](gtktreemodel#GtkTreePath-struct) *path`*);
```
Asks the [GtkTreeDragSource](gtk4-gtktreeview-drag-and-drop#GtkTreeDragSource-struct) to return a [GdkContentProvider](https://developer-old.gnome.org/gtk4/html/GdkContentProvider.html#GdkContentProvider-struct) representing the row at *`path`* . Should robustly handle a *`path`* no longer found in the model!
#### Parameters
| | | |
| --- | --- | --- |
| drag\_source | a [GtkTreeDragSource](gtk4-gtktreeview-drag-and-drop#GtkTreeDragSource-struct) | |
| path | row that was dragged | |
#### Returns
a [GdkContentProvider](https://developer-old.gnome.org/gtk4/html/GdkContentProvider.html#GdkContentProvider-struct) for the given *`path`* or `NULL` if none exists.
[nullable][transfer full]
### gtk\_tree\_drag\_source\_row\_draggable ()
```
gboolean
gtk_tree_drag_source_row_draggable (*`[GtkTreeDragSource](gtk4-gtktreeview-drag-and-drop#GtkTreeDragSource-struct) *drag_source`*,
*`[GtkTreePath](gtktreemodel#GtkTreePath-struct) *path`*);
```
Asks the [GtkTreeDragSource](gtk4-gtktreeview-drag-and-drop#GtkTreeDragSource-struct) whether a particular row can be used as the source of a DND operation. If the source doesn’t implement this interface, the row is assumed draggable.
#### Parameters
| | | |
| --- | --- | --- |
| drag\_source | a [GtkTreeDragSource](gtk4-gtktreeview-drag-and-drop#GtkTreeDragSource-struct) | |
| path | row on which user is initiating a drag | |
#### Returns
`TRUE` if the row can be dragged
### gtk\_tree\_drag\_dest\_drag\_data\_received ()
```
gboolean
gtk_tree_drag_dest_drag_data_received (*`[GtkTreeDragDest](gtk4-gtktreeview-drag-and-drop#GtkTreeDragDest-struct) *drag_dest`*,
*`[GtkTreePath](gtktreemodel#GtkTreePath-struct) *dest`*,
*`const GValue *value`*);
```
Asks the [GtkTreeDragDest](gtk4-gtktreeview-drag-and-drop#GtkTreeDragDest-struct) to insert a row before the path *`dest`* , deriving the contents of the row from *`value`* . If *`dest`* is outside the tree so that inserting before it is impossible, `FALSE` will be returned. Also, `FALSE` may be returned if the new row is not created for some model-specific reason. Should robustly handle a *`dest`* no longer found in the model!
#### Parameters
| | | |
| --- | --- | --- |
| drag\_dest | a [GtkTreeDragDest](gtk4-gtktreeview-drag-and-drop#GtkTreeDragDest-struct) | |
| dest | row to drop in front of | |
| value | data to drop | |
#### Returns
whether a new row was created before position *`dest`*
### gtk\_tree\_drag\_dest\_row\_drop\_possible ()
```
gboolean
gtk_tree_drag_dest_row_drop_possible (*`[GtkTreeDragDest](gtk4-gtktreeview-drag-and-drop#GtkTreeDragDest-struct) *drag_dest`*,
*`[GtkTreePath](gtktreemodel#GtkTreePath-struct) *dest_path`*,
*`const GValue *value`*);
```
Determines whether a drop is possible before the given *`dest_path`* , at the same depth as *`dest_path`* . i.e., can we drop the data in *`value`* at that location. *`dest_path`* does not have to exist; the return value will almost certainly be `FALSE` if the parent of *`dest_path`* doesn’t exist, though.
#### Parameters
| | | |
| --- | --- | --- |
| drag\_dest | a [GtkTreeDragDest](gtk4-gtktreeview-drag-and-drop#GtkTreeDragDest-struct) | |
| dest\_path | destination row | |
| value | the data being dropped | |
#### Returns
`TRUE` if a drop is possible before *`dest_path`*
### gtk\_tree\_create\_row\_drag\_content ()
```
[GdkContentProvider](https://developer-old.gnome.org/gtk4/html/GdkContentProvider.html#GdkContentProvider-struct) *
gtk_tree_create_row_drag_content (*`[GtkTreeModel](gtktreemodel#GtkTreeModel-struct) *tree_model`*,
*`[GtkTreePath](gtktreemodel#GtkTreePath-struct) *path`*);
```
Creates a content provider for dragging *`path`* from *`tree_model`* .
#### Parameters
| | | |
| --- | --- | --- |
| tree\_model | a [GtkTreeModel](gtktreemodel#GtkTreeModel-struct) | |
| path | a row in *`tree_model`* | |
#### Returns
a new [GdkContentProvider](https://developer-old.gnome.org/gtk4/html/GdkContentProvider.html#GdkContentProvider-struct).
[transfer full]
### gtk\_tree\_get\_row\_drag\_data ()
```
gboolean
gtk_tree_get_row_drag_data (*`const GValue *value`*,
*`[GtkTreeModel](gtktreemodel#GtkTreeModel-struct) **tree_model`*,
*`[GtkTreePath](gtktreemodel#GtkTreePath-struct) **path`*);
```
Obtains a *`tree_model`* and *`path`* from value of target type [`GTK_TYPE_TREE_ROW_DATA`](gtk4-gtktreeview-drag-and-drop#GTK-TYPE-TREE-ROW-DATA:CAPS).
The returned path must be freed with [`gtk_tree_path_free()`](gtktreemodel#gtk-tree-path-free).
#### Parameters
| | | |
| --- | --- | --- |
| value | a GValue | |
| tree\_model | a [GtkTreeModel](gtktreemodel#GtkTreeModel-struct). | [nullable][optional][transfer none][out] |
| path | row in *`tree_model`* . | [nullable][optional][out] |
#### Returns
`TRUE` if *`selection_data`* had target type [`GTK_TYPE_TREE_ROW_DATA`](gtk4-gtktreeview-drag-and-drop#GTK-TYPE-TREE-ROW-DATA:CAPS) is otherwise valid
Types and Values
----------------
### GtkTreeDragSource
```
typedef struct _GtkTreeDragSource GtkTreeDragSource;
```
### struct GtkTreeDragSourceIface
```
struct GtkTreeDragSourceIface {
/* VTable - not signals */
gboolean (* row_draggable) (GtkTreeDragSource *drag_source,
GtkTreePath *path);
GdkContentProvider * (* drag_data_get)(GtkTreeDragSource *drag_source,
GtkTreePath *path);
gboolean (* drag_data_delete) (GtkTreeDragSource *drag_source,
GtkTreePath *path);
};
```
#### Members
| | | |
| --- | --- | --- |
| *`row_draggable`* () | Asks the [GtkTreeDragSource](gtk4-gtktreeview-drag-and-drop#GtkTreeDragSource-struct) whether a particular row can be used as the source of a DND operation. | |
| *`drag_data_get`* () | Asks the [GtkTreeDragSource](gtk4-gtktreeview-drag-and-drop#GtkTreeDragSource-struct) to fill in selection\_data with a representation of the row at path. | |
| *`drag_data_delete`* () | Asks the [GtkTreeDragSource](gtk4-gtktreeview-drag-and-drop#GtkTreeDragSource-struct) to delete the row at path, because it was moved somewhere else via drag-and-drop. | |
### GtkTreeDragDest
```
typedef struct _GtkTreeDragDest GtkTreeDragDest;
```
### struct GtkTreeDragDestIface
```
struct GtkTreeDragDestIface {
/* VTable - not signals */
gboolean (* drag_data_received) (GtkTreeDragDest *drag_dest,
GtkTreePath *dest,
const GValue *value);
gboolean (* row_drop_possible) (GtkTreeDragDest *drag_dest,
GtkTreePath *dest_path,
const GValue *value);
};
```
#### Members
| | | |
| --- | --- | --- |
| *`drag_data_received`* () | Asks the [GtkTreeDragDest](gtk4-gtktreeview-drag-and-drop#GtkTreeDragDest-struct) to insert a row before the path dest, deriving the contents of the row from selection\_data. | |
| *`row_drop_possible`* () | Determines whether a drop is possible before the given dest\_path, at the same depth as dest\_path. | |
### GTK\_TYPE\_TREE\_ROW\_DATA
```
#define GTK_TYPE_TREE_ROW_DATA (gtk_tree_row_data_get_type ())
```
Data in this format will be provided by [`gtk_tree_create_row_drag_content()`](gtk4-gtktreeview-drag-and-drop#gtk-tree-create-row-drag-content) and can be consumed via [`gtk_tree_get_row_drag_data()`](gtk4-gtktreeview-drag-and-drop#gtk-tree-get-row-drag-data).
gtk GtkButton GtkButton
=========
GtkButton — A widget that emits a signal when clicked on
Functions
---------
| | |
| --- | --- |
| [GtkWidget](gtkwidget#GtkWidget-struct) \* | [gtk\_button\_new](gtkbutton#gtk-button-new) () |
| [GtkWidget](gtkwidget#GtkWidget-struct) \* | [gtk\_button\_new\_with\_label](gtkbutton#gtk-button-new-with-label) () |
| [GtkWidget](gtkwidget#GtkWidget-struct) \* | [gtk\_button\_new\_with\_mnemonic](gtkbutton#gtk-button-new-with-mnemonic) () |
| [GtkWidget](gtkwidget#GtkWidget-struct) \* | [gtk\_button\_new\_from\_icon\_name](gtkbutton#gtk-button-new-from-icon-name) () |
| void | [gtk\_button\_set\_has\_frame](gtkbutton#gtk-button-set-has-frame) () |
| gboolean | [gtk\_button\_get\_has\_frame](gtkbutton#gtk-button-get-has-frame) () |
| const char \* | [gtk\_button\_get\_label](gtkbutton#gtk-button-get-label) () |
| void | [gtk\_button\_set\_label](gtkbutton#gtk-button-set-label) () |
| gboolean | [gtk\_button\_get\_use\_underline](gtkbutton#gtk-button-get-use-underline) () |
| void | [gtk\_button\_set\_use\_underline](gtkbutton#gtk-button-set-use-underline) () |
| void | [gtk\_button\_set\_icon\_name](gtkbutton#gtk-button-set-icon-name) () |
| const char \* | [gtk\_button\_get\_icon\_name](gtkbutton#gtk-button-get-icon-name) () |
| void | [gtk\_button\_set\_child](gtkbutton#gtk-button-set-child) () |
| [GtkWidget](gtkwidget#GtkWidget-struct) \* | [gtk\_button\_get\_child](gtkbutton#gtk-button-get-child) () |
Properties
----------
| | | |
| --- | --- | --- |
| [GtkWidget](gtkwidget#GtkWidget-struct) \* | [child](gtkbutton#GtkButton--child) | Read / Write |
| gboolean | [has-frame](gtkbutton#GtkButton--has-frame) | Read / Write |
| char \* | [icon-name](gtkbutton#GtkButton--icon-name) | Read / Write |
| char \* | [label](gtkbutton#GtkButton--label) | Read / Write |
| gboolean | [use-underline](gtkbutton#GtkButton--use-underline) | Read / Write |
Signals
-------
| | | |
| --- | --- | --- |
| void | [activate](gtkbutton#GtkButton-activate) | Action |
| void | [clicked](gtkbutton#GtkButton-clicked) | Action |
Types and Values
----------------
| | |
| --- | --- |
| struct | [GtkButton](gtkbutton#GtkButton-struct) |
| struct | [GtkButtonClass](gtkbutton#GtkButtonClass) |
Object Hierarchy
----------------
```
GObject
╰── GInitiallyUnowned
╰── [GtkWidget](gtkwidget#GtkWidget-struct)
╰── GtkButton
├── [GtkLinkButton](gtklinkbutton#GtkLinkButton-struct)
├── [GtkLockButton](gtklockbutton#GtkLockButton-struct)
╰── [GtkToggleButton](gtktogglebutton#GtkToggleButton-struct)
```
Implemented Interfaces
----------------------
GtkButton implements [GtkAccessible](gtkaccessible#GtkAccessible-struct), [GtkBuildable](gtkbuildable#GtkBuildable-struct), [GtkConstraintTarget](gtkconstraint#GtkConstraintTarget-struct) and [GtkActionable](gtkactionable#GtkActionable-struct).
Includes
--------
```
#include <gtk/gtk.h>
```
Description
-----------
The [GtkButton](gtkbutton#GtkButton-struct) widget is generally used to trigger a callback function that is called when the button is pressed. The various signals and how to use them are outlined below.
The [GtkButton](gtkbutton#GtkButton-struct) widget can hold any valid child widget. That is, it can hold almost any other standard [GtkWidget](gtkwidget#GtkWidget-struct). The most commonly used child is the [GtkLabel](gtklabel#GtkLabel-struct).
### CSS nodes
GtkButton has a single CSS node with name button. The node will get the style classes .image-button or .text-button, if the content is just an image or label, respectively. It may also receive the .flat style class.
Other style classes that are commonly used with GtkButton include .suggested-action and .destructive-action. In special cases, buttons can be made round by adding the .circular style class.
Button-like widgets like [GtkToggleButton](gtktogglebutton#GtkToggleButton-struct), [GtkMenuButton](gtkmenubutton#GtkMenuButton-struct), [GtkVolumeButton](gtkvolumebutton#GtkVolumeButton-struct), [GtkLockButton](gtklockbutton#GtkLockButton-struct), [GtkColorButton](gtkcolorbutton#GtkColorButton-struct) or [GtkFontButton](gtkfontbutton#GtkFontButton-struct) use style classes such as .toggle, .popup, .scale, .lock, .color on the button node to differentiate themselves from a plain GtkButton.
### Accessibility
GtkButton uses the [GTK\_ACCESSIBLE\_ROLE\_BUTTON](gtkaccessible#GTK-ACCESSIBLE-ROLE-BUTTON:CAPS) role.
Functions
---------
### gtk\_button\_new ()
```
[GtkWidget](gtkwidget#GtkWidget-struct) *
gtk_button_new (*`void`*);
```
Creates a new [GtkButton](gtkbutton#GtkButton-struct) widget. To add a child widget to the button, use [`gtk_button_set_child()`](gtkbutton#gtk-button-set-child).
#### Returns
The newly created [GtkButton](gtkbutton#GtkButton-struct) widget.
### gtk\_button\_new\_with\_label ()
```
[GtkWidget](gtkwidget#GtkWidget-struct) *
gtk_button_new_with_label (*`const char *label`*);
```
Creates a [GtkButton](gtkbutton#GtkButton-struct) widget with a [GtkLabel](gtklabel#GtkLabel-struct) child containing the given text.
#### Parameters
| | | |
| --- | --- | --- |
| label | The text you want the [GtkLabel](gtklabel#GtkLabel-struct) to hold. | |
#### Returns
The newly created [GtkButton](gtkbutton#GtkButton-struct) widget.
### gtk\_button\_new\_with\_mnemonic ()
```
[GtkWidget](gtkwidget#GtkWidget-struct) *
gtk_button_new_with_mnemonic (*`const char *label`*);
```
Creates a new [GtkButton](gtkbutton#GtkButton-struct) containing a label. If characters in *`label`* are preceded by an underscore, they are underlined. If you need a literal underscore character in a label, use “\_\_” (two underscores). The first underlined character represents a keyboard accelerator called a mnemonic. Pressing Alt and that key activates the button.
#### Parameters
| | | |
| --- | --- | --- |
| label | The text of the button, with an underscore in front of the mnemonic character | |
#### Returns
a new [GtkButton](gtkbutton#GtkButton-struct)
### gtk\_button\_new\_from\_icon\_name ()
```
[GtkWidget](gtkwidget#GtkWidget-struct) *
gtk_button_new_from_icon_name (*`const char *icon_name`*);
```
Creates a new button containing an icon from the current icon theme.
If the icon name isn’t known, a “broken image” icon will be displayed instead. If the current icon theme is changed, the icon will be updated appropriately.
#### Parameters
| | | |
| --- | --- | --- |
| icon\_name | an icon name or `NULL`. | [nullable] |
#### Returns
a new [GtkButton](gtkbutton#GtkButton-struct) displaying the themed icon
### gtk\_button\_set\_has\_frame ()
```
void
gtk_button_set_has_frame (*`[GtkButton](gtkbutton#GtkButton-struct) *button`*,
*`gboolean has_frame`*);
```
Sets the style of the button. Buttons can has a flat appearance or have a frame drawn around them.
#### Parameters
| | | |
| --- | --- | --- |
| button | a [GtkButton](gtkbutton#GtkButton-struct) | |
| has\_frame | whether the button should have a visible frame | |
### gtk\_button\_get\_has\_frame ()
```
gboolean
gtk_button_get_has_frame (*`[GtkButton](gtkbutton#GtkButton-struct) *button`*);
```
Returns whether the button has a frame.
#### Parameters
| | | |
| --- | --- | --- |
| button | a [GtkButton](gtkbutton#GtkButton-struct) | |
#### Returns
`TRUE` if the button has a frame
### gtk\_button\_get\_label ()
```
const char *
gtk_button_get_label (*`[GtkButton](gtkbutton#GtkButton-struct) *button`*);
```
Fetches the text from the label of the button, as set by [`gtk_button_set_label()`](gtkbutton#gtk-button-set-label). If the label text has not been set the return value will be `NULL`. This will be the case if you create an empty button with [`gtk_button_new()`](gtkbutton#gtk-button-new) to use as a container.
#### Parameters
| | | |
| --- | --- | --- |
| button | a [GtkButton](gtkbutton#GtkButton-struct) | |
#### Returns
The text of the label widget. This string is owned by the widget and must not be modified or freed.
[nullable]
### gtk\_button\_set\_label ()
```
void
gtk_button_set_label (*`[GtkButton](gtkbutton#GtkButton-struct) *button`*,
*`const char *label`*);
```
Sets the text of the label of the button to *`label`* .
This will also clear any previously set labels.
#### Parameters
| | | |
| --- | --- | --- |
| button | a [GtkButton](gtkbutton#GtkButton-struct) | |
| label | a string | |
### gtk\_button\_get\_use\_underline ()
```
gboolean
gtk_button_get_use_underline (*`[GtkButton](gtkbutton#GtkButton-struct) *button`*);
```
Returns whether an embedded underline in the button label indicates a mnemonic. See [`gtk_button_set_use_underline()`](gtkbutton#gtk-button-set-use-underline).
#### Parameters
| | | |
| --- | --- | --- |
| button | a [GtkButton](gtkbutton#GtkButton-struct) | |
#### Returns
`TRUE` if an embedded underline in the button label indicates the mnemonic accelerator keys.
### gtk\_button\_set\_use\_underline ()
```
void
gtk_button_set_use_underline (*`[GtkButton](gtkbutton#GtkButton-struct) *button`*,
*`gboolean use_underline`*);
```
If true, an underline in the text of the button label indicates the next character should be used for the mnemonic accelerator key.
#### Parameters
| | | |
| --- | --- | --- |
| button | a [GtkButton](gtkbutton#GtkButton-struct) | |
| use\_underline | `TRUE` if underlines in the text indicate mnemonics | |
### gtk\_button\_set\_icon\_name ()
```
void
gtk_button_set_icon_name (*`[GtkButton](gtkbutton#GtkButton-struct) *button`*,
*`const char *icon_name`*);
```
Adds a [GtkImage](gtkimage#GtkImage-struct) with the given icon name as a child. If *`button`* already contains a child widget, that child widget will be removed and replaced with the image.
#### Parameters
| | | |
| --- | --- | --- |
| button | A [GtkButton](gtkbutton#GtkButton-struct) | |
| icon\_name | An icon name | |
### gtk\_button\_get\_icon\_name ()
```
const char *
gtk_button_get_icon_name (*`[GtkButton](gtkbutton#GtkButton-struct) *button`*);
```
Returns the icon name set via [`gtk_button_set_icon_name()`](gtkbutton#gtk-button-set-icon-name).
#### Parameters
| | | |
| --- | --- | --- |
| button | A [GtkButton](gtkbutton#GtkButton-struct) | |
#### Returns
The icon name set via [`gtk_button_set_icon_name()`](gtkbutton#gtk-button-set-icon-name).
[nullable]
### gtk\_button\_set\_child ()
```
void
gtk_button_set_child (*`[GtkButton](gtkbutton#GtkButton-struct) *button`*,
*`[GtkWidget](gtkwidget#GtkWidget-struct) *child`*);
```
Sets the child widget of *`button`* .
#### Parameters
| | | |
| --- | --- | --- |
| button | a [GtkButton](gtkbutton#GtkButton-struct) | |
| child | the child widget. | [allow-none] |
### gtk\_button\_get\_child ()
```
[GtkWidget](gtkwidget#GtkWidget-struct) *
gtk_button_get_child (*`[GtkButton](gtkbutton#GtkButton-struct) *button`*);
```
Gets the child widget of *`button`* .
#### Parameters
| | | |
| --- | --- | --- |
| button | a [GtkButton](gtkbutton#GtkButton-struct) | |
#### Returns
the child widget of *`button`* .
[nullable][transfer none]
Types and Values
----------------
### struct GtkButton
```
struct GtkButton;
```
### struct GtkButtonClass
```
struct GtkButtonClass {
GtkWidgetClass parent_class;
void (* clicked) (GtkButton *button);
void (* activate) (GtkButton *button);
};
```
#### Members
| | | |
| --- | --- | --- |
| *`clicked`* () | Signal emitted when the button has been activated (pressed and released). | |
| *`activate`* () | Signal that causes the button to animate press then release. Applications should never connect to this signal, but use the *`clicked`* signal. | |
Property Details
----------------
### The `“child”` property
```
“child” [GtkWidget](gtkwidget#GtkWidget-struct) *
```
The child widget.
Owner: GtkButton
Flags: Read / Write
### The `“has-frame”` property
```
“has-frame” gboolean
```
Whether the button has a frame.
Owner: GtkButton
Flags: Read / Write
Default value: TRUE
### The `“icon-name”` property
```
“icon-name” char *
```
The name of the icon used to automatically populate the button.
Owner: GtkButton
Flags: Read / Write
Default value: NULL
### The `“label”` property
```
“label” char *
```
Text of the label widget inside the button, if the button contains a label widget.
Owner: GtkButton
Flags: Read / Write
Default value: NULL
### The `“use-underline”` property
```
“use-underline” gboolean
```
If set, an underline in the text indicates the next character should be used for the mnemonic accelerator key.
Owner: GtkButton
Flags: Read / Write
Default value: FALSE
Signal Details
--------------
### The `“activate”` signal
```
void
user_function ([GtkButton](gtkbutton#GtkButton-struct) *widget,
gpointer user_data)
```
The ::activate signal on GtkButton is an action signal and emitting it causes the button to animate press then release. Applications should never connect to this signal, but use the [“clicked”](gtkbutton#GtkButton-clicked) signal.
#### Parameters
| | | |
| --- | --- | --- |
| widget | the object which received the signal. | |
| user\_data | user data set when the signal handler was connected. | |
Flags: Action
### The `“clicked”` signal
```
void
user_function ([GtkButton](gtkbutton#GtkButton-struct) *button,
gpointer user_data)
```
Emitted when the button has been activated (pressed and released).
#### Parameters
| | | |
| --- | --- | --- |
| button | the object that received the signal | |
| user\_data | user data set when the signal handler was connected. | |
Flags: Action
| programming_docs |
gtk Filesystem utilities Filesystem utilities
====================
Filesystem utilities — Functions for working with GIO
Functions
---------
| | |
| --- | --- |
| GMountOperation \* | [gtk\_mount\_operation\_new](gtk4-filesystem-utilities#gtk-mount-operation-new) () |
| gboolean | [gtk\_mount\_operation\_is\_showing](gtk4-filesystem-utilities#gtk-mount-operation-is-showing) () |
| void | [gtk\_mount\_operation\_set\_parent](gtk4-filesystem-utilities#gtk-mount-operation-set-parent) () |
| [GtkWindow](gtkwindow#GtkWindow-struct) \* | [gtk\_mount\_operation\_get\_parent](gtk4-filesystem-utilities#gtk-mount-operation-get-parent) () |
| void | [gtk\_mount\_operation\_set\_display](gtk4-filesystem-utilities#gtk-mount-operation-set-display) () |
| [GdkDisplay](https://developer-old.gnome.org/gtk4/html/GdkDisplay.html#GdkDisplay-struct) \* | [gtk\_mount\_operation\_get\_display](gtk4-filesystem-utilities#gtk-mount-operation-get-display) () |
| void | [gtk\_show\_uri\_full](gtk4-filesystem-utilities#gtk-show-uri-full) () |
| gboolean | [gtk\_show\_uri\_full\_finish](gtk4-filesystem-utilities#gtk-show-uri-full-finish) () |
| void | [gtk\_show\_uri](gtk4-filesystem-utilities#gtk-show-uri) () |
Properties
----------
| | | |
| --- | --- | --- |
| [GdkDisplay](https://developer-old.gnome.org/gtk4/html/GdkDisplay.html#GdkDisplay-struct) \* | [display](gtk4-filesystem-utilities#GtkMountOperation--display) | Read / Write |
| gboolean | [is-showing](gtk4-filesystem-utilities#GtkMountOperation--is-showing) | Read |
| [GtkWindow](gtkwindow#GtkWindow-struct) \* | [parent](gtk4-filesystem-utilities#GtkMountOperation--parent) | Read / Write |
Types and Values
----------------
| | |
| --- | --- |
| struct | [GtkMountOperation](gtk4-filesystem-utilities#GtkMountOperation-struct) |
| struct | [GtkMountOperationClass](gtk4-filesystem-utilities#GtkMountOperationClass) |
Object Hierarchy
----------------
```
GObject
╰── GMountOperation
╰── GtkMountOperation
```
Includes
--------
```
#include <gtk/gtk.h>
```
Description
-----------
The functions and objects described here make working with GTK and GIO more convenient.
[GtkMountOperation](gtk4-filesystem-utilities#GtkMountOperation-struct) is needed when mounting volumes: It is an implementation of GMountOperation that can be used with GIO functions for mounting volumes such as `g_file_mount_enclosing_volume()`, `g_file_mount_mountable()`, `g_volume_mount()`, `g_mount_unmount_with_operation()` and others.
When necessary, [GtkMountOperation](gtk4-filesystem-utilities#GtkMountOperation-struct) shows dialogs to ask for passwords, questions or show processes blocking unmount.
gtk\_show\_uri\_on\_window() is a convenient way to launch applications for URIs.
Another object that is worth mentioning in this context is [GdkAppLaunchContext](https://developer-old.gnome.org/gtk4/html/gdk4-Application-launching.html#GdkAppLaunchContext-struct), which provides visual feedback when launching applications.
Functions
---------
### gtk\_mount\_operation\_new ()
```
GMountOperation *
gtk_mount_operation_new (*`[GtkWindow](gtkwindow#GtkWindow-struct) *parent`*);
```
Creates a new [GtkMountOperation](gtk4-filesystem-utilities#GtkMountOperation-struct)
#### Parameters
| | | |
| --- | --- | --- |
| parent | transient parent of the window, or `NULL`. | [allow-none] |
#### Returns
a new [GtkMountOperation](gtk4-filesystem-utilities#GtkMountOperation-struct)
### gtk\_mount\_operation\_is\_showing ()
```
gboolean
gtk_mount_operation_is_showing (*`[GtkMountOperation](gtk4-filesystem-utilities#GtkMountOperation-struct) *op`*);
```
Returns whether the [GtkMountOperation](gtk4-filesystem-utilities#GtkMountOperation-struct) is currently displaying a window.
#### Parameters
| | | |
| --- | --- | --- |
| op | a [GtkMountOperation](gtk4-filesystem-utilities#GtkMountOperation-struct) | |
#### Returns
`TRUE` if *`op`* is currently displaying a window
### gtk\_mount\_operation\_set\_parent ()
```
void
gtk_mount_operation_set_parent (*`[GtkMountOperation](gtk4-filesystem-utilities#GtkMountOperation-struct) *op`*,
*`[GtkWindow](gtkwindow#GtkWindow-struct) *parent`*);
```
Sets the transient parent for windows shown by the [GtkMountOperation](gtk4-filesystem-utilities#GtkMountOperation-struct).
#### Parameters
| | | |
| --- | --- | --- |
| op | a [GtkMountOperation](gtk4-filesystem-utilities#GtkMountOperation-struct) | |
| parent | transient parent of the window, or `NULL`. | [allow-none] |
### gtk\_mount\_operation\_get\_parent ()
```
[GtkWindow](gtkwindow#GtkWindow-struct) *
gtk_mount_operation_get_parent (*`[GtkMountOperation](gtk4-filesystem-utilities#GtkMountOperation-struct) *op`*);
```
Gets the transient parent used by the [GtkMountOperation](gtk4-filesystem-utilities#GtkMountOperation-struct)
#### Parameters
| | | |
| --- | --- | --- |
| op | a [GtkMountOperation](gtk4-filesystem-utilities#GtkMountOperation-struct) | |
#### Returns
the transient parent for windows shown by *`op`* .
[transfer none]
### gtk\_mount\_operation\_set\_display ()
```
void
gtk_mount_operation_set_display (*`[GtkMountOperation](gtk4-filesystem-utilities#GtkMountOperation-struct) *op`*,
*`[GdkDisplay](https://developer-old.gnome.org/gtk4/html/GdkDisplay.html#GdkDisplay-struct) *display`*);
```
Sets the display to show windows of the [GtkMountOperation](gtk4-filesystem-utilities#GtkMountOperation-struct) on.
#### Parameters
| | | |
| --- | --- | --- |
| op | a [GtkMountOperation](gtk4-filesystem-utilities#GtkMountOperation-struct) | |
| display | a [GdkDisplay](https://developer-old.gnome.org/gtk4/html/GdkDisplay.html#GdkDisplay-struct) | |
### gtk\_mount\_operation\_get\_display ()
```
[GdkDisplay](https://developer-old.gnome.org/gtk4/html/GdkDisplay.html#GdkDisplay-struct) *
gtk_mount_operation_get_display (*`[GtkMountOperation](gtk4-filesystem-utilities#GtkMountOperation-struct) *op`*);
```
Gets the display on which windows of the [GtkMountOperation](gtk4-filesystem-utilities#GtkMountOperation-struct) will be shown.
#### Parameters
| | | |
| --- | --- | --- |
| op | a [GtkMountOperation](gtk4-filesystem-utilities#GtkMountOperation-struct) | |
#### Returns
the display on which windows of *`op`* are shown.
[transfer none]
### gtk\_show\_uri\_full ()
```
void
gtk_show_uri_full (*`[GtkWindow](gtkwindow#GtkWindow-struct) *parent`*,
*`const char *uri`*,
*`guint32 timestamp`*,
*`GCancellable *cancellable`*,
*`GAsyncReadyCallback callback`*,
*`gpointer user_data`*);
```
This function launches the default application for showing a given uri.
The *`callback`* will be called when the launch is completed. It should call [`gtk_show_uri_full_finish()`](gtk4-filesystem-utilities#gtk-show-uri-full-finish) to obtain the result.
This is the recommended call to be used as it passes information necessary for sandbox helpers to parent their dialogs properly.
#### Parameters
| | | |
| --- | --- | --- |
| parent | parent window. | [nullable] |
| uri | the uri to show | |
| timestamp | timestamp from the event that triggered this call, or [`GDK_CURRENT_TIME`](https://developer-old.gnome.org/gtk4/html/gdk4-Events.html#GDK-CURRENT-TIME:CAPS) | |
| cancellable | a GCancellable to cancel the launch. | [nullable] |
| callback | a callback to call when the action is complete. | [scope async] |
| user\_data | data to pass to *`callback`* . | [closure callback] |
### gtk\_show\_uri\_full\_finish ()
```
gboolean
gtk_show_uri_full_finish (*`[GtkWindow](gtkwindow#GtkWindow-struct) *parent`*,
*`GAsyncResult *result`*,
*`GError **error`*);
```
Finishes the [`gtk_show_uri()`](gtk4-filesystem-utilities#gtk-show-uri) call and returns the result of the operation.
#### Parameters
| | | |
| --- | --- | --- |
| parent | the [GtkWindow](gtkwindow#GtkWindow-struct) passed to [`gtk_show_uri()`](gtk4-filesystem-utilities#gtk-show-uri) | |
| result | GAsyncResult that was passed to *`callback`* | |
| error | return location for an error | |
#### Returns
`TRUE` if the URI was shown successfully. Otherwise, `FALSE` is returned and *`error`* is set
### gtk\_show\_uri ()
```
void
gtk_show_uri (*`[GtkWindow](gtkwindow#GtkWindow-struct) *parent`*,
*`const char *uri`*,
*`guint32 timestamp`*);
```
This function launches the default application for showing a given uri, or shows an error dialog if that fails.
#### Parameters
| | | |
| --- | --- | --- |
| parent | parent window. | [allow-none] |
| uri | the uri to show | |
| timestamp | timestamp from the event that triggered this call, or [`GDK_CURRENT_TIME`](https://developer-old.gnome.org/gtk4/html/gdk4-Events.html#GDK-CURRENT-TIME:CAPS) | |
Types and Values
----------------
### struct GtkMountOperation
```
struct GtkMountOperation;
```
This should not be accessed directly. Use the accessor functions below.
### struct GtkMountOperationClass
```
struct GtkMountOperationClass {
GMountOperationClass parent_class;
};
```
#### Members
Property Details
----------------
### The `“display”` property
```
“display” [GdkDisplay](https://developer-old.gnome.org/gtk4/html/GdkDisplay.html#GdkDisplay-struct) *
```
The display where this window will be displayed.
Owner: GtkMountOperation
Flags: Read / Write
### The `“is-showing”` property
```
“is-showing” gboolean
```
Are we showing a dialog.
Owner: GtkMountOperation
Flags: Read
Default value: FALSE
### The `“parent”` property
```
“parent” [GtkWindow](gtkwindow#GtkWindow-struct) *
```
The parent window.
Owner: GtkMountOperation
Flags: Read / Write
gtk GtkActionable GtkActionable
=============
GtkActionable — An interface for widgets that can be associated with actions
Functions
---------
| | |
| --- | --- |
| const char \* | [gtk\_actionable\_get\_action\_name](gtkactionable#gtk-actionable-get-action-name) () |
| void | [gtk\_actionable\_set\_action\_name](gtkactionable#gtk-actionable-set-action-name) () |
| GVariant \* | [gtk\_actionable\_get\_action\_target\_value](gtkactionable#gtk-actionable-get-action-target-value) () |
| void | [gtk\_actionable\_set\_action\_target\_value](gtkactionable#gtk-actionable-set-action-target-value) () |
| void | [gtk\_actionable\_set\_action\_target](gtkactionable#gtk-actionable-set-action-target) () |
| void | [gtk\_actionable\_set\_detailed\_action\_name](gtkactionable#gtk-actionable-set-detailed-action-name) () |
Properties
----------
| | | |
| --- | --- | --- |
| char \* | [action-name](gtkactionable#GtkActionable--action-name) | Read / Write |
| GVariant \* | [action-target](gtkactionable#GtkActionable--action-target) | Read / Write |
Types and Values
----------------
| | |
| --- | --- |
| | [GtkActionable](gtkactionable#GtkActionable-struct) |
| struct | [GtkActionableInterface](gtkactionable#GtkActionableInterface) |
Object Hierarchy
----------------
```
[GInterface](https://developer-old.gnome.org/gobject/stable/GTypeModule.html)
╰── GtkActionable
```
Prerequisites
-------------
GtkActionable requires [GtkWidget](gtkwidget#GtkWidget-struct).
Known Implementations
---------------------
GtkActionable is implemented by [GtkButton](gtkbutton#GtkButton-struct), [GtkCheckButton](gtkcheckbutton#GtkCheckButton-struct), [GtkLinkButton](gtklinkbutton#GtkLinkButton-struct), [GtkListBoxRow](gtklistbox#GtkListBoxRow-struct), [GtkLockButton](gtklockbutton#GtkLockButton-struct), [GtkSwitch](gtkswitch#GtkSwitch-struct) and [GtkToggleButton](gtktogglebutton#GtkToggleButton-struct).
Includes
--------
```
#include <gtk/gtk.h>
```
Description
-----------
This interface provides a convenient way of associating widgets with actions on a [GtkApplicationWindow](gtkapplicationwindow#GtkApplicationWindow-struct) or [GtkApplication](gtkapplication#GtkApplication-struct).
It primarily consists of two properties: [“action-name”](gtkactionable#GtkActionable--action-name) and [“action-target”](gtkactionable#GtkActionable--action-target). There are also some convenience APIs for setting these properties.
The action will be looked up in action groups that are found among the widgets ancestors. Most commonly, these will be the actions with the “win.” or “app.” prefix that are associated with the [GtkApplicationWindow](gtkapplicationwindow#GtkApplicationWindow-struct) or [GtkApplication](gtkapplication#GtkApplication-struct), but other action groups that are added with [`gtk_widget_insert_action_group()`](gtkwidget#gtk-widget-insert-action-group) will be consulted as well.
Functions
---------
### gtk\_actionable\_get\_action\_name ()
```
const char *
gtk_actionable_get_action_name (*`[GtkActionable](gtkactionable#GtkActionable-struct) *actionable`*);
```
Gets the action name for *`actionable`* .
See [`gtk_actionable_set_action_name()`](gtkactionable#gtk-actionable-set-action-name) for more information.
#### Parameters
| | | |
| --- | --- | --- |
| actionable | a [GtkActionable](gtkactionable#GtkActionable-struct) widget | |
#### Returns
the action name, or `NULL` if none is set.
[nullable]
### gtk\_actionable\_set\_action\_name ()
```
void
gtk_actionable_set_action_name (*`[GtkActionable](gtkactionable#GtkActionable-struct) *actionable`*,
*`const char *action_name`*);
```
Specifies the name of the action with which this widget should be associated. If *`action_name`* is `NULL` then the widget will be unassociated from any previous action.
Usually this function is used when the widget is located (or will be located) within the hierarchy of a [GtkApplicationWindow](gtkapplicationwindow#GtkApplicationWindow-struct).
Names are of the form “win.save” or “app.quit” for actions on the containing [GtkApplicationWindow](gtkapplicationwindow#GtkApplicationWindow-struct) or its associated [GtkApplication](gtkapplication#GtkApplication-struct), respectively. This is the same form used for actions in the GMenu associated with the window.
#### Parameters
| | | |
| --- | --- | --- |
| actionable | a [GtkActionable](gtkactionable#GtkActionable-struct) widget | |
| action\_name | an action name, or `NULL`. | [nullable] |
### gtk\_actionable\_get\_action\_target\_value ()
```
GVariant *
gtk_actionable_get_action_target_value
(*`[GtkActionable](gtkactionable#GtkActionable-struct) *actionable`*);
```
Gets the current target value of *`actionable`* .
See [`gtk_actionable_set_action_target_value()`](gtkactionable#gtk-actionable-set-action-target-value) for more information.
#### Parameters
| | | |
| --- | --- | --- |
| actionable | a [GtkActionable](gtkactionable#GtkActionable-struct) widget | |
#### Returns
the current target value.
[nullable][transfer none]
### gtk\_actionable\_set\_action\_target\_value ()
```
void
gtk_actionable_set_action_target_value
(*`[GtkActionable](gtkactionable#GtkActionable-struct) *actionable`*,
*`GVariant *target_value`*);
```
Sets the target value of an actionable widget.
If *`target_value`* is `NULL` then the target value is unset.
The target value has two purposes. First, it is used as the parameter to activation of the action associated with the [GtkActionable](gtkactionable#GtkActionable-struct) widget. Second, it is used to determine if the widget should be rendered as “active” — the widget is active if the state is equal to the given target.
Consider the example of associating a set of buttons with a GAction with string state in a typical “radio button” situation. Each button will be associated with the same action, but with a different target value for that action. Clicking on a particular button will activate the action with the target of that button, which will typically cause the action’s state to change to that value. Since the action’s state is now equal to the target value of the button, the button will now be rendered as active (and the other buttons, with different targets, rendered inactive).
#### Parameters
| | | |
| --- | --- | --- |
| actionable | a [GtkActionable](gtkactionable#GtkActionable-struct) widget | |
| target\_value | a GVariant to set as the target value, or `NULL`. | [nullable] |
### gtk\_actionable\_set\_action\_target ()
```
void
gtk_actionable_set_action_target (*`[GtkActionable](gtkactionable#GtkActionable-struct) *actionable`*,
*`const char *format_string`*,
*`...`*);
```
Sets the target of an actionable widget.
This is a convenience function that calls `g_variant_new()` for *`format_string`* and uses the result to call [`gtk_actionable_set_action_target_value()`](gtkactionable#gtk-actionable-set-action-target-value).
If you are setting a string-valued target and want to set the action name at the same time, you can use [`gtk_actionable_set_detailed_action_name()`](gtkactionable#gtk-actionable-set-detailed-action-name).
#### Parameters
| | | |
| --- | --- | --- |
| actionable | a [GtkActionable](gtkactionable#GtkActionable-struct) widget | |
| format\_string | a GVariant format string | |
| ... | arguments appropriate for *`format_string`* | |
### gtk\_actionable\_set\_detailed\_action\_name ()
```
void
gtk_actionable_set_detailed_action_name
(*`[GtkActionable](gtkactionable#GtkActionable-struct) *actionable`*,
*`const char *detailed_action_name`*);
```
Sets the action-name and associated string target value of an actionable widget.
*`detailed_action_name`* is a string in the format accepted by `g_action_parse_detailed_name()`.
(Note that prior to version 3.22.25, this function is only usable for actions with a simple "s" target, and *`detailed_action_name`* must be of the form `"action::target"` where `action` is the action name and `target` is the string to use as the target.)
#### Parameters
| | | |
| --- | --- | --- |
| actionable | a [GtkActionable](gtkactionable#GtkActionable-struct) widget | |
| detailed\_action\_name | the detailed action name | |
Types and Values
----------------
### GtkActionable
```
typedef struct _GtkActionable GtkActionable;
```
An opaque pointer type.
### struct GtkActionableInterface
```
struct GtkActionableInterface {
const char * (* get_action_name) (GtkActionable *actionable);
void (* set_action_name) (GtkActionable *actionable,
const char *action_name);
GVariant * (* get_action_target_value) (GtkActionable *actionable);
void (* set_action_target_value) (GtkActionable *actionable,
GVariant *target_value);
};
```
The interface vtable for [GtkActionable](gtkactionable#GtkActionable-struct).
#### Members
| | | |
| --- | --- | --- |
| *`get_action_name`* () | virtual function for [`gtk_actionable_get_action_name()`](gtkactionable#gtk-actionable-get-action-name) | |
| *`set_action_name`* () | virtual function for [`gtk_actionable_set_action_name()`](gtkactionable#gtk-actionable-set-action-name) | |
| *`get_action_target_value`* () | virtual function for [`gtk_actionable_get_action_target_value()`](gtkactionable#gtk-actionable-get-action-target-value) | |
| *`set_action_target_value`* () | virtual function for [`gtk_actionable_set_action_target_value()`](gtkactionable#gtk-actionable-set-action-target-value) | |
Property Details
----------------
### The `“action-name”` property
```
“action-name” char *
```
The name of the associated action, like “app.quit”.
Owner: GtkActionable
Flags: Read / Write
Default value: NULL
### The `“action-target”` property
```
“action-target” GVariant *
```
The parameter for action invocations.
Owner: GtkActionable
Flags: Read / Write
Allowed values: GVariant<\*>
Default value: NULL
| programming_docs |
gtk GtkRange GtkRange
========
GtkRange — Base class for widgets which visualize an adjustment
Functions
---------
| | |
| --- | --- |
| double | [gtk\_range\_get\_fill\_level](gtkrange#gtk-range-get-fill-level) () |
| gboolean | [gtk\_range\_get\_restrict\_to\_fill\_level](gtkrange#gtk-range-get-restrict-to-fill-level) () |
| gboolean | [gtk\_range\_get\_show\_fill\_level](gtkrange#gtk-range-get-show-fill-level) () |
| void | [gtk\_range\_set\_fill\_level](gtkrange#gtk-range-set-fill-level) () |
| void | [gtk\_range\_set\_restrict\_to\_fill\_level](gtkrange#gtk-range-set-restrict-to-fill-level) () |
| void | [gtk\_range\_set\_show\_fill\_level](gtkrange#gtk-range-set-show-fill-level) () |
| [GtkAdjustment](gtkadjustment#GtkAdjustment-struct) \* | [gtk\_range\_get\_adjustment](gtkrange#gtk-range-get-adjustment) () |
| void | [gtk\_range\_set\_adjustment](gtkrange#gtk-range-set-adjustment) () |
| gboolean | [gtk\_range\_get\_inverted](gtkrange#gtk-range-get-inverted) () |
| void | [gtk\_range\_set\_inverted](gtkrange#gtk-range-set-inverted) () |
| double | [gtk\_range\_get\_value](gtkrange#gtk-range-get-value) () |
| void | [gtk\_range\_set\_value](gtkrange#gtk-range-set-value) () |
| void | [gtk\_range\_set\_increments](gtkrange#gtk-range-set-increments) () |
| void | [gtk\_range\_set\_range](gtkrange#gtk-range-set-range) () |
| int | [gtk\_range\_get\_round\_digits](gtkrange#gtk-range-get-round-digits) () |
| void | [gtk\_range\_set\_round\_digits](gtkrange#gtk-range-set-round-digits) () |
| gboolean | [gtk\_range\_get\_flippable](gtkrange#gtk-range-get-flippable) () |
| void | [gtk\_range\_set\_flippable](gtkrange#gtk-range-set-flippable) () |
| void | [gtk\_range\_get\_range\_rect](gtkrange#gtk-range-get-range-rect) () |
| void | [gtk\_range\_get\_slider\_range](gtkrange#gtk-range-get-slider-range) () |
| gboolean | [gtk\_range\_get\_slider\_size\_fixed](gtkrange#gtk-range-get-slider-size-fixed) () |
| void | [gtk\_range\_set\_slider\_size\_fixed](gtkrange#gtk-range-set-slider-size-fixed) () |
Properties
----------
| | | |
| --- | --- | --- |
| [GtkAdjustment](gtkadjustment#GtkAdjustment-struct) \* | [adjustment](gtkrange#GtkRange--adjustment) | Read / Write / Construct |
| double | [fill-level](gtkrange#GtkRange--fill-level) | Read / Write |
| gboolean | [inverted](gtkrange#GtkRange--inverted) | Read / Write |
| gboolean | [restrict-to-fill-level](gtkrange#GtkRange--restrict-to-fill-level) | Read / Write |
| int | [round-digits](gtkrange#GtkRange--round-digits) | Read / Write |
| gboolean | [show-fill-level](gtkrange#GtkRange--show-fill-level) | Read / Write |
Signals
-------
| | | |
| --- | --- | --- |
| void | [adjust-bounds](gtkrange#GtkRange-adjust-bounds) | Run Last |
| gboolean | [change-value](gtkrange#GtkRange-change-value) | Run Last |
| void | [move-slider](gtkrange#GtkRange-move-slider) | Action |
| void | [value-changed](gtkrange#GtkRange-value-changed) | Run Last |
Types and Values
----------------
| | |
| --- | --- |
| struct | [GtkRange](gtkrange#GtkRange-struct) |
Object Hierarchy
----------------
```
GObject
╰── GInitiallyUnowned
╰── [GtkWidget](gtkwidget#GtkWidget-struct)
╰── GtkRange
╰── [GtkScale](gtkscale#GtkScale-struct)
```
Implemented Interfaces
----------------------
GtkRange implements [GtkAccessible](gtkaccessible#GtkAccessible-struct), [GtkBuildable](gtkbuildable#GtkBuildable-struct), [GtkConstraintTarget](gtkconstraint#GtkConstraintTarget-struct) and [GtkOrientable](gtk4-orientable#GtkOrientable-struct).
Includes
--------
```
#include <gtk/gtk.h>
```
Description
-----------
[GtkRange](gtkrange#GtkRange-struct) is the common base class for widgets which visualize an adjustment, e.g [GtkScale](gtkscale#GtkScale-struct) or [GtkScrollbar](gtkscrollbar#GtkScrollbar-struct).
Apart from signals for monitoring the parameters of the adjustment, [GtkRange](gtkrange#GtkRange-struct) provides properties and methods for setting a “fill level” on range widgets. See [`gtk_range_set_fill_level()`](gtkrange#gtk-range-set-fill-level).
Functions
---------
### gtk\_range\_get\_fill\_level ()
```
double
gtk_range_get_fill_level (*`[GtkRange](gtkrange#GtkRange-struct) *range`*);
```
Gets the current position of the fill level indicator.
#### Parameters
| | | |
| --- | --- | --- |
| range | A [GtkRange](gtkrange#GtkRange-struct) | |
#### Returns
The current fill level
### gtk\_range\_get\_restrict\_to\_fill\_level ()
```
gboolean
gtk_range_get_restrict_to_fill_level (*`[GtkRange](gtkrange#GtkRange-struct) *range`*);
```
Gets whether the range is restricted to the fill level.
#### Parameters
| | | |
| --- | --- | --- |
| range | A [GtkRange](gtkrange#GtkRange-struct) | |
#### Returns
`TRUE` if *`range`* is restricted to the fill level.
### gtk\_range\_get\_show\_fill\_level ()
```
gboolean
gtk_range_get_show_fill_level (*`[GtkRange](gtkrange#GtkRange-struct) *range`*);
```
Gets whether the range displays the fill level graphically.
#### Parameters
| | | |
| --- | --- | --- |
| range | A [GtkRange](gtkrange#GtkRange-struct) | |
#### Returns
`TRUE` if *`range`* shows the fill level.
### gtk\_range\_set\_fill\_level ()
```
void
gtk_range_set_fill_level (*`[GtkRange](gtkrange#GtkRange-struct) *range`*,
*`double fill_level`*);
```
Set the new position of the fill level indicator.
The “fill level” is probably best described by its most prominent use case, which is an indicator for the amount of pre-buffering in a streaming media player. In that use case, the value of the range would indicate the current play position, and the fill level would be the position up to which the file/stream has been downloaded.
This amount of prebuffering can be displayed on the range’s trough and is themeable separately from the trough. To enable fill level display, use [`gtk_range_set_show_fill_level()`](gtkrange#gtk-range-set-show-fill-level). The range defaults to not showing the fill level.
Additionally, it’s possible to restrict the range’s slider position to values which are smaller than the fill level. This is controller by [`gtk_range_set_restrict_to_fill_level()`](gtkrange#gtk-range-set-restrict-to-fill-level) and is by default enabled.
#### Parameters
| | | |
| --- | --- | --- |
| range | a [GtkRange](gtkrange#GtkRange-struct) | |
| fill\_level | the new position of the fill level indicator | |
### gtk\_range\_set\_restrict\_to\_fill\_level ()
```
void
gtk_range_set_restrict_to_fill_level (*`[GtkRange](gtkrange#GtkRange-struct) *range`*,
*`gboolean restrict_to_fill_level`*);
```
Sets whether the slider is restricted to the fill level. See [`gtk_range_set_fill_level()`](gtkrange#gtk-range-set-fill-level) for a general description of the fill level concept.
#### Parameters
| | | |
| --- | --- | --- |
| range | A [GtkRange](gtkrange#GtkRange-struct) | |
| restrict\_to\_fill\_level | Whether the fill level restricts slider movement. | |
### gtk\_range\_set\_show\_fill\_level ()
```
void
gtk_range_set_show_fill_level (*`[GtkRange](gtkrange#GtkRange-struct) *range`*,
*`gboolean show_fill_level`*);
```
Sets whether a graphical fill level is show on the trough. See [`gtk_range_set_fill_level()`](gtkrange#gtk-range-set-fill-level) for a general description of the fill level concept.
#### Parameters
| | | |
| --- | --- | --- |
| range | A [GtkRange](gtkrange#GtkRange-struct) | |
| show\_fill\_level | Whether a fill level indicator graphics is shown. | |
### gtk\_range\_get\_adjustment ()
```
[GtkAdjustment](gtkadjustment#GtkAdjustment-struct) *
gtk_range_get_adjustment (*`[GtkRange](gtkrange#GtkRange-struct) *range`*);
```
Get the [GtkAdjustment](gtkadjustment#GtkAdjustment-struct) which is the “model” object for [GtkRange](gtkrange#GtkRange-struct). See [`gtk_range_set_adjustment()`](gtkrange#gtk-range-set-adjustment) for details. The return value does not have a reference added, so should not be unreferenced.
#### Parameters
| | | |
| --- | --- | --- |
| range | a [GtkRange](gtkrange#GtkRange-struct) | |
#### Returns
a [GtkAdjustment](gtkadjustment#GtkAdjustment-struct).
[transfer none]
### gtk\_range\_set\_adjustment ()
```
void
gtk_range_set_adjustment (*`[GtkRange](gtkrange#GtkRange-struct) *range`*,
*`[GtkAdjustment](gtkadjustment#GtkAdjustment-struct) *adjustment`*);
```
Sets the adjustment to be used as the “model” object for this range widget. The adjustment indicates the current range value, the minimum and maximum range values, the step/page increments used for keybindings and scrolling, and the page size. The page size is normally 0 for [GtkScale](gtkscale#GtkScale-struct) and nonzero for [GtkScrollbar](gtkscrollbar#GtkScrollbar-struct), and indicates the size of the visible area of the widget being scrolled. The page size affects the size of the scrollbar slider.
#### Parameters
| | | |
| --- | --- | --- |
| range | a [GtkRange](gtkrange#GtkRange-struct) | |
| adjustment | a [GtkAdjustment](gtkadjustment#GtkAdjustment-struct) | |
### gtk\_range\_get\_inverted ()
```
gboolean
gtk_range_get_inverted (*`[GtkRange](gtkrange#GtkRange-struct) *range`*);
```
Gets the value set by [`gtk_range_set_inverted()`](gtkrange#gtk-range-set-inverted).
#### Parameters
| | | |
| --- | --- | --- |
| range | a [GtkRange](gtkrange#GtkRange-struct) | |
#### Returns
`TRUE` if the range is inverted
### gtk\_range\_set\_inverted ()
```
void
gtk_range_set_inverted (*`[GtkRange](gtkrange#GtkRange-struct) *range`*,
*`gboolean setting`*);
```
Ranges normally move from lower to higher values as the slider moves from top to bottom or left to right. Inverted ranges have higher values at the top or on the right rather than on the bottom or left.
#### Parameters
| | | |
| --- | --- | --- |
| range | a [GtkRange](gtkrange#GtkRange-struct) | |
| setting | `TRUE` to invert the range | |
### gtk\_range\_get\_value ()
```
double
gtk_range_get_value (*`[GtkRange](gtkrange#GtkRange-struct) *range`*);
```
Gets the current value of the range.
#### Parameters
| | | |
| --- | --- | --- |
| range | a [GtkRange](gtkrange#GtkRange-struct) | |
#### Returns
current value of the range.
### gtk\_range\_set\_value ()
```
void
gtk_range_set_value (*`[GtkRange](gtkrange#GtkRange-struct) *range`*,
*`double value`*);
```
Sets the current value of the range; if the value is outside the minimum or maximum range values, it will be clamped to fit inside them. The range emits the [“value-changed”](gtkrange#GtkRange-value-changed) signal if the value changes.
#### Parameters
| | | |
| --- | --- | --- |
| range | a [GtkRange](gtkrange#GtkRange-struct) | |
| value | new value of the range | |
### gtk\_range\_set\_increments ()
```
void
gtk_range_set_increments (*`[GtkRange](gtkrange#GtkRange-struct) *range`*,
*`double step`*,
*`double page`*);
```
Sets the step and page sizes for the range. The step size is used when the user clicks the [GtkScrollbar](gtkscrollbar#GtkScrollbar-struct) arrows or moves [GtkScale](gtkscale#GtkScale-struct) via arrow keys. The page size is used for example when moving via Page Up or Page Down keys.
#### Parameters
| | | |
| --- | --- | --- |
| range | a [GtkRange](gtkrange#GtkRange-struct) | |
| step | step size | |
| page | page size | |
### gtk\_range\_set\_range ()
```
void
gtk_range_set_range (*`[GtkRange](gtkrange#GtkRange-struct) *range`*,
*`double min`*,
*`double max`*);
```
Sets the allowable values in the [GtkRange](gtkrange#GtkRange-struct), and clamps the range value to be between *`min`* and *`max`* . (If the range has a non-zero page size, it is clamped between *`min`* and *`max`* - page-size.)
#### Parameters
| | | |
| --- | --- | --- |
| range | a [GtkRange](gtkrange#GtkRange-struct) | |
| min | minimum range value | |
| max | maximum range value | |
### gtk\_range\_get\_round\_digits ()
```
int
gtk_range_get_round_digits (*`[GtkRange](gtkrange#GtkRange-struct) *range`*);
```
Gets the number of digits to round the value to when it changes. See [“change-value”](gtkrange#GtkRange-change-value).
#### Parameters
| | | |
| --- | --- | --- |
| range | a [GtkRange](gtkrange#GtkRange-struct) | |
#### Returns
the number of digits to round to
### gtk\_range\_set\_round\_digits ()
```
void
gtk_range_set_round_digits (*`[GtkRange](gtkrange#GtkRange-struct) *range`*,
*`int round_digits`*);
```
Sets the number of digits to round the value to when it changes. See [“change-value”](gtkrange#GtkRange-change-value).
#### Parameters
| | | |
| --- | --- | --- |
| range | a [GtkRange](gtkrange#GtkRange-struct) | |
| round\_digits | the precision in digits, or -1 | |
### gtk\_range\_get\_flippable ()
```
gboolean
gtk_range_get_flippable (*`[GtkRange](gtkrange#GtkRange-struct) *range`*);
```
Gets the value set by [`gtk_range_set_flippable()`](gtkrange#gtk-range-set-flippable).
#### Parameters
| | | |
| --- | --- | --- |
| range | a [GtkRange](gtkrange#GtkRange-struct) | |
#### Returns
`TRUE` if the range is flippable
### gtk\_range\_set\_flippable ()
```
void
gtk_range_set_flippable (*`[GtkRange](gtkrange#GtkRange-struct) *range`*,
*`gboolean flippable`*);
```
If a range is flippable, it will switch its direction if it is horizontal and its direction is [`GTK_TEXT_DIR_RTL`](gtkwidget#GTK-TEXT-DIR-RTL:CAPS).
See [`gtk_widget_get_direction()`](gtkwidget#gtk-widget-get-direction).
#### Parameters
| | | |
| --- | --- | --- |
| range | a [GtkRange](gtkrange#GtkRange-struct) | |
| flippable | `TRUE` to make the range flippable | |
### gtk\_range\_get\_range\_rect ()
```
void
gtk_range_get_range_rect (*`[GtkRange](gtkrange#GtkRange-struct) *range`*,
*`[GdkRectangle](https://developer-old.gnome.org/gtk4/html/gdk4-Rectangles-and-Regions.html#GdkRectangle-struct) *range_rect`*);
```
This function returns the area that contains the range’s trough, in coordinates relative to *`range`* 's origin.
This function is useful mainly for [GtkRange](gtkrange#GtkRange-struct) subclasses.
#### Parameters
| | | |
| --- | --- | --- |
| range | a [GtkRange](gtkrange#GtkRange-struct) | |
| range\_rect | return location for the range rectangle. | [out] |
### gtk\_range\_get\_slider\_range ()
```
void
gtk_range_get_slider_range (*`[GtkRange](gtkrange#GtkRange-struct) *range`*,
*`int *slider_start`*,
*`int *slider_end`*);
```
This function returns sliders range along the long dimension, in widget->window coordinates.
This function is useful mainly for [GtkRange](gtkrange#GtkRange-struct) subclasses.
#### Parameters
| | | |
| --- | --- | --- |
| range | a [GtkRange](gtkrange#GtkRange-struct) | |
| slider\_start | return location for the slider's start, or `NULL`. | [out][allow-none] |
| slider\_end | return location for the slider's end, or `NULL`. | [out][allow-none] |
### gtk\_range\_get\_slider\_size\_fixed ()
```
gboolean
gtk_range_get_slider_size_fixed (*`[GtkRange](gtkrange#GtkRange-struct) *range`*);
```
This function is useful mainly for [GtkRange](gtkrange#GtkRange-struct) subclasses.
See [`gtk_range_set_slider_size_fixed()`](gtkrange#gtk-range-set-slider-size-fixed).
#### Parameters
| | | |
| --- | --- | --- |
| range | a [GtkRange](gtkrange#GtkRange-struct) | |
#### Returns
whether the range’s slider has a fixed size.
### gtk\_range\_set\_slider\_size\_fixed ()
```
void
gtk_range_set_slider_size_fixed (*`[GtkRange](gtkrange#GtkRange-struct) *range`*,
*`gboolean size_fixed`*);
```
Sets whether the range’s slider has a fixed size, or a size that depends on its adjustment’s page size.
This function is useful mainly for [GtkRange](gtkrange#GtkRange-struct) subclasses.
#### Parameters
| | | |
| --- | --- | --- |
| range | a [GtkRange](gtkrange#GtkRange-struct) | |
| size\_fixed | `TRUE` to make the slider size constant | |
Types and Values
----------------
### struct GtkRange
```
struct GtkRange;
```
Property Details
----------------
### The `“adjustment”` property
```
“adjustment” [GtkAdjustment](gtkadjustment#GtkAdjustment-struct) *
```
The GtkAdjustment that contains the current value of this range object.
Owner: GtkRange
Flags: Read / Write / Construct
### The `“fill-level”` property
```
“fill-level” double
```
The fill level (e.g. prebuffering of a network stream). See [`gtk_range_set_fill_level()`](gtkrange#gtk-range-set-fill-level).
Owner: GtkRange
Flags: Read / Write
Default value: 1.79769e+308
### The `“inverted”` property
```
“inverted” gboolean
```
Invert direction slider moves to increase range value.
Owner: GtkRange
Flags: Read / Write
Default value: FALSE
### The `“restrict-to-fill-level”` property
```
“restrict-to-fill-level” gboolean
```
The restrict-to-fill-level property controls whether slider movement is restricted to an upper boundary set by the fill level. See [`gtk_range_set_restrict_to_fill_level()`](gtkrange#gtk-range-set-restrict-to-fill-level).
Owner: GtkRange
Flags: Read / Write
Default value: TRUE
### The `“round-digits”` property
```
“round-digits” int
```
The number of digits to round the value to when it changes, or -1. See [“change-value”](gtkrange#GtkRange-change-value).
Owner: GtkRange
Flags: Read / Write
Allowed values: >= -1
Default value: -1
### The `“show-fill-level”` property
```
“show-fill-level” gboolean
```
The show-fill-level property controls whether fill level indicator graphics are displayed on the trough. See [`gtk_range_set_show_fill_level()`](gtkrange#gtk-range-set-show-fill-level).
Owner: GtkRange
Flags: Read / Write
Default value: FALSE
Signal Details
--------------
### The `“adjust-bounds”` signal
```
void
user_function ([GtkRange](gtkrange#GtkRange-struct) *range,
double value,
gpointer user_data)
```
Emitted before clamping a value, to give the application a chance to adjust the bounds.
#### Parameters
| | | |
| --- | --- | --- |
| range | the [GtkRange](gtkrange#GtkRange-struct) that received the signal | |
| value | the value before we clamp | |
| user\_data | user data set when the signal handler was connected. | |
Flags: Run Last
### The `“change-value”` signal
```
gboolean
user_function ([GtkRange](gtkrange#GtkRange-struct) *range,
[GtkScrollType](gtk4-standard-enumerations#GtkScrollType) scroll,
double value,
gpointer user_data)
```
The [“change-value”](gtkrange#GtkRange-change-value) signal is emitted when a scroll action is performed on a range. It allows an application to determine the type of scroll event that occurred and the resultant new value. The application can handle the event itself and return `TRUE` to prevent further processing. Or, by returning `FALSE`, it can pass the event to other handlers until the default GTK handler is reached.
The value parameter is unrounded. An application that overrides the GtkRange::change-value signal is responsible for clamping the value to the desired number of decimal digits; the default GTK handler clamps the value based on [“round-digits”](gtkrange#GtkRange--round-digits).
#### Parameters
| | | |
| --- | --- | --- |
| range | the [GtkRange](gtkrange#GtkRange-struct) that received the signal | |
| scroll | the type of scroll action that was performed | |
| value | the new value resulting from the scroll action | |
| user\_data | user data set when the signal handler was connected. | |
#### Returns
`TRUE` to prevent other handlers from being invoked for the signal, `FALSE` to propagate the signal further
Flags: Run Last
### The `“move-slider”` signal
```
void
user_function ([GtkRange](gtkrange#GtkRange-struct) *range,
[GtkScrollType](gtk4-standard-enumerations#GtkScrollType) step,
gpointer user_data)
```
Virtual function that moves the slider. Used for keybindings.
#### Parameters
| | | |
| --- | --- | --- |
| range | the [GtkRange](gtkrange#GtkRange-struct) that received the signal | |
| step | how to move the slider | |
| user\_data | user data set when the signal handler was connected. | |
Flags: Action
### The `“value-changed”` signal
```
void
user_function ([GtkRange](gtkrange#GtkRange-struct) *range,
gpointer user_data)
```
Emitted when the range value changes.
#### Parameters
| | | |
| --- | --- | --- |
| range | the [GtkRange](gtkrange#GtkRange-struct) that received the signal | |
| user\_data | user data set when the signal handler was connected. | |
Flags: Run Last
| programming_docs |
gtk GtkAdjustment GtkAdjustment
=============
GtkAdjustment — A representation of an adjustable bounded value
Functions
---------
| | |
| --- | --- |
| [GtkAdjustment](gtkadjustment#GtkAdjustment-struct) \* | [gtk\_adjustment\_new](gtkadjustment#gtk-adjustment-new) () |
| double | [gtk\_adjustment\_get\_value](gtkadjustment#gtk-adjustment-get-value) () |
| void | [gtk\_adjustment\_set\_value](gtkadjustment#gtk-adjustment-set-value) () |
| void | [gtk\_adjustment\_clamp\_page](gtkadjustment#gtk-adjustment-clamp-page) () |
| void | [gtk\_adjustment\_configure](gtkadjustment#gtk-adjustment-configure) () |
| double | [gtk\_adjustment\_get\_lower](gtkadjustment#gtk-adjustment-get-lower) () |
| double | [gtk\_adjustment\_get\_page\_increment](gtkadjustment#gtk-adjustment-get-page-increment) () |
| double | [gtk\_adjustment\_get\_page\_size](gtkadjustment#gtk-adjustment-get-page-size) () |
| double | [gtk\_adjustment\_get\_step\_increment](gtkadjustment#gtk-adjustment-get-step-increment) () |
| double | [gtk\_adjustment\_get\_minimum\_increment](gtkadjustment#gtk-adjustment-get-minimum-increment) () |
| double | [gtk\_adjustment\_get\_upper](gtkadjustment#gtk-adjustment-get-upper) () |
| void | [gtk\_adjustment\_set\_lower](gtkadjustment#gtk-adjustment-set-lower) () |
| void | [gtk\_adjustment\_set\_page\_increment](gtkadjustment#gtk-adjustment-set-page-increment) () |
| void | [gtk\_adjustment\_set\_page\_size](gtkadjustment#gtk-adjustment-set-page-size) () |
| void | [gtk\_adjustment\_set\_step\_increment](gtkadjustment#gtk-adjustment-set-step-increment) () |
| void | [gtk\_adjustment\_set\_upper](gtkadjustment#gtk-adjustment-set-upper) () |
Properties
----------
| | | |
| --- | --- | --- |
| double | [lower](gtkadjustment#GtkAdjustment--lower) | Read / Write |
| double | [page-increment](gtkadjustment#GtkAdjustment--page-increment) | Read / Write |
| double | [page-size](gtkadjustment#GtkAdjustment--page-size) | Read / Write |
| double | [step-increment](gtkadjustment#GtkAdjustment--step-increment) | Read / Write |
| double | [upper](gtkadjustment#GtkAdjustment--upper) | Read / Write |
| double | [value](gtkadjustment#GtkAdjustment--value) | Read / Write |
Signals
-------
| | | |
| --- | --- | --- |
| void | [changed](gtkadjustment#GtkAdjustment-changed) | No Recursion |
| void | [value-changed](gtkadjustment#GtkAdjustment-value-changed) | No Recursion |
Types and Values
----------------
| | |
| --- | --- |
| | [GtkAdjustment](gtkadjustment#GtkAdjustment-struct) |
Object Hierarchy
----------------
```
GObject
╰── GInitiallyUnowned
╰── GtkAdjustment
```
Includes
--------
```
#include <gtk/gtk.h>
```
Description
-----------
The [GtkAdjustment](gtkadjustment#GtkAdjustment-struct) object represents a value which has an associated lower and upper bound, together with step and page increments, and a page size. It is used within several GTK+ widgets, including [GtkSpinButton](gtkspinbutton#GtkSpinButton-struct), [GtkViewport](gtkviewport#GtkViewport-struct), and [GtkRange](gtkrange#GtkRange-struct) (which is a base class for [GtkScrollbar](gtkscrollbar#GtkScrollbar-struct) and [GtkScale](gtkscale#GtkScale-struct)).
The [GtkAdjustment](gtkadjustment#GtkAdjustment-struct) object does not update the value itself. Instead it is left up to the owner of the [GtkAdjustment](gtkadjustment#GtkAdjustment-struct) to control the value.
Functions
---------
### gtk\_adjustment\_new ()
```
[GtkAdjustment](gtkadjustment#GtkAdjustment-struct) *
gtk_adjustment_new (*`double value`*,
*`double lower`*,
*`double upper`*,
*`double step_increment`*,
*`double page_increment`*,
*`double page_size`*);
```
Creates a new [GtkAdjustment](gtkadjustment#GtkAdjustment-struct).
#### Parameters
| | | |
| --- | --- | --- |
| value | the initial value | |
| lower | the minimum value | |
| upper | the maximum value | |
| step\_increment | the step increment | |
| page\_increment | the page increment | |
| page\_size | the page size | |
#### Returns
a new [GtkAdjustment](gtkadjustment#GtkAdjustment-struct)
### gtk\_adjustment\_get\_value ()
```
double
gtk_adjustment_get_value (*`[GtkAdjustment](gtkadjustment#GtkAdjustment-struct) *adjustment`*);
```
Gets the current value of the adjustment. See [`gtk_adjustment_set_value()`](gtkadjustment#gtk-adjustment-set-value).
#### Parameters
| | | |
| --- | --- | --- |
| adjustment | a [GtkAdjustment](gtkadjustment#GtkAdjustment-struct) | |
#### Returns
The current value of the adjustment
### gtk\_adjustment\_set\_value ()
```
void
gtk_adjustment_set_value (*`[GtkAdjustment](gtkadjustment#GtkAdjustment-struct) *adjustment`*,
*`double value`*);
```
Sets the [GtkAdjustment](gtkadjustment#GtkAdjustment-struct) value. The value is clamped to lie between [“lower”](gtkadjustment#GtkAdjustment--lower) and [“upper”](gtkadjustment#GtkAdjustment--upper).
Note that for adjustments which are used in a [GtkScrollbar](gtkscrollbar#GtkScrollbar-struct), the effective range of allowed values goes from [“lower”](gtkadjustment#GtkAdjustment--lower) to [“upper”](gtkadjustment#GtkAdjustment--upper) - [“page-size”](gtkadjustment#GtkAdjustment--page-size).
#### Parameters
| | | |
| --- | --- | --- |
| adjustment | a [GtkAdjustment](gtkadjustment#GtkAdjustment-struct) | |
| value | the new value | |
### gtk\_adjustment\_clamp\_page ()
```
void
gtk_adjustment_clamp_page (*`[GtkAdjustment](gtkadjustment#GtkAdjustment-struct) *adjustment`*,
*`double lower`*,
*`double upper`*);
```
Updates the [“value”](gtkadjustment#GtkAdjustment--value) property to ensure that the range between *`lower`* and *`upper`* is in the current page (i.e. between [“value”](gtkadjustment#GtkAdjustment--value) and [“value”](gtkadjustment#GtkAdjustment--value) + [“page-size”](gtkadjustment#GtkAdjustment--page-size)). If the range is larger than the page size, then only the start of it will be in the current page.
A [“value-changed”](gtkadjustment#GtkAdjustment-value-changed) signal will be emitted if the value is changed.
#### Parameters
| | | |
| --- | --- | --- |
| adjustment | a [GtkAdjustment](gtkadjustment#GtkAdjustment-struct) | |
| lower | the lower value | |
| upper | the upper value | |
### gtk\_adjustment\_configure ()
```
void
gtk_adjustment_configure (*`[GtkAdjustment](gtkadjustment#GtkAdjustment-struct) *adjustment`*,
*`double value`*,
*`double lower`*,
*`double upper`*,
*`double step_increment`*,
*`double page_increment`*,
*`double page_size`*);
```
Sets all properties of the adjustment at once.
Use this function to avoid multiple emissions of the [“changed”](gtkadjustment#GtkAdjustment-changed) signal. See [`gtk_adjustment_set_lower()`](gtkadjustment#gtk-adjustment-set-lower) for an alternative way of compressing multiple emissions of [“changed”](gtkadjustment#GtkAdjustment-changed) into one.
#### Parameters
| | | |
| --- | --- | --- |
| adjustment | a [GtkAdjustment](gtkadjustment#GtkAdjustment-struct) | |
| value | the new value | |
| lower | the new minimum value | |
| upper | the new maximum value | |
| step\_increment | the new step increment | |
| page\_increment | the new page increment | |
| page\_size | the new page size | |
### gtk\_adjustment\_get\_lower ()
```
double
gtk_adjustment_get_lower (*`[GtkAdjustment](gtkadjustment#GtkAdjustment-struct) *adjustment`*);
```
Retrieves the minimum value of the adjustment.
#### Parameters
| | | |
| --- | --- | --- |
| adjustment | a [GtkAdjustment](gtkadjustment#GtkAdjustment-struct) | |
#### Returns
The current minimum value of the adjustment
### gtk\_adjustment\_get\_page\_increment ()
```
double
gtk_adjustment_get_page_increment (*`[GtkAdjustment](gtkadjustment#GtkAdjustment-struct) *adjustment`*);
```
Retrieves the page increment of the adjustment.
#### Parameters
| | | |
| --- | --- | --- |
| adjustment | a [GtkAdjustment](gtkadjustment#GtkAdjustment-struct) | |
#### Returns
The current page increment of the adjustment
### gtk\_adjustment\_get\_page\_size ()
```
double
gtk_adjustment_get_page_size (*`[GtkAdjustment](gtkadjustment#GtkAdjustment-struct) *adjustment`*);
```
Retrieves the page size of the adjustment.
#### Parameters
| | | |
| --- | --- | --- |
| adjustment | a [GtkAdjustment](gtkadjustment#GtkAdjustment-struct) | |
#### Returns
The current page size of the adjustment
### gtk\_adjustment\_get\_step\_increment ()
```
double
gtk_adjustment_get_step_increment (*`[GtkAdjustment](gtkadjustment#GtkAdjustment-struct) *adjustment`*);
```
Retrieves the step increment of the adjustment.
#### Parameters
| | | |
| --- | --- | --- |
| adjustment | a [GtkAdjustment](gtkadjustment#GtkAdjustment-struct) | |
#### Returns
The current step increment of the adjustment.
### gtk\_adjustment\_get\_minimum\_increment ()
```
double
gtk_adjustment_get_minimum_increment (*`[GtkAdjustment](gtkadjustment#GtkAdjustment-struct) *adjustment`*);
```
Gets the smaller of step increment and page increment.
#### Parameters
| | | |
| --- | --- | --- |
| adjustment | a [GtkAdjustment](gtkadjustment#GtkAdjustment-struct) | |
#### Returns
the minimum increment of *`adjustment`*
### gtk\_adjustment\_get\_upper ()
```
double
gtk_adjustment_get_upper (*`[GtkAdjustment](gtkadjustment#GtkAdjustment-struct) *adjustment`*);
```
Retrieves the maximum value of the adjustment.
#### Parameters
| | | |
| --- | --- | --- |
| adjustment | a [GtkAdjustment](gtkadjustment#GtkAdjustment-struct) | |
#### Returns
The current maximum value of the adjustment
### gtk\_adjustment\_set\_lower ()
```
void
gtk_adjustment_set_lower (*`[GtkAdjustment](gtkadjustment#GtkAdjustment-struct) *adjustment`*,
*`double lower`*);
```
Sets the minimum value of the adjustment.
When setting multiple adjustment properties via their individual setters, multiple [“changed”](gtkadjustment#GtkAdjustment-changed) signals will be emitted. However, since the emission of the [“changed”](gtkadjustment#GtkAdjustment-changed) signal is tied to the emission of the “notify” signals of the changed properties, it’s possible to compress the [“changed”](gtkadjustment#GtkAdjustment-changed) signals into one by calling `g_object_freeze_notify()` and `g_object_thaw_notify()` around the calls to the individual setters.
Alternatively, using a single `g_object_set()` for all the properties to change, or using [`gtk_adjustment_configure()`](gtkadjustment#gtk-adjustment-configure) has the same effect of compressing [“changed”](gtkadjustment#GtkAdjustment-changed) emissions.
#### Parameters
| | | |
| --- | --- | --- |
| adjustment | a [GtkAdjustment](gtkadjustment#GtkAdjustment-struct) | |
| lower | the new minimum value | |
### gtk\_adjustment\_set\_page\_increment ()
```
void
gtk_adjustment_set_page_increment (*`[GtkAdjustment](gtkadjustment#GtkAdjustment-struct) *adjustment`*,
*`double page_increment`*);
```
Sets the page increment of the adjustment.
See [`gtk_adjustment_set_lower()`](gtkadjustment#gtk-adjustment-set-lower) about how to compress multiple emissions of the [“changed”](gtkadjustment#GtkAdjustment-changed) signal when setting multiple adjustment properties.
#### Parameters
| | | |
| --- | --- | --- |
| adjustment | a [GtkAdjustment](gtkadjustment#GtkAdjustment-struct) | |
| page\_increment | the new page increment | |
### gtk\_adjustment\_set\_page\_size ()
```
void
gtk_adjustment_set_page_size (*`[GtkAdjustment](gtkadjustment#GtkAdjustment-struct) *adjustment`*,
*`double page_size`*);
```
Sets the page size of the adjustment.
See [`gtk_adjustment_set_lower()`](gtkadjustment#gtk-adjustment-set-lower) about how to compress multiple emissions of the GtkAdjustment::changed signal when setting multiple adjustment properties.
#### Parameters
| | | |
| --- | --- | --- |
| adjustment | a [GtkAdjustment](gtkadjustment#GtkAdjustment-struct) | |
| page\_size | the new page size | |
### gtk\_adjustment\_set\_step\_increment ()
```
void
gtk_adjustment_set_step_increment (*`[GtkAdjustment](gtkadjustment#GtkAdjustment-struct) *adjustment`*,
*`double step_increment`*);
```
Sets the step increment of the adjustment.
See [`gtk_adjustment_set_lower()`](gtkadjustment#gtk-adjustment-set-lower) about how to compress multiple emissions of the [“changed”](gtkadjustment#GtkAdjustment-changed) signal when setting multiple adjustment properties.
#### Parameters
| | | |
| --- | --- | --- |
| adjustment | a [GtkAdjustment](gtkadjustment#GtkAdjustment-struct) | |
| step\_increment | the new step increment | |
### gtk\_adjustment\_set\_upper ()
```
void
gtk_adjustment_set_upper (*`[GtkAdjustment](gtkadjustment#GtkAdjustment-struct) *adjustment`*,
*`double upper`*);
```
Sets the maximum value of the adjustment.
Note that values will be restricted by `upper - page-size` if the page-size property is nonzero.
See [`gtk_adjustment_set_lower()`](gtkadjustment#gtk-adjustment-set-lower) about how to compress multiple emissions of the [“changed”](gtkadjustment#GtkAdjustment-changed) signal when setting multiple adjustment properties.
#### Parameters
| | | |
| --- | --- | --- |
| adjustment | a [GtkAdjustment](gtkadjustment#GtkAdjustment-struct) | |
| upper | the new maximum value | |
Types and Values
----------------
### GtkAdjustment
```
typedef struct _GtkAdjustment GtkAdjustment;
```
The [GtkAdjustment](gtkadjustment#GtkAdjustment-struct) contains only private fields and should not be directly accessed.
Property Details
----------------
### The `“lower”` property
```
“lower” double
```
The minimum value of the adjustment.
Owner: GtkAdjustment
Flags: Read / Write
Default value: 0
### The `“page-increment”` property
```
“page-increment” double
```
The page increment of the adjustment.
Owner: GtkAdjustment
Flags: Read / Write
Default value: 0
### The `“page-size”` property
```
“page-size” double
```
The page size of the adjustment. Note that the page-size is irrelevant and should be set to zero if the adjustment is used for a simple scalar value, e.g. in a [GtkSpinButton](gtkspinbutton#GtkSpinButton-struct).
Owner: GtkAdjustment
Flags: Read / Write
Default value: 0
### The `“step-increment”` property
```
“step-increment” double
```
The step increment of the adjustment.
Owner: GtkAdjustment
Flags: Read / Write
Default value: 0
### The `“upper”` property
```
“upper” double
```
The maximum value of the adjustment. Note that values will be restricted by `upper - page-size` if the page-size property is nonzero.
Owner: GtkAdjustment
Flags: Read / Write
Default value: 0
### The `“value”` property
```
“value” double
```
The value of the adjustment.
Owner: GtkAdjustment
Flags: Read / Write
Default value: 0
Signal Details
--------------
### The `“changed”` signal
```
void
user_function ([GtkAdjustment](gtkadjustment#GtkAdjustment-struct) *adjustment,
gpointer user_data)
```
Emitted when one or more of the [GtkAdjustment](gtkadjustment#GtkAdjustment-struct) properties have been changed, other than the [“value”](gtkadjustment#GtkAdjustment--value) property.
#### Parameters
| | | |
| --- | --- | --- |
| adjustment | the object which received the signal | |
| user\_data | user data set when the signal handler was connected. | |
Flags: No Recursion
### The `“value-changed”` signal
```
void
user_function ([GtkAdjustment](gtkadjustment#GtkAdjustment-struct) *adjustment,
gpointer user_data)
```
Emitted when the [“value”](gtkadjustment#GtkAdjustment--value) property has been changed.
#### Parameters
| | | |
| --- | --- | --- |
| adjustment | the object which received the signal | |
| user\_data | user data set when the signal handler was connected. | |
Flags: No Recursion
gtk GtkAccessible GtkAccessible
=============
GtkAccessible — Accessible interface
Functions
---------
| | |
| --- | --- |
| [GtkAccessibleRole](gtkaccessible#GtkAccessibleRole) | [gtk\_accessible\_get\_accessible\_role](gtkaccessible#gtk-accessible-get-accessible-role) () |
| void | [gtk\_accessible\_update\_state](gtkaccessible#gtk-accessible-update-state) () |
| void | [gtk\_accessible\_update\_state\_value](gtkaccessible#gtk-accessible-update-state-value) () |
| void | [gtk\_accessible\_reset\_state](gtkaccessible#gtk-accessible-reset-state) () |
| void | [gtk\_accessible\_update\_property](gtkaccessible#gtk-accessible-update-property) () |
| void | [gtk\_accessible\_update\_property\_value](gtkaccessible#gtk-accessible-update-property-value) () |
| void | [gtk\_accessible\_reset\_property](gtkaccessible#gtk-accessible-reset-property) () |
| void | [gtk\_accessible\_update\_relation](gtkaccessible#gtk-accessible-update-relation) () |
| void | [gtk\_accessible\_update\_relation\_value](gtkaccessible#gtk-accessible-update-relation-value) () |
| void | [gtk\_accessible\_reset\_relation](gtkaccessible#gtk-accessible-reset-relation) () |
| void | [gtk\_accessible\_property\_init\_value](gtkaccessible#gtk-accessible-property-init-value) () |
| void | [gtk\_accessible\_relation\_init\_value](gtkaccessible#gtk-accessible-relation-init-value) () |
| void | [gtk\_accessible\_state\_init\_value](gtkaccessible#gtk-accessible-state-init-value) () |
Properties
----------
| | | |
| --- | --- | --- |
| [GtkAccessibleRole](gtkaccessible#GtkAccessibleRole) | [accessible-role](gtkaccessible#GtkAccessible--accessible-role) | Read / Write |
Types and Values
----------------
| | |
| --- | --- |
| | [GtkAccessible](gtkaccessible#GtkAccessible-struct) |
| enum | [GtkAccessibleRole](gtkaccessible#GtkAccessibleRole) |
| enum | [GtkAccessibleState](gtkaccessible#GtkAccessibleState) |
| enum | [GtkAccessibleProperty](gtkaccessible#GtkAccessibleProperty) |
| enum | [GtkAccessibleRelation](gtkaccessible#GtkAccessibleRelation) |
| enum | [GtkAccessibleTristate](gtkaccessible#GtkAccessibleTristate) |
| enum | [GtkAccessibleInvalidState](gtkaccessible#GtkAccessibleInvalidState) |
| enum | [GtkAccessibleAutocomplete](gtkaccessible#GtkAccessibleAutocomplete) |
| enum | [GtkAccessibleSort](gtkaccessible#GtkAccessibleSort) |
Object Hierarchy
----------------
```
[GInterface](https://developer-old.gnome.org/gobject/stable/GTypeModule.html)
╰── GtkAccessible
```
Prerequisites
-------------
GtkAccessible requires GObject.
Known Implementations
---------------------
GtkAccessible is implemented by [GtkAboutDialog](gtkaboutdialog#GtkAboutDialog-struct), [GtkActionBar](gtkactionbar#GtkActionBar-struct), [GtkAppChooserButton](gtkappchooserbutton#GtkAppChooserButton-struct), [GtkAppChooserDialog](gtkappchooserdialog#GtkAppChooserDialog-struct), [GtkAppChooserWidget](gtkappchooserwidget#GtkAppChooserWidget-struct), [GtkApplicationWindow](gtkapplicationwindow#GtkApplicationWindow-struct), [GtkAspectFrame](gtkaspectframe#GtkAspectFrame-struct), [GtkAssistant](gtkassistant#GtkAssistant-struct), [GtkBox](gtkbox#GtkBox-struct), [GtkButton](gtkbutton#GtkButton-struct), [GtkCalendar](gtkcalendar#GtkCalendar-struct), [GtkCellView](gtkcellview#GtkCellView-struct), [GtkCenterBox](https://developer-old.gnome.org/usr/share/gtk-doc/html/gtk4/gtk4-GtkCenterBox.html#GtkCenterBox), [GtkCheckButton](gtkcheckbutton#GtkCheckButton-struct), [GtkColorButton](gtkcolorbutton#GtkColorButton-struct), [GtkColorChooserDialog](gtkcolorchooserdialog#GtkColorChooserDialog-struct), [GtkColorChooserWidget](gtkcolorchooserwidget#GtkColorChooserWidget-struct), [GtkColumnView](gtkcolumnview#GtkColumnView-struct), [GtkComboBox](gtkcombobox#GtkComboBox-struct), [GtkComboBoxText](gtkcomboboxtext#GtkComboBoxText-struct), [GtkDialog](gtkdialog#GtkDialog-struct), [GtkDragIcon](gtkdragicon#GtkDragIcon-struct), [GtkDrawingArea](gtkdrawingarea#GtkDrawingArea-struct), [GtkDropDown](gtkdropdown#GtkDropDown-struct), [GtkEditableLabel](gtkeditablelabel#GtkEditableLabel-struct), [GtkEmojiChooser](gtkemojichooser#GtkEmojiChooser-struct), [GtkEntry](gtkentry#GtkEntry-struct), [GtkExpander](gtkexpander#GtkExpander-struct), [GtkFileChooserDialog](gtkfilechooserdialog#GtkFileChooserDialog-struct), [GtkFileChooserWidget](gtkfilechooserwidget#GtkFileChooserWidget-struct), [GtkFixed](gtkfixed#GtkFixed-struct), [GtkFlowBox](gtkflowbox#GtkFlowBox-struct), [GtkFlowBoxChild](gtkflowbox#GtkFlowBoxChild-struct), [GtkFontButton](gtkfontbutton#GtkFontButton-struct), [GtkFontChooserDialog](gtkfontchooserdialog#GtkFontChooserDialog-struct), [GtkFontChooserWidget](gtkfontchooserwidget#GtkFontChooserWidget-struct), [GtkFrame](gtkframe#GtkFrame-struct), [GtkGLArea](gtkglarea#GtkGLArea-struct), [GtkGrid](gtkgrid#GtkGrid-struct), [GtkGridView](gtkgridview#GtkGridView-struct), [GtkHeaderBar](gtkheaderbar#GtkHeaderBar-struct), [GtkIconView](gtkiconview#GtkIconView-struct), [GtkImage](gtkimage#GtkImage-struct), [GtkInfoBar](gtkinfobar#GtkInfoBar-struct), [GtkLabel](gtklabel#GtkLabel-struct), [GtkLevelBar](gtklevelbar#GtkLevelBar-struct), [GtkLinkButton](gtklinkbutton#GtkLinkButton-struct), [GtkListBox](gtklistbox#GtkListBox-struct), [GtkListBoxRow](gtklistbox#GtkListBoxRow-struct), [GtkListView](gtklistview#GtkListView-struct), [GtkLockButton](gtklockbutton#GtkLockButton-struct), [GtkMediaControls](gtkmediacontrols#GtkMediaControls-struct), [GtkMenuButton](gtkmenubutton#GtkMenuButton-struct), [GtkMessageDialog](gtkmessagedialog#GtkMessageDialog-struct), [GtkNotebook](gtknotebook#GtkNotebook-struct), [GtkOverlay](gtkoverlay#GtkOverlay-struct), [GtkPageSetupUnixDialog](gtkpagesetupunixdialog#GtkPageSetupUnixDialog-struct), [GtkPaned](gtkpaned#GtkPaned-struct), [GtkPasswordEntry](gtkpasswordentry#GtkPasswordEntry-struct), [GtkPicture](gtkpicture#GtkPicture-struct), [GtkPopover](gtkpopover#GtkPopover-struct), [GtkPopoverMenu](gtkpopovermenu#GtkPopoverMenu-struct), [GtkPopoverMenuBar](gtkpopovermenubar#GtkPopoverMenuBar-struct), [GtkPrintUnixDialog](gtkprintunixdialog#GtkPrintUnixDialog-struct), [GtkProgressBar](gtkprogressbar#GtkProgressBar-struct), [GtkRange](gtkrange#GtkRange-struct), [GtkRevealer](gtkrevealer#GtkRevealer-struct), [GtkScale](gtkscale#GtkScale-struct), [GtkScaleButton](gtkscalebutton#GtkScaleButton-struct), [GtkScrollbar](gtkscrollbar#GtkScrollbar-struct), [GtkScrolledWindow](gtkscrolledwindow#GtkScrolledWindow-struct), [GtkSearchBar](gtksearchbar#GtkSearchBar-struct), [GtkSearchEntry](gtksearchentry#GtkSearchEntry-struct), [GtkSeparator](gtkseparator#GtkSeparator-struct), [GtkShortcutLabel](gtkshortcutlabel#GtkShortcutLabel-struct), [GtkShortcutsGroup](gtkshortcutsgroup#GtkShortcutsGroup-struct), [GtkShortcutsSection](gtkshortcutssection#GtkShortcutsSection-struct), [GtkShortcutsShortcut](gtkshortcutsshortcut#GtkShortcutsShortcut-struct), [GtkShortcutsWindow](gtkshortcutswindow#GtkShortcutsWindow-struct), [GtkSpinButton](gtkspinbutton#GtkSpinButton-struct), [GtkSpinner](gtkspinner#GtkSpinner-struct), [GtkStack](gtkstack#GtkStack-struct), [GtkStackPage](gtkstack#GtkStackPage-struct), [GtkStackSidebar](gtkstacksidebar#GtkStackSidebar-struct), [GtkStackSwitcher](gtkstackswitcher#GtkStackSwitcher-struct), [GtkStatusbar](gtkstatusbar#GtkStatusbar-struct), [GtkSwitch](gtkswitch#GtkSwitch-struct), [GtkText](gtktext#GtkText-struct), [GtkTextView](gtktextview#GtkTextView-struct), [GtkToggleButton](gtktogglebutton#GtkToggleButton-struct), [GtkTreeExpander](gtktreeexpander#GtkTreeExpander-struct), [GtkTreeView](gtktreeview#GtkTreeView-struct), [GtkVideo](gtkvideo#GtkVideo-struct), [GtkViewport](gtkviewport#GtkViewport-struct), [GtkVolumeButton](gtkvolumebutton#GtkVolumeButton-struct), [GtkWidget](gtkwidget#GtkWidget-struct), [GtkWindow](gtkwindow#GtkWindow-struct), [GtkWindowControls](gtkwindowcontrols#GtkWindowControls-struct) and [GtkWindowHandle](gtkwindowhandle#GtkWindowHandle-struct).
Includes
--------
```
#include <gtk/gtk.h>
```
Description
-----------
GtkAccessible provides an interface for describing a UI element, like a [GtkWidget](gtkwidget#GtkWidget-struct), in a way that can be consumed by Assistive Technologies, or “AT”. Every accessible implementation has:
* a “role”, represented by a value of the [GtkAccessibleRole](gtkaccessible#GtkAccessibleRole) enumeration
* an “attribute”, represented by a set of [GtkAccessibleState](gtkaccessible#GtkAccessibleState), [GtkAccessibleProperty](gtkaccessible#GtkAccessibleProperty) and [GtkAccessibleRelation](gtkaccessible#GtkAccessibleRelation) values
The role cannot be changed after instantiating a [GtkAccessible](gtkaccessible#GtkAccessible-struct) implementation.
The attributes are updated every time a UI element's state changes in a way that should be reflected by assistive technologies. For instance, if a [GtkWidget](gtkwidget#GtkWidget-struct) visibility changes, the [`GTK_ACCESSIBLE_STATE_HIDDEN`](gtkaccessible#GTK-ACCESSIBLE-STATE-HIDDEN:CAPS) state will also change to reflect the [“visible”](gtkwidget#GtkWidget--visible) property.
Functions
---------
### gtk\_accessible\_get\_accessible\_role ()
```
[GtkAccessibleRole](gtkaccessible#GtkAccessibleRole)
gtk_accessible_get_accessible_role (*`[GtkAccessible](gtkaccessible#GtkAccessible-struct) *self`*);
```
Retrieves the [GtkAccessibleRole](gtkaccessible#GtkAccessibleRole) for the given [GtkAccessible](gtkaccessible#GtkAccessible-struct).
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkAccessible](gtkaccessible#GtkAccessible-struct) | |
#### Returns
a [GtkAccessibleRole](gtkaccessible#GtkAccessibleRole)
### gtk\_accessible\_update\_state ()
```
void
gtk_accessible_update_state (*`[GtkAccessible](gtkaccessible#GtkAccessible-struct) *self`*,
*`[GtkAccessibleState](gtkaccessible#GtkAccessibleState) first_state`*,
*`...`*);
```
Updates a list of accessible states. See the [GtkAccessibleState](gtkaccessible#GtkAccessibleState) documentation for the value types of accessible states.
This function should be called by [GtkWidget](gtkwidget#GtkWidget-struct) types whenever an accessible state change must be communicated to assistive technologies.
Example:
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkAccessible](gtkaccessible#GtkAccessible-struct) | |
| first\_state | the first [GtkAccessibleState](gtkaccessible#GtkAccessibleState) | |
| ... | a list of state and value pairs, terminated by -1 | |
### gtk\_accessible\_update\_state\_value ()
```
void
gtk_accessible_update_state_value (*`[GtkAccessible](gtkaccessible#GtkAccessible-struct) *self`*,
*`int n_states`*,
*`[GtkAccessibleState](gtkaccessible#GtkAccessibleState) states[]`*,
*`const GValue values[]`*);
```
Updates an array of accessible states.
This function should be called by [GtkWidget](gtkwidget#GtkWidget-struct) types whenever an accessible state change must be communicated to assistive technologies.
This function is meant to be used by language bindings.
[rename-to gtk\_accessible\_update\_state]
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkAccessible](gtkaccessible#GtkAccessible-struct) | |
| n\_states | the number of accessible states to set | |
| states | an array of [GtkAccessibleState](gtkaccessible#GtkAccessibleState). | [array length=n\_states] |
| values | an array of GValues, one for each state. | [array length=n\_states] |
### gtk\_accessible\_reset\_state ()
```
void
gtk_accessible_reset_state (*`[GtkAccessible](gtkaccessible#GtkAccessible-struct) *self`*,
*`[GtkAccessibleState](gtkaccessible#GtkAccessibleState) state`*);
```
Resets the accessible *`state`* to its default value.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkAccessible](gtkaccessible#GtkAccessible-struct) | |
| state | a [GtkAccessibleState](gtkaccessible#GtkAccessibleState) | |
### gtk\_accessible\_update\_property ()
```
void
gtk_accessible_update_property (*`[GtkAccessible](gtkaccessible#GtkAccessible-struct) *self`*,
*`[GtkAccessibleProperty](gtkaccessible#GtkAccessibleProperty) first_property`*,
*`...`*);
```
Updates a list of accessible properties. See the [GtkAccessibleProperty](gtkaccessible#GtkAccessibleProperty) documentation for the value types of accessible properties.
This function should be called by [GtkWidget](gtkwidget#GtkWidget-struct) types whenever an accessible property change must be communicated to assistive technologies.
Example:
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkAccessible](gtkaccessible#GtkAccessible-struct) | |
| first\_property | the first [GtkAccessibleProperty](gtkaccessible#GtkAccessibleProperty) | |
| ... | a list of property and value pairs, terminated by -1 | |
### gtk\_accessible\_update\_property\_value ()
```
void
gtk_accessible_update_property_value (*`[GtkAccessible](gtkaccessible#GtkAccessible-struct) *self`*,
*`int n_properties`*,
*`[GtkAccessibleProperty](gtkaccessible#GtkAccessibleProperty) properties[]`*,
*`const GValue values[]`*);
```
Updates an array of accessible properties.
This function should be called by [GtkWidget](gtkwidget#GtkWidget-struct) types whenever an accessible property change must be communicated to assistive technologies.
This function is meant to be used by language bindings.
[rename-to gtk\_accessible\_update\_property]
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkAccessible](gtkaccessible#GtkAccessible-struct) | |
| n\_properties | the number of accessible properties to set | |
| properties | an array of [GtkAccessibleProperty](gtkaccessible#GtkAccessibleProperty). | [array length=n\_properties] |
| values | an array of GValues, one for each property. | [array length=n\_properties] |
### gtk\_accessible\_reset\_property ()
```
void
gtk_accessible_reset_property (*`[GtkAccessible](gtkaccessible#GtkAccessible-struct) *self`*,
*`[GtkAccessibleProperty](gtkaccessible#GtkAccessibleProperty) property`*);
```
Resets the accessible *`property`* to its default value.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkAccessible](gtkaccessible#GtkAccessible-struct) | |
| property | a [GtkAccessibleProperty](gtkaccessible#GtkAccessibleProperty) | |
### gtk\_accessible\_update\_relation ()
```
void
gtk_accessible_update_relation (*`[GtkAccessible](gtkaccessible#GtkAccessible-struct) *self`*,
*`[GtkAccessibleRelation](gtkaccessible#GtkAccessibleRelation) first_relation`*,
*`...`*);
```
Updates a list of accessible relations.
This function should be called by [GtkWidget](gtkwidget#GtkWidget-struct) types whenever an accessible relation change must be communicated to assistive technologies.
If the [GtkAccessibleRelation](gtkaccessible#GtkAccessibleRelation) requires a list of references, you should pass each reference individually, followed by `NULL`, e.g.
```
value = GTK_ACCESSIBLE_TRISTATE_MIXED;
gtk_accessible_update_state (GTK_ACCESSIBLE (check_button),
GTK_ACCESSIBLE_STATE_CHECKED, value,
-1);
```
| #### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkAccessible](gtkaccessible#GtkAccessible-struct) | |
| first\_relation | the first [GtkAccessibleRelation](gtkaccessible#GtkAccessibleRelation) | |
| ... | a list of relation and value pairs, terminated by -1 | |
### gtk\_accessible\_update\_relation\_value ()
```
void
gtk_accessible_update_relation_value (*`[GtkAccessible](gtkaccessible#GtkAccessible-struct) *self`*,
*`int n_relations`*,
*`[GtkAccessibleRelation](gtkaccessible#GtkAccessibleRelation) relations[]`*,
*`const GValue values[]`*);
```
Updates an array of accessible relations.
This function should be called by [GtkWidget](gtkwidget#GtkWidget-struct) types whenever an accessible relation change must be communicated to assistive technologies.
This function is meant to be used by language bindings.
[rename-to gtk\_accessible\_update\_relation]
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkAccessible](gtkaccessible#GtkAccessible-struct) | |
| n\_relations | the number of accessible relations to set | |
| relations | an array of [GtkAccessibleRelation](gtkaccessible#GtkAccessibleRelation). | [array length=n\_relations] |
| values | an array of GValues, one for each relation. | [array length=n\_relations] |
### gtk\_accessible\_reset\_relation ()
```
void
gtk_accessible_reset_relation (*`[GtkAccessible](gtkaccessible#GtkAccessible-struct) *self`*,
*`[GtkAccessibleRelation](gtkaccessible#GtkAccessibleRelation) relation`*);
```
Resets the accessible *`relation`* to its default value.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkAccessible](gtkaccessible#GtkAccessible-struct) | |
| relation | a [GtkAccessibleRelation](gtkaccessible#GtkAccessibleRelation) | |
### gtk\_accessible\_property\_init\_value ()
```
void
gtk_accessible_property_init_value (*`[GtkAccessibleProperty](gtkaccessible#GtkAccessibleProperty) property`*,
*`GValue *value`*);
```
Initializes *`value`* with the appropriate type for the *`property`* .
This function is mostly meant for language bindings, in conjunction with [`gtk_accessible_update_property_value()`](gtkaccessible#gtk-accessible-update-property-value).
#### Parameters
| | | |
| --- | --- | --- |
| property | a [GtkAccessibleProperty](gtkaccessible#GtkAccessibleProperty) | |
| value | an uninitialized GValue | |
### gtk\_accessible\_relation\_init\_value ()
```
void
gtk_accessible_relation_init_value (*`[GtkAccessibleRelation](gtkaccessible#GtkAccessibleRelation) relation`*,
*`GValue *value`*);
```
Initializes *`value`* with the appropriate type for the *`relation`* .
This function is mostly meant for language bindings, in conjunction with [`gtk_accessible_update_relation_value()`](gtkaccessible#gtk-accessible-update-relation-value).
#### Parameters
| | | |
| --- | --- | --- |
| relation | a [GtkAccessibleRelation](gtkaccessible#GtkAccessibleRelation) | |
| value | an uninitialized GValue | |
### gtk\_accessible\_state\_init\_value ()
```
void
gtk_accessible_state_init_value (*`[GtkAccessibleState](gtkaccessible#GtkAccessibleState) state`*,
*`GValue *value`*);
```
Initializes *`value`* with the appropriate type for the *`state`* .
This function is mostly meant for language bindings, in conjunction with `gtk_accessible_update_relation_state()`.
#### Parameters
| | | |
| --- | --- | --- |
| state | a [GtkAccessibleState](gtkaccessible#GtkAccessibleState) | |
| value | an uninitialized GValue | |
Types and Values
----------------
### GtkAccessible
```
typedef struct _GtkAccessible GtkAccessible;
```
### enum GtkAccessibleRole
The accessible role for a [GtkAccessible](gtkaccessible#GtkAccessible-struct) implementation.
Abstract roles are only used as part of the ontology; application developers must not use abstract roles in their code.
#### Members
| | | |
| --- | --- | --- |
| GTK\_ACCESSIBLE\_ROLE\_ALERT | An element with important, and usually time-sensitive, information | |
| GTK\_ACCESSIBLE\_ROLE\_ALERT\_DIALOG | A type of dialog that contains an alert message | |
| GTK\_ACCESSIBLE\_ROLE\_BANNER | Unused | |
| GTK\_ACCESSIBLE\_ROLE\_BUTTON | An input element that allows for user-triggered actions when clicked or pressed | |
| GTK\_ACCESSIBLE\_ROLE\_CAPTION | Unused | |
| GTK\_ACCESSIBLE\_ROLE\_CELL | Unused | |
| GTK\_ACCESSIBLE\_ROLE\_CHECKBOX | A checkable input element that has three possible values: `true`, `false`, or `mixed` | |
| GTK\_ACCESSIBLE\_ROLE\_COLUMN\_HEADER | A header in a columned list. | |
| GTK\_ACCESSIBLE\_ROLE\_COMBO\_BOX | An input that controls another element, such as a list or a grid, that can dynamically pop up to help the user set the value of the input | |
| GTK\_ACCESSIBLE\_ROLE\_COMMAND | Abstract role. | |
| GTK\_ACCESSIBLE\_ROLE\_COMPOSITE | Abstract role. | |
| GTK\_ACCESSIBLE\_ROLE\_DIALOG | A dialog is a window that is designed to interrupt the current processing of an application in order to prompt the user to enter information or require a response. | |
| GTK\_ACCESSIBLE\_ROLE\_DOCUMENT | Unused | |
| GTK\_ACCESSIBLE\_ROLE\_FEED | Unused | |
| GTK\_ACCESSIBLE\_ROLE\_FORM | Unused | |
| GTK\_ACCESSIBLE\_ROLE\_GENERIC | Unused | |
| GTK\_ACCESSIBLE\_ROLE\_GRID | A grid of items. | |
| GTK\_ACCESSIBLE\_ROLE\_GRID\_CELL | An item in a grid or tree grid. | |
| GTK\_ACCESSIBLE\_ROLE\_GROUP | An element that groups multiple widgets. GTK uses this role for various containers, like [GtkBox](gtkbox#GtkBox-struct), [GtkViewport](gtkviewport#GtkViewport-struct), and [GtkHeaderBar](gtkheaderbar#GtkHeaderBar-struct). | |
| GTK\_ACCESSIBLE\_ROLE\_HEADING | Unused | |
| GTK\_ACCESSIBLE\_ROLE\_IMG | An image. | |
| GTK\_ACCESSIBLE\_ROLE\_INPUT | Abstract role. | |
| GTK\_ACCESSIBLE\_ROLE\_LABEL | A visible name or caption for a user interface component. | |
| GTK\_ACCESSIBLE\_ROLE\_LANDMARK | Abstract role. | |
| GTK\_ACCESSIBLE\_ROLE\_LEGEND | Unused | |
| GTK\_ACCESSIBLE\_ROLE\_LINK | A clickable link. | |
| GTK\_ACCESSIBLE\_ROLE\_LIST | A list of items. | |
| GTK\_ACCESSIBLE\_ROLE\_LIST\_BOX | Unused. | |
| GTK\_ACCESSIBLE\_ROLE\_LIST\_ITEM | An item in a list. | |
| GTK\_ACCESSIBLE\_ROLE\_LOG | Unused | |
| GTK\_ACCESSIBLE\_ROLE\_MAIN | Unused | |
| GTK\_ACCESSIBLE\_ROLE\_MARQUEE | Unused | |
| GTK\_ACCESSIBLE\_ROLE\_MATH | Unused | |
| GTK\_ACCESSIBLE\_ROLE\_METER | An element that represents a value within a known range. | |
| GTK\_ACCESSIBLE\_ROLE\_MENU | A menu. | |
| GTK\_ACCESSIBLE\_ROLE\_MENU\_BAR | A menubar. | |
| GTK\_ACCESSIBLE\_ROLE\_MENU\_ITEM | An item in a menu. | |
| GTK\_ACCESSIBLE\_ROLE\_MENU\_ITEM\_CHECKBOX | A check item in a menu. | |
| GTK\_ACCESSIBLE\_ROLE\_MENU\_ITEM\_RADIO | A radio item in a menu. | |
| GTK\_ACCESSIBLE\_ROLE\_NAVIGATION | Unused | |
| GTK\_ACCESSIBLE\_ROLE\_NONE | An element that is not represented to accessibility technologies. | |
| GTK\_ACCESSIBLE\_ROLE\_NOTE | Unused | |
| GTK\_ACCESSIBLE\_ROLE\_OPTION | Unused | |
| GTK\_ACCESSIBLE\_ROLE\_PRESENTATION | An element that is not represented to accessibility technologies. | |
| GTK\_ACCESSIBLE\_ROLE\_PROGRESS\_BAR | An element that displays the progress status for tasks that take a long time. | |
| GTK\_ACCESSIBLE\_ROLE\_RADIO | A checkable input in a group of radio roles, only one of which can be checked at a time. | |
| GTK\_ACCESSIBLE\_ROLE\_RADIO\_GROUP | Unused | |
| GTK\_ACCESSIBLE\_ROLE\_RANGE | Abstract role. | |
| GTK\_ACCESSIBLE\_ROLE\_REGION | Unused | |
| GTK\_ACCESSIBLE\_ROLE\_ROW | A row in a columned list. | |
| GTK\_ACCESSIBLE\_ROLE\_ROW\_GROUP | Unused | |
| GTK\_ACCESSIBLE\_ROLE\_ROW\_HEADER | Unused | |
| GTK\_ACCESSIBLE\_ROLE\_SCROLLBAR | A graphical object that controls the scrolling of content within a viewing area, regardless of whether the content is fully displayed within the viewing area. | |
| GTK\_ACCESSIBLE\_ROLE\_SEARCH | Unused | |
| GTK\_ACCESSIBLE\_ROLE\_SEARCH\_BOX | A type of textbox intended for specifying search criteria. | |
| GTK\_ACCESSIBLE\_ROLE\_SECTION | Abstract role. | |
| GTK\_ACCESSIBLE\_ROLE\_SECTION\_HEAD | Abstract role. | |
| GTK\_ACCESSIBLE\_ROLE\_SELECT | Abstract role. | |
| GTK\_ACCESSIBLE\_ROLE\_SEPARATOR | A divider that separates and distinguishes sections of content or groups of menuitems. | |
| GTK\_ACCESSIBLE\_ROLE\_SLIDER | A user input where the user selects a value from within a given range. | |
| GTK\_ACCESSIBLE\_ROLE\_SPIN\_BUTTON | A form of range that expects the user to select from among discrete choices. | |
| GTK\_ACCESSIBLE\_ROLE\_STATUS | Unused | |
| GTK\_ACCESSIBLE\_ROLE\_STRUCTURE | Abstract role. | |
| GTK\_ACCESSIBLE\_ROLE\_SWITCH | A type of checkbox that represents on/off values, as opposed to checked/unchecked values. | |
| GTK\_ACCESSIBLE\_ROLE\_TAB | An item in a list of tab used for switching pages. | |
| GTK\_ACCESSIBLE\_ROLE\_TABLE | Unused | |
| GTK\_ACCESSIBLE\_ROLE\_TAB\_LIST | A list of tabs for switching pages. | |
| GTK\_ACCESSIBLE\_ROLE\_TAB\_PANEL | A page in a notebook or stack. | |
| GTK\_ACCESSIBLE\_ROLE\_TEXT\_BOX | A type of input that allows free-form text as its value. | |
| GTK\_ACCESSIBLE\_ROLE\_TIME | Unused | |
| GTK\_ACCESSIBLE\_ROLE\_TIMER | Unused | |
| GTK\_ACCESSIBLE\_ROLE\_TOOLBAR | Unused | |
| GTK\_ACCESSIBLE\_ROLE\_TOOLTIP | Unused | |
| GTK\_ACCESSIBLE\_ROLE\_TREE | Unused | |
| GTK\_ACCESSIBLE\_ROLE\_TREE\_GRID | A treeview-like, columned list. | |
| GTK\_ACCESSIBLE\_ROLE\_TREE\_ITEM | Unused | |
| GTK\_ACCESSIBLE\_ROLE\_WIDGET | An interactive component of a graphical user interface. This is the role that GTK uses by default for widgets. | |
| GTK\_ACCESSIBLE\_ROLE\_WINDOW | An application window. | |
### enum GtkAccessibleState
The possible accessible states of a [GtkAccessible](gtkaccessible#GtkAccessible-struct).
#### Members
| | | |
| --- | --- | --- |
| GTK\_ACCESSIBLE\_STATE\_BUSY | A “busy” state. This state has boolean values | |
| GTK\_ACCESSIBLE\_STATE\_CHECKED | A “checked” state; indicates the current state of a [GtkCheckButton](gtkcheckbutton#GtkCheckButton-struct). Value type: [GtkAccessibleTristate](gtkaccessible#GtkAccessibleTristate) | |
| GTK\_ACCESSIBLE\_STATE\_DISABLED | A “disabled” state; corresponds to the [“sensitive”](gtkwidget#GtkWidget--sensitive) property on [GtkWidget](gtkwidget#GtkWidget-struct). It indicates a UI element that is perceivable, but not editable or operable. Value type: boolean | |
| GTK\_ACCESSIBLE\_STATE\_EXPANDED | An “expanded” state; corresponds to the [“expanded”](gtkexpander#GtkExpander--expanded) property on [GtkExpander](gtkexpander#GtkExpander-struct). Value type: boolean or undefined | |
| GTK\_ACCESSIBLE\_STATE\_HIDDEN | A “hidden” state; corresponds to the [“visible”](gtkwidget#GtkWidget--visible) property on [GtkWidget](gtkwidget#GtkWidget-struct). You can use this state explicitly on UI elements that should not be exposed to an assistive technology. Value type: boolean See also: [`GTK_ACCESSIBLE_STATE_DISABLED`](gtkaccessible#GTK-ACCESSIBLE-STATE-DISABLED:CAPS) | |
| GTK\_ACCESSIBLE\_STATE\_INVALID | An “invalid” state; set when a widget is showing an error. Value type: [GtkAccessibleInvalidState](gtkaccessible#GtkAccessibleInvalidState) | |
| GTK\_ACCESSIBLE\_STATE\_PRESSED | A “pressed” state; indicates the current state of a [GtkToggleButton](gtktogglebutton#GtkToggleButton-struct). Value type: [GtkAccessibleTristate](gtkaccessible#GtkAccessibleTristate) enumeration | |
| GTK\_ACCESSIBLE\_STATE\_SELECTED | A “selected” state; set when a widget is selected. Value type: boolean or undefined | |
### enum GtkAccessibleProperty
The possible accessible properties of a [GtkAccessible](gtkaccessible#GtkAccessible-struct).
#### Members
| | | |
| --- | --- | --- |
| GTK\_ACCESSIBLE\_PROPERTY\_AUTOCOMPLETE | Indicates whether inputting text could trigger display of one or more predictions of the user's intended value for a combobox, searchbox, or textbox and specifies how predictions would be presented if they were made. Value type: [GtkAccessibleAutocomplete](gtkaccessible#GtkAccessibleAutocomplete) | |
| GTK\_ACCESSIBLE\_PROPERTY\_DESCRIPTION | Defines a string value that describes or annotates the current element. Value type: string | |
| GTK\_ACCESSIBLE\_PROPERTY\_HAS\_POPUP | Indicates the availability and type of interactive popup element, such as menu or dialog, that can be triggered by an element. | |
| GTK\_ACCESSIBLE\_PROPERTY\_KEY\_SHORTCUTS | Indicates keyboard shortcuts that an author has implemented to activate or give focus to an element. Value type: string | |
| GTK\_ACCESSIBLE\_PROPERTY\_LABEL | Defines a string value that labels the current element. Value type: string | |
| GTK\_ACCESSIBLE\_PROPERTY\_LEVEL | Defines the hierarchical level of an element within a structure. Value type: integer | |
| GTK\_ACCESSIBLE\_PROPERTY\_MODAL | Indicates whether an element is modal when displayed. Value type: boolean | |
| GTK\_ACCESSIBLE\_PROPERTY\_MULTI\_LINE | Indicates whether a text box accepts multiple lines of input or only a single line. Value type: boolean | |
| GTK\_ACCESSIBLE\_PROPERTY\_MULTI\_SELECTABLE | Indicates that the user may select more than one item from the current selectable descendants. Value type: boolean | |
| GTK\_ACCESSIBLE\_PROPERTY\_ORIENTATION | Indicates whether the element's orientation is horizontal, vertical, or unknown/ambiguous. Value type: [GtkOrientation](gtk4-standard-enumerations#GtkOrientation) | |
| GTK\_ACCESSIBLE\_PROPERTY\_PLACEHOLDER | Defines a short hint (a word or short phrase) intended to aid the user with data entry when the control has no value. A hint could be a sample value or a brief description of the expected format. Value type: string | |
| GTK\_ACCESSIBLE\_PROPERTY\_READ\_ONLY | Indicates that the element is not editable, but is otherwise operable. Value type: boolean | |
| GTK\_ACCESSIBLE\_PROPERTY\_REQUIRED | Indicates that user input is required on the element before a form may be submitted. Value type: boolean | |
| GTK\_ACCESSIBLE\_PROPERTY\_ROLE\_DESCRIPTION | Defines a human-readable, author-localized description for the role of an element. Value type: string | |
| GTK\_ACCESSIBLE\_PROPERTY\_SORT | Indicates if items in a table or grid are sorted in ascending or descending order. Possible property values are in the [GtkAccessibleSort](gtkaccessible#GtkAccessibleSort) enumeration. Value type: [GtkAccessibleSort](gtkaccessible#GtkAccessibleSort) | |
| GTK\_ACCESSIBLE\_PROPERTY\_VALUE\_MAX | Defines the maximum allowed value for a range widget. Value type: double | |
| GTK\_ACCESSIBLE\_PROPERTY\_VALUE\_MIN | Defines the minimum allowed value for a range widget. Value type: double | |
| GTK\_ACCESSIBLE\_PROPERTY\_VALUE\_NOW | Defines the current value for a range widget. Value type: double | |
| GTK\_ACCESSIBLE\_PROPERTY\_VALUE\_TEXT | Defines the human readable text alternative of aria-valuenow for a range widget. Value type: string | |
### enum GtkAccessibleRelation
The possible accessible relations of a [GtkAccessible](gtkaccessible#GtkAccessible-struct). Accessible relations can be references to other widgets, integers or strings.
#### Members
| | | |
| --- | --- | --- |
| GTK\_ACCESSIBLE\_RELATION\_ACTIVE\_DESCENDANT | Identifies the currently active element when focus is on a composite widget, combobox, textbox, group, or application. Value type: reference | |
| GTK\_ACCESSIBLE\_RELATION\_COL\_COUNT | Defines the total number of columns in a table, grid, or treegrid. Value type: integer | |
| GTK\_ACCESSIBLE\_RELATION\_COL\_INDEX | Defines an element's column index or position with respect to the total number of columns within a table, grid, or treegrid. Value type: integer | |
| GTK\_ACCESSIBLE\_RELATION\_COL\_INDEX\_TEXT | Defines a human readable text alternative of [`GTK_ACCESSIBLE_RELATION_COL_INDEX`](gtkaccessible#GTK-ACCESSIBLE-RELATION-COL-INDEX:CAPS). Value type: string | |
| GTK\_ACCESSIBLE\_RELATION\_COL\_SPAN | Defines the number of columns spanned by a cell or gridcell within a table, grid, or treegrid. Value type: integer | |
| GTK\_ACCESSIBLE\_RELATION\_CONTROLS | Identifies the element (or elements) whose contents or presence are controlled by the current element. Value type: reference | |
| GTK\_ACCESSIBLE\_RELATION\_DESCRIBED\_BY | Identifies the element (or elements) that describes the object. Value type: reference | |
| GTK\_ACCESSIBLE\_RELATION\_DETAILS | Identifies the element (or elements) that provide additional information related to the object. Value type: reference | |
| GTK\_ACCESSIBLE\_RELATION\_ERROR\_MESSAGE | Identifies the element that provides an error message for an object. Value type: reference | |
| GTK\_ACCESSIBLE\_RELATION\_FLOW\_TO | Identifies the next element (or elements) in an alternate reading order of content which, at the user's discretion, allows assistive technology to override the general default of reading in document source order. Value type: reference | |
| GTK\_ACCESSIBLE\_RELATION\_LABELLED\_BY | Identifies the element (or elements) that labels the current element. Value type: reference | |
| GTK\_ACCESSIBLE\_RELATION\_OWNS | Identifies an element (or elements) in order to define a visual, functional, or contextual parent/child relationship between elements where the widget hierarchy cannot be used to represent the relationship. Value type: reference | |
| GTK\_ACCESSIBLE\_RELATION\_POS\_IN\_SET | Defines an element's number or position in the current set of listitems or treeitems. Value type: integer | |
| GTK\_ACCESSIBLE\_RELATION\_ROW\_COUNT | Defines the total number of rows in a table, grid, or treegrid. Value type: integer | |
| GTK\_ACCESSIBLE\_RELATION\_ROW\_INDEX | Defines an element's row index or position with respect to the total number of rows within a table, grid, or treegrid. Value type: integer | |
| GTK\_ACCESSIBLE\_RELATION\_ROW\_INDEX\_TEXT | Defines a human readable text alternative of aria-rowindex. Value type: string | |
| GTK\_ACCESSIBLE\_RELATION\_ROW\_SPAN | Defines the number of rows spanned by a cell or gridcell within a table, grid, or treegrid. Value type: integer | |
| GTK\_ACCESSIBLE\_RELATION\_SET\_SIZE | Defines the number of items in the current set of listitems or treeitems. Value type: integer | |
### enum GtkAccessibleTristate
The possible values for the [`GTK_ACCESSIBLE_STATE_PRESSED`](gtkaccessible#GTK-ACCESSIBLE-STATE-PRESSED:CAPS) accessible state.
Note that the [`GTK_ACCESSIBLE_TRISTATE_FALSE`](gtkaccessible#GTK-ACCESSIBLE-TRISTATE-FALSE:CAPS) and [`GTK_ACCESSIBLE_TRISTATE_TRUE`](gtkaccessible#GTK-ACCESSIBLE-TRISTATE-TRUE:CAPS) have the same values as `FALSE` and `TRUE`.
#### Members
| | | |
| --- | --- | --- |
| GTK\_ACCESSIBLE\_TRISTATE\_FALSE | The state is `false` | |
| GTK\_ACCESSIBLE\_TRISTATE\_TRUE | The state is `true` | |
| GTK\_ACCESSIBLE\_TRISTATE\_MIXED | The state is `mixed` | |
### enum GtkAccessibleInvalidState
The possible values for the [`GTK_ACCESSIBLE_STATE_INVALID`](gtkaccessible#GTK-ACCESSIBLE-STATE-INVALID:CAPS) accessible state.
Note that the [`GTK_ACCESSIBLE_INVALID_FALSE`](gtkaccessible#GTK-ACCESSIBLE-INVALID-FALSE:CAPS) and [`GTK_ACCESSIBLE_INVALID_TRUE`](gtkaccessible#GTK-ACCESSIBLE-INVALID-TRUE:CAPS) have the same values as `FALSE` and `TRUE`.
#### Members
| | | |
| --- | --- | --- |
| GTK\_ACCESSIBLE\_INVALID\_FALSE | There are no detected errors in the value | |
| GTK\_ACCESSIBLE\_INVALID\_TRUE | The value entered by the user has failed validation | |
| GTK\_ACCESSIBLE\_INVALID\_GRAMMAR | A grammatical error was detected | |
| GTK\_ACCESSIBLE\_INVALID\_SPELLING | A spelling error was detected | |
### enum GtkAccessibleAutocomplete
The possible values for the [`GTK_ACCESSIBLE_PROPERTY_AUTOCOMPLETE`](gtkaccessible#GTK-ACCESSIBLE-PROPERTY-AUTOCOMPLETE:CAPS) accessible property.
#### Members
| | | |
| --- | --- | --- |
| GTK\_ACCESSIBLE\_AUTOCOMPLETE\_NONE | Automatic suggestions are not displayed. | |
| GTK\_ACCESSIBLE\_AUTOCOMPLETE\_INLINE | When a user is providing input, text suggesting one way to complete the provided input may be dynamically inserted after the caret. | |
| GTK\_ACCESSIBLE\_AUTOCOMPLETE\_LIST | When a user is providing input, an element containing a collection of values that could complete the provided input may be displayed. | |
| GTK\_ACCESSIBLE\_AUTOCOMPLETE\_BOTH | When a user is providing input, an element containing a collection of values that could complete the provided input may be displayed. If displayed, one value in the collection is automatically selected, and the text needed to complete the automatically selected value appears after the caret in the input. | |
### enum GtkAccessibleSort
The possible values for the [`GTK_ACCESSIBLE_PROPERTY_SORT`](gtkaccessible#GTK-ACCESSIBLE-PROPERTY-SORT:CAPS) accessible property.
#### Members
| | | |
| --- | --- | --- |
| GTK\_ACCESSIBLE\_SORT\_NONE | There is no defined sort applied to the column. | |
| GTK\_ACCESSIBLE\_SORT\_ASCENDING | Items are sorted in ascending order by this column. | |
| GTK\_ACCESSIBLE\_SORT\_DESCENDING | Items are sorted in descending order by this column. | |
| GTK\_ACCESSIBLE\_SORT\_OTHER | A sort algorithm other than ascending or descending has been applied. | |
Property Details
----------------
### The `“accessible-role”` property
```
“accessible-role” [GtkAccessibleRole](gtkaccessible#GtkAccessibleRole)
```
The accessible role of the given [GtkAccessible](gtkaccessible#GtkAccessible-struct) implementation.
The accessible role cannot be changed once set.
Owner: GtkAccessible
Flags: Read / Write
Default value: GTK\_ACCESSIBLE\_ROLE\_NONE
| programming_docs |
gtk GtkRevealer GtkRevealer
===========
GtkRevealer — Hide and show with animation
Functions
---------
| | |
| --- | --- |
| [GtkWidget](gtkwidget#GtkWidget-struct) \* | [gtk\_revealer\_new](gtkrevealer#gtk-revealer-new) () |
| [GtkWidget](gtkwidget#GtkWidget-struct) \* | [gtk\_revealer\_get\_child](gtkrevealer#gtk-revealer-get-child) () |
| void | [gtk\_revealer\_set\_child](gtkrevealer#gtk-revealer-set-child) () |
| gboolean | [gtk\_revealer\_get\_reveal\_child](gtkrevealer#gtk-revealer-get-reveal-child) () |
| void | [gtk\_revealer\_set\_reveal\_child](gtkrevealer#gtk-revealer-set-reveal-child) () |
| gboolean | [gtk\_revealer\_get\_child\_revealed](gtkrevealer#gtk-revealer-get-child-revealed) () |
| guint | [gtk\_revealer\_get\_transition\_duration](gtkrevealer#gtk-revealer-get-transition-duration) () |
| void | [gtk\_revealer\_set\_transition\_duration](gtkrevealer#gtk-revealer-set-transition-duration) () |
| [GtkRevealerTransitionType](gtkrevealer#GtkRevealerTransitionType) | [gtk\_revealer\_get\_transition\_type](gtkrevealer#gtk-revealer-get-transition-type) () |
| void | [gtk\_revealer\_set\_transition\_type](gtkrevealer#gtk-revealer-set-transition-type) () |
Properties
----------
| | | |
| --- | --- | --- |
| [GtkWidget](gtkwidget#GtkWidget-struct) \* | [child](gtkrevealer#GtkRevealer--child) | Read / Write |
| gboolean | [child-revealed](gtkrevealer#GtkRevealer--child-revealed) | Read |
| gboolean | [reveal-child](gtkrevealer#GtkRevealer--reveal-child) | Read / Write / Construct |
| guint | [transition-duration](gtkrevealer#GtkRevealer--transition-duration) | Read / Write / Construct |
| [GtkRevealerTransitionType](gtkrevealer#GtkRevealerTransitionType) | [transition-type](gtkrevealer#GtkRevealer--transition-type) | Read / Write / Construct |
Types and Values
----------------
| | |
| --- | --- |
| | [GtkRevealer](gtkrevealer#GtkRevealer-struct) |
| enum | [GtkRevealerTransitionType](gtkrevealer#GtkRevealerTransitionType) |
Object Hierarchy
----------------
```
GObject
╰── GInitiallyUnowned
╰── [GtkWidget](gtkwidget#GtkWidget-struct)
╰── GtkRevealer
```
Implemented Interfaces
----------------------
GtkRevealer implements [GtkAccessible](gtkaccessible#GtkAccessible-struct), [GtkBuildable](gtkbuildable#GtkBuildable-struct) and [GtkConstraintTarget](gtkconstraint#GtkConstraintTarget-struct).
Includes
--------
```
#include <gtk/gtk.h>
```
Description
-----------
The GtkRevealer widget is a container which animates the transition of its child from invisible to visible.
The style of transition can be controlled with [`gtk_revealer_set_transition_type()`](gtkrevealer#gtk-revealer-set-transition-type).
These animations respect the [“gtk-enable-animations”](gtksettings#GtkSettings--gtk-enable-animations) setting.
### CSS nodes
GtkRevealer has a single CSS node with name revealer. When styling [GtkRevealer](gtkrevealer#GtkRevealer-struct) using CSS, remember that it only hides its contents, not itself. That means applied margin, padding and borders will be visible even when the [“reveal-child”](gtkrevealer#GtkRevealer--reveal-child) property is set to `FALSE`.
### Accessibility
GtkRevealer uses the [`GTK_ACCESSIBLE_ROLE_GROUP`](gtkaccessible#GTK-ACCESSIBLE-ROLE-GROUP:CAPS) role.
The child of GtkRevealer, if set, is always available in the accessibility tree, regardless of the state of the revealer widget.
Functions
---------
### gtk\_revealer\_new ()
```
[GtkWidget](gtkwidget#GtkWidget-struct) *
gtk_revealer_new (*`void`*);
```
Creates a new [GtkRevealer](gtkrevealer#GtkRevealer-struct).
#### Returns
a newly created [GtkRevealer](gtkrevealer#GtkRevealer-struct)
### gtk\_revealer\_get\_child ()
```
[GtkWidget](gtkwidget#GtkWidget-struct) *
gtk_revealer_get_child (*`[GtkRevealer](gtkrevealer#GtkRevealer-struct) *revealer`*);
```
Gets the child widget of *`revealer`* .
#### Parameters
| | | |
| --- | --- | --- |
| revealer | a [GtkRevealer](gtkrevealer#GtkRevealer-struct) | |
#### Returns
the child widget of *`revealer`* .
[nullable][transfer none]
### gtk\_revealer\_set\_child ()
```
void
gtk_revealer_set_child (*`[GtkRevealer](gtkrevealer#GtkRevealer-struct) *revealer`*,
*`[GtkWidget](gtkwidget#GtkWidget-struct) *child`*);
```
Sets the child widget of *`revealer`* .
#### Parameters
| | | |
| --- | --- | --- |
| revealer | a [GtkRevealer](gtkrevealer#GtkRevealer-struct) | |
| child | the child widget. | [allow-none] |
### gtk\_revealer\_get\_reveal\_child ()
```
gboolean
gtk_revealer_get_reveal_child (*`[GtkRevealer](gtkrevealer#GtkRevealer-struct) *revealer`*);
```
Returns whether the child is currently revealed. See [`gtk_revealer_set_reveal_child()`](gtkrevealer#gtk-revealer-set-reveal-child).
This function returns `TRUE` as soon as the transition is to the revealed state is started. To learn whether the child is fully revealed (ie the transition is completed), use [`gtk_revealer_get_child_revealed()`](gtkrevealer#gtk-revealer-get-child-revealed).
#### Parameters
| | | |
| --- | --- | --- |
| revealer | a [GtkRevealer](gtkrevealer#GtkRevealer-struct) | |
#### Returns
`TRUE` if the child is revealed.
### gtk\_revealer\_set\_reveal\_child ()
```
void
gtk_revealer_set_reveal_child (*`[GtkRevealer](gtkrevealer#GtkRevealer-struct) *revealer`*,
*`gboolean reveal_child`*);
```
Tells the [GtkRevealer](gtkrevealer#GtkRevealer-struct) to reveal or conceal its child.
The transition will be animated with the current transition type of *`revealer`* .
#### Parameters
| | | |
| --- | --- | --- |
| revealer | a [GtkRevealer](gtkrevealer#GtkRevealer-struct) | |
| reveal\_child | `TRUE` to reveal the child | |
### gtk\_revealer\_get\_child\_revealed ()
```
gboolean
gtk_revealer_get_child_revealed (*`[GtkRevealer](gtkrevealer#GtkRevealer-struct) *revealer`*);
```
Returns whether the child is fully revealed, in other words whether the transition to the revealed state is completed.
#### Parameters
| | | |
| --- | --- | --- |
| revealer | a [GtkRevealer](gtkrevealer#GtkRevealer-struct) | |
#### Returns
`TRUE` if the child is fully revealed
### gtk\_revealer\_get\_transition\_duration ()
```
guint
gtk_revealer_get_transition_duration (*`[GtkRevealer](gtkrevealer#GtkRevealer-struct) *revealer`*);
```
Returns the amount of time (in milliseconds) that transitions will take.
#### Parameters
| | | |
| --- | --- | --- |
| revealer | a [GtkRevealer](gtkrevealer#GtkRevealer-struct) | |
#### Returns
the transition duration
### gtk\_revealer\_set\_transition\_duration ()
```
void
gtk_revealer_set_transition_duration (*`[GtkRevealer](gtkrevealer#GtkRevealer-struct) *revealer`*,
*`guint duration`*);
```
Sets the duration that transitions will take.
#### Parameters
| | | |
| --- | --- | --- |
| revealer | a [GtkRevealer](gtkrevealer#GtkRevealer-struct) | |
| duration | the new duration, in milliseconds | |
### gtk\_revealer\_get\_transition\_type ()
```
[GtkRevealerTransitionType](gtkrevealer#GtkRevealerTransitionType)
gtk_revealer_get_transition_type (*`[GtkRevealer](gtkrevealer#GtkRevealer-struct) *revealer`*);
```
Gets the type of animation that will be used for transitions in *`revealer`* .
#### Parameters
| | | |
| --- | --- | --- |
| revealer | a [GtkRevealer](gtkrevealer#GtkRevealer-struct) | |
#### Returns
the current transition type of *`revealer`*
### gtk\_revealer\_set\_transition\_type ()
```
void
gtk_revealer_set_transition_type (*`[GtkRevealer](gtkrevealer#GtkRevealer-struct) *revealer`*,
*`[GtkRevealerTransitionType](gtkrevealer#GtkRevealerTransitionType) transition`*);
```
Sets the type of animation that will be used for transitions in *`revealer`* . Available types include various kinds of fades and slides.
#### Parameters
| | | |
| --- | --- | --- |
| revealer | a [GtkRevealer](gtkrevealer#GtkRevealer-struct) | |
| transition | the new transition type | |
Types and Values
----------------
### GtkRevealer
```
typedef struct _GtkRevealer GtkRevealer;
```
### enum GtkRevealerTransitionType
These enumeration values describe the possible transitions when the child of a [GtkRevealer](gtkrevealer#GtkRevealer-struct) widget is shown or hidden.
#### Members
| | | |
| --- | --- | --- |
| GTK\_REVEALER\_TRANSITION\_TYPE\_NONE | No transition | |
| GTK\_REVEALER\_TRANSITION\_TYPE\_CROSSFADE | Fade in | |
| GTK\_REVEALER\_TRANSITION\_TYPE\_SLIDE\_RIGHT | Slide in from the left | |
| GTK\_REVEALER\_TRANSITION\_TYPE\_SLIDE\_LEFT | Slide in from the right | |
| GTK\_REVEALER\_TRANSITION\_TYPE\_SLIDE\_UP | Slide in from the bottom | |
| GTK\_REVEALER\_TRANSITION\_TYPE\_SLIDE\_DOWN | Slide in from the top | |
| GTK\_REVEALER\_TRANSITION\_TYPE\_SWING\_RIGHT | Floop in from the left | |
| GTK\_REVEALER\_TRANSITION\_TYPE\_SWING\_LEFT | Floop in from the right | |
| GTK\_REVEALER\_TRANSITION\_TYPE\_SWING\_UP | Floop in from the bottom | |
| GTK\_REVEALER\_TRANSITION\_TYPE\_SWING\_DOWN | Floop in from the top | |
Property Details
----------------
### The `“child”` property
```
“child” [GtkWidget](gtkwidget#GtkWidget-struct) *
```
The child widget.
Owner: GtkRevealer
Flags: Read / Write
### The `“child-revealed”` property
```
“child-revealed” gboolean
```
Whether the child is revealed and the animation target reached.
Owner: GtkRevealer
Flags: Read
Default value: FALSE
### The `“reveal-child”` property
```
“reveal-child” gboolean
```
Whether the container should reveal the child.
Owner: GtkRevealer
Flags: Read / Write / Construct
Default value: FALSE
### The `“transition-duration”` property
```
“transition-duration” guint
```
The animation duration, in milliseconds.
Owner: GtkRevealer
Flags: Read / Write / Construct
Default value: 250
### The `“transition-type”` property
```
“transition-type” [GtkRevealerTransitionType](gtkrevealer#GtkRevealerTransitionType)
```
The type of animation used to transition.
Owner: GtkRevealer
Flags: Read / Write / Construct
Default value: GTK\_REVEALER\_TRANSITION\_TYPE\_SLIDE\_DOWN
See Also
--------
[GtkExpander](gtkexpander#GtkExpander-struct)
gtk GtkPopoverMenu GtkPopoverMenu
==============
GtkPopoverMenu — Popovers to use as menus
Functions
---------
| | |
| --- | --- |
| [GtkWidget](gtkwidget#GtkWidget-struct) \* | [gtk\_popover\_menu\_new\_from\_model](gtkpopovermenu#gtk-popover-menu-new-from-model) () |
| [GtkWidget](gtkwidget#GtkWidget-struct) \* | [gtk\_popover\_menu\_new\_from\_model\_full](gtkpopovermenu#gtk-popover-menu-new-from-model-full) () |
| void | [gtk\_popover\_menu\_set\_menu\_model](gtkpopovermenu#gtk-popover-menu-set-menu-model) () |
| GMenuModel \* | [gtk\_popover\_menu\_get\_menu\_model](gtkpopovermenu#gtk-popover-menu-get-menu-model) () |
| gboolean | [gtk\_popover\_menu\_add\_child](gtkpopovermenu#gtk-popover-menu-add-child) () |
| gboolean | [gtk\_popover\_menu\_remove\_child](gtkpopovermenu#gtk-popover-menu-remove-child) () |
Properties
----------
| | | |
| --- | --- | --- |
| GMenuModel \* | [menu-model](gtkpopovermenu#GtkPopoverMenu--menu-model) | Read / Write |
| char \* | [visible-submenu](gtkpopovermenu#GtkPopoverMenu--visible-submenu) | Read / Write |
Types and Values
----------------
| | |
| --- | --- |
| | [GtkPopoverMenu](gtkpopovermenu#GtkPopoverMenu-struct) |
| enum | [GtkPopoverMenuFlags](gtkpopovermenu#GtkPopoverMenuFlags) |
Object Hierarchy
----------------
```
GObject
╰── GInitiallyUnowned
╰── [GtkWidget](gtkwidget#GtkWidget-struct)
╰── [GtkPopover](gtkpopover#GtkPopover-struct)
╰── GtkPopoverMenu
```
Implemented Interfaces
----------------------
GtkPopoverMenu implements [GtkAccessible](gtkaccessible#GtkAccessible-struct), [GtkBuildable](gtkbuildable#GtkBuildable-struct), [GtkConstraintTarget](gtkconstraint#GtkConstraintTarget-struct), [GtkShortcutManager](gtkshortcutmanager#GtkShortcutManager-struct) and [GtkNative](gtknative#GtkNative-struct).
Includes
--------
```
#include <gtk/gtk.h>
```
Description
-----------
GtkPopoverMenu is a subclass of [GtkPopover](gtkpopover#GtkPopover-struct) that treats its children like menus and allows switching between them. It can open submenus as traditional, nested submenus, or in a more touch-friendly sliding fashion.
GtkPopoverMenu is meant to be used primarily with menu models, using [`gtk_popover_menu_new_from_model()`](gtkpopovermenu#gtk-popover-menu-new-from-model). If you need to put other widgets such as [GtkSpinButton](gtkspinbutton#GtkSpinButton-struct) or [GtkSwitch](gtkswitch#GtkSwitch-struct) into a popover, use a plain [GtkPopover](gtkpopover#GtkPopover-struct).
#### Menu models
The XML format understood by [GtkBuilder](gtkbuilder#GtkBuilder-struct) for GMenuModel consists of a toplevel `<menu>` element, which contains one or more `<item>` elements. Each `<item>` element contains `<attribute>` and `<link>` elements with a mandatory name attribute. `<link>` elements have the same content model as `<menu>`. Instead of `<link name="submenu>` or `<link name="section">`, you can use `<submenu>` or `<section>` elements.
```
<menu id='app-menu'>
<section>
<item>
<attribute name='label' translatable='yes'>_New Window</attribute>
<attribute name='action'>app.new</attribute>
</item>
<item>
<attribute name='label' translatable='yes'>_About Sunny</attribute>
<attribute name='action'>app.about</attribute>
</item>
<item>
<attribute name='label' translatable='yes'>_Quit</attribute>
<attribute name='action'>app.quit</attribute>
</item>
</section>
</menu>
```
| Attribute values can be translated using gettext, like other [GtkBuilder](gtkbuilder#GtkBuilder-struct) content. `<attribute>` elements can be marked for translation with a `translatable="yes"` attribute. It is also possible to specify message context and translator comments, using the context and comments attributes. To make use of this, the [GtkBuilder](gtkbuilder#GtkBuilder-struct) must have been given the gettext domain to use.
The following attributes are used when constructing menu items:
* "label": a user-visible string to display
* "action": the prefixed name of the action to trigger
* "target": the parameter to use when activating the action
* "icon" and "verb-icon": names of icons that may be displayed
* "submenu-action": name of an action that may be used to determine if a submenu can be opened
* "hidden-when": a string used to determine when the item will be hidden. Possible values include "action-disabled", "action-missing", "macos-menubar". This is mainly useful for exported menus, see [`gtk_application_set_menubar()`](gtkapplication#gtk-application-set-menubar).
* "custom": a string used to match against the ID of a custom child added with [`gtk_popover_menu_add_child()`](gtkpopovermenu#gtk-popover-menu-add-child), [`gtk_popover_menu_bar_add_child()`](gtkpopovermenubar#gtk-popover-menu-bar-add-child), or in the ui file with `<child type="ID">`.
The following attributes are used when constructing sections:
* "label": a user-visible string to use as section heading
* "display-hint": a string used to determine special formatting for the section. Possible values include "horizontal-buttons", "circular-buttons" and "inline-buttons". They all indicate that section should be displayed as a horizontal row of buttons.
* "text-direction": a string used to determine the [GtkTextDirection](gtkwidget#GtkTextDirection) to use when "display-hint" is set to "horizontal-buttons". Possible values include "rtl", "ltr", and "none".
The following attributes are used when constructing submenus:
* "label": a user-visible string to display
* "icon": icon name to display
Menu items will also show accelerators, which are usually associated with actions via [`gtk_application_set_accels_for_action()`](gtkapplication#gtk-application-set-accels-for-action), [`gtk_widget_class_add_binding_action()`](gtkwidget#gtk-widget-class-add-binding-action) or [`gtk_shortcut_controller_add_shortcut()`](gtkshortcutcontroller#gtk-shortcut-controller-add-shortcut).
### CSS Nodes
[GtkPopoverMenu](gtkpopovermenu#GtkPopoverMenu-struct) is just a subclass of [GtkPopover](gtkpopover#GtkPopover-struct) that adds custom content to it, therefore it has the same CSS nodes. It is one of the cases that add a .menu style class to the popover's main node.
### Accessibility
GtkPopoverMenu uses the [GTK\_ACCESSIBLE\_ROLE\_MENU](gtkaccessible#GTK-ACCESSIBLE-ROLE-MENU:CAPS) role, and its items use the [GTK\_ACCESSIBLE\_ROLE\_MENU\_ITEM](gtkaccessible#GTK-ACCESSIBLE-ROLE-MENU-ITEM:CAPS), [GTK\_ACCESSIBLE\_ROLE\_MENU\_ITEM\_CHECKBOX](gtkaccessible#GTK-ACCESSIBLE-ROLE-MENU-ITEM-CHECKBOX:CAPS) or [GTK\_ACCESSIBLE\_ROLE\_MENU\_ITEM\_RADIO](gtkaccessible#GTK-ACCESSIBLE-ROLE-MENU-ITEM-RADIO:CAPS) roles, depending on the action they are connected to.
Functions
---------
### gtk\_popover\_menu\_new\_from\_model ()
```
[GtkWidget](gtkwidget#GtkWidget-struct) *
gtk_popover_menu_new_from_model (*`GMenuModel *model`*);
```
Creates a [GtkPopoverMenu](gtkpopovermenu#GtkPopoverMenu-struct) and populates it according to *`model`* .
The created buttons are connected to actions found in the [GtkApplicationWindow](gtkapplicationwindow#GtkApplicationWindow-struct) to which the popover belongs - typically by means of being attached to a widget that is contained within the [GtkApplicationWindows](gtkapplicationwindow#GtkApplicationWindow-struct) widget hierarchy.
Actions can also be added using [`gtk_widget_insert_action_group()`](gtkwidget#gtk-widget-insert-action-group) on the menus attach widget or on any of its parent widgets.
This function creates menus with sliding submenus. See [`gtk_popover_menu_new_from_model_full()`](gtkpopovermenu#gtk-popover-menu-new-from-model-full) for a way to control this.
#### Parameters
| | | |
| --- | --- | --- |
| model | a GMenuModel, or `NULL`. | [allow-none] |
#### Returns
the new [GtkPopoverMenu](gtkpopovermenu#GtkPopoverMenu-struct)
### gtk\_popover\_menu\_new\_from\_model\_full ()
```
[GtkWidget](gtkwidget#GtkWidget-struct) *
gtk_popover_menu_new_from_model_full (*`GMenuModel *model`*,
*`[GtkPopoverMenuFlags](gtkpopovermenu#GtkPopoverMenuFlags) flags`*);
```
Creates a [GtkPopoverMenu](gtkpopovermenu#GtkPopoverMenu-struct) and populates it according to *`model`* .
The created buttons are connected to actions found in the action groups that are accessible from the parent widget. This includes the [GtkApplicationWindow](gtkapplicationwindow#GtkApplicationWindow-struct) to which the popover belongs. Actions can also be added using [`gtk_widget_insert_action_group()`](gtkwidget#gtk-widget-insert-action-group) on the parent widget or on any of its parent widgets.
The only flag that is supported currently is [GTK\_POPOVER\_MENU\_NESTED](gtkpopovermenu#GTK-POPOVER-MENU-NESTED:CAPS), which makes GTK create traditional, nested submenus instead of the default sliding submenus.
#### Parameters
| | | |
| --- | --- | --- |
| model | a GMenuModel | |
| flags | flags that affect how the menu is created | |
#### Returns
the new [GtkPopoverMenu](gtkpopovermenu#GtkPopoverMenu-struct).
[transfer full]
### gtk\_popover\_menu\_set\_menu\_model ()
```
void
gtk_popover_menu_set_menu_model (*`[GtkPopoverMenu](gtkpopovermenu#GtkPopoverMenu-struct) *popover`*,
*`GMenuModel *model`*);
```
Sets a new menu model on *`popover`* .
The existing contents of *`popover`* are removed, and the *`popover`* is populated with new contents according to *`model`* .
#### Parameters
| | | |
| --- | --- | --- |
| popover | a [GtkPopoverMenu](gtkpopovermenu#GtkPopoverMenu-struct) | |
| model | a GMenuModel, or `NULL`. | [nullable] |
### gtk\_popover\_menu\_get\_menu\_model ()
```
GMenuModel *
gtk_popover_menu_get_menu_model (*`[GtkPopoverMenu](gtkpopovermenu#GtkPopoverMenu-struct) *popover`*);
```
Returns the menu model used to populate the popover.
#### Parameters
| | | |
| --- | --- | --- |
| popover | a [GtkPopoverMenu](gtkpopovermenu#GtkPopoverMenu-struct) | |
#### Returns
the menu model of *`popover`* .
[transfer none]
### gtk\_popover\_menu\_add\_child ()
```
gboolean
gtk_popover_menu_add_child (*`[GtkPopoverMenu](gtkpopovermenu#GtkPopoverMenu-struct) *popover`*,
*`[GtkWidget](gtkwidget#GtkWidget-struct) *child`*,
*`const char *id`*);
```
Adds a custom widget to a generated menu.
For this to work, the menu model of *`popover`* must have an item with a `custom` attribute that matches *`id`* .
#### Parameters
| | | |
| --- | --- | --- |
| popover | a [GtkPopoverMenu](gtkpopovermenu#GtkPopoverMenu-struct) | |
| child | the [GtkWidget](gtkwidget#GtkWidget-struct) to add | |
| id | the ID to insert *`child`* at | |
#### Returns
`TRUE` if *`id`* was found and the widget added
### gtk\_popover\_menu\_remove\_child ()
```
gboolean
gtk_popover_menu_remove_child (*`[GtkPopoverMenu](gtkpopovermenu#GtkPopoverMenu-struct) *popover`*,
*`[GtkWidget](gtkwidget#GtkWidget-struct) *child`*);
```
Removes a widget that has previously been added with [`gtk_popover_menu_add_child()`](gtkpopovermenu#gtk-popover-menu-add-child).
#### Parameters
| | | |
| --- | --- | --- |
| popover | a [GtkPopoverMenu](gtkpopovermenu#GtkPopoverMenu-struct) | |
| child | the [GtkWidget](gtkwidget#GtkWidget-struct) to remove | |
#### Returns
`TRUE` if the widget was removed
Types and Values
----------------
### GtkPopoverMenu
```
typedef struct _GtkPopoverMenu GtkPopoverMenu;
```
### enum GtkPopoverMenuFlags
Flags that affect how popover menus are created from a menu model.
#### Members
| | | |
| --- | --- | --- |
| GTK\_POPOVER\_MENU\_NESTED | Create submenus as nested popovers. Without this flag, submenus are created as sliding pages that replace the main menu. | |
Property Details
----------------
### The `“menu-model”` property
```
“menu-model” GMenuModel *
```
The model from which the menu is made.
Owner: GtkPopoverMenu
Flags: Read / Write
### The `“visible-submenu”` property
```
“visible-submenu” char *
```
The name of the visible submenu.
Owner: GtkPopoverMenu
Flags: Read / Write
Default value: NULL
| programming_docs |
gtk GtkMenuButton GtkMenuButton
=============
GtkMenuButton — A widget that shows a popup when clicked on
Functions
---------
| | |
| --- | --- |
| [GtkWidget](gtkwidget#GtkWidget-struct) \* | [gtk\_menu\_button\_new](gtkmenubutton#gtk-menu-button-new) () |
| void | [gtk\_menu\_button\_set\_popover](gtkmenubutton#gtk-menu-button-set-popover) () |
| [GtkPopover](gtkpopover#GtkPopover-struct) \* | [gtk\_menu\_button\_get\_popover](gtkmenubutton#gtk-menu-button-get-popover) () |
| void | [gtk\_menu\_button\_set\_menu\_model](gtkmenubutton#gtk-menu-button-set-menu-model) () |
| GMenuModel \* | [gtk\_menu\_button\_get\_menu\_model](gtkmenubutton#gtk-menu-button-get-menu-model) () |
| void | [gtk\_menu\_button\_set\_direction](gtkmenubutton#gtk-menu-button-set-direction) () |
| [GtkArrowType](gtkmenubutton#GtkArrowType) | [gtk\_menu\_button\_get\_direction](gtkmenubutton#gtk-menu-button-get-direction) () |
| void | [gtk\_menu\_button\_set\_icon\_name](gtkmenubutton#gtk-menu-button-set-icon-name) () |
| const char \* | [gtk\_menu\_button\_get\_icon\_name](gtkmenubutton#gtk-menu-button-get-icon-name) () |
| void | [gtk\_menu\_button\_set\_label](gtkmenubutton#gtk-menu-button-set-label) () |
| const char \* | [gtk\_menu\_button\_get\_label](gtkmenubutton#gtk-menu-button-get-label) () |
| void | [gtk\_menu\_button\_set\_has\_frame](gtkmenubutton#gtk-menu-button-set-has-frame) () |
| gboolean | [gtk\_menu\_button\_get\_has\_frame](gtkmenubutton#gtk-menu-button-get-has-frame) () |
| gboolean | [gtk\_menu\_button\_get\_use\_underline](gtkmenubutton#gtk-menu-button-get-use-underline) () |
| void | [gtk\_menu\_button\_set\_use\_underline](gtkmenubutton#gtk-menu-button-set-use-underline) () |
| void | [gtk\_menu\_button\_popup](gtkmenubutton#gtk-menu-button-popup) () |
| void | [gtk\_menu\_button\_popdown](gtkmenubutton#gtk-menu-button-popdown) () |
| void | ([\*GtkMenuButtonCreatePopupFunc](gtkmenubutton#GtkMenuButtonCreatePopupFunc)) () |
| void | [gtk\_menu\_button\_set\_create\_popup\_func](gtkmenubutton#gtk-menu-button-set-create-popup-func) () |
Properties
----------
| | | |
| --- | --- | --- |
| [GtkArrowType](gtkmenubutton#GtkArrowType) | [direction](gtkmenubutton#GtkMenuButton--direction) | Read / Write |
| gboolean | [has-frame](gtkmenubutton#GtkMenuButton--has-frame) | Read / Write |
| char \* | [icon-name](gtkmenubutton#GtkMenuButton--icon-name) | Read / Write |
| char \* | [label](gtkmenubutton#GtkMenuButton--label) | Read / Write |
| GMenuModel \* | [menu-model](gtkmenubutton#GtkMenuButton--menu-model) | Read / Write |
| [GtkPopover](gtkpopover#GtkPopover-struct) \* | [popover](gtkmenubutton#GtkMenuButton--popover) | Read / Write |
| gboolean | [use-underline](gtkmenubutton#GtkMenuButton--use-underline) | Read / Write |
Types and Values
----------------
| | |
| --- | --- |
| | [GtkMenuButton](gtkmenubutton#GtkMenuButton-struct) |
| enum | [GtkArrowType](gtkmenubutton#GtkArrowType) |
Object Hierarchy
----------------
```
GObject
╰── GInitiallyUnowned
╰── [GtkWidget](gtkwidget#GtkWidget-struct)
╰── GtkMenuButton
```
Implemented Interfaces
----------------------
GtkMenuButton implements [GtkAccessible](gtkaccessible#GtkAccessible-struct), [GtkBuildable](gtkbuildable#GtkBuildable-struct) and [GtkConstraintTarget](gtkconstraint#GtkConstraintTarget-struct).
Includes
--------
```
#include <gtk/gtk.h>
```
Description
-----------
The [GtkMenuButton](gtkmenubutton#GtkMenuButton-struct) widget is used to display a popup when clicked on. This popup can be provided either as a [GtkPopover](gtkpopover#GtkPopover-struct) or as an abstract GMenuModel.
The [GtkMenuButton](gtkmenubutton#GtkMenuButton-struct) widget can show either an icon (set with the [“icon-name”](gtkmenubutton#GtkMenuButton--icon-name) property) or a label (set with the [“label”](gtkmenubutton#GtkMenuButton--label) property). If neither is explicitly set, a [GtkImage](gtkimage#GtkImage-struct) is automatically created, using an arrow image oriented according to [“direction”](gtkmenubutton#GtkMenuButton--direction) or the generic “open-menu-symbolic” icon if the direction is not set.
The positioning of the popup is determined by the [“direction”](gtkmenubutton#GtkMenuButton--direction) property of the menu button.
For menus, the [“halign”](gtkwidget#GtkWidget--halign) and [“valign”](gtkwidget#GtkWidget--valign) properties of the menu are also taken into account. For example, when the direction is [`GTK_ARROW_DOWN`](gtkmenubutton#GTK-ARROW-DOWN:CAPS) and the horizontal alignment is [`GTK_ALIGN_START`](gtkwidget#GTK-ALIGN-START:CAPS), the menu will be positioned below the button, with the starting edge (depending on the text direction) of the menu aligned with the starting edge of the button. If there is not enough space below the button, the menu is popped up above the button instead. If the alignment would move part of the menu offscreen, it is “pushed in”.
#### Direction = Down
* halign = start
* halign = center
* halign = end
#### Direction = Up
* halign = start
* halign = center
* halign = end
#### Direction = Left
* valign = start
* valign = center
* valign = end
#### Direction = Right
* valign = start
* valign = center
* valign = end
### CSS nodes
```
menubutton
╰── button.toggle
╰── [content]
```
| GtkMenuButton has a single CSS node with name menubutton which contains a toggle button node.
### Accessibility
GtkMenuButton uses the [GTK\_ACCESSIBLE\_ROLE\_BUTTON](gtkaccessible#GTK-ACCESSIBLE-ROLE-BUTTON:CAPS) role.
Functions
---------
### gtk\_menu\_button\_new ()
```
[GtkWidget](gtkwidget#GtkWidget-struct) *
gtk_menu_button_new (*`void`*);
```
Creates a new [GtkMenuButton](gtkmenubutton#GtkMenuButton-struct) widget with downwards-pointing arrow as the only child. You can replace the child widget with another [GtkWidget](gtkwidget#GtkWidget-struct) should you wish to.
#### Returns
The newly created [GtkMenuButton](gtkmenubutton#GtkMenuButton-struct) widget
### gtk\_menu\_button\_set\_popover ()
```
void
gtk_menu_button_set_popover (*`[GtkMenuButton](gtkmenubutton#GtkMenuButton-struct) *menu_button`*,
*`[GtkWidget](gtkwidget#GtkWidget-struct) *popover`*);
```
Sets the [GtkPopover](gtkpopover#GtkPopover-struct) that will be popped up when the *`menu_button`* is clicked, or `NULL` to dissociate any existing popover and disable the button.
If [“menu-model”](gtkmenubutton#GtkMenuButton--menu-model) is set, the menu model is dissociated from the *`menu_button`* , and the property is set to `NULL`.
#### Parameters
| | | |
| --- | --- | --- |
| menu\_button | a [GtkMenuButton](gtkmenubutton#GtkMenuButton-struct) | |
| popover | a [GtkPopover](gtkpopover#GtkPopover-struct), or `NULL` to unset and disable the button. | [nullable] |
### gtk\_menu\_button\_get\_popover ()
```
[GtkPopover](gtkpopover#GtkPopover-struct) *
gtk_menu_button_get_popover (*`[GtkMenuButton](gtkmenubutton#GtkMenuButton-struct) *menu_button`*);
```
Returns the [GtkPopover](gtkpopover#GtkPopover-struct) that pops out of the button. If the button is not using a [GtkPopover](gtkpopover#GtkPopover-struct), this function returns `NULL`.
#### Parameters
| | | |
| --- | --- | --- |
| menu\_button | a [GtkMenuButton](gtkmenubutton#GtkMenuButton-struct) | |
#### Returns
a [GtkPopover](gtkpopover#GtkPopover-struct) or `NULL`.
[nullable][transfer none]
### gtk\_menu\_button\_set\_menu\_model ()
```
void
gtk_menu_button_set_menu_model (*`[GtkMenuButton](gtkmenubutton#GtkMenuButton-struct) *menu_button`*,
*`GMenuModel *menu_model`*);
```
Sets the GMenuModel from which the popup will be constructed, or `NULL` to dissociate any existing menu model and disable the button.
A [GtkPopover](gtkpopover#GtkPopover-struct) will be created from the menu model with [`gtk_popover_menu_new_from_model()`](gtkpopovermenu#gtk-popover-menu-new-from-model). Actions will be connected as documented for this function.
If [“popover”](gtkmenubutton#GtkMenuButton--popover) is already set, it will be dissociated from the *`menu_button`* , and the property is set to `NULL`.
#### Parameters
| | | |
| --- | --- | --- |
| menu\_button | a [GtkMenuButton](gtkmenubutton#GtkMenuButton-struct) | |
| menu\_model | a GMenuModel, or `NULL` to unset and disable the button. | [nullable] |
### gtk\_menu\_button\_get\_menu\_model ()
```
GMenuModel *
gtk_menu_button_get_menu_model (*`[GtkMenuButton](gtkmenubutton#GtkMenuButton-struct) *menu_button`*);
```
Returns the GMenuModel used to generate the popup.
#### Parameters
| | | |
| --- | --- | --- |
| menu\_button | a [GtkMenuButton](gtkmenubutton#GtkMenuButton-struct) | |
#### Returns
a GMenuModel or `NULL`.
[nullable][transfer none]
### gtk\_menu\_button\_set\_direction ()
```
void
gtk_menu_button_set_direction (*`[GtkMenuButton](gtkmenubutton#GtkMenuButton-struct) *menu_button`*,
*`[GtkArrowType](gtkmenubutton#GtkArrowType) direction`*);
```
Sets the direction in which the popup will be popped up, as well as changing the arrow’s direction. The child will not be changed to an arrow if it was customized.
If the does not fit in the available space in the given direction, GTK will its best to keep it inside the screen and fully visible.
If you pass [`GTK_ARROW_NONE`](gtkmenubutton#GTK-ARROW-NONE:CAPS) for a *`direction`* , the popup will behave as if you passed [`GTK_ARROW_DOWN`](gtkmenubutton#GTK-ARROW-DOWN:CAPS) (although you won’t see any arrows).
#### Parameters
| | | |
| --- | --- | --- |
| menu\_button | a [GtkMenuButton](gtkmenubutton#GtkMenuButton-struct) | |
| direction | a [GtkArrowType](gtkmenubutton#GtkArrowType) | |
### gtk\_menu\_button\_get\_direction ()
```
[GtkArrowType](gtkmenubutton#GtkArrowType)
gtk_menu_button_get_direction (*`[GtkMenuButton](gtkmenubutton#GtkMenuButton-struct) *menu_button`*);
```
Returns the direction the popup will be pointing at when popped up.
#### Parameters
| | | |
| --- | --- | --- |
| menu\_button | a [GtkMenuButton](gtkmenubutton#GtkMenuButton-struct) | |
#### Returns
a [GtkArrowType](gtkmenubutton#GtkArrowType) value
### gtk\_menu\_button\_set\_icon\_name ()
```
void
gtk_menu_button_set_icon_name (*`[GtkMenuButton](gtkmenubutton#GtkMenuButton-struct) *menu_button`*,
*`const char *icon_name`*);
```
Sets the name of an icon to show inside the menu button.
#### Parameters
| | | |
| --- | --- | --- |
| menu\_button | a [GtkMenuButton](gtkmenubutton#GtkMenuButton-struct) | |
| icon\_name | the icon name | |
### gtk\_menu\_button\_get\_icon\_name ()
```
const char *
gtk_menu_button_get_icon_name (*`[GtkMenuButton](gtkmenubutton#GtkMenuButton-struct) *menu_button`*);
```
Gets the name of the icon shown in the button.
#### Parameters
| | | |
| --- | --- | --- |
| menu\_button | a [GtkMenuButton](gtkmenubutton#GtkMenuButton-struct) | |
#### Returns
the name of the icon shown in the button
### gtk\_menu\_button\_set\_label ()
```
void
gtk_menu_button_set_label (*`[GtkMenuButton](gtkmenubutton#GtkMenuButton-struct) *menu_button`*,
*`const char *label`*);
```
Sets the label to show inside the menu button.
#### Parameters
| | | |
| --- | --- | --- |
| menu\_button | a [GtkMenuButton](gtkmenubutton#GtkMenuButton-struct) | |
| label | the label | |
### gtk\_menu\_button\_get\_label ()
```
const char *
gtk_menu_button_get_label (*`[GtkMenuButton](gtkmenubutton#GtkMenuButton-struct) *menu_button`*);
```
Gets the label shown in the button
#### Parameters
| | | |
| --- | --- | --- |
| menu\_button | a [GtkMenuButton](gtkmenubutton#GtkMenuButton-struct) | |
#### Returns
the label shown in the button
### gtk\_menu\_button\_set\_has\_frame ()
```
void
gtk_menu_button_set_has_frame (*`[GtkMenuButton](gtkmenubutton#GtkMenuButton-struct) *menu_button`*,
*`gboolean has_frame`*);
```
Sets the style of the button.
#### Parameters
| | | |
| --- | --- | --- |
| menu\_button | a [GtkMenuButton](gtkmenubutton#GtkMenuButton-struct) | |
| has\_frame | whether the button should have a visible frame | |
### gtk\_menu\_button\_get\_has\_frame ()
```
gboolean
gtk_menu_button_get_has_frame (*`[GtkMenuButton](gtkmenubutton#GtkMenuButton-struct) *menu_button`*);
```
Returns whether the button has a frame.
#### Parameters
| | | |
| --- | --- | --- |
| menu\_button | a [GtkMenuButton](gtkmenubutton#GtkMenuButton-struct) | |
#### Returns
`TRUE` if the button has a frame
### gtk\_menu\_button\_get\_use\_underline ()
```
gboolean
gtk_menu_button_get_use_underline (*`[GtkMenuButton](gtkmenubutton#GtkMenuButton-struct) *menu_button`*);
```
Returns whether an embedded underline in the text indicates a mnemonic. See [`gtk_menu_button_set_use_underline()`](gtkmenubutton#gtk-menu-button-set-use-underline).
#### Parameters
| | | |
| --- | --- | --- |
| menu\_button | a [GtkMenuButton](gtkmenubutton#GtkMenuButton-struct) | |
#### Returns
`TRUE` whether an embedded underline in the text indicates the mnemonic accelerator keys.
### gtk\_menu\_button\_set\_use\_underline ()
```
void
gtk_menu_button_set_use_underline (*`[GtkMenuButton](gtkmenubutton#GtkMenuButton-struct) *menu_button`*,
*`gboolean use_underline`*);
```
If true, an underline in the text indicates the next character should be used for the mnemonic accelerator key.
#### Parameters
| | | |
| --- | --- | --- |
| menu\_button | a [GtkMenuButton](gtkmenubutton#GtkMenuButton-struct) | |
| use\_underline | `TRUE` if underlines in the text indicate mnemonics | |
### gtk\_menu\_button\_popup ()
```
void
gtk_menu_button_popup (*`[GtkMenuButton](gtkmenubutton#GtkMenuButton-struct) *menu_button`*);
```
Pop up the menu.
#### Parameters
| | | |
| --- | --- | --- |
| menu\_button | a [GtkMenuButton](gtkmenubutton#GtkMenuButton-struct) | |
### gtk\_menu\_button\_popdown ()
```
void
gtk_menu_button_popdown (*`[GtkMenuButton](gtkmenubutton#GtkMenuButton-struct) *menu_button`*);
```
Dismiss the menu.
#### Parameters
| | | |
| --- | --- | --- |
| menu\_button | a [GtkMenuButton](gtkmenubutton#GtkMenuButton-struct) | |
### GtkMenuButtonCreatePopupFunc ()
```
void
(*GtkMenuButtonCreatePopupFunc) (*`[GtkMenuButton](gtkmenubutton#GtkMenuButton-struct) *menu_button`*,
*`gpointer user_data`*);
```
User-provided callback function to create a popup for *`menu_button`* on demand. This function is called when the popup of *`menu_button`* is shown, but none has been provided via [`gtk_menu_button_set_popover()`](gtkmenubutton#gtk-menu-button-set-popover) or [`gtk_menu_button_set_menu_model()`](gtkmenubutton#gtk-menu-button-set-menu-model).
#### Parameters
| | | |
| --- | --- | --- |
| menu\_button | the [GtkMenuButton](gtkmenubutton#GtkMenuButton-struct) | |
| user\_data | User data passed to [`gtk_menu_button_set_create_popup_func()`](gtkmenubutton#gtk-menu-button-set-create-popup-func) | |
### gtk\_menu\_button\_set\_create\_popup\_func ()
```
void
gtk_menu_button_set_create_popup_func (*`[GtkMenuButton](gtkmenubutton#GtkMenuButton-struct) *menu_button`*,
*`[GtkMenuButtonCreatePopupFunc](gtkmenubutton#GtkMenuButtonCreatePopupFunc) func`*,
*`gpointer user_data`*,
*`GDestroyNotify destroy_notify`*);
```
Sets *`func`* to be called when a popup is about to be shown. *`func`* should use one of
* gtk\_menu\_button\_set\_popover()
* gtk\_menu\_button\_set\_menu\_model()
to set a popup for *`menu_button`* . If *`func`* is non-`NULL`, *`menu_button`* will always be sensitive.
Using this function will not reset the menu widget attached to *`menu_button`* . Instead, this can be done manually in *`func`* .
#### Parameters
| | | |
| --- | --- | --- |
| menu\_button | a [GtkMenuButton](gtkmenubutton#GtkMenuButton-struct) | |
| func | function to call when a popuop is about to be shown, but none has been provided via other means, or `NULL` to reset to default behavior. | [nullable] |
| user\_data | user data to pass to *`func`* . | [closure] |
| destroy\_notify | destroy notify for *`user_data`* . | [nullable] |
Types and Values
----------------
### GtkMenuButton
```
typedef struct _GtkMenuButton GtkMenuButton;
```
### enum GtkArrowType
Used to indicate the direction in which an arrow should point.
#### Members
| | | |
| --- | --- | --- |
| GTK\_ARROW\_UP | Represents an upward pointing arrow. | |
| GTK\_ARROW\_DOWN | Represents a downward pointing arrow. | |
| GTK\_ARROW\_LEFT | Represents a left pointing arrow. | |
| GTK\_ARROW\_RIGHT | Represents a right pointing arrow. | |
| GTK\_ARROW\_NONE | No arrow. | |
Property Details
----------------
### The `“direction”` property
```
“direction” [GtkArrowType](gtkmenubutton#GtkArrowType)
```
The [GtkArrowType](gtkmenubutton#GtkArrowType) representing the direction in which the menu or popover will be popped out.
Owner: GtkMenuButton
Flags: Read / Write
Default value: GTK\_ARROW\_DOWN
### The `“has-frame”` property
```
“has-frame” gboolean
```
Whether the button has a frame.
Owner: GtkMenuButton
Flags: Read / Write
Default value: TRUE
### The `“icon-name”` property
```
“icon-name” char *
```
The name of the icon used to automatically populate the button.
Owner: GtkMenuButton
Flags: Read / Write
Default value: NULL
### The `“label”` property
```
“label” char *
```
The label for the button.
Owner: GtkMenuButton
Flags: Read / Write
Default value: NULL
### The `“menu-model”` property
```
“menu-model” GMenuModel *
```
The GMenuModel from which the popup will be created.
See [`gtk_menu_button_set_menu_model()`](gtkmenubutton#gtk-menu-button-set-menu-model) for the interaction with the “popup” property.
Owner: GtkMenuButton
Flags: Read / Write
### The `“popover”` property
```
“popover” [GtkPopover](gtkpopover#GtkPopover-struct) *
```
The [GtkPopover](gtkpopover#GtkPopover-struct) that will be popped up when the button is clicked.
Owner: GtkMenuButton
Flags: Read / Write
### The `“use-underline”` property
```
“use-underline” gboolean
```
If set, an underline in the text indicates the next character should be used for the mnemonic accelerator key.
Owner: GtkMenuButton
Flags: Read / Write
Default value: FALSE
gtk GtkCalendar GtkCalendar
===========
GtkCalendar — Displays a calendar and allows the user to select a date
Functions
---------
| | |
| --- | --- |
| [GtkWidget](gtkwidget#GtkWidget-struct) \* | [gtk\_calendar\_new](gtkcalendar#gtk-calendar-new) () |
| void | [gtk\_calendar\_select\_day](gtkcalendar#gtk-calendar-select-day) () |
| void | [gtk\_calendar\_mark\_day](gtkcalendar#gtk-calendar-mark-day) () |
| void | [gtk\_calendar\_unmark\_day](gtkcalendar#gtk-calendar-unmark-day) () |
| gboolean | [gtk\_calendar\_get\_day\_is\_marked](gtkcalendar#gtk-calendar-get-day-is-marked) () |
| void | [gtk\_calendar\_clear\_marks](gtkcalendar#gtk-calendar-clear-marks) () |
| gboolean | [gtk\_calendar\_get\_show\_day\_names](gtkcalendar#gtk-calendar-get-show-day-names) () |
| void | [gtk\_calendar\_set\_show\_day\_names](gtkcalendar#gtk-calendar-set-show-day-names) () |
| gboolean | [gtk\_calendar\_get\_show\_heading](gtkcalendar#gtk-calendar-get-show-heading) () |
| void | [gtk\_calendar\_set\_show\_heading](gtkcalendar#gtk-calendar-set-show-heading) () |
| gboolean | [gtk\_calendar\_get\_show\_week\_numbers](gtkcalendar#gtk-calendar-get-show-week-numbers) () |
| void | [gtk\_calendar\_set\_show\_week\_numbers](gtkcalendar#gtk-calendar-set-show-week-numbers) () |
| GDateTime \* | [gtk\_calendar\_get\_date](gtkcalendar#gtk-calendar-get-date) () |
Properties
----------
| | | |
| --- | --- | --- |
| int | [day](gtkcalendar#GtkCalendar--day) | Read / Write |
| int | [month](gtkcalendar#GtkCalendar--month) | Read / Write |
| gboolean | [show-day-names](gtkcalendar#GtkCalendar--show-day-names) | Read / Write |
| gboolean | [show-heading](gtkcalendar#GtkCalendar--show-heading) | Read / Write |
| gboolean | [show-week-numbers](gtkcalendar#GtkCalendar--show-week-numbers) | Read / Write |
| int | [year](gtkcalendar#GtkCalendar--year) | Read / Write |
Signals
-------
| | | |
| --- | --- | --- |
| void | [day-selected](gtkcalendar#GtkCalendar-day-selected) | Run First |
| void | [next-month](gtkcalendar#GtkCalendar-next-month) | Run First |
| void | [next-year](gtkcalendar#GtkCalendar-next-year) | Run First |
| void | [prev-month](gtkcalendar#GtkCalendar-prev-month) | Run First |
| void | [prev-year](gtkcalendar#GtkCalendar-prev-year) | Run First |
Types and Values
----------------
| | |
| --- | --- |
| | [GtkCalendar](gtkcalendar#GtkCalendar-struct) |
Object Hierarchy
----------------
```
GObject
╰── GInitiallyUnowned
╰── [GtkWidget](gtkwidget#GtkWidget-struct)
╰── GtkCalendar
```
Implemented Interfaces
----------------------
GtkCalendar implements [GtkAccessible](gtkaccessible#GtkAccessible-struct), [GtkBuildable](gtkbuildable#GtkBuildable-struct) and [GtkConstraintTarget](gtkconstraint#GtkConstraintTarget-struct).
Includes
--------
```
#include <gtk/gtk.h>
```
Description
-----------
[GtkCalendar](gtkcalendar#GtkCalendar-struct) is a widget that displays a Gregorian calendar, one month at a time. It can be created with [`gtk_calendar_new()`](gtkcalendar#gtk-calendar-new).
The date that is currently displayed can be altered with [`gtk_calendar_select_day()`](gtkcalendar#gtk-calendar-select-day).
To place a visual marker on a particular day, use [`gtk_calendar_mark_day()`](gtkcalendar#gtk-calendar-mark-day) and to remove the marker, [`gtk_calendar_unmark_day()`](gtkcalendar#gtk-calendar-unmark-day). Alternative, all marks can be cleared with [`gtk_calendar_clear_marks()`](gtkcalendar#gtk-calendar-clear-marks).
The selected date can be retrieved from a [GtkCalendar](gtkcalendar#GtkCalendar-struct) using [`gtk_calendar_get_date()`](gtkcalendar#gtk-calendar-get-date).
Users should be aware that, although the Gregorian calendar is the legal calendar in most countries, it was adopted progressively between 1582 and 1929. Display before these dates is likely to be historically incorrect.
### CSS nodes
```
calendar.view
├── header
│ ├── button
│ ├── stack.month
│ ├── button
│ ├── button
│ ├── label.year
│ ╰── button
╰── grid
╰── label[.day-name][.week-number][.day-number][.other-month][.today]
```
| GtkCalendar has a main node with name calendar. It contains a subnode called header containing the widgets for switching between years and months.
The grid subnode contains all day labels, including week numbers on the left (marked with the .week-number css class) and day names on top (marked with the .day-name css class).
Day labels that belong to the previous or next month get the .other-month style class. The label of the current day get the .today style class.
Marked day labels get the :selected state assigned.
Functions
---------
### gtk\_calendar\_new ()
```
[GtkWidget](gtkwidget#GtkWidget-struct) *
gtk_calendar_new (*`void`*);
```
Creates a new calendar, with the current date being selected.
#### Returns
a newly [GtkCalendar](gtkcalendar#GtkCalendar-struct) widget
### gtk\_calendar\_select\_day ()
```
void
gtk_calendar_select_day (*`[GtkCalendar](gtkcalendar#GtkCalendar-struct) *self`*,
*`GDateTime *date`*);
```
Will switch to *`date`* 's year and month and select its day.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkCalendar](gtkcalendar#GtkCalendar-struct). | |
| date | a GDateTime representing the day to select. | [transfer none] |
### gtk\_calendar\_mark\_day ()
```
void
gtk_calendar_mark_day (*`[GtkCalendar](gtkcalendar#GtkCalendar-struct) *calendar`*,
*`guint day`*);
```
Places a visual marker on a particular day.
#### Parameters
| | | |
| --- | --- | --- |
| calendar | a [GtkCalendar](gtkcalendar#GtkCalendar-struct) | |
| day | the day number to mark between 1 and 31. | |
### gtk\_calendar\_unmark\_day ()
```
void
gtk_calendar_unmark_day (*`[GtkCalendar](gtkcalendar#GtkCalendar-struct) *calendar`*,
*`guint day`*);
```
Removes the visual marker from a particular day.
#### Parameters
| | | |
| --- | --- | --- |
| calendar | a [GtkCalendar](gtkcalendar#GtkCalendar-struct). | |
| day | the day number to unmark between 1 and 31. | |
### gtk\_calendar\_get\_day\_is\_marked ()
```
gboolean
gtk_calendar_get_day_is_marked (*`[GtkCalendar](gtkcalendar#GtkCalendar-struct) *calendar`*,
*`guint day`*);
```
Returns if the *`day`* of the *`calendar`* is already marked.
#### Parameters
| | | |
| --- | --- | --- |
| calendar | a [GtkCalendar](gtkcalendar#GtkCalendar-struct) | |
| day | the day number between 1 and 31. | |
#### Returns
whether the day is marked.
### gtk\_calendar\_clear\_marks ()
```
void
gtk_calendar_clear_marks (*`[GtkCalendar](gtkcalendar#GtkCalendar-struct) *calendar`*);
```
Remove all visual markers.
#### Parameters
| | | |
| --- | --- | --- |
| calendar | a [GtkCalendar](gtkcalendar#GtkCalendar-struct) | |
### gtk\_calendar\_get\_show\_day\_names ()
```
gboolean
gtk_calendar_get_show_day_names (*`[GtkCalendar](gtkcalendar#GtkCalendar-struct) *self`*);
```
Returns whether *`self`* is currently showing the names of the week days above the day numbers, i.e. the value of the [“show-day-names”](gtkcalendar#GtkCalendar--show-day-names) property.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkCalendar](gtkcalendar#GtkCalendar-struct) | |
#### Returns
Whether the calendar shows day names.
### gtk\_calendar\_set\_show\_day\_names ()
```
void
gtk_calendar_set_show_day_names (*`[GtkCalendar](gtkcalendar#GtkCalendar-struct) *self`*,
*`gboolean value`*);
```
Sets whether the calendar shows day names.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkCalendar](gtkcalendar#GtkCalendar-struct) | |
| value | Whether to show day names above the day numbers | |
### gtk\_calendar\_get\_show\_heading ()
```
gboolean
gtk_calendar_get_show_heading (*`[GtkCalendar](gtkcalendar#GtkCalendar-struct) *self`*);
```
Returns whether *`self`* is currently showing the heading, i.e. the value of the [“show-heading”](gtkcalendar#GtkCalendar--show-heading) property.
Return: Whether the calendar is showing a heading.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkCalendar](gtkcalendar#GtkCalendar-struct) | |
### gtk\_calendar\_set\_show\_heading ()
```
void
gtk_calendar_set_show_heading (*`[GtkCalendar](gtkcalendar#GtkCalendar-struct) *self`*,
*`gboolean value`*);
```
Sets whether the calendar should show a heading containing the current year and month as well as buttons for changing both.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkCalendar](gtkcalendar#GtkCalendar-struct) | |
| value | Whether to show the heading in the calendar | |
### gtk\_calendar\_get\_show\_week\_numbers ()
```
gboolean
gtk_calendar_get_show_week_numbers (*`[GtkCalendar](gtkcalendar#GtkCalendar-struct) *self`*);
```
Returns whether *`self`* is showing week numbers right now, i.e. the value of the [“show-week-numbers”](gtkcalendar#GtkCalendar--show-week-numbers) property.
Return: Whether the calendar is showing week numbers.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkCalendar](gtkcalendar#GtkCalendar-struct) | |
### gtk\_calendar\_set\_show\_week\_numbers ()
```
void
gtk_calendar_set_show_week_numbers (*`[GtkCalendar](gtkcalendar#GtkCalendar-struct) *self`*,
*`gboolean value`*);
```
Sets whether week numbers are shown in the calendar.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkCalendar](gtkcalendar#GtkCalendar-struct) | |
| value | whether to show week numbers on the left of the days | |
### gtk\_calendar\_get\_date ()
```
GDateTime *
gtk_calendar_get_date (*`[GtkCalendar](gtkcalendar#GtkCalendar-struct) *self`*);
```
Returns a GDateTime representing the shown year, month and the selected day, in the local time zone.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkCalendar](gtkcalendar#GtkCalendar-struct) | |
#### Returns
the GDate representing the shown date.
[transfer full]
Types and Values
----------------
### GtkCalendar
```
typedef struct _GtkCalendar GtkCalendar;
```
Property Details
----------------
### The `“day”` property
```
“day” int
```
The selected day (as a number between 1 and 31, or 0 to unselect the currently selected day). This property gets initially set to the current day.
Owner: GtkCalendar
Flags: Read / Write
Allowed values: [0,31]
Default value: 0
### The `“month”` property
```
“month” int
```
The selected month (as a number between 0 and 11). This property gets initially set to the current month.
Owner: GtkCalendar
Flags: Read / Write
Allowed values: [0,11]
Default value: 0
### The `“show-day-names”` property
```
“show-day-names” gboolean
```
Determines whether day names are displayed.
Owner: GtkCalendar
Flags: Read / Write
Default value: TRUE
### The `“show-heading”` property
```
“show-heading” gboolean
```
Determines whether a heading is displayed.
Owner: GtkCalendar
Flags: Read / Write
Default value: TRUE
### The `“show-week-numbers”` property
```
“show-week-numbers” gboolean
```
Determines whether week numbers are displayed.
Owner: GtkCalendar
Flags: Read / Write
Default value: FALSE
### The `“year”` property
```
“year” int
```
The selected year. This property gets initially set to the current year.
Owner: GtkCalendar
Flags: Read / Write
Allowed values: [1,9999]
Default value: 1
Signal Details
--------------
### The `“day-selected”` signal
```
void
user_function ([GtkCalendar](gtkcalendar#GtkCalendar-struct) *calendar,
gpointer user_data)
```
Emitted when the user selects a day.
#### Parameters
| | | |
| --- | --- | --- |
| calendar | the object which received the signal. | |
| user\_data | user data set when the signal handler was connected. | |
Flags: Run First
### The `“next-month”` signal
```
void
user_function ([GtkCalendar](gtkcalendar#GtkCalendar-struct) *calendar,
gpointer user_data)
```
Emitted when the user switched to the next month.
#### Parameters
| | | |
| --- | --- | --- |
| calendar | the object which received the signal. | |
| user\_data | user data set when the signal handler was connected. | |
Flags: Run First
### The `“next-year”` signal
```
void
user_function ([GtkCalendar](gtkcalendar#GtkCalendar-struct) *calendar,
gpointer user_data)
```
Emitted when user switched to the next year.
#### Parameters
| | | |
| --- | --- | --- |
| calendar | the object which received the signal. | |
| user\_data | user data set when the signal handler was connected. | |
Flags: Run First
### The `“prev-month”` signal
```
void
user_function ([GtkCalendar](gtkcalendar#GtkCalendar-struct) *calendar,
gpointer user_data)
```
Emitted when the user switched to the previous month.
#### Parameters
| | | |
| --- | --- | --- |
| calendar | the object which received the signal. | |
| user\_data | user data set when the signal handler was connected. | |
Flags: Run First
### The `“prev-year”` signal
```
void
user_function ([GtkCalendar](gtkcalendar#GtkCalendar-struct) *calendar,
gpointer user_data)
```
Emitted when user switched to the previous year.
#### Parameters
| | | |
| --- | --- | --- |
| calendar | the object which received the signal. | |
| user\_data | user data set when the signal handler was connected. | |
Flags: Run First
| programming_docs |
gtk Connecting actions to widgets Connecting actions to widgets
=============================
Any widget that implements the GtkActionable interface can be connected to an action just by setting the ::action-name property. If the action has a parameter, you will also need to set the ::action-target property. Widgets that implement GtkActionable include GtkSwitch, GtkButton, and their respective subclasses.
Another way of obtaining widgets that are connected to actions is to create a menu using a GMenu menu model. GMenu provides an abstract way to describe typical menus: nested groups of items where each item can have a label, and icon, and an action.
A typical use of GMenu inside GTK is to set up an application menubar with [`gtk_application_set_menubar()`](gtkapplication#gtk-application-set-menubar). Another, maybe more common use is to create a popover for a menubutton, using [`gtk_menu_button_set_menu_model()`](gtkmenubutton#gtk-menu-button-set-menu-model).
Unlike traditional menus, those created from menu models don’t have keyboard accelerators associated with menu items. Instead, GtkApplication offers the [`gtk_application_set_accels_for_action()`](gtkapplication#gtk-application-set-accels-for-action) API to associate keyboard shortcuts with actions.
gtk GtkCellRendererText GtkCellRendererText
===================
GtkCellRendererText — Renders text in a cell
Functions
---------
| | |
| --- | --- |
| [GtkCellRenderer](gtkcellrenderer#GtkCellRenderer-struct) \* | [gtk\_cell\_renderer\_text\_new](gtkcellrenderertext#gtk-cell-renderer-text-new) () |
| void | [gtk\_cell\_renderer\_text\_set\_fixed\_height\_from\_font](gtkcellrenderertext#gtk-cell-renderer-text-set-fixed-height-from-font) () |
Properties
----------
| | | |
| --- | --- | --- |
| gboolean | [align-set](gtkcellrenderertext#GtkCellRendererText--align-set) | Read / Write |
| [PangoAlignment](https://developer-old.gnome.org/pango/stable/pango-Layout-Objects.html#PangoAlignment) | [alignment](gtkcellrenderertext#GtkCellRendererText--alignment) | Read / Write |
| [PangoAttrList](https://developer-old.gnome.org/pango/stable/pango-Text-Attributes.html#PangoAttrList-struct) \* | [attributes](gtkcellrenderertext#GtkCellRendererText--attributes) | Read / Write |
| char \* | [background](gtkcellrenderertext#GtkCellRendererText--background) | Write |
| [GdkRGBA](https://developer-old.gnome.org/gtk4/html/gdk4-RGBA-Colors.html#GdkRGBA-struct) \* | [background-rgba](gtkcellrenderertext#GtkCellRendererText--background-rgba) | Read / Write |
| gboolean | [background-set](gtkcellrenderertext#GtkCellRendererText--background-set) | Read / Write |
| gboolean | [editable](gtkcellrenderertext#GtkCellRendererText--editable) | Read / Write |
| gboolean | [editable-set](gtkcellrenderertext#GtkCellRendererText--editable-set) | Read / Write |
| [PangoEllipsizeMode](https://developer-old.gnome.org/pango/stable/pango-Layout-Objects.html#PangoEllipsizeMode) | [ellipsize](gtkcellrenderertext#GtkCellRendererText--ellipsize) | Read / Write |
| gboolean | [ellipsize-set](gtkcellrenderertext#GtkCellRendererText--ellipsize-set) | Read / Write |
| char \* | [family](gtkcellrenderertext#GtkCellRendererText--family) | Read / Write |
| gboolean | [family-set](gtkcellrenderertext#GtkCellRendererText--family-set) | Read / Write |
| char \* | [font](gtkcellrenderertext#GtkCellRendererText--font) | Read / Write |
| [PangoFontDescription](https://developer-old.gnome.org/pango/stable/pango-Fonts.html#PangoFontDescription-struct) \* | [font-desc](gtkcellrenderertext#GtkCellRendererText--font-desc) | Read / Write |
| char \* | [foreground](gtkcellrenderertext#GtkCellRendererText--foreground) | Write |
| [GdkRGBA](https://developer-old.gnome.org/gtk4/html/gdk4-RGBA-Colors.html#GdkRGBA-struct) \* | [foreground-rgba](gtkcellrenderertext#GtkCellRendererText--foreground-rgba) | Read / Write |
| gboolean | [foreground-set](gtkcellrenderertext#GtkCellRendererText--foreground-set) | Read / Write |
| char \* | [language](gtkcellrenderertext#GtkCellRendererText--language) | Read / Write |
| gboolean | [language-set](gtkcellrenderertext#GtkCellRendererText--language-set) | Read / Write |
| char \* | [markup](gtkcellrenderertext#GtkCellRendererText--markup) | Write |
| int | [max-width-chars](gtkcellrenderertext#GtkCellRendererText--max-width-chars) | Read / Write |
| char \* | [placeholder-text](gtkcellrenderertext#GtkCellRendererText--placeholder-text) | Read / Write |
| int | [rise](gtkcellrenderertext#GtkCellRendererText--rise) | Read / Write |
| gboolean | [rise-set](gtkcellrenderertext#GtkCellRendererText--rise-set) | Read / Write |
| double | [scale](gtkcellrenderertext#GtkCellRendererText--scale) | Read / Write |
| gboolean | [scale-set](gtkcellrenderertext#GtkCellRendererText--scale-set) | Read / Write |
| gboolean | [single-paragraph-mode](gtkcellrenderertext#GtkCellRendererText--single-paragraph-mode) | Read / Write |
| int | [size](gtkcellrenderertext#GtkCellRendererText--size) | Read / Write |
| double | [size-points](gtkcellrenderertext#GtkCellRendererText--size-points) | Read / Write |
| gboolean | [size-set](gtkcellrenderertext#GtkCellRendererText--size-set) | Read / Write |
| [PangoStretch](https://developer-old.gnome.org/pango/stable/pango-Fonts.html#PangoStretch) | [stretch](gtkcellrenderertext#GtkCellRendererText--stretch) | Read / Write |
| gboolean | [stretch-set](gtkcellrenderertext#GtkCellRendererText--stretch-set) | Read / Write |
| gboolean | [strikethrough](gtkcellrenderertext#GtkCellRendererText--strikethrough) | Read / Write |
| gboolean | [strikethrough-set](gtkcellrenderertext#GtkCellRendererText--strikethrough-set) | Read / Write |
| [PangoStyle](https://developer-old.gnome.org/pango/stable/pango-Fonts.html#PangoStyle) | [style](gtkcellrenderertext#GtkCellRendererText--style) | Read / Write |
| gboolean | [style-set](gtkcellrenderertext#GtkCellRendererText--style-set) | Read / Write |
| char \* | [text](gtkcellrenderertext#GtkCellRendererText--text) | Read / Write |
| [PangoUnderline](https://developer-old.gnome.org/pango/stable/pango-Text-Attributes.html#PangoUnderline) | [underline](gtkcellrenderertext#GtkCellRendererText--underline) | Read / Write |
| gboolean | [underline-set](gtkcellrenderertext#GtkCellRendererText--underline-set) | Read / Write |
| [PangoVariant](https://developer-old.gnome.org/pango/stable/pango-Fonts.html#PangoVariant) | [variant](gtkcellrenderertext#GtkCellRendererText--variant) | Read / Write |
| gboolean | [variant-set](gtkcellrenderertext#GtkCellRendererText--variant-set) | Read / Write |
| int | [weight](gtkcellrenderertext#GtkCellRendererText--weight) | Read / Write |
| gboolean | [weight-set](gtkcellrenderertext#GtkCellRendererText--weight-set) | Read / Write |
| int | [width-chars](gtkcellrenderertext#GtkCellRendererText--width-chars) | Read / Write |
| [PangoWrapMode](https://developer-old.gnome.org/pango/stable/pango-Layout-Objects.html#PangoWrapMode) | [wrap-mode](gtkcellrenderertext#GtkCellRendererText--wrap-mode) | Read / Write |
| int | [wrap-width](gtkcellrenderertext#GtkCellRendererText--wrap-width) | Read / Write |
Signals
-------
| | | |
| --- | --- | --- |
| void | [edited](gtkcellrenderertext#GtkCellRendererText-edited) | Run Last |
Types and Values
----------------
| | |
| --- | --- |
| struct | [GtkCellRendererText](gtkcellrenderertext#GtkCellRendererText-struct) |
Object Hierarchy
----------------
```
GObject
╰── GInitiallyUnowned
╰── [GtkCellRenderer](gtkcellrenderer#GtkCellRenderer-struct)
╰── GtkCellRendererText
├── [GtkCellRendererAccel](gtkcellrendereraccel#GtkCellRendererAccel-struct)
├── [GtkCellRendererCombo](gtkcellrenderercombo#GtkCellRendererCombo-struct)
╰── [GtkCellRendererSpin](gtkcellrendererspin#GtkCellRendererSpin-struct)
```
Includes
--------
```
#include <gtk/gtk.h>
```
Description
-----------
A [GtkCellRendererText](gtkcellrenderertext#GtkCellRendererText-struct) renders a given text in its cell, using the font, color and style information provided by its properties. The text will be ellipsized if it is too long and the [“ellipsize”](gtkcellrenderertext#GtkCellRendererText--ellipsize) property allows it.
If the [“mode”](gtkcellrenderer#GtkCellRenderer--mode) is [`GTK_CELL_RENDERER_MODE_EDITABLE`](gtkcellrenderer#GTK-CELL-RENDERER-MODE-EDITABLE:CAPS), the [GtkCellRendererText](gtkcellrenderertext#GtkCellRendererText-struct) allows to edit its text using an entry.
Functions
---------
### gtk\_cell\_renderer\_text\_new ()
```
[GtkCellRenderer](gtkcellrenderer#GtkCellRenderer-struct) *
gtk_cell_renderer_text_new (*`void`*);
```
Creates a new [GtkCellRendererText](gtkcellrenderertext#GtkCellRendererText-struct). Adjust how text is drawn using object properties. Object properties can be set globally (with `g_object_set()`). Also, with [GtkTreeViewColumn](gtktreeviewcolumn#GtkTreeViewColumn-struct), you can bind a property to a value in a [GtkTreeModel](gtktreemodel#GtkTreeModel-struct). For example, you can bind the “text” property on the cell renderer to a string value in the model, thus rendering a different string in each row of the [GtkTreeView](gtktreeview#GtkTreeView-struct)
#### Returns
the new cell renderer
### gtk\_cell\_renderer\_text\_set\_fixed\_height\_from\_font ()
```
void
gtk_cell_renderer_text_set_fixed_height_from_font
(*`[GtkCellRendererText](gtkcellrenderertext#GtkCellRendererText-struct) *renderer`*,
*`int number_of_rows`*);
```
Sets the height of a renderer to explicitly be determined by the “font” and “y\_pad” property set on it. Further changes in these properties do not affect the height, so they must be accompanied by a subsequent call to this function. Using this function is inflexible, and should really only be used if calculating the size of a cell is too slow (ie, a massive number of cells displayed). If *`number_of_rows`* is -1, then the fixed height is unset, and the height is determined by the properties again.
#### Parameters
| | | |
| --- | --- | --- |
| renderer | A [GtkCellRendererText](gtkcellrenderertext#GtkCellRendererText-struct) | |
| number\_of\_rows | Number of rows of text each cell renderer is allocated, or -1 | |
Types and Values
----------------
### struct GtkCellRendererText
```
struct GtkCellRendererText;
```
Property Details
----------------
### The `“align-set”` property
```
“align-set” gboolean
```
Whether this tag affects the alignment mode.
Owner: GtkCellRendererText
Flags: Read / Write
Default value: FALSE
### The `“alignment”` property
```
“alignment” [PangoAlignment](https://developer-old.gnome.org/pango/stable/pango-Layout-Objects.html#PangoAlignment)
```
Specifies how to align the lines of text with respect to each other.
Note that this property describes how to align the lines of text in case there are several of them. The "xalign" property of [GtkCellRenderer](gtkcellrenderer#GtkCellRenderer-struct), on the other hand, sets the horizontal alignment of the whole text.
Owner: GtkCellRendererText
Flags: Read / Write
Default value: PANGO\_ALIGN\_LEFT
### The `“attributes”` property
```
“attributes” [PangoAttrList](https://developer-old.gnome.org/pango/stable/pango-Text-Attributes.html#PangoAttrList-struct) *
```
A list of style attributes to apply to the text of the renderer.
Owner: GtkCellRendererText
Flags: Read / Write
### The `“background”` property
```
“background” char *
```
Background color as a string.
Owner: GtkCellRendererText
Flags: Write
Default value: NULL
### The `“background-rgba”` property
```
“background-rgba” [GdkRGBA](https://developer-old.gnome.org/gtk4/html/gdk4-RGBA-Colors.html#GdkRGBA-struct) *
```
Background color as a [GdkRGBA](https://developer-old.gnome.org/gtk4/html/gdk4-RGBA-Colors.html#GdkRGBA-struct)
Owner: GtkCellRendererText
Flags: Read / Write
### The `“background-set”` property
```
“background-set” gboolean
```
Whether this tag affects the background color.
Owner: GtkCellRendererText
Flags: Read / Write
Default value: FALSE
### The `“editable”` property
```
“editable” gboolean
```
Whether the text can be modified by the user.
Owner: GtkCellRendererText
Flags: Read / Write
Default value: FALSE
### The `“editable-set”` property
```
“editable-set” gboolean
```
Whether this tag affects text editability.
Owner: GtkCellRendererText
Flags: Read / Write
Default value: FALSE
### The `“ellipsize”` property
```
“ellipsize” [PangoEllipsizeMode](https://developer-old.gnome.org/pango/stable/pango-Layout-Objects.html#PangoEllipsizeMode)
```
Specifies the preferred place to ellipsize the string, if the cell renderer does not have enough room to display the entire string. Setting it to [`PANGO_ELLIPSIZE_NONE`](https://developer-old.gnome.org/pango/stable/pango-Layout-Objects.html#PANGO-ELLIPSIZE-NONE:CAPS) turns off ellipsizing. See the wrap-width property for another way of making the text fit into a given width.
Owner: GtkCellRendererText
Flags: Read / Write
Default value: PANGO\_ELLIPSIZE\_NONE
### The `“ellipsize-set”` property
```
“ellipsize-set” gboolean
```
Whether this tag affects the ellipsize mode.
Owner: GtkCellRendererText
Flags: Read / Write
Default value: FALSE
### The `“family”` property
```
“family” char *
```
Name of the font family, e.g. Sans, Helvetica, Times, Monospace.
Owner: GtkCellRendererText
Flags: Read / Write
Default value: NULL
### The `“family-set”` property
```
“family-set” gboolean
```
Whether this tag affects the font family.
Owner: GtkCellRendererText
Flags: Read / Write
Default value: FALSE
### The `“font”` property
```
“font” char *
```
Font description as a string, e.g. “Sans Italic 12”.
Owner: GtkCellRendererText
Flags: Read / Write
Default value: NULL
### The `“font-desc”` property
```
“font-desc” [PangoFontDescription](https://developer-old.gnome.org/pango/stable/pango-Fonts.html#PangoFontDescription-struct) *
```
Font description as a PangoFontDescription struct.
Owner: GtkCellRendererText
Flags: Read / Write
### The `“foreground”` property
```
“foreground” char *
```
Foreground color as a string.
Owner: GtkCellRendererText
Flags: Write
Default value: NULL
### The `“foreground-rgba”` property
```
“foreground-rgba” [GdkRGBA](https://developer-old.gnome.org/gtk4/html/gdk4-RGBA-Colors.html#GdkRGBA-struct) *
```
Foreground color as a [GdkRGBA](https://developer-old.gnome.org/gtk4/html/gdk4-RGBA-Colors.html#GdkRGBA-struct)
Owner: GtkCellRendererText
Flags: Read / Write
### The `“foreground-set”` property
```
“foreground-set” gboolean
```
Whether this tag affects the foreground color.
Owner: GtkCellRendererText
Flags: Read / Write
Default value: FALSE
### The `“language”` property
```
“language” char *
```
The language this text is in, as an ISO code. Pango can use this as a hint when rendering the text. If you don’t understand this parameter, you probably don’t need it.
Owner: GtkCellRendererText
Flags: Read / Write
Default value: NULL
### The `“language-set”` property
```
“language-set” gboolean
```
Whether this tag affects the language the text is rendered as.
Owner: GtkCellRendererText
Flags: Read / Write
Default value: FALSE
### The `“markup”` property
```
“markup” char *
```
Marked up text to render.
Owner: GtkCellRendererText
Flags: Write
Default value: NULL
### The `“max-width-chars”` property
```
“max-width-chars” int
```
The desired maximum width of the cell, in characters. If this property is set to -1, the width will be calculated automatically.
For cell renderers that ellipsize or wrap text; this property controls the maximum reported width of the cell. The cell should not receive any greater allocation unless it is set to expand in its [GtkCellLayout](gtkcelllayout#GtkCellLayout-struct) and all of the cell's siblings have received their natural width.
Owner: GtkCellRendererText
Flags: Read / Write
Allowed values: >= -1
Default value: -1
### The `“placeholder-text”` property
```
“placeholder-text” char *
```
The text that will be displayed in the [GtkCellRenderer](gtkcellrenderer#GtkCellRenderer-struct) if [“editable”](gtkcellrenderertext#GtkCellRendererText--editable) is `TRUE` and the cell is empty.
Owner: GtkCellRendererText
Flags: Read / Write
Default value: NULL
### The `“rise”` property
```
“rise” int
```
Offset of text above the baseline (below the baseline if rise is negative).
Owner: GtkCellRendererText
Flags: Read / Write
Allowed values: >= -2147483647
Default value: 0
### The `“rise-set”` property
```
“rise-set” gboolean
```
Whether this tag affects the rise.
Owner: GtkCellRendererText
Flags: Read / Write
Default value: FALSE
### The `“scale”` property
```
“scale” double
```
Font scaling factor.
Owner: GtkCellRendererText
Flags: Read / Write
Allowed values: >= 0
Default value: 1
### The `“scale-set”` property
```
“scale-set” gboolean
```
Whether this tag scales the font size by a factor.
Owner: GtkCellRendererText
Flags: Read / Write
Default value: FALSE
### The `“single-paragraph-mode”` property
```
“single-paragraph-mode” gboolean
```
Whether to keep all text in a single paragraph.
Owner: GtkCellRendererText
Flags: Read / Write
Default value: FALSE
### The `“size”` property
```
“size” int
```
Font size.
Owner: GtkCellRendererText
Flags: Read / Write
Allowed values: >= 0
Default value: 0
### The `“size-points”` property
```
“size-points” double
```
Font size in points.
Owner: GtkCellRendererText
Flags: Read / Write
Allowed values: >= 0
Default value: 0
### The `“size-set”` property
```
“size-set” gboolean
```
Whether this tag affects the font size.
Owner: GtkCellRendererText
Flags: Read / Write
Default value: FALSE
### The `“stretch”` property
```
“stretch” [PangoStretch](https://developer-old.gnome.org/pango/stable/pango-Fonts.html#PangoStretch)
```
Font stretch.
Owner: GtkCellRendererText
Flags: Read / Write
Default value: PANGO\_STRETCH\_NORMAL
### The `“stretch-set”` property
```
“stretch-set” gboolean
```
Whether this tag affects the font stretch.
Owner: GtkCellRendererText
Flags: Read / Write
Default value: FALSE
### The `“strikethrough”` property
```
“strikethrough” gboolean
```
Whether to strike through the text.
Owner: GtkCellRendererText
Flags: Read / Write
Default value: FALSE
### The `“strikethrough-set”` property
```
“strikethrough-set” gboolean
```
Whether this tag affects strikethrough.
Owner: GtkCellRendererText
Flags: Read / Write
Default value: FALSE
### The `“style”` property
```
“style” [PangoStyle](https://developer-old.gnome.org/pango/stable/pango-Fonts.html#PangoStyle)
```
Font style.
Owner: GtkCellRendererText
Flags: Read / Write
Default value: PANGO\_STYLE\_NORMAL
### The `“style-set”` property
```
“style-set” gboolean
```
Whether this tag affects the font style.
Owner: GtkCellRendererText
Flags: Read / Write
Default value: FALSE
### The `“text”` property
```
“text” char *
```
Text to render.
Owner: GtkCellRendererText
Flags: Read / Write
Default value: NULL
### The `“underline”` property
```
“underline” [PangoUnderline](https://developer-old.gnome.org/pango/stable/pango-Text-Attributes.html#PangoUnderline)
```
Style of underline for this text.
Owner: GtkCellRendererText
Flags: Read / Write
Default value: PANGO\_UNDERLINE\_NONE
### The `“underline-set”` property
```
“underline-set” gboolean
```
Whether this tag affects underlining.
Owner: GtkCellRendererText
Flags: Read / Write
Default value: FALSE
### The `“variant”` property
```
“variant” [PangoVariant](https://developer-old.gnome.org/pango/stable/pango-Fonts.html#PangoVariant)
```
Font variant.
Owner: GtkCellRendererText
Flags: Read / Write
Default value: PANGO\_VARIANT\_NORMAL
### The `“variant-set”` property
```
“variant-set” gboolean
```
Whether this tag affects the font variant.
Owner: GtkCellRendererText
Flags: Read / Write
Default value: FALSE
### The `“weight”` property
```
“weight” int
```
Font weight.
Owner: GtkCellRendererText
Flags: Read / Write
Allowed values: >= 0
Default value: 400
### The `“weight-set”` property
```
“weight-set” gboolean
```
Whether this tag affects the font weight.
Owner: GtkCellRendererText
Flags: Read / Write
Default value: FALSE
### The `“width-chars”` property
```
“width-chars” int
```
The desired width of the cell, in characters. If this property is set to -1, the width will be calculated automatically, otherwise the cell will request either 3 characters or the property value, whichever is greater.
Owner: GtkCellRendererText
Flags: Read / Write
Allowed values: >= -1
Default value: -1
### The `“wrap-mode”` property
```
“wrap-mode” [PangoWrapMode](https://developer-old.gnome.org/pango/stable/pango-Layout-Objects.html#PangoWrapMode)
```
Specifies how to break the string into multiple lines, if the cell renderer does not have enough room to display the entire string. This property has no effect unless the wrap-width property is set.
Owner: GtkCellRendererText
Flags: Read / Write
Default value: PANGO\_WRAP\_CHAR
### The `“wrap-width”` property
```
“wrap-width” int
```
Specifies the minimum width at which the text is wrapped. The wrap-mode property can be used to influence at what character positions the line breaks can be placed. Setting wrap-width to -1 turns wrapping off.
Owner: GtkCellRendererText
Flags: Read / Write
Allowed values: >= -1
Default value: -1
Signal Details
--------------
### The `“edited”` signal
```
void
user_function ([GtkCellRendererText](gtkcellrenderertext#GtkCellRendererText-struct) *renderer,
char *path,
char *new_text,
gpointer user_data)
```
This signal is emitted after *`renderer`* has been edited.
It is the responsibility of the application to update the model and store *`new_text`* at the position indicated by *`path`* .
#### Parameters
| | | |
| --- | --- | --- |
| renderer | the object which received the signal | |
| path | the path identifying the edited cell | |
| new\_text | the new text | |
| user\_data | user data set when the signal handler was connected. | |
Flags: Run Last
| programming_docs |
gtk Keyboard input Keyboard input
==============
Every [GtkWindow](gtkwindow#GtkWindow-struct) maintains a single focus location (in the [“focus-widget”](gtkwindow#GtkWindow--focus-widget) property). The focus widget is the target widget for key events sent to the window. Only widgets which have [“can-focus”](gtkwidget#GtkWidget--can-focus) set to `TRUE` can become the focus. Typically these are input controls such as entries or text fields, but e.g. buttons can take the focus too.
Input widgets can be given the focus by clicking on them, but focus can also be moved around with certain key events (this is known as “keyboard navigation”). GTK reserves the Tab key to move the focus to the next location, and Shift-Tab to move it back to the previous one. In addition many containers allow “directional navigation” with the arrow keys.
Many widgets can be “activated” to trigger and action. E.g., you can activate a button or switch by clicking on them, but you can also activate them with the keyboard, by using the Enter or Space keys.
Apart from keyboard navigation, activation and directly typing into entries or text views, GTK widgets can use key events for activating “shortcuts”. Shortcuts generally act as a quick way to move the focus around or to activate a widget that does not currently have the focus.
GTK has traditionally supported different kinds of shortcuts:
* Accelerators are any other shortcuts that can be activated regardless of where the focus is, and typically trigger global actions, such as Ctrl-Q to quit an application.
* Mnemonics are usually triggered using Alt as a modifier for a letter. They are used in places where a label is associated with a control, and are indicated by underlining the letter in the label. As a special case, inside menus (i.e. inside [GtkPopoverMenu](gtkpopovermenu#GtkPopoverMenu-struct)), mnemonics can be triggered without the modifier.
* Key bindings are specific to individual widgets, such as Ctrl-C or Ctrl-V in an entry copy to or paste from the clipboard. They are only triggered when the widget has focus.
GTK handles accelerators and mnemonics in a global scope, during the capture phase, and key bindings locally, during the target phase.
Under the hood, all shortcuts are represented as instances of [GtkShortcut](gtkshortcut#GtkShortcut-struct), and they are managed by [GtkShortcutController](gtkshortcutcontroller#GtkShortcutController-struct).
gtk GtkCellRendererProgress GtkCellRendererProgress
=======================
GtkCellRendererProgress — Renders numbers as progress bars
Functions
---------
| | |
| --- | --- |
| [GtkCellRenderer](gtkcellrenderer#GtkCellRenderer-struct) \* | [gtk\_cell\_renderer\_progress\_new](gtkcellrendererprogress#gtk-cell-renderer-progress-new) () |
Properties
----------
| | | |
| --- | --- | --- |
| gboolean | [inverted](gtkcellrendererprogress#GtkCellRendererProgress--inverted) | Read / Write |
| int | [pulse](gtkcellrendererprogress#GtkCellRendererProgress--pulse) | Read / Write |
| char \* | [text](gtkcellrendererprogress#GtkCellRendererProgress--text) | Read / Write |
| float | [text-xalign](gtkcellrendererprogress#GtkCellRendererProgress--text-xalign) | Read / Write |
| float | [text-yalign](gtkcellrendererprogress#GtkCellRendererProgress--text-yalign) | Read / Write |
| int | [value](gtkcellrendererprogress#GtkCellRendererProgress--value) | Read / Write |
Types and Values
----------------
| | |
| --- | --- |
| | [GtkCellRendererProgress](gtkcellrendererprogress#GtkCellRendererProgress-struct) |
Object Hierarchy
----------------
```
GObject
╰── GInitiallyUnowned
╰── [GtkCellRenderer](gtkcellrenderer#GtkCellRenderer-struct)
╰── GtkCellRendererProgress
```
Implemented Interfaces
----------------------
GtkCellRendererProgress implements [GtkOrientable](gtk4-orientable#GtkOrientable-struct).
Includes
--------
```
#include <gtk/gtk.h>
```
Description
-----------
[GtkCellRendererProgress](gtkcellrendererprogress#GtkCellRendererProgress-struct) renders a numeric value as a progress par in a cell. Additionally, it can display a text on top of the progress bar.
Functions
---------
### gtk\_cell\_renderer\_progress\_new ()
```
[GtkCellRenderer](gtkcellrenderer#GtkCellRenderer-struct) *
gtk_cell_renderer_progress_new (*`void`*);
```
Creates a new [GtkCellRendererProgress](gtkcellrendererprogress#GtkCellRendererProgress-struct).
#### Returns
the new cell renderer
Types and Values
----------------
### GtkCellRendererProgress
```
typedef struct _GtkCellRendererProgress GtkCellRendererProgress;
```
Property Details
----------------
### The `“inverted”` property
```
“inverted” gboolean
```
Invert the direction in which the progress bar grows.
Owner: GtkCellRendererProgress
Flags: Read / Write
Default value: FALSE
### The `“pulse”` property
```
“pulse” int
```
Setting this to a non-negative value causes the cell renderer to enter "activity mode", where a block bounces back and forth to indicate that some progress is made, without specifying exactly how much.
Each increment of the property causes the block to move by a little bit.
To indicate that the activity has not started yet, set the property to zero. To indicate completion, set the property to `G_MAXINT`.
Owner: GtkCellRendererProgress
Flags: Read / Write
Allowed values: >= -1
Default value: -1
### The `“text”` property
```
“text” char *
```
The "text" property determines the label which will be drawn over the progress bar. Setting this property to `NULL` causes the default label to be displayed. Setting this property to an empty string causes no label to be displayed.
Owner: GtkCellRendererProgress
Flags: Read / Write
Default value: NULL
### The `“text-xalign”` property
```
“text-xalign” float
```
The "text-xalign" property controls the horizontal alignment of the text in the progress bar. Valid values range from 0 (left) to 1 (right). Reserved for RTL layouts.
Owner: GtkCellRendererProgress
Flags: Read / Write
Allowed values: [0,1]
Default value: 0.5
### The `“text-yalign”` property
```
“text-yalign” float
```
The "text-yalign" property controls the vertical alignment of the text in the progress bar. Valid values range from 0 (top) to 1 (bottom).
Owner: GtkCellRendererProgress
Flags: Read / Write
Allowed values: [0,1]
Default value: 0.5
### The `“value”` property
```
“value” int
```
The "value" property determines the percentage to which the progress bar will be "filled in".
Owner: GtkCellRendererProgress
Flags: Read / Write
Allowed values: [0,100]
Default value: 0
gtk GtkLockButton GtkLockButton
=============
GtkLockButton — A widget to unlock or lock privileged operations
Functions
---------
| | |
| --- | --- |
| [GtkWidget](gtkwidget#GtkWidget-struct) \* | [gtk\_lock\_button\_new](gtklockbutton#gtk-lock-button-new) () |
| GPermission \* | [gtk\_lock\_button\_get\_permission](gtklockbutton#gtk-lock-button-get-permission) () |
| void | [gtk\_lock\_button\_set\_permission](gtklockbutton#gtk-lock-button-set-permission) () |
Properties
----------
| | | |
| --- | --- | --- |
| GPermission \* | [permission](gtklockbutton#GtkLockButton--permission) | Read / Write |
| char \* | [text-lock](gtklockbutton#GtkLockButton--text-lock) | Read / Write / Construct |
| char \* | [text-unlock](gtklockbutton#GtkLockButton--text-unlock) | Read / Write / Construct |
| char \* | [tooltip-lock](gtklockbutton#GtkLockButton--tooltip-lock) | Read / Write / Construct |
| char \* | [tooltip-not-authorized](gtklockbutton#GtkLockButton--tooltip-not-authorized) | Read / Write / Construct |
| char \* | [tooltip-unlock](gtklockbutton#GtkLockButton--tooltip-unlock) | Read / Write / Construct |
Types and Values
----------------
| | |
| --- | --- |
| | [GtkLockButton](gtklockbutton#GtkLockButton-struct) |
Object Hierarchy
----------------
```
GObject
╰── GInitiallyUnowned
╰── [GtkWidget](gtkwidget#GtkWidget-struct)
╰── [GtkButton](gtkbutton#GtkButton-struct)
╰── GtkLockButton
```
Implemented Interfaces
----------------------
GtkLockButton implements [GtkAccessible](gtkaccessible#GtkAccessible-struct), [GtkBuildable](gtkbuildable#GtkBuildable-struct), [GtkConstraintTarget](gtkconstraint#GtkConstraintTarget-struct) and [GtkActionable](gtkactionable#GtkActionable-struct).
Includes
--------
```
#include <gtk/gtk.h>
```
Description
-----------
GtkLockButton is a widget that can be used in control panels or preference dialogs to allow users to obtain and revoke authorizations needed to operate the controls. The required authorization is represented by a GPermission object. Concrete implementations of GPermission may use PolicyKit or some other authorization framework. To obtain a PolicyKit-based GPermission, use [`polkit_permission_new()`](https://developer-old.gnome.org/usr/share/gtk-doc/html/polkit-1/PolkitPermission.html#polkit-permission-new).
If the user is not currently allowed to perform the action, but can obtain the permission, the widget looks like this:
and the user can click the button to request the permission. Depending on the platform, this may pop up an authentication dialog or ask the user to authenticate in some other way. Once the user has obtained the permission, the widget changes to this:
and the permission can be dropped again by clicking the button. If the user is not able to obtain the permission at all, the widget looks like this:
If the user has the permission and cannot drop it, the button is hidden.
The text (and tooltips) that are shown in the various cases can be adjusted with the [“text-lock”](gtklockbutton#GtkLockButton--text-lock), [“text-unlock”](gtklockbutton#GtkLockButton--text-unlock), [“tooltip-lock”](gtklockbutton#GtkLockButton--tooltip-lock), [“tooltip-unlock”](gtklockbutton#GtkLockButton--tooltip-unlock) and [“tooltip-not-authorized”](gtklockbutton#GtkLockButton--tooltip-not-authorized) properties.
Functions
---------
### gtk\_lock\_button\_new ()
```
[GtkWidget](gtkwidget#GtkWidget-struct) *
gtk_lock_button_new (*`GPermission *permission`*);
```
Creates a new lock button which reflects the *`permission`* .
#### Parameters
| | | |
| --- | --- | --- |
| permission | a GPermission. | [allow-none] |
#### Returns
a new [GtkLockButton](gtklockbutton#GtkLockButton-struct)
### gtk\_lock\_button\_get\_permission ()
```
GPermission *
gtk_lock_button_get_permission (*`[GtkLockButton](gtklockbutton#GtkLockButton-struct) *button`*);
```
Obtains the GPermission object that controls *`button`* .
#### Parameters
| | | |
| --- | --- | --- |
| button | a [GtkLockButton](gtklockbutton#GtkLockButton-struct) | |
#### Returns
the GPermission of *`button`* .
[transfer none]
### gtk\_lock\_button\_set\_permission ()
```
void
gtk_lock_button_set_permission (*`[GtkLockButton](gtklockbutton#GtkLockButton-struct) *button`*,
*`GPermission *permission`*);
```
Sets the GPermission object that controls *`button`* .
#### Parameters
| | | |
| --- | --- | --- |
| button | a [GtkLockButton](gtklockbutton#GtkLockButton-struct) | |
| permission | a GPermission object, or `NULL`. | [allow-none] |
Types and Values
----------------
### GtkLockButton
```
typedef struct _GtkLockButton GtkLockButton;
```
Property Details
----------------
### The `“permission”` property
```
“permission” GPermission *
```
The GPermission object controlling this button.
Owner: GtkLockButton
Flags: Read / Write
### The `“text-lock”` property
```
“text-lock” char *
```
The text to display when prompting the user to lock.
Owner: GtkLockButton
Flags: Read / Write / Construct
Default value: "Lock"
### The `“text-unlock”` property
```
“text-unlock” char *
```
The text to display when prompting the user to unlock.
Owner: GtkLockButton
Flags: Read / Write / Construct
Default value: "Unlock"
### The `“tooltip-lock”` property
```
“tooltip-lock” char *
```
The tooltip to display when prompting the user to lock.
Owner: GtkLockButton
Flags: Read / Write / Construct
Default value: "Dialog is unlocked.\nClick to prevent further changes"
### The `“tooltip-not-authorized”` property
```
“tooltip-not-authorized” char *
```
The tooltip to display when prompting the user cannot obtain authorization.
Owner: GtkLockButton
Flags: Read / Write / Construct
Default value: "System policy prevents changes.\nContact your system administrator"
### The `“tooltip-unlock”` property
```
“tooltip-unlock” char *
```
The tooltip to display when prompting the user to unlock.
Owner: GtkLockButton
Flags: Read / Write / Construct
Default value: "Dialog is locked.\nClick to make changes"
gtk GtkPrintJob GtkPrintJob
===========
GtkPrintJob — Represents a print job
Functions
---------
| | |
| --- | --- |
| void | ([\*GtkPrintJobCompleteFunc](gtkprintjob#GtkPrintJobCompleteFunc)) () |
| [GtkPrintJob](gtkprintjob#GtkPrintJob-struct) \* | [gtk\_print\_job\_new](gtkprintjob#gtk-print-job-new) () |
| [GtkPrintSettings](gtkprintsettings#GtkPrintSettings-struct) \* | [gtk\_print\_job\_get\_settings](gtkprintjob#gtk-print-job-get-settings) () |
| [GtkPrinter](gtkprinter#GtkPrinter-struct) \* | [gtk\_print\_job\_get\_printer](gtkprintjob#gtk-print-job-get-printer) () |
| const char \* | [gtk\_print\_job\_get\_title](gtkprintjob#gtk-print-job-get-title) () |
| [GtkPrintStatus](gtk4-high-level-printing-api#GtkPrintStatus) | [gtk\_print\_job\_get\_status](gtkprintjob#gtk-print-job-get-status) () |
| gboolean | [gtk\_print\_job\_set\_source\_file](gtkprintjob#gtk-print-job-set-source-file) () |
| gboolean | [gtk\_print\_job\_set\_source\_fd](gtkprintjob#gtk-print-job-set-source-fd) () |
| [cairo\_surface\_t](https://developer-old.gnome.org/cairo/stable/cairo-cairo-surface-t.html#cairo-surface-t) \* | [gtk\_print\_job\_get\_surface](gtkprintjob#gtk-print-job-get-surface) () |
| void | [gtk\_print\_job\_send](gtkprintjob#gtk-print-job-send) () |
| void | [gtk\_print\_job\_set\_track\_print\_status](gtkprintjob#gtk-print-job-set-track-print-status) () |
| gboolean | [gtk\_print\_job\_get\_track\_print\_status](gtkprintjob#gtk-print-job-get-track-print-status) () |
| [GtkPrintPages](gtkprintsettings#GtkPrintPages) | [gtk\_print\_job\_get\_pages](gtkprintjob#gtk-print-job-get-pages) () |
| void | [gtk\_print\_job\_set\_pages](gtkprintjob#gtk-print-job-set-pages) () |
| [GtkPageRange](gtkprintsettings#GtkPageRange) \* | [gtk\_print\_job\_get\_page\_ranges](gtkprintjob#gtk-print-job-get-page-ranges) () |
| void | [gtk\_print\_job\_set\_page\_ranges](gtkprintjob#gtk-print-job-set-page-ranges) () |
| [GtkPageSet](gtkprintsettings#GtkPageSet) | [gtk\_print\_job\_get\_page\_set](gtkprintjob#gtk-print-job-get-page-set) () |
| void | [gtk\_print\_job\_set\_page\_set](gtkprintjob#gtk-print-job-set-page-set) () |
| int | [gtk\_print\_job\_get\_num\_copies](gtkprintjob#gtk-print-job-get-num-copies) () |
| void | [gtk\_print\_job\_set\_num\_copies](gtkprintjob#gtk-print-job-set-num-copies) () |
| double | [gtk\_print\_job\_get\_scale](gtkprintjob#gtk-print-job-get-scale) () |
| void | [gtk\_print\_job\_set\_scale](gtkprintjob#gtk-print-job-set-scale) () |
| guint | [gtk\_print\_job\_get\_n\_up](gtkprintjob#gtk-print-job-get-n-up) () |
| void | [gtk\_print\_job\_set\_n\_up](gtkprintjob#gtk-print-job-set-n-up) () |
| [GtkNumberUpLayout](gtkprintsettings#GtkNumberUpLayout) | [gtk\_print\_job\_get\_n\_up\_layout](gtkprintjob#gtk-print-job-get-n-up-layout) () |
| void | [gtk\_print\_job\_set\_n\_up\_layout](gtkprintjob#gtk-print-job-set-n-up-layout) () |
| gboolean | [gtk\_print\_job\_get\_rotate](gtkprintjob#gtk-print-job-get-rotate) () |
| void | [gtk\_print\_job\_set\_rotate](gtkprintjob#gtk-print-job-set-rotate) () |
| gboolean | [gtk\_print\_job\_get\_collate](gtkprintjob#gtk-print-job-get-collate) () |
| void | [gtk\_print\_job\_set\_collate](gtkprintjob#gtk-print-job-set-collate) () |
| gboolean | [gtk\_print\_job\_get\_reverse](gtkprintjob#gtk-print-job-get-reverse) () |
| void | [gtk\_print\_job\_set\_reverse](gtkprintjob#gtk-print-job-set-reverse) () |
Properties
----------
| | | |
| --- | --- | --- |
| [GtkPageSetup](gtkpagesetup#GtkPageSetup-struct) \* | [page-setup](gtkprintjob#GtkPrintJob--page-setup) | Read / Write / Construct Only |
| [GtkPrinter](gtkprinter#GtkPrinter-struct) \* | [printer](gtkprintjob#GtkPrintJob--printer) | Read / Write / Construct Only |
| [GtkPrintSettings](gtkprintsettings#GtkPrintSettings-struct) \* | [settings](gtkprintjob#GtkPrintJob--settings) | Read / Write / Construct Only |
| char \* | [title](gtkprintjob#GtkPrintJob--title) | Read / Write / Construct Only |
| gboolean | [track-print-status](gtkprintjob#GtkPrintJob--track-print-status) | Read / Write |
Signals
-------
| | | |
| --- | --- | --- |
| void | [status-changed](gtkprintjob#GtkPrintJob-status-changed) | Run Last |
Types and Values
----------------
| | |
| --- | --- |
| | [GtkPrintJob](gtkprintjob#GtkPrintJob-struct) |
Object Hierarchy
----------------
```
GObject
╰── GtkPrintJob
```
Includes
--------
```
#include <gtk/gtkunixprint.h>
```
Description
-----------
A [GtkPrintJob](gtkprintjob#GtkPrintJob-struct) object represents a job that is sent to a printer. You only need to deal directly with print jobs if you use the non-portable [GtkPrintUnixDialog](gtkprintunixdialog#GtkPrintUnixDialog-struct) API.
Use [`gtk_print_job_get_surface()`](gtkprintjob#gtk-print-job-get-surface) to obtain the cairo surface onto which the pages must be drawn. Use [`gtk_print_job_send()`](gtkprintjob#gtk-print-job-send) to send the finished job to the printer. If you don’t use cairo [GtkPrintJob](gtkprintjob#GtkPrintJob-struct) also supports printing of manually generated postscript, via [`gtk_print_job_set_source_file()`](gtkprintjob#gtk-print-job-set-source-file).
Functions
---------
### GtkPrintJobCompleteFunc ()
```
void
(*GtkPrintJobCompleteFunc) (*`[GtkPrintJob](gtkprintjob#GtkPrintJob-struct) *print_job`*,
*`gpointer user_data`*,
*`const GError *error`*);
```
The type of callback that is passed to [`gtk_print_job_send()`](gtkprintjob#gtk-print-job-send). It is called when the print job has been completely sent.
#### Parameters
| | | |
| --- | --- | --- |
| print\_job | the [GtkPrintJob](gtkprintjob#GtkPrintJob-struct) | |
| user\_data | user data that has been passed to [`gtk_print_job_send()`](gtkprintjob#gtk-print-job-send) | |
| error | a GError that contains error information if the sending of the print job failed, otherwise `NULL` | |
### gtk\_print\_job\_new ()
```
[GtkPrintJob](gtkprintjob#GtkPrintJob-struct) *
gtk_print_job_new (*`const char *title`*,
*`[GtkPrinter](gtkprinter#GtkPrinter-struct) *printer`*,
*`[GtkPrintSettings](gtkprintsettings#GtkPrintSettings-struct) *settings`*,
*`[GtkPageSetup](gtkpagesetup#GtkPageSetup-struct) *page_setup`*);
```
Creates a new [GtkPrintJob](gtkprintjob#GtkPrintJob-struct).
#### Parameters
| | | |
| --- | --- | --- |
| title | the job title | |
| printer | a [GtkPrinter](gtkprinter#GtkPrinter-struct) | |
| settings | a [GtkPrintSettings](gtkprintsettings#GtkPrintSettings-struct) | |
| page\_setup | a [GtkPageSetup](gtkpagesetup#GtkPageSetup-struct) | |
#### Returns
a new [GtkPrintJob](gtkprintjob#GtkPrintJob-struct)
### gtk\_print\_job\_get\_settings ()
```
[GtkPrintSettings](gtkprintsettings#GtkPrintSettings-struct) *
gtk_print_job_get_settings (*`[GtkPrintJob](gtkprintjob#GtkPrintJob-struct) *job`*);
```
Gets the [GtkPrintSettings](gtkprintsettings#GtkPrintSettings-struct) of the print job.
#### Parameters
| | | |
| --- | --- | --- |
| job | a [GtkPrintJob](gtkprintjob#GtkPrintJob-struct) | |
#### Returns
the settings of *`job`* .
[transfer none]
### gtk\_print\_job\_get\_printer ()
```
[GtkPrinter](gtkprinter#GtkPrinter-struct) *
gtk_print_job_get_printer (*`[GtkPrintJob](gtkprintjob#GtkPrintJob-struct) *job`*);
```
Gets the [GtkPrinter](gtkprinter#GtkPrinter-struct) of the print job.
#### Parameters
| | | |
| --- | --- | --- |
| job | a [GtkPrintJob](gtkprintjob#GtkPrintJob-struct) | |
#### Returns
the printer of *`job`* .
[transfer none]
### gtk\_print\_job\_get\_title ()
```
const char *
gtk_print_job_get_title (*`[GtkPrintJob](gtkprintjob#GtkPrintJob-struct) *job`*);
```
Gets the job title.
#### Parameters
| | | |
| --- | --- | --- |
| job | a [GtkPrintJob](gtkprintjob#GtkPrintJob-struct) | |
#### Returns
the title of *`job`*
### gtk\_print\_job\_get\_status ()
```
[GtkPrintStatus](gtk4-high-level-printing-api#GtkPrintStatus)
gtk_print_job_get_status (*`[GtkPrintJob](gtkprintjob#GtkPrintJob-struct) *job`*);
```
Gets the status of the print job.
#### Parameters
| | | |
| --- | --- | --- |
| job | a [GtkPrintJob](gtkprintjob#GtkPrintJob-struct) | |
#### Returns
the status of *`job`*
### gtk\_print\_job\_set\_source\_file ()
```
gboolean
gtk_print_job_set_source_file (*`[GtkPrintJob](gtkprintjob#GtkPrintJob-struct) *job`*,
*`const char *filename`*,
*`GError **error`*);
```
Make the [GtkPrintJob](gtkprintjob#GtkPrintJob-struct) send an existing document to the printing system. The file can be in any format understood by the platforms printing system (typically PostScript, but on many platforms PDF may work too). See [`gtk_printer_accepts_pdf()`](gtkprinter#gtk-printer-accepts-pdf) and [`gtk_printer_accepts_ps()`](gtkprinter#gtk-printer-accepts-ps).
#### Parameters
| | | |
| --- | --- | --- |
| job | a [GtkPrintJob](gtkprintjob#GtkPrintJob-struct) | |
| filename | the file to be printed. | [type filename] |
| error | return location for errors | |
#### Returns
`FALSE` if an error occurred
### gtk\_print\_job\_set\_source\_fd ()
```
gboolean
gtk_print_job_set_source_fd (*`[GtkPrintJob](gtkprintjob#GtkPrintJob-struct) *job`*,
*`int fd`*,
*`GError **error`*);
```
Make the [GtkPrintJob](gtkprintjob#GtkPrintJob-struct) send an existing document to the printing system. The file can be in any format understood by the platforms printing system (typically PostScript, but on many platforms PDF may work too). See [`gtk_printer_accepts_pdf()`](gtkprinter#gtk-printer-accepts-pdf) and [`gtk_printer_accepts_ps()`](gtkprinter#gtk-printer-accepts-ps).
This is similar to [`gtk_print_job_set_source_file()`](gtkprintjob#gtk-print-job-set-source-file), but takes expects an open file descriptor for the file, instead of a filename.
#### Parameters
| | | |
| --- | --- | --- |
| job | a [GtkPrintJob](gtkprintjob#GtkPrintJob-struct) | |
| fd | a file descriptor | |
| error | return location for errors | |
#### Returns
`FALSE` if an error occurred
### gtk\_print\_job\_get\_surface ()
```
[cairo\_surface\_t](https://developer-old.gnome.org/cairo/stable/cairo-cairo-surface-t.html#cairo-surface-t) *
gtk_print_job_get_surface (*`[GtkPrintJob](gtkprintjob#GtkPrintJob-struct) *job`*,
*`GError **error`*);
```
Gets a cairo surface onto which the pages of the print job should be rendered.
#### Parameters
| | | |
| --- | --- | --- |
| job | a [GtkPrintJob](gtkprintjob#GtkPrintJob-struct) | |
| error | return location for errors, or `NULL`. | [allow-none] |
#### Returns
the cairo surface of *`job`* .
[transfer none]
### gtk\_print\_job\_send ()
```
void
gtk_print_job_send (*`[GtkPrintJob](gtkprintjob#GtkPrintJob-struct) *job`*,
*`[GtkPrintJobCompleteFunc](gtkprintjob#GtkPrintJobCompleteFunc) callback`*,
*`gpointer user_data`*,
*`GDestroyNotify dnotify`*);
```
Sends the print job off to the printer.
#### Parameters
| | | |
| --- | --- | --- |
| job | a GtkPrintJob | |
| callback | function to call when the job completes or an error occurs | |
| user\_data | user data that gets passed to *`callback`* . | [closure] |
| dnotify | destroy notify for *`user_data`* | |
### gtk\_print\_job\_set\_track\_print\_status ()
```
void
gtk_print_job_set_track_print_status (*`[GtkPrintJob](gtkprintjob#GtkPrintJob-struct) *job`*,
*`gboolean track_status`*);
```
If track\_status is `TRUE`, the print job will try to continue report on the status of the print job in the printer queues and printer. This can allow your application to show things like “out of paper” issues, and when the print job actually reaches the printer.
This function is often implemented using some form of polling, so it should not be enabled unless needed.
#### Parameters
| | | |
| --- | --- | --- |
| job | a [GtkPrintJob](gtkprintjob#GtkPrintJob-struct) | |
| track\_status | `TRUE` to track status after printing | |
### gtk\_print\_job\_get\_track\_print\_status ()
```
gboolean
gtk_print_job_get_track_print_status (*`[GtkPrintJob](gtkprintjob#GtkPrintJob-struct) *job`*);
```
Returns whether jobs will be tracked after printing. For details, see [`gtk_print_job_set_track_print_status()`](gtkprintjob#gtk-print-job-set-track-print-status).
#### Parameters
| | | |
| --- | --- | --- |
| job | a [GtkPrintJob](gtkprintjob#GtkPrintJob-struct) | |
#### Returns
`TRUE` if print job status will be reported after printing
### gtk\_print\_job\_get\_pages ()
```
[GtkPrintPages](gtkprintsettings#GtkPrintPages)
gtk_print_job_get_pages (*`[GtkPrintJob](gtkprintjob#GtkPrintJob-struct) *job`*);
```
Gets the [GtkPrintPages](gtkprintsettings#GtkPrintPages) setting for this job.
#### Parameters
| | | |
| --- | --- | --- |
| job | a [GtkPrintJob](gtkprintjob#GtkPrintJob-struct) | |
#### Returns
the [GtkPrintPages](gtkprintsettings#GtkPrintPages) setting
### gtk\_print\_job\_set\_pages ()
```
void
gtk_print_job_set_pages (*`[GtkPrintJob](gtkprintjob#GtkPrintJob-struct) *job`*,
*`[GtkPrintPages](gtkprintsettings#GtkPrintPages) pages`*);
```
Sets the [GtkPrintPages](gtkprintsettings#GtkPrintPages) setting for this job.
#### Parameters
| | | |
| --- | --- | --- |
| job | a [GtkPrintJob](gtkprintjob#GtkPrintJob-struct) | |
| pages | the [GtkPrintPages](gtkprintsettings#GtkPrintPages) setting | |
### gtk\_print\_job\_get\_page\_ranges ()
```
[GtkPageRange](gtkprintsettings#GtkPageRange) *
gtk_print_job_get_page_ranges (*`[GtkPrintJob](gtkprintjob#GtkPrintJob-struct) *job`*,
*`int *n_ranges`*);
```
Gets the page ranges for this job.
#### Parameters
| | | |
| --- | --- | --- |
| job | a [GtkPrintJob](gtkprintjob#GtkPrintJob-struct) | |
| n\_ranges | return location for the number of ranges. | [out] |
#### Returns
a pointer to an array of [GtkPageRange](gtkprintsettings#GtkPageRange) structs.
[array length=n\_ranges][transfer none]
### gtk\_print\_job\_set\_page\_ranges ()
```
void
gtk_print_job_set_page_ranges (*`[GtkPrintJob](gtkprintjob#GtkPrintJob-struct) *job`*,
*`[GtkPageRange](gtkprintsettings#GtkPageRange) *ranges`*,
*`int n_ranges`*);
```
Sets the page ranges for this job.
#### Parameters
| | | |
| --- | --- | --- |
| job | a [GtkPrintJob](gtkprintjob#GtkPrintJob-struct) | |
| ranges | pointer to an array of [GtkPageRange](gtkprintsettings#GtkPageRange) structs. | [array length=n\_ranges][transfer full] |
| n\_ranges | the length of the *`ranges`* array | |
### gtk\_print\_job\_get\_page\_set ()
```
[GtkPageSet](gtkprintsettings#GtkPageSet)
gtk_print_job_get_page_set (*`[GtkPrintJob](gtkprintjob#GtkPrintJob-struct) *job`*);
```
Gets the [GtkPageSet](gtkprintsettings#GtkPageSet) setting for this job.
#### Parameters
| | | |
| --- | --- | --- |
| job | a [GtkPrintJob](gtkprintjob#GtkPrintJob-struct) | |
#### Returns
the [GtkPageSet](gtkprintsettings#GtkPageSet) setting
### gtk\_print\_job\_set\_page\_set ()
```
void
gtk_print_job_set_page_set (*`[GtkPrintJob](gtkprintjob#GtkPrintJob-struct) *job`*,
*`[GtkPageSet](gtkprintsettings#GtkPageSet) page_set`*);
```
Sets the [GtkPageSet](gtkprintsettings#GtkPageSet) setting for this job.
#### Parameters
| | | |
| --- | --- | --- |
| job | a [GtkPrintJob](gtkprintjob#GtkPrintJob-struct) | |
| page\_set | a [GtkPageSet](gtkprintsettings#GtkPageSet) setting | |
### gtk\_print\_job\_get\_num\_copies ()
```
int
gtk_print_job_get_num_copies (*`[GtkPrintJob](gtkprintjob#GtkPrintJob-struct) *job`*);
```
Gets the number of copies of this job.
#### Parameters
| | | |
| --- | --- | --- |
| job | a [GtkPrintJob](gtkprintjob#GtkPrintJob-struct) | |
#### Returns
the number of copies
### gtk\_print\_job\_set\_num\_copies ()
```
void
gtk_print_job_set_num_copies (*`[GtkPrintJob](gtkprintjob#GtkPrintJob-struct) *job`*,
*`int num_copies`*);
```
Sets the number of copies for this job.
#### Parameters
| | | |
| --- | --- | --- |
| job | a [GtkPrintJob](gtkprintjob#GtkPrintJob-struct) | |
| num\_copies | the number of copies | |
### gtk\_print\_job\_get\_scale ()
```
double
gtk_print_job_get_scale (*`[GtkPrintJob](gtkprintjob#GtkPrintJob-struct) *job`*);
```
Gets the scale for this job (where 1.0 means unscaled).
#### Parameters
| | | |
| --- | --- | --- |
| job | a [GtkPrintJob](gtkprintjob#GtkPrintJob-struct) | |
#### Returns
the scale
### gtk\_print\_job\_set\_scale ()
```
void
gtk_print_job_set_scale (*`[GtkPrintJob](gtkprintjob#GtkPrintJob-struct) *job`*,
*`double scale`*);
```
Sets the scale for this job (where 1.0 means unscaled).
#### Parameters
| | | |
| --- | --- | --- |
| job | a [GtkPrintJob](gtkprintjob#GtkPrintJob-struct) | |
| scale | the scale | |
### gtk\_print\_job\_get\_n\_up ()
```
guint
gtk_print_job_get_n_up (*`[GtkPrintJob](gtkprintjob#GtkPrintJob-struct) *job`*);
```
Gets the n-up setting for this job.
#### Parameters
| | | |
| --- | --- | --- |
| job | a [GtkPrintJob](gtkprintjob#GtkPrintJob-struct) | |
#### Returns
the n-up setting
### gtk\_print\_job\_set\_n\_up ()
```
void
gtk_print_job_set_n_up (*`[GtkPrintJob](gtkprintjob#GtkPrintJob-struct) *job`*,
*`guint n_up`*);
```
Sets the n-up setting for this job.
#### Parameters
| | | |
| --- | --- | --- |
| job | a [GtkPrintJob](gtkprintjob#GtkPrintJob-struct) | |
| n\_up | the n-up value | |
### gtk\_print\_job\_get\_n\_up\_layout ()
```
[GtkNumberUpLayout](gtkprintsettings#GtkNumberUpLayout)
gtk_print_job_get_n_up_layout (*`[GtkPrintJob](gtkprintjob#GtkPrintJob-struct) *job`*);
```
Gets the n-up layout setting for this job.
#### Parameters
| | | |
| --- | --- | --- |
| job | a [GtkPrintJob](gtkprintjob#GtkPrintJob-struct) | |
#### Returns
the n-up layout
### gtk\_print\_job\_set\_n\_up\_layout ()
```
void
gtk_print_job_set_n_up_layout (*`[GtkPrintJob](gtkprintjob#GtkPrintJob-struct) *job`*,
*`[GtkNumberUpLayout](gtkprintsettings#GtkNumberUpLayout) layout`*);
```
Sets the n-up layout setting for this job.
#### Parameters
| | | |
| --- | --- | --- |
| job | a [GtkPrintJob](gtkprintjob#GtkPrintJob-struct) | |
| layout | the n-up layout setting | |
### gtk\_print\_job\_get\_rotate ()
```
gboolean
gtk_print_job_get_rotate (*`[GtkPrintJob](gtkprintjob#GtkPrintJob-struct) *job`*);
```
Gets whether the job is printed rotated.
#### Parameters
| | | |
| --- | --- | --- |
| job | a [GtkPrintJob](gtkprintjob#GtkPrintJob-struct) | |
#### Returns
whether the job is printed rotated
### gtk\_print\_job\_set\_rotate ()
```
void
gtk_print_job_set_rotate (*`[GtkPrintJob](gtkprintjob#GtkPrintJob-struct) *job`*,
*`gboolean rotate`*);
```
Sets whether this job is printed rotated.
#### Parameters
| | | |
| --- | --- | --- |
| job | a [GtkPrintJob](gtkprintjob#GtkPrintJob-struct) | |
| rotate | whether to print rotated | |
### gtk\_print\_job\_get\_collate ()
```
gboolean
gtk_print_job_get_collate (*`[GtkPrintJob](gtkprintjob#GtkPrintJob-struct) *job`*);
```
Gets whether this job is printed collated.
#### Parameters
| | | |
| --- | --- | --- |
| job | a [GtkPrintJob](gtkprintjob#GtkPrintJob-struct) | |
#### Returns
whether the job is printed collated
### gtk\_print\_job\_set\_collate ()
```
void
gtk_print_job_set_collate (*`[GtkPrintJob](gtkprintjob#GtkPrintJob-struct) *job`*,
*`gboolean collate`*);
```
Sets whether this job is printed collated.
#### Parameters
| | | |
| --- | --- | --- |
| job | a [GtkPrintJob](gtkprintjob#GtkPrintJob-struct) | |
| collate | whether the job is printed collated | |
### gtk\_print\_job\_get\_reverse ()
```
gboolean
gtk_print_job_get_reverse (*`[GtkPrintJob](gtkprintjob#GtkPrintJob-struct) *job`*);
```
Gets whether this job is printed reversed.
#### Parameters
| | | |
| --- | --- | --- |
| job | a [GtkPrintJob](gtkprintjob#GtkPrintJob-struct) | |
#### Returns
whether the job is printed reversed.
### gtk\_print\_job\_set\_reverse ()
```
void
gtk_print_job_set_reverse (*`[GtkPrintJob](gtkprintjob#GtkPrintJob-struct) *job`*,
*`gboolean reverse`*);
```
Sets whether this job is printed reversed.
#### Parameters
| | | |
| --- | --- | --- |
| job | a [GtkPrintJob](gtkprintjob#GtkPrintJob-struct) | |
| reverse | whether the job is printed reversed | |
Types and Values
----------------
### GtkPrintJob
```
typedef struct _GtkPrintJob GtkPrintJob;
```
Property Details
----------------
### The `“page-setup”` property
```
“page-setup” [GtkPageSetup](gtkpagesetup#GtkPageSetup-struct) *
```
Page Setup.
Owner: GtkPrintJob
Flags: Read / Write / Construct Only
### The `“printer”` property
```
“printer” [GtkPrinter](gtkprinter#GtkPrinter-struct) *
```
Printer to print the job to.
Owner: GtkPrintJob
Flags: Read / Write / Construct Only
### The `“settings”` property
```
“settings” [GtkPrintSettings](gtkprintsettings#GtkPrintSettings-struct) *
```
Printer settings.
Owner: GtkPrintJob
Flags: Read / Write / Construct Only
### The `“title”` property
```
“title” char *
```
Title of the print job.
Owner: GtkPrintJob
Flags: Read / Write / Construct Only
Default value: NULL
### The `“track-print-status”` property
```
“track-print-status” gboolean
```
TRUE if the print job will continue to emit status-changed signals after the print data has been sent to the printer or print server.
Owner: GtkPrintJob
Flags: Read / Write
Default value: FALSE
Signal Details
--------------
### The `“status-changed”` signal
```
void
user_function ([GtkPrintJob](gtkprintjob#GtkPrintJob-struct) *job,
gpointer user_data)
```
Gets emitted when the status of a job changes. The signal handler can use [`gtk_print_job_get_status()`](gtkprintjob#gtk-print-job-get-status) to obtain the new status.
#### Parameters
| | | |
| --- | --- | --- |
| job | the [GtkPrintJob](gtkprintjob#GtkPrintJob-struct) object on which the signal was emitted | |
| user\_data | user data set when the signal handler was connected. | |
Flags: Run Last
| programming_docs |
gtk GtkFileChooser GtkFileChooser
==============
GtkFileChooser — File chooser interface used by GtkFileChooserWidget and GtkFileChooserDialog
Functions
---------
| | |
| --- | --- |
| void | [gtk\_file\_chooser\_set\_action](gtkfilechooser#gtk-file-chooser-set-action) () |
| [GtkFileChooserAction](gtkfilechooser#GtkFileChooserAction) | [gtk\_file\_chooser\_get\_action](gtkfilechooser#gtk-file-chooser-get-action) () |
| void | [gtk\_file\_chooser\_set\_select\_multiple](gtkfilechooser#gtk-file-chooser-set-select-multiple) () |
| gboolean | [gtk\_file\_chooser\_get\_select\_multiple](gtkfilechooser#gtk-file-chooser-get-select-multiple) () |
| void | [gtk\_file\_chooser\_set\_create\_folders](gtkfilechooser#gtk-file-chooser-set-create-folders) () |
| gboolean | [gtk\_file\_chooser\_get\_create\_folders](gtkfilechooser#gtk-file-chooser-get-create-folders) () |
| void | [gtk\_file\_chooser\_set\_current\_name](gtkfilechooser#gtk-file-chooser-set-current-name) () |
| char \* | [gtk\_file\_chooser\_get\_current\_name](gtkfilechooser#gtk-file-chooser-get-current-name) () |
| GFile \* | [gtk\_file\_chooser\_get\_file](gtkfilechooser#gtk-file-chooser-get-file) () |
| gboolean | [gtk\_file\_chooser\_set\_file](gtkfilechooser#gtk-file-chooser-set-file) () |
| GListModel \* | [gtk\_file\_chooser\_get\_files](gtkfilechooser#gtk-file-chooser-get-files) () |
| gboolean | [gtk\_file\_chooser\_set\_current\_folder](gtkfilechooser#gtk-file-chooser-set-current-folder) () |
| GFile \* | [gtk\_file\_chooser\_get\_current\_folder](gtkfilechooser#gtk-file-chooser-get-current-folder) () |
| void | [gtk\_file\_chooser\_add\_filter](gtkfilechooser#gtk-file-chooser-add-filter) () |
| void | [gtk\_file\_chooser\_remove\_filter](gtkfilechooser#gtk-file-chooser-remove-filter) () |
| GListModel \* | [gtk\_file\_chooser\_get\_filters](gtkfilechooser#gtk-file-chooser-get-filters) () |
| void | [gtk\_file\_chooser\_set\_filter](gtkfilechooser#gtk-file-chooser-set-filter) () |
| [GtkFileFilter](gtkfilefilter#GtkFileFilter-struct) \* | [gtk\_file\_chooser\_get\_filter](gtkfilechooser#gtk-file-chooser-get-filter) () |
| gboolean | [gtk\_file\_chooser\_add\_shortcut\_folder](gtkfilechooser#gtk-file-chooser-add-shortcut-folder) () |
| gboolean | [gtk\_file\_chooser\_remove\_shortcut\_folder](gtkfilechooser#gtk-file-chooser-remove-shortcut-folder) () |
| GListModel \* | [gtk\_file\_chooser\_get\_shortcut\_folders](gtkfilechooser#gtk-file-chooser-get-shortcut-folders) () |
| void | [gtk\_file\_chooser\_add\_choice](gtkfilechooser#gtk-file-chooser-add-choice) () |
| void | [gtk\_file\_chooser\_remove\_choice](gtkfilechooser#gtk-file-chooser-remove-choice) () |
| void | [gtk\_file\_chooser\_set\_choice](gtkfilechooser#gtk-file-chooser-set-choice) () |
| const char \* | [gtk\_file\_chooser\_get\_choice](gtkfilechooser#gtk-file-chooser-get-choice) () |
Properties
----------
| | | |
| --- | --- | --- |
| [GtkFileChooserAction](gtkfilechooser#GtkFileChooserAction) | [action](gtkfilechooser#GtkFileChooser--action) | Read / Write |
| gboolean | [create-folders](gtkfilechooser#GtkFileChooser--create-folders) | Read / Write |
| [GtkFileFilter](gtkfilefilter#GtkFileFilter-struct) \* | [filter](gtkfilechooser#GtkFileChooser--filter) | Read / Write |
| GListModel \* | [filters](gtkfilechooser#GtkFileChooser--filters) | Read |
| gboolean | [select-multiple](gtkfilechooser#GtkFileChooser--select-multiple) | Read / Write |
| GListModel \* | [shortcut-folders](gtkfilechooser#GtkFileChooser--shortcut-folders) | Read |
Types and Values
----------------
| | |
| --- | --- |
| | [GtkFileChooser](gtkfilechooser#GtkFileChooser-struct) |
| enum | [GtkFileChooserAction](gtkfilechooser#GtkFileChooserAction) |
| #define | [GTK\_FILE\_CHOOSER\_ERROR](gtkfilechooser#GTK-FILE-CHOOSER-ERROR:CAPS) |
| enum | [GtkFileChooserError](gtkfilechooser#GtkFileChooserError) |
Object Hierarchy
----------------
```
[GInterface](https://developer-old.gnome.org/gobject/stable/GTypeModule.html)
╰── GtkFileChooser
```
Prerequisites
-------------
GtkFileChooser requires GObject.
Known Implementations
---------------------
GtkFileChooser is implemented by [GtkFileChooserDialog](gtkfilechooserdialog#GtkFileChooserDialog-struct), [GtkFileChooserNative](gtkfilechoosernative#GtkFileChooserNative-struct) and [GtkFileChooserWidget](gtkfilechooserwidget#GtkFileChooserWidget-struct).
Includes
--------
```
#include <gtk/gtk.h>
```
Description
-----------
[GtkFileChooser](gtkfilechooser#GtkFileChooser-struct) is an interface that can be implemented by file selection widgets. In GTK, the main objects that implement this interface are [GtkFileChooserWidget](gtkfilechooserwidget#GtkFileChooserWidget-struct) and [GtkFileChooserDialog](gtkfilechooserdialog#GtkFileChooserDialog-struct). You do not need to write an object that implements the [GtkFileChooser](gtkfilechooser#GtkFileChooser-struct) interface unless you are trying to adapt an existing file selector to expose a standard programming interface.
[GtkFileChooser](gtkfilechooser#GtkFileChooser-struct) allows for shortcuts to various places in the filesystem. In the default implementation these are displayed in the left pane. It may be a bit confusing at first that these shortcuts come from various sources and in various flavours, so lets explain the terminology here:
* Bookmarks: are created by the user, by dragging folders from the right pane to the left pane, or by using the “Add”. Bookmarks can be renamed and deleted by the user.
* Shortcuts: can be provided by the application. For example, a Paint program may want to add a shortcut for a Clipart folder. Shortcuts cannot be modified by the user.
* Volumes: are provided by the underlying filesystem abstraction. They are the “roots” of the filesystem.
### File Names and Encodings
When the user is finished selecting files in a [GtkFileChooser](gtkfilechooser#GtkFileChooser-struct), your program can get the selected filenames as GFiles.
### Adding options
You can add extra widgets to a file chooser to provide options that are not present in the default design, by using [`gtk_file_chooser_add_choice()`](gtkfilechooser#gtk-file-chooser-add-choice). Each choice has an identifier and a user visible label; additionally, each choice can have multiple options. If a choice has no option, it will be rendered as a check button with the given label; if a choice has options, it will be rendered as a combo box.
Functions
---------
### gtk\_file\_chooser\_set\_action ()
```
void
gtk_file_chooser_set_action (*`[GtkFileChooser](gtkfilechooser#GtkFileChooser-struct) *chooser`*,
*`[GtkFileChooserAction](gtkfilechooser#GtkFileChooserAction) action`*);
```
Sets the type of operation that the chooser is performing; the user interface is adapted to suit the selected action. For example, an option to create a new folder might be shown if the action is [`GTK_FILE_CHOOSER_ACTION_SAVE`](gtkfilechooser#GTK-FILE-CHOOSER-ACTION-SAVE:CAPS) but not if the action is [`GTK_FILE_CHOOSER_ACTION_OPEN`](gtkfilechooser#GTK-FILE-CHOOSER-ACTION-OPEN:CAPS).
#### Parameters
| | | |
| --- | --- | --- |
| chooser | a [GtkFileChooser](gtkfilechooser#GtkFileChooser-struct) | |
| action | the action that the file selector is performing | |
### gtk\_file\_chooser\_get\_action ()
```
[GtkFileChooserAction](gtkfilechooser#GtkFileChooserAction)
gtk_file_chooser_get_action (*`[GtkFileChooser](gtkfilechooser#GtkFileChooser-struct) *chooser`*);
```
Gets the type of operation that the file chooser is performing; see [`gtk_file_chooser_set_action()`](gtkfilechooser#gtk-file-chooser-set-action).
#### Parameters
| | | |
| --- | --- | --- |
| chooser | a [GtkFileChooser](gtkfilechooser#GtkFileChooser-struct) | |
#### Returns
the action that the file selector is performing
### gtk\_file\_chooser\_set\_select\_multiple ()
```
void
gtk_file_chooser_set_select_multiple (*`[GtkFileChooser](gtkfilechooser#GtkFileChooser-struct) *chooser`*,
*`gboolean select_multiple`*);
```
Sets whether multiple files can be selected in the file selector. This is only relevant if the action is set to be [`GTK_FILE_CHOOSER_ACTION_OPEN`](gtkfilechooser#GTK-FILE-CHOOSER-ACTION-OPEN:CAPS) or [`GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER`](gtkfilechooser#GTK-FILE-CHOOSER-ACTION-SELECT-FOLDER:CAPS).
#### Parameters
| | | |
| --- | --- | --- |
| chooser | a [GtkFileChooser](gtkfilechooser#GtkFileChooser-struct) | |
| select\_multiple | `TRUE` if multiple files can be selected. | |
### gtk\_file\_chooser\_get\_select\_multiple ()
```
gboolean
gtk_file_chooser_get_select_multiple (*`[GtkFileChooser](gtkfilechooser#GtkFileChooser-struct) *chooser`*);
```
Gets whether multiple files can be selected in the file selector. See [`gtk_file_chooser_set_select_multiple()`](gtkfilechooser#gtk-file-chooser-set-select-multiple).
#### Parameters
| | | |
| --- | --- | --- |
| chooser | a [GtkFileChooser](gtkfilechooser#GtkFileChooser-struct) | |
#### Returns
`TRUE` if multiple files can be selected.
### gtk\_file\_chooser\_set\_create\_folders ()
```
void
gtk_file_chooser_set_create_folders (*`[GtkFileChooser](gtkfilechooser#GtkFileChooser-struct) *chooser`*,
*`gboolean create_folders`*);
```
Sets whether file chooser will offer to create new folders. This is only relevant if the action is not set to be [`GTK_FILE_CHOOSER_ACTION_OPEN`](gtkfilechooser#GTK-FILE-CHOOSER-ACTION-OPEN:CAPS).
#### Parameters
| | | |
| --- | --- | --- |
| chooser | a [GtkFileChooser](gtkfilechooser#GtkFileChooser-struct) | |
| create\_folders | `TRUE` if the Create Folder button should be displayed | |
### gtk\_file\_chooser\_get\_create\_folders ()
```
gboolean
gtk_file_chooser_get_create_folders (*`[GtkFileChooser](gtkfilechooser#GtkFileChooser-struct) *chooser`*);
```
Gets whether file chooser will offer to create new folders. See [`gtk_file_chooser_set_create_folders()`](gtkfilechooser#gtk-file-chooser-set-create-folders).
#### Parameters
| | | |
| --- | --- | --- |
| chooser | a [GtkFileChooser](gtkfilechooser#GtkFileChooser-struct) | |
#### Returns
`TRUE` if the Create Folder button should be displayed.
### gtk\_file\_chooser\_set\_current\_name ()
```
void
gtk_file_chooser_set_current_name (*`[GtkFileChooser](gtkfilechooser#GtkFileChooser-struct) *chooser`*,
*`const char *name`*);
```
Sets the current name in the file selector, as if entered by the user. Note that the name passed in here is a UTF-8 string rather than a filename. This function is meant for such uses as a suggested name in a “Save As...” dialog. You can pass “Untitled.doc” or a similarly suitable suggestion for the *`name`* .
If you want to preselect a particular existing file, you should use [`gtk_file_chooser_set_file()`](gtkfilechooser#gtk-file-chooser-set-file) instead.
Please see the documentation for those functions for an example of using [`gtk_file_chooser_set_current_name()`](gtkfilechooser#gtk-file-chooser-set-current-name) as well.
#### Parameters
| | | |
| --- | --- | --- |
| chooser | a [GtkFileChooser](gtkfilechooser#GtkFileChooser-struct) | |
| name | the filename to use, as a UTF-8 string. | [type utf8] |
### gtk\_file\_chooser\_get\_current\_name ()
```
char *
gtk_file_chooser_get_current_name (*`[GtkFileChooser](gtkfilechooser#GtkFileChooser-struct) *chooser`*);
```
Gets the current name in the file selector, as entered by the user in the text entry for “Name”.
This is meant to be used in save dialogs, to get the currently typed filename when the file itself does not exist yet.
#### Parameters
| | | |
| --- | --- | --- |
| chooser | a [GtkFileChooser](gtkfilechooser#GtkFileChooser-struct) | |
#### Returns
The raw text from the file chooser’s “Name” entry. Free this with `g_free()`. Note that this string is not a full pathname or URI; it is whatever the contents of the entry are. Note also that this string is in UTF-8 encoding, which is not necessarily the system’s encoding for filenames.
### gtk\_file\_chooser\_get\_file ()
```
GFile *
gtk_file_chooser_get_file (*`[GtkFileChooser](gtkfilechooser#GtkFileChooser-struct) *chooser`*);
```
Gets the GFile for the currently selected file in the file selector. If multiple files are selected, one of the files will be returned at random.
If the file chooser is in folder mode, this function returns the selected folder.
#### Parameters
| | | |
| --- | --- | --- |
| chooser | a [GtkFileChooser](gtkfilechooser#GtkFileChooser-struct) | |
#### Returns
a selected GFile. You own the returned file; use `g_object_unref()` to release it.
[transfer full]
### gtk\_file\_chooser\_set\_file ()
```
gboolean
gtk_file_chooser_set_file (*`[GtkFileChooser](gtkfilechooser#GtkFileChooser-struct) *chooser`*,
*`GFile *file`*,
*`GError **error`*);
```
Sets *`file`* as the current filename for the file chooser, by changing to the file’s parent folder and actually selecting the file in list. If the *`chooser`* is in [`GTK_FILE_CHOOSER_ACTION_SAVE`](gtkfilechooser#GTK-FILE-CHOOSER-ACTION-SAVE:CAPS) mode, the file’s base name will also appear in the dialog’s file name entry.
If the file name isn’t in the current folder of *`chooser`* , then the current folder of *`chooser`* will be changed to the folder containing *`filename`* .
Note that the file must exist, or nothing will be done except for the directory change.
If you are implementing a save dialog, you should use this function if you already have a file name to which the user may save; for example, when the user opens an existing file and then does Save As... If you don’t have a file name already — for example, if the user just created a new file and is saving it for the first time, do not call this function. Instead, use something similar to this:
```
static void
prepare_file_chooser (GtkFileChooser *chooser,
GFile *existing_file)
{
gboolean document_is_new = (existing_file == NULL);
if (document_is_new)
{
GFile *default_file_for_saving = g_file_new_for_path ("./out.txt");
// the user just created a new document
gtk_file_chooser_set_current_folder (chooser, default_file_for_saving, NULL);
gtk_file_chooser_set_current_name (chooser, "Untitled document");
g_object_unref (default_file_for_saving);
}
else
{
// the user edited an existing document
gtk_file_chooser_set_file (chooser, existing_file, NULL);
}
}
```
| #### Parameters
| | | |
| --- | --- | --- |
| chooser | a [GtkFileChooser](gtkfilechooser#GtkFileChooser-struct) | |
| file | the GFile to set as current | |
| error | location to store the error, or `NULL` to ignore errors. | [allow-none] |
#### Returns
Not useful.
### gtk\_file\_chooser\_get\_files ()
```
GListModel *
gtk_file_chooser_get_files (*`[GtkFileChooser](gtkfilechooser#GtkFileChooser-struct) *chooser`*);
```
Lists all the selected files and subfolders in the current folder of *`chooser`* as GFile.
#### Parameters
| | | |
| --- | --- | --- |
| chooser | a [GtkFileChooser](gtkfilechooser#GtkFileChooser-struct) | |
#### Returns
a list model containing a GFile for each selected file and subfolder in the current folder. Free the returned list with `g_object_unref()`.
[transfer full]
### gtk\_file\_chooser\_set\_current\_folder ()
```
gboolean
gtk_file_chooser_set_current_folder (*`[GtkFileChooser](gtkfilechooser#GtkFileChooser-struct) *chooser`*,
*`GFile *file`*,
*`GError **error`*);
```
Sets the current folder for *`chooser`* from a GFile.
#### Parameters
| | | |
| --- | --- | --- |
| chooser | a [GtkFileChooser](gtkfilechooser#GtkFileChooser-struct) | |
| file | the GFile for the new folder | |
| error | location to store error, or `NULL`. | |
#### Returns
`TRUE` if the folder could be changed successfully, `FALSE` otherwise.
### gtk\_file\_chooser\_get\_current\_folder ()
```
GFile *
gtk_file_chooser_get_current_folder (*`[GtkFileChooser](gtkfilechooser#GtkFileChooser-struct) *chooser`*);
```
Gets the current folder of *`chooser`* as GFile.
#### Parameters
| | | |
| --- | --- | --- |
| chooser | a [GtkFileChooser](gtkfilechooser#GtkFileChooser-struct) | |
#### Returns
the GFile for the current folder.
[transfer full]
### gtk\_file\_chooser\_add\_filter ()
```
void
gtk_file_chooser_add_filter (*`[GtkFileChooser](gtkfilechooser#GtkFileChooser-struct) *chooser`*,
*`[GtkFileFilter](gtkfilefilter#GtkFileFilter-struct) *filter`*);
```
Adds *`filter`* to the list of filters that the user can select between. When a filter is selected, only files that are passed by that filter are displayed.
Note that the *`chooser`* takes ownership of the filter if it is floating, so you have to ref and sink it if you want to keep a reference.
#### Parameters
| | | |
| --- | --- | --- |
| chooser | a [GtkFileChooser](gtkfilechooser#GtkFileChooser-struct) | |
| filter | a [GtkFileFilter](gtkfilefilter#GtkFileFilter-struct). | [transfer none] |
### gtk\_file\_chooser\_remove\_filter ()
```
void
gtk_file_chooser_remove_filter (*`[GtkFileChooser](gtkfilechooser#GtkFileChooser-struct) *chooser`*,
*`[GtkFileFilter](gtkfilefilter#GtkFileFilter-struct) *filter`*);
```
Removes *`filter`* from the list of filters that the user can select between.
#### Parameters
| | | |
| --- | --- | --- |
| chooser | a [GtkFileChooser](gtkfilechooser#GtkFileChooser-struct) | |
| filter | a [GtkFileFilter](gtkfilefilter#GtkFileFilter-struct) | |
### gtk\_file\_chooser\_get\_filters ()
```
GListModel *
gtk_file_chooser_get_filters (*`[GtkFileChooser](gtkfilechooser#GtkFileChooser-struct) *chooser`*);
```
Gets the current set of user-selectable filters, as a list model; see [`gtk_file_chooser_add_filter()`](gtkfilechooser#gtk-file-chooser-add-filter), [`gtk_file_chooser_remove_filter()`](gtkfilechooser#gtk-file-chooser-remove-filter).
You should not modify the returned list model. Future changes to *`chooser`* may or may not affect the returned model.
#### Parameters
| | | |
| --- | --- | --- |
| chooser | a [GtkFileChooser](gtkfilechooser#GtkFileChooser-struct) | |
#### Returns
a GListModel containing the current set of user-selectable filters.
[transfer full]
### gtk\_file\_chooser\_set\_filter ()
```
void
gtk_file_chooser_set_filter (*`[GtkFileChooser](gtkfilechooser#GtkFileChooser-struct) *chooser`*,
*`[GtkFileFilter](gtkfilefilter#GtkFileFilter-struct) *filter`*);
```
Sets the current filter; only the files that pass the filter will be displayed. If the user-selectable list of filters is non-empty, then the filter should be one of the filters in that list. Setting the current filter when the list of filters is empty is useful if you want to restrict the displayed set of files without letting the user change it.
#### Parameters
| | | |
| --- | --- | --- |
| chooser | a [GtkFileChooser](gtkfilechooser#GtkFileChooser-struct) | |
| filter | a [GtkFileFilter](gtkfilefilter#GtkFileFilter-struct) | |
### gtk\_file\_chooser\_get\_filter ()
```
[GtkFileFilter](gtkfilefilter#GtkFileFilter-struct) *
gtk_file_chooser_get_filter (*`[GtkFileChooser](gtkfilechooser#GtkFileChooser-struct) *chooser`*);
```
Gets the current filter; see [`gtk_file_chooser_set_filter()`](gtkfilechooser#gtk-file-chooser-set-filter).
#### Parameters
| | | |
| --- | --- | --- |
| chooser | a [GtkFileChooser](gtkfilechooser#GtkFileChooser-struct) | |
#### Returns
the current filter, or `NULL`.
[nullable][transfer none]
### gtk\_file\_chooser\_add\_shortcut\_folder ()
```
gboolean
gtk_file_chooser_add_shortcut_folder (*`[GtkFileChooser](gtkfilechooser#GtkFileChooser-struct) *chooser`*,
*`GFile *folder`*,
*`GError **error`*);
```
Adds a folder to be displayed with the shortcut folders in a file chooser.
#### Parameters
| | | |
| --- | --- | --- |
| chooser | a [GtkFileChooser](gtkfilechooser#GtkFileChooser-struct) | |
| folder | a GFile for the folder to add | |
| error | location to store error, or `NULL` | |
#### Returns
`TRUE` if the folder could be added successfully, `FALSE` otherwise.
### gtk\_file\_chooser\_remove\_shortcut\_folder ()
```
gboolean
gtk_file_chooser_remove_shortcut_folder
(*`[GtkFileChooser](gtkfilechooser#GtkFileChooser-struct) *chooser`*,
*`GFile *folder`*,
*`GError **error`*);
```
Removes a folder from the shortcut folders in a file chooser.
#### Parameters
| | | |
| --- | --- | --- |
| chooser | a [GtkFileChooser](gtkfilechooser#GtkFileChooser-struct) | |
| folder | a GFile for the folder to remove | |
| error | location to store error, or `NULL` | |
#### Returns
`TRUE` if the folder could be removed successfully, `FALSE` otherwise.
### gtk\_file\_chooser\_get\_shortcut\_folders ()
```
GListModel *
gtk_file_chooser_get_shortcut_folders (*`[GtkFileChooser](gtkfilechooser#GtkFileChooser-struct) *chooser`*);
```
Queries the list of shortcut folders in the file chooser, as set by [`gtk_file_chooser_add_shortcut_folder()`](gtkfilechooser#gtk-file-chooser-add-shortcut-folder).
You should not modify the returned list model. Future changes to *`chooser`* may or may not affect the returned model.
#### Parameters
| | | |
| --- | --- | --- |
| chooser | a [GtkFileChooser](gtkfilechooser#GtkFileChooser-struct) | |
#### Returns
A list model of GFiles.
[transfer full]
### gtk\_file\_chooser\_add\_choice ()
```
void
gtk_file_chooser_add_choice (*`[GtkFileChooser](gtkfilechooser#GtkFileChooser-struct) *chooser`*,
*`const char *id`*,
*`const char *label`*,
*`const char **options`*,
*`const char **option_labels`*);
```
Adds a 'choice' to the file chooser. This is typically implemented as a combobox or, for boolean choices, as a checkbutton. You can select a value using [`gtk_file_chooser_set_choice()`](gtkfilechooser#gtk-file-chooser-set-choice) before the dialog is shown, and you can obtain the user-selected value in the ::response signal handler using [`gtk_file_chooser_get_choice()`](gtkfilechooser#gtk-file-chooser-get-choice).
#### Parameters
| | | |
| --- | --- | --- |
| chooser | a [GtkFileChooser](gtkfilechooser#GtkFileChooser-struct) | |
| id | id for the added choice | |
| label | user-visible label for the added choice | |
| options | ids for the options of the choice, or `NULL` for a boolean choice. | [nullable][array zero-terminated=1] |
| option\_labels | user-visible labels for the options, must be the same length as *`options`* . | [nullable][array zero-terminated=1] |
### gtk\_file\_chooser\_remove\_choice ()
```
void
gtk_file_chooser_remove_choice (*`[GtkFileChooser](gtkfilechooser#GtkFileChooser-struct) *chooser`*,
*`const char *id`*);
```
Removes a 'choice' that has been added with [`gtk_file_chooser_add_choice()`](gtkfilechooser#gtk-file-chooser-add-choice).
#### Parameters
| | | |
| --- | --- | --- |
| chooser | a [GtkFileChooser](gtkfilechooser#GtkFileChooser-struct) | |
| id | the ID of the choice to remove | |
### gtk\_file\_chooser\_set\_choice ()
```
void
gtk_file_chooser_set_choice (*`[GtkFileChooser](gtkfilechooser#GtkFileChooser-struct) *chooser`*,
*`const char *id`*,
*`const char *option`*);
```
Selects an option in a 'choice' that has been added with [`gtk_file_chooser_add_choice()`](gtkfilechooser#gtk-file-chooser-add-choice). For a boolean choice, the possible options are "true" and "false".
#### Parameters
| | | |
| --- | --- | --- |
| chooser | a [GtkFileChooser](gtkfilechooser#GtkFileChooser-struct) | |
| id | the ID of the choice to set | |
| option | the ID of the option to select | |
### gtk\_file\_chooser\_get\_choice ()
```
const char *
gtk_file_chooser_get_choice (*`[GtkFileChooser](gtkfilechooser#GtkFileChooser-struct) *chooser`*,
*`const char *id`*);
```
Gets the currently selected option in the 'choice' with the given ID.
#### Parameters
| | | |
| --- | --- | --- |
| chooser | a [GtkFileChooser](gtkfilechooser#GtkFileChooser-struct) | |
| id | the ID of the choice to get | |
#### Returns
the ID of the currently selected option
Types and Values
----------------
### GtkFileChooser
```
typedef struct _GtkFileChooser GtkFileChooser;
```
### enum GtkFileChooserAction
Describes whether a [GtkFileChooser](gtkfilechooser#GtkFileChooser-struct) is being used to open existing files or to save to a possibly new file.
#### Members
| | | |
| --- | --- | --- |
| GTK\_FILE\_CHOOSER\_ACTION\_OPEN | Indicates open mode. The file chooser will only let the user pick an existing file. | |
| GTK\_FILE\_CHOOSER\_ACTION\_SAVE | Indicates save mode. The file chooser will let the user pick an existing file, or type in a new filename. | |
| GTK\_FILE\_CHOOSER\_ACTION\_SELECT\_FOLDER | Indicates an Open mode for selecting folders. The file chooser will let the user pick an existing folder. | |
### GTK\_FILE\_CHOOSER\_ERROR
```
#define GTK_FILE_CHOOSER_ERROR (gtk_file_chooser_error_quark ())
```
Used to get the GError quark for [GtkFileChooser](gtkfilechooser#GtkFileChooser-struct) errors.
### enum GtkFileChooserError
These identify the various errors that can occur while calling [GtkFileChooser](gtkfilechooser#GtkFileChooser-struct) functions.
#### Members
| | | |
| --- | --- | --- |
| GTK\_FILE\_CHOOSER\_ERROR\_NONEXISTENT | Indicates that a file does not exist. | |
| GTK\_FILE\_CHOOSER\_ERROR\_BAD\_FILENAME | Indicates a malformed filename. | |
| GTK\_FILE\_CHOOSER\_ERROR\_ALREADY\_EXISTS | Indicates a duplicate path (e.g. when adding a bookmark). | |
| GTK\_FILE\_CHOOSER\_ERROR\_INCOMPLETE\_HOSTNAME | Indicates an incomplete hostname (e.g. "http://foo" without a slash after that). | |
Property Details
----------------
### The `“action”` property
```
“action” [GtkFileChooserAction](gtkfilechooser#GtkFileChooserAction)
```
The type of operation that the file selector is performing.
Owner: GtkFileChooser
Flags: Read / Write
Default value: GTK\_FILE\_CHOOSER\_ACTION\_OPEN
### The `“create-folders”` property
```
“create-folders” gboolean
```
Whether a file chooser not in [`GTK_FILE_CHOOSER_ACTION_OPEN`](gtkfilechooser#GTK-FILE-CHOOSER-ACTION-OPEN:CAPS) mode will offer the user to create new folders.
Owner: GtkFileChooser
Flags: Read / Write
Default value: TRUE
### The `“filter”` property
```
“filter” [GtkFileFilter](gtkfilefilter#GtkFileFilter-struct) *
```
The current filter for selecting which files are displayed.
Owner: GtkFileChooser
Flags: Read / Write
### The `“filters”` property
```
“filters” GListModel *
```
A GListModel containing the filters that have been added with [`gtk_file_chooser_add_filter()`](gtkfilechooser#gtk-file-chooser-add-filter).
The returned object should not be modified. It may or may not be updated for later changes.
Owner: GtkFileChooser
Flags: Read
### The `“select-multiple”` property
```
“select-multiple” gboolean
```
Whether to allow multiple files to be selected.
Owner: GtkFileChooser
Flags: Read / Write
Default value: FALSE
### The `“shortcut-folders”` property
```
“shortcut-folders” GListModel *
```
A GListModel containing the shortcut folders that have been added with [`gtk_file_chooser_add_shortcut_folder()`](gtkfilechooser#gtk-file-chooser-add-shortcut-folder).
The returned object should not be modified. It may or may not be updated for later changes.
Owner: GtkFileChooser
Flags: Read
See Also
--------
[GtkFileChooserDialog](gtkfilechooserdialog#GtkFileChooserDialog-struct), [GtkFileChooserWidget](gtkfilechooserwidget#GtkFileChooserWidget-struct)
| programming_docs |
gtk GtkEventControllerKey GtkEventControllerKey
=====================
GtkEventControllerKey — Event controller for key events
Functions
---------
| | |
| --- | --- |
| [GtkEventController](gtkeventcontroller#GtkEventController-struct) \* | [gtk\_event\_controller\_key\_new](gtkeventcontrollerkey#gtk-event-controller-key-new) () |
| void | [gtk\_event\_controller\_key\_set\_im\_context](gtkeventcontrollerkey#gtk-event-controller-key-set-im-context) () |
| [GtkIMContext](gtkimcontext#GtkIMContext-struct) \* | [gtk\_event\_controller\_key\_get\_im\_context](gtkeventcontrollerkey#gtk-event-controller-key-get-im-context) () |
| gboolean | [gtk\_event\_controller\_key\_forward](gtkeventcontrollerkey#gtk-event-controller-key-forward) () |
| guint | [gtk\_event\_controller\_key\_get\_group](gtkeventcontrollerkey#gtk-event-controller-key-get-group) () |
Signals
-------
| | | |
| --- | --- | --- |
| void | [im-update](gtkeventcontrollerkey#GtkEventControllerKey-im-update) | Run Last |
| gboolean | [key-pressed](gtkeventcontrollerkey#GtkEventControllerKey-key-pressed) | Run Last |
| void | [key-released](gtkeventcontrollerkey#GtkEventControllerKey-key-released) | Run Last |
| gboolean | [modifiers](gtkeventcontrollerkey#GtkEventControllerKey-modifiers) | Run Last |
Types and Values
----------------
| | |
| --- | --- |
| | [GtkEventControllerKey](gtkeventcontrollerkey#GtkEventControllerKey-struct) |
Object Hierarchy
----------------
```
GObject
╰── [GtkEventController](gtkeventcontroller#GtkEventController-struct)
╰── GtkEventControllerKey
```
Includes
--------
```
#include <gtk/gtk.h>
```
Description
-----------
[GtkEventControllerKey](gtkeventcontrollerkey#GtkEventControllerKey-struct) is an event controller meant for situations where you need access to key events.
Functions
---------
### gtk\_event\_controller\_key\_new ()
```
[GtkEventController](gtkeventcontroller#GtkEventController-struct) *
gtk_event_controller_key_new (*`void`*);
```
Creates a new event controller that will handle key events.
#### Returns
a new [GtkEventControllerKey](gtkeventcontrollerkey#GtkEventControllerKey-struct)
### gtk\_event\_controller\_key\_set\_im\_context ()
```
void
gtk_event_controller_key_set_im_context
(*`[GtkEventControllerKey](gtkeventcontrollerkey#GtkEventControllerKey-struct) *controller`*,
*`[GtkIMContext](gtkimcontext#GtkIMContext-struct) *im_context`*);
```
Sets the input method context of the key *`controller`* .
#### Parameters
| | | |
| --- | --- | --- |
| controller | a [GtkEventControllerKey](gtkeventcontrollerkey#GtkEventControllerKey-struct) | |
| im\_context | a [GtkIMContext](gtkimcontext#GtkIMContext-struct) | |
### gtk\_event\_controller\_key\_get\_im\_context ()
```
[GtkIMContext](gtkimcontext#GtkIMContext-struct) *
gtk_event_controller_key_get_im_context
(*`[GtkEventControllerKey](gtkeventcontrollerkey#GtkEventControllerKey-struct) *controller`*);
```
Gets the input method context of the key *`controller`* .
#### Parameters
| | | |
| --- | --- | --- |
| controller | a [GtkEventControllerKey](gtkeventcontrollerkey#GtkEventControllerKey-struct) | |
#### Returns
the [GtkIMContext](gtkimcontext#GtkIMContext-struct).
[transfer none]
### gtk\_event\_controller\_key\_forward ()
```
gboolean
gtk_event_controller_key_forward (*`[GtkEventControllerKey](gtkeventcontrollerkey#GtkEventControllerKey-struct) *controller`*,
*`[GtkWidget](gtkwidget#GtkWidget-struct) *widget`*);
```
Forwards the current event of this *`controller`* to a *`widget`* .
This function can only be used in handlers for the [“key-pressed”](gtkeventcontrollerkey#GtkEventControllerKey-key-pressed), [“key-released”](gtkeventcontrollerkey#GtkEventControllerKey-key-released) or [“modifiers”](gtkeventcontrollerkey#GtkEventControllerKey-modifiers) signals.
#### Parameters
| | | |
| --- | --- | --- |
| controller | a [GtkEventControllerKey](gtkeventcontrollerkey#GtkEventControllerKey-struct) | |
| widget | a [GtkWidget](gtkwidget#GtkWidget-struct) | |
#### Returns
whether the *`widget`* handled the event
### gtk\_event\_controller\_key\_get\_group ()
```
guint
gtk_event_controller_key_get_group (*`[GtkEventControllerKey](gtkeventcontrollerkey#GtkEventControllerKey-struct) *controller`*);
```
Gets the key group of the current event of this *`controller`* . See `gdk_key_event_get_group()`.
#### Parameters
| | | |
| --- | --- | --- |
| controller | a [GtkEventControllerKey](gtkeventcontrollerkey#GtkEventControllerKey-struct) | |
#### Returns
the key group
Types and Values
----------------
### GtkEventControllerKey
```
typedef struct _GtkEventControllerKey GtkEventControllerKey;
```
Signal Details
--------------
### The `“im-update”` signal
```
void
user_function ([GtkEventControllerKey](gtkeventcontrollerkey#GtkEventControllerKey-struct) *controller,
gpointer user_data)
```
This signal is emitted whenever the input method context filters away a keypress and prevents the *`controller`* receiving it. See [`gtk_event_controller_key_set_im_context()`](gtkeventcontrollerkey#gtk-event-controller-key-set-im-context) and [`gtk_im_context_filter_keypress()`](gtkimcontext#gtk-im-context-filter-keypress).
#### Parameters
| | | |
| --- | --- | --- |
| controller | the object which received the signal | |
| user\_data | user data set when the signal handler was connected. | |
Flags: Run Last
### The `“key-pressed”` signal
```
gboolean
user_function ([GtkEventControllerKey](gtkeventcontrollerkey#GtkEventControllerKey-struct) *controller,
guint keyval,
guint keycode,
[GdkModifierType](https://developer-old.gnome.org/gtk4/html/GdkSurface.html#GdkModifierType) state,
gpointer user_data)
```
This signal is emitted whenever a key is pressed.
#### Parameters
| | | |
| --- | --- | --- |
| controller | the object which received the signal. | |
| keyval | the pressed key. | |
| keycode | the raw code of the pressed key. | |
| state | the bitmask, representing the state of modifier keys and pointer buttons. See [GdkModifierType](https://developer-old.gnome.org/gtk4/html/GdkSurface.html#GdkModifierType). | |
| user\_data | user data set when the signal handler was connected. | |
#### Returns
`TRUE` if the key press was handled, `FALSE` otherwise.
Flags: Run Last
### The `“key-released”` signal
```
void
user_function ([GtkEventControllerKey](gtkeventcontrollerkey#GtkEventControllerKey-struct) *controller,
guint keyval,
guint keycode,
[GdkModifierType](https://developer-old.gnome.org/gtk4/html/GdkSurface.html#GdkModifierType) state,
gpointer user_data)
```
This signal is emitted whenever a key is released.
#### Parameters
| | | |
| --- | --- | --- |
| controller | the object which received the signal. | |
| keyval | the released key. | |
| keycode | the raw code of the released key. | |
| state | the bitmask, representing the state of modifier keys and pointer buttons. See [GdkModifierType](https://developer-old.gnome.org/gtk4/html/GdkSurface.html#GdkModifierType). | |
| user\_data | user data set when the signal handler was connected. | |
Flags: Run Last
### The `“modifiers”` signal
```
gboolean
user_function ([GtkEventControllerKey](gtkeventcontrollerkey#GtkEventControllerKey-struct) *controller,
[GdkModifierType](https://developer-old.gnome.org/gtk4/html/GdkSurface.html#GdkModifierType) keyval,
gpointer user_data)
```
This signal is emitted whenever the state of modifier keys and pointer buttons change.
#### Parameters
| | | |
| --- | --- | --- |
| controller | the object which received the signal. | |
| keyval | the released key. | |
| state | the bitmask, representing the new state of modifier keys and pointer buttons. See [GdkModifierType](https://developer-old.gnome.org/gtk4/html/GdkSurface.html#GdkModifierType). | |
| user\_data | user data set when the signal handler was connected. | |
Flags: Run Last
See Also
--------
[GtkEventController](gtkeventcontroller#GtkEventController-struct)
gtk GtkSingleSelection GtkSingleSelection
==================
GtkSingleSelection — A selection model that allows selecting a single item
Functions
---------
| | |
| --- | --- |
| [GtkSingleSelection](gtksingleselection#GtkSingleSelection-struct) \* | [gtk\_single\_selection\_new](gtksingleselection#gtk-single-selection-new) () |
| GListModel \* | [gtk\_single\_selection\_get\_model](gtksingleselection#gtk-single-selection-get-model) () |
| void | [gtk\_single\_selection\_set\_model](gtksingleselection#gtk-single-selection-set-model) () |
| guint | [gtk\_single\_selection\_get\_selected](gtksingleselection#gtk-single-selection-get-selected) () |
| void | [gtk\_single\_selection\_set\_selected](gtksingleselection#gtk-single-selection-set-selected) () |
| gpointer | [gtk\_single\_selection\_get\_selected\_item](gtksingleselection#gtk-single-selection-get-selected-item) () |
| gboolean | [gtk\_single\_selection\_get\_autoselect](gtksingleselection#gtk-single-selection-get-autoselect) () |
| void | [gtk\_single\_selection\_set\_autoselect](gtksingleselection#gtk-single-selection-set-autoselect) () |
| gboolean | [gtk\_single\_selection\_get\_can\_unselect](gtksingleselection#gtk-single-selection-get-can-unselect) () |
| void | [gtk\_single\_selection\_set\_can\_unselect](gtksingleselection#gtk-single-selection-set-can-unselect) () |
Properties
----------
| | | |
| --- | --- | --- |
| gboolean | [autoselect](gtksingleselection#GtkSingleSelection--autoselect) | Read / Write |
| gboolean | [can-unselect](gtksingleselection#GtkSingleSelection--can-unselect) | Read / Write |
| GListModel \* | [model](gtksingleselection#GtkSingleSelection--model) | Read / Write |
| guint | [selected](gtksingleselection#GtkSingleSelection--selected) | Read / Write |
| GObject \* | [selected-item](gtksingleselection#GtkSingleSelection--selected-item) | Read |
Types and Values
----------------
| | |
| --- | --- |
| | [GtkSingleSelection](gtksingleselection#GtkSingleSelection-struct) |
| #define | [GTK\_INVALID\_LIST\_POSITION](gtksingleselection#GTK-INVALID-LIST-POSITION:CAPS) |
Object Hierarchy
----------------
```
GObject
╰── GtkSingleSelection
```
Implemented Interfaces
----------------------
GtkSingleSelection implements GListModel and [GtkSelectionModel](gtkselectionmodel#GtkSelectionModel-struct).
Includes
--------
```
#include <gtk/gtk.h>
```
Description
-----------
GtkSingleSelection is an implementation of the [GtkSelectionModel](gtkselectionmodel#GtkSelectionModel-struct) interface that allows selecting a single element. It is the default selection method used by list widgets in GTK.
Note that the selection is \*persistent\* -- if the selected item is removed and re-added in the same “items-changed” emission, it stays selected. In particular, this means that changing the sort order of an underlying sort model will preserve the selection.
Functions
---------
### gtk\_single\_selection\_new ()
```
[GtkSingleSelection](gtksingleselection#GtkSingleSelection-struct) *
gtk_single_selection_new (*`GListModel *model`*);
```
Creates a new selection to handle *`model`* .
#### Parameters
| | | |
| --- | --- | --- |
| model | the GListModel to manage, or `NULL`. | [allow-none][transfer full] |
#### Returns
a new [GtkSingleSelection](gtksingleselection#GtkSingleSelection-struct).
[transfer full][type GtkSingleSelection]
### gtk\_single\_selection\_get\_model ()
```
GListModel *
gtk_single_selection_get_model (*`[GtkSingleSelection](gtksingleselection#GtkSingleSelection-struct) *self`*);
```
Gets the model that *`self`* is wrapping.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkSingleSelection](gtksingleselection#GtkSingleSelection-struct) | |
#### Returns
The model being wrapped.
[transfer none]
### gtk\_single\_selection\_set\_model ()
```
void
gtk_single_selection_set_model (*`[GtkSingleSelection](gtksingleselection#GtkSingleSelection-struct) *self`*,
*`GListModel *model`*);
```
Sets the model that *`self`* should wrap. If *`model`* is `NULL`, *`self`* will be empty.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkSingleSelection](gtksingleselection#GtkSingleSelection-struct) | |
| model | A GListModel to wrap. | [allow-none] |
### gtk\_single\_selection\_get\_selected ()
```
guint
gtk_single_selection_get_selected (*`[GtkSingleSelection](gtksingleselection#GtkSingleSelection-struct) *self`*);
```
Gets the position of the selected item. If no item is selected, [GTK\_INVALID\_LIST\_POSITION](gtksingleselection#GTK-INVALID-LIST-POSITION:CAPS) is returned.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkSingleSelection](gtksingleselection#GtkSingleSelection-struct) | |
#### Returns
The position of the selected item
### gtk\_single\_selection\_set\_selected ()
```
void
gtk_single_selection_set_selected (*`[GtkSingleSelection](gtksingleselection#GtkSingleSelection-struct) *self`*,
*`guint position`*);
```
Selects the item at the given position.
If the list does not have an item at *`position`* or [GTK\_INVALID\_LIST\_POSITION](gtksingleselection#GTK-INVALID-LIST-POSITION:CAPS) is given, the behavior depends on the value of the [“autoselect”](gtksingleselection#GtkSingleSelection--autoselect) property: If it is set, no change will occur and the old item will stay selected. If it is unset, the selection will be unset and no item will be selected.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkSingleSelection](gtksingleselection#GtkSingleSelection-struct) | |
| position | the item to select or [GTK\_INVALID\_LIST\_POSITION](gtksingleselection#GTK-INVALID-LIST-POSITION:CAPS) | |
### gtk\_single\_selection\_get\_selected\_item ()
```
gpointer
gtk_single_selection_get_selected_item
(*`[GtkSingleSelection](gtksingleselection#GtkSingleSelection-struct) *self`*);
```
Gets the selected item.
If no item is selected, `NULL` is returned.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkSingleSelection](gtksingleselection#GtkSingleSelection-struct) | |
#### Returns
The selected item.
[transfer none]
### gtk\_single\_selection\_get\_autoselect ()
```
gboolean
gtk_single_selection_get_autoselect (*`[GtkSingleSelection](gtksingleselection#GtkSingleSelection-struct) *self`*);
```
Checks if autoselect has been enabled or disabled via [`gtk_single_selection_set_autoselect()`](gtksingleselection#gtk-single-selection-set-autoselect).
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkSingleSelection](gtksingleselection#GtkSingleSelection-struct) | |
#### Returns
`TRUE` if autoselect is enabled
### gtk\_single\_selection\_set\_autoselect ()
```
void
gtk_single_selection_set_autoselect (*`[GtkSingleSelection](gtksingleselection#GtkSingleSelection-struct) *self`*,
*`gboolean autoselect`*);
```
If *`autoselect`* is `TRUE`, *`self`* will enforce that an item is always selected. It will select a new item when the currently selected item is deleted and it will disallow unselecting the current item.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkSingleSelection](gtksingleselection#GtkSingleSelection-struct) | |
| autoselect | `TRUE` to always select an item | |
### gtk\_single\_selection\_get\_can\_unselect ()
```
gboolean
gtk_single_selection_get_can_unselect (*`[GtkSingleSelection](gtksingleselection#GtkSingleSelection-struct) *self`*);
```
If `TRUE`, [`gtk_selection_model_unselect_item()`](gtkselectionmodel#gtk-selection-model-unselect-item) is supported and allows unselecting the selected item.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkSingleSelection](gtksingleselection#GtkSingleSelection-struct) | |
#### Returns
`TRUE` to support unselecting
### gtk\_single\_selection\_set\_can\_unselect ()
```
void
gtk_single_selection_set_can_unselect (*`[GtkSingleSelection](gtksingleselection#GtkSingleSelection-struct) *self`*,
*`gboolean can_unselect`*);
```
If `TRUE`, unselecting the current item via [`gtk_selection_model_unselect_item()`](gtkselectionmodel#gtk-selection-model-unselect-item) is supported.
Note that setting [“autoselect”](gtksingleselection#GtkSingleSelection--autoselect) will cause the unselecting to not work, so it practically makes no sense to set both at the same time the same time.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkSingleSelection](gtksingleselection#GtkSingleSelection-struct) | |
| can\_unselect | `TRUE` to allow unselecting | |
Types and Values
----------------
### GtkSingleSelection
```
typedef struct _GtkSingleSelection GtkSingleSelection;
```
### GTK\_INVALID\_LIST\_POSITION
```
#define GTK_INVALID_LIST_POSITION (G_MAXUINT)
```
The value used to refer to a guaranteed invalid position in a GListModel. This value may be returned from some functions, others may accept it as input. Its interpretation may differ for different functions.
Refer to each function's documentation for if this value is allowed and what it does.
Property Details
----------------
### The `“autoselect”` property
```
“autoselect” gboolean
```
If the selection will always select an item
Owner: GtkSingleSelection
Flags: Read / Write
Default value: TRUE
### The `“can-unselect”` property
```
“can-unselect” gboolean
```
If unselecting the selected item is allowed
Owner: GtkSingleSelection
Flags: Read / Write
Default value: FALSE
### The `“model”` property
```
“model” GListModel *
```
The model being managed
Owner: GtkSingleSelection
Flags: Read / Write
### The `“selected”` property
```
“selected” guint
```
Position of the selected item
Owner: GtkSingleSelection
Flags: Read / Write
Default value: 4294967295
### The `“selected-item”` property
```
“selected-item” GObject *
```
The selected item
Owner: GtkSingleSelection
Flags: Read
See Also
--------
[GtkSelectionModel](gtkselectionmodel#GtkSelectionModel-struct)
gtk GtkTreeSortable GtkTreeSortable
===============
GtkTreeSortable — The interface for sortable models used by GtkTreeView
Functions
---------
| | |
| --- | --- |
| int | ([\*GtkTreeIterCompareFunc](gtktreesortable#GtkTreeIterCompareFunc)) () |
| void | [gtk\_tree\_sortable\_sort\_column\_changed](gtktreesortable#gtk-tree-sortable-sort-column-changed) () |
| gboolean | [gtk\_tree\_sortable\_get\_sort\_column\_id](gtktreesortable#gtk-tree-sortable-get-sort-column-id) () |
| void | [gtk\_tree\_sortable\_set\_sort\_column\_id](gtktreesortable#gtk-tree-sortable-set-sort-column-id) () |
| void | [gtk\_tree\_sortable\_set\_sort\_func](gtktreesortable#gtk-tree-sortable-set-sort-func) () |
| void | [gtk\_tree\_sortable\_set\_default\_sort\_func](gtktreesortable#gtk-tree-sortable-set-default-sort-func) () |
| gboolean | [gtk\_tree\_sortable\_has\_default\_sort\_func](gtktreesortable#gtk-tree-sortable-has-default-sort-func) () |
Signals
-------
| | | |
| --- | --- | --- |
| void | [sort-column-changed](gtktreesortable#GtkTreeSortable-sort-column-changed) | Run Last |
Types and Values
----------------
| | |
| --- | --- |
| | [GtkTreeSortable](gtktreesortable#GtkTreeSortable-struct) |
| struct | [GtkTreeSortableIface](gtktreesortable#GtkTreeSortableIface) |
| #define | [GTK\_TREE\_SORTABLE\_DEFAULT\_SORT\_COLUMN\_ID](gtktreesortable#GTK-TREE-SORTABLE-DEFAULT-SORT-COLUMN-ID:CAPS) |
| #define | [GTK\_TREE\_SORTABLE\_UNSORTED\_SORT\_COLUMN\_ID](gtktreesortable#GTK-TREE-SORTABLE-UNSORTED-SORT-COLUMN-ID:CAPS) |
Object Hierarchy
----------------
```
[GInterface](https://developer-old.gnome.org/gobject/stable/GTypeModule.html)
╰── GtkTreeSortable
```
Prerequisites
-------------
GtkTreeSortable requires [GtkTreeModel](gtktreemodel#GtkTreeModel-struct) and GObject.
Known Implementations
---------------------
GtkTreeSortable is implemented by [GtkListStore](gtkliststore#GtkListStore-struct), [GtkTreeModelSort](gtktreemodelsort#GtkTreeModelSort-struct) and [GtkTreeStore](gtktreestore#GtkTreeStore-struct).
Includes
--------
```
#include <gtk/gtk.h>
```
Description
-----------
[GtkTreeSortable](gtktreesortable#GtkTreeSortable-struct) is an interface to be implemented by tree models which support sorting. The [GtkTreeView](gtktreeview#GtkTreeView-struct) uses the methods provided by this interface to sort the model.
Functions
---------
### GtkTreeIterCompareFunc ()
```
int
(*GtkTreeIterCompareFunc) (*`[GtkTreeModel](gtktreemodel#GtkTreeModel-struct) *model`*,
*`[GtkTreeIter](gtktreemodel#GtkTreeIter-struct) *a`*,
*`[GtkTreeIter](gtktreemodel#GtkTreeIter-struct) *b`*,
*`gpointer user_data`*);
```
A GtkTreeIterCompareFunc should return a negative integer, zero, or a positive integer if *`a`* sorts before *`b`* , *`a`* sorts with *`b`* , or *`a`* sorts after *`b`* respectively. If two iters compare as equal, their order in the sorted model is undefined. In order to ensure that the [GtkTreeSortable](gtktreesortable#GtkTreeSortable-struct) behaves as expected, the GtkTreeIterCompareFunc must define a partial order on the model, i.e. it must be reflexive, antisymmetric and transitive.
For example, if *`model`* is a product catalogue, then a compare function for the “price” column could be one which returns `price_of(@a) - price_of(@b)`.
#### Parameters
| | | |
| --- | --- | --- |
| model | The [GtkTreeModel](gtktreemodel#GtkTreeModel-struct) the comparison is within | |
| a | A [GtkTreeIter](gtktreemodel#GtkTreeIter-struct) in *`model`* | |
| b | Another [GtkTreeIter](gtktreemodel#GtkTreeIter-struct) in *`model`* | |
| user\_data | Data passed when the compare func is assigned e.g. by [`gtk_tree_sortable_set_sort_func()`](gtktreesortable#gtk-tree-sortable-set-sort-func) | |
#### Returns
a negative integer, zero or a positive integer depending on whether *`a`* sorts before, with or after *`b`*
### gtk\_tree\_sortable\_sort\_column\_changed ()
```
void
gtk_tree_sortable_sort_column_changed (*`[GtkTreeSortable](gtktreesortable#GtkTreeSortable-struct) *sortable`*);
```
Emits a [“sort-column-changed”](gtktreesortable#GtkTreeSortable-sort-column-changed) signal on *`sortable`* .
#### Parameters
| | | |
| --- | --- | --- |
| sortable | A [GtkTreeSortable](gtktreesortable#GtkTreeSortable-struct) | |
### gtk\_tree\_sortable\_get\_sort\_column\_id ()
```
gboolean
gtk_tree_sortable_get_sort_column_id (*`[GtkTreeSortable](gtktreesortable#GtkTreeSortable-struct) *sortable`*,
*`int *sort_column_id`*,
*`[GtkSortType](gtk4-standard-enumerations#GtkSortType) *order`*);
```
Fills in *`sort_column_id`* and *`order`* with the current sort column and the order. It returns `TRUE` unless the *`sort_column_id`* is [`GTK_TREE_SORTABLE_DEFAULT_SORT_COLUMN_ID`](gtktreesortable#GTK-TREE-SORTABLE-DEFAULT-SORT-COLUMN-ID:CAPS) or [`GTK_TREE_SORTABLE_UNSORTED_SORT_COLUMN_ID`](gtktreesortable#GTK-TREE-SORTABLE-UNSORTED-SORT-COLUMN-ID:CAPS).
#### Parameters
| | | |
| --- | --- | --- |
| sortable | A [GtkTreeSortable](gtktreesortable#GtkTreeSortable-struct) | |
| sort\_column\_id | The sort column id to be filled in. | [out] |
| order | The [GtkSortType](gtk4-standard-enumerations#GtkSortType) to be filled in. | [out] |
#### Returns
`TRUE` if the sort column is not one of the special sort column ids.
### gtk\_tree\_sortable\_set\_sort\_column\_id ()
```
void
gtk_tree_sortable_set_sort_column_id (*`[GtkTreeSortable](gtktreesortable#GtkTreeSortable-struct) *sortable`*,
*`int sort_column_id`*,
*`[GtkSortType](gtk4-standard-enumerations#GtkSortType) order`*);
```
Sets the current sort column to be *`sort_column_id`* . The *`sortable`* will resort itself to reflect this change, after emitting a [“sort-column-changed”](gtktreesortable#GtkTreeSortable-sort-column-changed) signal. *`sort_column_id`* may either be a regular column id, or one of the following special values:
* [`GTK_TREE_SORTABLE_DEFAULT_SORT_COLUMN_ID`](gtktreesortable#GTK-TREE-SORTABLE-DEFAULT-SORT-COLUMN-ID:CAPS): the default sort function will be used, if it is set
* [`GTK_TREE_SORTABLE_UNSORTED_SORT_COLUMN_ID`](gtktreesortable#GTK-TREE-SORTABLE-UNSORTED-SORT-COLUMN-ID:CAPS): no sorting will occur
#### Parameters
| | | |
| --- | --- | --- |
| sortable | A [GtkTreeSortable](gtktreesortable#GtkTreeSortable-struct) | |
| sort\_column\_id | the sort column id to set | |
| order | The sort order of the column | |
### gtk\_tree\_sortable\_set\_sort\_func ()
```
void
gtk_tree_sortable_set_sort_func (*`[GtkTreeSortable](gtktreesortable#GtkTreeSortable-struct) *sortable`*,
*`int sort_column_id`*,
*`[GtkTreeIterCompareFunc](gtktreesortable#GtkTreeIterCompareFunc) sort_func`*,
*`gpointer user_data`*,
*`GDestroyNotify destroy`*);
```
Sets the comparison function used when sorting to be *`sort_func`* . If the current sort column id of *`sortable`* is the same as *`sort_column_id`* , then the model will sort using this function.
#### Parameters
| | | |
| --- | --- | --- |
| sortable | A [GtkTreeSortable](gtktreesortable#GtkTreeSortable-struct) | |
| sort\_column\_id | the sort column id to set the function for | |
| sort\_func | The comparison function | |
| user\_data | User data to pass to *`sort_func`* , or `NULL`. | [closure] |
| destroy | Destroy notifier of *`user_data`* , or `NULL`. | [allow-none] |
### gtk\_tree\_sortable\_set\_default\_sort\_func ()
```
void
gtk_tree_sortable_set_default_sort_func
(*`[GtkTreeSortable](gtktreesortable#GtkTreeSortable-struct) *sortable`*,
*`[GtkTreeIterCompareFunc](gtktreesortable#GtkTreeIterCompareFunc) sort_func`*,
*`gpointer user_data`*,
*`GDestroyNotify destroy`*);
```
Sets the default comparison function used when sorting to be *`sort_func`* . If the current sort column id of *`sortable`* is [`GTK_TREE_SORTABLE_DEFAULT_SORT_COLUMN_ID`](gtktreesortable#GTK-TREE-SORTABLE-DEFAULT-SORT-COLUMN-ID:CAPS), then the model will sort using this function.
If *`sort_func`* is `NULL`, then there will be no default comparison function. This means that once the model has been sorted, it can’t go back to the default state. In this case, when the current sort column id of *`sortable`* is [`GTK_TREE_SORTABLE_DEFAULT_SORT_COLUMN_ID`](gtktreesortable#GTK-TREE-SORTABLE-DEFAULT-SORT-COLUMN-ID:CAPS), the model will be unsorted.
#### Parameters
| | | |
| --- | --- | --- |
| sortable | A [GtkTreeSortable](gtktreesortable#GtkTreeSortable-struct) | |
| sort\_func | The comparison function | |
| user\_data | User data to pass to *`sort_func`* , or `NULL`. | [closure] |
| destroy | Destroy notifier of *`user_data`* , or `NULL`. | [allow-none] |
### gtk\_tree\_sortable\_has\_default\_sort\_func ()
```
gboolean
gtk_tree_sortable_has_default_sort_func
(*`[GtkTreeSortable](gtktreesortable#GtkTreeSortable-struct) *sortable`*);
```
Returns `TRUE` if the model has a default sort function. This is used primarily by GtkTreeViewColumns in order to determine if a model can go back to the default state, or not.
#### Parameters
| | | |
| --- | --- | --- |
| sortable | A [GtkTreeSortable](gtktreesortable#GtkTreeSortable-struct) | |
#### Returns
`TRUE`, if the model has a default sort function
Types and Values
----------------
### GtkTreeSortable
```
typedef struct _GtkTreeSortable GtkTreeSortable;
```
### struct GtkTreeSortableIface
```
struct GtkTreeSortableIface {
/* signals */
void (* sort_column_changed) (GtkTreeSortable *sortable);
/* virtual table */
gboolean (* get_sort_column_id) (GtkTreeSortable *sortable,
int *sort_column_id,
GtkSortType *order);
void (* set_sort_column_id) (GtkTreeSortable *sortable,
int sort_column_id,
GtkSortType order);
void (* set_sort_func) (GtkTreeSortable *sortable,
int sort_column_id,
GtkTreeIterCompareFunc sort_func,
gpointer user_data,
GDestroyNotify destroy);
void (* set_default_sort_func) (GtkTreeSortable *sortable,
GtkTreeIterCompareFunc sort_func,
gpointer user_data,
GDestroyNotify destroy);
gboolean (* has_default_sort_func) (GtkTreeSortable *sortable);
};
```
#### Members
| | | |
| --- | --- | --- |
| *`sort_column_changed`* () | Signal emitted when the sort column or sort order of sortable is changed. | |
| *`get_sort_column_id`* () | Fills in sort\_column\_id and order with the current sort column and the order. | |
| *`set_sort_column_id`* () | Sets the current sort column to be sort\_column\_id. | |
| *`set_sort_func`* () | Sets the comparison function used when sorting to be sort\_func. | |
| *`set_default_sort_func`* () | Sets the default comparison function used when sorting to be sort\_func. | |
| *`has_default_sort_func`* () | `TRUE` if the model has a default sort function. | |
### GTK\_TREE\_SORTABLE\_DEFAULT\_SORT\_COLUMN\_ID
```
#define GTK_TREE_SORTABLE_DEFAULT_SORT_COLUMN_ID (-1)
```
The GTK\_TREE\_SORTABLE\_DEFAULT\_SORT\_COLUMN\_ID can be used to make a [GtkTreeSortable](gtktreesortable#GtkTreeSortable-struct) use the default sort function.
See also [`gtk_tree_sortable_set_sort_column_id()`](gtktreesortable#gtk-tree-sortable-set-sort-column-id)
### GTK\_TREE\_SORTABLE\_UNSORTED\_SORT\_COLUMN\_ID
```
#define GTK_TREE_SORTABLE_UNSORTED_SORT_COLUMN_ID (-2)
```
The GTK\_TREE\_SORTABLE\_UNSORTED\_SORT\_COLUMN\_ID can be used to make a [GtkTreeSortable](gtktreesortable#GtkTreeSortable-struct) use no sorting.
See also [`gtk_tree_sortable_set_sort_column_id()`](gtktreesortable#gtk-tree-sortable-set-sort-column-id)
Signal Details
--------------
### The `“sort-column-changed”` signal
```
void
user_function ([GtkTreeSortable](gtktreesortable#GtkTreeSortable-struct) *sortable,
gpointer user_data)
```
The ::sort-column-changed signal is emitted when the sort column or sort order of *`sortable`* is changed. The signal is emitted before the contents of *`sortable`* are resorted.
#### Parameters
| | | |
| --- | --- | --- |
| sortable | the object on which the signal is emitted | |
| user\_data | user data set when the signal handler was connected. | |
Flags: Run Last
See Also
--------
[GtkTreeModel](gtktreemodel#GtkTreeModel-struct), [GtkTreeView](gtktreeview#GtkTreeView-struct)
| programming_docs |
gtk GtkStackSidebar GtkStackSidebar
===============
GtkStackSidebar — An automatic sidebar widget
Functions
---------
| | |
| --- | --- |
| [GtkWidget](gtkwidget#GtkWidget-struct) \* | [gtk\_stack\_sidebar\_new](gtkstacksidebar#gtk-stack-sidebar-new) () |
| void | [gtk\_stack\_sidebar\_set\_stack](gtkstacksidebar#gtk-stack-sidebar-set-stack) () |
| [GtkStack](gtkstack#GtkStack-struct) \* | [gtk\_stack\_sidebar\_get\_stack](gtkstacksidebar#gtk-stack-sidebar-get-stack) () |
Properties
----------
| | | |
| --- | --- | --- |
| [GtkStack](gtkstack#GtkStack-struct) \* | [stack](gtkstacksidebar#GtkStackSidebar--stack) | Read / Write |
Types and Values
----------------
| | |
| --- | --- |
| | [GtkStackSidebar](gtkstacksidebar#GtkStackSidebar-struct) |
Object Hierarchy
----------------
```
GObject
╰── GInitiallyUnowned
╰── [GtkWidget](gtkwidget#GtkWidget-struct)
╰── GtkStackSidebar
```
Implemented Interfaces
----------------------
GtkStackSidebar implements [GtkAccessible](gtkaccessible#GtkAccessible-struct), [GtkBuildable](gtkbuildable#GtkBuildable-struct) and [GtkConstraintTarget](gtkconstraint#GtkConstraintTarget-struct).
Includes
--------
```
#include <gtk/gtk.h>
```
Description
-----------
A GtkStackSidebar enables you to quickly and easily provide a consistent "sidebar" object for your user interface.
In order to use a GtkStackSidebar, you simply use a GtkStack to organize your UI flow, and add the sidebar to your sidebar area. You can use [`gtk_stack_sidebar_set_stack()`](gtkstacksidebar#gtk-stack-sidebar-set-stack) to connect the [GtkStackSidebar](gtkstacksidebar#GtkStackSidebar-struct) to the [GtkStack](gtkstack#GtkStack-struct).
### CSS nodes
GtkStackSidebar has a single CSS node with name stacksidebar and style class .sidebar.
When circumstances require it, GtkStackSidebar adds the .needs-attention style class to the widgets representing the stack pages.
Functions
---------
### gtk\_stack\_sidebar\_new ()
```
[GtkWidget](gtkwidget#GtkWidget-struct) *
gtk_stack_sidebar_new (*`void`*);
```
Creates a new sidebar.
#### Returns
the new [GtkStackSidebar](gtkstacksidebar#GtkStackSidebar-struct)
### gtk\_stack\_sidebar\_set\_stack ()
```
void
gtk_stack_sidebar_set_stack (*`[GtkStackSidebar](gtkstacksidebar#GtkStackSidebar-struct) *self`*,
*`[GtkStack](gtkstack#GtkStack-struct) *stack`*);
```
Set the [GtkStack](gtkstack#GtkStack-struct) associated with this [GtkStackSidebar](gtkstacksidebar#GtkStackSidebar-struct).
The sidebar widget will automatically update according to the order (packing) and items within the given [GtkStack](gtkstack#GtkStack-struct).
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkStackSidebar](gtkstacksidebar#GtkStackSidebar-struct) | |
| stack | a [GtkStack](gtkstack#GtkStack-struct) | |
### gtk\_stack\_sidebar\_get\_stack ()
```
[GtkStack](gtkstack#GtkStack-struct) *
gtk_stack_sidebar_get_stack (*`[GtkStackSidebar](gtkstacksidebar#GtkStackSidebar-struct) *self`*);
```
Retrieves the stack. See [`gtk_stack_sidebar_set_stack()`](gtkstacksidebar#gtk-stack-sidebar-set-stack).
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkStackSidebar](gtkstacksidebar#GtkStackSidebar-struct) | |
#### Returns
the associated [GtkStack](gtkstack#GtkStack-struct) or `NULL` if none has been set explicitly.
[nullable][transfer none]
Types and Values
----------------
### GtkStackSidebar
```
typedef struct _GtkStackSidebar GtkStackSidebar;
```
Property Details
----------------
### The `“stack”` property
```
“stack” [GtkStack](gtkstack#GtkStack-struct) *
```
Associated stack for this GtkStackSidebar.
Owner: GtkStackSidebar
Flags: Read / Write
gtk GtkWindowHandle GtkWindowHandle
===============
GtkWindowHandle — A titlebar area widget
Functions
---------
| | |
| --- | --- |
| [GtkWidget](gtkwidget#GtkWidget-struct) \* | [gtk\_window\_handle\_new](gtkwindowhandle#gtk-window-handle-new) () |
| [GtkWidget](gtkwidget#GtkWidget-struct) \* | [gtk\_window\_handle\_get\_child](gtkwindowhandle#gtk-window-handle-get-child) () |
| void | [gtk\_window\_handle\_set\_child](gtkwindowhandle#gtk-window-handle-set-child) () |
Properties
----------
| | | |
| --- | --- | --- |
| [GtkWidget](gtkwidget#GtkWidget-struct) \* | [child](gtkwindowhandle#GtkWindowHandle--child) | Read / Write |
Types and Values
----------------
| | |
| --- | --- |
| | [GtkWindowHandle](gtkwindowhandle#GtkWindowHandle-struct) |
Object Hierarchy
----------------
```
GObject
╰── GInitiallyUnowned
╰── [GtkWidget](gtkwidget#GtkWidget-struct)
╰── GtkWindowHandle
```
Implemented Interfaces
----------------------
GtkWindowHandle implements [GtkAccessible](gtkaccessible#GtkAccessible-struct), [GtkBuildable](gtkbuildable#GtkBuildable-struct) and [GtkConstraintTarget](gtkconstraint#GtkConstraintTarget-struct).
Includes
--------
```
#include <gtk/gtk.h>
```
Description
-----------
GtkWindowHandle is a titlebar area widget. When added into a window, it can be dragged to move the window, and handles right click, double click and middle click as expected of a titlebar.
### CSS nodes
[GtkWindowHandle](gtkwindowhandle#GtkWindowHandle-struct) has a single CSS node with the name `windowhandle`.
### Accessibility
GtkWindowHandle uses the [`GTK_ACCESSIBLE_ROLE_GROUP`](gtkaccessible#GTK-ACCESSIBLE-ROLE-GROUP:CAPS) role.
Functions
---------
### gtk\_window\_handle\_new ()
```
[GtkWidget](gtkwidget#GtkWidget-struct) *
gtk_window_handle_new (*`void`*);
```
Creates a new [GtkWindowHandle](gtkwindowhandle#GtkWindowHandle-struct).
#### Returns
a new [GtkWindowHandle](gtkwindowhandle#GtkWindowHandle-struct).
### gtk\_window\_handle\_get\_child ()
```
[GtkWidget](gtkwidget#GtkWidget-struct) *
gtk_window_handle_get_child (*`[GtkWindowHandle](gtkwindowhandle#GtkWindowHandle-struct) *self`*);
```
Gets the child widget of *`self`* .
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkWindowHandle](gtkwindowhandle#GtkWindowHandle-struct) | |
#### Returns
the child widget of *`self`* .
[nullable][transfer none]
### gtk\_window\_handle\_set\_child ()
```
void
gtk_window_handle_set_child (*`[GtkWindowHandle](gtkwindowhandle#GtkWindowHandle-struct) *self`*,
*`[GtkWidget](gtkwidget#GtkWidget-struct) *child`*);
```
Sets the child widget of *`self`* .
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkWindowHandle](gtkwindowhandle#GtkWindowHandle-struct) | |
| child | the child widget. | [allow-none] |
Types and Values
----------------
### GtkWindowHandle
```
typedef struct _GtkWindowHandle GtkWindowHandle;
```
Property Details
----------------
### The `“child”` property
```
“child” [GtkWidget](gtkwidget#GtkWidget-struct) *
```
The child widget.
Owner: GtkWindowHandle
Flags: Read / Write
See Also
--------
[GtkWindow](gtkwindow#GtkWindow-struct), [GtkHeaderBar](gtkheaderbar#GtkHeaderBar-struct)
gtk GtkCellRendererSpin GtkCellRendererSpin
===================
GtkCellRendererSpin — Renders a spin button in a cell
Functions
---------
| | |
| --- | --- |
| [GtkCellRenderer](gtkcellrenderer#GtkCellRenderer-struct) \* | [gtk\_cell\_renderer\_spin\_new](gtkcellrendererspin#gtk-cell-renderer-spin-new) () |
Properties
----------
| | | |
| --- | --- | --- |
| [GtkAdjustment](gtkadjustment#GtkAdjustment-struct) \* | [adjustment](gtkcellrendererspin#GtkCellRendererSpin--adjustment) | Read / Write |
| double | [climb-rate](gtkcellrendererspin#GtkCellRendererSpin--climb-rate) | Read / Write |
| guint | [digits](gtkcellrendererspin#GtkCellRendererSpin--digits) | Read / Write |
Types and Values
----------------
| | |
| --- | --- |
| | [GtkCellRendererSpin](gtkcellrendererspin#GtkCellRendererSpin-struct) |
Object Hierarchy
----------------
```
GObject
╰── GInitiallyUnowned
╰── [GtkCellRenderer](gtkcellrenderer#GtkCellRenderer-struct)
╰── [GtkCellRendererText](gtkcellrenderertext#GtkCellRendererText-struct)
╰── GtkCellRendererSpin
```
Includes
--------
```
#include <gtk/gtk.h>
```
Description
-----------
[GtkCellRendererSpin](gtkcellrendererspin#GtkCellRendererSpin-struct) renders text in a cell like [GtkCellRendererText](gtkcellrenderertext#GtkCellRendererText-struct) from which it is derived. But while [GtkCellRendererText](gtkcellrenderertext#GtkCellRendererText-struct) offers a simple entry to edit the text, [GtkCellRendererSpin](gtkcellrendererspin#GtkCellRendererSpin-struct) offers a [GtkSpinButton](gtkspinbutton#GtkSpinButton-struct) widget. Of course, that means that the text has to be parseable as a floating point number.
The range of the spinbutton is taken from the adjustment property of the cell renderer, which can be set explicitly or mapped to a column in the tree model, like all properties of cell renders. [GtkCellRendererSpin](gtkcellrendererspin#GtkCellRendererSpin-struct) also has properties for the [“climb-rate”](gtkcellrendererspin#GtkCellRendererSpin--climb-rate) and the number of [“digits”](gtkcellrendererspin#GtkCellRendererSpin--digits) to display. Other [GtkSpinButton](gtkspinbutton#GtkSpinButton-struct) properties can be set in a handler for the [“editing-started”](gtkcellrenderer#GtkCellRenderer-editing-started) signal.
The [GtkCellRendererSpin](gtkcellrendererspin#GtkCellRendererSpin-struct) cell renderer was added in GTK 2.10.
Functions
---------
### gtk\_cell\_renderer\_spin\_new ()
```
[GtkCellRenderer](gtkcellrenderer#GtkCellRenderer-struct) *
gtk_cell_renderer_spin_new (*`void`*);
```
Creates a new [GtkCellRendererSpin](gtkcellrendererspin#GtkCellRendererSpin-struct).
#### Returns
a new [GtkCellRendererSpin](gtkcellrendererspin#GtkCellRendererSpin-struct)
Types and Values
----------------
### GtkCellRendererSpin
```
typedef struct _GtkCellRendererSpin GtkCellRendererSpin;
```
Property Details
----------------
### The `“adjustment”` property
```
“adjustment” [GtkAdjustment](gtkadjustment#GtkAdjustment-struct) *
```
The adjustment that holds the value of the spinbutton. This must be non-`NULL` for the cell renderer to be editable.
Owner: GtkCellRendererSpin
Flags: Read / Write
### The `“climb-rate”` property
```
“climb-rate” double
```
The acceleration rate when you hold down a button.
Owner: GtkCellRendererSpin
Flags: Read / Write
Allowed values: >= 0
Default value: 0
### The `“digits”` property
```
“digits” guint
```
The number of decimal places to display.
Owner: GtkCellRendererSpin
Flags: Read / Write
Allowed values: <= 20
Default value: 0
See Also
--------
[GtkCellRendererText](gtkcellrenderertext#GtkCellRendererText-struct), [GtkSpinButton](gtkspinbutton#GtkSpinButton-struct)
gtk Action groups and action maps Action groups and action maps
=============================
Actions rarely occurs in isolation. It is common to have groups of related actions, which are represented by instances of the GActionGroup interface.
Action maps are a variant of action groups that allow to change the name of the action as it is looked up. In GTK, the convention is to add a prefix to the action name to indicate the scope of the actions, such as “app.” for the actions with application scope or “win.” for those with window scope.
When referring to actions on a GActionMap only the name of the action itself is used (ie: “quit”, not “app.quit”). The “app.quit” form is only used when referring to actions from places like a GMenu or GtkActionable widget where the scope of the action is not already known.
GtkApplication and GtkApplicationWindow implement the GActionMap interface, so you can just add actions directly to them. For other widgets, use [`gtk_widget_insert_action_group()`](gtkwidget#gtk-widget-insert-action-group) to add actions to it.
If you want to insert several actions at the same time, it is typically faster and easier to use GActionEntry.
gtk Interactive debugging Interactive debugging
=====================
**Figure 18. The inspector**
GTK includes an interactive debugger, called the GTK Inspector, which lets you explore the widget tree of any GTK application at runtime, as well as tweak the theme and trigger visual debugging aids. You can easily try out changes at runtime before putting them into the code.
Note that the GTK inspector can only show GTK internals. It can not understand the application-specific logic of a GTK application. Also, the fact that the GTK inspector is running in the application process limits what it can do. It is meant as a complement to full-blown debuggers and system tracing facilities such as DTrace, not as a replacement.
To enable the GTK inspector, you can use the Control-Shift-I or Control-Shift-D keyboard shortcuts, or set the `GTK_DEBUG=interactive` environment variable.
There are a few more environment variables that can be set to influence how the inspector renders its UI. `GTK_INSPECTOR_DISPLAY` and `GTK_INSPECTOR_RENDERER` determine the GDK display and the GSK renderer that the inspector is using.
In some situations, it may be inappropriate to give users access to the GTK inspector. The keyboard shortcuts can be disabled with the `enable-inspector-keybinding` key in the `org.gtk.Settings.Debug` GSettings schema.
gtk GtkStringSorter GtkStringSorter
===============
GtkStringSorter — Sort by comparing strings
Functions
---------
| | |
| --- | --- |
| [GtkStringSorter](gtkstringsorter#GtkStringSorter-struct) \* | [gtk\_string\_sorter\_new](gtkstringsorter#gtk-string-sorter-new) () |
| [GtkExpression](gtkexpression#GtkExpression-struct) \* | [gtk\_string\_sorter\_get\_expression](gtkstringsorter#gtk-string-sorter-get-expression) () |
| void | [gtk\_string\_sorter\_set\_expression](gtkstringsorter#gtk-string-sorter-set-expression) () |
| gboolean | [gtk\_string\_sorter\_get\_ignore\_case](gtkstringsorter#gtk-string-sorter-get-ignore-case) () |
| void | [gtk\_string\_sorter\_set\_ignore\_case](gtkstringsorter#gtk-string-sorter-set-ignore-case) () |
Properties
----------
| | | |
| --- | --- | --- |
| [GtkExpression](gtkexpression#GtkExpression-struct) \* | [expression](gtkstringsorter#GtkStringSorter--expression) | Read / Write |
| gboolean | [ignore-case](gtkstringsorter#GtkStringSorter--ignore-case) | Read / Write |
Types and Values
----------------
| | |
| --- | --- |
| | [GtkStringSorter](gtkstringsorter#GtkStringSorter-struct) |
Object Hierarchy
----------------
```
GObject
╰── [GtkSorter](gtksorter#GtkSorter-struct)
╰── GtkStringSorter
```
Includes
--------
```
#include <gtk/gtk.h>
```
Description
-----------
GtkStringSorter is a [GtkSorter](gtksorter#GtkSorter-struct) that compares strings. It does the comparison in a linguistically correct way using the current locale by normalizing Unicode strings and possibly case-folding them before performing the comparison.
To obtain the strings to compare, this sorter evaluates a [GtkExpression](gtkexpression#GtkExpression-struct).
Functions
---------
### gtk\_string\_sorter\_new ()
```
[GtkStringSorter](gtkstringsorter#GtkStringSorter-struct) *
gtk_string_sorter_new (*`[GtkExpression](gtkexpression#GtkExpression-struct) *expression`*);
```
Creates a new string sorter that compares items using the given *`expression`* .
Unless an expression is set on it, this sorter will always compare items as invalid.
#### Parameters
| | | |
| --- | --- | --- |
| expression | The expression to evaluate. | [transfer full][nullable] |
#### Returns
a new [GtkStringSorter](gtkstringsorter#GtkStringSorter-struct)
### gtk\_string\_sorter\_get\_expression ()
```
[GtkExpression](gtkexpression#GtkExpression-struct) *
gtk_string_sorter_get_expression (*`[GtkStringSorter](gtkstringsorter#GtkStringSorter-struct) *self`*);
```
Gets the expression that is evaluated to obtain strings from items.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkStringSorter](gtkstringsorter#GtkStringSorter-struct) | |
#### Returns
a [GtkExpression](gtkexpression#GtkExpression-struct), or `NULL`.
[transfer none][nullable]
### gtk\_string\_sorter\_set\_expression ()
```
void
gtk_string_sorter_set_expression (*`[GtkStringSorter](gtkstringsorter#GtkStringSorter-struct) *self`*,
*`[GtkExpression](gtkexpression#GtkExpression-struct) *expression`*);
```
Sets the expression that is evaluated to obtain strings from items.
The expression must have the type G\_TYPE\_STRING.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkStringSorter](gtkstringsorter#GtkStringSorter-struct) | |
| expression | a [GtkExpression](gtkexpression#GtkExpression-struct), or `NULL`. | [nullable][transfer none] |
### gtk\_string\_sorter\_get\_ignore\_case ()
```
gboolean
gtk_string_sorter_get_ignore_case (*`[GtkStringSorter](gtkstringsorter#GtkStringSorter-struct) *self`*);
```
Gets whether the sorter ignores case differences.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkStringSorter](gtkstringsorter#GtkStringSorter-struct) | |
#### Returns
`TRUE` if *`self`* is ignoring case differences
### gtk\_string\_sorter\_set\_ignore\_case ()
```
void
gtk_string_sorter_set_ignore_case (*`[GtkStringSorter](gtkstringsorter#GtkStringSorter-struct) *self`*,
*`gboolean ignore_case`*);
```
Sets whether the sorter will ignore case differences.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkStringSorter](gtkstringsorter#GtkStringSorter-struct) | |
| ignore\_case | `TRUE` to ignore case differences | |
Types and Values
----------------
### GtkStringSorter
```
typedef struct _GtkStringSorter GtkStringSorter;
```
Property Details
----------------
### The `“expression”` property
```
“expression” [GtkExpression](gtkexpression#GtkExpression-struct) *
```
The expression to evaluate on item to get a string to compare with
[type GtkExpression]
Owner: GtkStringSorter
Flags: Read / Write
### The `“ignore-case”` property
```
“ignore-case” gboolean
```
If matching is case sensitive
Owner: GtkStringSorter
Flags: Read / Write
Default value: TRUE
See Also
--------
[GtkExpression](gtkexpression#GtkExpression-struct)
gtk GtkTreeModelFilter GtkTreeModelFilter
==================
GtkTreeModelFilter — A GtkTreeModel which hides parts of an underlying tree model
Functions
---------
| | |
| --- | --- |
| gboolean | ([\*GtkTreeModelFilterVisibleFunc](gtktreemodelfilter#GtkTreeModelFilterVisibleFunc)) () |
| void | ([\*GtkTreeModelFilterModifyFunc](gtktreemodelfilter#GtkTreeModelFilterModifyFunc)) () |
| [GtkTreeModel](gtktreemodel#GtkTreeModel-struct) \* | [gtk\_tree\_model\_filter\_new](gtktreemodelfilter#gtk-tree-model-filter-new) () |
| void | [gtk\_tree\_model\_filter\_set\_visible\_func](gtktreemodelfilter#gtk-tree-model-filter-set-visible-func) () |
| void | [gtk\_tree\_model\_filter\_set\_modify\_func](gtktreemodelfilter#gtk-tree-model-filter-set-modify-func) () |
| void | [gtk\_tree\_model\_filter\_set\_visible\_column](gtktreemodelfilter#gtk-tree-model-filter-set-visible-column) () |
| [GtkTreeModel](gtktreemodel#GtkTreeModel-struct) \* | [gtk\_tree\_model\_filter\_get\_model](gtktreemodelfilter#gtk-tree-model-filter-get-model) () |
| gboolean | [gtk\_tree\_model\_filter\_convert\_child\_iter\_to\_iter](gtktreemodelfilter#gtk-tree-model-filter-convert-child-iter-to-iter) () |
| void | [gtk\_tree\_model\_filter\_convert\_iter\_to\_child\_iter](gtktreemodelfilter#gtk-tree-model-filter-convert-iter-to-child-iter) () |
| [GtkTreePath](gtktreemodel#GtkTreePath-struct) \* | [gtk\_tree\_model\_filter\_convert\_child\_path\_to\_path](gtktreemodelfilter#gtk-tree-model-filter-convert-child-path-to-path) () |
| [GtkTreePath](gtktreemodel#GtkTreePath-struct) \* | [gtk\_tree\_model\_filter\_convert\_path\_to\_child\_path](gtktreemodelfilter#gtk-tree-model-filter-convert-path-to-child-path) () |
| void | [gtk\_tree\_model\_filter\_refilter](gtktreemodelfilter#gtk-tree-model-filter-refilter) () |
| void | [gtk\_tree\_model\_filter\_clear\_cache](gtktreemodelfilter#gtk-tree-model-filter-clear-cache) () |
Properties
----------
| | | |
| --- | --- | --- |
| [GtkTreeModel](gtktreemodel#GtkTreeModel-struct) \* | [child-model](gtktreemodelfilter#GtkTreeModelFilter--child-model) | Read / Write / Construct Only |
| [GtkTreePath](gtktreemodel#GtkTreePath-struct) \* | [virtual-root](gtktreemodelfilter#GtkTreeModelFilter--virtual-root) | Read / Write / Construct Only |
Types and Values
----------------
| | |
| --- | --- |
| struct | [GtkTreeModelFilter](gtktreemodelfilter#GtkTreeModelFilter-struct) |
Object Hierarchy
----------------
```
GObject
╰── GtkTreeModelFilter
```
Implemented Interfaces
----------------------
GtkTreeModelFilter implements [GtkTreeModel](gtktreemodel#GtkTreeModel-struct) and [GtkTreeDragSource](gtk4-gtktreeview-drag-and-drop#GtkTreeDragSource-struct).
Includes
--------
```
#include <gtk/gtk.h>
```
Description
-----------
A [GtkTreeModelFilter](gtktreemodelfilter#GtkTreeModelFilter-struct) is a tree model which wraps another tree model, and can do the following things:
* Filter specific rows, based on data from a “visible column”, a column storing booleans indicating whether the row should be filtered or not, or based on the return value of a “visible function”, which gets a model, iter and user\_data and returns a boolean indicating whether the row should be filtered or not.
* Modify the “appearance” of the model, using a modify function. This is extremely powerful and allows for just changing some values and also for creating a completely different model based on the given child model.
* Set a different root node, also known as a “virtual root”. You can pass in a [GtkTreePath](gtktreemodel#GtkTreePath-struct) indicating the root node for the filter at construction time.
The basic API is similar to [GtkTreeModelSort](gtktreemodelsort#GtkTreeModelSort-struct). For an example on its usage, see the section on [GtkTreeModelSort](gtktreemodelsort#GtkTreeModelSort-struct).
When using [GtkTreeModelFilter](gtktreemodelfilter#GtkTreeModelFilter-struct), it is important to realize that [GtkTreeModelFilter](gtktreemodelfilter#GtkTreeModelFilter-struct) maintains an internal cache of all nodes which are visible in its clients. The cache is likely to be a subtree of the tree exposed by the child model. [GtkTreeModelFilter](gtktreemodelfilter#GtkTreeModelFilter-struct) will not cache the entire child model when unnecessary to not compromise the caching mechanism that is exposed by the reference counting scheme. If the child model implements reference counting, unnecessary signals may not be emitted because of reference counting rule 3, see the [GtkTreeModel](gtktreemodel#GtkTreeModel-struct) documentation. (Note that e.g. [GtkTreeStore](gtktreestore#GtkTreeStore-struct) does not implement reference counting and will always emit all signals, even when the receiving node is not visible).
Because of this, limitations for possible visible functions do apply. In general, visible functions should only use data or properties from the node for which the visibility state must be determined, its siblings or its parents. Usually, having a dependency on the state of any child node is not possible, unless references are taken on these explicitly. When no such reference exists, no signals may be received for these child nodes (see reference counting rule number 3 in the [GtkTreeModel](gtktreemodel#GtkTreeModel-struct) section).
Determining the visibility state of a given node based on the state of its child nodes is a frequently occurring use case. Therefore, [GtkTreeModelFilter](gtktreemodelfilter#GtkTreeModelFilter-struct) explicitly supports this. For example, when a node does not have any children, you might not want the node to be visible. As soon as the first row is added to the node’s child level (or the last row removed), the node’s visibility should be updated.
This introduces a dependency from the node on its child nodes. In order to accommodate this, [GtkTreeModelFilter](gtktreemodelfilter#GtkTreeModelFilter-struct) must make sure the necessary signals are received from the child model. This is achieved by building, for all nodes which are exposed as visible nodes to [GtkTreeModelFilter](gtktreemodelfilter#GtkTreeModelFilter-struct)'s clients, the child level (if any) and take a reference on the first node in this level. Furthermore, for every row-inserted, row-changed or row-deleted signal (also these which were not handled because the node was not cached), [GtkTreeModelFilter](gtktreemodelfilter#GtkTreeModelFilter-struct) will check if the visibility state of any parent node has changed.
Beware, however, that this explicit support is limited to these two cases. For example, if you want a node to be visible only if two nodes in a child’s child level (2 levels deeper) are visible, you are on your own. In this case, either rely on [GtkTreeStore](gtktreestore#GtkTreeStore-struct) to emit all signals because it does not implement reference counting, or for models that do implement reference counting, obtain references on these child levels yourself.
Functions
---------
### GtkTreeModelFilterVisibleFunc ()
```
gboolean
(*GtkTreeModelFilterVisibleFunc) (*`[GtkTreeModel](gtktreemodel#GtkTreeModel-struct) *model`*,
*`[GtkTreeIter](gtktreemodel#GtkTreeIter-struct) *iter`*,
*`gpointer data`*);
```
A function which decides whether the row indicated by *`iter`* is visible.
#### Parameters
| | | |
| --- | --- | --- |
| model | the child model of the [GtkTreeModelFilter](gtktreemodelfilter#GtkTreeModelFilter-struct) | |
| iter | a [GtkTreeIter](gtktreemodel#GtkTreeIter-struct) pointing to the row in *`model`* whose visibility is determined | |
| data | user data given to [`gtk_tree_model_filter_set_visible_func()`](gtktreemodelfilter#gtk-tree-model-filter-set-visible-func). | [closure] |
#### Returns
Whether the row indicated by *`iter`* is visible.
### GtkTreeModelFilterModifyFunc ()
```
void
(*GtkTreeModelFilterModifyFunc) (*`[GtkTreeModel](gtktreemodel#GtkTreeModel-struct) *model`*,
*`[GtkTreeIter](gtktreemodel#GtkTreeIter-struct) *iter`*,
*`GValue *value`*,
*`int column`*,
*`gpointer data`*);
```
A function which calculates display values from raw values in the model. It must fill *`value`* with the display value for the column *`column`* in the row indicated by *`iter`* .
Since this function is called for each data access, it’s not a particularly efficient operation.
#### Parameters
| | | |
| --- | --- | --- |
| model | the [GtkTreeModelFilter](gtktreemodelfilter#GtkTreeModelFilter-struct) | |
| iter | a [GtkTreeIter](gtktreemodel#GtkTreeIter-struct) pointing to the row whose display values are determined | |
| value | A GValue which is already initialized for with the correct type for the column *`column`* . | [out caller-allocates] |
| column | the column whose display value is determined | |
| data | user data given to [`gtk_tree_model_filter_set_modify_func()`](gtktreemodelfilter#gtk-tree-model-filter-set-modify-func). | [closure] |
### gtk\_tree\_model\_filter\_new ()
```
[GtkTreeModel](gtktreemodel#GtkTreeModel-struct) *
gtk_tree_model_filter_new (*`[GtkTreeModel](gtktreemodel#GtkTreeModel-struct) *child_model`*,
*`[GtkTreePath](gtktreemodel#GtkTreePath-struct) *root`*);
```
Creates a new [GtkTreeModel](gtktreemodel#GtkTreeModel-struct), with *`child_model`* as the child\_model and *`root`* as the virtual root.
#### Parameters
| | | |
| --- | --- | --- |
| child\_model | A [GtkTreeModel](gtktreemodel#GtkTreeModel-struct). | |
| root | A [GtkTreePath](gtktreemodel#GtkTreePath-struct) or `NULL`. | [allow-none] |
#### Returns
A new [GtkTreeModel](gtktreemodel#GtkTreeModel-struct).
[transfer full]
### gtk\_tree\_model\_filter\_set\_visible\_func ()
```
void
gtk_tree_model_filter_set_visible_func
(*`[GtkTreeModelFilter](gtktreemodelfilter#GtkTreeModelFilter-struct) *filter`*,
*`[GtkTreeModelFilterVisibleFunc](gtktreemodelfilter#GtkTreeModelFilterVisibleFunc) func`*,
*`gpointer data`*,
*`GDestroyNotify destroy`*);
```
Sets the visible function used when filtering the *`filter`* to be *`func`* . The function should return `TRUE` if the given row should be visible and `FALSE` otherwise.
If the condition calculated by the function changes over time (e.g. because it depends on some global parameters), you must call [`gtk_tree_model_filter_refilter()`](gtktreemodelfilter#gtk-tree-model-filter-refilter) to keep the visibility information of the model up-to-date.
Note that *`func`* is called whenever a row is inserted, when it may still be empty. The visible function should therefore take special care of empty rows, like in the example below.
```
static gboolean
visible_func (GtkTreeModel *model,
GtkTreeIter *iter,
gpointer data)
{
// Visible if row is non-empty and first column is “HI”
char *str;
gboolean visible = FALSE;
gtk_tree_model_get (model, iter, 0, &str, -1);
if (str && strcmp (str, "HI") == 0)
visible = TRUE;
g_free (str);
return visible;
}
```
| Note that [`gtk_tree_model_filter_set_visible_func()`](gtktreemodelfilter#gtk-tree-model-filter-set-visible-func) or [`gtk_tree_model_filter_set_visible_column()`](gtktreemodelfilter#gtk-tree-model-filter-set-visible-column) can only be called once for a given filter model.
#### Parameters
| | | |
| --- | --- | --- |
| filter | A [GtkTreeModelFilter](gtktreemodelfilter#GtkTreeModelFilter-struct) | |
| func | A [GtkTreeModelFilterVisibleFunc](gtktreemodelfilter#GtkTreeModelFilterVisibleFunc), the visible function | |
| data | User data to pass to the visible function, or `NULL`. | [allow-none] |
| destroy | Destroy notifier of *`data`* , or `NULL`. | [allow-none] |
### gtk\_tree\_model\_filter\_set\_modify\_func ()
```
void
gtk_tree_model_filter_set_modify_func (*`[GtkTreeModelFilter](gtktreemodelfilter#GtkTreeModelFilter-struct) *filter`*,
*`int n_columns`*,
*`GType *types`*,
*`[GtkTreeModelFilterModifyFunc](gtktreemodelfilter#GtkTreeModelFilterModifyFunc) func`*,
*`gpointer data`*,
*`GDestroyNotify destroy`*);
```
With the *`n_columns`* and *`types`* parameters, you give an array of column types for this model (which will be exposed to the parent model/view). The *`func`* , *`data`* and *`destroy`* parameters are for specifying the modify function. The modify function will get called for each data access, the goal of the modify function is to return the data which should be displayed at the location specified using the parameters of the modify function.
Note that [`gtk_tree_model_filter_set_modify_func()`](gtktreemodelfilter#gtk-tree-model-filter-set-modify-func) can only be called once for a given filter model.
#### Parameters
| | | |
| --- | --- | --- |
| filter | A [GtkTreeModelFilter](gtktreemodelfilter#GtkTreeModelFilter-struct). | |
| n\_columns | The number of columns in the filter model. | |
| types | The GTypes of the columns. | [array length=n\_columns] |
| func | A [GtkTreeModelFilterModifyFunc](gtktreemodelfilter#GtkTreeModelFilterModifyFunc) | |
| data | User data to pass to the modify function, or `NULL`. | [allow-none] |
| destroy | Destroy notifier of *`data`* , or `NULL`. | [allow-none] |
### gtk\_tree\_model\_filter\_set\_visible\_column ()
```
void
gtk_tree_model_filter_set_visible_column
(*`[GtkTreeModelFilter](gtktreemodelfilter#GtkTreeModelFilter-struct) *filter`*,
*`int column`*);
```
Sets *`column`* of the child\_model to be the column where *`filter`* should look for visibility information. *`columns`* should be a column of type `G_TYPE_BOOLEAN`, where `TRUE` means that a row is visible, and `FALSE` if not.
Note that [`gtk_tree_model_filter_set_visible_func()`](gtktreemodelfilter#gtk-tree-model-filter-set-visible-func) or [`gtk_tree_model_filter_set_visible_column()`](gtktreemodelfilter#gtk-tree-model-filter-set-visible-column) can only be called once for a given filter model.
#### Parameters
| | | |
| --- | --- | --- |
| filter | A [GtkTreeModelFilter](gtktreemodelfilter#GtkTreeModelFilter-struct) | |
| column | A int which is the column containing the visible information | |
### gtk\_tree\_model\_filter\_get\_model ()
```
[GtkTreeModel](gtktreemodel#GtkTreeModel-struct) *
gtk_tree_model_filter_get_model (*`[GtkTreeModelFilter](gtktreemodelfilter#GtkTreeModelFilter-struct) *filter`*);
```
Returns a pointer to the child model of *`filter`* .
#### Parameters
| | | |
| --- | --- | --- |
| filter | A [GtkTreeModelFilter](gtktreemodelfilter#GtkTreeModelFilter-struct). | |
#### Returns
A pointer to a [GtkTreeModel](gtktreemodel#GtkTreeModel-struct).
[transfer none]
### gtk\_tree\_model\_filter\_convert\_child\_iter\_to\_iter ()
```
gboolean
gtk_tree_model_filter_convert_child_iter_to_iter
(*`[GtkTreeModelFilter](gtktreemodelfilter#GtkTreeModelFilter-struct) *filter`*,
*`[GtkTreeIter](gtktreemodel#GtkTreeIter-struct) *filter_iter`*,
*`[GtkTreeIter](gtktreemodel#GtkTreeIter-struct) *child_iter`*);
```
Sets *`filter_iter`* to point to the row in *`filter`* that corresponds to the row pointed at by *`child_iter`* . If *`filter_iter`* was not set, `FALSE` is returned.
#### Parameters
| | | |
| --- | --- | --- |
| filter | A [GtkTreeModelFilter](gtktreemodelfilter#GtkTreeModelFilter-struct). | |
| filter\_iter | An uninitialized [GtkTreeIter](gtktreemodel#GtkTreeIter-struct). | [out] |
| child\_iter | A valid [GtkTreeIter](gtktreemodel#GtkTreeIter-struct) pointing to a row on the child model. | |
#### Returns
`TRUE`, if *`filter_iter`* was set, i.e. if *`child_iter`* is a valid iterator pointing to a visible row in child model.
### gtk\_tree\_model\_filter\_convert\_iter\_to\_child\_iter ()
```
void
gtk_tree_model_filter_convert_iter_to_child_iter
(*`[GtkTreeModelFilter](gtktreemodelfilter#GtkTreeModelFilter-struct) *filter`*,
*`[GtkTreeIter](gtktreemodel#GtkTreeIter-struct) *child_iter`*,
*`[GtkTreeIter](gtktreemodel#GtkTreeIter-struct) *filter_iter`*);
```
Sets *`child_iter`* to point to the row pointed to by *`filter_iter`* .
#### Parameters
| | | |
| --- | --- | --- |
| filter | A [GtkTreeModelFilter](gtktreemodelfilter#GtkTreeModelFilter-struct). | |
| child\_iter | An uninitialized [GtkTreeIter](gtktreemodel#GtkTreeIter-struct). | [out] |
| filter\_iter | A valid [GtkTreeIter](gtktreemodel#GtkTreeIter-struct) pointing to a row on *`filter`* . | |
### gtk\_tree\_model\_filter\_convert\_child\_path\_to\_path ()
```
[GtkTreePath](gtktreemodel#GtkTreePath-struct) *
gtk_tree_model_filter_convert_child_path_to_path
(*`[GtkTreeModelFilter](gtktreemodelfilter#GtkTreeModelFilter-struct) *filter`*,
*`[GtkTreePath](gtktreemodel#GtkTreePath-struct) *child_path`*);
```
Converts *`child_path`* to a path relative to *`filter`* . That is, *`child_path`* points to a path in the child model. The rerturned path will point to the same row in the filtered model. If *`child_path`* isn’t a valid path on the child model or points to a row which is not visible in *`filter`* , then `NULL` is returned.
#### Parameters
| | | |
| --- | --- | --- |
| filter | A [GtkTreeModelFilter](gtktreemodelfilter#GtkTreeModelFilter-struct). | |
| child\_path | A [GtkTreePath](gtktreemodel#GtkTreePath-struct) to convert. | |
#### Returns
A newly allocated [GtkTreePath](gtktreemodel#GtkTreePath-struct), or `NULL`.
[nullable][transfer full]
### gtk\_tree\_model\_filter\_convert\_path\_to\_child\_path ()
```
[GtkTreePath](gtktreemodel#GtkTreePath-struct) *
gtk_tree_model_filter_convert_path_to_child_path
(*`[GtkTreeModelFilter](gtktreemodelfilter#GtkTreeModelFilter-struct) *filter`*,
*`[GtkTreePath](gtktreemodel#GtkTreePath-struct) *filter_path`*);
```
Converts *`filter_path`* to a path on the child model of *`filter`* . That is, *`filter_path`* points to a location in *`filter`* . The returned path will point to the same location in the model not being filtered. If *`filter_path`* does not point to a location in the child model, `NULL` is returned.
#### Parameters
| | | |
| --- | --- | --- |
| filter | A [GtkTreeModelFilter](gtktreemodelfilter#GtkTreeModelFilter-struct). | |
| filter\_path | A [GtkTreePath](gtktreemodel#GtkTreePath-struct) to convert. | |
#### Returns
A newly allocated [GtkTreePath](gtktreemodel#GtkTreePath-struct), or `NULL`.
[nullable][transfer full]
### gtk\_tree\_model\_filter\_refilter ()
```
void
gtk_tree_model_filter_refilter (*`[GtkTreeModelFilter](gtktreemodelfilter#GtkTreeModelFilter-struct) *filter`*);
```
Emits ::row\_changed for each row in the child model, which causes the filter to re-evaluate whether a row is visible or not.
#### Parameters
| | | |
| --- | --- | --- |
| filter | A [GtkTreeModelFilter](gtktreemodelfilter#GtkTreeModelFilter-struct). | |
### gtk\_tree\_model\_filter\_clear\_cache ()
```
void
gtk_tree_model_filter_clear_cache (*`[GtkTreeModelFilter](gtktreemodelfilter#GtkTreeModelFilter-struct) *filter`*);
```
This function should almost never be called. It clears the *`filter`* of any cached iterators that haven’t been reffed with [`gtk_tree_model_ref_node()`](gtktreemodel#gtk-tree-model-ref-node). This might be useful if the child model being filtered is static (and doesn’t change often) and there has been a lot of unreffed access to nodes. As a side effect of this function, all unreffed iters will be invalid.
#### Parameters
| | | |
| --- | --- | --- |
| filter | A [GtkTreeModelFilter](gtktreemodelfilter#GtkTreeModelFilter-struct). | |
Types and Values
----------------
### struct GtkTreeModelFilter
```
struct GtkTreeModelFilter;
```
Property Details
----------------
### The `“child-model”` property
```
“child-model” [GtkTreeModel](gtktreemodel#GtkTreeModel-struct) *
```
The model for the filtermodel to filter.
Owner: GtkTreeModelFilter
Flags: Read / Write / Construct Only
### The `“virtual-root”` property
```
“virtual-root” [GtkTreePath](gtktreemodel#GtkTreePath-struct) *
```
The virtual root (relative to the child model) for this filtermodel.
Owner: GtkTreeModelFilter
Flags: Read / Write / Construct Only
See Also
--------
[GtkTreeModelSort](gtktreemodelsort#GtkTreeModelSort-struct)
| programming_docs |
gtk GtkConstraint GtkConstraint
=============
GtkConstraint — The description of a constraint
Functions
---------
| | |
| --- | --- |
| [GtkConstraint](gtkconstraint#GtkConstraint-struct) \* | [gtk\_constraint\_new](gtkconstraint#gtk-constraint-new) () |
| [GtkConstraint](gtkconstraint#GtkConstraint-struct) \* | [gtk\_constraint\_new\_constant](gtkconstraint#gtk-constraint-new-constant) () |
| [GtkConstraintTarget](gtkconstraint#GtkConstraintTarget-struct) \* | [gtk\_constraint\_get\_target](gtkconstraint#gtk-constraint-get-target) () |
| [GtkConstraintAttribute](gtkconstraint#GtkConstraintAttribute) | [gtk\_constraint\_get\_target\_attribute](gtkconstraint#gtk-constraint-get-target-attribute) () |
| [GtkConstraintRelation](gtkconstraint#GtkConstraintRelation) | [gtk\_constraint\_get\_relation](gtkconstraint#gtk-constraint-get-relation) () |
| [GtkConstraintTarget](gtkconstraint#GtkConstraintTarget-struct) \* | [gtk\_constraint\_get\_source](gtkconstraint#gtk-constraint-get-source) () |
| [GtkConstraintAttribute](gtkconstraint#GtkConstraintAttribute) | [gtk\_constraint\_get\_source\_attribute](gtkconstraint#gtk-constraint-get-source-attribute) () |
| double | [gtk\_constraint\_get\_multiplier](gtkconstraint#gtk-constraint-get-multiplier) () |
| double | [gtk\_constraint\_get\_constant](gtkconstraint#gtk-constraint-get-constant) () |
| int | [gtk\_constraint\_get\_strength](gtkconstraint#gtk-constraint-get-strength) () |
| gboolean | [gtk\_constraint\_is\_required](gtkconstraint#gtk-constraint-is-required) () |
| gboolean | [gtk\_constraint\_is\_attached](gtkconstraint#gtk-constraint-is-attached) () |
| gboolean | [gtk\_constraint\_is\_constant](gtkconstraint#gtk-constraint-is-constant) () |
Properties
----------
| | | |
| --- | --- | --- |
| double | [constant](gtkconstraint#GtkConstraint--constant) | Read / Write / Construct Only |
| double | [multiplier](gtkconstraint#GtkConstraint--multiplier) | Read / Write / Construct Only |
| [GtkConstraintRelation](gtkconstraint#GtkConstraintRelation) | [relation](gtkconstraint#GtkConstraint--relation) | Read / Write / Construct Only |
| [GtkConstraintTarget](gtkconstraint#GtkConstraintTarget-struct) \* | [source](gtkconstraint#GtkConstraint--source) | Read / Write / Construct Only |
| [GtkConstraintAttribute](gtkconstraint#GtkConstraintAttribute) | [source-attribute](gtkconstraint#GtkConstraint--source-attribute) | Read / Write / Construct Only |
| int | [strength](gtkconstraint#GtkConstraint--strength) | Read / Write / Construct Only |
| [GtkConstraintTarget](gtkconstraint#GtkConstraintTarget-struct) \* | [target](gtkconstraint#GtkConstraint--target) | Read / Write / Construct Only |
| [GtkConstraintAttribute](gtkconstraint#GtkConstraintAttribute) | [target-attribute](gtkconstraint#GtkConstraint--target-attribute) | Read / Write / Construct Only |
Types and Values
----------------
| | |
| --- | --- |
| | [GtkConstraint](gtkconstraint#GtkConstraint-struct) |
| | [GtkConstraintTarget](gtkconstraint#GtkConstraintTarget-struct) |
| enum | [GtkConstraintAttribute](gtkconstraint#GtkConstraintAttribute) |
| enum | [GtkConstraintRelation](gtkconstraint#GtkConstraintRelation) |
| enum | [GtkConstraintStrength](gtkconstraint#GtkConstraintStrength) |
Object Hierarchy
----------------
```
[GInterface](https://developer-old.gnome.org/gobject/stable/GTypeModule.html)
╰── GtkConstraintTarget
GObject
╰── GtkConstraint
```
Prerequisites
-------------
GtkConstraintTarget requires GObject.
Known Implementations
---------------------
GtkConstraintTarget is implemented by [GtkAboutDialog](gtkaboutdialog#GtkAboutDialog-struct), [GtkActionBar](gtkactionbar#GtkActionBar-struct), [GtkAppChooserButton](gtkappchooserbutton#GtkAppChooserButton-struct), [GtkAppChooserDialog](gtkappchooserdialog#GtkAppChooserDialog-struct), [GtkAppChooserWidget](gtkappchooserwidget#GtkAppChooserWidget-struct), [GtkApplicationWindow](gtkapplicationwindow#GtkApplicationWindow-struct), [GtkAspectFrame](gtkaspectframe#GtkAspectFrame-struct), [GtkAssistant](gtkassistant#GtkAssistant-struct), [GtkBox](gtkbox#GtkBox-struct), [GtkButton](gtkbutton#GtkButton-struct), [GtkCalendar](gtkcalendar#GtkCalendar-struct), [GtkCellView](gtkcellview#GtkCellView-struct), [GtkCenterBox](https://developer-old.gnome.org/usr/share/gtk-doc/html/gtk4/gtk4-GtkCenterBox.html#GtkCenterBox), [GtkCheckButton](gtkcheckbutton#GtkCheckButton-struct), [GtkColorButton](gtkcolorbutton#GtkColorButton-struct), [GtkColorChooserDialog](gtkcolorchooserdialog#GtkColorChooserDialog-struct), [GtkColorChooserWidget](gtkcolorchooserwidget#GtkColorChooserWidget-struct), [GtkColumnView](gtkcolumnview#GtkColumnView-struct), [GtkComboBox](gtkcombobox#GtkComboBox-struct), [GtkComboBoxText](gtkcomboboxtext#GtkComboBoxText-struct), [GtkConstraintGuide](gtkconstraintguide#GtkConstraintGuide-struct), [GtkDialog](gtkdialog#GtkDialog-struct), [GtkDragIcon](gtkdragicon#GtkDragIcon-struct), [GtkDrawingArea](gtkdrawingarea#GtkDrawingArea-struct), [GtkDropDown](gtkdropdown#GtkDropDown-struct), [GtkEditableLabel](gtkeditablelabel#GtkEditableLabel-struct), [GtkEmojiChooser](gtkemojichooser#GtkEmojiChooser-struct), [GtkEntry](gtkentry#GtkEntry-struct), [GtkExpander](gtkexpander#GtkExpander-struct), [GtkFileChooserDialog](gtkfilechooserdialog#GtkFileChooserDialog-struct), [GtkFileChooserWidget](gtkfilechooserwidget#GtkFileChooserWidget-struct), [GtkFixed](gtkfixed#GtkFixed-struct), [GtkFlowBox](gtkflowbox#GtkFlowBox-struct), [GtkFlowBoxChild](gtkflowbox#GtkFlowBoxChild-struct), [GtkFontButton](gtkfontbutton#GtkFontButton-struct), [GtkFontChooserDialog](gtkfontchooserdialog#GtkFontChooserDialog-struct), [GtkFontChooserWidget](gtkfontchooserwidget#GtkFontChooserWidget-struct), [GtkFrame](gtkframe#GtkFrame-struct), [GtkGLArea](gtkglarea#GtkGLArea-struct), [GtkGrid](gtkgrid#GtkGrid-struct), [GtkGridView](gtkgridview#GtkGridView-struct), [GtkHeaderBar](gtkheaderbar#GtkHeaderBar-struct), [GtkIconView](gtkiconview#GtkIconView-struct), [GtkImage](gtkimage#GtkImage-struct), [GtkInfoBar](gtkinfobar#GtkInfoBar-struct), [GtkLabel](gtklabel#GtkLabel-struct), [GtkLevelBar](gtklevelbar#GtkLevelBar-struct), [GtkLinkButton](gtklinkbutton#GtkLinkButton-struct), [GtkListBox](gtklistbox#GtkListBox-struct), [GtkListBoxRow](gtklistbox#GtkListBoxRow-struct), [GtkListView](gtklistview#GtkListView-struct), [GtkLockButton](gtklockbutton#GtkLockButton-struct), [GtkMediaControls](gtkmediacontrols#GtkMediaControls-struct), [GtkMenuButton](gtkmenubutton#GtkMenuButton-struct), [GtkMessageDialog](gtkmessagedialog#GtkMessageDialog-struct), [GtkNotebook](gtknotebook#GtkNotebook-struct), [GtkOverlay](gtkoverlay#GtkOverlay-struct), [GtkPageSetupUnixDialog](gtkpagesetupunixdialog#GtkPageSetupUnixDialog-struct), [GtkPaned](gtkpaned#GtkPaned-struct), [GtkPasswordEntry](gtkpasswordentry#GtkPasswordEntry-struct), [GtkPicture](gtkpicture#GtkPicture-struct), [GtkPopover](gtkpopover#GtkPopover-struct), [GtkPopoverMenu](gtkpopovermenu#GtkPopoverMenu-struct), [GtkPopoverMenuBar](gtkpopovermenubar#GtkPopoverMenuBar-struct), [GtkPrintUnixDialog](gtkprintunixdialog#GtkPrintUnixDialog-struct), [GtkProgressBar](gtkprogressbar#GtkProgressBar-struct), [GtkRange](gtkrange#GtkRange-struct), [GtkRevealer](gtkrevealer#GtkRevealer-struct), [GtkScale](gtkscale#GtkScale-struct), [GtkScaleButton](gtkscalebutton#GtkScaleButton-struct), [GtkScrollbar](gtkscrollbar#GtkScrollbar-struct), [GtkScrolledWindow](gtkscrolledwindow#GtkScrolledWindow-struct), [GtkSearchBar](gtksearchbar#GtkSearchBar-struct), [GtkSearchEntry](gtksearchentry#GtkSearchEntry-struct), [GtkSeparator](gtkseparator#GtkSeparator-struct), [GtkShortcutLabel](gtkshortcutlabel#GtkShortcutLabel-struct), [GtkShortcutsGroup](gtkshortcutsgroup#GtkShortcutsGroup-struct), [GtkShortcutsSection](gtkshortcutssection#GtkShortcutsSection-struct), [GtkShortcutsShortcut](gtkshortcutsshortcut#GtkShortcutsShortcut-struct), [GtkShortcutsWindow](gtkshortcutswindow#GtkShortcutsWindow-struct), [GtkSpinButton](gtkspinbutton#GtkSpinButton-struct), [GtkSpinner](gtkspinner#GtkSpinner-struct), [GtkStack](gtkstack#GtkStack-struct), [GtkStackSidebar](gtkstacksidebar#GtkStackSidebar-struct), [GtkStackSwitcher](gtkstackswitcher#GtkStackSwitcher-struct), [GtkStatusbar](gtkstatusbar#GtkStatusbar-struct), [GtkSwitch](gtkswitch#GtkSwitch-struct), [GtkText](gtktext#GtkText-struct), [GtkTextView](gtktextview#GtkTextView-struct), [GtkToggleButton](gtktogglebutton#GtkToggleButton-struct), [GtkTreeExpander](gtktreeexpander#GtkTreeExpander-struct), [GtkTreeView](gtktreeview#GtkTreeView-struct), [GtkVideo](gtkvideo#GtkVideo-struct), [GtkViewport](gtkviewport#GtkViewport-struct), [GtkVolumeButton](gtkvolumebutton#GtkVolumeButton-struct), [GtkWidget](gtkwidget#GtkWidget-struct), [GtkWindow](gtkwindow#GtkWindow-struct), [GtkWindowControls](gtkwindowcontrols#GtkWindowControls-struct) and [GtkWindowHandle](gtkwindowhandle#GtkWindowHandle-struct).
Includes
--------
```
#include <gtk/gtk.h>
```
Description
-----------
[GtkConstraint](gtkconstraint#GtkConstraint-struct) describes a constraint between an attribute on a widget and another attribute on another widget, expressed as a linear equation like:
Each [GtkConstraint](gtkconstraint#GtkConstraint-struct) is part of a system that will be solved by a [GtkConstraintLayout](gtkconstraintlayout#GtkConstraintLayout-struct) in order to allocate and position each child widget.
The source and target widgets, as well as their attributes, of a [GtkConstraint](gtkconstraint#GtkConstraint-struct) instance are immutable after creation.
Functions
---------
### gtk\_constraint\_new ()
```
[GtkConstraint](gtkconstraint#GtkConstraint-struct) *
gtk_constraint_new (*`gpointer target`*,
*`[GtkConstraintAttribute](gtkconstraint#GtkConstraintAttribute) target_attribute`*,
*`[GtkConstraintRelation](gtkconstraint#GtkConstraintRelation) relation`*,
*`gpointer source`*,
*`[GtkConstraintAttribute](gtkconstraint#GtkConstraintAttribute) source_attribute`*,
*`double multiplier`*,
*`double constant`*,
*`int strength`*);
```
Creates a new [GtkConstraint](gtkconstraint#GtkConstraint-struct) representing a relation between a layout attribute on a source and a layout attribute on a target.
#### Parameters
| | | |
| --- | --- | --- |
| target | a [GtkConstraintTarget](gtkconstraint#GtkConstraintTarget-struct). | [nullable][type GtkConstraintTarget] |
| target\_attribute | the attribute of *`target`* to be set | |
| relation | the relation equivalence between *`target_attribute`* and *`source_attribute`* | |
| source | a [GtkConstraintTarget](gtkconstraint#GtkConstraintTarget-struct). | [nullable][type GtkConstraintTarget] |
| source\_attribute | the attribute of *`source`* to be read | |
| multiplier | a multiplication factor to be applied to *`source_attribute`* | |
| constant | a constant factor to be added to *`source_attribute`* | |
| strength | the strength of the constraint | |
#### Returns
the newly created [GtkConstraint](gtkconstraint#GtkConstraint-struct)
### gtk\_constraint\_new\_constant ()
```
[GtkConstraint](gtkconstraint#GtkConstraint-struct) *
gtk_constraint_new_constant (*`gpointer target`*,
*`[GtkConstraintAttribute](gtkconstraint#GtkConstraintAttribute) target_attribute`*,
*`[GtkConstraintRelation](gtkconstraint#GtkConstraintRelation) relation`*,
*`double constant`*,
*`int strength`*);
```
Creates a new [GtkConstraint](gtkconstraint#GtkConstraint-struct) representing a relation between a layout attribute on a target and a constant value.
#### Parameters
| | | |
| --- | --- | --- |
| target | a [GtkConstraintTarget](gtkconstraint#GtkConstraintTarget-struct). | [nullable][type GtkConstraintTarget] |
| target\_attribute | the attribute of *`target`* to be set | |
| relation | the relation equivalence between *`target_attribute`* and *`constant`* | |
| constant | a constant factor to be set on *`target_attribute`* | |
| strength | the strength of the constraint | |
#### Returns
the newly created [GtkConstraint](gtkconstraint#GtkConstraint-struct)
### gtk\_constraint\_get\_target ()
```
[GtkConstraintTarget](gtkconstraint#GtkConstraintTarget-struct) *
gtk_constraint_get_target (*`[GtkConstraint](gtkconstraint#GtkConstraint-struct) *constraint`*);
```
Retrieves the [GtkConstraintTarget](gtkconstraint#GtkConstraintTarget-struct) used as the target for *`constraint`* .
If the [“target”](gtkconstraint#GtkConstraint--target) property is set to `NULL`, the *`constraint`* will use the [GtkConstraintLayout](gtkconstraintlayout#GtkConstraintLayout-struct)'s widget.
#### Parameters
| | | |
| --- | --- | --- |
| constraint | a [GtkConstraint](gtkconstraint#GtkConstraint-struct) | |
#### Returns
a [GtkConstraintTarget](gtkconstraint#GtkConstraintTarget-struct).
[transfer none][nullable]
### gtk\_constraint\_get\_target\_attribute ()
```
[GtkConstraintAttribute](gtkconstraint#GtkConstraintAttribute)
gtk_constraint_get_target_attribute (*`[GtkConstraint](gtkconstraint#GtkConstraint-struct) *constraint`*);
```
Retrieves the attribute of the target to be set by the *`constraint`* .
#### Parameters
| | | |
| --- | --- | --- |
| constraint | a [GtkConstraint](gtkconstraint#GtkConstraint-struct) | |
#### Returns
the target's attribute
### gtk\_constraint\_get\_relation ()
```
[GtkConstraintRelation](gtkconstraint#GtkConstraintRelation)
gtk_constraint_get_relation (*`[GtkConstraint](gtkconstraint#GtkConstraint-struct) *constraint`*);
```
The order relation between the terms of the *`constraint`* .
#### Parameters
| | | |
| --- | --- | --- |
| constraint | a [GtkConstraint](gtkconstraint#GtkConstraint-struct) | |
#### Returns
a [GtkConstraintRelation](gtkconstraint#GtkConstraintRelation) value
### gtk\_constraint\_get\_source ()
```
[GtkConstraintTarget](gtkconstraint#GtkConstraintTarget-struct) *
gtk_constraint_get_source (*`[GtkConstraint](gtkconstraint#GtkConstraint-struct) *constraint`*);
```
Retrieves the [GtkConstraintTarget](gtkconstraint#GtkConstraintTarget-struct) used as the source for *`constraint`* .
If the [“source”](gtkconstraint#GtkConstraint--source) property is set to `NULL`, the *`constraint`* will use the [GtkConstraintLayout](gtkconstraintlayout#GtkConstraintLayout-struct)'s widget.
#### Parameters
| | | |
| --- | --- | --- |
| constraint | a [GtkConstraint](gtkconstraint#GtkConstraint-struct) | |
#### Returns
a [GtkConstraintTarget](gtkconstraint#GtkConstraintTarget-struct).
[transfer none][nullable]
### gtk\_constraint\_get\_source\_attribute ()
```
[GtkConstraintAttribute](gtkconstraint#GtkConstraintAttribute)
gtk_constraint_get_source_attribute (*`[GtkConstraint](gtkconstraint#GtkConstraint-struct) *constraint`*);
```
Retrieves the attribute of the source to be read by the *`constraint`* .
#### Parameters
| | | |
| --- | --- | --- |
| constraint | a [GtkConstraint](gtkconstraint#GtkConstraint-struct) | |
#### Returns
the target's attribute
### gtk\_constraint\_get\_multiplier ()
```
double
gtk_constraint_get_multiplier (*`[GtkConstraint](gtkconstraint#GtkConstraint-struct) *constraint`*);
```
Retrieves the multiplication factor applied to the source attribute's value.
#### Parameters
| | | |
| --- | --- | --- |
| constraint | a [GtkConstraint](gtkconstraint#GtkConstraint-struct) | |
#### Returns
a multiplication factor
### gtk\_constraint\_get\_constant ()
```
double
gtk_constraint_get_constant (*`[GtkConstraint](gtkconstraint#GtkConstraint-struct) *constraint`*);
```
Retrieves the constant factor added to the source attributes' value.
#### Parameters
| | | |
| --- | --- | --- |
| constraint | a [GtkConstraint](gtkconstraint#GtkConstraint-struct) | |
#### Returns
a constant factor
### gtk\_constraint\_get\_strength ()
```
int
gtk_constraint_get_strength (*`[GtkConstraint](gtkconstraint#GtkConstraint-struct) *constraint`*);
```
Retrieves the strength of the constraint.
#### Parameters
| | | |
| --- | --- | --- |
| constraint | a [GtkConstraint](gtkconstraint#GtkConstraint-struct) | |
#### Returns
the strength of the constraint
### gtk\_constraint\_is\_required ()
```
gboolean
gtk_constraint_is_required (*`[GtkConstraint](gtkconstraint#GtkConstraint-struct) *constraint`*);
```
Checks whether the *`constraint`* is a required relation for solving the constraint layout.
#### Parameters
| | | |
| --- | --- | --- |
| constraint | a [GtkConstraint](gtkconstraint#GtkConstraint-struct) | |
#### Returns
`TRUE` if the constraint is required
### gtk\_constraint\_is\_attached ()
```
gboolean
gtk_constraint_is_attached (*`[GtkConstraint](gtkconstraint#GtkConstraint-struct) *constraint`*);
```
Checks whether the *`constraint`* is attached to a [GtkConstraintLayout](gtkconstraintlayout#GtkConstraintLayout-struct), and it is contributing to the layout.
#### Parameters
| | | |
| --- | --- | --- |
| constraint | a [GtkConstraint](gtkconstraint#GtkConstraint-struct) | |
#### Returns
`TRUE` if the constraint is attached
### gtk\_constraint\_is\_constant ()
```
gboolean
gtk_constraint_is_constant (*`[GtkConstraint](gtkconstraint#GtkConstraint-struct) *constraint`*);
```
Checks whether the *`constraint`* describes a relation between an attribute on the [“target”](gtkconstraint#GtkConstraint--target) and a constant value.
#### Parameters
| | | |
| --- | --- | --- |
| constraint | a [GtkConstraint](gtkconstraint#GtkConstraint-struct) | |
#### Returns
`TRUE` if the constraint is a constant relation
Types and Values
----------------
### GtkConstraint
```
typedef struct _GtkConstraint GtkConstraint;
```
An object describing the relation between two widget attributes.
All relations are in the form:
```
target.attr1 = source.attr2 × multiplier + constant
```
| A [GtkConstraint](gtkconstraint#GtkConstraint-struct) is immutable once it's created.
### GtkConstraintTarget
```
typedef struct _GtkConstraintTarget GtkConstraintTarget;
```
The GtkConstraintTarget interface is implemented by objects that can be used as source or target in [GtkConstraints](gtkconstraint#GtkConstraint-struct). Besides [GtkWidget](gtkwidget#GtkWidget-struct), it is also implemented by [GtkConstraintGuide](gtkconstraintguide#GtkConstraintGuide-struct).
### enum GtkConstraintAttribute
The widget attributes that can be used when creating a [GtkConstraint](gtkconstraint#GtkConstraint-struct).
#### Members
| | | |
| --- | --- | --- |
| GTK\_CONSTRAINT\_ATTRIBUTE\_NONE | No attribute, used for constant relations | |
| GTK\_CONSTRAINT\_ATTRIBUTE\_LEFT | The left edge of a widget, regardless of text direction | |
| GTK\_CONSTRAINT\_ATTRIBUTE\_RIGHT | The right edge of a widget, regardless of text direction | |
| GTK\_CONSTRAINT\_ATTRIBUTE\_TOP | The top edge of a widget | |
| GTK\_CONSTRAINT\_ATTRIBUTE\_BOTTOM | The bottom edge of a widget | |
| GTK\_CONSTRAINT\_ATTRIBUTE\_START | The leading edge of a widget, depending on text direction; equivalent to [`GTK_CONSTRAINT_ATTRIBUTE_LEFT`](gtkconstraint#GTK-CONSTRAINT-ATTRIBUTE-LEFT:CAPS) for LTR languages, and [`GTK_CONSTRAINT_ATTRIBUTE_RIGHT`](gtkconstraint#GTK-CONSTRAINT-ATTRIBUTE-RIGHT:CAPS) for RTL ones | |
| GTK\_CONSTRAINT\_ATTRIBUTE\_END | The trailing edge of a widget, depending on text direction; equivalent to [`GTK_CONSTRAINT_ATTRIBUTE_RIGHT`](gtkconstraint#GTK-CONSTRAINT-ATTRIBUTE-RIGHT:CAPS) for LTR languages, and [`GTK_CONSTRAINT_ATTRIBUTE_LEFT`](gtkconstraint#GTK-CONSTRAINT-ATTRIBUTE-LEFT:CAPS) for RTL ones | |
| GTK\_CONSTRAINT\_ATTRIBUTE\_WIDTH | The width of a widget | |
| GTK\_CONSTRAINT\_ATTRIBUTE\_HEIGHT | The height of a widget | |
| GTK\_CONSTRAINT\_ATTRIBUTE\_CENTER\_X | The center of a widget, on the horizontal axis | |
| GTK\_CONSTRAINT\_ATTRIBUTE\_CENTER\_Y | The center of a widget, on the vertical axis | |
| GTK\_CONSTRAINT\_ATTRIBUTE\_BASELINE | The baseline of a widget | |
### enum GtkConstraintRelation
The relation between two terms of a constraint.
#### Members
| | | |
| --- | --- | --- |
| GTK\_CONSTRAINT\_RELATION\_LE | Less than, or equal | |
| GTK\_CONSTRAINT\_RELATION\_EQ | Equal | |
| GTK\_CONSTRAINT\_RELATION\_GE | Greater than, or equal | |
### enum GtkConstraintStrength
The strength of a constraint, expressed as a symbolic constant.
The strength of a [GtkConstraint](gtkconstraint#GtkConstraint-struct) can be expressed with any positive integer; the values of this enumeration can be used for readability.
#### Members
| | | |
| --- | --- | --- |
| GTK\_CONSTRAINT\_STRENGTH\_REQUIRED | The constraint is required towards solving the layout | |
| GTK\_CONSTRAINT\_STRENGTH\_STRONG | A strong constraint | |
| GTK\_CONSTRAINT\_STRENGTH\_MEDIUM | A medium constraint | |
| GTK\_CONSTRAINT\_STRENGTH\_WEAK | A weak constraint | |
Property Details
----------------
### The `“constant”` property
```
“constant” double
```
The constant value to be added to the [“source-attribute”](gtkconstraint#GtkConstraint--source-attribute).
Owner: GtkConstraint
Flags: Read / Write / Construct Only
Default value: 0
### The `“multiplier”` property
```
“multiplier” double
```
The multiplication factor to be applied to the [“source-attribute”](gtkconstraint#GtkConstraint--source-attribute).
Owner: GtkConstraint
Flags: Read / Write / Construct Only
Default value: 1
### The `“relation”` property
```
“relation” [GtkConstraintRelation](gtkconstraint#GtkConstraintRelation)
```
The order relation between the terms of the constraint.
Owner: GtkConstraint
Flags: Read / Write / Construct Only
Default value: GTK\_CONSTRAINT\_RELATION\_EQ
### The `“source”` property
```
“source” [GtkConstraintTarget](gtkconstraint#GtkConstraintTarget-struct) *
```
The source of the constraint.
The constraint will set the [“target-attribute”](gtkconstraint#GtkConstraint--target-attribute) of the target using the [“source-attribute”](gtkconstraint#GtkConstraint--source-attribute) of the source.
Owner: GtkConstraint
Flags: Read / Write / Construct Only
### The `“source-attribute”` property
```
“source-attribute” [GtkConstraintAttribute](gtkconstraint#GtkConstraintAttribute)
```
The attribute of the [“source”](gtkconstraint#GtkConstraint--source) read by the constraint.
Owner: GtkConstraint
Flags: Read / Write / Construct Only
Default value: GTK\_CONSTRAINT\_ATTRIBUTE\_NONE
### The `“strength”` property
```
“strength” int
```
The strength of the constraint.
The strength can be expressed either using one of the symbolic values of the [GtkConstraintStrength](gtkconstraint#GtkConstraintStrength) enumeration, or any positive integer value.
Owner: GtkConstraint
Flags: Read / Write / Construct Only
Allowed values: [0,1001001000]
Default value: 1001001000
### The `“target”` property
```
“target” [GtkConstraintTarget](gtkconstraint#GtkConstraintTarget-struct) *
```
The target of the constraint.
The constraint will set the [“target-attribute”](gtkconstraint#GtkConstraint--target-attribute) of the target using the [“source-attribute”](gtkconstraint#GtkConstraint--source-attribute) of the source widget.
Owner: GtkConstraint
Flags: Read / Write / Construct Only
### The `“target-attribute”` property
```
“target-attribute” [GtkConstraintAttribute](gtkconstraint#GtkConstraintAttribute)
```
The attribute of the [“target”](gtkconstraint#GtkConstraint--target) set by the constraint.
Owner: GtkConstraint
Flags: Read / Write / Construct Only
Default value: GTK\_CONSTRAINT\_ATTRIBUTE\_NONE
| programming_docs |
gtk GtkCustomSorter GtkCustomSorter
===============
GtkCustomSorter — Sorting with a callbacks
Functions
---------
| | |
| --- | --- |
| [GtkCustomSorter](gtkcustomsorter#GtkCustomSorter-struct) \* | [gtk\_custom\_sorter\_new](gtkcustomsorter#gtk-custom-sorter-new) () |
| void | [gtk\_custom\_sorter\_set\_sort\_func](gtkcustomsorter#gtk-custom-sorter-set-sort-func) () |
Types and Values
----------------
| | |
| --- | --- |
| | [GtkCustomSorter](gtkcustomsorter#GtkCustomSorter-struct) |
Object Hierarchy
----------------
```
GObject
╰── [GtkSorter](gtksorter#GtkSorter-struct)
╰── GtkCustomSorter
```
Includes
--------
```
#include <gtk/gtk.h>
```
Description
-----------
GtkCustomSorter is a [GtkSorter](gtksorter#GtkSorter-struct) implementation that sorts via a traditional GCompareDataFunc callback.
Functions
---------
### gtk\_custom\_sorter\_new ()
```
[GtkCustomSorter](gtkcustomsorter#GtkCustomSorter-struct) *
gtk_custom_sorter_new (*`GCompareDataFunc sort_func`*,
*`gpointer user_data`*,
*`GDestroyNotify user_destroy`*);
```
Creates a new [GtkSorter](gtksorter#GtkSorter-struct) that works by calling *`sort_func`* to compare items.
If *`sort_func`* is `NULL`, all items are considered equal.
#### Parameters
| | | |
| --- | --- | --- |
| sort\_func | the GCompareDataFunc to use for sorting. | [nullable] |
| user\_data | user data to pass to *`sort_func`* . | [nullable] |
| user\_destroy | destroy notify for *`user_data`* . | [nullable] |
#### Returns
a new [GtkCustomSorter](gtkcustomsorter#GtkCustomSorter-struct)
### gtk\_custom\_sorter\_set\_sort\_func ()
```
void
gtk_custom_sorter_set_sort_func (*`[GtkCustomSorter](gtkcustomsorter#GtkCustomSorter-struct) *self`*,
*`GCompareDataFunc sort_func`*,
*`gpointer user_data`*,
*`GDestroyNotify user_destroy`*);
```
Sets (or unsets) the function used for sorting items.
If *`sort_func`* is `NULL`, all items are considered equal.
If the sort func changes its sorting behavior, [`gtk_sorter_changed()`](gtksorter#gtk-sorter-changed) needs to be called.
If a previous function was set, its *`user_destroy`* will be called now.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkCustomSorter](gtkcustomsorter#GtkCustomSorter-struct) | |
| sort\_func | function to sort items. | [nullable] |
| user\_data | user data to pass to *`match_func`* . | [nullable] |
| user\_destroy | destroy notify for *`user_data`* | |
Types and Values
----------------
### GtkCustomSorter
```
typedef struct _GtkCustomSorter GtkCustomSorter;
```
gtk GtkAboutDialog GtkAboutDialog
==============
GtkAboutDialog — Display information about an application
Functions
---------
| | |
| --- | --- |
| [GtkWidget](gtkwidget#GtkWidget-struct) \* | [gtk\_about\_dialog\_new](gtkaboutdialog#gtk-about-dialog-new) () |
| const char \* | [gtk\_about\_dialog\_get\_program\_name](gtkaboutdialog#gtk-about-dialog-get-program-name) () |
| void | [gtk\_about\_dialog\_set\_program\_name](gtkaboutdialog#gtk-about-dialog-set-program-name) () |
| const char \* | [gtk\_about\_dialog\_get\_version](gtkaboutdialog#gtk-about-dialog-get-version) () |
| void | [gtk\_about\_dialog\_set\_version](gtkaboutdialog#gtk-about-dialog-set-version) () |
| const char \* | [gtk\_about\_dialog\_get\_copyright](gtkaboutdialog#gtk-about-dialog-get-copyright) () |
| void | [gtk\_about\_dialog\_set\_copyright](gtkaboutdialog#gtk-about-dialog-set-copyright) () |
| const char \* | [gtk\_about\_dialog\_get\_comments](gtkaboutdialog#gtk-about-dialog-get-comments) () |
| void | [gtk\_about\_dialog\_set\_comments](gtkaboutdialog#gtk-about-dialog-set-comments) () |
| const char \* | [gtk\_about\_dialog\_get\_license](gtkaboutdialog#gtk-about-dialog-get-license) () |
| void | [gtk\_about\_dialog\_set\_license](gtkaboutdialog#gtk-about-dialog-set-license) () |
| gboolean | [gtk\_about\_dialog\_get\_wrap\_license](gtkaboutdialog#gtk-about-dialog-get-wrap-license) () |
| void | [gtk\_about\_dialog\_set\_wrap\_license](gtkaboutdialog#gtk-about-dialog-set-wrap-license) () |
| [GtkLicense](gtkaboutdialog#GtkLicense) | [gtk\_about\_dialog\_get\_license\_type](gtkaboutdialog#gtk-about-dialog-get-license-type) () |
| void | [gtk\_about\_dialog\_set\_license\_type](gtkaboutdialog#gtk-about-dialog-set-license-type) () |
| const char \* | [gtk\_about\_dialog\_get\_website](gtkaboutdialog#gtk-about-dialog-get-website) () |
| void | [gtk\_about\_dialog\_set\_website](gtkaboutdialog#gtk-about-dialog-set-website) () |
| const char \* | [gtk\_about\_dialog\_get\_website\_label](gtkaboutdialog#gtk-about-dialog-get-website-label) () |
| void | [gtk\_about\_dialog\_set\_website\_label](gtkaboutdialog#gtk-about-dialog-set-website-label) () |
| const char \* const \* | [gtk\_about\_dialog\_get\_authors](gtkaboutdialog#gtk-about-dialog-get-authors) () |
| void | [gtk\_about\_dialog\_set\_authors](gtkaboutdialog#gtk-about-dialog-set-authors) () |
| const char \* const \* | [gtk\_about\_dialog\_get\_artists](gtkaboutdialog#gtk-about-dialog-get-artists) () |
| void | [gtk\_about\_dialog\_set\_artists](gtkaboutdialog#gtk-about-dialog-set-artists) () |
| const char \* const \* | [gtk\_about\_dialog\_get\_documenters](gtkaboutdialog#gtk-about-dialog-get-documenters) () |
| void | [gtk\_about\_dialog\_set\_documenters](gtkaboutdialog#gtk-about-dialog-set-documenters) () |
| const char \* | [gtk\_about\_dialog\_get\_translator\_credits](gtkaboutdialog#gtk-about-dialog-get-translator-credits) () |
| void | [gtk\_about\_dialog\_set\_translator\_credits](gtkaboutdialog#gtk-about-dialog-set-translator-credits) () |
| [GdkPaintable](https://developer-old.gnome.org/gtk4/html/GdkPaintable.html#GdkPaintable-struct) \* | [gtk\_about\_dialog\_get\_logo](gtkaboutdialog#gtk-about-dialog-get-logo) () |
| void | [gtk\_about\_dialog\_set\_logo](gtkaboutdialog#gtk-about-dialog-set-logo) () |
| const char \* | [gtk\_about\_dialog\_get\_logo\_icon\_name](gtkaboutdialog#gtk-about-dialog-get-logo-icon-name) () |
| void | [gtk\_about\_dialog\_set\_logo\_icon\_name](gtkaboutdialog#gtk-about-dialog-set-logo-icon-name) () |
| const char \* | [gtk\_about\_dialog\_get\_system\_information](gtkaboutdialog#gtk-about-dialog-get-system-information) () |
| void | [gtk\_about\_dialog\_set\_system\_information](gtkaboutdialog#gtk-about-dialog-set-system-information) () |
| void | [gtk\_about\_dialog\_add\_credit\_section](gtkaboutdialog#gtk-about-dialog-add-credit-section) () |
| void | [gtk\_show\_about\_dialog](gtkaboutdialog#gtk-show-about-dialog) () |
Properties
----------
| | | |
| --- | --- | --- |
| GStrv | [artists](gtkaboutdialog#GtkAboutDialog--artists) | Read / Write |
| GStrv | [authors](gtkaboutdialog#GtkAboutDialog--authors) | Read / Write |
| char \* | [comments](gtkaboutdialog#GtkAboutDialog--comments) | Read / Write |
| char \* | [copyright](gtkaboutdialog#GtkAboutDialog--copyright) | Read / Write |
| GStrv | [documenters](gtkaboutdialog#GtkAboutDialog--documenters) | Read / Write |
| char \* | [license](gtkaboutdialog#GtkAboutDialog--license) | Read / Write |
| [GtkLicense](gtkaboutdialog#GtkLicense) | [license-type](gtkaboutdialog#GtkAboutDialog--license-type) | Read / Write |
| [GdkPaintable](https://developer-old.gnome.org/gtk4/html/GdkPaintable.html#GdkPaintable-struct) \* | [logo](gtkaboutdialog#GtkAboutDialog--logo) | Read / Write |
| char \* | [logo-icon-name](gtkaboutdialog#GtkAboutDialog--logo-icon-name) | Read / Write |
| char \* | [program-name](gtkaboutdialog#GtkAboutDialog--program-name) | Read / Write |
| char \* | [system-information](gtkaboutdialog#GtkAboutDialog--system-information) | Read / Write |
| char \* | [translator-credits](gtkaboutdialog#GtkAboutDialog--translator-credits) | Read / Write |
| char \* | [version](gtkaboutdialog#GtkAboutDialog--version) | Read / Write |
| char \* | [website](gtkaboutdialog#GtkAboutDialog--website) | Read / Write |
| char \* | [website-label](gtkaboutdialog#GtkAboutDialog--website-label) | Read / Write |
| gboolean | [wrap-license](gtkaboutdialog#GtkAboutDialog--wrap-license) | Read / Write |
Signals
-------
| | | |
| --- | --- | --- |
| gboolean | [activate-link](gtkaboutdialog#GtkAboutDialog-activate-link) | Run Last |
Types and Values
----------------
| | |
| --- | --- |
| | [GtkAboutDialog](gtkaboutdialog#GtkAboutDialog-struct) |
| enum | [GtkLicense](gtkaboutdialog#GtkLicense) |
Object Hierarchy
----------------
```
GObject
╰── GInitiallyUnowned
╰── [GtkWidget](gtkwidget#GtkWidget-struct)
╰── [GtkWindow](gtkwindow#GtkWindow-struct)
╰── GtkAboutDialog
```
Implemented Interfaces
----------------------
GtkAboutDialog implements [GtkAccessible](gtkaccessible#GtkAccessible-struct), [GtkBuildable](gtkbuildable#GtkBuildable-struct), [GtkConstraintTarget](gtkconstraint#GtkConstraintTarget-struct), [GtkNative](gtknative#GtkNative-struct), [GtkShortcutManager](gtkshortcutmanager#GtkShortcutManager-struct) and [GtkRoot](gtkroot#GtkRoot-struct).
Includes
--------
```
#include <gtk/gtk.h>
```
Description
-----------
The GtkAboutDialog offers a simple way to display information about a program like its logo, name, copyright, website and license. It is also possible to give credits to the authors, documenters, translators and artists who have worked on the program. An about dialog is typically opened when the user selects the `About` option from the `Help` menu. All parts of the dialog are optional.
About dialogs often contain links and email addresses. GtkAboutDialog displays these as clickable links. By default, it calls [`gtk_show_uri()`](gtk4-filesystem-utilities#gtk-show-uri) when a user clicks one. The behaviour can be overridden with the [“activate-link”](gtkaboutdialog#GtkAboutDialog-activate-link) signal.
To specify a person with an email address, use a string like "Edgar Allan Poe <[email protected]>". To specify a website with a title, use a string like "GTK team http://www.gtk.org".
To make constructing a GtkAboutDialog as convenient as possible, you can use the function [`gtk_show_about_dialog()`](gtkaboutdialog#gtk-show-about-dialog) which constructs and shows a dialog and keeps it around so that it can be shown again.
Note that GTK sets a default title of `_("About %s")` on the dialog window (where %s is replaced by the name of the application, but in order to ensure proper translation of the title, applications should set the title property explicitly when constructing a GtkAboutDialog, as shown in the following example:
### CSS nodes
GtkAboutDialog has a single CSS node with the name window and style class .aboutdialog.
Functions
---------
### gtk\_about\_dialog\_new ()
```
[GtkWidget](gtkwidget#GtkWidget-struct) *
gtk_about_dialog_new (*`void`*);
```
Creates a new [GtkAboutDialog](gtkaboutdialog#GtkAboutDialog-struct).
#### Returns
a newly created [GtkAboutDialog](gtkaboutdialog#GtkAboutDialog-struct)
### gtk\_about\_dialog\_get\_program\_name ()
```
const char *
gtk_about_dialog_get_program_name (*`[GtkAboutDialog](gtkaboutdialog#GtkAboutDialog-struct) *about`*);
```
Returns the program name displayed in the about dialog.
#### Parameters
| | | |
| --- | --- | --- |
| about | a [GtkAboutDialog](gtkaboutdialog#GtkAboutDialog-struct) | |
#### Returns
The program name. The string is owned by the about dialog and must not be modified.
[nullable]
### gtk\_about\_dialog\_set\_program\_name ()
```
void
gtk_about_dialog_set_program_name (*`[GtkAboutDialog](gtkaboutdialog#GtkAboutDialog-struct) *about`*,
*`const char *name`*);
```
Sets the name to display in the about dialog. If this is not set, it defaults to `g_get_application_name()`.
#### Parameters
| | | |
| --- | --- | --- |
| about | a [GtkAboutDialog](gtkaboutdialog#GtkAboutDialog-struct) | |
| name | the program name | |
### gtk\_about\_dialog\_get\_version ()
```
const char *
gtk_about_dialog_get_version (*`[GtkAboutDialog](gtkaboutdialog#GtkAboutDialog-struct) *about`*);
```
Returns the version string.
#### Parameters
| | | |
| --- | --- | --- |
| about | a [GtkAboutDialog](gtkaboutdialog#GtkAboutDialog-struct) | |
#### Returns
The version string. The string is owned by the about dialog and must not be modified.
[nullable]
### gtk\_about\_dialog\_set\_version ()
```
void
gtk_about_dialog_set_version (*`[GtkAboutDialog](gtkaboutdialog#GtkAboutDialog-struct) *about`*,
*`const char *version`*);
```
Sets the version string to display in the about dialog.
#### Parameters
| | | |
| --- | --- | --- |
| about | a [GtkAboutDialog](gtkaboutdialog#GtkAboutDialog-struct) | |
| version | the version string. | [allow-none] |
### gtk\_about\_dialog\_get\_copyright ()
```
const char *
gtk_about_dialog_get_copyright (*`[GtkAboutDialog](gtkaboutdialog#GtkAboutDialog-struct) *about`*);
```
Returns the copyright string.
#### Parameters
| | | |
| --- | --- | --- |
| about | a [GtkAboutDialog](gtkaboutdialog#GtkAboutDialog-struct) | |
#### Returns
The copyright string. The string is owned by the about dialog and must not be modified.
[nullable]
### gtk\_about\_dialog\_set\_copyright ()
```
void
gtk_about_dialog_set_copyright (*`[GtkAboutDialog](gtkaboutdialog#GtkAboutDialog-struct) *about`*,
*`const char *copyright`*);
```
Sets the copyright string to display in the about dialog. This should be a short string of one or two lines.
#### Parameters
| | | |
| --- | --- | --- |
| about | a [GtkAboutDialog](gtkaboutdialog#GtkAboutDialog-struct) | |
| copyright | the copyright string. | [allow-none] |
### gtk\_about\_dialog\_get\_comments ()
```
const char *
gtk_about_dialog_get_comments (*`[GtkAboutDialog](gtkaboutdialog#GtkAboutDialog-struct) *about`*);
```
Returns the comments string.
#### Parameters
| | | |
| --- | --- | --- |
| about | a [GtkAboutDialog](gtkaboutdialog#GtkAboutDialog-struct) | |
#### Returns
The comments. The string is owned by the about dialog and must not be modified.
[nullable]
### gtk\_about\_dialog\_set\_comments ()
```
void
gtk_about_dialog_set_comments (*`[GtkAboutDialog](gtkaboutdialog#GtkAboutDialog-struct) *about`*,
*`const char *comments`*);
```
Sets the comments string to display in the about dialog. This should be a short string of one or two lines.
#### Parameters
| | | |
| --- | --- | --- |
| about | a [GtkAboutDialog](gtkaboutdialog#GtkAboutDialog-struct) | |
| comments | a comments string. | [allow-none] |
### gtk\_about\_dialog\_get\_license ()
```
const char *
gtk_about_dialog_get_license (*`[GtkAboutDialog](gtkaboutdialog#GtkAboutDialog-struct) *about`*);
```
Returns the license information.
#### Parameters
| | | |
| --- | --- | --- |
| about | a [GtkAboutDialog](gtkaboutdialog#GtkAboutDialog-struct) | |
#### Returns
The license information. The string is owned by the about dialog and must not be modified.
[nullable]
### gtk\_about\_dialog\_set\_license ()
```
void
gtk_about_dialog_set_license (*`[GtkAboutDialog](gtkaboutdialog#GtkAboutDialog-struct) *about`*,
*`const char *license`*);
```
Sets the license information to be displayed in the secondary license dialog. If *`license`* is `NULL`, the license button is hidden.
#### Parameters
| | | |
| --- | --- | --- |
| about | a [GtkAboutDialog](gtkaboutdialog#GtkAboutDialog-struct) | |
| license | the license information or `NULL`. | [allow-none] |
### gtk\_about\_dialog\_get\_wrap\_license ()
```
gboolean
gtk_about_dialog_get_wrap_license (*`[GtkAboutDialog](gtkaboutdialog#GtkAboutDialog-struct) *about`*);
```
Returns whether the license text in *`about`* is automatically wrapped.
#### Parameters
| | | |
| --- | --- | --- |
| about | a [GtkAboutDialog](gtkaboutdialog#GtkAboutDialog-struct) | |
#### Returns
`TRUE` if the license text is wrapped
### gtk\_about\_dialog\_set\_wrap\_license ()
```
void
gtk_about_dialog_set_wrap_license (*`[GtkAboutDialog](gtkaboutdialog#GtkAboutDialog-struct) *about`*,
*`gboolean wrap_license`*);
```
Sets whether the license text in *`about`* is automatically wrapped.
#### Parameters
| | | |
| --- | --- | --- |
| about | a [GtkAboutDialog](gtkaboutdialog#GtkAboutDialog-struct) | |
| wrap\_license | whether to wrap the license | |
### gtk\_about\_dialog\_get\_license\_type ()
```
[GtkLicense](gtkaboutdialog#GtkLicense)
gtk_about_dialog_get_license_type (*`[GtkAboutDialog](gtkaboutdialog#GtkAboutDialog-struct) *about`*);
```
Retrieves the license set using [`gtk_about_dialog_set_license_type()`](gtkaboutdialog#gtk-about-dialog-set-license-type)
#### Parameters
| | | |
| --- | --- | --- |
| about | a [GtkAboutDialog](gtkaboutdialog#GtkAboutDialog-struct) | |
#### Returns
a [GtkLicense](gtkaboutdialog#GtkLicense) value
### gtk\_about\_dialog\_set\_license\_type ()
```
void
gtk_about_dialog_set_license_type (*`[GtkAboutDialog](gtkaboutdialog#GtkAboutDialog-struct) *about`*,
*`[GtkLicense](gtkaboutdialog#GtkLicense) license_type`*);
```
Sets the license of the application showing the *`about`* dialog from a list of known licenses.
This function overrides the license set using [`gtk_about_dialog_set_license()`](gtkaboutdialog#gtk-about-dialog-set-license).
#### Parameters
| | | |
| --- | --- | --- |
| about | a [GtkAboutDialog](gtkaboutdialog#GtkAboutDialog-struct) | |
| license\_type | the type of license | |
### gtk\_about\_dialog\_get\_website ()
```
const char *
gtk_about_dialog_get_website (*`[GtkAboutDialog](gtkaboutdialog#GtkAboutDialog-struct) *about`*);
```
Returns the website URL.
#### Parameters
| | | |
| --- | --- | --- |
| about | a [GtkAboutDialog](gtkaboutdialog#GtkAboutDialog-struct) | |
#### Returns
The website URL. The string is owned by the about dialog and must not be modified.
[nullable]
### gtk\_about\_dialog\_set\_website ()
```
void
gtk_about_dialog_set_website (*`[GtkAboutDialog](gtkaboutdialog#GtkAboutDialog-struct) *about`*,
*`const char *website`*);
```
Sets the URL to use for the website link.
#### Parameters
| | | |
| --- | --- | --- |
| about | a [GtkAboutDialog](gtkaboutdialog#GtkAboutDialog-struct) | |
| website | a URL string starting with "http://". | [allow-none] |
### gtk\_about\_dialog\_get\_website\_label ()
```
const char *
gtk_about_dialog_get_website_label (*`[GtkAboutDialog](gtkaboutdialog#GtkAboutDialog-struct) *about`*);
```
Returns the label used for the website link.
#### Parameters
| | | |
| --- | --- | --- |
| about | a [GtkAboutDialog](gtkaboutdialog#GtkAboutDialog-struct) | |
#### Returns
The label used for the website link. The string is owned by the about dialog and must not be modified.
[nullable]
### gtk\_about\_dialog\_set\_website\_label ()
```
void
gtk_about_dialog_set_website_label (*`[GtkAboutDialog](gtkaboutdialog#GtkAboutDialog-struct) *about`*,
*`const char *website_label`*);
```
Sets the label to be used for the website link.
#### Parameters
| | | |
| --- | --- | --- |
| about | a [GtkAboutDialog](gtkaboutdialog#GtkAboutDialog-struct) | |
| website\_label | the label used for the website link | |
### gtk\_about\_dialog\_get\_authors ()
```
const char * const *
gtk_about_dialog_get_authors (*`[GtkAboutDialog](gtkaboutdialog#GtkAboutDialog-struct) *about`*);
```
Returns the string which are displayed in the authors tab of the secondary credits dialog.
#### Parameters
| | | |
| --- | --- | --- |
| about | a [GtkAboutDialog](gtkaboutdialog#GtkAboutDialog-struct) | |
#### Returns
A `NULL`-terminated string array containing the authors. The array is owned by the about dialog and must not be modified.
[array zero-terminated=1][transfer none]
### gtk\_about\_dialog\_set\_authors ()
```
void
gtk_about_dialog_set_authors (*`[GtkAboutDialog](gtkaboutdialog#GtkAboutDialog-struct) *about`*,
*`const char **authors`*);
```
Sets the strings which are displayed in the authors tab of the secondary credits dialog.
#### Parameters
| | | |
| --- | --- | --- |
| about | a [GtkAboutDialog](gtkaboutdialog#GtkAboutDialog-struct) | |
| authors | a `NULL`-terminated array of strings. | [array zero-terminated=1] |
### gtk\_about\_dialog\_get\_artists ()
```
const char * const *
gtk_about_dialog_get_artists (*`[GtkAboutDialog](gtkaboutdialog#GtkAboutDialog-struct) *about`*);
```
Returns the string which are displayed in the artists tab of the secondary credits dialog.
#### Parameters
| | | |
| --- | --- | --- |
| about | a [GtkAboutDialog](gtkaboutdialog#GtkAboutDialog-struct) | |
#### Returns
A `NULL`-terminated string array containing the artists. The array is owned by the about dialog and must not be modified.
[array zero-terminated=1][transfer none]
### gtk\_about\_dialog\_set\_artists ()
```
void
gtk_about_dialog_set_artists (*`[GtkAboutDialog](gtkaboutdialog#GtkAboutDialog-struct) *about`*,
*`const char **artists`*);
```
Sets the strings which are displayed in the artists tab of the secondary credits dialog.
#### Parameters
| | | |
| --- | --- | --- |
| about | a [GtkAboutDialog](gtkaboutdialog#GtkAboutDialog-struct) | |
| artists | a `NULL`-terminated array of strings. | [array zero-terminated=1] |
### gtk\_about\_dialog\_get\_documenters ()
```
const char * const *
gtk_about_dialog_get_documenters (*`[GtkAboutDialog](gtkaboutdialog#GtkAboutDialog-struct) *about`*);
```
Returns the string which are displayed in the documenters tab of the secondary credits dialog.
#### Parameters
| | | |
| --- | --- | --- |
| about | a [GtkAboutDialog](gtkaboutdialog#GtkAboutDialog-struct) | |
#### Returns
A `NULL`-terminated string array containing the documenters. The array is owned by the about dialog and must not be modified.
[array zero-terminated=1][transfer none]
### gtk\_about\_dialog\_set\_documenters ()
```
void
gtk_about_dialog_set_documenters (*`[GtkAboutDialog](gtkaboutdialog#GtkAboutDialog-struct) *about`*,
*`const char **documenters`*);
```
Sets the strings which are displayed in the documenters tab of the credits dialog.
#### Parameters
| | | |
| --- | --- | --- |
| about | a [GtkAboutDialog](gtkaboutdialog#GtkAboutDialog-struct) | |
| documenters | a `NULL`-terminated array of strings. | [array zero-terminated=1] |
### gtk\_about\_dialog\_get\_translator\_credits ()
```
const char *
gtk_about_dialog_get_translator_credits
(*`[GtkAboutDialog](gtkaboutdialog#GtkAboutDialog-struct) *about`*);
```
Returns the translator credits string which is displayed in the translators tab of the secondary credits dialog.
#### Parameters
| | | |
| --- | --- | --- |
| about | a [GtkAboutDialog](gtkaboutdialog#GtkAboutDialog-struct) | |
#### Returns
The translator credits string. The string is owned by the about dialog and must not be modified.
[nullable]
### gtk\_about\_dialog\_set\_translator\_credits ()
```
void
gtk_about_dialog_set_translator_credits
(*`[GtkAboutDialog](gtkaboutdialog#GtkAboutDialog-struct) *about`*,
*`const char *translator_credits`*);
```
Sets the translator credits string which is displayed in the translators tab of the secondary credits dialog.
The intended use for this string is to display the translator of the language which is currently used in the user interface. Using `gettext()`, a simple way to achieve that is to mark the string for translation:
```
GFile *logo_file = g_file_new_for_path ("./logo.png");
GdkTexture *example_logo = gdk_texture_new_from_file (logo_file, NULL);
g_object_unref (logo_file);
gtk_show_about_dialog (NULL,
"program-name", "ExampleCode",
"logo", example_logo,
"title", _("About ExampleCode"),
NULL);
```
| It is a good idea to use the customary msgid “translator-credits” for this purpose, since translators will already know the purpose of that msgid, and since [GtkAboutDialog](gtkaboutdialog#GtkAboutDialog-struct) will detect if “translator-credits” is untranslated and hide the tab.
#### Parameters
| | | |
| --- | --- | --- |
| about | a [GtkAboutDialog](gtkaboutdialog#GtkAboutDialog-struct) | |
| translator\_credits | the translator credits. | [allow-none] |
### gtk\_about\_dialog\_get\_logo ()
```
[GdkPaintable](https://developer-old.gnome.org/gtk4/html/GdkPaintable.html#GdkPaintable-struct) *
gtk_about_dialog_get_logo (*`[GtkAboutDialog](gtkaboutdialog#GtkAboutDialog-struct) *about`*);
```
Returns the paintable displayed as logo in the about dialog.
#### Parameters
| | | |
| --- | --- | --- |
| about | a [GtkAboutDialog](gtkaboutdialog#GtkAboutDialog-struct) | |
#### Returns
the paintable displayed as logo or `NULL` if the logo is unset or has been set via [`gtk_about_dialog_set_logo_icon_name()`](gtkaboutdialog#gtk-about-dialog-set-logo-icon-name). The paintable is owned by the about dialog. If you want to keep a reference to it, you have to call `g_object_ref()` on it.
[transfer none][nullable]
### gtk\_about\_dialog\_set\_logo ()
```
void
gtk_about_dialog_set_logo (*`[GtkAboutDialog](gtkaboutdialog#GtkAboutDialog-struct) *about`*,
*`[GdkPaintable](https://developer-old.gnome.org/gtk4/html/GdkPaintable.html#GdkPaintable-struct) *logo`*);
```
Sets the logo in the about dialog.
#### Parameters
| | | |
| --- | --- | --- |
| about | a [GtkAboutDialog](gtkaboutdialog#GtkAboutDialog-struct) | |
| logo | a [GdkPaintable](https://developer-old.gnome.org/gtk4/html/GdkPaintable.html#GdkPaintable-struct), or `NULL`. | [allow-none] |
### gtk\_about\_dialog\_get\_logo\_icon\_name ()
```
const char *
gtk_about_dialog_get_logo_icon_name (*`[GtkAboutDialog](gtkaboutdialog#GtkAboutDialog-struct) *about`*);
```
Returns the icon name displayed as logo in the about dialog.
#### Parameters
| | | |
| --- | --- | --- |
| about | a [GtkAboutDialog](gtkaboutdialog#GtkAboutDialog-struct) | |
#### Returns
the icon name displayed as logo or `NULL` if the logo has been set via [`gtk_about_dialog_set_logo()`](gtkaboutdialog#gtk-about-dialog-set-logo). The string is owned by the dialog. If you want to keep a reference to it, you have to call `g_strdup()` on it.
[transfer none][nullable]
### gtk\_about\_dialog\_set\_logo\_icon\_name ()
```
void
gtk_about_dialog_set_logo_icon_name (*`[GtkAboutDialog](gtkaboutdialog#GtkAboutDialog-struct) *about`*,
*`const char *icon_name`*);
```
Sets the icon name to be displayed as logo in the about dialog.
#### Parameters
| | | |
| --- | --- | --- |
| about | a [GtkAboutDialog](gtkaboutdialog#GtkAboutDialog-struct) | |
| icon\_name | an icon name, or `NULL`. | [allow-none] |
### gtk\_about\_dialog\_get\_system\_information ()
```
const char *
gtk_about_dialog_get_system_information
(*`[GtkAboutDialog](gtkaboutdialog#GtkAboutDialog-struct) *about`*);
```
Returns the system information that is shown in the about dialog.
#### Parameters
| | | |
| --- | --- | --- |
| about | a [GtkAboutDialog](gtkaboutdialog#GtkAboutDialog-struct) | |
#### Returns
the system information.
[nullable]
### gtk\_about\_dialog\_set\_system\_information ()
```
void
gtk_about_dialog_set_system_information
(*`[GtkAboutDialog](gtkaboutdialog#GtkAboutDialog-struct) *about`*,
*`const char *system_information`*);
```
Sets the system information to be displayed in the about dialog. If *`system_information`* is `NULL`, the system information tab is hidden.
See [“system-information”](gtkaboutdialog#GtkAboutDialog--system-information).
#### Parameters
| | | |
| --- | --- | --- |
| about | a [GtkAboutDialog](gtkaboutdialog#GtkAboutDialog-struct) | |
| system\_information | system information or `NULL`. | [allow-none] |
### gtk\_about\_dialog\_add\_credit\_section ()
```
void
gtk_about_dialog_add_credit_section (*`[GtkAboutDialog](gtkaboutdialog#GtkAboutDialog-struct) *about`*,
*`const char *section_name`*,
*`const char **people`*);
```
Creates a new section in the Credits page.
#### Parameters
| | | |
| --- | --- | --- |
| about | A [GtkAboutDialog](gtkaboutdialog#GtkAboutDialog-struct) | |
| section\_name | The name of the section | |
| people | The people who belong to that section. | [array zero-terminated=1] |
### gtk\_show\_about\_dialog ()
```
void
gtk_show_about_dialog (*`[GtkWindow](gtkwindow#GtkWindow-struct) *parent`*,
*`const char *first_property_name`*,
*`...`*);
```
This is a convenience function for showing an application’s about box. The constructed dialog is associated with the parent window and reused for future invocations of this function.
#### Parameters
| | | |
| --- | --- | --- |
| parent | transient parent, or `NULL` for none. | [allow-none] |
| first\_property\_name | the name of the first property | |
| ... | value of first property, followed by more properties, `NULL`-terminated | |
Types and Values
----------------
### GtkAboutDialog
```
typedef struct _GtkAboutDialog GtkAboutDialog;
```
### enum GtkLicense
The type of license for an application.
This enumeration can be expanded at later date.
#### Members
| | | |
| --- | --- | --- |
| GTK\_LICENSE\_UNKNOWN | No license specified | |
| GTK\_LICENSE\_CUSTOM | A license text is going to be specified by the developer | |
| GTK\_LICENSE\_GPL\_2\_0 | The GNU General Public License, version 2.0 or later | |
| GTK\_LICENSE\_GPL\_3\_0 | The GNU General Public License, version 3.0 or later | |
| GTK\_LICENSE\_LGPL\_2\_1 | The GNU Lesser General Public License, version 2.1 or later | |
| GTK\_LICENSE\_LGPL\_3\_0 | The GNU Lesser General Public License, version 3.0 or later | |
| GTK\_LICENSE\_BSD | The BSD standard license | |
| GTK\_LICENSE\_MIT\_X11 | The MIT/X11 standard license | |
| GTK\_LICENSE\_ARTISTIC | The Artistic License, version 2.0 | |
| GTK\_LICENSE\_GPL\_2\_0\_ONLY | The GNU General Public License, version 2.0 only | |
| GTK\_LICENSE\_GPL\_3\_0\_ONLY | The GNU General Public License, version 3.0 only | |
| GTK\_LICENSE\_LGPL\_2\_1\_ONLY | The GNU Lesser General Public License, version 2.1 only | |
| GTK\_LICENSE\_LGPL\_3\_0\_ONLY | The GNU Lesser General Public License, version 3.0 only | |
| GTK\_LICENSE\_AGPL\_3\_0 | The GNU Affero General Public License, version 3.0 or later | |
| GTK\_LICENSE\_AGPL\_3\_0\_ONLY | The GNU Affero General Public License, version 3.0 only | |
| GTK\_LICENSE\_BSD\_3 | The 3-clause BSD licence | |
| GTK\_LICENSE\_APACHE\_2\_0 | The Apache License, version 2.0 | |
| GTK\_LICENSE\_MPL\_2\_0 | The Mozilla Public License, version 2.0 | |
Property Details
----------------
### The `“artists”` property
```
“artists” GStrv
```
The people who contributed artwork to the program, as a `NULL`-terminated array of strings. Each string may contain email addresses and URLs, which will be displayed as links, see the introduction for more details.
Owner: GtkAboutDialog
Flags: Read / Write
### The `“authors”` property
```
“authors” GStrv
```
The authors of the program, as a `NULL`-terminated array of strings. Each string may contain email addresses and URLs, which will be displayed as links, see the introduction for more details.
Owner: GtkAboutDialog
Flags: Read / Write
### The `“comments”` property
```
“comments” char *
```
Comments about the program. This string is displayed in a label in the main dialog, thus it should be a short explanation of the main purpose of the program, not a detailed list of features.
Owner: GtkAboutDialog
Flags: Read / Write
Default value: NULL
### The `“copyright”` property
```
“copyright” char *
```
Copyright information for the program.
Owner: GtkAboutDialog
Flags: Read / Write
Default value: NULL
### The `“documenters”` property
```
“documenters” GStrv
```
The people documenting the program, as a `NULL`-terminated array of strings. Each string may contain email addresses and URLs, which will be displayed as links, see the introduction for more details.
Owner: GtkAboutDialog
Flags: Read / Write
### The `“license”` property
```
“license” char *
```
The license of the program. This string is displayed in a text view in a secondary dialog, therefore it is fine to use a long multi-paragraph text. Note that the text is only wrapped in the text view if the "wrap-license" property is set to `TRUE`; otherwise the text itself must contain the intended linebreaks. When setting this property to a non-`NULL` value, the [“license-type”](gtkaboutdialog#GtkAboutDialog--license-type) property is set to [`GTK_LICENSE_CUSTOM`](gtkaboutdialog#GTK-LICENSE-CUSTOM:CAPS) as a side effect.
The text may contain links in this format <http://www.some.place/> and email references in the form <mail-to*`some.body`* >, and these will be converted into clickable links.
Owner: GtkAboutDialog
Flags: Read / Write
Default value: NULL
### The `“license-type”` property
```
“license-type” [GtkLicense](gtkaboutdialog#GtkLicense)
```
The license of the program, as a value of the [`GtkLicense`](gtkaboutdialog#GtkLicense) enumeration.
The [GtkAboutDialog](gtkaboutdialog#GtkAboutDialog-struct) will automatically fill out a standard disclaimer and link the user to the appropriate online resource for the license text.
If [`GTK_LICENSE_UNKNOWN`](gtkaboutdialog#GTK-LICENSE-UNKNOWN:CAPS) is used, the link used will be the same specified in the [“website”](gtkaboutdialog#GtkAboutDialog--website) property.
If [`GTK_LICENSE_CUSTOM`](gtkaboutdialog#GTK-LICENSE-CUSTOM:CAPS) is used, the current contents of the [“license”](gtkaboutdialog#GtkAboutDialog--license) property are used.
For any other [GtkLicense](gtkaboutdialog#GtkLicense) value, the contents of the [“license”](gtkaboutdialog#GtkAboutDialog--license) property are also set by this property as a side effect.
Owner: GtkAboutDialog
Flags: Read / Write
Default value: GTK\_LICENSE\_UNKNOWN
### The `“logo”` property
```
“logo” [GdkPaintable](https://developer-old.gnome.org/gtk4/html/GdkPaintable.html#GdkPaintable-struct) *
```
A logo for the about box. If it is `NULL`, the default window icon set with [`gtk_window_set_default_icon_name()`](gtkwindow#gtk-window-set-default-icon-name) will be used.
Owner: GtkAboutDialog
Flags: Read / Write
### The `“logo-icon-name”` property
```
“logo-icon-name” char *
```
A named icon to use as the logo for the about box. This property overrides the [“logo”](gtkaboutdialog#GtkAboutDialog--logo) property.
Owner: GtkAboutDialog
Flags: Read / Write
Default value: NULL
### The `“program-name”` property
```
“program-name” char *
```
The name of the program. If this is not set, it defaults to `g_get_application_name()`.
Owner: GtkAboutDialog
Flags: Read / Write
Default value: NULL
### The `“system-information”` property
```
“system-information” char *
```
Information about the system on which the program is running. This is displayed in a separate tab, therefore it is fine to use a long multi-paragraph text. Note that the text should contain the intended linebreaks.
The text may contain links in this format <http://www.some.place/> and email references in the form <mail-to*`some.body`* >, and these will be converted into clickable links.
Owner: GtkAboutDialog
Flags: Read / Write
Default value: NULL
### The `“translator-credits”` property
```
“translator-credits” char *
```
Credits to the translators. This string should be marked as translatable. The string may contain email addresses and URLs, which will be displayed as links, see the introduction for more details.
Owner: GtkAboutDialog
Flags: Read / Write
Default value: NULL
### The `“version”` property
```
“version” char *
```
The version of the program.
Owner: GtkAboutDialog
Flags: Read / Write
Default value: NULL
### The `“website”` property
```
“website” char *
```
The URL for the link to the website of the program. This should be a string starting with "http://.
Owner: GtkAboutDialog
Flags: Read / Write
Default value: NULL
### The `“website-label”` property
```
“website-label” char *
```
The label for the link to the website of the program.
Owner: GtkAboutDialog
Flags: Read / Write
Default value: NULL
### The `“wrap-license”` property
```
“wrap-license” gboolean
```
Whether to wrap the text in the license dialog.
Owner: GtkAboutDialog
Flags: Read / Write
Default value: FALSE
Signal Details
--------------
### The `“activate-link”` signal
```
gboolean
user_function ([GtkAboutDialog](gtkaboutdialog#GtkAboutDialog-struct) *label,
char *uri,
gpointer user_data)
```
The signal which gets emitted to activate a URI. Applications may connect to it to override the default behaviour, which is to call [`gtk_show_uri()`](gtk4-filesystem-utilities#gtk-show-uri).
#### Parameters
| | | |
| --- | --- | --- |
| label | The object on which the signal was emitted | |
| uri | the URI that is activated | |
| user\_data | user data set when the signal handler was connected. | |
#### Returns
`TRUE` if the link has been activated
Flags: Run Last
| programming_docs |
gtk GTK CSS Properties GTK CSS Properties
==================
[Basic types](ch39#id-1.6.3.3) [Colors](ch39s02) [Images](ch39s03) [GTK CSS Properties](ch39s04) GTK supports CSS properties and shorthands as far as they can be applied in the context of widgets, and adds its own properties only when needed. All GTK-specific properties have a -gtk prefix.
All properties support the following keywords: inherit, initial, unset, with the same meaning as defined in the [CSS Cascading and Inheritance](https://www.w3.org/TR/css3-cascade/#defaulting-keywords) spec.
The following units are supported for basic datatypes:
| | |
| --- | --- |
| Length | px, pt, em, ex, rem, pc, in, cm, mm, `calc()` |
| Percentage | %, `calc()` |
| Angle | deg | grad | turn, `calc()` |
| Time | s | ms, `calc()` |
Length values with the em or ex units are resolved using the font size value, unless they occur in setting the font-size itself, in which case they are resolved using the inherited font size value.
The rem unit is resolved using the initial font size value, which is not quite the same as the CSS definition of rem.
The `calc()` notation adds considerable expressive power. There are limits on what types can be combined in such an expression (e.g. it does not make sense to add a number and a time). For the full details, see the [CSS3 VAlues and Units](https://www.w3.org/TR/css3-values/#calc-notation) spec.
A common pattern among shorthand properties (called “four sides”) is one where one to four values can be specified, to determine a value for each side of an area. In this case, the specified values are interpreted as follows:
| | |
| --- | --- |
| 4 values: | top right bottom left |
| 3 values: | top horizontal bottom |
| 2 values: | vertical horizontal |
| 1 value: | all |
gtk GtkFileChooserDialog GtkFileChooserDialog
====================
GtkFileChooserDialog — A file chooser dialog, suitable for “File Open” or “File Save” commands
Functions
---------
| | |
| --- | --- |
| [GtkWidget](gtkwidget#GtkWidget-struct) \* | [gtk\_file\_chooser\_dialog\_new](gtkfilechooserdialog#gtk-file-chooser-dialog-new) () |
Actions
-------
| | | |
| --- | --- | --- |
| | response.activate | |
Types and Values
----------------
| | |
| --- | --- |
| | [GtkFileChooserDialog](gtkfilechooserdialog#GtkFileChooserDialog-struct) |
Object Hierarchy
----------------
```
GObject
╰── GInitiallyUnowned
╰── [GtkWidget](gtkwidget#GtkWidget-struct)
╰── [GtkWindow](gtkwindow#GtkWindow-struct)
╰── [GtkDialog](gtkdialog#GtkDialog-struct)
╰── GtkFileChooserDialog
```
Implemented Interfaces
----------------------
GtkFileChooserDialog implements [GtkAccessible](gtkaccessible#GtkAccessible-struct), [GtkBuildable](gtkbuildable#GtkBuildable-struct), [GtkConstraintTarget](gtkconstraint#GtkConstraintTarget-struct), [GtkNative](gtknative#GtkNative-struct), [GtkShortcutManager](gtkshortcutmanager#GtkShortcutManager-struct), [GtkRoot](gtkroot#GtkRoot-struct) and [GtkFileChooser](gtkfilechooser#GtkFileChooser-struct).
Includes
--------
```
#include <gtk/gtk.h>
```
Description
-----------
[GtkFileChooserDialog](gtkfilechooserdialog#GtkFileChooserDialog-struct) is a dialog box suitable for use with “File Open” or “File Save” commands. This widget works by putting a [GtkFileChooserWidget](gtkfilechooserwidget#GtkFileChooserWidget-struct) inside a [GtkDialog](gtkdialog#GtkDialog-struct). It exposes the [GtkFileChooser](gtkfilechooser#GtkFileChooser-struct) interface, so you can use all of the [GtkFileChooser](gtkfilechooser#GtkFileChooser-struct) functions on the file chooser dialog as well as those for [GtkDialog](gtkdialog#GtkDialog-struct).
Note that [GtkFileChooserDialog](gtkfilechooserdialog#GtkFileChooserDialog-struct) does not have any methods of its own. Instead, you should use the functions that work on a [GtkFileChooser](gtkfilechooser#GtkFileChooser-struct).
If you want to integrate well with the platform you should use the [GtkFileChooserNative](gtkfilechoosernative#GtkFileChooserNative-struct) API, which will use a platform-specific dialog if available and fall back to GtkFileChooserDialog otherwise.
#### Typical usage
In the simplest of cases, you can the following code to use [GtkFileChooserDialog](gtkfilechooserdialog#GtkFileChooserDialog-struct) to select a file for opening:
To use a dialog for saving, you can use this:
#### Setting up a file chooser dialog
There are various cases in which you may need to use a [GtkFileChooserDialog](gtkfilechooserdialog#GtkFileChooserDialog-struct):
* To select a file for opening. Use [GTK\_FILE\_CHOOSER\_ACTION\_OPEN](gtkfilechooser#GTK-FILE-CHOOSER-ACTION-OPEN:CAPS).
* To save a file for the first time. Use [GTK\_FILE\_CHOOSER\_ACTION\_SAVE](gtkfilechooser#GTK-FILE-CHOOSER-ACTION-SAVE:CAPS), and suggest a name such as “Untitled” with [`gtk_file_chooser_set_current_name()`](gtkfilechooser#gtk-file-chooser-set-current-name).
* To save a file under a different name. Use [GTK\_FILE\_CHOOSER\_ACTION\_SAVE](gtkfilechooser#GTK-FILE-CHOOSER-ACTION-SAVE:CAPS), and set the existing file with [`gtk_file_chooser_set_file()`](gtkfilechooser#gtk-file-chooser-set-file).
* To choose a folder instead of a file. Use [GTK\_FILE\_CHOOSER\_ACTION\_SELECT\_FOLDER](gtkfilechooser#GTK-FILE-CHOOSER-ACTION-SELECT-FOLDER:CAPS).
Note that old versions of the file chooser’s documentation suggested using [`gtk_file_chooser_set_current_folder()`](gtkfilechooser#gtk-file-chooser-set-current-folder) in various situations, with the intention of letting the application suggest a reasonable default folder. This is no longer considered to be a good policy, as now the file chooser is able to make good suggestions on its own. In general, you should only cause the file chooser to show a specific folder when it is appropriate to use [`gtk_file_chooser_set_file()`](gtkfilechooser#gtk-file-chooser-set-file), i.e. when you are doing a Save As command and you already have a file saved somewhere.
#### Response Codes
[GtkFileChooserDialog](gtkfilechooserdialog#GtkFileChooserDialog-struct) inherits from [GtkDialog](gtkdialog#GtkDialog-struct), so buttons that go in its action area have response codes such as [GTK\_RESPONSE\_ACCEPT](gtkdialog#GTK-RESPONSE-ACCEPT:CAPS) and [GTK\_RESPONSE\_CANCEL](gtkdialog#GTK-RESPONSE-CANCEL:CAPS). For example, you could call [`gtk_file_chooser_dialog_new()`](gtkfilechooserdialog#gtk-file-chooser-dialog-new) as follows:
```
static void
on_open_response (GtkDialog *dialog,
int response)
{
if (response == GTK_RESPONSE_ACCEPT)
{
GtkFileChooser *chooser = GTK_FILE_CHOOSER (dialog);
g_autoptr(GFile) file = gtk_file_chooser_get_file (chooser);
open_file (file);
}
gtk_window_destroy (GTK_WINDOW (dialog));
}
// ...
GtkWidget *dialog;
GtkFileChooserAction action = GTK_FILE_CHOOSER_ACTION_OPEN;
dialog = gtk_file_chooser_dialog_new ("Open File",
parent_window,
action,
_("_Cancel"),
GTK_RESPONSE_CANCEL,
_("_Open"),
GTK_RESPONSE_ACCEPT,
NULL);
gtk_widget_show (dialog);
g_signal_connect (dialog, "response",
G_CALLBACK (on_open_response),
NULL);
```
| This will create buttons for “Cancel” and “Open” that use predefined response identifiers from [GtkResponseType](gtkdialog#GtkResponseType). For most dialog boxes you can use your own custom response codes rather than the ones in [GtkResponseType](gtkdialog#GtkResponseType), but [GtkFileChooserDialog](gtkfilechooserdialog#GtkFileChooserDialog-struct) assumes that its “accept”-type action, e.g. an “Open” or “Save” button, will have one of the following response codes:
* [GTK\_RESPONSE\_ACCEPT](gtkdialog#GTK-RESPONSE-ACCEPT:CAPS)
* [GTK\_RESPONSE\_OK](gtkdialog#GTK-RESPONSE-OK:CAPS)
* [GTK\_RESPONSE\_YES](gtkdialog#GTK-RESPONSE-YES:CAPS)
* [GTK\_RESPONSE\_APPLY](gtkdialog#GTK-RESPONSE-APPLY:CAPS)
This is because [GtkFileChooserDialog](gtkfilechooserdialog#GtkFileChooserDialog-struct) must intercept responses and switch to folders if appropriate, rather than letting the dialog terminate — the implementation uses these known response codes to know which responses can be blocked if appropriate.
To summarize, make sure you use a predefined response code when you use [GtkFileChooserDialog](gtkfilechooserdialog#GtkFileChooserDialog-struct) to ensure proper operation.
Functions
---------
### gtk\_file\_chooser\_dialog\_new ()
```
[GtkWidget](gtkwidget#GtkWidget-struct) *
gtk_file_chooser_dialog_new (*`const char *title`*,
*`[GtkWindow](gtkwindow#GtkWindow-struct) *parent`*,
*`[GtkFileChooserAction](gtkfilechooser#GtkFileChooserAction) action`*,
*`const char *first_button_text`*,
*`...`*);
```
Creates a new [GtkFileChooserDialog](gtkfilechooserdialog#GtkFileChooserDialog-struct). This function is analogous to [`gtk_dialog_new_with_buttons()`](gtkdialog#gtk-dialog-new-with-buttons).
#### Parameters
| | | |
| --- | --- | --- |
| title | Title of the dialog, or `NULL`. | [allow-none] |
| parent | Transient parent of the dialog, or `NULL`. | [allow-none] |
| action | Open or save mode for the dialog | |
| first\_button\_text | text to go in the first button, or `NULL`. | [allow-none] |
| ... | response ID for the first button, then additional (button, id) pairs, ending with `NULL` | |
#### Returns
a new [GtkFileChooserDialog](gtkfilechooserdialog#GtkFileChooserDialog-struct)
Types and Values
----------------
### GtkFileChooserDialog
```
typedef struct _GtkFileChooserDialog GtkFileChooserDialog;
```
Action Details
--------------
### The `“response.activate”` action
Activate the default response of the dialog.
See Also
--------
[GtkFileChooser](gtkfilechooser#GtkFileChooser-struct), [GtkDialog](gtkdialog#GtkDialog-struct), [GtkFileChooserNative](gtkfilechoosernative#GtkFileChooserNative-struct)
gtk GtkIMMulticontext GtkIMMulticontext
=================
GtkIMMulticontext — An input method context supporting multiple, loadable input methods
Functions
---------
| | |
| --- | --- |
| [GtkIMContext](gtkimcontext#GtkIMContext-struct) \* | [gtk\_im\_multicontext\_new](gtkimmulticontext#gtk-im-multicontext-new) () |
| const char \* | [gtk\_im\_multicontext\_get\_context\_id](gtkimmulticontext#gtk-im-multicontext-get-context-id) () |
| void | [gtk\_im\_multicontext\_set\_context\_id](gtkimmulticontext#gtk-im-multicontext-set-context-id) () |
Types and Values
----------------
| | |
| --- | --- |
| struct | [GtkIMMulticontext](gtkimmulticontext#GtkIMMulticontext-struct) |
Object Hierarchy
----------------
```
GObject
╰── [GtkIMContext](gtkimcontext#GtkIMContext-struct)
╰── GtkIMMulticontext
```
Includes
--------
```
#include <gtk/gtk.h>
```
Description
-----------
Functions
---------
### gtk\_im\_multicontext\_new ()
```
[GtkIMContext](gtkimcontext#GtkIMContext-struct) *
gtk_im_multicontext_new (*`void`*);
```
Creates a new [GtkIMMulticontext](gtkimmulticontext#GtkIMMulticontext-struct).
#### Returns
a new [GtkIMMulticontext](gtkimmulticontext#GtkIMMulticontext-struct).
### gtk\_im\_multicontext\_get\_context\_id ()
```
const char *
gtk_im_multicontext_get_context_id (*`[GtkIMMulticontext](gtkimmulticontext#GtkIMMulticontext-struct) *context`*);
```
Gets the id of the currently active delegate of the *`context`* .
#### Parameters
| | | |
| --- | --- | --- |
| context | a [GtkIMMulticontext](gtkimmulticontext#GtkIMMulticontext-struct) | |
#### Returns
the id of the currently active delegate
### gtk\_im\_multicontext\_set\_context\_id ()
```
void
gtk_im_multicontext_set_context_id (*`[GtkIMMulticontext](gtkimmulticontext#GtkIMMulticontext-struct) *context`*,
*`const char *context_id`*);
```
Sets the context id for *`context`* .
This causes the currently active delegate of *`context`* to be replaced by the delegate corresponding to the new context id.
#### Parameters
| | | |
| --- | --- | --- |
| context | a [GtkIMMulticontext](gtkimmulticontext#GtkIMMulticontext-struct) | |
| context\_id | the id to use | |
Types and Values
----------------
### struct GtkIMMulticontext
```
struct GtkIMMulticontext;
```
gtk GtkGestureZoom GtkGestureZoom
==============
GtkGestureZoom — Zoom gesture
Functions
---------
| | |
| --- | --- |
| [GtkGesture](gtkgesture#GtkGesture-struct) \* | [gtk\_gesture\_zoom\_new](gtkgesturezoom#gtk-gesture-zoom-new) () |
| double | [gtk\_gesture\_zoom\_get\_scale\_delta](gtkgesturezoom#gtk-gesture-zoom-get-scale-delta) () |
Signals
-------
| | | |
| --- | --- | --- |
| void | [scale-changed](gtkgesturezoom#GtkGestureZoom-scale-changed) | Run First |
Types and Values
----------------
| | |
| --- | --- |
| | [GtkGestureZoom](gtkgesturezoom#GtkGestureZoom-struct) |
Object Hierarchy
----------------
```
GObject
╰── [GtkEventController](gtkeventcontroller#GtkEventController-struct)
╰── [GtkGesture](gtkgesture#GtkGesture-struct)
╰── GtkGestureZoom
```
Includes
--------
```
#include <gtk/gtk.h>
```
Description
-----------
[GtkGestureZoom](gtkgesturezoom#GtkGestureZoom-struct) is a [GtkGesture](gtkgesture#GtkGesture-struct) implementation able to recognize pinch/zoom gestures, whenever the distance between both tracked sequences changes, the [“scale-changed”](gtkgesturezoom#GtkGestureZoom-scale-changed) signal is emitted to report the scale factor.
Functions
---------
### gtk\_gesture\_zoom\_new ()
```
[GtkGesture](gtkgesture#GtkGesture-struct) *
gtk_gesture_zoom_new (*`void`*);
```
Returns a newly created [GtkGesture](gtkgesture#GtkGesture-struct) that recognizes zoom in/out gestures (usually known as pinch/zoom).
#### Returns
a newly created [GtkGestureZoom](gtkgesturezoom#GtkGestureZoom-struct)
### gtk\_gesture\_zoom\_get\_scale\_delta ()
```
double
gtk_gesture_zoom_get_scale_delta (*`[GtkGestureZoom](gtkgesturezoom#GtkGestureZoom-struct) *gesture`*);
```
If *`gesture`* is active, this function returns the zooming difference since the gesture was recognized (hence the starting point is considered 1:1). If *`gesture`* is not active, 1 is returned.
#### Parameters
| | | |
| --- | --- | --- |
| gesture | a [GtkGestureZoom](gtkgesturezoom#GtkGestureZoom-struct) | |
#### Returns
the scale delta
Types and Values
----------------
### GtkGestureZoom
```
typedef struct _GtkGestureZoom GtkGestureZoom;
```
Signal Details
--------------
### The `“scale-changed”` signal
```
void
user_function ([GtkGestureZoom](gtkgesturezoom#GtkGestureZoom-struct) *controller,
double scale,
gpointer user_data)
```
This signal is emitted whenever the distance between both tracked sequences changes.
#### Parameters
| | | |
| --- | --- | --- |
| controller | the object on which the signal is emitted | |
| scale | Scale delta, taking the initial state as 1:1 | |
| user\_data | user data set when the signal handler was connected. | |
Flags: Run First
See Also
--------
[GtkGestureRotate](gtkgesturerotate#GtkGestureRotate-struct)
gtk GtkMapListModel GtkMapListModel
===============
GtkMapListModel — A list model that transforms its items
Functions
---------
| | |
| --- | --- |
| gpointer | ([\*GtkMapListModelMapFunc](gtkmaplistmodel#GtkMapListModelMapFunc)) () |
| [GtkMapListModel](gtkmaplistmodel#GtkMapListModel-struct) \* | [gtk\_map\_list\_model\_new](gtkmaplistmodel#gtk-map-list-model-new) () |
| void | [gtk\_map\_list\_model\_set\_map\_func](gtkmaplistmodel#gtk-map-list-model-set-map-func) () |
| void | [gtk\_map\_list\_model\_set\_model](gtkmaplistmodel#gtk-map-list-model-set-model) () |
| GListModel \* | [gtk\_map\_list\_model\_get\_model](gtkmaplistmodel#gtk-map-list-model-get-model) () |
| gboolean | [gtk\_map\_list\_model\_has\_map](gtkmaplistmodel#gtk-map-list-model-has-map) () |
Properties
----------
| | | |
| --- | --- | --- |
| gboolean | [has-map](gtkmaplistmodel#GtkMapListModel--has-map) | Read |
| GListModel \* | [model](gtkmaplistmodel#GtkMapListModel--model) | Read / Write / Construct Only |
Types and Values
----------------
| | |
| --- | --- |
| | [GtkMapListModel](gtkmaplistmodel#GtkMapListModel-struct) |
Object Hierarchy
----------------
```
GObject
╰── GtkMapListModel
```
Implemented Interfaces
----------------------
GtkMapListModel implements GListModel.
Includes
--------
```
#include <gtk/gtk.h>
```
Description
-----------
[GtkMapListModel](gtkmaplistmodel#GtkMapListModel-struct) is a list model that takes a list model and maps the items in that model to different items according to a [GtkMapListModelMapFunc](gtkmaplistmodel#GtkMapListModelMapFunc).
Example: Create a list of [GtkEventControllers](gtkeventcontroller#GtkEventController-struct)
```
static gpointer
map_to_controllers (gpointer widget,
gpointer data)
{
gpointer result = gtk_widget_observe_controllers (widget);
g_object_unref (widget);
return result;
}
widgets = gtk_widget_observe_children (widget);
controllers = gtk_map_list_model_new (G_TYPE_LIST_MODEL,
widgets,
map_to_controllers,
NULL, NULL);
model = gtk_flatten_list_model_new (GTK_TYPE_EVENT_CONTROLLER,
controllers);
```
| [GtkMapListModel](gtkmaplistmodel#GtkMapListModel-struct) will attempt to discard the mapped objects as soon as they are no longer needed and recreate them if necessary.
Functions
---------
### GtkMapListModelMapFunc ()
```
gpointer
(*GtkMapListModelMapFunc) (gpointer item,
gpointer user_data);
```
User function that is called to map an *`item`* of the original model to an item expected by the map model.
The returned items must conform to the item type of the model they are used with.
#### Parameters
| | | |
| --- | --- | --- |
| item | The item to map. | [type GObject][transfer full] |
| user\_data | user data | |
#### Returns
The item to map to. This function may not return `NULL`.
[type GObject][transfer full]
### gtk\_map\_list\_model\_new ()
```
[GtkMapListModel](gtkmaplistmodel#GtkMapListModel-struct) *
gtk_map_list_model_new (*`GListModel *model`*,
*`[GtkMapListModelMapFunc](gtkmaplistmodel#GtkMapListModelMapFunc) map_func`*,
*`gpointer user_data`*,
*`GDestroyNotify user_destroy`*);
```
Creates a new [GtkMapListModel](gtkmaplistmodel#GtkMapListModel-struct) for the given arguments.
#### Parameters
| | | |
| --- | --- | --- |
| model | The model to map or `NULL` for none. | [transfer full][allow-none] |
| map\_func | map function or `NULL` to not map items. | [allow-none] |
| user\_data | user data passed to *`map_func`* . | [closure] |
| user\_destroy | destroy notifier for *`user_data`* | |
#### Returns
a new [GtkMapListModel](gtkmaplistmodel#GtkMapListModel-struct)
### gtk\_map\_list\_model\_set\_map\_func ()
```
void
gtk_map_list_model_set_map_func (*`[GtkMapListModel](gtkmaplistmodel#GtkMapListModel-struct) *self`*,
*`[GtkMapListModelMapFunc](gtkmaplistmodel#GtkMapListModelMapFunc) map_func`*,
*`gpointer user_data`*,
*`GDestroyNotify user_destroy`*);
```
Sets the function used to map items. The function will be called whenever an item needs to be mapped and must return the item to use for the given input item.
Note that [GtkMapListModel](gtkmaplistmodel#GtkMapListModel-struct) may call this function multiple times on the same item, because it may delete items it doesn't need anymore.
GTK makes no effort to ensure that *`map_func`* conforms to the item type of *`self`* . It assumes that the caller knows what they are doing and the map function returns items of the appropriate type.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkMapListModel](gtkmaplistmodel#GtkMapListModel-struct) | |
| map\_func | map function or `NULL` to not map items. | [allow-none] |
| user\_data | user data passed to *`map_func`* . | [closure] |
| user\_destroy | destroy notifier for *`user_data`* | |
### gtk\_map\_list\_model\_set\_model ()
```
void
gtk_map_list_model_set_model (*`[GtkMapListModel](gtkmaplistmodel#GtkMapListModel-struct) *self`*,
*`GListModel *model`*);
```
Sets the model to be mapped.
GTK makes no effort to ensure that *`model`* conforms to the item type expected by the map function. It assumes that the caller knows what they are doing and have set up an appropriate map function.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkMapListModel](gtkmaplistmodel#GtkMapListModel-struct) | |
| model | The model to be mapped. | [allow-none] |
### gtk\_map\_list\_model\_get\_model ()
```
GListModel *
gtk_map_list_model_get_model (*`[GtkMapListModel](gtkmaplistmodel#GtkMapListModel-struct) *self`*);
```
Gets the model that is currently being mapped or `NULL` if none.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkMapListModel](gtkmaplistmodel#GtkMapListModel-struct) | |
#### Returns
The model that gets mapped.
[nullable][transfer none]
### gtk\_map\_list\_model\_has\_map ()
```
gboolean
gtk_map_list_model_has_map (*`[GtkMapListModel](gtkmaplistmodel#GtkMapListModel-struct) *self`*);
```
Checks if a map function is currently set on *`self`*
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkMapListModel](gtkmaplistmodel#GtkMapListModel-struct) | |
#### Returns
`TRUE` if a map function is set
Types and Values
----------------
### GtkMapListModel
```
typedef struct _GtkMapListModel GtkMapListModel;
```
Property Details
----------------
### The `“has-map”` property
```
“has-map” gboolean
```
If a map is set for this model
Owner: GtkMapListModel
Flags: Read
Default value: FALSE
### The `“model”` property
```
“model” GListModel *
```
The model being mapped
Owner: GtkMapListModel
Flags: Read / Write / Construct Only
See Also
--------
GListModel
| programming_docs |
gtk GtkCellRendererAccel GtkCellRendererAccel
====================
GtkCellRendererAccel — Renders a keyboard accelerator in a cell
Functions
---------
| | |
| --- | --- |
| [GtkCellRenderer](gtkcellrenderer#GtkCellRenderer-struct) \* | [gtk\_cell\_renderer\_accel\_new](gtkcellrendereraccel#gtk-cell-renderer-accel-new) () |
Properties
----------
| | | |
| --- | --- | --- |
| guint | [accel-key](gtkcellrendereraccel#GtkCellRendererAccel--accel-key) | Read / Write |
| [GtkCellRendererAccelMode](gtkcellrendereraccel#GtkCellRendererAccelMode) | [accel-mode](gtkcellrendereraccel#GtkCellRendererAccel--accel-mode) | Read / Write |
| [GdkModifierType](https://developer-old.gnome.org/gtk4/html/GdkSurface.html#GdkModifierType) | [accel-mods](gtkcellrendereraccel#GtkCellRendererAccel--accel-mods) | Read / Write |
| guint | [keycode](gtkcellrendereraccel#GtkCellRendererAccel--keycode) | Read / Write |
Signals
-------
| | | |
| --- | --- | --- |
| void | [accel-cleared](gtkcellrendereraccel#GtkCellRendererAccel-accel-cleared) | Run Last |
| void | [accel-edited](gtkcellrendereraccel#GtkCellRendererAccel-accel-edited) | Run Last |
Types and Values
----------------
| | |
| --- | --- |
| | [GtkCellRendererAccel](gtkcellrendereraccel#GtkCellRendererAccel-struct) |
| enum | [GtkCellRendererAccelMode](gtkcellrendereraccel#GtkCellRendererAccelMode) |
Object Hierarchy
----------------
```
GObject
╰── GInitiallyUnowned
╰── [GtkCellRenderer](gtkcellrenderer#GtkCellRenderer-struct)
╰── [GtkCellRendererText](gtkcellrenderertext#GtkCellRendererText-struct)
╰── GtkCellRendererAccel
```
Includes
--------
```
#include <gtk/gtk.h>
```
Description
-----------
[GtkCellRendererAccel](gtkcellrendereraccel#GtkCellRendererAccel-struct) displays a keyboard accelerator (i.e. a key combination like `Control + a`). If the cell renderer is editable, the accelerator can be changed by simply typing the new combination.
Functions
---------
### gtk\_cell\_renderer\_accel\_new ()
```
[GtkCellRenderer](gtkcellrenderer#GtkCellRenderer-struct) *
gtk_cell_renderer_accel_new (*`void`*);
```
Creates a new [GtkCellRendererAccel](gtkcellrendereraccel#GtkCellRendererAccel-struct).
#### Returns
the new cell renderer
Types and Values
----------------
### GtkCellRendererAccel
```
typedef struct _GtkCellRendererAccel GtkCellRendererAccel;
```
### enum GtkCellRendererAccelMode
Determines if the edited accelerators are GTK accelerators. If they are, consumed modifiers are suppressed, only accelerators accepted by GTK are allowed, and the accelerators are rendered in the same way as they are in menus.
#### Members
| | | |
| --- | --- | --- |
| GTK\_CELL\_RENDERER\_ACCEL\_MODE\_GTK | GTK accelerators mode | |
| GTK\_CELL\_RENDERER\_ACCEL\_MODE\_OTHER | Other accelerator mode | |
Property Details
----------------
### The `“accel-key”` property
```
“accel-key” guint
```
The keyval of the accelerator.
Owner: GtkCellRendererAccel
Flags: Read / Write
Allowed values: <= G\_MAXINT
Default value: 0
### The `“accel-mode”` property
```
“accel-mode” [GtkCellRendererAccelMode](gtkcellrendereraccel#GtkCellRendererAccelMode)
```
Determines if the edited accelerators are GTK accelerators. If they are, consumed modifiers are suppressed, only accelerators accepted by GTK are allowed, and the accelerators are rendered in the same way as they are in menus.
Owner: GtkCellRendererAccel
Flags: Read / Write
Default value: GTK\_CELL\_RENDERER\_ACCEL\_MODE\_GTK
### The `“accel-mods”` property
```
“accel-mods” [GdkModifierType](https://developer-old.gnome.org/gtk4/html/GdkSurface.html#GdkModifierType)
```
The modifier mask of the accelerator.
Owner: GtkCellRendererAccel
Flags: Read / Write
### The `“keycode”` property
```
“keycode” guint
```
The hardware keycode of the accelerator. Note that the hardware keycode is only relevant if the key does not have a keyval. Normally, the keyboard configuration should assign keyvals to all keys.
Owner: GtkCellRendererAccel
Flags: Read / Write
Allowed values: <= G\_MAXINT
Default value: 0
Signal Details
--------------
### The `“accel-cleared”` signal
```
void
user_function ([GtkCellRendererAccel](gtkcellrendereraccel#GtkCellRendererAccel-struct) *accel,
char *path_string,
gpointer user_data)
```
Gets emitted when the user has removed the accelerator.
#### Parameters
| | | |
| --- | --- | --- |
| accel | the object reveiving the signal | |
| path\_string | the path identifying the row of the edited cell | |
| user\_data | user data set when the signal handler was connected. | |
Flags: Run Last
### The `“accel-edited”` signal
```
void
user_function ([GtkCellRendererAccel](gtkcellrendereraccel#GtkCellRendererAccel-struct) *accel,
char *path_string,
guint accel_key,
[GdkModifierType](https://developer-old.gnome.org/gtk4/html/GdkSurface.html#GdkModifierType) accel_mods,
guint hardware_keycode,
gpointer user_data)
```
Gets emitted when the user has selected a new accelerator.
#### Parameters
| | | |
| --- | --- | --- |
| accel | the object reveiving the signal | |
| path\_string | the path identifying the row of the edited cell | |
| accel\_key | the new accelerator keyval | |
| accel\_mods | the new acclerator modifier mask | |
| hardware\_keycode | the keycode of the new accelerator | |
| user\_data | user data set when the signal handler was connected. | |
Flags: Run Last
gtk GtkShortcutAction GtkShortcutAction
=================
GtkShortcutAction — Tracking if shortcuts should be activated
Functions
---------
| | |
| --- | --- |
| gboolean | ([\*GtkShortcutFunc](gtkshortcutaction#GtkShortcutFunc)) () |
| char \* | [gtk\_shortcut\_action\_to\_string](gtkshortcutaction#gtk-shortcut-action-to-string) () |
| void | [gtk\_shortcut\_action\_print](gtkshortcutaction#gtk-shortcut-action-print) () |
| [GtkShortcutAction](gtkshortcutaction#GtkShortcutAction-struct) \* | [gtk\_shortcut\_action\_parse\_string](gtkshortcutaction#gtk-shortcut-action-parse-string) () |
| gboolean | [gtk\_shortcut\_action\_activate](gtkshortcutaction#gtk-shortcut-action-activate) () |
| [GtkShortcutAction](gtkshortcutaction#GtkShortcutAction-struct) \* | [gtk\_nothing\_action\_get](gtkshortcutaction#gtk-nothing-action-get) () |
| [GtkShortcutAction](gtkshortcutaction#GtkShortcutAction-struct) \* | [gtk\_callback\_action\_new](gtkshortcutaction#gtk-callback-action-new) () |
| [GtkShortcutAction](gtkshortcutaction#GtkShortcutAction-struct) \* | [gtk\_mnemonic\_action\_get](gtkshortcutaction#gtk-mnemonic-action-get) () |
| [GtkShortcutAction](gtkshortcutaction#GtkShortcutAction-struct) \* | [gtk\_activate\_action\_get](gtkshortcutaction#gtk-activate-action-get) () |
| [GtkShortcutAction](gtkshortcutaction#GtkShortcutAction-struct) \* | [gtk\_signal\_action\_new](gtkshortcutaction#gtk-signal-action-new) () |
| const char \* | [gtk\_signal\_action\_get\_signal\_name](gtkshortcutaction#gtk-signal-action-get-signal-name) () |
| [GtkShortcutAction](gtkshortcutaction#GtkShortcutAction-struct) \* | [gtk\_named\_action\_new](gtkshortcutaction#gtk-named-action-new) () |
| const char \* | [gtk\_named\_action\_get\_action\_name](gtkshortcutaction#gtk-named-action-get-action-name) () |
Types and Values
----------------
| | |
| --- | --- |
| | [GtkShortcutAction](gtkshortcutaction#GtkShortcutAction-struct) |
| enum | [GtkShortcutActionFlags](gtkshortcutaction#GtkShortcutActionFlags) |
| | [GtkNothingAction](gtkshortcutaction#GtkNothingAction-struct) |
| | [GtkCallbackAction](gtkshortcutaction#GtkCallbackAction-struct) |
| | [GtkMnemonicAction](gtkshortcutaction#GtkMnemonicAction) |
| | [GtkActivateAction](gtkshortcutaction#GtkActivateAction) |
| | [GtkSignalAction](gtkshortcutaction#GtkSignalAction-struct) |
| | [GtkNamedAction](gtkshortcutaction#GtkNamedAction-struct) |
Object Hierarchy
----------------
```
GObject
╰── GtkShortcutAction
├── GtkSignalAction
├── GtkNothingAction
├── GtkNamedAction
╰── GtkCallbackAction
```
Includes
--------
```
#include <gtk/gtk.h>
```
Description
-----------
[GtkShortcutAction](gtkshortcutaction#GtkShortcutAction-struct) is the object used to describe what a [GtkShortcut](gtkshortcut#GtkShortcut-struct) should do when triggered. To activate a [GtkShortcutAction](gtkshortcutaction#GtkShortcutAction-struct) manually, [`gtk_shortcut_action_activate()`](gtkshortcutaction#gtk-shortcut-action-activate) can be called.
[GtkShortcutActions](gtkshortcutaction#GtkShortcutAction-struct) contain functions that allow easy presentation to end users as well as being printed for debugging.
All [GtkShortcutActions](gtkshortcutaction#GtkShortcutAction-struct) are immutable, you can only specify their properties during construction. If you want to change a action, you have to replace it with a new one. If you need to pass arguments to an action, these are specified by the higher-level [GtkShortcut](gtkshortcut#GtkShortcut-struct) object.
GTK provides various actions:
* [GtkMnemonicAction](gtkshortcutaction#GtkMnemonicAction): a shortcut action that calls [`gtk_widget_mnemonic_activate()`](gtkwidget#gtk-widget-mnemonic-activate)
* [GtkCallbackAction](gtkshortcutaction#GtkCallbackAction-struct): a shortcut action that invokes a given callback
* [GtkSignalAction](gtkshortcutaction#GtkSignalAction-struct): a shortcut action that emits a given signal
* [GtkActivateAction](gtkshortcutaction#GtkActivateAction): a shortcut action that calls [`gtk_widget_activate()`](gtkwidget#gtk-widget-activate)
* [GtkNamedAction](gtkshortcutaction#GtkNamedAction-struct): a shortcut action that calls [`gtk_widget_activate_action()`](gtkwidget#gtk-widget-activate-action)
* [GtkNothingAction](gtkshortcutaction#GtkNothingAction-struct): a shortcut action that does nothing
### GtkShortcutAction as GtkBuildable
GtkShortcut
Functions
---------
### GtkShortcutFunc ()
```
gboolean
(*GtkShortcutFunc) (*`[GtkWidget](gtkwidget#GtkWidget-struct) *widget`*,
*`GVariant *args`*,
*`gpointer user_data`*);
```
Prototype for shortcuts based on user callbacks.
#### Parameters
| | | |
| --- | --- | --- |
| widget | The widget passed to the activation | |
| args | The arguments passed to the activation. | [nullable] |
| user\_data | The user data provided when activating the action. | [nullable] |
### gtk\_shortcut\_action\_to\_string ()
```
char *
gtk_shortcut_action_to_string (*`[GtkShortcutAction](gtkshortcutaction#GtkShortcutAction-struct) *self`*);
```
Prints the given action into a human-readable string. This is a small wrapper around [`gtk_shortcut_action_print()`](gtkshortcutaction#gtk-shortcut-action-print) to help when debugging.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkShortcutAction](gtkshortcutaction#GtkShortcutAction-struct) | |
#### Returns
a new string.
[transfer full]
### gtk\_shortcut\_action\_print ()
```
void
gtk_shortcut_action_print (*`[GtkShortcutAction](gtkshortcutaction#GtkShortcutAction-struct) *self`*,
*`GString *string`*);
```
Prints the given action into a string for the developer. This is meant for debugging and logging.
The form of the representation may change at any time and is not guaranteed to stay identical.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkShortcutAction](gtkshortcutaction#GtkShortcutAction-struct) | |
| string | a GString to print into | |
### gtk\_shortcut\_action\_parse\_string ()
```
[GtkShortcutAction](gtkshortcutaction#GtkShortcutAction-struct) *
gtk_shortcut_action_parse_string (*`const char *string`*);
```
Tries to parse the given string into an action. On success, the parsed action is returned. When parsing failed, `NULL` is returned.
The accepted strings are:
* `nothing`, for [GtkNothingAction](gtkshortcutaction#GtkNothingAction-struct)
* `activate`, for [GtkActivateAction](gtkshortcutaction#GtkActivateAction)
* `mnemonic-activate`, for [GtkMnemonicAction](gtkshortcutaction#GtkMnemonicAction)
* `action(NAME)`, for a [GtkNamedAction](gtkshortcutaction#GtkNamedAction-struct) for the action named `NAME`
* `signal(NAME)`, for a [GtkSignalAction](gtkshortcutaction#GtkSignalAction-struct) for the signal `NAME`
[constructor]
#### Parameters
| | | |
| --- | --- | --- |
| string | the string to parse | |
#### Returns
a new [GtkShortcutAction](gtkshortcutaction#GtkShortcutAction-struct) or `NULL` on error.
[nullable][transfer full]
### gtk\_shortcut\_action\_activate ()
```
gboolean
gtk_shortcut_action_activate (*`[GtkShortcutAction](gtkshortcutaction#GtkShortcutAction-struct) *self`*,
*`[GtkShortcutActionFlags](gtkshortcutaction#GtkShortcutActionFlags) flags`*,
*`[GtkWidget](gtkwidget#GtkWidget-struct) *widget`*,
*`GVariant *args`*);
```
Activates the action on the *`widget`* with the given *`args`* .
Note that some actions ignore the passed in *`flags`* , *`widget`* or *`args`* .
Activation of an action can fail for various reasons. If the action is not supported by the *`widget`* , if the *`args`* don't match the action or if the activation otherwise had no effect, `FALSE` will be returned.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkShortcutAction](gtkshortcutaction#GtkShortcutAction-struct) | |
| flags | flags to activate with | |
| widget | Target of the activation | |
| args | arguments to pass. | [allow-none] |
#### Returns
`TRUE` if this action was activated successfully
### gtk\_nothing\_action\_get ()
```
[GtkShortcutAction](gtkshortcutaction#GtkShortcutAction-struct) *
gtk_nothing_action_get (*`void`*);
```
Gets the nothing action. This is an action that does nothing and where activating it always fails.
#### Returns
The nothing action.
[transfer none][type GtkNothingAction]
### gtk\_callback\_action\_new ()
```
[GtkShortcutAction](gtkshortcutaction#GtkShortcutAction-struct) *
gtk_callback_action_new (*`[GtkShortcutFunc](gtkshortcutaction#GtkShortcutFunc) callback`*,
*`gpointer data`*,
*`GDestroyNotify destroy`*);
```
Create a custom action that calls the given *`callback`* when activated.
#### Parameters
| | | |
| --- | --- | --- |
| callback | the callback to call. | [scope notified] |
| data | the data to be passed to *`callback`* . | [closure callback] |
| destroy | the function to be called when the callback action is finalized. | [destroy data] |
#### Returns
A new shortcut action.
[transfer full][type GtkCallbackAction]
### gtk\_mnemonic\_action\_get ()
```
[GtkShortcutAction](gtkshortcutaction#GtkShortcutAction-struct) *
gtk_mnemonic_action_get (*`void`*);
```
Gets the mnemonic action. This is an action that calls [`gtk_widget_mnemonic_activate()`](gtkwidget#gtk-widget-mnemonic-activate) on the given widget upon activation.
#### Returns
The mnemonic action.
[transfer none][type GtkMnemonicAction]
### gtk\_activate\_action\_get ()
```
[GtkShortcutAction](gtkshortcutaction#GtkShortcutAction-struct) *
gtk_activate_action_get (*`void`*);
```
Gets the activate action. This is an action that calls [`gtk_widget_activate()`](gtkwidget#gtk-widget-activate) on the given widget upon activation.
#### Returns
The activate action.
[transfer none][type GtkActivateAction]
### gtk\_signal\_action\_new ()
```
[GtkShortcutAction](gtkshortcutaction#GtkShortcutAction-struct) *
gtk_signal_action_new (*`const char *signal_name`*);
```
Creates an action that when activated, emits the given action signal on the provided widget unpacking the given args into arguments passed to the signal.
#### Parameters
| | | |
| --- | --- | --- |
| signal\_name | name of the signal to emit | |
#### Returns
a new [GtkShortcutAction](gtkshortcutaction#GtkShortcutAction-struct).
[transfer full][type GtkSignalAction]
### gtk\_signal\_action\_get\_signal\_name ()
```
const char *
gtk_signal_action_get_signal_name (*`[GtkSignalAction](gtkshortcutaction#GtkSignalAction-struct) *self`*);
```
Returns the name of the signal that will be emitted.
#### Parameters
| | | |
| --- | --- | --- |
| self | a signal action | |
#### Returns
the name of the signal to emit.
[transfer none]
### gtk\_named\_action\_new ()
```
[GtkShortcutAction](gtkshortcutaction#GtkShortcutAction-struct) *
gtk_named_action_new (*`const char *name`*);
```
Creates an action that when activated, activates the action given by the detailed *`name`* on the widget passing the given arguments to it.
See [`gtk_widget_insert_action_group()`](gtkwidget#gtk-widget-insert-action-group) for how to add actions to widgets.
#### Parameters
| | | |
| --- | --- | --- |
| name | the detailed name of the action | |
#### Returns
a new [GtkShortcutAction](gtkshortcutaction#GtkShortcutAction-struct).
[transfer full][type GtkNamedAction]
### gtk\_named\_action\_get\_action\_name ()
```
const char *
gtk_named_action_get_action_name (*`[GtkNamedAction](gtkshortcutaction#GtkNamedAction-struct) *self`*);
```
Returns the name of the action that will be activated.
#### Parameters
| | | |
| --- | --- | --- |
| self | a named action | |
#### Returns
the name of the action to activate
Types and Values
----------------
### GtkShortcutAction
```
typedef struct _GtkShortcutAction GtkShortcutAction;
```
### enum GtkShortcutActionFlags
List of flags that can be passed to action activation. More flags may be added in the future.
#### Members
| | | |
| --- | --- | --- |
| GTK\_SHORTCUT\_ACTION\_EXCLUSIVE | The action is the only action that can be activated. If this flag is not set, a future activation may select a different action. | |
### GtkNothingAction
```
typedef struct _GtkNothingAction GtkNothingAction;
```
A [GtkShortcutAction](gtkshortcutaction#GtkShortcutAction-struct) that does nothing.
### GtkCallbackAction
```
typedef struct _GtkCallbackAction GtkCallbackAction;
```
A [GtkShortcutAction](gtkshortcutaction#GtkShortcutAction-struct) that invokes a callback.
### GtkMnemonicAction
```
typedef struct _GtkMnemonicAction GtkMnemonicAction;
```
A [GtkShortcutAction](gtkshortcutaction#GtkShortcutAction-struct) that calls [`gtk_widget_mnemonic_activate()`](gtkwidget#gtk-widget-mnemonic-activate).
### GtkActivateAction
```
typedef struct _GtkActivateAction GtkActivateAction;
```
A [GtkShortcutAction](gtkshortcutaction#GtkShortcutAction-struct) that calls [`gtk_widget_activate()`](gtkwidget#gtk-widget-activate).
### GtkSignalAction
```
typedef struct _GtkSignalAction GtkSignalAction;
```
A [GtkShortcutAction](gtkshortcutaction#GtkShortcutAction-struct) that emits a signal.
Signals that are used in this way are referred to as keybinding signals, and they are expected to be defined with the `G_SIGNAL_ACTION` flag.
### GtkNamedAction
```
typedef struct _GtkNamedAction GtkNamedAction;
```
A [GtkShortcutAction](gtkshortcutaction#GtkShortcutAction-struct) that activates an action by name.
See Also
--------
[GtkShortcut](gtkshortcut#GtkShortcut-struct)
gtk GtkColorButton GtkColorButton
==============
GtkColorButton — A button to launch a color selection dialog
Functions
---------
| | |
| --- | --- |
| [GtkWidget](gtkwidget#GtkWidget-struct) \* | [gtk\_color\_button\_new](gtkcolorbutton#gtk-color-button-new) () |
| [GtkWidget](gtkwidget#GtkWidget-struct) \* | [gtk\_color\_button\_new\_with\_rgba](gtkcolorbutton#gtk-color-button-new-with-rgba) () |
| void | [gtk\_color\_button\_set\_title](gtkcolorbutton#gtk-color-button-set-title) () |
| const char \* | [gtk\_color\_button\_get\_title](gtkcolorbutton#gtk-color-button-get-title) () |
| void | [gtk\_color\_button\_set\_modal](gtkcolorbutton#gtk-color-button-set-modal) () |
| gboolean | [gtk\_color\_button\_get\_modal](gtkcolorbutton#gtk-color-button-get-modal) () |
Properties
----------
| | | |
| --- | --- | --- |
| gboolean | [modal](gtkcolorbutton#GtkColorButton--modal) | Read / Write |
| gboolean | [show-editor](gtkcolorbutton#GtkColorButton--show-editor) | Read / Write |
| char \* | [title](gtkcolorbutton#GtkColorButton--title) | Read / Write |
Signals
-------
| | | |
| --- | --- | --- |
| void | [color-set](gtkcolorbutton#GtkColorButton-color-set) | Run First |
Types and Values
----------------
| | |
| --- | --- |
| | [GtkColorButton](gtkcolorbutton#GtkColorButton-struct) |
Object Hierarchy
----------------
```
GObject
╰── GInitiallyUnowned
╰── [GtkWidget](gtkwidget#GtkWidget-struct)
╰── GtkColorButton
```
Implemented Interfaces
----------------------
GtkColorButton implements [GtkAccessible](gtkaccessible#GtkAccessible-struct), [GtkBuildable](gtkbuildable#GtkBuildable-struct), [GtkConstraintTarget](gtkconstraint#GtkConstraintTarget-struct) and [GtkColorChooser](gtkcolorchooser#GtkColorChooser-struct).
Includes
--------
```
#include <gtk/gtk.h>
```
Description
-----------
The [GtkColorButton](gtkcolorbutton#GtkColorButton-struct) is a button which displays the currently selected color and allows to open a color selection dialog to change the color. It is suitable widget for selecting a color in a preference dialog.
### CSS nodes
```
colorbutton
╰── button.color
╰── [content]
```
| GtkColorButton has a single CSS node with name colorbutton which contains a button node. To differentiate it from a plain [GtkButton](gtkbutton#GtkButton-struct), it gets the .color style class.
Functions
---------
### gtk\_color\_button\_new ()
```
[GtkWidget](gtkwidget#GtkWidget-struct) *
gtk_color_button_new (*`void`*);
```
Creates a new color button.
This returns a widget in the form of a small button containing a swatch representing the current selected color. When the button is clicked, a color-selection dialog will open, allowing the user to select a color. The swatch will be updated to reflect the new color when the user finishes.
#### Returns
a new color button
### gtk\_color\_button\_new\_with\_rgba ()
```
[GtkWidget](gtkwidget#GtkWidget-struct) *
gtk_color_button_new_with_rgba (*`const [GdkRGBA](https://developer-old.gnome.org/gtk4/html/gdk4-RGBA-Colors.html#GdkRGBA-struct) *rgba`*);
```
Creates a new color button.
#### Parameters
| | | |
| --- | --- | --- |
| rgba | A [GdkRGBA](https://developer-old.gnome.org/gtk4/html/gdk4-RGBA-Colors.html#GdkRGBA-struct) to set the current color with | |
#### Returns
a new color button
### gtk\_color\_button\_set\_title ()
```
void
gtk_color_button_set_title (*`[GtkColorButton](gtkcolorbutton#GtkColorButton-struct) *button`*,
*`const char *title`*);
```
Sets the title for the color selection dialog.
#### Parameters
| | | |
| --- | --- | --- |
| button | a [GtkColorButton](gtkcolorbutton#GtkColorButton-struct) | |
| title | String containing new window title | |
### gtk\_color\_button\_get\_title ()
```
const char *
gtk_color_button_get_title (*`[GtkColorButton](gtkcolorbutton#GtkColorButton-struct) *button`*);
```
Gets the title of the color selection dialog.
#### Parameters
| | | |
| --- | --- | --- |
| button | a [GtkColorButton](gtkcolorbutton#GtkColorButton-struct) | |
#### Returns
An internal string, do not free the return value
### gtk\_color\_button\_set\_modal ()
```
void
gtk_color_button_set_modal (*`[GtkColorButton](gtkcolorbutton#GtkColorButton-struct) *button`*,
*`gboolean modal`*);
```
Sets whether the dialog should be modal.
#### Parameters
| | | |
| --- | --- | --- |
| button | a [GtkColorButton](gtkcolorbutton#GtkColorButton-struct) | |
| modal | `TRUE` to make the dialog modal | |
### gtk\_color\_button\_get\_modal ()
```
gboolean
gtk_color_button_get_modal (*`[GtkColorButton](gtkcolorbutton#GtkColorButton-struct) *button`*);
```
Gets whether the dialog is modal.
#### Parameters
| | | |
| --- | --- | --- |
| button | a [GtkColorButton](gtkcolorbutton#GtkColorButton-struct) | |
#### Returns
`TRUE` if the dialog is modal
Types and Values
----------------
### GtkColorButton
```
typedef struct _GtkColorButton GtkColorButton;
```
Property Details
----------------
### The `“modal”` property
```
“modal” gboolean
```
Whether the dialog is modal.
Owner: GtkColorButton
Flags: Read / Write
Default value: TRUE
### The `“show-editor”` property
```
“show-editor” gboolean
```
Set this property to `TRUE` to skip the palette in the dialog and go directly to the color editor.
This property should be used in cases where the palette in the editor would be redundant, such as when the color button is already part of a palette.
Owner: GtkColorButton
Flags: Read / Write
Default value: FALSE
### The `“title”` property
```
“title” char *
```
The title of the color selection dialog
Owner: GtkColorButton
Flags: Read / Write
Default value: "Pick a Color"
Signal Details
--------------
### The `“color-set”` signal
```
void
user_function ([GtkColorButton](gtkcolorbutton#GtkColorButton-struct) *widget,
gpointer user_data)
```
The ::color-set signal is emitted when the user selects a color. When handling this signal, use [`gtk_color_chooser_get_rgba()`](gtkcolorchooser#gtk-color-chooser-get-rgba) to find out which color was just selected.
Note that this signal is only emitted when the user changes the color. If you need to react to programmatic color changes as well, use the notify::color signal.
#### Parameters
| | | |
| --- | --- | --- |
| widget | the object which received the signal. | |
| user\_data | user data set when the signal handler was connected. | |
Flags: Run First
See Also
--------
[GtkFontButton](gtkfontbutton#GtkFontButton-struct)
| programming_docs |
gtk GtkTreeSelection GtkTreeSelection
================
GtkTreeSelection — The selection object for GtkTreeView
Functions
---------
| | |
| --- | --- |
| gboolean | ([\*GtkTreeSelectionFunc](gtktreeselection#GtkTreeSelectionFunc)) () |
| void | ([\*GtkTreeSelectionForeachFunc](gtktreeselection#GtkTreeSelectionForeachFunc)) () |
| void | [gtk\_tree\_selection\_set\_mode](gtktreeselection#gtk-tree-selection-set-mode) () |
| [GtkSelectionMode](gtk4-standard-enumerations#GtkSelectionMode) | [gtk\_tree\_selection\_get\_mode](gtktreeselection#gtk-tree-selection-get-mode) () |
| void | [gtk\_tree\_selection\_set\_select\_function](gtktreeselection#gtk-tree-selection-set-select-function) () |
| [GtkTreeSelectionFunc](gtktreeselection#GtkTreeSelectionFunc) | [gtk\_tree\_selection\_get\_select\_function](gtktreeselection#gtk-tree-selection-get-select-function) () |
| gpointer | [gtk\_tree\_selection\_get\_user\_data](gtktreeselection#gtk-tree-selection-get-user-data) () |
| [GtkTreeView](gtktreeview#GtkTreeView-struct) \* | [gtk\_tree\_selection\_get\_tree\_view](gtktreeselection#gtk-tree-selection-get-tree-view) () |
| gboolean | [gtk\_tree\_selection\_get\_selected](gtktreeselection#gtk-tree-selection-get-selected) () |
| void | [gtk\_tree\_selection\_selected\_foreach](gtktreeselection#gtk-tree-selection-selected-foreach) () |
| GList \* | [gtk\_tree\_selection\_get\_selected\_rows](gtktreeselection#gtk-tree-selection-get-selected-rows) () |
| int | [gtk\_tree\_selection\_count\_selected\_rows](gtktreeselection#gtk-tree-selection-count-selected-rows) () |
| void | [gtk\_tree\_selection\_select\_path](gtktreeselection#gtk-tree-selection-select-path) () |
| void | [gtk\_tree\_selection\_unselect\_path](gtktreeselection#gtk-tree-selection-unselect-path) () |
| gboolean | [gtk\_tree\_selection\_path\_is\_selected](gtktreeselection#gtk-tree-selection-path-is-selected) () |
| void | [gtk\_tree\_selection\_select\_iter](gtktreeselection#gtk-tree-selection-select-iter) () |
| void | [gtk\_tree\_selection\_unselect\_iter](gtktreeselection#gtk-tree-selection-unselect-iter) () |
| gboolean | [gtk\_tree\_selection\_iter\_is\_selected](gtktreeselection#gtk-tree-selection-iter-is-selected) () |
| void | [gtk\_tree\_selection\_select\_all](gtktreeselection#gtk-tree-selection-select-all) () |
| void | [gtk\_tree\_selection\_unselect\_all](gtktreeselection#gtk-tree-selection-unselect-all) () |
| void | [gtk\_tree\_selection\_select\_range](gtktreeselection#gtk-tree-selection-select-range) () |
| void | [gtk\_tree\_selection\_unselect\_range](gtktreeselection#gtk-tree-selection-unselect-range) () |
Properties
----------
| | | |
| --- | --- | --- |
| [GtkSelectionMode](gtk4-standard-enumerations#GtkSelectionMode) | [mode](gtktreeselection#GtkTreeSelection--mode) | Read / Write |
Signals
-------
| | | |
| --- | --- | --- |
| void | [changed](gtktreeselection#GtkTreeSelection-changed) | Run First |
Types and Values
----------------
| | |
| --- | --- |
| | [GtkTreeSelection](gtktreeselection#GtkTreeSelection-struct) |
Object Hierarchy
----------------
```
GObject
╰── GtkTreeSelection
```
Includes
--------
```
#include <gtk/gtk.h>
```
Description
-----------
The [GtkTreeSelection](gtktreeselection#GtkTreeSelection-struct) object is a helper object to manage the selection for a [GtkTreeView](gtktreeview#GtkTreeView-struct) widget. The [GtkTreeSelection](gtktreeselection#GtkTreeSelection-struct) object is automatically created when a new [GtkTreeView](gtktreeview#GtkTreeView-struct) widget is created, and cannot exist independently of this widget. The primary reason the [GtkTreeSelection](gtktreeselection#GtkTreeSelection-struct) objects exists is for cleanliness of code and API. That is, there is no conceptual reason all these functions could not be methods on the [GtkTreeView](gtktreeview#GtkTreeView-struct) widget instead of a separate function.
The [GtkTreeSelection](gtktreeselection#GtkTreeSelection-struct) object is gotten from a [GtkTreeView](gtktreeview#GtkTreeView-struct) by calling [`gtk_tree_view_get_selection()`](gtktreeview#gtk-tree-view-get-selection). It can be manipulated to check the selection status of the tree, as well as select and deselect individual rows. Selection is done completely view side. As a result, multiple views of the same model can have completely different selections. Additionally, you cannot change the selection of a row on the model that is not currently displayed by the view without expanding its parents first.
One of the important things to remember when monitoring the selection of a view is that the [“changed”](gtktreeselection#GtkTreeSelection-changed) signal is mostly a hint. That is, it may only emit one signal when a range of rows is selected. Additionally, it may on occasion emit a [“changed”](gtktreeselection#GtkTreeSelection-changed) signal when nothing has happened (mostly as a result of programmers calling select\_row on an already selected row).
Functions
---------
### GtkTreeSelectionFunc ()
```
gboolean
(*GtkTreeSelectionFunc) (*`[GtkTreeSelection](gtktreeselection#GtkTreeSelection-struct) *selection`*,
*`[GtkTreeModel](gtktreemodel#GtkTreeModel-struct) *model`*,
*`[GtkTreePath](gtktreemodel#GtkTreePath-struct) *path`*,
*`gboolean path_currently_selected`*,
*`gpointer data`*);
```
A function used by [`gtk_tree_selection_set_select_function()`](gtktreeselection#gtk-tree-selection-set-select-function) to filter whether or not a row may be selected. It is called whenever a row's state might change. A return value of `TRUE` indicates to *`selection`* that it is okay to change the selection.
#### Parameters
| | | |
| --- | --- | --- |
| selection | A [GtkTreeSelection](gtktreeselection#GtkTreeSelection-struct) | |
| model | A [GtkTreeModel](gtktreemodel#GtkTreeModel-struct) being viewed | |
| path | The [GtkTreePath](gtktreemodel#GtkTreePath-struct) of the row in question | |
| path\_currently\_selected | `TRUE`, if the path is currently selected | |
| data | user data. | [closure] |
#### Returns
`TRUE`, if the selection state of the row can be toggled
### GtkTreeSelectionForeachFunc ()
```
void
(*GtkTreeSelectionForeachFunc) (*`[GtkTreeModel](gtktreemodel#GtkTreeModel-struct) *model`*,
*`[GtkTreePath](gtktreemodel#GtkTreePath-struct) *path`*,
*`[GtkTreeIter](gtktreemodel#GtkTreeIter-struct) *iter`*,
*`gpointer data`*);
```
A function used by [`gtk_tree_selection_selected_foreach()`](gtktreeselection#gtk-tree-selection-selected-foreach) to map all selected rows. It will be called on every selected row in the view.
#### Parameters
| | | |
| --- | --- | --- |
| model | The [GtkTreeModel](gtktreemodel#GtkTreeModel-struct) being viewed | |
| path | The [GtkTreePath](gtktreemodel#GtkTreePath-struct) of a selected row | |
| iter | A [GtkTreeIter](gtktreemodel#GtkTreeIter-struct) pointing to a selected row | |
| data | user data. | [closure] |
### gtk\_tree\_selection\_set\_mode ()
```
void
gtk_tree_selection_set_mode (*`[GtkTreeSelection](gtktreeselection#GtkTreeSelection-struct) *selection`*,
*`[GtkSelectionMode](gtk4-standard-enumerations#GtkSelectionMode) type`*);
```
Sets the selection mode of the *`selection`* . If the previous type was [GTK\_SELECTION\_MULTIPLE](gtk4-standard-enumerations#GTK-SELECTION-MULTIPLE:CAPS), then the anchor is kept selected, if it was previously selected.
#### Parameters
| | | |
| --- | --- | --- |
| selection | A [GtkTreeSelection](gtktreeselection#GtkTreeSelection-struct). | |
| type | The selection mode | |
### gtk\_tree\_selection\_get\_mode ()
```
[GtkSelectionMode](gtk4-standard-enumerations#GtkSelectionMode)
gtk_tree_selection_get_mode (*`[GtkTreeSelection](gtktreeselection#GtkTreeSelection-struct) *selection`*);
```
Gets the selection mode for *`selection`* . See [`gtk_tree_selection_set_mode()`](gtktreeselection#gtk-tree-selection-set-mode).
#### Parameters
| | | |
| --- | --- | --- |
| selection | a [GtkTreeSelection](gtktreeselection#GtkTreeSelection-struct) | |
#### Returns
the current selection mode
### gtk\_tree\_selection\_set\_select\_function ()
```
void
gtk_tree_selection_set_select_function
(*`[GtkTreeSelection](gtktreeselection#GtkTreeSelection-struct) *selection`*,
*`[GtkTreeSelectionFunc](gtktreeselection#GtkTreeSelectionFunc) func`*,
*`gpointer data`*,
*`GDestroyNotify destroy`*);
```
Sets the selection function.
If set, this function is called before any node is selected or unselected, giving some control over which nodes are selected. The select function should return `TRUE` if the state of the node may be toggled, and `FALSE` if the state of the node should be left unchanged.
#### Parameters
| | | |
| --- | --- | --- |
| selection | A [GtkTreeSelection](gtktreeselection#GtkTreeSelection-struct). | |
| func | The selection function. May be `NULL`. | [nullable] |
| data | The selection function’s data. May be `NULL` | |
| destroy | The destroy function for user data. May be `NULL` | |
### gtk\_tree\_selection\_get\_select\_function ()
```
[GtkTreeSelectionFunc](gtktreeselection#GtkTreeSelectionFunc)
gtk_tree_selection_get_select_function
(*`[GtkTreeSelection](gtktreeselection#GtkTreeSelection-struct) *selection`*);
```
Returns the current selection function.
[skip]
#### Parameters
| | | |
| --- | --- | --- |
| selection | A [GtkTreeSelection](gtktreeselection#GtkTreeSelection-struct). | |
#### Returns
The function.
### gtk\_tree\_selection\_get\_user\_data ()
```
gpointer
gtk_tree_selection_get_user_data (*`[GtkTreeSelection](gtktreeselection#GtkTreeSelection-struct) *selection`*);
```
Returns the user data for the selection function.
[skip]
#### Parameters
| | | |
| --- | --- | --- |
| selection | A [GtkTreeSelection](gtktreeselection#GtkTreeSelection-struct). | |
#### Returns
The user data.
### gtk\_tree\_selection\_get\_tree\_view ()
```
[GtkTreeView](gtktreeview#GtkTreeView-struct) *
gtk_tree_selection_get_tree_view (*`[GtkTreeSelection](gtktreeselection#GtkTreeSelection-struct) *selection`*);
```
Returns the tree view associated with *`selection`* .
#### Parameters
| | | |
| --- | --- | --- |
| selection | A [GtkTreeSelection](gtktreeselection#GtkTreeSelection-struct) | |
#### Returns
A [GtkTreeView](gtktreeview#GtkTreeView-struct).
[transfer none]
### gtk\_tree\_selection\_get\_selected ()
```
gboolean
gtk_tree_selection_get_selected (*`[GtkTreeSelection](gtktreeselection#GtkTreeSelection-struct) *selection`*,
*`[GtkTreeModel](gtktreemodel#GtkTreeModel-struct) **model`*,
*`[GtkTreeIter](gtktreemodel#GtkTreeIter-struct) *iter`*);
```
Sets *`iter`* to the currently selected node if *`selection`* is set to [GTK\_SELECTION\_SINGLE](gtk4-standard-enumerations#GTK-SELECTION-SINGLE:CAPS) or [GTK\_SELECTION\_BROWSE](gtk4-standard-enumerations#GTK-SELECTION-BROWSE:CAPS). *`iter`* may be NULL if you just want to test if *`selection`* has any selected nodes. *`model`* is filled with the current model as a convenience. This function will not work if you use *`selection`* is [GTK\_SELECTION\_MULTIPLE](gtk4-standard-enumerations#GTK-SELECTION-MULTIPLE:CAPS).
#### Parameters
| | | |
| --- | --- | --- |
| selection | A [GtkTreeSelection](gtktreeselection#GtkTreeSelection-struct). | |
| model | A pointer to set to the [GtkTreeModel](gtktreemodel#GtkTreeModel-struct), or NULL. | [out][allow-none][transfer none] |
| iter | The [GtkTreeIter](gtktreemodel#GtkTreeIter-struct), or NULL. | [out][allow-none] |
#### Returns
TRUE, if there is a selected node.
### gtk\_tree\_selection\_selected\_foreach ()
```
void
gtk_tree_selection_selected_foreach (*`[GtkTreeSelection](gtktreeselection#GtkTreeSelection-struct) *selection`*,
*`[GtkTreeSelectionForeachFunc](gtktreeselection#GtkTreeSelectionForeachFunc) func`*,
*`gpointer data`*);
```
Calls a function for each selected node. Note that you cannot modify the tree or selection from within this function. As a result, [`gtk_tree_selection_get_selected_rows()`](gtktreeselection#gtk-tree-selection-get-selected-rows) might be more useful.
#### Parameters
| | | |
| --- | --- | --- |
| selection | A [GtkTreeSelection](gtktreeselection#GtkTreeSelection-struct). | |
| func | The function to call for each selected node. | [scope call] |
| data | user data to pass to the function. | |
### gtk\_tree\_selection\_get\_selected\_rows ()
```
GList *
gtk_tree_selection_get_selected_rows (*`[GtkTreeSelection](gtktreeselection#GtkTreeSelection-struct) *selection`*,
*`[GtkTreeModel](gtktreemodel#GtkTreeModel-struct) **model`*);
```
Creates a list of path of all selected rows. Additionally, if you are planning on modifying the model after calling this function, you may want to convert the returned list into a list of GtkTreeRowReferences. To do this, you can use [`gtk_tree_row_reference_new()`](gtktreemodel#gtk-tree-row-reference-new).
To free the return value, use:
```
g_list_free_full (list, (GDestroyNotify) gtk_tree_path_free);
```
| #### Parameters
| | | |
| --- | --- | --- |
| selection | A [GtkTreeSelection](gtktreeselection#GtkTreeSelection-struct). | |
| model | A pointer to set to the [GtkTreeModel](gtktreemodel#GtkTreeModel-struct), or `NULL`. | [out][allow-none][transfer none] |
#### Returns
A GList containing a [GtkTreePath](gtktreemodel#GtkTreePath-struct) for each selected row.
[element-type GtkTreePath][transfer full]
### gtk\_tree\_selection\_count\_selected\_rows ()
```
int
gtk_tree_selection_count_selected_rows
(*`[GtkTreeSelection](gtktreeselection#GtkTreeSelection-struct) *selection`*);
```
Returns the number of rows that have been selected in *`tree`* .
#### Parameters
| | | |
| --- | --- | --- |
| selection | A [GtkTreeSelection](gtktreeselection#GtkTreeSelection-struct). | |
#### Returns
The number of rows selected.
### gtk\_tree\_selection\_select\_path ()
```
void
gtk_tree_selection_select_path (*`[GtkTreeSelection](gtktreeselection#GtkTreeSelection-struct) *selection`*,
*`[GtkTreePath](gtktreemodel#GtkTreePath-struct) *path`*);
```
Select the row at *`path`* .
#### Parameters
| | | |
| --- | --- | --- |
| selection | A [GtkTreeSelection](gtktreeselection#GtkTreeSelection-struct). | |
| path | The [GtkTreePath](gtktreemodel#GtkTreePath-struct) to be selected. | |
### gtk\_tree\_selection\_unselect\_path ()
```
void
gtk_tree_selection_unselect_path (*`[GtkTreeSelection](gtktreeselection#GtkTreeSelection-struct) *selection`*,
*`[GtkTreePath](gtktreemodel#GtkTreePath-struct) *path`*);
```
Unselects the row at *`path`* .
#### Parameters
| | | |
| --- | --- | --- |
| selection | A [GtkTreeSelection](gtktreeselection#GtkTreeSelection-struct). | |
| path | The [GtkTreePath](gtktreemodel#GtkTreePath-struct) to be unselected. | |
### gtk\_tree\_selection\_path\_is\_selected ()
```
gboolean
gtk_tree_selection_path_is_selected (*`[GtkTreeSelection](gtktreeselection#GtkTreeSelection-struct) *selection`*,
*`[GtkTreePath](gtktreemodel#GtkTreePath-struct) *path`*);
```
Returns `TRUE` if the row pointed to by *`path`* is currently selected. If *`path`* does not point to a valid location, `FALSE` is returned
#### Parameters
| | | |
| --- | --- | --- |
| selection | A [GtkTreeSelection](gtktreeselection#GtkTreeSelection-struct). | |
| path | A [GtkTreePath](gtktreemodel#GtkTreePath-struct) to check selection on. | |
#### Returns
`TRUE` if *`path`* is selected.
### gtk\_tree\_selection\_select\_iter ()
```
void
gtk_tree_selection_select_iter (*`[GtkTreeSelection](gtktreeselection#GtkTreeSelection-struct) *selection`*,
*`[GtkTreeIter](gtktreemodel#GtkTreeIter-struct) *iter`*);
```
Selects the specified iterator.
#### Parameters
| | | |
| --- | --- | --- |
| selection | A [GtkTreeSelection](gtktreeselection#GtkTreeSelection-struct). | |
| iter | The [GtkTreeIter](gtktreemodel#GtkTreeIter-struct) to be selected. | |
### gtk\_tree\_selection\_unselect\_iter ()
```
void
gtk_tree_selection_unselect_iter (*`[GtkTreeSelection](gtktreeselection#GtkTreeSelection-struct) *selection`*,
*`[GtkTreeIter](gtktreemodel#GtkTreeIter-struct) *iter`*);
```
Unselects the specified iterator.
#### Parameters
| | | |
| --- | --- | --- |
| selection | A [GtkTreeSelection](gtktreeselection#GtkTreeSelection-struct). | |
| iter | The [GtkTreeIter](gtktreemodel#GtkTreeIter-struct) to be unselected. | |
### gtk\_tree\_selection\_iter\_is\_selected ()
```
gboolean
gtk_tree_selection_iter_is_selected (*`[GtkTreeSelection](gtktreeselection#GtkTreeSelection-struct) *selection`*,
*`[GtkTreeIter](gtktreemodel#GtkTreeIter-struct) *iter`*);
```
Returns `TRUE` if the row at *`iter`* is currently selected.
#### Parameters
| | | |
| --- | --- | --- |
| selection | A [GtkTreeSelection](gtktreeselection#GtkTreeSelection-struct) | |
| iter | A valid [GtkTreeIter](gtktreemodel#GtkTreeIter-struct) | |
#### Returns
`TRUE`, if *`iter`* is selected
### gtk\_tree\_selection\_select\_all ()
```
void
gtk_tree_selection_select_all (*`[GtkTreeSelection](gtktreeselection#GtkTreeSelection-struct) *selection`*);
```
Selects all the nodes. *`selection`* must be set to [GTK\_SELECTION\_MULTIPLE](gtk4-standard-enumerations#GTK-SELECTION-MULTIPLE:CAPS) mode.
#### Parameters
| | | |
| --- | --- | --- |
| selection | A [GtkTreeSelection](gtktreeselection#GtkTreeSelection-struct). | |
### gtk\_tree\_selection\_unselect\_all ()
```
void
gtk_tree_selection_unselect_all (*`[GtkTreeSelection](gtktreeselection#GtkTreeSelection-struct) *selection`*);
```
Unselects all the nodes.
#### Parameters
| | | |
| --- | --- | --- |
| selection | A [GtkTreeSelection](gtktreeselection#GtkTreeSelection-struct). | |
### gtk\_tree\_selection\_select\_range ()
```
void
gtk_tree_selection_select_range (*`[GtkTreeSelection](gtktreeselection#GtkTreeSelection-struct) *selection`*,
*`[GtkTreePath](gtktreemodel#GtkTreePath-struct) *start_path`*,
*`[GtkTreePath](gtktreemodel#GtkTreePath-struct) *end_path`*);
```
Selects a range of nodes, determined by *`start_path`* and *`end_path`* inclusive. *`selection`* must be set to [GTK\_SELECTION\_MULTIPLE](gtk4-standard-enumerations#GTK-SELECTION-MULTIPLE:CAPS) mode.
#### Parameters
| | | |
| --- | --- | --- |
| selection | A [GtkTreeSelection](gtktreeselection#GtkTreeSelection-struct). | |
| start\_path | The initial node of the range. | |
| end\_path | The final node of the range. | |
### gtk\_tree\_selection\_unselect\_range ()
```
void
gtk_tree_selection_unselect_range (*`[GtkTreeSelection](gtktreeselection#GtkTreeSelection-struct) *selection`*,
*`[GtkTreePath](gtktreemodel#GtkTreePath-struct) *start_path`*,
*`[GtkTreePath](gtktreemodel#GtkTreePath-struct) *end_path`*);
```
Unselects a range of nodes, determined by *`start_path`* and *`end_path`* inclusive.
#### Parameters
| | | |
| --- | --- | --- |
| selection | A [GtkTreeSelection](gtktreeselection#GtkTreeSelection-struct). | |
| start\_path | The initial node of the range. | |
| end\_path | The initial node of the range. | |
Types and Values
----------------
### GtkTreeSelection
```
typedef struct _GtkTreeSelection GtkTreeSelection;
```
Property Details
----------------
### The `“mode”` property
```
“mode” [GtkSelectionMode](gtk4-standard-enumerations#GtkSelectionMode)
```
Selection mode. See [`gtk_tree_selection_set_mode()`](gtktreeselection#gtk-tree-selection-set-mode) for more information on this property.
Owner: GtkTreeSelection
Flags: Read / Write
Default value: GTK\_SELECTION\_SINGLE
Signal Details
--------------
### The `“changed”` signal
```
void
user_function ([GtkTreeSelection](gtktreeselection#GtkTreeSelection-struct) *treeselection,
gpointer user_data)
```
Emitted whenever the selection has (possibly) changed. Please note that this signal is mostly a hint. It may only be emitted once when a range of rows are selected, and it may occasionally be emitted when nothing has happened.
#### Parameters
| | | |
| --- | --- | --- |
| treeselection | the object which received the signal. | |
| user\_data | user data set when the signal handler was connected. | |
Flags: Run First
See Also
--------
[GtkTreeView](gtktreeview#GtkTreeView-struct), [GtkTreeViewColumn](gtktreeviewcolumn#GtkTreeViewColumn-struct), [GtkTreeModel](gtktreemodel#GtkTreeModel-struct), [GtkTreeSortable](gtktreesortable#GtkTreeSortable-struct), [GtkTreeModelSort](gtktreemodelsort#GtkTreeModelSort-struct), [GtkListStore](gtkliststore#GtkListStore-struct), [GtkTreeStore](gtktreestore#GtkTreeStore-struct), [GtkCellRenderer](gtkcellrenderer#GtkCellRenderer-struct), [GtkCellEditable](gtkcelleditable#GtkCellEditable-struct), [GtkCellRendererPixbuf](gtkcellrendererpixbuf#GtkCellRendererPixbuf-struct), [GtkCellRendererText](gtkcellrenderertext#GtkCellRendererText-struct), [GtkCellRendererToggle](gtkcellrenderertoggle#GtkCellRendererToggle-struct), GtkTreeView drag-and-drop
| programming_docs |
gtk GtkDropControllerMotion GtkDropControllerMotion
=======================
GtkDropControllerMotion — Event controller for motion events during a drop
Functions
---------
| | |
| --- | --- |
| [GtkEventController](gtkeventcontroller#GtkEventController-struct) \* | [gtk\_drop\_controller\_motion\_new](gtkdropcontrollermotion#gtk-drop-controller-motion-new) () |
| gboolean | [gtk\_drop\_controller\_motion\_contains\_pointer](gtkdropcontrollermotion#gtk-drop-controller-motion-contains-pointer) () |
| gboolean | [gtk\_drop\_controller\_motion\_is\_pointer](gtkdropcontrollermotion#gtk-drop-controller-motion-is-pointer) () |
| [GdkDrop](https://developer-old.gnome.org/gtk4/html/gdk4-Drag-and-Drop.html#GdkDrop-struct) \* | [gtk\_drop\_controller\_motion\_get\_drop](gtkdropcontrollermotion#gtk-drop-controller-motion-get-drop) () |
Properties
----------
| | | |
| --- | --- | --- |
| gboolean | [contains-pointer](gtkdropcontrollermotion#GtkDropControllerMotion--contains-pointer) | Read |
| [GdkDrop](https://developer-old.gnome.org/gtk4/html/gdk4-Drag-and-Drop.html#GdkDrop-struct) \* | [drop](gtkdropcontrollermotion#GtkDropControllerMotion--drop) | Read |
| gboolean | [is-pointer](gtkdropcontrollermotion#GtkDropControllerMotion--is-pointer) | Read |
Signals
-------
| | | |
| --- | --- | --- |
| void | [enter](gtkdropcontrollermotion#GtkDropControllerMotion-enter) | Run Last |
| void | [leave](gtkdropcontrollermotion#GtkDropControllerMotion-leave) | Run Last |
| void | [motion](gtkdropcontrollermotion#GtkDropControllerMotion-motion) | Run First |
Types and Values
----------------
| | |
| --- | --- |
| | [GtkDropControllerMotion](gtkdropcontrollermotion#GtkDropControllerMotion-struct) |
Object Hierarchy
----------------
```
GObject
╰── [GtkEventController](gtkeventcontroller#GtkEventController-struct)
╰── GtkDropControllerMotion
```
Includes
--------
```
#include <gtk/gtk.h>
```
Description
-----------
[GtkDropControllerMotion](https://developer-old.gnome.org/usr/share/gtk-doc/html/gtk4/gtk4-GtkDropControllerMotion.html#GtkDropControllerMotion) is an event controller meant for tracking the pointer hovering over a widget during a drag and drop operation.
It is modeled after [GtkEventControllerMotion](gtkeventcontrollermotion#GtkEventControllerMotion-struct) so if you have used that, this should feel really familiar.
The drop controller is not able to accept drops, use [GtkDropTarget](gtkdroptarget#GtkDropTarget-struct) for that purpose.
Functions
---------
### gtk\_drop\_controller\_motion\_new ()
```
[GtkEventController](gtkeventcontroller#GtkEventController-struct) *
gtk_drop_controller_motion_new (*`void`*);
```
Creates a new event controller that will handle pointer motion events during drag and drop.
#### Returns
a new [GtkDropControllerMotion](https://developer-old.gnome.org/usr/share/gtk-doc/html/gtk4/gtk4-GtkDropControllerMotion.html#GtkDropControllerMotion)
### gtk\_drop\_controller\_motion\_contains\_pointer ()
```
gboolean
gtk_drop_controller_motion_contains_pointer
(*`[GtkDropControllerMotion](https://developer-old.gnome.org/usr/share/gtk-doc/html/gtk4/gtk4-GtkDropControllerMotion.html#GtkDropControllerMotion) *self`*);
```
Returns the value of the GtkDropControllerMotion:contains-pointer property.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkDropControllerMotion](https://developer-old.gnome.org/usr/share/gtk-doc/html/gtk4/gtk4-GtkDropControllerMotion.html#GtkDropControllerMotion) | |
#### Returns
`TRUE` if a dragging pointer is within *`self`* or one of its children.
### gtk\_drop\_controller\_motion\_is\_pointer ()
```
gboolean
gtk_drop_controller_motion_is_pointer (*`[GtkDropControllerMotion](https://developer-old.gnome.org/usr/share/gtk-doc/html/gtk4/gtk4-GtkDropControllerMotion.html#GtkDropControllerMotion) *self`*);
```
Returns the value of the GtkDropControllerMotion:is-pointer property.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkEventControllerKey](gtkeventcontrollerkey#GtkEventControllerKey-struct) | |
#### Returns
`TRUE` if a dragging pointer is within *`self`* but not one of its children
### gtk\_drop\_controller\_motion\_get\_drop ()
```
[GdkDrop](https://developer-old.gnome.org/gtk4/html/gdk4-Drag-and-Drop.html#GdkDrop-struct) *
gtk_drop_controller_motion_get_drop (*`[GtkDropControllerMotion](https://developer-old.gnome.org/usr/share/gtk-doc/html/gtk4/gtk4-GtkDropControllerMotion.html#GtkDropControllerMotion) *self`*);
```
Returns the value of the GtkDropControllerMotion:drop property.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkDropControllerMotion](https://developer-old.gnome.org/usr/share/gtk-doc/html/gtk4/gtk4-GtkDropControllerMotion.html#GtkDropControllerMotion) | |
#### Returns
The [GdkDrop](https://developer-old.gnome.org/gtk4/html/gdk4-Drag-and-Drop.html#GdkDrop-struct) currently happening within *`self`* or `NULL` if none.
[transfer none][nullable]
Types and Values
----------------
### GtkDropControllerMotion
```
typedef struct _GtkDropControllerMotion GtkDropControllerMotion;
```
Property Details
----------------
### The `“contains-pointer”` property
```
“contains-pointer” gboolean
```
Whether the pointer of a drag and drop operation is in the controller's widget or a descendant. See also [“is-pointer”](gtkdropcontrollermotion#GtkDropControllerMotion--is-pointer).
When handling crossing events, this property is updated before [“enter”](gtkdropcontrollermotion#GtkDropControllerMotion-enter) but after [“leave”](gtkdropcontrollermotion#GtkDropControllerMotion-leave) is emitted.
Owner: GtkDropControllerMotion
Flags: Read
Default value: FALSE
### The `“drop”` property
```
“drop” [GdkDrop](https://developer-old.gnome.org/gtk4/html/gdk4-Drag-and-Drop.html#GdkDrop-struct) *
```
The ongoing drop operation over the controller's widget or its descendant. If no drop operation is going on, this property returns `NULL`.
The event controller should not modify the *`drop`* , but it might want to query its properties.
When handling crossing events, this property is updated before [“enter”](gtkdropcontrollermotion#GtkDropControllerMotion-enter) but after [“leave”](gtkdropcontrollermotion#GtkDropControllerMotion-leave) is emitted.
Owner: GtkDropControllerMotion
Flags: Read
### The `“is-pointer”` property
```
“is-pointer” gboolean
```
Whether the pointer is in the controllers widget itself, as opposed to in a descendent widget. See also [“contains-pointer”](gtkdropcontrollermotion#GtkDropControllerMotion--contains-pointer).
When handling crossing events, this property is updated before [“enter”](gtkdropcontrollermotion#GtkDropControllerMotion-enter) but after [“leave”](gtkdropcontrollermotion#GtkDropControllerMotion-leave) is emitted.
Owner: GtkDropControllerMotion
Flags: Read
Default value: FALSE
Signal Details
--------------
### The `“enter”` signal
```
void
user_function ([GtkDropControllerMotion](https://developer-old.gnome.org/usr/share/gtk-doc/html/gtk4/gtk4-GtkDropControllerMotion.html#GtkDropControllerMotion) *self,
double x,
double y,
gpointer user_data)
```
Signals that the pointer has entered the widget.
#### Parameters
| | | |
| --- | --- | --- |
| self | the object which received the signal | |
| x | coordinates of pointer location | |
| y | coordinates of pointer location | |
| user\_data | user data set when the signal handler was connected. | |
Flags: Run Last
### The `“leave”` signal
```
void
user_function ([GtkDropControllerMotion](https://developer-old.gnome.org/usr/share/gtk-doc/html/gtk4/gtk4-GtkDropControllerMotion.html#GtkDropControllerMotion) *self,
gpointer user_data)
```
Signals that the pointer has left the widget.
#### Parameters
| | | |
| --- | --- | --- |
| self | the object which received the signal | |
| user\_data | user data set when the signal handler was connected. | |
Flags: Run Last
### The `“motion”` signal
```
void
user_function ([GtkDropControllerMotion](https://developer-old.gnome.org/usr/share/gtk-doc/html/gtk4/gtk4-GtkDropControllerMotion.html#GtkDropControllerMotion) *self,
double x,
double y,
gpointer user_data)
```
Emitted when the pointer moves inside the widget.
#### Parameters
| | | |
| --- | --- | --- |
| self | The object that received the signal | |
| x | the x coordinate | |
| y | the y coordinate | |
| user\_data | user data set when the signal handler was connected. | |
Flags: Run First
See Also
--------
[GtkDropControllerMotion](https://developer-old.gnome.org/usr/share/gtk-doc/html/gtk4/gtk4-GtkDropControllerMotion.html#GtkDropControllerMotion), [GdkDrop](https://developer-old.gnome.org/gtk4/html/gdk4-Drag-and-Drop.html#GdkDrop-struct), [GtkDropTarget](gtkdroptarget#GtkDropTarget-struct)
gtk GtkTreeListRowSorter GtkTreeListRowSorter
====================
GtkTreeListRowSorter — Sort trees by levels
Functions
---------
| | |
| --- | --- |
| [GtkTreeListRowSorter](gtktreelistrowsorter#GtkTreeListRowSorter-struct) \* | [gtk\_tree\_list\_row\_sorter\_new](gtktreelistrowsorter#gtk-tree-list-row-sorter-new) () |
| [GtkSorter](gtksorter#GtkSorter-struct) \* | [gtk\_tree\_list\_row\_sorter\_get\_sorter](gtktreelistrowsorter#gtk-tree-list-row-sorter-get-sorter) () |
| void | [gtk\_tree\_list\_row\_sorter\_set\_sorter](gtktreelistrowsorter#gtk-tree-list-row-sorter-set-sorter) () |
Properties
----------
| | | |
| --- | --- | --- |
| [GtkSorter](gtksorter#GtkSorter-struct) \* | [sorter](gtktreelistrowsorter#GtkTreeListRowSorter--sorter) | Read / Write |
Types and Values
----------------
| | |
| --- | --- |
| | [GtkTreeListRowSorter](gtktreelistrowsorter#GtkTreeListRowSorter-struct) |
Object Hierarchy
----------------
```
GObject
╰── [GtkSorter](gtksorter#GtkSorter-struct)
╰── GtkTreeListRowSorter
```
Includes
--------
```
#include <gtk/gtk.h>
```
Description
-----------
[GtkTreeListRowSorter](gtktreelistrowsorter#GtkTreeListRowSorter-struct) is a special-purpose sorter that will apply a given sorter to the levels in a tree, while respecting the tree structure.
Here is an example for setting up a column view with a tree model and a GtkTreeListSorter:
```
column_sorter = gtk_column_view_get_sorter (view);
sorter = gtk_tree_list_row_sorter_new (g_object_ref (column_sorter));
sort_model = gtk_sort_list_model_new (tree_model, sorter);
selection = gtk_single_selection_new (sort_model);
gtk_column_view_set_model (view, G_LIST_MODEL (selection));
```
| Functions
---------
### gtk\_tree\_list\_row\_sorter\_new ()
```
[GtkTreeListRowSorter](gtktreelistrowsorter#GtkTreeListRowSorter-struct) *
gtk_tree_list_row_sorter_new (*`[GtkSorter](gtksorter#GtkSorter-struct) *sorter`*);
```
Create a special-purpose sorter that applies the sorting of *`sorter`* to the levels of a [GtkTreeListModel](gtktreelistmodel#GtkTreeListModel-struct).
Note that this sorter relies on [“passthrough”](gtktreelistmodel#GtkTreeListModel--passthrough) being `FALSE` as it can only sort [GtkTreeListRows](gtktreelistmodel#GtkTreeListRow-struct).
#### Parameters
| | | |
| --- | --- | --- |
| sorter | a [GtkSorter](gtksorter#GtkSorter-struct), or `NULL`. | [nullable][transfer full] |
#### Returns
a new [GtkTreeListRowSorter](gtktreelistrowsorter#GtkTreeListRowSorter-struct)
### gtk\_tree\_list\_row\_sorter\_get\_sorter ()
```
[GtkSorter](gtksorter#GtkSorter-struct) *
gtk_tree_list_row_sorter_get_sorter (*`[GtkTreeListRowSorter](gtktreelistrowsorter#GtkTreeListRowSorter-struct) *self`*);
```
Returns the sorter used by *`self`* .
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkTreeListRowSorter](gtktreelistrowsorter#GtkTreeListRowSorter-struct) | |
#### Returns
the sorter used.
[transfer none][nullable]
### gtk\_tree\_list\_row\_sorter\_set\_sorter ()
```
void
gtk_tree_list_row_sorter_set_sorter (*`[GtkTreeListRowSorter](gtktreelistrowsorter#GtkTreeListRowSorter-struct) *self`*,
*`[GtkSorter](gtksorter#GtkSorter-struct) *sorter`*);
```
Sets the sorter to use for items with the same parent.
This sorter will be passed the [“item”](gtktreelistmodel#GtkTreeListRow--item) of the tree list rows passed to *`self`* .
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkTreeListRowSorter](gtktreelistrowsorter#GtkTreeListRowSorter-struct) | |
| sorter | The sorter to use, or `NULL`. | [nullable][transfer none] |
Types and Values
----------------
### GtkTreeListRowSorter
```
typedef struct _GtkTreeListRowSorter GtkTreeListRowSorter;
```
Property Details
----------------
### The `“sorter”` property
```
“sorter” [GtkSorter](gtksorter#GtkSorter-struct) *
```
The underlying sorter
Owner: GtkTreeListRowSorter
Flags: Read / Write
See Also
--------
[GtkTreeListModel](gtktreelistmodel#GtkTreeListModel-struct)
gtk GtkSizeGroup GtkSizeGroup
============
GtkSizeGroup — Grouping widgets so they request the same size
Functions
---------
| | |
| --- | --- |
| [GtkSizeGroup](gtksizegroup#GtkSizeGroup-struct) \* | [gtk\_size\_group\_new](gtksizegroup#gtk-size-group-new) () |
| void | [gtk\_size\_group\_set\_mode](gtksizegroup#gtk-size-group-set-mode) () |
| [GtkSizeGroupMode](gtksizegroup#GtkSizeGroupMode) | [gtk\_size\_group\_get\_mode](gtksizegroup#gtk-size-group-get-mode) () |
| void | [gtk\_size\_group\_add\_widget](gtksizegroup#gtk-size-group-add-widget) () |
| void | [gtk\_size\_group\_remove\_widget](gtksizegroup#gtk-size-group-remove-widget) () |
| GSList \* | [gtk\_size\_group\_get\_widgets](gtksizegroup#gtk-size-group-get-widgets) () |
Properties
----------
| | | |
| --- | --- | --- |
| [GtkSizeGroupMode](gtksizegroup#GtkSizeGroupMode) | [mode](gtksizegroup#GtkSizeGroup--mode) | Read / Write |
Types and Values
----------------
| | |
| --- | --- |
| struct | [GtkSizeGroup](gtksizegroup#GtkSizeGroup-struct) |
| enum | [GtkSizeGroupMode](gtksizegroup#GtkSizeGroupMode) |
Object Hierarchy
----------------
```
GObject
╰── GtkSizeGroup
```
Implemented Interfaces
----------------------
GtkSizeGroup implements [GtkBuildable](gtkbuildable#GtkBuildable-struct).
Includes
--------
```
#include <gtk/gtk.h>
```
Description
-----------
[GtkSizeGroup](gtksizegroup#GtkSizeGroup-struct) provides a mechanism for grouping a number of widgets together so they all request the same amount of space. This is typically useful when you want a column of widgets to have the same size, but you can’t use a [GtkGrid](gtkgrid#GtkGrid-struct) widget.
In detail, the size requested for each widget in a [GtkSizeGroup](gtksizegroup#GtkSizeGroup-struct) is the maximum of the sizes that would have been requested for each widget in the size group if they were not in the size group. The mode of the size group (see [`gtk_size_group_set_mode()`](gtksizegroup#gtk-size-group-set-mode)) determines whether this applies to the horizontal size, the vertical size, or both sizes.
Note that size groups only affect the amount of space requested, not the size that the widgets finally receive. If you want the widgets in a [GtkSizeGroup](gtksizegroup#GtkSizeGroup-struct) to actually be the same size, you need to pack them in such a way that they get the size they request and not more. For example, if you are packing your widgets into a table, you would not include the `GTK_FILL` flag.
[GtkSizeGroup](gtksizegroup#GtkSizeGroup-struct) objects are referenced by each widget in the size group, so once you have added all widgets to a [GtkSizeGroup](gtksizegroup#GtkSizeGroup-struct), you can drop the initial reference to the size group with `g_object_unref()`. If the widgets in the size group are subsequently destroyed, then they will be removed from the size group and drop their references on the size group; when all widgets have been removed, the size group will be freed.
Widgets can be part of multiple size groups; GTK will compute the horizontal size of a widget from the horizontal requisition of all widgets that can be reached from the widget by a chain of size groups of type [`GTK_SIZE_GROUP_HORIZONTAL`](gtksizegroup#GTK-SIZE-GROUP-HORIZONTAL:CAPS) or [`GTK_SIZE_GROUP_BOTH`](gtksizegroup#GTK-SIZE-GROUP-BOTH:CAPS), and the vertical size from the vertical requisition of all widgets that can be reached from the widget by a chain of size groups of type [`GTK_SIZE_GROUP_VERTICAL`](gtksizegroup#GTK-SIZE-GROUP-VERTICAL:CAPS) or [`GTK_SIZE_GROUP_BOTH`](gtksizegroup#GTK-SIZE-GROUP-BOTH:CAPS).
Note that only non-contextual sizes of every widget are ever consulted by size groups (since size groups have no knowledge of what size a widget will be allocated in one dimension, it cannot derive how much height a widget will receive for a given width). When grouping widgets that trade height for width in mode [`GTK_SIZE_GROUP_VERTICAL`](gtksizegroup#GTK-SIZE-GROUP-VERTICAL:CAPS) or [`GTK_SIZE_GROUP_BOTH`](gtksizegroup#GTK-SIZE-GROUP-BOTH:CAPS): the height for the minimum width will be the requested height for all widgets in the group. The same is of course true when horizontally grouping width for height widgets.
Widgets that trade height-for-width should set a reasonably large minimum width by way of [“width-chars”](gtklabel#GtkLabel--width-chars) for instance. Widgets with static sizes as well as widgets that grow (such as ellipsizing text) need no such considerations.
### GtkSizeGroup as GtkBuildable
Size groups can be specified in a UI definition by placing an <object> element with `class="GtkSizeGroup"` somewhere in the UI definition. The widgets that belong to the size group are specified by a <widgets> element that may contain multiple <widget> elements, one for each member of the size group. The ”name” attribute gives the id of the widget.
An example of a UI definition fragment with GtkSizeGroup:
```
<object class="GtkSizeGroup">
<property name="mode">horizontal</property>
<widgets>
<widget name="radio1"/>
<widget name="radio2"/>
</widgets>
</object>
```
| Functions
---------
### gtk\_size\_group\_new ()
```
[GtkSizeGroup](gtksizegroup#GtkSizeGroup-struct) *
gtk_size_group_new (*`[GtkSizeGroupMode](gtksizegroup#GtkSizeGroupMode) mode`*);
```
Create a new [GtkSizeGroup](gtksizegroup#GtkSizeGroup-struct).
#### Parameters
| | | |
| --- | --- | --- |
| mode | the mode for the new size group. | |
#### Returns
a newly created [GtkSizeGroup](gtksizegroup#GtkSizeGroup-struct)
### gtk\_size\_group\_set\_mode ()
```
void
gtk_size_group_set_mode (*`[GtkSizeGroup](gtksizegroup#GtkSizeGroup-struct) *size_group`*,
*`[GtkSizeGroupMode](gtksizegroup#GtkSizeGroupMode) mode`*);
```
Sets the [GtkSizeGroupMode](gtksizegroup#GtkSizeGroupMode) of the size group. The mode of the size group determines whether the widgets in the size group should all have the same horizontal requisition ([`GTK_SIZE_GROUP_HORIZONTAL`](gtksizegroup#GTK-SIZE-GROUP-HORIZONTAL:CAPS)) all have the same vertical requisition ([`GTK_SIZE_GROUP_VERTICAL`](gtksizegroup#GTK-SIZE-GROUP-VERTICAL:CAPS)), or should all have the same requisition in both directions ([`GTK_SIZE_GROUP_BOTH`](gtksizegroup#GTK-SIZE-GROUP-BOTH:CAPS)).
#### Parameters
| | | |
| --- | --- | --- |
| size\_group | a [GtkSizeGroup](gtksizegroup#GtkSizeGroup-struct) | |
| mode | the mode to set for the size group. | |
### gtk\_size\_group\_get\_mode ()
```
[GtkSizeGroupMode](gtksizegroup#GtkSizeGroupMode)
gtk_size_group_get_mode (*`[GtkSizeGroup](gtksizegroup#GtkSizeGroup-struct) *size_group`*);
```
Gets the current mode of the size group. See [`gtk_size_group_set_mode()`](gtksizegroup#gtk-size-group-set-mode).
#### Parameters
| | | |
| --- | --- | --- |
| size\_group | a [GtkSizeGroup](gtksizegroup#GtkSizeGroup-struct) | |
#### Returns
the current mode of the size group.
### gtk\_size\_group\_add\_widget ()
```
void
gtk_size_group_add_widget (*`[GtkSizeGroup](gtksizegroup#GtkSizeGroup-struct) *size_group`*,
*`[GtkWidget](gtkwidget#GtkWidget-struct) *widget`*);
```
Adds a widget to a [GtkSizeGroup](gtksizegroup#GtkSizeGroup-struct). In the future, the requisition of the widget will be determined as the maximum of its requisition and the requisition of the other widgets in the size group. Whether this applies horizontally, vertically, or in both directions depends on the mode of the size group. See [`gtk_size_group_set_mode()`](gtksizegroup#gtk-size-group-set-mode).
When the widget is destroyed or no longer referenced elsewhere, it will be removed from the size group.
#### Parameters
| | | |
| --- | --- | --- |
| size\_group | a [GtkSizeGroup](gtksizegroup#GtkSizeGroup-struct) | |
| widget | the [GtkWidget](gtkwidget#GtkWidget-struct) to add | |
### gtk\_size\_group\_remove\_widget ()
```
void
gtk_size_group_remove_widget (*`[GtkSizeGroup](gtksizegroup#GtkSizeGroup-struct) *size_group`*,
*`[GtkWidget](gtkwidget#GtkWidget-struct) *widget`*);
```
Removes a widget from a [GtkSizeGroup](gtksizegroup#GtkSizeGroup-struct).
#### Parameters
| | | |
| --- | --- | --- |
| size\_group | a [GtkSizeGroup](gtksizegroup#GtkSizeGroup-struct) | |
| widget | the [GtkWidget](gtkwidget#GtkWidget-struct) to remove | |
### gtk\_size\_group\_get\_widgets ()
```
GSList *
gtk_size_group_get_widgets (*`[GtkSizeGroup](gtksizegroup#GtkSizeGroup-struct) *size_group`*);
```
Returns the list of widgets associated with *`size_group`* .
#### Parameters
| | | |
| --- | --- | --- |
| size\_group | a [GtkSizeGroup](gtksizegroup#GtkSizeGroup-struct) | |
#### Returns
a GSList of widgets. The list is owned by GTK and should not be modified.
[element-type GtkWidget][transfer none]
Types and Values
----------------
### struct GtkSizeGroup
```
struct GtkSizeGroup;
```
### enum GtkSizeGroupMode
The mode of the size group determines the directions in which the size group affects the requested sizes of its component widgets.
#### Members
| | | |
| --- | --- | --- |
| GTK\_SIZE\_GROUP\_NONE | group has no effect | |
| GTK\_SIZE\_GROUP\_HORIZONTAL | group affects horizontal requisition | |
| GTK\_SIZE\_GROUP\_VERTICAL | group affects vertical requisition | |
| GTK\_SIZE\_GROUP\_BOTH | group affects both horizontal and vertical requisition | |
Property Details
----------------
### The `“mode”` property
```
“mode” [GtkSizeGroupMode](gtksizegroup#GtkSizeGroupMode)
```
The directions in which the size group affects the requested sizes of its component widgets.
Owner: GtkSizeGroup
Flags: Read / Write
Default value: GTK\_SIZE\_GROUP\_HORIZONTAL
| programming_docs |
gtk GTK CSS Properties GTK CSS Properties
==================
| Property | Reference | Notes |
| --- | --- | --- |
| color | [CSS Color Level 3](https://www.w3.org/TR/css3-color/#foreground) | |
| opacity | [CSS Color Level 3](https://www.w3.org/TR/css3-color/#opacity) | |
| filter | [CSS Filter Effect Level 1](https://drafts.fxtf.org/filters/#FilterProperty) | CSS allows drop-shadow |
| font-family | [CSS Fonts Level 3](https://www.w3.org/TR/css3-fonts/#font-family-prop) | defaults to gtk-font-name setting |
| font-size | [CSS Fonts Level 3](https://www.w3.org/TR/css3-fonts/#font-size-prop) | defaults to gtk-font-name setting |
| font-style | [CSS Fonts Level 3](https://www.w3.org/TR/css3-fonts/#font-style-prop) | |
| font-variant | [CSS Fonts Level 3](https://www.w3.org/TR/css3-fonts/#descdef-font-variant) | only CSS2 values supported |
| font-weight | [CSS Fonts Level 3](https://www.w3.org/TR/css3-fonts/#font-weight-prop) | |
| font-stretch | [CSS Fonts Level 3](https://www.w3.org/TR/css3-fonts/#font-stretch-prop) | |
| font-kerning | [CSS Fonts Level 3](https://www.w3.org/TR/css3-fonts/#font-kerning-prop) | |
| font-variant-ligatures | [CSS Fonts Level 3](https://www.w3.org/TR/css3-fonts/#font-variant-ligatures-prop) | |
| font-variant-position | [CSS Fonts Level 3](https://www.w3.org/TR/css3-fonts/#font-variant-position-prop) | |
| font-variant-caps | [CSS Fonts Level 3](https://www.w3.org/TR/css3-fonts/#font-variant-position-prop) | |
| font-variant-numeric | [CSS Fonts Level 3](https://www.w3.org/TR/css3-fonts/#font-variant-numeric-prop) | |
| font-variant-alternates | [CSS Fonts Level 3](https://www.w3.org/TR/css3-fonts/#font-variant-alternates-prop) | |
| font-variant-east-asian | [CSS Fonts Level 3](https://www.w3.org/TR/css3-fonts/#font-variant-east-asian-prop) | |
| font-feature-settings | [CSS Fonts Level 3](https://www.w3.org/TR/css3-fonts/#font-feature-settings-prop) | |
| font-variation-settings | [CSS Fonts Level 4](https://www.w3.org/TR/css-fonts-4/#font-variation-settings-def) | |
| -gtk-dpi | [Number](https://www.w3.org/TR/css3-values/#number-value) | defaults to screen resolution |
| font | [CSS Fonts Level 3](https://www.w3.org/TR/css3-fonts/#font-prop) | CSS allows line-height, etc |
| font-variant | [CSS Fonts Level 3](https://www.w3.org/TR/css3-fonts/#font-variant-prop) | |
| caret-color | [CSS Basic User Interface Level 3](https://www.w3.org/TR/css3-ui/#caret-color) | CSS allows an auto value |
| -gtk-secondary-caret-color | [Color](https://www.w3.org/TR/css-color-3/#valuea-def-color) | used for the secondary caret in bidirectional text |
| letter-spacing | [CSS Text Level 3](https://www.w3.org/TR/css3-text/#letter-spacing) | |
| text-decoration-line | [CSS Text Decoration Level 3](https://www.w3.org/TR/css-text-decor-3/#text-decoration-line-property) | CSS allows overline |
| text-decoration-color | [CSS Text Decoration Level 3](https://www.w3.org/TR/css-text-decor-3/#text-decoration-color-property) | |
| text-decoration-style | [CSS Text Decoration Level 3](https://www.w3.org/TR/css-text-decor-3/#text-decoration-style-property) | CSS allows dashed and dotted |
| text-shadow | [CSS Text Decoration Level 3](https://www.w3.org/TR/css-text-decor-3/#text-shadow-property) | |
| text-decoration | [CSS Text Decoration Level 3](https://www.w3.org/TR/css-text-decor-3/#text-decoration-property) | |
| -gtk-icon-source | [Image](https://www.w3.org/TR/css-backgrounds-3/#typedef-image), `builtin` or `none` | used for builtin icons in buttons and expanders |
| -gtk-icon-size | [Length](https://www.w3.org/TR/css3-values/#length-value) | size used for builtin icons in buttons and expanders |
| -gtk-icon-style | `requested`, `regular` or `symbolic` | preferred style for application-loaded icons |
| -gtk-icon-transform | [Transform list](https://drafts.csswg.org/css-transforms-1/#typedef-transform-list) or `none` | applied to builtin and application-loaded icons |
| -gtk-icon-palette | Color palette, as explained above | used to recolor symbolic icons |
| -gtk-icon-shadow | [Shadow](https://www.w3.org/TR/css-backgrounds-3/#typedef-shadow) or `none` | applied to builtin and application-loaded icons |
| -gtk-icon-filter | [Filter value list](https://www.w3.org/TR/filter-effects-1/#typedef-filter-value-list) or `none` | applied to builtin and application-loaded icons |
| transform | [CSS Transforms Level 2](https://drafts.csswg.org/css-transforms-2/) | |
| min-width | [CSS Box Model Level 3](https://www.w3.org/TR/css3-box/#min-width) | CSS allows percentages |
| min-height | [CSS Box Model Level 3](https://www.w3.org/TR/css3-box/#min-height) | CSS allows percentages |
| margin-top | [CSS Box Model Level 3](https://www.w3.org/TR/css3-box/#margin-top) | CSS allows percentages or auto |
| margin-right | [CSS Box Model Level 3](https://www.w3.org/TR/css3-box/#margin-right) | CSS allows percentages or auto |
| margin-bottom | [CSS Box Model Level 3](https://www.w3.org/TR/css3-box/#margin-bottom) | CSS allows percentages or auto |
| margin-left | [CSS Box Model Level 3](https://www.w3.org/TR/css3-box/#margin-left) | CSS allows percentages or auto |
| padding-top | [CSS Box Model Level 3](https://www.w3.org/TR/css3-box/#padding-top) | CSS allows percentages |
| padding-right | [CSS Box Model Level 3](https://www.w3.org/TR/css3-box/#padding-right) | CSS allows percentages |
| padding-bottom | [CSS Box Model Level 3](https://www.w3.org/TR/css3-box/#padding-bottom) | CSS allows percentages |
| padding-left | [CSS Box Model Level 3](https://www.w3.org/TR/css3-box/#padding-left) | CSS allows percentages |
| margin | [CSS Box Model Level 3](https://www.w3.org/TR/css3-box/#margin) | a “four sides” property |
| padding | [CSS Box Model Level 3](https://www.w3.org/TR/css3-box/#padding) | a “four sides” property |
| border-top-width | [CSS Backgrounds and Borders Level 3](https://www.w3.org/TR/css3-background/#the-border-width) | CSS allows other values |
| border-right-width | [CSS Backgrounds and Borders Level 3](https://www.w3.org/TR/css3-background/#the-border-width) | CSS allows other values |
| border-bottom-width | [CSS Backgrounds and Borders Level 3](https://www.w3.org/TR/css3-background/#the-border-width) | CSS allows other values |
| border-left-width | [CSS Backgrounds and Borders Level 3](https://www.w3.org/TR/css3-background/#the-border-width) | CSS allows other values |
| border-top-style | [CSS Backgrounds and Borders Level 3](https://www.w3.org/TR/css3-background/#the-border-style) | |
| border-right-style | [CSS Backgrounds and Borders Level 3](https://www.w3.org/TR/css3-background/#the-border-style) | |
| border-bottom-style | [CSS Backgrounds and Borders Level 3](https://www.w3.org/TR/css3-background/#the-border-style) | |
| border-left-style | [CSS Backgrounds and Borders Level 3](https://www.w3.org/TR/css3-background/#the-border-style) | |
| border-top-right-radius | [CSS Backgrounds and Borders Level 3](https://www.w3.org/TR/css3-background/#the-border-radius) | |
| border-bottom-right-radius | [CSS Backgrounds and Borders Level 3](https://www.w3.org/TR/css3-background/#the-border-radius) | |
| border-bottom-left-radius | [CSS Backgrounds and Borders Level 3](https://www.w3.org/TR/css3-background/#the-border-radius) | |
| border-top-left-radius | [CSS Backgrounds and Borders Level 3](https://www.w3.org/TR/css3-background/#the-border-radius) | |
| border-top-color | [CSS Backgrounds and Borders Level 3](https://www.w3.org/TR/css3-background/#the-border-color) | |
| border-right-color | [CSS Backgrounds and Borders Level 3](https://www.w3.org/TR/css3-background/#the-border-color) | |
| border-bottom-color | [CSS Backgrounds and Borders Level 3](https://www.w3.org/TR/css3-background/#the-border-color) | |
| border-left-color | [CSS Backgrounds and Borders Level 3](https://www.w3.org/TR/css3-background/#the-border-color) | |
| border-image-source | [CSS Backgrounds and Borders Level 3](https://www.w3.org/TR/css3-background/#the-border-image-source) | |
| border-image-repeat | [CSS Backgrounds and Borders Level 3](https://www.w3.org/TR/css3-background/#the-border-image-repeat) | |
| border-image-slice | [CSS Backgrounds and Borders Level 3](https://www.w3.org/TR/css3-background/#the-border-image-slice) | a “four sides” property |
| border-image-width | [CSS Backgrounds and Borders Level 3](https://www.w3.org/TR/css3-background/#the-border-image-width) | a “four sides” property |
| border-width | [CSS Backgrounds and Borders Level 3](https://www.w3.org/TR/css3-background/#the-border-width) | a “four sides” property |
| border-style | [CSS Backgrounds and Borders Level 3](https://www.w3.org/TR/css3-background/#the-border-style) | a “four sides” property |
| border-color | [CSS Backgrounds and Borders Level 3](https://www.w3.org/TR/css3-background/#border-color) | a “four sides” property |
| border-top | [CSS Backgrounds and Borders Level 3](https://www.w3.org/TR/css3-background/#border-top) | |
| border-right | [CSS Backgrounds and Borders Level 3](https://www.w3.org/TR/css3-background/#border-right) | |
| border-bottom | [CSS Backgrounds and Borders Level 3](https://www.w3.org/TR/css3-background/#border-bottom) | |
| border-left | [CSS Backgrounds and Borders Level 3](https://www.w3.org/TR/css3-background/#border-left) | |
| border | [CSS Backgrounds and Borders Level 3](https://www.w3.org/TR/css3-background/#border) | |
| border-radius | [CSS Backgrounds and Borders Level 3](https://www.w3.org/TR/css3-background/#border-radius) | |
| border-image | [CSS Backgrounds and Borders Level 3](https://www.w3.org/TR/css3-background/#border-image) | |
| outline-style | [CSS Basic User Interface Level 3](https://www.w3.org/TR/css3-ui/#outline-style) | initial value is none, auto is not supported |
| outline-width | [CSS Basic User Interface Level 3](https://www.w3.org/TR/css3-ui/#outline-width) | |
| outline-color | [CSS Basic User Interface Level 3](https://www.w3.org/TR/css3-ui/#outline-color) | initial value is currentColor, invert is not supported |
| outline-offset | [CSS Basic User Interface Level 3](https://www.w3.org/TR/css3-ui/#outline-offset) | |
| outline | [CSS Basic User Interface Level 3](https://www.w3.org/TR/css3-ui/#propdef-outline) | |
| background-color | [CSS Backgrounds and Borders Level 3](https://www.w3.org/TR/css3-background/#background-color) | |
| background-clip | [CSS Backgrounds and Borders Level 3](https://www.w3.org/TR/css3-background/#background-clip) | |
| background-origin | [CSS Backgrounds and Borders Level 3](https://www.w3.org/TR/css3-background/#background-origin) | |
| background-size | [CSS Backgrounds and Borders Level 3](https://www.w3.org/TR/css3-background/#background-size) | |
| background-position | [CSS Backgrounds and Borders Level 3](https://www.w3.org/TR/css3-background/#background-position) | |
| background-repeat | [CSS Backgrounds and Borders Level 3](https://www.w3.org/TR/css3-background/#background-repeat) | |
| background-image | [CSS Backgrounds and Borders Level 3](https://www.w3.org/TR/css3-background/#background-image) | not supported: urls without quotes, colors in crossfades |
| box-shadow | [CSS Backgrounds and Borders Level 3](https://www.w3.org/TR/css3-background/#box-shadow) | |
| background-blend-mode | [CSS Compositing and Blending Level 1](https://www.w3.org/TR/compositing-1/#propdef-background-blend-mode) | only affects multiple backgrounds |
| background | [CSS Backgrounds and Borders Level 3](https://www.w3.org/TR/css3-background/#background) | |
| transition-property | [CSS Transitions](https://www.w3.org/TR/css3-transitions/#transition-property) | |
| transition-duration | [CSS Transitions](https://www.w3.org/TR/css3-transitions/#transition-duration) | |
| transition-timing-function | [CSS Transitions](https://www.w3.org/TR/css3-transitions/#transition-timing-function) | |
| transition-delay | [CSS Transitions](https://www.w3.org/TR/css3-transitions/#transition-delay) | |
| transition | [CSS Transitions](https://www.w3.org/TR/css3-transitions/#transition) | |
| animation-name | [CSS Animations Level 1](https://www.w3.org/TR/css3-animations/#animation-name) | |
| animation-duration | [CSS Animations Level 1](https://www.w3.org/TR/css3-animations/#animation-duration) | |
| animation-timing-function | [CSS Animations Level 1](https://www.w3.org/TR/css3-animations/#animation-timing-function) | |
| animation-iteration-count | [CSS Animations Level 1](https://www.w3.org/TR/css3-animations/#animation-iteration-count) | |
| animation-direction | [CSS Animations Level 1](https://www.w3.org/TR/css3-animations/#animation-direction) | |
| animation-play-state | [CSS Animations Level 1](https://www.w3.org/TR/css3-animations/#animation-play-state) | |
| animation-delay | [CSS Animations Level 1](https://www.w3.org/TR/css3-animations/#animation-delay) | |
| animation-fill-mode | [CSS Animations Level 1](https://www.w3.org/TR/css3-animations/#animation-fill-mode) | |
| animation | [CSS Animations Level 1](https://www.w3.org/TR/css3-animations/#animation) | |
| border-spacing | [CSS Table Level 3](https://www.w3.org/TR/css-tables-3/#border-spacing-property) | respected by GtkBoxLayout, GtkGridLayout, GtkCenterLayout |
gtk gtk4-encode-symbolic-svg gtk4-encode-symbolic-svg
========================
gtk4-encode-symbolic-svg — Symbolic icon conversion utility
Synopsis
--------
`gtk4-encode-symbolic-svg` [OPTION...] *`PATH`* *`WIDTH`*x*`HEIGHT`*
Description
-----------
**gtk4-encode-symbolic-svg** converts symbolic svg icons into specially prepared png files. GTK can load and recolor these pngs, just like original svgs, but loading them is much faster.
*`PATH`* is the name of a symbolic svg file, *`WIDTH`*x*`HEIGHT`* are the desired dimensions for the generated png file.
To distinguish them from ordinary pngs, the generated files have the extension `.symbolic.png`.
Options
-------
| | |
| --- | --- |
| -o *`DIRECTORY`*, --output *`DIRECTORY`* | Write png files to *`DIRECTORY`* instead of the current working directory. |
| --debug | Generate png files of the various channels during the conversion. If these files are not monochrome green, they are often helpful in pinpointing the problematic parts of the source svg. |
gtk GtkNativeDialog GtkNativeDialog
===============
GtkNativeDialog — Integrate with native dialogs
Functions
---------
| | |
| --- | --- |
| void | [gtk\_native\_dialog\_show](gtknativedialog#gtk-native-dialog-show) () |
| void | [gtk\_native\_dialog\_hide](gtknativedialog#gtk-native-dialog-hide) () |
| void | [gtk\_native\_dialog\_destroy](gtknativedialog#gtk-native-dialog-destroy) () |
| gboolean | [gtk\_native\_dialog\_get\_visible](gtknativedialog#gtk-native-dialog-get-visible) () |
| void | [gtk\_native\_dialog\_set\_modal](gtknativedialog#gtk-native-dialog-set-modal) () |
| gboolean | [gtk\_native\_dialog\_get\_modal](gtknativedialog#gtk-native-dialog-get-modal) () |
| void | [gtk\_native\_dialog\_set\_title](gtknativedialog#gtk-native-dialog-set-title) () |
| const char \* | [gtk\_native\_dialog\_get\_title](gtknativedialog#gtk-native-dialog-get-title) () |
| void | [gtk\_native\_dialog\_set\_transient\_for](gtknativedialog#gtk-native-dialog-set-transient-for) () |
| [GtkWindow](gtkwindow#GtkWindow-struct) \* | [gtk\_native\_dialog\_get\_transient\_for](gtknativedialog#gtk-native-dialog-get-transient-for) () |
Properties
----------
| | | |
| --- | --- | --- |
| gboolean | [modal](gtknativedialog#GtkNativeDialog--modal) | Read / Write |
| char \* | [title](gtknativedialog#GtkNativeDialog--title) | Read / Write |
| [GtkWindow](gtkwindow#GtkWindow-struct) \* | [transient-for](gtknativedialog#GtkNativeDialog--transient-for) | Read / Write / Construct |
| gboolean | [visible](gtknativedialog#GtkNativeDialog--visible) | Read / Write |
Signals
-------
| | | |
| --- | --- | --- |
| void | [response](gtknativedialog#GtkNativeDialog-response) | Run Last |
Types and Values
----------------
| | |
| --- | --- |
| | [GtkNativeDialog](gtknativedialog#GtkNativeDialog-struct) |
| struct | [GtkNativeDialogClass](gtknativedialog#GtkNativeDialogClass) |
Object Hierarchy
----------------
```
GObject
╰── GtkNativeDialog
╰── [GtkFileChooserNative](gtkfilechoosernative#GtkFileChooserNative-struct)
```
Includes
--------
```
#include <gtk/gtk.h>
```
Description
-----------
Native dialogs are platform dialogs that don't use [GtkDialog](gtkdialog#GtkDialog-struct) or [GtkWindow](gtkwindow#GtkWindow-struct). They are used in order to integrate better with a platform, by looking the same as other native applications and supporting platform specific features.
The [GtkDialog](gtkdialog#GtkDialog-struct) functions cannot be used on such objects, but we need a similar API in order to drive them. The [GtkNativeDialog](gtknativedialog#GtkNativeDialog-struct) object is an API that allows you to do this. It allows you to set various common properties on the dialog, as well as show and hide it and get a [“response”](gtknativedialog#GtkNativeDialog-response) signal when the user finished with the dialog.
Note that unlike [GtkDialog](gtkdialog#GtkDialog-struct), [GtkNativeDialog](gtknativedialog#GtkNativeDialog-struct) objects are not toplevel widgets, and GTK does not keep them alive. It is your responsibility to keep a reference until you are done with the object.
Functions
---------
### gtk\_native\_dialog\_show ()
```
void
gtk_native_dialog_show (*`[GtkNativeDialog](gtknativedialog#GtkNativeDialog-struct) *self`*);
```
Shows the dialog on the display, allowing the user to interact with it. When the user accepts the state of the dialog the dialog will be automatically hidden and the [“response”](gtknativedialog#GtkNativeDialog-response) signal will be emitted.
Multiple calls while the dialog is visible will be ignored.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkNativeDialog](gtknativedialog#GtkNativeDialog-struct) | |
### gtk\_native\_dialog\_hide ()
```
void
gtk_native_dialog_hide (*`[GtkNativeDialog](gtknativedialog#GtkNativeDialog-struct) *self`*);
```
Hides the dialog if it is visilbe, aborting any interaction. Once this is called the [“response”](gtknativedialog#GtkNativeDialog-response) signal will not be emitted until after the next call to [`gtk_native_dialog_show()`](gtknativedialog#gtk-native-dialog-show).
If the dialog is not visible this does nothing.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkNativeDialog](gtknativedialog#GtkNativeDialog-struct) | |
### gtk\_native\_dialog\_destroy ()
```
void
gtk_native_dialog_destroy (*`[GtkNativeDialog](gtknativedialog#GtkNativeDialog-struct) *self`*);
```
Destroys a dialog.
When a dialog is destroyed, it will break any references it holds to other objects. If it is visible it will be hidden and any underlying window system resources will be destroyed.
Note that this does not release any reference to the object (as opposed to destroying a GtkWindow) because there is no reference from the windowing system to the [GtkNativeDialog](gtknativedialog#GtkNativeDialog-struct).
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkNativeDialog](gtknativedialog#GtkNativeDialog-struct) | |
### gtk\_native\_dialog\_get\_visible ()
```
gboolean
gtk_native_dialog_get_visible (*`[GtkNativeDialog](gtknativedialog#GtkNativeDialog-struct) *self`*);
```
Determines whether the dialog is visible.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkNativeDialog](gtknativedialog#GtkNativeDialog-struct) | |
#### Returns
`TRUE` if the dialog is visible
### gtk\_native\_dialog\_set\_modal ()
```
void
gtk_native_dialog_set_modal (*`[GtkNativeDialog](gtknativedialog#GtkNativeDialog-struct) *self`*,
*`gboolean modal`*);
```
Sets a dialog modal or non-modal. Modal dialogs prevent interaction with other windows in the same application. To keep modal dialogs on top of main application windows, use [`gtk_native_dialog_set_transient_for()`](gtknativedialog#gtk-native-dialog-set-transient-for) to make the dialog transient for the parent; most window managers will then disallow lowering the dialog below the parent.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkNativeDialog](gtknativedialog#GtkNativeDialog-struct) | |
| modal | whether the window is modal | |
### gtk\_native\_dialog\_get\_modal ()
```
gboolean
gtk_native_dialog_get_modal (*`[GtkNativeDialog](gtknativedialog#GtkNativeDialog-struct) *self`*);
```
Returns whether the dialog is modal. See [`gtk_native_dialog_set_modal()`](gtknativedialog#gtk-native-dialog-set-modal).
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkNativeDialog](gtknativedialog#GtkNativeDialog-struct) | |
#### Returns
`TRUE` if the dialog is set to be modal
### gtk\_native\_dialog\_set\_title ()
```
void
gtk_native_dialog_set_title (*`[GtkNativeDialog](gtknativedialog#GtkNativeDialog-struct) *self`*,
*`const char *title`*);
```
Sets the title of the [GtkNativeDialog](gtknativedialog#GtkNativeDialog-struct).
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkNativeDialog](gtknativedialog#GtkNativeDialog-struct) | |
| title | title of the dialog | |
### gtk\_native\_dialog\_get\_title ()
```
const char *
gtk_native_dialog_get_title (*`[GtkNativeDialog](gtknativedialog#GtkNativeDialog-struct) *self`*);
```
Gets the title of the [GtkNativeDialog](gtknativedialog#GtkNativeDialog-struct).
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkNativeDialog](gtknativedialog#GtkNativeDialog-struct) | |
#### Returns
the title of the dialog, or `NULL` if none has been set explicitly. The returned string is owned by the widget and must not be modified or freed.
[nullable]
### gtk\_native\_dialog\_set\_transient\_for ()
```
void
gtk_native_dialog_set_transient_for (*`[GtkNativeDialog](gtknativedialog#GtkNativeDialog-struct) *self`*,
*`[GtkWindow](gtkwindow#GtkWindow-struct) *parent`*);
```
Dialog windows should be set transient for the main application window they were spawned from. This allows window managers to e.g. keep the dialog on top of the main window, or center the dialog over the main window.
Passing `NULL` for *`parent`* unsets the current transient window.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkNativeDialog](gtknativedialog#GtkNativeDialog-struct) | |
| parent | parent window, or `NULL`. | [allow-none] |
### gtk\_native\_dialog\_get\_transient\_for ()
```
[GtkWindow](gtkwindow#GtkWindow-struct) *
gtk_native_dialog_get_transient_for (*`[GtkNativeDialog](gtknativedialog#GtkNativeDialog-struct) *self`*);
```
Fetches the transient parent for this window. See [`gtk_native_dialog_set_transient_for()`](gtknativedialog#gtk-native-dialog-set-transient-for).
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkNativeDialog](gtknativedialog#GtkNativeDialog-struct) | |
#### Returns
the transient parent for this window, or `NULL` if no transient parent has been set.
[nullable][transfer none]
Types and Values
----------------
### GtkNativeDialog
```
typedef struct _GtkNativeDialog GtkNativeDialog;
```
### struct GtkNativeDialogClass
```
struct GtkNativeDialogClass {
void (* response) (GtkNativeDialog *self, int response_id);
};
```
Class structure for [GtkNativeDialog](gtknativedialog#GtkNativeDialog-struct).
#### Members
| | | |
| --- | --- | --- |
| *`response`* () | class handler for the [“response”](gtknativedialog#GtkNativeDialog-response) signal | |
Property Details
----------------
### The `“modal”` property
```
“modal” gboolean
```
Whether the window should be modal with respect to its transient parent.
Owner: GtkNativeDialog
Flags: Read / Write
Default value: FALSE
### The `“title”` property
```
“title” char *
```
The title of the dialog window
Owner: GtkNativeDialog
Flags: Read / Write
Default value: NULL
### The `“transient-for”` property
```
“transient-for” [GtkWindow](gtkwindow#GtkWindow-struct) *
```
The transient parent of the dialog, or `NULL` for none.
Owner: GtkNativeDialog
Flags: Read / Write / Construct
### The `“visible”` property
```
“visible” gboolean
```
Whether the window is currently visible.
Owner: GtkNativeDialog
Flags: Read / Write
Default value: FALSE
Signal Details
--------------
### The `“response”` signal
```
void
user_function ([GtkNativeDialog](gtknativedialog#GtkNativeDialog-struct) *self,
int response_id,
gpointer user_data)
```
Emitted when the user responds to the dialog.
When this is called the dialog has been hidden.
If you call [`gtk_native_dialog_hide()`](gtknativedialog#gtk-native-dialog-hide) before the user responds to the dialog this signal will not be emitted.
#### Parameters
| | | |
| --- | --- | --- |
| self | the object on which the signal is emitted | |
| response\_id | the response ID | |
| user\_data | user data set when the signal handler was connected. | |
Flags: Run Last
See Also
--------
[GtkFileChooserNative](gtkfilechoosernative#GtkFileChooserNative-struct), [GtkDialog](gtkdialog#GtkDialog-struct)
| programming_docs |
gtk GtkGestureLongPress GtkGestureLongPress
===================
GtkGestureLongPress — "Press and Hold" gesture
Functions
---------
| | |
| --- | --- |
| [GtkGesture](gtkgesture#GtkGesture-struct) \* | [gtk\_gesture\_long\_press\_new](gtkgesturelongpress#gtk-gesture-long-press-new) () |
| void | [gtk\_gesture\_long\_press\_set\_delay\_factor](gtkgesturelongpress#gtk-gesture-long-press-set-delay-factor) () |
| double | [gtk\_gesture\_long\_press\_get\_delay\_factor](gtkgesturelongpress#gtk-gesture-long-press-get-delay-factor) () |
Properties
----------
| | | |
| --- | --- | --- |
| double | [delay-factor](gtkgesturelongpress#GtkGestureLongPress--delay-factor) | Read / Write |
Signals
-------
| | | |
| --- | --- | --- |
| void | [cancelled](gtkgesturelongpress#GtkGestureLongPress-cancelled) | Run Last |
| void | [pressed](gtkgesturelongpress#GtkGestureLongPress-pressed) | Run Last |
Types and Values
----------------
| | |
| --- | --- |
| | [GtkGestureLongPress](gtkgesturelongpress#GtkGestureLongPress-struct) |
Object Hierarchy
----------------
```
GObject
╰── [GtkEventController](gtkeventcontroller#GtkEventController-struct)
╰── [GtkGesture](gtkgesture#GtkGesture-struct)
╰── [GtkGestureSingle](gtkgesturesingle#GtkGestureSingle-struct)
╰── GtkGestureLongPress
```
Includes
--------
```
#include <gtk/gtk.h>
```
Description
-----------
[GtkGestureLongPress](gtkgesturelongpress#GtkGestureLongPress-struct) is a [GtkGesture](gtkgesture#GtkGesture-struct) implementation able to recognize long presses, triggering the [“pressed”](gtkgesturelongpress#GtkGestureLongPress-pressed) after the timeout is exceeded.
If the touchpoint is lifted before the timeout passes, or if it drifts too far of the initial press point, the [“cancelled”](gtkgesturelongpress#GtkGestureLongPress-cancelled) signal will be emitted.
Functions
---------
### gtk\_gesture\_long\_press\_new ()
```
[GtkGesture](gtkgesture#GtkGesture-struct) *
gtk_gesture_long_press_new (*`void`*);
```
Returns a newly created [GtkGesture](gtkgesture#GtkGesture-struct) that recognizes long presses.
#### Returns
a newly created [GtkGestureLongPress](gtkgesturelongpress#GtkGestureLongPress-struct)
### gtk\_gesture\_long\_press\_set\_delay\_factor ()
```
void
gtk_gesture_long_press_set_delay_factor
(*`[GtkGestureLongPress](gtkgesturelongpress#GtkGestureLongPress-struct) *gesture`*,
*`double delay_factor`*);
```
Applies the given delay factor. The default long press time will be multiplied by this value. Valid values are in the range [0.5..2.0].
#### Parameters
| | | |
| --- | --- | --- |
| gesture | A [GtkGestureLongPress](gtkgesturelongpress#GtkGestureLongPress-struct) | |
| delay\_factor | The delay factor to apply | |
### gtk\_gesture\_long\_press\_get\_delay\_factor ()
```
double
gtk_gesture_long_press_get_delay_factor
(*`[GtkGestureLongPress](gtkgesturelongpress#GtkGestureLongPress-struct) *gesture`*);
```
Returns the delay factor as set by [`gtk_gesture_long_press_set_delay_factor()`](gtkgesturelongpress#gtk-gesture-long-press-set-delay-factor).
#### Parameters
| | | |
| --- | --- | --- |
| gesture | A [GtkGestureLongPress](gtkgesturelongpress#GtkGestureLongPress-struct) | |
#### Returns
the delay factor
Types and Values
----------------
### GtkGestureLongPress
```
typedef struct _GtkGestureLongPress GtkGestureLongPress;
```
Property Details
----------------
### The `“delay-factor”` property
```
“delay-factor” double
```
Factor by which to modify the default timeout.
Owner: GtkGestureLongPress
Flags: Read / Write
Allowed values: [0.5,2]
Default value: 1
Signal Details
--------------
### The `“cancelled”` signal
```
void
user_function ([GtkGestureLongPress](gtkgesturelongpress#GtkGestureLongPress-struct) *gesture,
gpointer user_data)
```
This signal is emitted whenever a press moved too far, or was released before [“pressed”](gtkgesturelongpress#GtkGestureLongPress-pressed) happened.
#### Parameters
| | | |
| --- | --- | --- |
| gesture | the object which received the signal | |
| user\_data | user data set when the signal handler was connected. | |
Flags: Run Last
### The `“pressed”` signal
```
void
user_function ([GtkGestureLongPress](gtkgesturelongpress#GtkGestureLongPress-struct) *gesture,
double x,
double y,
gpointer user_data)
```
This signal is emitted whenever a press goes unmoved/unreleased longer than what the GTK defaults tell.
#### Parameters
| | | |
| --- | --- | --- |
| gesture | the object which received the signal | |
| x | the X coordinate where the press happened, relative to the widget allocation | |
| y | the Y coordinate where the press happened, relative to the widget allocation | |
| user\_data | user data set when the signal handler was connected. | |
Flags: Run Last
gtk GtkSpinButton GtkSpinButton
=============
GtkSpinButton — Retrieve an integer or floating-point number from the user
Functions
---------
| | |
| --- | --- |
| [GtkWidget](gtkwidget#GtkWidget-struct) \* | [gtk\_spin\_button\_new](gtkspinbutton#gtk-spin-button-new) () |
| [GtkWidget](gtkwidget#GtkWidget-struct) \* | [gtk\_spin\_button\_new\_with\_range](gtkspinbutton#gtk-spin-button-new-with-range) () |
| void | [gtk\_spin\_button\_set\_adjustment](gtkspinbutton#gtk-spin-button-set-adjustment) () |
| [GtkAdjustment](gtkadjustment#GtkAdjustment-struct) \* | [gtk\_spin\_button\_get\_adjustment](gtkspinbutton#gtk-spin-button-get-adjustment) () |
| void | [gtk\_spin\_button\_set\_digits](gtkspinbutton#gtk-spin-button-set-digits) () |
| guint | [gtk\_spin\_button\_get\_digits](gtkspinbutton#gtk-spin-button-get-digits) () |
| void | [gtk\_spin\_button\_set\_increments](gtkspinbutton#gtk-spin-button-set-increments) () |
| void | [gtk\_spin\_button\_get\_increments](gtkspinbutton#gtk-spin-button-get-increments) () |
| void | [gtk\_spin\_button\_set\_range](gtkspinbutton#gtk-spin-button-set-range) () |
| void | [gtk\_spin\_button\_get\_range](gtkspinbutton#gtk-spin-button-get-range) () |
| int | [gtk\_spin\_button\_get\_value\_as\_int](gtkspinbutton#gtk-spin-button-get-value-as-int) () |
| void | [gtk\_spin\_button\_set\_value](gtkspinbutton#gtk-spin-button-set-value) () |
| double | [gtk\_spin\_button\_get\_value](gtkspinbutton#gtk-spin-button-get-value) () |
| void | [gtk\_spin\_button\_set\_update\_policy](gtkspinbutton#gtk-spin-button-set-update-policy) () |
| [GtkSpinButtonUpdatePolicy](gtkspinbutton#GtkSpinButtonUpdatePolicy) | [gtk\_spin\_button\_get\_update\_policy](gtkspinbutton#gtk-spin-button-get-update-policy) () |
| void | [gtk\_spin\_button\_set\_numeric](gtkspinbutton#gtk-spin-button-set-numeric) () |
| gboolean | [gtk\_spin\_button\_get\_numeric](gtkspinbutton#gtk-spin-button-get-numeric) () |
| void | [gtk\_spin\_button\_set\_wrap](gtkspinbutton#gtk-spin-button-set-wrap) () |
| gboolean | [gtk\_spin\_button\_get\_wrap](gtkspinbutton#gtk-spin-button-get-wrap) () |
| void | [gtk\_spin\_button\_set\_snap\_to\_ticks](gtkspinbutton#gtk-spin-button-set-snap-to-ticks) () |
| gboolean | [gtk\_spin\_button\_get\_snap\_to\_ticks](gtkspinbutton#gtk-spin-button-get-snap-to-ticks) () |
| void | [gtk\_spin\_button\_set\_climb\_rate](gtkspinbutton#gtk-spin-button-set-climb-rate) () |
| double | [gtk\_spin\_button\_get\_climb\_rate](gtkspinbutton#gtk-spin-button-get-climb-rate) () |
| void | [gtk\_spin\_button\_configure](gtkspinbutton#gtk-spin-button-configure) () |
| void | [gtk\_spin\_button\_spin](gtkspinbutton#gtk-spin-button-spin) () |
| void | [gtk\_spin\_button\_update](gtkspinbutton#gtk-spin-button-update) () |
Properties
----------
| | | |
| --- | --- | --- |
| [GtkAdjustment](gtkadjustment#GtkAdjustment-struct) \* | [adjustment](gtkspinbutton#GtkSpinButton--adjustment) | Read / Write |
| double | [climb-rate](gtkspinbutton#GtkSpinButton--climb-rate) | Read / Write |
| guint | [digits](gtkspinbutton#GtkSpinButton--digits) | Read / Write |
| gboolean | [numeric](gtkspinbutton#GtkSpinButton--numeric) | Read / Write |
| gboolean | [snap-to-ticks](gtkspinbutton#GtkSpinButton--snap-to-ticks) | Read / Write |
| [GtkSpinButtonUpdatePolicy](gtkspinbutton#GtkSpinButtonUpdatePolicy) | [update-policy](gtkspinbutton#GtkSpinButton--update-policy) | Read / Write |
| double | [value](gtkspinbutton#GtkSpinButton--value) | Read / Write |
| gboolean | [wrap](gtkspinbutton#GtkSpinButton--wrap) | Read / Write |
Signals
-------
| | | |
| --- | --- | --- |
| void | [change-value](gtkspinbutton#GtkSpinButton-change-value) | Action |
| int | [input](gtkspinbutton#GtkSpinButton-input) | Run Last |
| gboolean | [output](gtkspinbutton#GtkSpinButton-output) | Run Last |
| void | [value-changed](gtkspinbutton#GtkSpinButton-value-changed) | Run Last |
| void | [wrapped](gtkspinbutton#GtkSpinButton-wrapped) | Run Last |
Types and Values
----------------
| | |
| --- | --- |
| | [GtkSpinButton](gtkspinbutton#GtkSpinButton-struct) |
| enum | [GtkSpinButtonUpdatePolicy](gtkspinbutton#GtkSpinButtonUpdatePolicy) |
| enum | [GtkSpinType](gtkspinbutton#GtkSpinType) |
| #define | [GTK\_INPUT\_ERROR](gtkspinbutton#GTK-INPUT-ERROR:CAPS) |
Object Hierarchy
----------------
```
GObject
╰── GInitiallyUnowned
╰── [GtkWidget](gtkwidget#GtkWidget-struct)
╰── GtkSpinButton
```
Implemented Interfaces
----------------------
GtkSpinButton implements [GtkAccessible](gtkaccessible#GtkAccessible-struct), [GtkBuildable](gtkbuildable#GtkBuildable-struct), [GtkConstraintTarget](gtkconstraint#GtkConstraintTarget-struct), [GtkOrientable](gtk4-orientable#GtkOrientable-struct), [GtkEditable](gtkeditable#GtkEditable-struct) and [GtkCellEditable](gtkcelleditable#GtkCellEditable-struct).
Includes
--------
```
#include <gtk/gtk.h>
```
Description
-----------
A [GtkSpinButton](gtkspinbutton#GtkSpinButton-struct) is an ideal way to allow the user to set the value of some attribute. Rather than having to directly type a number into a [GtkEntry](gtkentry#GtkEntry-struct), GtkSpinButton allows the user to click on one of two arrows to increment or decrement the displayed value. A value can still be typed in, with the bonus that it can be checked to ensure it is in a given range.
The main properties of a GtkSpinButton are through an adjustment. See the [GtkAdjustment](gtkadjustment#GtkAdjustment-struct) section for more details about an adjustment's properties.
Note that GtkSpinButton will by default make its entry large enough to accommodate the lower and upper bounds of the adjustment. If this is not desired, the automatic sizing can be turned off by explicitly setting “width-chars” to a value != -1.
#### Using a GtkSpinButton to get an integer
#### Using a GtkSpinButton to get a floating point value
### CSS nodes
GtkSpinButtons main CSS node has the name spinbutton. It creates subnodes for the entry and the two buttons, with these names. The button nodes have the style classes .up and .down. The GtkText subnodes (if present) are put below the text node. The orientation of the spin button is reflected in the .vertical or .horizontal style class on the main node.
### Accessiblity
GtkSpinButton uses the [GTK\_ACCESSIBLE\_ROLE\_SPIN\_BUTTON](gtkaccessible#GTK-ACCESSIBLE-ROLE-SPIN-BUTTON:CAPS) role.
Functions
---------
### gtk\_spin\_button\_new ()
```
[GtkWidget](gtkwidget#GtkWidget-struct) *
gtk_spin_button_new (*`[GtkAdjustment](gtkadjustment#GtkAdjustment-struct) *adjustment`*,
*`double climb_rate`*,
*`guint digits`*);
```
Creates a new [GtkSpinButton](gtkspinbutton#GtkSpinButton-struct).
#### Parameters
| | | |
| --- | --- | --- |
| adjustment | the [GtkAdjustment](gtkadjustment#GtkAdjustment-struct) object that this spin button should use, or `NULL`. | [allow-none] |
| climb\_rate | specifies by how much the rate of change in the value will accelerate if you continue to hold down an up/down button or arrow key | |
| digits | the number of decimal places to display | |
#### Returns
The new spin button as a [GtkWidget](gtkwidget#GtkWidget-struct)
### gtk\_spin\_button\_new\_with\_range ()
```
[GtkWidget](gtkwidget#GtkWidget-struct) *
gtk_spin_button_new_with_range (*`double min`*,
*`double max`*,
*`double step`*);
```
This is a convenience constructor that allows creation of a numeric [GtkSpinButton](gtkspinbutton#GtkSpinButton-struct) without manually creating an adjustment. The value is initially set to the minimum value and a page increment of 10 \* *`step`* is the default. The precision of the spin button is equivalent to the precision of *`step`* .
Note that the way in which the precision is derived works best if *`step`* is a power of ten. If the resulting precision is not suitable for your needs, use [`gtk_spin_button_set_digits()`](gtkspinbutton#gtk-spin-button-set-digits) to correct it.
#### Parameters
| | | |
| --- | --- | --- |
| min | Minimum allowable value | |
| max | Maximum allowable value | |
| step | Increment added or subtracted by spinning the widget | |
#### Returns
The new spin button as a [GtkWidget](gtkwidget#GtkWidget-struct)
### gtk\_spin\_button\_set\_adjustment ()
```
void
gtk_spin_button_set_adjustment (*`[GtkSpinButton](gtkspinbutton#GtkSpinButton-struct) *spin_button`*,
*`[GtkAdjustment](gtkadjustment#GtkAdjustment-struct) *adjustment`*);
```
Replaces the [GtkAdjustment](gtkadjustment#GtkAdjustment-struct) associated with *`spin_button`* .
#### Parameters
| | | |
| --- | --- | --- |
| spin\_button | a [GtkSpinButton](gtkspinbutton#GtkSpinButton-struct) | |
| adjustment | a [GtkAdjustment](gtkadjustment#GtkAdjustment-struct) to replace the existing adjustment | |
### gtk\_spin\_button\_get\_adjustment ()
```
[GtkAdjustment](gtkadjustment#GtkAdjustment-struct) *
gtk_spin_button_get_adjustment (*`[GtkSpinButton](gtkspinbutton#GtkSpinButton-struct) *spin_button`*);
```
Get the adjustment associated with a [GtkSpinButton](gtkspinbutton#GtkSpinButton-struct)
#### Parameters
| | | |
| --- | --- | --- |
| spin\_button | a [GtkSpinButton](gtkspinbutton#GtkSpinButton-struct) | |
#### Returns
the [GtkAdjustment](gtkadjustment#GtkAdjustment-struct) of *`spin_button`* .
[transfer none]
### gtk\_spin\_button\_set\_digits ()
```
void
gtk_spin_button_set_digits (*`[GtkSpinButton](gtkspinbutton#GtkSpinButton-struct) *spin_button`*,
*`guint digits`*);
```
Set the precision to be displayed by *`spin_button`* . Up to 20 digit precision is allowed.
#### Parameters
| | | |
| --- | --- | --- |
| spin\_button | a [GtkSpinButton](gtkspinbutton#GtkSpinButton-struct) | |
| digits | the number of digits after the decimal point to be displayed for the spin button’s value | |
### gtk\_spin\_button\_get\_digits ()
```
guint
gtk_spin_button_get_digits (*`[GtkSpinButton](gtkspinbutton#GtkSpinButton-struct) *spin_button`*);
```
Fetches the precision of *`spin_button`* . See [`gtk_spin_button_set_digits()`](gtkspinbutton#gtk-spin-button-set-digits).
#### Parameters
| | | |
| --- | --- | --- |
| spin\_button | a [GtkSpinButton](gtkspinbutton#GtkSpinButton-struct) | |
#### Returns
the current precision
### gtk\_spin\_button\_set\_increments ()
```
void
gtk_spin_button_set_increments (*`[GtkSpinButton](gtkspinbutton#GtkSpinButton-struct) *spin_button`*,
*`double step`*,
*`double page`*);
```
Sets the step and page increments for spin\_button. This affects how quickly the value changes when the spin button’s arrows are activated.
#### Parameters
| | | |
| --- | --- | --- |
| spin\_button | a [GtkSpinButton](gtkspinbutton#GtkSpinButton-struct) | |
| step | increment applied for a button 1 press. | |
| page | increment applied for a button 2 press. | |
### gtk\_spin\_button\_get\_increments ()
```
void
gtk_spin_button_get_increments (*`[GtkSpinButton](gtkspinbutton#GtkSpinButton-struct) *spin_button`*,
*`double *step`*,
*`double *page`*);
```
Gets the current step and page the increments used by *`spin_button`* . See [`gtk_spin_button_set_increments()`](gtkspinbutton#gtk-spin-button-set-increments).
#### Parameters
| | | |
| --- | --- | --- |
| spin\_button | a [GtkSpinButton](gtkspinbutton#GtkSpinButton-struct) | |
| step | location to store step increment, or `NULL`. | [out][allow-none] |
| page | location to store page increment, or `NULL`. | [out][allow-none] |
### gtk\_spin\_button\_set\_range ()
```
void
gtk_spin_button_set_range (*`[GtkSpinButton](gtkspinbutton#GtkSpinButton-struct) *spin_button`*,
*`double min`*,
*`double max`*);
```
Sets the minimum and maximum allowable values for *`spin_button`* .
If the current value is outside this range, it will be adjusted to fit within the range, otherwise it will remain unchanged.
#### Parameters
| | | |
| --- | --- | --- |
| spin\_button | a [GtkSpinButton](gtkspinbutton#GtkSpinButton-struct) | |
| min | minimum allowable value | |
| max | maximum allowable value | |
### gtk\_spin\_button\_get\_range ()
```
void
gtk_spin_button_get_range (*`[GtkSpinButton](gtkspinbutton#GtkSpinButton-struct) *spin_button`*,
*`double *min`*,
*`double *max`*);
```
Gets the range allowed for *`spin_button`* . See [`gtk_spin_button_set_range()`](gtkspinbutton#gtk-spin-button-set-range).
#### Parameters
| | | |
| --- | --- | --- |
| spin\_button | a [GtkSpinButton](gtkspinbutton#GtkSpinButton-struct) | |
| min | location to store minimum allowed value, or `NULL`. | [out][optional] |
| max | location to store maximum allowed value, or `NULL`. | [out][optional] |
### gtk\_spin\_button\_get\_value\_as\_int ()
```
int
gtk_spin_button_get_value_as_int (*`[GtkSpinButton](gtkspinbutton#GtkSpinButton-struct) *spin_button`*);
```
Get the value *`spin_button`* represented as an integer.
#### Parameters
| | | |
| --- | --- | --- |
| spin\_button | a [GtkSpinButton](gtkspinbutton#GtkSpinButton-struct) | |
#### Returns
the value of *`spin_button`*
### gtk\_spin\_button\_set\_value ()
```
void
gtk_spin_button_set_value (*`[GtkSpinButton](gtkspinbutton#GtkSpinButton-struct) *spin_button`*,
*`double value`*);
```
Sets the value of *`spin_button`* .
#### Parameters
| | | |
| --- | --- | --- |
| spin\_button | a [GtkSpinButton](gtkspinbutton#GtkSpinButton-struct) | |
| value | the new value | |
### gtk\_spin\_button\_get\_value ()
```
double
gtk_spin_button_get_value (*`[GtkSpinButton](gtkspinbutton#GtkSpinButton-struct) *spin_button`*);
```
Get the value in the *`spin_button`* .
#### Parameters
| | | |
| --- | --- | --- |
| spin\_button | a [GtkSpinButton](gtkspinbutton#GtkSpinButton-struct) | |
#### Returns
the value of *`spin_button`*
### gtk\_spin\_button\_set\_update\_policy ()
```
void
gtk_spin_button_set_update_policy (*`[GtkSpinButton](gtkspinbutton#GtkSpinButton-struct) *spin_button`*,
*`[GtkSpinButtonUpdatePolicy](gtkspinbutton#GtkSpinButtonUpdatePolicy) policy`*);
```
Sets the update behavior of a spin button. This determines whether the spin button is always updated or only when a valid value is set.
#### Parameters
| | | |
| --- | --- | --- |
| spin\_button | a [GtkSpinButton](gtkspinbutton#GtkSpinButton-struct) | |
| policy | a [GtkSpinButtonUpdatePolicy](gtkspinbutton#GtkSpinButtonUpdatePolicy) value | |
### gtk\_spin\_button\_get\_update\_policy ()
```
[GtkSpinButtonUpdatePolicy](gtkspinbutton#GtkSpinButtonUpdatePolicy)
gtk_spin_button_get_update_policy (*`[GtkSpinButton](gtkspinbutton#GtkSpinButton-struct) *spin_button`*);
```
Gets the update behavior of a spin button. See [`gtk_spin_button_set_update_policy()`](gtkspinbutton#gtk-spin-button-set-update-policy).
#### Parameters
| | | |
| --- | --- | --- |
| spin\_button | a [GtkSpinButton](gtkspinbutton#GtkSpinButton-struct) | |
#### Returns
the current update policy
### gtk\_spin\_button\_set\_numeric ()
```
void
gtk_spin_button_set_numeric (*`[GtkSpinButton](gtkspinbutton#GtkSpinButton-struct) *spin_button`*,
*`gboolean numeric`*);
```
Sets the flag that determines if non-numeric text can be typed into the spin button.
#### Parameters
| | | |
| --- | --- | --- |
| spin\_button | a [GtkSpinButton](gtkspinbutton#GtkSpinButton-struct) | |
| numeric | flag indicating if only numeric entry is allowed | |
### gtk\_spin\_button\_get\_numeric ()
```
gboolean
gtk_spin_button_get_numeric (*`[GtkSpinButton](gtkspinbutton#GtkSpinButton-struct) *spin_button`*);
```
Returns whether non-numeric text can be typed into the spin button. See [`gtk_spin_button_set_numeric()`](gtkspinbutton#gtk-spin-button-set-numeric).
#### Parameters
| | | |
| --- | --- | --- |
| spin\_button | a [GtkSpinButton](gtkspinbutton#GtkSpinButton-struct) | |
#### Returns
`TRUE` if only numeric text can be entered
### gtk\_spin\_button\_set\_wrap ()
```
void
gtk_spin_button_set_wrap (*`[GtkSpinButton](gtkspinbutton#GtkSpinButton-struct) *spin_button`*,
*`gboolean wrap`*);
```
Sets the flag that determines if a spin button value wraps around to the opposite limit when the upper or lower limit of the range is exceeded.
#### Parameters
| | | |
| --- | --- | --- |
| spin\_button | a [GtkSpinButton](gtkspinbutton#GtkSpinButton-struct) | |
| wrap | a flag indicating if wrapping behavior is performed | |
### gtk\_spin\_button\_get\_wrap ()
```
gboolean
gtk_spin_button_get_wrap (*`[GtkSpinButton](gtkspinbutton#GtkSpinButton-struct) *spin_button`*);
```
Returns whether the spin button’s value wraps around to the opposite limit when the upper or lower limit of the range is exceeded. See [`gtk_spin_button_set_wrap()`](gtkspinbutton#gtk-spin-button-set-wrap).
#### Parameters
| | | |
| --- | --- | --- |
| spin\_button | a [GtkSpinButton](gtkspinbutton#GtkSpinButton-struct) | |
#### Returns
`TRUE` if the spin button wraps around
### gtk\_spin\_button\_set\_snap\_to\_ticks ()
```
void
gtk_spin_button_set_snap_to_ticks (*`[GtkSpinButton](gtkspinbutton#GtkSpinButton-struct) *spin_button`*,
*`gboolean snap_to_ticks`*);
```
Sets the policy as to whether values are corrected to the nearest step increment when a spin button is activated after providing an invalid value.
#### Parameters
| | | |
| --- | --- | --- |
| spin\_button | a [GtkSpinButton](gtkspinbutton#GtkSpinButton-struct) | |
| snap\_to\_ticks | a flag indicating if invalid values should be corrected | |
### gtk\_spin\_button\_get\_snap\_to\_ticks ()
```
gboolean
gtk_spin_button_get_snap_to_ticks (*`[GtkSpinButton](gtkspinbutton#GtkSpinButton-struct) *spin_button`*);
```
Returns whether the values are corrected to the nearest step. See [`gtk_spin_button_set_snap_to_ticks()`](gtkspinbutton#gtk-spin-button-set-snap-to-ticks).
#### Parameters
| | | |
| --- | --- | --- |
| spin\_button | a [GtkSpinButton](gtkspinbutton#GtkSpinButton-struct) | |
#### Returns
`TRUE` if values are snapped to the nearest step
### gtk\_spin\_button\_set\_climb\_rate ()
```
void
gtk_spin_button_set_climb_rate (*`[GtkSpinButton](gtkspinbutton#GtkSpinButton-struct) *spin_button`*,
*`double climb_rate`*);
```
Sets the acceleration rate for repeated changes when you hold down a button or key.
#### Parameters
| | | |
| --- | --- | --- |
| spin\_button | a [GtkSpinButton](gtkspinbutton#GtkSpinButton-struct) | |
| climb\_rate | the rate of acceleration, must be >= 0 | |
### gtk\_spin\_button\_get\_climb\_rate ()
```
double
gtk_spin_button_get_climb_rate (*`[GtkSpinButton](gtkspinbutton#GtkSpinButton-struct) *spin_button`*);
```
Returns the acceleration rate for repeated changes.
#### Parameters
| | | |
| --- | --- | --- |
| spin\_button | a [GtkSpinButton](gtkspinbutton#GtkSpinButton-struct) | |
#### Returns
the acceleration rate
### gtk\_spin\_button\_configure ()
```
void
gtk_spin_button_configure (*`[GtkSpinButton](gtkspinbutton#GtkSpinButton-struct) *spin_button`*,
*`[GtkAdjustment](gtkadjustment#GtkAdjustment-struct) *adjustment`*,
*`double climb_rate`*,
*`guint digits`*);
```
Changes the properties of an existing spin button. The adjustment, climb rate, and number of decimal places are updated accordingly.
#### Parameters
| | | |
| --- | --- | --- |
| spin\_button | a [GtkSpinButton](gtkspinbutton#GtkSpinButton-struct) | |
| adjustment | a [GtkAdjustment](gtkadjustment#GtkAdjustment-struct) to replace the spin button’s existing adjustment, or `NULL` to leave its current adjustment unchanged. | [nullable] |
| climb\_rate | the new climb rate | |
| digits | the number of decimal places to display in the spin button | |
### gtk\_spin\_button\_spin ()
```
void
gtk_spin_button_spin (*`[GtkSpinButton](gtkspinbutton#GtkSpinButton-struct) *spin_button`*,
*`[GtkSpinType](gtkspinbutton#GtkSpinType) direction`*,
*`double increment`*);
```
Increment or decrement a spin button’s value in a specified direction by a specified amount.
#### Parameters
| | | |
| --- | --- | --- |
| spin\_button | a [GtkSpinButton](gtkspinbutton#GtkSpinButton-struct) | |
| direction | a [GtkSpinType](gtkspinbutton#GtkSpinType) indicating the direction to spin | |
| increment | step increment to apply in the specified direction | |
### gtk\_spin\_button\_update ()
```
void
gtk_spin_button_update (*`[GtkSpinButton](gtkspinbutton#GtkSpinButton-struct) *spin_button`*);
```
Manually force an update of the spin button.
#### Parameters
| | | |
| --- | --- | --- |
| spin\_button | a [GtkSpinButton](gtkspinbutton#GtkSpinButton-struct) | |
Types and Values
----------------
### GtkSpinButton
```
typedef struct _GtkSpinButton GtkSpinButton;
```
### enum GtkSpinButtonUpdatePolicy
The spin button update policy determines whether the spin button displays values even if they are outside the bounds of its adjustment. See [`gtk_spin_button_set_update_policy()`](gtkspinbutton#gtk-spin-button-set-update-policy).
#### Members
| | | |
| --- | --- | --- |
| GTK\_UPDATE\_ALWAYS | When refreshing your [GtkSpinButton](gtkspinbutton#GtkSpinButton-struct), the value is always displayed | |
| GTK\_UPDATE\_IF\_VALID | When refreshing your [GtkSpinButton](gtkspinbutton#GtkSpinButton-struct), the value is only displayed if it is valid within the bounds of the spin button's adjustment | |
### enum GtkSpinType
The values of the GtkSpinType enumeration are used to specify the change to make in [`gtk_spin_button_spin()`](gtkspinbutton#gtk-spin-button-spin).
#### Members
| | | |
| --- | --- | --- |
| GTK\_SPIN\_STEP\_FORWARD | Increment by the adjustments step increment. | |
| GTK\_SPIN\_STEP\_BACKWARD | Decrement by the adjustments step increment. | |
| GTK\_SPIN\_PAGE\_FORWARD | Increment by the adjustments page increment. | |
| GTK\_SPIN\_PAGE\_BACKWARD | Decrement by the adjustments page increment. | |
| GTK\_SPIN\_HOME | Go to the adjustments lower bound. | |
| GTK\_SPIN\_END | Go to the adjustments upper bound. | |
| GTK\_SPIN\_USER\_DEFINED | Change by a specified amount. | |
### GTK\_INPUT\_ERROR
```
#define GTK_INPUT_ERROR -1
```
Constant to return from a signal handler for the [“input”](gtkspinbutton#GtkSpinButton-input) signal in case of conversion failure.
Property Details
----------------
### The `“adjustment”` property
```
“adjustment” [GtkAdjustment](gtkadjustment#GtkAdjustment-struct) *
```
The adjustment that holds the value of the spin button.
Owner: GtkSpinButton
Flags: Read / Write
### The `“climb-rate”` property
```
“climb-rate” double
```
The acceleration rate when you hold down a button or key.
Owner: GtkSpinButton
Flags: Read / Write
Allowed values: >= 0
Default value: 0
### The `“digits”` property
```
“digits” guint
```
The number of decimal places to display.
Owner: GtkSpinButton
Flags: Read / Write
Allowed values: <= 20
Default value: 0
### The `“numeric”` property
```
“numeric” gboolean
```
Whether non-numeric characters should be ignored.
Owner: GtkSpinButton
Flags: Read / Write
Default value: FALSE
### The `“snap-to-ticks”` property
```
“snap-to-ticks” gboolean
```
Whether erroneous values are automatically changed to a spin button’s nearest step increment.
Owner: GtkSpinButton
Flags: Read / Write
Default value: FALSE
### The `“update-policy”` property
```
“update-policy” [GtkSpinButtonUpdatePolicy](gtkspinbutton#GtkSpinButtonUpdatePolicy)
```
Whether the spin button should update always, or only when the value is legal.
Owner: GtkSpinButton
Flags: Read / Write
Default value: GTK\_UPDATE\_ALWAYS
### The `“value”` property
```
“value” double
```
Reads the current value, or sets a new value.
Owner: GtkSpinButton
Flags: Read / Write
Default value: 0
### The `“wrap”` property
```
“wrap” gboolean
```
Whether a spin button should wrap upon reaching its limits.
Owner: GtkSpinButton
Flags: Read / Write
Default value: FALSE
Signal Details
--------------
### The `“change-value”` signal
```
void
user_function ([GtkSpinButton](gtkspinbutton#GtkSpinButton-struct) *spin_button,
[GtkScrollType](gtk4-standard-enumerations#GtkScrollType) scroll,
gpointer user_data)
```
The ::change-value signal is a [keybinding signal](gtkshortcutaction#GtkSignalAction-struct) which gets emitted when the user initiates a value change.
Applications should not connect to it, but may emit it with `g_signal_emit_by_name()` if they need to control the cursor programmatically.
The default bindings for this signal are Up/Down and PageUp and/PageDown.
#### Parameters
| | | |
| --- | --- | --- |
| spin\_button | the object on which the signal was emitted | |
| scroll | a [GtkScrollType](gtk4-standard-enumerations#GtkScrollType) to specify the speed and amount of change | |
| user\_data | user data set when the signal handler was connected. | |
Flags: Action
### The `“input”` signal
```
int
user_function ([GtkSpinButton](gtkspinbutton#GtkSpinButton-struct) *spin_button,
gpointer new_value,
gpointer user_data)
```
The ::input signal can be used to influence the conversion of the users input into a double value. The signal handler is expected to use [`gtk_editable_get_text()`](gtkeditable#gtk-editable-get-text) to retrieve the text of the spinbutton and set *`new_value`* to the new value.
The default conversion uses `g_strtod()`.
#### Parameters
| | | |
| --- | --- | --- |
| spin\_button | the object on which the signal was emitted | |
| new\_value | return location for the new value. | [out][type double] |
| user\_data | user data set when the signal handler was connected. | |
#### Returns
`TRUE` for a successful conversion, `FALSE` if the input was not handled, and [`GTK_INPUT_ERROR`](gtkspinbutton#GTK-INPUT-ERROR:CAPS) if the conversion failed.
Flags: Run Last
### The `“output”` signal
```
gboolean
user_function ([GtkSpinButton](gtkspinbutton#GtkSpinButton-struct) *spin_button,
gpointer user_data)
```
The ::output signal can be used to change to formatting of the value that is displayed in the spin buttons entry.
```
// Provides a function to retrieve an integer value from a GtkSpinButton
// and creates a spin button to model percentage values.
int
grab_int_value (GtkSpinButton *button,
gpointer user_data)
{
return gtk_spin_button_get_value_as_int (button);
}
void
create_integer_spin_button (void)
{
GtkWidget *window, *button;
GtkAdjustment *adjustment;
adjustment = gtk_adjustment_new (50.0, 0.0, 100.0, 1.0, 5.0, 0.0);
window = gtk_window_new ();
// creates the spinbutton, with no decimal places
button = gtk_spin_button_new (adjustment, 1.0, 0);
gtk_window_set_child (GTK_WINDOW (window), button);
gtk_widget_show (window);
}
```
| #### Parameters
| | | |
| --- | --- | --- |
| spin\_button | the object on which the signal was emitted | |
| user\_data | user data set when the signal handler was connected. | |
#### Returns
`TRUE` if the value has been displayed
Flags: Run Last
### The `“value-changed”` signal
```
void
user_function ([GtkSpinButton](gtkspinbutton#GtkSpinButton-struct) *spin_button,
gpointer user_data)
```
The ::value-changed signal is emitted when the value represented by *`spinbutton`* changes. Also see the [“output”](gtkspinbutton#GtkSpinButton-output) signal.
#### Parameters
| | | |
| --- | --- | --- |
| spin\_button | the object on which the signal was emitted | |
| user\_data | user data set when the signal handler was connected. | |
Flags: Run Last
### The `“wrapped”` signal
```
void
user_function ([GtkSpinButton](gtkspinbutton#GtkSpinButton-struct) *spin_button,
gpointer user_data)
```
The ::wrapped signal is emitted right after the spinbutton wraps from its maximum to minimum value or vice-versa.
#### Parameters
| | | |
| --- | --- | --- |
| spin\_button | the object on which the signal was emitted | |
| user\_data | user data set when the signal handler was connected. | |
Flags: Run Last
See Also
--------
[GtkEntry](gtkentry#GtkEntry-struct)
| programming_docs |
gtk GtkTooltip GtkTooltip
==========
GtkTooltip — Add tips to your widgets
Functions
---------
| | |
| --- | --- |
| void | [gtk\_tooltip\_set\_markup](gtktooltip#gtk-tooltip-set-markup) () |
| void | [gtk\_tooltip\_set\_text](gtktooltip#gtk-tooltip-set-text) () |
| void | [gtk\_tooltip\_set\_icon](gtktooltip#gtk-tooltip-set-icon) () |
| void | [gtk\_tooltip\_set\_icon\_from\_icon\_name](gtktooltip#gtk-tooltip-set-icon-from-icon-name) () |
| void | [gtk\_tooltip\_set\_icon\_from\_gicon](gtktooltip#gtk-tooltip-set-icon-from-gicon) () |
| void | [gtk\_tooltip\_set\_custom](gtktooltip#gtk-tooltip-set-custom) () |
| void | [gtk\_tooltip\_set\_tip\_area](gtktooltip#gtk-tooltip-set-tip-area) () |
Types and Values
----------------
| | |
| --- | --- |
| | [GtkTooltip](gtktooltip#GtkTooltip-struct) |
Object Hierarchy
----------------
```
GObject
╰── GtkTooltip
```
Includes
--------
```
#include <gtk/gtk.h>
```
Description
-----------
Basic tooltips can be realized simply by using [`gtk_widget_set_tooltip_text()`](gtkwidget#gtk-widget-set-tooltip-text) or [`gtk_widget_set_tooltip_markup()`](gtkwidget#gtk-widget-set-tooltip-markup) without any explicit tooltip object.
When you need a tooltip with a little more fancy contents, like adding an image, or you want the tooltip to have different contents per [GtkTreeView](gtktreeview#GtkTreeView-struct) row or cell, you will have to do a little more work:
* Set the [“has-tooltip”](gtkwidget#GtkWidget--has-tooltip) property to `TRUE`, this will make GTK monitor the widget for motion and related events which are needed to determine when and where to show a tooltip.
* Connect to the [“query-tooltip”](gtkwidget#GtkWidget-query-tooltip) signal. This signal will be emitted when a tooltip is supposed to be shown. One of the arguments passed to the signal handler is a GtkTooltip object. This is the object that we are about to display as a tooltip, and can be manipulated in your callback using functions like [`gtk_tooltip_set_icon()`](gtktooltip#gtk-tooltip-set-icon). There are functions for setting the tooltip’s markup, setting an image from a named icon, or even putting in a custom widget.
Return `TRUE` from your query-tooltip handler. This causes the tooltip to be show. If you return `FALSE`, it will not be shown.
Functions
---------
### gtk\_tooltip\_set\_markup ()
```
void
gtk_tooltip_set_markup (*`[GtkTooltip](gtktooltip#GtkTooltip-struct) *tooltip`*,
*`const char *markup`*);
```
Sets the text of the tooltip to be *`markup`* , which is marked up with the Pango text markup language. If *`markup`* is `NULL`, the label will be hidden.
#### Parameters
| | | |
| --- | --- | --- |
| tooltip | a [GtkTooltip](gtktooltip#GtkTooltip-struct) | |
| markup | a markup string (see Pango markup format) or `NULL`. | [allow-none] |
### gtk\_tooltip\_set\_text ()
```
void
gtk_tooltip_set_text (*`[GtkTooltip](gtktooltip#GtkTooltip-struct) *tooltip`*,
*`const char *text`*);
```
Sets the text of the tooltip to be *`text`* . If *`text`* is `NULL`, the label will be hidden. See also [`gtk_tooltip_set_markup()`](gtktooltip#gtk-tooltip-set-markup).
#### Parameters
| | | |
| --- | --- | --- |
| tooltip | a [GtkTooltip](gtktooltip#GtkTooltip-struct) | |
| text | a text string or `NULL`. | [allow-none] |
### gtk\_tooltip\_set\_icon ()
```
void
gtk_tooltip_set_icon (*`[GtkTooltip](gtktooltip#GtkTooltip-struct) *tooltip`*,
*`[GdkPaintable](https://developer-old.gnome.org/gtk4/html/GdkPaintable.html#GdkPaintable-struct) *paintable`*);
```
Sets the icon of the tooltip (which is in front of the text) to be *`paintable`* . If *`paintable`* is `NULL`, the image will be hidden.
#### Parameters
| | | |
| --- | --- | --- |
| tooltip | a [GtkTooltip](gtktooltip#GtkTooltip-struct) | |
| paintable | a [GdkPaintable](https://developer-old.gnome.org/gtk4/html/GdkPaintable.html#GdkPaintable-struct), or `NULL`. | [allow-none] |
### gtk\_tooltip\_set\_icon\_from\_icon\_name ()
```
void
gtk_tooltip_set_icon_from_icon_name (*`[GtkTooltip](gtktooltip#GtkTooltip-struct) *tooltip`*,
*`const char *icon_name`*);
```
Sets the icon of the tooltip (which is in front of the text) to be the icon indicated by *`icon_name`* with the size indicated by *`size`* . If *`icon_name`* is `NULL`, the image will be hidden.
#### Parameters
| | | |
| --- | --- | --- |
| tooltip | a [GtkTooltip](gtktooltip#GtkTooltip-struct) | |
| icon\_name | an icon name, or `NULL`. | [allow-none] |
### gtk\_tooltip\_set\_icon\_from\_gicon ()
```
void
gtk_tooltip_set_icon_from_gicon (*`[GtkTooltip](gtktooltip#GtkTooltip-struct) *tooltip`*,
*`GIcon *gicon`*);
```
Sets the icon of the tooltip (which is in front of the text) to be the icon indicated by *`gicon`* with the size indicated by *`size`* . If *`gicon`* is `NULL`, the image will be hidden.
#### Parameters
| | | |
| --- | --- | --- |
| tooltip | a [GtkTooltip](gtktooltip#GtkTooltip-struct) | |
| gicon | a GIcon representing the icon, or `NULL`. | [allow-none] |
### gtk\_tooltip\_set\_custom ()
```
void
gtk_tooltip_set_custom (*`[GtkTooltip](gtktooltip#GtkTooltip-struct) *tooltip`*,
*`[GtkWidget](gtkwidget#GtkWidget-struct) *custom_widget`*);
```
Replaces the widget packed into the tooltip with *`custom_widget`* . *`custom_widget`* does not get destroyed when the tooltip goes away. By default a box with a [GtkImage](gtkimage#GtkImage-struct) and [GtkLabel](gtklabel#GtkLabel-struct) is embedded in the tooltip, which can be configured using [`gtk_tooltip_set_markup()`](gtktooltip#gtk-tooltip-set-markup) and [`gtk_tooltip_set_icon()`](gtktooltip#gtk-tooltip-set-icon).
#### Parameters
| | | |
| --- | --- | --- |
| tooltip | a [GtkTooltip](gtktooltip#GtkTooltip-struct) | |
| custom\_widget | a [GtkWidget](gtkwidget#GtkWidget-struct), or `NULL` to unset the old custom widget. | [allow-none] |
### gtk\_tooltip\_set\_tip\_area ()
```
void
gtk_tooltip_set_tip_area (*`[GtkTooltip](gtktooltip#GtkTooltip-struct) *tooltip`*,
*`const [GdkRectangle](https://developer-old.gnome.org/gtk4/html/gdk4-Rectangles-and-Regions.html#GdkRectangle-struct) *rect`*);
```
Sets the area of the widget, where the contents of this tooltip apply, to be *`rect`* (in widget coordinates). This is especially useful for properly setting tooltips on [GtkTreeView](gtktreeview#GtkTreeView-struct) rows and cells, [GtkIconViews](gtkiconview#GtkIconView-struct), etc.
For setting tooltips on [GtkTreeView](gtktreeview#GtkTreeView-struct), please refer to the convenience functions for this: [`gtk_tree_view_set_tooltip_row()`](gtktreeview#gtk-tree-view-set-tooltip-row) and [`gtk_tree_view_set_tooltip_cell()`](gtktreeview#gtk-tree-view-set-tooltip-cell).
#### Parameters
| | | |
| --- | --- | --- |
| tooltip | a [GtkTooltip](gtktooltip#GtkTooltip-struct) | |
| rect | a [GdkRectangle](https://developer-old.gnome.org/gtk4/html/gdk4-Rectangles-and-Regions.html#GdkRectangle-struct) | |
Types and Values
----------------
### GtkTooltip
```
typedef struct _GtkTooltip GtkTooltip;
```
gtk GtkEditableLabel GtkEditableLabel
================
GtkEditableLabel — A label that can be edited
Functions
---------
| | |
| --- | --- |
| [GtkWidget](gtkwidget#GtkWidget-struct) \* | [gtk\_editable\_label\_new](gtkeditablelabel#gtk-editable-label-new) () |
| gboolean | [gtk\_editable\_label\_get\_editing](gtkeditablelabel#gtk-editable-label-get-editing) () |
| void | [gtk\_editable\_label\_start\_editing](gtkeditablelabel#gtk-editable-label-start-editing) () |
| void | [gtk\_editable\_label\_stop\_editing](gtkeditablelabel#gtk-editable-label-stop-editing) () |
Properties
----------
| | | |
| --- | --- | --- |
| gboolean | [editing](gtkeditablelabel#GtkEditableLabel--editing) | Read |
Actions
-------
| | | |
| --- | --- | --- |
| | editing.stop | b |
| | editing.start | |
Types and Values
----------------
| | |
| --- | --- |
| | [GtkEditableLabel](gtkeditablelabel#GtkEditableLabel-struct) |
Object Hierarchy
----------------
```
GObject
╰── GInitiallyUnowned
╰── [GtkWidget](gtkwidget#GtkWidget-struct)
╰── GtkEditableLabel
```
Implemented Interfaces
----------------------
GtkEditableLabel implements [GtkAccessible](gtkaccessible#GtkAccessible-struct), [GtkBuildable](gtkbuildable#GtkBuildable-struct), [GtkConstraintTarget](gtkconstraint#GtkConstraintTarget-struct) and [GtkEditable](gtkeditable#GtkEditable-struct).
Includes
--------
```
#include <gtk/gtk.h>
```
Description
-----------
A GtkEditableLabel is a [GtkLabel](gtklabel#GtkLabel-struct) that allows users to edit the text by switching the widget to an “edit mode”.
GtkEditableLabel does not have API of its own, but it implements the [GtkEditable](gtkeditable#GtkEditable-struct) interface.
The default bindings for activating the edit mode is to click or press the Enter key. The default bindings for leaving the edit mode are the Enter key (to save the results) or the Escape key (to cancel the editing).
### CSS nodes
```
editablelabel[.editing]
╰── stack
├── label
╰── text
```
| GtkEditableLabel has a main node with the name editablelabel. When the entry is in editing mode, it gets the .editing style class.
For all the subnodes added to the text node in various situations, see [GtkText](gtktext#GtkText-struct).
Functions
---------
### gtk\_editable\_label\_new ()
```
[GtkWidget](gtkwidget#GtkWidget-struct) *
gtk_editable_label_new (*`const char *str`*);
```
Creates a new [GtkEditableLabel](gtkeditablelabel#GtkEditableLabel-struct) widget.
#### Parameters
| | | |
| --- | --- | --- |
| str | the text for the label | |
#### Returns
the new [GtkEditableLabel](gtkeditablelabel#GtkEditableLabel-struct)
### gtk\_editable\_label\_get\_editing ()
```
gboolean
gtk_editable_label_get_editing (*`[GtkEditableLabel](gtkeditablelabel#GtkEditableLabel-struct) *self`*);
```
Returns whether the label is currently in “editing mode”.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkEditableLabel](gtkeditablelabel#GtkEditableLabel-struct) | |
#### Returns
`TRUE` if *`self`* is currently in editing mode
### gtk\_editable\_label\_start\_editing ()
```
void
gtk_editable_label_start_editing (*`[GtkEditableLabel](gtkeditablelabel#GtkEditableLabel-struct) *self`*);
```
Switches the label into “editing mode”.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkEditableLabel](gtkeditablelabel#GtkEditableLabel-struct) | |
### gtk\_editable\_label\_stop\_editing ()
```
void
gtk_editable_label_stop_editing (*`[GtkEditableLabel](gtkeditablelabel#GtkEditableLabel-struct) *self`*,
*`gboolean commit`*);
```
Switches the label out of “editing mode”. If *`commit`* is `TRUE`, the resulting text is kept as the [“text”](gtkeditable#GtkEditable--text) property value, otherwise the resulting text is discarded and the label will keep its previous [“text”](gtkeditable#GtkEditable--text) property value.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkEditableLabel](gtkeditablelabel#GtkEditableLabel-struct) | |
| commit | whether to set the edited text on the label | |
Types and Values
----------------
### GtkEditableLabel
```
typedef struct _GtkEditableLabel GtkEditableLabel;
```
Property Details
----------------
### The `“editing”` property
```
“editing” gboolean
```
This property is `TRUE` while the widget is in edit mode.
Owner: GtkEditableLabel
Flags: Read
Default value: FALSE
Action Details
--------------
### The `“editing.stop”` action
Switch the widget out of editing mode. If *`commit`* is `TRUE`, then the results of the editing are taken as the new value of [“text”](gtkeditable#GtkEditable--text).
The default binding for this action is the Escape key.
This action is disabled when [“editing”](gtkeditablelabel#GtkEditableLabel--editing) is `FALSE`.
Parameter type: b
#### Parameters
| | | |
| --- | --- | --- |
| commit | Whether the make changes permanent | |
### The `“editing.start”` action
Switch the widget into editing mode, so that the user can make changes to the text.
The default bindings for this action are clicking on the widget and the Enter key.
This action is disabled when [“editing”](gtkeditablelabel#GtkEditableLabel--editing) is `FALSE`.
See Also
--------
[GtkEditable](gtkeditable#GtkEditable-struct), [GtkLabel](gtklabel#GtkLabel-struct), [GtkEntry](gtkentry#GtkEntry-struct)
gtk GtkOverlayLayout GtkOverlayLayout
================
GtkOverlayLayout — Layout manager that places widgets as overlays
Functions
---------
| | |
| --- | --- |
| [GtkLayoutManager](gtklayoutmanager#GtkLayoutManager-struct) \* | [gtk\_overlay\_layout\_new](gtkoverlaylayout#gtk-overlay-layout-new) () |
| void | [gtk\_overlay\_layout\_child\_set\_measure](gtkoverlaylayout#gtk-overlay-layout-child-set-measure) () |
| gboolean | [gtk\_overlay\_layout\_child\_get\_measure](gtkoverlaylayout#gtk-overlay-layout-child-get-measure) () |
| void | [gtk\_overlay\_layout\_child\_set\_clip\_overlay](gtkoverlaylayout#gtk-overlay-layout-child-set-clip-overlay) () |
| gboolean | [gtk\_overlay\_layout\_child\_get\_clip\_overlay](gtkoverlaylayout#gtk-overlay-layout-child-get-clip-overlay) () |
Properties
----------
| | | |
| --- | --- | --- |
| gboolean | [clip-overlay](gtkoverlaylayout#GtkOverlayLayoutChild--clip-overlay) | Read / Write |
| gboolean | [measure](gtkoverlaylayout#GtkOverlayLayoutChild--measure) | Read / Write |
Types and Values
----------------
| | |
| --- | --- |
| | [GtkOverlayLayout](gtkoverlaylayout#GtkOverlayLayout-struct) |
| | [GtkOverlayLayoutChild](gtkoverlaylayout#GtkOverlayLayoutChild-struct) |
Object Hierarchy
----------------
```
GObject
├── [GtkLayoutChild](gtklayoutchild#GtkLayoutChild-struct)
│ ╰── GtkOverlayLayoutChild
╰── [GtkLayoutManager](gtklayoutmanager#GtkLayoutManager-struct)
╰── GtkOverlayLayout
```
Includes
--------
```
#include <gtk/gtk.h>
```
Description
-----------
GtkOverlayLayout is the layout manager used by [GtkOverlay](gtkoverlay#GtkOverlay-struct). It places widgets as overlays on top of the main child.
This is not a reusable layout manager, since it expects its widget to be a [GtkOverlay](gtkoverlay#GtkOverlay-struct). It only listed here so that its layout properties get documented.
Functions
---------
### gtk\_overlay\_layout\_new ()
```
[GtkLayoutManager](gtklayoutmanager#GtkLayoutManager-struct) *
gtk_overlay_layout_new (*`void`*);
```
Creates a new [GtkOverlayLayout](gtkoverlaylayout#GtkOverlayLayout-struct) instance.
#### Returns
the newly created instance
### gtk\_overlay\_layout\_child\_set\_measure ()
```
void
gtk_overlay_layout_child_set_measure (*`[GtkOverlayLayoutChild](gtkoverlaylayout#GtkOverlayLayoutChild-struct) *child`*,
*`gboolean measure`*);
```
Sets whether to measure this child.
#### Parameters
| | | |
| --- | --- | --- |
| child | a [GtkOverlayLayoutChild](gtkoverlaylayout#GtkOverlayLayoutChild-struct) | |
| measure | whether to measure this child | |
### gtk\_overlay\_layout\_child\_get\_measure ()
```
gboolean
gtk_overlay_layout_child_get_measure (*`[GtkOverlayLayoutChild](gtkoverlaylayout#GtkOverlayLayoutChild-struct) *child`*);
```
Retrieves whether the child is measured.
#### Parameters
| | | |
| --- | --- | --- |
| child | a [GtkOverlayLayoutChild](gtkoverlaylayout#GtkOverlayLayoutChild-struct) | |
#### Returns
whether the child is measured
### gtk\_overlay\_layout\_child\_set\_clip\_overlay ()
```
void
gtk_overlay_layout_child_set_clip_overlay
(*`[GtkOverlayLayoutChild](gtkoverlaylayout#GtkOverlayLayoutChild-struct) *child`*,
*`gboolean clip_overlay`*);
```
Sets whether to clip this child.
#### Parameters
| | | |
| --- | --- | --- |
| child | a [GtkOverlayLayoutChild](gtkoverlaylayout#GtkOverlayLayoutChild-struct) | |
| clip\_overlay | whether to clip this child | |
### gtk\_overlay\_layout\_child\_get\_clip\_overlay ()
```
gboolean
gtk_overlay_layout_child_get_clip_overlay
(*`[GtkOverlayLayoutChild](gtkoverlaylayout#GtkOverlayLayoutChild-struct) *child`*);
```
Retrieves whether the child is clipped.
#### Parameters
| | | |
| --- | --- | --- |
| child | a [GtkOverlayLayoutChild](gtkoverlaylayout#GtkOverlayLayoutChild-struct) | |
#### Returns
whether the child is clipped
Types and Values
----------------
### GtkOverlayLayout
```
typedef struct _GtkOverlayLayout GtkOverlayLayout;
```
### GtkOverlayLayoutChild
```
typedef struct _GtkOverlayLayoutChild GtkOverlayLayoutChild;
```
Property Details
----------------
### The `“clip-overlay”` property
```
“clip-overlay” gboolean
```
Whether the child should be clipped to fit the parent's size.
Owner: GtkOverlayLayoutChild
Flags: Read / Write
Default value: FALSE
### The `“measure”` property
```
“measure” gboolean
```
Whether the child size should contribute to the [GtkOverlayLayout](gtkoverlaylayout#GtkOverlayLayout-struct)'s measurement.
Owner: GtkOverlayLayoutChild
Flags: Read / Write
Default value: FALSE
gtk GtkSpinner GtkSpinner
==========
GtkSpinner — Show a spinner animation
Functions
---------
| | |
| --- | --- |
| [GtkWidget](gtkwidget#GtkWidget-struct) \* | [gtk\_spinner\_new](gtkspinner#gtk-spinner-new) () |
| void | [gtk\_spinner\_start](gtkspinner#gtk-spinner-start) () |
| void | [gtk\_spinner\_stop](gtkspinner#gtk-spinner-stop) () |
| void | [gtk\_spinner\_set\_spinning](gtkspinner#gtk-spinner-set-spinning) () |
| gboolean | [gtk\_spinner\_get\_spinning](gtkspinner#gtk-spinner-get-spinning) () |
Properties
----------
| | | |
| --- | --- | --- |
| gboolean | [spinning](gtkspinner#GtkSpinner--spinning) | Read / Write |
Types and Values
----------------
| | |
| --- | --- |
| | [GtkSpinner](gtkspinner#GtkSpinner-struct) |
Object Hierarchy
----------------
```
GObject
╰── GInitiallyUnowned
╰── [GtkWidget](gtkwidget#GtkWidget-struct)
╰── GtkSpinner
```
Implemented Interfaces
----------------------
GtkSpinner implements [GtkAccessible](gtkaccessible#GtkAccessible-struct), [GtkBuildable](gtkbuildable#GtkBuildable-struct) and [GtkConstraintTarget](gtkconstraint#GtkConstraintTarget-struct).
Includes
--------
```
#include <gtk/gtk.h>
```
Description
-----------
A GtkSpinner widget displays an icon-size spinning animation. It is often used as an alternative to a [GtkProgressBar](gtkprogressbar#GtkProgressBar-struct) for displaying indefinite activity, instead of actual progress.
To start the animation, use [`gtk_spinner_start()`](gtkspinner#gtk-spinner-start), to stop it use [`gtk_spinner_stop()`](gtkspinner#gtk-spinner-stop).
### CSS nodes
GtkSpinner has a single CSS node with the name spinner. When the animation is active, the :checked pseudoclass is added to this node.
Functions
---------
### gtk\_spinner\_new ()
```
[GtkWidget](gtkwidget#GtkWidget-struct) *
gtk_spinner_new (*`void`*);
```
Returns a new spinner widget. Not yet started.
#### Returns
a new [GtkSpinner](gtkspinner#GtkSpinner-struct)
### gtk\_spinner\_start ()
```
void
gtk_spinner_start (*`[GtkSpinner](gtkspinner#GtkSpinner-struct) *spinner`*);
```
Starts the animation of the spinner.
#### Parameters
| | | |
| --- | --- | --- |
| spinner | a [GtkSpinner](gtkspinner#GtkSpinner-struct) | |
### gtk\_spinner\_stop ()
```
void
gtk_spinner_stop (*`[GtkSpinner](gtkspinner#GtkSpinner-struct) *spinner`*);
```
Stops the animation of the spinner.
#### Parameters
| | | |
| --- | --- | --- |
| spinner | a [GtkSpinner](gtkspinner#GtkSpinner-struct) | |
### gtk\_spinner\_set\_spinning ()
```
void
gtk_spinner_set_spinning (*`[GtkSpinner](gtkspinner#GtkSpinner-struct) *spinner`*,
*`gboolean spinning`*);
```
Sets the activity of the spinner.
#### Parameters
| | | |
| --- | --- | --- |
| spinner | a [GtkSpinner](gtkspinner#GtkSpinner-struct) | |
| spinning | whether the spinner should be spinning | |
### gtk\_spinner\_get\_spinning ()
```
gboolean
gtk_spinner_get_spinning (*`[GtkSpinner](gtkspinner#GtkSpinner-struct) *spinner`*);
```
Returns whether the spinner is spinning.
#### Parameters
| | | |
| --- | --- | --- |
| spinner | a [GtkSpinner](gtkspinner#GtkSpinner-struct) | |
#### Returns
`TRUE` if the spinner is active
Types and Values
----------------
### GtkSpinner
```
typedef struct _GtkSpinner GtkSpinner;
```
Property Details
----------------
### The `“spinning”` property
```
“spinning” gboolean
```
Whether the spinner is spinning.
Owner: GtkSpinner
Flags: Read / Write
Default value: FALSE
See Also
--------
[GtkCellRendererSpinner](gtkcellrendererspinner#GtkCellRendererSpinner-struct), [GtkProgressBar](gtkprogressbar#GtkProgressBar-struct)
| programming_docs |
gtk GtkApplication GtkApplication
==============
GtkApplication — Application class
Functions
---------
| | |
| --- | --- |
| [GtkApplication](gtkapplication#GtkApplication-struct) \* | [gtk\_application\_new](gtkapplication#gtk-application-new) () |
| void | [gtk\_application\_add\_window](gtkapplication#gtk-application-add-window) () |
| void | [gtk\_application\_remove\_window](gtkapplication#gtk-application-remove-window) () |
| GList \* | [gtk\_application\_get\_windows](gtkapplication#gtk-application-get-windows) () |
| [GtkWindow](gtkwindow#GtkWindow-struct) \* | [gtk\_application\_get\_window\_by\_id](gtkapplication#gtk-application-get-window-by-id) () |
| [GtkWindow](gtkwindow#GtkWindow-struct) \* | [gtk\_application\_get\_active\_window](gtkapplication#gtk-application-get-active-window) () |
| guint | [gtk\_application\_inhibit](gtkapplication#gtk-application-inhibit) () |
| void | [gtk\_application\_uninhibit](gtkapplication#gtk-application-uninhibit) () |
| GMenuModel \* | [gtk\_application\_get\_menubar](gtkapplication#gtk-application-get-menubar) () |
| void | [gtk\_application\_set\_menubar](gtkapplication#gtk-application-set-menubar) () |
| GMenu \* | [gtk\_application\_get\_menu\_by\_id](gtkapplication#gtk-application-get-menu-by-id) () |
| char \*\* | [gtk\_application\_list\_action\_descriptions](gtkapplication#gtk-application-list-action-descriptions) () |
| char \*\* | [gtk\_application\_get\_accels\_for\_action](gtkapplication#gtk-application-get-accels-for-action) () |
| void | [gtk\_application\_set\_accels\_for\_action](gtkapplication#gtk-application-set-accels-for-action) () |
| char \*\* | [gtk\_application\_get\_actions\_for\_accel](gtkapplication#gtk-application-get-actions-for-accel) () |
Properties
----------
| | | |
| --- | --- | --- |
| [GtkWindow](gtkwindow#GtkWindow-struct) \* | [active-window](gtkapplication#GtkApplication--active-window) | Read |
| GMenuModel \* | [menubar](gtkapplication#GtkApplication--menubar) | Read / Write |
| gboolean | [register-session](gtkapplication#GtkApplication--register-session) | Read / Write |
| gboolean | [screensaver-active](gtkapplication#GtkApplication--screensaver-active) | Read |
Signals
-------
| | | |
| --- | --- | --- |
| void | [query-end](gtkapplication#GtkApplication-query-end) | Run First |
| void | [window-added](gtkapplication#GtkApplication-window-added) | Run First |
| void | [window-removed](gtkapplication#GtkApplication-window-removed) | Run First |
Types and Values
----------------
| | |
| --- | --- |
| struct | [GtkApplication](gtkapplication#GtkApplication-struct) |
| struct | [GtkApplicationClass](gtkapplication#GtkApplicationClass) |
| enum | [GtkApplicationInhibitFlags](gtkapplication#GtkApplicationInhibitFlags) |
Object Hierarchy
----------------
```
GObject
╰── GApplication
╰── GtkApplication
```
Implemented Interfaces
----------------------
GtkApplication implements GActionGroup and GActionMap.
Includes
--------
```
#include <gtk/gtk.h>
```
Description
-----------
[GtkApplication](gtkapplication#GtkApplication-struct) is a class that handles many important aspects of a GTK+ application in a convenient fashion, without enforcing a one-size-fits-all application model.
Currently, GtkApplication handles GTK initialization, application uniqueness, session management, provides some basic scriptability and desktop shell integration by exporting actions and menus and manages a list of toplevel windows whose life-cycle is automatically tied to the life-cycle of your application.
While GtkApplication works fine with plain [GtkWindows](gtkwindow#GtkWindow-struct), it is recommended to use it together with [GtkApplicationWindow](gtkapplicationwindow#GtkApplicationWindow-struct).
When GDK threads are enabled, GtkApplication will acquire the GDK lock when invoking actions that arrive from other processes. The GDK lock is not touched for local action invocations. In order to have actions invoked in a predictable context it is therefore recommended that the GDK lock be held while invoking actions locally with `g_action_group_activate_action()`. The same applies to actions associated with [GtkApplicationWindow](gtkapplicationwindow#GtkApplicationWindow-struct) and to the “activate” and “open” GApplication methods.
#### Automatic resources
[GtkApplication](gtkapplication#GtkApplication-struct) will automatically load menus from the [GtkBuilder](gtkbuilder#GtkBuilder-struct) resource located at "gtk/menus.ui", relative to the application's resource base path (see `g_application_set_resource_base_path()`). The menu with the ID "menubar" is taken as the application's menubar. Additional menus (most interesting submenus) can be named and accessed via [`gtk_application_get_menu_by_id()`](gtkapplication#gtk-application-get-menu-by-id) which allows for dynamic population of a part of the menu structure.
It is also possible to provide the menubar manually using [`gtk_application_set_menubar()`](gtkapplication#gtk-application-set-menubar).
[GtkApplication](gtkapplication#GtkApplication-struct) will also automatically setup an icon search path for the default icon theme by appending "icons" to the resource base path. This allows your application to easily store its icons as resources. See [`gtk_icon_theme_add_resource_path()`](gtkicontheme#gtk-icon-theme-add-resource-path) for more information.
If there is a resource located at "gtk/help-overlay.ui" which defines a [GtkShortcutsWindow](gtkshortcutswindow#GtkShortcutsWindow-struct) with ID "help\_overlay" then GtkApplication associates an instance of this shortcuts window with each [GtkApplicationWindow](gtkapplicationwindow#GtkApplicationWindow-struct) and sets up the keyboard accelerator Control-? to open it. To create a menu item that displays the shortcuts window, associate the item with the action win.show-help-overlay.
#### A simple application
[A simple example](https://gitlab.gnome.org/GNOME/gtk/tree/master/examples/bp/bloatpad.c)
GtkApplication optionally registers with a session manager of the users session (if you set the [“register-session”](gtkapplication#GtkApplication--register-session) property) and offers various functionality related to the session life-cycle.
An application can block various ways to end the session with the [`gtk_application_inhibit()`](gtkapplication#gtk-application-inhibit) function. Typical use cases for this kind of inhibiting are long-running, uninterruptible operations, such as burning a CD or performing a disk backup. The session manager may not honor the inhibitor, but it can be expected to inform the user about the negative consequences of ending the session while inhibitors are present.
#### See Also
[HowDoI: Using GtkApplication](https://wiki.gnome.org/HowDoI/GtkApplication), [Getting Started with GTK: Basics](https://developer-old.gnome.org/gtk3/stable/gtk-getting-started.html#id-1.2.3.3)
Functions
---------
### gtk\_application\_new ()
```
[GtkApplication](gtkapplication#GtkApplication-struct) *
gtk_application_new (*`const char *application_id`*,
*`GApplicationFlags flags`*);
```
Creates a new [GtkApplication](gtkapplication#GtkApplication-struct) instance.
When using [GtkApplication](gtkapplication#GtkApplication-struct), it is not necessary to call [`gtk_init()`](gtk4-general#gtk-init) manually. It is called as soon as the application gets registered as the primary instance.
Concretely, [`gtk_init()`](gtk4-general#gtk-init) is called in the default handler for the “startup” signal. Therefore, [GtkApplication](gtkapplication#GtkApplication-struct) subclasses should chain up in their “startup” handler before using any GTK+ API.
Note that commandline arguments are not passed to [`gtk_init()`](gtk4-general#gtk-init). All GTK+ functionality that is available via commandline arguments can also be achieved by setting suitable environment variables such as `G_DEBUG`, so this should not be a big problem. If you absolutely must support GTK+ commandline arguments, you can explicitly call [`gtk_init()`](gtk4-general#gtk-init) before creating the application instance.
If non-`NULL`, the application ID must be valid. See `g_application_id_is_valid()`.
If no application ID is given then some features (most notably application uniqueness) will be disabled.
#### Parameters
| | | |
| --- | --- | --- |
| application\_id | The application ID. | [allow-none] |
| flags | the application flags | |
#### Returns
a new [GtkApplication](gtkapplication#GtkApplication-struct) instance
### gtk\_application\_add\_window ()
```
void
gtk_application_add_window (*`[GtkApplication](gtkapplication#GtkApplication-struct) *application`*,
*`[GtkWindow](gtkwindow#GtkWindow-struct) *window`*);
```
Adds a window to *`application`* .
This call can only happen after the *`application`* has started; typically, you should add new application windows in response to the emission of the “activate” signal.
This call is equivalent to setting the [“application”](gtkwindow#GtkWindow--application) property of *`window`* to *`application`* .
Normally, the connection between the application and the window will remain until the window is destroyed, but you can explicitly remove it with [`gtk_application_remove_window()`](gtkapplication#gtk-application-remove-window).
GTK+ will keep the *`application`* running as long as it has any windows.
#### Parameters
| | | |
| --- | --- | --- |
| application | a [GtkApplication](gtkapplication#GtkApplication-struct) | |
| window | a [GtkWindow](gtkwindow#GtkWindow-struct) | |
### gtk\_application\_remove\_window ()
```
void
gtk_application_remove_window (*`[GtkApplication](gtkapplication#GtkApplication-struct) *application`*,
*`[GtkWindow](gtkwindow#GtkWindow-struct) *window`*);
```
Remove a window from *`application`* .
If *`window`* belongs to *`application`* then this call is equivalent to setting the [“application”](gtkwindow#GtkWindow--application) property of *`window`* to `NULL`.
The application may stop running as a result of a call to this function.
#### Parameters
| | | |
| --- | --- | --- |
| application | a [GtkApplication](gtkapplication#GtkApplication-struct) | |
| window | a [GtkWindow](gtkwindow#GtkWindow-struct) | |
### gtk\_application\_get\_windows ()
```
GList *
gtk_application_get_windows (*`[GtkApplication](gtkapplication#GtkApplication-struct) *application`*);
```
Gets a list of the [GtkWindows](gtkwindow#GtkWindow-struct) associated with *`application`* .
The list is sorted by most recently focused window, such that the first element is the currently focused window. (Useful for choosing a parent for a transient window.)
The list that is returned should not be modified in any way. It will only remain valid until the next focus change or window creation or deletion.
#### Parameters
| | | |
| --- | --- | --- |
| application | a [GtkApplication](gtkapplication#GtkApplication-struct) | |
#### Returns
a GList of [GtkWindow](gtkwindow#GtkWindow-struct).
[element-type GtkWindow][transfer none]
### gtk\_application\_get\_window\_by\_id ()
```
[GtkWindow](gtkwindow#GtkWindow-struct) *
gtk_application_get_window_by_id (*`[GtkApplication](gtkapplication#GtkApplication-struct) *application`*,
*`guint id`*);
```
Returns the [GtkApplicationWindow](gtkapplicationwindow#GtkApplicationWindow-struct) with the given ID.
The ID of a [GtkApplicationWindow](gtkapplicationwindow#GtkApplicationWindow-struct) can be retrieved with [`gtk_application_window_get_id()`](gtkapplicationwindow#gtk-application-window-get-id).
#### Parameters
| | | |
| --- | --- | --- |
| application | a [GtkApplication](gtkapplication#GtkApplication-struct) | |
| id | an identifier number | |
#### Returns
the window with ID *`id`* , or `NULL` if there is no window with this ID.
[nullable][transfer none]
### gtk\_application\_get\_active\_window ()
```
[GtkWindow](gtkwindow#GtkWindow-struct) *
gtk_application_get_active_window (*`[GtkApplication](gtkapplication#GtkApplication-struct) *application`*);
```
Gets the “active” window for the application.
The active window is the one that was most recently focused (within the application). This window may not have the focus at the moment if another application has it — this is just the most recently-focused window within this application.
#### Parameters
| | | |
| --- | --- | --- |
| application | a [GtkApplication](gtkapplication#GtkApplication-struct) | |
#### Returns
the active window, or `NULL` if there isn't one.
[transfer none][nullable]
### gtk\_application\_inhibit ()
```
guint
gtk_application_inhibit (*`[GtkApplication](gtkapplication#GtkApplication-struct) *application`*,
*`[GtkWindow](gtkwindow#GtkWindow-struct) *window`*,
*`[GtkApplicationInhibitFlags](gtkapplication#GtkApplicationInhibitFlags) flags`*,
*`const char *reason`*);
```
Inform the session manager that certain types of actions should be inhibited. This is not guaranteed to work on all platforms and for all types of actions.
Applications should invoke this method when they begin an operation that should not be interrupted, such as creating a CD or DVD. The types of actions that may be blocked are specified by the *`flags`* parameter. When the application completes the operation it should call [`gtk_application_uninhibit()`](gtkapplication#gtk-application-uninhibit) to remove the inhibitor. Note that an application can have multiple inhibitors, and all of them must be individually removed. Inhibitors are also cleared when the application exits.
Applications should not expect that they will always be able to block the action. In most cases, users will be given the option to force the action to take place.
Reasons should be short and to the point.
If *`window`* is given, the session manager may point the user to this window to find out more about why the action is inhibited.
#### Parameters
| | | |
| --- | --- | --- |
| application | the [GtkApplication](gtkapplication#GtkApplication-struct) | |
| window | a [GtkWindow](gtkwindow#GtkWindow-struct), or `NULL`. | [allow-none] |
| flags | what types of actions should be inhibited | |
| reason | a short, human-readable string that explains why these operations are inhibited. | [allow-none] |
#### Returns
A non-zero cookie that is used to uniquely identify this request. It should be used as an argument to [`gtk_application_uninhibit()`](gtkapplication#gtk-application-uninhibit) in order to remove the request. If the platform does not support inhibiting or the request failed for some reason, 0 is returned.
### gtk\_application\_uninhibit ()
```
void
gtk_application_uninhibit (*`[GtkApplication](gtkapplication#GtkApplication-struct) *application`*,
*`guint cookie`*);
```
Removes an inhibitor that has been established with [`gtk_application_inhibit()`](gtkapplication#gtk-application-inhibit). Inhibitors are also cleared when the application exits.
#### Parameters
| | | |
| --- | --- | --- |
| application | the [GtkApplication](gtkapplication#GtkApplication-struct) | |
| cookie | a cookie that was returned by [`gtk_application_inhibit()`](gtkapplication#gtk-application-inhibit) | |
### gtk\_application\_get\_menubar ()
```
GMenuModel *
gtk_application_get_menubar (*`[GtkApplication](gtkapplication#GtkApplication-struct) *application`*);
```
Returns the menu model that has been set with [`gtk_application_set_menubar()`](gtkapplication#gtk-application-set-menubar).
#### Parameters
| | | |
| --- | --- | --- |
| application | a [GtkApplication](gtkapplication#GtkApplication-struct) | |
#### Returns
the menubar for windows of *`application`* .
[nullable][transfer none]
### gtk\_application\_set\_menubar ()
```
void
gtk_application_set_menubar (*`[GtkApplication](gtkapplication#GtkApplication-struct) *application`*,
*`GMenuModel *menubar`*);
```
Sets or unsets the menubar for windows of *`application`* .
This is a menubar in the traditional sense.
This can only be done in the primary instance of the application, after it has been registered. “startup” is a good place to call this.
Depending on the desktop environment, this may appear at the top of each window, or at the top of the screen. In some environments, if both the application menu and the menubar are set, the application menu will be presented as if it were the first item of the menubar. Other environments treat the two as completely separate — for example, the application menu may be rendered by the desktop shell while the menubar (if set) remains in each individual window.
Use the base GActionMap interface to add actions, to respond to the user selecting these menu items.
#### Parameters
| | | |
| --- | --- | --- |
| application | a [GtkApplication](gtkapplication#GtkApplication-struct) | |
| menubar | a GMenuModel, or `NULL`. | [allow-none] |
### gtk\_application\_get\_menu\_by\_id ()
```
GMenu *
gtk_application_get_menu_by_id (*`[GtkApplication](gtkapplication#GtkApplication-struct) *application`*,
*`const char *id`*);
```
Gets a menu from automatically loaded resources. See Automatic resources for more information.
#### Parameters
| | | |
| --- | --- | --- |
| application | a [GtkApplication](gtkapplication#GtkApplication-struct) | |
| id | the id of the menu to look up | |
#### Returns
Gets the menu with the given id from the automatically loaded resources.
[nullable][transfer none]
### gtk\_application\_list\_action\_descriptions ()
```
char **
gtk_application_list_action_descriptions
(*`[GtkApplication](gtkapplication#GtkApplication-struct) *application`*);
```
Lists the detailed action names which have associated accelerators. See [`gtk_application_set_accels_for_action()`](gtkapplication#gtk-application-set-accels-for-action).
#### Parameters
| | | |
| --- | --- | --- |
| application | a [GtkApplication](gtkapplication#GtkApplication-struct) | |
#### Returns
a `NULL`-terminated array of strings, free with `g_strfreev()` when done.
[transfer full]
### gtk\_application\_get\_accels\_for\_action ()
```
char **
gtk_application_get_accels_for_action (*`[GtkApplication](gtkapplication#GtkApplication-struct) *application`*,
*`const char *detailed_action_name`*);
```
Gets the accelerators that are currently associated with the given action.
#### Parameters
| | | |
| --- | --- | --- |
| application | a [GtkApplication](gtkapplication#GtkApplication-struct) | |
| detailed\_action\_name | a detailed action name, specifying an action and target to obtain accelerators for | |
#### Returns
accelerators for *`detailed_action_name`* , as a `NULL`-terminated array. Free with `g_strfreev()` when no longer needed.
[transfer full]
### gtk\_application\_set\_accels\_for\_action ()
```
void
gtk_application_set_accels_for_action (*`[GtkApplication](gtkapplication#GtkApplication-struct) *application`*,
*`const char *detailed_action_name`*,
*`const char * const *accels`*);
```
Sets zero or more keyboard accelerators that will trigger the given action. The first item in *`accels`* will be the primary accelerator, which may be displayed in the UI.
To remove all accelerators for an action, use an empty, zero-terminated array for *`accels`* .
For the *`detailed_action_name`* , see `g_action_parse_detailed_name()` and `g_action_print_detailed_name()`.
#### Parameters
| | | |
| --- | --- | --- |
| application | a [GtkApplication](gtkapplication#GtkApplication-struct) | |
| detailed\_action\_name | a detailed action name, specifying an action and target to associate accelerators with | |
| accels | a list of accelerators in the format understood by [`gtk_accelerator_parse()`](gtk4-keyboard-accelerators#gtk-accelerator-parse). | [array zero-terminated=1] |
### gtk\_application\_get\_actions\_for\_accel ()
```
char **
gtk_application_get_actions_for_accel (*`[GtkApplication](gtkapplication#GtkApplication-struct) *application`*,
*`const char *accel`*);
```
Returns the list of actions (possibly empty) that *`accel`* maps to. Each item in the list is a detailed action name in the usual form.
This might be useful to discover if an accel already exists in order to prevent installation of a conflicting accelerator (from an accelerator editor or a plugin system, for example). Note that having more than one action per accelerator may not be a bad thing and might make sense in cases where the actions never appear in the same context.
In case there are no actions for a given accelerator, an empty array is returned. `NULL` is never returned.
It is a programmer error to pass an invalid accelerator string. If you are unsure, check it with [`gtk_accelerator_parse()`](gtk4-keyboard-accelerators#gtk-accelerator-parse) first.
#### Parameters
| | | |
| --- | --- | --- |
| application | a [GtkApplication](gtkapplication#GtkApplication-struct) | |
| accel | an accelerator that can be parsed by [`gtk_accelerator_parse()`](gtk4-keyboard-accelerators#gtk-accelerator-parse) | |
#### Returns
a `NULL`-terminated array of actions for *`accel`* .
[transfer full]
Types and Values
----------------
### struct GtkApplication
```
struct GtkApplication;
```
### struct GtkApplicationClass
```
struct GtkApplicationClass {
GApplicationClass parent_class;
void (*window_added) (GtkApplication *application,
GtkWindow *window);
void (*window_removed) (GtkApplication *application,
GtkWindow *window);
};
```
#### Members
| | | |
| --- | --- | --- |
| *`window_added`* () | Signal emitted when a [GtkWindow](gtkwindow#GtkWindow-struct) is added to application through [`gtk_application_add_window()`](gtkapplication#gtk-application-add-window). | |
| *`window_removed`* () | Signal emitted when a [GtkWindow](gtkwindow#GtkWindow-struct) is removed from application, either as a side-effect of being destroyed or explicitly through [`gtk_application_remove_window()`](gtkapplication#gtk-application-remove-window). | |
### enum GtkApplicationInhibitFlags
Types of user actions that may be blocked by [`gtk_application_inhibit()`](gtkapplication#gtk-application-inhibit).
#### Members
| | | |
| --- | --- | --- |
| GTK\_APPLICATION\_INHIBIT\_LOGOUT | Inhibit ending the user session by logging out or by shutting down the computer | |
| GTK\_APPLICATION\_INHIBIT\_SWITCH | Inhibit user switching | |
| GTK\_APPLICATION\_INHIBIT\_SUSPEND | Inhibit suspending the session or computer | |
| GTK\_APPLICATION\_INHIBIT\_IDLE | Inhibit the session being marked as idle (and possibly locked) | |
Property Details
----------------
### The `“active-window”` property
```
“active-window” [GtkWindow](gtkwindow#GtkWindow-struct) *
```
The window which most recently had focus.
Owner: GtkApplication
Flags: Read
### The `“menubar”` property
```
“menubar” GMenuModel *
```
The GMenuModel for the menubar.
Owner: GtkApplication
Flags: Read / Write
### The `“register-session”` property
```
“register-session” gboolean
```
Set this property to `TRUE` to register with the session manager. This will make GTK+ track the session state (such as the [“screensaver-active”](gtkapplication#GtkApplication--screensaver-active) property).
Owner: GtkApplication
Flags: Read / Write
Default value: FALSE
### The `“screensaver-active”` property
```
“screensaver-active” gboolean
```
This property is `TRUE` if GTK+ believes that the screensaver is currently active. GTK+ only tracks session state (including this) when [“register-session”](gtkapplication#GtkApplication--register-session) is set to `TRUE`.
Tracking the screensaver state is supported on Linux.
Owner: GtkApplication
Flags: Read
Default value: FALSE
Signal Details
--------------
### The `“query-end”` signal
```
void
user_function ([GtkApplication](gtkapplication#GtkApplication-struct) *application,
gpointer user_data)
```
Emitted when the session manager is about to end the session, only if [“register-session”](gtkapplication#GtkApplication--register-session) is `TRUE`. Applications can connect to this signal and call [`gtk_application_inhibit()`](gtkapplication#gtk-application-inhibit) with [`GTK_APPLICATION_INHIBIT_LOGOUT`](gtkapplication#GTK-APPLICATION-INHIBIT-LOGOUT:CAPS) to delay the end of the session until state has been saved.
#### Parameters
| | | |
| --- | --- | --- |
| application | the [GtkApplication](gtkapplication#GtkApplication-struct) which emitted the signal | |
| user\_data | user data set when the signal handler was connected. | |
Flags: Run First
### The `“window-added”` signal
```
void
user_function ([GtkApplication](gtkapplication#GtkApplication-struct) *application,
[GtkWindow](gtkwindow#GtkWindow-struct) *window,
gpointer user_data)
```
Emitted when a [GtkWindow](gtkwindow#GtkWindow-struct) is added to *`application`* through [`gtk_application_add_window()`](gtkapplication#gtk-application-add-window).
#### Parameters
| | | |
| --- | --- | --- |
| application | the [GtkApplication](gtkapplication#GtkApplication-struct) which emitted the signal | |
| window | the newly-added [GtkWindow](gtkwindow#GtkWindow-struct) | |
| user\_data | user data set when the signal handler was connected. | |
Flags: Run First
### The `“window-removed”` signal
```
void
user_function ([GtkApplication](gtkapplication#GtkApplication-struct) *application,
[GtkWindow](gtkwindow#GtkWindow-struct) *window,
gpointer user_data)
```
Emitted when a [GtkWindow](gtkwindow#GtkWindow-struct) is removed from *`application`* , either as a side-effect of being destroyed or explicitly through [`gtk_application_remove_window()`](gtkapplication#gtk-application-remove-window).
#### Parameters
| | | |
| --- | --- | --- |
| application | the [GtkApplication](gtkapplication#GtkApplication-struct) which emitted the signal | |
| window | the [GtkWindow](gtkwindow#GtkWindow-struct) that is being removed | |
| user\_data | user data set when the signal handler was connected. | |
Flags: Run First
| programming_docs |
gtk GtkListView GtkListView
===========
GtkListView — A widget for displaying lists
Functions
---------
| | |
| --- | --- |
| [GtkWidget](gtkwidget#GtkWidget-struct) \* | [gtk\_list\_view\_new](gtklistview#gtk-list-view-new) () |
| void | [gtk\_list\_view\_set\_factory](gtklistview#gtk-list-view-set-factory) () |
| [GtkListItemFactory](gtklistitemfactory#GtkListItemFactory-struct) \* | [gtk\_list\_view\_get\_factory](gtklistview#gtk-list-view-get-factory) () |
| void | [gtk\_list\_view\_set\_model](gtklistview#gtk-list-view-set-model) () |
| [GtkSelectionModel](gtkselectionmodel#GtkSelectionModel-struct) \* | [gtk\_list\_view\_get\_model](gtklistview#gtk-list-view-get-model) () |
| void | [gtk\_list\_view\_set\_show\_separators](gtklistview#gtk-list-view-set-show-separators) () |
| gboolean | [gtk\_list\_view\_get\_show\_separators](gtklistview#gtk-list-view-get-show-separators) () |
| void | [gtk\_list\_view\_set\_single\_click\_activate](gtklistview#gtk-list-view-set-single-click-activate) () |
| gboolean | [gtk\_list\_view\_get\_single\_click\_activate](gtklistview#gtk-list-view-get-single-click-activate) () |
| void | [gtk\_list\_view\_set\_enable\_rubberband](gtklistview#gtk-list-view-set-enable-rubberband) () |
| gboolean | [gtk\_list\_view\_get\_enable\_rubberband](gtklistview#gtk-list-view-get-enable-rubberband) () |
Properties
----------
| | | |
| --- | --- | --- |
| gboolean | [enable-rubberband](gtklistview#GtkListView--enable-rubberband) | Read / Write |
| [GtkListItemFactory](gtklistitemfactory#GtkListItemFactory-struct) \* | [factory](gtklistview#GtkListView--factory) | Read / Write |
| [GtkSelectionModel](gtkselectionmodel#GtkSelectionModel-struct) \* | [model](gtklistview#GtkListView--model) | Read / Write |
| gboolean | [show-separators](gtklistview#GtkListView--show-separators) | Read / Write |
| gboolean | [single-click-activate](gtklistview#GtkListView--single-click-activate) | Read / Write |
Signals
-------
| | | |
| --- | --- | --- |
| void | [activate](gtklistview#GtkListView-activate) | Run Last |
Actions
-------
| | | |
| --- | --- | --- |
| | list.activate-item | u |
Types and Values
----------------
| | |
| --- | --- |
| | [GtkListView](gtklistview#GtkListView-struct) |
Object Hierarchy
----------------
```
GObject
╰── GInitiallyUnowned
╰── [GtkWidget](gtkwidget#GtkWidget-struct)
╰── GtkListBase
╰── GtkListView
```
Implemented Interfaces
----------------------
GtkListView implements [GtkAccessible](gtkaccessible#GtkAccessible-struct), [GtkBuildable](gtkbuildable#GtkBuildable-struct), [GtkConstraintTarget](gtkconstraint#GtkConstraintTarget-struct), [GtkOrientable](gtk4-orientable#GtkOrientable-struct) and [GtkScrollable](gtkscrollable#GtkScrollable-struct).
Includes
--------
```
#include <gtk/gtk.h>
```
Description
-----------
GtkListView is a widget to present a view into a large dynamic list of items.
GtkListView uses its factory to generate one row widget for each visible item and shows them in a linear display, either vertically or horizontally. The [“show-separators”](gtklistview#GtkListView--show-separators) property offers a simple way to display separators between the rows.
GtkListView allows the user to select items according to the selection characteristics of the model. For models that allow multiple selected items, it is possible to turn on \_rubberband selection\_, using [“enable-rubberband”](gtklistview#GtkListView--enable-rubberband).
If you need multiple columns with headers, see [GtkColumnView](gtkcolumnview#GtkColumnView-struct).
To learn more about the list widget framework, see the [overview](#ListWidget).
An example of using GtkListView:
### CSS nodes
```
static void
setup_listitem_cb (GtkListItemFactory *factory,
GtkListItem *list_item)
{
GtkWidget *image;
image = gtk_image_new ();
gtk_image_set_icon_size (GTK_IMAGE (image), GTK_ICON_SIZE_LARGE);
gtk_list_item_set_child (list_item, image);
}
static void
bind_listitem_cb (GtkListItemFactory *factory,
GtkListItem *list_item)
{
GtkWidget *image;
GAppInfo *app_info;
image = gtk_list_item_get_child (list_item);
app_info = gtk_list_item_get_item (list_item);
gtk_image_set_from_gicon (GTK_IMAGE (image), g_app_info_get_icon (app_info));
}
static void
activate_cb (GtkListView *list,
guint position,
gpointer unused)
{
GAppInfo *app_info;
app_info = g_list_model_get_item (G_LIST_MODEL (gtk_list_view_get_model (list)), position);
g_app_info_launch (app_info, NULL, NULL, NULL);
g_object_unref (app_info);
}
...
model = create_application_list ();
factory = gtk_signal_list_item_factory_new ();
g_signal_connect (factory, "setup", G_CALLBACK (setup_listitem_cb), NULL);
g_signal_connect (factory, "bind", G_CALLBACK (bind_listitem_cb), NULL);
list = gtk_list_view_new (GTK_SELECTION_MODEL (gtk_single_selection_new (model)), factory);
g_signal_connect (list, "activate", G_CALLBACK (activate_cb), NULL);
gtk_scrolled_window_set_child (GTK_SCROLLED_WINDOW (sw), list);
```
| GtkListView uses a single CSS node named listview. It may carry the .separators style class, when [“show-separators”](gtklistview#GtkListView--show-separators) property is set. Each child widget uses a single CSS node named row. For rubberband selection, a node with name rubberband is used.
The main listview node may also carry style classes to select the style of [list presentation](listcontainers#list-styles): .rich-list, .navigation-sidebar or .data-table.
### Accessibility
GtkListView uses the [GTK\_ACCESSIBLE\_ROLE\_LIST](gtkaccessible#GTK-ACCESSIBLE-ROLE-LIST:CAPS) role, and the list items use the [GTK\_ACCESSIBLE\_ROLE\_LIST\_ITEM](gtkaccessible#GTK-ACCESSIBLE-ROLE-LIST-ITEM:CAPS) role.
Functions
---------
### gtk\_list\_view\_new ()
```
[GtkWidget](gtkwidget#GtkWidget-struct) *
gtk_list_view_new (*`[GtkSelectionModel](gtkselectionmodel#GtkSelectionModel-struct) *model`*,
*`[GtkListItemFactory](gtklistitemfactory#GtkListItemFactory-struct) *factory`*);
```
Creates a new [GtkListView](gtklistview#GtkListView-struct) that uses the given *`factory`* for mapping items to widgets.
The function takes ownership of the arguments, so you can write code like `list_view = gtk_list_view_new (`create_model()`,
gtk_builder_list_item_factory_new_from_resource ("/resource.ui"));`
#### Parameters
| | | |
| --- | --- | --- |
| model | the model to use, or `NULL`. | [allow-none][transfer full] |
| factory | The factory to populate items with, or `NULL`. | [allow-none][transfer full] |
#### Returns
a new [GtkListView](gtklistview#GtkListView-struct) using the given *`model`* and *`factory`*
### gtk\_list\_view\_set\_factory ()
```
void
gtk_list_view_set_factory (*`[GtkListView](gtklistview#GtkListView-struct) *self`*,
*`[GtkListItemFactory](gtklistitemfactory#GtkListItemFactory-struct) *factory`*);
```
Sets the [GtkListItemFactory](gtklistitemfactory#GtkListItemFactory-struct) to use for populating list items.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkListView](gtklistview#GtkListView-struct) | |
| factory | the factory to use or `NULL` for none. | [allow-none][transfer none] |
### gtk\_list\_view\_get\_factory ()
```
[GtkListItemFactory](gtklistitemfactory#GtkListItemFactory-struct) *
gtk_list_view_get_factory (*`[GtkListView](gtklistview#GtkListView-struct) *self`*);
```
Gets the factory that's currently used to populate list items.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkListView](gtklistview#GtkListView-struct) | |
#### Returns
The factory in use.
[nullable][transfer none]
### gtk\_list\_view\_set\_model ()
```
void
gtk_list_view_set_model (*`[GtkListView](gtklistview#GtkListView-struct) *self`*,
*`[GtkSelectionModel](gtkselectionmodel#GtkSelectionModel-struct) *model`*);
```
Sets the [GtkSelectionModel](gtkselectionmodel#GtkSelectionModel-struct) to use.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkListView](gtklistview#GtkListView-struct) | |
| model | the model to use or `NULL` for none. | [allow-none][transfer none] |
### gtk\_list\_view\_get\_model ()
```
[GtkSelectionModel](gtkselectionmodel#GtkSelectionModel-struct) *
gtk_list_view_get_model (*`[GtkListView](gtklistview#GtkListView-struct) *self`*);
```
Gets the model that's currently used to read the items displayed.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkListView](gtklistview#GtkListView-struct) | |
#### Returns
The model in use.
[nullable][transfer none]
### gtk\_list\_view\_set\_show\_separators ()
```
void
gtk_list_view_set_show_separators (*`[GtkListView](gtklistview#GtkListView-struct) *self`*,
*`gboolean show_separators`*);
```
Sets whether the list box should show separators between rows.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkListView](gtklistview#GtkListView-struct) | |
| show\_separators | `TRUE` to show separators | |
### gtk\_list\_view\_get\_show\_separators ()
```
gboolean
gtk_list_view_get_show_separators (*`[GtkListView](gtklistview#GtkListView-struct) *self`*);
```
Returns whether the list box should show separators between rows.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkListView](gtklistview#GtkListView-struct) | |
#### Returns
`TRUE` if the list box shows separators
### gtk\_list\_view\_set\_single\_click\_activate ()
```
void
gtk_list_view_set_single_click_activate
(*`[GtkListView](gtklistview#GtkListView-struct) *self`*,
*`gboolean single_click_activate`*);
```
Sets whether rows should be activated on single click and selected on hover.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkListView](gtklistview#GtkListView-struct) | |
| single\_click\_activate | `TRUE` to activate items on single click | |
### gtk\_list\_view\_get\_single\_click\_activate ()
```
gboolean
gtk_list_view_get_single_click_activate
(*`[GtkListView](gtklistview#GtkListView-struct) *self`*);
```
Returns whether rows will be activated on single click and selected on hover.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkListView](gtklistview#GtkListView-struct) | |
#### Returns
`TRUE` if rows are activated on single click
### gtk\_list\_view\_set\_enable\_rubberband ()
```
void
gtk_list_view_set_enable_rubberband (*`[GtkListView](gtklistview#GtkListView-struct) *self`*,
*`gboolean enable_rubberband`*);
```
Sets whether selections can be changed by dragging with the mouse.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkListView](gtklistview#GtkListView-struct) | |
| enable\_rubberband | `TRUE` to enable rubberband selection | |
### gtk\_list\_view\_get\_enable\_rubberband ()
```
gboolean
gtk_list_view_get_enable_rubberband (*`[GtkListView](gtklistview#GtkListView-struct) *self`*);
```
Returns whether rows can be selected by dragging with the mouse.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkListView](gtklistview#GtkListView-struct) | |
#### Returns
`TRUE` if rubberband selection is enabled
Types and Values
----------------
### GtkListView
```
typedef struct _GtkListView GtkListView;
```
GtkListView is the simple list implementation for GTK's list widgets.
Property Details
----------------
### The `“enable-rubberband”` property
```
“enable-rubberband” gboolean
```
Allow rubberband selection
Owner: GtkListView
Flags: Read / Write
Default value: FALSE
### The `“factory”` property
```
“factory” [GtkListItemFactory](gtklistitemfactory#GtkListItemFactory-struct) *
```
Factory for populating list items
Owner: GtkListView
Flags: Read / Write
### The `“model”` property
```
“model” [GtkSelectionModel](gtkselectionmodel#GtkSelectionModel-struct) *
```
Model for the items displayed
Owner: GtkListView
Flags: Read / Write
### The `“show-separators”` property
```
“show-separators” gboolean
```
Show separators between rows
Owner: GtkListView
Flags: Read / Write
Default value: FALSE
### The `“single-click-activate”` property
```
“single-click-activate” gboolean
```
Activate rows on single click and select them on hover
Owner: GtkListView
Flags: Read / Write
Default value: FALSE
Signal Details
--------------
### The `“activate”` signal
```
void
user_function ([GtkListView](gtklistview#GtkListView-struct) *self,
guint position,
gpointer user_data)
```
The ::activate signal is emitted when a row has been activated by the user, usually via activating the GtkListView|list.activate-item action.
This allows for a convenient way to handle activation in a listview. See [`gtk_list_item_set_activatable()`](gtklistitem#gtk-list-item-set-activatable) for details on how to use this signal.
#### Parameters
| | | |
| --- | --- | --- |
| self | The [GtkListView](gtklistview#GtkListView-struct) | |
| position | position of item to activate | |
| user\_data | user data set when the signal handler was connected. | |
Flags: Run Last
Action Details
--------------
### The `“list.activate-item”` action
Activates the item given in *`position`* by emitting the GtkListView::activate signal.
Parameter type: u
#### Parameters
| | | |
| --- | --- | --- |
| position | position of item to activate | |
See Also
--------
[GtkSelectionModel](gtkselectionmodel#GtkSelectionModel-struct), [GtkColumnView](gtkcolumnview#GtkColumnView-struct), [GtkGridView](gtkgridview#GtkGridView-struct)
gtk GtkCustomFilter GtkCustomFilter
===============
GtkCustomFilter — Filtering with callbacks
Functions
---------
| | |
| --- | --- |
| gboolean | ([\*GtkCustomFilterFunc](gtkcustomfilter#GtkCustomFilterFunc)) () |
| [GtkCustomFilter](gtkcustomfilter#GtkCustomFilter-struct) \* | [gtk\_custom\_filter\_new](gtkcustomfilter#gtk-custom-filter-new) () |
| void | [gtk\_custom\_filter\_set\_filter\_func](gtkcustomfilter#gtk-custom-filter-set-filter-func) () |
Types and Values
----------------
| | |
| --- | --- |
| | [GtkCustomFilter](gtkcustomfilter#GtkCustomFilter-struct) |
Object Hierarchy
----------------
```
GObject
╰── [GtkFilter](gtkfilter#GtkFilter-struct)
╰── GtkCustomFilter
```
Includes
--------
```
#include <gtk/gtk.h>
```
Description
-----------
[GtkCustomFilter](gtkcustomfilter#GtkCustomFilter-struct) is a [GtkFilter](gtkfilter#GtkFilter-struct) that uses a callback to determine whether to include an item or not.
Functions
---------
### GtkCustomFilterFunc ()
```
gboolean
(*GtkCustomFilterFunc) (gpointer item,
gpointer user_data);
```
User function that is called to determine if the *`item`* should be matched. If the filter matches the item, this function must return `TRUE`. If the item should be filtered out, `FALSE` must be returned.
#### Parameters
| | | |
| --- | --- | --- |
| item | The item to be matched. | [type GObject] |
| user\_data | user data | |
#### Returns
`TRUE` to keep the item around
### gtk\_custom\_filter\_new ()
```
[GtkCustomFilter](gtkcustomfilter#GtkCustomFilter-struct) *
gtk_custom_filter_new (*`[GtkCustomFilterFunc](gtkcustomfilter#GtkCustomFilterFunc) match_func`*,
*`gpointer user_data`*,
*`GDestroyNotify user_destroy`*);
```
Creates a new filter using the given *`match_func`* to filter items.
If *`match_func`* is `NULL`, the filter matches all items.
If the filter func changes its filtering behavior, [`gtk_filter_changed()`](gtkfilter#gtk-filter-changed) needs to be called.
#### Parameters
| | | |
| --- | --- | --- |
| match\_func | function to filter items. | [nullable] |
| user\_data | user data to pass to *`match_func`* . | [nullable] |
| user\_destroy | destroy notify for *`user_data`* | |
#### Returns
a new [GtkCustomFilter](gtkcustomfilter#GtkCustomFilter-struct)
### gtk\_custom\_filter\_set\_filter\_func ()
```
void
gtk_custom_filter_set_filter_func (*`[GtkCustomFilter](gtkcustomfilter#GtkCustomFilter-struct) *self`*,
*`[GtkCustomFilterFunc](gtkcustomfilter#GtkCustomFilterFunc) match_func`*,
*`gpointer user_data`*,
*`GDestroyNotify user_destroy`*);
```
Sets (or unsets) the function used for filtering items.
If *`match_func`* is `NULL`, the filter matches all items.
If the filter func changes its filtering behavior, [`gtk_filter_changed()`](gtkfilter#gtk-filter-changed) needs to be called.
If a previous function was set, its *`user_destroy`* will be called now.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkCustomFilter](gtkcustomfilter#GtkCustomFilter-struct) | |
| match\_func | function to filter items. | [nullable] |
| user\_data | user data to pass to *`match_func`* . | [nullable] |
| user\_destroy | destroy notify for *`user_data`* | |
Types and Values
----------------
### GtkCustomFilter
```
typedef struct _GtkCustomFilter GtkCustomFilter;
```
gtk Compiling GTK Applications on UNIX Compiling GTK Applications on UNIX
==================================
To compile a GTK application, you need to tell the compiler where to find the GTK header files and libraries. This is done with the `pkg-config` utility.
The following interactive shell session demonstrates how `pkg-config` is used (the actual output on your system may be different):
```
$ pkg-config --cflags gtk4
-pthread -I/usr/include/gtk-4.0 -I/usr/lib64/gtk-4.0/include -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/libpng12
$ pkg-config --libs gtk4
-pthread -lgtk-4 -lgdk-4 -lgio-2.0 -lpangoft2-1.0 -lgdk_pixbuf-2.0 -lpangocairo-1.0 -lcairo -lpango-1.0 -lfreetype -lfontconfig -lgobject-2.0 -lgmodule-2.0 -lgthread-2.0 -lrt -lglib-2.0
```
The simplest way to compile a program is to use the “backticks” feature of the shell. If you enclose a command in backticks (*not single quotes*), then its output will be substituted into the command line before execution. So to compile a GTK Hello, World, you would type the following:
```
$ cc `pkg-config --cflags gtk4` hello.c -o hello `pkg-config --libs gtk4`
```
Deprecated GTK functions are annotated to make the compiler emit warnings when they are used (e.g. with gcc, you need to use the -Wdeprecated-declarations option). If these warnings are problematic, they can be turned off by defining the preprocessor symbol [`GDK_DISABLE_DEPRECATION_WARNINGS`](https://developer-old.gnome.org/gtk4/html/gdk4-General.html#GDK-DISABLE-DEPRECATION-WARNINGS:CAPS) by using the commandline option `-DGDK_DISABLE_DEPRECATION_WARNINGS`.
GTK deprecation annotations are versioned; by defining the macros [`GDK_VERSION_MIN_REQUIRED`](https://developer-old.gnome.org/gtk4/html/gdk4-General.html#GDK-VERSION-MIN-REQUIRED:CAPS) and [`GDK_VERSION_MAX_ALLOWED`](https://developer-old.gnome.org/gtk4/html/gdk4-General.html#GDK-VERSION-MAX-ALLOWED:CAPS), you can specify the range of GTK versions whose API you want to use. APIs that were deprecated before or introduced after this range will trigger compiler warnings.
Here is how you would compile hello.c if you want to allow it to use symbols that were not deprecated in 4.2:
```
$ cc `pkg-config --cflags gtk4` -DGDK_VERSION_MIN_REQUIRED=GDK_VERSION_4_2 hello.c -o hello `pkg-config --libs gtk4`
```
And here is how you would compile hello.c if you don’t want it to use any symbols that were introduced after 4.2:
```
$ cc `pkg-config --cflags gtk4` -DGDK_VERSION_MAX_ALLOWED=GDK_VERSION_4_2 hello.c -o hello `pkg-config --libs gtk4`
```
The older deprecation mechanism of hiding deprecated interfaces entirely from the compiler by using the preprocessor symbol GTK\_DISABLE\_DEPRECATED is still used for deprecated macros, enumeration values, etc. To detect uses of these in your code, use the commandline option `-DGTK_DISABLE_DEPRECATED`. There are similar symbols GDK\_DISABLE\_DEPRECATED, GDK\_PIXBUF\_DISABLE\_DEPRECATED and G\_DISABLE\_DEPRECATED for GDK, GdkPixbuf and GLib.
| programming_docs |
gtk GtkAspectFrame GtkAspectFrame
==============
GtkAspectFrame — A frame that constrains its child to a particular aspect ratio
Functions
---------
| | |
| --- | --- |
| [GtkWidget](gtkwidget#GtkWidget-struct) \* | [gtk\_aspect\_frame\_new](gtkaspectframe#gtk-aspect-frame-new) () |
| void | [gtk\_aspect\_frame\_set\_xalign](gtkaspectframe#gtk-aspect-frame-set-xalign) () |
| float | [gtk\_aspect\_frame\_get\_xalign](gtkaspectframe#gtk-aspect-frame-get-xalign) () |
| void | [gtk\_aspect\_frame\_set\_yalign](gtkaspectframe#gtk-aspect-frame-set-yalign) () |
| float | [gtk\_aspect\_frame\_get\_yalign](gtkaspectframe#gtk-aspect-frame-get-yalign) () |
| void | [gtk\_aspect\_frame\_set\_ratio](gtkaspectframe#gtk-aspect-frame-set-ratio) () |
| float | [gtk\_aspect\_frame\_get\_ratio](gtkaspectframe#gtk-aspect-frame-get-ratio) () |
| void | [gtk\_aspect\_frame\_set\_obey\_child](gtkaspectframe#gtk-aspect-frame-set-obey-child) () |
| gboolean | [gtk\_aspect\_frame\_get\_obey\_child](gtkaspectframe#gtk-aspect-frame-get-obey-child) () |
| void | [gtk\_aspect\_frame\_set\_child](gtkaspectframe#gtk-aspect-frame-set-child) () |
| [GtkWidget](gtkwidget#GtkWidget-struct) \* | [gtk\_aspect\_frame\_get\_child](gtkaspectframe#gtk-aspect-frame-get-child) () |
Properties
----------
| | | |
| --- | --- | --- |
| [GtkWidget](gtkwidget#GtkWidget-struct) \* | [child](gtkaspectframe#GtkAspectFrame--child) | Read / Write |
| gboolean | [obey-child](gtkaspectframe#GtkAspectFrame--obey-child) | Read / Write |
| float | [ratio](gtkaspectframe#GtkAspectFrame--ratio) | Read / Write |
| float | [xalign](gtkaspectframe#GtkAspectFrame--xalign) | Read / Write |
| float | [yalign](gtkaspectframe#GtkAspectFrame--yalign) | Read / Write |
Types and Values
----------------
| | |
| --- | --- |
| | [GtkAspectFrame](gtkaspectframe#GtkAspectFrame-struct) |
Object Hierarchy
----------------
```
GObject
╰── GInitiallyUnowned
╰── [GtkWidget](gtkwidget#GtkWidget-struct)
╰── GtkAspectFrame
```
Implemented Interfaces
----------------------
GtkAspectFrame implements [GtkAccessible](gtkaccessible#GtkAccessible-struct), [GtkBuildable](gtkbuildable#GtkBuildable-struct) and [GtkConstraintTarget](gtkconstraint#GtkConstraintTarget-struct).
Includes
--------
```
#include <gtk/gtk.h>
```
Description
-----------
GtkAspectFrame is useful when you want pack a widget so that it can resize while retaining the same aspect ratio. For instance, one might be drawing a small preview of a larger image.
The frame can respect the aspect ratio of the child widget, or use its own aspect ratio.
### CSS nodes
GtkAspectFrame uses a CSS node with name `frame`.
Functions
---------
### gtk\_aspect\_frame\_new ()
```
[GtkWidget](gtkwidget#GtkWidget-struct) *
gtk_aspect_frame_new (*`float xalign`*,
*`float yalign`*,
*`float ratio`*,
*`gboolean obey_child`*);
```
Create a new [GtkAspectFrame](gtkaspectframe#GtkAspectFrame-struct).
#### Parameters
| | | |
| --- | --- | --- |
| xalign | Horizontal alignment of the child within the allocation of the [GtkAspectFrame](gtkaspectframe#GtkAspectFrame-struct). This ranges from 0.0 (left aligned) to 1.0 (right aligned) | |
| yalign | Vertical alignment of the child within the allocation of the [GtkAspectFrame](gtkaspectframe#GtkAspectFrame-struct). This ranges from 0.0 (top aligned) to 1.0 (bottom aligned) | |
| ratio | The desired aspect ratio. | |
| obey\_child | If `TRUE`, *`ratio`* is ignored, and the aspect ratio is taken from the requistion of the child. | |
#### Returns
the new [GtkAspectFrame](gtkaspectframe#GtkAspectFrame-struct).
### gtk\_aspect\_frame\_set\_xalign ()
```
void
gtk_aspect_frame_set_xalign (*`[GtkAspectFrame](gtkaspectframe#GtkAspectFrame-struct) *self`*,
*`float xalign`*);
```
Sets the horizontal alignment of the child within the allocation of the [GtkAspectFrame](gtkaspectframe#GtkAspectFrame-struct).
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkAspectFrame](gtkaspectframe#GtkAspectFrame-struct) | |
| xalign | horizontal alignment, from 0.0 (left aligned) to 1.0 (right aligned) | |
### gtk\_aspect\_frame\_get\_xalign ()
```
float
gtk_aspect_frame_get_xalign (*`[GtkAspectFrame](gtkaspectframe#GtkAspectFrame-struct) *self`*);
```
Returns the horizontal alignment of the child within the allocation of the [GtkAspectFrame](gtkaspectframe#GtkAspectFrame-struct).
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkAspectFrame](gtkaspectframe#GtkAspectFrame-struct) | |
#### Returns
the horizontal alignment
### gtk\_aspect\_frame\_set\_yalign ()
```
void
gtk_aspect_frame_set_yalign (*`[GtkAspectFrame](gtkaspectframe#GtkAspectFrame-struct) *self`*,
*`float yalign`*);
```
Sets the vertical alignment of the child within the allocation of the [GtkAspectFrame](gtkaspectframe#GtkAspectFrame-struct).
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkAspectFrame](gtkaspectframe#GtkAspectFrame-struct) | |
| yalign | horizontal alignment, from 0.0 (top aligned) to 1.0 (bottom aligned) | |
### gtk\_aspect\_frame\_get\_yalign ()
```
float
gtk_aspect_frame_get_yalign (*`[GtkAspectFrame](gtkaspectframe#GtkAspectFrame-struct) *self`*);
```
Returns the vertical alignment of the child within the allocation of the [GtkAspectFrame](gtkaspectframe#GtkAspectFrame-struct).
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkAspectFrame](gtkaspectframe#GtkAspectFrame-struct) | |
#### Returns
the vertical alignment
### gtk\_aspect\_frame\_set\_ratio ()
```
void
gtk_aspect_frame_set_ratio (*`[GtkAspectFrame](gtkaspectframe#GtkAspectFrame-struct) *self`*,
*`float ratio`*);
```
Sets the desired aspect ratio of the child.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkAspectFrame](gtkaspectframe#GtkAspectFrame-struct) | |
| ratio | aspect ratio of the child | |
### gtk\_aspect\_frame\_get\_ratio ()
```
float
gtk_aspect_frame_get_ratio (*`[GtkAspectFrame](gtkaspectframe#GtkAspectFrame-struct) *self`*);
```
Returns the desired aspect ratio of the child set using [`gtk_aspect_frame_set_ratio()`](gtkaspectframe#gtk-aspect-frame-set-ratio).
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkAspectFrame](gtkaspectframe#GtkAspectFrame-struct) | |
#### Returns
the desired aspect ratio
### gtk\_aspect\_frame\_set\_obey\_child ()
```
void
gtk_aspect_frame_set_obey_child (*`[GtkAspectFrame](gtkaspectframe#GtkAspectFrame-struct) *self`*,
*`gboolean obey_child`*);
```
Sets whether the aspect ratio of the child's size request should override the set aspect ratio of the [GtkAspectFrame](gtkaspectframe#GtkAspectFrame-struct).
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkAspectFrame](gtkaspectframe#GtkAspectFrame-struct) | |
| obey\_child | If `TRUE`, *`ratio`* is ignored, and the aspect ratio is taken from the requistion of the child. | |
### gtk\_aspect\_frame\_get\_obey\_child ()
```
gboolean
gtk_aspect_frame_get_obey_child (*`[GtkAspectFrame](gtkaspectframe#GtkAspectFrame-struct) *self`*);
```
Returns whether the child's size request should override the set aspect ratio of the [GtkAspectFrame](gtkaspectframe#GtkAspectFrame-struct).
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkAspectFrame](gtkaspectframe#GtkAspectFrame-struct) | |
#### Returns
whether to obey the child's size request
### gtk\_aspect\_frame\_set\_child ()
```
void
gtk_aspect_frame_set_child (*`[GtkAspectFrame](gtkaspectframe#GtkAspectFrame-struct) *self`*,
*`[GtkWidget](gtkwidget#GtkWidget-struct) *child`*);
```
Sets the child widget of *`self`* .
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkAspectFrame](gtkaspectframe#GtkAspectFrame-struct) | |
| child | the child widget. | [allow-none] |
### gtk\_aspect\_frame\_get\_child ()
```
[GtkWidget](gtkwidget#GtkWidget-struct) *
gtk_aspect_frame_get_child (*`[GtkAspectFrame](gtkaspectframe#GtkAspectFrame-struct) *self`*);
```
Gets the child widget of *`self`* .
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkAspectFrame](gtkaspectframe#GtkAspectFrame-struct) | |
#### Returns
the child widget of self@.
[nullable][transfer none]
Types and Values
----------------
### GtkAspectFrame
```
typedef struct _GtkAspectFrame GtkAspectFrame;
```
Property Details
----------------
### The `“child”` property
```
“child” [GtkWidget](gtkwidget#GtkWidget-struct) *
```
The child widget of the [GtkAspectFrame](gtkaspectframe#GtkAspectFrame-struct).
Owner: GtkAspectFrame
Flags: Read / Write
### The `“obey-child”` property
```
“obey-child” gboolean
```
Whether the [GtkAspectFrame](gtkaspectframe#GtkAspectFrame-struct) should use the aspect ratio of its [“child”](gtkaspectframe#GtkAspectFrame--child) widget.
Owner: GtkAspectFrame
Flags: Read / Write
Default value: TRUE
### The `“ratio”` property
```
“ratio” float
```
The aspect ratio to be used by the [GtkAspectFrame](gtkaspectframe#GtkAspectFrame-struct).
This property is only used if [“obey-child”](gtkaspectframe#GtkAspectFrame--obey-child) is set to `FALSE`.
Owner: GtkAspectFrame
Flags: Read / Write
Allowed values: [0.0001,10000]
Default value: 1
### The `“xalign”` property
```
“xalign” float
```
The horizontal alignment of the [“child”](gtkaspectframe#GtkAspectFrame--child) widget of the aspect frame.
Owner: GtkAspectFrame
Flags: Read / Write
Allowed values: [0,1]
Default value: 0.5
### The `“yalign”` property
```
“yalign” float
```
The vertical alignment of the [“child”](gtkaspectframe#GtkAspectFrame--child) widget of the aspect frame.
Owner: GtkAspectFrame
Flags: Read / Write
Allowed values: [0,1]
Default value: 0.5
gtk GtkGrid GtkGrid
=======
GtkGrid — Pack widgets in rows and columns
Functions
---------
| | |
| --- | --- |
| [GtkWidget](gtkwidget#GtkWidget-struct) \* | [gtk\_grid\_new](gtkgrid#gtk-grid-new) () |
| void | [gtk\_grid\_attach](gtkgrid#gtk-grid-attach) () |
| void | [gtk\_grid\_attach\_next\_to](gtkgrid#gtk-grid-attach-next-to) () |
| void | [gtk\_grid\_remove](gtkgrid#gtk-grid-remove) () |
| [GtkWidget](gtkwidget#GtkWidget-struct) \* | [gtk\_grid\_get\_child\_at](gtkgrid#gtk-grid-get-child-at) () |
| void | [gtk\_grid\_query\_child](gtkgrid#gtk-grid-query-child) () |
| void | [gtk\_grid\_insert\_row](gtkgrid#gtk-grid-insert-row) () |
| void | [gtk\_grid\_insert\_column](gtkgrid#gtk-grid-insert-column) () |
| void | [gtk\_grid\_remove\_row](gtkgrid#gtk-grid-remove-row) () |
| void | [gtk\_grid\_remove\_column](gtkgrid#gtk-grid-remove-column) () |
| void | [gtk\_grid\_insert\_next\_to](gtkgrid#gtk-grid-insert-next-to) () |
| void | [gtk\_grid\_set\_row\_homogeneous](gtkgrid#gtk-grid-set-row-homogeneous) () |
| gboolean | [gtk\_grid\_get\_row\_homogeneous](gtkgrid#gtk-grid-get-row-homogeneous) () |
| void | [gtk\_grid\_set\_row\_spacing](gtkgrid#gtk-grid-set-row-spacing) () |
| guint | [gtk\_grid\_get\_row\_spacing](gtkgrid#gtk-grid-get-row-spacing) () |
| void | [gtk\_grid\_set\_column\_homogeneous](gtkgrid#gtk-grid-set-column-homogeneous) () |
| gboolean | [gtk\_grid\_get\_column\_homogeneous](gtkgrid#gtk-grid-get-column-homogeneous) () |
| void | [gtk\_grid\_set\_column\_spacing](gtkgrid#gtk-grid-set-column-spacing) () |
| guint | [gtk\_grid\_get\_column\_spacing](gtkgrid#gtk-grid-get-column-spacing) () |
| int | [gtk\_grid\_get\_baseline\_row](gtkgrid#gtk-grid-get-baseline-row) () |
| void | [gtk\_grid\_set\_baseline\_row](gtkgrid#gtk-grid-set-baseline-row) () |
| [GtkBaselinePosition](gtk4-standard-enumerations#GtkBaselinePosition) | [gtk\_grid\_get\_row\_baseline\_position](gtkgrid#gtk-grid-get-row-baseline-position) () |
| void | [gtk\_grid\_set\_row\_baseline\_position](gtkgrid#gtk-grid-set-row-baseline-position) () |
Properties
----------
| | | |
| --- | --- | --- |
| int | [baseline-row](gtkgrid#GtkGrid--baseline-row) | Read / Write |
| gboolean | [column-homogeneous](gtkgrid#GtkGrid--column-homogeneous) | Read / Write |
| int | [column-spacing](gtkgrid#GtkGrid--column-spacing) | Read / Write |
| gboolean | [row-homogeneous](gtkgrid#GtkGrid--row-homogeneous) | Read / Write |
| int | [row-spacing](gtkgrid#GtkGrid--row-spacing) | Read / Write |
Types and Values
----------------
| | |
| --- | --- |
| struct | [GtkGrid](gtkgrid#GtkGrid-struct) |
| struct | [GtkGridClass](gtkgrid#GtkGridClass) |
Object Hierarchy
----------------
```
GObject
╰── GInitiallyUnowned
╰── [GtkWidget](gtkwidget#GtkWidget-struct)
╰── GtkGrid
```
Implemented Interfaces
----------------------
GtkGrid implements [GtkAccessible](gtkaccessible#GtkAccessible-struct), [GtkBuildable](gtkbuildable#GtkBuildable-struct), [GtkConstraintTarget](gtkconstraint#GtkConstraintTarget-struct) and [GtkOrientable](gtk4-orientable#GtkOrientable-struct).
Includes
--------
```
#include <gtk/gtk.h>
```
Description
-----------
GtkGrid is a container which arranges its child widgets in rows and columns, with arbitrary positions and horizontal/vertical spans.
Children are added using [`gtk_grid_attach()`](gtkgrid#gtk-grid-attach). They can span multiple rows or columns. It is also possible to add a child next to an existing child, using [`gtk_grid_attach_next_to()`](gtkgrid#gtk-grid-attach-next-to). To remove a child from the grid, use [`gtk_grid_remove()`](gtkgrid#gtk-grid-remove). The behaviour of GtkGrid when several children occupy the same grid cell is undefined.
### CSS nodes
GtkGrid uses a single CSS node with name `grid`.
### Accessibility
GtkGrid uses the [`GTK_ACCESSIBLE_ROLE_GROUP`](gtkaccessible#GTK-ACCESSIBLE-ROLE-GROUP:CAPS) role.
Functions
---------
### gtk\_grid\_new ()
```
[GtkWidget](gtkwidget#GtkWidget-struct) *
gtk_grid_new (*`void`*);
```
Creates a new grid widget.
#### Returns
the new [GtkGrid](gtkgrid#GtkGrid-struct)
### gtk\_grid\_attach ()
```
void
gtk_grid_attach (*`[GtkGrid](gtkgrid#GtkGrid-struct) *grid`*,
*`[GtkWidget](gtkwidget#GtkWidget-struct) *child`*,
*`int column`*,
*`int row`*,
*`int width`*,
*`int height`*);
```
Adds a widget to the grid.
The position of *`child`* is determined by *`column`* and *`row`* . The number of “cells” that *`child`* will occupy is determined by *`width`* and *`height`* .
#### Parameters
| | | |
| --- | --- | --- |
| grid | a [GtkGrid](gtkgrid#GtkGrid-struct) | |
| child | the widget to add | |
| column | the column number to attach the left side of *`child`* to | |
| row | the row number to attach the top side of *`child`* to | |
| width | the number of columns that *`child`* will span | |
| height | the number of rows that *`child`* will span | |
### gtk\_grid\_attach\_next\_to ()
```
void
gtk_grid_attach_next_to (*`[GtkGrid](gtkgrid#GtkGrid-struct) *grid`*,
*`[GtkWidget](gtkwidget#GtkWidget-struct) *child`*,
*`[GtkWidget](gtkwidget#GtkWidget-struct) *sibling`*,
*`[GtkPositionType](gtk4-standard-enumerations#GtkPositionType) side`*,
*`int width`*,
*`int height`*);
```
Adds a widget to the grid.
The widget is placed next to *`sibling`* , on the side determined by *`side`* . When *`sibling`* is `NULL`, the widget is placed in row (for left or right placement) or column 0 (for top or bottom placement), at the end indicated by *`side`* .
Attaching widgets labeled [1], [2], [3] with *`sibling`* == `NULL` and *`side`* == [`GTK_POS_LEFT`](gtk4-standard-enumerations#GTK-POS-LEFT:CAPS) yields a layout of 3[1].
#### Parameters
| | | |
| --- | --- | --- |
| grid | a [GtkGrid](gtkgrid#GtkGrid-struct) | |
| child | the widget to add | |
| sibling | the child of *`grid`* that *`child`* will be placed next to, or `NULL` to place *`child`* at the beginning or end. | [allow-none] |
| side | the side of *`sibling`* that *`child`* is positioned next to | |
| width | the number of columns that *`child`* will span | |
| height | the number of rows that *`child`* will span | |
### gtk\_grid\_remove ()
```
void
gtk_grid_remove (*`[GtkGrid](gtkgrid#GtkGrid-struct) *grid`*,
*`[GtkWidget](gtkwidget#GtkWidget-struct) *child`*);
```
Removes a child from *`grid`* , after it has been added with [`gtk_grid_attach()`](gtkgrid#gtk-grid-attach) or [`gtk_grid_attach_next_to()`](gtkgrid#gtk-grid-attach-next-to).
#### Parameters
| | | |
| --- | --- | --- |
| grid | a [GtkGrid](gtkgrid#GtkGrid-struct) | |
| child | the child widget to remove | |
### gtk\_grid\_get\_child\_at ()
```
[GtkWidget](gtkwidget#GtkWidget-struct) *
gtk_grid_get_child_at (*`[GtkGrid](gtkgrid#GtkGrid-struct) *grid`*,
*`int column`*,
*`int row`*);
```
Gets the child of *`grid`* whose area covers the grid cell at *`column`* , *`row`* .
#### Parameters
| | | |
| --- | --- | --- |
| grid | a [GtkGrid](gtkgrid#GtkGrid-struct) | |
| column | the left edge of the cell | |
| row | the top edge of the cell | |
#### Returns
the child at the given position, or `NULL`.
[transfer none][nullable]
### gtk\_grid\_query\_child ()
```
void
gtk_grid_query_child (*`[GtkGrid](gtkgrid#GtkGrid-struct) *grid`*,
*`[GtkWidget](gtkwidget#GtkWidget-struct) *child`*,
*`int *column`*,
*`int *row`*,
*`int *width`*,
*`int *height`*);
```
Queries the attach points and spans of *`child`* inside the given [GtkGrid](gtkgrid#GtkGrid-struct).
#### Parameters
| | | |
| --- | --- | --- |
| grid | a [GtkGrid](gtkgrid#GtkGrid-struct) | |
| child | a [GtkWidget](gtkwidget#GtkWidget-struct) child of *`grid`* | |
| column | the column used to attach the left side of *`child`* . | [out][optional] |
| row | the row used to attach the top side of *`child`* . | [out][optional] |
| width | the number of columns *`child`* spans. | [out][optional] |
| height | the number of rows *`child`* spans. | [out][optional] |
### gtk\_grid\_insert\_row ()
```
void
gtk_grid_insert_row (*`[GtkGrid](gtkgrid#GtkGrid-struct) *grid`*,
*`int position`*);
```
Inserts a row at the specified position.
Children which are attached at or below this position are moved one row down. Children which span across this position are grown to span the new row.
#### Parameters
| | | |
| --- | --- | --- |
| grid | a [GtkGrid](gtkgrid#GtkGrid-struct) | |
| position | the position to insert the row at | |
### gtk\_grid\_insert\_column ()
```
void
gtk_grid_insert_column (*`[GtkGrid](gtkgrid#GtkGrid-struct) *grid`*,
*`int position`*);
```
Inserts a column at the specified position.
Children which are attached at or to the right of this position are moved one column to the right. Children which span across this position are grown to span the new column.
#### Parameters
| | | |
| --- | --- | --- |
| grid | a [GtkGrid](gtkgrid#GtkGrid-struct) | |
| position | the position to insert the column at | |
### gtk\_grid\_remove\_row ()
```
void
gtk_grid_remove_row (*`[GtkGrid](gtkgrid#GtkGrid-struct) *grid`*,
*`int position`*);
```
Removes a row from the grid.
Children that are placed in this row are removed, spanning children that overlap this row have their height reduced by one, and children below the row are moved up.
#### Parameters
| | | |
| --- | --- | --- |
| grid | a [GtkGrid](gtkgrid#GtkGrid-struct) | |
| position | the position of the row to remove | |
### gtk\_grid\_remove\_column ()
```
void
gtk_grid_remove_column (*`[GtkGrid](gtkgrid#GtkGrid-struct) *grid`*,
*`int position`*);
```
Removes a column from the grid.
Children that are placed in this column are removed, spanning children that overlap this column have their width reduced by one, and children after the column are moved to the left.
#### Parameters
| | | |
| --- | --- | --- |
| grid | a [GtkGrid](gtkgrid#GtkGrid-struct) | |
| position | the position of the column to remove | |
### gtk\_grid\_insert\_next\_to ()
```
void
gtk_grid_insert_next_to (*`[GtkGrid](gtkgrid#GtkGrid-struct) *grid`*,
*`[GtkWidget](gtkwidget#GtkWidget-struct) *sibling`*,
*`[GtkPositionType](gtk4-standard-enumerations#GtkPositionType) side`*);
```
Inserts a row or column at the specified position.
The new row or column is placed next to *`sibling`* , on the side determined by *`side`* . If *`side`* is [`GTK_POS_TOP`](gtk4-standard-enumerations#GTK-POS-TOP:CAPS) or [`GTK_POS_BOTTOM`](gtk4-standard-enumerations#GTK-POS-BOTTOM:CAPS), a row is inserted. If *`side`* is [`GTK_POS_LEFT`](gtk4-standard-enumerations#GTK-POS-LEFT:CAPS) of [`GTK_POS_RIGHT`](gtk4-standard-enumerations#GTK-POS-RIGHT:CAPS), a column is inserted.
#### Parameters
| | | |
| --- | --- | --- |
| grid | a [GtkGrid](gtkgrid#GtkGrid-struct) | |
| sibling | the child of *`grid`* that the new row or column will be placed next to | |
| side | the side of *`sibling`* that *`child`* is positioned next to | |
### gtk\_grid\_set\_row\_homogeneous ()
```
void
gtk_grid_set_row_homogeneous (*`[GtkGrid](gtkgrid#GtkGrid-struct) *grid`*,
*`gboolean homogeneous`*);
```
Sets whether all rows of *`grid`* will have the same height.
#### Parameters
| | | |
| --- | --- | --- |
| grid | a [GtkGrid](gtkgrid#GtkGrid-struct) | |
| homogeneous | `TRUE` to make rows homogeneous | |
### gtk\_grid\_get\_row\_homogeneous ()
```
gboolean
gtk_grid_get_row_homogeneous (*`[GtkGrid](gtkgrid#GtkGrid-struct) *grid`*);
```
Returns whether all rows of *`grid`* have the same height.
#### Parameters
| | | |
| --- | --- | --- |
| grid | a [GtkGrid](gtkgrid#GtkGrid-struct) | |
#### Returns
whether all rows of *`grid`* have the same height.
### gtk\_grid\_set\_row\_spacing ()
```
void
gtk_grid_set_row_spacing (*`[GtkGrid](gtkgrid#GtkGrid-struct) *grid`*,
*`guint spacing`*);
```
Sets the amount of space between rows of *`grid`* .
#### Parameters
| | | |
| --- | --- | --- |
| grid | a [GtkGrid](gtkgrid#GtkGrid-struct) | |
| spacing | the amount of space to insert between rows | |
### gtk\_grid\_get\_row\_spacing ()
```
guint
gtk_grid_get_row_spacing (*`[GtkGrid](gtkgrid#GtkGrid-struct) *grid`*);
```
Returns the amount of space between the rows of *`grid`* .
#### Parameters
| | | |
| --- | --- | --- |
| grid | a [GtkGrid](gtkgrid#GtkGrid-struct) | |
#### Returns
the row spacing of *`grid`*
### gtk\_grid\_set\_column\_homogeneous ()
```
void
gtk_grid_set_column_homogeneous (*`[GtkGrid](gtkgrid#GtkGrid-struct) *grid`*,
*`gboolean homogeneous`*);
```
Sets whether all columns of *`grid`* will have the same width.
#### Parameters
| | | |
| --- | --- | --- |
| grid | a [GtkGrid](gtkgrid#GtkGrid-struct) | |
| homogeneous | `TRUE` to make columns homogeneous | |
### gtk\_grid\_get\_column\_homogeneous ()
```
gboolean
gtk_grid_get_column_homogeneous (*`[GtkGrid](gtkgrid#GtkGrid-struct) *grid`*);
```
Returns whether all columns of *`grid`* have the same width.
#### Parameters
| | | |
| --- | --- | --- |
| grid | a [GtkGrid](gtkgrid#GtkGrid-struct) | |
#### Returns
whether all columns of *`grid`* have the same width.
### gtk\_grid\_set\_column\_spacing ()
```
void
gtk_grid_set_column_spacing (*`[GtkGrid](gtkgrid#GtkGrid-struct) *grid`*,
*`guint spacing`*);
```
Sets the amount of space between columns of *`grid`* .
#### Parameters
| | | |
| --- | --- | --- |
| grid | a [GtkGrid](gtkgrid#GtkGrid-struct) | |
| spacing | the amount of space to insert between columns | |
### gtk\_grid\_get\_column\_spacing ()
```
guint
gtk_grid_get_column_spacing (*`[GtkGrid](gtkgrid#GtkGrid-struct) *grid`*);
```
Returns the amount of space between the columns of *`grid`* .
#### Parameters
| | | |
| --- | --- | --- |
| grid | a [GtkGrid](gtkgrid#GtkGrid-struct) | |
#### Returns
the column spacing of *`grid`*
### gtk\_grid\_get\_baseline\_row ()
```
int
gtk_grid_get_baseline_row (*`[GtkGrid](gtkgrid#GtkGrid-struct) *grid`*);
```
Returns which row defines the global baseline of *`grid`* .
#### Parameters
| | | |
| --- | --- | --- |
| grid | a [GtkGrid](gtkgrid#GtkGrid-struct) | |
#### Returns
the row index defining the global baseline
### gtk\_grid\_set\_baseline\_row ()
```
void
gtk_grid_set_baseline_row (*`[GtkGrid](gtkgrid#GtkGrid-struct) *grid`*,
*`int row`*);
```
Sets which row defines the global baseline for the entire grid. Each row in the grid can have its own local baseline, but only one of those is global, meaning it will be the baseline in the parent of the *`grid`* .
#### Parameters
| | | |
| --- | --- | --- |
| grid | a [GtkGrid](gtkgrid#GtkGrid-struct) | |
| row | the row index | |
### gtk\_grid\_get\_row\_baseline\_position ()
```
[GtkBaselinePosition](gtk4-standard-enumerations#GtkBaselinePosition)
gtk_grid_get_row_baseline_position (*`[GtkGrid](gtkgrid#GtkGrid-struct) *grid`*,
*`int row`*);
```
Returns the baseline position of *`row`* as set by [`gtk_grid_set_row_baseline_position()`](gtkgrid#gtk-grid-set-row-baseline-position) or the default value [`GTK_BASELINE_POSITION_CENTER`](gtk4-standard-enumerations#GTK-BASELINE-POSITION-CENTER:CAPS).
#### Parameters
| | | |
| --- | --- | --- |
| grid | a [GtkGrid](gtkgrid#GtkGrid-struct) | |
| row | a row index | |
#### Returns
the baseline position of *`row`*
### gtk\_grid\_set\_row\_baseline\_position ()
```
void
gtk_grid_set_row_baseline_position (*`[GtkGrid](gtkgrid#GtkGrid-struct) *grid`*,
*`int row`*,
*`[GtkBaselinePosition](gtk4-standard-enumerations#GtkBaselinePosition) pos`*);
```
Sets how the baseline should be positioned on *`row`* of the grid, in case that row is assigned more space than is requested.
#### Parameters
| | | |
| --- | --- | --- |
| grid | a [GtkGrid](gtkgrid#GtkGrid-struct) | |
| row | a row index | |
| pos | a [GtkBaselinePosition](gtk4-standard-enumerations#GtkBaselinePosition) | |
Types and Values
----------------
### struct GtkGrid
```
struct GtkGrid;
```
### struct GtkGridClass
```
struct GtkGridClass {
GtkWidgetClass parent_class;
};
```
#### Members
Property Details
----------------
### The `“baseline-row”` property
```
“baseline-row” int
```
The row to align the to the baseline when valign is GTK\_ALIGN\_BASELINE.
Owner: GtkGrid
Flags: Read / Write
Allowed values: >= 0
Default value: 0
### The `“column-homogeneous”` property
```
“column-homogeneous” gboolean
```
If TRUE, the columns are all the same width.
Owner: GtkGrid
Flags: Read / Write
Default value: FALSE
### The `“column-spacing”` property
```
“column-spacing” int
```
The amount of space between two consecutive columns.
Owner: GtkGrid
Flags: Read / Write
Allowed values: [0,32767]
Default value: 0
### The `“row-homogeneous”` property
```
“row-homogeneous” gboolean
```
If TRUE, the rows are all the same height.
Owner: GtkGrid
Flags: Read / Write
Default value: FALSE
### The `“row-spacing”` property
```
“row-spacing” int
```
The amount of space between two consecutive rows.
Owner: GtkGrid
Flags: Read / Write
Allowed values: [0,32767]
Default value: 0
See Also
--------
[GtkBox](gtkbox#GtkBox-struct)
| programming_docs |
gtk GtkEmojiChooser GtkEmojiChooser
===============
GtkEmojiChooser — A popover to choose an Emoji character
Functions
---------
| | |
| --- | --- |
| [GtkWidget](gtkwidget#GtkWidget-struct) \* | [gtk\_emoji\_chooser\_new](gtkemojichooser#gtk-emoji-chooser-new) () |
Signals
-------
| | | |
| --- | --- | --- |
| void | [emoji-picked](gtkemojichooser#GtkEmojiChooser-emoji-picked) | Run Last |
Actions
-------
| | | |
| --- | --- | --- |
| | scroll.section | i |
Types and Values
----------------
| | |
| --- | --- |
| | [GtkEmojiChooser](gtkemojichooser#GtkEmojiChooser-struct) |
Object Hierarchy
----------------
```
GObject
╰── GInitiallyUnowned
╰── [GtkWidget](gtkwidget#GtkWidget-struct)
╰── [GtkPopover](gtkpopover#GtkPopover-struct)
╰── GtkEmojiChooser
```
Implemented Interfaces
----------------------
GtkEmojiChooser implements [GtkAccessible](gtkaccessible#GtkAccessible-struct), [GtkBuildable](gtkbuildable#GtkBuildable-struct), [GtkConstraintTarget](gtkconstraint#GtkConstraintTarget-struct), [GtkShortcutManager](gtkshortcutmanager#GtkShortcutManager-struct) and [GtkNative](gtknative#GtkNative-struct).
Includes
--------
```
#include <gtk/gtk.h>
```
Description
-----------
The [GtkEmojiChooser](gtkemojichooser#GtkEmojiChooser-struct) popover is used by text widgets such as [GtkEntry](gtkentry#GtkEntry-struct) or [GtkTextView](gtktextview#GtkTextView-struct) to offer users a convenient way to insert Emoji characters.
GtkEmojiChooser emits the [“emoji-picked”](gtkemojichooser#GtkEmojiChooser-emoji-picked) signal when an Emoji is selected.
### CSS nodes
```
popover
├── box.emoji-searchbar
│ ╰── entry.search
╰── box.emoji-toolbar
├── button.image-button.emoji-section
├── ...
╰── button.image-button.emoji-section
```
| Every [GtkEmojiChooser](gtkemojichooser#GtkEmojiChooser-struct) consists of a main node called popover. The contents of the popover are largely implementation defined and supposed to inherit general styles. The top searchbar used to search emoji and gets the .emoji-searchbar style class itself. The bottom toolbar used to switch between different emoji categories consists of buttons with the .emoji-section style class and gets the .emoji-toolbar style class itself.
Functions
---------
### gtk\_emoji\_chooser\_new ()
```
[GtkWidget](gtkwidget#GtkWidget-struct) *
gtk_emoji_chooser_new (*`void`*);
```
Creates a new [GtkEmojiChooser](gtkemojichooser#GtkEmojiChooser-struct).
#### Returns
a new [GtkEmojiChooser](gtkemojichooser#GtkEmojiChooser-struct)
Types and Values
----------------
### GtkEmojiChooser
```
typedef struct _GtkEmojiChooser GtkEmojiChooser;
```
Signal Details
--------------
### The `“emoji-picked”` signal
```
void
user_function ([GtkEmojiChooser](gtkemojichooser#GtkEmojiChooser-struct) *chooser,
char *text,
gpointer user_data)
```
The ::emoji-picked signal is emitted when the user selects an Emoji.
#### Parameters
| | | |
| --- | --- | --- |
| chooser | the [GtkEmojiChooser](gtkemojichooser#GtkEmojiChooser-struct) | |
| text | the Unicode sequence for the picked Emoji, in UTF-8 | |
| user\_data | user data set when the signal handler was connected. | |
Flags: Run Last
Action Details
--------------
### The `“scroll.section”` action
Scrolls to the next or previous section.
Parameter type: i
#### Parameters
| | | |
| --- | --- | --- |
| direction | 1 to scroll forward, -1 to scroll back | |
gtk GtkGestureStylus GtkGestureStylus
================
GtkGestureStylus — Gesture for stylus input
Functions
---------
| | |
| --- | --- |
| [GtkGesture](gtkgesture#GtkGesture-struct) \* | [gtk\_gesture\_stylus\_new](gtkgesturestylus#gtk-gesture-stylus-new) () |
| gboolean | [gtk\_gesture\_stylus\_get\_axis](gtkgesturestylus#gtk-gesture-stylus-get-axis) () |
| gboolean | [gtk\_gesture\_stylus\_get\_axes](gtkgesturestylus#gtk-gesture-stylus-get-axes) () |
| gboolean | [gtk\_gesture\_stylus\_get\_backlog](gtkgesturestylus#gtk-gesture-stylus-get-backlog) () |
| [GdkDeviceTool](https://developer-old.gnome.org/gtk4/html/GdkDevice.html#GdkDeviceTool-struct) \* | [gtk\_gesture\_stylus\_get\_device\_tool](gtkgesturestylus#gtk-gesture-stylus-get-device-tool) () |
Signals
-------
| | | |
| --- | --- | --- |
| void | [down](gtkgesturestylus#GtkGestureStylus-down) | Run Last |
| void | [motion](gtkgesturestylus#GtkGestureStylus-motion) | Run Last |
| void | [proximity](gtkgesturestylus#GtkGestureStylus-proximity) | Run Last |
| void | [up](gtkgesturestylus#GtkGestureStylus-up) | Run Last |
Types and Values
----------------
| | |
| --- | --- |
| | [GtkGestureStylus](gtkgesturestylus#GtkGestureStylus-struct) |
Object Hierarchy
----------------
```
GObject
╰── [GtkEventController](gtkeventcontroller#GtkEventController-struct)
╰── [GtkGesture](gtkgesture#GtkGesture-struct)
╰── [GtkGestureSingle](gtkgesturesingle#GtkGestureSingle-struct)
╰── GtkGestureStylus
```
Includes
--------
```
#include <gtk/gtk.h>
```
Description
-----------
[GtkGestureStylus](gtkgesturestylus#GtkGestureStylus-struct) is a [GtkGesture](gtkgesture#GtkGesture-struct) implementation specific to stylus input. The provided signals just relay the basic information of the stylus events.
Functions
---------
### gtk\_gesture\_stylus\_new ()
```
[GtkGesture](gtkgesture#GtkGesture-struct) *
gtk_gesture_stylus_new (*`void`*);
```
Creates a new [GtkGestureStylus](gtkgesturestylus#GtkGestureStylus-struct).
#### Returns
a newly created stylus gesture
### gtk\_gesture\_stylus\_get\_axis ()
```
gboolean
gtk_gesture_stylus_get_axis (*`[GtkGestureStylus](gtkgesturestylus#GtkGestureStylus-struct) *gesture`*,
*`[GdkAxisUse](https://developer-old.gnome.org/gtk4/html/GdkDevice.html#GdkAxisUse) axis`*,
*`double *value`*);
```
Returns the current value for the requested *`axis`* .
This function must be called from the handler of one of the [“down”](gtkgesturestylus#GtkGestureStylus-down), [“motion”](gtkgesturestylus#GtkGestureStylus-motion), [“up”](gtkgesturestylus#GtkGestureStylus-up) or [“proximity”](gtkgesturestylus#GtkGestureStylus-proximity) signals.
#### Parameters
| | | |
| --- | --- | --- |
| gesture | a [GtkGestureStylus](gtkgesturestylus#GtkGestureStylus-struct) | |
| axis | requested device axis | |
| value | return location for the axis value. | [out] |
#### Returns
`TRUE` if there is a current value for the axis
### gtk\_gesture\_stylus\_get\_axes ()
```
gboolean
gtk_gesture_stylus_get_axes (*`[GtkGestureStylus](gtkgesturestylus#GtkGestureStylus-struct) *gesture`*,
*`[GdkAxisUse](https://developer-old.gnome.org/gtk4/html/GdkDevice.html#GdkAxisUse) axes[]`*,
*`double **values`*);
```
Returns the current values for the requested *`axes`* . This function must be called from either the [“down”](gtkgesturestylus#GtkGestureStylus-down), [“motion”](gtkgesturestylus#GtkGestureStylus-motion), [“up”](gtkgesturestylus#GtkGestureStylus-up) or [“proximity”](gtkgesturestylus#GtkGestureStylus-proximity) signals.
#### Parameters
| | | |
| --- | --- | --- |
| gesture | a GtkGestureStylus | |
| axes | array of requested axes, terminated with [GDK\_AXIS\_IGNORE](https://developer-old.gnome.org/gtk4/html/GdkDevice.html#GDK-AXIS-IGNORE:CAPS). | [array] |
| values | return location for the axis values. | [out][array] |
#### Returns
`TRUE` if there is a current value for the axes
### gtk\_gesture\_stylus\_get\_backlog ()
```
gboolean
gtk_gesture_stylus_get_backlog (*`[GtkGestureStylus](gtkgesturestylus#GtkGestureStylus-struct) *gesture`*,
*`[GdkTimeCoord](https://developer-old.gnome.org/gtk4/html/GdkDevice.html#GdkTimeCoord) **backlog`*,
*`guint *n_elems`*);
```
By default, GTK will limit rate of input events. On stylus input where accuracy of strokes is paramount, this function returns the accumulated coordinate/timing state before the emission of the current [“motion”](gtkgesturestylus#GtkGestureStylus-motion) signal.
This function may only be called within a [“motion”](gtkgesturestylus#GtkGestureStylus-motion) signal handler, the state given in this signal and obtainable through [`gtk_gesture_stylus_get_axis()`](gtkgesturestylus#gtk-gesture-stylus-get-axis) call express the latest (most up-to-date) state in motion history.
The *`backlog`* is provided in chronological order.
#### Parameters
| | | |
| --- | --- | --- |
| gesture | a [GtkGestureStylus](gtkgesturestylus#GtkGestureStylus-struct) | |
| backlog | coordinates and times for the backlog events. | [out][array length=n\_elems] |
| n\_elems | return location for the number of elements. | [out] |
#### Returns
`TRUE` if there is a backlog to unfold in the current state.
### gtk\_gesture\_stylus\_get\_device\_tool ()
```
[GdkDeviceTool](https://developer-old.gnome.org/gtk4/html/GdkDevice.html#GdkDeviceTool-struct) *
gtk_gesture_stylus_get_device_tool (*`[GtkGestureStylus](gtkgesturestylus#GtkGestureStylus-struct) *gesture`*);
```
Returns the [GdkDeviceTool](https://developer-old.gnome.org/gtk4/html/GdkDevice.html#GdkDeviceTool-struct) currently driving input through this gesture. This function must be called from either the [“down”](gtkgesturestylus#GtkGestureStylus-down), [“motion”](gtkgesturestylus#GtkGestureStylus-motion), [“up”](gtkgesturestylus#GtkGestureStylus-up) or [“proximity”](gtkgesturestylus#GtkGestureStylus-proximity) signal handlers.
#### Parameters
| | | |
| --- | --- | --- |
| gesture | a [GtkGestureStylus](gtkgesturestylus#GtkGestureStylus-struct) | |
#### Returns
The current stylus tool.
[nullable][transfer none]
Types and Values
----------------
### GtkGestureStylus
```
typedef struct _GtkGestureStylus GtkGestureStylus;
```
Signal Details
--------------
### The `“down”` signal
```
void
user_function ([GtkGestureStylus](gtkgesturestylus#GtkGestureStylus-struct) *gesture,
double x,
double y,
gpointer user_data)
```
A signal emitted when the stylus touches the device.
#### Parameters
| | | |
| --- | --- | --- |
| gesture | the [GtkGestureStylus](gtkgesturestylus#GtkGestureStylus-struct) that emitted the signal | |
| x | the X coordinate of the stylus event | |
| y | the Y coordinate of the stylus event | |
| user\_data | user data set when the signal handler was connected. | |
Flags: Run Last
### The `“motion”` signal
```
void
user_function ([GtkGestureStylus](gtkgesturestylus#GtkGestureStylus-struct) *gesture,
double x,
double y,
gpointer user_data)
```
A signal emitted when the stylus moves while touching the device.
#### Parameters
| | | |
| --- | --- | --- |
| gesture | the [GtkGestureStylus](gtkgesturestylus#GtkGestureStylus-struct) that emitted the signal | |
| x | the X coordinate of the stylus event | |
| y | the Y coordinate of the stylus event | |
| user\_data | user data set when the signal handler was connected. | |
Flags: Run Last
### The `“proximity”` signal
```
void
user_function ([GtkGestureStylus](gtkgesturestylus#GtkGestureStylus-struct) *gesture,
double x,
double y,
gpointer user_data)
```
A signal emitted when the stylus is in proximity of the device.
#### Parameters
| | | |
| --- | --- | --- |
| gesture | the [GtkGestureStylus](gtkgesturestylus#GtkGestureStylus-struct) that emitted the signal | |
| x | the X coordinate of the stylus event | |
| y | the Y coordinate of the stylus event | |
| user\_data | user data set when the signal handler was connected. | |
Flags: Run Last
### The `“up”` signal
```
void
user_function ([GtkGestureStylus](gtkgesturestylus#GtkGestureStylus-struct) *gesture,
double x,
double y,
gpointer user_data)
```
A signal emitted when the stylus no longer touches the device.
#### Parameters
| | | |
| --- | --- | --- |
| gesture | the [GtkGestureStylus](gtkgesturestylus#GtkGestureStylus-struct) that emitted the signal | |
| x | the X coordinate of the stylus event | |
| y | the Y coordinate of the stylus event | |
| user\_data | user data set when the signal handler was connected. | |
Flags: Run Last
See Also
--------
[GtkGesture](gtkgesture#GtkGesture-struct), [GtkGestureSingle](gtkgesturesingle#GtkGestureSingle-struct)
gtk GtkStringFilter GtkStringFilter
===============
GtkStringFilter — Filtering by strings
Functions
---------
| | |
| --- | --- |
| [GtkStringFilter](gtkstringfilter#GtkStringFilter-struct) \* | [gtk\_string\_filter\_new](gtkstringfilter#gtk-string-filter-new) () |
| const char \* | [gtk\_string\_filter\_get\_search](gtkstringfilter#gtk-string-filter-get-search) () |
| void | [gtk\_string\_filter\_set\_search](gtkstringfilter#gtk-string-filter-set-search) () |
| [GtkExpression](gtkexpression#GtkExpression-struct) \* | [gtk\_string\_filter\_get\_expression](gtkstringfilter#gtk-string-filter-get-expression) () |
| void | [gtk\_string\_filter\_set\_expression](gtkstringfilter#gtk-string-filter-set-expression) () |
| gboolean | [gtk\_string\_filter\_get\_ignore\_case](gtkstringfilter#gtk-string-filter-get-ignore-case) () |
| void | [gtk\_string\_filter\_set\_ignore\_case](gtkstringfilter#gtk-string-filter-set-ignore-case) () |
| [GtkStringFilterMatchMode](gtkstringfilter#GtkStringFilterMatchMode) | [gtk\_string\_filter\_get\_match\_mode](gtkstringfilter#gtk-string-filter-get-match-mode) () |
| void | [gtk\_string\_filter\_set\_match\_mode](gtkstringfilter#gtk-string-filter-set-match-mode) () |
Properties
----------
| | | |
| --- | --- | --- |
| [GtkExpression](gtkexpression#GtkExpression-struct) \* | [expression](gtkstringfilter#GtkStringFilter--expression) | Read / Write |
| gboolean | [ignore-case](gtkstringfilter#GtkStringFilter--ignore-case) | Read / Write |
| [GtkStringFilterMatchMode](gtkstringfilter#GtkStringFilterMatchMode) | [match-mode](gtkstringfilter#GtkStringFilter--match-mode) | Read / Write |
| char \* | [search](gtkstringfilter#GtkStringFilter--search) | Read / Write |
Types and Values
----------------
| | |
| --- | --- |
| | [GtkStringFilter](gtkstringfilter#GtkStringFilter-struct) |
| enum | [GtkStringFilterMatchMode](gtkstringfilter#GtkStringFilterMatchMode) |
Object Hierarchy
----------------
```
GObject
╰── [GtkFilter](gtkfilter#GtkFilter-struct)
╰── GtkStringFilter
```
Includes
--------
```
#include <gtk/gtk.h>
```
Description
-----------
GtkStringFilter determines whether to include items by looking at strings and comparing them to a fixed search term. The strings are obtained from the items by evaluating a [GtkExpression](gtkexpression#GtkExpression-struct).
GtkStringFilter has several different modes of comparison - it can match the whole string, just a prefix, or any substring.
Functions
---------
### gtk\_string\_filter\_new ()
```
[GtkStringFilter](gtkstringfilter#GtkStringFilter-struct) *
gtk_string_filter_new (*`[GtkExpression](gtkexpression#GtkExpression-struct) *expression`*);
```
Creates a new string filter.
You will want to set up the filter by providing a string to search for and by providing a property to look up on the item.
#### Parameters
| | | |
| --- | --- | --- |
| expression | The expression to evaluate or `NULL` for none. | [transfer full][nullable] |
#### Returns
a new [GtkStringFilter](gtkstringfilter#GtkStringFilter-struct)
### gtk\_string\_filter\_get\_search ()
```
const char *
gtk_string_filter_get_search (*`[GtkStringFilter](gtkstringfilter#GtkStringFilter-struct) *self`*);
```
Gets the search string set via [`gtk_string_filter_set_search()`](gtkstringfilter#gtk-string-filter-set-search).
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkStringFilter](gtkstringfilter#GtkStringFilter-struct) | |
#### Returns
The search string.
[nullable][transfer none]
### gtk\_string\_filter\_set\_search ()
```
void
gtk_string_filter_set_search (*`[GtkStringFilter](gtkstringfilter#GtkStringFilter-struct) *self`*,
*`const char *search`*);
```
Sets the string to search for.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkStringFilter](gtkstringfilter#GtkStringFilter-struct) | |
| search | The string to search for or `NULL` to clear the search. | [transfer none][nullable] |
### gtk\_string\_filter\_get\_expression ()
```
[GtkExpression](gtkexpression#GtkExpression-struct) *
gtk_string_filter_get_expression (*`[GtkStringFilter](gtkstringfilter#GtkStringFilter-struct) *self`*);
```
Gets the expression that the string filter uses to obtain strings from items.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkStringFilter](gtkstringfilter#GtkStringFilter-struct) | |
#### Returns
a [GtkExpression](gtkexpression#GtkExpression-struct).
[transfer none]
### gtk\_string\_filter\_set\_expression ()
```
void
gtk_string_filter_set_expression (*`[GtkStringFilter](gtkstringfilter#GtkStringFilter-struct) *self`*,
*`[GtkExpression](gtkexpression#GtkExpression-struct) *expression`*);
```
Sets the expression that the string filter uses to obtain strings from items. The expression must have a value type of G\_TYPE\_STRING.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkStringFilter](gtkstringfilter#GtkStringFilter-struct) | |
| expression | a [GtkExpression](gtkexpression#GtkExpression-struct) | |
### gtk\_string\_filter\_get\_ignore\_case ()
```
gboolean
gtk_string_filter_get_ignore_case (*`[GtkStringFilter](gtkstringfilter#GtkStringFilter-struct) *self`*);
```
Returns whether the filter ignores case differences.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkStringFilter](gtkstringfilter#GtkStringFilter-struct) | |
#### Returns
`TRUE` if the filter ignores case
### gtk\_string\_filter\_set\_ignore\_case ()
```
void
gtk_string_filter_set_ignore_case (*`[GtkStringFilter](gtkstringfilter#GtkStringFilter-struct) *self`*,
*`gboolean ignore_case`*);
```
Sets whether the filter ignores case differences.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkStringFilter](gtkstringfilter#GtkStringFilter-struct) | |
| ignore\_case | `TRUE` to ignore case | |
### gtk\_string\_filter\_get\_match\_mode ()
```
[GtkStringFilterMatchMode](gtkstringfilter#GtkStringFilterMatchMode)
gtk_string_filter_get_match_mode (*`[GtkStringFilter](gtkstringfilter#GtkStringFilter-struct) *self`*);
```
Returns the match mode that the filter is using.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkStringFilter](gtkstringfilter#GtkStringFilter-struct) | |
#### Returns
the match mode of the filter
### gtk\_string\_filter\_set\_match\_mode ()
```
void
gtk_string_filter_set_match_mode (*`[GtkStringFilter](gtkstringfilter#GtkStringFilter-struct) *self`*,
*`[GtkStringFilterMatchMode](gtkstringfilter#GtkStringFilterMatchMode) mode`*);
```
Sets the match mode for the filter.
#### Parameters
| | | |
| --- | --- | --- |
| self | a [GtkStringFilter](gtkstringfilter#GtkStringFilter-struct) | |
| mode | the new match mode | |
Types and Values
----------------
### GtkStringFilter
```
typedef struct _GtkStringFilter GtkStringFilter;
```
### enum GtkStringFilterMatchMode
Specifies how search strings are matched inside text.
#### Members
| | | |
| --- | --- | --- |
| GTK\_STRING\_FILTER\_MATCH\_MODE\_EXACT | The search string and text must match exactly. | |
| GTK\_STRING\_FILTER\_MATCH\_MODE\_SUBSTRING | The search string must be contained as a substring inside the text. | |
| GTK\_STRING\_FILTER\_MATCH\_MODE\_PREFIX | The text must begin with the search string. | |
Property Details
----------------
### The `“expression”` property
```
“expression” [GtkExpression](gtkexpression#GtkExpression-struct) *
```
The expression to evaluate on item to get a string to compare with
[type GtkExpression]
Owner: GtkStringFilter
Flags: Read / Write
### The `“ignore-case”` property
```
“ignore-case” gboolean
```
If matching is case sensitive
Owner: GtkStringFilter
Flags: Read / Write
Default value: TRUE
### The `“match-mode”` property
```
“match-mode” [GtkStringFilterMatchMode](gtkstringfilter#GtkStringFilterMatchMode)
```
If exact matches are necessary or if substrings are allowed
Owner: GtkStringFilter
Flags: Read / Write
Default value: GTK\_STRING\_FILTER\_MATCH\_MODE\_SUBSTRING
### The `“search”` property
```
“search” char *
```
The search term
Owner: GtkStringFilter
Flags: Read / Write
Default value: NULL
| programming_docs |
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.