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