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