// // PreferencesRow.swift // Adwaita // // Created by auto-generation on 19.07.24. // import CAdw import LevenshteinTransformations /// A [class@Gtk.ListBoxRow] used to present preferences. /// /// The `AdwPreferencesRow` widget has a title that [class@PreferencesDialog] /// will use to let the user look for a preference. It doesn't present the title /// in any way and lets you present the preference as you please. /// /// [class@ActionRow] and its derivatives are convenient to use as preference /// rows as they take care of presenting the preference's title while letting you /// compose the inputs of the preference around it. public struct PreferencesRow: Widget { /// Additional update functions for type extensions. var updateFunctions: [(ViewStorage, [(View) -> View], Bool) -> Void] = [] /// Additional appear functions for type extensions. var appearFunctions: [(ViewStorage, [(View) -> View]) -> Void] = [] /// 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`. var title: String? /// Whether the user can copy the title from the label. /// /// See also [property@Gtk.Label:selectable]. var titleSelectable: Bool? /// Whether to use Pango markup for the title label. /// /// Subclasses may also use it for other labels, such as subtitle. /// /// See also [func@Pango.parse_markup]. var useMarkup: Bool? /// Whether an embedded underline in the title indicates a mnemonic. var useUnderline: Bool? /// The application. var app: GTUIApp? /// The window. var window: GTUIApplicationWindow? /// Initialize `PreferencesRow`. public init() { } /// Get the widget's view storage. /// - Parameter modifiers: The view modifiers. /// - Returns: The view storage. public func container(modifiers: [(View) -> View]) -> ViewStorage { let storage = ViewStorage(adw_preferences_row_new()?.opaque()) for function in appearFunctions { function(storage, modifiers) } update(storage, modifiers: modifiers, updateProperties: true) return storage } /// Update the widget's view storage. /// - Parameters: /// - storage: The view storage. /// - modifiers: The view modifiers. /// - updateProperties: Whether to update the view's properties. public func update(_ storage: ViewStorage, modifiers: [(View) -> View], updateProperties: Bool) { storage.modify { widget in if let title, updateProperties { adw_preferences_row_set_title(widget?.cast(), title) } if let titleSelectable, updateProperties { adw_preferences_row_set_title_selectable(widget?.cast(), titleSelectable.cBool) } if let useMarkup, updateProperties { adw_preferences_row_set_use_markup(widget?.cast(), useMarkup.cBool) } if let useUnderline, updateProperties { adw_preferences_row_set_use_underline(widget?.cast(), useUnderline.cBool) } } for function in updateFunctions { function(storage, modifiers, updateProperties) } } /// 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`. public func title(_ title: String?) -> Self { var newSelf = self newSelf.title = title return newSelf } /// Whether the user can copy the title from the label. /// /// See also [property@Gtk.Label:selectable]. public func titleSelectable(_ titleSelectable: Bool? = true) -> Self { var newSelf = self newSelf.titleSelectable = titleSelectable return newSelf } /// Whether to use Pango markup for the title label. /// /// Subclasses may also use it for other labels, such as subtitle. /// /// See also [func@Pango.parse_markup]. public func useMarkup(_ useMarkup: Bool? = true) -> Self { var newSelf = self newSelf.useMarkup = useMarkup return newSelf } /// Whether an embedded underline in the title indicates a mnemonic. public func useUnderline(_ useUnderline: Bool? = true) -> Self { var newSelf = self newSelf.useUnderline = useUnderline return newSelf } }