Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEATURE REQUEST] Improve usability of .css_classes in builders #1224

Closed
hwittenborn opened this issue Dec 18, 2022 · 5 comments
Closed

[FEATURE REQUEST] Improve usability of .css_classes in builders #1224

hwittenborn opened this issue Dec 18, 2022 · 5 comments
Labels
enhancement New feature or request

Comments

@hwittenborn
Copy link

hwittenborn commented Dec 18, 2022

Currently in builders (such as LabelBuilder), css_classes requires a Vec<String>, which is quite annoying to use, with snippets such as these littered throughout my codebase (this isn't an actual example, but it shows the point):

...
.css_classes(vec!["background".to_string(), "error".to_string()])

The fact that I have to run .to_string() really makes it messier. It would be nicer if I could just pass in &str references so I could do this:

...
.css_classes(vec!["background", "error")])

It probably wouldn't be best to just break things though - maybe a Vec<impl ToString> or Vec<impl AsRef<str>> could be passed instead? I just don't really want to have to be typing .to_string() everywhere, and I don't really see any reason why it'd have to stay as such.

@hwittenborn hwittenborn added the enhancement New feature or request label Dec 18, 2022
@hwittenborn
Copy link
Author

hwittenborn commented Dec 18, 2022

On that note, it might be nice to even just accept &[impl AsRef<str>] or something like that so it's not forced to be a vector either. I think it'd be acceptable to convert such into a vector inside of the css_classes function internally if needed.

@bilelmoussaoui
Copy link
Member

See gtk-rs/gir#1122

@bilelmoussaoui
Copy link
Member

Also please check #1110

@hwittenborn
Copy link
Author

Is this just waiting for someone to submit a PR then @bilelmoussaoui? I'd be more than glad to look into it if so

@bilelmoussaoui
Copy link
Member

I would wait until gtk-rs/gir#1417 lands first

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants