Giter Club home page Giter Club logo

Comments (2)

sagara- avatar sagara- commented on August 21, 2024

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.

sdroege avatar sdroege commented on August 21, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.