Skip to content
This repository was archived by the owner on Jun 8, 2021. It is now read-only.

Setting xalign property with an f64 on CellRendererText fails with an unhelpful error #912

Closed
marcianx opened this issue Nov 14, 2019 · 3 comments

Comments

@marcianx
Copy link

To right-justify a column's cells in a TreeView, I tried to set the xalign property on the column's CellRendererText. However, that seems to fail with "property can't be set from the given type". I'm having a difficult time finding an example to follow, and I'm not finding the documentation helpful in resolving this.

Minimal reproducible program:

use gio::prelude::*;
use gtk::prelude::*;

use gtk::{Application, CellRendererText};

fn main() {
    let application = Application::new(Some("foo"), Default::default()).unwrap();
    application.connect_activate(|_| {
        let renderer = CellRendererText::new();
        renderer.set_property("xalign", &1.0).unwrap(); // panics
    });
    application.run(&[]);
}
@marcianx
Copy link
Author

marcianx commented Nov 14, 2019

Wow, it just clicked right now as happen to glance at the C library docs. It needs to be &1.0f32 since that's a gfloat in the docs.

Could this bug thus be changed to a feature request (just edited the title) for a clearer error?

@marcianx marcianx changed the title Setting xalign property on CellRendererText fails Setting xalign property with an f64 on CellRendererText fails with an unhelpful error Nov 14, 2019
@EPashkin
Copy link
Member

IMHO gtk-rs/glib#513 fixed this problem

@sdroege
Copy link
Member

sdroege commented Nov 14, 2019

Yes that will give a nicer error message now when unwrapping. Or you use renderer.set_property_xaling(1.0) or renderer.set_alignment(1.0, yalign).

@GuillaumeGomez this can be closed :)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants