jeremyletang / rgtk

GTK+ bindings and wrappers for Rust (DEPRECATED SEE https://github.com/rust-gnome )
GNU Lesser General Public License v3.0
121 stars 22 forks source link

Add glib::type_::Type that corresponds to GType #225

Closed gkoz closed 9 years ago

gkoz commented 9 years ago

Add an enum Type that represents GType in a Rust-y way and implements translation between them.

Example usage would be

use glib::Type;
use glib::translate::{ToGlib, from_glib};
// ...
    pub fn init(&self, _type: Type) {
        unsafe { ffi::g_value_init(self.pointer, _type.to_glib()) }
    }
    pub fn foo() -> Type {
        unsafe { from_glib(ffi::g_foo_that_returns_g_type()) }
    }
gkoz commented 9 years ago

Right, the example...

gkoz commented 9 years ago

I'll reshuffle the changes between commits a bit more for nicer separation...

oakes commented 9 years ago

I think list_store.rs, tree_store.rs, and value.rs need to use your enum, and then the treeview example can use it. That should allow the ffi module in rgtk.rs to be removed.

gkoz commented 9 years ago

Your PR handles that part I guess. Except Value should be moved to glib, it's not a part of GTK either.

oakes commented 9 years ago

I'll close my PR and submit a new one after this is merged. My current PR will definitely conflict.

GuillaumeGomez commented 9 years ago

If this good for you I merge.

gkoz commented 9 years ago

Yeah, go ahead

GuillaumeGomez commented 9 years ago

Thanks !

oakes commented 9 years ago

@gkoz I assume that gtype.rs should also be in glib.

Edit: I'll leave that file alone for now.