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