Skip to main content

gtk4/auto/
text.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
5#[cfg(feature = "v4_10")]
6#[cfg_attr(docsrs, doc(cfg(feature = "v4_10")))]
7use crate::Accessible;
8#[cfg(feature = "v4_14")]
9#[cfg_attr(docsrs, doc(cfg(feature = "v4_14")))]
10use crate::AccessibleText;
11use crate::{
12    AccessibleRole, Align, Buildable, ConstraintTarget, Editable, EntryBuffer, InputHints,
13    InputPurpose, LayoutManager, Overflow, Widget, ffi,
14};
15use glib::{
16    prelude::*,
17    signal::{SignalHandlerId, connect_raw},
18    translate::*,
19};
20use std::boxed::Box as Box_;
21
22#[cfg(all(feature = "v4_10", feature = "v4_14"))]
23#[cfg_attr(docsrs, doc(cfg(feature = "v4_14")))]
24glib::wrapper! {
25    /// A single-line text entry.
26    ///
27    /// [`Text`][crate::Text] is the common implementation of single-line text editing
28    /// that is shared between [`Entry`][crate::Entry], [`PasswordEntry`][crate::PasswordEntry],
29    /// [`SpinButton`][crate::SpinButton], and other widgets. In all of these, a [`Text`][crate::Text]
30    /// instance is used as the delegate for the [`Editable`][crate::Editable] implementation.
31    ///
32    /// A large number of key bindings s supported by default. If the entered
33    /// text is longer than the allocation of the widget, the widget will scroll
34    /// so that the cursor position is visible.
35    ///
36    /// When using an entry for passwords and other sensitive information,
37    /// it can be put into “password mode” using [`set_visibility()`][Self::set_visibility()].
38    /// In this mode, entered text is displayed using an “invisible” character.
39    /// By default, GTK picks the best invisible character that is available
40    /// in the current font, but it can be changed with
41    /// [`set_invisible_char()`][Self::set_invisible_char()].
42    ///
43    /// If you want to add icons or progress display in an entry, look at
44    /// [`Entry`][crate::Entry]. There are other alternatives for more specialized
45    /// use cases, such as [`SearchEntry`][crate::SearchEntry].
46    ///
47    /// If you need multi-line editable text, use [`TextView`][crate::TextView].
48    ///
49    /// # Shortcuts and Gestures
50    ///
51    /// [`Text`][crate::Text] supports the following keyboard shortcuts:
52    ///
53    /// - <kbd>Shift</kbd>+<kbd>F10</kbd> or <kbd>Menu</kbd> opens the context menu.
54    /// - <kbd>Ctrl</kbd>+<kbd>A</kbd> or <kbd>Ctrl</kbd>+<kbd>&sol;</kbd>
55    ///   selects all the text.
56    /// - <kbd>Ctrl</kbd>+<kbd>Shift</kbd>+<kbd>A</kbd> or
57    ///   <kbd>Ctrl</kbd>+<kbd>&bsol;</kbd> unselects all.
58    /// - <kbd>Ctrl</kbd>+<kbd>Z</kbd> undoes the last modification.
59    /// - <kbd>Ctrl</kbd>+<kbd>Y</kbd> or <kbd>Ctrl</kbd>+<kbd>Shift</kbd>+<kbd>Z</kbd>
60    ///   redoes the last undone modification.
61    /// - <kbd>Ctrl</kbd>+<kbd>Shift</kbd>+<kbd>T</kbd> toggles the text direction.
62    /// - <kbd>Clear</kbd> clears the content.
63    ///
64    /// Additionally, the following signals have default keybindings:
65    ///
66    /// - [`activate`][struct@crate::Text#activate]
67    /// - [`backspace`][struct@crate::Text#backspace]
68    /// - [`copy-clipboard`][struct@crate::Text#copy-clipboard]
69    /// - [`cut-clipboard`][struct@crate::Text#cut-clipboard]
70    /// - [`delete-from-cursor`][struct@crate::Text#delete-from-cursor]
71    /// - [`insert-emoji`][struct@crate::Text#insert-emoji]
72    /// - [`move-cursor`][struct@crate::Text#move-cursor]
73    /// - [`paste-clipboard`][struct@crate::Text#paste-clipboard]
74    /// - [`toggle-overwrite`][struct@crate::Text#toggle-overwrite]
75    ///
76    /// # Actions
77    ///
78    /// [`Text`][crate::Text] defines a set of built-in actions:
79    ///
80    /// - `clipboard.copy` copies the contents to the clipboard.
81    /// - `clipboard.cut` copies the contents to the clipboard and deletes it from
82    ///   the widget.
83    /// - `clipboard.paste` inserts the contents of the clipboard into the widget.
84    /// - `menu.popup` opens the context menu.
85    /// - `misc.insert-emoji` opens the Emoji chooser.
86    /// - `misc.toggle-visibility` toggles the [`Text`][crate::Text]:visibility property.
87    /// - `misc.toggle-direction` toggles the text direction.
88    /// - `selection.delete` deletes the current selection.
89    /// - `selection.select-all` selects all of the widgets content.
90    /// - `text.redo` redoes the last change to the contents.
91    /// - `text.undo` undoes the last change to the contents.
92    /// - `text.clear` removes all content.
93    ///
94    /// # CSS nodes
95    ///
96    /// ```text
97    /// text[.read-only]
98    /// ├── placeholder
99    /// ├── undershoot.left
100    /// ├── undershoot.right
101    /// ├── [selection]
102    /// ├── [block-cursor]
103    /// ├── [cursor-handle[.top/.bottom][.insertion-cursor]]
104    /// ├── [preedit[.whole][.selection][.prediction][.prefix/.suffix][.spelling-error][.compose-error]]
105    /// ╰── [window.popup]
106    /// ```
107    ///
108    /// [`Text`][crate::Text] has a main node with the name `text`. Depending on the properties
109    /// of the widget, the `.read-only` style class may appear.
110    ///
111    /// When the entry has a selection, it adds a subnode with the name `selection`.
112    ///
113    /// When the entry is in overwrite mode, it adds a subnode with the name
114    /// `block-cursor` that determines how the block cursor is drawn.
115    ///
116    /// The CSS node for a context menu is added as a subnode with the name `popup`.
117    ///
118    /// The `undershoot` nodes are used to draw the underflow indication when content
119    /// is scrolled out of view. These nodes get the `.left` or `.right` style class
120    /// added depending on where the indication is drawn.
121    ///
122    /// When touch is used and touch selection handles are shown, they are using
123    /// CSS nodes with name `cursor-handle`. They get the `.top` or `.bottom` style
124    /// class depending on where they are shown in relation to the selection. If
125    /// there is just a single handle for the text cursor, it gets the style class
126    /// `.insertion-cursor`.
127    ///
128    /// If using an input method with a pre-edit buffer, this string will be styled
129    /// with the `preedit` CSS node, the different style classes express the possible
130    /// roles of a piece of text in the pre-edit buffer:
131    ///
132    /// - `.whole` denotes the parts of the pre-edit buffer without a special role
133    /// - `.selection`, `.prefix` and `.suffix` style classes will be used to
134    ///   highlight the specific portions of the pre-edit buffer being edited and its
135    ///   surroundings
136    /// - `.prediction` will be used for parts of the pre-edit buffer not typed by the
137    ///   user (e.g. autocompletion)
138    /// - `.spelling-error` and `.compose-error` will be respectively used to indicate
139    ///   errors in spelling or character composition (e.g. non-existent transliterations).
140    ///
141    /// # Accessibility
142    ///
143    /// [`Text`][crate::Text] uses the [enum@Gtk.AccessibleRole.none] role, which causes it to be
144    /// skipped for accessibility. This is because [`Text`][crate::Text] is expected to be used
145    /// as a delegate for a [`Editable`][crate::Editable] implementation that will be represented
146    /// to accessibility.
147    ///
148    /// ## Properties
149    ///
150    ///
151    /// #### `activates-default`
152    ///  Whether to activate the default widget when <kbd>Enter</kbd> is pressed.
153    ///
154    /// Readable | Writable
155    ///
156    ///
157    /// #### `attributes`
158    ///  A list of Pango attributes to apply to the text.
159    ///
160    /// This is mainly useful to change the size or weight of the text.
161    ///
162    /// The `PangoAttribute`'s @start_index and @end_index must refer to the
163    /// [`EntryBuffer`][crate::EntryBuffer] text, i.e. without the preedit string.
164    ///
165    /// Readable | Writable
166    ///
167    ///
168    /// #### `buffer`
169    ///  The [`EntryBuffer`][crate::EntryBuffer] object which stores the text.
170    ///
171    /// Readable | Writable | Construct
172    ///
173    ///
174    /// #### `enable-emoji-completion`
175    ///  Whether to suggest Emoji replacements.
176    ///
177    /// Readable | Writable
178    ///
179    ///
180    /// #### `extra-menu`
181    ///  A menu model whose contents will be appended to the context menu.
182    ///
183    /// Readable | Writable
184    ///
185    ///
186    /// #### `im-module`
187    ///  Which input method module should be used.
188    ///
189    /// See [`IMMulticontext`][crate::IMMulticontext].
190    ///
191    /// Setting this to a non-`NULL` value overrides the system-wide
192    /// input method. See the [`gtk-im-module`][struct@crate::Settings#gtk-im-module]
193    /// setting.
194    ///
195    /// Readable | Writable
196    ///
197    ///
198    /// #### `input-hints`
199    ///  Additional hints that allow input methods to fine-tune
200    /// their behaviour.
201    ///
202    /// Readable | Writable
203    ///
204    ///
205    /// #### `input-purpose`
206    ///  The purpose of this text field.
207    ///
208    /// This information can be used by on-screen keyboards and other input
209    /// methods to adjust their behaviour.
210    ///
211    /// Note that setting the purpose to [enum@Gtk.InputPurpose.password]
212    /// or [enum@Gtk.InputPurpose.pin] is independent from setting
213    /// [`visibility`][struct@crate::Text#visibility].
214    ///
215    /// Readable | Writable
216    ///
217    ///
218    /// #### `invisible-char`
219    ///  The character to used when masking contents (in “password mode”).
220    ///
221    /// Readable | Writable
222    ///
223    ///
224    /// #### `invisible-char-set`
225    ///  Whether the invisible char has been set.
226    ///
227    /// Readable | Writable
228    ///
229    ///
230    /// #### `max-length`
231    ///  Maximum number of characters that are allowed.
232    ///
233    /// Zero indicates no limit.
234    ///
235    /// Readable | Writable
236    ///
237    ///
238    /// #### `overwrite-mode`
239    ///  If text is overwritten when typing.
240    ///
241    /// Readable | Writable
242    ///
243    ///
244    /// #### `placeholder-text`
245    ///  The text that will be displayed in the [`Text`][crate::Text] when it is empty
246    /// and unfocused.
247    ///
248    /// Readable | Writable
249    ///
250    ///
251    /// #### `propagate-text-width`
252    ///  Whether the widget should grow and shrink with the content.
253    ///
254    /// Readable | Writable
255    ///
256    ///
257    /// #### `scroll-offset`
258    ///  Number of pixels scrolled of the screen to the left.
259    ///
260    /// Readable
261    ///
262    ///
263    /// #### `tabs`
264    ///  Custom tabs for this text widget.
265    ///
266    /// Readable | Writable
267    ///
268    ///
269    /// #### `truncate-multiline`
270    ///  When true, pasted multi-line text is truncated to the first line.
271    ///
272    /// Readable | Writable
273    ///
274    ///
275    /// #### `visibility`
276    ///  If false, the text is masked with the “invisible char”.
277    ///
278    /// Readable | Writable
279    /// <details><summary><h4>Widget</h4></summary>
280    ///
281    ///
282    /// #### `can-focus`
283    ///  Whether the widget or any of its descendents can accept
284    /// the input focus.
285    ///
286    /// This property is meant to be set by widget implementations,
287    /// typically in their instance init function.
288    ///
289    /// Readable | Writable
290    ///
291    ///
292    /// #### `can-target`
293    ///  Whether the widget can receive pointer events.
294    ///
295    /// Readable | Writable
296    ///
297    ///
298    /// #### `css-classes`
299    ///  A list of css classes applied to this widget.
300    ///
301    /// Readable | Writable
302    ///
303    ///
304    /// #### `css-name`
305    ///  The name of this widget in the CSS tree.
306    ///
307    /// This property is meant to be set by widget implementations,
308    /// typically in their instance init function.
309    ///
310    /// Readable | Writable | Construct Only
311    ///
312    ///
313    /// #### `cursor`
314    ///  The cursor used by @widget.
315    ///
316    /// Readable | Writable
317    ///
318    ///
319    /// #### `focus-on-click`
320    ///  Whether the widget should grab focus when it is clicked with the mouse.
321    ///
322    /// This property is only relevant for widgets that can take focus.
323    ///
324    /// Readable | Writable
325    ///
326    ///
327    /// #### `focusable`
328    ///  Whether this widget itself will accept the input focus.
329    ///
330    /// Readable | Writable
331    ///
332    ///
333    /// #### `halign`
334    ///  How to distribute horizontal space if widget gets extra space.
335    ///
336    /// Readable | Writable
337    ///
338    ///
339    /// #### `has-default`
340    ///  Whether the widget is the default widget.
341    ///
342    /// Readable
343    ///
344    ///
345    /// #### `has-focus`
346    ///  Whether the widget has the input focus.
347    ///
348    /// Readable
349    ///
350    ///
351    /// #### `has-tooltip`
352    ///  Enables or disables the emission of the [`query-tooltip`][struct@crate::Widget#query-tooltip]
353    /// signal on @widget.
354    ///
355    /// A true value indicates that @widget can have a tooltip, in this case
356    /// the widget will be queried using [`query-tooltip`][struct@crate::Widget#query-tooltip] to
357    /// determine whether it will provide a tooltip or not.
358    ///
359    /// Readable | Writable
360    ///
361    ///
362    /// #### `height-request`
363    ///  Overrides for height request of the widget.
364    ///
365    /// If this is -1, the natural request will be used.
366    ///
367    /// Readable | Writable
368    ///
369    ///
370    /// #### `hexpand`
371    ///  Whether to expand horizontally.
372    ///
373    /// Readable | Writable
374    ///
375    ///
376    /// #### `hexpand-set`
377    ///  Whether to use the `hexpand` property.
378    ///
379    /// Readable | Writable
380    ///
381    ///
382    /// #### `layout-manager`
383    ///  The [`LayoutManager`][crate::LayoutManager] instance to use to compute
384    /// the preferred size of the widget, and allocate its children.
385    ///
386    /// This property is meant to be set by widget implementations,
387    /// typically in their instance init function.
388    ///
389    /// Readable | Writable
390    ///
391    ///
392    /// #### `limit-events`
393    ///  Makes this widget act like a modal dialog, with respect to
394    /// event delivery.
395    ///
396    /// Global event controllers will not handle events with targets
397    /// inside the widget, unless they are set up to ignore propagation
398    /// limits. See [`EventControllerExt::set_propagation_limit()`][crate::prelude::EventControllerExt::set_propagation_limit()].
399    ///
400    /// Readable | Writable
401    ///
402    ///
403    /// #### `margin-bottom`
404    ///  Margin on bottom side of widget.
405    ///
406    /// This property adds margin outside of the widget's normal size
407    /// request, the margin will be added in addition to the size from
408    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
409    ///
410    /// Readable | Writable
411    ///
412    ///
413    /// #### `margin-end`
414    ///  Margin on end of widget, horizontally.
415    ///
416    /// This property supports left-to-right and right-to-left text
417    /// directions.
418    ///
419    /// This property adds margin outside of the widget's normal size
420    /// request, the margin will be added in addition to the size from
421    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
422    ///
423    /// Readable | Writable
424    ///
425    ///
426    /// #### `margin-start`
427    ///  Margin on start of widget, horizontally.
428    ///
429    /// This property supports left-to-right and right-to-left text
430    /// directions.
431    ///
432    /// This property adds margin outside of the widget's normal size
433    /// request, the margin will be added in addition to the size from
434    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
435    ///
436    /// Readable | Writable
437    ///
438    ///
439    /// #### `margin-top`
440    ///  Margin on top side of widget.
441    ///
442    /// This property adds margin outside of the widget's normal size
443    /// request, the margin will be added in addition to the size from
444    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
445    ///
446    /// Readable | Writable
447    ///
448    ///
449    /// #### `name`
450    ///  The name of the widget.
451    ///
452    /// Readable | Writable
453    ///
454    ///
455    /// #### `opacity`
456    ///  The requested opacity of the widget.
457    ///
458    /// Readable | Writable
459    ///
460    ///
461    /// #### `overflow`
462    ///  How content outside the widget's content area is treated.
463    ///
464    /// This property is meant to be set by widget implementations,
465    /// typically in their instance init function.
466    ///
467    /// Readable | Writable
468    ///
469    ///
470    /// #### `parent`
471    ///  The parent widget of this widget.
472    ///
473    /// Readable
474    ///
475    ///
476    /// #### `receives-default`
477    ///  Whether the widget will receive the default action when it is focused.
478    ///
479    /// Readable | Writable
480    ///
481    ///
482    /// #### `root`
483    ///  The [`Root`][crate::Root] widget of the widget tree containing this widget.
484    ///
485    /// This will be `NULL` if the widget is not contained in a root widget.
486    ///
487    /// Readable
488    ///
489    ///
490    /// #### `scale-factor`
491    ///  The scale factor of the widget.
492    ///
493    /// Readable
494    ///
495    ///
496    /// #### `sensitive`
497    ///  Whether the widget responds to input.
498    ///
499    /// Readable | Writable
500    ///
501    ///
502    /// #### `tooltip-markup`
503    ///  Sets the text of tooltip to be the given string, which is marked up
504    /// with Pango markup.
505    ///
506    /// Also see [`Tooltip::set_markup()`][crate::Tooltip::set_markup()].
507    ///
508    /// This is a convenience property which will take care of getting the
509    /// tooltip shown if the given string is not `NULL`:
510    /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
511    /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
512    /// the default signal handler.
513    ///
514    /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
515    /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
516    ///
517    /// Readable | Writable
518    ///
519    ///
520    /// #### `tooltip-text`
521    ///  Sets the text of tooltip to be the given string.
522    ///
523    /// Also see [`Tooltip::set_text()`][crate::Tooltip::set_text()].
524    ///
525    /// This is a convenience property which will take care of getting the
526    /// tooltip shown if the given string is not `NULL`:
527    /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
528    /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
529    /// the default signal handler.
530    ///
531    /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
532    /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
533    ///
534    /// Readable | Writable
535    ///
536    ///
537    /// #### `valign`
538    ///  How to distribute vertical space if widget gets extra space.
539    ///
540    /// Readable | Writable
541    ///
542    ///
543    /// #### `vexpand`
544    ///  Whether to expand vertically.
545    ///
546    /// Readable | Writable
547    ///
548    ///
549    /// #### `vexpand-set`
550    ///  Whether to use the `vexpand` property.
551    ///
552    /// Readable | Writable
553    ///
554    ///
555    /// #### `visible`
556    ///  Whether the widget is visible.
557    ///
558    /// Readable | Writable
559    ///
560    ///
561    /// #### `width-request`
562    ///  Overrides for width request of the widget.
563    ///
564    /// If this is -1, the natural request will be used.
565    ///
566    /// Readable | Writable
567    /// </details>
568    /// <details><summary><h4>Accessible</h4></summary>
569    ///
570    ///
571    /// #### `accessible-role`
572    ///  The accessible role of the given [`Accessible`][crate::Accessible] implementation.
573    ///
574    /// The accessible role cannot be changed once set.
575    ///
576    /// Readable | Writable
577    /// </details>
578    /// <details><summary><h4>Editable</h4></summary>
579    ///
580    ///
581    /// #### `complete-text`
582    ///  The contents of the entry, including uncommited content such as the
583    /// preedit.
584    ///
585    /// Readable
586    ///
587    ///
588    /// #### `cursor-position`
589    ///  The current position of the insertion cursor in chars.
590    ///
591    /// Readable
592    ///
593    ///
594    /// #### `editable`
595    ///  Whether the entry contents can be edited.
596    ///
597    /// Readable | Writable
598    ///
599    ///
600    /// #### `enable-undo`
601    ///  If undo/redo should be enabled for the editable.
602    ///
603    /// Readable | Writable
604    ///
605    ///
606    /// #### `max-width-chars`
607    ///  The desired maximum width of the entry, in characters.
608    ///
609    /// Readable | Writable
610    ///
611    ///
612    /// #### `selection-bound`
613    ///  The position of the opposite end of the selection from the cursor in chars.
614    ///
615    /// Readable
616    ///
617    ///
618    /// #### `text`
619    ///  The contents of the entry.
620    ///
621    /// Readable | Writable
622    ///
623    ///
624    /// #### `width-chars`
625    ///  Number of characters to leave space for in the entry.
626    ///
627    /// Readable | Writable
628    ///
629    ///
630    /// #### `xalign`
631    ///  The horizontal alignment, from 0 (left) to 1 (right).
632    ///
633    /// Reversed for RTL layouts.
634    ///
635    /// Readable | Writable
636    /// </details>
637    ///
638    /// ## Signals
639    ///
640    ///
641    /// #### `activate`
642    ///  Emitted when the user hits the <kbd>Enter</kbd> key.
643    ///
644    /// The default bindings for this signal are all forms
645    /// of the <kbd>Enter</kbd> key.
646    ///
647    /// Action
648    ///
649    ///
650    /// #### `backspace`
651    ///  Emitted when the user asks for it.
652    ///
653    /// This is a [keybinding signal](class.SignalAction.html).
654    ///
655    /// The default bindings for this signal are
656    /// <kbd>Backspace</kbd> and <kbd>Shift</kbd>+<kbd>Backspace</kbd>.
657    ///
658    /// Action
659    ///
660    ///
661    /// #### `copy-clipboard`
662    ///  Emitted to copy the selection to the clipboard.
663    ///
664    /// This is a [keybinding signal](class.SignalAction.html).
665    ///
666    /// The default bindings for this signal are
667    /// <kbd>Ctrl</kbd>+<kbd>c</kbd> and
668    /// <kbd>Ctrl</kbd>+<kbd>Insert</kbd>.
669    ///
670    /// Action
671    ///
672    ///
673    /// #### `cut-clipboard`
674    ///  Emitted to cut the selection to the clipboard.
675    ///
676    /// This is a [keybinding signal](class.SignalAction.html).
677    ///
678    /// The default bindings for this signal are
679    /// <kbd>Ctrl</kbd>+<kbd>x</kbd> and
680    /// <kbd>Shift</kbd>+<kbd>Delete</kbd>.
681    ///
682    /// Action
683    ///
684    ///
685    /// #### `delete-from-cursor`
686    ///  Emitted when the user initiates a text deletion.
687    ///
688    /// This is a [keybinding signal](class.SignalAction.html).
689    ///
690    /// If the @type_ is [enum@Gtk.DeleteType.chars], GTK deletes the
691    /// selection if there is one, otherwise it deletes the requested
692    /// number of characters.
693    ///
694    /// The default bindings for this signal are <kbd>Delete</kbd>
695    /// for deleting a character and <kbd>Ctrl</kbd>+<kbd>Delete</kbd>
696    /// for deleting a word.
697    ///
698    /// Action
699    ///
700    ///
701    /// #### `insert-at-cursor`
702    ///  Emitted when the user initiates the insertion of a
703    /// fixed string at the cursor.
704    ///
705    /// This is a [keybinding signal](class.SignalAction.html).
706    ///
707    /// This signal has no default bindings.
708    ///
709    /// Action
710    ///
711    ///
712    /// #### `insert-emoji`
713    ///  Emitted to present the Emoji chooser.
714    ///
715    /// This is a [keybinding signal](class.SignalAction.html).
716    ///
717    /// The default bindings for this signal are
718    /// <kbd>Ctrl</kbd>+<kbd>.</kbd> and
719    /// <kbd>Ctrl</kbd>+<kbd>;</kbd>
720    ///
721    /// Action
722    ///
723    ///
724    /// #### `move-cursor`
725    ///  Emitted when the user initiates a cursor movement.
726    ///
727    /// If the cursor is not visible in @self_, this signal causes
728    /// the viewport to be moved instead.
729    ///
730    /// This is a [keybinding signal](class.SignalAction.html).
731    ///
732    /// Applications should not connect to it, but may emit it with
733    /// `signal_emit_by_name()` if they need to control
734    /// the cursor programmatically.
735    ///
736    /// The default bindings for this signal come in two variants,
737    /// the variant with the <kbd>Shift</kbd> modifier extends the
738    /// selection, the variant without it does not.
739    /// There are too many key combinations to list them all here.
740    ///
741    /// - <kbd>←</kbd>, <kbd>→</kbd>, <kbd>↑</kbd>, <kbd>↓</kbd>
742    ///   move by individual characters/lines
743    /// - <kbd>Ctrl</kbd>+<kbd>←</kbd>, etc. move by words/paragraphs
744    /// - <kbd>Home</kbd> and <kbd>End</kbd> move to the ends of the buffer
745    ///
746    /// Action
747    ///
748    ///
749    /// #### `paste-clipboard`
750    ///  Emitted to paste the contents of the clipboard.
751    ///
752    /// This is a [keybinding signal](class.SignalAction.html).
753    ///
754    /// The default bindings for this signal are
755    /// <kbd>Ctrl</kbd>+<kbd>v</kbd> and <kbd>Shift</kbd>+<kbd>Insert</kbd>.
756    ///
757    /// Action
758    ///
759    ///
760    /// #### `preedit-changed`
761    ///  Emitted when the preedit text changes.
762    ///
763    /// If an input method is used, the typed text will not immediately
764    /// be committed to the buffer. So if you are interested in the text,
765    /// connect to this signal.
766    ///
767    /// Action
768    ///
769    ///
770    /// #### `toggle-overwrite`
771    ///  Emitted to toggle the overwrite mode.
772    ///
773    /// This is a [keybinding signal](class.SignalAction.html).
774    ///
775    /// The default bindings for this signal is <kbd>Insert</kbd>.
776    ///
777    /// Action
778    /// <details><summary><h4>Widget</h4></summary>
779    ///
780    ///
781    /// #### `destroy`
782    ///  Signals that all holders of a reference to the widget should release
783    /// the reference that they hold.
784    ///
785    /// May result in finalization of the widget if all references are released.
786    ///
787    /// This signal is not suitable for saving widget state.
788    ///
789    ///
790    ///
791    ///
792    /// #### `direction-changed`
793    ///  Emitted when the text direction of a widget changes.
794    ///
795    ///
796    ///
797    ///
798    /// #### `hide`
799    ///  Emitted when @widget is hidden.
800    ///
801    ///
802    ///
803    ///
804    /// #### `keynav-failed`
805    ///  Emitted if keyboard navigation fails.
806    ///
807    /// See [`WidgetExt::keynav_failed()`][crate::prelude::WidgetExt::keynav_failed()] for details.
808    ///
809    ///
810    ///
811    ///
812    /// #### `map`
813    ///  Emitted when @widget is going to be mapped.
814    ///
815    /// A widget is mapped when the widget is visible (which is controlled with
816    /// [`visible`][struct@crate::Widget#visible]) and all its parents up to the toplevel widget
817    /// are also visible.
818    ///
819    /// The `::map` signal can be used to determine whether a widget will be drawn,
820    /// for instance it can resume an animation that was stopped during the
821    /// emission of [`unmap`][struct@crate::Widget#unmap].
822    ///
823    ///
824    ///
825    ///
826    /// #### `mnemonic-activate`
827    ///  Emitted when a widget is activated via a mnemonic.
828    ///
829    /// The default handler for this signal activates @widget if @group_cycling
830    /// is false, or just makes @widget grab focus if @group_cycling is true.
831    ///
832    ///
833    ///
834    ///
835    /// #### `move-focus`
836    ///  Emitted when the focus is moved.
837    ///
838    /// The `::move-focus` signal is a [keybinding signal](class.SignalAction.html).
839    ///
840    /// The default bindings for this signal are <kbd>Tab</kbd> to move forward,
841    /// and <kbd>Shift</kbd>+<kbd>Tab</kbd> to move backward.
842    ///
843    /// Action
844    ///
845    ///
846    /// #### `query-tooltip`
847    ///  Emitted when the widget’s tooltip is about to be shown.
848    ///
849    /// This happens when the [`has-tooltip`][struct@crate::Widget#has-tooltip] property
850    /// is true and the hover timeout has expired with the cursor hovering
851    /// above @widget; or emitted when @widget got focus in keyboard mode.
852    ///
853    /// Using the given coordinates, the signal handler should determine
854    /// whether a tooltip should be shown for @widget. If this is the case
855    /// true should be returned, false otherwise. Note that if @keyboard_mode
856    /// is true, the values of @x and @y are undefined and should not be used.
857    ///
858    /// The signal handler is free to manipulate @tooltip with the therefore
859    /// destined function calls.
860    ///
861    ///
862    ///
863    ///
864    /// #### `realize`
865    ///  Emitted when @widget is associated with a [`gdk::Surface`][crate::gdk::Surface].
866    ///
867    /// This means that [`WidgetExt::realize()`][crate::prelude::WidgetExt::realize()] has been called
868    /// or the widget has been mapped (that is, it is going to be drawn).
869    ///
870    ///
871    ///
872    ///
873    /// #### `show`
874    ///  Emitted when @widget is shown.
875    ///
876    ///
877    ///
878    ///
879    /// #### `state-flags-changed`
880    ///  Emitted when the widget state changes.
881    ///
882    /// See [`WidgetExt::state_flags()`][crate::prelude::WidgetExt::state_flags()].
883    ///
884    ///
885    ///
886    ///
887    /// #### `unmap`
888    ///  Emitted when @widget is going to be unmapped.
889    ///
890    /// A widget is unmapped when either it or any of its parents up to the
891    /// toplevel widget have been set as hidden.
892    ///
893    /// As `::unmap` indicates that a widget will not be shown any longer,
894    /// it can be used to, for example, stop an animation on the widget.
895    ///
896    ///
897    ///
898    ///
899    /// #### `unrealize`
900    ///  Emitted when the [`gdk::Surface`][crate::gdk::Surface] associated with @widget is destroyed.
901    ///
902    /// This means that [`WidgetExt::unrealize()`][crate::prelude::WidgetExt::unrealize()] has been called
903    /// or the widget has been unmapped (that is, it is going to be hidden).
904    ///
905    ///
906    /// </details>
907    /// <details><summary><h4>Editable</h4></summary>
908    ///
909    ///
910    /// #### `changed`
911    ///  Emitted at the end of a single user-visible operation on the
912    /// contents.
913    ///
914    /// E.g., a paste operation that replaces the contents of the
915    /// selection will cause only one signal emission (even though it
916    /// is implemented by first deleting the selection, then inserting
917    /// the new content, and may cause multiple ::notify::text signals
918    /// to be emitted).
919    ///
920    ///
921    ///
922    ///
923    /// #### `delete-text`
924    ///  Emitted when text is deleted from the widget by the user.
925    ///
926    /// The default handler for this signal will normally be responsible for
927    /// deleting the text, so by connecting to this signal and then stopping
928    /// the signal with g_signal_stop_emission(), it is possible to modify the
929    /// range of deleted text, or prevent it from being deleted entirely.
930    ///
931    /// The @start_pos and @end_pos parameters are interpreted as for
932    /// [`EditableExt::delete_text()`][crate::prelude::EditableExt::delete_text()].
933    ///
934    ///
935    ///
936    ///
937    /// #### `insert-text`
938    ///  Emitted when text is inserted into the widget by the user.
939    ///
940    /// The default handler for this signal will normally be responsible
941    /// for inserting the text, so by connecting to this signal and then
942    /// stopping the signal with g_signal_stop_emission(), it is possible
943    /// to modify the inserted text, or prevent it from being inserted entirely.
944    ///
945    ///
946    /// </details>
947    ///
948    /// # Implements
949    ///
950    /// [`WidgetExt`][trait@crate::prelude::WidgetExt], [`trait@glib::ObjectExt`], [`AccessibleExt`][trait@crate::prelude::AccessibleExt], [`BuildableExt`][trait@crate::prelude::BuildableExt], [`ConstraintTargetExt`][trait@crate::prelude::ConstraintTargetExt], [`AccessibleTextExt`][trait@crate::prelude::AccessibleTextExt], [`EditableExt`][trait@crate::prelude::EditableExt], [`WidgetExtManual`][trait@crate::prelude::WidgetExtManual], [`AccessibleExtManual`][trait@crate::prelude::AccessibleExtManual], [`EditableExtManual`][trait@crate::prelude::EditableExtManual]
951    #[doc(alias = "GtkText")]
952    pub struct Text(Object<ffi::GtkText>) @extends Widget, @implements Accessible, Buildable, ConstraintTarget, AccessibleText, Editable;
953
954    match fn {
955        type_ => || ffi::gtk_text_get_type(),
956    }
957}
958
959#[cfg(all(feature = "v4_10", not(feature = "v4_14")))]
960glib::wrapper! {
961    #[doc(alias = "GtkText")]
962    pub struct Text(Object<ffi::GtkText>) @extends Widget, @implements Accessible, Buildable, ConstraintTarget, Editable;
963
964    match fn {
965        type_ => || ffi::gtk_text_get_type(),
966    }
967}
968
969#[cfg(not(any(feature = "v4_10", feature = "v4_14")))]
970glib::wrapper! {
971    #[doc(alias = "GtkText")]
972    pub struct Text(Object<ffi::GtkText>) @extends Widget, @implements Buildable, ConstraintTarget, Editable;
973
974    match fn {
975        type_ => || ffi::gtk_text_get_type(),
976    }
977}
978
979impl Text {
980    /// Creates a new [`Text`][crate::Text].
981    ///
982    /// # Returns
983    ///
984    /// the new [`Text`][crate::Text]
985    #[doc(alias = "gtk_text_new")]
986    pub fn new() -> Text {
987        assert_initialized_main_thread!();
988        unsafe { Widget::from_glib_none(ffi::gtk_text_new()).unsafe_cast() }
989    }
990
991    /// Creates a new [`Text`][crate::Text] with the specified buffer.
992    /// ## `buffer`
993    /// the buffer to use
994    ///
995    /// # Returns
996    ///
997    /// a new [`Text`][crate::Text]
998    #[doc(alias = "gtk_text_new_with_buffer")]
999    #[doc(alias = "new_with_buffer")]
1000    pub fn with_buffer(buffer: &impl IsA<EntryBuffer>) -> Text {
1001        skip_assert_initialized!();
1002        unsafe {
1003            Widget::from_glib_none(ffi::gtk_text_new_with_buffer(
1004                buffer.as_ref().to_glib_none().0,
1005            ))
1006            .unsafe_cast()
1007        }
1008    }
1009
1010    // rustdoc-stripper-ignore-next
1011    /// Creates a new builder-pattern struct instance to construct [`Text`] objects.
1012    ///
1013    /// This method returns an instance of [`TextBuilder`](crate::builders::TextBuilder) which can be used to create [`Text`] objects.
1014    pub fn builder() -> TextBuilder {
1015        TextBuilder::new()
1016    }
1017
1018    /// Determines the positions of the strong and weak cursors for a
1019    /// given character position.
1020    ///
1021    /// The position of each cursor is stored as a zero-width rectangle.
1022    /// The strong cursor location is the location where characters of
1023    /// the directionality equal to the base direction are inserted.
1024    /// The weak cursor location is the location where characters of
1025    /// the directionality opposite to the base direction are inserted.
1026    ///
1027    /// The rectangle positions are in widget coordinates.
1028    /// ## `position`
1029    /// the character position
1030    ///
1031    /// # Returns
1032    ///
1033    ///
1034    /// ## `strong`
1035    /// location to store the strong cursor position
1036    ///
1037    /// ## `weak`
1038    /// location to store the weak cursor position
1039    #[cfg(feature = "v4_4")]
1040    #[cfg_attr(docsrs, doc(cfg(feature = "v4_4")))]
1041    #[doc(alias = "gtk_text_compute_cursor_extents")]
1042    pub fn compute_cursor_extents(&self, position: usize) -> (graphene::Rect, graphene::Rect) {
1043        unsafe {
1044            let mut strong = graphene::Rect::uninitialized();
1045            let mut weak = graphene::Rect::uninitialized();
1046            ffi::gtk_text_compute_cursor_extents(
1047                self.to_glib_none().0,
1048                position,
1049                strong.to_glib_none_mut().0,
1050                weak.to_glib_none_mut().0,
1051            );
1052            (strong, weak)
1053        }
1054    }
1055
1056    /// Returns whether pressing <kbd>Enter</kbd> will activate
1057    /// the default widget for the window containing the widget.
1058    ///
1059    /// See [`set_activates_default()`][Self::set_activates_default()].
1060    ///
1061    /// # Returns
1062    ///
1063    /// true if @self will activate the default widget
1064    #[doc(alias = "gtk_text_get_activates_default")]
1065    #[doc(alias = "get_activates_default")]
1066    #[doc(alias = "activates-default")]
1067    pub fn activates_default(&self) -> bool {
1068        unsafe { from_glib(ffi::gtk_text_get_activates_default(self.to_glib_none().0)) }
1069    }
1070
1071    /// Gets the attribute list that was set on the text widget.
1072    ///
1073    /// See [`set_attributes()`][Self::set_attributes()].
1074    ///
1075    /// # Returns
1076    ///
1077    /// the attribute list
1078    #[doc(alias = "gtk_text_get_attributes")]
1079    #[doc(alias = "get_attributes")]
1080    pub fn attributes(&self) -> Option<pango::AttrList> {
1081        unsafe { from_glib_none(ffi::gtk_text_get_attributes(self.to_glib_none().0)) }
1082    }
1083
1084    /// Get the entry buffer object which holds the text for
1085    /// this widget.
1086    ///
1087    /// # Returns
1088    ///
1089    /// the entry buffer object
1090    #[doc(alias = "gtk_text_get_buffer")]
1091    #[doc(alias = "get_buffer")]
1092    pub fn buffer(&self) -> EntryBuffer {
1093        unsafe { from_glib_none(ffi::gtk_text_get_buffer(self.to_glib_none().0)) }
1094    }
1095
1096    /// Returns whether Emoji completion is enabled.
1097    ///
1098    /// # Returns
1099    ///
1100    /// true if Emoji completion is enabled
1101    #[doc(alias = "gtk_text_get_enable_emoji_completion")]
1102    #[doc(alias = "get_enable_emoji_completion")]
1103    #[doc(alias = "enable-emoji-completion")]
1104    pub fn enables_emoji_completion(&self) -> bool {
1105        unsafe {
1106            from_glib(ffi::gtk_text_get_enable_emoji_completion(
1107                self.to_glib_none().0,
1108            ))
1109        }
1110    }
1111
1112    /// Gets the extra menu model of the text widget.
1113    ///
1114    /// See [`set_extra_menu()`][Self::set_extra_menu()].
1115    ///
1116    /// # Returns
1117    ///
1118    /// the menu model
1119    #[doc(alias = "gtk_text_get_extra_menu")]
1120    #[doc(alias = "get_extra_menu")]
1121    #[doc(alias = "extra-menu")]
1122    pub fn extra_menu(&self) -> Option<gio::MenuModel> {
1123        unsafe { from_glib_none(ffi::gtk_text_get_extra_menu(self.to_glib_none().0)) }
1124    }
1125
1126    /// Gets the input hints of the text widget.
1127    ///
1128    /// # Returns
1129    ///
1130    /// the input hints
1131    #[doc(alias = "gtk_text_get_input_hints")]
1132    #[doc(alias = "get_input_hints")]
1133    #[doc(alias = "input-hints")]
1134    pub fn input_hints(&self) -> InputHints {
1135        unsafe { from_glib(ffi::gtk_text_get_input_hints(self.to_glib_none().0)) }
1136    }
1137
1138    /// Gets the input purpose of the text widget.
1139    ///
1140    /// # Returns
1141    ///
1142    /// the input purpose
1143    #[doc(alias = "gtk_text_get_input_purpose")]
1144    #[doc(alias = "get_input_purpose")]
1145    #[doc(alias = "input-purpose")]
1146    pub fn input_purpose(&self) -> InputPurpose {
1147        unsafe { from_glib(ffi::gtk_text_get_input_purpose(self.to_glib_none().0)) }
1148    }
1149
1150    /// Retrieves the character displayed when visibility is set to false.
1151    ///
1152    /// Note that GTK does not compute this value unless it needs it,
1153    /// so the value returned by this function is not very useful unless
1154    /// it has been explicitly set with [`set_invisible_char()`][Self::set_invisible_char()].
1155    ///
1156    /// # Returns
1157    ///
1158    /// the current invisible char, or 0, if @text does not
1159    ///   show invisible text at all
1160    #[doc(alias = "gtk_text_get_invisible_char")]
1161    #[doc(alias = "get_invisible_char")]
1162    #[doc(alias = "invisible-char")]
1163    pub fn invisible_char(&self) -> char {
1164        unsafe {
1165            std::convert::TryFrom::try_from(ffi::gtk_text_get_invisible_char(self.to_glib_none().0))
1166                .expect("conversion from an invalid Unicode value attempted")
1167        }
1168    }
1169
1170    /// Retrieves the maximum allowed length of the contents.
1171    ///
1172    /// See [`set_max_length()`][Self::set_max_length()].
1173    ///
1174    /// This is equivalent to getting @self's [`EntryBuffer`][crate::EntryBuffer] and
1175    /// calling [`EntryBufferExtManual::max_length()`][crate::prelude::EntryBufferExtManual::max_length()] on it.
1176    ///
1177    /// # Returns
1178    ///
1179    /// the maximum allowed number of characters, or 0 if
1180    ///   there is no limit
1181    #[doc(alias = "gtk_text_get_max_length")]
1182    #[doc(alias = "get_max_length")]
1183    #[doc(alias = "max-length")]
1184    pub fn max_length(&self) -> i32 {
1185        unsafe { ffi::gtk_text_get_max_length(self.to_glib_none().0) }
1186    }
1187
1188    /// Gets whether text is overwritten when typing.
1189    ///
1190    /// See [`set_overwrite_mode()`][Self::set_overwrite_mode()].
1191    ///
1192    /// # Returns
1193    ///
1194    /// whether text is overwritten when typing
1195    #[doc(alias = "gtk_text_get_overwrite_mode")]
1196    #[doc(alias = "get_overwrite_mode")]
1197    #[doc(alias = "overwrite-mode")]
1198    pub fn is_overwrite_mode(&self) -> bool {
1199        unsafe { from_glib(ffi::gtk_text_get_overwrite_mode(self.to_glib_none().0)) }
1200    }
1201
1202    /// Retrieves the text that will be displayed when the text widget
1203    /// is empty and unfocused
1204    ///
1205    /// See [`set_placeholder_text()`][Self::set_placeholder_text()].
1206    ///
1207    /// # Returns
1208    ///
1209    /// the placeholder text
1210    #[doc(alias = "gtk_text_get_placeholder_text")]
1211    #[doc(alias = "get_placeholder_text")]
1212    #[doc(alias = "placeholder-text")]
1213    pub fn placeholder_text(&self) -> Option<glib::GString> {
1214        unsafe { from_glib_none(ffi::gtk_text_get_placeholder_text(self.to_glib_none().0)) }
1215    }
1216
1217    /// Returns whether the text widget will grow and shrink
1218    /// with the content.
1219    ///
1220    /// # Returns
1221    ///
1222    /// true if @self will propagate the text width
1223    #[doc(alias = "gtk_text_get_propagate_text_width")]
1224    #[doc(alias = "get_propagate_text_width")]
1225    #[doc(alias = "propagate-text-width")]
1226    pub fn propagates_text_width(&self) -> bool {
1227        unsafe {
1228            from_glib(ffi::gtk_text_get_propagate_text_width(
1229                self.to_glib_none().0,
1230            ))
1231        }
1232    }
1233
1234    /// Gets the tab stops for the text widget.
1235    ///
1236    /// See [`set_tabs()`][Self::set_tabs()].
1237    ///
1238    /// # Returns
1239    ///
1240    /// the tab stops
1241    #[doc(alias = "gtk_text_get_tabs")]
1242    #[doc(alias = "get_tabs")]
1243    pub fn tabs(&self) -> Option<pango::TabArray> {
1244        unsafe { from_glib_none(ffi::gtk_text_get_tabs(self.to_glib_none().0)) }
1245    }
1246
1247    /// Retrieves the length of the contents.
1248    ///
1249    /// This is equivalent to getting @self's [`EntryBuffer`][crate::EntryBuffer]
1250    /// and calling [`EntryBufferExtManual::length()`][crate::prelude::EntryBufferExtManual::length()] on it.
1251    ///
1252    /// # Returns
1253    ///
1254    /// the length of the contents, in characters
1255    #[doc(alias = "gtk_text_get_text_length")]
1256    #[doc(alias = "get_text_length")]
1257    pub fn text_length(&self) -> u16 {
1258        unsafe { ffi::gtk_text_get_text_length(self.to_glib_none().0) }
1259    }
1260
1261    /// Returns whether pasted text will be truncated to the first line.
1262    ///
1263    /// # Returns
1264    ///
1265    /// true if @self will truncate pasted multi-line text
1266    #[doc(alias = "gtk_text_get_truncate_multiline")]
1267    #[doc(alias = "get_truncate_multiline")]
1268    #[doc(alias = "truncate-multiline")]
1269    pub fn must_truncate_multiline(&self) -> bool {
1270        unsafe { from_glib(ffi::gtk_text_get_truncate_multiline(self.to_glib_none().0)) }
1271    }
1272
1273    /// Retrieves whether the text is visible.
1274    ///
1275    /// # Returns
1276    ///
1277    /// true if the text is visible
1278    #[doc(alias = "gtk_text_get_visibility")]
1279    #[doc(alias = "get_visibility")]
1280    #[doc(alias = "visibility")]
1281    pub fn is_visible(&self) -> bool {
1282        unsafe { from_glib(ffi::gtk_text_get_visibility(self.to_glib_none().0)) }
1283    }
1284
1285    /// Causes the text widget to have the keyboard focus.
1286    ///
1287    /// It behaves like [`WidgetExt::grab_focus()`][crate::prelude::WidgetExt::grab_focus()],
1288    /// except that it does not select the contents of @self.
1289    ///
1290    /// You only want to call this on some special entries
1291    /// which the user usually doesn't want to replace all
1292    /// text in, such as search-as-you-type entries.
1293    ///
1294    /// # Returns
1295    ///
1296    /// true if focus is now inside @self
1297    #[doc(alias = "gtk_text_grab_focus_without_selecting")]
1298    pub fn grab_focus_without_selecting(&self) -> bool {
1299        unsafe {
1300            from_glib(ffi::gtk_text_grab_focus_without_selecting(
1301                self.to_glib_none().0,
1302            ))
1303        }
1304    }
1305
1306    /// Sets whether pressing <kbd>Enter</kbd> will activate
1307    /// the default widget.
1308    ///
1309    /// This usually means that the dialog containing @self will
1310    /// be closed, since the default widget is usually one of
1311    /// the dialog buttons.
1312    /// ## `activates`
1313    /// true to activate window’s default widget on
1314    ///   <kbd>Enter</kbd> keypress
1315    #[doc(alias = "gtk_text_set_activates_default")]
1316    #[doc(alias = "activates-default")]
1317    pub fn set_activates_default(&self, activates: bool) {
1318        unsafe {
1319            ffi::gtk_text_set_activates_default(self.to_glib_none().0, activates.into_glib());
1320        }
1321    }
1322
1323    /// Apply attributes to the contents of the text widget.
1324    /// ## `attrs`
1325    /// a list of style attributes
1326    #[doc(alias = "gtk_text_set_attributes")]
1327    #[doc(alias = "attributes")]
1328    pub fn set_attributes(&self, attrs: Option<&pango::AttrList>) {
1329        unsafe {
1330            ffi::gtk_text_set_attributes(self.to_glib_none().0, attrs.to_glib_none().0);
1331        }
1332    }
1333
1334    /// Set the entry buffer object which holds the text for
1335    /// this widget.
1336    /// ## `buffer`
1337    /// an entry buffer object
1338    #[doc(alias = "gtk_text_set_buffer")]
1339    #[doc(alias = "buffer")]
1340    pub fn set_buffer(&self, buffer: &impl IsA<EntryBuffer>) {
1341        unsafe {
1342            ffi::gtk_text_set_buffer(self.to_glib_none().0, buffer.as_ref().to_glib_none().0);
1343        }
1344    }
1345
1346    /// Sets whether Emoji completion is enabled.
1347    ///
1348    /// If it is, typing ':', followed by a recognized keyword,
1349    /// will pop up a window with suggested Emojis matching the
1350    /// keyword.
1351    /// ## `enable_emoji_completion`
1352    /// true to enable Emoji completion
1353    #[doc(alias = "gtk_text_set_enable_emoji_completion")]
1354    #[doc(alias = "enable-emoji-completion")]
1355    pub fn set_enable_emoji_completion(&self, enable_emoji_completion: bool) {
1356        unsafe {
1357            ffi::gtk_text_set_enable_emoji_completion(
1358                self.to_glib_none().0,
1359                enable_emoji_completion.into_glib(),
1360            );
1361        }
1362    }
1363
1364    /// Sets a menu model to add to the context menu of the text widget.
1365    /// ## `model`
1366    /// a menu model
1367    #[doc(alias = "gtk_text_set_extra_menu")]
1368    #[doc(alias = "extra-menu")]
1369    pub fn set_extra_menu(&self, model: Option<&impl IsA<gio::MenuModel>>) {
1370        unsafe {
1371            ffi::gtk_text_set_extra_menu(
1372                self.to_glib_none().0,
1373                model.map(|p| p.as_ref()).to_glib_none().0,
1374            );
1375        }
1376    }
1377
1378    /// Sets hints that allow input methods to fine-tune their behaviour.
1379    /// ## `hints`
1380    /// input hints
1381    #[doc(alias = "gtk_text_set_input_hints")]
1382    #[doc(alias = "input-hints")]
1383    pub fn set_input_hints(&self, hints: InputHints) {
1384        unsafe {
1385            ffi::gtk_text_set_input_hints(self.to_glib_none().0, hints.into_glib());
1386        }
1387    }
1388
1389    /// Sets the input purpose of the text widget.
1390    ///
1391    /// The input purpose can be used by on-screen keyboards
1392    /// and other input methods to adjust their behaviour.
1393    /// ## `purpose`
1394    /// the input purpose
1395    #[doc(alias = "gtk_text_set_input_purpose")]
1396    #[doc(alias = "input-purpose")]
1397    pub fn set_input_purpose(&self, purpose: InputPurpose) {
1398        unsafe {
1399            ffi::gtk_text_set_input_purpose(self.to_glib_none().0, purpose.into_glib());
1400        }
1401    }
1402
1403    /// Sets the character to use when in “password mode”.
1404    ///
1405    /// By default, GTK picks the best invisible char available in the
1406    /// current font. If you set the invisible char to 0, then the user
1407    /// will get no feedback at all; there will be no text on the screen
1408    /// as they type.
1409    /// ## `ch`
1410    /// a Unicode character
1411    #[doc(alias = "gtk_text_set_invisible_char")]
1412    #[doc(alias = "invisible-char")]
1413    pub fn set_invisible_char(&self, ch: char) {
1414        unsafe {
1415            ffi::gtk_text_set_invisible_char(self.to_glib_none().0, ch.into_glib());
1416        }
1417    }
1418
1419    /// Sets the maximum allowed length of the contents.
1420    ///
1421    /// If the current contents are longer than the given length,
1422    /// they will be truncated to fit.
1423    ///
1424    /// This is equivalent to getting @self's [`EntryBuffer`][crate::EntryBuffer] and
1425    /// calling [`EntryBufferExtManual::set_max_length()`][crate::prelude::EntryBufferExtManual::set_max_length()] on it.
1426    /// ## `length`
1427    /// the maximum length of the text, or 0 for no maximum.
1428    ///   (other than the maximum length of entries.) The value passed
1429    ///   in will be clamped to the range 0-65536
1430    #[doc(alias = "gtk_text_set_max_length")]
1431    #[doc(alias = "max-length")]
1432    pub fn set_max_length(&self, length: i32) {
1433        unsafe {
1434            ffi::gtk_text_set_max_length(self.to_glib_none().0, length);
1435        }
1436    }
1437
1438    /// Sets whether the text is overwritten when typing.
1439    /// ## `overwrite`
1440    /// new value
1441    #[doc(alias = "gtk_text_set_overwrite_mode")]
1442    #[doc(alias = "overwrite-mode")]
1443    pub fn set_overwrite_mode(&self, overwrite: bool) {
1444        unsafe {
1445            ffi::gtk_text_set_overwrite_mode(self.to_glib_none().0, overwrite.into_glib());
1446        }
1447    }
1448
1449    /// Sets the text to be displayed when the text widget is
1450    /// empty and unfocused.
1451    ///
1452    /// This can be used to give a visual hint of the expected
1453    /// contents of the text widget.
1454    /// ## `text`
1455    /// a string to be displayed when @self
1456    ///   is empty and unfocused
1457    #[doc(alias = "gtk_text_set_placeholder_text")]
1458    #[doc(alias = "placeholder-text")]
1459    pub fn set_placeholder_text(&self, text: Option<&str>) {
1460        unsafe {
1461            ffi::gtk_text_set_placeholder_text(self.to_glib_none().0, text.to_glib_none().0);
1462        }
1463    }
1464
1465    /// Sets whether the text widget should grow and shrink with the content.
1466    /// ## `propagate_text_width`
1467    /// true to propagate the text width
1468    #[doc(alias = "gtk_text_set_propagate_text_width")]
1469    #[doc(alias = "propagate-text-width")]
1470    pub fn set_propagate_text_width(&self, propagate_text_width: bool) {
1471        unsafe {
1472            ffi::gtk_text_set_propagate_text_width(
1473                self.to_glib_none().0,
1474                propagate_text_width.into_glib(),
1475            );
1476        }
1477    }
1478
1479    /// Sets tab stops for the text widget.
1480    /// ## `tabs`
1481    /// tab stops
1482    #[doc(alias = "gtk_text_set_tabs")]
1483    #[doc(alias = "tabs")]
1484    pub fn set_tabs(&self, tabs: Option<&pango::TabArray>) {
1485        unsafe {
1486            ffi::gtk_text_set_tabs(self.to_glib_none().0, mut_override(tabs.to_glib_none().0));
1487        }
1488    }
1489
1490    /// Sets whether pasted text should be truncated to the first line.
1491    /// ## `truncate_multiline`
1492    /// true to truncate multi-line text
1493    #[doc(alias = "gtk_text_set_truncate_multiline")]
1494    #[doc(alias = "truncate-multiline")]
1495    pub fn set_truncate_multiline(&self, truncate_multiline: bool) {
1496        unsafe {
1497            ffi::gtk_text_set_truncate_multiline(
1498                self.to_glib_none().0,
1499                truncate_multiline.into_glib(),
1500            );
1501        }
1502    }
1503
1504    /// Sets whether the contents of the text widget are visible or not.
1505    ///
1506    /// When visibility is set to false, characters are displayed
1507    /// as the invisible char, and it will also appear that way when
1508    /// the text in the widget is copied to the clipboard.
1509    ///
1510    /// By default, GTK picks the best invisible character available
1511    /// in the current font, but it can be changed with
1512    /// [`set_invisible_char()`][Self::set_invisible_char()].
1513    ///
1514    /// Note that you probably want to set [`input-purpose`][struct@crate::Text#input-purpose]
1515    /// to [enum@Gtk.InputPurpose.password] or [enum@Gtk.InputPurpose.pin]
1516    /// to inform input methods about the purpose of this widget, in addition
1517    /// to setting visibility to false.
1518    /// ## `visible`
1519    /// true if the contents of the text widget are displayed
1520    ///   as plain text
1521    #[doc(alias = "gtk_text_set_visibility")]
1522    #[doc(alias = "visibility")]
1523    pub fn set_visibility(&self, visible: bool) {
1524        unsafe {
1525            ffi::gtk_text_set_visibility(self.to_glib_none().0, visible.into_glib());
1526        }
1527    }
1528
1529    /// Unsets the invisible char.
1530    ///
1531    /// After calling this, the default invisible char is used again.
1532    #[doc(alias = "gtk_text_unset_invisible_char")]
1533    pub fn unset_invisible_char(&self) {
1534        unsafe {
1535            ffi::gtk_text_unset_invisible_char(self.to_glib_none().0);
1536        }
1537    }
1538
1539    /// Which input method module should be used.
1540    ///
1541    /// See [`IMMulticontext`][crate::IMMulticontext].
1542    ///
1543    /// Setting this to a non-`NULL` value overrides the system-wide
1544    /// input method. See the [`gtk-im-module`][struct@crate::Settings#gtk-im-module]
1545    /// setting.
1546    #[doc(alias = "im-module")]
1547    pub fn im_module(&self) -> Option<glib::GString> {
1548        ObjectExt::property(self, "im-module")
1549    }
1550
1551    /// Which input method module should be used.
1552    ///
1553    /// See [`IMMulticontext`][crate::IMMulticontext].
1554    ///
1555    /// Setting this to a non-`NULL` value overrides the system-wide
1556    /// input method. See the [`gtk-im-module`][struct@crate::Settings#gtk-im-module]
1557    /// setting.
1558    #[doc(alias = "im-module")]
1559    pub fn set_im_module(&self, im_module: Option<&str>) {
1560        ObjectExt::set_property(self, "im-module", im_module)
1561    }
1562
1563    /// Whether the invisible char has been set.
1564    #[doc(alias = "invisible-char-set")]
1565    pub fn is_invisible_char_set(&self) -> bool {
1566        ObjectExt::property(self, "invisible-char-set")
1567    }
1568
1569    /// Number of pixels scrolled of the screen to the left.
1570    #[doc(alias = "scroll-offset")]
1571    pub fn scroll_offset(&self) -> i32 {
1572        ObjectExt::property(self, "scroll-offset")
1573    }
1574
1575    #[doc(alias = "activates-default")]
1576    pub fn connect_activates_default_notify<F: Fn(&Self) + 'static>(
1577        &self,
1578        f: F,
1579    ) -> SignalHandlerId {
1580        unsafe extern "C" fn notify_activates_default_trampoline<F: Fn(&Text) + 'static>(
1581            this: *mut ffi::GtkText,
1582            _param_spec: glib::ffi::gpointer,
1583            f: glib::ffi::gpointer,
1584        ) {
1585            unsafe {
1586                let f: &F = &*(f as *const F);
1587                f(&from_glib_borrow(this))
1588            }
1589        }
1590        unsafe {
1591            let f: Box_<F> = Box_::new(f);
1592            connect_raw(
1593                self.as_ptr() as *mut _,
1594                c"notify::activates-default".as_ptr(),
1595                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1596                    notify_activates_default_trampoline::<F> as *const (),
1597                )),
1598                Box_::into_raw(f),
1599            )
1600        }
1601    }
1602
1603    #[doc(alias = "attributes")]
1604    pub fn connect_attributes_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1605        unsafe extern "C" fn notify_attributes_trampoline<F: Fn(&Text) + 'static>(
1606            this: *mut ffi::GtkText,
1607            _param_spec: glib::ffi::gpointer,
1608            f: glib::ffi::gpointer,
1609        ) {
1610            unsafe {
1611                let f: &F = &*(f as *const F);
1612                f(&from_glib_borrow(this))
1613            }
1614        }
1615        unsafe {
1616            let f: Box_<F> = Box_::new(f);
1617            connect_raw(
1618                self.as_ptr() as *mut _,
1619                c"notify::attributes".as_ptr(),
1620                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1621                    notify_attributes_trampoline::<F> as *const (),
1622                )),
1623                Box_::into_raw(f),
1624            )
1625        }
1626    }
1627
1628    #[doc(alias = "buffer")]
1629    pub fn connect_buffer_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1630        unsafe extern "C" fn notify_buffer_trampoline<F: Fn(&Text) + 'static>(
1631            this: *mut ffi::GtkText,
1632            _param_spec: glib::ffi::gpointer,
1633            f: glib::ffi::gpointer,
1634        ) {
1635            unsafe {
1636                let f: &F = &*(f as *const F);
1637                f(&from_glib_borrow(this))
1638            }
1639        }
1640        unsafe {
1641            let f: Box_<F> = Box_::new(f);
1642            connect_raw(
1643                self.as_ptr() as *mut _,
1644                c"notify::buffer".as_ptr(),
1645                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1646                    notify_buffer_trampoline::<F> as *const (),
1647                )),
1648                Box_::into_raw(f),
1649            )
1650        }
1651    }
1652
1653    #[doc(alias = "enable-emoji-completion")]
1654    pub fn connect_enable_emoji_completion_notify<F: Fn(&Self) + 'static>(
1655        &self,
1656        f: F,
1657    ) -> SignalHandlerId {
1658        unsafe extern "C" fn notify_enable_emoji_completion_trampoline<F: Fn(&Text) + 'static>(
1659            this: *mut ffi::GtkText,
1660            _param_spec: glib::ffi::gpointer,
1661            f: glib::ffi::gpointer,
1662        ) {
1663            unsafe {
1664                let f: &F = &*(f as *const F);
1665                f(&from_glib_borrow(this))
1666            }
1667        }
1668        unsafe {
1669            let f: Box_<F> = Box_::new(f);
1670            connect_raw(
1671                self.as_ptr() as *mut _,
1672                c"notify::enable-emoji-completion".as_ptr(),
1673                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1674                    notify_enable_emoji_completion_trampoline::<F> as *const (),
1675                )),
1676                Box_::into_raw(f),
1677            )
1678        }
1679    }
1680
1681    #[doc(alias = "extra-menu")]
1682    pub fn connect_extra_menu_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1683        unsafe extern "C" fn notify_extra_menu_trampoline<F: Fn(&Text) + 'static>(
1684            this: *mut ffi::GtkText,
1685            _param_spec: glib::ffi::gpointer,
1686            f: glib::ffi::gpointer,
1687        ) {
1688            unsafe {
1689                let f: &F = &*(f as *const F);
1690                f(&from_glib_borrow(this))
1691            }
1692        }
1693        unsafe {
1694            let f: Box_<F> = Box_::new(f);
1695            connect_raw(
1696                self.as_ptr() as *mut _,
1697                c"notify::extra-menu".as_ptr(),
1698                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1699                    notify_extra_menu_trampoline::<F> as *const (),
1700                )),
1701                Box_::into_raw(f),
1702            )
1703        }
1704    }
1705
1706    #[doc(alias = "im-module")]
1707    pub fn connect_im_module_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1708        unsafe extern "C" fn notify_im_module_trampoline<F: Fn(&Text) + 'static>(
1709            this: *mut ffi::GtkText,
1710            _param_spec: glib::ffi::gpointer,
1711            f: glib::ffi::gpointer,
1712        ) {
1713            unsafe {
1714                let f: &F = &*(f as *const F);
1715                f(&from_glib_borrow(this))
1716            }
1717        }
1718        unsafe {
1719            let f: Box_<F> = Box_::new(f);
1720            connect_raw(
1721                self.as_ptr() as *mut _,
1722                c"notify::im-module".as_ptr(),
1723                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1724                    notify_im_module_trampoline::<F> as *const (),
1725                )),
1726                Box_::into_raw(f),
1727            )
1728        }
1729    }
1730
1731    #[doc(alias = "input-hints")]
1732    pub fn connect_input_hints_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1733        unsafe extern "C" fn notify_input_hints_trampoline<F: Fn(&Text) + 'static>(
1734            this: *mut ffi::GtkText,
1735            _param_spec: glib::ffi::gpointer,
1736            f: glib::ffi::gpointer,
1737        ) {
1738            unsafe {
1739                let f: &F = &*(f as *const F);
1740                f(&from_glib_borrow(this))
1741            }
1742        }
1743        unsafe {
1744            let f: Box_<F> = Box_::new(f);
1745            connect_raw(
1746                self.as_ptr() as *mut _,
1747                c"notify::input-hints".as_ptr(),
1748                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1749                    notify_input_hints_trampoline::<F> as *const (),
1750                )),
1751                Box_::into_raw(f),
1752            )
1753        }
1754    }
1755
1756    #[doc(alias = "input-purpose")]
1757    pub fn connect_input_purpose_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1758        unsafe extern "C" fn notify_input_purpose_trampoline<F: Fn(&Text) + 'static>(
1759            this: *mut ffi::GtkText,
1760            _param_spec: glib::ffi::gpointer,
1761            f: glib::ffi::gpointer,
1762        ) {
1763            unsafe {
1764                let f: &F = &*(f as *const F);
1765                f(&from_glib_borrow(this))
1766            }
1767        }
1768        unsafe {
1769            let f: Box_<F> = Box_::new(f);
1770            connect_raw(
1771                self.as_ptr() as *mut _,
1772                c"notify::input-purpose".as_ptr(),
1773                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1774                    notify_input_purpose_trampoline::<F> as *const (),
1775                )),
1776                Box_::into_raw(f),
1777            )
1778        }
1779    }
1780
1781    #[doc(alias = "invisible-char")]
1782    pub fn connect_invisible_char_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1783        unsafe extern "C" fn notify_invisible_char_trampoline<F: Fn(&Text) + 'static>(
1784            this: *mut ffi::GtkText,
1785            _param_spec: glib::ffi::gpointer,
1786            f: glib::ffi::gpointer,
1787        ) {
1788            unsafe {
1789                let f: &F = &*(f as *const F);
1790                f(&from_glib_borrow(this))
1791            }
1792        }
1793        unsafe {
1794            let f: Box_<F> = Box_::new(f);
1795            connect_raw(
1796                self.as_ptr() as *mut _,
1797                c"notify::invisible-char".as_ptr(),
1798                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1799                    notify_invisible_char_trampoline::<F> as *const (),
1800                )),
1801                Box_::into_raw(f),
1802            )
1803        }
1804    }
1805
1806    #[doc(alias = "invisible-char-set")]
1807    pub fn connect_invisible_char_set_notify<F: Fn(&Self) + 'static>(
1808        &self,
1809        f: F,
1810    ) -> SignalHandlerId {
1811        unsafe extern "C" fn notify_invisible_char_set_trampoline<F: Fn(&Text) + 'static>(
1812            this: *mut ffi::GtkText,
1813            _param_spec: glib::ffi::gpointer,
1814            f: glib::ffi::gpointer,
1815        ) {
1816            unsafe {
1817                let f: &F = &*(f as *const F);
1818                f(&from_glib_borrow(this))
1819            }
1820        }
1821        unsafe {
1822            let f: Box_<F> = Box_::new(f);
1823            connect_raw(
1824                self.as_ptr() as *mut _,
1825                c"notify::invisible-char-set".as_ptr(),
1826                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1827                    notify_invisible_char_set_trampoline::<F> as *const (),
1828                )),
1829                Box_::into_raw(f),
1830            )
1831        }
1832    }
1833
1834    #[doc(alias = "max-length")]
1835    pub fn connect_max_length_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1836        unsafe extern "C" fn notify_max_length_trampoline<F: Fn(&Text) + 'static>(
1837            this: *mut ffi::GtkText,
1838            _param_spec: glib::ffi::gpointer,
1839            f: glib::ffi::gpointer,
1840        ) {
1841            unsafe {
1842                let f: &F = &*(f as *const F);
1843                f(&from_glib_borrow(this))
1844            }
1845        }
1846        unsafe {
1847            let f: Box_<F> = Box_::new(f);
1848            connect_raw(
1849                self.as_ptr() as *mut _,
1850                c"notify::max-length".as_ptr(),
1851                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1852                    notify_max_length_trampoline::<F> as *const (),
1853                )),
1854                Box_::into_raw(f),
1855            )
1856        }
1857    }
1858
1859    #[doc(alias = "overwrite-mode")]
1860    pub fn connect_overwrite_mode_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1861        unsafe extern "C" fn notify_overwrite_mode_trampoline<F: Fn(&Text) + 'static>(
1862            this: *mut ffi::GtkText,
1863            _param_spec: glib::ffi::gpointer,
1864            f: glib::ffi::gpointer,
1865        ) {
1866            unsafe {
1867                let f: &F = &*(f as *const F);
1868                f(&from_glib_borrow(this))
1869            }
1870        }
1871        unsafe {
1872            let f: Box_<F> = Box_::new(f);
1873            connect_raw(
1874                self.as_ptr() as *mut _,
1875                c"notify::overwrite-mode".as_ptr(),
1876                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1877                    notify_overwrite_mode_trampoline::<F> as *const (),
1878                )),
1879                Box_::into_raw(f),
1880            )
1881        }
1882    }
1883
1884    #[doc(alias = "placeholder-text")]
1885    pub fn connect_placeholder_text_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1886        unsafe extern "C" fn notify_placeholder_text_trampoline<F: Fn(&Text) + 'static>(
1887            this: *mut ffi::GtkText,
1888            _param_spec: glib::ffi::gpointer,
1889            f: glib::ffi::gpointer,
1890        ) {
1891            unsafe {
1892                let f: &F = &*(f as *const F);
1893                f(&from_glib_borrow(this))
1894            }
1895        }
1896        unsafe {
1897            let f: Box_<F> = Box_::new(f);
1898            connect_raw(
1899                self.as_ptr() as *mut _,
1900                c"notify::placeholder-text".as_ptr(),
1901                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1902                    notify_placeholder_text_trampoline::<F> as *const (),
1903                )),
1904                Box_::into_raw(f),
1905            )
1906        }
1907    }
1908
1909    #[doc(alias = "propagate-text-width")]
1910    pub fn connect_propagate_text_width_notify<F: Fn(&Self) + 'static>(
1911        &self,
1912        f: F,
1913    ) -> SignalHandlerId {
1914        unsafe extern "C" fn notify_propagate_text_width_trampoline<F: Fn(&Text) + 'static>(
1915            this: *mut ffi::GtkText,
1916            _param_spec: glib::ffi::gpointer,
1917            f: glib::ffi::gpointer,
1918        ) {
1919            unsafe {
1920                let f: &F = &*(f as *const F);
1921                f(&from_glib_borrow(this))
1922            }
1923        }
1924        unsafe {
1925            let f: Box_<F> = Box_::new(f);
1926            connect_raw(
1927                self.as_ptr() as *mut _,
1928                c"notify::propagate-text-width".as_ptr(),
1929                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1930                    notify_propagate_text_width_trampoline::<F> as *const (),
1931                )),
1932                Box_::into_raw(f),
1933            )
1934        }
1935    }
1936
1937    #[doc(alias = "scroll-offset")]
1938    pub fn connect_scroll_offset_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1939        unsafe extern "C" fn notify_scroll_offset_trampoline<F: Fn(&Text) + 'static>(
1940            this: *mut ffi::GtkText,
1941            _param_spec: glib::ffi::gpointer,
1942            f: glib::ffi::gpointer,
1943        ) {
1944            unsafe {
1945                let f: &F = &*(f as *const F);
1946                f(&from_glib_borrow(this))
1947            }
1948        }
1949        unsafe {
1950            let f: Box_<F> = Box_::new(f);
1951            connect_raw(
1952                self.as_ptr() as *mut _,
1953                c"notify::scroll-offset".as_ptr(),
1954                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1955                    notify_scroll_offset_trampoline::<F> as *const (),
1956                )),
1957                Box_::into_raw(f),
1958            )
1959        }
1960    }
1961
1962    #[doc(alias = "tabs")]
1963    pub fn connect_tabs_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1964        unsafe extern "C" fn notify_tabs_trampoline<F: Fn(&Text) + 'static>(
1965            this: *mut ffi::GtkText,
1966            _param_spec: glib::ffi::gpointer,
1967            f: glib::ffi::gpointer,
1968        ) {
1969            unsafe {
1970                let f: &F = &*(f as *const F);
1971                f(&from_glib_borrow(this))
1972            }
1973        }
1974        unsafe {
1975            let f: Box_<F> = Box_::new(f);
1976            connect_raw(
1977                self.as_ptr() as *mut _,
1978                c"notify::tabs".as_ptr(),
1979                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1980                    notify_tabs_trampoline::<F> as *const (),
1981                )),
1982                Box_::into_raw(f),
1983            )
1984        }
1985    }
1986
1987    #[doc(alias = "truncate-multiline")]
1988    pub fn connect_truncate_multiline_notify<F: Fn(&Self) + 'static>(
1989        &self,
1990        f: F,
1991    ) -> SignalHandlerId {
1992        unsafe extern "C" fn notify_truncate_multiline_trampoline<F: Fn(&Text) + 'static>(
1993            this: *mut ffi::GtkText,
1994            _param_spec: glib::ffi::gpointer,
1995            f: glib::ffi::gpointer,
1996        ) {
1997            unsafe {
1998                let f: &F = &*(f as *const F);
1999                f(&from_glib_borrow(this))
2000            }
2001        }
2002        unsafe {
2003            let f: Box_<F> = Box_::new(f);
2004            connect_raw(
2005                self.as_ptr() as *mut _,
2006                c"notify::truncate-multiline".as_ptr(),
2007                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
2008                    notify_truncate_multiline_trampoline::<F> as *const (),
2009                )),
2010                Box_::into_raw(f),
2011            )
2012        }
2013    }
2014
2015    #[doc(alias = "visibility")]
2016    pub fn connect_visibility_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
2017        unsafe extern "C" fn notify_visibility_trampoline<F: Fn(&Text) + 'static>(
2018            this: *mut ffi::GtkText,
2019            _param_spec: glib::ffi::gpointer,
2020            f: glib::ffi::gpointer,
2021        ) {
2022            unsafe {
2023                let f: &F = &*(f as *const F);
2024                f(&from_glib_borrow(this))
2025            }
2026        }
2027        unsafe {
2028            let f: Box_<F> = Box_::new(f);
2029            connect_raw(
2030                self.as_ptr() as *mut _,
2031                c"notify::visibility".as_ptr(),
2032                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
2033                    notify_visibility_trampoline::<F> as *const (),
2034                )),
2035                Box_::into_raw(f),
2036            )
2037        }
2038    }
2039}
2040
2041impl Default for Text {
2042    fn default() -> Self {
2043        Self::new()
2044    }
2045}
2046
2047// rustdoc-stripper-ignore-next
2048/// A [builder-pattern] type to construct [`Text`] objects.
2049///
2050/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
2051#[must_use = "The builder must be built to be used"]
2052pub struct TextBuilder {
2053    builder: glib::object::ObjectBuilder<'static, Text>,
2054}
2055
2056impl TextBuilder {
2057    fn new() -> Self {
2058        Self {
2059            builder: glib::object::Object::builder(),
2060        }
2061    }
2062
2063    /// Whether to activate the default widget when <kbd>Enter</kbd> is pressed.
2064    pub fn activates_default(self, activates_default: bool) -> Self {
2065        Self {
2066            builder: self
2067                .builder
2068                .property("activates-default", activates_default),
2069        }
2070    }
2071
2072    /// A list of Pango attributes to apply to the text.
2073    ///
2074    /// This is mainly useful to change the size or weight of the text.
2075    ///
2076    /// The `PangoAttribute`'s @start_index and @end_index must refer to the
2077    /// [`EntryBuffer`][crate::EntryBuffer] text, i.e. without the preedit string.
2078    pub fn attributes(self, attributes: &pango::AttrList) -> Self {
2079        Self {
2080            builder: self.builder.property("attributes", attributes.clone()),
2081        }
2082    }
2083
2084    /// The [`EntryBuffer`][crate::EntryBuffer] object which stores the text.
2085    pub fn buffer(self, buffer: &impl IsA<EntryBuffer>) -> Self {
2086        Self {
2087            builder: self.builder.property("buffer", buffer.clone().upcast()),
2088        }
2089    }
2090
2091    /// Whether to suggest Emoji replacements.
2092    pub fn enable_emoji_completion(self, enable_emoji_completion: bool) -> Self {
2093        Self {
2094            builder: self
2095                .builder
2096                .property("enable-emoji-completion", enable_emoji_completion),
2097        }
2098    }
2099
2100    /// A menu model whose contents will be appended to the context menu.
2101    pub fn extra_menu(self, extra_menu: &impl IsA<gio::MenuModel>) -> Self {
2102        Self {
2103            builder: self
2104                .builder
2105                .property("extra-menu", extra_menu.clone().upcast()),
2106        }
2107    }
2108
2109    /// Which input method module should be used.
2110    ///
2111    /// See [`IMMulticontext`][crate::IMMulticontext].
2112    ///
2113    /// Setting this to a non-`NULL` value overrides the system-wide
2114    /// input method. See the [`gtk-im-module`][struct@crate::Settings#gtk-im-module]
2115    /// setting.
2116    pub fn im_module(self, im_module: impl Into<glib::GString>) -> Self {
2117        Self {
2118            builder: self.builder.property("im-module", im_module.into()),
2119        }
2120    }
2121
2122    /// Additional hints that allow input methods to fine-tune
2123    /// their behaviour.
2124    pub fn input_hints(self, input_hints: InputHints) -> Self {
2125        Self {
2126            builder: self.builder.property("input-hints", input_hints),
2127        }
2128    }
2129
2130    /// The purpose of this text field.
2131    ///
2132    /// This information can be used by on-screen keyboards and other input
2133    /// methods to adjust their behaviour.
2134    ///
2135    /// Note that setting the purpose to [enum@Gtk.InputPurpose.password]
2136    /// or [enum@Gtk.InputPurpose.pin] is independent from setting
2137    /// [`visibility`][struct@crate::Text#visibility].
2138    pub fn input_purpose(self, input_purpose: InputPurpose) -> Self {
2139        Self {
2140            builder: self.builder.property("input-purpose", input_purpose),
2141        }
2142    }
2143
2144    /// The character to used when masking contents (in “password mode”).
2145    pub fn invisible_char(self, invisible_char: u32) -> Self {
2146        Self {
2147            builder: self.builder.property("invisible-char", invisible_char),
2148        }
2149    }
2150
2151    /// Whether the invisible char has been set.
2152    pub fn invisible_char_set(self, invisible_char_set: bool) -> Self {
2153        Self {
2154            builder: self
2155                .builder
2156                .property("invisible-char-set", invisible_char_set),
2157        }
2158    }
2159
2160    /// Maximum number of characters that are allowed.
2161    ///
2162    /// Zero indicates no limit.
2163    pub fn max_length(self, max_length: i32) -> Self {
2164        Self {
2165            builder: self.builder.property("max-length", max_length),
2166        }
2167    }
2168
2169    /// If text is overwritten when typing.
2170    pub fn overwrite_mode(self, overwrite_mode: bool) -> Self {
2171        Self {
2172            builder: self.builder.property("overwrite-mode", overwrite_mode),
2173        }
2174    }
2175
2176    /// The text that will be displayed in the [`Text`][crate::Text] when it is empty
2177    /// and unfocused.
2178    pub fn placeholder_text(self, placeholder_text: impl Into<glib::GString>) -> Self {
2179        Self {
2180            builder: self
2181                .builder
2182                .property("placeholder-text", placeholder_text.into()),
2183        }
2184    }
2185
2186    /// Whether the widget should grow and shrink with the content.
2187    pub fn propagate_text_width(self, propagate_text_width: bool) -> Self {
2188        Self {
2189            builder: self
2190                .builder
2191                .property("propagate-text-width", propagate_text_width),
2192        }
2193    }
2194
2195    /// Custom tabs for this text widget.
2196    pub fn tabs(self, tabs: &pango::TabArray) -> Self {
2197        Self {
2198            builder: self.builder.property("tabs", tabs),
2199        }
2200    }
2201
2202    /// When true, pasted multi-line text is truncated to the first line.
2203    pub fn truncate_multiline(self, truncate_multiline: bool) -> Self {
2204        Self {
2205            builder: self
2206                .builder
2207                .property("truncate-multiline", truncate_multiline),
2208        }
2209    }
2210
2211    /// If false, the text is masked with the “invisible char”.
2212    pub fn visibility(self, visibility: bool) -> Self {
2213        Self {
2214            builder: self.builder.property("visibility", visibility),
2215        }
2216    }
2217
2218    /// Whether the widget or any of its descendents can accept
2219    /// the input focus.
2220    ///
2221    /// This property is meant to be set by widget implementations,
2222    /// typically in their instance init function.
2223    pub fn can_focus(self, can_focus: bool) -> Self {
2224        Self {
2225            builder: self.builder.property("can-focus", can_focus),
2226        }
2227    }
2228
2229    /// Whether the widget can receive pointer events.
2230    pub fn can_target(self, can_target: bool) -> Self {
2231        Self {
2232            builder: self.builder.property("can-target", can_target),
2233        }
2234    }
2235
2236    /// A list of css classes applied to this widget.
2237    pub fn css_classes(self, css_classes: impl Into<glib::StrV>) -> Self {
2238        Self {
2239            builder: self.builder.property("css-classes", css_classes.into()),
2240        }
2241    }
2242
2243    /// The name of this widget in the CSS tree.
2244    ///
2245    /// This property is meant to be set by widget implementations,
2246    /// typically in their instance init function.
2247    pub fn css_name(self, css_name: impl Into<glib::GString>) -> Self {
2248        Self {
2249            builder: self.builder.property("css-name", css_name.into()),
2250        }
2251    }
2252
2253    /// The cursor used by @widget.
2254    pub fn cursor(self, cursor: &gdk::Cursor) -> Self {
2255        Self {
2256            builder: self.builder.property("cursor", cursor.clone()),
2257        }
2258    }
2259
2260    /// Whether the widget should grab focus when it is clicked with the mouse.
2261    ///
2262    /// This property is only relevant for widgets that can take focus.
2263    pub fn focus_on_click(self, focus_on_click: bool) -> Self {
2264        Self {
2265            builder: self.builder.property("focus-on-click", focus_on_click),
2266        }
2267    }
2268
2269    /// Whether this widget itself will accept the input focus.
2270    pub fn focusable(self, focusable: bool) -> Self {
2271        Self {
2272            builder: self.builder.property("focusable", focusable),
2273        }
2274    }
2275
2276    /// How to distribute horizontal space if widget gets extra space.
2277    pub fn halign(self, halign: Align) -> Self {
2278        Self {
2279            builder: self.builder.property("halign", halign),
2280        }
2281    }
2282
2283    /// Enables or disables the emission of the [`query-tooltip`][struct@crate::Widget#query-tooltip]
2284    /// signal on @widget.
2285    ///
2286    /// A true value indicates that @widget can have a tooltip, in this case
2287    /// the widget will be queried using [`query-tooltip`][struct@crate::Widget#query-tooltip] to
2288    /// determine whether it will provide a tooltip or not.
2289    pub fn has_tooltip(self, has_tooltip: bool) -> Self {
2290        Self {
2291            builder: self.builder.property("has-tooltip", has_tooltip),
2292        }
2293    }
2294
2295    /// Overrides for height request of the widget.
2296    ///
2297    /// If this is -1, the natural request will be used.
2298    pub fn height_request(self, height_request: i32) -> Self {
2299        Self {
2300            builder: self.builder.property("height-request", height_request),
2301        }
2302    }
2303
2304    /// Whether to expand horizontally.
2305    pub fn hexpand(self, hexpand: bool) -> Self {
2306        Self {
2307            builder: self.builder.property("hexpand", hexpand),
2308        }
2309    }
2310
2311    /// Whether to use the `hexpand` property.
2312    pub fn hexpand_set(self, hexpand_set: bool) -> Self {
2313        Self {
2314            builder: self.builder.property("hexpand-set", hexpand_set),
2315        }
2316    }
2317
2318    /// The [`LayoutManager`][crate::LayoutManager] instance to use to compute
2319    /// the preferred size of the widget, and allocate its children.
2320    ///
2321    /// This property is meant to be set by widget implementations,
2322    /// typically in their instance init function.
2323    pub fn layout_manager(self, layout_manager: &impl IsA<LayoutManager>) -> Self {
2324        Self {
2325            builder: self
2326                .builder
2327                .property("layout-manager", layout_manager.clone().upcast()),
2328        }
2329    }
2330
2331    /// Makes this widget act like a modal dialog, with respect to
2332    /// event delivery.
2333    ///
2334    /// Global event controllers will not handle events with targets
2335    /// inside the widget, unless they are set up to ignore propagation
2336    /// limits. See [`EventControllerExt::set_propagation_limit()`][crate::prelude::EventControllerExt::set_propagation_limit()].
2337    #[cfg(feature = "v4_18")]
2338    #[cfg_attr(docsrs, doc(cfg(feature = "v4_18")))]
2339    pub fn limit_events(self, limit_events: bool) -> Self {
2340        Self {
2341            builder: self.builder.property("limit-events", limit_events),
2342        }
2343    }
2344
2345    /// Margin on bottom side of widget.
2346    ///
2347    /// This property adds margin outside of the widget's normal size
2348    /// request, the margin will be added in addition to the size from
2349    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
2350    pub fn margin_bottom(self, margin_bottom: i32) -> Self {
2351        Self {
2352            builder: self.builder.property("margin-bottom", margin_bottom),
2353        }
2354    }
2355
2356    /// Margin on end of widget, horizontally.
2357    ///
2358    /// This property supports left-to-right and right-to-left text
2359    /// directions.
2360    ///
2361    /// This property adds margin outside of the widget's normal size
2362    /// request, the margin will be added in addition to the size from
2363    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
2364    pub fn margin_end(self, margin_end: i32) -> Self {
2365        Self {
2366            builder: self.builder.property("margin-end", margin_end),
2367        }
2368    }
2369
2370    /// Margin on start of widget, horizontally.
2371    ///
2372    /// This property supports left-to-right and right-to-left text
2373    /// directions.
2374    ///
2375    /// This property adds margin outside of the widget's normal size
2376    /// request, the margin will be added in addition to the size from
2377    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
2378    pub fn margin_start(self, margin_start: i32) -> Self {
2379        Self {
2380            builder: self.builder.property("margin-start", margin_start),
2381        }
2382    }
2383
2384    /// Margin on top side of widget.
2385    ///
2386    /// This property adds margin outside of the widget's normal size
2387    /// request, the margin will be added in addition to the size from
2388    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
2389    pub fn margin_top(self, margin_top: i32) -> Self {
2390        Self {
2391            builder: self.builder.property("margin-top", margin_top),
2392        }
2393    }
2394
2395    /// The name of the widget.
2396    pub fn name(self, name: impl Into<glib::GString>) -> Self {
2397        Self {
2398            builder: self.builder.property("name", name.into()),
2399        }
2400    }
2401
2402    /// The requested opacity of the widget.
2403    pub fn opacity(self, opacity: f64) -> Self {
2404        Self {
2405            builder: self.builder.property("opacity", opacity),
2406        }
2407    }
2408
2409    /// How content outside the widget's content area is treated.
2410    ///
2411    /// This property is meant to be set by widget implementations,
2412    /// typically in their instance init function.
2413    pub fn overflow(self, overflow: Overflow) -> Self {
2414        Self {
2415            builder: self.builder.property("overflow", overflow),
2416        }
2417    }
2418
2419    /// Whether the widget will receive the default action when it is focused.
2420    pub fn receives_default(self, receives_default: bool) -> Self {
2421        Self {
2422            builder: self.builder.property("receives-default", receives_default),
2423        }
2424    }
2425
2426    /// Whether the widget responds to input.
2427    pub fn sensitive(self, sensitive: bool) -> Self {
2428        Self {
2429            builder: self.builder.property("sensitive", sensitive),
2430        }
2431    }
2432
2433    /// Sets the text of tooltip to be the given string, which is marked up
2434    /// with Pango markup.
2435    ///
2436    /// Also see [`Tooltip::set_markup()`][crate::Tooltip::set_markup()].
2437    ///
2438    /// This is a convenience property which will take care of getting the
2439    /// tooltip shown if the given string is not `NULL`:
2440    /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
2441    /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
2442    /// the default signal handler.
2443    ///
2444    /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
2445    /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
2446    pub fn tooltip_markup(self, tooltip_markup: impl Into<glib::GString>) -> Self {
2447        Self {
2448            builder: self
2449                .builder
2450                .property("tooltip-markup", tooltip_markup.into()),
2451        }
2452    }
2453
2454    /// Sets the text of tooltip to be the given string.
2455    ///
2456    /// Also see [`Tooltip::set_text()`][crate::Tooltip::set_text()].
2457    ///
2458    /// This is a convenience property which will take care of getting the
2459    /// tooltip shown if the given string is not `NULL`:
2460    /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
2461    /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
2462    /// the default signal handler.
2463    ///
2464    /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
2465    /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
2466    pub fn tooltip_text(self, tooltip_text: impl Into<glib::GString>) -> Self {
2467        Self {
2468            builder: self.builder.property("tooltip-text", tooltip_text.into()),
2469        }
2470    }
2471
2472    /// How to distribute vertical space if widget gets extra space.
2473    pub fn valign(self, valign: Align) -> Self {
2474        Self {
2475            builder: self.builder.property("valign", valign),
2476        }
2477    }
2478
2479    /// Whether to expand vertically.
2480    pub fn vexpand(self, vexpand: bool) -> Self {
2481        Self {
2482            builder: self.builder.property("vexpand", vexpand),
2483        }
2484    }
2485
2486    /// Whether to use the `vexpand` property.
2487    pub fn vexpand_set(self, vexpand_set: bool) -> Self {
2488        Self {
2489            builder: self.builder.property("vexpand-set", vexpand_set),
2490        }
2491    }
2492
2493    /// Whether the widget is visible.
2494    pub fn visible(self, visible: bool) -> Self {
2495        Self {
2496            builder: self.builder.property("visible", visible),
2497        }
2498    }
2499
2500    /// Overrides for width request of the widget.
2501    ///
2502    /// If this is -1, the natural request will be used.
2503    pub fn width_request(self, width_request: i32) -> Self {
2504        Self {
2505            builder: self.builder.property("width-request", width_request),
2506        }
2507    }
2508
2509    /// The accessible role of the given [`Accessible`][crate::Accessible] implementation.
2510    ///
2511    /// The accessible role cannot be changed once set.
2512    pub fn accessible_role(self, accessible_role: AccessibleRole) -> Self {
2513        Self {
2514            builder: self.builder.property("accessible-role", accessible_role),
2515        }
2516    }
2517
2518    /// Whether the entry contents can be edited.
2519    pub fn editable(self, editable: bool) -> Self {
2520        Self {
2521            builder: self.builder.property("editable", editable),
2522        }
2523    }
2524
2525    /// If undo/redo should be enabled for the editable.
2526    pub fn enable_undo(self, enable_undo: bool) -> Self {
2527        Self {
2528            builder: self.builder.property("enable-undo", enable_undo),
2529        }
2530    }
2531
2532    /// The desired maximum width of the entry, in characters.
2533    pub fn max_width_chars(self, max_width_chars: i32) -> Self {
2534        Self {
2535            builder: self.builder.property("max-width-chars", max_width_chars),
2536        }
2537    }
2538
2539    /// The contents of the entry.
2540    pub fn text(self, text: impl Into<glib::GString>) -> Self {
2541        Self {
2542            builder: self.builder.property("text", text.into()),
2543        }
2544    }
2545
2546    /// Number of characters to leave space for in the entry.
2547    pub fn width_chars(self, width_chars: i32) -> Self {
2548        Self {
2549            builder: self.builder.property("width-chars", width_chars),
2550        }
2551    }
2552
2553    /// The horizontal alignment, from 0 (left) to 1 (right).
2554    ///
2555    /// Reversed for RTL layouts.
2556    pub fn xalign(self, xalign: f32) -> Self {
2557        Self {
2558            builder: self.builder.property("xalign", xalign),
2559        }
2560    }
2561
2562    // rustdoc-stripper-ignore-next
2563    /// Build the [`Text`].
2564    #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
2565    pub fn build(self) -> Text {
2566        assert_initialized_main_thread!();
2567        self.builder.build()
2568    }
2569}