#[cfg(any(feature = "v5_0", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v5_0")))]
use crate::Buffer;
#[cfg(any(feature = "v5_0", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v5_0")))]
use crate::Completion;
#[cfg(any(feature = "v5_0", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v5_0")))]
use crate::CompletionActivation;
#[cfg(any(feature = "v5_0", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v5_0")))]
use crate::CompletionProvider;
#[cfg(any(feature = "v5_0", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v5_0")))]
use crate::Language;
#[cfg(any(feature = "v5_0", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v5_0")))]
use crate::View;
use glib::object::Cast;
#[cfg(any(feature = "v5_0", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v5_0")))]
use glib::object::IsA;
#[cfg(any(feature = "v5_0", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v5_0")))]
use glib::object::ObjectType as ObjectType_;
#[cfg(any(feature = "v5_0", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v5_0")))]
use glib::signal::connect_raw;
#[cfg(any(feature = "v5_0", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v5_0")))]
use glib::signal::SignalHandlerId;
use glib::translate::*;
use glib::StaticType;
use glib::ToValue;
#[cfg(any(feature = "v5_0", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v5_0")))]
use std::boxed::Box as Box_;
use std::fmt;
#[cfg(any(feature = "v5_0", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v5_0")))]
use std::mem::transmute;
glib::wrapper! {
pub struct CompletionContext(Object<ffi::GtkSourceCompletionContext, ffi::GtkSourceCompletionContextClass>) @implements gio::ListModel;
match fn {
get_type => || ffi::gtk_source_completion_context_get_type(),
}
}
impl CompletionContext {
#[cfg(any(feature = "v5_0", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v5_0")))]
#[doc(alias = "gtk_source_completion_context_get_activation")]
pub fn get_activation(&self) -> CompletionActivation {
unsafe {
from_glib(ffi::gtk_source_completion_context_get_activation(
self.to_glib_none().0,
))
}
}
#[cfg(any(feature = "v5_0", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v5_0")))]
#[doc(alias = "gtk_source_completion_context_get_bounds")]
pub fn get_bounds(&self) -> Option<(gtk::TextIter, gtk::TextIter)> {
unsafe {
let mut begin = gtk::TextIter::uninitialized();
let mut end = gtk::TextIter::uninitialized();
let ret = from_glib(ffi::gtk_source_completion_context_get_bounds(
self.to_glib_none().0,
begin.to_glib_none_mut().0,
end.to_glib_none_mut().0,
));
if ret {
Some((begin, end))
} else {
None
}
}
}
#[cfg(any(feature = "v5_0", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v5_0")))]
#[doc(alias = "gtk_source_completion_context_get_buffer")]
pub fn get_buffer(&self) -> Option<Buffer> {
unsafe {
from_glib_none(ffi::gtk_source_completion_context_get_buffer(
self.to_glib_none().0,
))
}
}
#[cfg(any(feature = "v5_0", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v5_0")))]
#[doc(alias = "gtk_source_completion_context_get_busy")]
pub fn get_busy(&self) -> bool {
unsafe {
from_glib(ffi::gtk_source_completion_context_get_busy(
self.to_glib_none().0,
))
}
}
#[cfg(any(feature = "v5_0", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v5_0")))]
#[doc(alias = "gtk_source_completion_context_get_completion")]
pub fn get_completion(&self) -> Option<Completion> {
unsafe {
from_glib_none(ffi::gtk_source_completion_context_get_completion(
self.to_glib_none().0,
))
}
}
#[cfg(any(feature = "v5_0", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v5_0")))]
#[doc(alias = "gtk_source_completion_context_get_empty")]
pub fn get_empty(&self) -> bool {
unsafe {
from_glib(ffi::gtk_source_completion_context_get_empty(
self.to_glib_none().0,
))
}
}
#[cfg(any(feature = "v5_0", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v5_0")))]
#[doc(alias = "gtk_source_completion_context_get_language")]
pub fn get_language(&self) -> Option<Language> {
unsafe {
from_glib_none(ffi::gtk_source_completion_context_get_language(
self.to_glib_none().0,
))
}
}
#[doc(alias = "gtk_source_completion_context_get_start_iter")]
pub fn get_start_iter(&self, iter: &mut gtk::TextIter) {
unsafe {
ffi::gtk_source_completion_context_get_start_iter(
self.to_glib_none().0,
iter.to_glib_none_mut().0,
);
}
}
#[cfg(any(feature = "v5_0", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v5_0")))]
#[doc(alias = "gtk_source_completion_context_get_view")]
pub fn get_view(&self) -> Option<View> {
unsafe {
from_glib_none(ffi::gtk_source_completion_context_get_view(
self.to_glib_none().0,
))
}
}
#[cfg(any(feature = "v5_0", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v5_0")))]
#[doc(alias = "gtk_source_completion_context_get_word")]
pub fn get_word(&self) -> Option<glib::GString> {
unsafe {
from_glib_full(ffi::gtk_source_completion_context_get_word(
self.to_glib_none().0,
))
}
}
#[cfg(any(feature = "v5_0", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v5_0")))]
#[doc(alias = "gtk_source_completion_context_set_proposals_for_provider")]
pub fn set_proposals_for_provider<P: IsA<CompletionProvider>, Q: IsA<gio::ListModel>>(
&self,
provider: &P,
results: Option<&Q>,
) {
unsafe {
ffi::gtk_source_completion_context_set_proposals_for_provider(
self.to_glib_none().0,
provider.as_ref().to_glib_none().0,
results.map(|p| p.as_ref()).to_glib_none().0,
);
}
}
#[cfg(any(feature = "v5_0", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v5_0")))]
pub fn connect_property_busy_notify<F: Fn(&CompletionContext) + 'static>(
&self,
f: F,
) -> SignalHandlerId {
unsafe extern "C" fn notify_busy_trampoline<F: Fn(&CompletionContext) + 'static>(
this: *mut ffi::GtkSourceCompletionContext,
_param_spec: glib::ffi::gpointer,
f: glib::ffi::gpointer,
) {
let f: &F = &*(f as *const F);
f(&from_glib_borrow(this))
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"notify::busy\0".as_ptr() as *const _,
Some(transmute::<_, unsafe extern "C" fn()>(
notify_busy_trampoline::<F> as *const (),
)),
Box_::into_raw(f),
)
}
}
#[cfg(any(feature = "v5_0", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v5_0")))]
pub fn connect_property_empty_notify<F: Fn(&CompletionContext) + 'static>(
&self,
f: F,
) -> SignalHandlerId {
unsafe extern "C" fn notify_empty_trampoline<F: Fn(&CompletionContext) + 'static>(
this: *mut ffi::GtkSourceCompletionContext,
_param_spec: glib::ffi::gpointer,
f: glib::ffi::gpointer,
) {
let f: &F = &*(f as *const F);
f(&from_glib_borrow(this))
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"notify::empty\0".as_ptr() as *const _,
Some(transmute::<_, unsafe extern "C" fn()>(
notify_empty_trampoline::<F> as *const (),
)),
Box_::into_raw(f),
)
}
}
}
#[derive(Clone, Default)]
pub struct CompletionContextBuilder {
#[cfg(any(feature = "v5_0", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v5_0")))]
completion: Option<Completion>,
}
impl CompletionContextBuilder {
pub fn new() -> Self {
Self::default()
}
pub fn build(self) -> CompletionContext {
let mut properties: Vec<(&str, &dyn ToValue)> = vec![];
#[cfg(any(feature = "v5_0", feature = "dox"))]
if let Some(ref completion) = self.completion {
properties.push(("completion", completion));
}
let ret = glib::Object::new::<CompletionContext>(&properties).expect("object new");
ret
}
#[cfg(any(feature = "v5_0", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v5_0")))]
pub fn completion(mut self, completion: &Completion) -> Self {
self.completion = Some(completion.clone());
self
}
}
impl fmt::Display for CompletionContext {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.write_str("CompletionContext")
}
}