gtk4/auto/
text_view.rs

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