GithubHelp home page GithubHelp logo

gtk-rs.github.io's Introduction

gtk3-rs CI

This project is UNMAINTAINED. Please take a look at gtk4-rs instead!

The gtk-rs organization aims to provide safe Rust binding over GObject-based libraries. You can find more about it on https://gtk-rs.org.

This repository contains all the "core" crates of the gtk-rs organization. For more information about each crate, please refer to their README.md file in their directory.

Minimum supported Rust version

Currently, the minimum supported Rust version is 1.70.0.

Documentation

Ecosystem

The gtk3-rs repository contains Rust crates for GTK 3. However there is a large ecosystem of GObject libraries and many of these libraries have Rust bindings based on the tooling included in gtk-rs. Of particular note:

  • gtk-rs-core - bindings for some of the core libraries such as glib, gio, pango, graphene
  • gstreamer-rs - bindings for the GStreamer media framework

Additionally, Rust bindings for various libraries are hosted on GNOME's GitLab instance and can be found at https://gitlab.gnome.org/World/Rust.

When using crates that are not part of the gtk-rs repository, you will need to be careful and ensure that they do not pull in incompatible versions of core crates like glib-rs.

Regenerating

To regenerate crates using gir, please use the generator.py file as follows:

$ python3 generator.py

If you didn't do so yet, please check out all the submodules before via

$ git submodule update --checkout

Development

This repository is mostly split into two branches: master and crate. master contains the not yet released code and is where new developments are happening. crate contains the last release source code and isn't supposed to be updated.

This repository is structured as follows:

- crate/
   |
   |-- README.md
   |-- Gir.toml
   |-- Cargo.toml
   |-- src/
   |-- sys/

The crate is a "top" directory (so "atk" or "gdk" in here for example). Each crate contains:

  • README.md: explanations about the crate itself and eventually some details.
  • Cargo.toml: descriptor of the crate, used by cargo and Rust.
  • Gir.toml: configuration used by gir to generate most of the crates' code.
  • src: the source code of the crate.
  • sys: the 1:1 bindings of the C API.

The gir and gir-files top folders are not crates, but are git submodules which respectively contain the gir tool and the gir files used by the generator.

When running generator.py the tool will automatically update these git submodules and run the gir tool on the gir files to regenerate the code.

During development, it is useful to execute the generator with a different version of the gir tool or of the gir files, for instance to test if the code generation is successful before submitting a pull request to update one of the submodules. This can be done by specifying arguments to the generator script, for instance, to run the generator on a local copy of the gir files:

$ python3 generator.py --gir-files-directory ../gir-files/

See python3 generator.py --help for more details.

gtk-rs.github.io's People

Contributors

aaronerhardt avatar afranke avatar alatiera avatar antoniocorbibellot avatar b-ncmn avatar bilelmoussaoui avatar cogitri avatar deikatsuo avatar dns2utf8 avatar emmanueltouzery avatar epashkin avatar etrombly avatar fengalin avatar gkoz avatar grantshandy avatar guillaumegomez avatar gwutz avatar hfiguiere avatar hofer-julian avatar hwittenborn avatar ketsuban avatar lucab avatar martinber avatar mmstick avatar piegamesde avatar plowpath avatar sdroege avatar sophie-h avatar sprang avatar tglman avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

gtk-rs.github.io's Issues

Logo

At this point, I think we should make a logo (nothing fancy). If anyone has a proposition, please feel free to do so! :)

cc @gtk-rs/collaborators

Website organization

The website has lots of useful information, but I found it a little hard to navigate, so I'm suggesting some changes.

Right now the locations of every piece of documentation of gtk-rs I could find is:

Site map

Changes I suggest

If you think it's a good idea I'm going to work on these changes

  • Move /docs-src/tutorial to /docs-src/tutorial/index and move /tuto/* to /docs-src/tutorial/.

  • In the tutorials page I find it odd that the links to rust_and_gtk and gnome_and_rust are tutorials just like the ones in the list below. I think that every tutorial should be in some sort of list.

  • Below each tutorial there are links to the next tutorial, previous tutorial and the summary but it needs some kind of indication of that. Also it would be better if the links were not hardcoded inside each .md file. Can be solved when this new merged Jekyll feature is released

  • I found that the examples are good tutorials, also that "Projects using gtk-rs" are good examples too.

  • I think that the instructions about how to add the dependencies to Cargo.toml are on too many places:

    I would remove that brief introduction from /docs-src/index and maybe merge the rust_and_gtk and version tutorial too.

  • I don't know the purpose of the /docs page and the docs repository

Link to further resources below homepage example

I just got Hello World to work on Windows - awesome! Afterwards I looked at the homepage below the example, expecting to find further learning resources. Sadly, I didn't find any.

I think we should probably put a link to the Tutorial there. This would create a nice flow for new users: They start with a simple example and are then guided to the next learning steps.

gtk-rs links to docs-src

Go to the website, click Gtk-rs documentation, click gtk, error 404.
As I understand, it should just link to http://gtk-rs.org/docs/ like everywhere else.

Changes for next version after gtk 0.1.3

Added https://github.com/gtk-rs/sourceview

Fix object properties
gtk-rs/gtk#507
gtk-rs/gio#25

Generate *Ext traits by default and allow disabling them instead (by @sdroege)
gtk-rs/gir#364
gtk-rs/gtk#509
gtk-rs/pango#70
gtk-rs/pango#71
gtk-rs/gio#26

gtk-rs/glib#167 Use g_object_ref_sink() instead of g_object_ref() everywhere (by @sdroege)

Generate global function
gtk-rs/gir#371 (by @sdroege)
gtk-rs/gtk#510
gtk-rs/gtk#512
gtk-rs/gdk#164
gtk-rs/gdk#165
gtk-rs/pango#72
gtk-rs/pango#73
gtk-rs/gio#27
gtk-rs/gio#28
gtk-rs/gio#30
gtk-rs/glib#170

gtk-rs/pango#71 fix xcb features (by @charlesvdv)
gtk-rs/pango#75 Generate Coverage and Renderer structs
gtk-rs/pango#81 add Color generation
gtk-rs/pango#82 Generate new types
gtk-rs/pango#84 Added AttrList
gtk-rs/gtk#541 Use more pango objects

Add glib::BoolError for use as return value of possibly failing functions returning booleans (by @sdroege)
gtk-rs/glib#169
gtk-rs/glib#179
gtk-rs/gtk#523

gtk-rs/glib#171 Add Windows implementations for g_setenv, g_getenv, g_unsetenv and g_get_current_dir (by @sdroege)
gtk-rs/glib#172 Implement FromGlibPtrNone and FromGlibPtrFull for Value (by @sdroege)
gtk-rs/glib#194 Initial GMainLoop/GMainContext bindings (by @sdroege)

Generate gio::Icon, gio::ThemedIcon, gdk::DrawingContext
gtk-rs/gio#29
gtk-rs/gdk#166
gtk-rs/gtk#513

Generate windows specific function names:
gtk-rs/gir#375
gtk-rs/sys#50
gtk-rs/glib#177

Add support for gobject closures
gtk-rs/glib#173
gtk-rs/glib#178

Breaking change Implement Value traits inside glib_wrapper!() instead of doing it generically
gtk-rs/glib#196

gsize and fixed length arrays support + enum safety:
gtk-rs/glib#183
gtk-rs/glib#184
gtk-rs/gtk#533
gtk-rs/pango#79
gtk-rs/gio#39
gtk-rs/gdk#171

add property and signal support to trait ObjectExt (by sdroege):
gtk-rs/glib#189 Implement public ObjectExt::set_property() and ::get_property()
gtk-rs/glib#190 Various GObject property changes
gtk-rs/glib#191 Implement ObjectExt::connect() for connecting to arbitrary signals
gtk-rs/glib#192 Implement ObjectExt::emit() for emitting arbitrary signals
gtk-rs/glib#193 Remove now obsolete comment from ObjectExt::set_property()

gtk-rs/gtk#516 Add Into for child properties Option

gtk-rs/gtk#518 Add GtkIMMulticontext and GtkIMContext (by daa84)
gtk-rs/gtk#519 Add PrintContext

gtk-rs/glib#180 Add signal::signal_handler_disconnect()

gtk-rs/gtk#525 Change gtk::Application::new parameter to use Into<Option<&str>> (by jeandudey)

gtk-rs/gio#34 Implement open signal and open function
gtk-rs/gio#37 Generate FileInfo (by hfiguiere)
gtk-rs/gio#38 Generate Notification (by nielsdg)
gtk-rs/gio#39 Enable Application::open() autogeneration again
gtk-rs/gio#40 Tls certificate (by antoyo)
gtk-rs/cairo#136 Fix macOS specific functions (by Znapi)
gtk-rs/cairo#140 Error trait for errors
gtk-rs/gtk#529 Simplify API for RadioButton and RadioMenuItem
gtk-rs/gdk#170 Add remaining GdkAtom constants
gtk-rs/gdk#171 Regenerate with latest GIR and enable Display::store_clipboard()
gtk-rs/gdk#172 gdk_window_fullscreen_on_monitor available since 3.18
gtk-rs/gdk#174 Add missing getters for EventScroll
gtk-rs/gtk#535 ShortcutsWindow available since 3.20
gtk-rs/gtk#537 Generate IconTheme
gtk-rs/gtk#538 New types
gtk-rs/gdk#176 Add Geometry, Use cairo types

@GuillaumeGomez What you think about collecting change log here and close issue on merging release PR?

Add FAQ

Like:

  • adding new crates binding to gtk-rs
  • ...

The documentation is incoherent and poor

Some parts of the documentation are incoherent and should be fixed, for example this page and this other page show a different way of including gtk as a dependency since one recommends to use a git link while the other shows that including it as a normal depencency should work fine.
This is just an example and I don't know if there are other incoherent parts.

In addition to that, but not as important, the documentation should be clearer and provide more explainations so that new users can start quickly to use the library without having to suppose how it may works.

Thanks in advance!

Example on gtk-rs.org should be more complete.

I think the snippet should be buildable and runnable out of the box.

Instead of just

use gtk::{Button, Window, WindowType};

there should be

extern crate gtk;
use gtk::{Button, Window, WindowType, Inhibit, WindowExt, ContainerExt, WidgetExt, ButtonExt};

or just use gtk::prelude::*; repeated from the snippet above.

Link to gitter

We should add it somewhere, possibly find a reasonable way to put it in the navigation block.

Some DNS do not resolve gtk-rs.org

Hello,

I have strange issues with gtk-rs.org address. On some ISPs in Poland, their DNS do not resolve this domain, resulting in site being unreachable. The workaround is to hardcode DNS server addresses to CloudFlare or Google DNS.

Has this problem occurred earlier, or am I a rare case?

GTK tutorial missing with the new design

The old design (before #205) used to feature a tutorial for GTK 3 users, including instructions for cross-compilation and various other details about how Rust wraps GTK.

This tutorial is referenced from various places, like the GTK 3 crate README for example (https://crates.io/crates/gtk), this link being currently broken.

Since GTK 4 isn't released, and the online book mentioned on the homepage doesn't cover the same topics, shouldn't the tutorial be kept online until new resources cover the same subjects or more?

Link to the old tutorial in case people visiting this issue need it: https://github.com/gtk-rs/gtk-rs.github.io/tree/617a9f8fb44f7fb0d338b4a6f4703815e7ea66a0/docs-src/tutorial

Cross-compilation guide partially outdated

The very useful cross-compilation guide needs some extra instructions. Gettext requires setting an environment variable pointing to the mingw installation. In the Compiling section, right before the build command, it is necessary to do export MINGW_PREFIX=$GTK_INSTALL_PATH.

Unfortunately, GTK_INSTALL_PATH is only introduced in a later section (Packaging). The guide might need a little restructuring to stay coherent. I also think it would be valuable to mention for example on Fedora the relevant path is /usr/x86_64-w64-mingw32/sys-root/mingw/.

Lastly, I think think (but am not sure) there is a mistake in export PKG_CONFIG_PATH=/usr/i686-w64-mingw32/lib/pkgconfig. The whole guide is about x86_64, but here we point to i686 data, can that be right?

So to summarize:

  • The compiling section needs to mention setting MINGW_PREFIX to satisfy gettext.
  • It might mistakenly refer to i686 instead of x86_64 for mingw's pkg_config.
  • The document might need a little rewriting to stay coherent and mention path equivalents from other distributions (notably Fedora).

What is the process to make this happen, if I'd like to?

Request for additional information

I would like to request a few extra pages on the website.

A page on building on windows. I figured out how to build my app on windows with the help of a reddit post and some pieces of information in issues floating around, it would be great to have this information condensed on the website.

A page about resources and app deployment. This would be helpful as well, given the fact someone created an application, how is this best deployed to the various platforms? Topics such as resources (images, icons) could be described here.

Does this make sense?

Release notes page for 2020-07-04 contains a link to nowhere

As pointed out and clarified by /u/MachaHack on /r/rust, the following passage in the latest release notes contains a link to nowhere:

glib-macros

There's a new crate glib-macros now, which is re-exported by the glib
crate and provides a couple of proc-macros

  • #[derive(GBoxed) for easily deriving a boxed type for any Rust type
    the implements the Clone trait. This can be used to store values of that
    type in e.g. in glib::Value.
  • #[derive(GEnum)] for integer representation Rust enums, which registers
    GLib type for them and allows to use them e.g. in a glib::Value.
  • #[gflags], which registers a GLib type for bitflags and wraps around the
    bitflags crate. Same as above this can then be used e.g. in a
    glib::Value.

Check the documentation for details about the above.

Is https://gtk-rs.org/docs/glib-macro/ still being written, or should the link point somewhere else?

Provide png favicons as well

Currently we are setting the SVG icon as the favicon which doesn't work for old browsers. We should also provide a 32px/16px PNG fallbacks.

Those will also be useful for the generated docs by rustdoc. It would also be nice to have a 256px variant of the SVG logo so we can use it for the docs as well

Improve wording

I wrote some texts more or less as placeholders. Would be nice if someone who is good with English words could check the start page.

#207

Projects using gtk-rs: Add carousel/slideshow

  • Select 3 to 4 apps that are featured with a screenshot (and maybe app icon.)
  • Maybe keep the huge list of apps for fun and for broader inspiration. Possibly hidden with some mechanisms that reveals all of them.

No package 'gdk-3.0' found

I am trying to compile a basic hello world and I keep running into the following error:

Compiling gdk-sys v0.9.0
error: failed to run custom build command for `gdk-sys v0.9.0`

Caused by:
  process didn't exit successfully: `/home/jhessin/Documents/bitbucket/rust-rev/target/debug/build/gdk-sys-15a474474e7b5275/build-script-build` (exit code: 1)
--- stderr
`"pkg-config" "--libs" "--cflags" "gdk-3.0 >= 3.22"` did not exit successfully: exit code: 1
--- stderr
Package gdk-3.0 was not found in the pkg-config search path.
Perhaps you should add the directory containing `gdk-3.0.pc'
to the PKG_CONFIG_PATH environment variable
No package 'gdk-3.0' found

I have checked and my $PKG_CONFIG_PATH variable is: /usr/lib/x86_64-linux-gnu/pkgconfig/
and gdk-3.0.pc IS in this directory. I was a bit confused about all the "Features" listed here, but I tried quite a few of them with no success. Here is my Cargo.toml as it stands now:

[package]
name = "rust-rev"
version = "0.1.0"
authors = ["Jim Hessin <[email protected]>"]
edition = "2018"


# orbtk = { git = "https://gitlab.redox-os.org/redox-os/orbtk.git" }
[dependencies.gtk]
version = "0.7.0"
default-features = false
features = [ "v3_22" ]

[dependencies.gio]
version = "0.7.0"
features = [ "v2_44" ]

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
#
# [dependencies.rusqlite]
# version = "0.18.0"
# features = ["bundled"]

docs-src vs docs

https://github.com/gtk-rs/gtk-rs.github.io/blob/master/README.md says:

The documentation in docs-src is not intended to be viewed at the /docs-src/ location. Instead the generated static files (_site/docs-src/*) are merged into the docs repo, keeping a nice urls structure.

but currently we have many links to it: Ex. https://gtk-rs.org/#Using
seems it time to fix it and update docs generation in your https://github.com/gtk-rs/release process.
Note: I not sure how to "generate static files" and https://github.com/gtk-rs/docs/ unusable in Windows so I can do almost nothing yourself.
@GuillaumeGomez can you fix this issue?

Example for sourceview::FileLoader

Examples (non-Rust) elsewhere suggest that you can create a sourceview::FileLoader and then invoke load_async() on it, which presumably loads the file into your sourceview::View. However, the load_async function is not implemented for FileLoader. Is this an oversight, or have I misinterpreted the way it's all supposed to work? I confess to being a newbie to Rust and to GTK, so I could just be missing something obvious.

Mention to include in next release

Please include the following mention in the release notes so as to ease developers migration process.

## Note to applications developers

Applications developers should use [`fix-getters-calls`](https://crates.io/crates/fix-getters-calls) to ease migration of their applications. Use [`fix-getters-def`](https://crates.io/crates/fix-getters-def) if you also want your get functions definition to comply with the API standards applied in this release.

Glade tutorial missing gtk::init

The tutorial that can be found at https://gtk-rs.org/docs-src/tutorial/glade in regards to Glade does not work out of the box with the dependencies from the home web page

[dependencies.gtk]
version = "0.7.0"
features = ["v3_16"]

[dependencies.gio]
version = ""
features = ["v2_44"]

Attempting to build will yield

Application exited
thread 'main' panicked at 'GTK has not been initialized. Call `gtk::init` first.', /home/jgarcia/.cargo/registry/src/github.com-1ecc6299db9ec823/gtk-0.7.0/src/auto/builder.rs:46:9
note: Run with `RUST_BACKTRACE=1` environment variable to display a backtrace.

gtk::init(); should be called prior to any use of Builder.

"Hello World" gtk-rs application example should return app.run();

https://gtk-rs.org/gtk4-rs/stable/latest/docs/gtk4/

Noticed the example here (When copied verbatim) was giving linter/compiler errors because main wasn't returning a value:

use gtk4 as gtk;
use gtk::prelude::*;
use gtk::{Application, ApplicationWindow};

fn main() -> glib::ExitCode { // implicitly returns `()` as its body has no tail or `return` expression
    let app = Application::builder()
        .application_id("org.example.HelloWorld")
        .build();

    app.connect_activate(|app| {
        // We create the main window.
        let window = ApplicationWindow::builder()
            .application(app)
            .default_width(320)
            .default_height(200)
            .title("Hello, World!")
            .build();

        // Show the window.
        window.show();
    });

    app.run();
}

Adding return before app.run(); solves this, and I assume it was just a typo. I'd have opened a PR myself but not quite sure how the jekyll project layout works 😂

Help: Initializing and Setting a GValueArray in Rust

I would like to make a GValueArray of GDouble in Rust to set the gStreamer element property. I would sincerely appreciate any help. I can do it in C as shown in the examples below.

Currently, in rust I am stuck at trying to make GValue.

Now stuck at the audioiirfilter.set_property("a", &a); call.

    let mut gv: gobject_sys::GValue;
    let v: Box<gobject_sys::GValue> = Box::new(gv);
    let v: *mut gobject_sys::GValue = Box::into_raw(v);

    gobject_sys::g_value_init(v, gobject_sys::G_TYPE_DOUBLE);

    gobject_sys::g_value_set_double(v, 1.0);
    
    let a = gobject_sys::g_value_array_new(2);

    gobject_sys::g_value_array_append(a, v);

    audioiirfilter.set_property("a", &a); #Error
error[E0277]: the trait bound `*mut gobject_sys::GValueArray: glib::value::SetValue` is not satisfied
  --> src/main.rs:64:38
   |
64 |     audioiirfilter.set_property("a", &a);
   |                                      ^^ the trait `glib::value::SetValue` is not implemented for `*mut gobject_sys::GValueArray`
   |
   = note: required because of the requirements on the impl of `glib::value::ToValue` for `*mut gobject_sys::GValueArray`
   = note: required for the cast to the object type `dyn glib::value::ToValue`

Without context in C:

    GValueArray *va;
    GValue v = {
        0,
    };
    gdouble a_kernel[2];

    a_kernel[0] = 1;
    a_kernel[1] = -0.05095288;

    va = g_value_array_new(1);
    g_value_init(&v, G_TYPE_DOUBLE);

    for (int i = 0; i < 2; i++)
    {
        g_value_set_double(&v, a_kernel[i]);
        g_value_array_append(va, &v);
        g_value_reset(&v);
    }

With context in C:

#define GLIB_DISABLE_DEPRECATION_WARNINGS

#include <gst/gst.h>

int main(int argc, char *argv[])
{
    GstElement *pipeline, *source, *sink, *audioiirfilter;
    GstBus *bus;
    GstMessage *msg;
    GstStateChangeReturn ret;

    /* Initialize GStreamer */
    gst_init(&argc, &argv);

    /* Create the elements */
    source = gst_element_factory_make("audiotestsrc", "source");
    sink = gst_element_factory_make("autoaudiosink", "sink");

    audioiirfilter = gst_element_factory_make("audioiirfilter", "audioiirfilter");

    /* Create the empty pipeline */
    pipeline = gst_pipeline_new("test-pipeline");

    if (!pipeline || !source || !sink)
    {
        g_printerr("Not all elements could be created.\n");
        return -1;
    }

    /* Build the pipeline */
    gst_bin_add_many(GST_BIN(pipeline), source, audioiirfilter, sink, NULL);

    if (gst_element_link(source, audioiirfilter) != TRUE)
    {
        g_printerr("Elements could not be linked.\n");
        gst_object_unref(pipeline);
        return -1;
    }
    if (gst_element_link(audioiirfilter, sink) != TRUE)
    {
        g_printerr("Elements could not be linked.\n");
        gst_object_unref(pipeline);
        return -1;
    }

    GValueArray *va;
    GValue v = {
        0,
    };
    gdouble a_kernel[2];

    a_kernel[0] = 1;
    a_kernel[1] = -0.05095288;

    va = g_value_array_new(1);
    g_value_init(&v, G_TYPE_DOUBLE);

    for (int i = 0; i < 2; i++)
    {
        g_value_set_double(&v, a_kernel[i]);
        g_value_array_append(va, &v);
        g_value_reset(&v);
    }

    g_object_set(audioiirfilter, "a", va, NULL);
    g_value_array_free(va);

    /* Start playing */
    ret = gst_element_set_state(pipeline, GST_STATE_PLAYING);
    if (ret == GST_STATE_CHANGE_FAILURE)
    {
        g_printerr("Unable to set the pipeline to the playing state.\n");
        gst_object_unref(pipeline);
        return -1;
    }

    /* Wait until error or EOS */
    bus = gst_element_get_bus(pipeline);
    msg = gst_bus_timed_pop_filtered(bus, GST_CLOCK_TIME_NONE, GST_MESSAGE_ERROR | GST_MESSAGE_EOS);

    /* Free resources */
    gst_object_unref(bus);
    gst_element_set_state(pipeline, GST_STATE_NULL);
    gst_object_unref(pipeline);
    return 0;
}

If you want to run. Paste the with context example to c.c and run the following after following setup guidelines for gstreamer:

gcc c.c -o c `pkg-config --cflags --libs gstreamer-1.0` && ./c

Website overhaul

I adjusted the design based on gtk-rs/release#138

So far, it seem that everyone would like the design better than the status quo.

There have been some discussion about grey and white. Here are two versions, which both have a darker background than the current gtk-rs.org.

I'm not really happy with the header design. But it would also depend a bit on the final project icon.

  • Decide on grey
  • Adjust to/add icon
  • Replace project list with something having less optical illusions

1-light


1-dark

cc @sdroege @GuillaumeGomez

Things that need to be updated with new design

  • Add a case with "more blog posts here"?
  • Replace italic in text with bold (looks a bit weird currently)
  • We're not part of GNOME Circle yet :) (fixed in #206)
  • Comment gtk4 from the list of crates for now as it's not released yet
  • Center "If you want your app to be added to this list, please create a Pull Request for it."?
  • Link /docs-src/ to start page (since it is linked from other pages)
  • Put back application screenshot somewhere on the index page
  • Add feed link to <head>
  • Fix wording for "Projects"
  • Make drop down menu a bit nicer
  • Improve wording (for example, "provides safe Rust bindings for fundamental libraries" instead of "provides safe bindings to the Rust language")
  • Projects using gtk-rs: Add carousel/slideshow (#213)

fix crate version on homepage

On the homepage the crate version of gtk4 is 0.2.0, but on crates.io it's 0.3.1.

Is there a way to keep it updated automatically? Maybe adding some crates.io badge like
crates.io

It's just an image to https://img.shields.io/crates/v/gtk4.svg

Improvements/fixes required for the gir tutorial

Copy/paste from here:

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 

License?

I don't see a license for this project. I guess this should be added?

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.