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