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 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, ffi,
13};
14use glib::{
15 object::ObjectType as _,
16 prelude::*,
17 signal::{SignalHandlerId, connect_raw},
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 { Some(iter) } else { None }
1994 }
1995 }
1996
1997 /// Retrieves the iterator pointing to the character at buffer
1998 /// coordinates @x and @y.
1999 ///
2000 /// Buffer coordinates are coordinates for the entire buffer, not just
2001 /// the currently-displayed portion. If you have coordinates from an event,
2002 /// you have to convert those to buffer coordinates with
2003 /// [`window_to_buffer_coords()`][Self::window_to_buffer_coords()].
2004 ///
2005 /// Note that this is different from [`iter_at_location()`][Self::iter_at_location()],
2006 /// which returns cursor locations, i.e. positions between characters.
2007 /// ## `x`
2008 /// x position, in buffer coordinates
2009 /// ## `y`
2010 /// y position, in buffer coordinates
2011 ///
2012 /// # Returns
2013 ///
2014 /// [`true`] if the position is over text
2015 ///
2016 /// ## `iter`
2017 /// a [`TextIter`][crate::TextIter]
2018 ///
2019 /// ## `trailing`
2020 /// if non-[`None`], location to store
2021 /// an integer indicating where in the grapheme the user clicked.
2022 /// It will either be zero, or the number of characters in the grapheme.
2023 /// 0 represents the trailing edge of the grapheme.
2024 #[doc(alias = "gtk_text_view_get_iter_at_position")]
2025 #[doc(alias = "get_iter_at_position")]
2026 fn iter_at_position(&self, x: i32, y: i32) -> Option<(TextIter, i32)> {
2027 unsafe {
2028 let mut iter = TextIter::uninitialized();
2029 let mut trailing = std::mem::MaybeUninit::uninit();
2030 let ret = from_glib(ffi::gtk_text_view_get_iter_at_position(
2031 self.as_ref().to_glib_none().0,
2032 iter.to_glib_none_mut().0,
2033 trailing.as_mut_ptr(),
2034 x,
2035 y,
2036 ));
2037 if ret {
2038 Some((iter, trailing.assume_init()))
2039 } else {
2040 None
2041 }
2042 }
2043 }
2044
2045 /// Gets a rectangle which roughly contains the character at @iter.
2046 ///
2047 /// The rectangle position is in buffer coordinates; use
2048 /// [`buffer_to_window_coords()`][Self::buffer_to_window_coords()] to convert these
2049 /// coordinates to coordinates for one of the windows in the text view.
2050 /// ## `iter`
2051 /// a [`TextIter`][crate::TextIter]
2052 ///
2053 /// # Returns
2054 ///
2055 ///
2056 /// ## `location`
2057 /// bounds of the character at @iter
2058 #[doc(alias = "gtk_text_view_get_iter_location")]
2059 #[doc(alias = "get_iter_location")]
2060 fn iter_location(&self, iter: &TextIter) -> gdk::Rectangle {
2061 unsafe {
2062 let mut location = gdk::Rectangle::uninitialized();
2063 ffi::gtk_text_view_get_iter_location(
2064 self.as_ref().to_glib_none().0,
2065 iter.to_glib_none().0,
2066 location.to_glib_none_mut().0,
2067 );
2068 location
2069 }
2070 }
2071
2072 /// Gets the default justification of paragraphs in @self.
2073 ///
2074 /// Tags in the buffer may override the default.
2075 ///
2076 /// # Returns
2077 ///
2078 /// default justification
2079 #[doc(alias = "gtk_text_view_get_justification")]
2080 #[doc(alias = "get_justification")]
2081 fn justification(&self) -> Justification {
2082 unsafe {
2083 from_glib(ffi::gtk_text_view_get_justification(
2084 self.as_ref().to_glib_none().0,
2085 ))
2086 }
2087 }
2088
2089 /// Gets the default left margin size of paragraphs in the @self.
2090 ///
2091 /// Tags in the buffer may override the default.
2092 ///
2093 /// # Returns
2094 ///
2095 /// left margin in pixels
2096 #[doc(alias = "gtk_text_view_get_left_margin")]
2097 #[doc(alias = "get_left_margin")]
2098 #[doc(alias = "left-margin")]
2099 fn left_margin(&self) -> i32 {
2100 unsafe { ffi::gtk_text_view_get_left_margin(self.as_ref().to_glib_none().0) }
2101 }
2102
2103 /// Gets the [`TextIter`][crate::TextIter] at the start of the line containing
2104 /// the coordinate @y.
2105 ///
2106 /// @y is in buffer coordinates, convert from window coordinates with
2107 /// [`window_to_buffer_coords()`][Self::window_to_buffer_coords()]. If non-[`None`],
2108 /// @line_top will be filled with the coordinate of the top edge
2109 /// of the line.
2110 /// ## `y`
2111 /// a y coordinate
2112 ///
2113 /// # Returns
2114 ///
2115 ///
2116 /// ## `target_iter`
2117 /// a [`TextIter`][crate::TextIter]
2118 ///
2119 /// ## `line_top`
2120 /// return location for top coordinate of the line
2121 #[doc(alias = "gtk_text_view_get_line_at_y")]
2122 #[doc(alias = "get_line_at_y")]
2123 fn line_at_y(&self, y: i32) -> (TextIter, i32) {
2124 unsafe {
2125 let mut target_iter = TextIter::uninitialized();
2126 let mut line_top = std::mem::MaybeUninit::uninit();
2127 ffi::gtk_text_view_get_line_at_y(
2128 self.as_ref().to_glib_none().0,
2129 target_iter.to_glib_none_mut().0,
2130 y,
2131 line_top.as_mut_ptr(),
2132 );
2133 (target_iter, line_top.assume_init())
2134 }
2135 }
2136
2137 /// Gets the y coordinate of the top of the line containing @iter,
2138 /// and the height of the line.
2139 ///
2140 /// The coordinate is a buffer coordinate; convert to window
2141 /// coordinates with [`buffer_to_window_coords()`][Self::buffer_to_window_coords()].
2142 /// ## `iter`
2143 /// a [`TextIter`][crate::TextIter]
2144 ///
2145 /// # Returns
2146 ///
2147 ///
2148 /// ## `y`
2149 /// return location for a y coordinate
2150 ///
2151 /// ## `height`
2152 /// return location for a height
2153 #[doc(alias = "gtk_text_view_get_line_yrange")]
2154 #[doc(alias = "get_line_yrange")]
2155 fn line_yrange(&self, iter: &TextIter) -> (i32, i32) {
2156 unsafe {
2157 let mut y = std::mem::MaybeUninit::uninit();
2158 let mut height = std::mem::MaybeUninit::uninit();
2159 ffi::gtk_text_view_get_line_yrange(
2160 self.as_ref().to_glib_none().0,
2161 iter.to_glib_none().0,
2162 y.as_mut_ptr(),
2163 height.as_mut_ptr(),
2164 );
2165 (y.assume_init(), height.assume_init())
2166 }
2167 }
2168
2169 /// Gets the [`pango::Context`][crate::pango::Context] that is used for rendering LTR directed
2170 /// text layouts.
2171 ///
2172 /// The context may be replaced when CSS changes occur.
2173 ///
2174 /// # Returns
2175 ///
2176 /// a [`pango::Context`][crate::pango::Context]
2177 #[cfg(feature = "v4_4")]
2178 #[cfg_attr(docsrs, doc(cfg(feature = "v4_4")))]
2179 #[doc(alias = "gtk_text_view_get_ltr_context")]
2180 #[doc(alias = "get_ltr_context")]
2181 fn ltr_context(&self) -> pango::Context {
2182 unsafe {
2183 from_glib_none(ffi::gtk_text_view_get_ltr_context(
2184 self.as_ref().to_glib_none().0,
2185 ))
2186 }
2187 }
2188
2189 /// Gets whether the [`TextView`][crate::TextView] uses monospace styling.
2190 ///
2191 /// # Returns
2192 ///
2193 /// [`true`] if monospace fonts are desired
2194 #[doc(alias = "gtk_text_view_get_monospace")]
2195 #[doc(alias = "get_monospace")]
2196 #[doc(alias = "monospace")]
2197 fn is_monospace(&self) -> bool {
2198 unsafe {
2199 from_glib(ffi::gtk_text_view_get_monospace(
2200 self.as_ref().to_glib_none().0,
2201 ))
2202 }
2203 }
2204
2205 /// Returns whether the [`TextView`][crate::TextView] is in overwrite mode or not.
2206 ///
2207 /// # Returns
2208 ///
2209 /// whether @self is in overwrite mode or not.
2210 #[doc(alias = "gtk_text_view_get_overwrite")]
2211 #[doc(alias = "get_overwrite")]
2212 #[doc(alias = "overwrite")]
2213 fn overwrites(&self) -> bool {
2214 unsafe {
2215 from_glib(ffi::gtk_text_view_get_overwrite(
2216 self.as_ref().to_glib_none().0,
2217 ))
2218 }
2219 }
2220
2221 /// Gets the default number of pixels to put above paragraphs.
2222 ///
2223 /// Adding this function with [`pixels_below_lines()`][Self::pixels_below_lines()]
2224 /// is equal to the line space between each paragraph.
2225 ///
2226 /// # Returns
2227 ///
2228 /// default number of pixels above paragraphs
2229 #[doc(alias = "gtk_text_view_get_pixels_above_lines")]
2230 #[doc(alias = "get_pixels_above_lines")]
2231 #[doc(alias = "pixels-above-lines")]
2232 fn pixels_above_lines(&self) -> i32 {
2233 unsafe { ffi::gtk_text_view_get_pixels_above_lines(self.as_ref().to_glib_none().0) }
2234 }
2235
2236 /// Gets the default number of pixels to put below paragraphs.
2237 ///
2238 /// The line space is the sum of the value returned by this function and
2239 /// the value returned by [`pixels_above_lines()`][Self::pixels_above_lines()].
2240 ///
2241 /// # Returns
2242 ///
2243 /// default number of blank pixels below paragraphs
2244 #[doc(alias = "gtk_text_view_get_pixels_below_lines")]
2245 #[doc(alias = "get_pixels_below_lines")]
2246 #[doc(alias = "pixels-below-lines")]
2247 fn pixels_below_lines(&self) -> i32 {
2248 unsafe { ffi::gtk_text_view_get_pixels_below_lines(self.as_ref().to_glib_none().0) }
2249 }
2250
2251 /// Gets the default number of pixels to put between wrapped lines
2252 /// inside a paragraph.
2253 ///
2254 /// # Returns
2255 ///
2256 /// default number of pixels of blank space between wrapped lines
2257 #[doc(alias = "gtk_text_view_get_pixels_inside_wrap")]
2258 #[doc(alias = "get_pixels_inside_wrap")]
2259 #[doc(alias = "pixels-inside-wrap")]
2260 fn pixels_inside_wrap(&self) -> i32 {
2261 unsafe { ffi::gtk_text_view_get_pixels_inside_wrap(self.as_ref().to_glib_none().0) }
2262 }
2263
2264 /// Gets the default right margin for text in @self.
2265 ///
2266 /// Tags in the buffer may override the default.
2267 ///
2268 /// # Returns
2269 ///
2270 /// right margin in pixels
2271 #[doc(alias = "gtk_text_view_get_right_margin")]
2272 #[doc(alias = "get_right_margin")]
2273 #[doc(alias = "right-margin")]
2274 fn right_margin(&self) -> i32 {
2275 unsafe { ffi::gtk_text_view_get_right_margin(self.as_ref().to_glib_none().0) }
2276 }
2277
2278 /// Gets the [`pango::Context`][crate::pango::Context] that is used for rendering RTL directed
2279 /// text layouts.
2280 ///
2281 /// The context may be replaced when CSS changes occur.
2282 ///
2283 /// # Returns
2284 ///
2285 /// a [`pango::Context`][crate::pango::Context]
2286 #[cfg(feature = "v4_4")]
2287 #[cfg_attr(docsrs, doc(cfg(feature = "v4_4")))]
2288 #[doc(alias = "gtk_text_view_get_rtl_context")]
2289 #[doc(alias = "get_rtl_context")]
2290 fn rtl_context(&self) -> pango::Context {
2291 unsafe {
2292 from_glib_none(ffi::gtk_text_view_get_rtl_context(
2293 self.as_ref().to_glib_none().0,
2294 ))
2295 }
2296 }
2297
2298 /// Gets the default tabs for @self.
2299 ///
2300 /// Tags in the buffer may override the defaults. The returned array
2301 /// will be [`None`] if “standard” (8-space) tabs are used. Free the
2302 /// return value with `Pango::TabArray::free()`.
2303 ///
2304 /// # Returns
2305 ///
2306 /// copy of default tab array,
2307 /// or [`None`] if standard tabs are used; must be freed with
2308 /// `Pango::TabArray::free()`.
2309 #[doc(alias = "gtk_text_view_get_tabs")]
2310 #[doc(alias = "get_tabs")]
2311 fn tabs(&self) -> Option<pango::TabArray> {
2312 unsafe { from_glib_full(ffi::gtk_text_view_get_tabs(self.as_ref().to_glib_none().0)) }
2313 }
2314
2315 /// Gets the top margin for text in the @self.
2316 ///
2317 /// # Returns
2318 ///
2319 /// top margin in pixels
2320 #[doc(alias = "gtk_text_view_get_top_margin")]
2321 #[doc(alias = "get_top_margin")]
2322 #[doc(alias = "top-margin")]
2323 fn top_margin(&self) -> i32 {
2324 unsafe { ffi::gtk_text_view_get_top_margin(self.as_ref().to_glib_none().0) }
2325 }
2326
2327 /// Gets the X,Y offset in buffer coordinates of the top-left corner of
2328 /// the textview's text contents.
2329 ///
2330 /// This allows for more-precise positioning than what is provided by
2331 /// [`visible_rect()`][Self::visible_rect()] as you can discover what
2332 /// device pixel is being quantized for text positioning.
2333 ///
2334 /// You might want this when making ulterior widgets align with quantized
2335 /// device pixels of the textview contents such as line numbers.
2336 ///
2337 /// # Returns
2338 ///
2339 ///
2340 /// ## `x_offset`
2341 /// a location for the X offset
2342 ///
2343 /// ## `y_offset`
2344 /// a location for the Y offset
2345 #[cfg(feature = "v4_18")]
2346 #[cfg_attr(docsrs, doc(cfg(feature = "v4_18")))]
2347 #[doc(alias = "gtk_text_view_get_visible_offset")]
2348 #[doc(alias = "get_visible_offset")]
2349 fn visible_offset(&self) -> (f64, f64) {
2350 unsafe {
2351 let mut x_offset = std::mem::MaybeUninit::uninit();
2352 let mut y_offset = std::mem::MaybeUninit::uninit();
2353 ffi::gtk_text_view_get_visible_offset(
2354 self.as_ref().to_glib_none().0,
2355 x_offset.as_mut_ptr(),
2356 y_offset.as_mut_ptr(),
2357 );
2358 (x_offset.assume_init(), y_offset.assume_init())
2359 }
2360 }
2361
2362 /// Fills @visible_rect with the currently-visible
2363 /// region of the buffer, in buffer coordinates.
2364 ///
2365 /// Convert to window coordinates with
2366 /// [`buffer_to_window_coords()`][Self::buffer_to_window_coords()].
2367 ///
2368 /// # Returns
2369 ///
2370 ///
2371 /// ## `visible_rect`
2372 /// rectangle to fill
2373 #[doc(alias = "gtk_text_view_get_visible_rect")]
2374 #[doc(alias = "get_visible_rect")]
2375 fn visible_rect(&self) -> gdk::Rectangle {
2376 unsafe {
2377 let mut visible_rect = gdk::Rectangle::uninitialized();
2378 ffi::gtk_text_view_get_visible_rect(
2379 self.as_ref().to_glib_none().0,
2380 visible_rect.to_glib_none_mut().0,
2381 );
2382 visible_rect
2383 }
2384 }
2385
2386 /// Gets the line wrapping for the view.
2387 ///
2388 /// # Returns
2389 ///
2390 /// the line wrap setting
2391 #[doc(alias = "gtk_text_view_get_wrap_mode")]
2392 #[doc(alias = "get_wrap_mode")]
2393 #[doc(alias = "wrap-mode")]
2394 fn wrap_mode(&self) -> WrapMode {
2395 unsafe {
2396 from_glib(ffi::gtk_text_view_get_wrap_mode(
2397 self.as_ref().to_glib_none().0,
2398 ))
2399 }
2400 }
2401
2402 /// Allow the [`TextView`][crate::TextView] input method to internally handle key press
2403 /// and release events.
2404 ///
2405 /// If this function returns [`true`], then no further processing should be
2406 /// done for this key event. See [`IMContextExt::filter_keypress()`][crate::prelude::IMContextExt::filter_keypress()].
2407 ///
2408 /// Note that you are expected to call this function from your handler
2409 /// when overriding key event handling. This is needed in the case when
2410 /// you need to insert your own key handling between the input method
2411 /// and the default key event handling of the [`TextView`][crate::TextView].
2412 ///
2413 /// **⚠️ The following code is in c ⚠️**
2414 ///
2415 /// ```c
2416 /// static gboolean
2417 /// gtk_foo_bar_key_press_event (GtkWidget *widget,
2418 /// GdkEvent *event)
2419 /// {
2420 /// guint keyval;
2421 ///
2422 /// gdk_event_get_keyval ((GdkEvent*)event, &keyval);
2423 ///
2424 /// if (keyval == GDK_KEY_Return || keyval == GDK_KEY_KP_Enter)
2425 /// {
2426 /// if (gtk_text_view_im_context_filter_keypress (GTK_TEXT_VIEW (widget), event))
2427 /// return TRUE;
2428 /// }
2429 ///
2430 /// // Do some stuff
2431 ///
2432 /// return GTK_WIDGET_CLASS (gtk_foo_bar_parent_class)->key_press_event (widget, event);
2433 /// }
2434 /// ```
2435 /// ## `event`
2436 /// the key event
2437 ///
2438 /// # Returns
2439 ///
2440 /// [`true`] if the input method handled the key event.
2441 #[doc(alias = "gtk_text_view_im_context_filter_keypress")]
2442 fn im_context_filter_keypress(&self, event: impl AsRef<gdk::Event>) -> bool {
2443 unsafe {
2444 from_glib(ffi::gtk_text_view_im_context_filter_keypress(
2445 self.as_ref().to_glib_none().0,
2446 event.as_ref().to_glib_none().0,
2447 ))
2448 }
2449 }
2450
2451 /// Moves a mark within the buffer so that it's
2452 /// located within the currently-visible text area.
2453 /// ## `mark`
2454 /// a [`TextMark`][crate::TextMark]
2455 ///
2456 /// # Returns
2457 ///
2458 /// [`true`] if the mark moved (wasn’t already onscreen)
2459 #[doc(alias = "gtk_text_view_move_mark_onscreen")]
2460 fn move_mark_onscreen(&self, mark: &impl IsA<TextMark>) -> bool {
2461 unsafe {
2462 from_glib(ffi::gtk_text_view_move_mark_onscreen(
2463 self.as_ref().to_glib_none().0,
2464 mark.as_ref().to_glib_none().0,
2465 ))
2466 }
2467 }
2468
2469 /// Updates the position of a child.
2470 ///
2471 /// See [`add_overlay()`][Self::add_overlay()].
2472 /// ## `child`
2473 /// a widget already added with [`add_overlay()`][Self::add_overlay()]
2474 /// ## `xpos`
2475 /// new X position in buffer coordinates
2476 /// ## `ypos`
2477 /// new Y position in buffer coordinates
2478 #[doc(alias = "gtk_text_view_move_overlay")]
2479 fn move_overlay(&self, child: &impl IsA<Widget>, xpos: i32, ypos: i32) {
2480 unsafe {
2481 ffi::gtk_text_view_move_overlay(
2482 self.as_ref().to_glib_none().0,
2483 child.as_ref().to_glib_none().0,
2484 xpos,
2485 ypos,
2486 );
2487 }
2488 }
2489
2490 /// Move the iterator a given number of characters visually, treating
2491 /// it as the strong cursor position.
2492 ///
2493 /// If @count is positive, then the new strong cursor position will
2494 /// be @count positions to the right of the old cursor position.
2495 /// If @count is negative then the new strong cursor position will
2496 /// be @count positions to the left of the old cursor position.
2497 ///
2498 /// In the presence of bi-directional text, the correspondence
2499 /// between logical and visual order will depend on the direction
2500 /// of the current run, and there may be jumps when the cursor
2501 /// is moved off of the end of a run.
2502 /// ## `iter`
2503 /// a [`TextIter`][crate::TextIter]
2504 /// ## `count`
2505 /// number of characters to move (negative moves left,
2506 /// positive moves right)
2507 ///
2508 /// # Returns
2509 ///
2510 /// [`true`] if @iter moved and is not on the end iterator
2511 #[doc(alias = "gtk_text_view_move_visually")]
2512 fn move_visually(&self, iter: &mut TextIter, count: i32) -> bool {
2513 unsafe {
2514 from_glib(ffi::gtk_text_view_move_visually(
2515 self.as_ref().to_glib_none().0,
2516 iter.to_glib_none_mut().0,
2517 count,
2518 ))
2519 }
2520 }
2521
2522 /// Moves the cursor to the currently visible region of the
2523 /// buffer.
2524 ///
2525 /// # Returns
2526 ///
2527 /// [`true`] if the cursor had to be moved.
2528 #[doc(alias = "gtk_text_view_place_cursor_onscreen")]
2529 fn place_cursor_onscreen(&self) -> bool {
2530 unsafe {
2531 from_glib(ffi::gtk_text_view_place_cursor_onscreen(
2532 self.as_ref().to_glib_none().0,
2533 ))
2534 }
2535 }
2536
2537 /// Removes a child widget from @self.
2538 /// ## `child`
2539 /// the child to remove
2540 #[doc(alias = "gtk_text_view_remove")]
2541 fn remove(&self, child: &impl IsA<Widget>) {
2542 unsafe {
2543 ffi::gtk_text_view_remove(
2544 self.as_ref().to_glib_none().0,
2545 child.as_ref().to_glib_none().0,
2546 );
2547 }
2548 }
2549
2550 /// Ensures that the cursor is shown.
2551 ///
2552 /// This also resets the time that it will stay blinking (or
2553 /// visible, in case blinking is disabled).
2554 ///
2555 /// This function should be called in response to user input
2556 /// (e.g. from derived classes that override the textview's
2557 /// event handlers).
2558 #[doc(alias = "gtk_text_view_reset_cursor_blink")]
2559 fn reset_cursor_blink(&self) {
2560 unsafe {
2561 ffi::gtk_text_view_reset_cursor_blink(self.as_ref().to_glib_none().0);
2562 }
2563 }
2564
2565 /// Reset the input method context of the text view if needed.
2566 ///
2567 /// This can be necessary in the case where modifying the buffer
2568 /// would confuse on-going input method behavior.
2569 #[doc(alias = "gtk_text_view_reset_im_context")]
2570 fn reset_im_context(&self) {
2571 unsafe {
2572 ffi::gtk_text_view_reset_im_context(self.as_ref().to_glib_none().0);
2573 }
2574 }
2575
2576 /// Scrolls @self the minimum distance such that @mark is contained
2577 /// within the visible area of the widget.
2578 /// ## `mark`
2579 /// a mark in the buffer for @self
2580 #[doc(alias = "gtk_text_view_scroll_mark_onscreen")]
2581 fn scroll_mark_onscreen(&self, mark: &impl IsA<TextMark>) {
2582 unsafe {
2583 ffi::gtk_text_view_scroll_mark_onscreen(
2584 self.as_ref().to_glib_none().0,
2585 mark.as_ref().to_glib_none().0,
2586 );
2587 }
2588 }
2589
2590 /// Scrolls @self so that @iter is on the screen in the position
2591 /// indicated by @xalign and @yalign.
2592 ///
2593 /// An alignment of 0.0 indicates left or top, 1.0 indicates right or
2594 /// bottom, 0.5 means center. If @use_align is [`false`], the text scrolls
2595 /// the minimal distance to get the mark onscreen, possibly not scrolling
2596 /// at all. The effective screen for purposes of this function is reduced
2597 /// by a margin of size @within_margin.
2598 ///
2599 /// Note that this function uses the currently-computed height of the
2600 /// lines in the text buffer. Line heights are computed in an idle
2601 /// handler; so this function may not have the desired effect if it’s
2602 /// called before the height computations. To avoid oddness, consider
2603 /// using [`scroll_to_mark()`][Self::scroll_to_mark()] which saves a point to be
2604 /// scrolled to after line validation.
2605 /// ## `iter`
2606 /// a [`TextIter`][crate::TextIter]
2607 /// ## `within_margin`
2608 /// margin as a [0.0,0.5) fraction of screen size
2609 /// ## `use_align`
2610 /// whether to use alignment arguments (if [`false`],
2611 /// just get the mark onscreen)
2612 /// ## `xalign`
2613 /// horizontal alignment of mark within visible area
2614 /// ## `yalign`
2615 /// vertical alignment of mark within visible area
2616 ///
2617 /// # Returns
2618 ///
2619 /// [`true`] if scrolling occurred
2620 #[doc(alias = "gtk_text_view_scroll_to_iter")]
2621 fn scroll_to_iter(
2622 &self,
2623 iter: &mut TextIter,
2624 within_margin: f64,
2625 use_align: bool,
2626 xalign: f64,
2627 yalign: f64,
2628 ) -> bool {
2629 unsafe {
2630 from_glib(ffi::gtk_text_view_scroll_to_iter(
2631 self.as_ref().to_glib_none().0,
2632 iter.to_glib_none_mut().0,
2633 within_margin,
2634 use_align.into_glib(),
2635 xalign,
2636 yalign,
2637 ))
2638 }
2639 }
2640
2641 /// Scrolls @self so that @mark is on the screen in the position
2642 /// indicated by @xalign and @yalign.
2643 ///
2644 /// An alignment of 0.0 indicates left or top, 1.0 indicates right or
2645 /// bottom, 0.5 means center. If @use_align is [`false`], the text scrolls
2646 /// the minimal distance to get the mark onscreen, possibly not scrolling
2647 /// at all. The effective screen for purposes of this function is reduced
2648 /// by a margin of size @within_margin.
2649 /// ## `mark`
2650 /// a [`TextMark`][crate::TextMark]
2651 /// ## `within_margin`
2652 /// margin as a [0.0,0.5) fraction of screen size
2653 /// ## `use_align`
2654 /// whether to use alignment arguments (if [`false`], just
2655 /// get the mark onscreen)
2656 /// ## `xalign`
2657 /// horizontal alignment of mark within visible area
2658 /// ## `yalign`
2659 /// vertical alignment of mark within visible area
2660 #[doc(alias = "gtk_text_view_scroll_to_mark")]
2661 fn scroll_to_mark(
2662 &self,
2663 mark: &impl IsA<TextMark>,
2664 within_margin: f64,
2665 use_align: bool,
2666 xalign: f64,
2667 yalign: f64,
2668 ) {
2669 unsafe {
2670 ffi::gtk_text_view_scroll_to_mark(
2671 self.as_ref().to_glib_none().0,
2672 mark.as_ref().to_glib_none().0,
2673 within_margin,
2674 use_align.into_glib(),
2675 xalign,
2676 yalign,
2677 );
2678 }
2679 }
2680
2681 /// Sets the behavior of the text widget when the <kbd>Tab</kbd> key is pressed.
2682 ///
2683 /// If @accepts_tab is [`true`], a tab character is inserted. If @accepts_tab
2684 /// is [`false`] the keyboard focus is moved to the next widget in the focus
2685 /// chain.
2686 ///
2687 /// Focus can always be moved using <kbd>Ctrl</kbd>+<kbd>Tab</kbd>.
2688 /// ## `accepts_tab`
2689 /// [`true`] if pressing the Tab key should insert a tab
2690 /// character, [`false`], if pressing the Tab key should move the
2691 /// keyboard focus.
2692 #[doc(alias = "gtk_text_view_set_accepts_tab")]
2693 #[doc(alias = "accepts-tab")]
2694 fn set_accepts_tab(&self, accepts_tab: bool) {
2695 unsafe {
2696 ffi::gtk_text_view_set_accepts_tab(
2697 self.as_ref().to_glib_none().0,
2698 accepts_tab.into_glib(),
2699 );
2700 }
2701 }
2702
2703 /// Sets the bottom margin for text in @self.
2704 ///
2705 /// Note that this function is confusingly named.
2706 /// In CSS terms, the value set here is padding.
2707 /// ## `bottom_margin`
2708 /// bottom margin in pixels
2709 #[doc(alias = "gtk_text_view_set_bottom_margin")]
2710 #[doc(alias = "bottom-margin")]
2711 fn set_bottom_margin(&self, bottom_margin: i32) {
2712 unsafe {
2713 ffi::gtk_text_view_set_bottom_margin(self.as_ref().to_glib_none().0, bottom_margin);
2714 }
2715 }
2716
2717 /// Sets @buffer as the buffer being displayed by @self.
2718 ///
2719 /// The previous buffer displayed by the text view is unreferenced, and
2720 /// a reference is added to @buffer. If you owned a reference to @buffer
2721 /// before passing it to this function, you must remove that reference
2722 /// yourself; [`TextView`][crate::TextView] will not “adopt” it.
2723 /// ## `buffer`
2724 /// a [`TextBuffer`][crate::TextBuffer]
2725 #[doc(alias = "gtk_text_view_set_buffer")]
2726 #[doc(alias = "buffer")]
2727 fn set_buffer(&self, buffer: Option<&impl IsA<TextBuffer>>) {
2728 unsafe {
2729 ffi::gtk_text_view_set_buffer(
2730 self.as_ref().to_glib_none().0,
2731 buffer.map(|p| p.as_ref()).to_glib_none().0,
2732 );
2733 }
2734 }
2735
2736 /// Toggles whether the insertion point should be displayed.
2737 ///
2738 /// A buffer with no editable text probably shouldn’t have a visible
2739 /// cursor, so you may want to turn the cursor off.
2740 ///
2741 /// Note that this property may be overridden by the
2742 /// [`gtk-keynav-use-caret`][struct@crate::Settings#gtk-keynav-use-caret] setting.
2743 /// ## `setting`
2744 /// whether to show the insertion cursor
2745 #[doc(alias = "gtk_text_view_set_cursor_visible")]
2746 #[doc(alias = "cursor-visible")]
2747 fn set_cursor_visible(&self, setting: bool) {
2748 unsafe {
2749 ffi::gtk_text_view_set_cursor_visible(
2750 self.as_ref().to_glib_none().0,
2751 setting.into_glib(),
2752 );
2753 }
2754 }
2755
2756 /// Sets the default editability of the [`TextView`][crate::TextView].
2757 ///
2758 /// You can override this default setting with tags in the buffer,
2759 /// using the “editable” attribute of tags.
2760 /// ## `setting`
2761 /// whether it’s editable
2762 #[doc(alias = "gtk_text_view_set_editable")]
2763 #[doc(alias = "editable")]
2764 fn set_editable(&self, setting: bool) {
2765 unsafe {
2766 ffi::gtk_text_view_set_editable(self.as_ref().to_glib_none().0, setting.into_glib());
2767 }
2768 }
2769
2770 /// Sets a menu model to add when constructing the context
2771 /// menu for @self.
2772 ///
2773 /// You can pass [`None`] to remove a previously set extra menu.
2774 /// ## `model`
2775 /// a `GMenuModel`
2776 #[doc(alias = "gtk_text_view_set_extra_menu")]
2777 #[doc(alias = "extra-menu")]
2778 fn set_extra_menu(&self, model: Option<&impl IsA<gio::MenuModel>>) {
2779 unsafe {
2780 ffi::gtk_text_view_set_extra_menu(
2781 self.as_ref().to_glib_none().0,
2782 model.map(|p| p.as_ref()).to_glib_none().0,
2783 );
2784 }
2785 }
2786
2787 /// Places @widget into the gutter specified by @win.
2788 ///
2789 /// @win must be one of [`TextWindowType::Left`][crate::TextWindowType::Left], [`TextWindowType::Right`][crate::TextWindowType::Right],
2790 /// [`TextWindowType::Top`][crate::TextWindowType::Top], or [`TextWindowType::Bottom`][crate::TextWindowType::Bottom].
2791 /// ## `win`
2792 /// a [`TextWindowType`][crate::TextWindowType]
2793 /// ## `widget`
2794 /// a [`Widget`][crate::Widget]
2795 #[doc(alias = "gtk_text_view_set_gutter")]
2796 fn set_gutter(&self, win: TextWindowType, widget: Option<&impl IsA<Widget>>) {
2797 unsafe {
2798 ffi::gtk_text_view_set_gutter(
2799 self.as_ref().to_glib_none().0,
2800 win.into_glib(),
2801 widget.map(|p| p.as_ref()).to_glib_none().0,
2802 );
2803 }
2804 }
2805
2806 /// Sets the default indentation for paragraphs in @self.
2807 ///
2808 /// Tags in the buffer may override the default.
2809 /// ## `indent`
2810 /// indentation in pixels
2811 #[doc(alias = "gtk_text_view_set_indent")]
2812 #[doc(alias = "indent")]
2813 fn set_indent(&self, indent: i32) {
2814 unsafe {
2815 ffi::gtk_text_view_set_indent(self.as_ref().to_glib_none().0, indent);
2816 }
2817 }
2818
2819 /// Sets the `input-hints` of the [`TextView`][crate::TextView].
2820 ///
2821 /// The `input-hints` allow input methods to fine-tune
2822 /// their behaviour.
2823 /// ## `hints`
2824 /// the hints
2825 #[doc(alias = "gtk_text_view_set_input_hints")]
2826 #[doc(alias = "input-hints")]
2827 fn set_input_hints(&self, hints: InputHints) {
2828 unsafe {
2829 ffi::gtk_text_view_set_input_hints(self.as_ref().to_glib_none().0, hints.into_glib());
2830 }
2831 }
2832
2833 /// Sets the `input-purpose` of the [`TextView`][crate::TextView].
2834 ///
2835 /// The `input-purpose` can be used by on-screen keyboards
2836 /// and other input methods to adjust their behaviour.
2837 /// ## `purpose`
2838 /// the purpose
2839 #[doc(alias = "gtk_text_view_set_input_purpose")]
2840 #[doc(alias = "input-purpose")]
2841 fn set_input_purpose(&self, purpose: InputPurpose) {
2842 unsafe {
2843 ffi::gtk_text_view_set_input_purpose(
2844 self.as_ref().to_glib_none().0,
2845 purpose.into_glib(),
2846 );
2847 }
2848 }
2849
2850 /// Sets the default justification of text in @self.
2851 ///
2852 /// Tags in the view’s buffer may override the default.
2853 /// ## `justification`
2854 /// justification
2855 #[doc(alias = "gtk_text_view_set_justification")]
2856 #[doc(alias = "justification")]
2857 fn set_justification(&self, justification: Justification) {
2858 unsafe {
2859 ffi::gtk_text_view_set_justification(
2860 self.as_ref().to_glib_none().0,
2861 justification.into_glib(),
2862 );
2863 }
2864 }
2865
2866 /// Sets the default left margin for text in @self.
2867 ///
2868 /// Tags in the buffer may override the default.
2869 ///
2870 /// Note that this function is confusingly named.
2871 /// In CSS terms, the value set here is padding.
2872 /// ## `left_margin`
2873 /// left margin in pixels
2874 #[doc(alias = "gtk_text_view_set_left_margin")]
2875 #[doc(alias = "left-margin")]
2876 fn set_left_margin(&self, left_margin: i32) {
2877 unsafe {
2878 ffi::gtk_text_view_set_left_margin(self.as_ref().to_glib_none().0, left_margin);
2879 }
2880 }
2881
2882 /// Sets whether the [`TextView`][crate::TextView] should display text in
2883 /// monospace styling.
2884 /// ## `monospace`
2885 /// [`true`] to request monospace styling
2886 #[doc(alias = "gtk_text_view_set_monospace")]
2887 #[doc(alias = "monospace")]
2888 fn set_monospace(&self, monospace: bool) {
2889 unsafe {
2890 ffi::gtk_text_view_set_monospace(self.as_ref().to_glib_none().0, monospace.into_glib());
2891 }
2892 }
2893
2894 /// Changes the [`TextView`][crate::TextView] overwrite mode.
2895 /// ## `overwrite`
2896 /// [`true`] to turn on overwrite mode, [`false`] to turn it off
2897 #[doc(alias = "gtk_text_view_set_overwrite")]
2898 #[doc(alias = "overwrite")]
2899 fn set_overwrite(&self, overwrite: bool) {
2900 unsafe {
2901 ffi::gtk_text_view_set_overwrite(self.as_ref().to_glib_none().0, overwrite.into_glib());
2902 }
2903 }
2904
2905 /// Sets the default number of blank pixels above paragraphs in @self.
2906 ///
2907 /// Tags in the buffer for @self may override the defaults.
2908 /// ## `pixels_above_lines`
2909 /// pixels above paragraphs
2910 #[doc(alias = "gtk_text_view_set_pixels_above_lines")]
2911 #[doc(alias = "pixels-above-lines")]
2912 fn set_pixels_above_lines(&self, pixels_above_lines: i32) {
2913 unsafe {
2914 ffi::gtk_text_view_set_pixels_above_lines(
2915 self.as_ref().to_glib_none().0,
2916 pixels_above_lines,
2917 );
2918 }
2919 }
2920
2921 /// Sets the default number of pixels of blank space
2922 /// to put below paragraphs in @self.
2923 ///
2924 /// May be overridden by tags applied to @self’s buffer.
2925 /// ## `pixels_below_lines`
2926 /// pixels below paragraphs
2927 #[doc(alias = "gtk_text_view_set_pixels_below_lines")]
2928 #[doc(alias = "pixels-below-lines")]
2929 fn set_pixels_below_lines(&self, pixels_below_lines: i32) {
2930 unsafe {
2931 ffi::gtk_text_view_set_pixels_below_lines(
2932 self.as_ref().to_glib_none().0,
2933 pixels_below_lines,
2934 );
2935 }
2936 }
2937
2938 /// Sets the default number of pixels of blank space to leave between
2939 /// display/wrapped lines within a paragraph.
2940 ///
2941 /// May be overridden by tags in @self’s buffer.
2942 /// ## `pixels_inside_wrap`
2943 /// default number of pixels between wrapped lines
2944 #[doc(alias = "gtk_text_view_set_pixels_inside_wrap")]
2945 #[doc(alias = "pixels-inside-wrap")]
2946 fn set_pixels_inside_wrap(&self, pixels_inside_wrap: i32) {
2947 unsafe {
2948 ffi::gtk_text_view_set_pixels_inside_wrap(
2949 self.as_ref().to_glib_none().0,
2950 pixels_inside_wrap,
2951 );
2952 }
2953 }
2954
2955 /// Sets the default right margin for text in the text view.
2956 ///
2957 /// Tags in the buffer may override the default.
2958 ///
2959 /// Note that this function is confusingly named.
2960 /// In CSS terms, the value set here is padding.
2961 /// ## `right_margin`
2962 /// right margin in pixels
2963 #[doc(alias = "gtk_text_view_set_right_margin")]
2964 #[doc(alias = "right-margin")]
2965 fn set_right_margin(&self, right_margin: i32) {
2966 unsafe {
2967 ffi::gtk_text_view_set_right_margin(self.as_ref().to_glib_none().0, right_margin);
2968 }
2969 }
2970
2971 /// Sets the default tab stops for paragraphs in @self.
2972 ///
2973 /// Tags in the buffer may override the default.
2974 /// ## `tabs`
2975 /// tabs as a [`pango::TabArray`][crate::pango::TabArray]
2976 #[doc(alias = "gtk_text_view_set_tabs")]
2977 #[doc(alias = "tabs")]
2978 fn set_tabs(&self, tabs: &pango::TabArray) {
2979 unsafe {
2980 ffi::gtk_text_view_set_tabs(
2981 self.as_ref().to_glib_none().0,
2982 mut_override(tabs.to_glib_none().0),
2983 );
2984 }
2985 }
2986
2987 /// Sets the top margin for text in @self.
2988 ///
2989 /// Note that this function is confusingly named.
2990 /// In CSS terms, the value set here is padding.
2991 /// ## `top_margin`
2992 /// top margin in pixels
2993 #[doc(alias = "gtk_text_view_set_top_margin")]
2994 #[doc(alias = "top-margin")]
2995 fn set_top_margin(&self, top_margin: i32) {
2996 unsafe {
2997 ffi::gtk_text_view_set_top_margin(self.as_ref().to_glib_none().0, top_margin);
2998 }
2999 }
3000
3001 /// Sets the line wrapping for the view.
3002 /// ## `wrap_mode`
3003 /// a [`WrapMode`][crate::WrapMode]
3004 #[doc(alias = "gtk_text_view_set_wrap_mode")]
3005 #[doc(alias = "wrap-mode")]
3006 fn set_wrap_mode(&self, wrap_mode: WrapMode) {
3007 unsafe {
3008 ffi::gtk_text_view_set_wrap_mode(self.as_ref().to_glib_none().0, wrap_mode.into_glib());
3009 }
3010 }
3011
3012 /// Determines whether @iter is at the start of a display line.
3013 ///
3014 /// See [`forward_display_line()`][Self::forward_display_line()] for an
3015 /// explanation of display lines vs. paragraphs.
3016 /// ## `iter`
3017 /// a [`TextIter`][crate::TextIter]
3018 ///
3019 /// # Returns
3020 ///
3021 /// [`true`] if @iter begins a wrapped line
3022 #[doc(alias = "gtk_text_view_starts_display_line")]
3023 fn starts_display_line(&self, iter: &TextIter) -> bool {
3024 unsafe {
3025 from_glib(ffi::gtk_text_view_starts_display_line(
3026 self.as_ref().to_glib_none().0,
3027 iter.to_glib_none().0,
3028 ))
3029 }
3030 }
3031
3032 /// Converts coordinates on the window identified by @win to buffer
3033 /// coordinates.
3034 /// ## `win`
3035 /// a [`TextWindowType`][crate::TextWindowType]
3036 /// ## `window_x`
3037 /// window x coordinate
3038 /// ## `window_y`
3039 /// window y coordinate
3040 ///
3041 /// # Returns
3042 ///
3043 ///
3044 /// ## `buffer_x`
3045 /// buffer x coordinate return location
3046 ///
3047 /// ## `buffer_y`
3048 /// buffer y coordinate return location
3049 #[doc(alias = "gtk_text_view_window_to_buffer_coords")]
3050 fn window_to_buffer_coords(
3051 &self,
3052 win: TextWindowType,
3053 window_x: i32,
3054 window_y: i32,
3055 ) -> (i32, i32) {
3056 unsafe {
3057 let mut buffer_x = std::mem::MaybeUninit::uninit();
3058 let mut buffer_y = std::mem::MaybeUninit::uninit();
3059 ffi::gtk_text_view_window_to_buffer_coords(
3060 self.as_ref().to_glib_none().0,
3061 win.into_glib(),
3062 window_x,
3063 window_y,
3064 buffer_x.as_mut_ptr(),
3065 buffer_y.as_mut_ptr(),
3066 );
3067 (buffer_x.assume_init(), buffer_y.assume_init())
3068 }
3069 }
3070
3071 /// Which IM (input method) module should be used for this text_view.
3072 ///
3073 /// See [`IMMulticontext`][crate::IMMulticontext].
3074 ///
3075 /// Setting this to a non-[`None`] value overrides the system-wide IM module
3076 /// setting. See the GtkSettings [`gtk-im-module`][struct@crate::Settings#gtk-im-module] property.
3077 #[doc(alias = "im-module")]
3078 fn im_module(&self) -> Option<glib::GString> {
3079 ObjectExt::property(self.as_ref(), "im-module")
3080 }
3081
3082 /// Which IM (input method) module should be used for this text_view.
3083 ///
3084 /// See [`IMMulticontext`][crate::IMMulticontext].
3085 ///
3086 /// Setting this to a non-[`None`] value overrides the system-wide IM module
3087 /// setting. See the GtkSettings [`gtk-im-module`][struct@crate::Settings#gtk-im-module] property.
3088 #[doc(alias = "im-module")]
3089 fn set_im_module(&self, im_module: Option<&str>) {
3090 ObjectExt::set_property(self.as_ref(), "im-module", im_module)
3091 }
3092
3093 /// Gets emitted when the user asks for it.
3094 ///
3095 /// The ::backspace signal is a [keybinding signal](class.SignalAction.html).
3096 ///
3097 /// The default bindings for this signal are
3098 /// <kbd>Backspace</kbd> and <kbd>Shift</kbd>+<kbd>Backspace</kbd>.
3099 #[doc(alias = "backspace")]
3100 fn connect_backspace<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
3101 unsafe extern "C" fn backspace_trampoline<P: IsA<TextView>, F: Fn(&P) + 'static>(
3102 this: *mut ffi::GtkTextView,
3103 f: glib::ffi::gpointer,
3104 ) {
3105 unsafe {
3106 let f: &F = &*(f as *const F);
3107 f(TextView::from_glib_borrow(this).unsafe_cast_ref())
3108 }
3109 }
3110 unsafe {
3111 let f: Box_<F> = Box_::new(f);
3112 connect_raw(
3113 self.as_ptr() as *mut _,
3114 c"backspace".as_ptr() as *const _,
3115 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
3116 backspace_trampoline::<Self, F> as *const (),
3117 )),
3118 Box_::into_raw(f),
3119 )
3120 }
3121 }
3122
3123 fn emit_backspace(&self) {
3124 self.emit_by_name::<()>("backspace", &[]);
3125 }
3126
3127 /// Gets emitted to copy the selection to the clipboard.
3128 ///
3129 /// The ::copy-clipboard signal is a [keybinding signal](class.SignalAction.html).
3130 ///
3131 /// The default bindings for this signal are
3132 /// <kbd>Ctrl</kbd>+<kbd>c</kbd> and
3133 /// <kbd>Ctrl</kbd>+<kbd>Insert</kbd>.
3134 #[doc(alias = "copy-clipboard")]
3135 fn connect_copy_clipboard<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
3136 unsafe extern "C" fn copy_clipboard_trampoline<P: IsA<TextView>, F: Fn(&P) + 'static>(
3137 this: *mut ffi::GtkTextView,
3138 f: glib::ffi::gpointer,
3139 ) {
3140 unsafe {
3141 let f: &F = &*(f as *const F);
3142 f(TextView::from_glib_borrow(this).unsafe_cast_ref())
3143 }
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 unsafe {
3176 let f: &F = &*(f as *const F);
3177 f(TextView::from_glib_borrow(this).unsafe_cast_ref())
3178 }
3179 }
3180 unsafe {
3181 let f: Box_<F> = Box_::new(f);
3182 connect_raw(
3183 self.as_ptr() as *mut _,
3184 c"cut-clipboard".as_ptr() as *const _,
3185 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
3186 cut_clipboard_trampoline::<Self, F> as *const (),
3187 )),
3188 Box_::into_raw(f),
3189 )
3190 }
3191 }
3192
3193 fn emit_cut_clipboard(&self) {
3194 self.emit_by_name::<()>("cut-clipboard", &[]);
3195 }
3196
3197 /// Gets emitted when the user initiates a text deletion.
3198 ///
3199 /// The ::delete-from-cursor signal is a [keybinding signal](class.SignalAction.html).
3200 ///
3201 /// If the @type_ is [`DeleteType::Chars`][crate::DeleteType::Chars], GTK deletes the selection
3202 /// if there is one, otherwise it deletes the requested number
3203 /// of characters.
3204 ///
3205 /// The default bindings for this signal are <kbd>Delete</kbd> for
3206 /// deleting a character, <kbd>Ctrl</kbd>+<kbd>Delete</kbd> for
3207 /// deleting a word and <kbd>Ctrl</kbd>+<kbd>Backspace</kbd> for
3208 /// deleting a word backwards.
3209 /// ## `type_`
3210 /// the granularity of the deletion, as a [`DeleteType`][crate::DeleteType]
3211 /// ## `count`
3212 /// the number of @type_ units to delete
3213 #[doc(alias = "delete-from-cursor")]
3214 fn connect_delete_from_cursor<F: Fn(&Self, DeleteType, i32) + 'static>(
3215 &self,
3216 f: F,
3217 ) -> SignalHandlerId {
3218 unsafe extern "C" fn delete_from_cursor_trampoline<
3219 P: IsA<TextView>,
3220 F: Fn(&P, DeleteType, i32) + 'static,
3221 >(
3222 this: *mut ffi::GtkTextView,
3223 type_: ffi::GtkDeleteType,
3224 count: std::ffi::c_int,
3225 f: glib::ffi::gpointer,
3226 ) {
3227 unsafe {
3228 let f: &F = &*(f as *const F);
3229 f(
3230 TextView::from_glib_borrow(this).unsafe_cast_ref(),
3231 from_glib(type_),
3232 count,
3233 )
3234 }
3235 }
3236 unsafe {
3237 let f: Box_<F> = Box_::new(f);
3238 connect_raw(
3239 self.as_ptr() as *mut _,
3240 c"delete-from-cursor".as_ptr() as *const _,
3241 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
3242 delete_from_cursor_trampoline::<Self, F> as *const (),
3243 )),
3244 Box_::into_raw(f),
3245 )
3246 }
3247 }
3248
3249 fn emit_delete_from_cursor(&self, type_: DeleteType, count: i32) {
3250 self.emit_by_name::<()>("delete-from-cursor", &[&type_, &count]);
3251 }
3252
3253 /// Emitted when the selection needs to be extended at @location.
3254 /// ## `granularity`
3255 /// the granularity type
3256 /// ## `location`
3257 /// the location where to extend the selection
3258 /// ## `start`
3259 /// where the selection should start
3260 /// ## `end`
3261 /// where the selection should end
3262 ///
3263 /// # Returns
3264 ///
3265 /// `GDK_EVENT_STOP` to stop other handlers from being invoked for the
3266 /// event. `GDK_EVENT_PROPAGATE` to propagate the event further.
3267 #[doc(alias = "extend-selection")]
3268 fn connect_extend_selection<
3269 F: Fn(&Self, TextExtendSelection, &TextIter, &TextIter, &TextIter) -> glib::Propagation
3270 + 'static,
3271 >(
3272 &self,
3273 f: F,
3274 ) -> SignalHandlerId {
3275 unsafe extern "C" fn extend_selection_trampoline<
3276 P: IsA<TextView>,
3277 F: Fn(&P, TextExtendSelection, &TextIter, &TextIter, &TextIter) -> glib::Propagation
3278 + 'static,
3279 >(
3280 this: *mut ffi::GtkTextView,
3281 granularity: ffi::GtkTextExtendSelection,
3282 location: *mut ffi::GtkTextIter,
3283 start: *mut ffi::GtkTextIter,
3284 end: *mut ffi::GtkTextIter,
3285 f: glib::ffi::gpointer,
3286 ) -> glib::ffi::gboolean {
3287 unsafe {
3288 let f: &F = &*(f as *const F);
3289 f(
3290 TextView::from_glib_borrow(this).unsafe_cast_ref(),
3291 from_glib(granularity),
3292 &from_glib_borrow(location),
3293 &from_glib_borrow(start),
3294 &from_glib_borrow(end),
3295 )
3296 .into_glib()
3297 }
3298 }
3299 unsafe {
3300 let f: Box_<F> = Box_::new(f);
3301 connect_raw(
3302 self.as_ptr() as *mut _,
3303 c"extend-selection".as_ptr() as *const _,
3304 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
3305 extend_selection_trampoline::<Self, F> as *const (),
3306 )),
3307 Box_::into_raw(f),
3308 )
3309 }
3310 }
3311
3312 /// Gets emitted when the user initiates the insertion of a
3313 /// fixed string at the cursor.
3314 ///
3315 /// The ::insert-at-cursor signal is a [keybinding signal](class.SignalAction.html).
3316 ///
3317 /// This signal has no default bindings.
3318 /// ## `string`
3319 /// the string to insert
3320 #[doc(alias = "insert-at-cursor")]
3321 fn connect_insert_at_cursor<F: Fn(&Self, &str) + 'static>(&self, f: F) -> SignalHandlerId {
3322 unsafe extern "C" fn insert_at_cursor_trampoline<
3323 P: IsA<TextView>,
3324 F: Fn(&P, &str) + 'static,
3325 >(
3326 this: *mut ffi::GtkTextView,
3327 string: *mut std::ffi::c_char,
3328 f: glib::ffi::gpointer,
3329 ) {
3330 unsafe {
3331 let f: &F = &*(f as *const F);
3332 f(
3333 TextView::from_glib_borrow(this).unsafe_cast_ref(),
3334 &glib::GString::from_glib_borrow(string),
3335 )
3336 }
3337 }
3338 unsafe {
3339 let f: Box_<F> = Box_::new(f);
3340 connect_raw(
3341 self.as_ptr() as *mut _,
3342 c"insert-at-cursor".as_ptr() as *const _,
3343 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
3344 insert_at_cursor_trampoline::<Self, F> as *const (),
3345 )),
3346 Box_::into_raw(f),
3347 )
3348 }
3349 }
3350
3351 fn emit_insert_at_cursor(&self, string: &str) {
3352 self.emit_by_name::<()>("insert-at-cursor", &[&string]);
3353 }
3354
3355 /// Gets emitted to present the Emoji chooser for the @text_view.
3356 ///
3357 /// The ::insert-emoji signal is a [keybinding signal](class.SignalAction.html).
3358 ///
3359 /// The default bindings for this signal are
3360 /// <kbd>Ctrl</kbd>+<kbd>.</kbd> and
3361 /// <kbd>Ctrl</kbd>+<kbd>;</kbd>
3362 #[doc(alias = "insert-emoji")]
3363 fn connect_insert_emoji<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
3364 unsafe extern "C" fn insert_emoji_trampoline<P: IsA<TextView>, F: Fn(&P) + 'static>(
3365 this: *mut ffi::GtkTextView,
3366 f: glib::ffi::gpointer,
3367 ) {
3368 unsafe {
3369 let f: &F = &*(f as *const F);
3370 f(TextView::from_glib_borrow(this).unsafe_cast_ref())
3371 }
3372 }
3373 unsafe {
3374 let f: Box_<F> = Box_::new(f);
3375 connect_raw(
3376 self.as_ptr() as *mut _,
3377 c"insert-emoji".as_ptr() as *const _,
3378 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
3379 insert_emoji_trampoline::<Self, F> as *const (),
3380 )),
3381 Box_::into_raw(f),
3382 )
3383 }
3384 }
3385
3386 fn emit_insert_emoji(&self) {
3387 self.emit_by_name::<()>("insert-emoji", &[]);
3388 }
3389
3390 /// Gets emitted when the user initiates a cursor movement.
3391 ///
3392 /// The ::move-cursor signal is a [keybinding signal](class.SignalAction.html).
3393 /// If the cursor is not visible in @text_view, this signal causes
3394 /// the viewport to be moved instead.
3395 ///
3396 /// Applications should not connect to it, but may emit it with
3397 /// g_signal_emit_by_name() if they need to control the cursor
3398 /// programmatically.
3399 ///
3400 ///
3401 /// The default bindings for this signal come in two variants,
3402 /// the variant with the <kbd>Shift</kbd> modifier extends the
3403 /// selection, the variant without it does not.
3404 /// There are too many key combinations to list them all here.
3405 ///
3406 /// - <kbd>←</kbd>, <kbd>→</kbd>, <kbd>↑</kbd>, <kbd>↓</kbd>
3407 /// move by individual characters/lines
3408 /// - <kbd>Ctrl</kbd>+<kbd>←</kbd>, etc. move by words/paragraphs
3409 /// - <kbd>Home</kbd> and <kbd>End</kbd> move to the ends of the buffer
3410 /// - <kbd>PgUp</kbd> and <kbd>PgDn</kbd> move vertically by pages
3411 /// - <kbd>Ctrl</kbd>+<kbd>PgUp</kbd> and <kbd>Ctrl</kbd>+<kbd>PgDn</kbd>
3412 /// move horizontally by pages
3413 /// ## `step`
3414 /// the granularity of the move, as a [`MovementStep`][crate::MovementStep]
3415 /// ## `count`
3416 /// the number of @step units to move
3417 /// ## `extend_selection`
3418 /// [`true`] if the move should extend the selection
3419 #[doc(alias = "move-cursor")]
3420 fn connect_move_cursor<F: Fn(&Self, MovementStep, i32, bool) + 'static>(
3421 &self,
3422 f: F,
3423 ) -> SignalHandlerId {
3424 unsafe extern "C" fn move_cursor_trampoline<
3425 P: IsA<TextView>,
3426 F: Fn(&P, MovementStep, i32, bool) + 'static,
3427 >(
3428 this: *mut ffi::GtkTextView,
3429 step: ffi::GtkMovementStep,
3430 count: std::ffi::c_int,
3431 extend_selection: glib::ffi::gboolean,
3432 f: glib::ffi::gpointer,
3433 ) {
3434 unsafe {
3435 let f: &F = &*(f as *const F);
3436 f(
3437 TextView::from_glib_borrow(this).unsafe_cast_ref(),
3438 from_glib(step),
3439 count,
3440 from_glib(extend_selection),
3441 )
3442 }
3443 }
3444 unsafe {
3445 let f: Box_<F> = Box_::new(f);
3446 connect_raw(
3447 self.as_ptr() as *mut _,
3448 c"move-cursor".as_ptr() as *const _,
3449 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
3450 move_cursor_trampoline::<Self, F> as *const (),
3451 )),
3452 Box_::into_raw(f),
3453 )
3454 }
3455 }
3456
3457 fn emit_move_cursor(&self, step: MovementStep, count: i32, extend_selection: bool) {
3458 self.emit_by_name::<()>("move-cursor", &[&step, &count, &extend_selection]);
3459 }
3460
3461 /// Gets emitted to move the viewport.
3462 ///
3463 /// The ::move-viewport signal is a [keybinding signal](class.SignalAction.html),
3464 /// which can be bound to key combinations to allow the user to move the viewport,
3465 /// i.e. change what part of the text view is visible in a containing scrolled
3466 /// window.
3467 ///
3468 /// There are no default bindings for this signal.
3469 /// ## `step`
3470 /// the granularity of the movement, as a [`ScrollStep`][crate::ScrollStep]
3471 /// ## `count`
3472 /// the number of @step units to move
3473 #[doc(alias = "move-viewport")]
3474 fn connect_move_viewport<F: Fn(&Self, ScrollStep, i32) + 'static>(
3475 &self,
3476 f: F,
3477 ) -> SignalHandlerId {
3478 unsafe extern "C" fn move_viewport_trampoline<
3479 P: IsA<TextView>,
3480 F: Fn(&P, ScrollStep, i32) + 'static,
3481 >(
3482 this: *mut ffi::GtkTextView,
3483 step: ffi::GtkScrollStep,
3484 count: std::ffi::c_int,
3485 f: glib::ffi::gpointer,
3486 ) {
3487 unsafe {
3488 let f: &F = &*(f as *const F);
3489 f(
3490 TextView::from_glib_borrow(this).unsafe_cast_ref(),
3491 from_glib(step),
3492 count,
3493 )
3494 }
3495 }
3496 unsafe {
3497 let f: Box_<F> = Box_::new(f);
3498 connect_raw(
3499 self.as_ptr() as *mut _,
3500 c"move-viewport".as_ptr() as *const _,
3501 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
3502 move_viewport_trampoline::<Self, F> as *const (),
3503 )),
3504 Box_::into_raw(f),
3505 )
3506 }
3507 }
3508
3509 fn emit_move_viewport(&self, step: ScrollStep, count: i32) {
3510 self.emit_by_name::<()>("move-viewport", &[&step, &count]);
3511 }
3512
3513 /// Gets emitted to paste the contents of the clipboard
3514 /// into the text view.
3515 ///
3516 /// The ::paste-clipboard signal is a [keybinding signal](class.SignalAction.html).
3517 ///
3518 /// The default bindings for this signal are
3519 /// <kbd>Ctrl</kbd>+<kbd>v</kbd> and
3520 /// <kbd>Shift</kbd>+<kbd>Insert</kbd>.
3521 #[doc(alias = "paste-clipboard")]
3522 fn connect_paste_clipboard<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
3523 unsafe extern "C" fn paste_clipboard_trampoline<P: IsA<TextView>, F: Fn(&P) + 'static>(
3524 this: *mut ffi::GtkTextView,
3525 f: glib::ffi::gpointer,
3526 ) {
3527 unsafe {
3528 let f: &F = &*(f as *const F);
3529 f(TextView::from_glib_borrow(this).unsafe_cast_ref())
3530 }
3531 }
3532 unsafe {
3533 let f: Box_<F> = Box_::new(f);
3534 connect_raw(
3535 self.as_ptr() as *mut _,
3536 c"paste-clipboard".as_ptr() as *const _,
3537 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
3538 paste_clipboard_trampoline::<Self, F> as *const (),
3539 )),
3540 Box_::into_raw(f),
3541 )
3542 }
3543 }
3544
3545 fn emit_paste_clipboard(&self) {
3546 self.emit_by_name::<()>("paste-clipboard", &[]);
3547 }
3548
3549 /// Emitted when preedit text of the active IM changes.
3550 ///
3551 /// If an input method is used, the typed text will not immediately
3552 /// be committed to the buffer. So if you are interested in the text,
3553 /// connect to this signal.
3554 ///
3555 /// This signal is only emitted if the text at the given position
3556 /// is actually editable.
3557 /// ## `preedit`
3558 /// the current preedit string
3559 #[doc(alias = "preedit-changed")]
3560 fn connect_preedit_changed<F: Fn(&Self, &str) + 'static>(&self, f: F) -> SignalHandlerId {
3561 unsafe extern "C" fn preedit_changed_trampoline<
3562 P: IsA<TextView>,
3563 F: Fn(&P, &str) + 'static,
3564 >(
3565 this: *mut ffi::GtkTextView,
3566 preedit: *mut std::ffi::c_char,
3567 f: glib::ffi::gpointer,
3568 ) {
3569 unsafe {
3570 let f: &F = &*(f as *const F);
3571 f(
3572 TextView::from_glib_borrow(this).unsafe_cast_ref(),
3573 &glib::GString::from_glib_borrow(preedit),
3574 )
3575 }
3576 }
3577 unsafe {
3578 let f: Box_<F> = Box_::new(f);
3579 connect_raw(
3580 self.as_ptr() as *mut _,
3581 c"preedit-changed".as_ptr() as *const _,
3582 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
3583 preedit_changed_trampoline::<Self, F> as *const (),
3584 )),
3585 Box_::into_raw(f),
3586 )
3587 }
3588 }
3589
3590 fn emit_preedit_changed(&self, preedit: &str) {
3591 self.emit_by_name::<()>("preedit-changed", &[&preedit]);
3592 }
3593
3594 /// Gets emitted to select or unselect the complete contents of the text view.
3595 ///
3596 /// The ::select-all signal is a [keybinding signal](class.SignalAction.html).
3597 ///
3598 /// The default bindings for this signal are
3599 /// <kbd>Ctrl</kbd>+<kbd>a</kbd> and
3600 /// <kbd>Ctrl</kbd>+<kbd>/</kbd> for selecting and
3601 /// <kbd>Shift</kbd>+<kbd>Ctrl</kbd>+<kbd>a</kbd> and
3602 /// <kbd>Ctrl</kbd>+<kbd>\</kbd> for unselecting.
3603 /// ## `select`
3604 /// [`true`] to select, [`false`] to unselect
3605 #[doc(alias = "select-all")]
3606 fn connect_select_all<F: Fn(&Self, bool) + 'static>(&self, f: F) -> SignalHandlerId {
3607 unsafe extern "C" fn select_all_trampoline<P: IsA<TextView>, F: Fn(&P, bool) + 'static>(
3608 this: *mut ffi::GtkTextView,
3609 select: glib::ffi::gboolean,
3610 f: glib::ffi::gpointer,
3611 ) {
3612 unsafe {
3613 let f: &F = &*(f as *const F);
3614 f(
3615 TextView::from_glib_borrow(this).unsafe_cast_ref(),
3616 from_glib(select),
3617 )
3618 }
3619 }
3620 unsafe {
3621 let f: Box_<F> = Box_::new(f);
3622 connect_raw(
3623 self.as_ptr() as *mut _,
3624 c"select-all".as_ptr() as *const _,
3625 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
3626 select_all_trampoline::<Self, F> as *const (),
3627 )),
3628 Box_::into_raw(f),
3629 )
3630 }
3631 }
3632
3633 fn emit_select_all(&self, select: bool) {
3634 self.emit_by_name::<()>("select-all", &[&select]);
3635 }
3636
3637 /// Gets emitted when the user initiates settings the "anchor" mark.
3638 ///
3639 /// The ::set-anchor signal is a [keybinding signal](class.SignalAction.html)
3640 /// which gets emitted when the user initiates setting the "anchor"
3641 /// mark. The "anchor" mark gets placed at the same position as the
3642 /// "insert" mark.
3643 ///
3644 /// This signal has no default bindings.
3645 #[doc(alias = "set-anchor")]
3646 fn connect_set_anchor<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
3647 unsafe extern "C" fn set_anchor_trampoline<P: IsA<TextView>, F: Fn(&P) + 'static>(
3648 this: *mut ffi::GtkTextView,
3649 f: glib::ffi::gpointer,
3650 ) {
3651 unsafe {
3652 let f: &F = &*(f as *const F);
3653 f(TextView::from_glib_borrow(this).unsafe_cast_ref())
3654 }
3655 }
3656 unsafe {
3657 let f: Box_<F> = Box_::new(f);
3658 connect_raw(
3659 self.as_ptr() as *mut _,
3660 c"set-anchor".as_ptr() as *const _,
3661 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
3662 set_anchor_trampoline::<Self, F> as *const (),
3663 )),
3664 Box_::into_raw(f),
3665 )
3666 }
3667 }
3668
3669 fn emit_set_anchor(&self) {
3670 self.emit_by_name::<()>("set-anchor", &[]);
3671 }
3672
3673 /// Gets emitted to toggle the `cursor-visible` property.
3674 ///
3675 /// The ::toggle-cursor-visible signal is a
3676 /// [keybinding signal](class.SignalAction.html).
3677 ///
3678 /// The default binding for this signal is <kbd>F7</kbd>.
3679 #[doc(alias = "toggle-cursor-visible")]
3680 fn connect_toggle_cursor_visible<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
3681 unsafe extern "C" fn toggle_cursor_visible_trampoline<
3682 P: IsA<TextView>,
3683 F: Fn(&P) + 'static,
3684 >(
3685 this: *mut ffi::GtkTextView,
3686 f: glib::ffi::gpointer,
3687 ) {
3688 unsafe {
3689 let f: &F = &*(f as *const F);
3690 f(TextView::from_glib_borrow(this).unsafe_cast_ref())
3691 }
3692 }
3693 unsafe {
3694 let f: Box_<F> = Box_::new(f);
3695 connect_raw(
3696 self.as_ptr() as *mut _,
3697 c"toggle-cursor-visible".as_ptr() as *const _,
3698 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
3699 toggle_cursor_visible_trampoline::<Self, F> as *const (),
3700 )),
3701 Box_::into_raw(f),
3702 )
3703 }
3704 }
3705
3706 fn emit_toggle_cursor_visible(&self) {
3707 self.emit_by_name::<()>("toggle-cursor-visible", &[]);
3708 }
3709
3710 /// Gets emitted to toggle the overwrite mode of the text view.
3711 ///
3712 /// The ::toggle-overwrite signal is a [keybinding signal](class.SignalAction.html).
3713 ///
3714 /// The default binding for this signal is <kbd>Insert</kbd>.
3715 #[doc(alias = "toggle-overwrite")]
3716 fn connect_toggle_overwrite<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
3717 unsafe extern "C" fn toggle_overwrite_trampoline<P: IsA<TextView>, F: Fn(&P) + 'static>(
3718 this: *mut ffi::GtkTextView,
3719 f: glib::ffi::gpointer,
3720 ) {
3721 unsafe {
3722 let f: &F = &*(f as *const F);
3723 f(TextView::from_glib_borrow(this).unsafe_cast_ref())
3724 }
3725 }
3726 unsafe {
3727 let f: Box_<F> = Box_::new(f);
3728 connect_raw(
3729 self.as_ptr() as *mut _,
3730 c"toggle-overwrite".as_ptr() as *const _,
3731 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
3732 toggle_overwrite_trampoline::<Self, F> as *const (),
3733 )),
3734 Box_::into_raw(f),
3735 )
3736 }
3737 }
3738
3739 fn emit_toggle_overwrite(&self) {
3740 self.emit_by_name::<()>("toggle-overwrite", &[]);
3741 }
3742
3743 #[doc(alias = "accepts-tab")]
3744 fn connect_accepts_tab_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
3745 unsafe extern "C" fn notify_accepts_tab_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 unsafe {
3754 let f: &F = &*(f as *const F);
3755 f(TextView::from_glib_borrow(this).unsafe_cast_ref())
3756 }
3757 }
3758 unsafe {
3759 let f: Box_<F> = Box_::new(f);
3760 connect_raw(
3761 self.as_ptr() as *mut _,
3762 c"notify::accepts-tab".as_ptr() as *const _,
3763 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
3764 notify_accepts_tab_trampoline::<Self, F> as *const (),
3765 )),
3766 Box_::into_raw(f),
3767 )
3768 }
3769 }
3770
3771 #[doc(alias = "bottom-margin")]
3772 fn connect_bottom_margin_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
3773 unsafe extern "C" fn notify_bottom_margin_trampoline<
3774 P: IsA<TextView>,
3775 F: Fn(&P) + 'static,
3776 >(
3777 this: *mut ffi::GtkTextView,
3778 _param_spec: glib::ffi::gpointer,
3779 f: glib::ffi::gpointer,
3780 ) {
3781 unsafe {
3782 let f: &F = &*(f as *const F);
3783 f(TextView::from_glib_borrow(this).unsafe_cast_ref())
3784 }
3785 }
3786 unsafe {
3787 let f: Box_<F> = Box_::new(f);
3788 connect_raw(
3789 self.as_ptr() as *mut _,
3790 c"notify::bottom-margin".as_ptr() as *const _,
3791 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
3792 notify_bottom_margin_trampoline::<Self, F> as *const (),
3793 )),
3794 Box_::into_raw(f),
3795 )
3796 }
3797 }
3798
3799 #[doc(alias = "buffer")]
3800 fn connect_buffer_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
3801 unsafe extern "C" fn notify_buffer_trampoline<P: IsA<TextView>, F: Fn(&P) + 'static>(
3802 this: *mut ffi::GtkTextView,
3803 _param_spec: glib::ffi::gpointer,
3804 f: glib::ffi::gpointer,
3805 ) {
3806 unsafe {
3807 let f: &F = &*(f as *const F);
3808 f(TextView::from_glib_borrow(this).unsafe_cast_ref())
3809 }
3810 }
3811 unsafe {
3812 let f: Box_<F> = Box_::new(f);
3813 connect_raw(
3814 self.as_ptr() as *mut _,
3815 c"notify::buffer".as_ptr() as *const _,
3816 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
3817 notify_buffer_trampoline::<Self, F> as *const (),
3818 )),
3819 Box_::into_raw(f),
3820 )
3821 }
3822 }
3823
3824 #[doc(alias = "cursor-visible")]
3825 fn connect_cursor_visible_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
3826 unsafe extern "C" fn notify_cursor_visible_trampoline<
3827 P: IsA<TextView>,
3828 F: Fn(&P) + 'static,
3829 >(
3830 this: *mut ffi::GtkTextView,
3831 _param_spec: glib::ffi::gpointer,
3832 f: glib::ffi::gpointer,
3833 ) {
3834 unsafe {
3835 let f: &F = &*(f as *const F);
3836 f(TextView::from_glib_borrow(this).unsafe_cast_ref())
3837 }
3838 }
3839 unsafe {
3840 let f: Box_<F> = Box_::new(f);
3841 connect_raw(
3842 self.as_ptr() as *mut _,
3843 c"notify::cursor-visible".as_ptr() as *const _,
3844 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
3845 notify_cursor_visible_trampoline::<Self, F> as *const (),
3846 )),
3847 Box_::into_raw(f),
3848 )
3849 }
3850 }
3851
3852 #[doc(alias = "editable")]
3853 fn connect_editable_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
3854 unsafe extern "C" fn notify_editable_trampoline<P: IsA<TextView>, F: Fn(&P) + 'static>(
3855 this: *mut ffi::GtkTextView,
3856 _param_spec: glib::ffi::gpointer,
3857 f: glib::ffi::gpointer,
3858 ) {
3859 unsafe {
3860 let f: &F = &*(f as *const F);
3861 f(TextView::from_glib_borrow(this).unsafe_cast_ref())
3862 }
3863 }
3864 unsafe {
3865 let f: Box_<F> = Box_::new(f);
3866 connect_raw(
3867 self.as_ptr() as *mut _,
3868 c"notify::editable".as_ptr() as *const _,
3869 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
3870 notify_editable_trampoline::<Self, F> as *const (),
3871 )),
3872 Box_::into_raw(f),
3873 )
3874 }
3875 }
3876
3877 #[doc(alias = "extra-menu")]
3878 fn connect_extra_menu_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
3879 unsafe extern "C" fn notify_extra_menu_trampoline<P: IsA<TextView>, F: Fn(&P) + 'static>(
3880 this: *mut ffi::GtkTextView,
3881 _param_spec: glib::ffi::gpointer,
3882 f: glib::ffi::gpointer,
3883 ) {
3884 unsafe {
3885 let f: &F = &*(f as *const F);
3886 f(TextView::from_glib_borrow(this).unsafe_cast_ref())
3887 }
3888 }
3889 unsafe {
3890 let f: Box_<F> = Box_::new(f);
3891 connect_raw(
3892 self.as_ptr() as *mut _,
3893 c"notify::extra-menu".as_ptr() as *const _,
3894 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
3895 notify_extra_menu_trampoline::<Self, F> as *const (),
3896 )),
3897 Box_::into_raw(f),
3898 )
3899 }
3900 }
3901
3902 #[doc(alias = "im-module")]
3903 fn connect_im_module_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
3904 unsafe extern "C" fn notify_im_module_trampoline<P: IsA<TextView>, F: Fn(&P) + 'static>(
3905 this: *mut ffi::GtkTextView,
3906 _param_spec: glib::ffi::gpointer,
3907 f: glib::ffi::gpointer,
3908 ) {
3909 unsafe {
3910 let f: &F = &*(f as *const F);
3911 f(TextView::from_glib_borrow(this).unsafe_cast_ref())
3912 }
3913 }
3914 unsafe {
3915 let f: Box_<F> = Box_::new(f);
3916 connect_raw(
3917 self.as_ptr() as *mut _,
3918 c"notify::im-module".as_ptr() as *const _,
3919 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
3920 notify_im_module_trampoline::<Self, F> as *const (),
3921 )),
3922 Box_::into_raw(f),
3923 )
3924 }
3925 }
3926
3927 #[doc(alias = "indent")]
3928 fn connect_indent_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
3929 unsafe extern "C" fn notify_indent_trampoline<P: IsA<TextView>, F: Fn(&P) + 'static>(
3930 this: *mut ffi::GtkTextView,
3931 _param_spec: glib::ffi::gpointer,
3932 f: glib::ffi::gpointer,
3933 ) {
3934 unsafe {
3935 let f: &F = &*(f as *const F);
3936 f(TextView::from_glib_borrow(this).unsafe_cast_ref())
3937 }
3938 }
3939 unsafe {
3940 let f: Box_<F> = Box_::new(f);
3941 connect_raw(
3942 self.as_ptr() as *mut _,
3943 c"notify::indent".as_ptr() as *const _,
3944 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
3945 notify_indent_trampoline::<Self, F> as *const (),
3946 )),
3947 Box_::into_raw(f),
3948 )
3949 }
3950 }
3951
3952 #[doc(alias = "input-hints")]
3953 fn connect_input_hints_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
3954 unsafe extern "C" fn notify_input_hints_trampoline<
3955 P: IsA<TextView>,
3956 F: Fn(&P) + 'static,
3957 >(
3958 this: *mut ffi::GtkTextView,
3959 _param_spec: glib::ffi::gpointer,
3960 f: glib::ffi::gpointer,
3961 ) {
3962 unsafe {
3963 let f: &F = &*(f as *const F);
3964 f(TextView::from_glib_borrow(this).unsafe_cast_ref())
3965 }
3966 }
3967 unsafe {
3968 let f: Box_<F> = Box_::new(f);
3969 connect_raw(
3970 self.as_ptr() as *mut _,
3971 c"notify::input-hints".as_ptr() as *const _,
3972 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
3973 notify_input_hints_trampoline::<Self, F> as *const (),
3974 )),
3975 Box_::into_raw(f),
3976 )
3977 }
3978 }
3979
3980 #[doc(alias = "input-purpose")]
3981 fn connect_input_purpose_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
3982 unsafe extern "C" fn notify_input_purpose_trampoline<
3983 P: IsA<TextView>,
3984 F: Fn(&P) + 'static,
3985 >(
3986 this: *mut ffi::GtkTextView,
3987 _param_spec: glib::ffi::gpointer,
3988 f: glib::ffi::gpointer,
3989 ) {
3990 unsafe {
3991 let f: &F = &*(f as *const F);
3992 f(TextView::from_glib_borrow(this).unsafe_cast_ref())
3993 }
3994 }
3995 unsafe {
3996 let f: Box_<F> = Box_::new(f);
3997 connect_raw(
3998 self.as_ptr() as *mut _,
3999 c"notify::input-purpose".as_ptr() as *const _,
4000 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
4001 notify_input_purpose_trampoline::<Self, F> as *const (),
4002 )),
4003 Box_::into_raw(f),
4004 )
4005 }
4006 }
4007
4008 #[doc(alias = "justification")]
4009 fn connect_justification_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
4010 unsafe extern "C" fn notify_justification_trampoline<
4011 P: IsA<TextView>,
4012 F: Fn(&P) + 'static,
4013 >(
4014 this: *mut ffi::GtkTextView,
4015 _param_spec: glib::ffi::gpointer,
4016 f: glib::ffi::gpointer,
4017 ) {
4018 unsafe {
4019 let f: &F = &*(f as *const F);
4020 f(TextView::from_glib_borrow(this).unsafe_cast_ref())
4021 }
4022 }
4023 unsafe {
4024 let f: Box_<F> = Box_::new(f);
4025 connect_raw(
4026 self.as_ptr() as *mut _,
4027 c"notify::justification".as_ptr() as *const _,
4028 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
4029 notify_justification_trampoline::<Self, F> as *const (),
4030 )),
4031 Box_::into_raw(f),
4032 )
4033 }
4034 }
4035
4036 #[doc(alias = "left-margin")]
4037 fn connect_left_margin_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
4038 unsafe extern "C" fn notify_left_margin_trampoline<
4039 P: IsA<TextView>,
4040 F: Fn(&P) + 'static,
4041 >(
4042 this: *mut ffi::GtkTextView,
4043 _param_spec: glib::ffi::gpointer,
4044 f: glib::ffi::gpointer,
4045 ) {
4046 unsafe {
4047 let f: &F = &*(f as *const F);
4048 f(TextView::from_glib_borrow(this).unsafe_cast_ref())
4049 }
4050 }
4051 unsafe {
4052 let f: Box_<F> = Box_::new(f);
4053 connect_raw(
4054 self.as_ptr() as *mut _,
4055 c"notify::left-margin".as_ptr() as *const _,
4056 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
4057 notify_left_margin_trampoline::<Self, F> as *const (),
4058 )),
4059 Box_::into_raw(f),
4060 )
4061 }
4062 }
4063
4064 #[doc(alias = "monospace")]
4065 fn connect_monospace_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
4066 unsafe extern "C" fn notify_monospace_trampoline<P: IsA<TextView>, F: Fn(&P) + 'static>(
4067 this: *mut ffi::GtkTextView,
4068 _param_spec: glib::ffi::gpointer,
4069 f: glib::ffi::gpointer,
4070 ) {
4071 unsafe {
4072 let f: &F = &*(f as *const F);
4073 f(TextView::from_glib_borrow(this).unsafe_cast_ref())
4074 }
4075 }
4076 unsafe {
4077 let f: Box_<F> = Box_::new(f);
4078 connect_raw(
4079 self.as_ptr() as *mut _,
4080 c"notify::monospace".as_ptr() as *const _,
4081 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
4082 notify_monospace_trampoline::<Self, F> as *const (),
4083 )),
4084 Box_::into_raw(f),
4085 )
4086 }
4087 }
4088
4089 #[doc(alias = "overwrite")]
4090 fn connect_overwrite_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
4091 unsafe extern "C" fn notify_overwrite_trampoline<P: IsA<TextView>, F: Fn(&P) + 'static>(
4092 this: *mut ffi::GtkTextView,
4093 _param_spec: glib::ffi::gpointer,
4094 f: glib::ffi::gpointer,
4095 ) {
4096 unsafe {
4097 let f: &F = &*(f as *const F);
4098 f(TextView::from_glib_borrow(this).unsafe_cast_ref())
4099 }
4100 }
4101 unsafe {
4102 let f: Box_<F> = Box_::new(f);
4103 connect_raw(
4104 self.as_ptr() as *mut _,
4105 c"notify::overwrite".as_ptr() as *const _,
4106 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
4107 notify_overwrite_trampoline::<Self, F> as *const (),
4108 )),
4109 Box_::into_raw(f),
4110 )
4111 }
4112 }
4113
4114 #[doc(alias = "pixels-above-lines")]
4115 fn connect_pixels_above_lines_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
4116 unsafe extern "C" fn notify_pixels_above_lines_trampoline<
4117 P: IsA<TextView>,
4118 F: Fn(&P) + 'static,
4119 >(
4120 this: *mut ffi::GtkTextView,
4121 _param_spec: glib::ffi::gpointer,
4122 f: glib::ffi::gpointer,
4123 ) {
4124 unsafe {
4125 let f: &F = &*(f as *const F);
4126 f(TextView::from_glib_borrow(this).unsafe_cast_ref())
4127 }
4128 }
4129 unsafe {
4130 let f: Box_<F> = Box_::new(f);
4131 connect_raw(
4132 self.as_ptr() as *mut _,
4133 c"notify::pixels-above-lines".as_ptr() as *const _,
4134 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
4135 notify_pixels_above_lines_trampoline::<Self, F> as *const (),
4136 )),
4137 Box_::into_raw(f),
4138 )
4139 }
4140 }
4141
4142 #[doc(alias = "pixels-below-lines")]
4143 fn connect_pixels_below_lines_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
4144 unsafe extern "C" fn notify_pixels_below_lines_trampoline<
4145 P: IsA<TextView>,
4146 F: Fn(&P) + 'static,
4147 >(
4148 this: *mut ffi::GtkTextView,
4149 _param_spec: glib::ffi::gpointer,
4150 f: glib::ffi::gpointer,
4151 ) {
4152 unsafe {
4153 let f: &F = &*(f as *const F);
4154 f(TextView::from_glib_borrow(this).unsafe_cast_ref())
4155 }
4156 }
4157 unsafe {
4158 let f: Box_<F> = Box_::new(f);
4159 connect_raw(
4160 self.as_ptr() as *mut _,
4161 c"notify::pixels-below-lines".as_ptr() as *const _,
4162 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
4163 notify_pixels_below_lines_trampoline::<Self, F> as *const (),
4164 )),
4165 Box_::into_raw(f),
4166 )
4167 }
4168 }
4169
4170 #[doc(alias = "pixels-inside-wrap")]
4171 fn connect_pixels_inside_wrap_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
4172 unsafe extern "C" fn notify_pixels_inside_wrap_trampoline<
4173 P: IsA<TextView>,
4174 F: Fn(&P) + 'static,
4175 >(
4176 this: *mut ffi::GtkTextView,
4177 _param_spec: glib::ffi::gpointer,
4178 f: glib::ffi::gpointer,
4179 ) {
4180 unsafe {
4181 let f: &F = &*(f as *const F);
4182 f(TextView::from_glib_borrow(this).unsafe_cast_ref())
4183 }
4184 }
4185 unsafe {
4186 let f: Box_<F> = Box_::new(f);
4187 connect_raw(
4188 self.as_ptr() as *mut _,
4189 c"notify::pixels-inside-wrap".as_ptr() as *const _,
4190 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
4191 notify_pixels_inside_wrap_trampoline::<Self, F> as *const (),
4192 )),
4193 Box_::into_raw(f),
4194 )
4195 }
4196 }
4197
4198 #[doc(alias = "right-margin")]
4199 fn connect_right_margin_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
4200 unsafe extern "C" fn notify_right_margin_trampoline<
4201 P: IsA<TextView>,
4202 F: Fn(&P) + 'static,
4203 >(
4204 this: *mut ffi::GtkTextView,
4205 _param_spec: glib::ffi::gpointer,
4206 f: glib::ffi::gpointer,
4207 ) {
4208 unsafe {
4209 let f: &F = &*(f as *const F);
4210 f(TextView::from_glib_borrow(this).unsafe_cast_ref())
4211 }
4212 }
4213 unsafe {
4214 let f: Box_<F> = Box_::new(f);
4215 connect_raw(
4216 self.as_ptr() as *mut _,
4217 c"notify::right-margin".as_ptr() as *const _,
4218 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
4219 notify_right_margin_trampoline::<Self, F> as *const (),
4220 )),
4221 Box_::into_raw(f),
4222 )
4223 }
4224 }
4225
4226 #[doc(alias = "tabs")]
4227 fn connect_tabs_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
4228 unsafe extern "C" fn notify_tabs_trampoline<P: IsA<TextView>, F: Fn(&P) + 'static>(
4229 this: *mut ffi::GtkTextView,
4230 _param_spec: glib::ffi::gpointer,
4231 f: glib::ffi::gpointer,
4232 ) {
4233 unsafe {
4234 let f: &F = &*(f as *const F);
4235 f(TextView::from_glib_borrow(this).unsafe_cast_ref())
4236 }
4237 }
4238 unsafe {
4239 let f: Box_<F> = Box_::new(f);
4240 connect_raw(
4241 self.as_ptr() as *mut _,
4242 c"notify::tabs".as_ptr() as *const _,
4243 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
4244 notify_tabs_trampoline::<Self, F> as *const (),
4245 )),
4246 Box_::into_raw(f),
4247 )
4248 }
4249 }
4250
4251 #[doc(alias = "top-margin")]
4252 fn connect_top_margin_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
4253 unsafe extern "C" fn notify_top_margin_trampoline<P: IsA<TextView>, F: Fn(&P) + 'static>(
4254 this: *mut ffi::GtkTextView,
4255 _param_spec: glib::ffi::gpointer,
4256 f: glib::ffi::gpointer,
4257 ) {
4258 unsafe {
4259 let f: &F = &*(f as *const F);
4260 f(TextView::from_glib_borrow(this).unsafe_cast_ref())
4261 }
4262 }
4263 unsafe {
4264 let f: Box_<F> = Box_::new(f);
4265 connect_raw(
4266 self.as_ptr() as *mut _,
4267 c"notify::top-margin".as_ptr() as *const _,
4268 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
4269 notify_top_margin_trampoline::<Self, F> as *const (),
4270 )),
4271 Box_::into_raw(f),
4272 )
4273 }
4274 }
4275
4276 #[doc(alias = "wrap-mode")]
4277 fn connect_wrap_mode_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
4278 unsafe extern "C" fn notify_wrap_mode_trampoline<P: IsA<TextView>, F: Fn(&P) + 'static>(
4279 this: *mut ffi::GtkTextView,
4280 _param_spec: glib::ffi::gpointer,
4281 f: glib::ffi::gpointer,
4282 ) {
4283 unsafe {
4284 let f: &F = &*(f as *const F);
4285 f(TextView::from_glib_borrow(this).unsafe_cast_ref())
4286 }
4287 }
4288 unsafe {
4289 let f: Box_<F> = Box_::new(f);
4290 connect_raw(
4291 self.as_ptr() as *mut _,
4292 c"notify::wrap-mode".as_ptr() as *const _,
4293 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
4294 notify_wrap_mode_trampoline::<Self, F> as *const (),
4295 )),
4296 Box_::into_raw(f),
4297 )
4298 }
4299 }
4300}
4301
4302impl<O: IsA<TextView>> TextViewExt for O {}