Update bindings whenever the view updates

This commit is contained in:
david-swift 2024-02-14 16:45:53 +01:00
parent 3a1ca63ef2
commit ffdb727a00
42 changed files with 102 additions and 102 deletions

View File

@ -131,7 +131,6 @@ public struct ActionRow: Widget {
adw_action_row_add_prefix(storage.pointer?.cast(), prefixStorage.last?.pointer?.cast()) adw_action_row_add_prefix(storage.pointer?.cast(), prefixStorage.last?.pointer?.cast())
} }
storage.content["prefix"] = prefixStorage storage.content["prefix"] = prefixStorage
for function in appearFunctions { for function in appearFunctions {
function(storage) function(storage)
} }
@ -150,6 +149,7 @@ public struct ActionRow: Widget {
} }
} }
storage.modify { widget in storage.modify { widget in
if let widget = storage.content["activatableWidget"]?.first { if let widget = storage.content["activatableWidget"]?.first {
activatableWidget?().widget(modifiers: modifiers).update(widget, modifiers: modifiers, updateProperties: updateProperties) activatableWidget?().widget(modifiers: modifiers).update(widget, modifiers: modifiers, updateProperties: updateProperties)
} }

View File

@ -68,7 +68,6 @@ public struct Avatar: Widget {
let storage = ViewStorage(adw_avatar_new(size.cInt, text, showInitials.cBool)?.opaque()) let storage = ViewStorage(adw_avatar_new(size.cInt, text, showInitials.cBool)?.opaque())
update(storage, modifiers: modifiers, updateProperties: true) update(storage, modifiers: modifiers, updateProperties: true)
for function in appearFunctions { for function in appearFunctions {
function(storage) function(storage)
} }
@ -82,6 +81,7 @@ public struct Avatar: Widget {
/// - updateProperties: Whether to update the view's properties. /// - updateProperties: Whether to update the view's properties.
public func update(_ storage: ViewStorage, modifiers: [(View) -> View], updateProperties: Bool) { public func update(_ storage: ViewStorage, modifiers: [(View) -> View], updateProperties: Bool) {
storage.modify { widget in storage.modify { widget in
if let iconName, updateProperties { if let iconName, updateProperties {
adw_avatar_set_icon_name(widget, iconName) adw_avatar_set_icon_name(widget, iconName)
} }

View File

@ -72,7 +72,6 @@ public struct Banner: Widget {
let storage = ViewStorage(adw_banner_new(title)?.opaque()) let storage = ViewStorage(adw_banner_new(title)?.opaque())
update(storage, modifiers: modifiers, updateProperties: true) update(storage, modifiers: modifiers, updateProperties: true)
for function in appearFunctions { for function in appearFunctions {
function(storage) function(storage)
} }
@ -91,6 +90,7 @@ public struct Banner: Widget {
} }
} }
storage.modify { widget in storage.modify { widget in
if let buttonLabel, updateProperties { if let buttonLabel, updateProperties {
adw_banner_set_button_label(widget, buttonLabel) adw_banner_set_button_label(widget, buttonLabel)
} }

View File

@ -46,7 +46,6 @@ public struct Bin: Widget {
adw_bin_set_child(storage.pointer?.cast(), childStorage.pointer?.cast()) adw_bin_set_child(storage.pointer?.cast(), childStorage.pointer?.cast())
} }
for function in appearFunctions { for function in appearFunctions {
function(storage) function(storage)
} }
@ -60,6 +59,7 @@ public struct Bin: Widget {
/// - updateProperties: Whether to update the view's properties. /// - updateProperties: Whether to update the view's properties.
public func update(_ storage: ViewStorage, modifiers: [(View) -> View], updateProperties: Bool) { public func update(_ storage: ViewStorage, modifiers: [(View) -> View], updateProperties: Bool) {
storage.modify { widget in storage.modify { widget in
if let widget = storage.content["child"]?.first { if let widget = storage.content["child"]?.first {
child?().widget(modifiers: modifiers).update(widget, modifiers: modifiers, updateProperties: updateProperties) child?().widget(modifiers: modifiers).update(widget, modifiers: modifiers, updateProperties: updateProperties)
} }

View File

@ -92,7 +92,6 @@ public struct Box: Widget {
gtk_box_prepend(storage.pointer?.cast(), prependStorage.last?.pointer?.cast()) gtk_box_prepend(storage.pointer?.cast(), prependStorage.last?.pointer?.cast())
} }
storage.content["prepend"] = prependStorage storage.content["prepend"] = prependStorage
for function in appearFunctions { for function in appearFunctions {
function(storage) function(storage)
} }
@ -106,6 +105,7 @@ public struct Box: Widget {
/// - updateProperties: Whether to update the view's properties. /// - updateProperties: Whether to update the view's properties.
public func update(_ storage: ViewStorage, modifiers: [(View) -> View], updateProperties: Bool) { public func update(_ storage: ViewStorage, modifiers: [(View) -> View], updateProperties: Bool) {
storage.modify { widget in storage.modify { widget in
if let baselineChild, updateProperties { if let baselineChild, updateProperties {
gtk_box_set_baseline_child(widget?.cast(), baselineChild.cInt) gtk_box_set_baseline_child(widget?.cast(), baselineChild.cInt)
} }

View File

@ -100,7 +100,6 @@ public struct Button: Widget {
gtk_button_set_child(storage.pointer?.cast(), childStorage.pointer?.cast()) gtk_button_set_child(storage.pointer?.cast(), childStorage.pointer?.cast())
} }
for function in appearFunctions { for function in appearFunctions {
function(storage) function(storage)
} }
@ -124,6 +123,7 @@ public struct Button: Widget {
} }
} }
storage.modify { widget in storage.modify { widget in
if let actionName, updateProperties { if let actionName, updateProperties {
gtk_actionable_set_action_name(widget, actionName) gtk_actionable_set_action_name(widget, actionName)
} }

View File

@ -84,7 +84,6 @@ public struct ButtonContent: Widget {
let storage = ViewStorage(adw_button_content_new()?.opaque()) let storage = ViewStorage(adw_button_content_new()?.opaque())
update(storage, modifiers: modifiers, updateProperties: true) update(storage, modifiers: modifiers, updateProperties: true)
for function in appearFunctions { for function in appearFunctions {
function(storage) function(storage)
} }
@ -98,6 +97,7 @@ public struct ButtonContent: Widget {
/// - updateProperties: Whether to update the view's properties. /// - updateProperties: Whether to update the view's properties.
public func update(_ storage: ViewStorage, modifiers: [(View) -> View], updateProperties: Bool) { public func update(_ storage: ViewStorage, modifiers: [(View) -> View], updateProperties: Bool) {
storage.modify { widget in storage.modify { widget in
if let canShrink, updateProperties { if let canShrink, updateProperties {
adw_button_content_set_can_shrink(widget, canShrink.cBool) adw_button_content_set_can_shrink(widget, canShrink.cBool)
} }

View File

@ -81,7 +81,6 @@ public struct Carousel<Element>: Widget where Element: Identifiable {
let storage = ViewStorage(adw_carousel_new()?.opaque()) let storage = ViewStorage(adw_carousel_new()?.opaque())
update(storage, modifiers: modifiers, updateProperties: true) update(storage, modifiers: modifiers, updateProperties: true)
for function in appearFunctions { for function in appearFunctions {
function(storage) function(storage)
} }
@ -100,6 +99,7 @@ public struct Carousel<Element>: Widget where Element: Identifiable {
} }
} }
storage.modify { widget in storage.modify { widget in
if let allowLongSwipes, updateProperties { if let allowLongSwipes, updateProperties {
adw_carousel_set_allow_long_swipes(widget, allowLongSwipes.cBool) adw_carousel_set_allow_long_swipes(widget, allowLongSwipes.cBool)
} }

View File

@ -104,7 +104,6 @@ public struct CenterBox: Widget {
gtk_center_box_set_start_widget(storage.pointer, startWidgetStorage.pointer?.cast()) gtk_center_box_set_start_widget(storage.pointer, startWidgetStorage.pointer?.cast())
} }
for function in appearFunctions { for function in appearFunctions {
function(storage) function(storage)
} }
@ -118,6 +117,7 @@ public struct CenterBox: Widget {
/// - updateProperties: Whether to update the view's properties. /// - updateProperties: Whether to update the view's properties.
public func update(_ storage: ViewStorage, modifiers: [(View) -> View], updateProperties: Bool) { public func update(_ storage: ViewStorage, modifiers: [(View) -> View], updateProperties: Bool) {
storage.modify { widget in storage.modify { widget in
if let widget = storage.content["centerWidget"]?.first { if let widget = storage.content["centerWidget"]?.first {
centerWidget?().widget(modifiers: modifiers).update(widget, modifiers: modifiers, updateProperties: updateProperties) centerWidget?().widget(modifiers: modifiers).update(widget, modifiers: modifiers, updateProperties: updateProperties)
} }

View File

@ -129,13 +129,6 @@ public struct CheckButton: Widget {
gtk_check_button_set_child(storage.pointer?.cast(), childStorage.pointer?.cast()) gtk_check_button_set_child(storage.pointer?.cast(), childStorage.pointer?.cast())
} }
storage.notify(name: "active") {
let newValue = gtk_check_button_get_active(storage.pointer?.cast()) != 0
if let active, newValue != active.wrappedValue {
active.wrappedValue = newValue
}
}
for function in appearFunctions { for function in appearFunctions {
function(storage) function(storage)
} }
@ -159,6 +152,13 @@ if let active, newValue != active.wrappedValue {
} }
} }
storage.modify { widget in storage.modify { widget in
storage.notify(name: "active") {
let newValue = gtk_check_button_get_active(storage.pointer?.cast()) != 0
if let active, newValue != active.wrappedValue {
active.wrappedValue = newValue
}
}
if let actionName, updateProperties { if let actionName, updateProperties {
gtk_actionable_set_action_name(widget, actionName) gtk_actionable_set_action_name(widget, actionName)
} }

View File

@ -74,7 +74,6 @@ public struct Clamp: Widget {
adw_clamp_set_child(storage.pointer, childStorage.pointer?.cast()) adw_clamp_set_child(storage.pointer, childStorage.pointer?.cast())
} }
for function in appearFunctions { for function in appearFunctions {
function(storage) function(storage)
} }
@ -88,6 +87,7 @@ public struct Clamp: Widget {
/// - updateProperties: Whether to update the view's properties. /// - updateProperties: Whether to update the view's properties.
public func update(_ storage: ViewStorage, modifiers: [(View) -> View], updateProperties: Bool) { public func update(_ storage: ViewStorage, modifiers: [(View) -> View], updateProperties: Bool) {
storage.modify { widget in storage.modify { widget in
if let widget = storage.content["child"]?.first { if let widget = storage.content["child"]?.first {
child?().widget(modifiers: modifiers).update(widget, modifiers: modifiers, updateProperties: updateProperties) child?().widget(modifiers: modifiers).update(widget, modifiers: modifiers, updateProperties: updateProperties)
} }

View File

@ -155,13 +155,6 @@ public struct ComboRow: Widget {
adw_action_row_add_prefix(storage.pointer?.cast(), prefixStorage.last?.pointer?.cast()) adw_action_row_add_prefix(storage.pointer?.cast(), prefixStorage.last?.pointer?.cast())
} }
storage.content["prefix"] = prefixStorage storage.content["prefix"] = prefixStorage
storage.notify(name: "selected") {
let newValue = UInt(adw_combo_row_get_selected(storage.pointer?.cast()))
if let selected, newValue != selected.wrappedValue {
selected.wrappedValue = newValue
}
}
for function in appearFunctions { for function in appearFunctions {
function(storage) function(storage)
} }
@ -180,6 +173,13 @@ if let selected, newValue != selected.wrappedValue {
} }
} }
storage.modify { widget in storage.modify { widget in
storage.notify(name: "selected") {
let newValue = UInt(adw_combo_row_get_selected(storage.pointer?.cast()))
if let selected, newValue != selected.wrappedValue {
selected.wrappedValue = newValue
}
}
if let widget = storage.content["activatableWidget"]?.first { if let widget = storage.content["activatableWidget"]?.first {
activatableWidget?().widget(modifiers: modifiers).update(widget, modifiers: modifiers, updateProperties: updateProperties) activatableWidget?().widget(modifiers: modifiers).update(widget, modifiers: modifiers, updateProperties: updateProperties)
} }

View File

@ -117,7 +117,6 @@ public struct EntryRow: Widget {
adw_entry_row_add_prefix(storage.pointer?.cast(), prefixStorage.last?.pointer?.cast()) adw_entry_row_add_prefix(storage.pointer?.cast(), prefixStorage.last?.pointer?.cast())
} }
storage.content["prefix"] = prefixStorage storage.content["prefix"] = prefixStorage
for function in appearFunctions { for function in appearFunctions {
function(storage) function(storage)
} }
@ -141,6 +140,7 @@ public struct EntryRow: Widget {
} }
} }
storage.modify { widget in storage.modify { widget in
if let activatesDefault, updateProperties { if let activatesDefault, updateProperties {
adw_entry_row_set_activates_default(widget?.cast(), activatesDefault.cBool) adw_entry_row_set_activates_default(widget?.cast(), activatesDefault.cBool)
} }

View File

@ -119,19 +119,6 @@ public struct ExpanderRow: Widget {
adw_expander_row_add_prefix(storage.pointer?.cast(), prefixStorage.last?.pointer?.cast()) adw_expander_row_add_prefix(storage.pointer?.cast(), prefixStorage.last?.pointer?.cast())
} }
storage.content["prefix"] = prefixStorage storage.content["prefix"] = prefixStorage
storage.notify(name: "enable-expansion") {
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") {
let newValue = adw_expander_row_get_expanded(storage.pointer?.cast()) != 0
if let expanded, newValue != expanded.wrappedValue {
expanded.wrappedValue = newValue
}
}
for function in appearFunctions { for function in appearFunctions {
function(storage) function(storage)
} }
@ -145,6 +132,19 @@ if let expanded, newValue != expanded.wrappedValue {
/// - updateProperties: Whether to update the view's properties. /// - updateProperties: Whether to update the view's properties.
public func update(_ storage: ViewStorage, modifiers: [(View) -> View], updateProperties: Bool) { public func update(_ storage: ViewStorage, modifiers: [(View) -> View], updateProperties: Bool) {
storage.modify { widget in storage.modify { widget in
storage.notify(name: "enable-expansion") {
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") {
let newValue = adw_expander_row_get_expanded(storage.pointer?.cast()) != 0
if let expanded, newValue != expanded.wrappedValue {
expanded.wrappedValue = newValue
}
}
if let enableExpansion, updateProperties, (adw_expander_row_get_enable_expansion(storage.pointer?.cast()) != 0) != enableExpansion.wrappedValue { 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) adw_expander_row_set_enable_expansion(storage.pointer?.cast(), enableExpansion.wrappedValue.cBool)
} }

View File

@ -156,7 +156,6 @@ public struct FlowBox<Element>: Widget where Element: Identifiable {
let storage = ViewStorage(gtk_flow_box_new()?.opaque()) let storage = ViewStorage(gtk_flow_box_new()?.opaque())
update(storage, modifiers: modifiers, updateProperties: true) update(storage, modifiers: modifiers, updateProperties: true)
for function in appearFunctions { for function in appearFunctions {
function(storage) function(storage)
} }
@ -205,6 +204,7 @@ public struct FlowBox<Element>: Widget where Element: Identifiable {
} }
} }
storage.modify { widget in storage.modify { widget in
if let activateOnSingleClick, updateProperties { if let activateOnSingleClick, updateProperties {
gtk_flow_box_set_activate_on_single_click(widget, activateOnSingleClick.cBool) gtk_flow_box_set_activate_on_single_click(widget, activateOnSingleClick.cBool)
} }

View File

@ -174,7 +174,6 @@ public struct HeaderBar: Widget {
adw_header_bar_pack_end(storage.pointer, endStorage.last?.pointer?.cast()) adw_header_bar_pack_end(storage.pointer, endStorage.last?.pointer?.cast())
} }
storage.content["end"] = endStorage storage.content["end"] = endStorage
for function in appearFunctions { for function in appearFunctions {
function(storage) function(storage)
} }
@ -188,6 +187,7 @@ public struct HeaderBar: Widget {
/// - updateProperties: Whether to update the view's properties. /// - updateProperties: Whether to update the view's properties.
public func update(_ storage: ViewStorage, modifiers: [(View) -> View], updateProperties: Bool) { public func update(_ storage: ViewStorage, modifiers: [(View) -> View], updateProperties: Bool) {
storage.modify { widget in storage.modify { widget in
if let decorationLayout, updateProperties { if let decorationLayout, updateProperties {
adw_header_bar_set_decoration_layout(widget, decorationLayout) adw_header_bar_set_decoration_layout(widget, decorationLayout)
} }

View File

@ -287,7 +287,6 @@ public struct Label: Widget {
gtk_label_set_mnemonic_widget(storage.pointer, mnemonicWidgetStorage.pointer?.cast()) gtk_label_set_mnemonic_widget(storage.pointer, mnemonicWidgetStorage.pointer?.cast())
} }
for function in appearFunctions { for function in appearFunctions {
function(storage) function(storage)
} }
@ -306,6 +305,7 @@ public struct Label: Widget {
} }
} }
storage.modify { widget in storage.modify { widget in
if updateProperties { if updateProperties {
gtk_label_set_label(widget, label) gtk_label_set_label(widget, label)
} }

View File

@ -152,7 +152,6 @@ public struct LevelBar: Widget {
let storage = ViewStorage(gtk_level_bar_new()?.opaque()) let storage = ViewStorage(gtk_level_bar_new()?.opaque())
update(storage, modifiers: modifiers, updateProperties: true) update(storage, modifiers: modifiers, updateProperties: true)
for function in appearFunctions { for function in appearFunctions {
function(storage) function(storage)
} }
@ -171,6 +170,7 @@ public struct LevelBar: Widget {
} }
} }
storage.modify { widget in storage.modify { widget in
if let inverted, updateProperties { if let inverted, updateProperties {
gtk_level_bar_set_inverted(widget, inverted.cBool) gtk_level_bar_set_inverted(widget, inverted.cBool)
} }

View File

@ -103,7 +103,6 @@ public struct LinkButton: Widget {
gtk_button_set_child(storage.pointer?.cast(), childStorage.pointer?.cast()) gtk_button_set_child(storage.pointer?.cast(), childStorage.pointer?.cast())
} }
for function in appearFunctions { for function in appearFunctions {
function(storage) function(storage)
} }
@ -127,6 +126,7 @@ public struct LinkButton: Widget {
} }
} }
storage.modify { widget in storage.modify { widget in
if let actionName, updateProperties { if let actionName, updateProperties {
gtk_actionable_set_action_name(widget, actionName) gtk_actionable_set_action_name(widget, actionName)
} }

View File

@ -133,7 +133,6 @@ public struct ListBox<Element>: Widget where Element: Identifiable {
let storage = ViewStorage(gtk_list_box_new()?.opaque()) let storage = ViewStorage(gtk_list_box_new()?.opaque())
update(storage, modifiers: modifiers, updateProperties: true) update(storage, modifiers: modifiers, updateProperties: true)
for function in appearFunctions { for function in appearFunctions {
function(storage) function(storage)
} }
@ -187,6 +186,7 @@ public struct ListBox<Element>: Widget where Element: Identifiable {
} }
} }
storage.modify { widget in storage.modify { widget in
if let activateOnSingleClick, updateProperties { if let activateOnSingleClick, updateProperties {
gtk_list_box_set_activate_on_single_click(widget, activateOnSingleClick.cBool) gtk_list_box_set_activate_on_single_click(widget, activateOnSingleClick.cBool)
} }

View File

@ -138,13 +138,6 @@ public struct Menu: Widget {
} }
} }
storage.notify(name: "active") {
let newValue = gtk_menu_button_get_active(storage.pointer) != 0
if let active, newValue != active.wrappedValue {
active.wrappedValue = newValue
}
}
for function in appearFunctions { for function in appearFunctions {
function(storage) function(storage)
} }
@ -163,6 +156,13 @@ if let active, newValue != active.wrappedValue {
} }
} }
storage.modify { widget in storage.modify { widget in
storage.notify(name: "active") {
let newValue = gtk_menu_button_get_active(storage.pointer) != 0
if let active, newValue != active.wrappedValue {
active.wrappedValue = newValue
}
}
if let active, updateProperties, (gtk_menu_button_get_active(storage.pointer) != 0) != active.wrappedValue { if let active, updateProperties, (gtk_menu_button_get_active(storage.pointer) != 0) != active.wrappedValue {
gtk_menu_button_set_active(storage.pointer, active.wrappedValue.cBool) gtk_menu_button_set_active(storage.pointer, active.wrappedValue.cBool)
} }

View File

@ -96,7 +96,6 @@ public struct Overlay: Widget {
gtk_overlay_add_overlay(storage.pointer, overlayStorage.last?.pointer?.cast()) gtk_overlay_add_overlay(storage.pointer, overlayStorage.last?.pointer?.cast())
} }
storage.content["overlay"] = overlayStorage storage.content["overlay"] = overlayStorage
for function in appearFunctions { for function in appearFunctions {
function(storage) function(storage)
} }
@ -115,6 +114,7 @@ public struct Overlay: Widget {
} }
} }
storage.modify { widget in storage.modify { widget in
if let widget = storage.content["child"]?.first { if let widget = storage.content["child"]?.first {
child?().widget(modifiers: modifiers).update(widget, modifiers: modifiers, updateProperties: updateProperties) child?().widget(modifiers: modifiers).update(widget, modifiers: modifiers, updateProperties: updateProperties)
} }

View File

@ -194,13 +194,6 @@ public struct OverlaySplitView: Widget {
adw_overlay_split_view_set_sidebar(storage.pointer, sidebarStorage.pointer?.cast()) adw_overlay_split_view_set_sidebar(storage.pointer, sidebarStorage.pointer?.cast())
} }
storage.notify(name: "show-sidebar") {
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 { for function in appearFunctions {
function(storage) function(storage)
} }
@ -214,6 +207,13 @@ if let showSidebar, newValue != showSidebar.wrappedValue {
/// - updateProperties: Whether to update the view's properties. /// - updateProperties: Whether to update the view's properties.
public func update(_ storage: ViewStorage, modifiers: [(View) -> View], updateProperties: Bool) { public func update(_ storage: ViewStorage, modifiers: [(View) -> View], updateProperties: Bool) {
storage.modify { widget in storage.modify { widget in
storage.notify(name: "show-sidebar") {
let newValue = adw_overlay_split_view_get_show_sidebar(storage.pointer) != 0
if let showSidebar, newValue != showSidebar.wrappedValue {
showSidebar.wrappedValue = newValue
}
}
if let collapsed, updateProperties { if let collapsed, updateProperties {
adw_overlay_split_view_set_collapsed(widget, collapsed.cBool) adw_overlay_split_view_set_collapsed(widget, collapsed.cBool)
} }

View File

@ -102,7 +102,6 @@ public struct PasswordEntryRow: Widget {
adw_entry_row_add_prefix(storage.pointer?.cast(), prefixStorage.last?.pointer?.cast()) adw_entry_row_add_prefix(storage.pointer?.cast(), prefixStorage.last?.pointer?.cast())
} }
storage.content["prefix"] = prefixStorage storage.content["prefix"] = prefixStorage
for function in appearFunctions { for function in appearFunctions {
function(storage) function(storage)
} }
@ -126,6 +125,7 @@ public struct PasswordEntryRow: Widget {
} }
} }
storage.modify { widget in storage.modify { widget in
if let activatesDefault, updateProperties { if let activatesDefault, updateProperties {
adw_entry_row_set_activates_default(widget?.cast(), activatesDefault.cBool) adw_entry_row_set_activates_default(widget?.cast(), activatesDefault.cBool)
} }

View File

@ -123,7 +123,6 @@ public struct Popover: Widget {
gtk_popover_set_default_widget(storage.pointer?.cast(), defaultWidgetStorage.pointer?.cast()) gtk_popover_set_default_widget(storage.pointer?.cast(), defaultWidgetStorage.pointer?.cast())
} }
for function in appearFunctions { for function in appearFunctions {
function(storage) function(storage)
} }
@ -147,6 +146,7 @@ public struct Popover: Widget {
} }
} }
storage.modify { widget in storage.modify { widget in
if let autohide, updateProperties { if let autohide, updateProperties {
gtk_popover_set_autohide(widget?.cast(), autohide.cBool) gtk_popover_set_autohide(widget?.cast(), autohide.cBool)
} }

View File

@ -82,7 +82,6 @@ public struct PreferencesGroup: Widget {
adw_preferences_group_add(storage.pointer?.cast(), childStorage.last?.pointer?.cast()) adw_preferences_group_add(storage.pointer?.cast(), childStorage.last?.pointer?.cast())
} }
storage.content["child"] = childStorage storage.content["child"] = childStorage
for function in appearFunctions { for function in appearFunctions {
function(storage) function(storage)
} }
@ -96,6 +95,7 @@ public struct PreferencesGroup: Widget {
/// - updateProperties: Whether to update the view's properties. /// - updateProperties: Whether to update the view's properties.
public func update(_ storage: ViewStorage, modifiers: [(View) -> View], updateProperties: Bool) { public func update(_ storage: ViewStorage, modifiers: [(View) -> View], updateProperties: Bool) {
storage.modify { widget in storage.modify { widget in
if let description, updateProperties { if let description, updateProperties {
adw_preferences_group_set_description(widget?.cast(), description) adw_preferences_group_set_description(widget?.cast(), description)
} }

View File

@ -63,7 +63,6 @@ public struct PreferencesPage: Widget {
adw_preferences_group_add(storage.pointer?.cast(), childStorage.last?.pointer?.cast()) adw_preferences_group_add(storage.pointer?.cast(), childStorage.last?.pointer?.cast())
} }
storage.content["child"] = childStorage storage.content["child"] = childStorage
for function in appearFunctions { for function in appearFunctions {
function(storage) function(storage)
} }
@ -77,6 +76,7 @@ public struct PreferencesPage: Widget {
/// - updateProperties: Whether to update the view's properties. /// - updateProperties: Whether to update the view's properties.
public func update(_ storage: ViewStorage, modifiers: [(View) -> View], updateProperties: Bool) { public func update(_ storage: ViewStorage, modifiers: [(View) -> View], updateProperties: Bool) {
storage.modify { widget in storage.modify { widget in
if let description, updateProperties { if let description, updateProperties {
adw_preferences_page_set_description(widget?.cast(), description) adw_preferences_page_set_description(widget?.cast(), description)
} }

View File

@ -57,7 +57,6 @@ public struct PreferencesRow: Widget {
let storage = ViewStorage(adw_preferences_row_new()?.opaque()) let storage = ViewStorage(adw_preferences_row_new()?.opaque())
update(storage, modifiers: modifiers, updateProperties: true) update(storage, modifiers: modifiers, updateProperties: true)
for function in appearFunctions { for function in appearFunctions {
function(storage) function(storage)
} }
@ -71,6 +70,7 @@ public struct PreferencesRow: Widget {
/// - updateProperties: Whether to update the view's properties. /// - updateProperties: Whether to update the view's properties.
public func update(_ storage: ViewStorage, modifiers: [(View) -> View], updateProperties: Bool) { public func update(_ storage: ViewStorage, modifiers: [(View) -> View], updateProperties: Bool) {
storage.modify { widget in storage.modify { widget in
if let title, updateProperties { if let title, updateProperties {
adw_preferences_row_set_title(widget?.cast(), title) adw_preferences_row_set_title(widget?.cast(), title)
} }

View File

@ -100,7 +100,6 @@ public struct ProgressBar: Widget {
let storage = ViewStorage(gtk_progress_bar_new()?.opaque()) let storage = ViewStorage(gtk_progress_bar_new()?.opaque())
update(storage, modifiers: modifiers, updateProperties: true) update(storage, modifiers: modifiers, updateProperties: true)
for function in appearFunctions { for function in appearFunctions {
function(storage) function(storage)
} }
@ -114,6 +113,7 @@ public struct ProgressBar: Widget {
/// - updateProperties: Whether to update the view's properties. /// - updateProperties: Whether to update the view's properties.
public func update(_ storage: ViewStorage, modifiers: [(View) -> View], updateProperties: Bool) { public func update(_ storage: ViewStorage, modifiers: [(View) -> View], updateProperties: Bool) {
storage.modify { widget in storage.modify { widget in
if let fraction, updateProperties { if let fraction, updateProperties {
gtk_progress_bar_set_fraction(widget, fraction) gtk_progress_bar_set_fraction(widget, fraction)
} }

View File

@ -180,7 +180,6 @@ public struct ScrolledWindow: Widget {
gtk_scrolled_window_set_child(storage.pointer, childStorage.pointer?.cast()) gtk_scrolled_window_set_child(storage.pointer, childStorage.pointer?.cast())
} }
for function in appearFunctions { for function in appearFunctions {
function(storage) function(storage)
} }
@ -214,6 +213,7 @@ public struct ScrolledWindow: Widget {
} }
} }
storage.modify { widget in storage.modify { widget in
if let widget = storage.content["child"]?.first { if let widget = storage.content["child"]?.first {
child?().widget(modifiers: modifiers).update(widget, modifiers: modifiers, updateProperties: updateProperties) child?().widget(modifiers: modifiers).update(widget, modifiers: modifiers, updateProperties: updateProperties)
} }

View File

@ -95,7 +95,6 @@ public struct SearchBar: Widget {
gtk_search_bar_set_key_capture_widget(storage.pointer, keyCaptureWidgetStorage.pointer?.cast()) gtk_search_bar_set_key_capture_widget(storage.pointer, keyCaptureWidgetStorage.pointer?.cast())
} }
for function in appearFunctions { for function in appearFunctions {
function(storage) function(storage)
} }
@ -109,6 +108,7 @@ public struct SearchBar: Widget {
/// - updateProperties: Whether to update the view's properties. /// - updateProperties: Whether to update the view's properties.
public func update(_ storage: ViewStorage, modifiers: [(View) -> View], updateProperties: Bool) { public func update(_ storage: ViewStorage, modifiers: [(View) -> View], updateProperties: Bool) {
storage.modify { widget in storage.modify { widget in
if let widget = storage.content["child"]?.first { if let widget = storage.content["child"]?.first {
child?().widget(modifiers: modifiers).update(widget, modifiers: modifiers, updateProperties: updateProperties) child?().widget(modifiers: modifiers).update(widget, modifiers: modifiers, updateProperties: updateProperties)
} }

View File

@ -170,13 +170,6 @@ public struct SearchEntry: Widget {
let storage = ViewStorage(gtk_search_entry_new()?.opaque()) let storage = ViewStorage(gtk_search_entry_new()?.opaque())
update(storage, modifiers: modifiers, updateProperties: true) update(storage, modifiers: modifiers, updateProperties: true)
storage.notify(name: "text") {
let newValue = String(cString: gtk_editable_get_text(storage.pointer))
if let text, newValue != text.wrappedValue {
text.wrappedValue = newValue
}
}
for function in appearFunctions { for function in appearFunctions {
function(storage) function(storage)
} }
@ -235,6 +228,13 @@ if let text, newValue != text.wrappedValue {
} }
} }
storage.modify { widget in storage.modify { widget in
storage.notify(name: "text") {
let newValue = String(cString: gtk_editable_get_text(storage.pointer))
if let text, newValue != text.wrappedValue {
text.wrappedValue = newValue
}
}
if let editable, updateProperties { if let editable, updateProperties {
gtk_editable_set_editable(widget, editable.cBool) gtk_editable_set_editable(widget, editable.cBool)
} }

View File

@ -147,13 +147,6 @@ public struct SpinRow: Widget {
adw_action_row_add_prefix(storage.pointer?.cast(), prefixStorage.last?.pointer?.cast()) adw_action_row_add_prefix(storage.pointer?.cast(), prefixStorage.last?.pointer?.cast())
} }
storage.content["prefix"] = prefixStorage storage.content["prefix"] = prefixStorage
storage.notify(name: "value") {
let newValue = adw_spin_row_get_value(storage.pointer)
if let value, newValue != value.wrappedValue {
value.wrappedValue = newValue
}
}
for function in appearFunctions { for function in appearFunctions {
function(storage) function(storage)
} }
@ -187,6 +180,13 @@ if let value, newValue != value.wrappedValue {
} }
} }
storage.modify { widget in storage.modify { widget in
storage.notify(name: "value") {
let newValue = adw_spin_row_get_value(storage.pointer)
if let value, newValue != value.wrappedValue {
value.wrappedValue = newValue
}
}
if let widget = storage.content["activatableWidget"]?.first { if let widget = storage.content["activatableWidget"]?.first {
activatableWidget?().widget(modifiers: modifiers).update(widget, modifiers: modifiers, updateProperties: updateProperties) activatableWidget?().widget(modifiers: modifiers).update(widget, modifiers: modifiers, updateProperties: updateProperties)
} }

View File

@ -52,7 +52,6 @@ public struct Spinner: Widget {
let storage = ViewStorage(gtk_spinner_new()?.opaque()) let storage = ViewStorage(gtk_spinner_new()?.opaque())
update(storage, modifiers: modifiers, updateProperties: true) update(storage, modifiers: modifiers, updateProperties: true)
for function in appearFunctions { for function in appearFunctions {
function(storage) function(storage)
} }
@ -66,6 +65,7 @@ public struct Spinner: Widget {
/// - updateProperties: Whether to update the view's properties. /// - updateProperties: Whether to update the view's properties.
public func update(_ storage: ViewStorage, modifiers: [(View) -> View], updateProperties: Bool) { public func update(_ storage: ViewStorage, modifiers: [(View) -> View], updateProperties: Bool) {
storage.modify { widget in storage.modify { widget in
if let spinning, updateProperties { if let spinning, updateProperties {
gtk_spinner_set_spinning(widget, spinning.cBool) gtk_spinner_set_spinning(widget, spinning.cBool)
} }

View File

@ -122,7 +122,6 @@ public struct SplitButton: Widget {
} }
} }
for function in appearFunctions { for function in appearFunctions {
function(storage) function(storage)
} }
@ -146,6 +145,7 @@ public struct SplitButton: Widget {
} }
} }
storage.modify { widget in storage.modify { widget in
if let canShrink, updateProperties { if let canShrink, updateProperties {
adw_split_button_set_can_shrink(widget, canShrink.cBool) adw_split_button_set_can_shrink(widget, canShrink.cBool)
} }

View File

@ -61,7 +61,6 @@ public struct StatusPage: Widget {
adw_status_page_set_child(storage.pointer, childStorage.pointer?.cast()) adw_status_page_set_child(storage.pointer, childStorage.pointer?.cast())
} }
for function in appearFunctions { for function in appearFunctions {
function(storage) function(storage)
} }
@ -75,6 +74,7 @@ public struct StatusPage: Widget {
/// - updateProperties: Whether to update the view's properties. /// - updateProperties: Whether to update the view's properties.
public func update(_ storage: ViewStorage, modifiers: [(View) -> View], updateProperties: Bool) { public func update(_ storage: ViewStorage, modifiers: [(View) -> View], updateProperties: Bool) {
storage.modify { widget in storage.modify { widget in
if let widget = storage.content["child"]?.first { if let widget = storage.content["child"]?.first {
child?().widget(modifiers: modifiers).update(widget, modifiers: modifiers, updateProperties: updateProperties) child?().widget(modifiers: modifiers).update(widget, modifiers: modifiers, updateProperties: updateProperties)
} }

View File

@ -122,13 +122,6 @@ public struct SwitchRow: Widget {
adw_action_row_add_prefix(storage.pointer?.cast(), prefixStorage.last?.pointer?.cast()) adw_action_row_add_prefix(storage.pointer?.cast(), prefixStorage.last?.pointer?.cast())
} }
storage.content["prefix"] = prefixStorage storage.content["prefix"] = prefixStorage
storage.notify(name: "active") {
let newValue = adw_switch_row_get_active(storage.pointer) != 0
if let active, newValue != active.wrappedValue {
active.wrappedValue = newValue
}
}
for function in appearFunctions { for function in appearFunctions {
function(storage) function(storage)
} }
@ -147,6 +140,13 @@ if let active, newValue != active.wrappedValue {
} }
} }
storage.modify { widget in storage.modify { widget in
storage.notify(name: "active") {
let newValue = adw_switch_row_get_active(storage.pointer) != 0
if let active, newValue != active.wrappedValue {
active.wrappedValue = newValue
}
}
if let widget = storage.content["activatableWidget"]?.first { if let widget = storage.content["activatableWidget"]?.first {
activatableWidget?().widget(modifiers: modifiers).update(widget, modifiers: modifiers, updateProperties: updateProperties) activatableWidget?().widget(modifiers: modifiers).update(widget, modifiers: modifiers, updateProperties: updateProperties)
} }

View File

@ -73,7 +73,6 @@ public struct ToastOverlay: Widget {
adw_toast_overlay_set_child(storage.pointer, childStorage.pointer?.cast()) adw_toast_overlay_set_child(storage.pointer, childStorage.pointer?.cast())
} }
for function in appearFunctions { for function in appearFunctions {
function(storage) function(storage)
} }
@ -87,6 +86,7 @@ public struct ToastOverlay: Widget {
/// - updateProperties: Whether to update the view's properties. /// - updateProperties: Whether to update the view's properties.
public func update(_ storage: ViewStorage, modifiers: [(View) -> View], updateProperties: Bool) { public func update(_ storage: ViewStorage, modifiers: [(View) -> View], updateProperties: Bool) {
storage.modify { widget in storage.modify { widget in
if let widget = storage.content["child"]?.first { if let widget = storage.content["child"]?.first {
child?().widget(modifiers: modifiers).update(widget, modifiers: modifiers, updateProperties: updateProperties) child?().widget(modifiers: modifiers).update(widget, modifiers: modifiers, updateProperties: updateProperties)
} }

View File

@ -149,13 +149,6 @@ public struct ToggleButton: Widget {
gtk_button_set_child(storage.pointer?.cast(), childStorage.pointer?.cast()) gtk_button_set_child(storage.pointer?.cast(), childStorage.pointer?.cast())
} }
storage.notify(name: "active") {
let newValue = gtk_toggle_button_get_active(storage.pointer?.cast()) != 0
if let active, newValue != active.wrappedValue {
active.wrappedValue = newValue
}
}
for function in appearFunctions { for function in appearFunctions {
function(storage) function(storage)
} }
@ -184,6 +177,13 @@ if let active, newValue != active.wrappedValue {
} }
} }
storage.modify { widget in storage.modify { widget in
storage.notify(name: "active") {
let newValue = gtk_toggle_button_get_active(storage.pointer?.cast()) != 0
if let active, newValue != active.wrappedValue {
active.wrappedValue = newValue
}
}
if let actionName, updateProperties { if let actionName, updateProperties {
gtk_actionable_set_action_name(widget, actionName) gtk_actionable_set_action_name(widget, actionName)
} }

View File

@ -170,7 +170,6 @@ public struct ToolbarView: Widget {
adw_toolbar_view_add_top_bar(storage.pointer, topStorage.last?.pointer?.cast()) adw_toolbar_view_add_top_bar(storage.pointer, topStorage.last?.pointer?.cast())
} }
storage.content["top"] = topStorage storage.content["top"] = topStorage
for function in appearFunctions { for function in appearFunctions {
function(storage) function(storage)
} }
@ -184,6 +183,7 @@ public struct ToolbarView: Widget {
/// - updateProperties: Whether to update the view's properties. /// - updateProperties: Whether to update the view's properties.
public func update(_ storage: ViewStorage, modifiers: [(View) -> View], updateProperties: Bool) { public func update(_ storage: ViewStorage, modifiers: [(View) -> View], updateProperties: Bool) {
storage.modify { widget in storage.modify { widget in
if let widget = storage.content["content"]?.first { if let widget = storage.content["content"]?.first {
content?().widget(modifiers: modifiers).update(widget, modifiers: modifiers, updateProperties: updateProperties) content?().widget(modifiers: modifiers).update(widget, modifiers: modifiers, updateProperties: updateProperties)
} }

View File

@ -52,7 +52,6 @@ public struct WindowTitle: Widget {
let storage = ViewStorage(adw_window_title_new(title, subtitle)?.opaque()) let storage = ViewStorage(adw_window_title_new(title, subtitle)?.opaque())
update(storage, modifiers: modifiers, updateProperties: true) update(storage, modifiers: modifiers, updateProperties: true)
for function in appearFunctions { for function in appearFunctions {
function(storage) function(storage)
} }
@ -66,6 +65,7 @@ public struct WindowTitle: Widget {
/// - updateProperties: Whether to update the view's properties. /// - updateProperties: Whether to update the view's properties.
public func update(_ storage: ViewStorage, modifiers: [(View) -> View], updateProperties: Bool) { public func update(_ storage: ViewStorage, modifiers: [(View) -> View], updateProperties: Bool) {
storage.modify { widget in storage.modify { widget in
if updateProperties { if updateProperties {
adw_window_title_set_subtitle(widget, subtitle) adw_window_title_set_subtitle(widget, subtitle)
} }

View File

@ -99,7 +99,6 @@ struct Class: ClassLike, Decodable {
let storage = ViewStorage(\(generateInitializer(name: widgetName, config: config, namespace: namespace, configs: configs))?.opaque()) let storage = ViewStorage(\(generateInitializer(name: widgetName, config: config, namespace: namespace, configs: configs))?.opaque())
update(storage, modifiers: modifiers, updateProperties: true) update(storage, modifiers: modifiers, updateProperties: true)
\(generateWidgetAssignments(config: config, genConfig: genConfig, namespace: namespace, configs: configs)) \(generateWidgetAssignments(config: config, genConfig: genConfig, namespace: namespace, configs: configs))
\(generateBindingAssignments(config: config, genConfig: genConfig, namespace: namespace, configs: configs))
for function in appearFunctions { for function in appearFunctions {
function(storage) function(storage)
} }
@ -113,6 +112,7 @@ struct Class: ClassLike, Decodable {
/// - updateProperties: Whether to update the view's properties. /// - updateProperties: Whether to update the view's properties.
public func update(_ storage: ViewStorage, modifiers: [(View) -> View], updateProperties: Bool) {\(generateSignalModifications(config: config, genConfig: genConfig, namespace: namespace)) public func update(_ storage: ViewStorage, modifiers: [(View) -> View], updateProperties: Bool) {\(generateSignalModifications(config: config, genConfig: genConfig, namespace: namespace))
storage.modify { widget in storage.modify { widget in
\(generateBindingAssignments(config: config, genConfig: genConfig, namespace: namespace, configs: configs))
\(generateModifications(config: config, genConfig: genConfig, namespace: namespace, configs: configs)) \(generateModifications(config: config, genConfig: genConfig, namespace: namespace, configs: configs))
\(generateDynamicWidgetUpdate(config: config, genConfig: genConfig)) \(generateDynamicWidgetUpdate(config: config, genConfig: genConfig))
} }