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

Add GBinding bindings #349

Merged
merged 3 commits into from Jul 3, 2018

Conversation

Projects
None yet
3 participants
@sdroege
Member

sdroege commented Jul 3, 2018

Kind of ugly because of the autogenerated code that can't be autogenerated due to how gir works :)

Also untested so far, please review carefully. Will report back once I know that it works.

@GuillaumeGomez

This comment has been minimized.

Show comment
Hide comment
@GuillaumeGomez

GuillaumeGomez Jul 3, 2018

Member

Should we split apart GObject and GLib?

Member

GuillaumeGomez commented Jul 3, 2018

Should we split apart GObject and GLib?

@sdroege

This comment has been minimized.

Show comment
Hide comment
@sdroege

sdroege Jul 3, 2018

Member

Should we split apart GObject and GLib?

GLib by itself is rather useless in Rust IMHO, and the code is all entangled (just because of the GType related things already, which are from GObject but used in GLib).

Member

sdroege commented Jul 3, 2018

Should we split apart GObject and GLib?

GLib by itself is rather useless in Rust IMHO, and the code is all entangled (just because of the GType related things already, which are from GObject but used in GLib).

@GuillaumeGomez

This comment has been minimized.

Show comment
Hide comment
@GuillaumeGomez

GuillaumeGomez Jul 3, 2018

Member

Indeed but it's a requirement that we need for the moment. And right now we can't generate two bindings at once if I understand things correctly.

Member

GuillaumeGomez commented Jul 3, 2018

Indeed but it's a requirement that we need for the moment. And right now we can't generate two bindings at once if I understand things correctly.

@sdroege

This comment has been minimized.

Show comment
Hide comment
@sdroege

sdroege Jul 3, 2018

Member

Indeed but it's a requirement that we need for the moment. And right now we can't generate two bindings at once if I understand things correctly.

I would prefer to fix gir so it can output to e.g. src/auto_gobject via some commandline parameter

Member

sdroege commented Jul 3, 2018

Indeed but it's a requirement that we need for the moment. And right now we can't generate two bindings at once if I understand things correctly.

I would prefer to fix gir so it can output to e.g. src/auto_gobject via some commandline parameter

Show outdated Hide outdated src/object.rs

@sdroege sdroege referenced this pull request Jul 3, 2018

Open

Restructuring #337

@EPashkin

This comment has been minimized.

Show comment
Hide comment
@EPashkin

EPashkin Jul 3, 2018

Member

@sdroege I thought that path be src/gobject/auto, this way we can separate manual code too.
But your suggestion also acceptable.

Member

EPashkin commented Jul 3, 2018

@sdroege I thought that path be src/gobject/auto, this way we can separate manual code too.
But your suggestion also acceptable.

@sdroege

This comment has been minimized.

Show comment
Hide comment
@sdroege

sdroege Jul 3, 2018

Member

@sdroege I thought that path be src/gobject/auto, this way we can separate manual code too.
But your suggestion also acceptable.

It just has to be configurable, and more important gir has to create the use statements for GObject like for GLib

Member

sdroege commented Jul 3, 2018

@sdroege I thought that path be src/gobject/auto, this way we can separate manual code too.
But your suggestion also acceptable.

It just has to be configurable, and more important gir has to create the use statements for GObject like for GLib

Show outdated Hide outdated src/object.rs
@sdroege

This comment has been minimized.

Show comment
Hide comment
@sdroege

sdroege Jul 3, 2018

Member

Ok, please review the API if that makes sense to you :) One usage I have here right now is

        item.bind_property("age", &label, "label")
            .flags(glib::BindingFlags::DEFAULT | glib::BindingFlags::SYNC_CREATE)
            .transform_from(|_binding, value| {
                let age = value.get::<u32>().unwrap();
                Some(format!("{}", age).to_value())
            })
            .build();
Member

sdroege commented Jul 3, 2018

Ok, please review the API if that makes sense to you :) One usage I have here right now is

        item.bind_property("age", &label, "label")
            .flags(glib::BindingFlags::DEFAULT | glib::BindingFlags::SYNC_CREATE)
            .transform_from(|_binding, value| {
                let age = value.get::<u32>().unwrap();
                Some(format!("{}", age).to_value())
            })
            .build();
}
}
pub fn flags(self, flags: ::BindingFlags) -> Self {

This comment has been minimized.

@sdroege

sdroege Jul 3, 2018

Member

Instead of this, one could have a fn bidirectional(self) -> Self etc for each of the flags

@sdroege

sdroege Jul 3, 2018

Member

Instead of this, one could have a fn bidirectional(self) -> Self etc for each of the flags

@EPashkin EPashkin referenced this pull request Jul 3, 2018

Merged

Gobject generation #619

@EPashkin

This comment has been minimized.

Show comment
Hide comment
@EPashkin

EPashkin Jul 3, 2018

Member

@sdroege Binding API looks good

Member

EPashkin commented Jul 3, 2018

@sdroege Binding API looks good

@sdroege

This comment has been minimized.

Show comment
Hide comment
@sdroege

sdroege Jul 3, 2018

Member

And autogenerated now

Member

sdroege commented Jul 3, 2018

And autogenerated now

[[object]]
name = "GObject.*"
status = "ignore"

This comment has been minimized.

@EPashkin

EPashkin Jul 3, 2018

Member

In final version this need be status = "generate"

@EPashkin

EPashkin Jul 3, 2018

Member

In final version this need be status = "generate"

This comment has been minimized.

@sdroege

sdroege Jul 3, 2018

Member

Why? I don't care about any of those functions. They can be added when someone needs them :)

And more important, all those that can be autogenerated need manual bindings (and many of them have already, either here or in my gobject-subclass crate)

@sdroege

sdroege Jul 3, 2018

Member

Why? I don't care about any of those functions. They can be added when someone needs them :)

And more important, all those that can be autogenerated need manual bindings (and many of them have already, either here or in my gobject-subclass crate)

This comment has been minimized.

@EPashkin

EPashkin Jul 3, 2018

Member

Ok

@EPashkin
@@ -1051,3 +1060,78 @@ impl<T: IsA<Object> + StaticType + UnsafeFrom<ObjectRef> + Wrapper + ?Sized> Wea
}
}
pub struct BindingBuilder<'a, S: IsA<Object> + 'a, T: IsA<Object> + 'a> {

This comment has been minimized.

@EPashkin

EPashkin Jul 3, 2018

Member

Maybe this better moved to src/gobject/binding_builder.rs

@EPashkin

EPashkin Jul 3, 2018

Member

Maybe this better moved to src/gobject/binding_builder.rs

This comment has been minimized.

@sdroege

sdroege Jul 3, 2018

Member

Ok, will move it later if @GuillaumeGomez has no other comments

@sdroege

sdroege Jul 3, 2018

Member

Ok, will move it later if @GuillaumeGomez has no other comments

@@ -0,0 +1,7 @@
// This file was generated by gir (https://github.com/gtk-rs/gir)

This comment has been minimized.

@GuillaumeGomez

GuillaumeGomez Jul 3, 2018

Member

Is it normal to have this empty file?

@GuillaumeGomez

GuillaumeGomez Jul 3, 2018

Member

Is it normal to have this empty file?

This comment has been minimized.

@sdroege

sdroege Jul 3, 2018

Member

Yes

@sdroege

This comment has been minimized.

@GuillaumeGomez

GuillaumeGomez Jul 3, 2018

Member

Can we not have it if it's useless? :)

@GuillaumeGomez

GuillaumeGomez Jul 3, 2018

Member

Can we not have it if it's useless? :)

This comment has been minimized.

@sdroege

sdroege Jul 3, 2018

Member

Sure, same for flags I guess :) But can we do that in a separate PR, it requires some further gir changes but I can put that on my list then

@sdroege

sdroege Jul 3, 2018

Member

Sure, same for flags I guess :) But can we do that in a separate PR, it requires some further gir changes but I can put that on my list then

This comment has been minimized.

@GuillaumeGomez

GuillaumeGomez Jul 3, 2018

Member

Fine by me!

@GuillaumeGomez

GuillaumeGomez Jul 3, 2018

Member

Fine by me!

@GuillaumeGomez

This comment has been minimized.

Show comment
Hide comment
@GuillaumeGomez

GuillaumeGomez Jul 3, 2018

Member

Thanks!

Member

GuillaumeGomez commented Jul 3, 2018

Thanks!

@GuillaumeGomez GuillaumeGomez merged commit 0ada05a into gtk-rs:master Jul 3, 2018

1 of 2 checks passed

continuous-integration/travis-ci/pr The Travis CI build could not complete due to an error
Details
continuous-integration/appveyor/pr AppVeyor build succeeded
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment