gtk 0.6.0

Rust bindings for the GTK+ 3 library
Documentation
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files (https://github.com/gtk-rs/gir-files)
// DO NOT EDIT

use Bin;
use Buildable;
use CellEditable;
use CellLayout;
use ComboBox;
use Container;
use Widget;
use ffi;
use glib::GString;
use glib::object::Cast;
use glib::object::IsA;
use glib::translate::*;
use std::fmt;

glib_wrapper! {
    pub struct ComboBoxText(Object<ffi::GtkComboBoxText, ffi::GtkComboBoxTextClass, ComboBoxTextClass>) @extends ComboBox, Bin, Container, Widget, @implements Buildable, CellEditable, CellLayout;

    match fn {
        get_type => || ffi::gtk_combo_box_text_get_type(),
    }
}

impl ComboBoxText {
    pub fn new() -> ComboBoxText {
        assert_initialized_main_thread!();
        unsafe {
            Widget::from_glib_none(ffi::gtk_combo_box_text_new()).unsafe_cast()
        }
    }

    pub fn new_with_entry() -> ComboBoxText {
        assert_initialized_main_thread!();
        unsafe {
            Widget::from_glib_none(ffi::gtk_combo_box_text_new_with_entry()).unsafe_cast()
        }
    }
}

impl Default for ComboBoxText {
    fn default() -> Self {
        Self::new()
    }
}

pub const NONE_COMBO_BOX_TEXT: Option<&ComboBoxText> = None;

pub trait ComboBoxTextExt: 'static {
    fn append<'a, P: Into<Option<&'a str>>>(&self, id: P, text: &str);

    fn append_text(&self, text: &str);

    fn get_active_text(&self) -> Option<GString>;

    fn insert<'a, P: Into<Option<&'a str>>>(&self, position: i32, id: P, text: &str);

    fn insert_text(&self, position: i32, text: &str);

    fn prepend<'a, P: Into<Option<&'a str>>>(&self, id: P, text: &str);

    fn prepend_text(&self, text: &str);

    fn remove(&self, position: i32);

    fn remove_all(&self);
}

impl<O: IsA<ComboBoxText>> ComboBoxTextExt for O {
    fn append<'a, P: Into<Option<&'a str>>>(&self, id: P, text: &str) {
        let id = id.into();
        unsafe {
            ffi::gtk_combo_box_text_append(self.as_ref().to_glib_none().0, id.to_glib_none().0, text.to_glib_none().0);
        }
    }

    fn append_text(&self, text: &str) {
        unsafe {
            ffi::gtk_combo_box_text_append_text(self.as_ref().to_glib_none().0, text.to_glib_none().0);
        }
    }

    fn get_active_text(&self) -> Option<GString> {
        unsafe {
            from_glib_full(ffi::gtk_combo_box_text_get_active_text(self.as_ref().to_glib_none().0))
        }
    }

    fn insert<'a, P: Into<Option<&'a str>>>(&self, position: i32, id: P, text: &str) {
        let id = id.into();
        unsafe {
            ffi::gtk_combo_box_text_insert(self.as_ref().to_glib_none().0, position, id.to_glib_none().0, text.to_glib_none().0);
        }
    }

    fn insert_text(&self, position: i32, text: &str) {
        unsafe {
            ffi::gtk_combo_box_text_insert_text(self.as_ref().to_glib_none().0, position, text.to_glib_none().0);
        }
    }

    fn prepend<'a, P: Into<Option<&'a str>>>(&self, id: P, text: &str) {
        let id = id.into();
        unsafe {
            ffi::gtk_combo_box_text_prepend(self.as_ref().to_glib_none().0, id.to_glib_none().0, text.to_glib_none().0);
        }
    }

    fn prepend_text(&self, text: &str) {
        unsafe {
            ffi::gtk_combo_box_text_prepend_text(self.as_ref().to_glib_none().0, text.to_glib_none().0);
        }
    }

    fn remove(&self, position: i32) {
        unsafe {
            ffi::gtk_combo_box_text_remove(self.as_ref().to_glib_none().0, position);
        }
    }

    fn remove_all(&self) {
        unsafe {
            ffi::gtk_combo_box_text_remove_all(self.as_ref().to_glib_none().0);
        }
    }
}

impl fmt::Display for ComboBoxText {
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        write!(f, "ComboBoxText")
    }
}