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