Skip to main content

gtk4/auto/
text.rs

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