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