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 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322
// 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 crate::{CompletionActivation, CompletionContext, CompletionInfo, CompletionProposal};
use glib::{prelude::*, translate::*};
use std::fmt;
glib::wrapper! {
///
///
/// # Implements
///
/// [`CompletionProviderExt`][trait@crate::prelude::CompletionProviderExt]
#[doc(alias = "GtkSourceCompletionProvider")]
pub struct CompletionProvider(Interface<ffi::GtkSourceCompletionProvider, ffi::GtkSourceCompletionProviderIface>);
match fn {
type_ => || ffi::gtk_source_completion_provider_get_type(),
}
}
impl CompletionProvider {
pub const NONE: Option<&'static CompletionProvider> = None;
}
mod sealed {
pub trait Sealed {}
impl<T: super::IsA<super::CompletionProvider>> Sealed for T {}
}
/// Trait containing all [`struct@CompletionProvider`] methods.
///
/// # Implementors
///
/// [`CompletionProvider`][struct@crate::CompletionProvider], [`CompletionWords`][struct@crate::CompletionWords]
pub trait CompletionProviderExt: IsA<CompletionProvider> + sealed::Sealed + 'static {
/// Activate `proposal` at `iter`. When this functions returns [`false`], the default
/// activation of `proposal` will take place which replaces the word at `iter`
/// with the text of `proposal` (see [`CompletionProposalExt::text()`][crate::prelude::CompletionProposalExt::text()]).
///
/// Here is how the default activation selects the boundaries of the word to
/// replace. The end of the word is `iter`. For the start of the word, it depends
/// on whether a start iter is defined for `proposal` (see
/// [`start_iter()`][Self::start_iter()]). If a start iter is defined,
/// the start of the word is the start iter. Else, the word (as long as possible)
/// will contain only alphanumerical and the "_" characters.
/// ## `proposal`
/// a [`CompletionProposal`][crate::CompletionProposal].
/// ## `iter`
/// a [`gtk::TextIter`][crate::gtk::TextIter].
///
/// # Returns
///
/// [`true`] to indicate that the proposal activation has been handled,
/// [`false`] otherwise.
#[doc(alias = "gtk_source_completion_provider_activate_proposal")]
fn activate_proposal(
&self,
proposal: &impl IsA<CompletionProposal>,
iter: &mut gtk::TextIter,
) -> bool {
unsafe {
from_glib(ffi::gtk_source_completion_provider_activate_proposal(
self.as_ref().to_glib_none().0,
proposal.as_ref().to_glib_none().0,
iter.to_glib_none_mut().0,
))
}
}
/// Get with what kind of activation the provider should be activated.
///
/// # Returns
///
/// a combination of [`CompletionActivation`][crate::CompletionActivation].
#[doc(alias = "gtk_source_completion_provider_get_activation")]
#[doc(alias = "get_activation")]
fn activation(&self) -> CompletionActivation {
unsafe {
from_glib(ffi::gtk_source_completion_provider_get_activation(
self.as_ref().to_glib_none().0,
))
}
}
/// Gets the [`gio::Icon`][crate::gio::Icon] for the icon of `self`.
///
/// # Returns
///
/// The icon to be used for the provider,
/// or [`None`] if the provider does not have a special icon.
#[doc(alias = "gtk_source_completion_provider_get_gicon")]
#[doc(alias = "get_gicon")]
fn gicon(&self) -> Option<gio::Icon> {
unsafe {
from_glib_none(ffi::gtk_source_completion_provider_get_gicon(
self.as_ref().to_glib_none().0,
))
}
}
/// Get the [`gdk_pixbuf::Pixbuf`][crate::gdk_pixbuf::Pixbuf] for the icon of the `self`.
///
/// # Returns
///
/// The icon to be used for the provider,
/// or [`None`] if the provider does not have a special icon.
#[doc(alias = "gtk_source_completion_provider_get_icon")]
#[doc(alias = "get_icon")]
fn icon(&self) -> Option<gdk_pixbuf::Pixbuf> {
unsafe {
from_glib_none(ffi::gtk_source_completion_provider_get_icon(
self.as_ref().to_glib_none().0,
))
}
}
/// Gets the icon name of `self`.
///
/// # Returns
///
/// The icon name to be used for the provider,
/// or [`None`] if the provider does not have a special icon.
#[doc(alias = "gtk_source_completion_provider_get_icon_name")]
#[doc(alias = "get_icon_name")]
fn icon_name(&self) -> Option<glib::GString> {
unsafe {
from_glib_none(ffi::gtk_source_completion_provider_get_icon_name(
self.as_ref().to_glib_none().0,
))
}
}
/// Get a customized info widget to show extra information of a proposal.
/// This allows for customized widgets on a proposal basis, although in general
/// providers will have the same custom widget for all their proposals and
/// `proposal` can be ignored. The implementation of this function is optional.
///
/// If this function is not implemented, the default widget is a `GtkLabel`. The
/// return value of [`CompletionProposalExt::info()`][crate::prelude::CompletionProposalExt::info()] is used as the
/// content of the `GtkLabel`.
///
/// `<note>`
/// `<para>`
/// If implemented, [`update_info()`][Self::update_info()]
/// `<emphasis>`must`</emphasis>` also be implemented.
/// `</para>`
/// `</note>`
/// ## `proposal`
/// a currently selected [`CompletionProposal`][crate::CompletionProposal].
///
/// # Returns
///
/// a custom [`gtk::Widget`][crate::gtk::Widget] to show extra
/// information about `proposal`, or [`None`] if the provider does not have a special
/// info widget.
#[doc(alias = "gtk_source_completion_provider_get_info_widget")]
#[doc(alias = "get_info_widget")]
fn info_widget(&self, proposal: &impl IsA<CompletionProposal>) -> Option<gtk::Widget> {
unsafe {
from_glib_none(ffi::gtk_source_completion_provider_get_info_widget(
self.as_ref().to_glib_none().0,
proposal.as_ref().to_glib_none().0,
))
}
}
/// Get the delay in milliseconds before starting interactive completion for
/// this provider. A value of -1 indicates to use the default value as set
/// by the [`auto-complete-delay`][struct@crate::Completion#auto-complete-delay] property.
///
/// # Returns
///
/// the interactive delay in milliseconds.
#[doc(alias = "gtk_source_completion_provider_get_interactive_delay")]
#[doc(alias = "get_interactive_delay")]
fn interactive_delay(&self) -> i32 {
unsafe {
ffi::gtk_source_completion_provider_get_interactive_delay(
self.as_ref().to_glib_none().0,
)
}
}
/// Get the name of the provider. This should be a translatable name for
/// display to the user. For example: _("Document word completion provider"). The
/// returned string must be freed with `g_free()`.
///
/// # Returns
///
/// a new string containing the name of the provider.
#[doc(alias = "gtk_source_completion_provider_get_name")]
#[doc(alias = "get_name")]
fn name(&self) -> Option<glib::GString> {
unsafe {
from_glib_full(ffi::gtk_source_completion_provider_get_name(
self.as_ref().to_glib_none().0,
))
}
}
/// Get the provider priority. The priority determines the order in which
/// proposals appear in the completion popup. Higher priorities are sorted
/// before lower priorities. The default priority is 0.
///
/// # Returns
///
/// the provider priority.
#[doc(alias = "gtk_source_completion_provider_get_priority")]
#[doc(alias = "get_priority")]
fn priority(&self) -> i32 {
unsafe { ffi::gtk_source_completion_provider_get_priority(self.as_ref().to_glib_none().0) }
}
/// Get the [`gtk::TextIter`][crate::gtk::TextIter] at which the completion for `proposal` starts. When
/// implemented, this information is used to position the completion window
/// accordingly when a proposal is selected in the completion window. The
/// `proposal` text inside the completion window is aligned on `iter`.
///
/// If this function is not implemented, the word boundary is taken to position
/// the completion window. See [`activate_proposal()`][Self::activate_proposal()]
/// for an explanation on the word boundaries.
///
/// When the `proposal` is activated, the default handler uses `iter` as the start
/// of the word to replace. See
/// [`activate_proposal()`][Self::activate_proposal()] for more information.
/// ## `context`
/// a [`CompletionContext`][crate::CompletionContext].
/// ## `proposal`
/// a [`CompletionProposal`][crate::CompletionProposal].
///
/// # Returns
///
/// [`true`] if `iter` was set for `proposal`, [`false`] otherwise.
///
/// ## `iter`
/// a [`gtk::TextIter`][crate::gtk::TextIter].
#[doc(alias = "gtk_source_completion_provider_get_start_iter")]
#[doc(alias = "get_start_iter")]
fn start_iter(
&self,
context: &impl IsA<CompletionContext>,
proposal: &impl IsA<CompletionProposal>,
) -> Option<gtk::TextIter> {
unsafe {
let mut iter = gtk::TextIter::uninitialized();
let ret = from_glib(ffi::gtk_source_completion_provider_get_start_iter(
self.as_ref().to_glib_none().0,
context.as_ref().to_glib_none().0,
proposal.as_ref().to_glib_none().0,
iter.to_glib_none_mut().0,
));
if ret {
Some(iter)
} else {
None
}
}
}
#[doc(alias = "gtk_source_completion_provider_match")]
#[doc(alias = "match")]
fn match_(&self, context: &impl IsA<CompletionContext>) -> bool {
unsafe {
from_glib(ffi::gtk_source_completion_provider_match(
self.as_ref().to_glib_none().0,
context.as_ref().to_glib_none().0,
))
}
}
/// Populate `context` with proposals from `self` added with the
/// [`CompletionContextExt::add_proposals()`][crate::prelude::CompletionContextExt::add_proposals()] function.
/// ## `context`
/// a [`CompletionContext`][crate::CompletionContext].
#[doc(alias = "gtk_source_completion_provider_populate")]
fn populate(&self, context: &impl IsA<CompletionContext>) {
unsafe {
ffi::gtk_source_completion_provider_populate(
self.as_ref().to_glib_none().0,
context.as_ref().to_glib_none().0,
);
}
}
/// Update extra information shown in `info` for `proposal`.
///
/// `<note>`
/// `<para>`
/// This function `<emphasis>`must`</emphasis>` be implemented when
/// [`info_widget()`][Self::info_widget()] is implemented.
/// `</para>`
/// `</note>`
/// ## `proposal`
/// a [`CompletionProposal`][crate::CompletionProposal].
/// ## `info`
/// a [`CompletionInfo`][crate::CompletionInfo].
#[doc(alias = "gtk_source_completion_provider_update_info")]
fn update_info(
&self,
proposal: &impl IsA<CompletionProposal>,
info: &impl IsA<CompletionInfo>,
) {
unsafe {
ffi::gtk_source_completion_provider_update_info(
self.as_ref().to_glib_none().0,
proposal.as_ref().to_glib_none().0,
info.as_ref().to_glib_none().0,
);
}
}
}
impl<O: IsA<CompletionProvider>> CompletionProviderExt for O {}
impl fmt::Display for CompletionProvider {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.write_str("CompletionProvider")
}
}