gtk4/auto/text_view.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, Adjustment, Align, Buildable, ConstraintTarget, DeleteType, InputHints,
13 InputPurpose, Justification, LayoutManager, MovementStep, Overflow, ScrollStep, Scrollable,
14 ScrollablePolicy, TextBuffer, TextChildAnchor, TextExtendSelection, TextIter, TextMark,
15 TextWindowType, Widget, WrapMode, ffi,
16};
17use glib::{
18 object::ObjectType as _,
19 prelude::*,
20 signal::{SignalHandlerId, connect_raw},
21 translate::*,
22};
23use std::boxed::Box as Box_;
24
25#[cfg(all(feature = "v4_10", feature = "v4_14"))]
26#[cfg_attr(docsrs, doc(cfg(feature = "v4_14")))]
27glib::wrapper! {
28 /// Displays the contents of a [`TextBuffer`][crate::TextBuffer].
29 ///
30 /// <picture>
31 /// <source srcset="multiline-text-dark.png" media="(prefers-color-scheme: dark)">
32 /// <img alt="An example GtkTextView" src="multiline-text.png">
33 /// </picture>
34 ///
35 /// You may wish to begin by reading the [conceptual overview](section-text-widget.html),
36 /// which gives an overview of all the objects and data types related to the
37 /// text widget and how they work together.
38 ///
39 /// ## Shortcuts and Gestures
40 ///
41 /// [`TextView`][crate::TextView] supports the following keyboard shortcuts:
42 ///
43 /// - <kbd>Shift</kbd>+<kbd>F10</kbd> or <kbd>Menu</kbd> opens the context menu.
44 /// - <kbd>Ctrl</kbd>+<kbd>Z</kbd> undoes the last modification.
45 /// - <kbd>Ctrl</kbd>+<kbd>Y</kbd> or <kbd>Ctrl</kbd>+<kbd>Shift</kbd>+<kbd>Z</kbd>
46 /// redoes the last undone modification.
47 /// - <kbd>Clear</kbd> clears the content.
48 ///
49 /// Additionally, the following signals have default keybindings:
50 ///
51 /// - [`backspace`][struct@crate::TextView#backspace]
52 /// - [`copy-clipboard`][struct@crate::TextView#copy-clipboard]
53 /// - [`cut-clipboard`][struct@crate::TextView#cut-clipboard]
54 /// - [`delete-from-cursor`][struct@crate::TextView#delete-from-cursor]
55 /// - [`insert-emoji`][struct@crate::TextView#insert-emoji]
56 /// - [`move-cursor`][struct@crate::TextView#move-cursor]
57 /// - [`paste-clipboard`][struct@crate::TextView#paste-clipboard]
58 /// - [`select-all`][struct@crate::TextView#select-all]
59 /// - [`toggle-cursor-visible`][struct@crate::TextView#toggle-cursor-visible]
60 /// - [`toggle-overwrite`][struct@crate::TextView#toggle-overwrite]
61 ///
62 /// ## Actions
63 ///
64 /// [`TextView`][crate::TextView] defines a set of built-in actions:
65 ///
66 /// - `clipboard.copy` copies the contents to the clipboard.
67 /// - `clipboard.cut` copies the contents to the clipboard and deletes it from
68 /// the widget.
69 /// - `clipboard.paste` inserts the contents of the clipboard into the widget.
70 /// - `menu.popup` opens the context menu.
71 /// - `misc.insert-emoji` opens the Emoji chooser.
72 /// - `selection.delete` deletes the current selection.
73 /// - `selection.select-all` selects all of the widgets content.
74 /// - `text.redo` redoes the last change to the contents.
75 /// - `text.undo` undoes the last change to the contents.
76 /// - `text.clear` clears the content.
77 ///
78 /// ## CSS nodes
79 ///
80 /// ```text
81 /// textview.view
82 /// ├── border.top
83 /// ├── border.left
84 /// ├── text
85 /// │ ├── [preedit[.whole][.selection][.prediction][.prefix/.suffix][.spelling-error][.compose-error]]
86 /// │ ╰── [selection]
87 /// ├── border.right
88 /// ├── border.bottom
89 /// ╰── [window.popup]
90 /// ```
91 ///
92 /// [`TextView`][crate::TextView] has a main css node with name textview and style class .view,
93 /// and subnodes for each of the border windows, and the main text area,
94 /// with names border and text, respectively. The border nodes each get
95 /// one of the style classes .left, .right, .top or .bottom.
96 ///
97 /// A node representing the selection will appear below the text node.
98 ///
99 /// If a context menu is opened, the window node will appear as a subnode
100 /// of the main node.
101 ///
102 /// If using an input method with a pre-edit buffer, this string will be styled
103 /// with a `preedit` subnode of the `text` node. the different style classes
104 /// express the possible roles of a piece of text in the pre-edit buffer:
105 ///
106 /// - `.whole` denotes the parts of the pre-edit buffer without a special role
107 /// - `.selection`, `.prefix` and `.suffix` style classes will be used to
108 /// highlight the specific portions of the pre-edit buffer being edited and its
109 /// surroundings
110 /// - `.prediction` will be used for parts of the pre-edit buffer not typed by the
111 /// user (e.g. autocompletion)
112 /// - `.spelling-error` and `.compose-error` will be respectively used to indicate
113 /// errors in spelling or character composition (e.g. non-existent transliterations).
114 ///
115 /// ## Accessibility
116 ///
117 /// [`TextView`][crate::TextView] uses the [enum@Gtk.AccessibleRole.text_box] role.
118 ///
119 /// ## Properties
120 ///
121 ///
122 /// #### `accepts-tab`
123 /// Whether Tab will result in a tab character being entered.
124 ///
125 /// Readable | Writable
126 ///
127 ///
128 /// #### `bottom-margin`
129 /// The bottom margin for text in the text view.
130 ///
131 /// Note that this property is confusingly named. In CSS terms,
132 /// the value set here is padding, and it is applied in addition
133 /// to the padding from the theme.
134 ///
135 /// Don't confuse this property with [`margin-bottom`][struct@crate::Widget#margin-bottom].
136 ///
137 /// Readable | Writable
138 ///
139 ///
140 /// #### `buffer`
141 /// The buffer which is displayed.
142 ///
143 /// Readable | Writable
144 ///
145 ///
146 /// #### `cursor-visible`
147 /// If the insertion cursor is shown.
148 ///
149 /// Readable | Writable
150 ///
151 ///
152 /// #### `editable`
153 /// Whether the text can be modified by the user.
154 ///
155 /// Readable | Writable
156 ///
157 ///
158 /// #### `extra-menu`
159 /// A menu model whose contents will be appended to the context menu.
160 ///
161 /// Readable | Writable
162 ///
163 ///
164 /// #### `im-module`
165 /// Which IM (input method) module should be used for this text_view.
166 ///
167 /// See [`IMMulticontext`][crate::IMMulticontext].
168 ///
169 /// Setting this to a non-[`None`] value overrides the system-wide IM module
170 /// setting. See the GtkSettings [`gtk-im-module`][struct@crate::Settings#gtk-im-module] property.
171 ///
172 /// Readable | Writable
173 ///
174 ///
175 /// #### `indent`
176 /// Amount to indent the paragraph, in pixels.
177 ///
178 /// A negative value of indent will produce a hanging indentation.
179 /// That is, the first line will have the full width, and subsequent
180 /// lines will be indented by the absolute value of indent.
181 ///
182 /// Readable | Writable
183 ///
184 ///
185 /// #### `input-hints`
186 /// Additional hints (beyond [`input-purpose`][struct@crate::TextView#input-purpose])
187 /// that allow input methods to fine-tune their behaviour.
188 ///
189 /// Readable | Writable
190 ///
191 ///
192 /// #### `input-purpose`
193 /// The purpose of this text field.
194 ///
195 /// This property can be used by on-screen keyboards and other input
196 /// methods to adjust their behaviour.
197 ///
198 /// Readable | Writable
199 ///
200 ///
201 /// #### `justification`
202 /// Left, right, or center justification.
203 ///
204 /// Readable | Writable
205 ///
206 ///
207 /// #### `left-margin`
208 /// The default left margin for text in the text view.
209 ///
210 /// Tags in the buffer may override the default.
211 ///
212 /// Note that this property is confusingly named. In CSS terms,
213 /// the value set here is padding, and it is applied in addition
214 /// to the padding from the theme.
215 ///
216 /// Readable | Writable
217 ///
218 ///
219 /// #### `monospace`
220 /// Whether text should be displayed in a monospace font.
221 ///
222 /// If [`true`], set the .monospace style class on the
223 /// text view to indicate that a monospace font is desired.
224 ///
225 /// Readable | Writable
226 ///
227 ///
228 /// #### `overwrite`
229 /// Whether entered text overwrites existing contents.
230 ///
231 /// Readable | Writable
232 ///
233 ///
234 /// #### `pixels-above-lines`
235 /// Pixels of blank space above paragraphs.
236 ///
237 /// Readable | Writable
238 ///
239 ///
240 /// #### `pixels-below-lines`
241 /// Pixels of blank space below paragraphs.
242 ///
243 /// Readable | Writable
244 ///
245 ///
246 /// #### `pixels-inside-wrap`
247 /// Pixels of blank space between wrapped lines in a paragraph.
248 ///
249 /// Readable | Writable
250 ///
251 ///
252 /// #### `right-margin`
253 /// The default right margin for text in the text view.
254 ///
255 /// Tags in the buffer may override the default.
256 ///
257 /// Note that this property is confusingly named. In CSS terms,
258 /// the value set here is padding, and it is applied in addition
259 /// to the padding from the theme.
260 ///
261 /// Readable | Writable
262 ///
263 ///
264 /// #### `tabs`
265 /// Custom tabs for this text.
266 ///
267 /// Readable | Writable
268 ///
269 ///
270 /// #### `top-margin`
271 /// The top margin for text in the text view.
272 ///
273 /// Note that this property is confusingly named. In CSS terms,
274 /// the value set here is padding, and it is applied in addition
275 /// to the padding from the theme.
276 ///
277 /// Don't confuse this property with [`margin-top`][struct@crate::Widget#margin-top].
278 ///
279 /// Readable | Writable
280 ///
281 ///
282 /// #### `wrap-mode`
283 /// Whether to wrap lines never, at word boundaries, or at character boundaries.
284 ///
285 /// Readable | Writable
286 /// <details><summary><h4>Widget</h4></summary>
287 ///
288 ///
289 /// #### `can-focus`
290 /// Whether the widget or any of its descendents can accept
291 /// the input focus.
292 ///
293 /// This property is meant to be set by widget implementations,
294 /// typically in their instance init function.
295 ///
296 /// Readable | Writable
297 ///
298 ///
299 /// #### `can-target`
300 /// Whether the widget can receive pointer events.
301 ///
302 /// Readable | Writable
303 ///
304 ///
305 /// #### `css-classes`
306 /// A list of css classes applied to this widget.
307 ///
308 /// Readable | Writable
309 ///
310 ///
311 /// #### `css-name`
312 /// The name of this widget in the CSS tree.
313 ///
314 /// This property is meant to be set by widget implementations,
315 /// typically in their instance init function.
316 ///
317 /// Readable | Writable | Construct Only
318 ///
319 ///
320 /// #### `cursor`
321 /// The cursor used by @widget.
322 ///
323 /// Readable | Writable
324 ///
325 ///
326 /// #### `focus-on-click`
327 /// Whether the widget should grab focus when it is clicked with the mouse.
328 ///
329 /// This property is only relevant for widgets that can take focus.
330 ///
331 /// Readable | Writable
332 ///
333 ///
334 /// #### `focusable`
335 /// Whether this widget itself will accept the input focus.
336 ///
337 /// Readable | Writable
338 ///
339 ///
340 /// #### `halign`
341 /// How to distribute horizontal space if widget gets extra space.
342 ///
343 /// Readable | Writable
344 ///
345 ///
346 /// #### `has-default`
347 /// Whether the widget is the default widget.
348 ///
349 /// Readable
350 ///
351 ///
352 /// #### `has-focus`
353 /// Whether the widget has the input focus.
354 ///
355 /// Readable
356 ///
357 ///
358 /// #### `has-tooltip`
359 /// Enables or disables the emission of the [`query-tooltip`][struct@crate::Widget#query-tooltip]
360 /// signal on @widget.
361 ///
362 /// A true value indicates that @widget can have a tooltip, in this case
363 /// the widget will be queried using [`query-tooltip`][struct@crate::Widget#query-tooltip] to
364 /// determine whether it will provide a tooltip or not.
365 ///
366 /// Readable | Writable
367 ///
368 ///
369 /// #### `height-request`
370 /// Overrides for height request of the widget.
371 ///
372 /// If this is -1, the natural request will be used.
373 ///
374 /// Readable | Writable
375 ///
376 ///
377 /// #### `hexpand`
378 /// Whether to expand horizontally.
379 ///
380 /// Readable | Writable
381 ///
382 ///
383 /// #### `hexpand-set`
384 /// Whether to use the `hexpand` property.
385 ///
386 /// Readable | Writable
387 ///
388 ///
389 /// #### `layout-manager`
390 /// The [`LayoutManager`][crate::LayoutManager] instance to use to compute
391 /// the preferred size of the widget, and allocate its children.
392 ///
393 /// This property is meant to be set by widget implementations,
394 /// typically in their instance init function.
395 ///
396 /// Readable | Writable
397 ///
398 ///
399 /// #### `limit-events`
400 /// Makes this widget act like a modal dialog, with respect to
401 /// event delivery.
402 ///
403 /// Global event controllers will not handle events with targets
404 /// inside the widget, unless they are set up to ignore propagation
405 /// limits. See [`EventControllerExt::set_propagation_limit()`][crate::prelude::EventControllerExt::set_propagation_limit()].
406 ///
407 /// Readable | Writable
408 ///
409 ///
410 /// #### `margin-bottom`
411 /// Margin on bottom side of widget.
412 ///
413 /// This property adds margin outside of the widget's normal size
414 /// request, the margin will be added in addition to the size from
415 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
416 ///
417 /// Readable | Writable
418 ///
419 ///
420 /// #### `margin-end`
421 /// Margin on end of widget, horizontally.
422 ///
423 /// This property supports left-to-right and right-to-left text
424 /// directions.
425 ///
426 /// This property adds margin outside of the widget's normal size
427 /// request, the margin will be added in addition to the size from
428 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
429 ///
430 /// Readable | Writable
431 ///
432 ///
433 /// #### `margin-start`
434 /// Margin on start of widget, horizontally.
435 ///
436 /// This property supports left-to-right and right-to-left text
437 /// directions.
438 ///
439 /// This property adds margin outside of the widget's normal size
440 /// request, the margin will be added in addition to the size from
441 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
442 ///
443 /// Readable | Writable
444 ///
445 ///
446 /// #### `margin-top`
447 /// Margin on top side of widget.
448 ///
449 /// This property adds margin outside of the widget's normal size
450 /// request, the margin will be added in addition to the size from
451 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
452 ///
453 /// Readable | Writable
454 ///
455 ///
456 /// #### `name`
457 /// The name of the widget.
458 ///
459 /// Readable | Writable
460 ///
461 ///
462 /// #### `opacity`
463 /// The requested opacity of the widget.
464 ///
465 /// Readable | Writable
466 ///
467 ///
468 /// #### `overflow`
469 /// How content outside the widget's content area is treated.
470 ///
471 /// This property is meant to be set by widget implementations,
472 /// typically in their instance init function.
473 ///
474 /// Readable | Writable
475 ///
476 ///
477 /// #### `parent`
478 /// The parent widget of this widget.
479 ///
480 /// Readable
481 ///
482 ///
483 /// #### `receives-default`
484 /// Whether the widget will receive the default action when it is focused.
485 ///
486 /// Readable | Writable
487 ///
488 ///
489 /// #### `root`
490 /// The [`Root`][crate::Root] widget of the widget tree containing this widget.
491 ///
492 /// This will be `NULL` if the widget is not contained in a root widget.
493 ///
494 /// Readable
495 ///
496 ///
497 /// #### `scale-factor`
498 /// The scale factor of the widget.
499 ///
500 /// Readable
501 ///
502 ///
503 /// #### `sensitive`
504 /// Whether the widget responds to input.
505 ///
506 /// Readable | Writable
507 ///
508 ///
509 /// #### `tooltip-markup`
510 /// Sets the text of tooltip to be the given string, which is marked up
511 /// with Pango markup.
512 ///
513 /// Also see [`Tooltip::set_markup()`][crate::Tooltip::set_markup()].
514 ///
515 /// This is a convenience property which will take care of getting the
516 /// tooltip shown if the given string is not `NULL`:
517 /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
518 /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
519 /// the default signal handler.
520 ///
521 /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
522 /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
523 ///
524 /// Readable | Writable
525 ///
526 ///
527 /// #### `tooltip-text`
528 /// Sets the text of tooltip to be the given string.
529 ///
530 /// Also see [`Tooltip::set_text()`][crate::Tooltip::set_text()].
531 ///
532 /// This is a convenience property which will take care of getting the
533 /// tooltip shown if the given string is not `NULL`:
534 /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
535 /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
536 /// the default signal handler.
537 ///
538 /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
539 /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
540 ///
541 /// Readable | Writable
542 ///
543 ///
544 /// #### `valign`
545 /// How to distribute vertical space if widget gets extra space.
546 ///
547 /// Readable | Writable
548 ///
549 ///
550 /// #### `vexpand`
551 /// Whether to expand vertically.
552 ///
553 /// Readable | Writable
554 ///
555 ///
556 /// #### `vexpand-set`
557 /// Whether to use the `vexpand` property.
558 ///
559 /// Readable | Writable
560 ///
561 ///
562 /// #### `visible`
563 /// Whether the widget is visible.
564 ///
565 /// Readable | Writable
566 ///
567 ///
568 /// #### `width-request`
569 /// Overrides for width request of the widget.
570 ///
571 /// If this is -1, the natural request will be used.
572 ///
573 /// Readable | Writable
574 /// </details>
575 /// <details><summary><h4>Accessible</h4></summary>
576 ///
577 ///
578 /// #### `accessible-role`
579 /// The accessible role of the given [`Accessible`][crate::Accessible] implementation.
580 ///
581 /// The accessible role cannot be changed once set.
582 ///
583 /// Readable | Writable
584 /// </details>
585 /// <details><summary><h4>Scrollable</h4></summary>
586 ///
587 ///
588 /// #### `hadjustment`
589 /// Horizontal [`Adjustment`][crate::Adjustment] of the scrollable widget.
590 ///
591 /// This adjustment is shared between the scrollable widget and its parent.
592 ///
593 /// Readable | Writable | Construct
594 ///
595 ///
596 /// #### `hscroll-policy`
597 /// Determines when horizontal scrolling should start.
598 ///
599 /// Readable | Writable
600 ///
601 ///
602 /// #### `vadjustment`
603 /// Vertical [`Adjustment`][crate::Adjustment] of the scrollable widget.
604 ///
605 /// This adjustment is shared between the scrollable widget and its parent.
606 ///
607 /// Readable | Writable | Construct
608 ///
609 ///
610 /// #### `vscroll-policy`
611 /// Determines when vertical scrolling should start.
612 ///
613 /// Readable | Writable
614 /// </details>
615 ///
616 /// ## Signals
617 ///
618 ///
619 /// #### `backspace`
620 /// Gets emitted when the user asks for it.
621 ///
622 /// The ::backspace signal is a [keybinding signal](class.SignalAction.html).
623 ///
624 /// The default bindings for this signal are
625 /// <kbd>Backspace</kbd> and <kbd>Shift</kbd>+<kbd>Backspace</kbd>.
626 ///
627 /// Action
628 ///
629 ///
630 /// #### `copy-clipboard`
631 /// Gets emitted to copy the selection to the clipboard.
632 ///
633 /// The ::copy-clipboard signal is a [keybinding signal](class.SignalAction.html).
634 ///
635 /// The default bindings for this signal are
636 /// <kbd>Ctrl</kbd>+<kbd>c</kbd> and
637 /// <kbd>Ctrl</kbd>+<kbd>Insert</kbd>.
638 ///
639 /// Action
640 ///
641 ///
642 /// #### `cut-clipboard`
643 /// Gets emitted to cut the selection to the clipboard.
644 ///
645 /// The ::cut-clipboard signal is a [keybinding signal](class.SignalAction.html).
646 ///
647 /// The default bindings for this signal are
648 /// <kbd>Ctrl</kbd>+<kbd>x</kbd> and
649 /// <kbd>Shift</kbd>+<kbd>Delete</kbd>.
650 ///
651 /// Action
652 ///
653 ///
654 /// #### `delete-from-cursor`
655 /// Gets emitted when the user initiates a text deletion.
656 ///
657 /// The ::delete-from-cursor signal is a [keybinding signal](class.SignalAction.html).
658 ///
659 /// If the @type_ is [`DeleteType::Chars`][crate::DeleteType::Chars], GTK deletes the selection
660 /// if there is one, otherwise it deletes the requested number
661 /// of characters.
662 ///
663 /// The default bindings for this signal are <kbd>Delete</kbd> for
664 /// deleting a character, <kbd>Ctrl</kbd>+<kbd>Delete</kbd> for
665 /// deleting a word and <kbd>Ctrl</kbd>+<kbd>Backspace</kbd> for
666 /// deleting a word backwards.
667 ///
668 /// Action
669 ///
670 ///
671 /// #### `extend-selection`
672 /// Emitted when the selection needs to be extended at @location.
673 ///
674 ///
675 ///
676 ///
677 /// #### `insert-at-cursor`
678 /// Gets emitted when the user initiates the insertion of a
679 /// fixed string at the cursor.
680 ///
681 /// The ::insert-at-cursor signal is a [keybinding signal](class.SignalAction.html).
682 ///
683 /// This signal has no default bindings.
684 ///
685 /// Action
686 ///
687 ///
688 /// #### `insert-emoji`
689 /// Gets emitted to present the Emoji chooser for the @text_view.
690 ///
691 /// The ::insert-emoji signal is a [keybinding signal](class.SignalAction.html).
692 ///
693 /// The default bindings for this signal are
694 /// <kbd>Ctrl</kbd>+<kbd>.</kbd> and
695 /// <kbd>Ctrl</kbd>+<kbd>;</kbd>
696 ///
697 /// Action
698 ///
699 ///
700 /// #### `move-cursor`
701 /// Gets emitted when the user initiates a cursor movement.
702 ///
703 /// The ::move-cursor signal is a [keybinding signal](class.SignalAction.html).
704 /// If the cursor is not visible in @text_view, this signal causes
705 /// the viewport to be moved instead.
706 ///
707 /// Applications should not connect to it, but may emit it with
708 /// g_signal_emit_by_name() if they need to control the cursor
709 /// programmatically.
710 ///
711 ///
712 /// The default bindings for this signal come in two variants,
713 /// the variant with the <kbd>Shift</kbd> modifier extends the
714 /// selection, the variant without it does not.
715 /// There are too many key combinations to list them all here.
716 ///
717 /// - <kbd>←</kbd>, <kbd>→</kbd>, <kbd>↑</kbd>, <kbd>↓</kbd>
718 /// move by individual characters/lines
719 /// - <kbd>Ctrl</kbd>+<kbd>←</kbd>, etc. move by words/paragraphs
720 /// - <kbd>Home</kbd> and <kbd>End</kbd> move to the ends of the buffer
721 /// - <kbd>PgUp</kbd> and <kbd>PgDn</kbd> move vertically by pages
722 /// - <kbd>Ctrl</kbd>+<kbd>PgUp</kbd> and <kbd>Ctrl</kbd>+<kbd>PgDn</kbd>
723 /// move horizontally by pages
724 ///
725 /// Action
726 ///
727 ///
728 /// #### `move-viewport`
729 /// Gets emitted to move the viewport.
730 ///
731 /// The ::move-viewport signal is a [keybinding signal](class.SignalAction.html),
732 /// which can be bound to key combinations to allow the user to move the viewport,
733 /// i.e. change what part of the text view is visible in a containing scrolled
734 /// window.
735 ///
736 /// There are no default bindings for this signal.
737 ///
738 /// Action
739 ///
740 ///
741 /// #### `paste-clipboard`
742 /// Gets emitted to paste the contents of the clipboard
743 /// into the text view.
744 ///
745 /// The ::paste-clipboard signal is a [keybinding signal](class.SignalAction.html).
746 ///
747 /// The default bindings for this signal are
748 /// <kbd>Ctrl</kbd>+<kbd>v</kbd> and
749 /// <kbd>Shift</kbd>+<kbd>Insert</kbd>.
750 ///
751 /// Action
752 ///
753 ///
754 /// #### `preedit-changed`
755 /// Emitted when preedit text of the active IM changes.
756 ///
757 /// If an input method is used, the typed text will not immediately
758 /// be committed to the buffer. So if you are interested in the text,
759 /// connect to this signal.
760 ///
761 /// This signal is only emitted if the text at the given position
762 /// is actually editable.
763 ///
764 /// Action
765 ///
766 ///
767 /// #### `select-all`
768 /// Gets emitted to select or unselect the complete contents of the text view.
769 ///
770 /// The ::select-all signal is a [keybinding signal](class.SignalAction.html).
771 ///
772 /// The default bindings for this signal are
773 /// <kbd>Ctrl</kbd>+<kbd>a</kbd> and
774 /// <kbd>Ctrl</kbd>+<kbd>/</kbd> for selecting and
775 /// <kbd>Shift</kbd>+<kbd>Ctrl</kbd>+<kbd>a</kbd> and
776 /// <kbd>Ctrl</kbd>+<kbd>\</kbd> for unselecting.
777 ///
778 /// Action
779 ///
780 ///
781 /// #### `set-anchor`
782 /// Gets emitted when the user initiates settings the "anchor" mark.
783 ///
784 /// The ::set-anchor signal is a [keybinding signal](class.SignalAction.html)
785 /// which gets emitted when the user initiates setting the "anchor"
786 /// mark. The "anchor" mark gets placed at the same position as the
787 /// "insert" mark.
788 ///
789 /// This signal has no default bindings.
790 ///
791 /// Action
792 ///
793 ///
794 /// #### `toggle-cursor-visible`
795 /// Gets emitted to toggle the `cursor-visible` property.
796 ///
797 /// The ::toggle-cursor-visible signal is a
798 /// [keybinding signal](class.SignalAction.html).
799 ///
800 /// The default binding for this signal is <kbd>F7</kbd>.
801 ///
802 /// Action
803 ///
804 ///
805 /// #### `toggle-overwrite`
806 /// Gets emitted to toggle the overwrite mode of the text view.
807 ///
808 /// The ::toggle-overwrite signal is a [keybinding signal](class.SignalAction.html).
809 ///
810 /// The default binding for this signal is <kbd>Insert</kbd>.
811 ///
812 /// Action
813 /// <details><summary><h4>Widget</h4></summary>
814 ///
815 ///
816 /// #### `destroy`
817 /// Signals that all holders of a reference to the widget should release
818 /// the reference that they hold.
819 ///
820 /// May result in finalization of the widget if all references are released.
821 ///
822 /// This signal is not suitable for saving widget state.
823 ///
824 ///
825 ///
826 ///
827 /// #### `direction-changed`
828 /// Emitted when the text direction of a widget changes.
829 ///
830 ///
831 ///
832 ///
833 /// #### `hide`
834 /// Emitted when @widget is hidden.
835 ///
836 ///
837 ///
838 ///
839 /// #### `keynav-failed`
840 /// Emitted if keyboard navigation fails.
841 ///
842 /// See [`WidgetExt::keynav_failed()`][crate::prelude::WidgetExt::keynav_failed()] for details.
843 ///
844 ///
845 ///
846 ///
847 /// #### `map`
848 /// Emitted when @widget is going to be mapped.
849 ///
850 /// A widget is mapped when the widget is visible (which is controlled with
851 /// [`visible`][struct@crate::Widget#visible]) and all its parents up to the toplevel widget
852 /// are also visible.
853 ///
854 /// The `::map` signal can be used to determine whether a widget will be drawn,
855 /// for instance it can resume an animation that was stopped during the
856 /// emission of [`unmap`][struct@crate::Widget#unmap].
857 ///
858 ///
859 ///
860 ///
861 /// #### `mnemonic-activate`
862 /// Emitted when a widget is activated via a mnemonic.
863 ///
864 /// The default handler for this signal activates @widget if @group_cycling
865 /// is false, or just makes @widget grab focus if @group_cycling is true.
866 ///
867 ///
868 ///
869 ///
870 /// #### `move-focus`
871 /// Emitted when the focus is moved.
872 ///
873 /// The `::move-focus` signal is a [keybinding signal](class.SignalAction.html).
874 ///
875 /// The default bindings for this signal are <kbd>Tab</kbd> to move forward,
876 /// and <kbd>Shift</kbd>+<kbd>Tab</kbd> to move backward.
877 ///
878 /// Action
879 ///
880 ///
881 /// #### `query-tooltip`
882 /// Emitted when the widget’s tooltip is about to be shown.
883 ///
884 /// This happens when the [`has-tooltip`][struct@crate::Widget#has-tooltip] property
885 /// is true and the hover timeout has expired with the cursor hovering
886 /// above @widget; or emitted when @widget got focus in keyboard mode.
887 ///
888 /// Using the given coordinates, the signal handler should determine
889 /// whether a tooltip should be shown for @widget. If this is the case
890 /// true should be returned, false otherwise. Note that if @keyboard_mode
891 /// is true, the values of @x and @y are undefined and should not be used.
892 ///
893 /// The signal handler is free to manipulate @tooltip with the therefore
894 /// destined function calls.
895 ///
896 ///
897 ///
898 ///
899 /// #### `realize`
900 /// Emitted when @widget is associated with a [`gdk::Surface`][crate::gdk::Surface].
901 ///
902 /// This means that [`WidgetExt::realize()`][crate::prelude::WidgetExt::realize()] has been called
903 /// or the widget has been mapped (that is, it is going to be drawn).
904 ///
905 ///
906 ///
907 ///
908 /// #### `show`
909 /// Emitted when @widget is shown.
910 ///
911 ///
912 ///
913 ///
914 /// #### `state-flags-changed`
915 /// Emitted when the widget state changes.
916 ///
917 /// See [`WidgetExt::state_flags()`][crate::prelude::WidgetExt::state_flags()].
918 ///
919 ///
920 ///
921 ///
922 /// #### `unmap`
923 /// Emitted when @widget is going to be unmapped.
924 ///
925 /// A widget is unmapped when either it or any of its parents up to the
926 /// toplevel widget have been set as hidden.
927 ///
928 /// As `::unmap` indicates that a widget will not be shown any longer,
929 /// it can be used to, for example, stop an animation on the widget.
930 ///
931 ///
932 ///
933 ///
934 /// #### `unrealize`
935 /// Emitted when the [`gdk::Surface`][crate::gdk::Surface] associated with @widget is destroyed.
936 ///
937 /// This means that [`WidgetExt::unrealize()`][crate::prelude::WidgetExt::unrealize()] has been called
938 /// or the widget has been unmapped (that is, it is going to be hidden).
939 ///
940 ///
941 /// </details>
942 ///
943 /// # Implements
944 ///
945 /// [`TextViewExt`][trait@crate::prelude::TextViewExt], [`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], [`ScrollableExt`][trait@crate::prelude::ScrollableExt], [`WidgetExtManual`][trait@crate::prelude::WidgetExtManual], [`AccessibleExtManual`][trait@crate::prelude::AccessibleExtManual]
946 #[doc(alias = "GtkTextView")]
947 pub struct TextView(Object<ffi::GtkTextView, ffi::GtkTextViewClass>) @extends Widget, @implements Accessible, Buildable, ConstraintTarget, AccessibleText, Scrollable;
948
949 match fn {
950 type_ => || ffi::gtk_text_view_get_type(),
951 }
952}
953
954#[cfg(all(feature = "v4_10", not(feature = "v4_14")))]
955glib::wrapper! {
956 #[doc(alias = "GtkTextView")]
957 pub struct TextView(Object<ffi::GtkTextView, ffi::GtkTextViewClass>) @extends Widget, @implements Accessible, Buildable, ConstraintTarget, Scrollable;
958
959 match fn {
960 type_ => || ffi::gtk_text_view_get_type(),
961 }
962}
963
964#[cfg(not(any(feature = "v4_10", feature = "v4_14")))]
965glib::wrapper! {
966 #[doc(alias = "GtkTextView")]
967 pub struct TextView(Object<ffi::GtkTextView, ffi::GtkTextViewClass>) @extends Widget, @implements Buildable, ConstraintTarget, Scrollable;
968
969 match fn {
970 type_ => || ffi::gtk_text_view_get_type(),
971 }
972}
973
974impl TextView {
975 pub const NONE: Option<&'static TextView> = None;
976
977 /// Creates a new [`TextView`][crate::TextView].
978 ///
979 /// If you don’t call [`TextViewExt::set_buffer()`][crate::prelude::TextViewExt::set_buffer()] before using the
980 /// text view, an empty default buffer will be created for you. Get the
981 /// buffer with [`TextViewExt::buffer()`][crate::prelude::TextViewExt::buffer()]. If you want to specify
982 /// your own buffer, consider [`with_buffer()`][Self::with_buffer()].
983 ///
984 /// # Returns
985 ///
986 /// a new [`TextView`][crate::TextView]
987 #[doc(alias = "gtk_text_view_new")]
988 pub fn new() -> TextView {
989 assert_initialized_main_thread!();
990 unsafe { Widget::from_glib_none(ffi::gtk_text_view_new()).unsafe_cast() }
991 }
992
993 /// Creates a new [`TextView`][crate::TextView] widget displaying the buffer @buffer.
994 ///
995 /// One buffer can be shared among many widgets. @buffer may be [`None`]
996 /// to create a default buffer, in which case this function is equivalent
997 /// to [`new()`][Self::new()]. The text view adds its own reference count
998 /// to the buffer; it does not take over an existing reference.
999 /// ## `buffer`
1000 /// a [`TextBuffer`][crate::TextBuffer]
1001 ///
1002 /// # Returns
1003 ///
1004 /// a new [`TextView`][crate::TextView].
1005 #[doc(alias = "gtk_text_view_new_with_buffer")]
1006 #[doc(alias = "new_with_buffer")]
1007 pub fn with_buffer(buffer: &impl IsA<TextBuffer>) -> TextView {
1008 skip_assert_initialized!();
1009 unsafe {
1010 Widget::from_glib_none(ffi::gtk_text_view_new_with_buffer(
1011 buffer.as_ref().to_glib_none().0,
1012 ))
1013 .unsafe_cast()
1014 }
1015 }
1016
1017 // rustdoc-stripper-ignore-next
1018 /// Creates a new builder-pattern struct instance to construct [`TextView`] objects.
1019 ///
1020 /// This method returns an instance of [`TextViewBuilder`](crate::builders::TextViewBuilder) which can be used to create [`TextView`] objects.
1021 pub fn builder() -> TextViewBuilder {
1022 TextViewBuilder::new()
1023 }
1024}
1025
1026impl Default for TextView {
1027 fn default() -> Self {
1028 Self::new()
1029 }
1030}
1031
1032// rustdoc-stripper-ignore-next
1033/// A [builder-pattern] type to construct [`TextView`] objects.
1034///
1035/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
1036#[must_use = "The builder must be built to be used"]
1037pub struct TextViewBuilder {
1038 builder: glib::object::ObjectBuilder<'static, TextView>,
1039}
1040
1041impl TextViewBuilder {
1042 fn new() -> Self {
1043 Self {
1044 builder: glib::object::Object::builder(),
1045 }
1046 }
1047
1048 /// Whether Tab will result in a tab character being entered.
1049 pub fn accepts_tab(self, accepts_tab: bool) -> Self {
1050 Self {
1051 builder: self.builder.property("accepts-tab", accepts_tab),
1052 }
1053 }
1054
1055 /// The bottom margin for text in the text view.
1056 ///
1057 /// Note that this property is confusingly named. In CSS terms,
1058 /// the value set here is padding, and it is applied in addition
1059 /// to the padding from the theme.
1060 ///
1061 /// Don't confuse this property with [`margin-bottom`][struct@crate::Widget#margin-bottom].
1062 pub fn bottom_margin(self, bottom_margin: i32) -> Self {
1063 Self {
1064 builder: self.builder.property("bottom-margin", bottom_margin),
1065 }
1066 }
1067
1068 /// The buffer which is displayed.
1069 pub fn buffer(self, buffer: &impl IsA<TextBuffer>) -> Self {
1070 Self {
1071 builder: self.builder.property("buffer", buffer.clone().upcast()),
1072 }
1073 }
1074
1075 /// If the insertion cursor is shown.
1076 pub fn cursor_visible(self, cursor_visible: bool) -> Self {
1077 Self {
1078 builder: self.builder.property("cursor-visible", cursor_visible),
1079 }
1080 }
1081
1082 /// Whether the text can be modified by the user.
1083 pub fn editable(self, editable: bool) -> Self {
1084 Self {
1085 builder: self.builder.property("editable", editable),
1086 }
1087 }
1088
1089 /// A menu model whose contents will be appended to the context menu.
1090 pub fn extra_menu(self, extra_menu: &impl IsA<gio::MenuModel>) -> Self {
1091 Self {
1092 builder: self
1093 .builder
1094 .property("extra-menu", extra_menu.clone().upcast()),
1095 }
1096 }
1097
1098 /// Which IM (input method) module should be used for this text_view.
1099 ///
1100 /// See [`IMMulticontext`][crate::IMMulticontext].
1101 ///
1102 /// Setting this to a non-[`None`] value overrides the system-wide IM module
1103 /// setting. See the GtkSettings [`gtk-im-module`][struct@crate::Settings#gtk-im-module] property.
1104 pub fn im_module(self, im_module: impl Into<glib::GString>) -> Self {
1105 Self {
1106 builder: self.builder.property("im-module", im_module.into()),
1107 }
1108 }
1109
1110 /// Amount to indent the paragraph, in pixels.
1111 ///
1112 /// A negative value of indent will produce a hanging indentation.
1113 /// That is, the first line will have the full width, and subsequent
1114 /// lines will be indented by the absolute value of indent.
1115 pub fn indent(self, indent: i32) -> Self {
1116 Self {
1117 builder: self.builder.property("indent", indent),
1118 }
1119 }
1120
1121 /// Additional hints (beyond [`input-purpose`][struct@crate::TextView#input-purpose])
1122 /// that allow input methods to fine-tune their behaviour.
1123 pub fn input_hints(self, input_hints: InputHints) -> Self {
1124 Self {
1125 builder: self.builder.property("input-hints", input_hints),
1126 }
1127 }
1128
1129 /// The purpose of this text field.
1130 ///
1131 /// This property can be used by on-screen keyboards and other input
1132 /// methods to adjust their behaviour.
1133 pub fn input_purpose(self, input_purpose: InputPurpose) -> Self {
1134 Self {
1135 builder: self.builder.property("input-purpose", input_purpose),
1136 }
1137 }
1138
1139 /// Left, right, or center justification.
1140 pub fn justification(self, justification: Justification) -> Self {
1141 Self {
1142 builder: self.builder.property("justification", justification),
1143 }
1144 }
1145
1146 /// The default left margin for text in the text view.
1147 ///
1148 /// Tags in the buffer may override the default.
1149 ///
1150 /// Note that this property is confusingly named. In CSS terms,
1151 /// the value set here is padding, and it is applied in addition
1152 /// to the padding from the theme.
1153 pub fn left_margin(self, left_margin: i32) -> Self {
1154 Self {
1155 builder: self.builder.property("left-margin", left_margin),
1156 }
1157 }
1158
1159 /// Whether text should be displayed in a monospace font.
1160 ///
1161 /// If [`true`], set the .monospace style class on the
1162 /// text view to indicate that a monospace font is desired.
1163 pub fn monospace(self, monospace: bool) -> Self {
1164 Self {
1165 builder: self.builder.property("monospace", monospace),
1166 }
1167 }
1168
1169 /// Whether entered text overwrites existing contents.
1170 pub fn overwrite(self, overwrite: bool) -> Self {
1171 Self {
1172 builder: self.builder.property("overwrite", overwrite),
1173 }
1174 }
1175
1176 /// Pixels of blank space above paragraphs.
1177 pub fn pixels_above_lines(self, pixels_above_lines: i32) -> Self {
1178 Self {
1179 builder: self
1180 .builder
1181 .property("pixels-above-lines", pixels_above_lines),
1182 }
1183 }
1184
1185 /// Pixels of blank space below paragraphs.
1186 pub fn pixels_below_lines(self, pixels_below_lines: i32) -> Self {
1187 Self {
1188 builder: self
1189 .builder
1190 .property("pixels-below-lines", pixels_below_lines),
1191 }
1192 }
1193
1194 /// Pixels of blank space between wrapped lines in a paragraph.
1195 pub fn pixels_inside_wrap(self, pixels_inside_wrap: i32) -> Self {
1196 Self {
1197 builder: self
1198 .builder
1199 .property("pixels-inside-wrap", pixels_inside_wrap),
1200 }
1201 }
1202
1203 /// The default right margin for text in the text view.
1204 ///
1205 /// Tags in the buffer may override the default.
1206 ///
1207 /// Note that this property is confusingly named. In CSS terms,
1208 /// the value set here is padding, and it is applied in addition
1209 /// to the padding from the theme.
1210 pub fn right_margin(self, right_margin: i32) -> Self {
1211 Self {
1212 builder: self.builder.property("right-margin", right_margin),
1213 }
1214 }
1215
1216 /// Custom tabs for this text.
1217 pub fn tabs(self, tabs: &pango::TabArray) -> Self {
1218 Self {
1219 builder: self.builder.property("tabs", tabs),
1220 }
1221 }
1222
1223 /// The top margin for text in the text view.
1224 ///
1225 /// Note that this property is confusingly named. In CSS terms,
1226 /// the value set here is padding, and it is applied in addition
1227 /// to the padding from the theme.
1228 ///
1229 /// Don't confuse this property with [`margin-top`][struct@crate::Widget#margin-top].
1230 pub fn top_margin(self, top_margin: i32) -> Self {
1231 Self {
1232 builder: self.builder.property("top-margin", top_margin),
1233 }
1234 }
1235
1236 /// Whether to wrap lines never, at word boundaries, or at character boundaries.
1237 pub fn wrap_mode(self, wrap_mode: WrapMode) -> Self {
1238 Self {
1239 builder: self.builder.property("wrap-mode", wrap_mode),
1240 }
1241 }
1242
1243 /// Whether the widget or any of its descendents can accept
1244 /// the input focus.
1245 ///
1246 /// This property is meant to be set by widget implementations,
1247 /// typically in their instance init function.
1248 pub fn can_focus(self, can_focus: bool) -> Self {
1249 Self {
1250 builder: self.builder.property("can-focus", can_focus),
1251 }
1252 }
1253
1254 /// Whether the widget can receive pointer events.
1255 pub fn can_target(self, can_target: bool) -> Self {
1256 Self {
1257 builder: self.builder.property("can-target", can_target),
1258 }
1259 }
1260
1261 /// A list of css classes applied to this widget.
1262 pub fn css_classes(self, css_classes: impl Into<glib::StrV>) -> Self {
1263 Self {
1264 builder: self.builder.property("css-classes", css_classes.into()),
1265 }
1266 }
1267
1268 /// The name of this widget in the CSS tree.
1269 ///
1270 /// This property is meant to be set by widget implementations,
1271 /// typically in their instance init function.
1272 pub fn css_name(self, css_name: impl Into<glib::GString>) -> Self {
1273 Self {
1274 builder: self.builder.property("css-name", css_name.into()),
1275 }
1276 }
1277
1278 /// The cursor used by @widget.
1279 pub fn cursor(self, cursor: &gdk::Cursor) -> Self {
1280 Self {
1281 builder: self.builder.property("cursor", cursor.clone()),
1282 }
1283 }
1284
1285 /// Whether the widget should grab focus when it is clicked with the mouse.
1286 ///
1287 /// This property is only relevant for widgets that can take focus.
1288 pub fn focus_on_click(self, focus_on_click: bool) -> Self {
1289 Self {
1290 builder: self.builder.property("focus-on-click", focus_on_click),
1291 }
1292 }
1293
1294 /// Whether this widget itself will accept the input focus.
1295 pub fn focusable(self, focusable: bool) -> Self {
1296 Self {
1297 builder: self.builder.property("focusable", focusable),
1298 }
1299 }
1300
1301 /// How to distribute horizontal space if widget gets extra space.
1302 pub fn halign(self, halign: Align) -> Self {
1303 Self {
1304 builder: self.builder.property("halign", halign),
1305 }
1306 }
1307
1308 /// Enables or disables the emission of the [`query-tooltip`][struct@crate::Widget#query-tooltip]
1309 /// signal on @widget.
1310 ///
1311 /// A true value indicates that @widget can have a tooltip, in this case
1312 /// the widget will be queried using [`query-tooltip`][struct@crate::Widget#query-tooltip] to
1313 /// determine whether it will provide a tooltip or not.
1314 pub fn has_tooltip(self, has_tooltip: bool) -> Self {
1315 Self {
1316 builder: self.builder.property("has-tooltip", has_tooltip),
1317 }
1318 }
1319
1320 /// Overrides for height request of the widget.
1321 ///
1322 /// If this is -1, the natural request will be used.
1323 pub fn height_request(self, height_request: i32) -> Self {
1324 Self {
1325 builder: self.builder.property("height-request", height_request),
1326 }
1327 }
1328
1329 /// Whether to expand horizontally.
1330 pub fn hexpand(self, hexpand: bool) -> Self {
1331 Self {
1332 builder: self.builder.property("hexpand", hexpand),
1333 }
1334 }
1335
1336 /// Whether to use the `hexpand` property.
1337 pub fn hexpand_set(self, hexpand_set: bool) -> Self {
1338 Self {
1339 builder: self.builder.property("hexpand-set", hexpand_set),
1340 }
1341 }
1342
1343 /// The [`LayoutManager`][crate::LayoutManager] instance to use to compute
1344 /// the preferred size of the widget, and allocate its children.
1345 ///
1346 /// This property is meant to be set by widget implementations,
1347 /// typically in their instance init function.
1348 pub fn layout_manager(self, layout_manager: &impl IsA<LayoutManager>) -> Self {
1349 Self {
1350 builder: self
1351 .builder
1352 .property("layout-manager", layout_manager.clone().upcast()),
1353 }
1354 }
1355
1356 /// Makes this widget act like a modal dialog, with respect to
1357 /// event delivery.
1358 ///
1359 /// Global event controllers will not handle events with targets
1360 /// inside the widget, unless they are set up to ignore propagation
1361 /// limits. See [`EventControllerExt::set_propagation_limit()`][crate::prelude::EventControllerExt::set_propagation_limit()].
1362 #[cfg(feature = "v4_18")]
1363 #[cfg_attr(docsrs, doc(cfg(feature = "v4_18")))]
1364 pub fn limit_events(self, limit_events: bool) -> Self {
1365 Self {
1366 builder: self.builder.property("limit-events", limit_events),
1367 }
1368 }
1369
1370 /// Margin on bottom side of widget.
1371 ///
1372 /// This property adds margin outside of the widget's normal size
1373 /// request, the margin will be added in addition to the size from
1374 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
1375 pub fn margin_bottom(self, margin_bottom: i32) -> Self {
1376 Self {
1377 builder: self.builder.property("margin-bottom", margin_bottom),
1378 }
1379 }
1380
1381 /// Margin on end of widget, horizontally.
1382 ///
1383 /// This property supports left-to-right and right-to-left text
1384 /// directions.
1385 ///
1386 /// This property adds margin outside of the widget's normal size
1387 /// request, the margin will be added in addition to the size from
1388 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
1389 pub fn margin_end(self, margin_end: i32) -> Self {
1390 Self {
1391 builder: self.builder.property("margin-end", margin_end),
1392 }
1393 }
1394
1395 /// Margin on start of widget, horizontally.
1396 ///
1397 /// This property supports left-to-right and right-to-left text
1398 /// directions.
1399 ///
1400 /// This property adds margin outside of the widget's normal size
1401 /// request, the margin will be added in addition to the size from
1402 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
1403 pub fn margin_start(self, margin_start: i32) -> Self {
1404 Self {
1405 builder: self.builder.property("margin-start", margin_start),
1406 }
1407 }
1408
1409 /// Margin on top side of widget.
1410 ///
1411 /// This property adds margin outside of the widget's normal size
1412 /// request, the margin will be added in addition to the size from
1413 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
1414 pub fn margin_top(self, margin_top: i32) -> Self {
1415 Self {
1416 builder: self.builder.property("margin-top", margin_top),
1417 }
1418 }
1419
1420 /// The name of the widget.
1421 pub fn name(self, name: impl Into<glib::GString>) -> Self {
1422 Self {
1423 builder: self.builder.property("name", name.into()),
1424 }
1425 }
1426
1427 /// The requested opacity of the widget.
1428 pub fn opacity(self, opacity: f64) -> Self {
1429 Self {
1430 builder: self.builder.property("opacity", opacity),
1431 }
1432 }
1433
1434 /// How content outside the widget's content area is treated.
1435 ///
1436 /// This property is meant to be set by widget implementations,
1437 /// typically in their instance init function.
1438 pub fn overflow(self, overflow: Overflow) -> Self {
1439 Self {
1440 builder: self.builder.property("overflow", overflow),
1441 }
1442 }
1443
1444 /// Whether the widget will receive the default action when it is focused.
1445 pub fn receives_default(self, receives_default: bool) -> Self {
1446 Self {
1447 builder: self.builder.property("receives-default", receives_default),
1448 }
1449 }
1450
1451 /// Whether the widget responds to input.
1452 pub fn sensitive(self, sensitive: bool) -> Self {
1453 Self {
1454 builder: self.builder.property("sensitive", sensitive),
1455 }
1456 }
1457
1458 /// Sets the text of tooltip to be the given string, which is marked up
1459 /// with Pango markup.
1460 ///
1461 /// Also see [`Tooltip::set_markup()`][crate::Tooltip::set_markup()].
1462 ///
1463 /// This is a convenience property which will take care of getting the
1464 /// tooltip shown if the given string is not `NULL`:
1465 /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
1466 /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
1467 /// the default signal handler.
1468 ///
1469 /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
1470 /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
1471 pub fn tooltip_markup(self, tooltip_markup: impl Into<glib::GString>) -> Self {
1472 Self {
1473 builder: self
1474 .builder
1475 .property("tooltip-markup", tooltip_markup.into()),
1476 }
1477 }
1478
1479 /// Sets the text of tooltip to be the given string.
1480 ///
1481 /// Also see [`Tooltip::set_text()`][crate::Tooltip::set_text()].
1482 ///
1483 /// This is a convenience property which will take care of getting the
1484 /// tooltip shown if the given string is not `NULL`:
1485 /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
1486 /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
1487 /// the default signal handler.
1488 ///
1489 /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
1490 /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
1491 pub fn tooltip_text(self, tooltip_text: impl Into<glib::GString>) -> Self {
1492 Self {
1493 builder: self.builder.property("tooltip-text", tooltip_text.into()),
1494 }
1495 }
1496
1497 /// How to distribute vertical space if widget gets extra space.
1498 pub fn valign(self, valign: Align) -> Self {
1499 Self {
1500 builder: self.builder.property("valign", valign),
1501 }
1502 }
1503
1504 /// Whether to expand vertically.
1505 pub fn vexpand(self, vexpand: bool) -> Self {
1506 Self {
1507 builder: self.builder.property("vexpand", vexpand),
1508 }
1509 }
1510
1511 /// Whether to use the `vexpand` property.
1512 pub fn vexpand_set(self, vexpand_set: bool) -> Self {
1513 Self {
1514 builder: self.builder.property("vexpand-set", vexpand_set),
1515 }
1516 }
1517
1518 /// Whether the widget is visible.
1519 pub fn visible(self, visible: bool) -> Self {
1520 Self {
1521 builder: self.builder.property("visible", visible),
1522 }
1523 }
1524
1525 /// Overrides for width request of the widget.
1526 ///
1527 /// If this is -1, the natural request will be used.
1528 pub fn width_request(self, width_request: i32) -> Self {
1529 Self {
1530 builder: self.builder.property("width-request", width_request),
1531 }
1532 }
1533
1534 /// The accessible role of the given [`Accessible`][crate::Accessible] implementation.
1535 ///
1536 /// The accessible role cannot be changed once set.
1537 pub fn accessible_role(self, accessible_role: AccessibleRole) -> Self {
1538 Self {
1539 builder: self.builder.property("accessible-role", accessible_role),
1540 }
1541 }
1542
1543 /// Horizontal [`Adjustment`][crate::Adjustment] of the scrollable widget.
1544 ///
1545 /// This adjustment is shared between the scrollable widget and its parent.
1546 pub fn hadjustment(self, hadjustment: &impl IsA<Adjustment>) -> Self {
1547 Self {
1548 builder: self
1549 .builder
1550 .property("hadjustment", hadjustment.clone().upcast()),
1551 }
1552 }
1553
1554 /// Determines when horizontal scrolling should start.
1555 pub fn hscroll_policy(self, hscroll_policy: ScrollablePolicy) -> Self {
1556 Self {
1557 builder: self.builder.property("hscroll-policy", hscroll_policy),
1558 }
1559 }
1560
1561 /// Vertical [`Adjustment`][crate::Adjustment] of the scrollable widget.
1562 ///
1563 /// This adjustment is shared between the scrollable widget and its parent.
1564 pub fn vadjustment(self, vadjustment: &impl IsA<Adjustment>) -> Self {
1565 Self {
1566 builder: self
1567 .builder
1568 .property("vadjustment", vadjustment.clone().upcast()),
1569 }
1570 }
1571
1572 /// Determines when vertical scrolling should start.
1573 pub fn vscroll_policy(self, vscroll_policy: ScrollablePolicy) -> Self {
1574 Self {
1575 builder: self.builder.property("vscroll-policy", vscroll_policy),
1576 }
1577 }
1578
1579 // rustdoc-stripper-ignore-next
1580 /// Build the [`TextView`].
1581 #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
1582 pub fn build(self) -> TextView {
1583 assert_initialized_main_thread!();
1584 self.builder.build()
1585 }
1586}
1587
1588/// Trait containing all [`struct@TextView`] methods.
1589///
1590/// # Implementors
1591///
1592/// [`TextView`][struct@crate::TextView]
1593pub trait TextViewExt: IsA<TextView> + 'static {
1594 /// Adds a child widget in the text buffer, at the given @anchor.
1595 /// ## `child`
1596 /// a [`Widget`][crate::Widget]
1597 /// ## `anchor`
1598 /// a [`TextChildAnchor`][crate::TextChildAnchor] in the [`TextBuffer`][crate::TextBuffer] for @self
1599 #[doc(alias = "gtk_text_view_add_child_at_anchor")]
1600 fn add_child_at_anchor(&self, child: &impl IsA<Widget>, anchor: &impl IsA<TextChildAnchor>) {
1601 unsafe {
1602 ffi::gtk_text_view_add_child_at_anchor(
1603 self.as_ref().to_glib_none().0,
1604 child.as_ref().to_glib_none().0,
1605 anchor.as_ref().to_glib_none().0,
1606 );
1607 }
1608 }
1609
1610 /// Adds @child at a fixed coordinate in the [`TextView`][crate::TextView]'s text window.
1611 ///
1612 /// The @xpos and @ypos must be in buffer coordinates (see
1613 /// [`iter_location()`][Self::iter_location()] to convert to
1614 /// buffer coordinates).
1615 ///
1616 /// @child will scroll with the text view.
1617 ///
1618 /// If instead you want a widget that will not move with the
1619 /// [`TextView`][crate::TextView] contents see [`Overlay`][crate::Overlay].
1620 /// ## `child`
1621 /// a [`Widget`][crate::Widget]
1622 /// ## `xpos`
1623 /// X position of child in window coordinates
1624 /// ## `ypos`
1625 /// Y position of child in window coordinates
1626 #[doc(alias = "gtk_text_view_add_overlay")]
1627 fn add_overlay(&self, child: &impl IsA<Widget>, xpos: i32, ypos: i32) {
1628 unsafe {
1629 ffi::gtk_text_view_add_overlay(
1630 self.as_ref().to_glib_none().0,
1631 child.as_ref().to_glib_none().0,
1632 xpos,
1633 ypos,
1634 );
1635 }
1636 }
1637
1638 /// Moves the given @iter backward by one display (wrapped) line.
1639 ///
1640 /// A display line is different from a paragraph. Paragraphs are
1641 /// separated by newlines or other paragraph separator characters.
1642 /// Display lines are created by line-wrapping a paragraph. If
1643 /// wrapping is turned off, display lines and paragraphs will be the
1644 /// same. Display lines are divided differently for each view, since
1645 /// they depend on the view’s width; paragraphs are the same in all
1646 /// views, since they depend on the contents of the [`TextBuffer`][crate::TextBuffer].
1647 /// ## `iter`
1648 /// a [`TextIter`][crate::TextIter]
1649 ///
1650 /// # Returns
1651 ///
1652 /// [`true`] if @iter was moved and is not on the end iterator
1653 #[doc(alias = "gtk_text_view_backward_display_line")]
1654 fn backward_display_line(&self, iter: &mut TextIter) -> bool {
1655 unsafe {
1656 from_glib(ffi::gtk_text_view_backward_display_line(
1657 self.as_ref().to_glib_none().0,
1658 iter.to_glib_none_mut().0,
1659 ))
1660 }
1661 }
1662
1663 /// Moves the given @iter backward to the next display line start.
1664 ///
1665 /// A display line is different from a paragraph. Paragraphs are
1666 /// separated by newlines or other paragraph separator characters.
1667 /// Display lines are created by line-wrapping a paragraph. If
1668 /// wrapping is turned off, display lines and paragraphs will be the
1669 /// same. Display lines are divided differently for each view, since
1670 /// they depend on the view’s width; paragraphs are the same in all
1671 /// views, since they depend on the contents of the [`TextBuffer`][crate::TextBuffer].
1672 /// ## `iter`
1673 /// a [`TextIter`][crate::TextIter]
1674 ///
1675 /// # Returns
1676 ///
1677 /// [`true`] if @iter was moved and is not on the end iterator
1678 #[doc(alias = "gtk_text_view_backward_display_line_start")]
1679 fn backward_display_line_start(&self, iter: &mut TextIter) -> bool {
1680 unsafe {
1681 from_glib(ffi::gtk_text_view_backward_display_line_start(
1682 self.as_ref().to_glib_none().0,
1683 iter.to_glib_none_mut().0,
1684 ))
1685 }
1686 }
1687
1688 /// Converts buffer coordinates to window coordinates.
1689 /// ## `win`
1690 /// a [`TextWindowType`][crate::TextWindowType]
1691 /// ## `buffer_x`
1692 /// buffer x coordinate
1693 /// ## `buffer_y`
1694 /// buffer y coordinate
1695 ///
1696 /// # Returns
1697 ///
1698 ///
1699 /// ## `window_x`
1700 /// window x coordinate return location
1701 ///
1702 /// ## `window_y`
1703 /// window y coordinate return location
1704 #[doc(alias = "gtk_text_view_buffer_to_window_coords")]
1705 fn buffer_to_window_coords(
1706 &self,
1707 win: TextWindowType,
1708 buffer_x: i32,
1709 buffer_y: i32,
1710 ) -> (i32, i32) {
1711 unsafe {
1712 let mut window_x = std::mem::MaybeUninit::uninit();
1713 let mut window_y = std::mem::MaybeUninit::uninit();
1714 ffi::gtk_text_view_buffer_to_window_coords(
1715 self.as_ref().to_glib_none().0,
1716 win.into_glib(),
1717 buffer_x,
1718 buffer_y,
1719 window_x.as_mut_ptr(),
1720 window_y.as_mut_ptr(),
1721 );
1722 (window_x.assume_init(), window_y.assume_init())
1723 }
1724 }
1725
1726 /// Moves the given @iter forward by one display (wrapped) line.
1727 ///
1728 /// A display line is different from a paragraph. Paragraphs are
1729 /// separated by newlines or other paragraph separator characters.
1730 /// Display lines are created by line-wrapping a paragraph. If
1731 /// wrapping is turned off, display lines and paragraphs will be the
1732 /// same. Display lines are divided differently for each view, since
1733 /// they depend on the view’s width; paragraphs are the same in all
1734 /// views, since they depend on the contents of the [`TextBuffer`][crate::TextBuffer].
1735 /// ## `iter`
1736 /// a [`TextIter`][crate::TextIter]
1737 ///
1738 /// # Returns
1739 ///
1740 /// [`true`] if @iter was moved and is not on the end iterator
1741 #[doc(alias = "gtk_text_view_forward_display_line")]
1742 fn forward_display_line(&self, iter: &mut TextIter) -> bool {
1743 unsafe {
1744 from_glib(ffi::gtk_text_view_forward_display_line(
1745 self.as_ref().to_glib_none().0,
1746 iter.to_glib_none_mut().0,
1747 ))
1748 }
1749 }
1750
1751 /// Moves the given @iter forward to the next display line end.
1752 ///
1753 /// A display line is different from a paragraph. Paragraphs are
1754 /// separated by newlines or other paragraph separator characters.
1755 /// Display lines are created by line-wrapping a paragraph. If
1756 /// wrapping is turned off, display lines and paragraphs will be the
1757 /// same. Display lines are divided differently for each view, since
1758 /// they depend on the view’s width; paragraphs are the same in all
1759 /// views, since they depend on the contents of the [`TextBuffer`][crate::TextBuffer].
1760 /// ## `iter`
1761 /// a [`TextIter`][crate::TextIter]
1762 ///
1763 /// # Returns
1764 ///
1765 /// [`true`] if @iter was moved and is not on the end iterator
1766 #[doc(alias = "gtk_text_view_forward_display_line_end")]
1767 fn forward_display_line_end(&self, iter: &mut TextIter) -> bool {
1768 unsafe {
1769 from_glib(ffi::gtk_text_view_forward_display_line_end(
1770 self.as_ref().to_glib_none().0,
1771 iter.to_glib_none_mut().0,
1772 ))
1773 }
1774 }
1775
1776 /// Returns whether pressing the <kbd>Tab</kbd> key inserts a tab characters.
1777 ///
1778 /// See [`set_accepts_tab()`][Self::set_accepts_tab()].
1779 ///
1780 /// # Returns
1781 ///
1782 /// [`true`] if pressing the Tab key inserts a tab character,
1783 /// [`false`] if pressing the Tab key moves the keyboard focus.
1784 #[doc(alias = "gtk_text_view_get_accepts_tab")]
1785 #[doc(alias = "get_accepts_tab")]
1786 #[doc(alias = "accepts-tab")]
1787 fn accepts_tab(&self) -> bool {
1788 unsafe {
1789 from_glib(ffi::gtk_text_view_get_accepts_tab(
1790 self.as_ref().to_glib_none().0,
1791 ))
1792 }
1793 }
1794
1795 /// Gets the bottom margin for text in the @self.
1796 ///
1797 /// # Returns
1798 ///
1799 /// bottom margin in pixels
1800 #[doc(alias = "gtk_text_view_get_bottom_margin")]
1801 #[doc(alias = "get_bottom_margin")]
1802 #[doc(alias = "bottom-margin")]
1803 fn bottom_margin(&self) -> i32 {
1804 unsafe { ffi::gtk_text_view_get_bottom_margin(self.as_ref().to_glib_none().0) }
1805 }
1806
1807 /// Returns the [`TextBuffer`][crate::TextBuffer] being displayed by this text view.
1808 ///
1809 /// The reference count on the buffer is not incremented; the caller
1810 /// of this function won’t own a new reference.
1811 ///
1812 /// # Returns
1813 ///
1814 /// a [`TextBuffer`][crate::TextBuffer]
1815 #[doc(alias = "gtk_text_view_get_buffer")]
1816 #[doc(alias = "get_buffer")]
1817 fn buffer(&self) -> TextBuffer {
1818 unsafe {
1819 from_glib_none(ffi::gtk_text_view_get_buffer(
1820 self.as_ref().to_glib_none().0,
1821 ))
1822 }
1823 }
1824
1825 /// Determine the positions of the strong and weak cursors if the
1826 /// insertion point is at @iter.
1827 ///
1828 /// The position of each cursor is stored as a zero-width rectangle.
1829 /// The strong cursor location is the location where characters of
1830 /// the directionality equal to the base direction of the paragraph
1831 /// are inserted. The weak cursor location is the location where
1832 /// characters of the directionality opposite to the base direction
1833 /// of the paragraph are inserted.
1834 ///
1835 /// If @iter is [`None`], the actual cursor position is used.
1836 ///
1837 /// Note that if @iter happens to be the actual cursor position, and
1838 /// there is currently an IM preedit sequence being entered, the
1839 /// returned locations will be adjusted to account for the preedit
1840 /// cursor’s offset within the preedit sequence.
1841 ///
1842 /// The rectangle position is in buffer coordinates; use
1843 /// [`buffer_to_window_coords()`][Self::buffer_to_window_coords()] to convert these
1844 /// coordinates to coordinates for one of the windows in the text view.
1845 /// ## `iter`
1846 /// a [`TextIter`][crate::TextIter]
1847 ///
1848 /// # Returns
1849 ///
1850 ///
1851 /// ## `strong`
1852 /// location to store the strong cursor position
1853 ///
1854 /// ## `weak`
1855 /// location to store the weak cursor position
1856 #[doc(alias = "gtk_text_view_get_cursor_locations")]
1857 #[doc(alias = "get_cursor_locations")]
1858 fn cursor_locations(&self, iter: Option<&TextIter>) -> (gdk::Rectangle, gdk::Rectangle) {
1859 unsafe {
1860 let mut strong = gdk::Rectangle::uninitialized();
1861 let mut weak = gdk::Rectangle::uninitialized();
1862 ffi::gtk_text_view_get_cursor_locations(
1863 self.as_ref().to_glib_none().0,
1864 iter.to_glib_none().0,
1865 strong.to_glib_none_mut().0,
1866 weak.to_glib_none_mut().0,
1867 );
1868 (strong, weak)
1869 }
1870 }
1871
1872 /// Find out whether the cursor should be displayed.
1873 ///
1874 /// # Returns
1875 ///
1876 /// whether the insertion mark is visible
1877 #[doc(alias = "gtk_text_view_get_cursor_visible")]
1878 #[doc(alias = "get_cursor_visible")]
1879 #[doc(alias = "cursor-visible")]
1880 fn is_cursor_visible(&self) -> bool {
1881 unsafe {
1882 from_glib(ffi::gtk_text_view_get_cursor_visible(
1883 self.as_ref().to_glib_none().0,
1884 ))
1885 }
1886 }
1887
1888 /// Returns the default editability of the [`TextView`][crate::TextView].
1889 ///
1890 /// Tags in the buffer may override this setting for some ranges of text.
1891 ///
1892 /// # Returns
1893 ///
1894 /// whether text is editable by default
1895 #[doc(alias = "gtk_text_view_get_editable")]
1896 #[doc(alias = "get_editable")]
1897 #[doc(alias = "editable")]
1898 fn is_editable(&self) -> bool {
1899 unsafe {
1900 from_glib(ffi::gtk_text_view_get_editable(
1901 self.as_ref().to_glib_none().0,
1902 ))
1903 }
1904 }
1905
1906 /// Gets the menu model that gets added to the context menu
1907 /// or [`None`] if none has been set.
1908 ///
1909 /// # Returns
1910 ///
1911 /// the menu model
1912 #[doc(alias = "gtk_text_view_get_extra_menu")]
1913 #[doc(alias = "get_extra_menu")]
1914 #[doc(alias = "extra-menu")]
1915 fn extra_menu(&self) -> Option<gio::MenuModel> {
1916 unsafe {
1917 from_glib_none(ffi::gtk_text_view_get_extra_menu(
1918 self.as_ref().to_glib_none().0,
1919 ))
1920 }
1921 }
1922
1923 /// Gets a [`Widget`][crate::Widget] that has previously been set as gutter.
1924 ///
1925 /// See [`set_gutter()`][Self::set_gutter()].
1926 ///
1927 /// @win must be one of [`TextWindowType::Left`][crate::TextWindowType::Left], [`TextWindowType::Right`][crate::TextWindowType::Right],
1928 /// [`TextWindowType::Top`][crate::TextWindowType::Top], or [`TextWindowType::Bottom`][crate::TextWindowType::Bottom].
1929 /// ## `win`
1930 /// a [`TextWindowType`][crate::TextWindowType]
1931 ///
1932 /// # Returns
1933 ///
1934 /// a [`Widget`][crate::Widget]
1935 #[doc(alias = "gtk_text_view_get_gutter")]
1936 #[doc(alias = "get_gutter")]
1937 fn gutter(&self, win: TextWindowType) -> Option<Widget> {
1938 unsafe {
1939 from_glib_none(ffi::gtk_text_view_get_gutter(
1940 self.as_ref().to_glib_none().0,
1941 win.into_glib(),
1942 ))
1943 }
1944 }
1945
1946 /// Gets the default indentation of paragraphs in @self.
1947 ///
1948 /// Tags in the view’s buffer may override the default.
1949 /// The indentation may be negative.
1950 ///
1951 /// # Returns
1952 ///
1953 /// number of pixels of indentation
1954 #[doc(alias = "gtk_text_view_get_indent")]
1955 #[doc(alias = "get_indent")]
1956 fn indent(&self) -> i32 {
1957 unsafe { ffi::gtk_text_view_get_indent(self.as_ref().to_glib_none().0) }
1958 }
1959
1960 /// Gets the `input-hints` of the [`TextView`][crate::TextView].
1961 ///
1962 /// # Returns
1963 ///
1964 /// the input hints
1965 #[doc(alias = "gtk_text_view_get_input_hints")]
1966 #[doc(alias = "get_input_hints")]
1967 #[doc(alias = "input-hints")]
1968 fn input_hints(&self) -> InputHints {
1969 unsafe {
1970 from_glib(ffi::gtk_text_view_get_input_hints(
1971 self.as_ref().to_glib_none().0,
1972 ))
1973 }
1974 }
1975
1976 /// Gets the `input-purpose` of the [`TextView`][crate::TextView].
1977 ///
1978 /// # Returns
1979 ///
1980 /// the input purpose
1981 #[doc(alias = "gtk_text_view_get_input_purpose")]
1982 #[doc(alias = "get_input_purpose")]
1983 #[doc(alias = "input-purpose")]
1984 fn input_purpose(&self) -> InputPurpose {
1985 unsafe {
1986 from_glib(ffi::gtk_text_view_get_input_purpose(
1987 self.as_ref().to_glib_none().0,
1988 ))
1989 }
1990 }
1991
1992 /// Retrieves the iterator at buffer coordinates @x and @y.
1993 ///
1994 /// Buffer coordinates are coordinates for the entire buffer, not just
1995 /// the currently-displayed portion. If you have coordinates from an
1996 /// event, you have to convert those to buffer coordinates with
1997 /// [`window_to_buffer_coords()`][Self::window_to_buffer_coords()].
1998 /// ## `x`
1999 /// x position, in buffer coordinates
2000 /// ## `y`
2001 /// y position, in buffer coordinates
2002 ///
2003 /// # Returns
2004 ///
2005 /// [`true`] if the position is over text
2006 ///
2007 /// ## `iter`
2008 /// a [`TextIter`][crate::TextIter]
2009 #[doc(alias = "gtk_text_view_get_iter_at_location")]
2010 #[doc(alias = "get_iter_at_location")]
2011 fn iter_at_location(&self, x: i32, y: i32) -> Option<TextIter> {
2012 unsafe {
2013 let mut iter = TextIter::uninitialized();
2014 let ret = from_glib(ffi::gtk_text_view_get_iter_at_location(
2015 self.as_ref().to_glib_none().0,
2016 iter.to_glib_none_mut().0,
2017 x,
2018 y,
2019 ));
2020 if ret { Some(iter) } else { None }
2021 }
2022 }
2023
2024 /// Retrieves the iterator pointing to the character at buffer
2025 /// coordinates @x and @y.
2026 ///
2027 /// Buffer coordinates are coordinates for the entire buffer, not just
2028 /// the currently-displayed portion. If you have coordinates from an event,
2029 /// you have to convert those to buffer coordinates with
2030 /// [`window_to_buffer_coords()`][Self::window_to_buffer_coords()].
2031 ///
2032 /// Note that this is different from [`iter_at_location()`][Self::iter_at_location()],
2033 /// which returns cursor locations, i.e. positions between characters.
2034 /// ## `x`
2035 /// x position, in buffer coordinates
2036 /// ## `y`
2037 /// y position, in buffer coordinates
2038 ///
2039 /// # Returns
2040 ///
2041 /// [`true`] if the position is over text
2042 ///
2043 /// ## `iter`
2044 /// a [`TextIter`][crate::TextIter]
2045 ///
2046 /// ## `trailing`
2047 /// if non-[`None`], location to store
2048 /// an integer indicating where in the grapheme the user clicked.
2049 /// It will either be zero, or the number of characters in the grapheme.
2050 /// 0 represents the trailing edge of the grapheme.
2051 #[doc(alias = "gtk_text_view_get_iter_at_position")]
2052 #[doc(alias = "get_iter_at_position")]
2053 fn iter_at_position(&self, x: i32, y: i32) -> Option<(TextIter, i32)> {
2054 unsafe {
2055 let mut iter = TextIter::uninitialized();
2056 let mut trailing = std::mem::MaybeUninit::uninit();
2057 let ret = from_glib(ffi::gtk_text_view_get_iter_at_position(
2058 self.as_ref().to_glib_none().0,
2059 iter.to_glib_none_mut().0,
2060 trailing.as_mut_ptr(),
2061 x,
2062 y,
2063 ));
2064 if ret {
2065 Some((iter, trailing.assume_init()))
2066 } else {
2067 None
2068 }
2069 }
2070 }
2071
2072 /// Gets a rectangle which roughly contains the character at @iter.
2073 ///
2074 /// The rectangle position is in buffer coordinates; use
2075 /// [`buffer_to_window_coords()`][Self::buffer_to_window_coords()] to convert these
2076 /// coordinates to coordinates for one of the windows in the text view.
2077 /// ## `iter`
2078 /// a [`TextIter`][crate::TextIter]
2079 ///
2080 /// # Returns
2081 ///
2082 ///
2083 /// ## `location`
2084 /// bounds of the character at @iter
2085 #[doc(alias = "gtk_text_view_get_iter_location")]
2086 #[doc(alias = "get_iter_location")]
2087 fn iter_location(&self, iter: &TextIter) -> gdk::Rectangle {
2088 unsafe {
2089 let mut location = gdk::Rectangle::uninitialized();
2090 ffi::gtk_text_view_get_iter_location(
2091 self.as_ref().to_glib_none().0,
2092 iter.to_glib_none().0,
2093 location.to_glib_none_mut().0,
2094 );
2095 location
2096 }
2097 }
2098
2099 /// Gets the default justification of paragraphs in @self.
2100 ///
2101 /// Tags in the buffer may override the default.
2102 ///
2103 /// # Returns
2104 ///
2105 /// default justification
2106 #[doc(alias = "gtk_text_view_get_justification")]
2107 #[doc(alias = "get_justification")]
2108 fn justification(&self) -> Justification {
2109 unsafe {
2110 from_glib(ffi::gtk_text_view_get_justification(
2111 self.as_ref().to_glib_none().0,
2112 ))
2113 }
2114 }
2115
2116 /// Gets the default left margin size of paragraphs in the @self.
2117 ///
2118 /// Tags in the buffer may override the default.
2119 ///
2120 /// # Returns
2121 ///
2122 /// left margin in pixels
2123 #[doc(alias = "gtk_text_view_get_left_margin")]
2124 #[doc(alias = "get_left_margin")]
2125 #[doc(alias = "left-margin")]
2126 fn left_margin(&self) -> i32 {
2127 unsafe { ffi::gtk_text_view_get_left_margin(self.as_ref().to_glib_none().0) }
2128 }
2129
2130 /// Gets the [`TextIter`][crate::TextIter] at the start of the line containing
2131 /// the coordinate @y.
2132 ///
2133 /// @y is in buffer coordinates, convert from window coordinates with
2134 /// [`window_to_buffer_coords()`][Self::window_to_buffer_coords()]. If non-[`None`],
2135 /// @line_top will be filled with the coordinate of the top edge
2136 /// of the line.
2137 /// ## `y`
2138 /// a y coordinate
2139 ///
2140 /// # Returns
2141 ///
2142 ///
2143 /// ## `target_iter`
2144 /// a [`TextIter`][crate::TextIter]
2145 ///
2146 /// ## `line_top`
2147 /// return location for top coordinate of the line
2148 #[doc(alias = "gtk_text_view_get_line_at_y")]
2149 #[doc(alias = "get_line_at_y")]
2150 fn line_at_y(&self, y: i32) -> (TextIter, i32) {
2151 unsafe {
2152 let mut target_iter = TextIter::uninitialized();
2153 let mut line_top = std::mem::MaybeUninit::uninit();
2154 ffi::gtk_text_view_get_line_at_y(
2155 self.as_ref().to_glib_none().0,
2156 target_iter.to_glib_none_mut().0,
2157 y,
2158 line_top.as_mut_ptr(),
2159 );
2160 (target_iter, line_top.assume_init())
2161 }
2162 }
2163
2164 /// Gets the y coordinate of the top of the line containing @iter,
2165 /// and the height of the line.
2166 ///
2167 /// The coordinate is a buffer coordinate; convert to window
2168 /// coordinates with [`buffer_to_window_coords()`][Self::buffer_to_window_coords()].
2169 /// ## `iter`
2170 /// a [`TextIter`][crate::TextIter]
2171 ///
2172 /// # Returns
2173 ///
2174 ///
2175 /// ## `y`
2176 /// return location for a y coordinate
2177 ///
2178 /// ## `height`
2179 /// return location for a height
2180 #[doc(alias = "gtk_text_view_get_line_yrange")]
2181 #[doc(alias = "get_line_yrange")]
2182 fn line_yrange(&self, iter: &TextIter) -> (i32, i32) {
2183 unsafe {
2184 let mut y = std::mem::MaybeUninit::uninit();
2185 let mut height = std::mem::MaybeUninit::uninit();
2186 ffi::gtk_text_view_get_line_yrange(
2187 self.as_ref().to_glib_none().0,
2188 iter.to_glib_none().0,
2189 y.as_mut_ptr(),
2190 height.as_mut_ptr(),
2191 );
2192 (y.assume_init(), height.assume_init())
2193 }
2194 }
2195
2196 /// Gets the [`pango::Context`][crate::pango::Context] that is used for rendering LTR directed
2197 /// text layouts.
2198 ///
2199 /// The context may be replaced when CSS changes occur.
2200 ///
2201 /// # Returns
2202 ///
2203 /// a [`pango::Context`][crate::pango::Context]
2204 #[cfg(feature = "v4_4")]
2205 #[cfg_attr(docsrs, doc(cfg(feature = "v4_4")))]
2206 #[doc(alias = "gtk_text_view_get_ltr_context")]
2207 #[doc(alias = "get_ltr_context")]
2208 fn ltr_context(&self) -> pango::Context {
2209 unsafe {
2210 from_glib_none(ffi::gtk_text_view_get_ltr_context(
2211 self.as_ref().to_glib_none().0,
2212 ))
2213 }
2214 }
2215
2216 /// Gets whether the [`TextView`][crate::TextView] uses monospace styling.
2217 ///
2218 /// # Returns
2219 ///
2220 /// [`true`] if monospace fonts are desired
2221 #[doc(alias = "gtk_text_view_get_monospace")]
2222 #[doc(alias = "get_monospace")]
2223 #[doc(alias = "monospace")]
2224 fn is_monospace(&self) -> bool {
2225 unsafe {
2226 from_glib(ffi::gtk_text_view_get_monospace(
2227 self.as_ref().to_glib_none().0,
2228 ))
2229 }
2230 }
2231
2232 /// Returns whether the [`TextView`][crate::TextView] is in overwrite mode or not.
2233 ///
2234 /// # Returns
2235 ///
2236 /// whether @self is in overwrite mode or not.
2237 #[doc(alias = "gtk_text_view_get_overwrite")]
2238 #[doc(alias = "get_overwrite")]
2239 #[doc(alias = "overwrite")]
2240 fn overwrites(&self) -> bool {
2241 unsafe {
2242 from_glib(ffi::gtk_text_view_get_overwrite(
2243 self.as_ref().to_glib_none().0,
2244 ))
2245 }
2246 }
2247
2248 /// Gets the default number of pixels to put above paragraphs.
2249 ///
2250 /// Adding this function with [`pixels_below_lines()`][Self::pixels_below_lines()]
2251 /// is equal to the line space between each paragraph.
2252 ///
2253 /// # Returns
2254 ///
2255 /// default number of pixels above paragraphs
2256 #[doc(alias = "gtk_text_view_get_pixels_above_lines")]
2257 #[doc(alias = "get_pixels_above_lines")]
2258 #[doc(alias = "pixels-above-lines")]
2259 fn pixels_above_lines(&self) -> i32 {
2260 unsafe { ffi::gtk_text_view_get_pixels_above_lines(self.as_ref().to_glib_none().0) }
2261 }
2262
2263 /// Gets the default number of pixels to put below paragraphs.
2264 ///
2265 /// The line space is the sum of the value returned by this function and
2266 /// the value returned by [`pixels_above_lines()`][Self::pixels_above_lines()].
2267 ///
2268 /// # Returns
2269 ///
2270 /// default number of blank pixels below paragraphs
2271 #[doc(alias = "gtk_text_view_get_pixels_below_lines")]
2272 #[doc(alias = "get_pixels_below_lines")]
2273 #[doc(alias = "pixels-below-lines")]
2274 fn pixels_below_lines(&self) -> i32 {
2275 unsafe { ffi::gtk_text_view_get_pixels_below_lines(self.as_ref().to_glib_none().0) }
2276 }
2277
2278 /// Gets the default number of pixels to put between wrapped lines
2279 /// inside a paragraph.
2280 ///
2281 /// # Returns
2282 ///
2283 /// default number of pixels of blank space between wrapped lines
2284 #[doc(alias = "gtk_text_view_get_pixels_inside_wrap")]
2285 #[doc(alias = "get_pixels_inside_wrap")]
2286 #[doc(alias = "pixels-inside-wrap")]
2287 fn pixels_inside_wrap(&self) -> i32 {
2288 unsafe { ffi::gtk_text_view_get_pixels_inside_wrap(self.as_ref().to_glib_none().0) }
2289 }
2290
2291 /// Gets the default right margin for text in @self.
2292 ///
2293 /// Tags in the buffer may override the default.
2294 ///
2295 /// # Returns
2296 ///
2297 /// right margin in pixels
2298 #[doc(alias = "gtk_text_view_get_right_margin")]
2299 #[doc(alias = "get_right_margin")]
2300 #[doc(alias = "right-margin")]
2301 fn right_margin(&self) -> i32 {
2302 unsafe { ffi::gtk_text_view_get_right_margin(self.as_ref().to_glib_none().0) }
2303 }
2304
2305 /// Gets the [`pango::Context`][crate::pango::Context] that is used for rendering RTL directed
2306 /// text layouts.
2307 ///
2308 /// The context may be replaced when CSS changes occur.
2309 ///
2310 /// # Returns
2311 ///
2312 /// a [`pango::Context`][crate::pango::Context]
2313 #[cfg(feature = "v4_4")]
2314 #[cfg_attr(docsrs, doc(cfg(feature = "v4_4")))]
2315 #[doc(alias = "gtk_text_view_get_rtl_context")]
2316 #[doc(alias = "get_rtl_context")]
2317 fn rtl_context(&self) -> pango::Context {
2318 unsafe {
2319 from_glib_none(ffi::gtk_text_view_get_rtl_context(
2320 self.as_ref().to_glib_none().0,
2321 ))
2322 }
2323 }
2324
2325 /// Gets the default tabs for @self.
2326 ///
2327 /// Tags in the buffer may override the defaults. The returned array
2328 /// will be [`None`] if “standard” (8-space) tabs are used. Free the
2329 /// return value with `Pango::TabArray::free()`.
2330 ///
2331 /// # Returns
2332 ///
2333 /// copy of default tab array,
2334 /// or [`None`] if standard tabs are used; must be freed with
2335 /// `Pango::TabArray::free()`.
2336 #[doc(alias = "gtk_text_view_get_tabs")]
2337 #[doc(alias = "get_tabs")]
2338 fn tabs(&self) -> Option<pango::TabArray> {
2339 unsafe { from_glib_full(ffi::gtk_text_view_get_tabs(self.as_ref().to_glib_none().0)) }
2340 }
2341
2342 /// Gets the top margin for text in the @self.
2343 ///
2344 /// # Returns
2345 ///
2346 /// top margin in pixels
2347 #[doc(alias = "gtk_text_view_get_top_margin")]
2348 #[doc(alias = "get_top_margin")]
2349 #[doc(alias = "top-margin")]
2350 fn top_margin(&self) -> i32 {
2351 unsafe { ffi::gtk_text_view_get_top_margin(self.as_ref().to_glib_none().0) }
2352 }
2353
2354 /// Gets the X,Y offset in buffer coordinates of the top-left corner of
2355 /// the textview's text contents.
2356 ///
2357 /// This allows for more-precise positioning than what is provided by
2358 /// [`visible_rect()`][Self::visible_rect()] as you can discover what
2359 /// device pixel is being quantized for text positioning.
2360 ///
2361 /// You might want this when making ulterior widgets align with quantized
2362 /// device pixels of the textview contents such as line numbers.
2363 ///
2364 /// # Returns
2365 ///
2366 ///
2367 /// ## `x_offset`
2368 /// a location for the X offset
2369 ///
2370 /// ## `y_offset`
2371 /// a location for the Y offset
2372 #[cfg(feature = "v4_18")]
2373 #[cfg_attr(docsrs, doc(cfg(feature = "v4_18")))]
2374 #[doc(alias = "gtk_text_view_get_visible_offset")]
2375 #[doc(alias = "get_visible_offset")]
2376 fn visible_offset(&self) -> (f64, f64) {
2377 unsafe {
2378 let mut x_offset = std::mem::MaybeUninit::uninit();
2379 let mut y_offset = std::mem::MaybeUninit::uninit();
2380 ffi::gtk_text_view_get_visible_offset(
2381 self.as_ref().to_glib_none().0,
2382 x_offset.as_mut_ptr(),
2383 y_offset.as_mut_ptr(),
2384 );
2385 (x_offset.assume_init(), y_offset.assume_init())
2386 }
2387 }
2388
2389 /// Fills @visible_rect with the currently-visible
2390 /// region of the buffer, in buffer coordinates.
2391 ///
2392 /// Convert to window coordinates with
2393 /// [`buffer_to_window_coords()`][Self::buffer_to_window_coords()].
2394 ///
2395 /// # Returns
2396 ///
2397 ///
2398 /// ## `visible_rect`
2399 /// rectangle to fill
2400 #[doc(alias = "gtk_text_view_get_visible_rect")]
2401 #[doc(alias = "get_visible_rect")]
2402 fn visible_rect(&self) -> gdk::Rectangle {
2403 unsafe {
2404 let mut visible_rect = gdk::Rectangle::uninitialized();
2405 ffi::gtk_text_view_get_visible_rect(
2406 self.as_ref().to_glib_none().0,
2407 visible_rect.to_glib_none_mut().0,
2408 );
2409 visible_rect
2410 }
2411 }
2412
2413 /// Gets the line wrapping for the view.
2414 ///
2415 /// # Returns
2416 ///
2417 /// the line wrap setting
2418 #[doc(alias = "gtk_text_view_get_wrap_mode")]
2419 #[doc(alias = "get_wrap_mode")]
2420 #[doc(alias = "wrap-mode")]
2421 fn wrap_mode(&self) -> WrapMode {
2422 unsafe {
2423 from_glib(ffi::gtk_text_view_get_wrap_mode(
2424 self.as_ref().to_glib_none().0,
2425 ))
2426 }
2427 }
2428
2429 /// Allow the [`TextView`][crate::TextView] input method to internally handle key press
2430 /// and release events.
2431 ///
2432 /// If this function returns [`true`], then no further processing should be
2433 /// done for this key event. See [`IMContextExt::filter_keypress()`][crate::prelude::IMContextExt::filter_keypress()].
2434 ///
2435 /// Note that you are expected to call this function from your handler
2436 /// when overriding key event handling. This is needed in the case when
2437 /// you need to insert your own key handling between the input method
2438 /// and the default key event handling of the [`TextView`][crate::TextView].
2439 ///
2440 /// **⚠️ The following code is in c ⚠️**
2441 ///
2442 /// ```c
2443 /// static gboolean
2444 /// gtk_foo_bar_key_press_event (GtkWidget *widget,
2445 /// GdkEvent *event)
2446 /// {
2447 /// guint keyval;
2448 ///
2449 /// gdk_event_get_keyval ((GdkEvent*)event, &keyval);
2450 ///
2451 /// if (keyval == GDK_KEY_Return || keyval == GDK_KEY_KP_Enter)
2452 /// {
2453 /// if (gtk_text_view_im_context_filter_keypress (GTK_TEXT_VIEW (widget), event))
2454 /// return TRUE;
2455 /// }
2456 ///
2457 /// // Do some stuff
2458 ///
2459 /// return GTK_WIDGET_CLASS (gtk_foo_bar_parent_class)->key_press_event (widget, event);
2460 /// }
2461 /// ```
2462 /// ## `event`
2463 /// the key event
2464 ///
2465 /// # Returns
2466 ///
2467 /// [`true`] if the input method handled the key event.
2468 #[doc(alias = "gtk_text_view_im_context_filter_keypress")]
2469 fn im_context_filter_keypress(&self, event: impl AsRef<gdk::Event>) -> bool {
2470 unsafe {
2471 from_glib(ffi::gtk_text_view_im_context_filter_keypress(
2472 self.as_ref().to_glib_none().0,
2473 event.as_ref().to_glib_none().0,
2474 ))
2475 }
2476 }
2477
2478 /// Moves a mark within the buffer so that it's
2479 /// located within the currently-visible text area.
2480 /// ## `mark`
2481 /// a [`TextMark`][crate::TextMark]
2482 ///
2483 /// # Returns
2484 ///
2485 /// [`true`] if the mark moved (wasn’t already onscreen)
2486 #[doc(alias = "gtk_text_view_move_mark_onscreen")]
2487 fn move_mark_onscreen(&self, mark: &impl IsA<TextMark>) -> bool {
2488 unsafe {
2489 from_glib(ffi::gtk_text_view_move_mark_onscreen(
2490 self.as_ref().to_glib_none().0,
2491 mark.as_ref().to_glib_none().0,
2492 ))
2493 }
2494 }
2495
2496 /// Updates the position of a child.
2497 ///
2498 /// See [`add_overlay()`][Self::add_overlay()].
2499 /// ## `child`
2500 /// a widget already added with [`add_overlay()`][Self::add_overlay()]
2501 /// ## `xpos`
2502 /// new X position in buffer coordinates
2503 /// ## `ypos`
2504 /// new Y position in buffer coordinates
2505 #[doc(alias = "gtk_text_view_move_overlay")]
2506 fn move_overlay(&self, child: &impl IsA<Widget>, xpos: i32, ypos: i32) {
2507 unsafe {
2508 ffi::gtk_text_view_move_overlay(
2509 self.as_ref().to_glib_none().0,
2510 child.as_ref().to_glib_none().0,
2511 xpos,
2512 ypos,
2513 );
2514 }
2515 }
2516
2517 /// Move the iterator a given number of characters visually, treating
2518 /// it as the strong cursor position.
2519 ///
2520 /// If @count is positive, then the new strong cursor position will
2521 /// be @count positions to the right of the old cursor position.
2522 /// If @count is negative then the new strong cursor position will
2523 /// be @count positions to the left of the old cursor position.
2524 ///
2525 /// In the presence of bi-directional text, the correspondence
2526 /// between logical and visual order will depend on the direction
2527 /// of the current run, and there may be jumps when the cursor
2528 /// is moved off of the end of a run.
2529 /// ## `iter`
2530 /// a [`TextIter`][crate::TextIter]
2531 /// ## `count`
2532 /// number of characters to move (negative moves left,
2533 /// positive moves right)
2534 ///
2535 /// # Returns
2536 ///
2537 /// [`true`] if @iter moved and is not on the end iterator
2538 #[doc(alias = "gtk_text_view_move_visually")]
2539 fn move_visually(&self, iter: &mut TextIter, count: i32) -> bool {
2540 unsafe {
2541 from_glib(ffi::gtk_text_view_move_visually(
2542 self.as_ref().to_glib_none().0,
2543 iter.to_glib_none_mut().0,
2544 count,
2545 ))
2546 }
2547 }
2548
2549 /// Moves the cursor to the currently visible region of the
2550 /// buffer.
2551 ///
2552 /// # Returns
2553 ///
2554 /// [`true`] if the cursor had to be moved.
2555 #[doc(alias = "gtk_text_view_place_cursor_onscreen")]
2556 fn place_cursor_onscreen(&self) -> bool {
2557 unsafe {
2558 from_glib(ffi::gtk_text_view_place_cursor_onscreen(
2559 self.as_ref().to_glib_none().0,
2560 ))
2561 }
2562 }
2563
2564 /// Removes a child widget from @self.
2565 /// ## `child`
2566 /// the child to remove
2567 #[doc(alias = "gtk_text_view_remove")]
2568 fn remove(&self, child: &impl IsA<Widget>) {
2569 unsafe {
2570 ffi::gtk_text_view_remove(
2571 self.as_ref().to_glib_none().0,
2572 child.as_ref().to_glib_none().0,
2573 );
2574 }
2575 }
2576
2577 /// Ensures that the cursor is shown.
2578 ///
2579 /// This also resets the time that it will stay blinking (or
2580 /// visible, in case blinking is disabled).
2581 ///
2582 /// This function should be called in response to user input
2583 /// (e.g. from derived classes that override the textview's
2584 /// event handlers).
2585 #[doc(alias = "gtk_text_view_reset_cursor_blink")]
2586 fn reset_cursor_blink(&self) {
2587 unsafe {
2588 ffi::gtk_text_view_reset_cursor_blink(self.as_ref().to_glib_none().0);
2589 }
2590 }
2591
2592 /// Reset the input method context of the text view if needed.
2593 ///
2594 /// This can be necessary in the case where modifying the buffer
2595 /// would confuse on-going input method behavior.
2596 #[doc(alias = "gtk_text_view_reset_im_context")]
2597 fn reset_im_context(&self) {
2598 unsafe {
2599 ffi::gtk_text_view_reset_im_context(self.as_ref().to_glib_none().0);
2600 }
2601 }
2602
2603 /// Scrolls @self the minimum distance such that @mark is contained
2604 /// within the visible area of the widget.
2605 /// ## `mark`
2606 /// a mark in the buffer for @self
2607 #[doc(alias = "gtk_text_view_scroll_mark_onscreen")]
2608 fn scroll_mark_onscreen(&self, mark: &impl IsA<TextMark>) {
2609 unsafe {
2610 ffi::gtk_text_view_scroll_mark_onscreen(
2611 self.as_ref().to_glib_none().0,
2612 mark.as_ref().to_glib_none().0,
2613 );
2614 }
2615 }
2616
2617 /// Scrolls @self so that @iter is on the screen in the position
2618 /// indicated by @xalign and @yalign.
2619 ///
2620 /// An alignment of 0.0 indicates left or top, 1.0 indicates right or
2621 /// bottom, 0.5 means center. If @use_align is [`false`], the text scrolls
2622 /// the minimal distance to get the mark onscreen, possibly not scrolling
2623 /// at all. The effective screen for purposes of this function is reduced
2624 /// by a margin of size @within_margin.
2625 ///
2626 /// Note that this function uses the currently-computed height of the
2627 /// lines in the text buffer. Line heights are computed in an idle
2628 /// handler; so this function may not have the desired effect if it’s
2629 /// called before the height computations. To avoid oddness, consider
2630 /// using [`scroll_to_mark()`][Self::scroll_to_mark()] which saves a point to be
2631 /// scrolled to after line validation.
2632 /// ## `iter`
2633 /// a [`TextIter`][crate::TextIter]
2634 /// ## `within_margin`
2635 /// margin as a [0.0,0.5) fraction of screen size
2636 /// ## `use_align`
2637 /// whether to use alignment arguments (if [`false`],
2638 /// just get the mark onscreen)
2639 /// ## `xalign`
2640 /// horizontal alignment of mark within visible area
2641 /// ## `yalign`
2642 /// vertical alignment of mark within visible area
2643 ///
2644 /// # Returns
2645 ///
2646 /// [`true`] if scrolling occurred
2647 #[doc(alias = "gtk_text_view_scroll_to_iter")]
2648 fn scroll_to_iter(
2649 &self,
2650 iter: &mut TextIter,
2651 within_margin: f64,
2652 use_align: bool,
2653 xalign: f64,
2654 yalign: f64,
2655 ) -> bool {
2656 unsafe {
2657 from_glib(ffi::gtk_text_view_scroll_to_iter(
2658 self.as_ref().to_glib_none().0,
2659 iter.to_glib_none_mut().0,
2660 within_margin,
2661 use_align.into_glib(),
2662 xalign,
2663 yalign,
2664 ))
2665 }
2666 }
2667
2668 /// Scrolls @self so that @mark is on the screen in the position
2669 /// indicated by @xalign and @yalign.
2670 ///
2671 /// An alignment of 0.0 indicates left or top, 1.0 indicates right or
2672 /// bottom, 0.5 means center. If @use_align is [`false`], the text scrolls
2673 /// the minimal distance to get the mark onscreen, possibly not scrolling
2674 /// at all. The effective screen for purposes of this function is reduced
2675 /// by a margin of size @within_margin.
2676 /// ## `mark`
2677 /// a [`TextMark`][crate::TextMark]
2678 /// ## `within_margin`
2679 /// margin as a [0.0,0.5) fraction of screen size
2680 /// ## `use_align`
2681 /// whether to use alignment arguments (if [`false`], just
2682 /// get the mark onscreen)
2683 /// ## `xalign`
2684 /// horizontal alignment of mark within visible area
2685 /// ## `yalign`
2686 /// vertical alignment of mark within visible area
2687 #[doc(alias = "gtk_text_view_scroll_to_mark")]
2688 fn scroll_to_mark(
2689 &self,
2690 mark: &impl IsA<TextMark>,
2691 within_margin: f64,
2692 use_align: bool,
2693 xalign: f64,
2694 yalign: f64,
2695 ) {
2696 unsafe {
2697 ffi::gtk_text_view_scroll_to_mark(
2698 self.as_ref().to_glib_none().0,
2699 mark.as_ref().to_glib_none().0,
2700 within_margin,
2701 use_align.into_glib(),
2702 xalign,
2703 yalign,
2704 );
2705 }
2706 }
2707
2708 /// Sets the behavior of the text widget when the <kbd>Tab</kbd> key is pressed.
2709 ///
2710 /// If @accepts_tab is [`true`], a tab character is inserted. If @accepts_tab
2711 /// is [`false`] the keyboard focus is moved to the next widget in the focus
2712 /// chain.
2713 ///
2714 /// Focus can always be moved using <kbd>Ctrl</kbd>+<kbd>Tab</kbd>.
2715 /// ## `accepts_tab`
2716 /// [`true`] if pressing the Tab key should insert a tab
2717 /// character, [`false`], if pressing the Tab key should move the
2718 /// keyboard focus.
2719 #[doc(alias = "gtk_text_view_set_accepts_tab")]
2720 #[doc(alias = "accepts-tab")]
2721 fn set_accepts_tab(&self, accepts_tab: bool) {
2722 unsafe {
2723 ffi::gtk_text_view_set_accepts_tab(
2724 self.as_ref().to_glib_none().0,
2725 accepts_tab.into_glib(),
2726 );
2727 }
2728 }
2729
2730 /// Sets the bottom margin for text in @self.
2731 ///
2732 /// Note that this function is confusingly named.
2733 /// In CSS terms, the value set here is padding.
2734 /// ## `bottom_margin`
2735 /// bottom margin in pixels
2736 #[doc(alias = "gtk_text_view_set_bottom_margin")]
2737 #[doc(alias = "bottom-margin")]
2738 fn set_bottom_margin(&self, bottom_margin: i32) {
2739 unsafe {
2740 ffi::gtk_text_view_set_bottom_margin(self.as_ref().to_glib_none().0, bottom_margin);
2741 }
2742 }
2743
2744 /// Sets @buffer as the buffer being displayed by @self.
2745 ///
2746 /// The previous buffer displayed by the text view is unreferenced, and
2747 /// a reference is added to @buffer. If you owned a reference to @buffer
2748 /// before passing it to this function, you must remove that reference
2749 /// yourself; [`TextView`][crate::TextView] will not “adopt” it.
2750 /// ## `buffer`
2751 /// a [`TextBuffer`][crate::TextBuffer]
2752 #[doc(alias = "gtk_text_view_set_buffer")]
2753 #[doc(alias = "buffer")]
2754 fn set_buffer(&self, buffer: Option<&impl IsA<TextBuffer>>) {
2755 unsafe {
2756 ffi::gtk_text_view_set_buffer(
2757 self.as_ref().to_glib_none().0,
2758 buffer.map(|p| p.as_ref()).to_glib_none().0,
2759 );
2760 }
2761 }
2762
2763 /// Toggles whether the insertion point should be displayed.
2764 ///
2765 /// A buffer with no editable text probably shouldn’t have a visible
2766 /// cursor, so you may want to turn the cursor off.
2767 ///
2768 /// Note that this property may be overridden by the
2769 /// [`gtk-keynav-use-caret`][struct@crate::Settings#gtk-keynav-use-caret] setting.
2770 /// ## `setting`
2771 /// whether to show the insertion cursor
2772 #[doc(alias = "gtk_text_view_set_cursor_visible")]
2773 #[doc(alias = "cursor-visible")]
2774 fn set_cursor_visible(&self, setting: bool) {
2775 unsafe {
2776 ffi::gtk_text_view_set_cursor_visible(
2777 self.as_ref().to_glib_none().0,
2778 setting.into_glib(),
2779 );
2780 }
2781 }
2782
2783 /// Sets the default editability of the [`TextView`][crate::TextView].
2784 ///
2785 /// You can override this default setting with tags in the buffer,
2786 /// using the “editable” attribute of tags.
2787 /// ## `setting`
2788 /// whether it’s editable
2789 #[doc(alias = "gtk_text_view_set_editable")]
2790 #[doc(alias = "editable")]
2791 fn set_editable(&self, setting: bool) {
2792 unsafe {
2793 ffi::gtk_text_view_set_editable(self.as_ref().to_glib_none().0, setting.into_glib());
2794 }
2795 }
2796
2797 /// Sets a menu model to add when constructing the context
2798 /// menu for @self.
2799 ///
2800 /// You can pass [`None`] to remove a previously set extra menu.
2801 /// ## `model`
2802 /// a `GMenuModel`
2803 #[doc(alias = "gtk_text_view_set_extra_menu")]
2804 #[doc(alias = "extra-menu")]
2805 fn set_extra_menu(&self, model: Option<&impl IsA<gio::MenuModel>>) {
2806 unsafe {
2807 ffi::gtk_text_view_set_extra_menu(
2808 self.as_ref().to_glib_none().0,
2809 model.map(|p| p.as_ref()).to_glib_none().0,
2810 );
2811 }
2812 }
2813
2814 /// Places @widget into the gutter specified by @win.
2815 ///
2816 /// @win must be one of [`TextWindowType::Left`][crate::TextWindowType::Left], [`TextWindowType::Right`][crate::TextWindowType::Right],
2817 /// [`TextWindowType::Top`][crate::TextWindowType::Top], or [`TextWindowType::Bottom`][crate::TextWindowType::Bottom].
2818 /// ## `win`
2819 /// a [`TextWindowType`][crate::TextWindowType]
2820 /// ## `widget`
2821 /// a [`Widget`][crate::Widget]
2822 #[doc(alias = "gtk_text_view_set_gutter")]
2823 fn set_gutter(&self, win: TextWindowType, widget: Option<&impl IsA<Widget>>) {
2824 unsafe {
2825 ffi::gtk_text_view_set_gutter(
2826 self.as_ref().to_glib_none().0,
2827 win.into_glib(),
2828 widget.map(|p| p.as_ref()).to_glib_none().0,
2829 );
2830 }
2831 }
2832
2833 /// Sets the default indentation for paragraphs in @self.
2834 ///
2835 /// Tags in the buffer may override the default.
2836 /// ## `indent`
2837 /// indentation in pixels
2838 #[doc(alias = "gtk_text_view_set_indent")]
2839 #[doc(alias = "indent")]
2840 fn set_indent(&self, indent: i32) {
2841 unsafe {
2842 ffi::gtk_text_view_set_indent(self.as_ref().to_glib_none().0, indent);
2843 }
2844 }
2845
2846 /// Sets the `input-hints` of the [`TextView`][crate::TextView].
2847 ///
2848 /// The `input-hints` allow input methods to fine-tune
2849 /// their behaviour.
2850 /// ## `hints`
2851 /// the hints
2852 #[doc(alias = "gtk_text_view_set_input_hints")]
2853 #[doc(alias = "input-hints")]
2854 fn set_input_hints(&self, hints: InputHints) {
2855 unsafe {
2856 ffi::gtk_text_view_set_input_hints(self.as_ref().to_glib_none().0, hints.into_glib());
2857 }
2858 }
2859
2860 /// Sets the `input-purpose` of the [`TextView`][crate::TextView].
2861 ///
2862 /// The `input-purpose` can be used by on-screen keyboards
2863 /// and other input methods to adjust their behaviour.
2864 /// ## `purpose`
2865 /// the purpose
2866 #[doc(alias = "gtk_text_view_set_input_purpose")]
2867 #[doc(alias = "input-purpose")]
2868 fn set_input_purpose(&self, purpose: InputPurpose) {
2869 unsafe {
2870 ffi::gtk_text_view_set_input_purpose(
2871 self.as_ref().to_glib_none().0,
2872 purpose.into_glib(),
2873 );
2874 }
2875 }
2876
2877 /// Sets the default justification of text in @self.
2878 ///
2879 /// Tags in the view’s buffer may override the default.
2880 /// ## `justification`
2881 /// justification
2882 #[doc(alias = "gtk_text_view_set_justification")]
2883 #[doc(alias = "justification")]
2884 fn set_justification(&self, justification: Justification) {
2885 unsafe {
2886 ffi::gtk_text_view_set_justification(
2887 self.as_ref().to_glib_none().0,
2888 justification.into_glib(),
2889 );
2890 }
2891 }
2892
2893 /// Sets the default left margin for text in @self.
2894 ///
2895 /// Tags in the buffer may override the default.
2896 ///
2897 /// Note that this function is confusingly named.
2898 /// In CSS terms, the value set here is padding.
2899 /// ## `left_margin`
2900 /// left margin in pixels
2901 #[doc(alias = "gtk_text_view_set_left_margin")]
2902 #[doc(alias = "left-margin")]
2903 fn set_left_margin(&self, left_margin: i32) {
2904 unsafe {
2905 ffi::gtk_text_view_set_left_margin(self.as_ref().to_glib_none().0, left_margin);
2906 }
2907 }
2908
2909 /// Sets whether the [`TextView`][crate::TextView] should display text in
2910 /// monospace styling.
2911 /// ## `monospace`
2912 /// [`true`] to request monospace styling
2913 #[doc(alias = "gtk_text_view_set_monospace")]
2914 #[doc(alias = "monospace")]
2915 fn set_monospace(&self, monospace: bool) {
2916 unsafe {
2917 ffi::gtk_text_view_set_monospace(self.as_ref().to_glib_none().0, monospace.into_glib());
2918 }
2919 }
2920
2921 /// Changes the [`TextView`][crate::TextView] overwrite mode.
2922 /// ## `overwrite`
2923 /// [`true`] to turn on overwrite mode, [`false`] to turn it off
2924 #[doc(alias = "gtk_text_view_set_overwrite")]
2925 #[doc(alias = "overwrite")]
2926 fn set_overwrite(&self, overwrite: bool) {
2927 unsafe {
2928 ffi::gtk_text_view_set_overwrite(self.as_ref().to_glib_none().0, overwrite.into_glib());
2929 }
2930 }
2931
2932 /// Sets the default number of blank pixels above paragraphs in @self.
2933 ///
2934 /// Tags in the buffer for @self may override the defaults.
2935 /// ## `pixels_above_lines`
2936 /// pixels above paragraphs
2937 #[doc(alias = "gtk_text_view_set_pixels_above_lines")]
2938 #[doc(alias = "pixels-above-lines")]
2939 fn set_pixels_above_lines(&self, pixels_above_lines: i32) {
2940 unsafe {
2941 ffi::gtk_text_view_set_pixels_above_lines(
2942 self.as_ref().to_glib_none().0,
2943 pixels_above_lines,
2944 );
2945 }
2946 }
2947
2948 /// Sets the default number of pixels of blank space
2949 /// to put below paragraphs in @self.
2950 ///
2951 /// May be overridden by tags applied to @self’s buffer.
2952 /// ## `pixels_below_lines`
2953 /// pixels below paragraphs
2954 #[doc(alias = "gtk_text_view_set_pixels_below_lines")]
2955 #[doc(alias = "pixels-below-lines")]
2956 fn set_pixels_below_lines(&self, pixels_below_lines: i32) {
2957 unsafe {
2958 ffi::gtk_text_view_set_pixels_below_lines(
2959 self.as_ref().to_glib_none().0,
2960 pixels_below_lines,
2961 );
2962 }
2963 }
2964
2965 /// Sets the default number of pixels of blank space to leave between
2966 /// display/wrapped lines within a paragraph.
2967 ///
2968 /// May be overridden by tags in @self’s buffer.
2969 /// ## `pixels_inside_wrap`
2970 /// default number of pixels between wrapped lines
2971 #[doc(alias = "gtk_text_view_set_pixels_inside_wrap")]
2972 #[doc(alias = "pixels-inside-wrap")]
2973 fn set_pixels_inside_wrap(&self, pixels_inside_wrap: i32) {
2974 unsafe {
2975 ffi::gtk_text_view_set_pixels_inside_wrap(
2976 self.as_ref().to_glib_none().0,
2977 pixels_inside_wrap,
2978 );
2979 }
2980 }
2981
2982 /// Sets the default right margin for text in the text view.
2983 ///
2984 /// Tags in the buffer may override the default.
2985 ///
2986 /// Note that this function is confusingly named.
2987 /// In CSS terms, the value set here is padding.
2988 /// ## `right_margin`
2989 /// right margin in pixels
2990 #[doc(alias = "gtk_text_view_set_right_margin")]
2991 #[doc(alias = "right-margin")]
2992 fn set_right_margin(&self, right_margin: i32) {
2993 unsafe {
2994 ffi::gtk_text_view_set_right_margin(self.as_ref().to_glib_none().0, right_margin);
2995 }
2996 }
2997
2998 /// Sets the default tab stops for paragraphs in @self.
2999 ///
3000 /// Tags in the buffer may override the default.
3001 /// ## `tabs`
3002 /// tabs as a [`pango::TabArray`][crate::pango::TabArray]
3003 #[doc(alias = "gtk_text_view_set_tabs")]
3004 #[doc(alias = "tabs")]
3005 fn set_tabs(&self, tabs: &pango::TabArray) {
3006 unsafe {
3007 ffi::gtk_text_view_set_tabs(
3008 self.as_ref().to_glib_none().0,
3009 mut_override(tabs.to_glib_none().0),
3010 );
3011 }
3012 }
3013
3014 /// Sets the top margin for text in @self.
3015 ///
3016 /// Note that this function is confusingly named.
3017 /// In CSS terms, the value set here is padding.
3018 /// ## `top_margin`
3019 /// top margin in pixels
3020 #[doc(alias = "gtk_text_view_set_top_margin")]
3021 #[doc(alias = "top-margin")]
3022 fn set_top_margin(&self, top_margin: i32) {
3023 unsafe {
3024 ffi::gtk_text_view_set_top_margin(self.as_ref().to_glib_none().0, top_margin);
3025 }
3026 }
3027
3028 /// Sets the line wrapping for the view.
3029 /// ## `wrap_mode`
3030 /// a [`WrapMode`][crate::WrapMode]
3031 #[doc(alias = "gtk_text_view_set_wrap_mode")]
3032 #[doc(alias = "wrap-mode")]
3033 fn set_wrap_mode(&self, wrap_mode: WrapMode) {
3034 unsafe {
3035 ffi::gtk_text_view_set_wrap_mode(self.as_ref().to_glib_none().0, wrap_mode.into_glib());
3036 }
3037 }
3038
3039 /// Determines whether @iter is at the start of a display line.
3040 ///
3041 /// See [`forward_display_line()`][Self::forward_display_line()] for an
3042 /// explanation of display lines vs. paragraphs.
3043 /// ## `iter`
3044 /// a [`TextIter`][crate::TextIter]
3045 ///
3046 /// # Returns
3047 ///
3048 /// [`true`] if @iter begins a wrapped line
3049 #[doc(alias = "gtk_text_view_starts_display_line")]
3050 fn starts_display_line(&self, iter: &TextIter) -> bool {
3051 unsafe {
3052 from_glib(ffi::gtk_text_view_starts_display_line(
3053 self.as_ref().to_glib_none().0,
3054 iter.to_glib_none().0,
3055 ))
3056 }
3057 }
3058
3059 /// Converts coordinates on the window identified by @win to buffer
3060 /// coordinates.
3061 /// ## `win`
3062 /// a [`TextWindowType`][crate::TextWindowType]
3063 /// ## `window_x`
3064 /// window x coordinate
3065 /// ## `window_y`
3066 /// window y coordinate
3067 ///
3068 /// # Returns
3069 ///
3070 ///
3071 /// ## `buffer_x`
3072 /// buffer x coordinate return location
3073 ///
3074 /// ## `buffer_y`
3075 /// buffer y coordinate return location
3076 #[doc(alias = "gtk_text_view_window_to_buffer_coords")]
3077 fn window_to_buffer_coords(
3078 &self,
3079 win: TextWindowType,
3080 window_x: i32,
3081 window_y: i32,
3082 ) -> (i32, i32) {
3083 unsafe {
3084 let mut buffer_x = std::mem::MaybeUninit::uninit();
3085 let mut buffer_y = std::mem::MaybeUninit::uninit();
3086 ffi::gtk_text_view_window_to_buffer_coords(
3087 self.as_ref().to_glib_none().0,
3088 win.into_glib(),
3089 window_x,
3090 window_y,
3091 buffer_x.as_mut_ptr(),
3092 buffer_y.as_mut_ptr(),
3093 );
3094 (buffer_x.assume_init(), buffer_y.assume_init())
3095 }
3096 }
3097
3098 /// Which IM (input method) module should be used for this text_view.
3099 ///
3100 /// See [`IMMulticontext`][crate::IMMulticontext].
3101 ///
3102 /// Setting this to a non-[`None`] value overrides the system-wide IM module
3103 /// setting. See the GtkSettings [`gtk-im-module`][struct@crate::Settings#gtk-im-module] property.
3104 #[doc(alias = "im-module")]
3105 fn im_module(&self) -> Option<glib::GString> {
3106 ObjectExt::property(self.as_ref(), "im-module")
3107 }
3108
3109 /// Which IM (input method) module should be used for this text_view.
3110 ///
3111 /// See [`IMMulticontext`][crate::IMMulticontext].
3112 ///
3113 /// Setting this to a non-[`None`] value overrides the system-wide IM module
3114 /// setting. See the GtkSettings [`gtk-im-module`][struct@crate::Settings#gtk-im-module] property.
3115 #[doc(alias = "im-module")]
3116 fn set_im_module(&self, im_module: Option<&str>) {
3117 ObjectExt::set_property(self.as_ref(), "im-module", im_module)
3118 }
3119
3120 /// Gets emitted when the user asks for it.
3121 ///
3122 /// The ::backspace signal is a [keybinding signal](class.SignalAction.html).
3123 ///
3124 /// The default bindings for this signal are
3125 /// <kbd>Backspace</kbd> and <kbd>Shift</kbd>+<kbd>Backspace</kbd>.
3126 #[doc(alias = "backspace")]
3127 fn connect_backspace<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
3128 unsafe extern "C" fn backspace_trampoline<P: IsA<TextView>, F: Fn(&P) + 'static>(
3129 this: *mut ffi::GtkTextView,
3130 f: glib::ffi::gpointer,
3131 ) {
3132 unsafe {
3133 let f: &F = &*(f as *const F);
3134 f(TextView::from_glib_borrow(this).unsafe_cast_ref())
3135 }
3136 }
3137 unsafe {
3138 let f: Box_<F> = Box_::new(f);
3139 connect_raw(
3140 self.as_ptr() as *mut _,
3141 c"backspace".as_ptr(),
3142 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
3143 backspace_trampoline::<Self, F> as *const (),
3144 )),
3145 Box_::into_raw(f),
3146 )
3147 }
3148 }
3149
3150 fn emit_backspace(&self) {
3151 self.emit_by_name::<()>("backspace", &[]);
3152 }
3153
3154 /// Gets emitted to copy the selection to the clipboard.
3155 ///
3156 /// The ::copy-clipboard signal is a [keybinding signal](class.SignalAction.html).
3157 ///
3158 /// The default bindings for this signal are
3159 /// <kbd>Ctrl</kbd>+<kbd>c</kbd> and
3160 /// <kbd>Ctrl</kbd>+<kbd>Insert</kbd>.
3161 #[doc(alias = "copy-clipboard")]
3162 fn connect_copy_clipboard<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
3163 unsafe extern "C" fn copy_clipboard_trampoline<P: IsA<TextView>, F: Fn(&P) + 'static>(
3164 this: *mut ffi::GtkTextView,
3165 f: glib::ffi::gpointer,
3166 ) {
3167 unsafe {
3168 let f: &F = &*(f as *const F);
3169 f(TextView::from_glib_borrow(this).unsafe_cast_ref())
3170 }
3171 }
3172 unsafe {
3173 let f: Box_<F> = Box_::new(f);
3174 connect_raw(
3175 self.as_ptr() as *mut _,
3176 c"copy-clipboard".as_ptr(),
3177 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
3178 copy_clipboard_trampoline::<Self, F> as *const (),
3179 )),
3180 Box_::into_raw(f),
3181 )
3182 }
3183 }
3184
3185 fn emit_copy_clipboard(&self) {
3186 self.emit_by_name::<()>("copy-clipboard", &[]);
3187 }
3188
3189 /// Gets emitted to cut the selection to the clipboard.
3190 ///
3191 /// The ::cut-clipboard signal is a [keybinding signal](class.SignalAction.html).
3192 ///
3193 /// The default bindings for this signal are
3194 /// <kbd>Ctrl</kbd>+<kbd>x</kbd> and
3195 /// <kbd>Shift</kbd>+<kbd>Delete</kbd>.
3196 #[doc(alias = "cut-clipboard")]
3197 fn connect_cut_clipboard<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
3198 unsafe extern "C" fn cut_clipboard_trampoline<P: IsA<TextView>, F: Fn(&P) + 'static>(
3199 this: *mut ffi::GtkTextView,
3200 f: glib::ffi::gpointer,
3201 ) {
3202 unsafe {
3203 let f: &F = &*(f as *const F);
3204 f(TextView::from_glib_borrow(this).unsafe_cast_ref())
3205 }
3206 }
3207 unsafe {
3208 let f: Box_<F> = Box_::new(f);
3209 connect_raw(
3210 self.as_ptr() as *mut _,
3211 c"cut-clipboard".as_ptr(),
3212 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
3213 cut_clipboard_trampoline::<Self, F> as *const (),
3214 )),
3215 Box_::into_raw(f),
3216 )
3217 }
3218 }
3219
3220 fn emit_cut_clipboard(&self) {
3221 self.emit_by_name::<()>("cut-clipboard", &[]);
3222 }
3223
3224 /// Gets emitted when the user initiates a text deletion.
3225 ///
3226 /// The ::delete-from-cursor signal is a [keybinding signal](class.SignalAction.html).
3227 ///
3228 /// If the @type_ is [`DeleteType::Chars`][crate::DeleteType::Chars], GTK deletes the selection
3229 /// if there is one, otherwise it deletes the requested number
3230 /// of characters.
3231 ///
3232 /// The default bindings for this signal are <kbd>Delete</kbd> for
3233 /// deleting a character, <kbd>Ctrl</kbd>+<kbd>Delete</kbd> for
3234 /// deleting a word and <kbd>Ctrl</kbd>+<kbd>Backspace</kbd> for
3235 /// deleting a word backwards.
3236 /// ## `type_`
3237 /// the granularity of the deletion, as a [`DeleteType`][crate::DeleteType]
3238 /// ## `count`
3239 /// the number of @type_ units to delete
3240 #[doc(alias = "delete-from-cursor")]
3241 fn connect_delete_from_cursor<F: Fn(&Self, DeleteType, i32) + 'static>(
3242 &self,
3243 f: F,
3244 ) -> SignalHandlerId {
3245 unsafe extern "C" fn delete_from_cursor_trampoline<
3246 P: IsA<TextView>,
3247 F: Fn(&P, DeleteType, i32) + 'static,
3248 >(
3249 this: *mut ffi::GtkTextView,
3250 type_: ffi::GtkDeleteType,
3251 count: std::ffi::c_int,
3252 f: glib::ffi::gpointer,
3253 ) {
3254 unsafe {
3255 let f: &F = &*(f as *const F);
3256 f(
3257 TextView::from_glib_borrow(this).unsafe_cast_ref(),
3258 from_glib(type_),
3259 count,
3260 )
3261 }
3262 }
3263 unsafe {
3264 let f: Box_<F> = Box_::new(f);
3265 connect_raw(
3266 self.as_ptr() as *mut _,
3267 c"delete-from-cursor".as_ptr(),
3268 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
3269 delete_from_cursor_trampoline::<Self, F> as *const (),
3270 )),
3271 Box_::into_raw(f),
3272 )
3273 }
3274 }
3275
3276 fn emit_delete_from_cursor(&self, type_: DeleteType, count: i32) {
3277 self.emit_by_name::<()>("delete-from-cursor", &[&type_, &count]);
3278 }
3279
3280 /// Emitted when the selection needs to be extended at @location.
3281 /// ## `granularity`
3282 /// the granularity type
3283 /// ## `location`
3284 /// the location where to extend the selection
3285 /// ## `start`
3286 /// where the selection should start
3287 /// ## `end`
3288 /// where the selection should end
3289 ///
3290 /// # Returns
3291 ///
3292 /// `GDK_EVENT_STOP` to stop other handlers from being invoked for the
3293 /// event. `GDK_EVENT_PROPAGATE` to propagate the event further.
3294 #[doc(alias = "extend-selection")]
3295 fn connect_extend_selection<
3296 F: Fn(&Self, TextExtendSelection, &TextIter, &TextIter, &TextIter) -> glib::Propagation
3297 + 'static,
3298 >(
3299 &self,
3300 f: F,
3301 ) -> SignalHandlerId {
3302 unsafe extern "C" fn extend_selection_trampoline<
3303 P: IsA<TextView>,
3304 F: Fn(&P, TextExtendSelection, &TextIter, &TextIter, &TextIter) -> glib::Propagation
3305 + 'static,
3306 >(
3307 this: *mut ffi::GtkTextView,
3308 granularity: ffi::GtkTextExtendSelection,
3309 location: *mut ffi::GtkTextIter,
3310 start: *mut ffi::GtkTextIter,
3311 end: *mut ffi::GtkTextIter,
3312 f: glib::ffi::gpointer,
3313 ) -> glib::ffi::gboolean {
3314 unsafe {
3315 let f: &F = &*(f as *const F);
3316 f(
3317 TextView::from_glib_borrow(this).unsafe_cast_ref(),
3318 from_glib(granularity),
3319 &from_glib_borrow(location),
3320 &from_glib_borrow(start),
3321 &from_glib_borrow(end),
3322 )
3323 .into_glib()
3324 }
3325 }
3326 unsafe {
3327 let f: Box_<F> = Box_::new(f);
3328 connect_raw(
3329 self.as_ptr() as *mut _,
3330 c"extend-selection".as_ptr(),
3331 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
3332 extend_selection_trampoline::<Self, F> as *const (),
3333 )),
3334 Box_::into_raw(f),
3335 )
3336 }
3337 }
3338
3339 /// Gets emitted when the user initiates the insertion of a
3340 /// fixed string at the cursor.
3341 ///
3342 /// The ::insert-at-cursor signal is a [keybinding signal](class.SignalAction.html).
3343 ///
3344 /// This signal has no default bindings.
3345 /// ## `string`
3346 /// the string to insert
3347 #[doc(alias = "insert-at-cursor")]
3348 fn connect_insert_at_cursor<F: Fn(&Self, &str) + 'static>(&self, f: F) -> SignalHandlerId {
3349 unsafe extern "C" fn insert_at_cursor_trampoline<
3350 P: IsA<TextView>,
3351 F: Fn(&P, &str) + 'static,
3352 >(
3353 this: *mut ffi::GtkTextView,
3354 string: *mut std::ffi::c_char,
3355 f: glib::ffi::gpointer,
3356 ) {
3357 unsafe {
3358 let f: &F = &*(f as *const F);
3359 f(
3360 TextView::from_glib_borrow(this).unsafe_cast_ref(),
3361 &glib::GString::from_glib_borrow(string),
3362 )
3363 }
3364 }
3365 unsafe {
3366 let f: Box_<F> = Box_::new(f);
3367 connect_raw(
3368 self.as_ptr() as *mut _,
3369 c"insert-at-cursor".as_ptr(),
3370 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
3371 insert_at_cursor_trampoline::<Self, F> as *const (),
3372 )),
3373 Box_::into_raw(f),
3374 )
3375 }
3376 }
3377
3378 fn emit_insert_at_cursor(&self, string: &str) {
3379 self.emit_by_name::<()>("insert-at-cursor", &[&string]);
3380 }
3381
3382 /// Gets emitted to present the Emoji chooser for the @text_view.
3383 ///
3384 /// The ::insert-emoji signal is a [keybinding signal](class.SignalAction.html).
3385 ///
3386 /// The default bindings for this signal are
3387 /// <kbd>Ctrl</kbd>+<kbd>.</kbd> and
3388 /// <kbd>Ctrl</kbd>+<kbd>;</kbd>
3389 #[doc(alias = "insert-emoji")]
3390 fn connect_insert_emoji<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
3391 unsafe extern "C" fn insert_emoji_trampoline<P: IsA<TextView>, F: Fn(&P) + 'static>(
3392 this: *mut ffi::GtkTextView,
3393 f: glib::ffi::gpointer,
3394 ) {
3395 unsafe {
3396 let f: &F = &*(f as *const F);
3397 f(TextView::from_glib_borrow(this).unsafe_cast_ref())
3398 }
3399 }
3400 unsafe {
3401 let f: Box_<F> = Box_::new(f);
3402 connect_raw(
3403 self.as_ptr() as *mut _,
3404 c"insert-emoji".as_ptr(),
3405 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
3406 insert_emoji_trampoline::<Self, F> as *const (),
3407 )),
3408 Box_::into_raw(f),
3409 )
3410 }
3411 }
3412
3413 fn emit_insert_emoji(&self) {
3414 self.emit_by_name::<()>("insert-emoji", &[]);
3415 }
3416
3417 /// Gets emitted when the user initiates a cursor movement.
3418 ///
3419 /// The ::move-cursor signal is a [keybinding signal](class.SignalAction.html).
3420 /// If the cursor is not visible in @text_view, this signal causes
3421 /// the viewport to be moved instead.
3422 ///
3423 /// Applications should not connect to it, but may emit it with
3424 /// g_signal_emit_by_name() if they need to control the cursor
3425 /// programmatically.
3426 ///
3427 ///
3428 /// The default bindings for this signal come in two variants,
3429 /// the variant with the <kbd>Shift</kbd> modifier extends the
3430 /// selection, the variant without it does not.
3431 /// There are too many key combinations to list them all here.
3432 ///
3433 /// - <kbd>←</kbd>, <kbd>→</kbd>, <kbd>↑</kbd>, <kbd>↓</kbd>
3434 /// move by individual characters/lines
3435 /// - <kbd>Ctrl</kbd>+<kbd>←</kbd>, etc. move by words/paragraphs
3436 /// - <kbd>Home</kbd> and <kbd>End</kbd> move to the ends of the buffer
3437 /// - <kbd>PgUp</kbd> and <kbd>PgDn</kbd> move vertically by pages
3438 /// - <kbd>Ctrl</kbd>+<kbd>PgUp</kbd> and <kbd>Ctrl</kbd>+<kbd>PgDn</kbd>
3439 /// move horizontally by pages
3440 /// ## `step`
3441 /// the granularity of the move, as a [`MovementStep`][crate::MovementStep]
3442 /// ## `count`
3443 /// the number of @step units to move
3444 /// ## `extend_selection`
3445 /// [`true`] if the move should extend the selection
3446 #[doc(alias = "move-cursor")]
3447 fn connect_move_cursor<F: Fn(&Self, MovementStep, i32, bool) + 'static>(
3448 &self,
3449 f: F,
3450 ) -> SignalHandlerId {
3451 unsafe extern "C" fn move_cursor_trampoline<
3452 P: IsA<TextView>,
3453 F: Fn(&P, MovementStep, i32, bool) + 'static,
3454 >(
3455 this: *mut ffi::GtkTextView,
3456 step: ffi::GtkMovementStep,
3457 count: std::ffi::c_int,
3458 extend_selection: glib::ffi::gboolean,
3459 f: glib::ffi::gpointer,
3460 ) {
3461 unsafe {
3462 let f: &F = &*(f as *const F);
3463 f(
3464 TextView::from_glib_borrow(this).unsafe_cast_ref(),
3465 from_glib(step),
3466 count,
3467 from_glib(extend_selection),
3468 )
3469 }
3470 }
3471 unsafe {
3472 let f: Box_<F> = Box_::new(f);
3473 connect_raw(
3474 self.as_ptr() as *mut _,
3475 c"move-cursor".as_ptr(),
3476 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
3477 move_cursor_trampoline::<Self, F> as *const (),
3478 )),
3479 Box_::into_raw(f),
3480 )
3481 }
3482 }
3483
3484 fn emit_move_cursor(&self, step: MovementStep, count: i32, extend_selection: bool) {
3485 self.emit_by_name::<()>("move-cursor", &[&step, &count, &extend_selection]);
3486 }
3487
3488 /// Gets emitted to move the viewport.
3489 ///
3490 /// The ::move-viewport signal is a [keybinding signal](class.SignalAction.html),
3491 /// which can be bound to key combinations to allow the user to move the viewport,
3492 /// i.e. change what part of the text view is visible in a containing scrolled
3493 /// window.
3494 ///
3495 /// There are no default bindings for this signal.
3496 /// ## `step`
3497 /// the granularity of the movement, as a [`ScrollStep`][crate::ScrollStep]
3498 /// ## `count`
3499 /// the number of @step units to move
3500 #[doc(alias = "move-viewport")]
3501 fn connect_move_viewport<F: Fn(&Self, ScrollStep, i32) + 'static>(
3502 &self,
3503 f: F,
3504 ) -> SignalHandlerId {
3505 unsafe extern "C" fn move_viewport_trampoline<
3506 P: IsA<TextView>,
3507 F: Fn(&P, ScrollStep, i32) + 'static,
3508 >(
3509 this: *mut ffi::GtkTextView,
3510 step: ffi::GtkScrollStep,
3511 count: std::ffi::c_int,
3512 f: glib::ffi::gpointer,
3513 ) {
3514 unsafe {
3515 let f: &F = &*(f as *const F);
3516 f(
3517 TextView::from_glib_borrow(this).unsafe_cast_ref(),
3518 from_glib(step),
3519 count,
3520 )
3521 }
3522 }
3523 unsafe {
3524 let f: Box_<F> = Box_::new(f);
3525 connect_raw(
3526 self.as_ptr() as *mut _,
3527 c"move-viewport".as_ptr(),
3528 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
3529 move_viewport_trampoline::<Self, F> as *const (),
3530 )),
3531 Box_::into_raw(f),
3532 )
3533 }
3534 }
3535
3536 fn emit_move_viewport(&self, step: ScrollStep, count: i32) {
3537 self.emit_by_name::<()>("move-viewport", &[&step, &count]);
3538 }
3539
3540 /// Gets emitted to paste the contents of the clipboard
3541 /// into the text view.
3542 ///
3543 /// The ::paste-clipboard signal is a [keybinding signal](class.SignalAction.html).
3544 ///
3545 /// The default bindings for this signal are
3546 /// <kbd>Ctrl</kbd>+<kbd>v</kbd> and
3547 /// <kbd>Shift</kbd>+<kbd>Insert</kbd>.
3548 #[doc(alias = "paste-clipboard")]
3549 fn connect_paste_clipboard<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
3550 unsafe extern "C" fn paste_clipboard_trampoline<P: IsA<TextView>, F: Fn(&P) + 'static>(
3551 this: *mut ffi::GtkTextView,
3552 f: glib::ffi::gpointer,
3553 ) {
3554 unsafe {
3555 let f: &F = &*(f as *const F);
3556 f(TextView::from_glib_borrow(this).unsafe_cast_ref())
3557 }
3558 }
3559 unsafe {
3560 let f: Box_<F> = Box_::new(f);
3561 connect_raw(
3562 self.as_ptr() as *mut _,
3563 c"paste-clipboard".as_ptr(),
3564 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
3565 paste_clipboard_trampoline::<Self, F> as *const (),
3566 )),
3567 Box_::into_raw(f),
3568 )
3569 }
3570 }
3571
3572 fn emit_paste_clipboard(&self) {
3573 self.emit_by_name::<()>("paste-clipboard", &[]);
3574 }
3575
3576 /// Emitted when preedit text of the active IM changes.
3577 ///
3578 /// If an input method is used, the typed text will not immediately
3579 /// be committed to the buffer. So if you are interested in the text,
3580 /// connect to this signal.
3581 ///
3582 /// This signal is only emitted if the text at the given position
3583 /// is actually editable.
3584 /// ## `preedit`
3585 /// the current preedit string
3586 #[doc(alias = "preedit-changed")]
3587 fn connect_preedit_changed<F: Fn(&Self, &str) + 'static>(&self, f: F) -> SignalHandlerId {
3588 unsafe extern "C" fn preedit_changed_trampoline<
3589 P: IsA<TextView>,
3590 F: Fn(&P, &str) + 'static,
3591 >(
3592 this: *mut ffi::GtkTextView,
3593 preedit: *mut std::ffi::c_char,
3594 f: glib::ffi::gpointer,
3595 ) {
3596 unsafe {
3597 let f: &F = &*(f as *const F);
3598 f(
3599 TextView::from_glib_borrow(this).unsafe_cast_ref(),
3600 &glib::GString::from_glib_borrow(preedit),
3601 )
3602 }
3603 }
3604 unsafe {
3605 let f: Box_<F> = Box_::new(f);
3606 connect_raw(
3607 self.as_ptr() as *mut _,
3608 c"preedit-changed".as_ptr(),
3609 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
3610 preedit_changed_trampoline::<Self, F> as *const (),
3611 )),
3612 Box_::into_raw(f),
3613 )
3614 }
3615 }
3616
3617 fn emit_preedit_changed(&self, preedit: &str) {
3618 self.emit_by_name::<()>("preedit-changed", &[&preedit]);
3619 }
3620
3621 /// Gets emitted to select or unselect the complete contents of the text view.
3622 ///
3623 /// The ::select-all signal is a [keybinding signal](class.SignalAction.html).
3624 ///
3625 /// The default bindings for this signal are
3626 /// <kbd>Ctrl</kbd>+<kbd>a</kbd> and
3627 /// <kbd>Ctrl</kbd>+<kbd>/</kbd> for selecting and
3628 /// <kbd>Shift</kbd>+<kbd>Ctrl</kbd>+<kbd>a</kbd> and
3629 /// <kbd>Ctrl</kbd>+<kbd>\</kbd> for unselecting.
3630 /// ## `select`
3631 /// [`true`] to select, [`false`] to unselect
3632 #[doc(alias = "select-all")]
3633 fn connect_select_all<F: Fn(&Self, bool) + 'static>(&self, f: F) -> SignalHandlerId {
3634 unsafe extern "C" fn select_all_trampoline<P: IsA<TextView>, F: Fn(&P, bool) + 'static>(
3635 this: *mut ffi::GtkTextView,
3636 select: glib::ffi::gboolean,
3637 f: glib::ffi::gpointer,
3638 ) {
3639 unsafe {
3640 let f: &F = &*(f as *const F);
3641 f(
3642 TextView::from_glib_borrow(this).unsafe_cast_ref(),
3643 from_glib(select),
3644 )
3645 }
3646 }
3647 unsafe {
3648 let f: Box_<F> = Box_::new(f);
3649 connect_raw(
3650 self.as_ptr() as *mut _,
3651 c"select-all".as_ptr(),
3652 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
3653 select_all_trampoline::<Self, F> as *const (),
3654 )),
3655 Box_::into_raw(f),
3656 )
3657 }
3658 }
3659
3660 fn emit_select_all(&self, select: bool) {
3661 self.emit_by_name::<()>("select-all", &[&select]);
3662 }
3663
3664 /// Gets emitted when the user initiates settings the "anchor" mark.
3665 ///
3666 /// The ::set-anchor signal is a [keybinding signal](class.SignalAction.html)
3667 /// which gets emitted when the user initiates setting the "anchor"
3668 /// mark. The "anchor" mark gets placed at the same position as the
3669 /// "insert" mark.
3670 ///
3671 /// This signal has no default bindings.
3672 #[doc(alias = "set-anchor")]
3673 fn connect_set_anchor<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
3674 unsafe extern "C" fn set_anchor_trampoline<P: IsA<TextView>, F: Fn(&P) + 'static>(
3675 this: *mut ffi::GtkTextView,
3676 f: glib::ffi::gpointer,
3677 ) {
3678 unsafe {
3679 let f: &F = &*(f as *const F);
3680 f(TextView::from_glib_borrow(this).unsafe_cast_ref())
3681 }
3682 }
3683 unsafe {
3684 let f: Box_<F> = Box_::new(f);
3685 connect_raw(
3686 self.as_ptr() as *mut _,
3687 c"set-anchor".as_ptr(),
3688 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
3689 set_anchor_trampoline::<Self, F> as *const (),
3690 )),
3691 Box_::into_raw(f),
3692 )
3693 }
3694 }
3695
3696 fn emit_set_anchor(&self) {
3697 self.emit_by_name::<()>("set-anchor", &[]);
3698 }
3699
3700 /// Gets emitted to toggle the `cursor-visible` property.
3701 ///
3702 /// The ::toggle-cursor-visible signal is a
3703 /// [keybinding signal](class.SignalAction.html).
3704 ///
3705 /// The default binding for this signal is <kbd>F7</kbd>.
3706 #[doc(alias = "toggle-cursor-visible")]
3707 fn connect_toggle_cursor_visible<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
3708 unsafe extern "C" fn toggle_cursor_visible_trampoline<
3709 P: IsA<TextView>,
3710 F: Fn(&P) + 'static,
3711 >(
3712 this: *mut ffi::GtkTextView,
3713 f: glib::ffi::gpointer,
3714 ) {
3715 unsafe {
3716 let f: &F = &*(f as *const F);
3717 f(TextView::from_glib_borrow(this).unsafe_cast_ref())
3718 }
3719 }
3720 unsafe {
3721 let f: Box_<F> = Box_::new(f);
3722 connect_raw(
3723 self.as_ptr() as *mut _,
3724 c"toggle-cursor-visible".as_ptr(),
3725 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
3726 toggle_cursor_visible_trampoline::<Self, F> as *const (),
3727 )),
3728 Box_::into_raw(f),
3729 )
3730 }
3731 }
3732
3733 fn emit_toggle_cursor_visible(&self) {
3734 self.emit_by_name::<()>("toggle-cursor-visible", &[]);
3735 }
3736
3737 /// Gets emitted to toggle the overwrite mode of the text view.
3738 ///
3739 /// The ::toggle-overwrite signal is a [keybinding signal](class.SignalAction.html).
3740 ///
3741 /// The default binding for this signal is <kbd>Insert</kbd>.
3742 #[doc(alias = "toggle-overwrite")]
3743 fn connect_toggle_overwrite<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
3744 unsafe extern "C" fn toggle_overwrite_trampoline<P: IsA<TextView>, F: Fn(&P) + 'static>(
3745 this: *mut ffi::GtkTextView,
3746 f: glib::ffi::gpointer,
3747 ) {
3748 unsafe {
3749 let f: &F = &*(f as *const F);
3750 f(TextView::from_glib_borrow(this).unsafe_cast_ref())
3751 }
3752 }
3753 unsafe {
3754 let f: Box_<F> = Box_::new(f);
3755 connect_raw(
3756 self.as_ptr() as *mut _,
3757 c"toggle-overwrite".as_ptr(),
3758 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
3759 toggle_overwrite_trampoline::<Self, F> as *const (),
3760 )),
3761 Box_::into_raw(f),
3762 )
3763 }
3764 }
3765
3766 fn emit_toggle_overwrite(&self) {
3767 self.emit_by_name::<()>("toggle-overwrite", &[]);
3768 }
3769
3770 #[doc(alias = "accepts-tab")]
3771 fn connect_accepts_tab_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
3772 unsafe extern "C" fn notify_accepts_tab_trampoline<
3773 P: IsA<TextView>,
3774 F: Fn(&P) + 'static,
3775 >(
3776 this: *mut ffi::GtkTextView,
3777 _param_spec: glib::ffi::gpointer,
3778 f: glib::ffi::gpointer,
3779 ) {
3780 unsafe {
3781 let f: &F = &*(f as *const F);
3782 f(TextView::from_glib_borrow(this).unsafe_cast_ref())
3783 }
3784 }
3785 unsafe {
3786 let f: Box_<F> = Box_::new(f);
3787 connect_raw(
3788 self.as_ptr() as *mut _,
3789 c"notify::accepts-tab".as_ptr(),
3790 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
3791 notify_accepts_tab_trampoline::<Self, F> as *const (),
3792 )),
3793 Box_::into_raw(f),
3794 )
3795 }
3796 }
3797
3798 #[doc(alias = "bottom-margin")]
3799 fn connect_bottom_margin_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
3800 unsafe extern "C" fn notify_bottom_margin_trampoline<
3801 P: IsA<TextView>,
3802 F: Fn(&P) + 'static,
3803 >(
3804 this: *mut ffi::GtkTextView,
3805 _param_spec: glib::ffi::gpointer,
3806 f: glib::ffi::gpointer,
3807 ) {
3808 unsafe {
3809 let f: &F = &*(f as *const F);
3810 f(TextView::from_glib_borrow(this).unsafe_cast_ref())
3811 }
3812 }
3813 unsafe {
3814 let f: Box_<F> = Box_::new(f);
3815 connect_raw(
3816 self.as_ptr() as *mut _,
3817 c"notify::bottom-margin".as_ptr(),
3818 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
3819 notify_bottom_margin_trampoline::<Self, F> as *const (),
3820 )),
3821 Box_::into_raw(f),
3822 )
3823 }
3824 }
3825
3826 #[doc(alias = "buffer")]
3827 fn connect_buffer_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
3828 unsafe extern "C" fn notify_buffer_trampoline<P: IsA<TextView>, F: Fn(&P) + 'static>(
3829 this: *mut ffi::GtkTextView,
3830 _param_spec: glib::ffi::gpointer,
3831 f: glib::ffi::gpointer,
3832 ) {
3833 unsafe {
3834 let f: &F = &*(f as *const F);
3835 f(TextView::from_glib_borrow(this).unsafe_cast_ref())
3836 }
3837 }
3838 unsafe {
3839 let f: Box_<F> = Box_::new(f);
3840 connect_raw(
3841 self.as_ptr() as *mut _,
3842 c"notify::buffer".as_ptr(),
3843 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
3844 notify_buffer_trampoline::<Self, F> as *const (),
3845 )),
3846 Box_::into_raw(f),
3847 )
3848 }
3849 }
3850
3851 #[doc(alias = "cursor-visible")]
3852 fn connect_cursor_visible_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
3853 unsafe extern "C" fn notify_cursor_visible_trampoline<
3854 P: IsA<TextView>,
3855 F: Fn(&P) + 'static,
3856 >(
3857 this: *mut ffi::GtkTextView,
3858 _param_spec: glib::ffi::gpointer,
3859 f: glib::ffi::gpointer,
3860 ) {
3861 unsafe {
3862 let f: &F = &*(f as *const F);
3863 f(TextView::from_glib_borrow(this).unsafe_cast_ref())
3864 }
3865 }
3866 unsafe {
3867 let f: Box_<F> = Box_::new(f);
3868 connect_raw(
3869 self.as_ptr() as *mut _,
3870 c"notify::cursor-visible".as_ptr(),
3871 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
3872 notify_cursor_visible_trampoline::<Self, F> as *const (),
3873 )),
3874 Box_::into_raw(f),
3875 )
3876 }
3877 }
3878
3879 #[doc(alias = "editable")]
3880 fn connect_editable_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
3881 unsafe extern "C" fn notify_editable_trampoline<P: IsA<TextView>, F: Fn(&P) + 'static>(
3882 this: *mut ffi::GtkTextView,
3883 _param_spec: glib::ffi::gpointer,
3884 f: glib::ffi::gpointer,
3885 ) {
3886 unsafe {
3887 let f: &F = &*(f as *const F);
3888 f(TextView::from_glib_borrow(this).unsafe_cast_ref())
3889 }
3890 }
3891 unsafe {
3892 let f: Box_<F> = Box_::new(f);
3893 connect_raw(
3894 self.as_ptr() as *mut _,
3895 c"notify::editable".as_ptr(),
3896 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
3897 notify_editable_trampoline::<Self, F> as *const (),
3898 )),
3899 Box_::into_raw(f),
3900 )
3901 }
3902 }
3903
3904 #[doc(alias = "extra-menu")]
3905 fn connect_extra_menu_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
3906 unsafe extern "C" fn notify_extra_menu_trampoline<P: IsA<TextView>, F: Fn(&P) + 'static>(
3907 this: *mut ffi::GtkTextView,
3908 _param_spec: glib::ffi::gpointer,
3909 f: glib::ffi::gpointer,
3910 ) {
3911 unsafe {
3912 let f: &F = &*(f as *const F);
3913 f(TextView::from_glib_borrow(this).unsafe_cast_ref())
3914 }
3915 }
3916 unsafe {
3917 let f: Box_<F> = Box_::new(f);
3918 connect_raw(
3919 self.as_ptr() as *mut _,
3920 c"notify::extra-menu".as_ptr(),
3921 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
3922 notify_extra_menu_trampoline::<Self, F> as *const (),
3923 )),
3924 Box_::into_raw(f),
3925 )
3926 }
3927 }
3928
3929 #[doc(alias = "im-module")]
3930 fn connect_im_module_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
3931 unsafe extern "C" fn notify_im_module_trampoline<P: IsA<TextView>, F: Fn(&P) + 'static>(
3932 this: *mut ffi::GtkTextView,
3933 _param_spec: glib::ffi::gpointer,
3934 f: glib::ffi::gpointer,
3935 ) {
3936 unsafe {
3937 let f: &F = &*(f as *const F);
3938 f(TextView::from_glib_borrow(this).unsafe_cast_ref())
3939 }
3940 }
3941 unsafe {
3942 let f: Box_<F> = Box_::new(f);
3943 connect_raw(
3944 self.as_ptr() as *mut _,
3945 c"notify::im-module".as_ptr(),
3946 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
3947 notify_im_module_trampoline::<Self, F> as *const (),
3948 )),
3949 Box_::into_raw(f),
3950 )
3951 }
3952 }
3953
3954 #[doc(alias = "indent")]
3955 fn connect_indent_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
3956 unsafe extern "C" fn notify_indent_trampoline<P: IsA<TextView>, F: Fn(&P) + 'static>(
3957 this: *mut ffi::GtkTextView,
3958 _param_spec: glib::ffi::gpointer,
3959 f: glib::ffi::gpointer,
3960 ) {
3961 unsafe {
3962 let f: &F = &*(f as *const F);
3963 f(TextView::from_glib_borrow(this).unsafe_cast_ref())
3964 }
3965 }
3966 unsafe {
3967 let f: Box_<F> = Box_::new(f);
3968 connect_raw(
3969 self.as_ptr() as *mut _,
3970 c"notify::indent".as_ptr(),
3971 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
3972 notify_indent_trampoline::<Self, F> as *const (),
3973 )),
3974 Box_::into_raw(f),
3975 )
3976 }
3977 }
3978
3979 #[doc(alias = "input-hints")]
3980 fn connect_input_hints_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
3981 unsafe extern "C" fn notify_input_hints_trampoline<
3982 P: IsA<TextView>,
3983 F: Fn(&P) + 'static,
3984 >(
3985 this: *mut ffi::GtkTextView,
3986 _param_spec: glib::ffi::gpointer,
3987 f: glib::ffi::gpointer,
3988 ) {
3989 unsafe {
3990 let f: &F = &*(f as *const F);
3991 f(TextView::from_glib_borrow(this).unsafe_cast_ref())
3992 }
3993 }
3994 unsafe {
3995 let f: Box_<F> = Box_::new(f);
3996 connect_raw(
3997 self.as_ptr() as *mut _,
3998 c"notify::input-hints".as_ptr(),
3999 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
4000 notify_input_hints_trampoline::<Self, F> as *const (),
4001 )),
4002 Box_::into_raw(f),
4003 )
4004 }
4005 }
4006
4007 #[doc(alias = "input-purpose")]
4008 fn connect_input_purpose_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
4009 unsafe extern "C" fn notify_input_purpose_trampoline<
4010 P: IsA<TextView>,
4011 F: Fn(&P) + 'static,
4012 >(
4013 this: *mut ffi::GtkTextView,
4014 _param_spec: glib::ffi::gpointer,
4015 f: glib::ffi::gpointer,
4016 ) {
4017 unsafe {
4018 let f: &F = &*(f as *const F);
4019 f(TextView::from_glib_borrow(this).unsafe_cast_ref())
4020 }
4021 }
4022 unsafe {
4023 let f: Box_<F> = Box_::new(f);
4024 connect_raw(
4025 self.as_ptr() as *mut _,
4026 c"notify::input-purpose".as_ptr(),
4027 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
4028 notify_input_purpose_trampoline::<Self, F> as *const (),
4029 )),
4030 Box_::into_raw(f),
4031 )
4032 }
4033 }
4034
4035 #[doc(alias = "justification")]
4036 fn connect_justification_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
4037 unsafe extern "C" fn notify_justification_trampoline<
4038 P: IsA<TextView>,
4039 F: Fn(&P) + 'static,
4040 >(
4041 this: *mut ffi::GtkTextView,
4042 _param_spec: glib::ffi::gpointer,
4043 f: glib::ffi::gpointer,
4044 ) {
4045 unsafe {
4046 let f: &F = &*(f as *const F);
4047 f(TextView::from_glib_borrow(this).unsafe_cast_ref())
4048 }
4049 }
4050 unsafe {
4051 let f: Box_<F> = Box_::new(f);
4052 connect_raw(
4053 self.as_ptr() as *mut _,
4054 c"notify::justification".as_ptr(),
4055 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
4056 notify_justification_trampoline::<Self, F> as *const (),
4057 )),
4058 Box_::into_raw(f),
4059 )
4060 }
4061 }
4062
4063 #[doc(alias = "left-margin")]
4064 fn connect_left_margin_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
4065 unsafe extern "C" fn notify_left_margin_trampoline<
4066 P: IsA<TextView>,
4067 F: Fn(&P) + 'static,
4068 >(
4069 this: *mut ffi::GtkTextView,
4070 _param_spec: glib::ffi::gpointer,
4071 f: glib::ffi::gpointer,
4072 ) {
4073 unsafe {
4074 let f: &F = &*(f as *const F);
4075 f(TextView::from_glib_borrow(this).unsafe_cast_ref())
4076 }
4077 }
4078 unsafe {
4079 let f: Box_<F> = Box_::new(f);
4080 connect_raw(
4081 self.as_ptr() as *mut _,
4082 c"notify::left-margin".as_ptr(),
4083 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
4084 notify_left_margin_trampoline::<Self, F> as *const (),
4085 )),
4086 Box_::into_raw(f),
4087 )
4088 }
4089 }
4090
4091 #[doc(alias = "monospace")]
4092 fn connect_monospace_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
4093 unsafe extern "C" fn notify_monospace_trampoline<P: IsA<TextView>, F: Fn(&P) + 'static>(
4094 this: *mut ffi::GtkTextView,
4095 _param_spec: glib::ffi::gpointer,
4096 f: glib::ffi::gpointer,
4097 ) {
4098 unsafe {
4099 let f: &F = &*(f as *const F);
4100 f(TextView::from_glib_borrow(this).unsafe_cast_ref())
4101 }
4102 }
4103 unsafe {
4104 let f: Box_<F> = Box_::new(f);
4105 connect_raw(
4106 self.as_ptr() as *mut _,
4107 c"notify::monospace".as_ptr(),
4108 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
4109 notify_monospace_trampoline::<Self, F> as *const (),
4110 )),
4111 Box_::into_raw(f),
4112 )
4113 }
4114 }
4115
4116 #[doc(alias = "overwrite")]
4117 fn connect_overwrite_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
4118 unsafe extern "C" fn notify_overwrite_trampoline<P: IsA<TextView>, F: Fn(&P) + 'static>(
4119 this: *mut ffi::GtkTextView,
4120 _param_spec: glib::ffi::gpointer,
4121 f: glib::ffi::gpointer,
4122 ) {
4123 unsafe {
4124 let f: &F = &*(f as *const F);
4125 f(TextView::from_glib_borrow(this).unsafe_cast_ref())
4126 }
4127 }
4128 unsafe {
4129 let f: Box_<F> = Box_::new(f);
4130 connect_raw(
4131 self.as_ptr() as *mut _,
4132 c"notify::overwrite".as_ptr(),
4133 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
4134 notify_overwrite_trampoline::<Self, F> as *const (),
4135 )),
4136 Box_::into_raw(f),
4137 )
4138 }
4139 }
4140
4141 #[doc(alias = "pixels-above-lines")]
4142 fn connect_pixels_above_lines_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
4143 unsafe extern "C" fn notify_pixels_above_lines_trampoline<
4144 P: IsA<TextView>,
4145 F: Fn(&P) + 'static,
4146 >(
4147 this: *mut ffi::GtkTextView,
4148 _param_spec: glib::ffi::gpointer,
4149 f: glib::ffi::gpointer,
4150 ) {
4151 unsafe {
4152 let f: &F = &*(f as *const F);
4153 f(TextView::from_glib_borrow(this).unsafe_cast_ref())
4154 }
4155 }
4156 unsafe {
4157 let f: Box_<F> = Box_::new(f);
4158 connect_raw(
4159 self.as_ptr() as *mut _,
4160 c"notify::pixels-above-lines".as_ptr(),
4161 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
4162 notify_pixels_above_lines_trampoline::<Self, F> as *const (),
4163 )),
4164 Box_::into_raw(f),
4165 )
4166 }
4167 }
4168
4169 #[doc(alias = "pixels-below-lines")]
4170 fn connect_pixels_below_lines_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
4171 unsafe extern "C" fn notify_pixels_below_lines_trampoline<
4172 P: IsA<TextView>,
4173 F: Fn(&P) + 'static,
4174 >(
4175 this: *mut ffi::GtkTextView,
4176 _param_spec: glib::ffi::gpointer,
4177 f: glib::ffi::gpointer,
4178 ) {
4179 unsafe {
4180 let f: &F = &*(f as *const F);
4181 f(TextView::from_glib_borrow(this).unsafe_cast_ref())
4182 }
4183 }
4184 unsafe {
4185 let f: Box_<F> = Box_::new(f);
4186 connect_raw(
4187 self.as_ptr() as *mut _,
4188 c"notify::pixels-below-lines".as_ptr(),
4189 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
4190 notify_pixels_below_lines_trampoline::<Self, F> as *const (),
4191 )),
4192 Box_::into_raw(f),
4193 )
4194 }
4195 }
4196
4197 #[doc(alias = "pixels-inside-wrap")]
4198 fn connect_pixels_inside_wrap_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
4199 unsafe extern "C" fn notify_pixels_inside_wrap_trampoline<
4200 P: IsA<TextView>,
4201 F: Fn(&P) + 'static,
4202 >(
4203 this: *mut ffi::GtkTextView,
4204 _param_spec: glib::ffi::gpointer,
4205 f: glib::ffi::gpointer,
4206 ) {
4207 unsafe {
4208 let f: &F = &*(f as *const F);
4209 f(TextView::from_glib_borrow(this).unsafe_cast_ref())
4210 }
4211 }
4212 unsafe {
4213 let f: Box_<F> = Box_::new(f);
4214 connect_raw(
4215 self.as_ptr() as *mut _,
4216 c"notify::pixels-inside-wrap".as_ptr(),
4217 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
4218 notify_pixels_inside_wrap_trampoline::<Self, F> as *const (),
4219 )),
4220 Box_::into_raw(f),
4221 )
4222 }
4223 }
4224
4225 #[doc(alias = "right-margin")]
4226 fn connect_right_margin_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
4227 unsafe extern "C" fn notify_right_margin_trampoline<
4228 P: IsA<TextView>,
4229 F: Fn(&P) + 'static,
4230 >(
4231 this: *mut ffi::GtkTextView,
4232 _param_spec: glib::ffi::gpointer,
4233 f: glib::ffi::gpointer,
4234 ) {
4235 unsafe {
4236 let f: &F = &*(f as *const F);
4237 f(TextView::from_glib_borrow(this).unsafe_cast_ref())
4238 }
4239 }
4240 unsafe {
4241 let f: Box_<F> = Box_::new(f);
4242 connect_raw(
4243 self.as_ptr() as *mut _,
4244 c"notify::right-margin".as_ptr(),
4245 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
4246 notify_right_margin_trampoline::<Self, F> as *const (),
4247 )),
4248 Box_::into_raw(f),
4249 )
4250 }
4251 }
4252
4253 #[doc(alias = "tabs")]
4254 fn connect_tabs_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
4255 unsafe extern "C" fn notify_tabs_trampoline<P: IsA<TextView>, F: Fn(&P) + 'static>(
4256 this: *mut ffi::GtkTextView,
4257 _param_spec: glib::ffi::gpointer,
4258 f: glib::ffi::gpointer,
4259 ) {
4260 unsafe {
4261 let f: &F = &*(f as *const F);
4262 f(TextView::from_glib_borrow(this).unsafe_cast_ref())
4263 }
4264 }
4265 unsafe {
4266 let f: Box_<F> = Box_::new(f);
4267 connect_raw(
4268 self.as_ptr() as *mut _,
4269 c"notify::tabs".as_ptr(),
4270 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
4271 notify_tabs_trampoline::<Self, F> as *const (),
4272 )),
4273 Box_::into_raw(f),
4274 )
4275 }
4276 }
4277
4278 #[doc(alias = "top-margin")]
4279 fn connect_top_margin_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
4280 unsafe extern "C" fn notify_top_margin_trampoline<P: IsA<TextView>, F: Fn(&P) + 'static>(
4281 this: *mut ffi::GtkTextView,
4282 _param_spec: glib::ffi::gpointer,
4283 f: glib::ffi::gpointer,
4284 ) {
4285 unsafe {
4286 let f: &F = &*(f as *const F);
4287 f(TextView::from_glib_borrow(this).unsafe_cast_ref())
4288 }
4289 }
4290 unsafe {
4291 let f: Box_<F> = Box_::new(f);
4292 connect_raw(
4293 self.as_ptr() as *mut _,
4294 c"notify::top-margin".as_ptr(),
4295 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
4296 notify_top_margin_trampoline::<Self, F> as *const (),
4297 )),
4298 Box_::into_raw(f),
4299 )
4300 }
4301 }
4302
4303 #[doc(alias = "wrap-mode")]
4304 fn connect_wrap_mode_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
4305 unsafe extern "C" fn notify_wrap_mode_trampoline<P: IsA<TextView>, F: Fn(&P) + 'static>(
4306 this: *mut ffi::GtkTextView,
4307 _param_spec: glib::ffi::gpointer,
4308 f: glib::ffi::gpointer,
4309 ) {
4310 unsafe {
4311 let f: &F = &*(f as *const F);
4312 f(TextView::from_glib_borrow(this).unsafe_cast_ref())
4313 }
4314 }
4315 unsafe {
4316 let f: Box_<F> = Box_::new(f);
4317 connect_raw(
4318 self.as_ptr() as *mut _,
4319 c"notify::wrap-mode".as_ptr(),
4320 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
4321 notify_wrap_mode_trampoline::<Self, F> as *const (),
4322 )),
4323 Box_::into_raw(f),
4324 )
4325 }
4326 }
4327}
4328
4329impl<O: IsA<TextView>> TextViewExt for O {}