gtk4/auto/editable.rs
1// This file was generated by gir (https://github.com/gtk-rs/gir)
2// from gir-files (https://github.com/gtk-rs/gir-files)
3// DO NOT EDIT
4
5#[cfg(feature = "v4_10")]
6#[cfg_attr(docsrs, doc(cfg(feature = "v4_10")))]
7use crate::{Accessible, AccessiblePlatformState};
8use crate::{Buildable, ConstraintTarget, Widget, ffi};
9use glib::{
10 object::ObjectType as _,
11 prelude::*,
12 signal::{SignalHandlerId, connect_raw},
13 translate::*,
14};
15use std::boxed::Box as Box_;
16
17#[cfg(feature = "v4_10")]
18#[cfg_attr(docsrs, doc(cfg(feature = "v4_10")))]
19glib::wrapper! {
20 /// Interface for single-line text editing widgets.
21 ///
22 /// Typical examples of editable widgets are [`Entry`][crate::Entry] and
23 /// [`SpinButton`][crate::SpinButton]. It contains functions for generically manipulating
24 /// an editable widget, a large number of action signals used for key bindings,
25 /// and several signals that an application can connect to modify the behavior
26 /// of a widget.
27 ///
28 /// As an example of the latter usage, by connecting the following handler to
29 /// [`insert-text`][struct@crate::Editable#insert-text], an application can convert all entry
30 /// into a widget into uppercase.
31 ///
32 /// ## Forcing entry to uppercase.
33 ///
34 /// **⚠️ The following code is in c ⚠️**
35 ///
36 /// ```c
37 /// #include <ctype.h>
38 ///
39 /// void
40 /// insert_text_handler (GtkEditable *editable,
41 /// const char *text,
42 /// int length,
43 /// int *position,
44 /// gpointer data)
45 /// {
46 /// char *result = g_utf8_strup (text, length);
47 ///
48 /// g_signal_handlers_block_by_func (editable,
49 /// (gpointer) insert_text_handler, data);
50 /// gtk_editable_insert_text (editable, result, length, position);
51 /// g_signal_handlers_unblock_by_func (editable,
52 /// (gpointer) insert_text_handler, data);
53 ///
54 /// g_signal_stop_emission_by_name (editable, "insert_text");
55 ///
56 /// g_free (result);
57 /// }
58 /// ```
59 ///
60 /// ## Implementing GtkEditable
61 ///
62 /// The most likely scenario for implementing [`Editable`][crate::Editable] on your own widget
63 /// is that you will embed a [`Text`][crate::Text] inside a complex widget, and want to
64 /// delegate the editable functionality to that text widget. [`Editable`][crate::Editable]
65 /// provides some utility functions to make this easy.
66 ///
67 /// In your class_init function, call [`install_properties()`][Self::install_properties()],
68 /// passing the first available property ID:
69 ///
70 /// **⚠️ The following code is in c ⚠️**
71 ///
72 /// ```c
73 /// static void
74 /// my_class_init (MyClass *class)
75 /// {
76 /// ...
77 /// g_object_class_install_properties (object_class, NUM_PROPERTIES, props);
78 /// gtk_editable_install_properties (object_class, NUM_PROPERTIES);
79 /// ...
80 /// }
81 /// ```
82 ///
83 /// In your interface_init function for the [`Editable`][crate::Editable] interface, provide
84 /// an implementation for the get_delegate vfunc that returns your text widget:
85 ///
86 /// **⚠️ The following code is in c ⚠️**
87 ///
88 /// ```c
89 /// GtkEditable *
90 /// get_editable_delegate (GtkEditable *editable)
91 /// {
92 /// return GTK_EDITABLE (MY_WIDGET (editable)->text_widget);
93 /// }
94 ///
95 /// static void
96 /// my_editable_init (GtkEditableInterface *iface)
97 /// {
98 /// iface->get_delegate = get_editable_delegate;
99 /// }
100 /// ```
101 ///
102 /// You don't need to provide any other vfuncs. The default implementations
103 /// work by forwarding to the delegate that the GtkEditableInterface.get_delegate()
104 /// vfunc returns.
105 ///
106 /// In your instance_init function, create your text widget, and then call
107 /// [`EditableExt::init_delegate()`][crate::prelude::EditableExt::init_delegate()]:
108 ///
109 /// **⚠️ The following code is in c ⚠️**
110 ///
111 /// ```c
112 /// static void
113 /// my_widget_init (MyWidget *self)
114 /// {
115 /// ...
116 /// self->text_widget = gtk_text_new ();
117 /// gtk_editable_init_delegate (GTK_EDITABLE (self));
118 /// ...
119 /// }
120 /// ```
121 ///
122 /// In your dispose function, call [`EditableExt::finish_delegate()`][crate::prelude::EditableExt::finish_delegate()] before
123 /// destroying your text widget:
124 ///
125 /// **⚠️ The following code is in c ⚠️**
126 ///
127 /// ```c
128 /// static void
129 /// my_widget_dispose (GObject *object)
130 /// {
131 /// ...
132 /// gtk_editable_finish_delegate (GTK_EDITABLE (self));
133 /// g_clear_pointer (&self->text_widget, gtk_widget_unparent);
134 /// ...
135 /// }
136 /// ```
137 ///
138 /// Finally, use [`delegate_set_property()`][Self::delegate_set_property()] in your `set_property`
139 /// function (and similar for `get_property`), to set the editable properties:
140 ///
141 /// **⚠️ The following code is in c ⚠️**
142 ///
143 /// ```c
144 /// ...
145 /// if (gtk_editable_delegate_set_property (object, prop_id, value, pspec))
146 /// return;
147 ///
148 /// switch (prop_id)
149 /// ...
150 /// ```
151 ///
152 /// It is important to note that if you create a [`Editable`][crate::Editable] that uses
153 /// a delegate, the low level [`insert-text`][struct@crate::Editable#insert-text] and
154 /// [`delete-text`][struct@crate::Editable#delete-text] signals will be propagated from the
155 /// "wrapper" editable to the delegate, but they will not be propagated from
156 /// the delegate to the "wrapper" editable, as they would cause an infinite
157 /// recursion. If you wish to connect to the [`insert-text`][struct@crate::Editable#insert-text]
158 /// and [`delete-text`][struct@crate::Editable#delete-text] signals, you will need to connect
159 /// to them on the delegate obtained via [`EditableExt::delegate()`][crate::prelude::EditableExt::delegate()].
160 ///
161 /// ## Properties
162 ///
163 ///
164 /// #### `complete-text`
165 /// The contents of the entry, including uncommited content such as the
166 /// preedit.
167 ///
168 /// Readable
169 ///
170 ///
171 /// #### `cursor-position`
172 /// The current position of the insertion cursor in chars.
173 ///
174 /// Readable
175 ///
176 ///
177 /// #### `editable`
178 /// Whether the entry contents can be edited.
179 ///
180 /// Readable | Writable
181 ///
182 ///
183 /// #### `enable-undo`
184 /// If undo/redo should be enabled for the editable.
185 ///
186 /// Readable | Writable
187 ///
188 ///
189 /// #### `input-interceptor`
190 /// The widget used to intercept input for this editable
191 ///
192 /// Readable | Writable
193 ///
194 ///
195 /// #### `max-width-chars`
196 /// The desired maximum width of the entry, in characters.
197 ///
198 /// Readable | Writable
199 ///
200 ///
201 /// #### `selection-bound`
202 /// The position of the opposite end of the selection from the cursor in chars.
203 ///
204 /// Readable
205 ///
206 ///
207 /// #### `text`
208 /// The contents of the entry.
209 ///
210 /// Readable | Writable
211 ///
212 ///
213 /// #### `width-chars`
214 /// Number of characters to leave space for in the entry.
215 ///
216 /// Readable | Writable
217 ///
218 ///
219 /// #### `xalign`
220 /// The horizontal alignment, from 0 (left) to 1 (right).
221 ///
222 /// Reversed for RTL layouts.
223 ///
224 /// Readable | Writable
225 /// <details><summary><h4>Widget</h4></summary>
226 ///
227 ///
228 /// #### `can-focus`
229 /// Whether the widget or any of its descendents can accept
230 /// the input focus.
231 ///
232 /// This property is meant to be set by widget implementations,
233 /// typically in their instance init function.
234 ///
235 /// Readable | Writable
236 ///
237 ///
238 /// #### `can-target`
239 /// Whether the widget can receive pointer events.
240 ///
241 /// Readable | Writable
242 ///
243 ///
244 /// #### `css-classes`
245 /// A list of css classes applied to this widget.
246 ///
247 /// Readable | Writable
248 ///
249 ///
250 /// #### `css-name`
251 /// The name of this widget in the CSS tree.
252 ///
253 /// This property is meant to be set by widget implementations,
254 /// typically in their instance init function.
255 ///
256 /// Readable | Writable | Construct Only
257 ///
258 ///
259 /// #### `cursor`
260 /// The cursor used by @widget.
261 ///
262 /// Readable | Writable
263 ///
264 ///
265 /// #### `focus-on-click`
266 /// Whether the widget should grab focus when it is clicked with the mouse.
267 ///
268 /// This property is only relevant for widgets that can take focus.
269 ///
270 /// Readable | Writable
271 ///
272 ///
273 /// #### `focusable`
274 /// Whether this widget itself will accept the input focus.
275 ///
276 /// Readable | Writable
277 ///
278 ///
279 /// #### `halign`
280 /// How to distribute horizontal space if widget gets extra space.
281 ///
282 /// Readable | Writable
283 ///
284 ///
285 /// #### `has-default`
286 /// Whether the widget is the default widget.
287 ///
288 /// Readable
289 ///
290 ///
291 /// #### `has-focus`
292 /// Whether the widget has the input focus.
293 ///
294 /// Readable
295 ///
296 ///
297 /// #### `has-tooltip`
298 /// Enables or disables the emission of the [`query-tooltip`][struct@crate::Widget#query-tooltip]
299 /// signal on @widget.
300 ///
301 /// A true value indicates that @widget can have a tooltip, in this case
302 /// the widget will be queried using [`query-tooltip`][struct@crate::Widget#query-tooltip] to
303 /// determine whether it will provide a tooltip or not.
304 ///
305 /// Readable | Writable
306 ///
307 ///
308 /// #### `height-request`
309 /// Overrides for height request of the widget.
310 ///
311 /// If this is -1, the natural request will be used.
312 ///
313 /// Readable | Writable
314 ///
315 ///
316 /// #### `hexpand`
317 /// Whether to expand horizontally.
318 ///
319 /// Readable | Writable
320 ///
321 ///
322 /// #### `hexpand-set`
323 /// Whether to use the `hexpand` property.
324 ///
325 /// Readable | Writable
326 ///
327 ///
328 /// #### `layout-manager`
329 /// The [`LayoutManager`][crate::LayoutManager] instance to use to compute
330 /// the preferred size of the widget, and allocate its children.
331 ///
332 /// This property is meant to be set by widget implementations,
333 /// typically in their instance init function.
334 ///
335 /// Readable | Writable
336 ///
337 ///
338 /// #### `limit-events`
339 /// Makes this widget act like a modal dialog, with respect to
340 /// event delivery.
341 ///
342 /// Global event controllers will not handle events with targets
343 /// inside the widget, unless they are set up to ignore propagation
344 /// limits. See [`EventControllerExt::set_propagation_limit()`][crate::prelude::EventControllerExt::set_propagation_limit()].
345 ///
346 /// Readable | Writable
347 ///
348 ///
349 /// #### `margin-bottom`
350 /// Margin on bottom side of widget.
351 ///
352 /// This property adds margin outside of the widget's normal size
353 /// request, the margin will be added in addition to the size from
354 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
355 ///
356 /// Readable | Writable
357 ///
358 ///
359 /// #### `margin-end`
360 /// Margin on end of widget, horizontally.
361 ///
362 /// This property supports left-to-right and right-to-left text
363 /// directions.
364 ///
365 /// This property adds margin outside of the widget's normal size
366 /// request, the margin will be added in addition to the size from
367 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
368 ///
369 /// Readable | Writable
370 ///
371 ///
372 /// #### `margin-start`
373 /// Margin on start of widget, horizontally.
374 ///
375 /// This property supports left-to-right and right-to-left text
376 /// directions.
377 ///
378 /// This property adds margin outside of the widget's normal size
379 /// request, the margin will be added in addition to the size from
380 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
381 ///
382 /// Readable | Writable
383 ///
384 ///
385 /// #### `margin-top`
386 /// Margin on top side of widget.
387 ///
388 /// This property adds margin outside of the widget's normal size
389 /// request, the margin will be added in addition to the size from
390 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
391 ///
392 /// Readable | Writable
393 ///
394 ///
395 /// #### `name`
396 /// The name of the widget.
397 ///
398 /// Readable | Writable
399 ///
400 ///
401 /// #### `opacity`
402 /// The requested opacity of the widget.
403 ///
404 /// Readable | Writable
405 ///
406 ///
407 /// #### `overflow`
408 /// How content outside the widget's content area is treated.
409 ///
410 /// This property is meant to be set by widget implementations,
411 /// typically in their instance init function.
412 ///
413 /// Readable | Writable
414 ///
415 ///
416 /// #### `parent`
417 /// The parent widget of this widget.
418 ///
419 /// Readable
420 ///
421 ///
422 /// #### `receives-default`
423 /// Whether the widget will receive the default action when it is focused.
424 ///
425 /// Readable | Writable
426 ///
427 ///
428 /// #### `root`
429 /// The [`Root`][crate::Root] widget of the widget tree containing this widget.
430 ///
431 /// This will be `NULL` if the widget is not contained in a root widget.
432 ///
433 /// Readable
434 ///
435 ///
436 /// #### `scale-factor`
437 /// The scale factor of the widget.
438 ///
439 /// Readable
440 ///
441 ///
442 /// #### `sensitive`
443 /// Whether the widget responds to input.
444 ///
445 /// Readable | Writable
446 ///
447 ///
448 /// #### `tooltip-markup`
449 /// Sets the text of tooltip to be the given string, which is marked up
450 /// with Pango markup.
451 ///
452 /// Also see [`Tooltip::set_markup()`][crate::Tooltip::set_markup()].
453 ///
454 /// This is a convenience property which will take care of getting the
455 /// tooltip shown if the given string is not `NULL`:
456 /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
457 /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
458 /// the default signal handler.
459 ///
460 /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
461 /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
462 ///
463 /// Readable | Writable
464 ///
465 ///
466 /// #### `tooltip-text`
467 /// Sets the text of tooltip to be the given string.
468 ///
469 /// Also see [`Tooltip::set_text()`][crate::Tooltip::set_text()].
470 ///
471 /// This is a convenience property which will take care of getting the
472 /// tooltip shown if the given string is not `NULL`:
473 /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
474 /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
475 /// the default signal handler.
476 ///
477 /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
478 /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
479 ///
480 /// Readable | Writable
481 ///
482 ///
483 /// #### `valign`
484 /// How to distribute vertical space if widget gets extra space.
485 ///
486 /// Readable | Writable
487 ///
488 ///
489 /// #### `vexpand`
490 /// Whether to expand vertically.
491 ///
492 /// Readable | Writable
493 ///
494 ///
495 /// #### `vexpand-set`
496 /// Whether to use the `vexpand` property.
497 ///
498 /// Readable | Writable
499 ///
500 ///
501 /// #### `visible`
502 /// Whether the widget is visible.
503 ///
504 /// Readable | Writable
505 ///
506 ///
507 /// #### `width-request`
508 /// Overrides for width request of the widget.
509 ///
510 /// If this is -1, the natural request will be used.
511 ///
512 /// Readable | Writable
513 /// </details>
514 /// <details><summary><h4>Accessible</h4></summary>
515 ///
516 ///
517 /// #### `accessible-role`
518 /// The accessible role of the given [`Accessible`][crate::Accessible] implementation.
519 ///
520 /// The accessible role cannot be changed once set.
521 ///
522 /// Readable | Writable
523 /// </details>
524 ///
525 /// ## Signals
526 ///
527 ///
528 /// #### `changed`
529 /// Emitted at the end of a single user-visible operation on the
530 /// contents.
531 ///
532 /// E.g., a paste operation that replaces the contents of the
533 /// selection will cause only one signal emission (even though it
534 /// is implemented by first deleting the selection, then inserting
535 /// the new content, and may cause multiple ::notify::text signals
536 /// to be emitted).
537 ///
538 ///
539 ///
540 ///
541 /// #### `delete-text`
542 /// Emitted when text is deleted from the widget by the user.
543 ///
544 /// The default handler for this signal will normally be responsible for
545 /// deleting the text, so by connecting to this signal and then stopping
546 /// the signal with g_signal_stop_emission(), it is possible to modify the
547 /// range of deleted text, or prevent it from being deleted entirely.
548 ///
549 /// The @start_pos and @end_pos parameters are interpreted as for
550 /// [`EditableExt::delete_text()`][crate::prelude::EditableExt::delete_text()].
551 ///
552 ///
553 ///
554 ///
555 /// #### `input-intercepted`
556 /// Emitted whenever keyboard input has been handled through the
557 /// input interceptor widget set through [`EditableExt::set_input_interceptor()`][crate::prelude::EditableExt::set_input_interceptor()]
558 ///
559 /// A typical reaction to this event would be to show and focus @editable, so
560 /// that input is handled directly. In that case keyboard input will no longer
561 /// be handled through the input interceptor and this signal will stop being
562 /// emitted.
563 ///
564 ///
565 ///
566 ///
567 /// #### `insert-text`
568 /// Emitted when text is inserted into the widget by the user.
569 ///
570 /// The default handler for this signal will normally be responsible
571 /// for inserting the text, so by connecting to this signal and then
572 /// stopping the signal with g_signal_stop_emission(), it is possible
573 /// to modify the inserted text, or prevent it from being inserted entirely.
574 ///
575 ///
576 /// <details><summary><h4>Widget</h4></summary>
577 ///
578 ///
579 /// #### `destroy`
580 /// Signals that all holders of a reference to the widget should release
581 /// the reference that they hold.
582 ///
583 /// May result in finalization of the widget if all references are released.
584 ///
585 /// This signal is not suitable for saving widget state.
586 ///
587 ///
588 ///
589 ///
590 /// #### `direction-changed`
591 /// Emitted when the text direction of a widget changes.
592 ///
593 ///
594 ///
595 ///
596 /// #### `hide`
597 /// Emitted when @widget is hidden.
598 ///
599 ///
600 ///
601 ///
602 /// #### `keynav-failed`
603 /// Emitted if keyboard navigation fails.
604 ///
605 /// See [`WidgetExt::keynav_failed()`][crate::prelude::WidgetExt::keynav_failed()] for details.
606 ///
607 ///
608 ///
609 ///
610 /// #### `map`
611 /// Emitted when @widget is going to be mapped.
612 ///
613 /// A widget is mapped when the widget is visible (which is controlled with
614 /// [`visible`][struct@crate::Widget#visible]) and all its parents up to the toplevel widget
615 /// are also visible.
616 ///
617 /// The `::map` signal can be used to determine whether a widget will be drawn,
618 /// for instance it can resume an animation that was stopped during the
619 /// emission of [`unmap`][struct@crate::Widget#unmap].
620 ///
621 ///
622 ///
623 ///
624 /// #### `mnemonic-activate`
625 /// Emitted when a widget is activated via a mnemonic.
626 ///
627 /// The default handler for this signal activates @widget if @group_cycling
628 /// is false, or just makes @widget grab focus if @group_cycling is true.
629 ///
630 ///
631 ///
632 ///
633 /// #### `move-focus`
634 /// Emitted when the focus is moved.
635 ///
636 /// The `::move-focus` signal is a [keybinding signal](class.SignalAction.html).
637 ///
638 /// The default bindings for this signal are <kbd>Tab</kbd> to move forward,
639 /// and <kbd>Shift</kbd>+<kbd>Tab</kbd> to move backward.
640 ///
641 /// Action
642 ///
643 ///
644 /// #### `query-tooltip`
645 /// Emitted when the widget’s tooltip is about to be shown.
646 ///
647 /// This happens when the [`has-tooltip`][struct@crate::Widget#has-tooltip] property
648 /// is true and the hover timeout has expired with the cursor hovering
649 /// above @widget; or emitted when @widget got focus in keyboard mode.
650 ///
651 /// Using the given coordinates, the signal handler should determine
652 /// whether a tooltip should be shown for @widget. If this is the case
653 /// true should be returned, false otherwise. Note that if @keyboard_mode
654 /// is true, the values of @x and @y are undefined and should not be used.
655 ///
656 /// The signal handler is free to manipulate @tooltip with the therefore
657 /// destined function calls.
658 ///
659 ///
660 ///
661 ///
662 /// #### `realize`
663 /// Emitted when @widget is associated with a [`gdk::Surface`][crate::gdk::Surface].
664 ///
665 /// This means that [`WidgetExt::realize()`][crate::prelude::WidgetExt::realize()] has been called
666 /// or the widget has been mapped (that is, it is going to be drawn).
667 ///
668 ///
669 ///
670 ///
671 /// #### `show`
672 /// Emitted when @widget is shown.
673 ///
674 ///
675 ///
676 ///
677 /// #### `state-flags-changed`
678 /// Emitted when the widget state changes.
679 ///
680 /// See [`WidgetExt::state_flags()`][crate::prelude::WidgetExt::state_flags()].
681 ///
682 ///
683 ///
684 ///
685 /// #### `unmap`
686 /// Emitted when @widget is going to be unmapped.
687 ///
688 /// A widget is unmapped when either it or any of its parents up to the
689 /// toplevel widget have been set as hidden.
690 ///
691 /// As `::unmap` indicates that a widget will not be shown any longer,
692 /// it can be used to, for example, stop an animation on the widget.
693 ///
694 ///
695 ///
696 ///
697 /// #### `unrealize`
698 /// Emitted when the [`gdk::Surface`][crate::gdk::Surface] associated with @widget is destroyed.
699 ///
700 /// This means that [`WidgetExt::unrealize()`][crate::prelude::WidgetExt::unrealize()] has been called
701 /// or the widget has been unmapped (that is, it is going to be hidden).
702 ///
703 ///
704 /// </details>
705 ///
706 /// # Implements
707 ///
708 /// [`EditableExt`][trait@crate::prelude::EditableExt], [`WidgetExt`][trait@crate::prelude::WidgetExt], [`trait@glib::ObjectExt`], [`AccessibleExt`][trait@crate::prelude::AccessibleExt], [`BuildableExt`][trait@crate::prelude::BuildableExt], [`ConstraintTargetExt`][trait@crate::prelude::ConstraintTargetExt], [`EditableExtManual`][trait@crate::prelude::EditableExtManual], [`WidgetExtManual`][trait@crate::prelude::WidgetExtManual], [`AccessibleExtManual`][trait@crate::prelude::AccessibleExtManual]
709 #[doc(alias = "GtkEditable")]
710 pub struct Editable(Interface<ffi::GtkEditable, ffi::GtkEditableInterface>) @requires Widget, Accessible, Buildable, ConstraintTarget;
711
712 match fn {
713 type_ => || ffi::gtk_editable_get_type(),
714 }
715}
716
717#[cfg(not(feature = "v4_10"))]
718glib::wrapper! {
719 #[doc(alias = "GtkEditable")]
720 pub struct Editable(Interface<ffi::GtkEditable, ffi::GtkEditableInterface>) @requires Widget, Buildable, ConstraintTarget;
721
722 match fn {
723 type_ => || ffi::gtk_editable_get_type(),
724 }
725}
726
727impl Editable {
728 pub const NONE: Option<&'static Editable> = None;
729}
730
731/// Trait containing all [`struct@Editable`] methods.
732///
733/// # Implementors
734///
735/// [`EditableLabel`][struct@crate::EditableLabel], [`Editable`][struct@crate::Editable], [`Entry`][struct@crate::Entry], [`PasswordEntry`][struct@crate::PasswordEntry], [`SearchEntry`][struct@crate::SearchEntry], [`SpinButton`][struct@crate::SpinButton], [`Text`][struct@crate::Text]
736pub trait EditableExt: IsA<Editable> + 'static {
737 /// Retrieves the accessible platform state from the editable delegate.
738 ///
739 /// This is an helper function to retrieve the accessible state for
740 /// [`Editable`][crate::Editable] interface implementations using a delegate pattern.
741 ///
742 /// You should call this function in your editable widget implementation
743 /// of the `vfunc::Gtk::Accessible::get_platform_state` virtual function, for
744 /// instance:
745 ///
746 /// **⚠️ The following code is in c ⚠️**
747 ///
748 /// ```c
749 /// static void
750 /// accessible_interface_init (GtkAccessibleInterface *iface)
751 /// {
752 /// iface->get_platform_state = your_editable_get_accessible_platform_state;
753 /// }
754 ///
755 /// static gboolean
756 /// your_editable_get_accessible_platform_state (GtkAccessible *accessible,
757 /// GtkAccessiblePlatformState state)
758 /// {
759 /// return gtk_editable_delegate_get_accessible_platform_state (GTK_EDITABLE (accessible), state);
760 /// }
761 /// ```
762 ///
763 /// Note that the widget which is the delegate *must* be a direct child of
764 /// this widget, otherwise your implementation of `vfunc::Gtk::Accessible::get_platform_state`
765 /// might not even be called, as the platform change will originate from
766 /// the parent of the delegate, and, as a result, will not work properly.
767 ///
768 /// So, if you can't ensure the direct child condition, you should give the
769 /// delegate the [`AccessibleRole::TextBox`][crate::AccessibleRole::TextBox] role, or you can
770 /// change your tree to allow this function to work.
771 /// ## `state`
772 /// what kind of accessible state to retrieve
773 ///
774 /// # Returns
775 ///
776 /// the accessible platform state of the delegate
777 #[cfg(feature = "v4_10")]
778 #[cfg_attr(docsrs, doc(cfg(feature = "v4_10")))]
779 #[doc(alias = "gtk_editable_delegate_get_accessible_platform_state")]
780 fn delegate_get_accessible_platform_state(&self, state: AccessiblePlatformState) -> bool {
781 unsafe {
782 from_glib(ffi::gtk_editable_delegate_get_accessible_platform_state(
783 self.as_ref().to_glib_none().0,
784 state.into_glib(),
785 ))
786 }
787 }
788
789 /// Deletes the currently selected text of the editable.
790 ///
791 /// This call doesn’t do anything if there is no selected text.
792 #[doc(alias = "gtk_editable_delete_selection")]
793 fn delete_selection(&self) {
794 unsafe {
795 ffi::gtk_editable_delete_selection(self.as_ref().to_glib_none().0);
796 }
797 }
798
799 /// Deletes a sequence of characters.
800 ///
801 /// The characters that are deleted are those characters at positions
802 /// from @start_pos up to, but not including @end_pos. If @end_pos is
803 /// negative, then the characters deleted are those from @start_pos to
804 /// the end of the text.
805 ///
806 /// Note that the positions are specified in characters, not bytes.
807 /// ## `start_pos`
808 /// start position
809 /// ## `end_pos`
810 /// end position
811 #[doc(alias = "gtk_editable_delete_text")]
812 fn delete_text(&self, start_pos: i32, end_pos: i32) {
813 unsafe {
814 ffi::gtk_editable_delete_text(self.as_ref().to_glib_none().0, start_pos, end_pos);
815 }
816 }
817
818 /// Undoes the setup done by [`init_delegate()`][Self::init_delegate()].
819 ///
820 /// This is a helper function that should be called from dispose,
821 /// before removing the delegate object.
822 #[doc(alias = "gtk_editable_finish_delegate")]
823 fn finish_delegate(&self) {
824 unsafe {
825 ffi::gtk_editable_finish_delegate(self.as_ref().to_glib_none().0);
826 }
827 }
828
829 /// Gets the alignment of the editable.
830 ///
831 /// # Returns
832 ///
833 /// the alignment
834 #[doc(alias = "gtk_editable_get_alignment")]
835 #[doc(alias = "get_alignment")]
836 #[doc(alias = "xalign")]
837 fn alignment(&self) -> f32 {
838 unsafe { ffi::gtk_editable_get_alignment(self.as_ref().to_glib_none().0) }
839 }
840
841 /// Retrieves a sequence of characters.
842 ///
843 /// The characters that are retrieved are those characters at positions
844 /// from @start_pos up to, but not including @end_pos. If @end_pos is negative,
845 /// then the characters retrieved are those characters from @start_pos to
846 /// the end of the text.
847 ///
848 /// Note that positions are specified in characters, not bytes.
849 /// ## `start_pos`
850 /// start of text
851 /// ## `end_pos`
852 /// end of text
853 ///
854 /// # Returns
855 ///
856 /// a pointer to the contents of the widget as a
857 /// string. This string is allocated by the [`Editable`][crate::Editable] implementation
858 /// and should be freed by the caller.
859 #[doc(alias = "gtk_editable_get_chars")]
860 #[doc(alias = "get_chars")]
861 fn chars(&self, start_pos: i32, end_pos: i32) -> glib::GString {
862 unsafe {
863 from_glib_full(ffi::gtk_editable_get_chars(
864 self.as_ref().to_glib_none().0,
865 start_pos,
866 end_pos,
867 ))
868 }
869 }
870
871 /// Retrieves the contents of @self, including *pseudo-content*
872 /// such as the preedit buffer.
873 ///
874 /// # Returns
875 ///
876 /// the complete contents of the editable
877 #[cfg(feature = "v4_24")]
878 #[cfg_attr(docsrs, doc(cfg(feature = "v4_24")))]
879 #[doc(alias = "gtk_editable_get_complete_text")]
880 #[doc(alias = "get_complete_text")]
881 #[doc(alias = "complete-text")]
882 fn complete_text(&self) -> glib::GString {
883 unsafe {
884 from_glib_full(ffi::gtk_editable_get_complete_text(
885 self.as_ref().to_glib_none().0,
886 ))
887 }
888 }
889
890 /// Gets the [`Editable`][crate::Editable] that @self is delegating its
891 /// implementation to.
892 ///
893 /// Typically, the delegate is a [`Text`][crate::Text] widget.
894 ///
895 /// # Returns
896 ///
897 /// the delegate [`Editable`][crate::Editable]
898 #[doc(alias = "gtk_editable_get_delegate")]
899 #[doc(alias = "get_delegate")]
900 #[must_use]
901 fn delegate(&self) -> Option<Editable> {
902 unsafe {
903 from_glib_none(ffi::gtk_editable_get_delegate(
904 self.as_ref().to_glib_none().0,
905 ))
906 }
907 }
908
909 /// Retrieves whether @self is editable.
910 ///
911 /// # Returns
912 ///
913 /// [`true`] if @self is editable.
914 #[doc(alias = "gtk_editable_get_editable")]
915 #[doc(alias = "get_editable")]
916 #[doc(alias = "editable")]
917 fn is_editable(&self) -> bool {
918 unsafe {
919 from_glib(ffi::gtk_editable_get_editable(
920 self.as_ref().to_glib_none().0,
921 ))
922 }
923 }
924
925 /// Gets if undo/redo actions are enabled for @self
926 ///
927 /// # Returns
928 ///
929 /// [`true`] if undo is enabled
930 #[doc(alias = "gtk_editable_get_enable_undo")]
931 #[doc(alias = "get_enable_undo")]
932 #[doc(alias = "enable-undo")]
933 fn enables_undo(&self) -> bool {
934 unsafe {
935 from_glib(ffi::gtk_editable_get_enable_undo(
936 self.as_ref().to_glib_none().0,
937 ))
938 }
939 }
940
941 /// Retrieves the widget that was previously set up as input interceptor
942 /// for @self. See [`set_input_interceptor()`][Self::set_input_interceptor()].
943 ///
944 /// # Returns
945 ///
946 /// The editable widget
947 #[cfg(feature = "v4_24")]
948 #[cfg_attr(docsrs, doc(cfg(feature = "v4_24")))]
949 #[doc(alias = "gtk_editable_get_input_interceptor")]
950 #[doc(alias = "get_input_interceptor")]
951 #[doc(alias = "input-interceptor")]
952 fn input_interceptor(&self) -> Option<Widget> {
953 unsafe {
954 from_glib_full(ffi::gtk_editable_get_input_interceptor(
955 self.as_ref().to_glib_none().0,
956 ))
957 }
958 }
959
960 /// Retrieves the desired maximum width of @self, in characters.
961 ///
962 /// # Returns
963 ///
964 /// the maximum width of the entry, in characters
965 #[doc(alias = "gtk_editable_get_max_width_chars")]
966 #[doc(alias = "get_max_width_chars")]
967 #[doc(alias = "max-width-chars")]
968 fn max_width_chars(&self) -> i32 {
969 unsafe { ffi::gtk_editable_get_max_width_chars(self.as_ref().to_glib_none().0) }
970 }
971
972 /// Retrieves the current position of the cursor relative
973 /// to the start of the content of the editable.
974 ///
975 /// Note that this position is in characters, not in bytes.
976 ///
977 /// # Returns
978 ///
979 /// the cursor position
980 #[doc(alias = "gtk_editable_get_position")]
981 #[doc(alias = "get_position")]
982 #[doc(alias = "cursor-position")]
983 fn position(&self) -> i32 {
984 unsafe { ffi::gtk_editable_get_position(self.as_ref().to_glib_none().0) }
985 }
986
987 /// Retrieves the selection bound of the editable.
988 ///
989 /// @start_pos will be filled with the start of the selection and
990 /// @end_pos with end. If no text was selected both will be identical
991 /// and [`false`] will be returned.
992 ///
993 /// Note that positions are specified in characters, not bytes.
994 ///
995 /// # Returns
996 ///
997 /// [`true`] if there is a non-empty selection, [`false`] otherwise
998 ///
999 /// ## `start_pos`
1000 /// location to store the starting position
1001 ///
1002 /// ## `end_pos`
1003 /// location to store the end position
1004 #[doc(alias = "gtk_editable_get_selection_bounds")]
1005 #[doc(alias = "get_selection_bounds")]
1006 fn selection_bounds(&self) -> Option<(i32, i32)> {
1007 unsafe {
1008 let mut start_pos = std::mem::MaybeUninit::uninit();
1009 let mut end_pos = std::mem::MaybeUninit::uninit();
1010 let ret = from_glib(ffi::gtk_editable_get_selection_bounds(
1011 self.as_ref().to_glib_none().0,
1012 start_pos.as_mut_ptr(),
1013 end_pos.as_mut_ptr(),
1014 ));
1015 if ret {
1016 Some((start_pos.assume_init(), end_pos.assume_init()))
1017 } else {
1018 None
1019 }
1020 }
1021 }
1022
1023 /// Retrieves the contents of @self.
1024 ///
1025 /// The returned string is owned by GTK and must not be modified or freed.
1026 ///
1027 /// # Returns
1028 ///
1029 /// a pointer to the contents of the editable
1030 #[doc(alias = "gtk_editable_get_text")]
1031 #[doc(alias = "get_text")]
1032 fn text(&self) -> glib::GString {
1033 unsafe { from_glib_none(ffi::gtk_editable_get_text(self.as_ref().to_glib_none().0)) }
1034 }
1035
1036 /// Gets the number of characters of space reserved
1037 /// for the contents of the editable.
1038 ///
1039 /// # Returns
1040 ///
1041 /// number of chars to request space for, or negative if unset
1042 #[doc(alias = "gtk_editable_get_width_chars")]
1043 #[doc(alias = "get_width_chars")]
1044 #[doc(alias = "width-chars")]
1045 fn width_chars(&self) -> i32 {
1046 unsafe { ffi::gtk_editable_get_width_chars(self.as_ref().to_glib_none().0) }
1047 }
1048
1049 /// Sets up a delegate for [`Editable`][crate::Editable].
1050 ///
1051 /// This is assuming that the get_delegate vfunc in the [`Editable`][crate::Editable]
1052 /// interface has been set up for the @self's type.
1053 ///
1054 /// This is a helper function that should be called in instance init,
1055 /// after creating the delegate object.
1056 #[doc(alias = "gtk_editable_init_delegate")]
1057 fn init_delegate(&self) {
1058 unsafe {
1059 ffi::gtk_editable_init_delegate(self.as_ref().to_glib_none().0);
1060 }
1061 }
1062
1063 /// Inserts @length bytes of @text into the contents of the
1064 /// widget, at position @position.
1065 ///
1066 /// Note that the position is in characters, not in bytes.
1067 /// The function updates @position to point after the newly
1068 /// inserted text.
1069 /// ## `text`
1070 /// the text to insert
1071 /// ## `length`
1072 /// the length of the text in bytes, or -1
1073 ///
1074 /// # Returns
1075 ///
1076 ///
1077 /// ## `position`
1078 /// location of the position text will be inserted at
1079 #[doc(alias = "gtk_editable_insert_text")]
1080 fn insert_text(&self, text: &str, position: &mut i32) {
1081 let length = text.len() as _;
1082 unsafe {
1083 ffi::gtk_editable_insert_text(
1084 self.as_ref().to_glib_none().0,
1085 text.to_glib_none().0,
1086 length,
1087 position,
1088 );
1089 }
1090 }
1091
1092 /// Selects a region of text.
1093 ///
1094 /// The characters that are selected are those characters at positions
1095 /// from @start_pos up to, but not including @end_pos. If @end_pos is
1096 /// negative, then the characters selected are those characters from
1097 /// @start_pos to the end of the text.
1098 ///
1099 /// Note that positions are specified in characters, not bytes.
1100 /// ## `start_pos`
1101 /// start of region
1102 /// ## `end_pos`
1103 /// end of region
1104 #[doc(alias = "gtk_editable_select_region")]
1105 fn select_region(&self, start_pos: i32, end_pos: i32) {
1106 unsafe {
1107 ffi::gtk_editable_select_region(self.as_ref().to_glib_none().0, start_pos, end_pos);
1108 }
1109 }
1110
1111 /// Sets the alignment for the contents of the editable.
1112 ///
1113 /// This controls the horizontal positioning of the contents when
1114 /// the displayed text is shorter than the width of the editable.
1115 /// ## `xalign`
1116 /// The horizontal alignment, from 0 (left) to 1 (right).
1117 /// Reversed for RTL layouts
1118 #[doc(alias = "gtk_editable_set_alignment")]
1119 #[doc(alias = "xalign")]
1120 fn set_alignment(&self, xalign: f32) {
1121 unsafe {
1122 ffi::gtk_editable_set_alignment(self.as_ref().to_glib_none().0, xalign);
1123 }
1124 }
1125
1126 /// Determines if the user can edit the text in the editable widget.
1127 /// ## `is_editable`
1128 /// [`true`] if the user is allowed to edit the text
1129 /// in the widget
1130 #[doc(alias = "gtk_editable_set_editable")]
1131 #[doc(alias = "editable")]
1132 fn set_editable(&self, is_editable: bool) {
1133 unsafe {
1134 ffi::gtk_editable_set_editable(self.as_ref().to_glib_none().0, is_editable.into_glib());
1135 }
1136 }
1137
1138 /// If enabled, changes to @self will be saved for undo/redo
1139 /// actions.
1140 ///
1141 /// This results in an additional copy of text changes and are not
1142 /// stored in secure memory. As such, undo is forcefully disabled
1143 /// when [`visibility`][struct@crate::Text#visibility] is set to [`false`].
1144 /// ## `enable_undo`
1145 /// if undo/redo should be enabled
1146 #[doc(alias = "gtk_editable_set_enable_undo")]
1147 #[doc(alias = "enable-undo")]
1148 fn set_enable_undo(&self, enable_undo: bool) {
1149 unsafe {
1150 ffi::gtk_editable_set_enable_undo(
1151 self.as_ref().to_glib_none().0,
1152 enable_undo.into_glib(),
1153 );
1154 }
1155 }
1156
1157 /// Sets @interceptor as the widget that @self will intercept key events from.
1158 ///
1159 /// A typical usecase for this is implementing auto-showing search entries, so
1160 /// that textual input may be intercepted from another widget and handled first
1161 /// hand by the given editable. The events will be handled in the bubble phase
1162 /// of @interceptor, which means that editable child widgets of @interceptor will
1163 /// receive the text input before it can be captured.
1164 ///
1165 /// Only those events that would be handled by an input method will be handled,
1166 /// this excludes combinations of Ctrl/Alt/Mod, and other shortcuts.
1167 /// ## `interceptor`
1168 /// the input interceptor widget
1169 #[cfg(feature = "v4_24")]
1170 #[cfg_attr(docsrs, doc(cfg(feature = "v4_24")))]
1171 #[doc(alias = "gtk_editable_set_input_interceptor")]
1172 #[doc(alias = "input-interceptor")]
1173 fn set_input_interceptor(&self, interceptor: Option<&impl IsA<Widget>>) {
1174 unsafe {
1175 ffi::gtk_editable_set_input_interceptor(
1176 self.as_ref().to_glib_none().0,
1177 interceptor.map(|p| p.as_ref()).to_glib_none().0,
1178 );
1179 }
1180 }
1181
1182 /// Sets the desired maximum width in characters of @self.
1183 /// ## `n_chars`
1184 /// the new desired maximum width, in characters
1185 #[doc(alias = "gtk_editable_set_max_width_chars")]
1186 #[doc(alias = "max-width-chars")]
1187 fn set_max_width_chars(&self, n_chars: i32) {
1188 unsafe {
1189 ffi::gtk_editable_set_max_width_chars(self.as_ref().to_glib_none().0, n_chars);
1190 }
1191 }
1192
1193 /// Sets the cursor position in the editable to the given value.
1194 ///
1195 /// The cursor is displayed before the character with the given (base 0)
1196 /// index in the contents of the editable. The value must be less than
1197 /// or equal to the number of characters in the editable. A value of -1
1198 /// indicates that the position should be set after the last character
1199 /// of the editable. Note that @position is in characters, not in bytes.
1200 /// ## `position`
1201 /// the position of the cursor
1202 #[doc(alias = "gtk_editable_set_position")]
1203 #[doc(alias = "cursor-position")]
1204 fn set_position(&self, position: i32) {
1205 unsafe {
1206 ffi::gtk_editable_set_position(self.as_ref().to_glib_none().0, position);
1207 }
1208 }
1209
1210 /// Sets the text in the editable to the given value.
1211 ///
1212 /// This is replacing the current contents.
1213 /// ## `text`
1214 /// the text to set
1215 #[doc(alias = "gtk_editable_set_text")]
1216 #[doc(alias = "text")]
1217 fn set_text(&self, text: &str) {
1218 unsafe {
1219 ffi::gtk_editable_set_text(self.as_ref().to_glib_none().0, text.to_glib_none().0);
1220 }
1221 }
1222
1223 /// Changes the size request of the editable to be about the
1224 /// right size for @n_chars characters.
1225 ///
1226 /// Note that it changes the size request, the size can still
1227 /// be affected by how you pack the widget into containers.
1228 /// If @n_chars is -1, the size reverts to the default size.
1229 /// ## `n_chars`
1230 /// width in chars
1231 #[doc(alias = "gtk_editable_set_width_chars")]
1232 #[doc(alias = "width-chars")]
1233 fn set_width_chars(&self, n_chars: i32) {
1234 unsafe {
1235 ffi::gtk_editable_set_width_chars(self.as_ref().to_glib_none().0, n_chars);
1236 }
1237 }
1238
1239 /// The position of the opposite end of the selection from the cursor in chars.
1240 #[doc(alias = "selection-bound")]
1241 fn selection_bound(&self) -> i32 {
1242 ObjectExt::property(self.as_ref(), "selection-bound")
1243 }
1244
1245 /// Emitted at the end of a single user-visible operation on the
1246 /// contents.
1247 ///
1248 /// E.g., a paste operation that replaces the contents of the
1249 /// selection will cause only one signal emission (even though it
1250 /// is implemented by first deleting the selection, then inserting
1251 /// the new content, and may cause multiple ::notify::text signals
1252 /// to be emitted).
1253 #[doc(alias = "changed")]
1254 fn connect_changed<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1255 unsafe extern "C" fn changed_trampoline<P: IsA<Editable>, F: Fn(&P) + 'static>(
1256 this: *mut ffi::GtkEditable,
1257 f: glib::ffi::gpointer,
1258 ) {
1259 unsafe {
1260 let f: &F = &*(f as *const F);
1261 f(Editable::from_glib_borrow(this).unsafe_cast_ref())
1262 }
1263 }
1264 unsafe {
1265 let f: Box_<F> = Box_::new(f);
1266 connect_raw(
1267 self.as_ptr() as *mut _,
1268 c"changed".as_ptr(),
1269 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1270 changed_trampoline::<Self, F> as *const (),
1271 )),
1272 Box_::into_raw(f),
1273 )
1274 }
1275 }
1276
1277 /// Emitted when text is deleted from the widget by the user.
1278 ///
1279 /// The default handler for this signal will normally be responsible for
1280 /// deleting the text, so by connecting to this signal and then stopping
1281 /// the signal with g_signal_stop_emission(), it is possible to modify the
1282 /// range of deleted text, or prevent it from being deleted entirely.
1283 ///
1284 /// The @start_pos and @end_pos parameters are interpreted as for
1285 /// [`delete_text()`][Self::delete_text()].
1286 /// ## `start_pos`
1287 /// the starting position
1288 /// ## `end_pos`
1289 /// the end position
1290 #[doc(alias = "delete-text")]
1291 fn connect_delete_text<F: Fn(&Self, i32, i32) + 'static>(&self, f: F) -> SignalHandlerId {
1292 unsafe extern "C" fn delete_text_trampoline<
1293 P: IsA<Editable>,
1294 F: Fn(&P, i32, i32) + 'static,
1295 >(
1296 this: *mut ffi::GtkEditable,
1297 start_pos: std::ffi::c_int,
1298 end_pos: std::ffi::c_int,
1299 f: glib::ffi::gpointer,
1300 ) {
1301 unsafe {
1302 let f: &F = &*(f as *const F);
1303 f(
1304 Editable::from_glib_borrow(this).unsafe_cast_ref(),
1305 start_pos,
1306 end_pos,
1307 )
1308 }
1309 }
1310 unsafe {
1311 let f: Box_<F> = Box_::new(f);
1312 connect_raw(
1313 self.as_ptr() as *mut _,
1314 c"delete-text".as_ptr(),
1315 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1316 delete_text_trampoline::<Self, F> as *const (),
1317 )),
1318 Box_::into_raw(f),
1319 )
1320 }
1321 }
1322
1323 /// Emitted whenever keyboard input has been handled through the
1324 /// input interceptor widget set through [`set_input_interceptor()`][Self::set_input_interceptor()]
1325 ///
1326 /// A typical reaction to this event would be to show and focus @editable, so
1327 /// that input is handled directly. In that case keyboard input will no longer
1328 /// be handled through the input interceptor and this signal will stop being
1329 /// emitted.
1330 #[cfg(feature = "v4_24")]
1331 #[cfg_attr(docsrs, doc(cfg(feature = "v4_24")))]
1332 #[doc(alias = "input-intercepted")]
1333 fn connect_input_intercepted<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1334 unsafe extern "C" fn input_intercepted_trampoline<P: IsA<Editable>, F: Fn(&P) + 'static>(
1335 this: *mut ffi::GtkEditable,
1336 f: glib::ffi::gpointer,
1337 ) {
1338 unsafe {
1339 let f: &F = &*(f as *const F);
1340 f(Editable::from_glib_borrow(this).unsafe_cast_ref())
1341 }
1342 }
1343 unsafe {
1344 let f: Box_<F> = Box_::new(f);
1345 connect_raw(
1346 self.as_ptr() as *mut _,
1347 c"input-intercepted".as_ptr(),
1348 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1349 input_intercepted_trampoline::<Self, F> as *const (),
1350 )),
1351 Box_::into_raw(f),
1352 )
1353 }
1354 }
1355
1356 #[cfg(feature = "v4_24")]
1357 #[cfg_attr(docsrs, doc(cfg(feature = "v4_24")))]
1358 #[doc(alias = "complete-text")]
1359 fn connect_complete_text_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1360 unsafe extern "C" fn notify_complete_text_trampoline<
1361 P: IsA<Editable>,
1362 F: Fn(&P) + 'static,
1363 >(
1364 this: *mut ffi::GtkEditable,
1365 _param_spec: glib::ffi::gpointer,
1366 f: glib::ffi::gpointer,
1367 ) {
1368 unsafe {
1369 let f: &F = &*(f as *const F);
1370 f(Editable::from_glib_borrow(this).unsafe_cast_ref())
1371 }
1372 }
1373 unsafe {
1374 let f: Box_<F> = Box_::new(f);
1375 connect_raw(
1376 self.as_ptr() as *mut _,
1377 c"notify::complete-text".as_ptr(),
1378 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1379 notify_complete_text_trampoline::<Self, F> as *const (),
1380 )),
1381 Box_::into_raw(f),
1382 )
1383 }
1384 }
1385
1386 #[doc(alias = "cursor-position")]
1387 fn connect_cursor_position_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1388 unsafe extern "C" fn notify_cursor_position_trampoline<
1389 P: IsA<Editable>,
1390 F: Fn(&P) + 'static,
1391 >(
1392 this: *mut ffi::GtkEditable,
1393 _param_spec: glib::ffi::gpointer,
1394 f: glib::ffi::gpointer,
1395 ) {
1396 unsafe {
1397 let f: &F = &*(f as *const F);
1398 f(Editable::from_glib_borrow(this).unsafe_cast_ref())
1399 }
1400 }
1401 unsafe {
1402 let f: Box_<F> = Box_::new(f);
1403 connect_raw(
1404 self.as_ptr() as *mut _,
1405 c"notify::cursor-position".as_ptr(),
1406 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1407 notify_cursor_position_trampoline::<Self, F> as *const (),
1408 )),
1409 Box_::into_raw(f),
1410 )
1411 }
1412 }
1413
1414 #[doc(alias = "editable")]
1415 fn connect_editable_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1416 unsafe extern "C" fn notify_editable_trampoline<P: IsA<Editable>, F: Fn(&P) + 'static>(
1417 this: *mut ffi::GtkEditable,
1418 _param_spec: glib::ffi::gpointer,
1419 f: glib::ffi::gpointer,
1420 ) {
1421 unsafe {
1422 let f: &F = &*(f as *const F);
1423 f(Editable::from_glib_borrow(this).unsafe_cast_ref())
1424 }
1425 }
1426 unsafe {
1427 let f: Box_<F> = Box_::new(f);
1428 connect_raw(
1429 self.as_ptr() as *mut _,
1430 c"notify::editable".as_ptr(),
1431 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1432 notify_editable_trampoline::<Self, F> as *const (),
1433 )),
1434 Box_::into_raw(f),
1435 )
1436 }
1437 }
1438
1439 #[doc(alias = "enable-undo")]
1440 fn connect_enable_undo_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1441 unsafe extern "C" fn notify_enable_undo_trampoline<
1442 P: IsA<Editable>,
1443 F: Fn(&P) + 'static,
1444 >(
1445 this: *mut ffi::GtkEditable,
1446 _param_spec: glib::ffi::gpointer,
1447 f: glib::ffi::gpointer,
1448 ) {
1449 unsafe {
1450 let f: &F = &*(f as *const F);
1451 f(Editable::from_glib_borrow(this).unsafe_cast_ref())
1452 }
1453 }
1454 unsafe {
1455 let f: Box_<F> = Box_::new(f);
1456 connect_raw(
1457 self.as_ptr() as *mut _,
1458 c"notify::enable-undo".as_ptr(),
1459 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1460 notify_enable_undo_trampoline::<Self, F> as *const (),
1461 )),
1462 Box_::into_raw(f),
1463 )
1464 }
1465 }
1466
1467 #[cfg(feature = "v4_24")]
1468 #[cfg_attr(docsrs, doc(cfg(feature = "v4_24")))]
1469 #[doc(alias = "input-interceptor")]
1470 fn connect_input_interceptor_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1471 unsafe extern "C" fn notify_input_interceptor_trampoline<
1472 P: IsA<Editable>,
1473 F: Fn(&P) + 'static,
1474 >(
1475 this: *mut ffi::GtkEditable,
1476 _param_spec: glib::ffi::gpointer,
1477 f: glib::ffi::gpointer,
1478 ) {
1479 unsafe {
1480 let f: &F = &*(f as *const F);
1481 f(Editable::from_glib_borrow(this).unsafe_cast_ref())
1482 }
1483 }
1484 unsafe {
1485 let f: Box_<F> = Box_::new(f);
1486 connect_raw(
1487 self.as_ptr() as *mut _,
1488 c"notify::input-interceptor".as_ptr(),
1489 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1490 notify_input_interceptor_trampoline::<Self, F> as *const (),
1491 )),
1492 Box_::into_raw(f),
1493 )
1494 }
1495 }
1496
1497 #[doc(alias = "max-width-chars")]
1498 fn connect_max_width_chars_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1499 unsafe extern "C" fn notify_max_width_chars_trampoline<
1500 P: IsA<Editable>,
1501 F: Fn(&P) + 'static,
1502 >(
1503 this: *mut ffi::GtkEditable,
1504 _param_spec: glib::ffi::gpointer,
1505 f: glib::ffi::gpointer,
1506 ) {
1507 unsafe {
1508 let f: &F = &*(f as *const F);
1509 f(Editable::from_glib_borrow(this).unsafe_cast_ref())
1510 }
1511 }
1512 unsafe {
1513 let f: Box_<F> = Box_::new(f);
1514 connect_raw(
1515 self.as_ptr() as *mut _,
1516 c"notify::max-width-chars".as_ptr(),
1517 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1518 notify_max_width_chars_trampoline::<Self, F> as *const (),
1519 )),
1520 Box_::into_raw(f),
1521 )
1522 }
1523 }
1524
1525 #[doc(alias = "selection-bound")]
1526 fn connect_selection_bound_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1527 unsafe extern "C" fn notify_selection_bound_trampoline<
1528 P: IsA<Editable>,
1529 F: Fn(&P) + 'static,
1530 >(
1531 this: *mut ffi::GtkEditable,
1532 _param_spec: glib::ffi::gpointer,
1533 f: glib::ffi::gpointer,
1534 ) {
1535 unsafe {
1536 let f: &F = &*(f as *const F);
1537 f(Editable::from_glib_borrow(this).unsafe_cast_ref())
1538 }
1539 }
1540 unsafe {
1541 let f: Box_<F> = Box_::new(f);
1542 connect_raw(
1543 self.as_ptr() as *mut _,
1544 c"notify::selection-bound".as_ptr(),
1545 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1546 notify_selection_bound_trampoline::<Self, F> as *const (),
1547 )),
1548 Box_::into_raw(f),
1549 )
1550 }
1551 }
1552
1553 #[doc(alias = "text")]
1554 fn connect_text_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1555 unsafe extern "C" fn notify_text_trampoline<P: IsA<Editable>, F: Fn(&P) + 'static>(
1556 this: *mut ffi::GtkEditable,
1557 _param_spec: glib::ffi::gpointer,
1558 f: glib::ffi::gpointer,
1559 ) {
1560 unsafe {
1561 let f: &F = &*(f as *const F);
1562 f(Editable::from_glib_borrow(this).unsafe_cast_ref())
1563 }
1564 }
1565 unsafe {
1566 let f: Box_<F> = Box_::new(f);
1567 connect_raw(
1568 self.as_ptr() as *mut _,
1569 c"notify::text".as_ptr(),
1570 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1571 notify_text_trampoline::<Self, F> as *const (),
1572 )),
1573 Box_::into_raw(f),
1574 )
1575 }
1576 }
1577
1578 #[doc(alias = "width-chars")]
1579 fn connect_width_chars_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1580 unsafe extern "C" fn notify_width_chars_trampoline<
1581 P: IsA<Editable>,
1582 F: Fn(&P) + 'static,
1583 >(
1584 this: *mut ffi::GtkEditable,
1585 _param_spec: glib::ffi::gpointer,
1586 f: glib::ffi::gpointer,
1587 ) {
1588 unsafe {
1589 let f: &F = &*(f as *const F);
1590 f(Editable::from_glib_borrow(this).unsafe_cast_ref())
1591 }
1592 }
1593 unsafe {
1594 let f: Box_<F> = Box_::new(f);
1595 connect_raw(
1596 self.as_ptr() as *mut _,
1597 c"notify::width-chars".as_ptr(),
1598 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1599 notify_width_chars_trampoline::<Self, F> as *const (),
1600 )),
1601 Box_::into_raw(f),
1602 )
1603 }
1604 }
1605
1606 #[doc(alias = "xalign")]
1607 fn connect_xalign_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1608 unsafe extern "C" fn notify_xalign_trampoline<P: IsA<Editable>, F: Fn(&P) + 'static>(
1609 this: *mut ffi::GtkEditable,
1610 _param_spec: glib::ffi::gpointer,
1611 f: glib::ffi::gpointer,
1612 ) {
1613 unsafe {
1614 let f: &F = &*(f as *const F);
1615 f(Editable::from_glib_borrow(this).unsafe_cast_ref())
1616 }
1617 }
1618 unsafe {
1619 let f: Box_<F> = Box_::new(f);
1620 connect_raw(
1621 self.as_ptr() as *mut _,
1622 c"notify::xalign".as_ptr(),
1623 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1624 notify_xalign_trampoline::<Self, F> as *const (),
1625 )),
1626 Box_::into_raw(f),
1627 )
1628 }
1629 }
1630}
1631
1632impl<O: IsA<Editable>> EditableExt for O {}