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