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