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

Overhaul GValue bindings #95

Merged
merged 9 commits into from
Jan 23, 2016
Merged

Overhaul GValue bindings #95

merged 9 commits into from
Jan 23, 2016

Conversation

gkoz
Copy link
Member

@gkoz gkoz commented Jan 22, 2016

Here's the best compromise between type safety and ergonomics I've managed to achieve.
cc #73

Examples:

    let mut value = glib::Value::from(Some("Hello world !"));
    println!("gvalue.get example: {}", value.typed::<String>().unwrap().get().unwrap());

    let mut int = glib::Value::from(1);
    int.typed_mut::<i32>().unwrap().set_some(&2);
    assert_eq!(int.get(), Some(2));

    for i in 0..10 {
        let iter = right_store.append(None);
        right_store.set_value(&iter, 0, &i.into());
    }

Reflect the fact that an existing value's type can't be changed and calling getters/setters is only safe if the type matches.
Fix #73.

[breaking change]
@gkoz
Copy link
Member Author

gkoz commented Jan 22, 2016

@GuillaumeGomez
Copy link
Member

Missing re-exported value I guess.

@gkoz
Copy link
Member Author

gkoz commented Jan 23, 2016

I think it's done now. Can't easily run cargo test in travis because of older glib and g_type_init issue but added to appveyor.

@gkoz
Copy link
Member Author

gkoz commented Jan 23, 2016

All right. It's the pthread linking errors again. I guess I'll remove the CI changes from this PR.

@gkoz
Copy link
Member Author

gkoz commented Jan 23, 2016

Writing the docs made me realize that borrowing the value to get TypedValue might not be the best idea. Instead Value could be converted to TypedValue, which would deref to Value.

@gkoz
Copy link
Member Author

gkoz commented Jan 23, 2016

Now TypedValue contains Value and derefs to it.

GuillaumeGomez added a commit that referenced this pull request Jan 23, 2016
Overhaul `GValue` bindings
@GuillaumeGomez GuillaumeGomez merged commit 66d28ba into gtk-rs:master Jan 23, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants