gtk-rs/gtk

Documentation: Suggested update to example on gtk-rs.org front page

ndearns opened this issue · 6 comments

I added gtk and gio to my toml file and tried to compile the standard cargo new hello world program, but this gave me a slew of errors in the build process, missing atk, pango, etc.

These were all resolved when I ran:

sudo apt-get install libgtk-3-dev

Can I suggest that this is added to gtk-rs.org home page? I nearly gave up on trying to use the gtk package because of that stumbling block, and I imagine that many people do. Telling them how to install all the missing dependencies might encourage more of them to stick with it.

You mean like https://gtk-rs.org/#using (which is the home of gtk-rs.org)?

Yes, that's the page.

I'm trying to work through the tutorials. It is very difficult.

Can I suggest a golden rule for tutorial examples?

All tutorial examples should be complete and executable

I'm newish to rust and have never used gtk before. I'm finding that the tutorial snippets do not work.

For example, when I try the casting example for Widgets I get this:

Compiling gtk_play v0.1.0 (/home/neilearnshaw/rust/gtk_play)
error[E0432]: unresolved import gtk::Object
--> src/main.rs:8:11
|
8 | use gtk::{Object, Box, Application, ApplicationWindow, Button};
| ^^^^^^ no Object in the root

error[E0412]: cannot find type Object in crate gtk
--> src/main.rs:44:21
|
44 | fn is_a<W: IsAgtk::Object + IsAgtk::Widget + Clone,
| ^^^^^^ not found in gtk
|
help: there is an enum variant gio::FileAttributeType::Object; try using the variant's enum
|
44 | fn is_a<W: IsAgio::FileAttributeType + IsAgtk::Widget + Clone,
| ^^^^^^^^^^^^^^^^^^^^^^

error[E0412]: cannot find type Object in crate gtk
--> src/main.rs:45:21
|

etc.

I would guess that you are very experienced with rust/gtk, but for people who aren't... it's things like this that make you want to go back to languages/guis that you know work. : (

Just with rust. For gtk, I mainly refer to the C documentation. If we added full examples every time, it'd be just too big...

Ha, ha, the 'rust' example in this page (https://gtk-rs.org/docs/gtk/struct.ApplicationWindow.html) is written in C:

image

Hmm, after three weeks of trying to get a working rust/gui combination together, I'm giving up. I'll come back in five years to see if rust is ready for real-world use. Thanks for your help, Guillamme and, Good Luck!

Oh that's a shame... Did you look at the examples?