Skip to main content

gtk4/auto/
emoji_chooser.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;
8use crate::{
9    AccessibleRole, Align, Buildable, ConstraintTarget, LayoutManager, Native, Overflow, Popover,
10    PositionType, ShortcutManager, Widget, ffi,
11};
12use glib::{
13    object::ObjectType as _,
14    prelude::*,
15    signal::{SignalHandlerId, connect_raw},
16    translate::*,
17};
18use std::boxed::Box as Box_;
19
20#[cfg(feature = "v4_10")]
21#[cfg_attr(docsrs, doc(cfg(feature = "v4_10")))]
22glib::wrapper! {
23    ///  to select the first emoji result.
24    ///
25    /// # Actions
26    ///
27    /// [`EmojiChooser`][crate::EmojiChooser] defines a set of built-in actions:
28    ///
29    /// - `scroll.section` scrolls to the next or previous section.
30    ///
31    /// # CSS nodes
32    ///
33    /// ```text
34    /// popover
35    /// ├── box.emoji-searchbar
36    /// │   ╰── entry.search
37    /// ╰── box.emoji-toolbar
38    ///     ├── button.image-button.emoji-section
39    ///     ├── ...
40    ///     ╰── button.image-button.emoji-section
41    /// ```
42    ///
43    /// Every [`EmojiChooser`][crate::EmojiChooser] consists of a main node called popover.
44    /// The contents of the popover are largely implementation defined
45    /// and supposed to inherit general styles.
46    /// The top searchbar used to search emoji and gets the .emoji-searchbar
47    /// style class itself.
48    /// The bottom toolbar used to switch between different emoji categories
49    /// consists of buttons with the .emoji-section style class and gets the
50    /// .emoji-toolbar style class itself.
51    ///
52    /// ## Signals
53    ///
54    ///
55    /// #### `emoji-picked`
56    ///  Emitted when the user selects an Emoji.
57    ///
58    ///
59    /// <details><summary><h4>Popover</h4></summary>
60    ///
61    ///
62    /// #### `activate-default`
63    ///  .
64    ///
65    /// Action
66    ///
67    ///
68    /// #### `closed`
69    ///  Emitted when the popover is closed.
70    ///
71    ///
72    /// </details>
73    /// <details><summary><h4>Widget</h4></summary>
74    ///
75    ///
76    /// #### `destroy`
77    ///  Signals that all holders of a reference to the widget should release
78    /// the reference that they hold.
79    ///
80    /// May result in finalization of the widget if all references are released.
81    ///
82    /// This signal is not suitable for saving widget state.
83    ///
84    ///
85    ///
86    ///
87    /// #### `direction-changed`
88    ///  Emitted when the text direction of a widget changes.
89    ///
90    ///
91    ///
92    ///
93    /// #### `hide`
94    ///  Emitted when @widget is hidden.
95    ///
96    ///
97    ///
98    ///
99    /// #### `keynav-failed`
100    ///  Emitted if keyboard navigation fails.
101    ///
102    /// See [`WidgetExt::keynav_failed()`][crate::prelude::WidgetExt::keynav_failed()] for details.
103    ///
104    ///
105    ///
106    ///
107    /// #### `map`
108    ///  Emitted when @widget is going to be mapped.
109    ///
110    /// A widget is mapped when the widget is visible (which is controlled with
111    /// [`visible`][struct@crate::Widget#visible]) and all its parents up to the toplevel widget
112    /// are also visible.
113    ///
114    /// The `::map` signal can be used to determine whether a widget will be drawn,
115    /// for instance it can resume an animation that was stopped during the
116    /// emission of [`unmap`][struct@crate::Widget#unmap].
117    ///
118    ///
119    ///
120    ///
121    /// #### `mnemonic-activate`
122    ///  Emitted when a widget is activated via a mnemonic.
123    ///
124    /// The default handler for this signal activates @widget if @group_cycling
125    /// is false, or just makes @widget grab focus if @group_cycling is true.
126    ///
127    ///
128    ///
129    ///
130    /// #### `move-focus`
131    ///   to move backward.
132    ///
133    /// Action
134    ///
135    ///
136    /// #### `query-tooltip`
137    ///  Emitted when the widget’s tooltip is about to be shown.
138    ///
139    /// This happens when the [`has-tooltip`][struct@crate::Widget#has-tooltip] property
140    /// is true and the hover timeout has expired with the cursor hovering
141    /// above @widget; or emitted when @widget got focus in keyboard mode.
142    ///
143    /// Using the given coordinates, the signal handler should determine
144    /// whether a tooltip should be shown for @widget. If this is the case
145    /// true should be returned, false otherwise. Note that if @keyboard_mode
146    /// is true, the values of @x and @y are undefined and should not be used.
147    ///
148    /// The signal handler is free to manipulate @tooltip with the therefore
149    /// destined function calls.
150    ///
151    ///
152    ///
153    ///
154    /// #### `realize`
155    ///  Emitted when @widget is associated with a [`gdk::Surface`][crate::gdk::Surface].
156    ///
157    /// This means that [`WidgetExt::realize()`][crate::prelude::WidgetExt::realize()] has been called
158    /// or the widget has been mapped (that is, it is going to be drawn).
159    ///
160    ///
161    ///
162    ///
163    /// #### `show`
164    ///  Emitted when @widget is shown.
165    ///
166    ///
167    ///
168    ///
169    /// #### `state-flags-changed`
170    ///  Emitted when the widget state changes.
171    ///
172    /// See [`WidgetExt::state_flags()`][crate::prelude::WidgetExt::state_flags()].
173    ///
174    ///
175    ///
176    ///
177    /// #### `unmap`
178    ///  Emitted when @widget is going to be unmapped.
179    ///
180    /// A widget is unmapped when either it or any of its parents up to the
181    /// toplevel widget have been set as hidden.
182    ///
183    /// As `::unmap` indicates that a widget will not be shown any longer,
184    /// it can be used to, for example, stop an animation on the widget.
185    ///
186    ///
187    ///
188    ///
189    /// #### `unrealize`
190    ///  Emitted when the [`gdk::Surface`][crate::gdk::Surface] associated with @widget is destroyed.
191    ///
192    /// This means that [`WidgetExt::unrealize()`][crate::prelude::WidgetExt::unrealize()] has been called
193    /// or the widget has been unmapped (that is, it is going to be hidden).
194    ///
195    ///
196    /// </details>
197    ///
198    /// # Implements
199    ///
200    /// [`PopoverExt`][trait@crate::prelude::PopoverExt], [`WidgetExt`][trait@crate::prelude::WidgetExt], [`trait@glib::ObjectExt`], [`AccessibleExt`][trait@crate::prelude::AccessibleExt], [`BuildableExt`][trait@crate::prelude::BuildableExt], [`ConstraintTargetExt`][trait@crate::prelude::ConstraintTargetExt], [`NativeExt`][trait@crate::prelude::NativeExt], [`ShortcutManagerExt`][trait@crate::prelude::ShortcutManagerExt], [`WidgetExtManual`][trait@crate::prelude::WidgetExtManual], [`AccessibleExtManual`][trait@crate::prelude::AccessibleExtManual]
201    #[doc(alias = "GtkEmojiChooser")]
202    pub struct EmojiChooser(Object<ffi::GtkEmojiChooser, ffi::GtkEmojiChooserClass>) @extends Popover, Widget, @implements Accessible, Buildable, ConstraintTarget, Native, ShortcutManager;
203
204    match fn {
205        type_ => || ffi::gtk_emoji_chooser_get_type(),
206    }
207}
208
209#[cfg(not(feature = "v4_10"))]
210glib::wrapper! {
211    #[doc(alias = "GtkEmojiChooser")]
212    pub struct EmojiChooser(Object<ffi::GtkEmojiChooser, ffi::GtkEmojiChooserClass>) @extends Popover, Widget, @implements Buildable, ConstraintTarget, Native, ShortcutManager;
213
214    match fn {
215        type_ => || ffi::gtk_emoji_chooser_get_type(),
216    }
217}
218
219impl EmojiChooser {
220    /// Creates a new [`EmojiChooser`][crate::EmojiChooser].
221    ///
222    /// # Returns
223    ///
224    /// a new [`EmojiChooser`][crate::EmojiChooser]
225    #[doc(alias = "gtk_emoji_chooser_new")]
226    pub fn new() -> EmojiChooser {
227        assert_initialized_main_thread!();
228        unsafe { Widget::from_glib_none(ffi::gtk_emoji_chooser_new()).unsafe_cast() }
229    }
230
231    // rustdoc-stripper-ignore-next
232    /// Creates a new builder-pattern struct instance to construct [`EmojiChooser`] objects.
233    ///
234    /// This method returns an instance of [`EmojiChooserBuilder`](crate::builders::EmojiChooserBuilder) which can be used to create [`EmojiChooser`] objects.
235    pub fn builder() -> EmojiChooserBuilder {
236        EmojiChooserBuilder::new()
237    }
238
239    /// Emitted when the user selects an Emoji.
240    /// ## `text`
241    /// the Unicode sequence for the picked Emoji, in UTF-8
242    #[doc(alias = "emoji-picked")]
243    pub fn connect_emoji_picked<F: Fn(&Self, &str) + 'static>(&self, f: F) -> SignalHandlerId {
244        unsafe extern "C" fn emoji_picked_trampoline<F: Fn(&EmojiChooser, &str) + 'static>(
245            this: *mut ffi::GtkEmojiChooser,
246            text: *mut std::ffi::c_char,
247            f: glib::ffi::gpointer,
248        ) {
249            unsafe {
250                let f: &F = &*(f as *const F);
251                f(
252                    &from_glib_borrow(this),
253                    &glib::GString::from_glib_borrow(text),
254                )
255            }
256        }
257        unsafe {
258            let f: Box_<F> = Box_::new(f);
259            connect_raw(
260                self.as_ptr() as *mut _,
261                c"emoji-picked".as_ptr(),
262                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
263                    emoji_picked_trampoline::<F> as *const (),
264                )),
265                Box_::into_raw(f),
266            )
267        }
268    }
269}
270
271impl Default for EmojiChooser {
272    fn default() -> Self {
273        Self::new()
274    }
275}
276
277// rustdoc-stripper-ignore-next
278/// A [builder-pattern] type to construct [`EmojiChooser`] objects.
279///
280/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
281#[must_use = "The builder must be built to be used"]
282pub struct EmojiChooserBuilder {
283    builder: glib::object::ObjectBuilder<'static, EmojiChooser>,
284}
285
286impl EmojiChooserBuilder {
287    fn new() -> Self {
288        Self {
289            builder: glib::object::Object::builder(),
290        }
291    }
292
293    /// Whether to dismiss the popover on outside clicks.
294    ///
295    /// If false, the popover won't automatically grab the focus when shown.
296    /// This is useful for usecases like entry completion, where the focus is
297    /// expected to stay on the entry.
298    pub fn autohide(self, autohide: bool) -> Self {
299        Self {
300            builder: self.builder.property("autohide", autohide),
301        }
302    }
303
304    /// Whether the popover pops down after a child popover.
305    ///
306    /// This is used to implement the expected behavior of submenus.
307    pub fn cascade_popdown(self, cascade_popdown: bool) -> Self {
308        Self {
309            builder: self.builder.property("cascade-popdown", cascade_popdown),
310        }
311    }
312
313    /// The child widget.
314    pub fn child(self, child: &impl IsA<Widget>) -> Self {
315        Self {
316            builder: self.builder.property("child", child.clone().upcast()),
317        }
318    }
319
320    /// The default widget inside the popover.
321    pub fn default_widget(self, default_widget: &impl IsA<Widget>) -> Self {
322        Self {
323            builder: self
324                .builder
325                .property("default-widget", default_widget.clone().upcast()),
326        }
327    }
328
329    /// Whether to draw an arrow.
330    pub fn has_arrow(self, has_arrow: bool) -> Self {
331        Self {
332            builder: self.builder.property("has-arrow", has_arrow),
333        }
334    }
335
336    /// Whether mnemonics are currently visible in this popover.
337    pub fn mnemonics_visible(self, mnemonics_visible: bool) -> Self {
338        Self {
339            builder: self
340                .builder
341                .property("mnemonics-visible", mnemonics_visible),
342        }
343    }
344
345    /// Rectangle in the parent widget that the popover points to.
346    pub fn pointing_to(self, pointing_to: &gdk::Rectangle) -> Self {
347        Self {
348            builder: self.builder.property("pointing-to", pointing_to),
349        }
350    }
351
352    /// How to place the popover, relative to its parent.
353    pub fn position(self, position: PositionType) -> Self {
354        Self {
355            builder: self.builder.property("position", position),
356        }
357    }
358
359    /// Whether the widget or any of its descendents can accept
360    /// the input focus.
361    ///
362    /// This property is meant to be set by widget implementations,
363    /// typically in their instance init function.
364    pub fn can_focus(self, can_focus: bool) -> Self {
365        Self {
366            builder: self.builder.property("can-focus", can_focus),
367        }
368    }
369
370    /// Whether the widget can receive pointer events.
371    pub fn can_target(self, can_target: bool) -> Self {
372        Self {
373            builder: self.builder.property("can-target", can_target),
374        }
375    }
376
377    /// A list of css classes applied to this widget.
378    pub fn css_classes(self, css_classes: impl Into<glib::StrV>) -> Self {
379        Self {
380            builder: self.builder.property("css-classes", css_classes.into()),
381        }
382    }
383
384    /// The name of this widget in the CSS tree.
385    ///
386    /// This property is meant to be set by widget implementations,
387    /// typically in their instance init function.
388    pub fn css_name(self, css_name: impl Into<glib::GString>) -> Self {
389        Self {
390            builder: self.builder.property("css-name", css_name.into()),
391        }
392    }
393
394    /// The cursor used by @widget.
395    pub fn cursor(self, cursor: &gdk::Cursor) -> Self {
396        Self {
397            builder: self.builder.property("cursor", cursor.clone()),
398        }
399    }
400
401    /// Whether the widget should grab focus when it is clicked with the mouse.
402    ///
403    /// This property is only relevant for widgets that can take focus.
404    pub fn focus_on_click(self, focus_on_click: bool) -> Self {
405        Self {
406            builder: self.builder.property("focus-on-click", focus_on_click),
407        }
408    }
409
410    /// Whether this widget itself will accept the input focus.
411    pub fn focusable(self, focusable: bool) -> Self {
412        Self {
413            builder: self.builder.property("focusable", focusable),
414        }
415    }
416
417    /// How to distribute horizontal space if widget gets extra space.
418    pub fn halign(self, halign: Align) -> Self {
419        Self {
420            builder: self.builder.property("halign", halign),
421        }
422    }
423
424    /// Enables or disables the emission of the [`query-tooltip`][struct@crate::Widget#query-tooltip]
425    /// signal on @widget.
426    ///
427    /// A true value indicates that @widget can have a tooltip, in this case
428    /// the widget will be queried using [`query-tooltip`][struct@crate::Widget#query-tooltip] to
429    /// determine whether it will provide a tooltip or not.
430    pub fn has_tooltip(self, has_tooltip: bool) -> Self {
431        Self {
432            builder: self.builder.property("has-tooltip", has_tooltip),
433        }
434    }
435
436    /// Overrides for height request of the widget.
437    ///
438    /// If this is -1, the natural request will be used.
439    pub fn height_request(self, height_request: i32) -> Self {
440        Self {
441            builder: self.builder.property("height-request", height_request),
442        }
443    }
444
445    /// Whether to expand horizontally.
446    pub fn hexpand(self, hexpand: bool) -> Self {
447        Self {
448            builder: self.builder.property("hexpand", hexpand),
449        }
450    }
451
452    /// Whether to use the `hexpand` property.
453    pub fn hexpand_set(self, hexpand_set: bool) -> Self {
454        Self {
455            builder: self.builder.property("hexpand-set", hexpand_set),
456        }
457    }
458
459    /// The [`LayoutManager`][crate::LayoutManager] instance to use to compute
460    /// the preferred size of the widget, and allocate its children.
461    ///
462    /// This property is meant to be set by widget implementations,
463    /// typically in their instance init function.
464    pub fn layout_manager(self, layout_manager: &impl IsA<LayoutManager>) -> Self {
465        Self {
466            builder: self
467                .builder
468                .property("layout-manager", layout_manager.clone().upcast()),
469        }
470    }
471
472    /// Makes this widget act like a modal dialog, with respect to
473    /// event delivery.
474    ///
475    /// Global event controllers will not handle events with targets
476    /// inside the widget, unless they are set up to ignore propagation
477    /// limits. See [`EventControllerExt::set_propagation_limit()`][crate::prelude::EventControllerExt::set_propagation_limit()].
478    #[cfg(feature = "v4_18")]
479    #[cfg_attr(docsrs, doc(cfg(feature = "v4_18")))]
480    pub fn limit_events(self, limit_events: bool) -> Self {
481        Self {
482            builder: self.builder.property("limit-events", limit_events),
483        }
484    }
485
486    /// Margin on bottom side of widget.
487    ///
488    /// This property adds margin outside of the widget's normal size
489    /// request, the margin will be added in addition to the size from
490    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
491    pub fn margin_bottom(self, margin_bottom: i32) -> Self {
492        Self {
493            builder: self.builder.property("margin-bottom", margin_bottom),
494        }
495    }
496
497    /// Margin on end of widget, horizontally.
498    ///
499    /// This property supports left-to-right and right-to-left text
500    /// directions.
501    ///
502    /// This property adds margin outside of the widget's normal size
503    /// request, the margin will be added in addition to the size from
504    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
505    pub fn margin_end(self, margin_end: i32) -> Self {
506        Self {
507            builder: self.builder.property("margin-end", margin_end),
508        }
509    }
510
511    /// Margin on start of widget, horizontally.
512    ///
513    /// This property supports left-to-right and right-to-left text
514    /// directions.
515    ///
516    /// This property adds margin outside of the widget's normal size
517    /// request, the margin will be added in addition to the size from
518    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
519    pub fn margin_start(self, margin_start: i32) -> Self {
520        Self {
521            builder: self.builder.property("margin-start", margin_start),
522        }
523    }
524
525    /// Margin on top side of widget.
526    ///
527    /// This property adds margin outside of the widget's normal size
528    /// request, the margin will be added in addition to the size from
529    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
530    pub fn margin_top(self, margin_top: i32) -> Self {
531        Self {
532            builder: self.builder.property("margin-top", margin_top),
533        }
534    }
535
536    /// The name of the widget.
537    pub fn name(self, name: impl Into<glib::GString>) -> Self {
538        Self {
539            builder: self.builder.property("name", name.into()),
540        }
541    }
542
543    /// The requested opacity of the widget.
544    pub fn opacity(self, opacity: f64) -> Self {
545        Self {
546            builder: self.builder.property("opacity", opacity),
547        }
548    }
549
550    /// How content outside the widget's content area is treated.
551    ///
552    /// This property is meant to be set by widget implementations,
553    /// typically in their instance init function.
554    pub fn overflow(self, overflow: Overflow) -> Self {
555        Self {
556            builder: self.builder.property("overflow", overflow),
557        }
558    }
559
560    /// Whether the widget will receive the default action when it is focused.
561    pub fn receives_default(self, receives_default: bool) -> Self {
562        Self {
563            builder: self.builder.property("receives-default", receives_default),
564        }
565    }
566
567    /// Whether the widget responds to input.
568    pub fn sensitive(self, sensitive: bool) -> Self {
569        Self {
570            builder: self.builder.property("sensitive", sensitive),
571        }
572    }
573
574    /// Sets the text of tooltip to be the given string, which is marked up
575    /// with Pango markup.
576    ///
577    /// Also see [`Tooltip::set_markup()`][crate::Tooltip::set_markup()].
578    ///
579    /// This is a convenience property which will take care of getting the
580    /// tooltip shown if the given string is not `NULL`:
581    /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
582    /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
583    /// the default signal handler.
584    ///
585    /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
586    /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
587    pub fn tooltip_markup(self, tooltip_markup: impl Into<glib::GString>) -> Self {
588        Self {
589            builder: self
590                .builder
591                .property("tooltip-markup", tooltip_markup.into()),
592        }
593    }
594
595    /// Sets the text of tooltip to be the given string.
596    ///
597    /// Also see [`Tooltip::set_text()`][crate::Tooltip::set_text()].
598    ///
599    /// This is a convenience property which will take care of getting the
600    /// tooltip shown if the given string is not `NULL`:
601    /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
602    /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
603    /// the default signal handler.
604    ///
605    /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
606    /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
607    pub fn tooltip_text(self, tooltip_text: impl Into<glib::GString>) -> Self {
608        Self {
609            builder: self.builder.property("tooltip-text", tooltip_text.into()),
610        }
611    }
612
613    /// How to distribute vertical space if widget gets extra space.
614    pub fn valign(self, valign: Align) -> Self {
615        Self {
616            builder: self.builder.property("valign", valign),
617        }
618    }
619
620    /// Whether to expand vertically.
621    pub fn vexpand(self, vexpand: bool) -> Self {
622        Self {
623            builder: self.builder.property("vexpand", vexpand),
624        }
625    }
626
627    /// Whether to use the `vexpand` property.
628    pub fn vexpand_set(self, vexpand_set: bool) -> Self {
629        Self {
630            builder: self.builder.property("vexpand-set", vexpand_set),
631        }
632    }
633
634    /// Whether the widget is visible.
635    pub fn visible(self, visible: bool) -> Self {
636        Self {
637            builder: self.builder.property("visible", visible),
638        }
639    }
640
641    /// Overrides for width request of the widget.
642    ///
643    /// If this is -1, the natural request will be used.
644    pub fn width_request(self, width_request: i32) -> Self {
645        Self {
646            builder: self.builder.property("width-request", width_request),
647        }
648    }
649
650    /// The accessible role of the given [`Accessible`][crate::Accessible] implementation.
651    ///
652    /// The accessible role cannot be changed once set.
653    pub fn accessible_role(self, accessible_role: AccessibleRole) -> Self {
654        Self {
655            builder: self.builder.property("accessible-role", accessible_role),
656        }
657    }
658
659    // rustdoc-stripper-ignore-next
660    /// Build the [`EmojiChooser`].
661    #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
662    pub fn build(self) -> EmojiChooser {
663        assert_initialized_main_thread!();
664        self.builder.build()
665    }
666}