Skip to main content

gtk/auto/
entry_completion.rs

1// This file was generated by gir (https://github.com/gtk-rs/gir)
2// from gir-files (https://github.com/gtk-rs/gir-files)
3// DO NOT EDIT
4
5use crate::{Buildable, CellArea, CellLayout, TreeIter, TreeModel};
6use glib::{
7    prelude::*,
8    signal::{connect_raw, SignalHandlerId},
9    translate::*,
10};
11use std::{boxed::Box as Box_, fmt, mem::transmute};
12
13glib::wrapper! {
14    /// [`EntryCompletion`][crate::EntryCompletion] is an auxiliary object to be used in conjunction with
15    /// [`Entry`][crate::Entry] to provide the completion functionality. It implements the
16    /// [`CellLayout`][crate::CellLayout] interface, to allow the user to add extra cells to the
17    /// [`TreeView`][crate::TreeView] with completion matches.
18    ///
19    /// “Completion functionality” means that when the user modifies the text
20    /// in the entry, [`EntryCompletion`][crate::EntryCompletion] checks which rows in the model match
21    /// the current content of the entry, and displays a list of matches.
22    /// By default, the matching is done by comparing the entry text
23    /// case-insensitively against the text column of the model (see
24    /// [`EntryCompletionExt::set_text_column()`][crate::prelude::EntryCompletionExt::set_text_column()]), but this can be overridden
25    /// with a custom match function (see [`EntryCompletionExt::set_match_func()`][crate::prelude::EntryCompletionExt::set_match_func()]).
26    ///
27    /// When the user selects a completion, the content of the entry is
28    /// updated. By default, the content of the entry is replaced by the
29    /// text column of the model, but this can be overridden by connecting
30    /// to the [`match-selected`][struct@crate::EntryCompletion#match-selected] signal and updating the
31    /// entry in the signal handler. Note that you should return [`true`] from
32    /// the signal handler to suppress the default behaviour.
33    ///
34    /// To add completion functionality to an entry, use [`EntryExt::set_completion()`][crate::prelude::EntryExt::set_completion()].
35    ///
36    /// In addition to regular completion matches, which will be inserted into the
37    /// entry when they are selected, [`EntryCompletion`][crate::EntryCompletion] also allows to display
38    /// “actions” in the popup window. Their appearance is similar to menuitems,
39    /// to differentiate them clearly from completion strings. When an action is
40    /// selected, the [`action-activated`][struct@crate::EntryCompletion#action-activated] signal is emitted.
41    ///
42    /// GtkEntryCompletion uses a [`TreeModelFilter`][crate::TreeModelFilter] model to represent the
43    /// subset of the entire model that is currently matching. While the
44    /// GtkEntryCompletion signals [`match-selected`][struct@crate::EntryCompletion#match-selected] and
45    /// [`cursor-on-match`][struct@crate::EntryCompletion#cursor-on-match] take the original model and an
46    /// iter pointing to that model as arguments, other callbacks and signals
47    /// (such as `GtkCellLayoutDataFuncs` or [`apply-attributes`][struct@crate::CellArea#apply-attributes])
48    /// will generally take the filter model as argument. As long as you are
49    /// only calling `gtk_tree_model_get()`, this will make no difference to
50    /// you. If for some reason, you need the original model, use
51    /// [`TreeModelFilterExt::model()`][crate::prelude::TreeModelFilterExt::model()]. Don’t forget to use
52    /// [`TreeModelFilterExt::convert_iter_to_child_iter()`][crate::prelude::TreeModelFilterExt::convert_iter_to_child_iter()] to obtain a
53    /// matching iter.
54    ///
55    /// ## Properties
56    ///
57    ///
58    /// #### `cell-area`
59    ///  The [`CellArea`][crate::CellArea] used to layout cell renderers in the treeview column.
60    ///
61    /// If no area is specified when creating the entry completion with
62    /// [`EntryCompletion::with_area()`][crate::EntryCompletion::with_area()] a horizontally oriented
63    /// [`CellAreaBox`][crate::CellAreaBox] will be used.
64    ///
65    /// Readable | Writeable | Construct Only
66    ///
67    ///
68    /// #### `inline-completion`
69    ///  Determines whether the common prefix of the possible completions
70    /// should be inserted automatically in the entry. Note that this
71    /// requires text-column to be set, even if you are using a custom
72    /// match function.
73    ///
74    /// Readable | Writeable
75    ///
76    ///
77    /// #### `inline-selection`
78    ///  Determines whether the possible completions on the popup
79    /// will appear in the entry as you navigate through them.
80    ///
81    /// Readable | Writeable
82    ///
83    ///
84    /// #### `minimum-key-length`
85    ///  Readable | Writeable
86    ///
87    ///
88    /// #### `model`
89    ///  Readable | Writeable
90    ///
91    ///
92    /// #### `popup-completion`
93    ///  Determines whether the possible completions should be
94    /// shown in a popup window.
95    ///
96    /// Readable | Writeable
97    ///
98    ///
99    /// #### `popup-set-width`
100    ///  Determines whether the completions popup window will be
101    /// resized to the width of the entry.
102    ///
103    /// Readable | Writeable
104    ///
105    ///
106    /// #### `popup-single-match`
107    ///  Determines whether the completions popup window will shown
108    /// for a single possible completion. You probably want to set
109    /// this to [`false`] if you are using
110    /// [inline completion][GtkEntryCompletion--inline-completion].
111    ///
112    /// Readable | Writeable
113    ///
114    ///
115    /// #### `text-column`
116    ///  The column of the model containing the strings.
117    /// Note that the strings must be UTF-8.
118    ///
119    /// Readable | Writeable
120    ///
121    /// ## Signals
122    ///
123    ///
124    /// #### `action-activated`
125    ///  Gets emitted when an action is activated.
126    ///
127    ///
128    ///
129    ///
130    /// #### `cursor-on-match`
131    ///  Gets emitted when a match from the cursor is on a match
132    /// of the list. The default behaviour is to replace the contents
133    /// of the entry with the contents of the text column in the row
134    /// pointed to by `iter`.
135    ///
136    /// Note that `model` is the model that was passed to
137    /// [`EntryCompletionExt::set_model()`][crate::prelude::EntryCompletionExt::set_model()].
138    ///
139    ///
140    ///
141    ///
142    /// #### `insert-prefix`
143    ///  Gets emitted when the inline autocompletion is triggered.
144    /// The default behaviour is to make the entry display the
145    /// whole prefix and select the newly inserted part.
146    ///
147    /// Applications may connect to this signal in order to insert only a
148    /// smaller part of the `prefix` into the entry - e.g. the entry used in
149    /// the [`FileChooser`][crate::FileChooser] inserts only the part of the prefix up to the
150    /// next '/'.
151    ///
152    ///
153    ///
154    ///
155    /// #### `match-selected`
156    ///  Gets emitted when a match from the list is selected.
157    /// The default behaviour is to replace the contents of the
158    /// entry with the contents of the text column in the row
159    /// pointed to by `iter`.
160    ///
161    /// Note that `model` is the model that was passed to
162    /// [`EntryCompletionExt::set_model()`][crate::prelude::EntryCompletionExt::set_model()].
163    ///
164    ///
165    ///
166    ///
167    /// #### `no-matches`
168    ///  Gets emitted when the filter model has zero
169    /// number of rows in completion_complete method.
170    /// (In other words when GtkEntryCompletion is out of
171    ///  suggestions)
172    ///
173    ///
174    ///
175    /// # Implements
176    ///
177    /// [`EntryCompletionExt`][trait@crate::prelude::EntryCompletionExt], [`trait@glib::ObjectExt`], [`BuildableExt`][trait@crate::prelude::BuildableExt], [`CellLayoutExt`][trait@crate::prelude::CellLayoutExt], [`EntryCompletionExtManual`][trait@crate::prelude::EntryCompletionExtManual], [`BuildableExtManual`][trait@crate::prelude::BuildableExtManual]
178    #[doc(alias = "GtkEntryCompletion")]
179    pub struct EntryCompletion(Object<ffi::GtkEntryCompletion, ffi::GtkEntryCompletionClass>) @implements Buildable, CellLayout;
180
181    match fn {
182        type_ => || ffi::gtk_entry_completion_get_type(),
183    }
184}
185
186impl EntryCompletion {
187    pub const NONE: Option<&'static EntryCompletion> = None;
188
189    /// Creates a new [`EntryCompletion`][crate::EntryCompletion] object.
190    ///
191    /// # Returns
192    ///
193    /// A newly created [`EntryCompletion`][crate::EntryCompletion] object
194    #[doc(alias = "gtk_entry_completion_new")]
195    pub fn new() -> EntryCompletion {
196        assert_initialized_main_thread!();
197        unsafe { from_glib_full(ffi::gtk_entry_completion_new()) }
198    }
199
200    /// Creates a new [`EntryCompletion`][crate::EntryCompletion] object using the
201    /// specified `area` to layout cells in the underlying
202    /// [`TreeViewColumn`][crate::TreeViewColumn] for the drop-down menu.
203    /// ## `area`
204    /// the [`CellArea`][crate::CellArea] used to layout cells
205    ///
206    /// # Returns
207    ///
208    /// A newly created [`EntryCompletion`][crate::EntryCompletion] object
209    #[doc(alias = "gtk_entry_completion_new_with_area")]
210    #[doc(alias = "new_with_area")]
211    pub fn with_area(area: &impl IsA<CellArea>) -> EntryCompletion {
212        skip_assert_initialized!();
213        unsafe {
214            from_glib_full(ffi::gtk_entry_completion_new_with_area(
215                area.as_ref().to_glib_none().0,
216            ))
217        }
218    }
219
220    // rustdoc-stripper-ignore-next
221    /// Creates a new builder-pattern struct instance to construct [`EntryCompletion`] objects.
222    ///
223    /// This method returns an instance of [`EntryCompletionBuilder`](crate::builders::EntryCompletionBuilder) which can be used to create [`EntryCompletion`] objects.
224    pub fn builder() -> EntryCompletionBuilder {
225        EntryCompletionBuilder::new()
226    }
227}
228
229impl Default for EntryCompletion {
230    fn default() -> Self {
231        Self::new()
232    }
233}
234
235// rustdoc-stripper-ignore-next
236/// A [builder-pattern] type to construct [`EntryCompletion`] objects.
237///
238/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
239#[must_use = "The builder must be built to be used"]
240pub struct EntryCompletionBuilder {
241    builder: glib::object::ObjectBuilder<'static, EntryCompletion>,
242}
243
244impl EntryCompletionBuilder {
245    fn new() -> Self {
246        Self {
247            builder: glib::object::Object::builder(),
248        }
249    }
250
251    /// The [`CellArea`][crate::CellArea] used to layout cell renderers in the treeview column.
252    ///
253    /// If no area is specified when creating the entry completion with
254    /// [`EntryCompletion::with_area()`][crate::EntryCompletion::with_area()] a horizontally oriented
255    /// [`CellAreaBox`][crate::CellAreaBox] will be used.
256    pub fn cell_area(self, cell_area: &impl IsA<CellArea>) -> Self {
257        Self {
258            builder: self
259                .builder
260                .property("cell-area", cell_area.clone().upcast()),
261        }
262    }
263
264    /// Determines whether the common prefix of the possible completions
265    /// should be inserted automatically in the entry. Note that this
266    /// requires text-column to be set, even if you are using a custom
267    /// match function.
268    pub fn inline_completion(self, inline_completion: bool) -> Self {
269        Self {
270            builder: self
271                .builder
272                .property("inline-completion", inline_completion),
273        }
274    }
275
276    /// Determines whether the possible completions on the popup
277    /// will appear in the entry as you navigate through them.
278    pub fn inline_selection(self, inline_selection: bool) -> Self {
279        Self {
280            builder: self.builder.property("inline-selection", inline_selection),
281        }
282    }
283
284    pub fn minimum_key_length(self, minimum_key_length: i32) -> Self {
285        Self {
286            builder: self
287                .builder
288                .property("minimum-key-length", minimum_key_length),
289        }
290    }
291
292    pub fn model(self, model: &impl IsA<TreeModel>) -> Self {
293        Self {
294            builder: self.builder.property("model", model.clone().upcast()),
295        }
296    }
297
298    /// Determines whether the possible completions should be
299    /// shown in a popup window.
300    pub fn popup_completion(self, popup_completion: bool) -> Self {
301        Self {
302            builder: self.builder.property("popup-completion", popup_completion),
303        }
304    }
305
306    /// Determines whether the completions popup window will be
307    /// resized to the width of the entry.
308    pub fn popup_set_width(self, popup_set_width: bool) -> Self {
309        Self {
310            builder: self.builder.property("popup-set-width", popup_set_width),
311        }
312    }
313
314    /// Determines whether the completions popup window will shown
315    /// for a single possible completion. You probably want to set
316    /// this to [`false`] if you are using
317    /// [inline completion][GtkEntryCompletion--inline-completion].
318    pub fn popup_single_match(self, popup_single_match: bool) -> Self {
319        Self {
320            builder: self
321                .builder
322                .property("popup-single-match", popup_single_match),
323        }
324    }
325
326    /// The column of the model containing the strings.
327    /// Note that the strings must be UTF-8.
328    pub fn text_column(self, text_column: i32) -> Self {
329        Self {
330            builder: self.builder.property("text-column", text_column),
331        }
332    }
333
334    // rustdoc-stripper-ignore-next
335    /// Build the [`EntryCompletion`].
336    #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
337    pub fn build(self) -> EntryCompletion {
338        self.builder.build()
339    }
340}
341
342mod sealed {
343    pub trait Sealed {}
344    impl<T: super::IsA<super::EntryCompletion>> Sealed for T {}
345}
346
347/// Trait containing all [`struct@EntryCompletion`] methods.
348///
349/// # Implementors
350///
351/// [`EntryCompletion`][struct@crate::EntryCompletion]
352pub trait EntryCompletionExt: IsA<EntryCompletion> + sealed::Sealed + 'static {
353    /// Requests a completion operation, or in other words a refiltering of the
354    /// current list with completions, using the current key. The completion list
355    /// view will be updated accordingly.
356    #[doc(alias = "gtk_entry_completion_complete")]
357    fn complete(&self) {
358        unsafe {
359            ffi::gtk_entry_completion_complete(self.as_ref().to_glib_none().0);
360        }
361    }
362
363    /// Computes the common prefix that is shared by all rows in `self`
364    /// that start with `key`. If no row matches `key`, [`None`] will be returned.
365    /// Note that a text column must have been set for this function to work,
366    /// see [`set_text_column()`][Self::set_text_column()] for details.
367    /// ## `key`
368    /// The text to complete for
369    ///
370    /// # Returns
371    ///
372    /// The common prefix all rows starting with
373    ///  `key` or [`None`] if no row matches `key`.
374    #[doc(alias = "gtk_entry_completion_compute_prefix")]
375    fn compute_prefix(&self, key: &str) -> Option<glib::GString> {
376        unsafe {
377            from_glib_full(ffi::gtk_entry_completion_compute_prefix(
378                self.as_ref().to_glib_none().0,
379                key.to_glib_none().0,
380            ))
381        }
382    }
383
384    /// Deletes the action at `index_` from `self`’s action list.
385    ///
386    /// Note that `index_` is a relative position and the position of an
387    /// action may have changed since it was inserted.
388    /// ## `index_`
389    /// the index of the item to delete
390    #[doc(alias = "gtk_entry_completion_delete_action")]
391    fn delete_action(&self, index_: i32) {
392        unsafe {
393            ffi::gtk_entry_completion_delete_action(self.as_ref().to_glib_none().0, index_);
394        }
395    }
396
397    /// Get the original text entered by the user that triggered
398    /// the completion or [`None`] if there’s no completion ongoing.
399    ///
400    /// # Returns
401    ///
402    /// the prefix for the current completion
403    #[doc(alias = "gtk_entry_completion_get_completion_prefix")]
404    #[doc(alias = "get_completion_prefix")]
405    fn completion_prefix(&self) -> Option<glib::GString> {
406        unsafe {
407            from_glib_none(ffi::gtk_entry_completion_get_completion_prefix(
408                self.as_ref().to_glib_none().0,
409            ))
410        }
411    }
412
413    /// Returns whether the common prefix of the possible completions should
414    /// be automatically inserted in the entry.
415    ///
416    /// # Returns
417    ///
418    /// [`true`] if inline completion is turned on
419    #[doc(alias = "gtk_entry_completion_get_inline_completion")]
420    #[doc(alias = "get_inline_completion")]
421    fn is_inline_completion(&self) -> bool {
422        unsafe {
423            from_glib(ffi::gtk_entry_completion_get_inline_completion(
424                self.as_ref().to_glib_none().0,
425            ))
426        }
427    }
428
429    /// Returns [`true`] if inline-selection mode is turned on.
430    ///
431    /// # Returns
432    ///
433    /// [`true`] if inline-selection mode is on
434    #[doc(alias = "gtk_entry_completion_get_inline_selection")]
435    #[doc(alias = "get_inline_selection")]
436    fn is_inline_selection(&self) -> bool {
437        unsafe {
438            from_glib(ffi::gtk_entry_completion_get_inline_selection(
439                self.as_ref().to_glib_none().0,
440            ))
441        }
442    }
443
444    /// Returns the minimum key length as set for `self`.
445    ///
446    /// # Returns
447    ///
448    /// The currently used minimum key length
449    #[doc(alias = "gtk_entry_completion_get_minimum_key_length")]
450    #[doc(alias = "get_minimum_key_length")]
451    fn minimum_key_length(&self) -> i32 {
452        unsafe { ffi::gtk_entry_completion_get_minimum_key_length(self.as_ref().to_glib_none().0) }
453    }
454
455    /// Returns the model the [`EntryCompletion`][crate::EntryCompletion] is using as data source.
456    /// Returns [`None`] if the model is unset.
457    ///
458    /// # Returns
459    ///
460    /// A [`TreeModel`][crate::TreeModel], or [`None`] if none
461    ///  is currently being used
462    #[doc(alias = "gtk_entry_completion_get_model")]
463    #[doc(alias = "get_model")]
464    fn model(&self) -> Option<TreeModel> {
465        unsafe {
466            from_glib_none(ffi::gtk_entry_completion_get_model(
467                self.as_ref().to_glib_none().0,
468            ))
469        }
470    }
471
472    /// Returns whether the completions should be presented in a popup window.
473    ///
474    /// # Returns
475    ///
476    /// [`true`] if popup completion is turned on
477    #[doc(alias = "gtk_entry_completion_get_popup_completion")]
478    #[doc(alias = "get_popup_completion")]
479    fn is_popup_completion(&self) -> bool {
480        unsafe {
481            from_glib(ffi::gtk_entry_completion_get_popup_completion(
482                self.as_ref().to_glib_none().0,
483            ))
484        }
485    }
486
487    /// Returns whether the completion popup window will be resized to the
488    /// width of the entry.
489    ///
490    /// # Returns
491    ///
492    /// [`true`] if the popup window will be resized to the width of
493    ///  the entry
494    #[doc(alias = "gtk_entry_completion_get_popup_set_width")]
495    #[doc(alias = "get_popup_set_width")]
496    fn is_popup_set_width(&self) -> bool {
497        unsafe {
498            from_glib(ffi::gtk_entry_completion_get_popup_set_width(
499                self.as_ref().to_glib_none().0,
500            ))
501        }
502    }
503
504    /// Returns whether the completion popup window will appear even if there is
505    /// only a single match.
506    ///
507    /// # Returns
508    ///
509    /// [`true`] if the popup window will appear regardless of the
510    ///  number of matches
511    #[doc(alias = "gtk_entry_completion_get_popup_single_match")]
512    #[doc(alias = "get_popup_single_match")]
513    fn is_popup_single_match(&self) -> bool {
514        unsafe {
515            from_glib(ffi::gtk_entry_completion_get_popup_single_match(
516                self.as_ref().to_glib_none().0,
517            ))
518        }
519    }
520
521    /// Returns the column in the model of `self` to get strings from.
522    ///
523    /// # Returns
524    ///
525    /// the column containing the strings
526    #[doc(alias = "gtk_entry_completion_get_text_column")]
527    #[doc(alias = "get_text_column")]
528    fn text_column(&self) -> i32 {
529        unsafe { ffi::gtk_entry_completion_get_text_column(self.as_ref().to_glib_none().0) }
530    }
531
532    /// Inserts an action in `self`’s action item list at position `index_`
533    /// with markup `markup`.
534    /// ## `index_`
535    /// the index of the item to insert
536    /// ## `markup`
537    /// markup of the item to insert
538    #[doc(alias = "gtk_entry_completion_insert_action_markup")]
539    fn insert_action_markup(&self, index_: i32, markup: &str) {
540        unsafe {
541            ffi::gtk_entry_completion_insert_action_markup(
542                self.as_ref().to_glib_none().0,
543                index_,
544                markup.to_glib_none().0,
545            );
546        }
547    }
548
549    /// Inserts an action in `self`’s action item list at position `index_`
550    /// with text `text`. If you want the action item to have markup, use
551    /// [`insert_action_markup()`][Self::insert_action_markup()].
552    ///
553    /// Note that `index_` is a relative position in the list of actions and
554    /// the position of an action can change when deleting a different action.
555    /// ## `index_`
556    /// the index of the item to insert
557    /// ## `text`
558    /// text of the item to insert
559    #[doc(alias = "gtk_entry_completion_insert_action_text")]
560    fn insert_action_text(&self, index_: i32, text: &str) {
561        unsafe {
562            ffi::gtk_entry_completion_insert_action_text(
563                self.as_ref().to_glib_none().0,
564                index_,
565                text.to_glib_none().0,
566            );
567        }
568    }
569
570    /// Requests a prefix insertion.
571    #[doc(alias = "gtk_entry_completion_insert_prefix")]
572    fn insert_prefix(&self) {
573        unsafe {
574            ffi::gtk_entry_completion_insert_prefix(self.as_ref().to_glib_none().0);
575        }
576    }
577
578    /// Sets whether the common prefix of the possible completions should
579    /// be automatically inserted in the entry.
580    /// ## `inline_completion`
581    /// [`true`] to do inline completion
582    #[doc(alias = "gtk_entry_completion_set_inline_completion")]
583    fn set_inline_completion(&self, inline_completion: bool) {
584        unsafe {
585            ffi::gtk_entry_completion_set_inline_completion(
586                self.as_ref().to_glib_none().0,
587                inline_completion.into_glib(),
588            );
589        }
590    }
591
592    /// Sets whether it is possible to cycle through the possible completions
593    /// inside the entry.
594    /// ## `inline_selection`
595    /// [`true`] to do inline selection
596    #[doc(alias = "gtk_entry_completion_set_inline_selection")]
597    fn set_inline_selection(&self, inline_selection: bool) {
598        unsafe {
599            ffi::gtk_entry_completion_set_inline_selection(
600                self.as_ref().to_glib_none().0,
601                inline_selection.into_glib(),
602            );
603        }
604    }
605
606    /// Sets the match function for `self` to be `func`. The match function
607    /// is used to determine if a row should or should not be in the completion
608    /// list.
609    /// ## `func`
610    /// the `GtkEntryCompletionMatchFunc` to use
611    /// ## `func_data`
612    /// user data for `func`
613    /// ## `func_notify`
614    /// destroy notify for `func_data`.
615    #[doc(alias = "gtk_entry_completion_set_match_func")]
616    fn set_match_func<P: Fn(&EntryCompletion, &str, &TreeIter) -> bool + 'static>(&self, func: P) {
617        let func_data: Box_<P> = Box_::new(func);
618        unsafe extern "C" fn func_func<
619            P: Fn(&EntryCompletion, &str, &TreeIter) -> bool + 'static,
620        >(
621            completion: *mut ffi::GtkEntryCompletion,
622            key: *const libc::c_char,
623            iter: *mut ffi::GtkTreeIter,
624            user_data: glib::ffi::gpointer,
625        ) -> glib::ffi::gboolean {
626            let completion = from_glib_borrow(completion);
627            let key: Borrowed<glib::GString> = from_glib_borrow(key);
628            let iter = from_glib_borrow(iter);
629            let callback: &P = &*(user_data as *mut _);
630            (*callback)(&completion, key.as_str(), &iter).into_glib()
631        }
632        let func = Some(func_func::<P> as _);
633        unsafe extern "C" fn func_notify_func<
634            P: Fn(&EntryCompletion, &str, &TreeIter) -> bool + 'static,
635        >(
636            data: glib::ffi::gpointer,
637        ) {
638            let _callback: Box_<P> = Box_::from_raw(data as *mut _);
639        }
640        let destroy_call3 = Some(func_notify_func::<P> as _);
641        let super_callback0: Box_<P> = func_data;
642        unsafe {
643            ffi::gtk_entry_completion_set_match_func(
644                self.as_ref().to_glib_none().0,
645                func,
646                Box_::into_raw(super_callback0) as *mut _,
647                destroy_call3,
648            );
649        }
650    }
651
652    /// Requires the length of the search key for `self` to be at least
653    /// `length`. This is useful for long lists, where completing using a small
654    /// key takes a lot of time and will come up with meaningless results anyway
655    /// (ie, a too large dataset).
656    /// ## `length`
657    /// the minimum length of the key in order to start completing
658    #[doc(alias = "gtk_entry_completion_set_minimum_key_length")]
659    fn set_minimum_key_length(&self, length: i32) {
660        unsafe {
661            ffi::gtk_entry_completion_set_minimum_key_length(
662                self.as_ref().to_glib_none().0,
663                length,
664            );
665        }
666    }
667
668    /// Sets the model for a [`EntryCompletion`][crate::EntryCompletion]. If `self` already has
669    /// a model set, it will remove it before setting the new model.
670    /// If model is [`None`], then it will unset the model.
671    /// ## `model`
672    /// the [`TreeModel`][crate::TreeModel]
673    #[doc(alias = "gtk_entry_completion_set_model")]
674    fn set_model(&self, model: Option<&impl IsA<TreeModel>>) {
675        unsafe {
676            ffi::gtk_entry_completion_set_model(
677                self.as_ref().to_glib_none().0,
678                model.map(|p| p.as_ref()).to_glib_none().0,
679            );
680        }
681    }
682
683    /// Sets whether the completions should be presented in a popup window.
684    /// ## `popup_completion`
685    /// [`true`] to do popup completion
686    #[doc(alias = "gtk_entry_completion_set_popup_completion")]
687    fn set_popup_completion(&self, popup_completion: bool) {
688        unsafe {
689            ffi::gtk_entry_completion_set_popup_completion(
690                self.as_ref().to_glib_none().0,
691                popup_completion.into_glib(),
692            );
693        }
694    }
695
696    /// Sets whether the completion popup window will be resized to be the same
697    /// width as the entry.
698    /// ## `popup_set_width`
699    /// [`true`] to make the width of the popup the same as the entry
700    #[doc(alias = "gtk_entry_completion_set_popup_set_width")]
701    fn set_popup_set_width(&self, popup_set_width: bool) {
702        unsafe {
703            ffi::gtk_entry_completion_set_popup_set_width(
704                self.as_ref().to_glib_none().0,
705                popup_set_width.into_glib(),
706            );
707        }
708    }
709
710    /// Sets whether the completion popup window will appear even if there is
711    /// only a single match. You may want to set this to [`false`] if you
712    /// are using [inline completion][GtkEntryCompletion--inline-completion].
713    /// ## `popup_single_match`
714    /// [`true`] if the popup should appear even for a single
715    ///  match
716    #[doc(alias = "gtk_entry_completion_set_popup_single_match")]
717    fn set_popup_single_match(&self, popup_single_match: bool) {
718        unsafe {
719            ffi::gtk_entry_completion_set_popup_single_match(
720                self.as_ref().to_glib_none().0,
721                popup_single_match.into_glib(),
722            );
723        }
724    }
725
726    /// Convenience function for setting up the most used case of this code: a
727    /// completion list with just strings. This function will set up `self`
728    /// to have a list displaying all (and just) strings in the completion list,
729    /// and to get those strings from `column` in the model of `self`.
730    ///
731    /// This functions creates and adds a [`CellRendererText`][crate::CellRendererText] for the selected
732    /// column. If you need to set the text column, but don't want the cell
733    /// renderer, use [`ObjectExt::set()`][crate::glib::prelude::ObjectExt::set()] to set the [`text-column`][struct@crate::EntryCompletion#text-column]
734    /// property directly.
735    /// ## `column`
736    /// the column in the model of `self` to get strings from
737    #[doc(alias = "gtk_entry_completion_set_text_column")]
738    fn set_text_column(&self, column: i32) {
739        unsafe {
740            ffi::gtk_entry_completion_set_text_column(self.as_ref().to_glib_none().0, column);
741        }
742    }
743
744    /// The [`CellArea`][crate::CellArea] used to layout cell renderers in the treeview column.
745    ///
746    /// If no area is specified when creating the entry completion with
747    /// [`EntryCompletion::with_area()`][crate::EntryCompletion::with_area()] a horizontally oriented
748    /// [`CellAreaBox`][crate::CellAreaBox] will be used.
749    #[doc(alias = "cell-area")]
750    fn cell_area(&self) -> Option<CellArea> {
751        ObjectExt::property(self.as_ref(), "cell-area")
752    }
753
754    /// Gets emitted when an action is activated.
755    /// ## `index`
756    /// the index of the activated action
757    #[doc(alias = "action-activated")]
758    fn connect_action_activated<F: Fn(&Self, i32) + 'static>(&self, f: F) -> SignalHandlerId {
759        unsafe extern "C" fn action_activated_trampoline<
760            P: IsA<EntryCompletion>,
761            F: Fn(&P, i32) + 'static,
762        >(
763            this: *mut ffi::GtkEntryCompletion,
764            index: libc::c_int,
765            f: glib::ffi::gpointer,
766        ) {
767            let f: &F = &*(f as *const F);
768            f(
769                EntryCompletion::from_glib_borrow(this).unsafe_cast_ref(),
770                index,
771            )
772        }
773        unsafe {
774            let f: Box_<F> = Box_::new(f);
775            connect_raw(
776                self.as_ptr() as *mut _,
777                b"action-activated\0".as_ptr() as *const _,
778                Some(transmute::<_, unsafe extern "C" fn()>(
779                    action_activated_trampoline::<Self, F> as *const (),
780                )),
781                Box_::into_raw(f),
782            )
783        }
784    }
785
786    /// Gets emitted when a match from the cursor is on a match
787    /// of the list. The default behaviour is to replace the contents
788    /// of the entry with the contents of the text column in the row
789    /// pointed to by `iter`.
790    ///
791    /// Note that `model` is the model that was passed to
792    /// [`set_model()`][Self::set_model()].
793    /// ## `model`
794    /// the [`TreeModel`][crate::TreeModel] containing the matches
795    /// ## `iter`
796    /// a [`TreeIter`][crate::TreeIter] positioned at the selected match
797    ///
798    /// # Returns
799    ///
800    /// [`true`] if the signal has been handled
801    #[doc(alias = "cursor-on-match")]
802    fn connect_cursor_on_match<
803        F: Fn(&Self, &TreeModel, &TreeIter) -> glib::Propagation + 'static,
804    >(
805        &self,
806        f: F,
807    ) -> SignalHandlerId {
808        unsafe extern "C" fn cursor_on_match_trampoline<
809            P: IsA<EntryCompletion>,
810            F: Fn(&P, &TreeModel, &TreeIter) -> glib::Propagation + 'static,
811        >(
812            this: *mut ffi::GtkEntryCompletion,
813            model: *mut ffi::GtkTreeModel,
814            iter: *mut ffi::GtkTreeIter,
815            f: glib::ffi::gpointer,
816        ) -> glib::ffi::gboolean {
817            let f: &F = &*(f as *const F);
818            f(
819                EntryCompletion::from_glib_borrow(this).unsafe_cast_ref(),
820                &from_glib_borrow(model),
821                &from_glib_borrow(iter),
822            )
823            .into_glib()
824        }
825        unsafe {
826            let f: Box_<F> = Box_::new(f);
827            connect_raw(
828                self.as_ptr() as *mut _,
829                b"cursor-on-match\0".as_ptr() as *const _,
830                Some(transmute::<_, unsafe extern "C" fn()>(
831                    cursor_on_match_trampoline::<Self, F> as *const (),
832                )),
833                Box_::into_raw(f),
834            )
835        }
836    }
837
838    /// Gets emitted when the inline autocompletion is triggered.
839    /// The default behaviour is to make the entry display the
840    /// whole prefix and select the newly inserted part.
841    ///
842    /// Applications may connect to this signal in order to insert only a
843    /// smaller part of the `prefix` into the entry - e.g. the entry used in
844    /// the [`FileChooser`][crate::FileChooser] inserts only the part of the prefix up to the
845    /// next '/'.
846    /// ## `prefix`
847    /// the common prefix of all possible completions
848    ///
849    /// # Returns
850    ///
851    /// [`true`] if the signal has been handled
852    #[doc(alias = "insert-prefix")]
853    fn connect_insert_prefix<F: Fn(&Self, &str) -> glib::Propagation + 'static>(
854        &self,
855        f: F,
856    ) -> SignalHandlerId {
857        unsafe extern "C" fn insert_prefix_trampoline<
858            P: IsA<EntryCompletion>,
859            F: Fn(&P, &str) -> glib::Propagation + 'static,
860        >(
861            this: *mut ffi::GtkEntryCompletion,
862            prefix: *mut libc::c_char,
863            f: glib::ffi::gpointer,
864        ) -> glib::ffi::gboolean {
865            let f: &F = &*(f as *const F);
866            f(
867                EntryCompletion::from_glib_borrow(this).unsafe_cast_ref(),
868                &glib::GString::from_glib_borrow(prefix),
869            )
870            .into_glib()
871        }
872        unsafe {
873            let f: Box_<F> = Box_::new(f);
874            connect_raw(
875                self.as_ptr() as *mut _,
876                b"insert-prefix\0".as_ptr() as *const _,
877                Some(transmute::<_, unsafe extern "C" fn()>(
878                    insert_prefix_trampoline::<Self, F> as *const (),
879                )),
880                Box_::into_raw(f),
881            )
882        }
883    }
884
885    /// Gets emitted when a match from the list is selected.
886    /// The default behaviour is to replace the contents of the
887    /// entry with the contents of the text column in the row
888    /// pointed to by `iter`.
889    ///
890    /// Note that `model` is the model that was passed to
891    /// [`set_model()`][Self::set_model()].
892    /// ## `model`
893    /// the [`TreeModel`][crate::TreeModel] containing the matches
894    /// ## `iter`
895    /// a [`TreeIter`][crate::TreeIter] positioned at the selected match
896    ///
897    /// # Returns
898    ///
899    /// [`true`] if the signal has been handled
900    #[doc(alias = "match-selected")]
901    fn connect_match_selected<
902        F: Fn(&Self, &TreeModel, &TreeIter) -> glib::Propagation + 'static,
903    >(
904        &self,
905        f: F,
906    ) -> SignalHandlerId {
907        unsafe extern "C" fn match_selected_trampoline<
908            P: IsA<EntryCompletion>,
909            F: Fn(&P, &TreeModel, &TreeIter) -> glib::Propagation + 'static,
910        >(
911            this: *mut ffi::GtkEntryCompletion,
912            model: *mut ffi::GtkTreeModel,
913            iter: *mut ffi::GtkTreeIter,
914            f: glib::ffi::gpointer,
915        ) -> glib::ffi::gboolean {
916            let f: &F = &*(f as *const F);
917            f(
918                EntryCompletion::from_glib_borrow(this).unsafe_cast_ref(),
919                &from_glib_borrow(model),
920                &from_glib_borrow(iter),
921            )
922            .into_glib()
923        }
924        unsafe {
925            let f: Box_<F> = Box_::new(f);
926            connect_raw(
927                self.as_ptr() as *mut _,
928                b"match-selected\0".as_ptr() as *const _,
929                Some(transmute::<_, unsafe extern "C" fn()>(
930                    match_selected_trampoline::<Self, F> as *const (),
931                )),
932                Box_::into_raw(f),
933            )
934        }
935    }
936
937    /// Gets emitted when the filter model has zero
938    /// number of rows in completion_complete method.
939    /// (In other words when GtkEntryCompletion is out of
940    ///  suggestions)
941    #[doc(alias = "no-matches")]
942    fn connect_no_matches<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
943        unsafe extern "C" fn no_matches_trampoline<P: IsA<EntryCompletion>, F: Fn(&P) + 'static>(
944            this: *mut ffi::GtkEntryCompletion,
945            f: glib::ffi::gpointer,
946        ) {
947            let f: &F = &*(f as *const F);
948            f(EntryCompletion::from_glib_borrow(this).unsafe_cast_ref())
949        }
950        unsafe {
951            let f: Box_<F> = Box_::new(f);
952            connect_raw(
953                self.as_ptr() as *mut _,
954                b"no-matches\0".as_ptr() as *const _,
955                Some(transmute::<_, unsafe extern "C" fn()>(
956                    no_matches_trampoline::<Self, F> as *const (),
957                )),
958                Box_::into_raw(f),
959            )
960        }
961    }
962
963    #[doc(alias = "inline-completion")]
964    fn connect_inline_completion_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
965        unsafe extern "C" fn notify_inline_completion_trampoline<
966            P: IsA<EntryCompletion>,
967            F: Fn(&P) + 'static,
968        >(
969            this: *mut ffi::GtkEntryCompletion,
970            _param_spec: glib::ffi::gpointer,
971            f: glib::ffi::gpointer,
972        ) {
973            let f: &F = &*(f as *const F);
974            f(EntryCompletion::from_glib_borrow(this).unsafe_cast_ref())
975        }
976        unsafe {
977            let f: Box_<F> = Box_::new(f);
978            connect_raw(
979                self.as_ptr() as *mut _,
980                b"notify::inline-completion\0".as_ptr() as *const _,
981                Some(transmute::<_, unsafe extern "C" fn()>(
982                    notify_inline_completion_trampoline::<Self, F> as *const (),
983                )),
984                Box_::into_raw(f),
985            )
986        }
987    }
988
989    #[doc(alias = "inline-selection")]
990    fn connect_inline_selection_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
991        unsafe extern "C" fn notify_inline_selection_trampoline<
992            P: IsA<EntryCompletion>,
993            F: Fn(&P) + 'static,
994        >(
995            this: *mut ffi::GtkEntryCompletion,
996            _param_spec: glib::ffi::gpointer,
997            f: glib::ffi::gpointer,
998        ) {
999            let f: &F = &*(f as *const F);
1000            f(EntryCompletion::from_glib_borrow(this).unsafe_cast_ref())
1001        }
1002        unsafe {
1003            let f: Box_<F> = Box_::new(f);
1004            connect_raw(
1005                self.as_ptr() as *mut _,
1006                b"notify::inline-selection\0".as_ptr() as *const _,
1007                Some(transmute::<_, unsafe extern "C" fn()>(
1008                    notify_inline_selection_trampoline::<Self, F> as *const (),
1009                )),
1010                Box_::into_raw(f),
1011            )
1012        }
1013    }
1014
1015    #[doc(alias = "minimum-key-length")]
1016    fn connect_minimum_key_length_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1017        unsafe extern "C" fn notify_minimum_key_length_trampoline<
1018            P: IsA<EntryCompletion>,
1019            F: Fn(&P) + 'static,
1020        >(
1021            this: *mut ffi::GtkEntryCompletion,
1022            _param_spec: glib::ffi::gpointer,
1023            f: glib::ffi::gpointer,
1024        ) {
1025            let f: &F = &*(f as *const F);
1026            f(EntryCompletion::from_glib_borrow(this).unsafe_cast_ref())
1027        }
1028        unsafe {
1029            let f: Box_<F> = Box_::new(f);
1030            connect_raw(
1031                self.as_ptr() as *mut _,
1032                b"notify::minimum-key-length\0".as_ptr() as *const _,
1033                Some(transmute::<_, unsafe extern "C" fn()>(
1034                    notify_minimum_key_length_trampoline::<Self, F> as *const (),
1035                )),
1036                Box_::into_raw(f),
1037            )
1038        }
1039    }
1040
1041    #[doc(alias = "model")]
1042    fn connect_model_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1043        unsafe extern "C" fn notify_model_trampoline<
1044            P: IsA<EntryCompletion>,
1045            F: Fn(&P) + 'static,
1046        >(
1047            this: *mut ffi::GtkEntryCompletion,
1048            _param_spec: glib::ffi::gpointer,
1049            f: glib::ffi::gpointer,
1050        ) {
1051            let f: &F = &*(f as *const F);
1052            f(EntryCompletion::from_glib_borrow(this).unsafe_cast_ref())
1053        }
1054        unsafe {
1055            let f: Box_<F> = Box_::new(f);
1056            connect_raw(
1057                self.as_ptr() as *mut _,
1058                b"notify::model\0".as_ptr() as *const _,
1059                Some(transmute::<_, unsafe extern "C" fn()>(
1060                    notify_model_trampoline::<Self, F> as *const (),
1061                )),
1062                Box_::into_raw(f),
1063            )
1064        }
1065    }
1066
1067    #[doc(alias = "popup-completion")]
1068    fn connect_popup_completion_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1069        unsafe extern "C" fn notify_popup_completion_trampoline<
1070            P: IsA<EntryCompletion>,
1071            F: Fn(&P) + 'static,
1072        >(
1073            this: *mut ffi::GtkEntryCompletion,
1074            _param_spec: glib::ffi::gpointer,
1075            f: glib::ffi::gpointer,
1076        ) {
1077            let f: &F = &*(f as *const F);
1078            f(EntryCompletion::from_glib_borrow(this).unsafe_cast_ref())
1079        }
1080        unsafe {
1081            let f: Box_<F> = Box_::new(f);
1082            connect_raw(
1083                self.as_ptr() as *mut _,
1084                b"notify::popup-completion\0".as_ptr() as *const _,
1085                Some(transmute::<_, unsafe extern "C" fn()>(
1086                    notify_popup_completion_trampoline::<Self, F> as *const (),
1087                )),
1088                Box_::into_raw(f),
1089            )
1090        }
1091    }
1092
1093    #[doc(alias = "popup-set-width")]
1094    fn connect_popup_set_width_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1095        unsafe extern "C" fn notify_popup_set_width_trampoline<
1096            P: IsA<EntryCompletion>,
1097            F: Fn(&P) + 'static,
1098        >(
1099            this: *mut ffi::GtkEntryCompletion,
1100            _param_spec: glib::ffi::gpointer,
1101            f: glib::ffi::gpointer,
1102        ) {
1103            let f: &F = &*(f as *const F);
1104            f(EntryCompletion::from_glib_borrow(this).unsafe_cast_ref())
1105        }
1106        unsafe {
1107            let f: Box_<F> = Box_::new(f);
1108            connect_raw(
1109                self.as_ptr() as *mut _,
1110                b"notify::popup-set-width\0".as_ptr() as *const _,
1111                Some(transmute::<_, unsafe extern "C" fn()>(
1112                    notify_popup_set_width_trampoline::<Self, F> as *const (),
1113                )),
1114                Box_::into_raw(f),
1115            )
1116        }
1117    }
1118
1119    #[doc(alias = "popup-single-match")]
1120    fn connect_popup_single_match_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1121        unsafe extern "C" fn notify_popup_single_match_trampoline<
1122            P: IsA<EntryCompletion>,
1123            F: Fn(&P) + 'static,
1124        >(
1125            this: *mut ffi::GtkEntryCompletion,
1126            _param_spec: glib::ffi::gpointer,
1127            f: glib::ffi::gpointer,
1128        ) {
1129            let f: &F = &*(f as *const F);
1130            f(EntryCompletion::from_glib_borrow(this).unsafe_cast_ref())
1131        }
1132        unsafe {
1133            let f: Box_<F> = Box_::new(f);
1134            connect_raw(
1135                self.as_ptr() as *mut _,
1136                b"notify::popup-single-match\0".as_ptr() as *const _,
1137                Some(transmute::<_, unsafe extern "C" fn()>(
1138                    notify_popup_single_match_trampoline::<Self, F> as *const (),
1139                )),
1140                Box_::into_raw(f),
1141            )
1142        }
1143    }
1144
1145    #[doc(alias = "text-column")]
1146    fn connect_text_column_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1147        unsafe extern "C" fn notify_text_column_trampoline<
1148            P: IsA<EntryCompletion>,
1149            F: Fn(&P) + 'static,
1150        >(
1151            this: *mut ffi::GtkEntryCompletion,
1152            _param_spec: glib::ffi::gpointer,
1153            f: glib::ffi::gpointer,
1154        ) {
1155            let f: &F = &*(f as *const F);
1156            f(EntryCompletion::from_glib_borrow(this).unsafe_cast_ref())
1157        }
1158        unsafe {
1159            let f: Box_<F> = Box_::new(f);
1160            connect_raw(
1161                self.as_ptr() as *mut _,
1162                b"notify::text-column\0".as_ptr() as *const _,
1163                Some(transmute::<_, unsafe extern "C" fn()>(
1164                    notify_text_column_trampoline::<Self, F> as *const (),
1165                )),
1166                Box_::into_raw(f),
1167            )
1168        }
1169    }
1170}
1171
1172impl<O: IsA<EntryCompletion>> EntryCompletionExt for O {}
1173
1174impl fmt::Display for EntryCompletion {
1175    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
1176        f.write_str("EntryCompletion")
1177    }
1178}