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