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