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 /// #### `complete-text`
423 /// The contents of the entry, including uncommited content such as the
424 /// preedit.
425 ///
426 /// Readable
427 ///
428 ///
429 /// #### `cursor-position`
430 /// The current position of the insertion cursor in chars.
431 ///
432 /// Readable
433 ///
434 ///
435 /// #### `editable`
436 /// Whether the entry contents can be edited.
437 ///
438 /// Readable | Writeable
439 ///
440 ///
441 /// #### `enable-undo`
442 /// If undo/redo should be enabled for the editable.
443 ///
444 /// Readable | Writeable
445 ///
446 ///
447 /// #### `max-width-chars`
448 /// The desired maximum width of the entry, in characters.
449 ///
450 /// Readable | Writeable
451 ///
452 ///
453 /// #### `selection-bound`
454 /// The position of the opposite end of the selection from the cursor in chars.
455 ///
456 /// Readable
457 ///
458 ///
459 /// #### `text`
460 /// The contents of the entry.
461 ///
462 /// Readable | Writeable
463 ///
464 ///
465 /// #### `width-chars`
466 /// Number of characters to leave space for in the entry.
467 ///
468 /// Readable | Writeable
469 ///
470 ///
471 /// #### `xalign`
472 /// The horizontal alignment, from 0 (left) to 1 (right).
473 ///
474 /// Reversed for RTL layouts.
475 ///
476 /// Readable | Writeable
477 /// </details>
478 ///
479 /// ## Signals
480 ///
481 ///
482 /// #### `activate`
483 /// Emitted when the entry is activated.
484 ///
485 /// The keybindings for this signal are all forms of the <kbd>Enter</kbd> key.
486 ///
487 /// Action
488 ///
489 ///
490 /// #### `next-match`
491 /// Emitted when the user initiates a move to the next match
492 /// for the current search string.
493 ///
494 /// This is a [keybinding signal](class.SignalAction.html).
495 ///
496 /// Applications should connect to it, to implement moving
497 /// between matches.
498 ///
499 /// The default bindings for this signal is <kbd>Ctrl</kbd>+<kbd>g</kbd>.
500 ///
501 /// Action
502 ///
503 ///
504 /// #### `previous-match`
505 /// Emitted when the user initiates a move to the previous match
506 /// for the current search string.
507 ///
508 /// This is a [keybinding signal](class.SignalAction.html).
509 ///
510 /// Applications should connect to it, to implement moving
511 /// between matches.
512 ///
513 /// The default bindings for this signal is
514 /// <kbd>Ctrl</kbd>+<kbd>Shift</kbd>+<kbd>g</kbd>.
515 ///
516 /// Action
517 ///
518 ///
519 /// #### `search-changed`
520 /// Emitted with a delay. The length of the delay can be
521 /// changed with the [`search-delay`][struct@crate::SearchEntry#search-delay]
522 /// property.
523 ///
524 ///
525 ///
526 ///
527 /// #### `search-started`
528 /// Emitted when the user initiated a search on the entry.
529 ///
530 ///
531 ///
532 ///
533 /// #### `stop-search`
534 /// Emitted when the user stops a search via keyboard input.
535 ///
536 /// This is a [keybinding signal](class.SignalAction.html).
537 ///
538 /// Applications should connect to it, to implement hiding
539 /// the search entry in this case.
540 ///
541 /// The default bindings for this signal is <kbd>Escape</kbd>.
542 ///
543 /// Action
544 /// <details><summary><h4>Widget</h4></summary>
545 ///
546 ///
547 /// #### `destroy`
548 /// Signals that all holders of a reference to the widget should release
549 /// the reference that they hold.
550 ///
551 /// May result in finalization of the widget if all references are released.
552 ///
553 /// This signal is not suitable for saving widget state.
554 ///
555 ///
556 ///
557 ///
558 /// #### `direction-changed`
559 /// Emitted when the text direction of a widget changes.
560 ///
561 ///
562 ///
563 ///
564 /// #### `hide`
565 /// Emitted when @widget is hidden.
566 ///
567 ///
568 ///
569 ///
570 /// #### `keynav-failed`
571 /// Emitted if keyboard navigation fails.
572 ///
573 /// See [`WidgetExt::keynav_failed()`][crate::prelude::WidgetExt::keynav_failed()] for details.
574 ///
575 ///
576 ///
577 ///
578 /// #### `map`
579 /// Emitted when @widget is going to be mapped.
580 ///
581 /// A widget is mapped when the widget is visible (which is controlled with
582 /// [`visible`][struct@crate::Widget#visible]) and all its parents up to the toplevel widget
583 /// are also visible.
584 ///
585 /// The `::map` signal can be used to determine whether a widget will be drawn,
586 /// for instance it can resume an animation that was stopped during the
587 /// emission of [`unmap`][struct@crate::Widget#unmap].
588 ///
589 ///
590 ///
591 ///
592 /// #### `mnemonic-activate`
593 /// Emitted when a widget is activated via a mnemonic.
594 ///
595 /// The default handler for this signal activates @widget if @group_cycling
596 /// is false, or just makes @widget grab focus if @group_cycling is true.
597 ///
598 ///
599 ///
600 ///
601 /// #### `move-focus`
602 /// Emitted when the focus is moved.
603 ///
604 /// The `::move-focus` signal is a [keybinding signal](class.SignalAction.html).
605 ///
606 /// The default bindings for this signal are <kbd>Tab</kbd> to move forward,
607 /// and <kbd>Shift</kbd>+<kbd>Tab</kbd> to move backward.
608 ///
609 /// Action
610 ///
611 ///
612 /// #### `query-tooltip`
613 /// Emitted when the widget’s tooltip is about to be shown.
614 ///
615 /// This happens when the [`has-tooltip`][struct@crate::Widget#has-tooltip] property
616 /// is true and the hover timeout has expired with the cursor hovering
617 /// above @widget; or emitted when @widget got focus in keyboard mode.
618 ///
619 /// Using the given coordinates, the signal handler should determine
620 /// whether a tooltip should be shown for @widget. If this is the case
621 /// true should be returned, false otherwise. Note that if @keyboard_mode
622 /// is true, the values of @x and @y are undefined and should not be used.
623 ///
624 /// The signal handler is free to manipulate @tooltip with the therefore
625 /// destined function calls.
626 ///
627 ///
628 ///
629 ///
630 /// #### `realize`
631 /// Emitted when @widget is associated with a [`gdk::Surface`][crate::gdk::Surface].
632 ///
633 /// This means that [`WidgetExt::realize()`][crate::prelude::WidgetExt::realize()] has been called
634 /// or the widget has been mapped (that is, it is going to be drawn).
635 ///
636 ///
637 ///
638 ///
639 /// #### `show`
640 /// Emitted when @widget is shown.
641 ///
642 ///
643 ///
644 ///
645 /// #### `state-flags-changed`
646 /// Emitted when the widget state changes.
647 ///
648 /// See [`WidgetExt::state_flags()`][crate::prelude::WidgetExt::state_flags()].
649 ///
650 ///
651 ///
652 ///
653 /// #### `unmap`
654 /// Emitted when @widget is going to be unmapped.
655 ///
656 /// A widget is unmapped when either it or any of its parents up to the
657 /// toplevel widget have been set as hidden.
658 ///
659 /// As `::unmap` indicates that a widget will not be shown any longer,
660 /// it can be used to, for example, stop an animation on the widget.
661 ///
662 ///
663 ///
664 ///
665 /// #### `unrealize`
666 /// Emitted when the [`gdk::Surface`][crate::gdk::Surface] associated with @widget is destroyed.
667 ///
668 /// This means that [`WidgetExt::unrealize()`][crate::prelude::WidgetExt::unrealize()] has been called
669 /// or the widget has been unmapped (that is, it is going to be hidden).
670 ///
671 ///
672 /// </details>
673 /// <details><summary><h4>Editable</h4></summary>
674 ///
675 ///
676 /// #### `changed`
677 /// Emitted at the end of a single user-visible operation on the
678 /// contents.
679 ///
680 /// E.g., a paste operation that replaces the contents of the
681 /// selection will cause only one signal emission (even though it
682 /// is implemented by first deleting the selection, then inserting
683 /// the new content, and may cause multiple ::notify::text signals
684 /// to be emitted).
685 ///
686 ///
687 ///
688 ///
689 /// #### `delete-text`
690 /// Emitted when text is deleted from the widget by the user.
691 ///
692 /// The default handler for this signal will normally be responsible for
693 /// deleting the text, so by connecting to this signal and then stopping
694 /// the signal with g_signal_stop_emission(), it is possible to modify the
695 /// range of deleted text, or prevent it from being deleted entirely.
696 ///
697 /// The @start_pos and @end_pos parameters are interpreted as for
698 /// [`EditableExt::delete_text()`][crate::prelude::EditableExt::delete_text()].
699 ///
700 ///
701 ///
702 ///
703 /// #### `insert-text`
704 /// Emitted when text is inserted into the widget by the user.
705 ///
706 /// The default handler for this signal will normally be responsible
707 /// for inserting the text, so by connecting to this signal and then
708 /// stopping the signal with g_signal_stop_emission(), it is possible
709 /// to modify the inserted text, or prevent it from being inserted entirely.
710 ///
711 ///
712 /// </details>
713 ///
714 /// # Implements
715 ///
716 /// [`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]
717 #[doc(alias = "GtkSearchEntry")]
718 pub struct SearchEntry(Object<ffi::GtkSearchEntry>) @extends Widget, @implements Accessible, Buildable, ConstraintTarget, Editable;
719
720 match fn {
721 type_ => || ffi::gtk_search_entry_get_type(),
722 }
723}
724
725impl SearchEntry {
726 /// Creates a [`SearchEntry`][crate::SearchEntry].
727 ///
728 /// # Returns
729 ///
730 /// a new [`SearchEntry`][crate::SearchEntry]
731 #[doc(alias = "gtk_search_entry_new")]
732 pub fn new() -> SearchEntry {
733 assert_initialized_main_thread!();
734 unsafe { Widget::from_glib_none(ffi::gtk_search_entry_new()).unsafe_cast() }
735 }
736
737 // rustdoc-stripper-ignore-next
738 /// Creates a new builder-pattern struct instance to construct [`SearchEntry`] objects.
739 ///
740 /// This method returns an instance of [`SearchEntryBuilder`](crate::builders::SearchEntryBuilder) which can be used to create [`SearchEntry`] objects.
741 pub fn builder() -> SearchEntryBuilder {
742 SearchEntryBuilder::new()
743 }
744
745 /// Gets the input purpose for @self.
746 ///
747 /// # Returns
748 ///
749 /// The input hints
750 #[cfg(feature = "v4_14")]
751 #[cfg_attr(docsrs, doc(cfg(feature = "v4_14")))]
752 #[doc(alias = "gtk_search_entry_get_input_hints")]
753 #[doc(alias = "get_input_hints")]
754 #[doc(alias = "input-hints")]
755 pub fn input_hints(&self) -> InputHints {
756 unsafe { from_glib(ffi::gtk_search_entry_get_input_hints(self.to_glib_none().0)) }
757 }
758
759 /// Gets the input purpose of @self.
760 ///
761 /// # Returns
762 ///
763 /// The input hints
764 #[cfg(feature = "v4_14")]
765 #[cfg_attr(docsrs, doc(cfg(feature = "v4_14")))]
766 #[doc(alias = "gtk_search_entry_get_input_purpose")]
767 #[doc(alias = "get_input_purpose")]
768 #[doc(alias = "input-purpose")]
769 pub fn input_purpose(&self) -> InputPurpose {
770 unsafe {
771 from_glib(ffi::gtk_search_entry_get_input_purpose(
772 self.to_glib_none().0,
773 ))
774 }
775 }
776
777 /// Gets the widget that @self is capturing key events from.
778 ///
779 /// # Returns
780 ///
781 /// The key capture widget.
782 #[doc(alias = "gtk_search_entry_get_key_capture_widget")]
783 #[doc(alias = "get_key_capture_widget")]
784 #[doc(alias = "key-capture-widget")]
785 pub fn key_capture_widget(&self) -> Option<Widget> {
786 unsafe {
787 from_glib_none(ffi::gtk_search_entry_get_key_capture_widget(
788 self.to_glib_none().0,
789 ))
790 }
791 }
792
793 /// Get the delay to be used between the last keypress and the
794 /// [`search-changed`][struct@crate::SearchEntry#search-changed] signal being emitted.
795 ///
796 /// # Returns
797 ///
798 /// a delay in milliseconds.
799 #[cfg(feature = "v4_8")]
800 #[cfg_attr(docsrs, doc(cfg(feature = "v4_8")))]
801 #[doc(alias = "gtk_search_entry_get_search_delay")]
802 #[doc(alias = "get_search_delay")]
803 #[doc(alias = "search-delay")]
804 pub fn search_delay(&self) -> u32 {
805 unsafe { ffi::gtk_search_entry_get_search_delay(self.to_glib_none().0) }
806 }
807
808 /// Sets the input hints for @self.
809 /// ## `hints`
810 /// the new input hints
811 #[cfg(feature = "v4_14")]
812 #[cfg_attr(docsrs, doc(cfg(feature = "v4_14")))]
813 #[doc(alias = "gtk_search_entry_set_input_hints")]
814 #[doc(alias = "input-hints")]
815 pub fn set_input_hints(&self, hints: InputHints) {
816 unsafe {
817 ffi::gtk_search_entry_set_input_hints(self.to_glib_none().0, hints.into_glib());
818 }
819 }
820
821 /// Sets the input purpose of @self.
822 /// ## `purpose`
823 /// the new input purpose
824 #[cfg(feature = "v4_14")]
825 #[cfg_attr(docsrs, doc(cfg(feature = "v4_14")))]
826 #[doc(alias = "gtk_search_entry_set_input_purpose")]
827 #[doc(alias = "input-purpose")]
828 pub fn set_input_purpose(&self, purpose: InputPurpose) {
829 unsafe {
830 ffi::gtk_search_entry_set_input_purpose(self.to_glib_none().0, purpose.into_glib());
831 }
832 }
833
834 /// Sets @widget as the widget that @self will capture key
835 /// events from.
836 ///
837 /// Key events are consumed by the search entry to start or
838 /// continue a search.
839 ///
840 /// If the entry is part of a [`SearchBar`][crate::SearchBar], it is preferable
841 /// to call [`SearchBar::set_key_capture_widget()`][crate::SearchBar::set_key_capture_widget()] instead,
842 /// which will reveal the entry in addition to triggering the
843 /// search entry.
844 ///
845 /// Note that despite the name of this function, the events
846 /// are only 'captured' in the bubble phase, which means that
847 /// editable child widgets of @widget will receive text input
848 /// before it gets captured. If that is not desired, you can
849 /// capture and forward the events yourself with
850 /// [`EventControllerKey::forward()`][crate::EventControllerKey::forward()].
851 /// ## `widget`
852 /// a [`Widget`][crate::Widget]
853 #[doc(alias = "gtk_search_entry_set_key_capture_widget")]
854 #[doc(alias = "key-capture-widget")]
855 pub fn set_key_capture_widget(&self, widget: Option<&impl IsA<Widget>>) {
856 unsafe {
857 ffi::gtk_search_entry_set_key_capture_widget(
858 self.to_glib_none().0,
859 widget.map(|p| p.as_ref()).to_glib_none().0,
860 );
861 }
862 }
863
864 /// Set the delay to be used between the last keypress and the
865 /// [`search-changed`][struct@crate::SearchEntry#search-changed] signal being emitted.
866 /// ## `delay`
867 /// a delay in milliseconds
868 #[cfg(feature = "v4_8")]
869 #[cfg_attr(docsrs, doc(cfg(feature = "v4_8")))]
870 #[doc(alias = "gtk_search_entry_set_search_delay")]
871 #[doc(alias = "search-delay")]
872 pub fn set_search_delay(&self, delay: u32) {
873 unsafe {
874 ffi::gtk_search_entry_set_search_delay(self.to_glib_none().0, delay);
875 }
876 }
877
878 /// Whether to activate the default widget when Enter is pressed.
879 #[doc(alias = "activates-default")]
880 pub fn activates_default(&self) -> bool {
881 ObjectExt::property(self, "activates-default")
882 }
883
884 /// Whether to activate the default widget when Enter is pressed.
885 #[doc(alias = "activates-default")]
886 pub fn set_activates_default(&self, activates_default: bool) {
887 ObjectExt::set_property(self, "activates-default", activates_default)
888 }
889
890 #[doc(alias = "placeholder-text")]
891 pub fn placeholder_text(&self) -> Option<glib::GString> {
892 ObjectExt::property(self, "placeholder-text")
893 }
894
895 #[doc(alias = "placeholder-text")]
896 pub fn set_placeholder_text(&self, placeholder_text: Option<&str>) {
897 ObjectExt::set_property(self, "placeholder-text", placeholder_text)
898 }
899
900 /// Emitted when the entry is activated.
901 ///
902 /// The keybindings for this signal are all forms of the <kbd>Enter</kbd> key.
903 #[doc(alias = "activate")]
904 pub fn connect_activate<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
905 unsafe extern "C" fn activate_trampoline<F: Fn(&SearchEntry) + 'static>(
906 this: *mut ffi::GtkSearchEntry,
907 f: glib::ffi::gpointer,
908 ) {
909 unsafe {
910 let f: &F = &*(f as *const F);
911 f(&from_glib_borrow(this))
912 }
913 }
914 unsafe {
915 let f: Box_<F> = Box_::new(f);
916 connect_raw(
917 self.as_ptr() as *mut _,
918 c"activate".as_ptr(),
919 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
920 activate_trampoline::<F> as *const (),
921 )),
922 Box_::into_raw(f),
923 )
924 }
925 }
926
927 pub fn emit_activate(&self) {
928 self.emit_by_name::<()>("activate", &[]);
929 }
930
931 /// Emitted when the user initiates a move to the next match
932 /// for the current search string.
933 ///
934 /// This is a [keybinding signal](class.SignalAction.html).
935 ///
936 /// Applications should connect to it, to implement moving
937 /// between matches.
938 ///
939 /// The default bindings for this signal is <kbd>Ctrl</kbd>+<kbd>g</kbd>.
940 #[doc(alias = "next-match")]
941 pub fn connect_next_match<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
942 unsafe extern "C" fn next_match_trampoline<F: Fn(&SearchEntry) + 'static>(
943 this: *mut ffi::GtkSearchEntry,
944 f: glib::ffi::gpointer,
945 ) {
946 unsafe {
947 let f: &F = &*(f as *const F);
948 f(&from_glib_borrow(this))
949 }
950 }
951 unsafe {
952 let f: Box_<F> = Box_::new(f);
953 connect_raw(
954 self.as_ptr() as *mut _,
955 c"next-match".as_ptr(),
956 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
957 next_match_trampoline::<F> as *const (),
958 )),
959 Box_::into_raw(f),
960 )
961 }
962 }
963
964 pub fn emit_next_match(&self) {
965 self.emit_by_name::<()>("next-match", &[]);
966 }
967
968 /// Emitted when the user initiates a move to the previous match
969 /// for the current search string.
970 ///
971 /// This is a [keybinding signal](class.SignalAction.html).
972 ///
973 /// Applications should connect to it, to implement moving
974 /// between matches.
975 ///
976 /// The default bindings for this signal is
977 /// <kbd>Ctrl</kbd>+<kbd>Shift</kbd>+<kbd>g</kbd>.
978 #[doc(alias = "previous-match")]
979 pub fn connect_previous_match<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
980 unsafe extern "C" fn previous_match_trampoline<F: Fn(&SearchEntry) + 'static>(
981 this: *mut ffi::GtkSearchEntry,
982 f: glib::ffi::gpointer,
983 ) {
984 unsafe {
985 let f: &F = &*(f as *const F);
986 f(&from_glib_borrow(this))
987 }
988 }
989 unsafe {
990 let f: Box_<F> = Box_::new(f);
991 connect_raw(
992 self.as_ptr() as *mut _,
993 c"previous-match".as_ptr(),
994 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
995 previous_match_trampoline::<F> as *const (),
996 )),
997 Box_::into_raw(f),
998 )
999 }
1000 }
1001
1002 pub fn emit_previous_match(&self) {
1003 self.emit_by_name::<()>("previous-match", &[]);
1004 }
1005
1006 /// Emitted with a delay. The length of the delay can be
1007 /// changed with the [`search-delay`][struct@crate::SearchEntry#search-delay]
1008 /// property.
1009 #[doc(alias = "search-changed")]
1010 pub fn connect_search_changed<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1011 unsafe extern "C" fn search_changed_trampoline<F: Fn(&SearchEntry) + 'static>(
1012 this: *mut ffi::GtkSearchEntry,
1013 f: glib::ffi::gpointer,
1014 ) {
1015 unsafe {
1016 let f: &F = &*(f as *const F);
1017 f(&from_glib_borrow(this))
1018 }
1019 }
1020 unsafe {
1021 let f: Box_<F> = Box_::new(f);
1022 connect_raw(
1023 self.as_ptr() as *mut _,
1024 c"search-changed".as_ptr(),
1025 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1026 search_changed_trampoline::<F> as *const (),
1027 )),
1028 Box_::into_raw(f),
1029 )
1030 }
1031 }
1032
1033 /// Emitted when the user initiated a search on the entry.
1034 #[doc(alias = "search-started")]
1035 pub fn connect_search_started<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1036 unsafe extern "C" fn search_started_trampoline<F: Fn(&SearchEntry) + 'static>(
1037 this: *mut ffi::GtkSearchEntry,
1038 f: glib::ffi::gpointer,
1039 ) {
1040 unsafe {
1041 let f: &F = &*(f as *const F);
1042 f(&from_glib_borrow(this))
1043 }
1044 }
1045 unsafe {
1046 let f: Box_<F> = Box_::new(f);
1047 connect_raw(
1048 self.as_ptr() as *mut _,
1049 c"search-started".as_ptr(),
1050 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1051 search_started_trampoline::<F> as *const (),
1052 )),
1053 Box_::into_raw(f),
1054 )
1055 }
1056 }
1057
1058 /// Emitted when the user stops a search via keyboard input.
1059 ///
1060 /// This is a [keybinding signal](class.SignalAction.html).
1061 ///
1062 /// Applications should connect to it, to implement hiding
1063 /// the search entry in this case.
1064 ///
1065 /// The default bindings for this signal is <kbd>Escape</kbd>.
1066 #[doc(alias = "stop-search")]
1067 pub fn connect_stop_search<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1068 unsafe extern "C" fn stop_search_trampoline<F: Fn(&SearchEntry) + 'static>(
1069 this: *mut ffi::GtkSearchEntry,
1070 f: glib::ffi::gpointer,
1071 ) {
1072 unsafe {
1073 let f: &F = &*(f as *const F);
1074 f(&from_glib_borrow(this))
1075 }
1076 }
1077 unsafe {
1078 let f: Box_<F> = Box_::new(f);
1079 connect_raw(
1080 self.as_ptr() as *mut _,
1081 c"stop-search".as_ptr(),
1082 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1083 stop_search_trampoline::<F> as *const (),
1084 )),
1085 Box_::into_raw(f),
1086 )
1087 }
1088 }
1089
1090 pub fn emit_stop_search(&self) {
1091 self.emit_by_name::<()>("stop-search", &[]);
1092 }
1093
1094 #[doc(alias = "activates-default")]
1095 pub fn connect_activates_default_notify<F: Fn(&Self) + 'static>(
1096 &self,
1097 f: F,
1098 ) -> SignalHandlerId {
1099 unsafe extern "C" fn notify_activates_default_trampoline<F: Fn(&SearchEntry) + 'static>(
1100 this: *mut ffi::GtkSearchEntry,
1101 _param_spec: glib::ffi::gpointer,
1102 f: glib::ffi::gpointer,
1103 ) {
1104 unsafe {
1105 let f: &F = &*(f as *const F);
1106 f(&from_glib_borrow(this))
1107 }
1108 }
1109 unsafe {
1110 let f: Box_<F> = Box_::new(f);
1111 connect_raw(
1112 self.as_ptr() as *mut _,
1113 c"notify::activates-default".as_ptr(),
1114 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1115 notify_activates_default_trampoline::<F> as *const (),
1116 )),
1117 Box_::into_raw(f),
1118 )
1119 }
1120 }
1121
1122 #[cfg(feature = "v4_14")]
1123 #[cfg_attr(docsrs, doc(cfg(feature = "v4_14")))]
1124 #[doc(alias = "input-hints")]
1125 pub fn connect_input_hints_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1126 unsafe extern "C" fn notify_input_hints_trampoline<F: Fn(&SearchEntry) + 'static>(
1127 this: *mut ffi::GtkSearchEntry,
1128 _param_spec: glib::ffi::gpointer,
1129 f: glib::ffi::gpointer,
1130 ) {
1131 unsafe {
1132 let f: &F = &*(f as *const F);
1133 f(&from_glib_borrow(this))
1134 }
1135 }
1136 unsafe {
1137 let f: Box_<F> = Box_::new(f);
1138 connect_raw(
1139 self.as_ptr() as *mut _,
1140 c"notify::input-hints".as_ptr(),
1141 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1142 notify_input_hints_trampoline::<F> as *const (),
1143 )),
1144 Box_::into_raw(f),
1145 )
1146 }
1147 }
1148
1149 #[cfg(feature = "v4_14")]
1150 #[cfg_attr(docsrs, doc(cfg(feature = "v4_14")))]
1151 #[doc(alias = "input-purpose")]
1152 pub fn connect_input_purpose_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1153 unsafe extern "C" fn notify_input_purpose_trampoline<F: Fn(&SearchEntry) + 'static>(
1154 this: *mut ffi::GtkSearchEntry,
1155 _param_spec: glib::ffi::gpointer,
1156 f: glib::ffi::gpointer,
1157 ) {
1158 unsafe {
1159 let f: &F = &*(f as *const F);
1160 f(&from_glib_borrow(this))
1161 }
1162 }
1163 unsafe {
1164 let f: Box_<F> = Box_::new(f);
1165 connect_raw(
1166 self.as_ptr() as *mut _,
1167 c"notify::input-purpose".as_ptr(),
1168 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1169 notify_input_purpose_trampoline::<F> as *const (),
1170 )),
1171 Box_::into_raw(f),
1172 )
1173 }
1174 }
1175
1176 #[cfg(feature = "v4_22")]
1177 #[cfg_attr(docsrs, doc(cfg(feature = "v4_22")))]
1178 #[doc(alias = "key-capture-widget")]
1179 pub fn connect_key_capture_widget_notify<F: Fn(&Self) + 'static>(
1180 &self,
1181 f: F,
1182 ) -> SignalHandlerId {
1183 unsafe extern "C" fn notify_key_capture_widget_trampoline<F: Fn(&SearchEntry) + 'static>(
1184 this: *mut ffi::GtkSearchEntry,
1185 _param_spec: glib::ffi::gpointer,
1186 f: glib::ffi::gpointer,
1187 ) {
1188 unsafe {
1189 let f: &F = &*(f as *const F);
1190 f(&from_glib_borrow(this))
1191 }
1192 }
1193 unsafe {
1194 let f: Box_<F> = Box_::new(f);
1195 connect_raw(
1196 self.as_ptr() as *mut _,
1197 c"notify::key-capture-widget".as_ptr(),
1198 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1199 notify_key_capture_widget_trampoline::<F> as *const (),
1200 )),
1201 Box_::into_raw(f),
1202 )
1203 }
1204 }
1205
1206 #[doc(alias = "placeholder-text")]
1207 pub fn connect_placeholder_text_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1208 unsafe extern "C" fn notify_placeholder_text_trampoline<F: Fn(&SearchEntry) + 'static>(
1209 this: *mut ffi::GtkSearchEntry,
1210 _param_spec: glib::ffi::gpointer,
1211 f: glib::ffi::gpointer,
1212 ) {
1213 unsafe {
1214 let f: &F = &*(f as *const F);
1215 f(&from_glib_borrow(this))
1216 }
1217 }
1218 unsafe {
1219 let f: Box_<F> = Box_::new(f);
1220 connect_raw(
1221 self.as_ptr() as *mut _,
1222 c"notify::placeholder-text".as_ptr(),
1223 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1224 notify_placeholder_text_trampoline::<F> as *const (),
1225 )),
1226 Box_::into_raw(f),
1227 )
1228 }
1229 }
1230
1231 #[cfg(feature = "v4_8")]
1232 #[cfg_attr(docsrs, doc(cfg(feature = "v4_8")))]
1233 #[doc(alias = "search-delay")]
1234 pub fn connect_search_delay_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1235 unsafe extern "C" fn notify_search_delay_trampoline<F: Fn(&SearchEntry) + 'static>(
1236 this: *mut ffi::GtkSearchEntry,
1237 _param_spec: glib::ffi::gpointer,
1238 f: glib::ffi::gpointer,
1239 ) {
1240 unsafe {
1241 let f: &F = &*(f as *const F);
1242 f(&from_glib_borrow(this))
1243 }
1244 }
1245 unsafe {
1246 let f: Box_<F> = Box_::new(f);
1247 connect_raw(
1248 self.as_ptr() as *mut _,
1249 c"notify::search-delay".as_ptr(),
1250 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1251 notify_search_delay_trampoline::<F> as *const (),
1252 )),
1253 Box_::into_raw(f),
1254 )
1255 }
1256 }
1257}
1258
1259impl Default for SearchEntry {
1260 fn default() -> Self {
1261 Self::new()
1262 }
1263}
1264
1265// rustdoc-stripper-ignore-next
1266/// A [builder-pattern] type to construct [`SearchEntry`] objects.
1267///
1268/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
1269#[must_use = "The builder must be built to be used"]
1270pub struct SearchEntryBuilder {
1271 builder: glib::object::ObjectBuilder<'static, SearchEntry>,
1272}
1273
1274impl SearchEntryBuilder {
1275 fn new() -> Self {
1276 Self {
1277 builder: glib::object::Object::builder(),
1278 }
1279 }
1280
1281 /// Whether to activate the default widget when Enter is pressed.
1282 pub fn activates_default(self, activates_default: bool) -> Self {
1283 Self {
1284 builder: self
1285 .builder
1286 .property("activates-default", activates_default),
1287 }
1288 }
1289
1290 /// The hints about input for the [`SearchEntry`][crate::SearchEntry] used to alter the
1291 /// behaviour of input methods.
1292 #[cfg(feature = "v4_14")]
1293 #[cfg_attr(docsrs, doc(cfg(feature = "v4_14")))]
1294 pub fn input_hints(self, input_hints: InputHints) -> Self {
1295 Self {
1296 builder: self.builder.property("input-hints", input_hints),
1297 }
1298 }
1299
1300 /// The purpose for the [`SearchEntry`][crate::SearchEntry] input used to alter the
1301 /// behaviour of input methods.
1302 #[cfg(feature = "v4_14")]
1303 #[cfg_attr(docsrs, doc(cfg(feature = "v4_14")))]
1304 pub fn input_purpose(self, input_purpose: InputPurpose) -> Self {
1305 Self {
1306 builder: self.builder.property("input-purpose", input_purpose),
1307 }
1308 }
1309
1310 /// The widget that the entry will use to capture key events.
1311 ///
1312 /// Key events are consumed by the search entry to start or continue a search.
1313 #[cfg(feature = "v4_22")]
1314 #[cfg_attr(docsrs, doc(cfg(feature = "v4_22")))]
1315 pub fn key_capture_widget(self, key_capture_widget: &impl IsA<Widget>) -> Self {
1316 Self {
1317 builder: self
1318 .builder
1319 .property("key-capture-widget", key_capture_widget.clone().upcast()),
1320 }
1321 }
1322
1323 /// The text that will be displayed in the [`SearchEntry`][crate::SearchEntry]
1324 /// when it is empty and unfocused.
1325 pub fn placeholder_text(self, placeholder_text: impl Into<glib::GString>) -> Self {
1326 Self {
1327 builder: self
1328 .builder
1329 .property("placeholder-text", placeholder_text.into()),
1330 }
1331 }
1332
1333 /// The delay in milliseconds from last keypress to the search
1334 /// changed signal.
1335 #[cfg(feature = "v4_8")]
1336 #[cfg_attr(docsrs, doc(cfg(feature = "v4_8")))]
1337 pub fn search_delay(self, search_delay: u32) -> Self {
1338 Self {
1339 builder: self.builder.property("search-delay", search_delay),
1340 }
1341 }
1342
1343 /// Whether the widget or any of its descendents can accept
1344 /// the input focus.
1345 ///
1346 /// This property is meant to be set by widget implementations,
1347 /// typically in their instance init function.
1348 pub fn can_focus(self, can_focus: bool) -> Self {
1349 Self {
1350 builder: self.builder.property("can-focus", can_focus),
1351 }
1352 }
1353
1354 /// Whether the widget can receive pointer events.
1355 pub fn can_target(self, can_target: bool) -> Self {
1356 Self {
1357 builder: self.builder.property("can-target", can_target),
1358 }
1359 }
1360
1361 /// A list of css classes applied to this widget.
1362 pub fn css_classes(self, css_classes: impl Into<glib::StrV>) -> Self {
1363 Self {
1364 builder: self.builder.property("css-classes", css_classes.into()),
1365 }
1366 }
1367
1368 /// The name of this widget in the CSS tree.
1369 ///
1370 /// This property is meant to be set by widget implementations,
1371 /// typically in their instance init function.
1372 pub fn css_name(self, css_name: impl Into<glib::GString>) -> Self {
1373 Self {
1374 builder: self.builder.property("css-name", css_name.into()),
1375 }
1376 }
1377
1378 /// The cursor used by @widget.
1379 pub fn cursor(self, cursor: &gdk::Cursor) -> Self {
1380 Self {
1381 builder: self.builder.property("cursor", cursor.clone()),
1382 }
1383 }
1384
1385 /// Whether the widget should grab focus when it is clicked with the mouse.
1386 ///
1387 /// This property is only relevant for widgets that can take focus.
1388 pub fn focus_on_click(self, focus_on_click: bool) -> Self {
1389 Self {
1390 builder: self.builder.property("focus-on-click", focus_on_click),
1391 }
1392 }
1393
1394 /// Whether this widget itself will accept the input focus.
1395 pub fn focusable(self, focusable: bool) -> Self {
1396 Self {
1397 builder: self.builder.property("focusable", focusable),
1398 }
1399 }
1400
1401 /// How to distribute horizontal space if widget gets extra space.
1402 pub fn halign(self, halign: Align) -> Self {
1403 Self {
1404 builder: self.builder.property("halign", halign),
1405 }
1406 }
1407
1408 /// Enables or disables the emission of the [`query-tooltip`][struct@crate::Widget#query-tooltip]
1409 /// signal on @widget.
1410 ///
1411 /// A true value indicates that @widget can have a tooltip, in this case
1412 /// the widget will be queried using [`query-tooltip`][struct@crate::Widget#query-tooltip] to
1413 /// determine whether it will provide a tooltip or not.
1414 pub fn has_tooltip(self, has_tooltip: bool) -> Self {
1415 Self {
1416 builder: self.builder.property("has-tooltip", has_tooltip),
1417 }
1418 }
1419
1420 /// Overrides for height request of the widget.
1421 ///
1422 /// If this is -1, the natural request will be used.
1423 pub fn height_request(self, height_request: i32) -> Self {
1424 Self {
1425 builder: self.builder.property("height-request", height_request),
1426 }
1427 }
1428
1429 /// Whether to expand horizontally.
1430 pub fn hexpand(self, hexpand: bool) -> Self {
1431 Self {
1432 builder: self.builder.property("hexpand", hexpand),
1433 }
1434 }
1435
1436 /// Whether to use the `hexpand` property.
1437 pub fn hexpand_set(self, hexpand_set: bool) -> Self {
1438 Self {
1439 builder: self.builder.property("hexpand-set", hexpand_set),
1440 }
1441 }
1442
1443 /// The [`LayoutManager`][crate::LayoutManager] instance to use to compute
1444 /// the preferred size of the widget, and allocate its children.
1445 ///
1446 /// This property is meant to be set by widget implementations,
1447 /// typically in their instance init function.
1448 pub fn layout_manager(self, layout_manager: &impl IsA<LayoutManager>) -> Self {
1449 Self {
1450 builder: self
1451 .builder
1452 .property("layout-manager", layout_manager.clone().upcast()),
1453 }
1454 }
1455
1456 /// Makes this widget act like a modal dialog, with respect to
1457 /// event delivery.
1458 ///
1459 /// Global event controllers will not handle events with targets
1460 /// inside the widget, unless they are set up to ignore propagation
1461 /// limits. See [`EventControllerExt::set_propagation_limit()`][crate::prelude::EventControllerExt::set_propagation_limit()].
1462 #[cfg(feature = "v4_18")]
1463 #[cfg_attr(docsrs, doc(cfg(feature = "v4_18")))]
1464 pub fn limit_events(self, limit_events: bool) -> Self {
1465 Self {
1466 builder: self.builder.property("limit-events", limit_events),
1467 }
1468 }
1469
1470 /// Margin on bottom side of widget.
1471 ///
1472 /// This property adds margin outside of the widget's normal size
1473 /// request, the margin will be added in addition to the size from
1474 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
1475 pub fn margin_bottom(self, margin_bottom: i32) -> Self {
1476 Self {
1477 builder: self.builder.property("margin-bottom", margin_bottom),
1478 }
1479 }
1480
1481 /// Margin on end of widget, horizontally.
1482 ///
1483 /// This property supports left-to-right and right-to-left text
1484 /// directions.
1485 ///
1486 /// This property adds margin outside of the widget's normal size
1487 /// request, the margin will be added in addition to the size from
1488 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
1489 pub fn margin_end(self, margin_end: i32) -> Self {
1490 Self {
1491 builder: self.builder.property("margin-end", margin_end),
1492 }
1493 }
1494
1495 /// Margin on start of widget, horizontally.
1496 ///
1497 /// This property supports left-to-right and right-to-left text
1498 /// directions.
1499 ///
1500 /// This property adds margin outside of the widget's normal size
1501 /// request, the margin will be added in addition to the size from
1502 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
1503 pub fn margin_start(self, margin_start: i32) -> Self {
1504 Self {
1505 builder: self.builder.property("margin-start", margin_start),
1506 }
1507 }
1508
1509 /// Margin on top side of widget.
1510 ///
1511 /// This property adds margin outside of the widget's normal size
1512 /// request, the margin will be added in addition to the size from
1513 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
1514 pub fn margin_top(self, margin_top: i32) -> Self {
1515 Self {
1516 builder: self.builder.property("margin-top", margin_top),
1517 }
1518 }
1519
1520 /// The name of the widget.
1521 pub fn name(self, name: impl Into<glib::GString>) -> Self {
1522 Self {
1523 builder: self.builder.property("name", name.into()),
1524 }
1525 }
1526
1527 /// The requested opacity of the widget.
1528 pub fn opacity(self, opacity: f64) -> Self {
1529 Self {
1530 builder: self.builder.property("opacity", opacity),
1531 }
1532 }
1533
1534 /// How content outside the widget's content area is treated.
1535 ///
1536 /// This property is meant to be set by widget implementations,
1537 /// typically in their instance init function.
1538 pub fn overflow(self, overflow: Overflow) -> Self {
1539 Self {
1540 builder: self.builder.property("overflow", overflow),
1541 }
1542 }
1543
1544 /// Whether the widget will receive the default action when it is focused.
1545 pub fn receives_default(self, receives_default: bool) -> Self {
1546 Self {
1547 builder: self.builder.property("receives-default", receives_default),
1548 }
1549 }
1550
1551 /// Whether the widget responds to input.
1552 pub fn sensitive(self, sensitive: bool) -> Self {
1553 Self {
1554 builder: self.builder.property("sensitive", sensitive),
1555 }
1556 }
1557
1558 /// Sets the text of tooltip to be the given string, which is marked up
1559 /// with Pango markup.
1560 ///
1561 /// Also see [`Tooltip::set_markup()`][crate::Tooltip::set_markup()].
1562 ///
1563 /// This is a convenience property which will take care of getting the
1564 /// tooltip shown if the given string is not `NULL`:
1565 /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
1566 /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
1567 /// the default signal handler.
1568 ///
1569 /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
1570 /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
1571 pub fn tooltip_markup(self, tooltip_markup: impl Into<glib::GString>) -> Self {
1572 Self {
1573 builder: self
1574 .builder
1575 .property("tooltip-markup", tooltip_markup.into()),
1576 }
1577 }
1578
1579 /// Sets the text of tooltip to be the given string.
1580 ///
1581 /// Also see [`Tooltip::set_text()`][crate::Tooltip::set_text()].
1582 ///
1583 /// This is a convenience property which will take care of getting the
1584 /// tooltip shown if the given string is not `NULL`:
1585 /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
1586 /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
1587 /// the default signal handler.
1588 ///
1589 /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
1590 /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
1591 pub fn tooltip_text(self, tooltip_text: impl Into<glib::GString>) -> Self {
1592 Self {
1593 builder: self.builder.property("tooltip-text", tooltip_text.into()),
1594 }
1595 }
1596
1597 /// How to distribute vertical space if widget gets extra space.
1598 pub fn valign(self, valign: Align) -> Self {
1599 Self {
1600 builder: self.builder.property("valign", valign),
1601 }
1602 }
1603
1604 /// Whether to expand vertically.
1605 pub fn vexpand(self, vexpand: bool) -> Self {
1606 Self {
1607 builder: self.builder.property("vexpand", vexpand),
1608 }
1609 }
1610
1611 /// Whether to use the `vexpand` property.
1612 pub fn vexpand_set(self, vexpand_set: bool) -> Self {
1613 Self {
1614 builder: self.builder.property("vexpand-set", vexpand_set),
1615 }
1616 }
1617
1618 /// Whether the widget is visible.
1619 pub fn visible(self, visible: bool) -> Self {
1620 Self {
1621 builder: self.builder.property("visible", visible),
1622 }
1623 }
1624
1625 /// Overrides for width request of the widget.
1626 ///
1627 /// If this is -1, the natural request will be used.
1628 pub fn width_request(self, width_request: i32) -> Self {
1629 Self {
1630 builder: self.builder.property("width-request", width_request),
1631 }
1632 }
1633
1634 /// The accessible role of the given [`Accessible`][crate::Accessible] implementation.
1635 ///
1636 /// The accessible role cannot be changed once set.
1637 pub fn accessible_role(self, accessible_role: AccessibleRole) -> Self {
1638 Self {
1639 builder: self.builder.property("accessible-role", accessible_role),
1640 }
1641 }
1642
1643 /// Whether the entry contents can be edited.
1644 pub fn editable(self, editable: bool) -> Self {
1645 Self {
1646 builder: self.builder.property("editable", editable),
1647 }
1648 }
1649
1650 /// If undo/redo should be enabled for the editable.
1651 pub fn enable_undo(self, enable_undo: bool) -> Self {
1652 Self {
1653 builder: self.builder.property("enable-undo", enable_undo),
1654 }
1655 }
1656
1657 /// The desired maximum width of the entry, in characters.
1658 pub fn max_width_chars(self, max_width_chars: i32) -> Self {
1659 Self {
1660 builder: self.builder.property("max-width-chars", max_width_chars),
1661 }
1662 }
1663
1664 /// The contents of the entry.
1665 pub fn text(self, text: impl Into<glib::GString>) -> Self {
1666 Self {
1667 builder: self.builder.property("text", text.into()),
1668 }
1669 }
1670
1671 /// Number of characters to leave space for in the entry.
1672 pub fn width_chars(self, width_chars: i32) -> Self {
1673 Self {
1674 builder: self.builder.property("width-chars", width_chars),
1675 }
1676 }
1677
1678 /// The horizontal alignment, from 0 (left) to 1 (right).
1679 ///
1680 /// Reversed for RTL layouts.
1681 pub fn xalign(self, xalign: f32) -> Self {
1682 Self {
1683 builder: self.builder.property("xalign", xalign),
1684 }
1685 }
1686
1687 // rustdoc-stripper-ignore-next
1688 /// Build the [`SearchEntry`].
1689 #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
1690 pub fn build(self) -> SearchEntry {
1691 assert_initialized_main_thread!();
1692 self.builder.build()
1693 }
1694}