owlkettle icon indicating copy to clipboard operation
owlkettle copied to clipboard

Fix or document the usage problems with non-PreferenceRow based Widgets with ExpanderRow

Open PhilippMDoerner opened this issue 7 months ago • 3 comments

For reference: This is a follow up issue that arose during PR #131

We noticed issues when adding Widgets such as "Box" via addRow to an ExpanderRow Widget. That caused runtime issues when trying to remove said Widget. Here a minimal example to reproduce said issue:

import owlkettle, owlkettle/adw

viewable App:
  numbers: seq[int] = @[1,2,3]

method view(app: AppState): Widget =
  result = gui:
    Window:
      ExpanderRow:
        title = "Expander Row"
        
        for index, value in app.numbers:
          Box {.addRow.}:
            Button():
              icon = "user-trash-symbolic"
              style = [ButtonDestructive]
              proc clicked() =
                app.numbers.delete(index)

adw.brew(gui(App()))

Steps to reproduce:

  1. Compile the example
  2. Open the expander row
  3. Click on the delete button - It will not remove the row and instead show this GTK warning in the terminal: Gtk-WARNING **: 19:02:24.292: Tried to remove non-child 0x556e76e45c30

During our discord chats you figured that this piece of GTK code explains said issue - In that they use different adder-procs based on PreferencesRow Widgets.

I don't really understand how that explains the problem, but it did solve it in that using PreferenceRow based Widgets instead (e.g. ActionRow, ComboRow etc.) solves this problem.

We should either fix this (I honestly don't fully understand how we would do such a thing because I don't understand from the beginning what the problem is) or at the absolute minimum we should add docs to ExpanderRow to only use PreferenceRow based Widgets with it.

PhilippMDoerner avatar Nov 09 '23 18:11 PhilippMDoerner