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