use Buildable;
use CellArea;
use CellLayout;
use TreeIter;
use TreeModel;
use Widget;
use ffi;
use glib::GString;
use glib::StaticType;
use glib::Value;
use glib::object::Cast;
use glib::object::IsA;
use glib::signal::SignalHandlerId;
use glib::signal::connect_raw;
use glib::translate::*;
use glib_ffi;
use gobject_ffi;
use libc;
use signal::Inhibit;
use std::boxed::Box as Box_;
use std::fmt;
use std::mem::transmute;
glib_wrapper! {
pub struct EntryCompletion(Object<ffi::GtkEntryCompletion, ffi::GtkEntryCompletionClass, EntryCompletionClass>) @implements Buildable, CellLayout;
match fn {
get_type => || ffi::gtk_entry_completion_get_type(),
}
}
impl EntryCompletion {
pub fn new() -> EntryCompletion {
assert_initialized_main_thread!();
unsafe {
from_glib_full(ffi::gtk_entry_completion_new())
}
}
pub fn new_with_area<P: IsA<CellArea>>(area: &P) -> EntryCompletion {
skip_assert_initialized!();
unsafe {
from_glib_full(ffi::gtk_entry_completion_new_with_area(area.as_ref().to_glib_none().0))
}
}
}
impl Default for EntryCompletion {
fn default() -> Self {
Self::new()
}
}
pub const NONE_ENTRY_COMPLETION: Option<&EntryCompletion> = None;
pub trait EntryCompletionExt: 'static {
fn complete(&self);
fn compute_prefix(&self, key: &str) -> Option<GString>;
fn delete_action(&self, index_: i32);
fn get_completion_prefix(&self) -> Option<GString>;
fn get_entry(&self) -> Option<Widget>;
fn get_inline_completion(&self) -> bool;
fn get_inline_selection(&self) -> bool;
fn get_minimum_key_length(&self) -> i32;
fn get_model(&self) -> Option<TreeModel>;
fn get_popup_completion(&self) -> bool;
fn get_popup_set_width(&self) -> bool;
fn get_popup_single_match(&self) -> bool;
fn get_text_column(&self) -> i32;
fn insert_action_markup(&self, index_: i32, markup: &str);
fn insert_action_text(&self, index_: i32, text: &str);
fn insert_prefix(&self);
fn set_inline_completion(&self, inline_completion: bool);
fn set_inline_selection(&self, inline_selection: bool);
fn set_match_func<P: Fn(&EntryCompletion, &str, &TreeIter) -> bool + 'static>(&self, func: P);
fn set_minimum_key_length(&self, length: i32);
fn set_model<'a, P: IsA<TreeModel> + 'a, Q: Into<Option<&'a P>>>(&self, model: Q);
fn set_popup_completion(&self, popup_completion: bool);
fn set_popup_set_width(&self, popup_set_width: bool);
fn set_popup_single_match(&self, popup_single_match: bool);
fn set_text_column(&self, column: i32);
fn get_property_cell_area(&self) -> Option<CellArea>;
fn connect_action_activated<F: Fn(&Self, i32) + 'static>(&self, f: F) -> SignalHandlerId;
fn connect_cursor_on_match<F: Fn(&Self, &TreeModel, &TreeIter) -> Inhibit + 'static>(&self, f: F) -> SignalHandlerId;
fn connect_insert_prefix<F: Fn(&Self, &str) -> Inhibit + 'static>(&self, f: F) -> SignalHandlerId;
fn connect_match_selected<F: Fn(&Self, &TreeModel, &TreeIter) -> Inhibit + 'static>(&self, f: F) -> SignalHandlerId;
fn connect_no_matches<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
fn connect_property_inline_completion_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
fn connect_property_inline_selection_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
fn connect_property_minimum_key_length_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
fn connect_property_model_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
fn connect_property_popup_completion_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
fn connect_property_popup_set_width_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
fn connect_property_popup_single_match_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
fn connect_property_text_column_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
}
impl<O: IsA<EntryCompletion>> EntryCompletionExt for O {
fn complete(&self) {
unsafe {
ffi::gtk_entry_completion_complete(self.as_ref().to_glib_none().0);
}
}
fn compute_prefix(&self, key: &str) -> Option<GString> {
unsafe {
from_glib_full(ffi::gtk_entry_completion_compute_prefix(self.as_ref().to_glib_none().0, key.to_glib_none().0))
}
}
fn delete_action(&self, index_: i32) {
unsafe {
ffi::gtk_entry_completion_delete_action(self.as_ref().to_glib_none().0, index_);
}
}
fn get_completion_prefix(&self) -> Option<GString> {
unsafe {
from_glib_none(ffi::gtk_entry_completion_get_completion_prefix(self.as_ref().to_glib_none().0))
}
}
fn get_entry(&self) -> Option<Widget> {
unsafe {
from_glib_none(ffi::gtk_entry_completion_get_entry(self.as_ref().to_glib_none().0))
}
}
fn get_inline_completion(&self) -> bool {
unsafe {
from_glib(ffi::gtk_entry_completion_get_inline_completion(self.as_ref().to_glib_none().0))
}
}
fn get_inline_selection(&self) -> bool {
unsafe {
from_glib(ffi::gtk_entry_completion_get_inline_selection(self.as_ref().to_glib_none().0))
}
}
fn get_minimum_key_length(&self) -> i32 {
unsafe {
ffi::gtk_entry_completion_get_minimum_key_length(self.as_ref().to_glib_none().0)
}
}
fn get_model(&self) -> Option<TreeModel> {
unsafe {
from_glib_none(ffi::gtk_entry_completion_get_model(self.as_ref().to_glib_none().0))
}
}
fn get_popup_completion(&self) -> bool {
unsafe {
from_glib(ffi::gtk_entry_completion_get_popup_completion(self.as_ref().to_glib_none().0))
}
}
fn get_popup_set_width(&self) -> bool {
unsafe {
from_glib(ffi::gtk_entry_completion_get_popup_set_width(self.as_ref().to_glib_none().0))
}
}
fn get_popup_single_match(&self) -> bool {
unsafe {
from_glib(ffi::gtk_entry_completion_get_popup_single_match(self.as_ref().to_glib_none().0))
}
}
fn get_text_column(&self) -> i32 {
unsafe {
ffi::gtk_entry_completion_get_text_column(self.as_ref().to_glib_none().0)
}
}
fn insert_action_markup(&self, index_: i32, markup: &str) {
unsafe {
ffi::gtk_entry_completion_insert_action_markup(self.as_ref().to_glib_none().0, index_, markup.to_glib_none().0);
}
}
fn insert_action_text(&self, index_: i32, text: &str) {
unsafe {
ffi::gtk_entry_completion_insert_action_text(self.as_ref().to_glib_none().0, index_, text.to_glib_none().0);
}
}
fn insert_prefix(&self) {
unsafe {
ffi::gtk_entry_completion_insert_prefix(self.as_ref().to_glib_none().0);
}
}
fn set_inline_completion(&self, inline_completion: bool) {
unsafe {
ffi::gtk_entry_completion_set_inline_completion(self.as_ref().to_glib_none().0, inline_completion.to_glib());
}
}
fn set_inline_selection(&self, inline_selection: bool) {
unsafe {
ffi::gtk_entry_completion_set_inline_selection(self.as_ref().to_glib_none().0, inline_selection.to_glib());
}
}
fn set_match_func<P: Fn(&EntryCompletion, &str, &TreeIter) -> bool + 'static>(&self, func: P) {
let func_data: Box_<P> = Box::new(func);
unsafe extern "C" fn func_func<P: Fn(&EntryCompletion, &str, &TreeIter) -> bool + 'static>(completion: *mut ffi::GtkEntryCompletion, key: *const libc::c_char, iter: *mut ffi::GtkTreeIter, user_data: glib_ffi::gpointer) -> glib_ffi::gboolean {
let completion = from_glib_borrow(completion);
let key: GString = from_glib_borrow(key);
let iter = from_glib_borrow(iter);
let callback: &P = &*(user_data as *mut _);
let res = (*callback)(&completion, key.as_str(), &iter);
res.to_glib()
}
let func = Some(func_func::<P> as _);
unsafe extern "C" fn func_notify_func<P: Fn(&EntryCompletion, &str, &TreeIter) -> bool + 'static>(data: glib_ffi::gpointer) {
let _callback: Box_<P> = Box_::from_raw(data as *mut _);
}
let destroy_call3 = Some(func_notify_func::<P> as _);
let super_callback0: Box_<P> = func_data;
unsafe {
ffi::gtk_entry_completion_set_match_func(self.as_ref().to_glib_none().0, func, Box::into_raw(super_callback0) as *mut _, destroy_call3);
}
}
fn set_minimum_key_length(&self, length: i32) {
unsafe {
ffi::gtk_entry_completion_set_minimum_key_length(self.as_ref().to_glib_none().0, length);
}
}
fn set_model<'a, P: IsA<TreeModel> + 'a, Q: Into<Option<&'a P>>>(&self, model: Q) {
let model = model.into();
unsafe {
ffi::gtk_entry_completion_set_model(self.as_ref().to_glib_none().0, model.map(|p| p.as_ref()).to_glib_none().0);
}
}
fn set_popup_completion(&self, popup_completion: bool) {
unsafe {
ffi::gtk_entry_completion_set_popup_completion(self.as_ref().to_glib_none().0, popup_completion.to_glib());
}
}
fn set_popup_set_width(&self, popup_set_width: bool) {
unsafe {
ffi::gtk_entry_completion_set_popup_set_width(self.as_ref().to_glib_none().0, popup_set_width.to_glib());
}
}
fn set_popup_single_match(&self, popup_single_match: bool) {
unsafe {
ffi::gtk_entry_completion_set_popup_single_match(self.as_ref().to_glib_none().0, popup_single_match.to_glib());
}
}
fn set_text_column(&self, column: i32) {
unsafe {
ffi::gtk_entry_completion_set_text_column(self.as_ref().to_glib_none().0, column);
}
}
fn get_property_cell_area(&self) -> Option<CellArea> {
unsafe {
let mut value = Value::from_type(<CellArea as StaticType>::static_type());
gobject_ffi::g_object_get_property(self.to_glib_none().0 as *mut gobject_ffi::GObject, b"cell-area\0".as_ptr() as *const _, value.to_glib_none_mut().0);
value.get()
}
}
fn connect_action_activated<F: Fn(&Self, i32) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(self.as_ptr() as *mut _, b"action-activated\0".as_ptr() as *const _,
Some(transmute(action_activated_trampoline::<Self, F> as usize)), Box_::into_raw(f))
}
}
fn connect_cursor_on_match<F: Fn(&Self, &TreeModel, &TreeIter) -> Inhibit + 'static>(&self, f: F) -> SignalHandlerId {
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(self.as_ptr() as *mut _, b"cursor-on-match\0".as_ptr() as *const _,
Some(transmute(cursor_on_match_trampoline::<Self, F> as usize)), Box_::into_raw(f))
}
}
fn connect_insert_prefix<F: Fn(&Self, &str) -> Inhibit + 'static>(&self, f: F) -> SignalHandlerId {
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(self.as_ptr() as *mut _, b"insert-prefix\0".as_ptr() as *const _,
Some(transmute(insert_prefix_trampoline::<Self, F> as usize)), Box_::into_raw(f))
}
}
fn connect_match_selected<F: Fn(&Self, &TreeModel, &TreeIter) -> Inhibit + 'static>(&self, f: F) -> SignalHandlerId {
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(self.as_ptr() as *mut _, b"match-selected\0".as_ptr() as *const _,
Some(transmute(match_selected_trampoline::<Self, F> as usize)), Box_::into_raw(f))
}
}
fn connect_no_matches<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(self.as_ptr() as *mut _, b"no-matches\0".as_ptr() as *const _,
Some(transmute(no_matches_trampoline::<Self, F> as usize)), Box_::into_raw(f))
}
}
fn connect_property_inline_completion_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(self.as_ptr() as *mut _, b"notify::inline-completion\0".as_ptr() as *const _,
Some(transmute(notify_inline_completion_trampoline::<Self, F> as usize)), Box_::into_raw(f))
}
}
fn connect_property_inline_selection_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(self.as_ptr() as *mut _, b"notify::inline-selection\0".as_ptr() as *const _,
Some(transmute(notify_inline_selection_trampoline::<Self, F> as usize)), Box_::into_raw(f))
}
}
fn connect_property_minimum_key_length_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(self.as_ptr() as *mut _, b"notify::minimum-key-length\0".as_ptr() as *const _,
Some(transmute(notify_minimum_key_length_trampoline::<Self, F> as usize)), Box_::into_raw(f))
}
}
fn connect_property_model_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(self.as_ptr() as *mut _, b"notify::model\0".as_ptr() as *const _,
Some(transmute(notify_model_trampoline::<Self, F> as usize)), Box_::into_raw(f))
}
}
fn connect_property_popup_completion_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(self.as_ptr() as *mut _, b"notify::popup-completion\0".as_ptr() as *const _,
Some(transmute(notify_popup_completion_trampoline::<Self, F> as usize)), Box_::into_raw(f))
}
}
fn connect_property_popup_set_width_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(self.as_ptr() as *mut _, b"notify::popup-set-width\0".as_ptr() as *const _,
Some(transmute(notify_popup_set_width_trampoline::<Self, F> as usize)), Box_::into_raw(f))
}
}
fn connect_property_popup_single_match_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(self.as_ptr() as *mut _, b"notify::popup-single-match\0".as_ptr() as *const _,
Some(transmute(notify_popup_single_match_trampoline::<Self, F> as usize)), Box_::into_raw(f))
}
}
fn connect_property_text_column_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(self.as_ptr() as *mut _, b"notify::text-column\0".as_ptr() as *const _,
Some(transmute(notify_text_column_trampoline::<Self, F> as usize)), Box_::into_raw(f))
}
}
}
unsafe extern "C" fn action_activated_trampoline<P, F: Fn(&P, i32) + 'static>(this: *mut ffi::GtkEntryCompletion, index: libc::c_int, f: glib_ffi::gpointer)
where P: IsA<EntryCompletion> {
let f: &F = transmute(f);
f(&EntryCompletion::from_glib_borrow(this).unsafe_cast(), index)
}
unsafe extern "C" fn cursor_on_match_trampoline<P, F: Fn(&P, &TreeModel, &TreeIter) -> Inhibit + 'static>(this: *mut ffi::GtkEntryCompletion, model: *mut ffi::GtkTreeModel, iter: *mut ffi::GtkTreeIter, f: glib_ffi::gpointer) -> glib_ffi::gboolean
where P: IsA<EntryCompletion> {
let f: &F = transmute(f);
f(&EntryCompletion::from_glib_borrow(this).unsafe_cast(), &from_glib_borrow(model), &from_glib_borrow(iter)).to_glib()
}
unsafe extern "C" fn insert_prefix_trampoline<P, F: Fn(&P, &str) -> Inhibit + 'static>(this: *mut ffi::GtkEntryCompletion, prefix: *mut libc::c_char, f: glib_ffi::gpointer) -> glib_ffi::gboolean
where P: IsA<EntryCompletion> {
let f: &F = transmute(f);
f(&EntryCompletion::from_glib_borrow(this).unsafe_cast(), &GString::from_glib_borrow(prefix)).to_glib()
}
unsafe extern "C" fn match_selected_trampoline<P, F: Fn(&P, &TreeModel, &TreeIter) -> Inhibit + 'static>(this: *mut ffi::GtkEntryCompletion, model: *mut ffi::GtkTreeModel, iter: *mut ffi::GtkTreeIter, f: glib_ffi::gpointer) -> glib_ffi::gboolean
where P: IsA<EntryCompletion> {
let f: &F = transmute(f);
f(&EntryCompletion::from_glib_borrow(this).unsafe_cast(), &from_glib_borrow(model), &from_glib_borrow(iter)).to_glib()
}
unsafe extern "C" fn no_matches_trampoline<P, F: Fn(&P) + 'static>(this: *mut ffi::GtkEntryCompletion, f: glib_ffi::gpointer)
where P: IsA<EntryCompletion> {
let f: &F = transmute(f);
f(&EntryCompletion::from_glib_borrow(this).unsafe_cast())
}
unsafe extern "C" fn notify_inline_completion_trampoline<P, F: Fn(&P) + 'static>(this: *mut ffi::GtkEntryCompletion, _param_spec: glib_ffi::gpointer, f: glib_ffi::gpointer)
where P: IsA<EntryCompletion> {
let f: &F = transmute(f);
f(&EntryCompletion::from_glib_borrow(this).unsafe_cast())
}
unsafe extern "C" fn notify_inline_selection_trampoline<P, F: Fn(&P) + 'static>(this: *mut ffi::GtkEntryCompletion, _param_spec: glib_ffi::gpointer, f: glib_ffi::gpointer)
where P: IsA<EntryCompletion> {
let f: &F = transmute(f);
f(&EntryCompletion::from_glib_borrow(this).unsafe_cast())
}
unsafe extern "C" fn notify_minimum_key_length_trampoline<P, F: Fn(&P) + 'static>(this: *mut ffi::GtkEntryCompletion, _param_spec: glib_ffi::gpointer, f: glib_ffi::gpointer)
where P: IsA<EntryCompletion> {
let f: &F = transmute(f);
f(&EntryCompletion::from_glib_borrow(this).unsafe_cast())
}
unsafe extern "C" fn notify_model_trampoline<P, F: Fn(&P) + 'static>(this: *mut ffi::GtkEntryCompletion, _param_spec: glib_ffi::gpointer, f: glib_ffi::gpointer)
where P: IsA<EntryCompletion> {
let f: &F = transmute(f);
f(&EntryCompletion::from_glib_borrow(this).unsafe_cast())
}
unsafe extern "C" fn notify_popup_completion_trampoline<P, F: Fn(&P) + 'static>(this: *mut ffi::GtkEntryCompletion, _param_spec: glib_ffi::gpointer, f: glib_ffi::gpointer)
where P: IsA<EntryCompletion> {
let f: &F = transmute(f);
f(&EntryCompletion::from_glib_borrow(this).unsafe_cast())
}
unsafe extern "C" fn notify_popup_set_width_trampoline<P, F: Fn(&P) + 'static>(this: *mut ffi::GtkEntryCompletion, _param_spec: glib_ffi::gpointer, f: glib_ffi::gpointer)
where P: IsA<EntryCompletion> {
let f: &F = transmute(f);
f(&EntryCompletion::from_glib_borrow(this).unsafe_cast())
}
unsafe extern "C" fn notify_popup_single_match_trampoline<P, F: Fn(&P) + 'static>(this: *mut ffi::GtkEntryCompletion, _param_spec: glib_ffi::gpointer, f: glib_ffi::gpointer)
where P: IsA<EntryCompletion> {
let f: &F = transmute(f);
f(&EntryCompletion::from_glib_borrow(this).unsafe_cast())
}
unsafe extern "C" fn notify_text_column_trampoline<P, F: Fn(&P) + 'static>(this: *mut ffi::GtkEntryCompletion, _param_spec: glib_ffi::gpointer, f: glib_ffi::gpointer)
where P: IsA<EntryCompletion> {
let f: &F = transmute(f);
f(&EntryCompletion::from_glib_borrow(this).unsafe_cast())
}
impl fmt::Display for EntryCompletion {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "EntryCompletion")
}
}