gtk4/auto/
cell_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#![allow(deprecated)]
5
6use crate::{ffi, Accessible, Buildable, ConstraintTarget, Widget};
7use glib::{
8    object::ObjectType as _,
9    prelude::*,
10    signal::{connect_raw, SignalHandlerId},
11    translate::*,
12};
13use std::boxed::Box as Box_;
14
15glib::wrapper! {
16    /// List views use widgets for displaying their
17    ///   contents. See [`Editable`][crate::Editable] for editable text widgets
18    /// Interface for widgets that can be used for editing cells
19    ///
20    /// The [`CellEditable`][crate::CellEditable] interface must be implemented for widgets to be usable
21    /// to edit the contents of a [`TreeView`][crate::TreeView] cell. It provides a way to specify how
22    /// temporary widgets should be configured for editing, get the new value, etc.
23    ///
24    /// ## Properties
25    ///
26    ///
27    /// #### `editing-canceled`
28    ///  Indicates whether editing on the cell has been canceled.
29    ///
30    /// Readable | Writeable
31    /// <details><summary><h4>Widget</h4></summary>
32    ///
33    ///
34    /// #### `can-focus`
35    ///  Whether the widget or any of its descendents can accept
36    /// the input focus.
37    ///
38    /// This property is meant to be set by widget implementations,
39    /// typically in their instance init function.
40    ///
41    /// Readable | Writeable
42    ///
43    ///
44    /// #### `can-target`
45    ///  Whether the widget can receive pointer events.
46    ///
47    /// Readable | Writeable
48    ///
49    ///
50    /// #### `css-classes`
51    ///  A list of css classes applied to this widget.
52    ///
53    /// Readable | Writeable
54    ///
55    ///
56    /// #### `css-name`
57    ///  The name of this widget in the CSS tree.
58    ///
59    /// This property is meant to be set by widget implementations,
60    /// typically in their instance init function.
61    ///
62    /// Readable | Writeable | Construct Only
63    ///
64    ///
65    /// #### `cursor`
66    ///  The cursor used by @widget.
67    ///
68    /// Readable | Writeable
69    ///
70    ///
71    /// #### `focus-on-click`
72    ///  Whether the widget should grab focus when it is clicked with the mouse.
73    ///
74    /// This property is only relevant for widgets that can take focus.
75    ///
76    /// Readable | Writeable
77    ///
78    ///
79    /// #### `focusable`
80    ///  Whether this widget itself will accept the input focus.
81    ///
82    /// Readable | Writeable
83    ///
84    ///
85    /// #### `halign`
86    ///  How to distribute horizontal space if widget gets extra space.
87    ///
88    /// Readable | Writeable
89    ///
90    ///
91    /// #### `has-default`
92    ///  Whether the widget is the default widget.
93    ///
94    /// Readable
95    ///
96    ///
97    /// #### `has-focus`
98    ///  Whether the widget has the input focus.
99    ///
100    /// Readable
101    ///
102    ///
103    /// #### `has-tooltip`
104    ///  Enables or disables the emission of the [`query-tooltip`][struct@crate::Widget#query-tooltip]
105    /// signal on @widget.
106    ///
107    /// A true value indicates that @widget can have a tooltip, in this case
108    /// the widget will be queried using [`query-tooltip`][struct@crate::Widget#query-tooltip] to
109    /// determine whether it will provide a tooltip or not.
110    ///
111    /// Readable | Writeable
112    ///
113    ///
114    /// #### `height-request`
115    ///  Overrides for height request of the widget.
116    ///
117    /// If this is -1, the natural request will be used.
118    ///
119    /// Readable | Writeable
120    ///
121    ///
122    /// #### `hexpand`
123    ///  Whether to expand horizontally.
124    ///
125    /// Readable | Writeable
126    ///
127    ///
128    /// #### `hexpand-set`
129    ///  Whether to use the `hexpand` property.
130    ///
131    /// Readable | Writeable
132    ///
133    ///
134    /// #### `layout-manager`
135    ///  The [`LayoutManager`][crate::LayoutManager] instance to use to compute
136    /// the preferred size of the widget, and allocate its children.
137    ///
138    /// This property is meant to be set by widget implementations,
139    /// typically in their instance init function.
140    ///
141    /// Readable | Writeable
142    ///
143    ///
144    /// #### `limit-events`
145    ///  Makes this widget act like a modal dialog, with respect to
146    /// event delivery.
147    ///
148    /// Global event controllers will not handle events with targets
149    /// inside the widget, unless they are set up to ignore propagation
150    /// limits. See [`EventControllerExt::set_propagation_limit()`][crate::prelude::EventControllerExt::set_propagation_limit()].
151    ///
152    /// Readable | Writeable
153    ///
154    ///
155    /// #### `margin-bottom`
156    ///  Margin on bottom side of widget.
157    ///
158    /// This property adds margin outside of the widget's normal size
159    /// request, the margin will be added in addition to the size from
160    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
161    ///
162    /// Readable | Writeable
163    ///
164    ///
165    /// #### `margin-end`
166    ///  Margin on end of widget, horizontally.
167    ///
168    /// This property supports left-to-right and right-to-left text
169    /// directions.
170    ///
171    /// This property adds margin outside of the widget's normal size
172    /// request, the margin will be added in addition to the size from
173    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
174    ///
175    /// Readable | Writeable
176    ///
177    ///
178    /// #### `margin-start`
179    ///  Margin on start of widget, horizontally.
180    ///
181    /// This property supports left-to-right and right-to-left text
182    /// directions.
183    ///
184    /// This property adds margin outside of the widget's normal size
185    /// request, the margin will be added in addition to the size from
186    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
187    ///
188    /// Readable | Writeable
189    ///
190    ///
191    /// #### `margin-top`
192    ///  Margin on top side of widget.
193    ///
194    /// This property adds margin outside of the widget's normal size
195    /// request, the margin will be added in addition to the size from
196    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
197    ///
198    /// Readable | Writeable
199    ///
200    ///
201    /// #### `name`
202    ///  The name of the widget.
203    ///
204    /// Readable | Writeable
205    ///
206    ///
207    /// #### `opacity`
208    ///  The requested opacity of the widget.
209    ///
210    /// Readable | Writeable
211    ///
212    ///
213    /// #### `overflow`
214    ///  How content outside the widget's content area is treated.
215    ///
216    /// This property is meant to be set by widget implementations,
217    /// typically in their instance init function.
218    ///
219    /// Readable | Writeable
220    ///
221    ///
222    /// #### `parent`
223    ///  The parent widget of this widget.
224    ///
225    /// Readable
226    ///
227    ///
228    /// #### `receives-default`
229    ///  Whether the widget will receive the default action when it is focused.
230    ///
231    /// Readable | Writeable
232    ///
233    ///
234    /// #### `root`
235    ///  The [`Root`][crate::Root] widget of the widget tree containing this widget.
236    ///
237    /// This will be `NULL` if the widget is not contained in a root widget.
238    ///
239    /// Readable
240    ///
241    ///
242    /// #### `scale-factor`
243    ///  The scale factor of the widget.
244    ///
245    /// Readable
246    ///
247    ///
248    /// #### `sensitive`
249    ///  Whether the widget responds to input.
250    ///
251    /// Readable | Writeable
252    ///
253    ///
254    /// #### `tooltip-markup`
255    ///  Sets the text of tooltip to be the given string, which is marked up
256    /// with Pango markup.
257    ///
258    /// Also see [`Tooltip::set_markup()`][crate::Tooltip::set_markup()].
259    ///
260    /// This is a convenience property which will take care of getting the
261    /// tooltip shown if the given string is not `NULL`:
262    /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
263    /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
264    /// the default signal handler.
265    ///
266    /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
267    /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
268    ///
269    /// Readable | Writeable
270    ///
271    ///
272    /// #### `tooltip-text`
273    ///  Sets the text of tooltip to be the given string.
274    ///
275    /// Also see [`Tooltip::set_text()`][crate::Tooltip::set_text()].
276    ///
277    /// This is a convenience property which will take care of getting the
278    /// tooltip shown if the given string is not `NULL`:
279    /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
280    /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
281    /// the default signal handler.
282    ///
283    /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
284    /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
285    ///
286    /// Readable | Writeable
287    ///
288    ///
289    /// #### `valign`
290    ///  How to distribute vertical space if widget gets extra space.
291    ///
292    /// Readable | Writeable
293    ///
294    ///
295    /// #### `vexpand`
296    ///  Whether to expand vertically.
297    ///
298    /// Readable | Writeable
299    ///
300    ///
301    /// #### `vexpand-set`
302    ///  Whether to use the `vexpand` property.
303    ///
304    /// Readable | Writeable
305    ///
306    ///
307    /// #### `visible`
308    ///  Whether the widget is visible.
309    ///
310    /// Readable | Writeable
311    ///
312    ///
313    /// #### `width-request`
314    ///  Overrides for width request of the widget.
315    ///
316    /// If this is -1, the natural request will be used.
317    ///
318    /// Readable | Writeable
319    /// </details>
320    /// <details><summary><h4>Accessible</h4></summary>
321    ///
322    ///
323    /// #### `accessible-role`
324    ///  The accessible role of the given [`Accessible`][crate::Accessible] implementation.
325    ///
326    /// The accessible role cannot be changed once set.
327    ///
328    /// Readable | Writeable
329    /// </details>
330    ///
331    /// ## Signals
332    ///
333    ///
334    /// #### `editing-done`
335    ///  This signal is a sign for the cell renderer to update its
336    /// value from the @cell_editable.
337    ///
338    /// Implementations of [`CellEditable`][crate::CellEditable] are responsible for
339    /// emitting this signal when they are done editing, e.g.
340    /// [`Entry`][crate::Entry] emits this signal when the user presses Enter. Typical things to
341    /// do in a handler for ::editing-done are to capture the edited value,
342    /// disconnect the @cell_editable from signals on the [`CellRenderer`][crate::CellRenderer], etc.
343    ///
344    /// gtk_cell_editable_editing_done() is a convenience method
345    /// for emitting `GtkCellEditable::editing-done`.
346    ///
347    ///
348    ///
349    ///
350    /// #### `remove-widget`
351    ///  This signal is meant to indicate that the cell is finished
352    /// editing, and the @cell_editable widget is being removed and may
353    /// subsequently be destroyed.
354    ///
355    /// Implementations of [`CellEditable`][crate::CellEditable] are responsible for
356    /// emitting this signal when they are done editing. It must
357    /// be emitted after the `GtkCellEditable::editing-done` signal,
358    /// to give the cell renderer a chance to update the cell's value
359    /// before the widget is removed.
360    ///
361    /// gtk_cell_editable_remove_widget() is a convenience method
362    /// for emitting `GtkCellEditable::remove-widget`.
363    ///
364    ///
365    /// <details><summary><h4>Widget</h4></summary>
366    ///
367    ///
368    /// #### `destroy`
369    ///  Signals that all holders of a reference to the widget should release
370    /// the reference that they hold.
371    ///
372    /// May result in finalization of the widget if all references are released.
373    ///
374    /// This signal is not suitable for saving widget state.
375    ///
376    ///
377    ///
378    ///
379    /// #### `direction-changed`
380    ///  Emitted when the text direction of a widget changes.
381    ///
382    ///
383    ///
384    ///
385    /// #### `hide`
386    ///  Emitted when @widget is hidden.
387    ///
388    ///
389    ///
390    ///
391    /// #### `keynav-failed`
392    ///  Emitted if keyboard navigation fails.
393    ///
394    /// See [`WidgetExt::keynav_failed()`][crate::prelude::WidgetExt::keynav_failed()] for details.
395    ///
396    ///
397    ///
398    ///
399    /// #### `map`
400    ///  Emitted when @widget is going to be mapped.
401    ///
402    /// A widget is mapped when the widget is visible (which is controlled with
403    /// [`visible`][struct@crate::Widget#visible]) and all its parents up to the toplevel widget
404    /// are also visible.
405    ///
406    /// The `::map` signal can be used to determine whether a widget will be drawn,
407    /// for instance it can resume an animation that was stopped during the
408    /// emission of [`unmap`][struct@crate::Widget#unmap].
409    ///
410    ///
411    ///
412    ///
413    /// #### `mnemonic-activate`
414    ///  Emitted when a widget is activated via a mnemonic.
415    ///
416    /// The default handler for this signal activates @widget if @group_cycling
417    /// is false, or just makes @widget grab focus if @group_cycling is true.
418    ///
419    ///
420    ///
421    ///
422    /// #### `move-focus`
423    ///  Emitted when the focus is moved.
424    ///
425    /// The `::move-focus` signal is a [keybinding signal](class.SignalAction.html).
426    ///
427    /// The default bindings for this signal are <kbd>Tab</kbd> to move forward,
428    /// and <kbd>Shift</kbd>+<kbd>Tab</kbd> to move backward.
429    ///
430    /// Action
431    ///
432    ///
433    /// #### `query-tooltip`
434    ///  Emitted when the widget’s tooltip is about to be shown.
435    ///
436    /// This happens when the [`has-tooltip`][struct@crate::Widget#has-tooltip] property
437    /// is true and the hover timeout has expired with the cursor hovering
438    /// above @widget; or emitted when @widget got focus in keyboard mode.
439    ///
440    /// Using the given coordinates, the signal handler should determine
441    /// whether a tooltip should be shown for @widget. If this is the case
442    /// true should be returned, false otherwise. Note that if @keyboard_mode
443    /// is true, the values of @x and @y are undefined and should not be used.
444    ///
445    /// The signal handler is free to manipulate @tooltip with the therefore
446    /// destined function calls.
447    ///
448    ///
449    ///
450    ///
451    /// #### `realize`
452    ///  Emitted when @widget is associated with a [`gdk::Surface`][crate::gdk::Surface].
453    ///
454    /// This means that [`WidgetExt::realize()`][crate::prelude::WidgetExt::realize()] has been called
455    /// or the widget has been mapped (that is, it is going to be drawn).
456    ///
457    ///
458    ///
459    ///
460    /// #### `show`
461    ///  Emitted when @widget is shown.
462    ///
463    ///
464    ///
465    ///
466    /// #### `state-flags-changed`
467    ///  Emitted when the widget state changes.
468    ///
469    /// See [`WidgetExt::state_flags()`][crate::prelude::WidgetExt::state_flags()].
470    ///
471    ///
472    ///
473    ///
474    /// #### `unmap`
475    ///  Emitted when @widget is going to be unmapped.
476    ///
477    /// A widget is unmapped when either it or any of its parents up to the
478    /// toplevel widget have been set as hidden.
479    ///
480    /// As `::unmap` indicates that a widget will not be shown any longer,
481    /// it can be used to, for example, stop an animation on the widget.
482    ///
483    ///
484    ///
485    ///
486    /// #### `unrealize`
487    ///  Emitted when the [`gdk::Surface`][crate::gdk::Surface] associated with @widget is destroyed.
488    ///
489    /// This means that [`WidgetExt::unrealize()`][crate::prelude::WidgetExt::unrealize()] has been called
490    /// or the widget has been unmapped (that is, it is going to be hidden).
491    ///
492    ///
493    /// </details>
494    ///
495    /// # Implements
496    ///
497    /// [`CellEditableExt`][trait@crate::prelude::CellEditableExt], [`WidgetExt`][trait@crate::prelude::WidgetExt], [`trait@glib::ObjectExt`], [`AccessibleExt`][trait@crate::prelude::AccessibleExt], [`BuildableExt`][trait@crate::prelude::BuildableExt], [`ConstraintTargetExt`][trait@crate::prelude::ConstraintTargetExt], [`WidgetExtManual`][trait@crate::prelude::WidgetExtManual], [`AccessibleExtManual`][trait@crate::prelude::AccessibleExtManual]
498    #[doc(alias = "GtkCellEditable")]
499    pub struct CellEditable(Interface<ffi::GtkCellEditable, ffi::GtkCellEditableIface>) @requires Widget, Accessible, Buildable, ConstraintTarget;
500
501    match fn {
502        type_ => || ffi::gtk_cell_editable_get_type(),
503    }
504}
505
506impl CellEditable {
507    pub const NONE: Option<&'static CellEditable> = None;
508}
509
510mod sealed {
511    pub trait Sealed {}
512    impl<T: super::IsA<super::CellEditable>> Sealed for T {}
513}
514
515/// Trait containing all [`struct@CellEditable`] methods.
516///
517/// # Implementors
518///
519/// [`CellEditable`][struct@crate::CellEditable], [`ComboBoxText`][struct@crate::ComboBoxText], [`ComboBox`][struct@crate::ComboBox], [`Entry`][struct@crate::Entry], [`SpinButton`][struct@crate::SpinButton]
520pub trait CellEditableExt: IsA<CellEditable> + sealed::Sealed + 'static {
521    /// Emits the `GtkCellEditable::editing-done` signal.
522    ///
523    /// # Deprecated since 4.10
524    ///
525    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
526    #[allow(deprecated)]
527    #[doc(alias = "gtk_cell_editable_editing_done")]
528    fn editing_done(&self) {
529        unsafe {
530            ffi::gtk_cell_editable_editing_done(self.as_ref().to_glib_none().0);
531        }
532    }
533
534    /// Emits the `GtkCellEditable::remove-widget` signal.
535    ///
536    /// # Deprecated since 4.10
537    ///
538    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
539    #[allow(deprecated)]
540    #[doc(alias = "gtk_cell_editable_remove_widget")]
541    fn remove_widget(&self) {
542        unsafe {
543            ffi::gtk_cell_editable_remove_widget(self.as_ref().to_glib_none().0);
544        }
545    }
546
547    /// Begins editing on a @self.
548    ///
549    /// The [`CellRenderer`][crate::CellRenderer] for the cell creates and returns a [`CellEditable`][crate::CellEditable] from
550    /// gtk_cell_renderer_start_editing(), configured for the [`CellRenderer`][crate::CellRenderer] type.
551    ///
552    /// gtk_cell_editable_start_editing() can then set up @self suitably for
553    /// editing a cell, e.g. making the Esc key emit `GtkCellEditable::editing-done`.
554    ///
555    /// Note that the @self is created on-demand for the current edit; its
556    /// lifetime is temporary and does not persist across other edits and/or cells.
557    /// ## `event`
558    /// The [`gdk::Event`][crate::gdk::Event] that began the editing process, or
559    ///   [`None`] if editing was initiated programmatically
560    #[doc(alias = "gtk_cell_editable_start_editing")]
561    fn start_editing(&self, event: Option<impl AsRef<gdk::Event>>) {
562        unsafe {
563            ffi::gtk_cell_editable_start_editing(
564                self.as_ref().to_glib_none().0,
565                event.as_ref().map(|p| p.as_ref()).to_glib_none().0,
566            );
567        }
568    }
569
570    /// Indicates whether editing on the cell has been canceled.
571    #[doc(alias = "editing-canceled")]
572    fn is_editing_canceled(&self) -> bool {
573        ObjectExt::property(self.as_ref(), "editing-canceled")
574    }
575
576    /// Indicates whether editing on the cell has been canceled.
577    #[doc(alias = "editing-canceled")]
578    fn set_editing_canceled(&self, editing_canceled: bool) {
579        ObjectExt::set_property(self.as_ref(), "editing-canceled", editing_canceled)
580    }
581
582    /// This signal is a sign for the cell renderer to update its
583    /// value from the @cell_editable.
584    ///
585    /// Implementations of [`CellEditable`][crate::CellEditable] are responsible for
586    /// emitting this signal when they are done editing, e.g.
587    /// [`Entry`][crate::Entry] emits this signal when the user presses Enter. Typical things to
588    /// do in a handler for ::editing-done are to capture the edited value,
589    /// disconnect the @cell_editable from signals on the [`CellRenderer`][crate::CellRenderer], etc.
590    ///
591    /// gtk_cell_editable_editing_done() is a convenience method
592    /// for emitting `GtkCellEditable::editing-done`.
593    #[doc(alias = "editing-done")]
594    fn connect_editing_done<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
595        unsafe extern "C" fn editing_done_trampoline<P: IsA<CellEditable>, F: Fn(&P) + 'static>(
596            this: *mut ffi::GtkCellEditable,
597            f: glib::ffi::gpointer,
598        ) {
599            let f: &F = &*(f as *const F);
600            f(CellEditable::from_glib_borrow(this).unsafe_cast_ref())
601        }
602        unsafe {
603            let f: Box_<F> = Box_::new(f);
604            connect_raw(
605                self.as_ptr() as *mut _,
606                b"editing-done\0".as_ptr() as *const _,
607                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
608                    editing_done_trampoline::<Self, F> as *const (),
609                )),
610                Box_::into_raw(f),
611            )
612        }
613    }
614
615    /// This signal is meant to indicate that the cell is finished
616    /// editing, and the @cell_editable widget is being removed and may
617    /// subsequently be destroyed.
618    ///
619    /// Implementations of [`CellEditable`][crate::CellEditable] are responsible for
620    /// emitting this signal when they are done editing. It must
621    /// be emitted after the `GtkCellEditable::editing-done` signal,
622    /// to give the cell renderer a chance to update the cell's value
623    /// before the widget is removed.
624    ///
625    /// gtk_cell_editable_remove_widget() is a convenience method
626    /// for emitting `GtkCellEditable::remove-widget`.
627    #[doc(alias = "remove-widget")]
628    fn connect_remove_widget<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
629        unsafe extern "C" fn remove_widget_trampoline<P: IsA<CellEditable>, F: Fn(&P) + 'static>(
630            this: *mut ffi::GtkCellEditable,
631            f: glib::ffi::gpointer,
632        ) {
633            let f: &F = &*(f as *const F);
634            f(CellEditable::from_glib_borrow(this).unsafe_cast_ref())
635        }
636        unsafe {
637            let f: Box_<F> = Box_::new(f);
638            connect_raw(
639                self.as_ptr() as *mut _,
640                b"remove-widget\0".as_ptr() as *const _,
641                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
642                    remove_widget_trampoline::<Self, F> as *const (),
643                )),
644                Box_::into_raw(f),
645            )
646        }
647    }
648
649    #[doc(alias = "editing-canceled")]
650    fn connect_editing_canceled_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
651        unsafe extern "C" fn notify_editing_canceled_trampoline<
652            P: IsA<CellEditable>,
653            F: Fn(&P) + 'static,
654        >(
655            this: *mut ffi::GtkCellEditable,
656            _param_spec: glib::ffi::gpointer,
657            f: glib::ffi::gpointer,
658        ) {
659            let f: &F = &*(f as *const F);
660            f(CellEditable::from_glib_borrow(this).unsafe_cast_ref())
661        }
662        unsafe {
663            let f: Box_<F> = Box_::new(f);
664            connect_raw(
665                self.as_ptr() as *mut _,
666                b"notify::editing-canceled\0".as_ptr() as *const _,
667                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
668                    notify_editing_canceled_trampoline::<Self, F> as *const (),
669                )),
670                Box_::into_raw(f),
671            )
672        }
673    }
674}
675
676impl<O: IsA<CellEditable>> CellEditableExt for O {}