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