diff --git a/Documentation/Reference/README.md b/Documentation/Reference/README.md index 582695e..bf39c27 100644 --- a/Documentation/Reference/README.md +++ b/Documentation/Reference/README.md @@ -37,6 +37,7 @@ - [FlowBox](structs/FlowBox.md) - [ForEach](structs/ForEach.md) - [Form](structs/Form.md) +- [Freeze](structs/Freeze.md) - [HStack](structs/HStack.md) - [HeaderBar](structs/HeaderBar.md) - [InspectorWrapper](structs/InspectorWrapper.md) @@ -58,6 +59,8 @@ - [PreferencesRow](structs/PreferencesRow.md) - [ProgressBar](structs/ProgressBar.md) - [ScrolledWindow](structs/ScrolledWindow.md) +- [SearchBar](structs/SearchBar.md) +- [SearchEntry](structs/SearchEntry.md) - [Signal](structs/Signal.md) - [SpinRow](structs/SpinRow.md) - [Spinner](structs/Spinner.md) diff --git a/Documentation/Reference/extensions/View.md b/Documentation/Reference/extensions/View.md index 5011d80..02a166f 100644 --- a/Documentation/Reference/extensions/View.md +++ b/Documentation/Reference/extensions/View.md @@ -71,6 +71,12 @@ Replace every occurrence of a certain view type in the content. - modify: Modify the view. - Returns: A view. +### `freeze(_:)` + +Prevent a view from being updated. +- Parameter freeze: Whether to freeze the view. +- Returns: A view. + ### `inspect(_:)` Modify a GTUI widget before being displayed and when being updated. diff --git a/Documentation/Reference/structs/ActionRow.md b/Documentation/Reference/structs/ActionRow.md index c2a3873..89fbcc1 100644 --- a/Documentation/Reference/structs/ActionRow.md +++ b/Documentation/Reference/structs/ActionRow.md @@ -79,12 +79,6 @@ Whether the user can copy the subtitle from the label. See also [property@Gtk.Label:selectable]. -### `titleLines` - -The number of lines at the end of which the title label will be ellipsized. - -If the value is 0, the number of lines won't be limited. - ### `title` The title of the preference represented by this row. @@ -92,6 +86,12 @@ The title of the preference represented by this row. The title is interpreted as Pango markup unless [property@PreferencesRow:use-markup] is set to `FALSE`. +### `titleLines` + +The number of lines at the end of which the title label will be ellipsized. + +If the value is 0, the number of lines won't be limited. + ### `titleSelectable` Whether the user can copy the title from the label. @@ -185,12 +185,6 @@ Whether the user can copy the subtitle from the label. See also [property@Gtk.Label:selectable]. -### `titleLines(_:)` - -The number of lines at the end of which the title label will be ellipsized. - -If the value is 0, the number of lines won't be limited. - ### `title(_:)` The title of the preference represented by this row. @@ -198,6 +192,12 @@ The title of the preference represented by this row. The title is interpreted as Pango markup unless [property@PreferencesRow:use-markup] is set to `FALSE`. +### `titleLines(_:)` + +The number of lines at the end of which the title label will be ellipsized. + +If the value is 0, the number of lines won't be limited. + ### `titleSelectable(_:)` Whether the user can copy the title from the label. diff --git a/Documentation/Reference/structs/Box.md b/Documentation/Reference/structs/Box.md index fc0cc32..a85c0be 100644 --- a/Documentation/Reference/structs/Box.md +++ b/Documentation/Reference/structs/Box.md @@ -46,6 +46,12 @@ Additional update functions for type extensions. Additional appear functions for type extensions. +### `accessibleRole` + +The accessible role of the given `GtkAccessible` implementation. + +The accessible role cannot be changed once set. + ### `baselineChild` The child that determines the baseline, in vertical orientation. @@ -93,6 +99,12 @@ Update the widget's view storage. - modifiers: The view modifiers. - updateProperties: Whether to update the view's properties. +### `accessibleRole(_:)` + +The accessible role of the given `GtkAccessible` implementation. + +The accessible role cannot be changed once set. + ### `baselineChild(_:)` The child that determines the baseline, in vertical orientation. diff --git a/Documentation/Reference/structs/Button.md b/Documentation/Reference/structs/Button.md index a154bad..a506f18 100644 --- a/Documentation/Reference/structs/Button.md +++ b/Documentation/Reference/structs/Button.md @@ -42,6 +42,16 @@ Additional update functions for type extensions. Additional appear functions for type extensions. +### `accessibleRole` + +The accessible role of the given `GtkAccessible` implementation. + +The accessible role cannot be changed once set. + +### `actionName` + +action-name + ### `canShrink` Whether the size of the button can be made smaller than the natural @@ -114,6 +124,16 @@ Update the widget's view storage. - modifiers: The view modifiers. - updateProperties: Whether to update the view's properties. +### `accessibleRole(_:)` + +The accessible role of the given `GtkAccessible` implementation. + +The accessible role cannot be changed once set. + +### `actionName(_:)` + +action-name + ### `canShrink(_:)` Whether the size of the button can be made smaller than the natural diff --git a/Documentation/Reference/structs/CenterBox.md b/Documentation/Reference/structs/CenterBox.md index a595c5b..0bc80ee 100644 --- a/Documentation/Reference/structs/CenterBox.md +++ b/Documentation/Reference/structs/CenterBox.md @@ -46,6 +46,12 @@ Additional update functions for type extensions. Additional appear functions for type extensions. +### `accessibleRole` + +The accessible role of the given `GtkAccessible` implementation. + +The accessible role cannot be changed once set. + ### `centerWidget` The widget that is placed at the center position. @@ -104,6 +110,12 @@ Update the widget's view storage. - modifiers: The view modifiers. - updateProperties: Whether to update the view's properties. +### `accessibleRole(_:)` + +The accessible role of the given `GtkAccessible` implementation. + +The accessible role cannot be changed once set. + ### `centerWidget(_:)` The widget that is placed at the center position. diff --git a/Documentation/Reference/structs/CheckButton.md b/Documentation/Reference/structs/CheckButton.md index 849fa5f..2dddd21 100644 --- a/Documentation/Reference/structs/CheckButton.md +++ b/Documentation/Reference/structs/CheckButton.md @@ -69,6 +69,16 @@ Additional update functions for type extensions. Additional appear functions for type extensions. +### `accessibleRole` + +The accessible role of the given `GtkAccessible` implementation. + +The accessible role cannot be changed once set. + +### `actionName` + +action-name + ### `active` If the check button is active. @@ -141,6 +151,16 @@ Update the widget's view storage. - modifiers: The view modifiers. - updateProperties: Whether to update the view's properties. +### `accessibleRole(_:)` + +The accessible role of the given `GtkAccessible` implementation. + +The accessible role cannot be changed once set. + +### `actionName(_:)` + +action-name + ### `active(_:)` If the check button is active. diff --git a/Documentation/Reference/structs/ComboRow.md b/Documentation/Reference/structs/ComboRow.md index a701e96..e5af96c 100644 --- a/Documentation/Reference/structs/ComboRow.md +++ b/Documentation/Reference/structs/ComboRow.md @@ -45,34 +45,6 @@ Additional update functions for type extensions. Additional appear functions for type extensions. -### `enableSearch` - -Whether to show a search entry in the popup. - -If set to `TRUE`, a search entry will be shown in the popup that -allows to search for items in the list. - -Search requires [property@ComboRow:expression] to be set. - -### `selected` - -The position of the selected item. - -If no item is selected, the property has the value -[const@Gtk.INVALID_LIST_POSITION] - -### `useSubtitle` - -Whether to use the current value as the subtitle. - -If you use a custom list item factory, you will need to give the row a -name conversion expression with [property@ComboRow:expression]. - -If set to `TRUE`, you should not access [property@ActionRow:subtitle]. - -The subtitle is interpreted as Pango markup if -[property@PreferencesRow:use-markup] is set to `TRUE`. - ### `activatableWidget` The widget to activate when the row is activated. @@ -85,10 +57,26 @@ mnemonics. The target widget will be activated by emitting the [signal@Gtk.Widget::mnemonic-activate] signal on it. +### `enableSearch` + +Whether to show a search entry in the popup. + +If set to `TRUE`, a search entry will be shown in the popup that +allows to search for items in the list. + +Search requires [property@ComboRow:expression] to be set. + ### `iconName` The icon name for this row. +### `selected` + +The position of the selected item. + +If no item is selected, the property has the value +[const@Gtk.INVALID_LIST_POSITION] + ### `subtitle` The subtitle for this row. @@ -109,12 +97,6 @@ Whether the user can copy the subtitle from the label. See also [property@Gtk.Label:selectable]. -### `titleLines` - -The number of lines at the end of which the title label will be ellipsized. - -If the value is 0, the number of lines won't be limited. - ### `title` The title of the preference represented by this row. @@ -122,6 +104,12 @@ The title of the preference represented by this row. The title is interpreted as Pango markup unless [property@PreferencesRow:use-markup] is set to `FALSE`. +### `titleLines` + +The number of lines at the end of which the title label will be ellipsized. + +If the value is 0, the number of lines won't be limited. + ### `titleSelectable` Whether the user can copy the title from the label. @@ -136,6 +124,18 @@ Subclasses may also use it for other labels, such as subtitle. See also [func@Pango.parse_markup]. +### `useSubtitle` + +Whether to use the current value as the subtitle. + +If you use a custom list item factory, you will need to give the row a +name conversion expression with [property@ComboRow:expression]. + +If set to `TRUE`, you should not access [property@ActionRow:subtitle]. + +The subtitle is interpreted as Pango markup if +[property@PreferencesRow:use-markup] is set to `TRUE`. + ### `useUnderline` Whether an embedded underline in the title indicates a mnemonic. @@ -179,34 +179,6 @@ Update the widget's view storage. - modifiers: The view modifiers. - updateProperties: Whether to update the view's properties. -### `enableSearch(_:)` - -Whether to show a search entry in the popup. - -If set to `TRUE`, a search entry will be shown in the popup that -allows to search for items in the list. - -Search requires [property@ComboRow:expression] to be set. - -### `selected(_:)` - -The position of the selected item. - -If no item is selected, the property has the value -[const@Gtk.INVALID_LIST_POSITION] - -### `useSubtitle(_:)` - -Whether to use the current value as the subtitle. - -If you use a custom list item factory, you will need to give the row a -name conversion expression with [property@ComboRow:expression]. - -If set to `TRUE`, you should not access [property@ActionRow:subtitle]. - -The subtitle is interpreted as Pango markup if -[property@PreferencesRow:use-markup] is set to `TRUE`. - ### `activatableWidget(_:)` The widget to activate when the row is activated. @@ -219,10 +191,26 @@ mnemonics. The target widget will be activated by emitting the [signal@Gtk.Widget::mnemonic-activate] signal on it. +### `enableSearch(_:)` + +Whether to show a search entry in the popup. + +If set to `TRUE`, a search entry will be shown in the popup that +allows to search for items in the list. + +Search requires [property@ComboRow:expression] to be set. + ### `iconName(_:)` The icon name for this row. +### `selected(_:)` + +The position of the selected item. + +If no item is selected, the property has the value +[const@Gtk.INVALID_LIST_POSITION] + ### `subtitle(_:)` The subtitle for this row. @@ -243,12 +231,6 @@ Whether the user can copy the subtitle from the label. See also [property@Gtk.Label:selectable]. -### `titleLines(_:)` - -The number of lines at the end of which the title label will be ellipsized. - -If the value is 0, the number of lines won't be limited. - ### `title(_:)` The title of the preference represented by this row. @@ -256,6 +238,12 @@ The title of the preference represented by this row. The title is interpreted as Pango markup unless [property@PreferencesRow:use-markup] is set to `FALSE`. +### `titleLines(_:)` + +The number of lines at the end of which the title label will be ellipsized. + +If the value is 0, the number of lines won't be limited. + ### `titleSelectable(_:)` Whether the user can copy the title from the label. @@ -270,6 +258,18 @@ Subclasses may also use it for other labels, such as subtitle. See also [func@Pango.parse_markup]. +### `useSubtitle(_:)` + +Whether to use the current value as the subtitle. + +If you use a custom list item factory, you will need to give the row a +name conversion expression with [property@ComboRow:expression]. + +If set to `TRUE`, you should not access [property@ActionRow:subtitle]. + +The subtitle is interpreted as Pango markup if +[property@PreferencesRow:use-markup] is set to `TRUE`. + ### `useUnderline(_:)` Whether an embedded underline in the title indicates a mnemonic. diff --git a/Documentation/Reference/structs/ExpanderRow.md b/Documentation/Reference/structs/ExpanderRow.md index c998c40..56bf794 100644 --- a/Documentation/Reference/structs/ExpanderRow.md +++ b/Documentation/Reference/structs/ExpanderRow.md @@ -67,12 +67,6 @@ ellipsized. If the value is 0, the number of lines won't be limited. -### `titleLines` - -The number of lines at the end of which the title label will be ellipsized. - -If the value is 0, the number of lines won't be limited. - ### `title` The title of the preference represented by this row. @@ -80,6 +74,12 @@ The title of the preference represented by this row. The title is interpreted as Pango markup unless [property@PreferencesRow:use-markup] is set to `FALSE`. +### `titleLines` + +The number of lines at the end of which the title label will be ellipsized. + +If the value is 0, the number of lines won't be limited. + ### `titleSelectable` Whether the user can copy the title from the label. @@ -167,12 +167,6 @@ ellipsized. If the value is 0, the number of lines won't be limited. -### `titleLines(_:)` - -The number of lines at the end of which the title label will be ellipsized. - -If the value is 0, the number of lines won't be limited. - ### `title(_:)` The title of the preference represented by this row. @@ -180,6 +174,12 @@ The title of the preference represented by this row. The title is interpreted as Pango markup unless [property@PreferencesRow:use-markup] is set to `FALSE`. +### `titleLines(_:)` + +The number of lines at the end of which the title label will be ellipsized. + +If the value is 0, the number of lines won't be limited. + ### `titleSelectable(_:)` Whether the user can copy the title from the label. diff --git a/Documentation/Reference/structs/FlowBox.md b/Documentation/Reference/structs/FlowBox.md index 7b6b0b6..006391d 100644 --- a/Documentation/Reference/structs/FlowBox.md +++ b/Documentation/Reference/structs/FlowBox.md @@ -60,6 +60,12 @@ Additional appear functions for type extensions. accept-unpaired-release +### `accessibleRole` + +The accessible role of the given `GtkAccessible` implementation. + +The accessible role cannot be changed once set. + ### `activateOnSingleClick` Determines whether children can be activated with a single @@ -194,6 +200,12 @@ Update the widget's view storage. accept-unpaired-release +### `accessibleRole(_:)` + +The accessible role of the given `GtkAccessible` implementation. + +The accessible role cannot be changed once set. + ### `activateOnSingleClick(_:)` Determines whether children can be activated with a single diff --git a/Documentation/Reference/structs/Freeze.md b/Documentation/Reference/structs/Freeze.md new file mode 100644 index 0000000..a54cd48 --- /dev/null +++ b/Documentation/Reference/structs/Freeze.md @@ -0,0 +1,29 @@ +**STRUCT** + +# `Freeze` + +State whether to update the child views or not. + +## Properties +### `freeze` + +Whether not to update the child view. + +### `content` + +The wrapped view. + +## Methods +### `container(modifiers:)` + +Get the content's container. +- Parameter modifiers: Modify views before being updated. +- Returns: The content's container. + +### `update(_:modifiers:updateProperties:)` + +Update the content. +- Parameters: + - storage: The content's storage. + - modifiers: Modify views before being updated. + - updateProperties: Whether to update properties. diff --git a/Documentation/Reference/structs/Label.md b/Documentation/Reference/structs/Label.md index 4eb89eb..2e84bf9 100644 --- a/Documentation/Reference/structs/Label.md +++ b/Documentation/Reference/structs/Label.md @@ -186,6 +186,12 @@ Additional update functions for type extensions. Additional appear functions for type extensions. +### `accessibleRole` + +The accessible role of the given `GtkAccessible` implementation. + +The accessible role cannot be changed once set. + ### `label` The contents of the label. @@ -314,6 +320,12 @@ Update the widget's view storage. - modifiers: The view modifiers. - updateProperties: Whether to update the view's properties. +### `accessibleRole(_:)` + +The accessible role of the given `GtkAccessible` implementation. + +The accessible role cannot be changed once set. + ### `label(_:)` The contents of the label. diff --git a/Documentation/Reference/structs/LevelBar.md b/Documentation/Reference/structs/LevelBar.md index bfe901a..8a586f5 100644 --- a/Documentation/Reference/structs/LevelBar.md +++ b/Documentation/Reference/structs/LevelBar.md @@ -109,6 +109,12 @@ Additional update functions for type extensions. Additional appear functions for type extensions. +### `accessibleRole` + +The accessible role of the given `GtkAccessible` implementation. + +The accessible role cannot be changed once set. + ### `inverted` Whether the `GtkLeveBar` is inverted. @@ -166,6 +172,12 @@ Update the widget's view storage. - modifiers: The view modifiers. - updateProperties: Whether to update the view's properties. +### `accessibleRole(_:)` + +The accessible role of the given `GtkAccessible` implementation. + +The accessible role cannot be changed once set. + ### `inverted(_:)` Whether the `GtkLeveBar` is inverted. diff --git a/Documentation/Reference/structs/LinkButton.md b/Documentation/Reference/structs/LinkButton.md index 8ebc83f..a3af692 100644 --- a/Documentation/Reference/structs/LinkButton.md +++ b/Documentation/Reference/structs/LinkButton.md @@ -38,15 +38,15 @@ Additional update functions for type extensions. Additional appear functions for type extensions. -### `uri` +### `accessibleRole` -The URI bound to this button. +The accessible role of the given `GtkAccessible` implementation. -### `visited` +The accessible role cannot be changed once set. -The 'visited' state of this button. +### `actionName` -A visited link is drawn in a different color. +action-name ### `canShrink` @@ -74,11 +74,21 @@ The name of the icon used to automatically populate the button. Text of the label inside the button, if the button contains a label widget. +### `uri` + +The URI bound to this button. + ### `useUnderline` If set, an underline in the text indicates that the following character is to be used as mnemonic. +### `visited` + +The 'visited' state of this button. + +A visited link is drawn in a different color. + ### `activate` Emitted to animate press then release. @@ -120,15 +130,15 @@ Update the widget's view storage. - modifiers: The view modifiers. - updateProperties: Whether to update the view's properties. -### `uri(_:)` +### `accessibleRole(_:)` -The URI bound to this button. +The accessible role of the given `GtkAccessible` implementation. -### `visited(_:)` +The accessible role cannot be changed once set. -The 'visited' state of this button. +### `actionName(_:)` -A visited link is drawn in a different color. +action-name ### `canShrink(_:)` @@ -156,11 +166,21 @@ The name of the icon used to automatically populate the button. Text of the label inside the button, if the button contains a label widget. +### `uri(_:)` + +The URI bound to this button. + ### `useUnderline(_:)` If set, an underline in the text indicates that the following character is to be used as mnemonic. +### `visited(_:)` + +The 'visited' state of this button. + +A visited link is drawn in a different color. + ### `activate(_:)` Emitted to animate press then release. diff --git a/Documentation/Reference/structs/ListBox.md b/Documentation/Reference/structs/ListBox.md index 9ecdf6c..70459d6 100644 --- a/Documentation/Reference/structs/ListBox.md +++ b/Documentation/Reference/structs/ListBox.md @@ -69,6 +69,12 @@ Additional appear functions for type extensions. Whether to accept unpaired release events. +### `accessibleRole` + +The accessible role of the given `GtkAccessible` implementation. + +The accessible role cannot be changed once set. + ### `activateOnSingleClick` Determines whether children can be activated with a single @@ -165,6 +171,12 @@ Update the widget's view storage. Whether to accept unpaired release events. +### `accessibleRole(_:)` + +The accessible role of the given `GtkAccessible` implementation. + +The accessible role cannot be changed once set. + ### `activateOnSingleClick(_:)` Determines whether children can be activated with a single diff --git a/Documentation/Reference/structs/Menu.md b/Documentation/Reference/structs/Menu.md index d6bb8f3..5d57e87 100644 --- a/Documentation/Reference/structs/Menu.md +++ b/Documentation/Reference/structs/Menu.md @@ -73,6 +73,12 @@ Additional update functions for type extensions. Additional appear functions for type extensions. +### `accessibleRole` + +The accessible role of the given `GtkAccessible` implementation. + +The accessible role cannot be changed once set. + ### `active` Whether the menu button is active. @@ -153,6 +159,12 @@ Update the widget's view storage. - modifiers: The view modifiers. - updateProperties: Whether to update the view's properties. +### `accessibleRole(_:)` + +The accessible role of the given `GtkAccessible` implementation. + +The accessible role cannot be changed once set. + ### `active(_:)` Whether the menu button is active. diff --git a/Documentation/Reference/structs/Overlay.md b/Documentation/Reference/structs/Overlay.md index 7f0dbde..6dae2b0 100644 --- a/Documentation/Reference/structs/Overlay.md +++ b/Documentation/Reference/structs/Overlay.md @@ -44,6 +44,12 @@ Additional update functions for type extensions. Additional appear functions for type extensions. +### `accessibleRole` + +The accessible role of the given `GtkAccessible` implementation. + +The accessible role cannot be changed once set. + ### `child` The main child widget. @@ -96,6 +102,12 @@ Update the widget's view storage. - modifiers: The view modifiers. - updateProperties: Whether to update the view's properties. +### `accessibleRole(_:)` + +The accessible role of the given `GtkAccessible` implementation. + +The accessible role cannot be changed once set. + ### `child(_:)` The main child widget. diff --git a/Documentation/Reference/structs/Popover.md b/Documentation/Reference/structs/Popover.md index 3e632c5..fc6637b 100644 --- a/Documentation/Reference/structs/Popover.md +++ b/Documentation/Reference/structs/Popover.md @@ -72,6 +72,12 @@ Additional update functions for type extensions. Additional appear functions for type extensions. +### `accessibleRole` + +The accessible role of the given `GtkAccessible` implementation. + +The accessible role cannot be changed once set. + ### `autohide` Whether to dismiss the popover on outside clicks. @@ -135,6 +141,12 @@ Update the widget's view storage. - modifiers: The view modifiers. - updateProperties: Whether to update the view's properties. +### `accessibleRole(_:)` + +The accessible role of the given `GtkAccessible` implementation. + +The accessible role cannot be changed once set. + ### `autohide(_:)` Whether to dismiss the popover on outside clicks. diff --git a/Documentation/Reference/structs/ProgressBar.md b/Documentation/Reference/structs/ProgressBar.md index 7136884..7658ea8 100644 --- a/Documentation/Reference/structs/ProgressBar.md +++ b/Documentation/Reference/structs/ProgressBar.md @@ -58,6 +58,12 @@ Additional update functions for type extensions. Additional appear functions for type extensions. +### `accessibleRole` + +The accessible role of the given `GtkAccessible` implementation. + +The accessible role cannot be changed once set. + ### `fraction` The fraction of total work that has been completed. @@ -114,6 +120,12 @@ Update the widget's view storage. - modifiers: The view modifiers. - updateProperties: Whether to update the view's properties. +### `accessibleRole(_:)` + +The accessible role of the given `GtkAccessible` implementation. + +The accessible role cannot be changed once set. + ### `fraction(_:)` The fraction of total work that has been completed. diff --git a/Documentation/Reference/structs/ScrolledWindow.md b/Documentation/Reference/structs/ScrolledWindow.md index 04d3e49..491a11d 100644 --- a/Documentation/Reference/structs/ScrolledWindow.md +++ b/Documentation/Reference/structs/ScrolledWindow.md @@ -80,6 +80,12 @@ Additional update functions for type extensions. Additional appear functions for type extensions. +### `accessibleRole` + +The accessible role of the given `GtkAccessible` implementation. + +The accessible role cannot be changed once set. + ### `child` The child widget. @@ -208,6 +214,12 @@ Update the widget's view storage. - modifiers: The view modifiers. - updateProperties: Whether to update the view's properties. +### `accessibleRole(_:)` + +The accessible role of the given `GtkAccessible` implementation. + +The accessible role cannot be changed once set. + ### `child(_:)` The child widget. diff --git a/Documentation/Reference/structs/SearchBar.md b/Documentation/Reference/structs/SearchBar.md new file mode 100644 index 0000000..3b7d8bf --- /dev/null +++ b/Documentation/Reference/structs/SearchBar.md @@ -0,0 +1,128 @@ +**STRUCT** + +# `SearchBar` + +`GtkSearchBar` is a container made to have a search entry. + +![An example GtkSearchBar](search-bar.png) + +It can also contain additional widgets, such as drop-down menus, +or buttons. The search bar would appear when a search is started +through typing on the keyboard, or the application’s search mode +is toggled on. + +For keyboard presses to start a search, the search bar must be told +of a widget to capture key events from through +[method@Gtk.SearchBar.set_key_capture_widget]. This widget will +typically be the top-level window, or a parent container of the +search bar. Common shortcuts such as Ctrl+F should be handled as an +application action, or through the menu items. + +You will also need to tell the search bar about which entry you +are using as your search entry using [method@Gtk.SearchBar.connect_entry]. + +## Creating a search bar + +The following example shows you how to create a more complex search +entry. + +[A simple example](https://gitlab.gnome.org/GNOME/gtk/tree/main/examples/search-bar.c) + +# CSS nodes + +``` +searchbar +╰── revealer +╰── box +├── [child] +╰── [button.close] +``` + +`GtkSearchBar` has a main CSS node with name searchbar. It has a child +node with name revealer that contains a node with name box. The box node +contains both the CSS node of the child widget as well as an optional button +node which gets the .close style class applied. + +# Accessibility + +`GtkSearchBar` uses the %GTK_ACCESSIBLE_ROLE_SEARCH role. + +## Properties +### `updateFunctions` + +Additional update functions for type extensions. + +### `appearFunctions` + +Additional appear functions for type extensions. + +### `accessibleRole` + +The accessible role of the given `GtkAccessible` implementation. + +The accessible role cannot be changed once set. + +### `child` + +The child widget. + +### `keyCaptureWidget` + +The key capture widget. + +### `searchModeEnabled` + +Whether the search mode is on and the search bar shown. + +### `showCloseButton` + +Whether to show the close button in the search bar. + +### `app` + +The application. + +### `window` + +The window. + +## Methods +### `init()` + +Initialize `SearchBar`. + +### `container(modifiers:)` + +Get the widget's view storage. +- Parameter modifiers: The view modifiers. +- Returns: The view storage. + +### `update(_:modifiers:updateProperties:)` + +Update the widget's view storage. +- Parameters: + - storage: The view storage. + - modifiers: The view modifiers. + - updateProperties: Whether to update the view's properties. + +### `accessibleRole(_:)` + +The accessible role of the given `GtkAccessible` implementation. + +The accessible role cannot be changed once set. + +### `child(_:)` + +The child widget. + +### `keyCaptureWidget(_:)` + +The key capture widget. + +### `searchModeEnabled(_:)` + +Whether the search mode is on and the search bar shown. + +### `showCloseButton(_:)` + +Whether to show the close button in the search bar. diff --git a/Documentation/Reference/structs/SearchEntry.md b/Documentation/Reference/structs/SearchEntry.md new file mode 100644 index 0000000..6c9ca38 --- /dev/null +++ b/Documentation/Reference/structs/SearchEntry.md @@ -0,0 +1,358 @@ +**STRUCT** + +# `SearchEntry` + +`GtkSearchEntry` 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` interface. + +![An example GtkSearchEntry](search-entry.png) + +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` +emits the [signal@Gtk.SearchEntry::search-changed] signal which +can be used instead of the [signal@Gtk.Editable::changed] signal. + +The [signal@Gtk.SearchEntry::previous-match], +[signal@Gtk.SearchEntry::next-match] and +[signal@Gtk.SearchEntry::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 [class@Gtk.SearchBar]. If that is not the case, +you can use [method@Gtk.SearchEntry.set_key_capture_widget] to +let it capture key input from another widget. + +`GtkSearchEntry` provides only minimal API and should be used with +the [iface@Gtk.Editable] API. + +## CSS Nodes + +``` +entry.search +╰── text +``` + +`GtkSearchEntry` has a single CSS node with name entry that carries +a `.search` style class, and the text node is a child of that. + +## Accessibility + +`GtkSearchEntry` uses the %GTK_ACCESSIBLE_ROLE_SEARCH_BOX role. + +## Properties +### `updateFunctions` + +Additional update functions for type extensions. + +### `appearFunctions` + +Additional appear functions for type extensions. + +### `accessibleRole` + +The accessible role of the given `GtkAccessible` implementation. + +The accessible role cannot be changed once set. + +### `activatesDefault` + +Whether to activate the default widget when Enter is pressed. + +### `cursorPosition` + +The current position of the insertion cursor in chars. + +### `editable` + +Whether the entry contents can be edited. + +### `enableUndo` + +If undo/redo should be enabled for the editable. + +### `maxWidthChars` + +The desired maximum width of the entry, in characters. + +### `placeholderText` + +The text that will be displayed in the `GtkSearchEntry` +when it is empty and unfocused. + +### `searchDelay` + +The delay in milliseconds from last keypress to the search +changed signal. + +### `selectionBound` + +The position of the opposite end of the selection from the cursor in chars. + +### `text` + +The contents of the entry. + +### `widthChars` + +Number of characters to leave space for in the entry. + +### `xalign` + +The horizontal alignment, from 0 (left) to 1 (right). + +Reversed for RTL layouts. + +### `activate` + +Emitted when the entry is activated. + +The keybindings for this signal are all forms of the Enter key. + +### `changed` + +Emitted at the end of a single user-visible operation on the +contents. + +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). + +### `deleteText` + +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 +[method@Gtk.Editable.delete_text]. + +### `insertText` + +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. + +### `nextMatch` + +Emitted when the user initiates a move to the next match +for the current search string. + +This is a [keybinding signal](class.SignalAction.html). + +Applications should connect to it, to implement moving +between matches. + +The default bindings for this signal is Ctrl-g. + +### `previousMatch` + +Emitted when the user initiates a move to the previous match +for the current search string. + +This is a [keybinding signal](class.SignalAction.html). + +Applications should connect to it, to implement moving +between matches. + +The default bindings for this signal is Ctrl-Shift-g. + +### `searchChanged` + +Emitted with a delay. The length of the delay can be +changed with the [property@Gtk.SearchEntry:search-delay] +property. + +### `searchStarted` + +Emitted when the user initiated a search on the entry. + +### `stopSearch` + +Emitted when the user stops a search via keyboard input. + +This is a [keybinding signal](class.SignalAction.html). + +Applications should connect to it, to implement hiding +the search entry in this case. + +The default bindings for this signal is Escape. + +### `app` + +The application. + +### `window` + +The window. + +## Methods +### `init()` + +Initialize `SearchEntry`. + +### `container(modifiers:)` + +Get the widget's view storage. +- Parameter modifiers: The view modifiers. +- Returns: The view storage. + +### `update(_:modifiers:updateProperties:)` + +Update the widget's view storage. +- Parameters: + - storage: The view storage. + - modifiers: The view modifiers. + - updateProperties: Whether to update the view's properties. + +### `accessibleRole(_:)` + +The accessible role of the given `GtkAccessible` implementation. + +The accessible role cannot be changed once set. + +### `activatesDefault(_:)` + +Whether to activate the default widget when Enter is pressed. + +### `cursorPosition(_:)` + +The current position of the insertion cursor in chars. + +### `editable(_:)` + +Whether the entry contents can be edited. + +### `enableUndo(_:)` + +If undo/redo should be enabled for the editable. + +### `maxWidthChars(_:)` + +The desired maximum width of the entry, in characters. + +### `placeholderText(_:)` + +The text that will be displayed in the `GtkSearchEntry` +when it is empty and unfocused. + +### `searchDelay(_:)` + +The delay in milliseconds from last keypress to the search +changed signal. + +### `selectionBound(_:)` + +The position of the opposite end of the selection from the cursor in chars. + +### `text(_:)` + +The contents of the entry. + +### `widthChars(_:)` + +Number of characters to leave space for in the entry. + +### `xalign(_:)` + +The horizontal alignment, from 0 (left) to 1 (right). + +Reversed for RTL layouts. + +### `activate(_:)` + +Emitted when the entry is activated. + +The keybindings for this signal are all forms of the Enter key. + +### `changed(_:)` + +Emitted at the end of a single user-visible operation on the +contents. + +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). + +### `deleteText(_:)` + +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 +[method@Gtk.Editable.delete_text]. + +### `insertText(_:)` + +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. + +### `nextMatch(_:)` + +Emitted when the user initiates a move to the next match +for the current search string. + +This is a [keybinding signal](class.SignalAction.html). + +Applications should connect to it, to implement moving +between matches. + +The default bindings for this signal is Ctrl-g. + +### `previousMatch(_:)` + +Emitted when the user initiates a move to the previous match +for the current search string. + +This is a [keybinding signal](class.SignalAction.html). + +Applications should connect to it, to implement moving +between matches. + +The default bindings for this signal is Ctrl-Shift-g. + +### `searchChanged(_:)` + +Emitted with a delay. The length of the delay can be +changed with the [property@Gtk.SearchEntry:search-delay] +property. + +### `searchStarted(_:)` + +Emitted when the user initiated a search on the entry. + +### `stopSearch(_:)` + +Emitted when the user stops a search via keyboard input. + +This is a [keybinding signal](class.SignalAction.html). + +Applications should connect to it, to implement hiding +the search entry in this case. + +The default bindings for this signal is Escape. diff --git a/Documentation/Reference/structs/SpinRow.md b/Documentation/Reference/structs/SpinRow.md index 0b20768..79a3eab 100644 --- a/Documentation/Reference/structs/SpinRow.md +++ b/Documentation/Reference/structs/SpinRow.md @@ -28,30 +28,6 @@ Additional update functions for type extensions. Additional appear functions for type extensions. -### `climbRate` - -The acceleration rate when you hold down a button or key. - -### `digits` - -The number of decimal places to display. - -### `numeric` - -Whether non-numeric characters should be ignored. - -### `snapToTicks` - -Whether invalid values are snapped to the nearest step increment. - -### `value` - -The current value. - -### `wrap` - -Whether the spin row should wrap upon reaching its limits. - ### `activatableWidget` The widget to activate when the row is activated. @@ -64,10 +40,26 @@ mnemonics. The target widget will be activated by emitting the [signal@Gtk.Widget::mnemonic-activate] signal on it. +### `climbRate` + +The acceleration rate when you hold down a button or key. + +### `digits` + +The number of decimal places to display. + ### `iconName` The icon name for this row. +### `numeric` + +Whether non-numeric characters should be ignored. + +### `snapToTicks` + +Whether invalid values are snapped to the nearest step increment. + ### `subtitle` The subtitle for this row. @@ -88,12 +80,6 @@ Whether the user can copy the subtitle from the label. See also [property@Gtk.Label:selectable]. -### `titleLines` - -The number of lines at the end of which the title label will be ellipsized. - -If the value is 0, the number of lines won't be limited. - ### `title` The title of the preference represented by this row. @@ -101,6 +87,12 @@ The title of the preference represented by this row. The title is interpreted as Pango markup unless [property@PreferencesRow:use-markup] is set to `FALSE`. +### `titleLines` + +The number of lines at the end of which the title label will be ellipsized. + +If the value is 0, the number of lines won't be limited. + ### `titleSelectable` Whether the user can copy the title from the label. @@ -119,6 +111,18 @@ See also [func@Pango.parse_markup]. Whether an embedded underline in the title indicates a mnemonic. +### `value` + +The current value. + +### `wrap` + +Whether the spin row should wrap upon reaching its limits. + +### `activated` + +This signal is emitted after the row has been activated. + ### `input` Emitted to convert the user's input into a double value. @@ -142,10 +146,6 @@ Emitted right after the spinbutton wraps. See [signal@Gtk.SpinButton::wrapped]. -### `activated` - -This signal is emitted after the row has been activated. - ### `suffix` The body for the widget "suffix". @@ -181,30 +181,6 @@ Update the widget's view storage. - modifiers: The view modifiers. - updateProperties: Whether to update the view's properties. -### `climbRate(_:)` - -The acceleration rate when you hold down a button or key. - -### `digits(_:)` - -The number of decimal places to display. - -### `numeric(_:)` - -Whether non-numeric characters should be ignored. - -### `snapToTicks(_:)` - -Whether invalid values are snapped to the nearest step increment. - -### `value(_:)` - -The current value. - -### `wrap(_:)` - -Whether the spin row should wrap upon reaching its limits. - ### `activatableWidget(_:)` The widget to activate when the row is activated. @@ -217,10 +193,26 @@ mnemonics. The target widget will be activated by emitting the [signal@Gtk.Widget::mnemonic-activate] signal on it. +### `climbRate(_:)` + +The acceleration rate when you hold down a button or key. + +### `digits(_:)` + +The number of decimal places to display. + ### `iconName(_:)` The icon name for this row. +### `numeric(_:)` + +Whether non-numeric characters should be ignored. + +### `snapToTicks(_:)` + +Whether invalid values are snapped to the nearest step increment. + ### `subtitle(_:)` The subtitle for this row. @@ -241,12 +233,6 @@ Whether the user can copy the subtitle from the label. See also [property@Gtk.Label:selectable]. -### `titleLines(_:)` - -The number of lines at the end of which the title label will be ellipsized. - -If the value is 0, the number of lines won't be limited. - ### `title(_:)` The title of the preference represented by this row. @@ -254,6 +240,12 @@ The title of the preference represented by this row. The title is interpreted as Pango markup unless [property@PreferencesRow:use-markup] is set to `FALSE`. +### `titleLines(_:)` + +The number of lines at the end of which the title label will be ellipsized. + +If the value is 0, the number of lines won't be limited. + ### `titleSelectable(_:)` Whether the user can copy the title from the label. @@ -272,6 +264,18 @@ See also [func@Pango.parse_markup]. Whether an embedded underline in the title indicates a mnemonic. +### `value(_:)` + +The current value. + +### `wrap(_:)` + +Whether the spin row should wrap upon reaching its limits. + +### `activated(_:)` + +This signal is emitted after the row has been activated. + ### `input(_:)` Emitted to convert the user's input into a double value. @@ -295,10 +299,6 @@ Emitted right after the spinbutton wraps. See [signal@Gtk.SpinButton::wrapped]. -### `activated(_:)` - -This signal is emitted after the row has been activated. - ### `suffix(_:)` Set the body for "suffix". diff --git a/Documentation/Reference/structs/Spinner.md b/Documentation/Reference/structs/Spinner.md index 2d530ca..ffaee28 100644 --- a/Documentation/Reference/structs/Spinner.md +++ b/Documentation/Reference/structs/Spinner.md @@ -27,6 +27,12 @@ Additional update functions for type extensions. Additional appear functions for type extensions. +### `accessibleRole` + +The accessible role of the given `GtkAccessible` implementation. + +The accessible role cannot be changed once set. + ### `spinning` Whether the spinner is spinning @@ -58,6 +64,12 @@ Update the widget's view storage. - modifiers: The view modifiers. - updateProperties: Whether to update the view's properties. +### `accessibleRole(_:)` + +The accessible role of the given `GtkAccessible` implementation. + +The accessible role cannot be changed once set. + ### `spinning(_:)` Whether the spinner is spinning diff --git a/Documentation/Reference/structs/SwitchRow.md b/Documentation/Reference/structs/SwitchRow.md index e681583..459686d 100644 --- a/Documentation/Reference/structs/SwitchRow.md +++ b/Documentation/Reference/structs/SwitchRow.md @@ -32,10 +32,6 @@ Additional update functions for type extensions. Additional appear functions for type extensions. -### `active` - -Whether the switch row is in the "on" or "off" position. - ### `activatableWidget` The widget to activate when the row is activated. @@ -48,6 +44,10 @@ mnemonics. The target widget will be activated by emitting the [signal@Gtk.Widget::mnemonic-activate] signal on it. +### `active` + +Whether the switch row is in the "on" or "off" position. + ### `iconName` The icon name for this row. @@ -72,12 +72,6 @@ Whether the user can copy the subtitle from the label. See also [property@Gtk.Label:selectable]. -### `titleLines` - -The number of lines at the end of which the title label will be ellipsized. - -If the value is 0, the number of lines won't be limited. - ### `title` The title of the preference represented by this row. @@ -85,6 +79,12 @@ The title of the preference represented by this row. The title is interpreted as Pango markup unless [property@PreferencesRow:use-markup] is set to `FALSE`. +### `titleLines` + +The number of lines at the end of which the title label will be ellipsized. + +If the value is 0, the number of lines won't be limited. + ### `titleSelectable` Whether the user can copy the title from the label. @@ -142,10 +142,6 @@ Update the widget's view storage. - modifiers: The view modifiers. - updateProperties: Whether to update the view's properties. -### `active(_:)` - -Whether the switch row is in the "on" or "off" position. - ### `activatableWidget(_:)` The widget to activate when the row is activated. @@ -158,6 +154,10 @@ mnemonics. The target widget will be activated by emitting the [signal@Gtk.Widget::mnemonic-activate] signal on it. +### `active(_:)` + +Whether the switch row is in the "on" or "off" position. + ### `iconName(_:)` The icon name for this row. @@ -182,12 +182,6 @@ Whether the user can copy the subtitle from the label. See also [property@Gtk.Label:selectable]. -### `titleLines(_:)` - -The number of lines at the end of which the title label will be ellipsized. - -If the value is 0, the number of lines won't be limited. - ### `title(_:)` The title of the preference represented by this row. @@ -195,6 +189,12 @@ The title of the preference represented by this row. The title is interpreted as Pango markup unless [property@PreferencesRow:use-markup] is set to `FALSE`. +### `titleLines(_:)` + +The number of lines at the end of which the title label will be ellipsized. + +If the value is 0, the number of lines won't be limited. + ### `titleSelectable(_:)` Whether the user can copy the title from the label. diff --git a/Documentation/Reference/structs/ToggleButton.md b/Documentation/Reference/structs/ToggleButton.md index 1f16662..d39b1cf 100644 --- a/Documentation/Reference/structs/ToggleButton.md +++ b/Documentation/Reference/structs/ToggleButton.md @@ -87,6 +87,16 @@ Additional update functions for type extensions. Additional appear functions for type extensions. +### `accessibleRole` + +The accessible role of the given `GtkAccessible` implementation. + +The accessible role cannot be changed once set. + +### `actionName` + +action-name + ### `active` If the toggle button should be pressed in. @@ -122,10 +132,6 @@ Text of the label inside the button, if the button contains a label widget. If set, an underline in the text indicates that the following character is to be used as mnemonic. -### `toggled` - -Emitted whenever the `GtkToggleButton`'s state is changed. - ### `activate` Emitted to animate press then release. @@ -140,6 +146,10 @@ The default bindings for this signal are all forms of the Emitted when the button has been activated (pressed and released). +### `toggled` + +Emitted whenever the `GtkToggleButton`'s state is changed. + ### `app` The application. @@ -167,6 +177,16 @@ Update the widget's view storage. - modifiers: The view modifiers. - updateProperties: Whether to update the view's properties. +### `accessibleRole(_:)` + +The accessible role of the given `GtkAccessible` implementation. + +The accessible role cannot be changed once set. + +### `actionName(_:)` + +action-name + ### `active(_:)` If the toggle button should be pressed in. @@ -202,10 +222,6 @@ Text of the label inside the button, if the button contains a label widget. If set, an underline in the text indicates that the following character is to be used as mnemonic. -### `toggled(_:)` - -Emitted whenever the `GtkToggleButton`'s state is changed. - ### `activate(_:)` Emitted to animate press then release. @@ -219,3 +235,7 @@ The default bindings for this signal are all forms of the ### `clicked(_:)` Emitted when the button has been activated (pressed and released). + +### `toggled(_:)` + +Emitted whenever the `GtkToggleButton`'s state is changed. diff --git a/Sources/Adwaita/View/Generated/CheckButton.swift b/Sources/Adwaita/View/Generated/CheckButton.swift index 939973f..c09c214 100644 --- a/Sources/Adwaita/View/Generated/CheckButton.swift +++ b/Sources/Adwaita/View/Generated/CheckButton.swift @@ -131,7 +131,10 @@ public struct CheckButton: Widget { storage.notify(name: "active") { - active?.wrappedValue = gtk_check_button_get_active(storage.pointer?.cast()) != 0 + let newValue = gtk_check_button_get_active(storage.pointer?.cast()) != 0 +if let active, newValue != active.wrappedValue { + active.wrappedValue = newValue +} } for function in appearFunctions { function(storage) @@ -159,8 +162,8 @@ public struct CheckButton: Widget { if let actionName, updateProperties { gtk_actionable_set_action_name(widget, actionName) } - if let active, updateProperties { - gtk_check_button_set_active(widget?.cast(), active.wrappedValue.cBool) + if let active, updateProperties, (gtk_check_button_get_active(storage.pointer?.cast()) != 0) != active.wrappedValue { + gtk_check_button_set_active(storage.pointer?.cast(), active.wrappedValue.cBool) } if let widget = storage.content["child"]?.first { child?().widget(modifiers: modifiers).update(widget, modifiers: modifiers, updateProperties: updateProperties) diff --git a/Sources/Adwaita/View/Generated/ComboRow.swift b/Sources/Adwaita/View/Generated/ComboRow.swift index 8097843..9806fbb 100644 --- a/Sources/Adwaita/View/Generated/ComboRow.swift +++ b/Sources/Adwaita/View/Generated/ComboRow.swift @@ -157,7 +157,10 @@ public struct ComboRow: Widget { storage.content["prefix"] = prefixStorage storage.notify(name: "selected") { - selected?.wrappedValue = .init(adw_combo_row_get_selected(storage.pointer?.cast())) + let newValue = UInt(adw_combo_row_get_selected(storage.pointer?.cast())) +if let selected, newValue != selected.wrappedValue { + selected.wrappedValue = newValue +} } for function in appearFunctions { function(storage) @@ -186,8 +189,8 @@ public struct ComboRow: Widget { if let iconName, updateProperties { adw_action_row_set_icon_name(widget?.cast(), iconName) } - if let selected, updateProperties { - adw_combo_row_set_selected(widget?.cast(), selected.wrappedValue.cInt) + if let selected, updateProperties, (UInt(adw_combo_row_get_selected(storage.pointer?.cast()))) != selected.wrappedValue { + adw_combo_row_set_selected(storage.pointer?.cast(), selected.wrappedValue.cInt) } if let subtitle, updateProperties { adw_action_row_set_subtitle(widget?.cast(), subtitle) diff --git a/Sources/Adwaita/View/Generated/ExpanderRow.swift b/Sources/Adwaita/View/Generated/ExpanderRow.swift index b8ceed9..69c13d2 100644 --- a/Sources/Adwaita/View/Generated/ExpanderRow.swift +++ b/Sources/Adwaita/View/Generated/ExpanderRow.swift @@ -121,10 +121,16 @@ public struct ExpanderRow: Widget { storage.content["prefix"] = prefixStorage storage.notify(name: "enable-expansion") { - enableExpansion?.wrappedValue = adw_expander_row_get_enable_expansion(storage.pointer?.cast()) != 0 + let newValue = adw_expander_row_get_enable_expansion(storage.pointer?.cast()) != 0 +if let enableExpansion, newValue != enableExpansion.wrappedValue { + enableExpansion.wrappedValue = newValue +} } storage.notify(name: "expanded") { - expanded?.wrappedValue = adw_expander_row_get_expanded(storage.pointer?.cast()) != 0 + let newValue = adw_expander_row_get_expanded(storage.pointer?.cast()) != 0 +if let expanded, newValue != expanded.wrappedValue { + expanded.wrappedValue = newValue +} } for function in appearFunctions { function(storage) @@ -139,11 +145,11 @@ public struct ExpanderRow: Widget { /// - updateProperties: Whether to update the view's properties. public func update(_ storage: ViewStorage, modifiers: [(View) -> View], updateProperties: Bool) { storage.modify { widget in - if let enableExpansion, updateProperties { - adw_expander_row_set_enable_expansion(widget?.cast(), enableExpansion.wrappedValue.cBool) + if let enableExpansion, updateProperties, (adw_expander_row_get_enable_expansion(storage.pointer?.cast()) != 0) != enableExpansion.wrappedValue { + adw_expander_row_set_enable_expansion(storage.pointer?.cast(), enableExpansion.wrappedValue.cBool) } - if let expanded, updateProperties { - adw_expander_row_set_expanded(widget?.cast(), expanded.wrappedValue.cBool) + if let expanded, updateProperties, (adw_expander_row_get_expanded(storage.pointer?.cast()) != 0) != expanded.wrappedValue { + adw_expander_row_set_expanded(storage.pointer?.cast(), expanded.wrappedValue.cBool) } if let iconName, updateProperties { adw_expander_row_set_icon_name(widget?.cast(), iconName) diff --git a/Sources/Adwaita/View/Generated/Menu.swift b/Sources/Adwaita/View/Generated/Menu.swift index 3343c1d..d7d511f 100644 --- a/Sources/Adwaita/View/Generated/Menu.swift +++ b/Sources/Adwaita/View/Generated/Menu.swift @@ -140,7 +140,10 @@ public struct Menu: Widget { storage.notify(name: "active") { - active?.wrappedValue = gtk_menu_button_get_active(storage.pointer) != 0 + let newValue = gtk_menu_button_get_active(storage.pointer) != 0 +if let active, newValue != active.wrappedValue { + active.wrappedValue = newValue +} } for function in appearFunctions { function(storage) @@ -160,8 +163,8 @@ public struct Menu: Widget { } } storage.modify { widget in - if let active, updateProperties { - gtk_menu_button_set_active(widget, active.wrappedValue.cBool) + if let active, updateProperties, (gtk_menu_button_get_active(storage.pointer) != 0) != active.wrappedValue { + gtk_menu_button_set_active(storage.pointer, active.wrappedValue.cBool) } if let alwaysShowArrow, updateProperties { gtk_menu_button_set_always_show_arrow(widget, alwaysShowArrow.cBool) diff --git a/Sources/Adwaita/View/Generated/OverlaySplitView.swift b/Sources/Adwaita/View/Generated/OverlaySplitView.swift index 03e4abd..59e6e45 100644 --- a/Sources/Adwaita/View/Generated/OverlaySplitView.swift +++ b/Sources/Adwaita/View/Generated/OverlaySplitView.swift @@ -196,7 +196,10 @@ public struct OverlaySplitView: Widget { storage.notify(name: "show-sidebar") { - showSidebar?.wrappedValue = adw_overlay_split_view_get_show_sidebar(storage.pointer) != 0 + let newValue = adw_overlay_split_view_get_show_sidebar(storage.pointer) != 0 +if let showSidebar, newValue != showSidebar.wrappedValue { + showSidebar.wrappedValue = newValue +} } for function in appearFunctions { function(storage) @@ -232,8 +235,8 @@ public struct OverlaySplitView: Widget { if let pinSidebar, updateProperties { adw_overlay_split_view_set_pin_sidebar(widget, pinSidebar.cBool) } - if let showSidebar, updateProperties { - adw_overlay_split_view_set_show_sidebar(widget, showSidebar.wrappedValue.cBool) + if let showSidebar, updateProperties, (adw_overlay_split_view_get_show_sidebar(storage.pointer) != 0) != showSidebar.wrappedValue { + adw_overlay_split_view_set_show_sidebar(storage.pointer, showSidebar.wrappedValue.cBool) } if let widget = storage.content["sidebar"]?.first { sidebar?().widget(modifiers: modifiers).update(widget, modifiers: modifiers, updateProperties: updateProperties) diff --git a/Sources/Adwaita/View/Generated/SearchEntry.swift b/Sources/Adwaita/View/Generated/SearchEntry.swift index 1645314..f23c24d 100644 --- a/Sources/Adwaita/View/Generated/SearchEntry.swift +++ b/Sources/Adwaita/View/Generated/SearchEntry.swift @@ -172,7 +172,10 @@ public struct SearchEntry: Widget { storage.notify(name: "text") { - text?.wrappedValue = .init(cString: gtk_editable_get_text(storage.pointer)) + let newValue = String(cString: gtk_editable_get_text(storage.pointer)) +if let text, newValue != text.wrappedValue { + text.wrappedValue = newValue +} } for function in appearFunctions { function(storage) @@ -247,8 +250,8 @@ public struct SearchEntry: Widget { if let searchDelay, updateProperties { gtk_search_entry_set_search_delay(widget, searchDelay.cInt) } - if let text, updateProperties { - gtk_editable_set_text(widget, text.wrappedValue) + if let text, updateProperties, (String(cString: gtk_editable_get_text(storage.pointer))) != text.wrappedValue { + gtk_editable_set_text(storage.pointer, text.wrappedValue) } if let widthChars, updateProperties { gtk_editable_set_width_chars(widget, widthChars.cInt) diff --git a/Sources/Adwaita/View/Generated/SpinRow.swift b/Sources/Adwaita/View/Generated/SpinRow.swift index 5cb8e7e..30e8c9d 100644 --- a/Sources/Adwaita/View/Generated/SpinRow.swift +++ b/Sources/Adwaita/View/Generated/SpinRow.swift @@ -149,7 +149,10 @@ public struct SpinRow: Widget { storage.content["prefix"] = prefixStorage storage.notify(name: "value") { - value?.wrappedValue = adw_spin_row_get_value(storage.pointer) + let newValue = adw_spin_row_get_value(storage.pointer) +if let value, newValue != value.wrappedValue { + value.wrappedValue = newValue +} } for function in appearFunctions { function(storage) @@ -226,8 +229,8 @@ public struct SpinRow: Widget { if let useUnderline, updateProperties { adw_preferences_row_set_use_underline(widget?.cast(), useUnderline.cBool) } - if let value, updateProperties { - adw_spin_row_set_value(widget, value.wrappedValue) + if let value, updateProperties, (adw_spin_row_get_value(storage.pointer)) != value.wrappedValue { + adw_spin_row_set_value(storage.pointer, value.wrappedValue) } if let wrap, updateProperties { adw_spin_row_set_wrap(widget, wrap.cBool) diff --git a/Sources/Adwaita/View/Generated/SwitchRow.swift b/Sources/Adwaita/View/Generated/SwitchRow.swift index 1a41e47..aca990c 100644 --- a/Sources/Adwaita/View/Generated/SwitchRow.swift +++ b/Sources/Adwaita/View/Generated/SwitchRow.swift @@ -124,7 +124,10 @@ public struct SwitchRow: Widget { storage.content["prefix"] = prefixStorage storage.notify(name: "active") { - active?.wrappedValue = adw_switch_row_get_active(storage.pointer) != 0 + let newValue = adw_switch_row_get_active(storage.pointer) != 0 +if let active, newValue != active.wrappedValue { + active.wrappedValue = newValue +} } for function in appearFunctions { function(storage) @@ -147,8 +150,8 @@ public struct SwitchRow: Widget { if let widget = storage.content["activatableWidget"]?.first { activatableWidget?().widget(modifiers: modifiers).update(widget, modifiers: modifiers, updateProperties: updateProperties) } - if let active, updateProperties { - adw_switch_row_set_active(widget, active.wrappedValue.cBool) + if let active, updateProperties, (adw_switch_row_get_active(storage.pointer) != 0) != active.wrappedValue { + adw_switch_row_set_active(storage.pointer, active.wrappedValue.cBool) } if let iconName, updateProperties { adw_action_row_set_icon_name(widget?.cast(), iconName) diff --git a/Sources/Adwaita/View/Generated/ToggleButton.swift b/Sources/Adwaita/View/Generated/ToggleButton.swift index cde4adf..ff5d455 100644 --- a/Sources/Adwaita/View/Generated/ToggleButton.swift +++ b/Sources/Adwaita/View/Generated/ToggleButton.swift @@ -151,7 +151,10 @@ public struct ToggleButton: Widget { storage.notify(name: "active") { - active?.wrappedValue = gtk_toggle_button_get_active(storage.pointer?.cast()) != 0 + let newValue = gtk_toggle_button_get_active(storage.pointer?.cast()) != 0 +if let active, newValue != active.wrappedValue { + active.wrappedValue = newValue +} } for function in appearFunctions { function(storage) @@ -184,8 +187,8 @@ public struct ToggleButton: Widget { if let actionName, updateProperties { gtk_actionable_set_action_name(widget, actionName) } - if let active, updateProperties { - gtk_toggle_button_set_active(widget?.cast(), active.wrappedValue.cBool) + if let active, updateProperties, (gtk_toggle_button_get_active(storage.pointer?.cast()) != 0) != active.wrappedValue { + gtk_toggle_button_set_active(storage.pointer?.cast(), active.wrappedValue.cBool) } if let canShrink, updateProperties { gtk_button_set_can_shrink(widget?.cast(), canShrink.cBool) diff --git a/Sources/Generation/GIR/Property.swift b/Sources/Generation/GIR/Property.swift index 1d33e15..2d0a50e 100644 --- a/Sources/Generation/GIR/Property.swift +++ b/Sources/Generation/GIR/Property.swift @@ -151,8 +151,14 @@ struct Property: Decodable { onlySetConditionsEnd = "\n }" } if config.bindings.contains(where: { $0.property == self.name }) { + var check = "" + let widget = (self.cast ?? config.cast) ? "storage.pointer?.cast()" : "storage.pointer" + if var getter { + getter = "\((self.prefix ?? prefix) + "_" + getter)(\(widget))" + check = ", (" + (genConfig.getterTypeConversions[self.type?.name ?? ""]?(getter) ?? getter) + ") != \(name).wrappedValue" + } return """ - if let \(name)\(setConditions), updateProperties { + if let \(name)\(setConditions), updateProperties\(check) { \(setter)(\(widget), \(name).wrappedValue\(propertyString)) } @@ -250,7 +256,12 @@ struct Property: Decodable { getter = "\((self.prefix ?? prefix) + "_" + getter)(\(widget))" let name = convertPropertyName(configuration: genConfig) let finalGetter = genConfig.getterTypeConversions[type?.name ?? ""]?(getter) ?? getter - let setter = "\(name)?.wrappedValue = \(finalGetter)" + let setter = """ + let newValue = \(finalGetter) + if let \(name), newValue != \(name).wrappedValue { + \(name).wrappedValue = newValue + } + """ if let signal { return """ diff --git a/Sources/Generation/GenerationConfiguration.swift b/Sources/Generation/GenerationConfiguration.swift index ce65309..cdffea4 100644 --- a/Sources/Generation/GenerationConfiguration.swift +++ b/Sources/Generation/GenerationConfiguration.swift @@ -285,8 +285,8 @@ struct GenerationConfiguration { /// Modifications for converting a C into a Swift type. var getterTypeConversions: [String: (String) -> String] = [ "gboolean": { "\($0) != 0" }, - "guint": { ".init(\($0))" }, - "utf8": { ".init(cString: \($0))" } + "guint": { "UInt(\($0))" }, + "utf8": { "String(cString: \($0))" } ] }