Skip to main content

gtk4/auto/
text.rs

1// This file was generated by gir (https://github.com/gtk-rs/gir)
2// from gir-files (https://github.com/gtk-rs/gir-files)
3// DO NOT EDIT
4
5#[cfg(feature = "v4_14")]
6#[cfg_attr(docsrs, doc(cfg(feature = "v4_14")))]
7use crate::AccessibleText;
8use crate::{
9    Accessible, AccessibleRole, Align, Buildable, ConstraintTarget, Editable, EntryBuffer,
10    InputHints, InputPurpose, LayoutManager, Overflow, Widget, ffi,
11};
12use glib::{
13    prelude::*,
14    signal::{SignalHandlerId, connect_raw},
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            unsafe {
1554                let f: &F = &*(f as *const F);
1555                f(&from_glib_borrow(this))
1556            }
1557        }
1558        unsafe {
1559            let f: Box_<F> = Box_::new(f);
1560            connect_raw(
1561                self.as_ptr() as *mut _,
1562                c"notify::activates-default".as_ptr() as *const _,
1563                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1564                    notify_activates_default_trampoline::<F> as *const (),
1565                )),
1566                Box_::into_raw(f),
1567            )
1568        }
1569    }
1570
1571    #[doc(alias = "attributes")]
1572    pub fn connect_attributes_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1573        unsafe extern "C" fn notify_attributes_trampoline<F: Fn(&Text) + 'static>(
1574            this: *mut ffi::GtkText,
1575            _param_spec: glib::ffi::gpointer,
1576            f: glib::ffi::gpointer,
1577        ) {
1578            unsafe {
1579                let f: &F = &*(f as *const F);
1580                f(&from_glib_borrow(this))
1581            }
1582        }
1583        unsafe {
1584            let f: Box_<F> = Box_::new(f);
1585            connect_raw(
1586                self.as_ptr() as *mut _,
1587                c"notify::attributes".as_ptr() as *const _,
1588                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1589                    notify_attributes_trampoline::<F> as *const (),
1590                )),
1591                Box_::into_raw(f),
1592            )
1593        }
1594    }
1595
1596    #[doc(alias = "buffer")]
1597    pub fn connect_buffer_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1598        unsafe extern "C" fn notify_buffer_trampoline<F: Fn(&Text) + 'static>(
1599            this: *mut ffi::GtkText,
1600            _param_spec: glib::ffi::gpointer,
1601            f: glib::ffi::gpointer,
1602        ) {
1603            unsafe {
1604                let f: &F = &*(f as *const F);
1605                f(&from_glib_borrow(this))
1606            }
1607        }
1608        unsafe {
1609            let f: Box_<F> = Box_::new(f);
1610            connect_raw(
1611                self.as_ptr() as *mut _,
1612                c"notify::buffer".as_ptr() as *const _,
1613                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1614                    notify_buffer_trampoline::<F> as *const (),
1615                )),
1616                Box_::into_raw(f),
1617            )
1618        }
1619    }
1620
1621    #[doc(alias = "enable-emoji-completion")]
1622    pub fn connect_enable_emoji_completion_notify<F: Fn(&Self) + 'static>(
1623        &self,
1624        f: F,
1625    ) -> SignalHandlerId {
1626        unsafe extern "C" fn notify_enable_emoji_completion_trampoline<F: Fn(&Text) + 'static>(
1627            this: *mut ffi::GtkText,
1628            _param_spec: glib::ffi::gpointer,
1629            f: glib::ffi::gpointer,
1630        ) {
1631            unsafe {
1632                let f: &F = &*(f as *const F);
1633                f(&from_glib_borrow(this))
1634            }
1635        }
1636        unsafe {
1637            let f: Box_<F> = Box_::new(f);
1638            connect_raw(
1639                self.as_ptr() as *mut _,
1640                c"notify::enable-emoji-completion".as_ptr() as *const _,
1641                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1642                    notify_enable_emoji_completion_trampoline::<F> as *const (),
1643                )),
1644                Box_::into_raw(f),
1645            )
1646        }
1647    }
1648
1649    #[doc(alias = "extra-menu")]
1650    pub fn connect_extra_menu_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1651        unsafe extern "C" fn notify_extra_menu_trampoline<F: Fn(&Text) + 'static>(
1652            this: *mut ffi::GtkText,
1653            _param_spec: glib::ffi::gpointer,
1654            f: glib::ffi::gpointer,
1655        ) {
1656            unsafe {
1657                let f: &F = &*(f as *const F);
1658                f(&from_glib_borrow(this))
1659            }
1660        }
1661        unsafe {
1662            let f: Box_<F> = Box_::new(f);
1663            connect_raw(
1664                self.as_ptr() as *mut _,
1665                c"notify::extra-menu".as_ptr() as *const _,
1666                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1667                    notify_extra_menu_trampoline::<F> as *const (),
1668                )),
1669                Box_::into_raw(f),
1670            )
1671        }
1672    }
1673
1674    #[doc(alias = "im-module")]
1675    pub fn connect_im_module_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1676        unsafe extern "C" fn notify_im_module_trampoline<F: Fn(&Text) + 'static>(
1677            this: *mut ffi::GtkText,
1678            _param_spec: glib::ffi::gpointer,
1679            f: glib::ffi::gpointer,
1680        ) {
1681            unsafe {
1682                let f: &F = &*(f as *const F);
1683                f(&from_glib_borrow(this))
1684            }
1685        }
1686        unsafe {
1687            let f: Box_<F> = Box_::new(f);
1688            connect_raw(
1689                self.as_ptr() as *mut _,
1690                c"notify::im-module".as_ptr() as *const _,
1691                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1692                    notify_im_module_trampoline::<F> as *const (),
1693                )),
1694                Box_::into_raw(f),
1695            )
1696        }
1697    }
1698
1699    #[doc(alias = "input-hints")]
1700    pub fn connect_input_hints_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1701        unsafe extern "C" fn notify_input_hints_trampoline<F: Fn(&Text) + 'static>(
1702            this: *mut ffi::GtkText,
1703            _param_spec: glib::ffi::gpointer,
1704            f: glib::ffi::gpointer,
1705        ) {
1706            unsafe {
1707                let f: &F = &*(f as *const F);
1708                f(&from_glib_borrow(this))
1709            }
1710        }
1711        unsafe {
1712            let f: Box_<F> = Box_::new(f);
1713            connect_raw(
1714                self.as_ptr() as *mut _,
1715                c"notify::input-hints".as_ptr() as *const _,
1716                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1717                    notify_input_hints_trampoline::<F> as *const (),
1718                )),
1719                Box_::into_raw(f),
1720            )
1721        }
1722    }
1723
1724    #[doc(alias = "input-purpose")]
1725    pub fn connect_input_purpose_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1726        unsafe extern "C" fn notify_input_purpose_trampoline<F: Fn(&Text) + 'static>(
1727            this: *mut ffi::GtkText,
1728            _param_spec: glib::ffi::gpointer,
1729            f: glib::ffi::gpointer,
1730        ) {
1731            unsafe {
1732                let f: &F = &*(f as *const F);
1733                f(&from_glib_borrow(this))
1734            }
1735        }
1736        unsafe {
1737            let f: Box_<F> = Box_::new(f);
1738            connect_raw(
1739                self.as_ptr() as *mut _,
1740                c"notify::input-purpose".as_ptr() as *const _,
1741                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1742                    notify_input_purpose_trampoline::<F> as *const (),
1743                )),
1744                Box_::into_raw(f),
1745            )
1746        }
1747    }
1748
1749    #[doc(alias = "invisible-char")]
1750    pub fn connect_invisible_char_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1751        unsafe extern "C" fn notify_invisible_char_trampoline<F: Fn(&Text) + 'static>(
1752            this: *mut ffi::GtkText,
1753            _param_spec: glib::ffi::gpointer,
1754            f: glib::ffi::gpointer,
1755        ) {
1756            unsafe {
1757                let f: &F = &*(f as *const F);
1758                f(&from_glib_borrow(this))
1759            }
1760        }
1761        unsafe {
1762            let f: Box_<F> = Box_::new(f);
1763            connect_raw(
1764                self.as_ptr() as *mut _,
1765                c"notify::invisible-char".as_ptr() as *const _,
1766                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1767                    notify_invisible_char_trampoline::<F> as *const (),
1768                )),
1769                Box_::into_raw(f),
1770            )
1771        }
1772    }
1773
1774    #[doc(alias = "invisible-char-set")]
1775    pub fn connect_invisible_char_set_notify<F: Fn(&Self) + 'static>(
1776        &self,
1777        f: F,
1778    ) -> SignalHandlerId {
1779        unsafe extern "C" fn notify_invisible_char_set_trampoline<F: Fn(&Text) + 'static>(
1780            this: *mut ffi::GtkText,
1781            _param_spec: glib::ffi::gpointer,
1782            f: glib::ffi::gpointer,
1783        ) {
1784            unsafe {
1785                let f: &F = &*(f as *const F);
1786                f(&from_glib_borrow(this))
1787            }
1788        }
1789        unsafe {
1790            let f: Box_<F> = Box_::new(f);
1791            connect_raw(
1792                self.as_ptr() as *mut _,
1793                c"notify::invisible-char-set".as_ptr() as *const _,
1794                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1795                    notify_invisible_char_set_trampoline::<F> as *const (),
1796                )),
1797                Box_::into_raw(f),
1798            )
1799        }
1800    }
1801
1802    #[doc(alias = "max-length")]
1803    pub fn connect_max_length_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1804        unsafe extern "C" fn notify_max_length_trampoline<F: Fn(&Text) + 'static>(
1805            this: *mut ffi::GtkText,
1806            _param_spec: glib::ffi::gpointer,
1807            f: glib::ffi::gpointer,
1808        ) {
1809            unsafe {
1810                let f: &F = &*(f as *const F);
1811                f(&from_glib_borrow(this))
1812            }
1813        }
1814        unsafe {
1815            let f: Box_<F> = Box_::new(f);
1816            connect_raw(
1817                self.as_ptr() as *mut _,
1818                c"notify::max-length".as_ptr() as *const _,
1819                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1820                    notify_max_length_trampoline::<F> as *const (),
1821                )),
1822                Box_::into_raw(f),
1823            )
1824        }
1825    }
1826
1827    #[doc(alias = "overwrite-mode")]
1828    pub fn connect_overwrite_mode_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1829        unsafe extern "C" fn notify_overwrite_mode_trampoline<F: Fn(&Text) + 'static>(
1830            this: *mut ffi::GtkText,
1831            _param_spec: glib::ffi::gpointer,
1832            f: glib::ffi::gpointer,
1833        ) {
1834            unsafe {
1835                let f: &F = &*(f as *const F);
1836                f(&from_glib_borrow(this))
1837            }
1838        }
1839        unsafe {
1840            let f: Box_<F> = Box_::new(f);
1841            connect_raw(
1842                self.as_ptr() as *mut _,
1843                c"notify::overwrite-mode".as_ptr() as *const _,
1844                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1845                    notify_overwrite_mode_trampoline::<F> as *const (),
1846                )),
1847                Box_::into_raw(f),
1848            )
1849        }
1850    }
1851
1852    #[doc(alias = "placeholder-text")]
1853    pub fn connect_placeholder_text_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1854        unsafe extern "C" fn notify_placeholder_text_trampoline<F: Fn(&Text) + 'static>(
1855            this: *mut ffi::GtkText,
1856            _param_spec: glib::ffi::gpointer,
1857            f: glib::ffi::gpointer,
1858        ) {
1859            unsafe {
1860                let f: &F = &*(f as *const F);
1861                f(&from_glib_borrow(this))
1862            }
1863        }
1864        unsafe {
1865            let f: Box_<F> = Box_::new(f);
1866            connect_raw(
1867                self.as_ptr() as *mut _,
1868                c"notify::placeholder-text".as_ptr() as *const _,
1869                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1870                    notify_placeholder_text_trampoline::<F> as *const (),
1871                )),
1872                Box_::into_raw(f),
1873            )
1874        }
1875    }
1876
1877    #[doc(alias = "propagate-text-width")]
1878    pub fn connect_propagate_text_width_notify<F: Fn(&Self) + 'static>(
1879        &self,
1880        f: F,
1881    ) -> SignalHandlerId {
1882        unsafe extern "C" fn notify_propagate_text_width_trampoline<F: Fn(&Text) + 'static>(
1883            this: *mut ffi::GtkText,
1884            _param_spec: glib::ffi::gpointer,
1885            f: glib::ffi::gpointer,
1886        ) {
1887            unsafe {
1888                let f: &F = &*(f as *const F);
1889                f(&from_glib_borrow(this))
1890            }
1891        }
1892        unsafe {
1893            let f: Box_<F> = Box_::new(f);
1894            connect_raw(
1895                self.as_ptr() as *mut _,
1896                c"notify::propagate-text-width".as_ptr() as *const _,
1897                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1898                    notify_propagate_text_width_trampoline::<F> as *const (),
1899                )),
1900                Box_::into_raw(f),
1901            )
1902        }
1903    }
1904
1905    #[doc(alias = "scroll-offset")]
1906    pub fn connect_scroll_offset_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1907        unsafe extern "C" fn notify_scroll_offset_trampoline<F: Fn(&Text) + 'static>(
1908            this: *mut ffi::GtkText,
1909            _param_spec: glib::ffi::gpointer,
1910            f: glib::ffi::gpointer,
1911        ) {
1912            unsafe {
1913                let f: &F = &*(f as *const F);
1914                f(&from_glib_borrow(this))
1915            }
1916        }
1917        unsafe {
1918            let f: Box_<F> = Box_::new(f);
1919            connect_raw(
1920                self.as_ptr() as *mut _,
1921                c"notify::scroll-offset".as_ptr() as *const _,
1922                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1923                    notify_scroll_offset_trampoline::<F> as *const (),
1924                )),
1925                Box_::into_raw(f),
1926            )
1927        }
1928    }
1929
1930    #[doc(alias = "tabs")]
1931    pub fn connect_tabs_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1932        unsafe extern "C" fn notify_tabs_trampoline<F: Fn(&Text) + 'static>(
1933            this: *mut ffi::GtkText,
1934            _param_spec: glib::ffi::gpointer,
1935            f: glib::ffi::gpointer,
1936        ) {
1937            unsafe {
1938                let f: &F = &*(f as *const F);
1939                f(&from_glib_borrow(this))
1940            }
1941        }
1942        unsafe {
1943            let f: Box_<F> = Box_::new(f);
1944            connect_raw(
1945                self.as_ptr() as *mut _,
1946                c"notify::tabs".as_ptr() as *const _,
1947                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1948                    notify_tabs_trampoline::<F> as *const (),
1949                )),
1950                Box_::into_raw(f),
1951            )
1952        }
1953    }
1954
1955    #[doc(alias = "truncate-multiline")]
1956    pub fn connect_truncate_multiline_notify<F: Fn(&Self) + 'static>(
1957        &self,
1958        f: F,
1959    ) -> SignalHandlerId {
1960        unsafe extern "C" fn notify_truncate_multiline_trampoline<F: Fn(&Text) + 'static>(
1961            this: *mut ffi::GtkText,
1962            _param_spec: glib::ffi::gpointer,
1963            f: glib::ffi::gpointer,
1964        ) {
1965            unsafe {
1966                let f: &F = &*(f as *const F);
1967                f(&from_glib_borrow(this))
1968            }
1969        }
1970        unsafe {
1971            let f: Box_<F> = Box_::new(f);
1972            connect_raw(
1973                self.as_ptr() as *mut _,
1974                c"notify::truncate-multiline".as_ptr() as *const _,
1975                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1976                    notify_truncate_multiline_trampoline::<F> as *const (),
1977                )),
1978                Box_::into_raw(f),
1979            )
1980        }
1981    }
1982
1983    #[doc(alias = "visibility")]
1984    pub fn connect_visibility_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1985        unsafe extern "C" fn notify_visibility_trampoline<F: Fn(&Text) + 'static>(
1986            this: *mut ffi::GtkText,
1987            _param_spec: glib::ffi::gpointer,
1988            f: glib::ffi::gpointer,
1989        ) {
1990            unsafe {
1991                let f: &F = &*(f as *const F);
1992                f(&from_glib_borrow(this))
1993            }
1994        }
1995        unsafe {
1996            let f: Box_<F> = Box_::new(f);
1997            connect_raw(
1998                self.as_ptr() as *mut _,
1999                c"notify::visibility".as_ptr() as *const _,
2000                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
2001                    notify_visibility_trampoline::<F> as *const (),
2002                )),
2003                Box_::into_raw(f),
2004            )
2005        }
2006    }
2007}
2008
2009impl Default for Text {
2010    fn default() -> Self {
2011        Self::new()
2012    }
2013}
2014
2015// rustdoc-stripper-ignore-next
2016/// A [builder-pattern] type to construct [`Text`] objects.
2017///
2018/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
2019#[must_use = "The builder must be built to be used"]
2020pub struct TextBuilder {
2021    builder: glib::object::ObjectBuilder<'static, Text>,
2022}
2023
2024impl TextBuilder {
2025    fn new() -> Self {
2026        Self {
2027            builder: glib::object::Object::builder(),
2028        }
2029    }
2030
2031    /// Whether to activate the default widget when <kbd>Enter</kbd> is pressed.
2032    pub fn activates_default(self, activates_default: bool) -> Self {
2033        Self {
2034            builder: self
2035                .builder
2036                .property("activates-default", activates_default),
2037        }
2038    }
2039
2040    /// A list of Pango attributes to apply to the text.
2041    ///
2042    /// This is mainly useful to change the size or weight of the text.
2043    ///
2044    /// The `PangoAttribute`'s @start_index and @end_index must refer to the
2045    /// [`EntryBuffer`][crate::EntryBuffer] text, i.e. without the preedit string.
2046    pub fn attributes(self, attributes: &pango::AttrList) -> Self {
2047        Self {
2048            builder: self.builder.property("attributes", attributes.clone()),
2049        }
2050    }
2051
2052    /// The [`EntryBuffer`][crate::EntryBuffer] object which stores the text.
2053    pub fn buffer(self, buffer: &impl IsA<EntryBuffer>) -> Self {
2054        Self {
2055            builder: self.builder.property("buffer", buffer.clone().upcast()),
2056        }
2057    }
2058
2059    /// Whether to suggest Emoji replacements.
2060    pub fn enable_emoji_completion(self, enable_emoji_completion: bool) -> Self {
2061        Self {
2062            builder: self
2063                .builder
2064                .property("enable-emoji-completion", enable_emoji_completion),
2065        }
2066    }
2067
2068    /// A menu model whose contents will be appended to the context menu.
2069    pub fn extra_menu(self, extra_menu: &impl IsA<gio::MenuModel>) -> Self {
2070        Self {
2071            builder: self
2072                .builder
2073                .property("extra-menu", extra_menu.clone().upcast()),
2074        }
2075    }
2076
2077    /// Which input method module should be used.
2078    ///
2079    /// See [`IMMulticontext`][crate::IMMulticontext].
2080    ///
2081    /// Setting this to a non-`NULL` value overrides the system-wide
2082    /// input method. See the [`gtk-im-module`][struct@crate::Settings#gtk-im-module]
2083    /// setting.
2084    pub fn im_module(self, im_module: impl Into<glib::GString>) -> Self {
2085        Self {
2086            builder: self.builder.property("im-module", im_module.into()),
2087        }
2088    }
2089
2090    /// Additional hints that allow input methods to fine-tune
2091    /// their behaviour.
2092    pub fn input_hints(self, input_hints: InputHints) -> Self {
2093        Self {
2094            builder: self.builder.property("input-hints", input_hints),
2095        }
2096    }
2097
2098    /// The purpose of this text field.
2099    ///
2100    /// This information can be used by on-screen keyboards and other input
2101    /// methods to adjust their behaviour.
2102    ///
2103    /// Note that setting the purpose to [enum@Gtk.InputPurpose.password]
2104    /// or [enum@Gtk.InputPurpose.pin] is independent from setting
2105    /// [`visibility`][struct@crate::Text#visibility].
2106    pub fn input_purpose(self, input_purpose: InputPurpose) -> Self {
2107        Self {
2108            builder: self.builder.property("input-purpose", input_purpose),
2109        }
2110    }
2111
2112    /// The character to used when masking contents (in “password mode”).
2113    pub fn invisible_char(self, invisible_char: u32) -> Self {
2114        Self {
2115            builder: self.builder.property("invisible-char", invisible_char),
2116        }
2117    }
2118
2119    /// Whether the invisible char has been set.
2120    pub fn invisible_char_set(self, invisible_char_set: bool) -> Self {
2121        Self {
2122            builder: self
2123                .builder
2124                .property("invisible-char-set", invisible_char_set),
2125        }
2126    }
2127
2128    /// Maximum number of characters that are allowed.
2129    ///
2130    /// Zero indicates no limit.
2131    pub fn max_length(self, max_length: i32) -> Self {
2132        Self {
2133            builder: self.builder.property("max-length", max_length),
2134        }
2135    }
2136
2137    /// If text is overwritten when typing.
2138    pub fn overwrite_mode(self, overwrite_mode: bool) -> Self {
2139        Self {
2140            builder: self.builder.property("overwrite-mode", overwrite_mode),
2141        }
2142    }
2143
2144    /// The text that will be displayed in the [`Text`][crate::Text] when it is empty
2145    /// and unfocused.
2146    pub fn placeholder_text(self, placeholder_text: impl Into<glib::GString>) -> Self {
2147        Self {
2148            builder: self
2149                .builder
2150                .property("placeholder-text", placeholder_text.into()),
2151        }
2152    }
2153
2154    /// Whether the widget should grow and shrink with the content.
2155    pub fn propagate_text_width(self, propagate_text_width: bool) -> Self {
2156        Self {
2157            builder: self
2158                .builder
2159                .property("propagate-text-width", propagate_text_width),
2160        }
2161    }
2162
2163    /// Custom tabs for this text widget.
2164    pub fn tabs(self, tabs: &pango::TabArray) -> Self {
2165        Self {
2166            builder: self.builder.property("tabs", tabs),
2167        }
2168    }
2169
2170    /// When true, pasted multi-line text is truncated to the first line.
2171    pub fn truncate_multiline(self, truncate_multiline: bool) -> Self {
2172        Self {
2173            builder: self
2174                .builder
2175                .property("truncate-multiline", truncate_multiline),
2176        }
2177    }
2178
2179    /// If false, the text is masked with the “invisible char”.
2180    pub fn visibility(self, visibility: bool) -> Self {
2181        Self {
2182            builder: self.builder.property("visibility", visibility),
2183        }
2184    }
2185
2186    /// Whether the widget or any of its descendents can accept
2187    /// the input focus.
2188    ///
2189    /// This property is meant to be set by widget implementations,
2190    /// typically in their instance init function.
2191    pub fn can_focus(self, can_focus: bool) -> Self {
2192        Self {
2193            builder: self.builder.property("can-focus", can_focus),
2194        }
2195    }
2196
2197    /// Whether the widget can receive pointer events.
2198    pub fn can_target(self, can_target: bool) -> Self {
2199        Self {
2200            builder: self.builder.property("can-target", can_target),
2201        }
2202    }
2203
2204    /// A list of css classes applied to this widget.
2205    pub fn css_classes(self, css_classes: impl Into<glib::StrV>) -> Self {
2206        Self {
2207            builder: self.builder.property("css-classes", css_classes.into()),
2208        }
2209    }
2210
2211    /// The name of this widget in the CSS tree.
2212    ///
2213    /// This property is meant to be set by widget implementations,
2214    /// typically in their instance init function.
2215    pub fn css_name(self, css_name: impl Into<glib::GString>) -> Self {
2216        Self {
2217            builder: self.builder.property("css-name", css_name.into()),
2218        }
2219    }
2220
2221    /// The cursor used by @widget.
2222    pub fn cursor(self, cursor: &gdk::Cursor) -> Self {
2223        Self {
2224            builder: self.builder.property("cursor", cursor.clone()),
2225        }
2226    }
2227
2228    /// Whether the widget should grab focus when it is clicked with the mouse.
2229    ///
2230    /// This property is only relevant for widgets that can take focus.
2231    pub fn focus_on_click(self, focus_on_click: bool) -> Self {
2232        Self {
2233            builder: self.builder.property("focus-on-click", focus_on_click),
2234        }
2235    }
2236
2237    /// Whether this widget itself will accept the input focus.
2238    pub fn focusable(self, focusable: bool) -> Self {
2239        Self {
2240            builder: self.builder.property("focusable", focusable),
2241        }
2242    }
2243
2244    /// How to distribute horizontal space if widget gets extra space.
2245    pub fn halign(self, halign: Align) -> Self {
2246        Self {
2247            builder: self.builder.property("halign", halign),
2248        }
2249    }
2250
2251    /// Enables or disables the emission of the [`query-tooltip`][struct@crate::Widget#query-tooltip]
2252    /// signal on @widget.
2253    ///
2254    /// A true value indicates that @widget can have a tooltip, in this case
2255    /// the widget will be queried using [`query-tooltip`][struct@crate::Widget#query-tooltip] to
2256    /// determine whether it will provide a tooltip or not.
2257    pub fn has_tooltip(self, has_tooltip: bool) -> Self {
2258        Self {
2259            builder: self.builder.property("has-tooltip", has_tooltip),
2260        }
2261    }
2262
2263    /// Overrides for height request of the widget.
2264    ///
2265    /// If this is -1, the natural request will be used.
2266    pub fn height_request(self, height_request: i32) -> Self {
2267        Self {
2268            builder: self.builder.property("height-request", height_request),
2269        }
2270    }
2271
2272    /// Whether to expand horizontally.
2273    pub fn hexpand(self, hexpand: bool) -> Self {
2274        Self {
2275            builder: self.builder.property("hexpand", hexpand),
2276        }
2277    }
2278
2279    /// Whether to use the `hexpand` property.
2280    pub fn hexpand_set(self, hexpand_set: bool) -> Self {
2281        Self {
2282            builder: self.builder.property("hexpand-set", hexpand_set),
2283        }
2284    }
2285
2286    /// The [`LayoutManager`][crate::LayoutManager] instance to use to compute
2287    /// the preferred size of the widget, and allocate its children.
2288    ///
2289    /// This property is meant to be set by widget implementations,
2290    /// typically in their instance init function.
2291    pub fn layout_manager(self, layout_manager: &impl IsA<LayoutManager>) -> Self {
2292        Self {
2293            builder: self
2294                .builder
2295                .property("layout-manager", layout_manager.clone().upcast()),
2296        }
2297    }
2298
2299    /// Makes this widget act like a modal dialog, with respect to
2300    /// event delivery.
2301    ///
2302    /// Global event controllers will not handle events with targets
2303    /// inside the widget, unless they are set up to ignore propagation
2304    /// limits. See [`EventControllerExt::set_propagation_limit()`][crate::prelude::EventControllerExt::set_propagation_limit()].
2305    #[cfg(feature = "v4_18")]
2306    #[cfg_attr(docsrs, doc(cfg(feature = "v4_18")))]
2307    pub fn limit_events(self, limit_events: bool) -> Self {
2308        Self {
2309            builder: self.builder.property("limit-events", limit_events),
2310        }
2311    }
2312
2313    /// Margin on bottom side of widget.
2314    ///
2315    /// This property adds margin outside of the widget's normal size
2316    /// request, the margin will be added in addition to the size from
2317    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
2318    pub fn margin_bottom(self, margin_bottom: i32) -> Self {
2319        Self {
2320            builder: self.builder.property("margin-bottom", margin_bottom),
2321        }
2322    }
2323
2324    /// Margin on end of widget, horizontally.
2325    ///
2326    /// This property supports left-to-right and right-to-left text
2327    /// directions.
2328    ///
2329    /// This property adds margin outside of the widget's normal size
2330    /// request, the margin will be added in addition to the size from
2331    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
2332    pub fn margin_end(self, margin_end: i32) -> Self {
2333        Self {
2334            builder: self.builder.property("margin-end", margin_end),
2335        }
2336    }
2337
2338    /// Margin on start of widget, horizontally.
2339    ///
2340    /// This property supports left-to-right and right-to-left text
2341    /// directions.
2342    ///
2343    /// This property adds margin outside of the widget's normal size
2344    /// request, the margin will be added in addition to the size from
2345    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
2346    pub fn margin_start(self, margin_start: i32) -> Self {
2347        Self {
2348            builder: self.builder.property("margin-start", margin_start),
2349        }
2350    }
2351
2352    /// Margin on top side of widget.
2353    ///
2354    /// This property adds margin outside of the widget's normal size
2355    /// request, the margin will be added in addition to the size from
2356    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
2357    pub fn margin_top(self, margin_top: i32) -> Self {
2358        Self {
2359            builder: self.builder.property("margin-top", margin_top),
2360        }
2361    }
2362
2363    /// The name of the widget.
2364    pub fn name(self, name: impl Into<glib::GString>) -> Self {
2365        Self {
2366            builder: self.builder.property("name", name.into()),
2367        }
2368    }
2369
2370    /// The requested opacity of the widget.
2371    pub fn opacity(self, opacity: f64) -> Self {
2372        Self {
2373            builder: self.builder.property("opacity", opacity),
2374        }
2375    }
2376
2377    /// How content outside the widget's content area is treated.
2378    ///
2379    /// This property is meant to be set by widget implementations,
2380    /// typically in their instance init function.
2381    pub fn overflow(self, overflow: Overflow) -> Self {
2382        Self {
2383            builder: self.builder.property("overflow", overflow),
2384        }
2385    }
2386
2387    /// Whether the widget will receive the default action when it is focused.
2388    pub fn receives_default(self, receives_default: bool) -> Self {
2389        Self {
2390            builder: self.builder.property("receives-default", receives_default),
2391        }
2392    }
2393
2394    /// Whether the widget responds to input.
2395    pub fn sensitive(self, sensitive: bool) -> Self {
2396        Self {
2397            builder: self.builder.property("sensitive", sensitive),
2398        }
2399    }
2400
2401    /// Sets the text of tooltip to be the given string, which is marked up
2402    /// with Pango markup.
2403    ///
2404    /// Also see [`Tooltip::set_markup()`][crate::Tooltip::set_markup()].
2405    ///
2406    /// This is a convenience property which will take care of getting the
2407    /// tooltip shown if the given string is not `NULL`:
2408    /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
2409    /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
2410    /// the default signal handler.
2411    ///
2412    /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
2413    /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
2414    pub fn tooltip_markup(self, tooltip_markup: impl Into<glib::GString>) -> Self {
2415        Self {
2416            builder: self
2417                .builder
2418                .property("tooltip-markup", tooltip_markup.into()),
2419        }
2420    }
2421
2422    /// Sets the text of tooltip to be the given string.
2423    ///
2424    /// Also see [`Tooltip::set_text()`][crate::Tooltip::set_text()].
2425    ///
2426    /// This is a convenience property which will take care of getting the
2427    /// tooltip shown if the given string is not `NULL`:
2428    /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
2429    /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
2430    /// the default signal handler.
2431    ///
2432    /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
2433    /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
2434    pub fn tooltip_text(self, tooltip_text: impl Into<glib::GString>) -> Self {
2435        Self {
2436            builder: self.builder.property("tooltip-text", tooltip_text.into()),
2437        }
2438    }
2439
2440    /// How to distribute vertical space if widget gets extra space.
2441    pub fn valign(self, valign: Align) -> Self {
2442        Self {
2443            builder: self.builder.property("valign", valign),
2444        }
2445    }
2446
2447    /// Whether to expand vertically.
2448    pub fn vexpand(self, vexpand: bool) -> Self {
2449        Self {
2450            builder: self.builder.property("vexpand", vexpand),
2451        }
2452    }
2453
2454    /// Whether to use the `vexpand` property.
2455    pub fn vexpand_set(self, vexpand_set: bool) -> Self {
2456        Self {
2457            builder: self.builder.property("vexpand-set", vexpand_set),
2458        }
2459    }
2460
2461    /// Whether the widget is visible.
2462    pub fn visible(self, visible: bool) -> Self {
2463        Self {
2464            builder: self.builder.property("visible", visible),
2465        }
2466    }
2467
2468    /// Overrides for width request of the widget.
2469    ///
2470    /// If this is -1, the natural request will be used.
2471    pub fn width_request(self, width_request: i32) -> Self {
2472        Self {
2473            builder: self.builder.property("width-request", width_request),
2474        }
2475    }
2476
2477    /// The accessible role of the given [`Accessible`][crate::Accessible] implementation.
2478    ///
2479    /// The accessible role cannot be changed once set.
2480    pub fn accessible_role(self, accessible_role: AccessibleRole) -> Self {
2481        Self {
2482            builder: self.builder.property("accessible-role", accessible_role),
2483        }
2484    }
2485
2486    /// Whether the entry contents can be edited.
2487    pub fn editable(self, editable: bool) -> Self {
2488        Self {
2489            builder: self.builder.property("editable", editable),
2490        }
2491    }
2492
2493    /// If undo/redo should be enabled for the editable.
2494    pub fn enable_undo(self, enable_undo: bool) -> Self {
2495        Self {
2496            builder: self.builder.property("enable-undo", enable_undo),
2497        }
2498    }
2499
2500    /// The desired maximum width of the entry, in characters.
2501    pub fn max_width_chars(self, max_width_chars: i32) -> Self {
2502        Self {
2503            builder: self.builder.property("max-width-chars", max_width_chars),
2504        }
2505    }
2506
2507    /// The contents of the entry.
2508    pub fn text(self, text: impl Into<glib::GString>) -> Self {
2509        Self {
2510            builder: self.builder.property("text", text.into()),
2511        }
2512    }
2513
2514    /// Number of characters to leave space for in the entry.
2515    pub fn width_chars(self, width_chars: i32) -> Self {
2516        Self {
2517            builder: self.builder.property("width-chars", width_chars),
2518        }
2519    }
2520
2521    /// The horizontal alignment, from 0 (left) to 1 (right).
2522    ///
2523    /// Reversed for RTL layouts.
2524    pub fn xalign(self, xalign: f32) -> Self {
2525        Self {
2526            builder: self.builder.property("xalign", xalign),
2527        }
2528    }
2529
2530    // rustdoc-stripper-ignore-next
2531    /// Build the [`Text`].
2532    #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
2533    pub fn build(self) -> Text {
2534        assert_initialized_main_thread!();
2535        self.builder.build()
2536    }
2537}