gtk/auto/search_entry.rs
1// This file was generated by gir (https://github.com/gtk-rs/gir)
2// from gir-files (https://github.com/gtk-rs/gir-files)
3// DO NOT EDIT
4
5use crate::{
6 Align, Buildable, CellEditable, Container, Editable, Entry, EntryBuffer, EntryCompletion,
7 InputHints, InputPurpose, Widget,
8};
9use glib::{
10 prelude::*,
11 signal::{connect_raw, SignalHandlerId},
12 translate::*,
13};
14use std::{boxed::Box as Box_, fmt, mem::transmute};
15
16glib::wrapper! {
17 /// [`SearchEntry`][crate::SearchEntry] is a subclass of [`Entry`][crate::Entry] that has been
18 /// tailored for use as a search entry.
19 ///
20 /// It will show an inactive symbolic “find” icon when the search
21 /// entry is empty, and a symbolic “clear” icon when there is text.
22 /// Clicking on the “clear” icon will empty the search entry.
23 ///
24 /// Note that the search/clear icon is shown using a secondary
25 /// icon, and thus does not work if you are using the secondary
26 /// icon position for some other purpose.
27 ///
28 /// To make filtering appear more reactive, it is a good idea to
29 /// not react to every change in the entry text immediately, but
30 /// only after a short delay. To support this, [`SearchEntry`][crate::SearchEntry]
31 /// emits the [`search-changed`][struct@crate::SearchEntry#search-changed] signal which can
32 /// be used instead of the [`changed`][struct@crate::Editable#changed] signal.
33 ///
34 /// The [`previous-match`][struct@crate::SearchEntry#previous-match], [`next-match`][struct@crate::SearchEntry#next-match]
35 /// and [`stop-search`][struct@crate::SearchEntry#stop-search] signals can be used to implement
36 /// moving between search results and ending the search.
37 ///
38 /// Often, GtkSearchEntry will be fed events by means of being
39 /// placed inside a [`SearchBar`][crate::SearchBar]. If that is not the case,
40 /// you can use [`SearchEntryExt::handle_event()`][crate::prelude::SearchEntryExt::handle_event()] to pass events.
41 ///
42 /// ## Signals
43 ///
44 ///
45 /// #### `next-match`
46 /// The ::next-match signal is a [keybinding signal][GtkBindingSignal]
47 /// which gets emitted when the user initiates a move to the next match
48 /// for the current search string.
49 ///
50 /// Applications should connect to it, to implement moving between
51 /// matches.
52 ///
53 /// The default bindings for this signal is Ctrl-g.
54 ///
55 /// Action
56 ///
57 ///
58 /// #### `previous-match`
59 /// The ::previous-match signal is a [keybinding signal][GtkBindingSignal]
60 /// which gets emitted when the user initiates a move to the previous match
61 /// for the current search string.
62 ///
63 /// Applications should connect to it, to implement moving between
64 /// matches.
65 ///
66 /// The default bindings for this signal is Ctrl-Shift-g.
67 ///
68 /// Action
69 ///
70 ///
71 /// #### `search-changed`
72 /// The [`search-changed`][struct@crate::SearchEntry#search-changed] signal is emitted with a short
73 /// delay of 150 milliseconds after the last change to the entry text.
74 ///
75 ///
76 ///
77 ///
78 /// #### `stop-search`
79 /// The ::stop-search signal is a [keybinding signal][GtkBindingSignal]
80 /// which gets emitted when the user stops a search via keyboard input.
81 ///
82 /// Applications should connect to it, to implement hiding the search
83 /// entry in this case.
84 ///
85 /// The default bindings for this signal is Escape.
86 ///
87 /// Action
88 /// <details><summary><h4>Entry</h4></summary>
89 ///
90 ///
91 /// #### `activate`
92 /// The ::activate signal is emitted when the user hits
93 /// the Enter key.
94 ///
95 /// While this signal is used as a
96 /// [keybinding signal][GtkBindingSignal],
97 /// it is also commonly used by applications to intercept
98 /// activation of entries.
99 ///
100 /// The default bindings for this signal are all forms of the Enter key.
101 ///
102 /// Action
103 ///
104 ///
105 /// #### `backspace`
106 /// The ::backspace signal is a
107 /// [keybinding signal][GtkBindingSignal]
108 /// which gets emitted when the user asks for it.
109 ///
110 /// The default bindings for this signal are
111 /// Backspace and Shift-Backspace.
112 ///
113 /// Action
114 ///
115 ///
116 /// #### `copy-clipboard`
117 /// The ::copy-clipboard signal is a
118 /// [keybinding signal][GtkBindingSignal]
119 /// which gets emitted to copy the selection to the clipboard.
120 ///
121 /// The default bindings for this signal are
122 /// Ctrl-c and Ctrl-Insert.
123 ///
124 /// Action
125 ///
126 ///
127 /// #### `cut-clipboard`
128 /// The ::cut-clipboard signal is a
129 /// [keybinding signal][GtkBindingSignal]
130 /// which gets emitted to cut the selection to the clipboard.
131 ///
132 /// The default bindings for this signal are
133 /// Ctrl-x and Shift-Delete.
134 ///
135 /// Action
136 ///
137 ///
138 /// #### `delete-from-cursor`
139 /// The ::delete-from-cursor signal is a
140 /// [keybinding signal][GtkBindingSignal]
141 /// which gets emitted when the user initiates a text deletion.
142 ///
143 /// If the `type_` is [`DeleteType::Chars`][crate::DeleteType::Chars], GTK+ deletes the selection
144 /// if there is one, otherwise it deletes the requested number
145 /// of characters.
146 ///
147 /// The default bindings for this signal are
148 /// Delete for deleting a character and Ctrl-Delete for
149 /// deleting a word.
150 ///
151 /// Action
152 ///
153 ///
154 /// #### `icon-press`
155 /// The ::icon-press signal is emitted when an activatable icon
156 /// is clicked.
157 ///
158 ///
159 ///
160 ///
161 /// #### `icon-release`
162 /// The ::icon-release signal is emitted on the button release from a
163 /// mouse click over an activatable icon.
164 ///
165 ///
166 ///
167 ///
168 /// #### `insert-at-cursor`
169 /// The ::insert-at-cursor signal is a
170 /// [keybinding signal][GtkBindingSignal]
171 /// which gets emitted when the user initiates the insertion of a
172 /// fixed string at the cursor.
173 ///
174 /// This signal has no default bindings.
175 ///
176 /// Action
177 ///
178 ///
179 /// #### `insert-emoji`
180 /// The ::insert-emoji signal is a
181 /// [keybinding signal][GtkBindingSignal]
182 /// which gets emitted to present the Emoji chooser for the `entry`.
183 ///
184 /// The default bindings for this signal are Ctrl-. and Ctrl-;
185 ///
186 /// Action
187 ///
188 ///
189 /// #### `move-cursor`
190 /// The ::move-cursor signal is a
191 /// [keybinding signal][GtkBindingSignal]
192 /// which gets emitted when the user initiates a cursor movement.
193 /// If the cursor is not visible in `entry`, this signal causes
194 /// the viewport to be moved instead.
195 ///
196 /// Applications should not connect to it, but may emit it with
197 /// `g_signal_emit_by_name()` if they need to control the cursor
198 /// programmatically.
199 ///
200 /// The default bindings for this signal come in two variants,
201 /// the variant with the Shift modifier extends the selection,
202 /// the variant without the Shift modifer does not.
203 /// There are too many key combinations to list them all here.
204 /// - Arrow keys move by individual characters/lines
205 /// - Ctrl-arrow key combinations move by words/paragraphs
206 /// - Home/End keys move to the ends of the buffer
207 ///
208 /// Action
209 ///
210 ///
211 /// #### `paste-clipboard`
212 /// The ::paste-clipboard signal is a
213 /// [keybinding signal][GtkBindingSignal]
214 /// which gets emitted to paste the contents of the clipboard
215 /// into the text view.
216 ///
217 /// The default bindings for this signal are
218 /// Ctrl-v and Shift-Insert.
219 ///
220 /// Action
221 ///
222 ///
223 /// #### `populate-popup`
224 /// The ::populate-popup signal gets emitted before showing the
225 /// context menu of the entry.
226 ///
227 /// If you need to add items to the context menu, connect
228 /// to this signal and append your items to the `widget`, which
229 /// will be a [`Menu`][crate::Menu] in this case.
230 ///
231 /// If [`populate-all`][struct@crate::Entry#populate-all] is [`true`], this signal will
232 /// also be emitted to populate touch popups. In this case,
233 /// `widget` will be a different container, e.g. a [`Toolbar`][crate::Toolbar].
234 /// The signal handler should not make assumptions about the
235 /// type of `widget`.
236 ///
237 ///
238 ///
239 ///
240 /// #### `preedit-changed`
241 /// If an input method is used, the typed text will not immediately
242 /// be committed to the buffer. So if you are interested in the text,
243 /// connect to this signal.
244 ///
245 /// Action
246 ///
247 ///
248 /// #### `toggle-overwrite`
249 /// The ::toggle-overwrite signal is a
250 /// [keybinding signal][GtkBindingSignal]
251 /// which gets emitted to toggle the overwrite mode of the entry.
252 ///
253 /// The default bindings for this signal is Insert.
254 ///
255 /// Action
256 /// </details>
257 /// <details><summary><h4>Widget</h4></summary>
258 ///
259 ///
260 /// #### `accel-closures-changed`
261 ///
262 ///
263 ///
264 /// #### `button-press-event`
265 /// The ::button-press-event signal will be emitted when a button
266 /// (typically from a mouse) is pressed.
267 ///
268 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the
269 /// widget needs to enable the [`gdk::EventMask::BUTTON_PRESS_MASK`][crate::gdk::EventMask::BUTTON_PRESS_MASK] mask.
270 ///
271 /// This signal will be sent to the grab widget if there is one.
272 ///
273 ///
274 ///
275 ///
276 /// #### `button-release-event`
277 /// The ::button-release-event signal will be emitted when a button
278 /// (typically from a mouse) is released.
279 ///
280 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the
281 /// widget needs to enable the [`gdk::EventMask::BUTTON_RELEASE_MASK`][crate::gdk::EventMask::BUTTON_RELEASE_MASK] mask.
282 ///
283 /// This signal will be sent to the grab widget if there is one.
284 ///
285 ///
286 ///
287 ///
288 /// #### `can-activate-accel`
289 /// Determines whether an accelerator that activates the signal
290 /// identified by `signal_id` can currently be activated.
291 /// This signal is present to allow applications and derived
292 /// widgets to override the default [`Widget`][crate::Widget] handling
293 /// for determining whether an accelerator can be activated.
294 ///
295 ///
296 ///
297 ///
298 /// #### `child-notify`
299 /// The ::child-notify signal is emitted for each
300 /// [child property][child-properties] that has
301 /// changed on an object. The signal's detail holds the property name.
302 ///
303 /// Detailed
304 ///
305 ///
306 /// #### `composited-changed`
307 /// The ::composited-changed signal is emitted when the composited
308 /// status of `widgets` screen changes.
309 /// See [`Screen::is_composited()`][crate::gdk::Screen::is_composited()].
310 ///
311 /// Action
312 ///
313 ///
314 /// #### `configure-event`
315 /// The ::configure-event signal will be emitted when the size, position or
316 /// stacking of the `widget`'s window has changed.
317 ///
318 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
319 /// to enable the [`gdk::EventMask::STRUCTURE_MASK`][crate::gdk::EventMask::STRUCTURE_MASK] mask. GDK will enable this mask
320 /// automatically for all new windows.
321 ///
322 ///
323 ///
324 ///
325 /// #### `damage-event`
326 /// Emitted when a redirected window belonging to `widget` gets drawn into.
327 /// The region/area members of the event shows what area of the redirected
328 /// drawable was drawn into.
329 ///
330 ///
331 ///
332 ///
333 /// #### `delete-event`
334 /// The ::delete-event signal is emitted if a user requests that
335 /// a toplevel window is closed. The default handler for this signal
336 /// destroys the window. Connecting [`WidgetExtManual::hide_on_delete()`][crate::prelude::WidgetExtManual::hide_on_delete()] to
337 /// this signal will cause the window to be hidden instead, so that
338 /// it can later be shown again without reconstructing it.
339 ///
340 ///
341 ///
342 ///
343 /// #### `destroy`
344 /// Signals that all holders of a reference to the widget should release
345 /// the reference that they hold. May result in finalization of the widget
346 /// if all references are released.
347 ///
348 /// This signal is not suitable for saving widget state.
349 ///
350 ///
351 ///
352 ///
353 /// #### `destroy-event`
354 /// The ::destroy-event signal is emitted when a [`gdk::Window`][crate::gdk::Window] is destroyed.
355 /// You rarely get this signal, because most widgets disconnect themselves
356 /// from their window before they destroy it, so no widget owns the
357 /// window at destroy time.
358 ///
359 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
360 /// to enable the [`gdk::EventMask::STRUCTURE_MASK`][crate::gdk::EventMask::STRUCTURE_MASK] mask. GDK will enable this mask
361 /// automatically for all new windows.
362 ///
363 ///
364 ///
365 ///
366 /// #### `direction-changed`
367 /// The ::direction-changed signal is emitted when the text direction
368 /// of a widget changes.
369 ///
370 ///
371 ///
372 ///
373 /// #### `drag-begin`
374 /// The ::drag-begin signal is emitted on the drag source when a drag is
375 /// started. A typical reason to connect to this signal is to set up a
376 /// custom drag icon with e.g. [`WidgetExt::drag_source_set_icon_pixbuf()`][crate::prelude::WidgetExt::drag_source_set_icon_pixbuf()].
377 ///
378 /// Note that some widgets set up a drag icon in the default handler of
379 /// this signal, so you may have to use `g_signal_connect_after()` to
380 /// override what the default handler did.
381 ///
382 ///
383 ///
384 ///
385 /// #### `drag-data-delete`
386 /// The ::drag-data-delete signal is emitted on the drag source when a drag
387 /// with the action [`gdk::DragAction::MOVE`][crate::gdk::DragAction::MOVE] is successfully completed. The signal
388 /// handler is responsible for deleting the data that has been dropped. What
389 /// "delete" means depends on the context of the drag operation.
390 ///
391 ///
392 ///
393 ///
394 /// #### `drag-data-get`
395 /// The ::drag-data-get signal is emitted on the drag source when the drop
396 /// site requests the data which is dragged. It is the responsibility of
397 /// the signal handler to fill `data` with the data in the format which
398 /// is indicated by `info`. See [`SelectionData::set()`][crate::SelectionData::set()] and
399 /// [`SelectionData::set_text()`][crate::SelectionData::set_text()].
400 ///
401 ///
402 ///
403 ///
404 /// #### `drag-data-received`
405 /// The ::drag-data-received signal is emitted on the drop site when the
406 /// dragged data has been received. If the data was received in order to
407 /// determine whether the drop will be accepted, the handler is expected
408 /// to call `gdk_drag_status()` and not finish the drag.
409 /// If the data was received in response to a [`drag-drop`][struct@crate::Widget#drag-drop] signal
410 /// (and this is the last target to be received), the handler for this
411 /// signal is expected to process the received data and then call
412 /// `gtk_drag_finish()`, setting the `success` parameter depending on
413 /// whether the data was processed successfully.
414 ///
415 /// Applications must create some means to determine why the signal was emitted
416 /// and therefore whether to call `gdk_drag_status()` or `gtk_drag_finish()`.
417 ///
418 /// The handler may inspect the selected action with
419 /// [`DragContext::selected_action()`][crate::gdk::DragContext::selected_action()] before calling
420 /// `gtk_drag_finish()`, e.g. to implement [`gdk::DragAction::ASK`][crate::gdk::DragAction::ASK] as
421 /// shown in the following example:
422 ///
423 ///
424 /// **⚠️ The following code is in C ⚠️**
425 ///
426 /// ```C
427 /// void
428 /// drag_data_received (GtkWidget *widget,
429 /// GdkDragContext *context,
430 /// gint x,
431 /// gint y,
432 /// GtkSelectionData *data,
433 /// guint info,
434 /// guint time)
435 /// {
436 /// if ((data->length >= 0) && (data->format == 8))
437 /// {
438 /// GdkDragAction action;
439 ///
440 /// // handle data here
441 ///
442 /// action = gdk_drag_context_get_selected_action (context);
443 /// if (action == GDK_ACTION_ASK)
444 /// {
445 /// GtkWidget *dialog;
446 /// gint response;
447 ///
448 /// dialog = gtk_message_dialog_new (NULL,
449 /// GTK_DIALOG_MODAL |
450 /// GTK_DIALOG_DESTROY_WITH_PARENT,
451 /// GTK_MESSAGE_INFO,
452 /// GTK_BUTTONS_YES_NO,
453 /// "Move the data ?\n");
454 /// response = gtk_dialog_run (GTK_DIALOG (dialog));
455 /// gtk_widget_destroy (dialog);
456 ///
457 /// if (response == GTK_RESPONSE_YES)
458 /// action = GDK_ACTION_MOVE;
459 /// else
460 /// action = GDK_ACTION_COPY;
461 /// }
462 ///
463 /// gtk_drag_finish (context, TRUE, action == GDK_ACTION_MOVE, time);
464 /// }
465 /// else
466 /// gtk_drag_finish (context, FALSE, FALSE, time);
467 /// }
468 /// ```
469 ///
470 ///
471 ///
472 ///
473 /// #### `drag-drop`
474 /// The ::drag-drop signal is emitted on the drop site when the user drops
475 /// the data onto the widget. The signal handler must determine whether
476 /// the cursor position is in a drop zone or not. If it is not in a drop
477 /// zone, it returns [`false`] and no further processing is necessary.
478 /// Otherwise, the handler returns [`true`]. In this case, the handler must
479 /// ensure that `gtk_drag_finish()` is called to let the source know that
480 /// the drop is done. The call to `gtk_drag_finish()` can be done either
481 /// directly or in a [`drag-data-received`][struct@crate::Widget#drag-data-received] handler which gets
482 /// triggered by calling [`WidgetExt::drag_get_data()`][crate::prelude::WidgetExt::drag_get_data()] to receive the data for one
483 /// or more of the supported targets.
484 ///
485 ///
486 ///
487 ///
488 /// #### `drag-end`
489 /// The ::drag-end signal is emitted on the drag source when a drag is
490 /// finished. A typical reason to connect to this signal is to undo
491 /// things done in [`drag-begin`][struct@crate::Widget#drag-begin].
492 ///
493 ///
494 ///
495 ///
496 /// #### `drag-failed`
497 /// The ::drag-failed signal is emitted on the drag source when a drag has
498 /// failed. The signal handler may hook custom code to handle a failed DnD
499 /// operation based on the type of error, it returns [`true`] is the failure has
500 /// been already handled (not showing the default "drag operation failed"
501 /// animation), otherwise it returns [`false`].
502 ///
503 ///
504 ///
505 ///
506 /// #### `drag-leave`
507 /// The ::drag-leave signal is emitted on the drop site when the cursor
508 /// leaves the widget. A typical reason to connect to this signal is to
509 /// undo things done in [`drag-motion`][struct@crate::Widget#drag-motion], e.g. undo highlighting
510 /// with [`WidgetExt::drag_unhighlight()`][crate::prelude::WidgetExt::drag_unhighlight()].
511 ///
512 ///
513 /// Likewise, the [`drag-leave`][struct@crate::Widget#drag-leave] signal is also emitted before the
514 /// ::drag-drop signal, for instance to allow cleaning up of a preview item
515 /// created in the [`drag-motion`][struct@crate::Widget#drag-motion] signal handler.
516 ///
517 ///
518 ///
519 ///
520 /// #### `drag-motion`
521 /// The ::drag-motion signal is emitted on the drop site when the user
522 /// moves the cursor over the widget during a drag. The signal handler
523 /// must determine whether the cursor position is in a drop zone or not.
524 /// If it is not in a drop zone, it returns [`false`] and no further processing
525 /// is necessary. Otherwise, the handler returns [`true`]. In this case, the
526 /// handler is responsible for providing the necessary information for
527 /// displaying feedback to the user, by calling `gdk_drag_status()`.
528 ///
529 /// If the decision whether the drop will be accepted or rejected can't be
530 /// made based solely on the cursor position and the type of the data, the
531 /// handler may inspect the dragged data by calling [`WidgetExt::drag_get_data()`][crate::prelude::WidgetExt::drag_get_data()] and
532 /// defer the `gdk_drag_status()` call to the [`drag-data-received`][struct@crate::Widget#drag-data-received]
533 /// handler. Note that you must pass [`DestDefaults::DROP`][crate::DestDefaults::DROP],
534 /// [`DestDefaults::MOTION`][crate::DestDefaults::MOTION] or [`DestDefaults::ALL`][crate::DestDefaults::ALL] to [`WidgetExtManual::drag_dest_set()`][crate::prelude::WidgetExtManual::drag_dest_set()]
535 /// when using the drag-motion signal that way.
536 ///
537 /// Also note that there is no drag-enter signal. The drag receiver has to
538 /// keep track of whether he has received any drag-motion signals since the
539 /// last [`drag-leave`][struct@crate::Widget#drag-leave] and if not, treat the drag-motion signal as
540 /// an "enter" signal. Upon an "enter", the handler will typically highlight
541 /// the drop site with [`WidgetExt::drag_highlight()`][crate::prelude::WidgetExt::drag_highlight()].
542 ///
543 ///
544 /// **⚠️ The following code is in C ⚠️**
545 ///
546 /// ```C
547 /// static void
548 /// drag_motion (GtkWidget *widget,
549 /// GdkDragContext *context,
550 /// gint x,
551 /// gint y,
552 /// guint time)
553 /// {
554 /// GdkAtom target;
555 ///
556 /// PrivateData *private_data = GET_PRIVATE_DATA (widget);
557 ///
558 /// if (!private_data->drag_highlight)
559 /// {
560 /// private_data->drag_highlight = 1;
561 /// gtk_drag_highlight (widget);
562 /// }
563 ///
564 /// target = gtk_drag_dest_find_target (widget, context, NULL);
565 /// if (target == GDK_NONE)
566 /// gdk_drag_status (context, 0, time);
567 /// else
568 /// {
569 /// private_data->pending_status
570 /// = gdk_drag_context_get_suggested_action (context);
571 /// gtk_drag_get_data (widget, context, target, time);
572 /// }
573 ///
574 /// return TRUE;
575 /// }
576 ///
577 /// static void
578 /// drag_data_received (GtkWidget *widget,
579 /// GdkDragContext *context,
580 /// gint x,
581 /// gint y,
582 /// GtkSelectionData *selection_data,
583 /// guint info,
584 /// guint time)
585 /// {
586 /// PrivateData *private_data = GET_PRIVATE_DATA (widget);
587 ///
588 /// if (private_data->suggested_action)
589 /// {
590 /// private_data->suggested_action = 0;
591 ///
592 /// // We are getting this data due to a request in drag_motion,
593 /// // rather than due to a request in drag_drop, so we are just
594 /// // supposed to call gdk_drag_status(), not actually paste in
595 /// // the data.
596 ///
597 /// str = gtk_selection_data_get_text (selection_data);
598 /// if (!data_is_acceptable (str))
599 /// gdk_drag_status (context, 0, time);
600 /// else
601 /// gdk_drag_status (context,
602 /// private_data->suggested_action,
603 /// time);
604 /// }
605 /// else
606 /// {
607 /// // accept the drop
608 /// }
609 /// }
610 /// ```
611 ///
612 ///
613 ///
614 ///
615 /// #### `draw`
616 /// This signal is emitted when a widget is supposed to render itself.
617 /// The `widget`'s top left corner must be painted at the origin of
618 /// the passed in context and be sized to the values returned by
619 /// [`WidgetExt::allocated_width()`][crate::prelude::WidgetExt::allocated_width()] and
620 /// [`WidgetExt::allocated_height()`][crate::prelude::WidgetExt::allocated_height()].
621 ///
622 /// Signal handlers connected to this signal can modify the cairo
623 /// context passed as `cr` in any way they like and don't need to
624 /// restore it. The signal emission takes care of calling `cairo_save()`
625 /// before and `cairo_restore()` after invoking the handler.
626 ///
627 /// The signal handler will get a `cr` with a clip region already set to the
628 /// widget's dirty region, i.e. to the area that needs repainting. Complicated
629 /// widgets that want to avoid redrawing themselves completely can get the full
630 /// extents of the clip region with `gdk_cairo_get_clip_rectangle()`, or they can
631 /// get a finer-grained representation of the dirty region with
632 /// `cairo_copy_clip_rectangle_list()`.
633 ///
634 ///
635 ///
636 ///
637 /// #### `enter-notify-event`
638 /// The ::enter-notify-event will be emitted when the pointer enters
639 /// the `widget`'s window.
640 ///
641 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
642 /// to enable the [`gdk::EventMask::ENTER_NOTIFY_MASK`][crate::gdk::EventMask::ENTER_NOTIFY_MASK] mask.
643 ///
644 /// This signal will be sent to the grab widget if there is one.
645 ///
646 ///
647 ///
648 ///
649 /// #### `event`
650 /// The GTK+ main loop will emit three signals for each GDK event delivered
651 /// to a widget: one generic ::event signal, another, more specific,
652 /// signal that matches the type of event delivered (e.g.
653 /// [`key-press-event`][struct@crate::Widget#key-press-event]) and finally a generic
654 /// [`event-after`][struct@crate::Widget#event-after] signal.
655 ///
656 ///
657 ///
658 ///
659 /// #### `event-after`
660 /// After the emission of the [`event`][struct@crate::Widget#event] signal and (optionally)
661 /// the second more specific signal, ::event-after will be emitted
662 /// regardless of the previous two signals handlers return values.
663 ///
664 ///
665 ///
666 ///
667 /// #### `focus`
668 ///
669 ///
670 ///
671 /// #### `focus-in-event`
672 /// The ::focus-in-event signal will be emitted when the keyboard focus
673 /// enters the `widget`'s window.
674 ///
675 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
676 /// to enable the [`gdk::EventMask::FOCUS_CHANGE_MASK`][crate::gdk::EventMask::FOCUS_CHANGE_MASK] mask.
677 ///
678 ///
679 ///
680 ///
681 /// #### `focus-out-event`
682 /// The ::focus-out-event signal will be emitted when the keyboard focus
683 /// leaves the `widget`'s window.
684 ///
685 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
686 /// to enable the [`gdk::EventMask::FOCUS_CHANGE_MASK`][crate::gdk::EventMask::FOCUS_CHANGE_MASK] mask.
687 ///
688 ///
689 ///
690 ///
691 /// #### `grab-broken-event`
692 /// Emitted when a pointer or keyboard grab on a window belonging
693 /// to `widget` gets broken.
694 ///
695 /// On X11, this happens when the grab window becomes unviewable
696 /// (i.e. it or one of its ancestors is unmapped), or if the same
697 /// application grabs the pointer or keyboard again.
698 ///
699 ///
700 ///
701 ///
702 /// #### `grab-focus`
703 /// Action
704 ///
705 ///
706 /// #### `grab-notify`
707 /// The ::grab-notify signal is emitted when a widget becomes
708 /// shadowed by a GTK+ grab (not a pointer or keyboard grab) on
709 /// another widget, or when it becomes unshadowed due to a grab
710 /// being removed.
711 ///
712 /// A widget is shadowed by a [`WidgetExt::grab_add()`][crate::prelude::WidgetExt::grab_add()] when the topmost
713 /// grab widget in the grab stack of its window group is not
714 /// its ancestor.
715 ///
716 ///
717 ///
718 ///
719 /// #### `hide`
720 /// The ::hide signal is emitted when `widget` is hidden, for example with
721 /// [`WidgetExt::hide()`][crate::prelude::WidgetExt::hide()].
722 ///
723 ///
724 ///
725 ///
726 /// #### `hierarchy-changed`
727 /// The ::hierarchy-changed signal is emitted when the
728 /// anchored state of a widget changes. A widget is
729 /// “anchored” when its toplevel
730 /// ancestor is a [`Window`][crate::Window]. This signal is emitted when
731 /// a widget changes from un-anchored to anchored or vice-versa.
732 ///
733 ///
734 ///
735 ///
736 /// #### `key-press-event`
737 /// The ::key-press-event signal is emitted when a key is pressed. The signal
738 /// emission will reoccur at the key-repeat rate when the key is kept pressed.
739 ///
740 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
741 /// to enable the [`gdk::EventMask::KEY_PRESS_MASK`][crate::gdk::EventMask::KEY_PRESS_MASK] mask.
742 ///
743 /// This signal will be sent to the grab widget if there is one.
744 ///
745 ///
746 ///
747 ///
748 /// #### `key-release-event`
749 /// The ::key-release-event signal is emitted when a key is released.
750 ///
751 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
752 /// to enable the [`gdk::EventMask::KEY_RELEASE_MASK`][crate::gdk::EventMask::KEY_RELEASE_MASK] mask.
753 ///
754 /// This signal will be sent to the grab widget if there is one.
755 ///
756 ///
757 ///
758 ///
759 /// #### `keynav-failed`
760 /// Gets emitted if keyboard navigation fails.
761 /// See [`WidgetExt::keynav_failed()`][crate::prelude::WidgetExt::keynav_failed()] for details.
762 ///
763 ///
764 ///
765 ///
766 /// #### `leave-notify-event`
767 /// The ::leave-notify-event will be emitted when the pointer leaves
768 /// the `widget`'s window.
769 ///
770 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
771 /// to enable the [`gdk::EventMask::LEAVE_NOTIFY_MASK`][crate::gdk::EventMask::LEAVE_NOTIFY_MASK] mask.
772 ///
773 /// This signal will be sent to the grab widget if there is one.
774 ///
775 ///
776 ///
777 ///
778 /// #### `map`
779 /// The ::map signal is emitted when `widget` is going to be mapped, that is
780 /// when the widget is visible (which is controlled with
781 /// [`WidgetExt::set_visible()`][crate::prelude::WidgetExt::set_visible()]) and all its parents up to the toplevel widget
782 /// are also visible. Once the map has occurred, [`map-event`][struct@crate::Widget#map-event] will
783 /// be emitted.
784 ///
785 /// The ::map signal can be used to determine whether a widget will be drawn,
786 /// for instance it can resume an animation that was stopped during the
787 /// emission of [`unmap`][struct@crate::Widget#unmap].
788 ///
789 ///
790 ///
791 ///
792 /// #### `map-event`
793 /// The ::map-event signal will be emitted when the `widget`'s window is
794 /// mapped. A window is mapped when it becomes visible on the screen.
795 ///
796 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
797 /// to enable the [`gdk::EventMask::STRUCTURE_MASK`][crate::gdk::EventMask::STRUCTURE_MASK] mask. GDK will enable this mask
798 /// automatically for all new windows.
799 ///
800 ///
801 ///
802 ///
803 /// #### `mnemonic-activate`
804 /// The default handler for this signal activates `widget` if `group_cycling`
805 /// is [`false`], or just makes `widget` grab focus if `group_cycling` is [`true`].
806 ///
807 ///
808 ///
809 ///
810 /// #### `motion-notify-event`
811 /// The ::motion-notify-event signal is emitted when the pointer moves
812 /// over the widget's [`gdk::Window`][crate::gdk::Window].
813 ///
814 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget
815 /// needs to enable the [`gdk::EventMask::POINTER_MOTION_MASK`][crate::gdk::EventMask::POINTER_MOTION_MASK] mask.
816 ///
817 /// This signal will be sent to the grab widget if there is one.
818 ///
819 ///
820 ///
821 ///
822 /// #### `move-focus`
823 /// Action
824 ///
825 ///
826 /// #### `parent-set`
827 /// The ::parent-set signal is emitted when a new parent
828 /// has been set on a widget.
829 ///
830 ///
831 ///
832 ///
833 /// #### `popup-menu`
834 /// This signal gets emitted whenever a widget should pop up a context
835 /// menu. This usually happens through the standard key binding mechanism;
836 /// by pressing a certain key while a widget is focused, the user can cause
837 /// the widget to pop up a menu. For example, the [`Entry`][crate::Entry] widget creates
838 /// a menu with clipboard commands. See the
839 /// [Popup Menu Migration Checklist][checklist-popup-menu]
840 /// for an example of how to use this signal.
841 ///
842 /// Action
843 ///
844 ///
845 /// #### `property-notify-event`
846 /// The ::property-notify-event signal will be emitted when a property on
847 /// the `widget`'s window has been changed or deleted.
848 ///
849 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
850 /// to enable the [`gdk::EventMask::PROPERTY_CHANGE_MASK`][crate::gdk::EventMask::PROPERTY_CHANGE_MASK] mask.
851 ///
852 ///
853 ///
854 ///
855 /// #### `proximity-in-event`
856 /// To receive this signal the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
857 /// to enable the [`gdk::EventMask::PROXIMITY_IN_MASK`][crate::gdk::EventMask::PROXIMITY_IN_MASK] mask.
858 ///
859 /// This signal will be sent to the grab widget if there is one.
860 ///
861 ///
862 ///
863 ///
864 /// #### `proximity-out-event`
865 /// To receive this signal the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
866 /// to enable the [`gdk::EventMask::PROXIMITY_OUT_MASK`][crate::gdk::EventMask::PROXIMITY_OUT_MASK] mask.
867 ///
868 /// This signal will be sent to the grab widget if there is one.
869 ///
870 ///
871 ///
872 ///
873 /// #### `query-tooltip`
874 /// Emitted when [`has-tooltip`][struct@crate::Widget#has-tooltip] is [`true`] and the hover timeout
875 /// has expired with the cursor hovering "above" `widget`; or emitted when `widget` got
876 /// focus in keyboard mode.
877 ///
878 /// Using the given coordinates, the signal handler should determine
879 /// whether a tooltip should be shown for `widget`. If this is the case
880 /// [`true`] should be returned, [`false`] otherwise. Note that if
881 /// `keyboard_mode` is [`true`], the values of `x` and `y` are undefined and
882 /// should not be used.
883 ///
884 /// The signal handler is free to manipulate `tooltip` with the therefore
885 /// destined function calls.
886 ///
887 ///
888 ///
889 ///
890 /// #### `realize`
891 /// The ::realize signal is emitted when `widget` is associated with a
892 /// [`gdk::Window`][crate::gdk::Window], which means that [`WidgetExt::realize()`][crate::prelude::WidgetExt::realize()] has been called or the
893 /// widget has been mapped (that is, it is going to be drawn).
894 ///
895 ///
896 ///
897 ///
898 /// #### `screen-changed`
899 /// The ::screen-changed signal gets emitted when the
900 /// screen of a widget has changed.
901 ///
902 ///
903 ///
904 ///
905 /// #### `scroll-event`
906 /// The ::scroll-event signal is emitted when a button in the 4 to 7
907 /// range is pressed. Wheel mice are usually configured to generate
908 /// button press events for buttons 4 and 5 when the wheel is turned.
909 ///
910 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
911 /// to enable the [`gdk::EventMask::SCROLL_MASK`][crate::gdk::EventMask::SCROLL_MASK] mask.
912 ///
913 /// This signal will be sent to the grab widget if there is one.
914 ///
915 ///
916 ///
917 ///
918 /// #### `selection-clear-event`
919 /// The ::selection-clear-event signal will be emitted when the
920 /// the `widget`'s window has lost ownership of a selection.
921 ///
922 ///
923 ///
924 ///
925 /// #### `selection-get`
926 ///
927 ///
928 ///
929 /// #### `selection-notify-event`
930 ///
931 ///
932 ///
933 /// #### `selection-received`
934 ///
935 ///
936 ///
937 /// #### `selection-request-event`
938 /// The ::selection-request-event signal will be emitted when
939 /// another client requests ownership of the selection owned by
940 /// the `widget`'s window.
941 ///
942 ///
943 ///
944 ///
945 /// #### `show`
946 /// The ::show signal is emitted when `widget` is shown, for example with
947 /// [`WidgetExt::show()`][crate::prelude::WidgetExt::show()].
948 ///
949 ///
950 ///
951 ///
952 /// #### `show-help`
953 /// Action
954 ///
955 ///
956 /// #### `size-allocate`
957 ///
958 ///
959 ///
960 /// #### `state-changed`
961 /// The ::state-changed signal is emitted when the widget state changes.
962 /// See `gtk_widget_get_state()`.
963 ///
964 ///
965 ///
966 ///
967 /// #### `state-flags-changed`
968 /// The ::state-flags-changed signal is emitted when the widget state
969 /// changes, see [`WidgetExt::state_flags()`][crate::prelude::WidgetExt::state_flags()].
970 ///
971 ///
972 ///
973 ///
974 /// #### `style-set`
975 /// The ::style-set signal is emitted when a new style has been set
976 /// on a widget. Note that style-modifying functions like
977 /// `gtk_widget_modify_base()` also cause this signal to be emitted.
978 ///
979 /// Note that this signal is emitted for changes to the deprecated
980 /// `GtkStyle`. To track changes to the [`StyleContext`][crate::StyleContext] associated
981 /// with a widget, use the [`style-updated`][struct@crate::Widget#style-updated] signal.
982 ///
983 ///
984 ///
985 ///
986 /// #### `style-updated`
987 /// The ::style-updated signal is a convenience signal that is emitted when the
988 /// [`changed`][struct@crate::StyleContext#changed] signal is emitted on the `widget`'s associated
989 /// [`StyleContext`][crate::StyleContext] as returned by [`WidgetExt::style_context()`][crate::prelude::WidgetExt::style_context()].
990 ///
991 /// Note that style-modifying functions like `gtk_widget_override_color()` also
992 /// cause this signal to be emitted.
993 ///
994 ///
995 ///
996 ///
997 /// #### `touch-event`
998 ///
999 ///
1000 ///
1001 /// #### `unmap`
1002 /// The ::unmap signal is emitted when `widget` is going to be unmapped, which
1003 /// means that either it or any of its parents up to the toplevel widget have
1004 /// been set as hidden.
1005 ///
1006 /// As ::unmap indicates that a widget will not be shown any longer, it can be
1007 /// used to, for example, stop an animation on the widget.
1008 ///
1009 ///
1010 ///
1011 ///
1012 /// #### `unmap-event`
1013 /// The ::unmap-event signal will be emitted when the `widget`'s window is
1014 /// unmapped. A window is unmapped when it becomes invisible on the screen.
1015 ///
1016 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
1017 /// to enable the [`gdk::EventMask::STRUCTURE_MASK`][crate::gdk::EventMask::STRUCTURE_MASK] mask. GDK will enable this mask
1018 /// automatically for all new windows.
1019 ///
1020 ///
1021 ///
1022 ///
1023 /// #### `unrealize`
1024 /// The ::unrealize signal is emitted when the [`gdk::Window`][crate::gdk::Window] associated with
1025 /// `widget` is destroyed, which means that [`WidgetExt::unrealize()`][crate::prelude::WidgetExt::unrealize()] has been
1026 /// called or the widget has been unmapped (that is, it is going to be
1027 /// hidden).
1028 ///
1029 ///
1030 ///
1031 ///
1032 /// #### `visibility-notify-event`
1033 /// The ::visibility-notify-event will be emitted when the `widget`'s
1034 /// window is obscured or unobscured.
1035 ///
1036 /// To receive this signal the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
1037 /// to enable the [`gdk::EventMask::VISIBILITY_NOTIFY_MASK`][crate::gdk::EventMask::VISIBILITY_NOTIFY_MASK] mask.
1038 ///
1039 ///
1040 ///
1041 ///
1042 /// #### `window-state-event`
1043 /// The ::window-state-event will be emitted when the state of the
1044 /// toplevel window associated to the `widget` changes.
1045 ///
1046 /// To receive this signal the [`gdk::Window`][crate::gdk::Window] associated to the widget
1047 /// needs to enable the [`gdk::EventMask::STRUCTURE_MASK`][crate::gdk::EventMask::STRUCTURE_MASK] mask. GDK will enable
1048 /// this mask automatically for all new windows.
1049 ///
1050 ///
1051 /// </details>
1052 /// <details><summary><h4>CellEditable</h4></summary>
1053 ///
1054 ///
1055 /// #### `editing-done`
1056 /// This signal is a sign for the cell renderer to update its
1057 /// value from the `cell_editable`.
1058 ///
1059 /// Implementations of [`CellEditable`][crate::CellEditable] are responsible for
1060 /// emitting this signal when they are done editing, e.g.
1061 /// [`Entry`][crate::Entry] emits this signal when the user presses Enter. Typical things to
1062 /// do in a handler for ::editing-done are to capture the edited value,
1063 /// disconnect the `cell_editable` from signals on the [`CellRenderer`][crate::CellRenderer], etc.
1064 ///
1065 /// [`CellEditableExt::editing_done()`][crate::prelude::CellEditableExt::editing_done()] is a convenience method
1066 /// for emitting [`editing-done`][struct@crate::CellEditable#editing-done].
1067 ///
1068 ///
1069 ///
1070 ///
1071 /// #### `remove-widget`
1072 /// This signal is meant to indicate that the cell is finished
1073 /// editing, and the `cell_editable` widget is being removed and may
1074 /// subsequently be destroyed.
1075 ///
1076 /// Implementations of [`CellEditable`][crate::CellEditable] are responsible for
1077 /// emitting this signal when they are done editing. It must
1078 /// be emitted after the [`editing-done`][struct@crate::CellEditable#editing-done] signal,
1079 /// to give the cell renderer a chance to update the cell's value
1080 /// before the widget is removed.
1081 ///
1082 /// [`CellEditableExt::remove_widget()`][crate::prelude::CellEditableExt::remove_widget()] is a convenience method
1083 /// for emitting [`remove-widget`][struct@crate::CellEditable#remove-widget].
1084 ///
1085 ///
1086 /// </details>
1087 /// <details><summary><h4>Editable</h4></summary>
1088 ///
1089 ///
1090 /// #### `changed`
1091 /// The ::changed signal is emitted at the end of a single
1092 /// user-visible operation on the contents of the [`Editable`][crate::Editable].
1093 ///
1094 /// E.g., a paste operation that replaces the contents of the
1095 /// selection will cause only one signal emission (even though it
1096 /// is implemented by first deleting the selection, then inserting
1097 /// the new content, and may cause multiple ::notify::text signals
1098 /// to be emitted).
1099 ///
1100 ///
1101 ///
1102 ///
1103 /// #### `delete-text`
1104 /// This signal is emitted when text is deleted from
1105 /// the widget by the user. The default handler for
1106 /// this signal will normally be responsible for deleting
1107 /// the text, so by connecting to this signal and then
1108 /// stopping the signal with `g_signal_stop_emission()`, it
1109 /// is possible to modify the range of deleted text, or
1110 /// prevent it from being deleted entirely. The `start_pos`
1111 /// and `end_pos` parameters are interpreted as for
1112 /// [`EditableExt::delete_text()`][crate::prelude::EditableExt::delete_text()].
1113 ///
1114 ///
1115 ///
1116 ///
1117 /// #### `insert-text`
1118 /// This signal is emitted when text is inserted into
1119 /// the widget by the user. The default handler for
1120 /// this signal will normally be responsible for inserting
1121 /// the text, so by connecting to this signal and then
1122 /// stopping the signal with `g_signal_stop_emission()`, it
1123 /// is possible to modify the inserted text, or prevent
1124 /// it from being inserted entirely.
1125 ///
1126 ///
1127 /// </details>
1128 ///
1129 /// # Implements
1130 ///
1131 /// [`SearchEntryExt`][trait@crate::prelude::SearchEntryExt], [`EntryExt`][trait@crate::prelude::EntryExt], [`WidgetExt`][trait@crate::prelude::WidgetExt], [`trait@glib::ObjectExt`], [`BuildableExt`][trait@crate::prelude::BuildableExt], [`CellEditableExt`][trait@crate::prelude::CellEditableExt], [`EditableExt`][trait@crate::prelude::EditableExt], [`EntryExtManual`][trait@crate::prelude::EntryExtManual], [`WidgetExtManual`][trait@crate::prelude::WidgetExtManual], [`BuildableExtManual`][trait@crate::prelude::BuildableExtManual], [`EditableSignals`][trait@crate::prelude::EditableSignals]
1132 #[doc(alias = "GtkSearchEntry")]
1133 pub struct SearchEntry(Object<ffi::GtkSearchEntry, ffi::GtkSearchEntryClass>) @extends Entry, Widget, @implements Buildable, CellEditable, Editable;
1134
1135 match fn {
1136 type_ => || ffi::gtk_search_entry_get_type(),
1137 }
1138}
1139
1140impl SearchEntry {
1141 pub const NONE: Option<&'static SearchEntry> = None;
1142
1143 /// Creates a [`SearchEntry`][crate::SearchEntry], with a find icon when the search field is
1144 /// empty, and a clear icon when it isn't.
1145 ///
1146 /// # Returns
1147 ///
1148 /// a new [`SearchEntry`][crate::SearchEntry]
1149 #[doc(alias = "gtk_search_entry_new")]
1150 pub fn new() -> SearchEntry {
1151 assert_initialized_main_thread!();
1152 unsafe { Widget::from_glib_none(ffi::gtk_search_entry_new()).unsafe_cast() }
1153 }
1154
1155 // rustdoc-stripper-ignore-next
1156 /// Creates a new builder-pattern struct instance to construct [`SearchEntry`] objects.
1157 ///
1158 /// This method returns an instance of [`SearchEntryBuilder`](crate::builders::SearchEntryBuilder) which can be used to create [`SearchEntry`] objects.
1159 pub fn builder() -> SearchEntryBuilder {
1160 SearchEntryBuilder::new()
1161 }
1162}
1163
1164impl Default for SearchEntry {
1165 fn default() -> Self {
1166 Self::new()
1167 }
1168}
1169
1170// rustdoc-stripper-ignore-next
1171/// A [builder-pattern] type to construct [`SearchEntry`] objects.
1172///
1173/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
1174#[must_use = "The builder must be built to be used"]
1175pub struct SearchEntryBuilder {
1176 builder: glib::object::ObjectBuilder<'static, SearchEntry>,
1177}
1178
1179impl SearchEntryBuilder {
1180 fn new() -> Self {
1181 Self {
1182 builder: glib::object::Object::builder(),
1183 }
1184 }
1185
1186 pub fn activates_default(self, activates_default: bool) -> Self {
1187 Self {
1188 builder: self
1189 .builder
1190 .property("activates-default", activates_default),
1191 }
1192 }
1193
1194 /// A list of Pango attributes to apply to the text of the entry.
1195 ///
1196 /// This is mainly useful to change the size or weight of the text.
1197 ///
1198 /// The `PangoAttribute`'s `start_index` and `end_index` must refer to the
1199 /// [`EntryBuffer`][crate::EntryBuffer] text, i.e. without the preedit string.
1200 pub fn attributes(self, attributes: &pango::AttrList) -> Self {
1201 Self {
1202 builder: self.builder.property("attributes", attributes.clone()),
1203 }
1204 }
1205
1206 pub fn buffer(self, buffer: &impl IsA<EntryBuffer>) -> Self {
1207 Self {
1208 builder: self.builder.property("buffer", buffer.clone().upcast()),
1209 }
1210 }
1211
1212 /// Whether password entries will show a warning when Caps Lock is on.
1213 ///
1214 /// Note that the warning is shown using a secondary icon, and thus
1215 /// does not work if you are using the secondary icon position for some
1216 /// other purpose.
1217 pub fn caps_lock_warning(self, caps_lock_warning: bool) -> Self {
1218 Self {
1219 builder: self
1220 .builder
1221 .property("caps-lock-warning", caps_lock_warning),
1222 }
1223 }
1224
1225 /// The auxiliary completion object to use with the entry.
1226 pub fn completion(self, completion: &impl IsA<EntryCompletion>) -> Self {
1227 Self {
1228 builder: self
1229 .builder
1230 .property("completion", completion.clone().upcast()),
1231 }
1232 }
1233
1234 pub fn editable(self, editable: bool) -> Self {
1235 Self {
1236 builder: self.builder.property("editable", editable),
1237 }
1238 }
1239
1240 pub fn enable_emoji_completion(self, enable_emoji_completion: bool) -> Self {
1241 Self {
1242 builder: self
1243 .builder
1244 .property("enable-emoji-completion", enable_emoji_completion),
1245 }
1246 }
1247
1248 pub fn has_frame(self, has_frame: bool) -> Self {
1249 Self {
1250 builder: self.builder.property("has-frame", has_frame),
1251 }
1252 }
1253
1254 /// Which IM (input method) module should be used for this entry.
1255 /// See [`IMContext`][crate::IMContext].
1256 ///
1257 /// Setting this to a non-[`None`] value overrides the
1258 /// system-wide IM module setting. See the GtkSettings
1259 /// [`gtk-im-module`][struct@crate::Settings#gtk-im-module] property.
1260 pub fn im_module(self, im_module: impl Into<glib::GString>) -> Self {
1261 Self {
1262 builder: self.builder.property("im-module", im_module.into()),
1263 }
1264 }
1265
1266 /// Additional hints (beyond [`input-purpose`][struct@crate::Entry#input-purpose]) that
1267 /// allow input methods to fine-tune their behaviour.
1268 pub fn input_hints(self, input_hints: InputHints) -> Self {
1269 Self {
1270 builder: self.builder.property("input-hints", input_hints),
1271 }
1272 }
1273
1274 /// The purpose of this text field.
1275 ///
1276 /// This property can be used by on-screen keyboards and other input
1277 /// methods to adjust their behaviour.
1278 ///
1279 /// Note that setting the purpose to [`InputPurpose::Password`][crate::InputPurpose::Password] or
1280 /// [`InputPurpose::Pin`][crate::InputPurpose::Pin] is independent from setting
1281 /// [`visibility`][struct@crate::Entry#visibility].
1282 pub fn input_purpose(self, input_purpose: InputPurpose) -> Self {
1283 Self {
1284 builder: self.builder.property("input-purpose", input_purpose),
1285 }
1286 }
1287
1288 /// The invisible character is used when masking entry contents (in
1289 /// \"password mode\")"). When it is not explicitly set with the
1290 /// [`invisible-char`][struct@crate::Entry#invisible-char] property, GTK+ determines the character
1291 /// to use from a list of possible candidates, depending on availability
1292 /// in the current font.
1293 ///
1294 /// This style property allows the theme to prepend a character
1295 /// to the list of candidates.
1296 pub fn invisible_char(self, invisible_char: u32) -> Self {
1297 Self {
1298 builder: self.builder.property("invisible-char", invisible_char),
1299 }
1300 }
1301
1302 /// Whether the invisible char has been set for the [`Entry`][crate::Entry].
1303 pub fn invisible_char_set(self, invisible_char_set: bool) -> Self {
1304 Self {
1305 builder: self
1306 .builder
1307 .property("invisible-char-set", invisible_char_set),
1308 }
1309 }
1310
1311 pub fn max_length(self, max_length: i32) -> Self {
1312 Self {
1313 builder: self.builder.property("max-length", max_length),
1314 }
1315 }
1316
1317 /// The desired maximum width of the entry, in characters.
1318 /// If this property is set to -1, the width will be calculated
1319 /// automatically.
1320 pub fn max_width_chars(self, max_width_chars: i32) -> Self {
1321 Self {
1322 builder: self.builder.property("max-width-chars", max_width_chars),
1323 }
1324 }
1325
1326 /// If text is overwritten when typing in the [`Entry`][crate::Entry].
1327 pub fn overwrite_mode(self, overwrite_mode: bool) -> Self {
1328 Self {
1329 builder: self.builder.property("overwrite-mode", overwrite_mode),
1330 }
1331 }
1332
1333 /// The text that will be displayed in the [`Entry`][crate::Entry] when it is empty
1334 /// and unfocused.
1335 pub fn placeholder_text(self, placeholder_text: impl Into<glib::GString>) -> Self {
1336 Self {
1337 builder: self
1338 .builder
1339 .property("placeholder-text", placeholder_text.into()),
1340 }
1341 }
1342
1343 /// If :populate-all is [`true`], the [`populate-popup`][struct@crate::Entry#populate-popup]
1344 /// signal is also emitted for touch popups.
1345 pub fn populate_all(self, populate_all: bool) -> Self {
1346 Self {
1347 builder: self.builder.property("populate-all", populate_all),
1348 }
1349 }
1350
1351 /// Whether the primary icon is activatable.
1352 ///
1353 /// GTK+ emits the [`icon-press`][struct@crate::Entry#icon-press] and [`icon-release`][struct@crate::Entry#icon-release]
1354 /// signals only on sensitive, activatable icons.
1355 ///
1356 /// Sensitive, but non-activatable icons can be used for purely
1357 /// informational purposes.
1358 pub fn primary_icon_activatable(self, primary_icon_activatable: bool) -> Self {
1359 Self {
1360 builder: self
1361 .builder
1362 .property("primary-icon-activatable", primary_icon_activatable),
1363 }
1364 }
1365
1366 /// The [`gio::Icon`][crate::gio::Icon] to use for the primary icon for the entry.
1367 pub fn primary_icon_gicon(self, primary_icon_gicon: &impl IsA<gio::Icon>) -> Self {
1368 Self {
1369 builder: self
1370 .builder
1371 .property("primary-icon-gicon", primary_icon_gicon.clone().upcast()),
1372 }
1373 }
1374
1375 /// The icon name to use for the primary icon for the entry.
1376 pub fn primary_icon_name(self, primary_icon_name: impl Into<glib::GString>) -> Self {
1377 Self {
1378 builder: self
1379 .builder
1380 .property("primary-icon-name", primary_icon_name.into()),
1381 }
1382 }
1383
1384 /// A pixbuf to use as the primary icon for the entry.
1385 pub fn primary_icon_pixbuf(self, primary_icon_pixbuf: &gdk_pixbuf::Pixbuf) -> Self {
1386 Self {
1387 builder: self
1388 .builder
1389 .property("primary-icon-pixbuf", primary_icon_pixbuf.clone()),
1390 }
1391 }
1392
1393 /// Whether the primary icon is sensitive.
1394 ///
1395 /// An insensitive icon appears grayed out. GTK+ does not emit the
1396 /// [`icon-press`][struct@crate::Entry#icon-press] and [`icon-release`][struct@crate::Entry#icon-release] signals and
1397 /// does not allow DND from insensitive icons.
1398 ///
1399 /// An icon should be set insensitive if the action that would trigger
1400 /// when clicked is currently not available.
1401 pub fn primary_icon_sensitive(self, primary_icon_sensitive: bool) -> Self {
1402 Self {
1403 builder: self
1404 .builder
1405 .property("primary-icon-sensitive", primary_icon_sensitive),
1406 }
1407 }
1408
1409 /// The contents of the tooltip on the primary icon, which is marked up
1410 /// with the [Pango text markup language][PangoMarkupFormat].
1411 ///
1412 /// Also see [`EntryExt::set_icon_tooltip_markup()`][crate::prelude::EntryExt::set_icon_tooltip_markup()].
1413 pub fn primary_icon_tooltip_markup(
1414 self,
1415 primary_icon_tooltip_markup: impl Into<glib::GString>,
1416 ) -> Self {
1417 Self {
1418 builder: self.builder.property(
1419 "primary-icon-tooltip-markup",
1420 primary_icon_tooltip_markup.into(),
1421 ),
1422 }
1423 }
1424
1425 /// The contents of the tooltip on the primary icon.
1426 ///
1427 /// Also see [`EntryExt::set_icon_tooltip_text()`][crate::prelude::EntryExt::set_icon_tooltip_text()].
1428 pub fn primary_icon_tooltip_text(
1429 self,
1430 primary_icon_tooltip_text: impl Into<glib::GString>,
1431 ) -> Self {
1432 Self {
1433 builder: self.builder.property(
1434 "primary-icon-tooltip-text",
1435 primary_icon_tooltip_text.into(),
1436 ),
1437 }
1438 }
1439
1440 /// The current fraction of the task that's been completed.
1441 pub fn progress_fraction(self, progress_fraction: f64) -> Self {
1442 Self {
1443 builder: self
1444 .builder
1445 .property("progress-fraction", progress_fraction),
1446 }
1447 }
1448
1449 /// The fraction of total entry width to move the progress
1450 /// bouncing block for each call to [`EntryExt::progress_pulse()`][crate::prelude::EntryExt::progress_pulse()].
1451 pub fn progress_pulse_step(self, progress_pulse_step: f64) -> Self {
1452 Self {
1453 builder: self
1454 .builder
1455 .property("progress-pulse-step", progress_pulse_step),
1456 }
1457 }
1458
1459 /// Whether the secondary icon is activatable.
1460 ///
1461 /// GTK+ emits the [`icon-press`][struct@crate::Entry#icon-press] and [`icon-release`][struct@crate::Entry#icon-release]
1462 /// signals only on sensitive, activatable icons.
1463 ///
1464 /// Sensitive, but non-activatable icons can be used for purely
1465 /// informational purposes.
1466 pub fn secondary_icon_activatable(self, secondary_icon_activatable: bool) -> Self {
1467 Self {
1468 builder: self
1469 .builder
1470 .property("secondary-icon-activatable", secondary_icon_activatable),
1471 }
1472 }
1473
1474 /// The [`gio::Icon`][crate::gio::Icon] to use for the secondary icon for the entry.
1475 pub fn secondary_icon_gicon(self, secondary_icon_gicon: &impl IsA<gio::Icon>) -> Self {
1476 Self {
1477 builder: self.builder.property(
1478 "secondary-icon-gicon",
1479 secondary_icon_gicon.clone().upcast(),
1480 ),
1481 }
1482 }
1483
1484 /// The icon name to use for the secondary icon for the entry.
1485 pub fn secondary_icon_name(self, secondary_icon_name: impl Into<glib::GString>) -> Self {
1486 Self {
1487 builder: self
1488 .builder
1489 .property("secondary-icon-name", secondary_icon_name.into()),
1490 }
1491 }
1492
1493 /// An pixbuf to use as the secondary icon for the entry.
1494 pub fn secondary_icon_pixbuf(self, secondary_icon_pixbuf: &gdk_pixbuf::Pixbuf) -> Self {
1495 Self {
1496 builder: self
1497 .builder
1498 .property("secondary-icon-pixbuf", secondary_icon_pixbuf.clone()),
1499 }
1500 }
1501
1502 /// Whether the secondary icon is sensitive.
1503 ///
1504 /// An insensitive icon appears grayed out. GTK+ does not emit the
1505 /// [`icon-press`][struct@crate::Entry#icon-press] and [`icon-release`][struct@crate::Entry#icon-release] signals and
1506 /// does not allow DND from insensitive icons.
1507 ///
1508 /// An icon should be set insensitive if the action that would trigger
1509 /// when clicked is currently not available.
1510 pub fn secondary_icon_sensitive(self, secondary_icon_sensitive: bool) -> Self {
1511 Self {
1512 builder: self
1513 .builder
1514 .property("secondary-icon-sensitive", secondary_icon_sensitive),
1515 }
1516 }
1517
1518 /// The contents of the tooltip on the secondary icon, which is marked up
1519 /// with the [Pango text markup language][PangoMarkupFormat].
1520 ///
1521 /// Also see [`EntryExt::set_icon_tooltip_markup()`][crate::prelude::EntryExt::set_icon_tooltip_markup()].
1522 pub fn secondary_icon_tooltip_markup(
1523 self,
1524 secondary_icon_tooltip_markup: impl Into<glib::GString>,
1525 ) -> Self {
1526 Self {
1527 builder: self.builder.property(
1528 "secondary-icon-tooltip-markup",
1529 secondary_icon_tooltip_markup.into(),
1530 ),
1531 }
1532 }
1533
1534 /// The contents of the tooltip on the secondary icon.
1535 ///
1536 /// Also see [`EntryExt::set_icon_tooltip_text()`][crate::prelude::EntryExt::set_icon_tooltip_text()].
1537 pub fn secondary_icon_tooltip_text(
1538 self,
1539 secondary_icon_tooltip_text: impl Into<glib::GString>,
1540 ) -> Self {
1541 Self {
1542 builder: self.builder.property(
1543 "secondary-icon-tooltip-text",
1544 secondary_icon_tooltip_text.into(),
1545 ),
1546 }
1547 }
1548
1549 pub fn show_emoji_icon(self, show_emoji_icon: bool) -> Self {
1550 Self {
1551 builder: self.builder.property("show-emoji-icon", show_emoji_icon),
1552 }
1553 }
1554
1555 pub fn tabs(self, tabs: &pango::TabArray) -> Self {
1556 Self {
1557 builder: self.builder.property("tabs", tabs),
1558 }
1559 }
1560
1561 pub fn text(self, text: impl Into<glib::GString>) -> Self {
1562 Self {
1563 builder: self.builder.property("text", text.into()),
1564 }
1565 }
1566
1567 /// When [`true`], pasted multi-line text is truncated to the first line.
1568 pub fn truncate_multiline(self, truncate_multiline: bool) -> Self {
1569 Self {
1570 builder: self
1571 .builder
1572 .property("truncate-multiline", truncate_multiline),
1573 }
1574 }
1575
1576 pub fn visibility(self, visibility: bool) -> Self {
1577 Self {
1578 builder: self.builder.property("visibility", visibility),
1579 }
1580 }
1581
1582 pub fn width_chars(self, width_chars: i32) -> Self {
1583 Self {
1584 builder: self.builder.property("width-chars", width_chars),
1585 }
1586 }
1587
1588 /// The horizontal alignment, from 0 (left) to 1 (right).
1589 /// Reversed for RTL layouts.
1590 pub fn xalign(self, xalign: f32) -> Self {
1591 Self {
1592 builder: self.builder.property("xalign", xalign),
1593 }
1594 }
1595
1596 pub fn app_paintable(self, app_paintable: bool) -> Self {
1597 Self {
1598 builder: self.builder.property("app-paintable", app_paintable),
1599 }
1600 }
1601
1602 pub fn can_default(self, can_default: bool) -> Self {
1603 Self {
1604 builder: self.builder.property("can-default", can_default),
1605 }
1606 }
1607
1608 pub fn can_focus(self, can_focus: bool) -> Self {
1609 Self {
1610 builder: self.builder.property("can-focus", can_focus),
1611 }
1612 }
1613
1614 pub fn events(self, events: gdk::EventMask) -> Self {
1615 Self {
1616 builder: self.builder.property("events", events),
1617 }
1618 }
1619
1620 /// Whether to expand in both directions. Setting this sets both [`hexpand`][struct@crate::Widget#hexpand] and [`vexpand`][struct@crate::Widget#vexpand]
1621 pub fn expand(self, expand: bool) -> Self {
1622 Self {
1623 builder: self.builder.property("expand", expand),
1624 }
1625 }
1626
1627 /// Whether the widget should grab focus when it is clicked with the mouse.
1628 ///
1629 /// This property is only relevant for widgets that can take focus.
1630 ///
1631 /// Before 3.20, several widgets (GtkButton, GtkFileChooserButton,
1632 /// GtkComboBox) implemented this property individually.
1633 pub fn focus_on_click(self, focus_on_click: bool) -> Self {
1634 Self {
1635 builder: self.builder.property("focus-on-click", focus_on_click),
1636 }
1637 }
1638
1639 /// How to distribute horizontal space if widget gets extra space, see [`Align`][crate::Align]
1640 pub fn halign(self, halign: Align) -> Self {
1641 Self {
1642 builder: self.builder.property("halign", halign),
1643 }
1644 }
1645
1646 pub fn has_default(self, has_default: bool) -> Self {
1647 Self {
1648 builder: self.builder.property("has-default", has_default),
1649 }
1650 }
1651
1652 pub fn has_focus(self, has_focus: bool) -> Self {
1653 Self {
1654 builder: self.builder.property("has-focus", has_focus),
1655 }
1656 }
1657
1658 /// Enables or disables the emission of [`query-tooltip`][struct@crate::Widget#query-tooltip] on `widget`.
1659 /// A value of [`true`] indicates that `widget` can have a tooltip, in this case
1660 /// the widget will be queried using [`query-tooltip`][struct@crate::Widget#query-tooltip] to determine
1661 /// whether it will provide a tooltip or not.
1662 ///
1663 /// Note that setting this property to [`true`] for the first time will change
1664 /// the event masks of the GdkWindows of this widget to include leave-notify
1665 /// and motion-notify events. This cannot and will not be undone when the
1666 /// property is set to [`false`] again.
1667 pub fn has_tooltip(self, has_tooltip: bool) -> Self {
1668 Self {
1669 builder: self.builder.property("has-tooltip", has_tooltip),
1670 }
1671 }
1672
1673 pub fn height_request(self, height_request: i32) -> Self {
1674 Self {
1675 builder: self.builder.property("height-request", height_request),
1676 }
1677 }
1678
1679 /// Whether to expand horizontally. See [`WidgetExt::set_hexpand()`][crate::prelude::WidgetExt::set_hexpand()].
1680 pub fn hexpand(self, hexpand: bool) -> Self {
1681 Self {
1682 builder: self.builder.property("hexpand", hexpand),
1683 }
1684 }
1685
1686 /// Whether to use the [`hexpand`][struct@crate::Widget#hexpand] property. See [`WidgetExt::is_hexpand_set()`][crate::prelude::WidgetExt::is_hexpand_set()].
1687 pub fn hexpand_set(self, hexpand_set: bool) -> Self {
1688 Self {
1689 builder: self.builder.property("hexpand-set", hexpand_set),
1690 }
1691 }
1692
1693 pub fn is_focus(self, is_focus: bool) -> Self {
1694 Self {
1695 builder: self.builder.property("is-focus", is_focus),
1696 }
1697 }
1698
1699 /// Sets all four sides' margin at once. If read, returns max
1700 /// margin on any side.
1701 pub fn margin(self, margin: i32) -> Self {
1702 Self {
1703 builder: self.builder.property("margin", margin),
1704 }
1705 }
1706
1707 /// Margin on bottom side of widget.
1708 ///
1709 /// This property adds margin outside of the widget's normal size
1710 /// request, the margin will be added in addition to the size from
1711 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
1712 pub fn margin_bottom(self, margin_bottom: i32) -> Self {
1713 Self {
1714 builder: self.builder.property("margin-bottom", margin_bottom),
1715 }
1716 }
1717
1718 /// Margin on end of widget, horizontally. This property supports
1719 /// left-to-right and right-to-left text directions.
1720 ///
1721 /// This property adds margin outside of the widget's normal size
1722 /// request, the margin will be added in addition to the size from
1723 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
1724 pub fn margin_end(self, margin_end: i32) -> Self {
1725 Self {
1726 builder: self.builder.property("margin-end", margin_end),
1727 }
1728 }
1729
1730 /// Margin on start of widget, horizontally. This property supports
1731 /// left-to-right and right-to-left text directions.
1732 ///
1733 /// This property adds margin outside of the widget's normal size
1734 /// request, the margin will be added in addition to the size from
1735 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
1736 pub fn margin_start(self, margin_start: i32) -> Self {
1737 Self {
1738 builder: self.builder.property("margin-start", margin_start),
1739 }
1740 }
1741
1742 /// Margin on top side of widget.
1743 ///
1744 /// This property adds margin outside of the widget's normal size
1745 /// request, the margin will be added in addition to the size from
1746 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
1747 pub fn margin_top(self, margin_top: i32) -> Self {
1748 Self {
1749 builder: self.builder.property("margin-top", margin_top),
1750 }
1751 }
1752
1753 pub fn name(self, name: impl Into<glib::GString>) -> Self {
1754 Self {
1755 builder: self.builder.property("name", name.into()),
1756 }
1757 }
1758
1759 pub fn no_show_all(self, no_show_all: bool) -> Self {
1760 Self {
1761 builder: self.builder.property("no-show-all", no_show_all),
1762 }
1763 }
1764
1765 /// The requested opacity of the widget. See [`WidgetExt::set_opacity()`][crate::prelude::WidgetExt::set_opacity()] for
1766 /// more details about window opacity.
1767 ///
1768 /// Before 3.8 this was only available in GtkWindow
1769 pub fn opacity(self, opacity: f64) -> Self {
1770 Self {
1771 builder: self.builder.property("opacity", opacity),
1772 }
1773 }
1774
1775 pub fn parent(self, parent: &impl IsA<Container>) -> Self {
1776 Self {
1777 builder: self.builder.property("parent", parent.clone().upcast()),
1778 }
1779 }
1780
1781 pub fn receives_default(self, receives_default: bool) -> Self {
1782 Self {
1783 builder: self.builder.property("receives-default", receives_default),
1784 }
1785 }
1786
1787 pub fn sensitive(self, sensitive: bool) -> Self {
1788 Self {
1789 builder: self.builder.property("sensitive", sensitive),
1790 }
1791 }
1792
1793 /// Sets the text of tooltip to be the given string, which is marked up
1794 /// with the [Pango text markup language][PangoMarkupFormat].
1795 /// Also see [`Tooltip::set_markup()`][crate::Tooltip::set_markup()].
1796 ///
1797 /// This is a convenience property which will take care of getting the
1798 /// tooltip shown if the given string is not [`None`]: [`has-tooltip`][struct@crate::Widget#has-tooltip]
1799 /// will automatically be set to [`true`] and there will be taken care of
1800 /// [`query-tooltip`][struct@crate::Widget#query-tooltip] in the default signal handler.
1801 ///
1802 /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and [`tooltip-markup`][struct@crate::Widget#tooltip-markup]
1803 /// are set, the last one wins.
1804 pub fn tooltip_markup(self, tooltip_markup: impl Into<glib::GString>) -> Self {
1805 Self {
1806 builder: self
1807 .builder
1808 .property("tooltip-markup", tooltip_markup.into()),
1809 }
1810 }
1811
1812 /// Sets the text of tooltip to be the given string.
1813 ///
1814 /// Also see [`Tooltip::set_text()`][crate::Tooltip::set_text()].
1815 ///
1816 /// This is a convenience property which will take care of getting the
1817 /// tooltip shown if the given string is not [`None`]: [`has-tooltip`][struct@crate::Widget#has-tooltip]
1818 /// will automatically be set to [`true`] and there will be taken care of
1819 /// [`query-tooltip`][struct@crate::Widget#query-tooltip] in the default signal handler.
1820 ///
1821 /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and [`tooltip-markup`][struct@crate::Widget#tooltip-markup]
1822 /// are set, the last one wins.
1823 pub fn tooltip_text(self, tooltip_text: impl Into<glib::GString>) -> Self {
1824 Self {
1825 builder: self.builder.property("tooltip-text", tooltip_text.into()),
1826 }
1827 }
1828
1829 /// How to distribute vertical space if widget gets extra space, see [`Align`][crate::Align]
1830 pub fn valign(self, valign: Align) -> Self {
1831 Self {
1832 builder: self.builder.property("valign", valign),
1833 }
1834 }
1835
1836 /// Whether to expand vertically. See [`WidgetExt::set_vexpand()`][crate::prelude::WidgetExt::set_vexpand()].
1837 pub fn vexpand(self, vexpand: bool) -> Self {
1838 Self {
1839 builder: self.builder.property("vexpand", vexpand),
1840 }
1841 }
1842
1843 /// Whether to use the [`vexpand`][struct@crate::Widget#vexpand] property. See [`WidgetExt::is_vexpand_set()`][crate::prelude::WidgetExt::is_vexpand_set()].
1844 pub fn vexpand_set(self, vexpand_set: bool) -> Self {
1845 Self {
1846 builder: self.builder.property("vexpand-set", vexpand_set),
1847 }
1848 }
1849
1850 pub fn visible(self, visible: bool) -> Self {
1851 Self {
1852 builder: self.builder.property("visible", visible),
1853 }
1854 }
1855
1856 pub fn width_request(self, width_request: i32) -> Self {
1857 Self {
1858 builder: self.builder.property("width-request", width_request),
1859 }
1860 }
1861
1862 /// Indicates whether editing on the cell has been canceled.
1863 pub fn editing_canceled(self, editing_canceled: bool) -> Self {
1864 Self {
1865 builder: self.builder.property("editing-canceled", editing_canceled),
1866 }
1867 }
1868
1869 // rustdoc-stripper-ignore-next
1870 /// Build the [`SearchEntry`].
1871 #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
1872 pub fn build(self) -> SearchEntry {
1873 self.builder.build()
1874 }
1875}
1876
1877mod sealed {
1878 pub trait Sealed {}
1879 impl<T: super::IsA<super::SearchEntry>> Sealed for T {}
1880}
1881
1882/// Trait containing all [`struct@SearchEntry`] methods.
1883///
1884/// # Implementors
1885///
1886/// [`SearchEntry`][struct@crate::SearchEntry]
1887pub trait SearchEntryExt: IsA<SearchEntry> + sealed::Sealed + 'static {
1888 /// This function should be called when the top-level window
1889 /// which contains the search entry received a key event. If
1890 /// the entry is part of a [`SearchBar`][crate::SearchBar], it is preferable
1891 /// to call [`SearchBarExt::handle_event()`][crate::prelude::SearchBarExt::handle_event()] instead, which will
1892 /// reveal the entry in addition to passing the event to this
1893 /// function.
1894 ///
1895 /// If the key event is handled by the search entry and starts
1896 /// or continues a search, `GDK_EVENT_STOP` will be returned.
1897 /// The caller should ensure that the entry is shown in this
1898 /// case, and not propagate the event further.
1899 /// ## `event`
1900 /// a key event
1901 ///
1902 /// # Returns
1903 ///
1904 /// `GDK_EVENT_STOP` if the key press event resulted
1905 /// in a search beginning or continuing, `GDK_EVENT_PROPAGATE`
1906 /// otherwise.
1907 #[doc(alias = "gtk_search_entry_handle_event")]
1908 fn handle_event(&self, event: &gdk::Event) -> bool {
1909 unsafe {
1910 from_glib(ffi::gtk_search_entry_handle_event(
1911 self.as_ref().to_glib_none().0,
1912 mut_override(event.to_glib_none().0),
1913 ))
1914 }
1915 }
1916
1917 /// The ::next-match signal is a [keybinding signal][GtkBindingSignal]
1918 /// which gets emitted when the user initiates a move to the next match
1919 /// for the current search string.
1920 ///
1921 /// Applications should connect to it, to implement moving between
1922 /// matches.
1923 ///
1924 /// The default bindings for this signal is Ctrl-g.
1925 #[doc(alias = "next-match")]
1926 fn connect_next_match<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1927 unsafe extern "C" fn next_match_trampoline<P: IsA<SearchEntry>, F: Fn(&P) + 'static>(
1928 this: *mut ffi::GtkSearchEntry,
1929 f: glib::ffi::gpointer,
1930 ) {
1931 let f: &F = &*(f as *const F);
1932 f(SearchEntry::from_glib_borrow(this).unsafe_cast_ref())
1933 }
1934 unsafe {
1935 let f: Box_<F> = Box_::new(f);
1936 connect_raw(
1937 self.as_ptr() as *mut _,
1938 b"next-match\0".as_ptr() as *const _,
1939 Some(transmute::<_, unsafe extern "C" fn()>(
1940 next_match_trampoline::<Self, F> as *const (),
1941 )),
1942 Box_::into_raw(f),
1943 )
1944 }
1945 }
1946
1947 fn emit_next_match(&self) {
1948 self.emit_by_name::<()>("next-match", &[]);
1949 }
1950
1951 /// The ::previous-match signal is a [keybinding signal][GtkBindingSignal]
1952 /// which gets emitted when the user initiates a move to the previous match
1953 /// for the current search string.
1954 ///
1955 /// Applications should connect to it, to implement moving between
1956 /// matches.
1957 ///
1958 /// The default bindings for this signal is Ctrl-Shift-g.
1959 #[doc(alias = "previous-match")]
1960 fn connect_previous_match<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1961 unsafe extern "C" fn previous_match_trampoline<P: IsA<SearchEntry>, F: Fn(&P) + 'static>(
1962 this: *mut ffi::GtkSearchEntry,
1963 f: glib::ffi::gpointer,
1964 ) {
1965 let f: &F = &*(f as *const F);
1966 f(SearchEntry::from_glib_borrow(this).unsafe_cast_ref())
1967 }
1968 unsafe {
1969 let f: Box_<F> = Box_::new(f);
1970 connect_raw(
1971 self.as_ptr() as *mut _,
1972 b"previous-match\0".as_ptr() as *const _,
1973 Some(transmute::<_, unsafe extern "C" fn()>(
1974 previous_match_trampoline::<Self, F> as *const (),
1975 )),
1976 Box_::into_raw(f),
1977 )
1978 }
1979 }
1980
1981 fn emit_previous_match(&self) {
1982 self.emit_by_name::<()>("previous-match", &[]);
1983 }
1984
1985 /// The [`search-changed`][struct@crate::SearchEntry#search-changed] signal is emitted with a short
1986 /// delay of 150 milliseconds after the last change to the entry text.
1987 #[doc(alias = "search-changed")]
1988 fn connect_search_changed<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1989 unsafe extern "C" fn search_changed_trampoline<P: IsA<SearchEntry>, F: Fn(&P) + 'static>(
1990 this: *mut ffi::GtkSearchEntry,
1991 f: glib::ffi::gpointer,
1992 ) {
1993 let f: &F = &*(f as *const F);
1994 f(SearchEntry::from_glib_borrow(this).unsafe_cast_ref())
1995 }
1996 unsafe {
1997 let f: Box_<F> = Box_::new(f);
1998 connect_raw(
1999 self.as_ptr() as *mut _,
2000 b"search-changed\0".as_ptr() as *const _,
2001 Some(transmute::<_, unsafe extern "C" fn()>(
2002 search_changed_trampoline::<Self, F> as *const (),
2003 )),
2004 Box_::into_raw(f),
2005 )
2006 }
2007 }
2008
2009 /// The ::stop-search signal is a [keybinding signal][GtkBindingSignal]
2010 /// which gets emitted when the user stops a search via keyboard input.
2011 ///
2012 /// Applications should connect to it, to implement hiding the search
2013 /// entry in this case.
2014 ///
2015 /// The default bindings for this signal is Escape.
2016 #[doc(alias = "stop-search")]
2017 fn connect_stop_search<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
2018 unsafe extern "C" fn stop_search_trampoline<P: IsA<SearchEntry>, F: Fn(&P) + 'static>(
2019 this: *mut ffi::GtkSearchEntry,
2020 f: glib::ffi::gpointer,
2021 ) {
2022 let f: &F = &*(f as *const F);
2023 f(SearchEntry::from_glib_borrow(this).unsafe_cast_ref())
2024 }
2025 unsafe {
2026 let f: Box_<F> = Box_::new(f);
2027 connect_raw(
2028 self.as_ptr() as *mut _,
2029 b"stop-search\0".as_ptr() as *const _,
2030 Some(transmute::<_, unsafe extern "C" fn()>(
2031 stop_search_trampoline::<Self, F> as *const (),
2032 )),
2033 Box_::into_raw(f),
2034 )
2035 }
2036 }
2037
2038 fn emit_stop_search(&self) {
2039 self.emit_by_name::<()>("stop-search", &[]);
2040 }
2041}
2042
2043impl<O: IsA<SearchEntry>> SearchEntryExt for O {}
2044
2045impl fmt::Display for SearchEntry {
2046 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
2047 f.write_str("SearchEntry")
2048 }
2049}