Replies: 4 comments 4 replies
-
I feel like for methods that originally accept an enum, but could be given a string instead for convenience I'd not rename them. I'm not very experinced with type script, but the setters should accept union of type string and the enum. The getters should always return the enum type. This way we have only one method for one function instead of For margin, I think this only effects window right now or? Other widgets do not override gtk margin if I remember correctly? Since you added
|
Beta Was this translation helpful? Give feedback.
-
How about |
Beta Was this translation helpful? Give feedback.
-
Subclass property setters and getters have to follow the parent's signatures These two are incompatible get halign(): Gtk.Align {}
set halign(align: Gtk.Align) {}
get halign(): string {}
set halign(align: string) {} currently the error is just ignored and its overridden anyway, but this leads to this inconsistency const widget = Widget({
halign: 'center' // correctly typed
connections: [
['signal', self => {
self.halign = 'center'; // will warn, because here it expects Gtk.Align
}],
]
});
widget.halign = 'center'; // same warning, it expects Gtk.Align this happens for all 4 properties I listed, and so a rename is needed |
Beta Was this translation helpful? Give feedback.
-
I like both. |
Beta Was this translation helpful? Give feedback.
-
I've had some time on my hands, so I iterated over a few solutions on how the widget subclasses should be implemented.
I have come to the conclusion that properties that are already a Gtk property will have to be renamed in order for typescript to infer everything automatically, to have a better dx, and keep the source code clean
The culprits are
Widget.style
Widget.halign
Widget.valign
Window.margin
What should they be renamed to?
halign
andvalign
could behalignment
orhadjust
.halign
will still work but it will take the original Gtk.Align enummargin
could belayer-margin
ormargins
For
style
I am not sure. How about just removingstyle
and sticking to the already existingcss
? The only difference between the two is just*{ }
three characters anywayBeta Was this translation helpful? Give feedback.
All reactions