pango icon indicating copy to clipboard operation
pango copied to clipboard

Allow to get Color from Analysis

Open romanzes opened this issue 6 years ago • 7 comments

The idea is to use it like this:

let attrs = analysis.extra_attrs();
for attr in attrs {
    let class = attr.get_attr_class();
    let attr_type = class.get_type();
    match attr_type {
        AttrType::Foreground => {
            let color_attr = pango::AttrColor::from(attr);
            let color = color_attr.get_color();
            println!("red color {:?}", color.red());
        }
        _ => {}
    }
}

romanzes avatar Nov 08 '19 03:11 romanzes

Need a hand in here?

GuillaumeGomez avatar Nov 29 '19 23:11 GuillaumeGomez

Ok, I updated the code. The Attribute API is a nightmare...

GuillaumeGomez avatar Nov 30 '19 15:11 GuillaumeGomez

Updated.

GuillaumeGomez avatar Dec 01 '19 15:12 GuillaumeGomez

I tried to look at code again after long time, and now I can't find way to "get Color from Analysis" 😢 so I prefer postpone PR

EPashkin avatar Dec 02 '19 14:12 EPashkin

You can't, that's the whole point. But at least you can now create all available attributes.

GuillaumeGomez avatar Dec 02 '19 14:12 GuillaumeGomez

Then maybe remove changes in analysis.rs and Gir.toml. Or user can do something significant with Vec<Attribute>?

This we have constructors and minimal get/set for Attribute (API really strange) and getters for PangoColor.

EPashkin avatar Dec 02 '19 14:12 EPashkin

That's a good point. The PR as it is now does not even implement what the title says :)

sdroege avatar Dec 02 '19 17:12 sdroege