gtk4/auto/
text_view.rs

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