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