portico/Sources/Portico/Extensions/ListBox+Extras.swift

86 lines
No EOL
3.6 KiB
Swift

import Gtk
extension WidgetView where Target: Gtk.ListBox {
/// Applies the `.boxed-list` style class.
///
/// Boxed-list appearance; the list box should have `selectionMode(.none)`.
///
/// - Parameter enabled: Whether the style class is applied.
/// - Returns: A copy of this view with the modifier applied.
public func boxedList(_ enabled: Bool = true) -> Self {
styleClass("boxed-list", enabled)
}
/// Applies the `.boxed-list` style class.
///
/// Boxed-list appearance; the list box should have `selectionMode(.none)`.
///
/// - Parameter enabled: A binding that controls whether the class is applied.
/// - Returns: A copy of this view with the modifier applied.
public func boxedList(_ enabled: Binding<Bool>) -> Self {
styleClass("boxed-list", enabled)
}
/// Applies the `.boxed-list-separate` style class.
///
/// Like ``boxedList`` but each row is a separate card instead of one card with separators; also expects `selectionMode(.none)`.
///
/// - Parameter enabled: Whether the style class is applied.
/// - Returns: A copy of this view with the modifier applied.
public func boxedListSeparate(_ enabled: Bool = true) -> Self {
styleClass("boxed-list-separate", enabled)
}
/// Applies the `.boxed-list-separate` style class.
///
/// Like ``boxedList`` but each row is a separate card instead of one card with separators; also expects `selectionMode(.none)`.
///
/// - Parameter enabled: A binding that controls whether the class is applied.
/// - Returns: A copy of this view with the modifier applied.
public func boxedListSeparate(_ enabled: Binding<Bool>) -> Self {
styleClass("boxed-list-separate", enabled)
}
/// Applies the `.navigation-sidebar` style class.
///
/// Sidebar look: rounded padded items, neutral (not accent) selection color, no default list background. Available on `Gtk.ListBox`, `Gtk.ListView`, `Gtk.FlowBox` and `Gtk.GridView`.
///
/// - Parameter enabled: Whether the style class is applied.
/// - Returns: A copy of this view with the modifier applied.
public func navigationSidebar(_ enabled: Bool = true) -> Self {
styleClass("navigation-sidebar", enabled)
}
/// Applies the `.navigation-sidebar` style class.
///
/// Sidebar look: rounded padded items, neutral (not accent) selection color, no default list background. Available on `Gtk.ListBox`, `Gtk.ListView`, `Gtk.FlowBox` and `Gtk.GridView`.
///
/// - Parameter enabled: A binding that controls whether the class is applied.
/// - Returns: A copy of this view with the modifier applied.
public func navigationSidebar(_ enabled: Binding<Bool>) -> Self {
styleClass("navigation-sidebar", enabled)
}
/// Applies the `.content` style class.
///
/// Deprecated version of ``boxedList``.
///
/// - Parameter enabled: Whether the style class is applied.
/// - Returns: A copy of this view with the modifier applied.
@available(*, deprecated, message: "Deprecated by libadwaita. Use boxedList() instead.")
public func content(_ enabled: Bool = true) -> Self {
styleClass("content", enabled)
}
/// Applies the `.content` style class.
///
/// Deprecated version of ``boxedList``.
///
/// - Parameter enabled: A binding that controls whether the class is applied.
/// - Returns: A copy of this view with the modifier applied.
@available(*, deprecated, message: "Deprecated by libadwaita. Use boxedList() instead.")
public func content(_ enabled: Binding<Bool>) -> Self {
styleClass("content", enabled)
}
}