Comments (2)
For anyone who runs into this issue, you need to add an explicit dependency on gio to your Cargo.toml, and import gio::prelude::*. The extern crate statements are no longer required in this case when using Rust 2018 edition.
gtk already depends on gio, however it doesn't re-export the crate so it's unavailable unless you explicitly add a dependency in Cargo.toml. The connect_activate() used in the examples is defined in gio::ApplicationExt, and similarly run() is in gio::ApplicationExtManual, which is why this is needed. As noted in https://gtk-rs.org/docs-src/tutorial/gnome_and_rust you need to explicitly import the traits containing various methods you wish to use, which is why this is needed.
It might be a good idea to re-export dependent crates (like gio, gdk, atk, etc) from gtk to avoid having to explicitly specify these libraries in Cargo.toml. rust-qt apparently does this: "Each crate re-exports its dependencies, so, for example, you can access qt_core as qt_widgets::qt_core without adding an explicit dependency." (https://rust-qt.github.io/qt/getting_started/). This would then allow importing gtk::gio::prelude::* in this example without needing the explicit gio dependency in Cargo.toml. In general unless you're writing library code for one of these layers directly I don't think importing them via gtk would really be an issue.
from examples.
Yeah that would happen if @LucasZanella didn't just get rid of the two extern crate
but also the use gio::prelude::*
. That one is required for this to work.
Thanks @sagara- !
from examples.
Related Issues (20)
- Clone_macros doesn't work HOT 7
- Example for GtkSwitcher usage
- could not compile `gtk-rs-examples` HOT 3
- Add an example with mutable state HOT 1
- How to set app menu bar on macOS? HOT 2
- How to display TreeView backed by a Vec of Rust objects HOT 9
- Example of STYLE_CLASS_* constants
- A command-line flags example
- in basic_subclass exmaple, the Private struct is exposed to gtk
- Fatal Crash with Drag and Drop on Mac OS X HOT 3
- windows build error HOT 1
- macOS Details (menu bar + docks)
- MenuBar and Toolbar with Glade and Actions
- MacOS overlay broken
- Come up with a way to handle panics
- Example with multi selection with header rows
- No examples with Popover/PopoverMenu
- Add Glade signal handlers example if applicable HOT 1
- Put DEPRECATION notice in README HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from examples.