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