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