diff --git a/Sources/Core/Model/Enumerations/ScrollbarVisibility.swift b/Sources/Core/Model/Enumerations/ScrollbarVisibility.swift new file mode 100644 index 0000000..5998d75 --- /dev/null +++ b/Sources/Core/Model/Enumerations/ScrollbarVisibility.swift @@ -0,0 +1,27 @@ +// +// ContentFit.swift +// Adwaita +// +// Created by david-swift on 19.07.24. +// + +import CAdw + +/// The visibility of a scroll bar. +public enum ScrollbarVisibility: UInt32 { + + /// The scrollbar is always visible. The view size is independent of the content. + case alwaysVisible + /// The scrollbar will appear and disappear as necessary. + case automatic + /// The scrollbar should never appear. In this mode the content determines the size. + case never + /// Don’t show a scrollbar, but don’t force the size to follow the content. + case external + + /// The ScrollbarVisibility value as a GtkPolicyType value. + var gtkValue: GtkPolicyType { + .init(rawValue) + } + +} diff --git a/Sources/Core/View/Generated/ActionRow.swift b/Sources/Core/View/Generated/ActionRow.swift index 860ab88..0c7b263 100644 --- a/Sources/Core/View/Generated/ActionRow.swift +++ b/Sources/Core/View/Generated/ActionRow.swift @@ -211,6 +211,7 @@ public struct ActionRow: AdwaitaWidget { } } + } for function in updateFunctions { function(storage, data, updateProperties) diff --git a/Sources/Core/View/Generated/AspectFrame.swift b/Sources/Core/View/Generated/AspectFrame.swift index f7efb93..ed45889 100644 --- a/Sources/Core/View/Generated/AspectFrame.swift +++ b/Sources/Core/View/Generated/AspectFrame.swift @@ -97,6 +97,7 @@ public struct AspectFrame: AdwaitaWidget { } + } for function in updateFunctions { function(storage, data, updateProperties) diff --git a/Sources/Core/View/Generated/Avatar.swift b/Sources/Core/View/Generated/Avatar.swift index bb3f589..053af53 100644 --- a/Sources/Core/View/Generated/Avatar.swift +++ b/Sources/Core/View/Generated/Avatar.swift @@ -95,6 +95,7 @@ public struct Avatar: AdwaitaWidget { } + } for function in updateFunctions { function(storage, data, updateProperties) diff --git a/Sources/Core/View/Generated/Banner.swift b/Sources/Core/View/Generated/Banner.swift index 5090d66..c021cc1 100644 --- a/Sources/Core/View/Generated/Banner.swift +++ b/Sources/Core/View/Generated/Banner.swift @@ -104,6 +104,7 @@ public struct Banner: AdwaitaWidget { } + } for function in updateFunctions { function(storage, data, updateProperties) diff --git a/Sources/Core/View/Generated/Bin.swift b/Sources/Core/View/Generated/Bin.swift index 8b1514b..41a83da 100644 --- a/Sources/Core/View/Generated/Bin.swift +++ b/Sources/Core/View/Generated/Bin.swift @@ -64,6 +64,7 @@ public struct Bin: AdwaitaWidget { } + } for function in updateFunctions { function(storage, data, updateProperties) diff --git a/Sources/Core/View/Generated/Box.swift b/Sources/Core/View/Generated/Box.swift index d127fc2..26fb88f 100644 --- a/Sources/Core/View/Generated/Box.swift +++ b/Sources/Core/View/Generated/Box.swift @@ -140,6 +140,7 @@ public struct Box: AdwaitaWidget { } } + } for function in updateFunctions { function(storage, data, updateProperties) diff --git a/Sources/Core/View/Generated/Button.swift b/Sources/Core/View/Generated/Button.swift index 45e86f6..efa5d4a 100644 --- a/Sources/Core/View/Generated/Button.swift +++ b/Sources/Core/View/Generated/Button.swift @@ -152,6 +152,7 @@ public struct Button: AdwaitaWidget { } + } for function in updateFunctions { function(storage, data, updateProperties) diff --git a/Sources/Core/View/Generated/ButtonContent.swift b/Sources/Core/View/Generated/ButtonContent.swift index b161d94..4739731 100644 --- a/Sources/Core/View/Generated/ButtonContent.swift +++ b/Sources/Core/View/Generated/ButtonContent.swift @@ -112,6 +112,7 @@ public struct ButtonContent: AdwaitaWidget { } + } for function in updateFunctions { function(storage, data, updateProperties) diff --git a/Sources/Core/View/Generated/Carousel.swift b/Sources/Core/View/Generated/Carousel.swift index fe2942e..edb6b1f 100644 --- a/Sources/Core/View/Generated/Carousel.swift +++ b/Sources/Core/View/Generated/Carousel.swift @@ -144,6 +144,7 @@ public struct Carousel: AdwaitaWidget where Element: Identifiable { for (index, element) in elements.enumerated() { content(element).updateStorage(contentStorage[index], data: data, updateProperties: updateProperties, type: type) } + } for function in updateFunctions { function(storage, data, updateProperties) diff --git a/Sources/Core/View/Generated/CenterBox.swift b/Sources/Core/View/Generated/CenterBox.swift index 34b3ebe..514c94b 100644 --- a/Sources/Core/View/Generated/CenterBox.swift +++ b/Sources/Core/View/Generated/CenterBox.swift @@ -131,6 +131,7 @@ public struct CenterBox: AdwaitaWidget { } + } for function in updateFunctions { function(storage, data, updateProperties) diff --git a/Sources/Core/View/Generated/CheckButton.swift b/Sources/Core/View/Generated/CheckButton.swift index df148a0..20d0c68 100644 --- a/Sources/Core/View/Generated/CheckButton.swift +++ b/Sources/Core/View/Generated/CheckButton.swift @@ -184,6 +184,7 @@ if let active, newValue != active.wrappedValue { } + } for function in updateFunctions { function(storage, data, updateProperties) diff --git a/Sources/Core/View/Generated/Clamp.swift b/Sources/Core/View/Generated/Clamp.swift index 36471bb..bae01f0 100644 --- a/Sources/Core/View/Generated/Clamp.swift +++ b/Sources/Core/View/Generated/Clamp.swift @@ -100,6 +100,7 @@ public struct Clamp: AdwaitaWidget { } + } for function in updateFunctions { function(storage, data, updateProperties) diff --git a/Sources/Core/View/Generated/ComboRow.swift b/Sources/Core/View/Generated/ComboRow.swift index 08bd73d..1e05b05 100644 --- a/Sources/Core/View/Generated/ComboRow.swift +++ b/Sources/Core/View/Generated/ComboRow.swift @@ -215,6 +215,7 @@ if let selected, newValue != selected.wrappedValue { } + } for function in updateFunctions { function(storage, data, updateProperties) diff --git a/Sources/Core/View/Generated/EntryRow.swift b/Sources/Core/View/Generated/EntryRow.swift index fdcce3e..ec09262 100644 --- a/Sources/Core/View/Generated/EntryRow.swift +++ b/Sources/Core/View/Generated/EntryRow.swift @@ -194,6 +194,7 @@ public struct EntryRow: AdwaitaWidget { } } + } for function in updateFunctions { function(storage, data, updateProperties) diff --git a/Sources/Core/View/Generated/ExpanderRow.swift b/Sources/Core/View/Generated/ExpanderRow.swift index a730f80..820f487 100644 --- a/Sources/Core/View/Generated/ExpanderRow.swift +++ b/Sources/Core/View/Generated/ExpanderRow.swift @@ -219,6 +219,7 @@ if let expanded, newValue != expanded.wrappedValue { } } + } for function in updateFunctions { function(storage, data, updateProperties) diff --git a/Sources/Core/View/Generated/Fixed.swift b/Sources/Core/View/Generated/Fixed.swift index e3936f4..94c46b0 100644 --- a/Sources/Core/View/Generated/Fixed.swift +++ b/Sources/Core/View/Generated/Fixed.swift @@ -87,6 +87,7 @@ public struct Fixed: AdwaitaWidget { + } for function in updateFunctions { function(storage, data, updateProperties) diff --git a/Sources/Core/View/Generated/FlowBox.swift b/Sources/Core/View/Generated/FlowBox.swift index 7c5fc8e..9003935 100644 --- a/Sources/Core/View/Generated/FlowBox.swift +++ b/Sources/Core/View/Generated/FlowBox.swift @@ -256,6 +256,7 @@ public struct FlowBox: AdwaitaWidget where Element: Identifiable { for (index, element) in elements.enumerated() { content(element).updateStorage(contentStorage[index], data: data, updateProperties: updateProperties, type: type) } + } for function in updateFunctions { function(storage, data, updateProperties) diff --git a/Sources/Core/View/Generated/HeaderBar.swift b/Sources/Core/View/Generated/HeaderBar.swift index 7ba9c14..109d66e 100644 --- a/Sources/Core/View/Generated/HeaderBar.swift +++ b/Sources/Core/View/Generated/HeaderBar.swift @@ -248,6 +248,7 @@ public struct HeaderBar: AdwaitaWidget { } } + } for function in updateFunctions { function(storage, data, updateProperties) diff --git a/Sources/Core/View/Generated/Label.swift b/Sources/Core/View/Generated/Label.swift index 5e8dd47..66b6d0f 100644 --- a/Sources/Core/View/Generated/Label.swift +++ b/Sources/Core/View/Generated/Label.swift @@ -379,6 +379,7 @@ public struct Label: AdwaitaWidget { } + } for function in updateFunctions { function(storage, data, updateProperties) diff --git a/Sources/Core/View/Generated/LevelBar.swift b/Sources/Core/View/Generated/LevelBar.swift index 7ad17e7..0f2a6a9 100644 --- a/Sources/Core/View/Generated/LevelBar.swift +++ b/Sources/Core/View/Generated/LevelBar.swift @@ -184,6 +184,7 @@ public struct LevelBar: AdwaitaWidget { } + } for function in updateFunctions { function(storage, data, updateProperties) diff --git a/Sources/Core/View/Generated/LinkButton.swift b/Sources/Core/View/Generated/LinkButton.swift index 478591d..83547b0 100644 --- a/Sources/Core/View/Generated/LinkButton.swift +++ b/Sources/Core/View/Generated/LinkButton.swift @@ -168,6 +168,7 @@ public struct LinkButton: AdwaitaWidget { } + } for function in updateFunctions { function(storage, data, updateProperties) diff --git a/Sources/Core/View/Generated/ListBox.swift b/Sources/Core/View/Generated/ListBox.swift index 8b93d7b..2e86c64 100644 --- a/Sources/Core/View/Generated/ListBox.swift +++ b/Sources/Core/View/Generated/ListBox.swift @@ -238,6 +238,7 @@ public struct ListBox: AdwaitaWidget where Element: Identifiable { for (index, element) in elements.enumerated() { content(element).updateStorage(contentStorage[index], data: data, updateProperties: updateProperties, type: type) } + } for function in updateFunctions { function(storage, data, updateProperties) diff --git a/Sources/Core/View/Generated/Menu.swift b/Sources/Core/View/Generated/Menu.swift index c10b7f7..288b144 100644 --- a/Sources/Core/View/Generated/Menu.swift +++ b/Sources/Core/View/Generated/Menu.swift @@ -193,6 +193,7 @@ if let active, newValue != active.wrappedValue { } + } for function in updateFunctions { function(storage, data, updateProperties) diff --git a/Sources/Core/View/Generated/NavigationView.swift b/Sources/Core/View/Generated/NavigationView.swift index 53e6d77..51f53e0 100644 --- a/Sources/Core/View/Generated/NavigationView.swift +++ b/Sources/Core/View/Generated/NavigationView.swift @@ -219,6 +219,7 @@ public struct NavigationView: AdwaitaWidget { } + } for function in updateFunctions { function(storage, data, updateProperties) diff --git a/Sources/Core/View/Generated/Overlay.swift b/Sources/Core/View/Generated/Overlay.swift index ba575b5..e642f1a 100644 --- a/Sources/Core/View/Generated/Overlay.swift +++ b/Sources/Core/View/Generated/Overlay.swift @@ -131,6 +131,7 @@ public struct Overlay: AdwaitaWidget { } } + } for function in updateFunctions { function(storage, data, updateProperties) diff --git a/Sources/Core/View/Generated/OverlaySplitView.swift b/Sources/Core/View/Generated/OverlaySplitView.swift index dbb3450..7d6845f 100644 --- a/Sources/Core/View/Generated/OverlaySplitView.swift +++ b/Sources/Core/View/Generated/OverlaySplitView.swift @@ -245,6 +245,7 @@ if let showSidebar, newValue != showSidebar.wrappedValue { } + } for function in updateFunctions { function(storage, data, updateProperties) diff --git a/Sources/Core/View/Generated/PasswordEntryRow.swift b/Sources/Core/View/Generated/PasswordEntryRow.swift index cbcca02..a245f73 100644 --- a/Sources/Core/View/Generated/PasswordEntryRow.swift +++ b/Sources/Core/View/Generated/PasswordEntryRow.swift @@ -155,6 +155,7 @@ public struct PasswordEntryRow: AdwaitaWidget { } + } for function in updateFunctions { function(storage, data, updateProperties) diff --git a/Sources/Core/View/Generated/Picture.swift b/Sources/Core/View/Generated/Picture.swift index d0b3248..6e0130c 100644 --- a/Sources/Core/View/Generated/Picture.swift +++ b/Sources/Core/View/Generated/Picture.swift @@ -111,6 +111,7 @@ public struct Picture: AdwaitaWidget { } + } for function in updateFunctions { function(storage, data, updateProperties) diff --git a/Sources/Core/View/Generated/Popover.swift b/Sources/Core/View/Generated/Popover.swift index baabf33..1d2c394 100644 --- a/Sources/Core/View/Generated/Popover.swift +++ b/Sources/Core/View/Generated/Popover.swift @@ -179,6 +179,7 @@ public struct Popover: AdwaitaWidget { } + } for function in updateFunctions { function(storage, data, updateProperties) diff --git a/Sources/Core/View/Generated/PreferencesGroup.swift b/Sources/Core/View/Generated/PreferencesGroup.swift index 6462016..e140aa3 100644 --- a/Sources/Core/View/Generated/PreferencesGroup.swift +++ b/Sources/Core/View/Generated/PreferencesGroup.swift @@ -132,6 +132,7 @@ public struct PreferencesGroup: AdwaitaWidget { } } + } for function in updateFunctions { function(storage, data, updateProperties) diff --git a/Sources/Core/View/Generated/PreferencesPage.swift b/Sources/Core/View/Generated/PreferencesPage.swift index 268bd94..57747fe 100644 --- a/Sources/Core/View/Generated/PreferencesPage.swift +++ b/Sources/Core/View/Generated/PreferencesPage.swift @@ -110,6 +110,7 @@ public struct PreferencesPage: AdwaitaWidget { } } + } for function in updateFunctions { function(storage, data, updateProperties) diff --git a/Sources/Core/View/Generated/PreferencesRow.swift b/Sources/Core/View/Generated/PreferencesRow.swift index eaa3929..7d5d36b 100644 --- a/Sources/Core/View/Generated/PreferencesRow.swift +++ b/Sources/Core/View/Generated/PreferencesRow.swift @@ -84,6 +84,7 @@ public struct PreferencesRow: AdwaitaWidget { } + } for function in updateFunctions { function(storage, data, updateProperties) diff --git a/Sources/Core/View/Generated/ProgressBar.swift b/Sources/Core/View/Generated/ProgressBar.swift index 2cae65d..ffe86cd 100644 --- a/Sources/Core/View/Generated/ProgressBar.swift +++ b/Sources/Core/View/Generated/ProgressBar.swift @@ -130,6 +130,7 @@ public struct ProgressBar: AdwaitaWidget { } + } for function in updateFunctions { function(storage, data, updateProperties) diff --git a/Sources/Core/View/Generated/ScrolledWindow.swift b/Sources/Core/View/Generated/ScrolledWindow.swift index f8a76a3..41dfbc6 100644 --- a/Sources/Core/View/Generated/ScrolledWindow.swift +++ b/Sources/Core/View/Generated/ScrolledWindow.swift @@ -101,6 +101,11 @@ public struct ScrolledWindow: AdwaitaWidget { var child: (() -> Body)? /// Whether to draw a frame around the contents. var hasFrame: Bool? + /// When the horizontal scrollbar is displayed. + /// + /// Use [method@Gtk.ScrolledWindow.set_policy] to set + /// this property. + var hscrollbarPolicy: ScrollbarVisibility? /// Whether kinetic scrolling is enabled or not. /// /// Kinetic scrolling only applies to devices with source %GDK_SOURCE_TOUCHSCREEN. @@ -134,6 +139,11 @@ public struct ScrolledWindow: AdwaitaWidget { /// This is useful in cases where an attempt should be made to allocate exactly /// enough space for the natural size of the child. var propagateNaturalWidth: Bool? + /// When the vertical scrollbar is displayed. + /// + /// Use [method@Gtk.ScrolledWindow.set_policy] to set + /// this property. + var vscrollbarPolicy: ScrollbarVisibility? /// Emitted whenever user initiated scrolling makes the scrolled /// window firmly surpass the limits defined by the adjustment /// in that orientation. @@ -255,6 +265,16 @@ public struct ScrolledWindow: AdwaitaWidget { } + +if hscrollbarPolicy != (storage.previousState as? Self)?.hscrollbarPolicy +|| vscrollbarPolicy != (storage.previousState as? Self)?.vscrollbarPolicy { + gtk_scrolled_window_set_policy( + widget, + (hscrollbarPolicy ?? .automatic).gtkValue, + (vscrollbarPolicy ?? .automatic).gtkValue + ) +} + } for function in updateFunctions { function(storage, data, updateProperties) @@ -291,6 +311,16 @@ public struct ScrolledWindow: AdwaitaWidget { return newSelf } + /// When the horizontal scrollbar is displayed. + /// + /// Use [method@Gtk.ScrolledWindow.set_policy] to set + /// this property. + public func hscrollbarPolicy(_ hscrollbarPolicy: ScrollbarVisibility?) -> Self { + var newSelf = self + newSelf.hscrollbarPolicy = hscrollbarPolicy + return newSelf + } + /// Whether kinetic scrolling is enabled or not. /// /// Kinetic scrolling only applies to devices with source %GDK_SOURCE_TOUCHSCREEN. @@ -364,6 +394,16 @@ public struct ScrolledWindow: AdwaitaWidget { return newSelf } + /// When the vertical scrollbar is displayed. + /// + /// Use [method@Gtk.ScrolledWindow.set_policy] to set + /// this property. + public func vscrollbarPolicy(_ vscrollbarPolicy: ScrollbarVisibility?) -> Self { + var newSelf = self + newSelf.vscrollbarPolicy = vscrollbarPolicy + return newSelf + } + /// Emitted whenever user initiated scrolling makes the scrolled /// window firmly surpass the limits defined by the adjustment /// in that orientation. diff --git a/Sources/Core/View/Generated/SearchBar.swift b/Sources/Core/View/Generated/SearchBar.swift index 6f9686b..02c06e2 100644 --- a/Sources/Core/View/Generated/SearchBar.swift +++ b/Sources/Core/View/Generated/SearchBar.swift @@ -128,6 +128,7 @@ public struct SearchBar: AdwaitaWidget { } + } for function in updateFunctions { function(storage, data, updateProperties) diff --git a/Sources/Core/View/Generated/SearchEntry.swift b/Sources/Core/View/Generated/SearchEntry.swift index edde6c6..188bb95 100644 --- a/Sources/Core/View/Generated/SearchEntry.swift +++ b/Sources/Core/View/Generated/SearchEntry.swift @@ -273,6 +273,7 @@ if let text, newValue != text.wrappedValue { } + } for function in updateFunctions { function(storage, data, updateProperties) diff --git a/Sources/Core/View/Generated/Separator.swift b/Sources/Core/View/Generated/Separator.swift index 1b0b7cf..2e61204 100644 --- a/Sources/Core/View/Generated/Separator.swift +++ b/Sources/Core/View/Generated/Separator.swift @@ -66,6 +66,7 @@ public struct Separator: AdwaitaWidget { + } for function in updateFunctions { function(storage, data, updateProperties) diff --git a/Sources/Core/View/Generated/SpinRow.swift b/Sources/Core/View/Generated/SpinRow.swift index 07e78e8..3c22efe 100644 --- a/Sources/Core/View/Generated/SpinRow.swift +++ b/Sources/Core/View/Generated/SpinRow.swift @@ -236,6 +236,7 @@ if let value, newValue != value.wrappedValue { } + } for function in updateFunctions { function(storage, data, updateProperties) diff --git a/Sources/Core/View/Generated/Spinner.swift b/Sources/Core/View/Generated/Spinner.swift index fca619d..f7dcacf 100644 --- a/Sources/Core/View/Generated/Spinner.swift +++ b/Sources/Core/View/Generated/Spinner.swift @@ -70,6 +70,7 @@ public struct Spinner: AdwaitaWidget { + } for function in updateFunctions { function(storage, data, updateProperties) diff --git a/Sources/Core/View/Generated/SplitButton.swift b/Sources/Core/View/Generated/SplitButton.swift index 3ea9248..08d4ea7 100644 --- a/Sources/Core/View/Generated/SplitButton.swift +++ b/Sources/Core/View/Generated/SplitButton.swift @@ -178,6 +178,7 @@ public struct SplitButton: AdwaitaWidget { } + } for function in updateFunctions { function(storage, data, updateProperties) diff --git a/Sources/Core/View/Generated/StatusPage.swift b/Sources/Core/View/Generated/StatusPage.swift index 2f912a0..75599b9 100644 --- a/Sources/Core/View/Generated/StatusPage.swift +++ b/Sources/Core/View/Generated/StatusPage.swift @@ -97,6 +97,7 @@ public struct StatusPage: AdwaitaWidget { } + } for function in updateFunctions { function(storage, data, updateProperties) diff --git a/Sources/Core/View/Generated/SwitchRow.swift b/Sources/Core/View/Generated/SwitchRow.swift index 4ae2bce..68578d7 100644 --- a/Sources/Core/View/Generated/SwitchRow.swift +++ b/Sources/Core/View/Generated/SwitchRow.swift @@ -180,6 +180,7 @@ if let active, newValue != active.wrappedValue { } + } for function in updateFunctions { function(storage, data, updateProperties) diff --git a/Sources/Core/View/Generated/ToastOverlay.swift b/Sources/Core/View/Generated/ToastOverlay.swift index 23811a4..220e2f5 100644 --- a/Sources/Core/View/Generated/ToastOverlay.swift +++ b/Sources/Core/View/Generated/ToastOverlay.swift @@ -91,6 +91,7 @@ public struct ToastOverlay: AdwaitaWidget { } + } for function in updateFunctions { function(storage, data, updateProperties) diff --git a/Sources/Core/View/Generated/ToggleButton.swift b/Sources/Core/View/Generated/ToggleButton.swift index 292eb6a..2c699b3 100644 --- a/Sources/Core/View/Generated/ToggleButton.swift +++ b/Sources/Core/View/Generated/ToggleButton.swift @@ -209,6 +209,7 @@ if let active, newValue != active.wrappedValue { } + } for function in updateFunctions { function(storage, data, updateProperties) diff --git a/Sources/Core/View/Generated/ToolbarView.swift b/Sources/Core/View/Generated/ToolbarView.swift index 8be8983..cbd144f 100644 --- a/Sources/Core/View/Generated/ToolbarView.swift +++ b/Sources/Core/View/Generated/ToolbarView.swift @@ -224,6 +224,7 @@ public struct ToolbarView: AdwaitaWidget { } } + } for function in updateFunctions { function(storage, data, updateProperties) diff --git a/Sources/Core/View/Generated/WindowTitle.swift b/Sources/Core/View/Generated/WindowTitle.swift index c8fd3f7..fc39b85 100644 --- a/Sources/Core/View/Generated/WindowTitle.swift +++ b/Sources/Core/View/Generated/WindowTitle.swift @@ -73,6 +73,7 @@ public struct WindowTitle: AdwaitaWidget { } + } for function in updateFunctions { function(storage, data, updateProperties) diff --git a/Sources/Demo/Demo.swift b/Sources/Demo/Demo.swift index 19da787..b60837d 100644 --- a/Sources/Demo/Demo.swift +++ b/Sources/Demo/Demo.swift @@ -85,11 +85,13 @@ struct Demo: App { ScrollView { List(Page.allCases, selection: $selection) { element in Text(element.label) + .ellipsize() .halign(.start) .padding() } .sidebarStyle() } + .hscrollbarPolicy(.never) .topToolbar { HeaderBar.end { menu diff --git a/Sources/Demo/Page.swift b/Sources/Demo/Page.swift index 61f3807..5aa4f0b 100644 --- a/Sources/Demo/Page.swift +++ b/Sources/Demo/Page.swift @@ -48,7 +48,7 @@ enum Page: String, Identifiable, CaseIterable, Codable, CustomStringConvertible case .alertDialog: return "Alert Dialog" case .passwordChecker: - return "Password Checker" + return "Password Checker is such a long name..." default: return rawValue.capitalized } diff --git a/Sources/Generation/GIR/Class+.swift b/Sources/Generation/GIR/Class+.swift index 4161d6d..8371178 100644 --- a/Sources/Generation/GIR/Class+.swift +++ b/Sources/Generation/GIR/Class+.swift @@ -77,6 +77,15 @@ extension Class { // swiftlint:enable fatal_error } + /// Generate the custom setters. + /// - Parameter config: The widget configuration. + /// - Returns: The code. + func generateManualSetters( + config: WidgetConfiguration + ) -> String { + config.setters.map { "\n\($0)\n" }.joined() + } + /// Generate the assignments for the widgets and menus. /// - Parameters: /// - config: The widget configuration. diff --git a/Sources/Generation/GIR/Class.swift b/Sources/Generation/GIR/Class.swift index 28586ab..9e1a346 100644 --- a/Sources/Generation/GIR/Class.swift +++ b/Sources/Generation/GIR/Class.swift @@ -118,6 +118,7 @@ struct Class: ClassLike, Decodable { \(generateBindingAssignments(config: config, genConfig: genConfig, namespace: namespace, configs: configs)) \(generateModifications(config: config, genConfig: genConfig, namespace: namespace, configs: configs)) \(generateDynamicWidgetUpdate(config: config, genConfig: genConfig)) + \(generateManualSetters(config: config)) } for function in updateFunctions { function(storage, data, updateProperties) diff --git a/Sources/Generation/GenerationConfiguration.swift b/Sources/Generation/GenerationConfiguration.swift index 14f3838..bb5c9d7 100644 --- a/Sources/Generation/GenerationConfiguration.swift +++ b/Sources/Generation/GenerationConfiguration.swift @@ -240,10 +240,20 @@ struct GenerationConfiguration { class: "ScrolledWindow", excludeProperties: [ "hadjustment", - "hscrollbar-policy", "vadjustment", - "vscrollbar-policy", "window-placement" + ], + setters: [ + """ + if hscrollbarPolicy != (storage.previousState as? Self)?.hscrollbarPolicy + || vscrollbarPolicy != (storage.previousState as? Self)?.vscrollbarPolicy { + gtk_scrolled_window_set_policy( + widget, + (hscrollbarPolicy ?? .automatic).gtkValue, + (vscrollbarPolicy ?? .automatic).gtkValue + ) + } + """ ] ), .init(class: "Overlay", staticWidgets: [.init(name: "overlay", add: "gtk_overlay_add_overlay")]), @@ -298,7 +308,8 @@ struct GenerationConfiguration { "GdkPixbuf*": "OpaquePointer", "GdkPaintable*": "OpaquePointer", "NavigationPage": "NavigationPage", - "ContentFit": "ContentFit" + "ContentFit": "ContentFit", + "PolicyType": "ScrollbarVisibility" ] /// Modifications for converting a Swift into a C type. @@ -306,7 +317,8 @@ struct GenerationConfiguration { "Bool": "cBool", "Int": "cInt", "UInt": "cInt", - "ContentFit": "gtkValue" + "ContentFit": "gtkValue", + "ScrollbarVisibility": "gtkValue" ] /// Default values for modifiers with a certain type. diff --git a/Sources/Generation/WidgetConfiguration.swift b/Sources/Generation/WidgetConfiguration.swift index f775116..43a7e22 100644 --- a/Sources/Generation/WidgetConfiguration.swift +++ b/Sources/Generation/WidgetConfiguration.swift @@ -34,6 +34,8 @@ struct WidgetConfiguration { var setConditions: [String: String] = [:] /// Properties that are set in the end of an update. var lastProperties: [String] = [] + /// Manually add setters which do not follow common practices. + var setters: [String] = [] /// The configuration for a binding. struct BindingConfiguration {