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 /// ## `position`
1074 /// location of the position text will be inserted at
1075 #[doc(alias = "gtk_editable_insert_text")]
1076 fn insert_text(&self, text: &str, position: &mut i32) {
1077 let length = text.len() as _;
1078 unsafe {
1079 ffi::gtk_editable_insert_text(
1080 self.as_ref().to_glib_none().0,
1081 text.to_glib_none().0,
1082 length,
1083 position,
1084 );
1085 }
1086 }
1087
1088 /// Selects a region of text.
1089 ///
1090 /// The characters that are selected are those characters at positions
1091 /// from @start_pos up to, but not including @end_pos. If @end_pos is
1092 /// negative, then the characters selected are those characters from
1093 /// @start_pos to the end of the text.
1094 ///
1095 /// Note that positions are specified in characters, not bytes.
1096 /// ## `start_pos`
1097 /// start of region
1098 /// ## `end_pos`
1099 /// end of region
1100 #[doc(alias = "gtk_editable_select_region")]
1101 fn select_region(&self, start_pos: i32, end_pos: i32) {
1102 unsafe {
1103 ffi::gtk_editable_select_region(self.as_ref().to_glib_none().0, start_pos, end_pos);
1104 }
1105 }
1106
1107 /// Sets the alignment for the contents of the editable.
1108 ///
1109 /// This controls the horizontal positioning of the contents when
1110 /// the displayed text is shorter than the width of the editable.
1111 /// ## `xalign`
1112 /// The horizontal alignment, from 0 (left) to 1 (right).
1113 /// Reversed for RTL layouts
1114 #[doc(alias = "gtk_editable_set_alignment")]
1115 #[doc(alias = "xalign")]
1116 fn set_alignment(&self, xalign: f32) {
1117 unsafe {
1118 ffi::gtk_editable_set_alignment(self.as_ref().to_glib_none().0, xalign);
1119 }
1120 }
1121
1122 /// Determines if the user can edit the text in the editable widget.
1123 /// ## `is_editable`
1124 /// [`true`] if the user is allowed to edit the text
1125 /// in the widget
1126 #[doc(alias = "gtk_editable_set_editable")]
1127 #[doc(alias = "editable")]
1128 fn set_editable(&self, is_editable: bool) {
1129 unsafe {
1130 ffi::gtk_editable_set_editable(self.as_ref().to_glib_none().0, is_editable.into_glib());
1131 }
1132 }
1133
1134 /// If enabled, changes to @self will be saved for undo/redo
1135 /// actions.
1136 ///
1137 /// This results in an additional copy of text changes and are not
1138 /// stored in secure memory. As such, undo is forcefully disabled
1139 /// when [`visibility`][struct@crate::Text#visibility] is set to [`false`].
1140 /// ## `enable_undo`
1141 /// if undo/redo should be enabled
1142 #[doc(alias = "gtk_editable_set_enable_undo")]
1143 #[doc(alias = "enable-undo")]
1144 fn set_enable_undo(&self, enable_undo: bool) {
1145 unsafe {
1146 ffi::gtk_editable_set_enable_undo(
1147 self.as_ref().to_glib_none().0,
1148 enable_undo.into_glib(),
1149 );
1150 }
1151 }
1152
1153 /// Sets @interceptor as the widget that @self will intercept key events from.
1154 ///
1155 /// A typical usecase for this is implementing auto-showing search entries, so
1156 /// that textual input may be intercepted from another widget and handled first
1157 /// hand by the given editable. The events will be handled in the bubble phase
1158 /// of @interceptor, which means that editable child widgets of @interceptor will
1159 /// receive the text input before it can be captured.
1160 ///
1161 /// Only those events that would be handled by an input method will be handled,
1162 /// this excludes combinations of Ctrl/Alt/Mod, and other shortcuts.
1163 /// ## `interceptor`
1164 /// the input interceptor widget
1165 #[cfg(feature = "v4_24")]
1166 #[cfg_attr(docsrs, doc(cfg(feature = "v4_24")))]
1167 #[doc(alias = "gtk_editable_set_input_interceptor")]
1168 #[doc(alias = "input-interceptor")]
1169 fn set_input_interceptor(&self, interceptor: Option<&impl IsA<Widget>>) {
1170 unsafe {
1171 ffi::gtk_editable_set_input_interceptor(
1172 self.as_ref().to_glib_none().0,
1173 interceptor.map(|p| p.as_ref()).to_glib_none().0,
1174 );
1175 }
1176 }
1177
1178 /// Sets the desired maximum width in characters of @self.
1179 /// ## `n_chars`
1180 /// the new desired maximum width, in characters
1181 #[doc(alias = "gtk_editable_set_max_width_chars")]
1182 #[doc(alias = "max-width-chars")]
1183 fn set_max_width_chars(&self, n_chars: i32) {
1184 unsafe {
1185 ffi::gtk_editable_set_max_width_chars(self.as_ref().to_glib_none().0, n_chars);
1186 }
1187 }
1188
1189 /// Sets the cursor position in the editable to the given value.
1190 ///
1191 /// The cursor is displayed before the character with the given (base 0)
1192 /// index in the contents of the editable. The value must be less than
1193 /// or equal to the number of characters in the editable. A value of -1
1194 /// indicates that the position should be set after the last character
1195 /// of the editable. Note that @position is in characters, not in bytes.
1196 /// ## `position`
1197 /// the position of the cursor
1198 #[doc(alias = "gtk_editable_set_position")]
1199 #[doc(alias = "cursor-position")]
1200 fn set_position(&self, position: i32) {
1201 unsafe {
1202 ffi::gtk_editable_set_position(self.as_ref().to_glib_none().0, position);
1203 }
1204 }
1205
1206 /// Sets the text in the editable to the given value.
1207 ///
1208 /// This is replacing the current contents.
1209 /// ## `text`
1210 /// the text to set
1211 #[doc(alias = "gtk_editable_set_text")]
1212 #[doc(alias = "text")]
1213 fn set_text(&self, text: &str) {
1214 unsafe {
1215 ffi::gtk_editable_set_text(self.as_ref().to_glib_none().0, text.to_glib_none().0);
1216 }
1217 }
1218
1219 /// Changes the size request of the editable to be about the
1220 /// right size for @n_chars characters.
1221 ///
1222 /// Note that it changes the size request, the size can still
1223 /// be affected by how you pack the widget into containers.
1224 /// If @n_chars is -1, the size reverts to the default size.
1225 /// ## `n_chars`
1226 /// width in chars
1227 #[doc(alias = "gtk_editable_set_width_chars")]
1228 #[doc(alias = "width-chars")]
1229 fn set_width_chars(&self, n_chars: i32) {
1230 unsafe {
1231 ffi::gtk_editable_set_width_chars(self.as_ref().to_glib_none().0, n_chars);
1232 }
1233 }
1234
1235 /// The position of the opposite end of the selection from the cursor in chars.
1236 #[doc(alias = "selection-bound")]
1237 fn selection_bound(&self) -> i32 {
1238 ObjectExt::property(self.as_ref(), "selection-bound")
1239 }
1240
1241 /// Emitted at the end of a single user-visible operation on the
1242 /// contents.
1243 ///
1244 /// E.g., a paste operation that replaces the contents of the
1245 /// selection will cause only one signal emission (even though it
1246 /// is implemented by first deleting the selection, then inserting
1247 /// the new content, and may cause multiple ::notify::text signals
1248 /// to be emitted).
1249 #[doc(alias = "changed")]
1250 fn connect_changed<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1251 unsafe extern "C" fn changed_trampoline<P: IsA<Editable>, F: Fn(&P) + 'static>(
1252 this: *mut ffi::GtkEditable,
1253 f: glib::ffi::gpointer,
1254 ) {
1255 unsafe {
1256 let f: &F = &*(f as *const F);
1257 f(Editable::from_glib_borrow(this).unsafe_cast_ref())
1258 }
1259 }
1260 unsafe {
1261 let f: Box_<F> = Box_::new(f);
1262 connect_raw(
1263 self.as_ptr() as *mut _,
1264 c"changed".as_ptr(),
1265 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1266 changed_trampoline::<Self, F> as *const (),
1267 )),
1268 Box_::into_raw(f),
1269 )
1270 }
1271 }
1272
1273 /// Emitted when text is deleted from the widget by the user.
1274 ///
1275 /// The default handler for this signal will normally be responsible for
1276 /// deleting the text, so by connecting to this signal and then stopping
1277 /// the signal with g_signal_stop_emission(), it is possible to modify the
1278 /// range of deleted text, or prevent it from being deleted entirely.
1279 ///
1280 /// The @start_pos and @end_pos parameters are interpreted as for
1281 /// [`delete_text()`][Self::delete_text()].
1282 /// ## `start_pos`
1283 /// the starting position
1284 /// ## `end_pos`
1285 /// the end position
1286 #[doc(alias = "delete-text")]
1287 fn connect_delete_text<F: Fn(&Self, i32, i32) + 'static>(&self, f: F) -> SignalHandlerId {
1288 unsafe extern "C" fn delete_text_trampoline<
1289 P: IsA<Editable>,
1290 F: Fn(&P, i32, i32) + 'static,
1291 >(
1292 this: *mut ffi::GtkEditable,
1293 start_pos: std::ffi::c_int,
1294 end_pos: std::ffi::c_int,
1295 f: glib::ffi::gpointer,
1296 ) {
1297 unsafe {
1298 let f: &F = &*(f as *const F);
1299 f(
1300 Editable::from_glib_borrow(this).unsafe_cast_ref(),
1301 start_pos,
1302 end_pos,
1303 )
1304 }
1305 }
1306 unsafe {
1307 let f: Box_<F> = Box_::new(f);
1308 connect_raw(
1309 self.as_ptr() as *mut _,
1310 c"delete-text".as_ptr(),
1311 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1312 delete_text_trampoline::<Self, F> as *const (),
1313 )),
1314 Box_::into_raw(f),
1315 )
1316 }
1317 }
1318
1319 /// Emitted whenever keyboard input has been handled through the
1320 /// input interceptor widget set through [`set_input_interceptor()`][Self::set_input_interceptor()]
1321 ///
1322 /// A typical reaction to this event would be to show and focus @editable, so
1323 /// that input is handled directly. In that case keyboard input will no longer
1324 /// be handled through the input interceptor and this signal will stop being
1325 /// emitted.
1326 #[cfg(feature = "v4_24")]
1327 #[cfg_attr(docsrs, doc(cfg(feature = "v4_24")))]
1328 #[doc(alias = "input-intercepted")]
1329 fn connect_input_intercepted<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1330 unsafe extern "C" fn input_intercepted_trampoline<P: IsA<Editable>, F: Fn(&P) + 'static>(
1331 this: *mut ffi::GtkEditable,
1332 f: glib::ffi::gpointer,
1333 ) {
1334 unsafe {
1335 let f: &F = &*(f as *const F);
1336 f(Editable::from_glib_borrow(this).unsafe_cast_ref())
1337 }
1338 }
1339 unsafe {
1340 let f: Box_<F> = Box_::new(f);
1341 connect_raw(
1342 self.as_ptr() as *mut _,
1343 c"input-intercepted".as_ptr(),
1344 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1345 input_intercepted_trampoline::<Self, F> as *const (),
1346 )),
1347 Box_::into_raw(f),
1348 )
1349 }
1350 }
1351
1352 #[cfg(feature = "v4_24")]
1353 #[cfg_attr(docsrs, doc(cfg(feature = "v4_24")))]
1354 #[doc(alias = "complete-text")]
1355 fn connect_complete_text_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1356 unsafe extern "C" fn notify_complete_text_trampoline<
1357 P: IsA<Editable>,
1358 F: Fn(&P) + 'static,
1359 >(
1360 this: *mut ffi::GtkEditable,
1361 _param_spec: glib::ffi::gpointer,
1362 f: glib::ffi::gpointer,
1363 ) {
1364 unsafe {
1365 let f: &F = &*(f as *const F);
1366 f(Editable::from_glib_borrow(this).unsafe_cast_ref())
1367 }
1368 }
1369 unsafe {
1370 let f: Box_<F> = Box_::new(f);
1371 connect_raw(
1372 self.as_ptr() as *mut _,
1373 c"notify::complete-text".as_ptr(),
1374 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1375 notify_complete_text_trampoline::<Self, F> as *const (),
1376 )),
1377 Box_::into_raw(f),
1378 )
1379 }
1380 }
1381
1382 #[doc(alias = "cursor-position")]
1383 fn connect_cursor_position_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1384 unsafe extern "C" fn notify_cursor_position_trampoline<
1385 P: IsA<Editable>,
1386 F: Fn(&P) + 'static,
1387 >(
1388 this: *mut ffi::GtkEditable,
1389 _param_spec: glib::ffi::gpointer,
1390 f: glib::ffi::gpointer,
1391 ) {
1392 unsafe {
1393 let f: &F = &*(f as *const F);
1394 f(Editable::from_glib_borrow(this).unsafe_cast_ref())
1395 }
1396 }
1397 unsafe {
1398 let f: Box_<F> = Box_::new(f);
1399 connect_raw(
1400 self.as_ptr() as *mut _,
1401 c"notify::cursor-position".as_ptr(),
1402 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1403 notify_cursor_position_trampoline::<Self, F> as *const (),
1404 )),
1405 Box_::into_raw(f),
1406 )
1407 }
1408 }
1409
1410 #[doc(alias = "editable")]
1411 fn connect_editable_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1412 unsafe extern "C" fn notify_editable_trampoline<P: IsA<Editable>, F: Fn(&P) + 'static>(
1413 this: *mut ffi::GtkEditable,
1414 _param_spec: glib::ffi::gpointer,
1415 f: glib::ffi::gpointer,
1416 ) {
1417 unsafe {
1418 let f: &F = &*(f as *const F);
1419 f(Editable::from_glib_borrow(this).unsafe_cast_ref())
1420 }
1421 }
1422 unsafe {
1423 let f: Box_<F> = Box_::new(f);
1424 connect_raw(
1425 self.as_ptr() as *mut _,
1426 c"notify::editable".as_ptr(),
1427 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1428 notify_editable_trampoline::<Self, F> as *const (),
1429 )),
1430 Box_::into_raw(f),
1431 )
1432 }
1433 }
1434
1435 #[doc(alias = "enable-undo")]
1436 fn connect_enable_undo_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1437 unsafe extern "C" fn notify_enable_undo_trampoline<
1438 P: IsA<Editable>,
1439 F: Fn(&P) + 'static,
1440 >(
1441 this: *mut ffi::GtkEditable,
1442 _param_spec: glib::ffi::gpointer,
1443 f: glib::ffi::gpointer,
1444 ) {
1445 unsafe {
1446 let f: &F = &*(f as *const F);
1447 f(Editable::from_glib_borrow(this).unsafe_cast_ref())
1448 }
1449 }
1450 unsafe {
1451 let f: Box_<F> = Box_::new(f);
1452 connect_raw(
1453 self.as_ptr() as *mut _,
1454 c"notify::enable-undo".as_ptr(),
1455 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1456 notify_enable_undo_trampoline::<Self, F> as *const (),
1457 )),
1458 Box_::into_raw(f),
1459 )
1460 }
1461 }
1462
1463 #[cfg(feature = "v4_24")]
1464 #[cfg_attr(docsrs, doc(cfg(feature = "v4_24")))]
1465 #[doc(alias = "input-interceptor")]
1466 fn connect_input_interceptor_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1467 unsafe extern "C" fn notify_input_interceptor_trampoline<
1468 P: IsA<Editable>,
1469 F: Fn(&P) + 'static,
1470 >(
1471 this: *mut ffi::GtkEditable,
1472 _param_spec: glib::ffi::gpointer,
1473 f: glib::ffi::gpointer,
1474 ) {
1475 unsafe {
1476 let f: &F = &*(f as *const F);
1477 f(Editable::from_glib_borrow(this).unsafe_cast_ref())
1478 }
1479 }
1480 unsafe {
1481 let f: Box_<F> = Box_::new(f);
1482 connect_raw(
1483 self.as_ptr() as *mut _,
1484 c"notify::input-interceptor".as_ptr(),
1485 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1486 notify_input_interceptor_trampoline::<Self, F> as *const (),
1487 )),
1488 Box_::into_raw(f),
1489 )
1490 }
1491 }
1492
1493 #[doc(alias = "max-width-chars")]
1494 fn connect_max_width_chars_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1495 unsafe extern "C" fn notify_max_width_chars_trampoline<
1496 P: IsA<Editable>,
1497 F: Fn(&P) + 'static,
1498 >(
1499 this: *mut ffi::GtkEditable,
1500 _param_spec: glib::ffi::gpointer,
1501 f: glib::ffi::gpointer,
1502 ) {
1503 unsafe {
1504 let f: &F = &*(f as *const F);
1505 f(Editable::from_glib_borrow(this).unsafe_cast_ref())
1506 }
1507 }
1508 unsafe {
1509 let f: Box_<F> = Box_::new(f);
1510 connect_raw(
1511 self.as_ptr() as *mut _,
1512 c"notify::max-width-chars".as_ptr(),
1513 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1514 notify_max_width_chars_trampoline::<Self, F> as *const (),
1515 )),
1516 Box_::into_raw(f),
1517 )
1518 }
1519 }
1520
1521 #[doc(alias = "selection-bound")]
1522 fn connect_selection_bound_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1523 unsafe extern "C" fn notify_selection_bound_trampoline<
1524 P: IsA<Editable>,
1525 F: Fn(&P) + 'static,
1526 >(
1527 this: *mut ffi::GtkEditable,
1528 _param_spec: glib::ffi::gpointer,
1529 f: glib::ffi::gpointer,
1530 ) {
1531 unsafe {
1532 let f: &F = &*(f as *const F);
1533 f(Editable::from_glib_borrow(this).unsafe_cast_ref())
1534 }
1535 }
1536 unsafe {
1537 let f: Box_<F> = Box_::new(f);
1538 connect_raw(
1539 self.as_ptr() as *mut _,
1540 c"notify::selection-bound".as_ptr(),
1541 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1542 notify_selection_bound_trampoline::<Self, F> as *const (),
1543 )),
1544 Box_::into_raw(f),
1545 )
1546 }
1547 }
1548
1549 #[doc(alias = "text")]
1550 fn connect_text_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1551 unsafe extern "C" fn notify_text_trampoline<P: IsA<Editable>, F: Fn(&P) + 'static>(
1552 this: *mut ffi::GtkEditable,
1553 _param_spec: glib::ffi::gpointer,
1554 f: glib::ffi::gpointer,
1555 ) {
1556 unsafe {
1557 let f: &F = &*(f as *const F);
1558 f(Editable::from_glib_borrow(this).unsafe_cast_ref())
1559 }
1560 }
1561 unsafe {
1562 let f: Box_<F> = Box_::new(f);
1563 connect_raw(
1564 self.as_ptr() as *mut _,
1565 c"notify::text".as_ptr(),
1566 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1567 notify_text_trampoline::<Self, F> as *const (),
1568 )),
1569 Box_::into_raw(f),
1570 )
1571 }
1572 }
1573
1574 #[doc(alias = "width-chars")]
1575 fn connect_width_chars_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1576 unsafe extern "C" fn notify_width_chars_trampoline<
1577 P: IsA<Editable>,
1578 F: Fn(&P) + 'static,
1579 >(
1580 this: *mut ffi::GtkEditable,
1581 _param_spec: glib::ffi::gpointer,
1582 f: glib::ffi::gpointer,
1583 ) {
1584 unsafe {
1585 let f: &F = &*(f as *const F);
1586 f(Editable::from_glib_borrow(this).unsafe_cast_ref())
1587 }
1588 }
1589 unsafe {
1590 let f: Box_<F> = Box_::new(f);
1591 connect_raw(
1592 self.as_ptr() as *mut _,
1593 c"notify::width-chars".as_ptr(),
1594 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1595 notify_width_chars_trampoline::<Self, F> as *const (),
1596 )),
1597 Box_::into_raw(f),
1598 )
1599 }
1600 }
1601
1602 #[doc(alias = "xalign")]
1603 fn connect_xalign_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1604 unsafe extern "C" fn notify_xalign_trampoline<P: IsA<Editable>, F: Fn(&P) + 'static>(
1605 this: *mut ffi::GtkEditable,
1606 _param_spec: glib::ffi::gpointer,
1607 f: glib::ffi::gpointer,
1608 ) {
1609 unsafe {
1610 let f: &F = &*(f as *const F);
1611 f(Editable::from_glib_borrow(this).unsafe_cast_ref())
1612 }
1613 }
1614 unsafe {
1615 let f: Box_<F> = Box_::new(f);
1616 connect_raw(
1617 self.as_ptr() as *mut _,
1618 c"notify::xalign".as_ptr(),
1619 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1620 notify_xalign_trampoline::<Self, F> as *const (),
1621 )),
1622 Box_::into_raw(f),
1623 )
1624 }
1625 }
1626}
1627
1628impl<O: IsA<Editable>> EditableExt for O {}