1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from
// from gir-files (https://github.com/gtk-rs/gir-files)
// DO NOT EDIT
use glib::{
prelude::*,
signal::{connect_raw, SignalHandlerId},
translate::*,
};
use std::{boxed::Box as Box_, fmt, mem::transmute};
glib::wrapper! {
///
///
/// ## Signals
///
///
/// #### `changed`
/// Emitted when the proposal has changed. The completion popup
/// will react to this by updating the shown information.
///
/// Action
///
/// # Implements
///
/// [`CompletionProposalExt`][trait@crate::prelude::CompletionProposalExt]
#[doc(alias = "GtkSourceCompletionProposal")]
pub struct CompletionProposal(Interface<ffi::GtkSourceCompletionProposal, ffi::GtkSourceCompletionProposalIface>);
match fn {
type_ => || ffi::gtk_source_completion_proposal_get_type(),
}
}
impl CompletionProposal {
pub const NONE: Option<&'static CompletionProposal> = None;
}
mod sealed {
pub trait Sealed {}
impl<T: super::IsA<super::CompletionProposal>> Sealed for T {}
}
/// Trait containing all [`struct@CompletionProposal`] methods.
///
/// # Implementors
///
/// [`CompletionItem`][struct@crate::CompletionItem], [`CompletionProposal`][struct@crate::CompletionProposal]
pub trait CompletionProposalExt: IsA<CompletionProposal> + sealed::Sealed + 'static {
/// Emits the "changed" signal on `self`. This should be called by
/// implementations whenever the name, icon or info of the proposal has
/// changed.
#[doc(alias = "gtk_source_completion_proposal_changed")]
fn changed(&self) {
unsafe {
ffi::gtk_source_completion_proposal_changed(self.as_ref().to_glib_none().0);
}
}
#[doc(alias = "gtk_source_completion_proposal_equal")]
fn equal(&self, other: &impl IsA<CompletionProposal>) -> bool {
unsafe {
from_glib(ffi::gtk_source_completion_proposal_equal(
self.as_ref().to_glib_none().0,
other.as_ref().to_glib_none().0,
))
}
}
/// Gets the [`gio::Icon`][crate::gio::Icon] for the icon of `self`.
///
/// # Returns
///
/// A [`gio::Icon`][crate::gio::Icon] with the icon of `self`.
#[doc(alias = "gtk_source_completion_proposal_get_gicon")]
#[doc(alias = "get_gicon")]
fn gicon(&self) -> Option<gio::Icon> {
unsafe {
from_glib_none(ffi::gtk_source_completion_proposal_get_gicon(
self.as_ref().to_glib_none().0,
))
}
}
/// Gets the [`gdk_pixbuf::Pixbuf`][crate::gdk_pixbuf::Pixbuf] for the icon of `self`.
///
/// # Returns
///
/// A [`gdk_pixbuf::Pixbuf`][crate::gdk_pixbuf::Pixbuf] with the icon of `self`.
#[doc(alias = "gtk_source_completion_proposal_get_icon")]
#[doc(alias = "get_icon")]
fn icon(&self) -> Option<gdk_pixbuf::Pixbuf> {
unsafe {
from_glib_none(ffi::gtk_source_completion_proposal_get_icon(
self.as_ref().to_glib_none().0,
))
}
}
/// Gets the icon name of `self`.
///
/// # Returns
///
/// The icon name of `self`.
#[doc(alias = "gtk_source_completion_proposal_get_icon_name")]
#[doc(alias = "get_icon_name")]
fn icon_name(&self) -> Option<glib::GString> {
unsafe {
from_glib_none(ffi::gtk_source_completion_proposal_get_icon_name(
self.as_ref().to_glib_none().0,
))
}
}
/// Gets extra information associated to the proposal. This information will be
/// used to present the user with extra, detailed information about the
/// selected proposal. The returned string must be freed with `g_free()`.
///
/// # Returns
///
/// a newly-allocated string containing
/// extra information of `self` or [`None`] if no extra information is associated
/// to `self`.
#[doc(alias = "gtk_source_completion_proposal_get_info")]
#[doc(alias = "get_info")]
fn info(&self) -> Option<glib::GString> {
unsafe {
from_glib_full(ffi::gtk_source_completion_proposal_get_info(
self.as_ref().to_glib_none().0,
))
}
}
/// Gets the label of `self`. The label is shown in the list of proposals as
/// plain text. If you need any markup (such as bold or italic text), you have
/// to implement [`markup()`][Self::markup()]. The returned string
/// must be freed with `g_free()`.
///
/// # Returns
///
/// a new string containing the label of `self`.
#[doc(alias = "gtk_source_completion_proposal_get_label")]
#[doc(alias = "get_label")]
fn label(&self) -> Option<glib::GString> {
unsafe {
from_glib_full(ffi::gtk_source_completion_proposal_get_label(
self.as_ref().to_glib_none().0,
))
}
}
/// Gets the label of `self` with markup. The label is shown in the list of
/// proposals and may contain markup. This will be used instead of
/// [`label()`][Self::label()] if implemented. The returned string
/// must be freed with `g_free()`.
///
/// # Returns
///
/// a new string containing the label of `self` with markup.
#[doc(alias = "gtk_source_completion_proposal_get_markup")]
#[doc(alias = "get_markup")]
fn markup(&self) -> Option<glib::GString> {
unsafe {
from_glib_full(ffi::gtk_source_completion_proposal_get_markup(
self.as_ref().to_glib_none().0,
))
}
}
/// Gets the text of `self`. The text that is inserted into
/// the text buffer when the proposal is activated by the default activation.
/// You are free to implement a custom activation handler in the provider and
/// not implement this function. For more information, see
/// [`CompletionProviderExt::activate_proposal()`][crate::prelude::CompletionProviderExt::activate_proposal()]. The returned string must
/// be freed with `g_free()`.
///
/// # Returns
///
/// a new string containing the text of `self`.
#[doc(alias = "gtk_source_completion_proposal_get_text")]
#[doc(alias = "get_text")]
fn text(&self) -> Option<glib::GString> {
unsafe {
from_glib_full(ffi::gtk_source_completion_proposal_get_text(
self.as_ref().to_glib_none().0,
))
}
}
#[doc(alias = "gtk_source_completion_proposal_hash")]
fn hash(&self) -> u32 {
unsafe { ffi::gtk_source_completion_proposal_hash(self.as_ref().to_glib_none().0) }
}
/// Emitted when the proposal has changed. The completion popup
/// will react to this by updating the shown information.
#[doc(alias = "changed")]
fn connect_changed<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn changed_trampoline<P: IsA<CompletionProposal>, F: Fn(&P) + 'static>(
this: *mut ffi::GtkSourceCompletionProposal,
f: glib::ffi::gpointer,
) {
let f: &F = &*(f as *const F);
f(CompletionProposal::from_glib_borrow(this).unsafe_cast_ref())
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"changed\0".as_ptr() as *const _,
Some(transmute::<_, unsafe extern "C" fn()>(
changed_trampoline::<Self, F> as *const (),
)),
Box_::into_raw(f),
)
}
}
fn emit_changed(&self) {
self.emit_by_name::<()>("changed", &[]);
}
}
impl<O: IsA<CompletionProposal>> CompletionProposalExt for O {}
impl fmt::Display for CompletionProposal {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.write_str("CompletionProposal")
}
}