Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
    emmanueltouzery
    @emmanueltouzery
    Hi, I'd like to had tabs in the title bar of the app, like gnome-clock does. I'm trying to use gtk::HeaderBar with a gtk::StackSwitcher inside. I think I'm supposed to call .add_named(<child_widget>, 'tab name') on the stack switcher, but if I'm not sure how could I add a relm widget as child to the stack switcher?
    I tried something like that:
                    gtk::HeaderBar {
                        gtk::StackSwitcher {
                            #[name="tabs_stack"]
                            gtk::Stack {
                            }
                        }
                    },
    and then in my init:
    self.tabs_stack.add_named(&self.info_bar, "Events");
    but of course the info_bar is a part of my widget tree, and that fails because gtk_container_add_with_properties: assertion '_gtk_widget_get_parent (widget) == NULL' failed, which makes sense to me
    somehow I'd need to build a free-standing child for the stack switcher
    ideally of course I'd like to add the children directly under gtk::StackSwitcher in the relm widget tree, but I guess that's not possible as of now?
    I can't find examples regarding that
    emmanueltouzery
    @emmanueltouzery

    hmm tried another thing now, i get an empty header bar:

            gtk::Window {
                gtk::Box {
                    orientation: gtk::Orientation::Vertical,
                    gtk::HeaderBar {
                        #[name="main_window_stack_switcher"]
                        gtk::StackSwitcher {
                        }
                    },
                    #[name="main_window_stack"]
                    gtk::Stack {
                        child: {
                            fill: true,
                            expand: true,
                        },
                        gtk::Box {
                            child: {
                                name: Some("Events")
                            },
                            ...
                        },
                        gtk::Box {
                            child: {
                                name: Some("Event Sources")
                            },
                        }
    ...

    and in the init:

            self.main_window_stack_switcher
                .set_stack(Some(&self.main_window_stack));
    emmanueltouzery
    @emmanueltouzery
    alright, sorry, i made it work :)
    sorry for the distraction
    compared to the last thing I pasted, I needed:
    in the child of the Stack to use child: { title: Some("Events"); } (title and not name)
    Glendon Solsberry
    @gms8994
    I really like the declarative style provided by #[widget] - is there a way to get TreeView and TreeViewColumn as well? I currently have a method of getting all of the columns on a TreeView object, but I'm not sure then how to get the TreeView object in to the declarative widget. Any assistance would be appreciated!
    antoyo
    @antoyo
    @gms8994 That is not supported for now, but I will add these as relm widgets in the future (or support them some other way). You might want to try creating such widgets, and that could be the first implementation for relm. I can help you with that if you're interested.
    Glendon Solsberry
    @gms8994
    @antoyo I'd be happy to try, if you can give me some pointers on where to start/look!
    antoyo
    @antoyo
    @gms8994: What I would do is to create a "special" container widget for the treeview. Please take a look at the multi-container example: https://github.com/antoyo/relm/blob/59ec74da87c7ca19bb6d6e1246a5b98f9b841bed/relm-examples/tests/multi-container.rs#L183-L205 Then, you would need to create a widget for the columns by specifying the parent ID you choose in your
    If you need more help to understand this example, I'll be happy to explain it.
    For the columns, you might actually be able to use the #[widget] attribute, like so: https://github.com/antoyo/relm/blob/master/relm-examples/tests/multi-container-attribute.rs#L60
    Glendon Solsberry
    @gms8994
    @antoyo in the first link, is there an example of how SplitBox would be used? I assume something like view! { gtk::Window { gtk::Box { gtk::SplitBox } } } ?
    antoyo
    @antoyo
    @gms8994: No, but you would use it like in the second link (https://github.com/antoyo/relm/blob/master/relm-examples/tests/multi-container-attribute.rs#L145), i.e. without the gtk:: prefix.
    Edvin
    @vuuk
    What is the prefered way of drawing charts in Relm? Is there any crate the works sort of like Qt's charts with Relm/gtk-rs? Does anyone have experience with this in gtk-rs or Relm?
    matrixbot
    @matrixbot
    silwol Edvin (Gitter): I have used https://crates.io/crates/plotters successfully, they have a GTK/Cairo drawing backend.
    Edvin
    @vuuk
    I tried using that, I could not get the CairoBackend to work. There seems to be a bug with the build currently. Have you tried it with the SvgBackend or BitmapBackend?
    As far as I understand the bitmap and the svg backends, plotters writes to a png file and then you just load it into an Image-widget in gtk.
    matrixbot
    @matrixbot
    silwol I was successful with it. What is the behavior it shows?
    Edvin
    @vuuk
    Their gtk-demo wont build currently. There seems to be a problem with the cairo::Context. I have filed an issue on their github page.

    `--> src/main.rs:12:38 let root = CairoBackend::new(cr, (500, 500)).unwrap().into_drawing_area();

    expected struct cairo::context::Context, found a different struct cairo::context::Context

    note: expected type &cairo::context::Context (struct cairo::context::Context)
    found type &cairo::context::Context (struct cairo::context::Context)

    note: Perhaps two different versions of crate cairo are being used?`

    That is the compilation error that is displayed when attempting to build the demo.
    matrixbot
    @matrixbot
    silwol yes, it looks as if it's exactly as the last line says.
    matrixbot
    @matrixbot
    silwol it seems they updated gtk in their project, but forgot to update the example. that's where the two different versions of cairo come from.
    Edvin
    @vuuk
    Yeah. I am fairly new to this so I could not figure out how to make it work in my own project neither.
    matrixbot
    @matrixbot
    silwol Upgrading cairo-rs to 0.8.1, gtk to 0.8.1 and gio to 0.8.1 makes it work, but it doesn't look as it should, I guess. It only shows an empty grid with labeled axes.
    Edvin
    @vuuk
    Is that a rule of thumb to always use the same versions of those crates?
    I understand that what versions you import is fairly sensitive when using the gtk-rs "stack"
    matrixbot
    @matrixbot
    silwol although that looks rather like what it should do according to the code.
    silwol gtk usually hase one set of versions released at a time. you can see what versions gtk depends on by looking at the "Dependencies" section on https://crates.io/crates/gtk
    silwol when a crate is in the tree in two different versions, this can cause problems in some cases, as happened here.
    silwol I typically use the cargo upgrade command from the cargo-edit crate.
    silwol then I get all crates updated to the latest versions.
    Edvin
    @vuuk
    Sounds like a good idea for me to install that crate :D
    Well thanks a lot for the help :) I have been on a quest for chart drawing crate for quite some time now
    matrixbot
    @matrixbot
    silwol I was quite happy with it. Sadly my employer went bankrupt, so I haven't written any production Rust code for around 3 months :-(
    Edvin
    @vuuk
    That sucks.. But yeah it really seems like a good crate, good enough for pet projects anyways :)
    Edvin
    @vuuk
    @matrixbot I got it to worked thanks to your help. However now I cannot get it to call the function passed to connect_draw. :-(
    taciturasa
    @taciturasa
    Hi there! how would I initialize a LinkButton in the view! macro?
    the structure inside view! seems very different from how gtk-rs does things and it isn't too well documented
    also, can i use from_file instead of from_pixbuf when defining a GtkImage inside here?
    antoyo
    @antoyo
    @taciturasa: There's a tutorial to help with the basics: https://relm.antoyo.xyz/getting-started/ That should answer both of your questions.
    taciturasa
    @taciturasa
    ah, nice! thanks, i didn't even see that