Skip to main content

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