-
-
Notifications
You must be signed in to change notification settings - Fork 62
Conversation
I don't get what you want to do. If the function |
I was expecting it to be used soon. If you want the whole thing at once, that's allright too... |
I'd prefer, otherwise it doesn't make sense. If didn't comment all unused functions, the only we'd have to know they're not binded would be with rust compiler warnings. Not very wonderful... I'll let this PR open. When you have binded the function, please notify me. Thanks in advance ! =D |
I don't see anything wrong with having unused definitions in the sys crates (as long as they're correct). Here, Rust is capable of expressing the |
@gkoz: It's mostly to avoid warnings and make easier the future bindings. Otherwise, we could just uncomment all the non-binded functions and say it's fine. Or maybe I didn't understand the point here ? |
There hardly can be such thing as an unused published member of a library, so there won't be any warnings. Uncommenting everything wholesale would be problematic because someone has to review the definitions so it makes sense to avoid that effort while there's no need for it. |
Hum... Okay. But then why not providing directly the binding for this function ? That's where I'm lost. |
I'll try to add the binding. @gkoz Regarding |
@vojtechkral: It was to avoid boring stuff haha (super explanation !). It was a (successfull) test I made, I wanted to do the same with a closure but for now there is an ICE in rust for it and I didn't try to avoid it (I'm working on cairo's documentation and rustdoc). For me, it's totally fine, it allows to avoid annoying stuff but I'm not sure that's the best solution... I'll dig to find more information. |
This is why we shouldn't be committing hacks. People try to stay consistent with the hacks, leading to more hacks. |
Well, that's not really a hack. |
Ok, I added a binding. Using only a Here's code I used to test the thing: https://gist.github.com/vojtechkral/ea7112bff8eaff0d0ff2 |
"to test the thing". It sounds very scary that way haha. Thanks a lot for your work ! I wait for travis and appveyor's confirmation and I merge. |
Wait wait I don't think this is ready to merge yet, there's a commented-out function header with closure which I'm not sure what to do about yet. A version with only a |
If you manage to make work a closure by passing it as a pointer, it could be nice. You can try if you feel like it. ;-) |
You want |
Right, thanks. I'll have a look at how the signal closures are done... |
@gkoz In the gtk signals.rs, I don't understand how |
Note also how the event handlers return the |
The closures are passed as |
Okay, I think I get it, will try to implement... |
This is the code so far. Problem is if I try to use the
in the trampoline function. PS. I'll add a proper return type later. |
That's weird but can be sidestepped by using the |
It works now, yay :-) In the future, |
|
||
//! callback idle functions | ||
|
||
pub mod idle { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This nested module seems redundant.
unsafe { | ||
// Box::from_raw API stability workaround | ||
let ptr = ptr as *mut RefCell<Box<FnMut() -> Continue + 'static>>; | ||
let _: Box<RefCell<Box<FnMut() -> Continue + 'static>>> = ::std::mem::transmute(ptr); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're importing transmute already so the full path isn't needed.
We might take a moment to think how this and the timeout functions will work together, the implications for the module name so we don't have to rename it ina week. |
Sure, by all means. |
One way to approach this could be to name the module |
@gkoz: Isn't it possible to just move every non method function in a global namespace (like source if you want) ? It could be nice to give an easy access to "global" gtk functions. |
@GuillaumeGomez This is mostly about the internal organization. I don't mind reexports in the topmost namespace. I've come to believe that the flat namespace is a necessary evil after all, because that's what other language bindings do and it's very hard to design some structure that will make sense from all points of view. The module might not even be public. |
@gkoz: My bad, I thought you wanted to create a file and a namespace for each type of global gtk function. It seemed a bit too much for me. Splitting these functions inside modules is good, we'll just reexport them as one. I don't think the flat namespace is "evil". However, if you have a better solution in mind, I'd be glad to know it ! ;-) |
My current preference is that the types and functions a user might need would be reexported at the top. (This will likely mean that the constants will have long names with just The traits and some essential types would put into |
Yes, that's what I meant. I think we don't understand each other on this. Nevermind haha. |
Naming the module Just my two cents |
They call it Oh, sorry, there is a |
I can convert the idle module + I suppose the timeout module to the flat model, but I reckon the scope of this PR shouldn't be broader than that right? |
Yeah, the |
Ok, done. Test code also updated. Hope everything's ok. edit: Sorry for typo in commit msg... |
} | ||
|
||
const G_PRIORITY_DEFAULT: i32 = 0; | ||
const G_PRIORITY_DEFAULT_IDLE: i32 = 200; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We drop the G
and similar prefixes everywhere.
/// | ||
/// # Examples | ||
/// | ||
/// ``` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you also please mark the examples with ignore
so cargo test
won't complain that they don't compile (or alternatively make them compile)?
http://doc.rust-lang.org/book/documentation.html#running-documentation-tests
Ok, I've added |
Good job, thanks! |
@gkoz: Pong ! Thanks for taking care of this PR too ! |
@gkoz Out of curiosity, what was the reason for the |
@vojtechkral We pass the ownership of the closure to the library, its lifetime is outside our control, it could outlive everything. There are ways like this to make some lifetime guarantees, but they're not terribly ergonomic either. |
@gkoz Okay, thanks! |
No description provided.