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] properties macro: automatically prepend is_ on generated getter functions on bool properties #993

Closed
SeaDve opened this issue Feb 14, 2023 · 10 comments
Labels
enhancement New feature or request

Comments

@SeaDve
Copy link
Contributor

SeaDve commented Feb 14, 2023

I believe it makes it more consistent with the generated bindings and it sounds more natural.

Example:

mod imp {
    #[derive(glib::Properties, Default)]
    #[properties(wrapper_type = super::Item)]
    pub struct Item {
        #[property(get, set)]
        pub(super) new: Cell<bool>,
    }

    ...
}

...

should have a generated getter of obj.is_new() instead of just obj.new().

@SeaDve SeaDve added the enhancement New feature or request label Feb 14, 2023
@sdroege
Copy link
Member

sdroege commented Feb 14, 2023

Why don't you name you property is-new then? As you say, that sounds much more natural :)

@SeaDve
Copy link
Contributor Author

SeaDve commented Feb 14, 2023

I keep it consistent with how the bindings handle bool properties like sensitive and visible, where the property name does not have is- prefix, but the getter function do. Not a big deal, but maybe something to consider.

@bilelmoussaoui
Copy link
Member

I keep it consistent with how the bindings handle bool properties like sensitive and visible, where the property name does not have is- prefix, but the getter function do. Not a big deal, but maybe something to consider.

Right, except those are part of the C API that is being adapted to Rust

@sdroege
Copy link
Member

sdroege commented Feb 14, 2023

There's also a lot of C API that prefixes the property names. is- has- etc.

@SeaDve
Copy link
Contributor Author

SeaDve commented Feb 14, 2023

I guess it is not worth it then to make the macro more complex just for this, I think I'll close this

@yuraiz
Copy link
Contributor

yuraiz commented Mar 27, 2023

I want to have loop property to be consistent with gtk::MediaStream, but I can't use it with Properties macro
I suggest to allow getter and setter renaming

@yuraiz
Copy link
Contributor

yuraiz commented Mar 27, 2023

Or it's possible to use is or has keywords instead of get

@bilelmoussaoui
Copy link
Member

Or it's possible to use is or has keywords instead of get

No. Please name your properties as wish them to be named. Regarding naming your property as loop, see #1067

@yuraiz
Copy link
Contributor

yuraiz commented Mar 27, 2023

But I want setter to have normal name set_loop

@yuraiz
Copy link
Contributor

yuraiz commented Mar 27, 2023

is prefix is used for many places in standart library: https://doc.rust-lang.org/std/?search=is_

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

4 participants