gtk4-rs icon indicating copy to clipboard operation
gtk4-rs copied to clipboard

[BUG] Broken EntryCompletion when using builder

Open panicbit opened this issue 3 years ago • 3 comments

Bug description Setting the text_column of an EntryCompletion using its builder instead of using set_text_column causes weird rendering / behavior of popup completion:

EntryCompletion::builder()
    .text_column(0)
    .build();

Changing the entry_completion example accordingly produces this:

image

Additional Information

  • GTK: 4.4
  • OS: Arch Linux

panicbit avatar Jan 08 '22 22:01 panicbit

It seems like gtk_entry_completion_set_text_column does a bit more than simply setting the text-column property (like the builder method does). Apparently my assumption that the builder methods are equivalent to their set_* counterparts is wrong. Is this an intentional design of gtk-rs?

panicbit avatar Jan 08 '22 22:01 panicbit

Normally properties that expect more than a change of the property value should use their setter on the value at https://github.com/GNOME/gtk/blob/50e4ca8593d12b2de76e4d092d34ec7a1655ede8/gtk/gtkentrycompletion.c#L563 but it doesn't seems to be the case for text-column property. So far we have no way to fix this easily other than:

  • Manually write the builder pattern and call the corresponding method if text-column property is set
  • Completely ignore the text-column property, it is blocked by https://github.com/gtk-rs/gir/issues/1302 unless we manually implement the builder pattern
  • Report this upstream and see if it makes sense to call gtk_entry_completion_set_text_column when setting the value of text-column property

bilelmoussaoui avatar Jan 09 '22 07:01 bilelmoussaoui

It seems like gtk_entry_completion_set_text_column does a bit more than simply setting the text-column property (like the builder method does). Apparently my assumption that the builder methods are equivalent to their set_* counterparts is wrong. Is this an intentional design of gtk-rs?

Builders are basically wrappers around calling glib::Object::new and passing the various properties to it with a bit of type safety at compile time. It definitely doesn't call the set_ functions

bilelmoussaoui avatar Jan 25 '22 08:01 bilelmoussaoui

Closing this as it is an upstream issue, setting the property should ideally call the setter instead of modifying the property value.

bilelmoussaoui avatar Oct 08 '22 11:10 bilelmoussaoui