Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • May 11 2015 14:08
    GuillaumeGomez commented #71
Jonas L.
@jooola
Nevermind, still learning rust and figured this out.
Matthew Goulart
@matthew798
Hi all. Wondering how to use DrawingArea. I can only find DrawingAreaBuilder but no docs for it.
Matthew Goulart
@matthew798
specifically, I read that you should perform all drawing in the expose-event event but I can't find any equivalent connect_exposed function on DrawingArea.
matrixbot
@matrixbot
alex285 hello, is there any way to Flatpak a project without going though the Meson process?
alex285 through*
Evan Stoll
@evanjs
Asked on Riot (via Rust ♄ GNOME), but does anybody have some good examples of async image loading?
I've been sifting through examples and did find one that seemed sort of helpful, but I'm struggling to tie it into my app right now
https://github.com/foldu/iv2/blob/310fe06030f9d538ba1a591f07a5a149b7890c7d/src/context.rs#L29
Still struggling with futures, though, and can't seem to get images to load in the background...
My scenario: I have a ScrolledWindow with a FlowBox (+ parent Viewport, etc)
I get a list of image paths and load those into the flowbox via a ListStore
I want to defer the image loading and not block the main thread when all that is happening
Evan Stoll
@evanjs
Ironically, I found this post the day I picked this project up again... https://blog.gtk.org/2020/06/07/scalable-lists-in-gtk-4/
GtkGridView looks like it's exactly what I need right now... đŸ€€ But that's gtk4 only, and as far as I can tell, gtk-rs/{gtk4, gir} aren't there, yet, IIUC
And even then... I wonder how much I'd have to change with my app...
laurent bernabé
@loloof64

Hello everyone ! I am trying to use the clone macro for a closure. But it seems I can't use for fields access :

fn build_widget(state: &ChessBoardState) -> DrawingArea {
        let area = DrawingArea::new();

        let size = state.size;

        area.set_size_request(size, size);
        area.connect_draw(clone!(@weak state => |_source, context| {
            let (bg_red, bg_green, bg_blue) = state.background_color;

            context.set_source_rgb(bg_red, bg_green, bg_blue);
            context.paint();

            Inhibit(false)
        }));


        area
    }

I got Variables need to be valid identifiers, e.g. field accesses are not allowed as is, you must rename it!. So using state variable as is is not possible, so is there a workaround ?

laurent bernabé
@loloof64
Sorry, I forgot the move keyword before the closure, but now I get new errors.
Matthew Goulart
@matthew798
Hey all, easy question: How does one create an instance of RGBA (gdk::RGBA) since gtk::gdk is private?
matrixbot
@matrixbot
zzeroo[m] Hi, how can I reach some glade hackers?
matrixbot
@matrixbot
adjivas Hello, the gtk4 examples are always buildable? I'm not sure which rust's version to use. https://github.com/gtk-rs/examples4
matrixbot
@matrixbot
adjivas With the last nightly version, rust could not compile gdk4
Emil Hammarström
@eHammarstrom

I tried grabbing a pixbuf of my screen, but I fail to retrieve the window surface using "offscreen_window_get_surface".

Are there any other API endpoints to grab the surface of the root window, or am I missing something?

Here's the code: https://gist.github.com/eHammarstrom/cf465d20690368dc1f5f9a7aaa482ff1

David O'Connor
@David-OConnor
Hello. I'm attempting to get this working on Windows, and after running into a linker error, found out I need to install GTK, which isn't straightfwd. I'm making a very simple GUI app that anyone on Windows, Linux, or Mac should be able to use. Is this possible, or does it need system dependencies to run? Thank you.
kc1212
@kc1212
hi @David-OConnor I made it work on windows many years ago, you can try the steps here https://github.com/kc1212/convolutional-stack#install-on-windows
Ville Hakulinen
@vhakulinen
The block_on fn on main context states that "This must only be called if no MainLoop or anything else is running on this specific main context.". Does this mean that one should not call block_on within the main thread? https://gtk-rs.org/docs/glib/struct.MainContext.html#method.block_on
Ville Hakulinen
@vhakulinen
gotta appreciate gtk-rs release blog posts/notes. Had some problems after update, but through the post I could easily find the affecting changes and reasons for the changes. Awesome work!
codic12
@codic12
hiyo, i put this code at the beginning of my main function: https://hastebin.com/wiyobacuga.php
but no dialog shows up
i want to have the dialog show up, and also actually put some text in it (see commented out line). And access the gtk::ResponseType for the button value from it. how can i do these?
i get no errors
Dario Navin
@Zarathustra2

Hey guys, I would like to draw nodes and lines between those nodes. These graphs will be used to simulate algorithms on them. At which structs should I take a look?

My use case is:

  • draw n nodes and give them a color
  • connect some of the nodes with a straight line also in a specific color
Dario Navin
@Zarathustra2
Found the DrawingArea, seems like this is what I need
matrixbot
@matrixbot
vancha112 hey everyone ^^ I'm looking to increase the size of my text in gtk-rs. I knew that gtk could make use of css for increasing for example text size, but I don't know how to do so in gtk-rs :(
matrixbot
@matrixbot
gondolyr Hey everyone, I'm looking to start a project with libhandy but when I go to build, I get failed to add UI: .:7:1 Invalid object type 'HdyApplicationWindow'. I've installed libgtk-3-dev and libhandy-0.0-0, though I'd like to use libhandy-1 when it's available from the Debian repository. Also, if anyone has a handy tutorial, I'd appreciate that as well.
matrixbot
@matrixbot
gondolyr I contacted the maintainers of my distro and they happily added libhandy to the repo.
matrixbot
@matrixbot

mmstick > <@vancha112:matrix.org> hey everyone ^^ I'm looking to increase the size of my text in gtk-rs. I knew that gtk could make use of css for increasing for example text size, but I don't know how to do so in gtk-rs :(

You could use CSS, but pango also works for modifying text attributes.

matrixbot
@matrixbot
vancha112 Then pango it will be, thanks mmstick :)
dhgelling
@dhgelling
Hi all, I'm just learning gtk and using gtk-rs to do a tiny app, tried to follow the tutorial but it isn't completely up to date. My main problem off the bat is that if I close the app window, the main loop keeps running
how do I get the app to close?
my code currently looks like this
use gtk::prelude::*;

fn main() {
    if let Err(msg) = gtk::init() {
        println!("Failed to initialize GTK: '{}'", msg);
        return;
    }

    let layout_src = include_str!("../res/gui_layout.glade");
    let builder = gtk::Builder::from_string(layout_src);

    let window: gtk::Window = builder.get_object("window").unwrap();
    window.show_all();
    gtk::main();
}
matrixbot
@matrixbot
mmstick You need to connect the delete event on your window with gtk::main_quit()
window.connect_delete_event(move |_, _| {
    gtk::main_quit();
    gtk::Inhibit(false)
});
dhgelling
@dhgelling
awesome! thanks
what does the gtk::Inhibit do?
matrixbot
@matrixbot
mmstick It won't do anything here since gtk::main_quit() will quit the application
matrixbot
@matrixbot
Timo I was trying the gtk4 rust bindings on fedora and got errors
Timo Is it broken atm?
Timo That us the error message:
error: failed to select a version for `gsk4-sys`.
    ... required by package `gtk4 v0.1.0 (https://github.com/gtk-rs/gtk4#8aeb9dce)`
    ... which is depended on by `gtk-rs-examples4 v0.0.1 (/home/timo/Programming/RustExperiments/examples4)`
versions that meet the requirements `*` are: 0.1.0

the package `gsk4-sys` links to the native library `gtk-4`, but it conflicts with a previous package which links to `gtk-4` as well:
package `gdk4-sys v0.1.0 (https://github.com/gtk-rs/sys#dbd887f1)`
    ... which is depended on by `gdk4 v0.1.0 (https://github.com/gtk-rs/gdk4#bf87233c)`
    ... which is depended on by `gtk-rs-examples4 v0.0.1 (/home/timo/Programming/RustExperiments/examples4)`

failed to select a version for `gsk4-sys` which could resolve this conflict
Timo * That is the error message:
error: failed to select a version for `gsk4-sys`.
    ... required by package `gtk4 v0.1.0 (https://github.com/gtk-rs/gtk4#8aeb9dce)`
    ... which is depended on by `gtk-rs-examples4 v0.0.1 (/home/timo/Programming/RustExperiments/examples4)`
versions that meet the requirements `*` are: 0.1.0

the package `gsk4-sys` links to the native library `gtk-4`, but it conflicts with a previous package which links to `gtk-4` as well:
package `gdk4-sys v0.1.0 (https://github.com/gtk-rs/sys#dbd887f1)`
    ... which is depended on by `gdk4 v0.1.0 (https://github.com/gtk-rs/gdk4#bf87233c)`
    ... which is depended on by `gtk-rs-examples4 v0.0.1 (/home/timo/Programming/RustExperiments/examples4)`

failed to select a version for `gsk4-sys` which could resolve this conflict
Artie Fuffkin
@smallB007
Hello everyone, I've started just recently using gtk-rs and I have a question, how to use builder connect_signals from gtk-rs?
sodo
@djdisodo
how can i use cairo-rs with gtk-rs
matrixbot
@matrixbot
mmstick What are you trying to do?
Artƫrs
@Townsheriff
Hey , any ideas how to get gobject from element?
Ben Konz
@benkonz
Does anyone have any experience getting GTK3 working on windows (through either native or cross compilation). I'm trying to follow https://gtk-rs.org/docs-src/tutorial/cross but am having trouble finding distros of the correct versions of GTK3 compiled with MinGW