You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi,
I am trying to generate bindings for gtk-layer-shell with a provided gir file and followed the tutorial 1 but I have a few questions. The code is available at https://github.com/grelltrier/gtk-layer-shell-gir 1
1: I got a bunch of errors when generating the Rust wrapper because of missing macro definitions. When I searched on Github, it seemed as if people just implement those macros themselves and they all looked the same so I just copied them and added the following to my lib.rs :
/// Asserts that this is the main thread and either `gdk::init` or `gtk::init` has been called.
macro_rules! assert_initialized_main_thread {
() => {
if !::gtk::is_initialized_main_thread() {
if ::gtk::is_initialized() {
panic!("GTK may only be used from the main thread.");
} else {
panic!("GTK has not been initialized. Call `gtk::init` first.");
}
}
};
}
/// No-op.
macro_rules! skip_assert_initialized {
() => {};
}
Is that a good idea or should I do something else?
2: When I try building the generated Rust wrapper I get two errors complaining about unresolved imports for each of the generated enums because the enums are defined in enums.rs but functions.rs tries importing them via
use Edge;
use Layer;
This fails but if I replace it with use super::enums::*; I no longer get any errors. Since I can read, I know you are not supposed to edit the generated files :stuck_out_tongue:
How can I generate correct code?
3: Additionally to enums.rs and function.rs a window.rs was generated. I don’t understand this file at all tbh. I don’t get why it is there/needed since I thought I told gir not to worry about Gtk.Window and I do not understand its code. Aside from that there is also a lot of code commented out. The tutorial said to add the types that follow the /Ignored/ to the Gir.toml under manual= []
I tried adding them but nothing changes. In case you’ll have a look at my repository, right now those types are commented out since they did not change anything anyways.
4: Since one of the needed types is Gdk.Monitor I added gdk to the dependencies in the cargo.toml and added features= [“v3_22”]. Then I added extern crate gdk;
Is that the proper way to do this?
All in all I am very impressed by gir and the generated code. Looks really nice and its a lot easier than writing it myself.
Thank you for taking the time to help
The text was updated successfully, but these errors were encountered:
Copy/paste from here:
The text was updated successfully, but these errors were encountered: