7 ms·
Gtk-rs: The huge and long awaited release is finally here
- msla 9y agoFrom the homepage: > Rust bindings for GTK+ 3, Cairo, GtkSourceView and other GLib-compatible libraries http://gtk-rs.org/ http://gtk-rs.org/
- Scarbutt 9y agoIs Gtk bundle into the final executable?
- brunoqc 9y agoEach example binary is about 3-4 MB when built in release mode and they use the gtk .so files.
- jnbiche 9y agoSo a static build is not possible?
- snuxoll 9y agoGtk+ is complex enough that statically linking libgtk3 isn't going to be enough anyway, there's all sorts of extra resources GTK relies upon beyond the .so that it's rather pointless to even try.
- abrowne 9y agoI've used Quod Libet and Meld, both GTK+ 3 apps, on MacOS by downloading .app bundles, so it must be possible, and maybe desirable on non-Linux(/BSD) platforms.
- tomku 9y agoMac .app bundles are folders, you can have both frameworks and .dylibs inside. Quod Libet, for example, has a whole bin/lib/libexec hierarchy inside its .app with shared Gtk libs, Python, etc.
- abrowne 9y agoAh, of course. I've used "Show Package Contents" enough that I should've realized.
- jnbiche 9y agoHow then are people packaging gtk-rs for Windows? Any idea?
- anfractuosity 9y agoI've just used WiX (http://wixtoolset.org/ http://wixtoolset.org/) to bundle GTKs dlls together with my program. I've not investigated statically linking GTK though.
- gigatexal 9y agoKudos to the collaborators. It seems everything these days is going either Rust or Go.
- kronos29296 9y agoIt's just an echo chamber effect. People still use other languages for their daily stuff. It's just that people want to write their hobby projects and new small work stuff in go or rust. Would take some years for main stream adoption that current popular and established languages enjoy. But rust and go have momentum going for them.
- josteink 9y ago> It seems everything these days is going either Rust or Go. Lots (most?) of things are simply just already built, keep on working and not going anywhere new.
- alphaalpha101 9y agoI think the difference is that Rust and Go projects seem to be posted to HackerNews (and upvoted!) much more than Python and C++ projects are, despite there being way more of the latter.
- anfractuosity 9y agoCongratulations, keep up the good work! I noticed there seems to be a webbrowser widget too, which I'll have to play with. 'Added PDF as a target Surface' that sounds very useful too! I'm just wondering would it be possible to make the gtk widgets copyable, as wouldn't that mean you could remove the clone! macro calls, or am I mistaken there?
- ridiculous_fish 9y agoHow does a pointer-soup toolkit like GTK work with Rust? For example, this code: let button = Button::new_with_label("Click me!"); window.add(&button); button.connect_clicked(|_| { println!("Clicked!"); }); We just mutated the button (connect_clicked) while the window holds a reference to it. Isn't that disallowed in Rust? How do the GTK types interoperate with Rust ownership?
- nialv7 9y agoIn Rust there is this concept called interior mutability. Which allows the user to mutate something through a shared reference (&T). You might want to say "hold on, how can this be safe?" The trick here is that there are runtime checks to make sure only one reference is used for mutation. Oh, did you believe all checks needed to make Rust memory safe is done at compile time? Well that's too bad.
- yorwba 9y agoExcept this isn't guaranteed to be safe, because the implementation [1] just calls GTK in an unsafe block: fn add<P: IsA<Widget>>(&self, widget: &P) { unsafe { ffi::gtk_container_add(self.to_glib_none().0, widget.to_glib_none().0); } } Oh, did you believe that Rust always does checks to ensure memory safety? Well that's too bad. Unsafe blocks are for exactly those situations where the compiler can't prove safety at compile time, giving you an escape hatch to say "this really is safe, I know what I'm doing". There are some runtime-checked abstractions built on this, but they can't help you when interacting with non-Rust code. [1] https://github.com/gtk-rs/gtk/blob/8949ac0304660f53e1fbe28503a970d5d75bae91/src/auto/container.rs#L111 https://github.com/gtk-rs/gtk/blob/8949ac0304660f53e1fbe2850...
- alphaalpha101 9y agoSo given that this isn't actually safe, you can presumably write some code that has undefined behaviour using this library for us?
- josteink 9y agoLooking at the change log, I see they generate a lot of code with a custom tool called "gir": https://github.com/gtk-rs/gir https://github.com/gtk-rs/gir Is it an acronym for something, or is just someone on the team a closet Invader Zim fan? :)
- IronBacon 9y agoWithout looking at the code, considering we are talking about GTK, I would guess it's related to "GObject Introspection".
- deleted 9y ago[deleted]
- gizmo686 9y agoSee https://wiki.gnome.org/Projects/GObjectIntrospection https://wiki.gnome.org/Projects/GObjectIntrospection GIR seems to be the XML format containing GObject introspection data. For what it is worth, the equivelent haskell library (haskell-gi) is composed of two source code directories: GIR and CodeGen. [0] [0] https://github.com/haskell-gi/haskell-gi/tree/master/lib/Data/GI https://github.com/haskell-gi/haskell-gi/tree/master/lib/Dat...
- senatorobama 9y agoCan we come up with something other than GObject/GTK? :(. I want a cross platform GUI that looks native.