gtk4/auto/search_entry.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 Accessible, AccessibleRole, Align, Buildable, ConstraintTarget, Editable, LayoutManager,
7 Overflow, Widget, ffi,
8};
9#[cfg(feature = "v4_14")]
10#[cfg_attr(docsrs, doc(cfg(feature = "v4_14")))]
11use crate::{InputHints, InputPurpose};
12use glib::{
13 object::ObjectType as _,
14 prelude::*,
15 signal::{SignalHandlerId, connect_raw},
16 translate::*,
17};
18use std::boxed::Box as Box_;
19
20glib::wrapper! {
21 /// A single-line text entry widget for use as a search entry.
22 ///
23 /// The main API for interacting with a [`SearchEntry`][crate::SearchEntry] as entry
24 /// is the [`Editable`][crate::Editable] interface.
25 ///
26 /// <picture>
27 /// <source srcset="search-entry-dark.png" media="(prefers-color-scheme: dark)">
28 /// <img alt="An example GtkSearchEntry" src="search-entry.png">
29 /// </picture>
30 ///
31 /// It will show an inactive symbolic “find” icon when the search
32 /// entry is empty, and a symbolic “clear” icon when there is text.
33 /// Clicking on the “clear” icon will empty the search entry.
34 ///
35 /// To make filtering appear more reactive, it is a good idea to
36 /// not react to every change in the entry text immediately, but
37 /// only after a short delay. To support this, [`SearchEntry`][crate::SearchEntry]
38 /// emits the [`search-changed`][struct@crate::SearchEntry#search-changed] signal which
39 /// can be used instead of the [`changed`][struct@crate::Editable#changed] signal.
40 ///
41 /// The [`previous-match`][struct@crate::SearchEntry#previous-match],
42 /// [`next-match`][struct@crate::SearchEntry#next-match] and
43 /// [`stop-search`][struct@crate::SearchEntry#stop-search] signals can be used to
44 /// implement moving between search results and ending the search.
45 ///
46 /// Often, [`SearchEntry`][crate::SearchEntry] will be fed events by means of being
47 /// placed inside a [`SearchBar`][crate::SearchBar]. If that is not the case,
48 /// you can use [`set_key_capture_widget()`][Self::set_key_capture_widget()] to
49 /// let it capture key input from another widget.
50 ///
51 /// [`SearchEntry`][crate::SearchEntry] provides only minimal API and should be used with
52 /// the [`Editable`][crate::Editable] API.
53 ///
54 /// ## Shortcuts and Gestures
55 ///
56 /// The following signals have default keybindings:
57 ///
58 /// - [`activate`][struct@crate::SearchEntry#activate]
59 /// - [`next-match`][struct@crate::SearchEntry#next-match]
60 /// - [`previous-match`][struct@crate::SearchEntry#previous-match]
61 /// - [`stop-search`][struct@crate::SearchEntry#stop-search]
62 ///
63 /// ## CSS Nodes
64 ///
65 /// ```text
66 /// entry.search
67 /// ╰── text
68 /// ```
69 ///
70 /// [`SearchEntry`][crate::SearchEntry] has a single CSS node with name entry that carries
71 /// a `.search` style class, and the text node is a child of that.
72 ///
73 /// ## Accessibility
74 ///
75 /// [`SearchEntry`][crate::SearchEntry] uses the [enum@Gtk.AccessibleRole.search_box] role.
76 ///
77 /// ## Properties
78 ///
79 ///
80 /// #### `activates-default`
81 /// Whether to activate the default widget when Enter is pressed.
82 ///
83 /// Readable | Writeable
84 ///
85 ///
86 /// #### `input-hints`
87 /// The hints about input for the [`SearchEntry`][crate::SearchEntry] used to alter the
88 /// behaviour of input methods.
89 ///
90 /// Readable | Writeable
91 ///
92 ///
93 /// #### `input-purpose`
94 /// The purpose for the [`SearchEntry`][crate::SearchEntry] input used to alter the
95 /// behaviour of input methods.
96 ///
97 /// Readable | Writeable
98 ///
99 ///
100 /// #### `key-capture-widget`
101 /// The widget that the entry will use to capture key events.
102 ///
103 /// Key events are consumed by the search entry to start or continue a search.
104 ///
105 /// Readable | Writeable | Construct
106 ///
107 ///
108 /// #### `placeholder-text`
109 /// The text that will be displayed in the [`SearchEntry`][crate::SearchEntry]
110 /// when it is empty and unfocused.
111 ///
112 /// Readable | Writeable
113 ///
114 ///
115 /// #### `search-delay`
116 /// The delay in milliseconds from last keypress to the search
117 /// changed signal.
118 ///
119 /// Readable | Writeable
120 /// <details><summary><h4>Widget</h4></summary>
121 ///
122 ///
123 /// #### `can-focus`
124 /// Whether the widget or any of its descendents can accept
125 /// the input focus.
126 ///
127 /// This property is meant to be set by widget implementations,
128 /// typically in their instance init function.
129 ///
130 /// Readable | Writeable
131 ///
132 ///
133 /// #### `can-target`
134 /// Whether the widget can receive pointer events.
135 ///
136 /// Readable | Writeable
137 ///
138 ///
139 /// #### `css-classes`
140 /// A list of css classes applied to this widget.
141 ///
142 /// Readable | Writeable
143 ///
144 ///
145 /// #### `css-name`
146 /// The name of this widget in the CSS tree.
147 ///
148 /// This property is meant to be set by widget implementations,
149 /// typically in their instance init function.
150 ///
151 /// Readable | Writeable | Construct Only
152 ///
153 ///
154 /// #### `cursor`
155 /// The cursor used by @widget.
156 ///
157 /// Readable | Writeable
158 ///
159 ///
160 /// #### `focus-on-click`
161 /// Whether the widget should grab focus when it is clicked with the mouse.
162 ///
163 /// This property is only relevant for widgets that can take focus.
164 ///
165 /// Readable | Writeable
166 ///
167 ///
168 /// #### `focusable`
169 /// Whether this widget itself will accept the input focus.
170 ///
171 /// Readable | Writeable
172 ///
173 ///
174 /// #### `halign`
175 /// How to distribute horizontal space if widget gets extra space.
176 ///
177 /// Readable | Writeable
178 ///
179 ///
180 /// #### `has-default`
181 /// Whether the widget is the default widget.
182 ///
183 /// Readable
184 ///
185 ///
186 /// #### `has-focus`
187 /// Whether the widget has the input focus.
188 ///
189 /// Readable
190 ///
191 ///
192 /// #### `has-tooltip`
193 /// Enables or disables the emission of the [`query-tooltip`][struct@crate::Widget#query-tooltip]
194 /// signal on @widget.
195 ///
196 /// A true value indicates that @widget can have a tooltip, in this case
197 /// the widget will be queried using [`query-tooltip`][struct@crate::Widget#query-tooltip] to
198 /// determine whether it will provide a tooltip or not.
199 ///
200 /// Readable | Writeable
201 ///
202 ///
203 /// #### `height-request`
204 /// Overrides for height request of the widget.
205 ///
206 /// If this is -1, the natural request will be used.
207 ///
208 /// Readable | Writeable
209 ///
210 ///
211 /// #### `hexpand`
212 /// Whether to expand horizontally.
213 ///
214 /// Readable | Writeable
215 ///
216 ///
217 /// #### `hexpand-set`
218 /// Whether to use the `hexpand` property.
219 ///
220 /// Readable | Writeable
221 ///
222 ///
223 /// #### `layout-manager`
224 /// The [`LayoutManager`][crate::LayoutManager] instance to use to compute
225 /// the preferred size of the widget, and allocate its children.
226 ///
227 /// This property is meant to be set by widget implementations,
228 /// typically in their instance init function.
229 ///
230 /// Readable | Writeable
231 ///
232 ///
233 /// #### `limit-events`
234 /// Makes this widget act like a modal dialog, with respect to
235 /// event delivery.
236 ///
237 /// Global event controllers will not handle events with targets
238 /// inside the widget, unless they are set up to ignore propagation
239 /// limits. See [`EventControllerExt::set_propagation_limit()`][crate::prelude::EventControllerExt::set_propagation_limit()].
240 ///
241 /// Readable | Writeable
242 ///
243 ///
244 /// #### `margin-bottom`
245 /// Margin on bottom side of widget.
246 ///
247 /// This property adds margin outside of the widget's normal size
248 /// request, the margin will be added in addition to the size from
249 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
250 ///
251 /// Readable | Writeable
252 ///
253 ///
254 /// #### `margin-end`
255 /// Margin on end of widget, horizontally.
256 ///
257 /// This property supports left-to-right and right-to-left text
258 /// directions.
259 ///
260 /// This property adds margin outside of the widget's normal size
261 /// request, the margin will be added in addition to the size from
262 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
263 ///
264 /// Readable | Writeable
265 ///
266 ///
267 /// #### `margin-start`
268 /// Margin on start of widget, horizontally.
269 ///
270 /// This property supports left-to-right and right-to-left text
271 /// directions.
272 ///
273 /// This property adds margin outside of the widget's normal size
274 /// request, the margin will be added in addition to the size from
275 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
276 ///
277 /// Readable | Writeable
278 ///
279 ///
280 /// #### `margin-top`
281 /// Margin on top side of widget.
282 ///
283 /// This property adds margin outside of the widget's normal size
284 /// request, the margin will be added in addition to the size from
285 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
286 ///
287 /// Readable | Writeable
288 ///
289 ///
290 /// #### `name`
291 /// The name of the widget.
292 ///
293 /// Readable | Writeable
294 ///
295 ///
296 /// #### `opacity`
297 /// The requested opacity of the widget.
298 ///
299 /// Readable | Writeable
300 ///
301 ///
302 /// #### `overflow`
303 /// How content outside the widget's content area is treated.
304 ///
305 /// This property is meant to be set by widget implementations,
306 /// typically in their instance init function.
307 ///
308 /// Readable | Writeable
309 ///
310 ///
311 /// #### `parent`
312 /// The parent widget of this widget.
313 ///
314 /// Readable
315 ///
316 ///
317 /// #### `receives-default`
318 /// Whether the widget will receive the default action when it is focused.
319 ///
320 /// Readable | Writeable
321 ///
322 ///
323 /// #### `root`
324 /// The [`Root`][crate::Root] widget of the widget tree containing this widget.
325 ///
326 /// This will be `NULL` if the widget is not contained in a root widget.
327 ///
328 /// Readable
329 ///
330 ///
331 /// #### `scale-factor`
332 /// The scale factor of the widget.
333 ///
334 /// Readable
335 ///
336 ///
337 /// #### `sensitive`
338 /// Whether the widget responds to input.
339 ///
340 /// Readable | Writeable
341 ///
342 ///
343 /// #### `tooltip-markup`
344 /// Sets the text of tooltip to be the given string, which is marked up
345 /// with Pango markup.
346 ///
347 /// Also see [`Tooltip::set_markup()`][crate::Tooltip::set_markup()].
348 ///
349 /// This is a convenience property which will take care of getting the
350 /// tooltip shown if the given string is not `NULL`:
351 /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
352 /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
353 /// the default signal handler.
354 ///
355 /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
356 /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
357 ///
358 /// Readable | Writeable
359 ///
360 ///
361 /// #### `tooltip-text`
362 /// Sets the text of tooltip to be the given string.
363 ///
364 /// Also see [`Tooltip::set_text()`][crate::Tooltip::set_text()].
365 ///
366 /// This is a convenience property which will take care of getting the
367 /// tooltip shown if the given string is not `NULL`:
368 /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
369 /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
370 /// the default signal handler.
371 ///
372 /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
373 /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
374 ///
375 /// Readable | Writeable
376 ///
377 ///
378 /// #### `valign`
379 /// How to distribute vertical space if widget gets extra space.
380 ///
381 /// Readable | Writeable
382 ///
383 ///
384 /// #### `vexpand`
385 /// Whether to expand vertically.
386 ///
387 /// Readable | Writeable
388 ///
389 ///
390 /// #### `vexpand-set`
391 /// Whether to use the `vexpand` property.
392 ///
393 /// Readable | Writeable
394 ///
395 ///
396 /// #### `visible`
397 /// Whether the widget is visible.
398 ///
399 /// Readable | Writeable
400 ///
401 ///
402 /// #### `width-request`
403 /// Overrides for width request of the widget.
404 ///
405 /// If this is -1, the natural request will be used.
406 ///
407 /// Readable | Writeable
408 /// </details>
409 /// <details><summary><h4>Accessible</h4></summary>
410 ///
411 ///
412 /// #### `accessible-role`
413 /// The accessible role of the given [`Accessible`][crate::Accessible] implementation.
414 ///
415 /// The accessible role cannot be changed once set.
416 ///
417 /// Readable | Writeable
418 /// </details>
419 /// <details><summary><h4>Editable</h4></summary>
420 ///
421 ///
422 /// #### `cursor-position`
423 /// The current position of the insertion cursor in chars.
424 ///
425 /// Readable
426 ///
427 ///
428 /// #### `editable`
429 /// Whether the entry contents can be edited.
430 ///
431 /// Readable | Writeable
432 ///
433 ///
434 /// #### `enable-undo`
435 /// If undo/redo should be enabled for the editable.
436 ///
437 /// Readable | Writeable
438 ///
439 ///
440 /// #### `max-width-chars`
441 /// The desired maximum width of the entry, in characters.
442 ///
443 /// Readable | Writeable
444 ///
445 ///
446 /// #### `selection-bound`
447 /// The position of the opposite end of the selection from the cursor in chars.
448 ///
449 /// Readable
450 ///
451 ///
452 /// #### `text`
453 /// The contents of the entry.
454 ///
455 /// Readable | Writeable
456 ///
457 ///
458 /// #### `width-chars`
459 /// Number of characters to leave space for in the entry.
460 ///
461 /// Readable | Writeable
462 ///
463 ///
464 /// #### `xalign`
465 /// The horizontal alignment, from 0 (left) to 1 (right).
466 ///
467 /// Reversed for RTL layouts.
468 ///
469 /// Readable | Writeable
470 /// </details>
471 ///
472 /// ## Signals
473 ///
474 ///
475 /// #### `activate`
476 /// Emitted when the entry is activated.
477 ///
478 /// The keybindings for this signal are all forms of the <kbd>Enter</kbd> key.
479 ///
480 /// Action
481 ///
482 ///
483 /// #### `next-match`
484 /// Emitted when the user initiates a move to the next match
485 /// for the current search string.
486 ///
487 /// This is a [keybinding signal](class.SignalAction.html).
488 ///
489 /// Applications should connect to it, to implement moving
490 /// between matches.
491 ///
492 /// The default bindings for this signal is <kbd>Ctrl</kbd>+<kbd>g</kbd>.
493 ///
494 /// Action
495 ///
496 ///
497 /// #### `previous-match`
498 /// Emitted when the user initiates a move to the previous match
499 /// for the current search string.
500 ///
501 /// This is a [keybinding signal](class.SignalAction.html).
502 ///
503 /// Applications should connect to it, to implement moving
504 /// between matches.
505 ///
506 /// The default bindings for this signal is
507 /// <kbd>Ctrl</kbd>+<kbd>Shift</kbd>+<kbd>g</kbd>.
508 ///
509 /// Action
510 ///
511 ///
512 /// #### `search-changed`
513 /// Emitted with a delay. The length of the delay can be
514 /// changed with the [`search-delay`][struct@crate::SearchEntry#search-delay]
515 /// property.
516 ///
517 ///
518 ///
519 ///
520 /// #### `search-started`
521 /// Emitted when the user initiated a search on the entry.
522 ///
523 ///
524 ///
525 ///
526 /// #### `stop-search`
527 /// Emitted when the user stops a search via keyboard input.
528 ///
529 /// This is a [keybinding signal](class.SignalAction.html).
530 ///
531 /// Applications should connect to it, to implement hiding
532 /// the search entry in this case.
533 ///
534 /// The default bindings for this signal is <kbd>Escape</kbd>.
535 ///
536 /// Action
537 /// <details><summary><h4>Widget</h4></summary>
538 ///
539 ///
540 /// #### `destroy`
541 /// Signals that all holders of a reference to the widget should release
542 /// the reference that they hold.
543 ///
544 /// May result in finalization of the widget if all references are released.
545 ///
546 /// This signal is not suitable for saving widget state.
547 ///
548 ///
549 ///
550 ///
551 /// #### `direction-changed`
552 /// Emitted when the text direction of a widget changes.
553 ///
554 ///
555 ///
556 ///
557 /// #### `hide`
558 /// Emitted when @widget is hidden.
559 ///
560 ///
561 ///
562 ///
563 /// #### `keynav-failed`
564 /// Emitted if keyboard navigation fails.
565 ///
566 /// See [`WidgetExt::keynav_failed()`][crate::prelude::WidgetExt::keynav_failed()] for details.
567 ///
568 ///
569 ///
570 ///
571 /// #### `map`
572 /// Emitted when @widget is going to be mapped.
573 ///
574 /// A widget is mapped when the widget is visible (which is controlled with
575 /// [`visible`][struct@crate::Widget#visible]) and all its parents up to the toplevel widget
576 /// are also visible.
577 ///
578 /// The `::map` signal can be used to determine whether a widget will be drawn,
579 /// for instance it can resume an animation that was stopped during the
580 /// emission of [`unmap`][struct@crate::Widget#unmap].
581 ///
582 ///
583 ///
584 ///
585 /// #### `mnemonic-activate`
586 /// Emitted when a widget is activated via a mnemonic.
587 ///
588 /// The default handler for this signal activates @widget if @group_cycling
589 /// is false, or just makes @widget grab focus if @group_cycling is true.
590 ///
591 ///
592 ///
593 ///
594 /// #### `move-focus`
595 /// Emitted when the focus is moved.
596 ///
597 /// The `::move-focus` signal is a [keybinding signal](class.SignalAction.html).
598 ///
599 /// The default bindings for this signal are <kbd>Tab</kbd> to move forward,
600 /// and <kbd>Shift</kbd>+<kbd>Tab</kbd> to move backward.
601 ///
602 /// Action
603 ///
604 ///
605 /// #### `query-tooltip`
606 /// Emitted when the widget’s tooltip is about to be shown.
607 ///
608 /// This happens when the [`has-tooltip`][struct@crate::Widget#has-tooltip] property
609 /// is true and the hover timeout has expired with the cursor hovering
610 /// above @widget; or emitted when @widget got focus in keyboard mode.
611 ///
612 /// Using the given coordinates, the signal handler should determine
613 /// whether a tooltip should be shown for @widget. If this is the case
614 /// true should be returned, false otherwise. Note that if @keyboard_mode
615 /// is true, the values of @x and @y are undefined and should not be used.
616 ///
617 /// The signal handler is free to manipulate @tooltip with the therefore
618 /// destined function calls.
619 ///
620 ///
621 ///
622 ///
623 /// #### `realize`
624 /// Emitted when @widget is associated with a [`gdk::Surface`][crate::gdk::Surface].
625 ///
626 /// This means that [`WidgetExt::realize()`][crate::prelude::WidgetExt::realize()] has been called
627 /// or the widget has been mapped (that is, it is going to be drawn).
628 ///
629 ///
630 ///
631 ///
632 /// #### `show`
633 /// Emitted when @widget is shown.
634 ///
635 ///
636 ///
637 ///
638 /// #### `state-flags-changed`
639 /// Emitted when the widget state changes.
640 ///
641 /// See [`WidgetExt::state_flags()`][crate::prelude::WidgetExt::state_flags()].
642 ///
643 ///
644 ///
645 ///
646 /// #### `unmap`
647 /// Emitted when @widget is going to be unmapped.
648 ///
649 /// A widget is unmapped when either it or any of its parents up to the
650 /// toplevel widget have been set as hidden.
651 ///
652 /// As `::unmap` indicates that a widget will not be shown any longer,
653 /// it can be used to, for example, stop an animation on the widget.
654 ///
655 ///
656 ///
657 ///
658 /// #### `unrealize`
659 /// Emitted when the [`gdk::Surface`][crate::gdk::Surface] associated with @widget is destroyed.
660 ///
661 /// This means that [`WidgetExt::unrealize()`][crate::prelude::WidgetExt::unrealize()] has been called
662 /// or the widget has been unmapped (that is, it is going to be hidden).
663 ///
664 ///
665 /// </details>
666 /// <details><summary><h4>Editable</h4></summary>
667 ///
668 ///
669 /// #### `changed`
670 /// Emitted at the end of a single user-visible operation on the
671 /// contents.
672 ///
673 /// E.g., a paste operation that replaces the contents of the
674 /// selection will cause only one signal emission (even though it
675 /// is implemented by first deleting the selection, then inserting
676 /// the new content, and may cause multiple ::notify::text signals
677 /// to be emitted).
678 ///
679 ///
680 ///
681 ///
682 /// #### `delete-text`
683 /// Emitted when text is deleted from the widget by the user.
684 ///
685 /// The default handler for this signal will normally be responsible for
686 /// deleting the text, so by connecting to this signal and then stopping
687 /// the signal with g_signal_stop_emission(), it is possible to modify the
688 /// range of deleted text, or prevent it from being deleted entirely.
689 ///
690 /// The @start_pos and @end_pos parameters are interpreted as for
691 /// [`EditableExt::delete_text()`][crate::prelude::EditableExt::delete_text()].
692 ///
693 ///
694 ///
695 ///
696 /// #### `insert-text`
697 /// Emitted when text is inserted into the widget by the user.
698 ///
699 /// The default handler for this signal will normally be responsible
700 /// for inserting the text, so by connecting to this signal and then
701 /// stopping the signal with g_signal_stop_emission(), it is possible
702 /// to modify the inserted text, or prevent it from being inserted entirely.
703 ///
704 ///
705 /// </details>
706 ///
707 /// # Implements
708 ///
709 /// [`WidgetExt`][trait@crate::prelude::WidgetExt], [`trait@glib::ObjectExt`], [`AccessibleExt`][trait@crate::prelude::AccessibleExt], [`BuildableExt`][trait@crate::prelude::BuildableExt], [`ConstraintTargetExt`][trait@crate::prelude::ConstraintTargetExt], [`EditableExt`][trait@crate::prelude::EditableExt], [`WidgetExtManual`][trait@crate::prelude::WidgetExtManual], [`AccessibleExtManual`][trait@crate::prelude::AccessibleExtManual], [`EditableExtManual`][trait@crate::prelude::EditableExtManual]
710 #[doc(alias = "GtkSearchEntry")]
711 pub struct SearchEntry(Object<ffi::GtkSearchEntry>) @extends Widget, @implements Accessible, Buildable, ConstraintTarget, Editable;
712
713 match fn {
714 type_ => || ffi::gtk_search_entry_get_type(),
715 }
716}
717
718impl SearchEntry {
719 /// Creates a [`SearchEntry`][crate::SearchEntry].
720 ///
721 /// # Returns
722 ///
723 /// a new [`SearchEntry`][crate::SearchEntry]
724 #[doc(alias = "gtk_search_entry_new")]
725 pub fn new() -> SearchEntry {
726 assert_initialized_main_thread!();
727 unsafe { Widget::from_glib_none(ffi::gtk_search_entry_new()).unsafe_cast() }
728 }
729
730 // rustdoc-stripper-ignore-next
731 /// Creates a new builder-pattern struct instance to construct [`SearchEntry`] objects.
732 ///
733 /// This method returns an instance of [`SearchEntryBuilder`](crate::builders::SearchEntryBuilder) which can be used to create [`SearchEntry`] objects.
734 pub fn builder() -> SearchEntryBuilder {
735 SearchEntryBuilder::new()
736 }
737
738 /// Gets the input purpose for @self.
739 ///
740 /// # Returns
741 ///
742 /// The input hints
743 #[cfg(feature = "v4_14")]
744 #[cfg_attr(docsrs, doc(cfg(feature = "v4_14")))]
745 #[doc(alias = "gtk_search_entry_get_input_hints")]
746 #[doc(alias = "get_input_hints")]
747 #[doc(alias = "input-hints")]
748 pub fn input_hints(&self) -> InputHints {
749 unsafe { from_glib(ffi::gtk_search_entry_get_input_hints(self.to_glib_none().0)) }
750 }
751
752 /// Gets the input purpose of @self.
753 ///
754 /// # Returns
755 ///
756 /// The input hints
757 #[cfg(feature = "v4_14")]
758 #[cfg_attr(docsrs, doc(cfg(feature = "v4_14")))]
759 #[doc(alias = "gtk_search_entry_get_input_purpose")]
760 #[doc(alias = "get_input_purpose")]
761 #[doc(alias = "input-purpose")]
762 pub fn input_purpose(&self) -> InputPurpose {
763 unsafe {
764 from_glib(ffi::gtk_search_entry_get_input_purpose(
765 self.to_glib_none().0,
766 ))
767 }
768 }
769
770 /// Gets the widget that @self is capturing key events from.
771 ///
772 /// # Returns
773 ///
774 /// The key capture widget.
775 #[doc(alias = "gtk_search_entry_get_key_capture_widget")]
776 #[doc(alias = "get_key_capture_widget")]
777 #[doc(alias = "key-capture-widget")]
778 pub fn key_capture_widget(&self) -> Option<Widget> {
779 unsafe {
780 from_glib_none(ffi::gtk_search_entry_get_key_capture_widget(
781 self.to_glib_none().0,
782 ))
783 }
784 }
785
786 /// Get the delay to be used between the last keypress and the
787 /// [`search-changed`][struct@crate::SearchEntry#search-changed] signal being emitted.
788 ///
789 /// # Returns
790 ///
791 /// a delay in milliseconds.
792 #[cfg(feature = "v4_8")]
793 #[cfg_attr(docsrs, doc(cfg(feature = "v4_8")))]
794 #[doc(alias = "gtk_search_entry_get_search_delay")]
795 #[doc(alias = "get_search_delay")]
796 #[doc(alias = "search-delay")]
797 pub fn search_delay(&self) -> u32 {
798 unsafe { ffi::gtk_search_entry_get_search_delay(self.to_glib_none().0) }
799 }
800
801 /// Sets the input hints for @self.
802 /// ## `hints`
803 /// the new input hints
804 #[cfg(feature = "v4_14")]
805 #[cfg_attr(docsrs, doc(cfg(feature = "v4_14")))]
806 #[doc(alias = "gtk_search_entry_set_input_hints")]
807 #[doc(alias = "input-hints")]
808 pub fn set_input_hints(&self, hints: InputHints) {
809 unsafe {
810 ffi::gtk_search_entry_set_input_hints(self.to_glib_none().0, hints.into_glib());
811 }
812 }
813
814 /// Sets the input purpose of @self.
815 /// ## `purpose`
816 /// the new input purpose
817 #[cfg(feature = "v4_14")]
818 #[cfg_attr(docsrs, doc(cfg(feature = "v4_14")))]
819 #[doc(alias = "gtk_search_entry_set_input_purpose")]
820 #[doc(alias = "input-purpose")]
821 pub fn set_input_purpose(&self, purpose: InputPurpose) {
822 unsafe {
823 ffi::gtk_search_entry_set_input_purpose(self.to_glib_none().0, purpose.into_glib());
824 }
825 }
826
827 /// Sets @widget as the widget that @self will capture key
828 /// events from.
829 ///
830 /// Key events are consumed by the search entry to start or
831 /// continue a search.
832 ///
833 /// If the entry is part of a [`SearchBar`][crate::SearchBar], it is preferable
834 /// to call [`SearchBar::set_key_capture_widget()`][crate::SearchBar::set_key_capture_widget()] instead,
835 /// which will reveal the entry in addition to triggering the
836 /// search entry.
837 ///
838 /// Note that despite the name of this function, the events
839 /// are only 'captured' in the bubble phase, which means that
840 /// editable child widgets of @widget will receive text input
841 /// before it gets captured. If that is not desired, you can
842 /// capture and forward the events yourself with
843 /// [`EventControllerKey::forward()`][crate::EventControllerKey::forward()].
844 /// ## `widget`
845 /// a [`Widget`][crate::Widget]
846 #[doc(alias = "gtk_search_entry_set_key_capture_widget")]
847 #[doc(alias = "key-capture-widget")]
848 pub fn set_key_capture_widget(&self, widget: Option<&impl IsA<Widget>>) {
849 unsafe {
850 ffi::gtk_search_entry_set_key_capture_widget(
851 self.to_glib_none().0,
852 widget.map(|p| p.as_ref()).to_glib_none().0,
853 );
854 }
855 }
856
857 /// Set the delay to be used between the last keypress and the
858 /// [`search-changed`][struct@crate::SearchEntry#search-changed] signal being emitted.
859 /// ## `delay`
860 /// a delay in milliseconds
861 #[cfg(feature = "v4_8")]
862 #[cfg_attr(docsrs, doc(cfg(feature = "v4_8")))]
863 #[doc(alias = "gtk_search_entry_set_search_delay")]
864 #[doc(alias = "search-delay")]
865 pub fn set_search_delay(&self, delay: u32) {
866 unsafe {
867 ffi::gtk_search_entry_set_search_delay(self.to_glib_none().0, delay);
868 }
869 }
870
871 /// Whether to activate the default widget when Enter is pressed.
872 #[doc(alias = "activates-default")]
873 pub fn activates_default(&self) -> bool {
874 ObjectExt::property(self, "activates-default")
875 }
876
877 /// Whether to activate the default widget when Enter is pressed.
878 #[doc(alias = "activates-default")]
879 pub fn set_activates_default(&self, activates_default: bool) {
880 ObjectExt::set_property(self, "activates-default", activates_default)
881 }
882
883 #[doc(alias = "placeholder-text")]
884 pub fn placeholder_text(&self) -> Option<glib::GString> {
885 ObjectExt::property(self, "placeholder-text")
886 }
887
888 #[doc(alias = "placeholder-text")]
889 pub fn set_placeholder_text(&self, placeholder_text: Option<&str>) {
890 ObjectExt::set_property(self, "placeholder-text", placeholder_text)
891 }
892
893 /// Emitted when the entry is activated.
894 ///
895 /// The keybindings for this signal are all forms of the <kbd>Enter</kbd> key.
896 #[doc(alias = "activate")]
897 pub fn connect_activate<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
898 unsafe extern "C" fn activate_trampoline<F: Fn(&SearchEntry) + 'static>(
899 this: *mut ffi::GtkSearchEntry,
900 f: glib::ffi::gpointer,
901 ) {
902 unsafe {
903 let f: &F = &*(f as *const F);
904 f(&from_glib_borrow(this))
905 }
906 }
907 unsafe {
908 let f: Box_<F> = Box_::new(f);
909 connect_raw(
910 self.as_ptr() as *mut _,
911 c"activate".as_ptr(),
912 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
913 activate_trampoline::<F> as *const (),
914 )),
915 Box_::into_raw(f),
916 )
917 }
918 }
919
920 pub fn emit_activate(&self) {
921 self.emit_by_name::<()>("activate", &[]);
922 }
923
924 /// Emitted when the user initiates a move to the next match
925 /// for the current search string.
926 ///
927 /// This is a [keybinding signal](class.SignalAction.html).
928 ///
929 /// Applications should connect to it, to implement moving
930 /// between matches.
931 ///
932 /// The default bindings for this signal is <kbd>Ctrl</kbd>+<kbd>g</kbd>.
933 #[doc(alias = "next-match")]
934 pub fn connect_next_match<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
935 unsafe extern "C" fn next_match_trampoline<F: Fn(&SearchEntry) + 'static>(
936 this: *mut ffi::GtkSearchEntry,
937 f: glib::ffi::gpointer,
938 ) {
939 unsafe {
940 let f: &F = &*(f as *const F);
941 f(&from_glib_borrow(this))
942 }
943 }
944 unsafe {
945 let f: Box_<F> = Box_::new(f);
946 connect_raw(
947 self.as_ptr() as *mut _,
948 c"next-match".as_ptr(),
949 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
950 next_match_trampoline::<F> as *const (),
951 )),
952 Box_::into_raw(f),
953 )
954 }
955 }
956
957 pub fn emit_next_match(&self) {
958 self.emit_by_name::<()>("next-match", &[]);
959 }
960
961 /// Emitted when the user initiates a move to the previous match
962 /// for the current search string.
963 ///
964 /// This is a [keybinding signal](class.SignalAction.html).
965 ///
966 /// Applications should connect to it, to implement moving
967 /// between matches.
968 ///
969 /// The default bindings for this signal is
970 /// <kbd>Ctrl</kbd>+<kbd>Shift</kbd>+<kbd>g</kbd>.
971 #[doc(alias = "previous-match")]
972 pub fn connect_previous_match<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
973 unsafe extern "C" fn previous_match_trampoline<F: Fn(&SearchEntry) + 'static>(
974 this: *mut ffi::GtkSearchEntry,
975 f: glib::ffi::gpointer,
976 ) {
977 unsafe {
978 let f: &F = &*(f as *const F);
979 f(&from_glib_borrow(this))
980 }
981 }
982 unsafe {
983 let f: Box_<F> = Box_::new(f);
984 connect_raw(
985 self.as_ptr() as *mut _,
986 c"previous-match".as_ptr(),
987 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
988 previous_match_trampoline::<F> as *const (),
989 )),
990 Box_::into_raw(f),
991 )
992 }
993 }
994
995 pub fn emit_previous_match(&self) {
996 self.emit_by_name::<()>("previous-match", &[]);
997 }
998
999 /// Emitted with a delay. The length of the delay can be
1000 /// changed with the [`search-delay`][struct@crate::SearchEntry#search-delay]
1001 /// property.
1002 #[doc(alias = "search-changed")]
1003 pub fn connect_search_changed<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1004 unsafe extern "C" fn search_changed_trampoline<F: Fn(&SearchEntry) + 'static>(
1005 this: *mut ffi::GtkSearchEntry,
1006 f: glib::ffi::gpointer,
1007 ) {
1008 unsafe {
1009 let f: &F = &*(f as *const F);
1010 f(&from_glib_borrow(this))
1011 }
1012 }
1013 unsafe {
1014 let f: Box_<F> = Box_::new(f);
1015 connect_raw(
1016 self.as_ptr() as *mut _,
1017 c"search-changed".as_ptr(),
1018 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1019 search_changed_trampoline::<F> as *const (),
1020 )),
1021 Box_::into_raw(f),
1022 )
1023 }
1024 }
1025
1026 /// Emitted when the user initiated a search on the entry.
1027 #[doc(alias = "search-started")]
1028 pub fn connect_search_started<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1029 unsafe extern "C" fn search_started_trampoline<F: Fn(&SearchEntry) + 'static>(
1030 this: *mut ffi::GtkSearchEntry,
1031 f: glib::ffi::gpointer,
1032 ) {
1033 unsafe {
1034 let f: &F = &*(f as *const F);
1035 f(&from_glib_borrow(this))
1036 }
1037 }
1038 unsafe {
1039 let f: Box_<F> = Box_::new(f);
1040 connect_raw(
1041 self.as_ptr() as *mut _,
1042 c"search-started".as_ptr(),
1043 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1044 search_started_trampoline::<F> as *const (),
1045 )),
1046 Box_::into_raw(f),
1047 )
1048 }
1049 }
1050
1051 /// Emitted when the user stops a search via keyboard input.
1052 ///
1053 /// This is a [keybinding signal](class.SignalAction.html).
1054 ///
1055 /// Applications should connect to it, to implement hiding
1056 /// the search entry in this case.
1057 ///
1058 /// The default bindings for this signal is <kbd>Escape</kbd>.
1059 #[doc(alias = "stop-search")]
1060 pub fn connect_stop_search<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1061 unsafe extern "C" fn stop_search_trampoline<F: Fn(&SearchEntry) + 'static>(
1062 this: *mut ffi::GtkSearchEntry,
1063 f: glib::ffi::gpointer,
1064 ) {
1065 unsafe {
1066 let f: &F = &*(f as *const F);
1067 f(&from_glib_borrow(this))
1068 }
1069 }
1070 unsafe {
1071 let f: Box_<F> = Box_::new(f);
1072 connect_raw(
1073 self.as_ptr() as *mut _,
1074 c"stop-search".as_ptr(),
1075 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1076 stop_search_trampoline::<F> as *const (),
1077 )),
1078 Box_::into_raw(f),
1079 )
1080 }
1081 }
1082
1083 pub fn emit_stop_search(&self) {
1084 self.emit_by_name::<()>("stop-search", &[]);
1085 }
1086
1087 #[doc(alias = "activates-default")]
1088 pub fn connect_activates_default_notify<F: Fn(&Self) + 'static>(
1089 &self,
1090 f: F,
1091 ) -> SignalHandlerId {
1092 unsafe extern "C" fn notify_activates_default_trampoline<F: Fn(&SearchEntry) + 'static>(
1093 this: *mut ffi::GtkSearchEntry,
1094 _param_spec: glib::ffi::gpointer,
1095 f: glib::ffi::gpointer,
1096 ) {
1097 unsafe {
1098 let f: &F = &*(f as *const F);
1099 f(&from_glib_borrow(this))
1100 }
1101 }
1102 unsafe {
1103 let f: Box_<F> = Box_::new(f);
1104 connect_raw(
1105 self.as_ptr() as *mut _,
1106 c"notify::activates-default".as_ptr(),
1107 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1108 notify_activates_default_trampoline::<F> as *const (),
1109 )),
1110 Box_::into_raw(f),
1111 )
1112 }
1113 }
1114
1115 #[cfg(feature = "v4_14")]
1116 #[cfg_attr(docsrs, doc(cfg(feature = "v4_14")))]
1117 #[doc(alias = "input-hints")]
1118 pub fn connect_input_hints_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1119 unsafe extern "C" fn notify_input_hints_trampoline<F: Fn(&SearchEntry) + 'static>(
1120 this: *mut ffi::GtkSearchEntry,
1121 _param_spec: glib::ffi::gpointer,
1122 f: glib::ffi::gpointer,
1123 ) {
1124 unsafe {
1125 let f: &F = &*(f as *const F);
1126 f(&from_glib_borrow(this))
1127 }
1128 }
1129 unsafe {
1130 let f: Box_<F> = Box_::new(f);
1131 connect_raw(
1132 self.as_ptr() as *mut _,
1133 c"notify::input-hints".as_ptr(),
1134 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1135 notify_input_hints_trampoline::<F> as *const (),
1136 )),
1137 Box_::into_raw(f),
1138 )
1139 }
1140 }
1141
1142 #[cfg(feature = "v4_14")]
1143 #[cfg_attr(docsrs, doc(cfg(feature = "v4_14")))]
1144 #[doc(alias = "input-purpose")]
1145 pub fn connect_input_purpose_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1146 unsafe extern "C" fn notify_input_purpose_trampoline<F: Fn(&SearchEntry) + 'static>(
1147 this: *mut ffi::GtkSearchEntry,
1148 _param_spec: glib::ffi::gpointer,
1149 f: glib::ffi::gpointer,
1150 ) {
1151 unsafe {
1152 let f: &F = &*(f as *const F);
1153 f(&from_glib_borrow(this))
1154 }
1155 }
1156 unsafe {
1157 let f: Box_<F> = Box_::new(f);
1158 connect_raw(
1159 self.as_ptr() as *mut _,
1160 c"notify::input-purpose".as_ptr(),
1161 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1162 notify_input_purpose_trampoline::<F> as *const (),
1163 )),
1164 Box_::into_raw(f),
1165 )
1166 }
1167 }
1168
1169 #[cfg(feature = "v4_22")]
1170 #[cfg_attr(docsrs, doc(cfg(feature = "v4_22")))]
1171 #[doc(alias = "key-capture-widget")]
1172 pub fn connect_key_capture_widget_notify<F: Fn(&Self) + 'static>(
1173 &self,
1174 f: F,
1175 ) -> SignalHandlerId {
1176 unsafe extern "C" fn notify_key_capture_widget_trampoline<F: Fn(&SearchEntry) + 'static>(
1177 this: *mut ffi::GtkSearchEntry,
1178 _param_spec: glib::ffi::gpointer,
1179 f: glib::ffi::gpointer,
1180 ) {
1181 unsafe {
1182 let f: &F = &*(f as *const F);
1183 f(&from_glib_borrow(this))
1184 }
1185 }
1186 unsafe {
1187 let f: Box_<F> = Box_::new(f);
1188 connect_raw(
1189 self.as_ptr() as *mut _,
1190 c"notify::key-capture-widget".as_ptr(),
1191 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1192 notify_key_capture_widget_trampoline::<F> as *const (),
1193 )),
1194 Box_::into_raw(f),
1195 )
1196 }
1197 }
1198
1199 #[doc(alias = "placeholder-text")]
1200 pub fn connect_placeholder_text_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1201 unsafe extern "C" fn notify_placeholder_text_trampoline<F: Fn(&SearchEntry) + 'static>(
1202 this: *mut ffi::GtkSearchEntry,
1203 _param_spec: glib::ffi::gpointer,
1204 f: glib::ffi::gpointer,
1205 ) {
1206 unsafe {
1207 let f: &F = &*(f as *const F);
1208 f(&from_glib_borrow(this))
1209 }
1210 }
1211 unsafe {
1212 let f: Box_<F> = Box_::new(f);
1213 connect_raw(
1214 self.as_ptr() as *mut _,
1215 c"notify::placeholder-text".as_ptr(),
1216 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1217 notify_placeholder_text_trampoline::<F> as *const (),
1218 )),
1219 Box_::into_raw(f),
1220 )
1221 }
1222 }
1223
1224 #[cfg(feature = "v4_8")]
1225 #[cfg_attr(docsrs, doc(cfg(feature = "v4_8")))]
1226 #[doc(alias = "search-delay")]
1227 pub fn connect_search_delay_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1228 unsafe extern "C" fn notify_search_delay_trampoline<F: Fn(&SearchEntry) + 'static>(
1229 this: *mut ffi::GtkSearchEntry,
1230 _param_spec: glib::ffi::gpointer,
1231 f: glib::ffi::gpointer,
1232 ) {
1233 unsafe {
1234 let f: &F = &*(f as *const F);
1235 f(&from_glib_borrow(this))
1236 }
1237 }
1238 unsafe {
1239 let f: Box_<F> = Box_::new(f);
1240 connect_raw(
1241 self.as_ptr() as *mut _,
1242 c"notify::search-delay".as_ptr(),
1243 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1244 notify_search_delay_trampoline::<F> as *const (),
1245 )),
1246 Box_::into_raw(f),
1247 )
1248 }
1249 }
1250}
1251
1252impl Default for SearchEntry {
1253 fn default() -> Self {
1254 Self::new()
1255 }
1256}
1257
1258// rustdoc-stripper-ignore-next
1259/// A [builder-pattern] type to construct [`SearchEntry`] objects.
1260///
1261/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
1262#[must_use = "The builder must be built to be used"]
1263pub struct SearchEntryBuilder {
1264 builder: glib::object::ObjectBuilder<'static, SearchEntry>,
1265}
1266
1267impl SearchEntryBuilder {
1268 fn new() -> Self {
1269 Self {
1270 builder: glib::object::Object::builder(),
1271 }
1272 }
1273
1274 /// Whether to activate the default widget when Enter is pressed.
1275 pub fn activates_default(self, activates_default: bool) -> Self {
1276 Self {
1277 builder: self
1278 .builder
1279 .property("activates-default", activates_default),
1280 }
1281 }
1282
1283 /// The hints about input for the [`SearchEntry`][crate::SearchEntry] used to alter the
1284 /// behaviour of input methods.
1285 #[cfg(feature = "v4_14")]
1286 #[cfg_attr(docsrs, doc(cfg(feature = "v4_14")))]
1287 pub fn input_hints(self, input_hints: InputHints) -> Self {
1288 Self {
1289 builder: self.builder.property("input-hints", input_hints),
1290 }
1291 }
1292
1293 /// The purpose for the [`SearchEntry`][crate::SearchEntry] input used to alter the
1294 /// behaviour of input methods.
1295 #[cfg(feature = "v4_14")]
1296 #[cfg_attr(docsrs, doc(cfg(feature = "v4_14")))]
1297 pub fn input_purpose(self, input_purpose: InputPurpose) -> Self {
1298 Self {
1299 builder: self.builder.property("input-purpose", input_purpose),
1300 }
1301 }
1302
1303 /// The widget that the entry will use to capture key events.
1304 ///
1305 /// Key events are consumed by the search entry to start or continue a search.
1306 #[cfg(feature = "v4_22")]
1307 #[cfg_attr(docsrs, doc(cfg(feature = "v4_22")))]
1308 pub fn key_capture_widget(self, key_capture_widget: &impl IsA<Widget>) -> Self {
1309 Self {
1310 builder: self
1311 .builder
1312 .property("key-capture-widget", key_capture_widget.clone().upcast()),
1313 }
1314 }
1315
1316 /// The text that will be displayed in the [`SearchEntry`][crate::SearchEntry]
1317 /// when it is empty and unfocused.
1318 pub fn placeholder_text(self, placeholder_text: impl Into<glib::GString>) -> Self {
1319 Self {
1320 builder: self
1321 .builder
1322 .property("placeholder-text", placeholder_text.into()),
1323 }
1324 }
1325
1326 /// The delay in milliseconds from last keypress to the search
1327 /// changed signal.
1328 #[cfg(feature = "v4_8")]
1329 #[cfg_attr(docsrs, doc(cfg(feature = "v4_8")))]
1330 pub fn search_delay(self, search_delay: u32) -> Self {
1331 Self {
1332 builder: self.builder.property("search-delay", search_delay),
1333 }
1334 }
1335
1336 /// Whether the widget or any of its descendents can accept
1337 /// the input focus.
1338 ///
1339 /// This property is meant to be set by widget implementations,
1340 /// typically in their instance init function.
1341 pub fn can_focus(self, can_focus: bool) -> Self {
1342 Self {
1343 builder: self.builder.property("can-focus", can_focus),
1344 }
1345 }
1346
1347 /// Whether the widget can receive pointer events.
1348 pub fn can_target(self, can_target: bool) -> Self {
1349 Self {
1350 builder: self.builder.property("can-target", can_target),
1351 }
1352 }
1353
1354 /// A list of css classes applied to this widget.
1355 pub fn css_classes(self, css_classes: impl Into<glib::StrV>) -> Self {
1356 Self {
1357 builder: self.builder.property("css-classes", css_classes.into()),
1358 }
1359 }
1360
1361 /// The name of this widget in the CSS tree.
1362 ///
1363 /// This property is meant to be set by widget implementations,
1364 /// typically in their instance init function.
1365 pub fn css_name(self, css_name: impl Into<glib::GString>) -> Self {
1366 Self {
1367 builder: self.builder.property("css-name", css_name.into()),
1368 }
1369 }
1370
1371 /// The cursor used by @widget.
1372 pub fn cursor(self, cursor: &gdk::Cursor) -> Self {
1373 Self {
1374 builder: self.builder.property("cursor", cursor.clone()),
1375 }
1376 }
1377
1378 /// Whether the widget should grab focus when it is clicked with the mouse.
1379 ///
1380 /// This property is only relevant for widgets that can take focus.
1381 pub fn focus_on_click(self, focus_on_click: bool) -> Self {
1382 Self {
1383 builder: self.builder.property("focus-on-click", focus_on_click),
1384 }
1385 }
1386
1387 /// Whether this widget itself will accept the input focus.
1388 pub fn focusable(self, focusable: bool) -> Self {
1389 Self {
1390 builder: self.builder.property("focusable", focusable),
1391 }
1392 }
1393
1394 /// How to distribute horizontal space if widget gets extra space.
1395 pub fn halign(self, halign: Align) -> Self {
1396 Self {
1397 builder: self.builder.property("halign", halign),
1398 }
1399 }
1400
1401 /// Enables or disables the emission of the [`query-tooltip`][struct@crate::Widget#query-tooltip]
1402 /// signal on @widget.
1403 ///
1404 /// A true value indicates that @widget can have a tooltip, in this case
1405 /// the widget will be queried using [`query-tooltip`][struct@crate::Widget#query-tooltip] to
1406 /// determine whether it will provide a tooltip or not.
1407 pub fn has_tooltip(self, has_tooltip: bool) -> Self {
1408 Self {
1409 builder: self.builder.property("has-tooltip", has_tooltip),
1410 }
1411 }
1412
1413 /// Overrides for height request of the widget.
1414 ///
1415 /// If this is -1, the natural request will be used.
1416 pub fn height_request(self, height_request: i32) -> Self {
1417 Self {
1418 builder: self.builder.property("height-request", height_request),
1419 }
1420 }
1421
1422 /// Whether to expand horizontally.
1423 pub fn hexpand(self, hexpand: bool) -> Self {
1424 Self {
1425 builder: self.builder.property("hexpand", hexpand),
1426 }
1427 }
1428
1429 /// Whether to use the `hexpand` property.
1430 pub fn hexpand_set(self, hexpand_set: bool) -> Self {
1431 Self {
1432 builder: self.builder.property("hexpand-set", hexpand_set),
1433 }
1434 }
1435
1436 /// The [`LayoutManager`][crate::LayoutManager] instance to use to compute
1437 /// the preferred size of the widget, and allocate its children.
1438 ///
1439 /// This property is meant to be set by widget implementations,
1440 /// typically in their instance init function.
1441 pub fn layout_manager(self, layout_manager: &impl IsA<LayoutManager>) -> Self {
1442 Self {
1443 builder: self
1444 .builder
1445 .property("layout-manager", layout_manager.clone().upcast()),
1446 }
1447 }
1448
1449 /// Makes this widget act like a modal dialog, with respect to
1450 /// event delivery.
1451 ///
1452 /// Global event controllers will not handle events with targets
1453 /// inside the widget, unless they are set up to ignore propagation
1454 /// limits. See [`EventControllerExt::set_propagation_limit()`][crate::prelude::EventControllerExt::set_propagation_limit()].
1455 #[cfg(feature = "v4_18")]
1456 #[cfg_attr(docsrs, doc(cfg(feature = "v4_18")))]
1457 pub fn limit_events(self, limit_events: bool) -> Self {
1458 Self {
1459 builder: self.builder.property("limit-events", limit_events),
1460 }
1461 }
1462
1463 /// Margin on bottom side of widget.
1464 ///
1465 /// This property adds margin outside of the widget's normal size
1466 /// request, the margin will be added in addition to the size from
1467 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
1468 pub fn margin_bottom(self, margin_bottom: i32) -> Self {
1469 Self {
1470 builder: self.builder.property("margin-bottom", margin_bottom),
1471 }
1472 }
1473
1474 /// Margin on end of widget, horizontally.
1475 ///
1476 /// This property supports left-to-right and right-to-left text
1477 /// directions.
1478 ///
1479 /// This property adds margin outside of the widget's normal size
1480 /// request, the margin will be added in addition to the size from
1481 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
1482 pub fn margin_end(self, margin_end: i32) -> Self {
1483 Self {
1484 builder: self.builder.property("margin-end", margin_end),
1485 }
1486 }
1487
1488 /// Margin on start of widget, horizontally.
1489 ///
1490 /// This property supports left-to-right and right-to-left text
1491 /// directions.
1492 ///
1493 /// This property adds margin outside of the widget's normal size
1494 /// request, the margin will be added in addition to the size from
1495 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
1496 pub fn margin_start(self, margin_start: i32) -> Self {
1497 Self {
1498 builder: self.builder.property("margin-start", margin_start),
1499 }
1500 }
1501
1502 /// Margin on top side of widget.
1503 ///
1504 /// This property adds margin outside of the widget's normal size
1505 /// request, the margin will be added in addition to the size from
1506 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
1507 pub fn margin_top(self, margin_top: i32) -> Self {
1508 Self {
1509 builder: self.builder.property("margin-top", margin_top),
1510 }
1511 }
1512
1513 /// The name of the widget.
1514 pub fn name(self, name: impl Into<glib::GString>) -> Self {
1515 Self {
1516 builder: self.builder.property("name", name.into()),
1517 }
1518 }
1519
1520 /// The requested opacity of the widget.
1521 pub fn opacity(self, opacity: f64) -> Self {
1522 Self {
1523 builder: self.builder.property("opacity", opacity),
1524 }
1525 }
1526
1527 /// How content outside the widget's content area is treated.
1528 ///
1529 /// This property is meant to be set by widget implementations,
1530 /// typically in their instance init function.
1531 pub fn overflow(self, overflow: Overflow) -> Self {
1532 Self {
1533 builder: self.builder.property("overflow", overflow),
1534 }
1535 }
1536
1537 /// Whether the widget will receive the default action when it is focused.
1538 pub fn receives_default(self, receives_default: bool) -> Self {
1539 Self {
1540 builder: self.builder.property("receives-default", receives_default),
1541 }
1542 }
1543
1544 /// Whether the widget responds to input.
1545 pub fn sensitive(self, sensitive: bool) -> Self {
1546 Self {
1547 builder: self.builder.property("sensitive", sensitive),
1548 }
1549 }
1550
1551 /// Sets the text of tooltip to be the given string, which is marked up
1552 /// with Pango markup.
1553 ///
1554 /// Also see [`Tooltip::set_markup()`][crate::Tooltip::set_markup()].
1555 ///
1556 /// This is a convenience property which will take care of getting the
1557 /// tooltip shown if the given string is not `NULL`:
1558 /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
1559 /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
1560 /// the default signal handler.
1561 ///
1562 /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
1563 /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
1564 pub fn tooltip_markup(self, tooltip_markup: impl Into<glib::GString>) -> Self {
1565 Self {
1566 builder: self
1567 .builder
1568 .property("tooltip-markup", tooltip_markup.into()),
1569 }
1570 }
1571
1572 /// Sets the text of tooltip to be the given string.
1573 ///
1574 /// Also see [`Tooltip::set_text()`][crate::Tooltip::set_text()].
1575 ///
1576 /// This is a convenience property which will take care of getting the
1577 /// tooltip shown if the given string is not `NULL`:
1578 /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
1579 /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
1580 /// the default signal handler.
1581 ///
1582 /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
1583 /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
1584 pub fn tooltip_text(self, tooltip_text: impl Into<glib::GString>) -> Self {
1585 Self {
1586 builder: self.builder.property("tooltip-text", tooltip_text.into()),
1587 }
1588 }
1589
1590 /// How to distribute vertical space if widget gets extra space.
1591 pub fn valign(self, valign: Align) -> Self {
1592 Self {
1593 builder: self.builder.property("valign", valign),
1594 }
1595 }
1596
1597 /// Whether to expand vertically.
1598 pub fn vexpand(self, vexpand: bool) -> Self {
1599 Self {
1600 builder: self.builder.property("vexpand", vexpand),
1601 }
1602 }
1603
1604 /// Whether to use the `vexpand` property.
1605 pub fn vexpand_set(self, vexpand_set: bool) -> Self {
1606 Self {
1607 builder: self.builder.property("vexpand-set", vexpand_set),
1608 }
1609 }
1610
1611 /// Whether the widget is visible.
1612 pub fn visible(self, visible: bool) -> Self {
1613 Self {
1614 builder: self.builder.property("visible", visible),
1615 }
1616 }
1617
1618 /// Overrides for width request of the widget.
1619 ///
1620 /// If this is -1, the natural request will be used.
1621 pub fn width_request(self, width_request: i32) -> Self {
1622 Self {
1623 builder: self.builder.property("width-request", width_request),
1624 }
1625 }
1626
1627 /// The accessible role of the given [`Accessible`][crate::Accessible] implementation.
1628 ///
1629 /// The accessible role cannot be changed once set.
1630 pub fn accessible_role(self, accessible_role: AccessibleRole) -> Self {
1631 Self {
1632 builder: self.builder.property("accessible-role", accessible_role),
1633 }
1634 }
1635
1636 /// Whether the entry contents can be edited.
1637 pub fn editable(self, editable: bool) -> Self {
1638 Self {
1639 builder: self.builder.property("editable", editable),
1640 }
1641 }
1642
1643 /// If undo/redo should be enabled for the editable.
1644 pub fn enable_undo(self, enable_undo: bool) -> Self {
1645 Self {
1646 builder: self.builder.property("enable-undo", enable_undo),
1647 }
1648 }
1649
1650 /// The desired maximum width of the entry, in characters.
1651 pub fn max_width_chars(self, max_width_chars: i32) -> Self {
1652 Self {
1653 builder: self.builder.property("max-width-chars", max_width_chars),
1654 }
1655 }
1656
1657 /// The contents of the entry.
1658 pub fn text(self, text: impl Into<glib::GString>) -> Self {
1659 Self {
1660 builder: self.builder.property("text", text.into()),
1661 }
1662 }
1663
1664 /// Number of characters to leave space for in the entry.
1665 pub fn width_chars(self, width_chars: i32) -> Self {
1666 Self {
1667 builder: self.builder.property("width-chars", width_chars),
1668 }
1669 }
1670
1671 /// The horizontal alignment, from 0 (left) to 1 (right).
1672 ///
1673 /// Reversed for RTL layouts.
1674 pub fn xalign(self, xalign: f32) -> Self {
1675 Self {
1676 builder: self.builder.property("xalign", xalign),
1677 }
1678 }
1679
1680 // rustdoc-stripper-ignore-next
1681 /// Build the [`SearchEntry`].
1682 #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
1683 pub fn build(self) -> SearchEntry {
1684 assert_initialized_main_thread!();
1685 self.builder.build()
1686 }
1687}