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

gio: more ergonomic ActionEntry initialization #1409

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

allan2
Copy link

@allan2 allan2 commented May 23, 2024

This aligns the initialization with other gio and gtk4 builders.

Before:

ActionEntry::builder("name").build()

Proposed:

ActionEntry::new("name")
ActionEntry::builder().name("name").build()

This aligns the initialization with other `gio` and `gtk4` builders.

Before:
```rs
ActionEntry::builder("name").build()
```

Proposed:
```rs
ActionEntry::new("name")`
ActionEntry::builder().name("name").build()
```

`ActionEntryBuilder` implements `Default` to satisfy Clippy/CI.
@sdroege
Copy link
Member

sdroege commented May 24, 2024

AFAIU the name is mandatory and can't be the empty string, and that's why it is a parameter to the builder constructor.

@bilelmoussaoui
Copy link
Member

AFAIU the name is mandatory and can't be the empty string, and that's why it is a parameter to the builder constructor.

Yes that is the whole reason why. For now, the code generator always generates that pattern for builders but ultimately, once we have a way to know which properties are required, we would generate builder patterns that match them instead of not generating them at all.

@allan2
Copy link
Author

allan2 commented May 25, 2024

That makes sense. It was because I saw UriLauncher::new("myurl") and UriLauncher::builder().uri("myurl").build(), so I wasn't sure whether mandatory parameters should be in the builder call or not.

Could I still implement ActionEntry::new then?

@bilelmoussaoui
Copy link
Member

That makes sense. It was because I saw UriLauncher::new("myurl") and UriLauncher::builder().uri("myurl").build(), so I wasn't sure whether mandatory parameters should be in the builder call or not.

yeah, we have to figure out how to improve those in the future.

Could I still implement ActionEntry::new then?

Sure

@sdroege
Copy link
Member

sdroege commented Jun 17, 2024

What's the plan here?

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

Successfully merging this pull request may close these issues.

3 participants