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