gtk4/auto/password_entry.rs
1// This file was generated by gir (https://github.com/gtk-rs/gir)
2// from gir-files (https://github.com/gtk-rs/gir-files)
3// DO NOT EDIT
4
5use crate::{
6 ffi, Accessible, AccessibleRole, Align, Buildable, ConstraintTarget, Editable, LayoutManager,
7 Overflow, Widget,
8};
9use glib::{
10 object::ObjectType as _,
11 prelude::*,
12 signal::{connect_raw, SignalHandlerId},
13 translate::*,
14};
15use std::boxed::Box as Box_;
16
17glib::wrapper! {
18 /// [`PasswordEntry`][crate::PasswordEntry] is an entry that has been tailored for entering secrets.
19 ///
20 /// 
21 ///
22 /// It does not show its contents in clear text, does not allow to copy it
23 /// to the clipboard, and it shows a warning when Caps Lock is engaged. If
24 /// the underlying platform allows it, [`PasswordEntry`][crate::PasswordEntry] will also place
25 /// the text in a non-pageable memory area, to avoid it being written out
26 /// to disk by the operating system.
27 ///
28 /// Optionally, it can offer a way to reveal the contents in clear text.
29 ///
30 /// [`PasswordEntry`][crate::PasswordEntry] provides only minimal API and should be used with
31 /// the [`Editable`][crate::Editable] API.
32 ///
33 /// # CSS Nodes
34 ///
35 /// ```text
36 /// entry.password
37 /// ╰── text
38 /// ├── image.caps-lock-indicator
39 /// ┊
40 /// ```
41 ///
42 /// [`PasswordEntry`][crate::PasswordEntry] has a single CSS node with name entry that carries
43 /// a .passwordstyle class. The text Css node below it has a child with
44 /// name image and style class .caps-lock-indicator for the Caps Lock
45 /// icon, and possibly other children.
46 ///
47 /// # Accessibility
48 ///
49 /// [`PasswordEntry`][crate::PasswordEntry] uses the [`AccessibleRole::TextBox`][crate::AccessibleRole::TextBox] role.
50 ///
51 /// ## Properties
52 ///
53 ///
54 /// #### `activates-default`
55 /// Whether to activate the default widget when Enter is pressed.
56 ///
57 /// Readable | Writeable
58 ///
59 ///
60 /// #### `extra-menu`
61 /// A menu model whose contents will be appended to
62 /// the context menu.
63 ///
64 /// Readable | Writeable
65 ///
66 ///
67 /// #### `placeholder-text`
68 /// The text that will be displayed in the [`PasswordEntry`][crate::PasswordEntry]
69 /// when it is empty and unfocused.
70 ///
71 /// Readable | Writeable
72 ///
73 ///
74 /// #### `show-peek-icon`
75 /// Whether to show an icon for revealing the content.
76 ///
77 /// Readable | Writeable
78 /// <details><summary><h4>Widget</h4></summary>
79 ///
80 ///
81 /// #### `can-focus`
82 /// Whether the widget or any of its descendents can accept
83 /// the input focus.
84 ///
85 /// This property is meant to be set by widget implementations,
86 /// typically in their instance init function.
87 ///
88 /// Readable | Writeable
89 ///
90 ///
91 /// #### `can-target`
92 /// Whether the widget can receive pointer events.
93 ///
94 /// Readable | Writeable
95 ///
96 ///
97 /// #### `css-classes`
98 /// A list of css classes applied to this widget.
99 ///
100 /// Readable | Writeable
101 ///
102 ///
103 /// #### `css-name`
104 /// The name of this widget in the CSS tree.
105 ///
106 /// This property is meant to be set by widget implementations,
107 /// typically in their instance init function.
108 ///
109 /// Readable | Writeable | Construct Only
110 ///
111 ///
112 /// #### `cursor`
113 /// The cursor used by @widget.
114 ///
115 /// Readable | Writeable
116 ///
117 ///
118 /// #### `focus-on-click`
119 /// Whether the widget should grab focus when it is clicked with the mouse.
120 ///
121 /// This property is only relevant for widgets that can take focus.
122 ///
123 /// Readable | Writeable
124 ///
125 ///
126 /// #### `focusable`
127 /// Whether this widget itself will accept the input focus.
128 ///
129 /// Readable | Writeable
130 ///
131 ///
132 /// #### `halign`
133 /// How to distribute horizontal space if widget gets extra space.
134 ///
135 /// Readable | Writeable
136 ///
137 ///
138 /// #### `has-default`
139 /// Whether the widget is the default widget.
140 ///
141 /// Readable
142 ///
143 ///
144 /// #### `has-focus`
145 /// Whether the widget has the input focus.
146 ///
147 /// Readable
148 ///
149 ///
150 /// #### `has-tooltip`
151 /// Enables or disables the emission of the [`query-tooltip`][struct@crate::Widget#query-tooltip]
152 /// signal on @widget.
153 ///
154 /// A true value indicates that @widget can have a tooltip, in this case
155 /// the widget will be queried using [`query-tooltip`][struct@crate::Widget#query-tooltip] to
156 /// determine whether it will provide a tooltip or not.
157 ///
158 /// Readable | Writeable
159 ///
160 ///
161 /// #### `height-request`
162 /// Overrides for height request of the widget.
163 ///
164 /// If this is -1, the natural request will be used.
165 ///
166 /// Readable | Writeable
167 ///
168 ///
169 /// #### `hexpand`
170 /// Whether to expand horizontally.
171 ///
172 /// Readable | Writeable
173 ///
174 ///
175 /// #### `hexpand-set`
176 /// Whether to use the `hexpand` property.
177 ///
178 /// Readable | Writeable
179 ///
180 ///
181 /// #### `layout-manager`
182 /// The [`LayoutManager`][crate::LayoutManager] instance to use to compute
183 /// the preferred size of the widget, and allocate its children.
184 ///
185 /// This property is meant to be set by widget implementations,
186 /// typically in their instance init function.
187 ///
188 /// Readable | Writeable
189 ///
190 ///
191 /// #### `limit-events`
192 /// Makes this widget act like a modal dialog, with respect to
193 /// event delivery.
194 ///
195 /// Global event controllers will not handle events with targets
196 /// inside the widget, unless they are set up to ignore propagation
197 /// limits. See [`EventControllerExt::set_propagation_limit()`][crate::prelude::EventControllerExt::set_propagation_limit()].
198 ///
199 /// Readable | Writeable
200 ///
201 ///
202 /// #### `margin-bottom`
203 /// Margin on bottom side of widget.
204 ///
205 /// This property adds margin outside of the widget's normal size
206 /// request, the margin will be added in addition to the size from
207 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
208 ///
209 /// Readable | Writeable
210 ///
211 ///
212 /// #### `margin-end`
213 /// Margin on end of widget, horizontally.
214 ///
215 /// This property supports left-to-right and right-to-left text
216 /// directions.
217 ///
218 /// This property adds margin outside of the widget's normal size
219 /// request, the margin will be added in addition to the size from
220 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
221 ///
222 /// Readable | Writeable
223 ///
224 ///
225 /// #### `margin-start`
226 /// Margin on start of widget, horizontally.
227 ///
228 /// This property supports left-to-right and right-to-left text
229 /// directions.
230 ///
231 /// This property adds margin outside of the widget's normal size
232 /// request, the margin will be added in addition to the size from
233 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
234 ///
235 /// Readable | Writeable
236 ///
237 ///
238 /// #### `margin-top`
239 /// Margin on top side of widget.
240 ///
241 /// This property adds margin outside of the widget's normal size
242 /// request, the margin will be added in addition to the size from
243 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
244 ///
245 /// Readable | Writeable
246 ///
247 ///
248 /// #### `name`
249 /// The name of the widget.
250 ///
251 /// Readable | Writeable
252 ///
253 ///
254 /// #### `opacity`
255 /// The requested opacity of the widget.
256 ///
257 /// Readable | Writeable
258 ///
259 ///
260 /// #### `overflow`
261 /// How content outside the widget's content area is treated.
262 ///
263 /// This property is meant to be set by widget implementations,
264 /// typically in their instance init function.
265 ///
266 /// Readable | Writeable
267 ///
268 ///
269 /// #### `parent`
270 /// The parent widget of this widget.
271 ///
272 /// Readable
273 ///
274 ///
275 /// #### `receives-default`
276 /// Whether the widget will receive the default action when it is focused.
277 ///
278 /// Readable | Writeable
279 ///
280 ///
281 /// #### `root`
282 /// The [`Root`][crate::Root] widget of the widget tree containing this widget.
283 ///
284 /// This will be `NULL` if the widget is not contained in a root widget.
285 ///
286 /// Readable
287 ///
288 ///
289 /// #### `scale-factor`
290 /// The scale factor of the widget.
291 ///
292 /// Readable
293 ///
294 ///
295 /// #### `sensitive`
296 /// Whether the widget responds to input.
297 ///
298 /// Readable | Writeable
299 ///
300 ///
301 /// #### `tooltip-markup`
302 /// Sets the text of tooltip to be the given string, which is marked up
303 /// with Pango markup.
304 ///
305 /// Also see [`Tooltip::set_markup()`][crate::Tooltip::set_markup()].
306 ///
307 /// This is a convenience property which will take care of getting the
308 /// tooltip shown if the given string is not `NULL`:
309 /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
310 /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
311 /// the default signal handler.
312 ///
313 /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
314 /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
315 ///
316 /// Readable | Writeable
317 ///
318 ///
319 /// #### `tooltip-text`
320 /// Sets the text of tooltip to be the given string.
321 ///
322 /// Also see [`Tooltip::set_text()`][crate::Tooltip::set_text()].
323 ///
324 /// This is a convenience property which will take care of getting the
325 /// tooltip shown if the given string is not `NULL`:
326 /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
327 /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
328 /// the default signal handler.
329 ///
330 /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
331 /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
332 ///
333 /// Readable | Writeable
334 ///
335 ///
336 /// #### `valign`
337 /// How to distribute vertical space if widget gets extra space.
338 ///
339 /// Readable | Writeable
340 ///
341 ///
342 /// #### `vexpand`
343 /// Whether to expand vertically.
344 ///
345 /// Readable | Writeable
346 ///
347 ///
348 /// #### `vexpand-set`
349 /// Whether to use the `vexpand` property.
350 ///
351 /// Readable | Writeable
352 ///
353 ///
354 /// #### `visible`
355 /// Whether the widget is visible.
356 ///
357 /// Readable | Writeable
358 ///
359 ///
360 /// #### `width-request`
361 /// Overrides for width request of the widget.
362 ///
363 /// If this is -1, the natural request will be used.
364 ///
365 /// Readable | Writeable
366 /// </details>
367 /// <details><summary><h4>Accessible</h4></summary>
368 ///
369 ///
370 /// #### `accessible-role`
371 /// The accessible role of the given [`Accessible`][crate::Accessible] implementation.
372 ///
373 /// The accessible role cannot be changed once set.
374 ///
375 /// Readable | Writeable
376 /// </details>
377 /// <details><summary><h4>Editable</h4></summary>
378 ///
379 ///
380 /// #### `cursor-position`
381 /// The current position of the insertion cursor in chars.
382 ///
383 /// Readable
384 ///
385 ///
386 /// #### `editable`
387 /// Whether the entry contents can be edited.
388 ///
389 /// Readable | Writeable
390 ///
391 ///
392 /// #### `enable-undo`
393 /// If undo/redo should be enabled for the editable.
394 ///
395 /// Readable | Writeable
396 ///
397 ///
398 /// #### `max-width-chars`
399 /// The desired maximum width of the entry, in characters.
400 ///
401 /// Readable | Writeable
402 ///
403 ///
404 /// #### `selection-bound`
405 /// The position of the opposite end of the selection from the cursor in chars.
406 ///
407 /// Readable
408 ///
409 ///
410 /// #### `text`
411 /// The contents of the entry.
412 ///
413 /// Readable | Writeable
414 ///
415 ///
416 /// #### `width-chars`
417 /// Number of characters to leave space for in the entry.
418 ///
419 /// Readable | Writeable
420 ///
421 ///
422 /// #### `xalign`
423 /// The horizontal alignment, from 0 (left) to 1 (right).
424 ///
425 /// Reversed for RTL layouts.
426 ///
427 /// Readable | Writeable
428 /// </details>
429 ///
430 /// ## Signals
431 ///
432 ///
433 /// #### `activate`
434 /// Emitted when the entry is activated.
435 ///
436 /// The keybindings for this signal are all forms of the Enter key.
437 ///
438 /// Action
439 /// <details><summary><h4>Widget</h4></summary>
440 ///
441 ///
442 /// #### `destroy`
443 /// Signals that all holders of a reference to the widget should release
444 /// the reference that they hold.
445 ///
446 /// May result in finalization of the widget if all references are released.
447 ///
448 /// This signal is not suitable for saving widget state.
449 ///
450 ///
451 ///
452 ///
453 /// #### `direction-changed`
454 /// Emitted when the text direction of a widget changes.
455 ///
456 ///
457 ///
458 ///
459 /// #### `hide`
460 /// Emitted when @widget is hidden.
461 ///
462 ///
463 ///
464 ///
465 /// #### `keynav-failed`
466 /// Emitted if keyboard navigation fails.
467 ///
468 /// See [`WidgetExt::keynav_failed()`][crate::prelude::WidgetExt::keynav_failed()] for details.
469 ///
470 ///
471 ///
472 ///
473 /// #### `map`
474 /// Emitted when @widget is going to be mapped.
475 ///
476 /// A widget is mapped when the widget is visible (which is controlled with
477 /// [`visible`][struct@crate::Widget#visible]) and all its parents up to the toplevel widget
478 /// are also visible.
479 ///
480 /// The `::map` signal can be used to determine whether a widget will be drawn,
481 /// for instance it can resume an animation that was stopped during the
482 /// emission of [`unmap`][struct@crate::Widget#unmap].
483 ///
484 ///
485 ///
486 ///
487 /// #### `mnemonic-activate`
488 /// Emitted when a widget is activated via a mnemonic.
489 ///
490 /// The default handler for this signal activates @widget if @group_cycling
491 /// is false, or just makes @widget grab focus if @group_cycling is true.
492 ///
493 ///
494 ///
495 ///
496 /// #### `move-focus`
497 /// Emitted when the focus is moved.
498 ///
499 /// The `::move-focus` signal is a [keybinding signal](class.SignalAction.html).
500 ///
501 /// The default bindings for this signal are <kbd>Tab</kbd> to move forward,
502 /// and <kbd>Shift</kbd>+<kbd>Tab</kbd> to move backward.
503 ///
504 /// Action
505 ///
506 ///
507 /// #### `query-tooltip`
508 /// Emitted when the widget’s tooltip is about to be shown.
509 ///
510 /// This happens when the [`has-tooltip`][struct@crate::Widget#has-tooltip] property
511 /// is true and the hover timeout has expired with the cursor hovering
512 /// above @widget; or emitted when @widget got focus in keyboard mode.
513 ///
514 /// Using the given coordinates, the signal handler should determine
515 /// whether a tooltip should be shown for @widget. If this is the case
516 /// true should be returned, false otherwise. Note that if @keyboard_mode
517 /// is true, the values of @x and @y are undefined and should not be used.
518 ///
519 /// The signal handler is free to manipulate @tooltip with the therefore
520 /// destined function calls.
521 ///
522 ///
523 ///
524 ///
525 /// #### `realize`
526 /// Emitted when @widget is associated with a [`gdk::Surface`][crate::gdk::Surface].
527 ///
528 /// This means that [`WidgetExt::realize()`][crate::prelude::WidgetExt::realize()] has been called
529 /// or the widget has been mapped (that is, it is going to be drawn).
530 ///
531 ///
532 ///
533 ///
534 /// #### `show`
535 /// Emitted when @widget is shown.
536 ///
537 ///
538 ///
539 ///
540 /// #### `state-flags-changed`
541 /// Emitted when the widget state changes.
542 ///
543 /// See [`WidgetExt::state_flags()`][crate::prelude::WidgetExt::state_flags()].
544 ///
545 ///
546 ///
547 ///
548 /// #### `unmap`
549 /// Emitted when @widget is going to be unmapped.
550 ///
551 /// A widget is unmapped when either it or any of its parents up to the
552 /// toplevel widget have been set as hidden.
553 ///
554 /// As `::unmap` indicates that a widget will not be shown any longer,
555 /// it can be used to, for example, stop an animation on the widget.
556 ///
557 ///
558 ///
559 ///
560 /// #### `unrealize`
561 /// Emitted when the [`gdk::Surface`][crate::gdk::Surface] associated with @widget is destroyed.
562 ///
563 /// This means that [`WidgetExt::unrealize()`][crate::prelude::WidgetExt::unrealize()] has been called
564 /// or the widget has been unmapped (that is, it is going to be hidden).
565 ///
566 ///
567 /// </details>
568 /// <details><summary><h4>Editable</h4></summary>
569 ///
570 ///
571 /// #### `changed`
572 /// Emitted at the end of a single user-visible operation on the
573 /// contents.
574 ///
575 /// E.g., a paste operation that replaces the contents of the
576 /// selection will cause only one signal emission (even though it
577 /// is implemented by first deleting the selection, then inserting
578 /// the new content, and may cause multiple ::notify::text signals
579 /// to be emitted).
580 ///
581 ///
582 ///
583 ///
584 /// #### `delete-text`
585 /// Emitted when text is deleted from the widget by the user.
586 ///
587 /// The default handler for this signal will normally be responsible for
588 /// deleting the text, so by connecting to this signal and then stopping
589 /// the signal with g_signal_stop_emission(), it is possible to modify the
590 /// range of deleted text, or prevent it from being deleted entirely.
591 ///
592 /// The @start_pos and @end_pos parameters are interpreted as for
593 /// [`EditableExt::delete_text()`][crate::prelude::EditableExt::delete_text()].
594 ///
595 ///
596 ///
597 ///
598 /// #### `insert-text`
599 /// Emitted when text is inserted into the widget by the user.
600 ///
601 /// The default handler for this signal will normally be responsible
602 /// for inserting the text, so by connecting to this signal and then
603 /// stopping the signal with g_signal_stop_emission(), it is possible
604 /// to modify the inserted text, or prevent it from being inserted entirely.
605 ///
606 ///
607 /// </details>
608 ///
609 /// # Implements
610 ///
611 /// [`WidgetExt`][trait@crate::prelude::WidgetExt], [`trait@glib::ObjectExt`], [`AccessibleExt`][trait@crate::prelude::AccessibleExt], [`BuildableExt`][trait@crate::prelude::BuildableExt], [`ConstraintTargetExt`][trait@crate::prelude::ConstraintTargetExt], [`EditableExt`][trait@crate::prelude::EditableExt], [`WidgetExtManual`][trait@crate::prelude::WidgetExtManual], [`AccessibleExtManual`][trait@crate::prelude::AccessibleExtManual], [`EditableExtManual`][trait@crate::prelude::EditableExtManual]
612 #[doc(alias = "GtkPasswordEntry")]
613 pub struct PasswordEntry(Object<ffi::GtkPasswordEntry, ffi::GtkPasswordEntryClass>) @extends Widget, @implements Accessible, Buildable, ConstraintTarget, Editable;
614
615 match fn {
616 type_ => || ffi::gtk_password_entry_get_type(),
617 }
618}
619
620impl PasswordEntry {
621 /// Creates a [`PasswordEntry`][crate::PasswordEntry].
622 ///
623 /// # Returns
624 ///
625 /// a new [`PasswordEntry`][crate::PasswordEntry]
626 #[doc(alias = "gtk_password_entry_new")]
627 pub fn new() -> PasswordEntry {
628 assert_initialized_main_thread!();
629 unsafe { Widget::from_glib_none(ffi::gtk_password_entry_new()).unsafe_cast() }
630 }
631
632 // rustdoc-stripper-ignore-next
633 /// Creates a new builder-pattern struct instance to construct [`PasswordEntry`] objects.
634 ///
635 /// This method returns an instance of [`PasswordEntryBuilder`](crate::builders::PasswordEntryBuilder) which can be used to create [`PasswordEntry`] objects.
636 pub fn builder() -> PasswordEntryBuilder {
637 PasswordEntryBuilder::new()
638 }
639
640 /// Gets the menu model set with gtk_password_entry_set_extra_menu().
641 ///
642 /// # Returns
643 ///
644 /// the menu model
645 #[doc(alias = "gtk_password_entry_get_extra_menu")]
646 #[doc(alias = "get_extra_menu")]
647 #[doc(alias = "extra-menu")]
648 pub fn extra_menu(&self) -> Option<gio::MenuModel> {
649 unsafe {
650 from_glib_none(ffi::gtk_password_entry_get_extra_menu(
651 self.to_glib_none().0,
652 ))
653 }
654 }
655
656 /// Returns whether the entry is showing an icon to
657 /// reveal the contents.
658 ///
659 /// # Returns
660 ///
661 /// [`true`] if an icon is shown
662 #[doc(alias = "gtk_password_entry_get_show_peek_icon")]
663 #[doc(alias = "get_show_peek_icon")]
664 #[doc(alias = "show-peek-icon")]
665 pub fn shows_peek_icon(&self) -> bool {
666 unsafe {
667 from_glib(ffi::gtk_password_entry_get_show_peek_icon(
668 self.to_glib_none().0,
669 ))
670 }
671 }
672
673 /// Sets a menu model to add when constructing
674 /// the context menu for @self.
675 /// ## `model`
676 /// a `GMenuModel`
677 #[doc(alias = "gtk_password_entry_set_extra_menu")]
678 #[doc(alias = "extra-menu")]
679 pub fn set_extra_menu(&self, model: Option<&impl IsA<gio::MenuModel>>) {
680 unsafe {
681 ffi::gtk_password_entry_set_extra_menu(
682 self.to_glib_none().0,
683 model.map(|p| p.as_ref()).to_glib_none().0,
684 );
685 }
686 }
687
688 /// Sets whether the entry should have a clickable icon
689 /// to reveal the contents.
690 ///
691 /// Setting this to [`false`] also hides the text again.
692 /// ## `show_peek_icon`
693 /// whether to show the peek icon
694 #[doc(alias = "gtk_password_entry_set_show_peek_icon")]
695 #[doc(alias = "show-peek-icon")]
696 pub fn set_show_peek_icon(&self, show_peek_icon: bool) {
697 unsafe {
698 ffi::gtk_password_entry_set_show_peek_icon(
699 self.to_glib_none().0,
700 show_peek_icon.into_glib(),
701 );
702 }
703 }
704
705 /// Whether to activate the default widget when Enter is pressed.
706 #[doc(alias = "activates-default")]
707 pub fn activates_default(&self) -> bool {
708 ObjectExt::property(self, "activates-default")
709 }
710
711 /// Whether to activate the default widget when Enter is pressed.
712 #[doc(alias = "activates-default")]
713 pub fn set_activates_default(&self, activates_default: bool) {
714 ObjectExt::set_property(self, "activates-default", activates_default)
715 }
716
717 /// The text that will be displayed in the [`PasswordEntry`][crate::PasswordEntry]
718 /// when it is empty and unfocused.
719 #[doc(alias = "placeholder-text")]
720 pub fn placeholder_text(&self) -> Option<glib::GString> {
721 ObjectExt::property(self, "placeholder-text")
722 }
723
724 /// The text that will be displayed in the [`PasswordEntry`][crate::PasswordEntry]
725 /// when it is empty and unfocused.
726 #[doc(alias = "placeholder-text")]
727 pub fn set_placeholder_text(&self, placeholder_text: Option<&str>) {
728 ObjectExt::set_property(self, "placeholder-text", placeholder_text)
729 }
730
731 /// Emitted when the entry is activated.
732 ///
733 /// The keybindings for this signal are all forms of the Enter key.
734 #[doc(alias = "activate")]
735 pub fn connect_activate<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
736 unsafe extern "C" fn activate_trampoline<F: Fn(&PasswordEntry) + 'static>(
737 this: *mut ffi::GtkPasswordEntry,
738 f: glib::ffi::gpointer,
739 ) {
740 let f: &F = &*(f as *const F);
741 f(&from_glib_borrow(this))
742 }
743 unsafe {
744 let f: Box_<F> = Box_::new(f);
745 connect_raw(
746 self.as_ptr() as *mut _,
747 c"activate".as_ptr() as *const _,
748 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
749 activate_trampoline::<F> as *const (),
750 )),
751 Box_::into_raw(f),
752 )
753 }
754 }
755
756 pub fn emit_activate(&self) {
757 self.emit_by_name::<()>("activate", &[]);
758 }
759
760 #[doc(alias = "activates-default")]
761 pub fn connect_activates_default_notify<F: Fn(&Self) + 'static>(
762 &self,
763 f: F,
764 ) -> SignalHandlerId {
765 unsafe extern "C" fn notify_activates_default_trampoline<
766 F: Fn(&PasswordEntry) + 'static,
767 >(
768 this: *mut ffi::GtkPasswordEntry,
769 _param_spec: glib::ffi::gpointer,
770 f: glib::ffi::gpointer,
771 ) {
772 let f: &F = &*(f as *const F);
773 f(&from_glib_borrow(this))
774 }
775 unsafe {
776 let f: Box_<F> = Box_::new(f);
777 connect_raw(
778 self.as_ptr() as *mut _,
779 c"notify::activates-default".as_ptr() as *const _,
780 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
781 notify_activates_default_trampoline::<F> as *const (),
782 )),
783 Box_::into_raw(f),
784 )
785 }
786 }
787
788 #[doc(alias = "extra-menu")]
789 pub fn connect_extra_menu_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
790 unsafe extern "C" fn notify_extra_menu_trampoline<F: Fn(&PasswordEntry) + 'static>(
791 this: *mut ffi::GtkPasswordEntry,
792 _param_spec: glib::ffi::gpointer,
793 f: glib::ffi::gpointer,
794 ) {
795 let f: &F = &*(f as *const F);
796 f(&from_glib_borrow(this))
797 }
798 unsafe {
799 let f: Box_<F> = Box_::new(f);
800 connect_raw(
801 self.as_ptr() as *mut _,
802 c"notify::extra-menu".as_ptr() as *const _,
803 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
804 notify_extra_menu_trampoline::<F> as *const (),
805 )),
806 Box_::into_raw(f),
807 )
808 }
809 }
810
811 #[doc(alias = "placeholder-text")]
812 pub fn connect_placeholder_text_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
813 unsafe extern "C" fn notify_placeholder_text_trampoline<F: Fn(&PasswordEntry) + 'static>(
814 this: *mut ffi::GtkPasswordEntry,
815 _param_spec: glib::ffi::gpointer,
816 f: glib::ffi::gpointer,
817 ) {
818 let f: &F = &*(f as *const F);
819 f(&from_glib_borrow(this))
820 }
821 unsafe {
822 let f: Box_<F> = Box_::new(f);
823 connect_raw(
824 self.as_ptr() as *mut _,
825 c"notify::placeholder-text".as_ptr() as *const _,
826 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
827 notify_placeholder_text_trampoline::<F> as *const (),
828 )),
829 Box_::into_raw(f),
830 )
831 }
832 }
833
834 #[doc(alias = "show-peek-icon")]
835 pub fn connect_show_peek_icon_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
836 unsafe extern "C" fn notify_show_peek_icon_trampoline<F: Fn(&PasswordEntry) + 'static>(
837 this: *mut ffi::GtkPasswordEntry,
838 _param_spec: glib::ffi::gpointer,
839 f: glib::ffi::gpointer,
840 ) {
841 let f: &F = &*(f as *const F);
842 f(&from_glib_borrow(this))
843 }
844 unsafe {
845 let f: Box_<F> = Box_::new(f);
846 connect_raw(
847 self.as_ptr() as *mut _,
848 c"notify::show-peek-icon".as_ptr() as *const _,
849 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
850 notify_show_peek_icon_trampoline::<F> as *const (),
851 )),
852 Box_::into_raw(f),
853 )
854 }
855 }
856}
857
858impl Default for PasswordEntry {
859 fn default() -> Self {
860 Self::new()
861 }
862}
863
864// rustdoc-stripper-ignore-next
865/// A [builder-pattern] type to construct [`PasswordEntry`] objects.
866///
867/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
868#[must_use = "The builder must be built to be used"]
869pub struct PasswordEntryBuilder {
870 builder: glib::object::ObjectBuilder<'static, PasswordEntry>,
871}
872
873impl PasswordEntryBuilder {
874 fn new() -> Self {
875 Self {
876 builder: glib::object::Object::builder(),
877 }
878 }
879
880 /// Whether to activate the default widget when Enter is pressed.
881 pub fn activates_default(self, activates_default: bool) -> Self {
882 Self {
883 builder: self
884 .builder
885 .property("activates-default", activates_default),
886 }
887 }
888
889 /// A menu model whose contents will be appended to
890 /// the context menu.
891 pub fn extra_menu(self, extra_menu: &impl IsA<gio::MenuModel>) -> Self {
892 Self {
893 builder: self
894 .builder
895 .property("extra-menu", extra_menu.clone().upcast()),
896 }
897 }
898
899 /// The text that will be displayed in the [`PasswordEntry`][crate::PasswordEntry]
900 /// when it is empty and unfocused.
901 pub fn placeholder_text(self, placeholder_text: impl Into<glib::GString>) -> Self {
902 Self {
903 builder: self
904 .builder
905 .property("placeholder-text", placeholder_text.into()),
906 }
907 }
908
909 /// Whether to show an icon for revealing the content.
910 pub fn show_peek_icon(self, show_peek_icon: bool) -> Self {
911 Self {
912 builder: self.builder.property("show-peek-icon", show_peek_icon),
913 }
914 }
915
916 /// Whether the widget or any of its descendents can accept
917 /// the input focus.
918 ///
919 /// This property is meant to be set by widget implementations,
920 /// typically in their instance init function.
921 pub fn can_focus(self, can_focus: bool) -> Self {
922 Self {
923 builder: self.builder.property("can-focus", can_focus),
924 }
925 }
926
927 /// Whether the widget can receive pointer events.
928 pub fn can_target(self, can_target: bool) -> Self {
929 Self {
930 builder: self.builder.property("can-target", can_target),
931 }
932 }
933
934 /// A list of css classes applied to this widget.
935 pub fn css_classes(self, css_classes: impl Into<glib::StrV>) -> Self {
936 Self {
937 builder: self.builder.property("css-classes", css_classes.into()),
938 }
939 }
940
941 /// The name of this widget in the CSS tree.
942 ///
943 /// This property is meant to be set by widget implementations,
944 /// typically in their instance init function.
945 pub fn css_name(self, css_name: impl Into<glib::GString>) -> Self {
946 Self {
947 builder: self.builder.property("css-name", css_name.into()),
948 }
949 }
950
951 /// The cursor used by @widget.
952 pub fn cursor(self, cursor: &gdk::Cursor) -> Self {
953 Self {
954 builder: self.builder.property("cursor", cursor.clone()),
955 }
956 }
957
958 /// Whether the widget should grab focus when it is clicked with the mouse.
959 ///
960 /// This property is only relevant for widgets that can take focus.
961 pub fn focus_on_click(self, focus_on_click: bool) -> Self {
962 Self {
963 builder: self.builder.property("focus-on-click", focus_on_click),
964 }
965 }
966
967 /// Whether this widget itself will accept the input focus.
968 pub fn focusable(self, focusable: bool) -> Self {
969 Self {
970 builder: self.builder.property("focusable", focusable),
971 }
972 }
973
974 /// How to distribute horizontal space if widget gets extra space.
975 pub fn halign(self, halign: Align) -> Self {
976 Self {
977 builder: self.builder.property("halign", halign),
978 }
979 }
980
981 /// Enables or disables the emission of the [`query-tooltip`][struct@crate::Widget#query-tooltip]
982 /// signal on @widget.
983 ///
984 /// A true value indicates that @widget can have a tooltip, in this case
985 /// the widget will be queried using [`query-tooltip`][struct@crate::Widget#query-tooltip] to
986 /// determine whether it will provide a tooltip or not.
987 pub fn has_tooltip(self, has_tooltip: bool) -> Self {
988 Self {
989 builder: self.builder.property("has-tooltip", has_tooltip),
990 }
991 }
992
993 /// Overrides for height request of the widget.
994 ///
995 /// If this is -1, the natural request will be used.
996 pub fn height_request(self, height_request: i32) -> Self {
997 Self {
998 builder: self.builder.property("height-request", height_request),
999 }
1000 }
1001
1002 /// Whether to expand horizontally.
1003 pub fn hexpand(self, hexpand: bool) -> Self {
1004 Self {
1005 builder: self.builder.property("hexpand", hexpand),
1006 }
1007 }
1008
1009 /// Whether to use the `hexpand` property.
1010 pub fn hexpand_set(self, hexpand_set: bool) -> Self {
1011 Self {
1012 builder: self.builder.property("hexpand-set", hexpand_set),
1013 }
1014 }
1015
1016 /// The [`LayoutManager`][crate::LayoutManager] instance to use to compute
1017 /// the preferred size of the widget, and allocate its children.
1018 ///
1019 /// This property is meant to be set by widget implementations,
1020 /// typically in their instance init function.
1021 pub fn layout_manager(self, layout_manager: &impl IsA<LayoutManager>) -> Self {
1022 Self {
1023 builder: self
1024 .builder
1025 .property("layout-manager", layout_manager.clone().upcast()),
1026 }
1027 }
1028
1029 /// Makes this widget act like a modal dialog, with respect to
1030 /// event delivery.
1031 ///
1032 /// Global event controllers will not handle events with targets
1033 /// inside the widget, unless they are set up to ignore propagation
1034 /// limits. See [`EventControllerExt::set_propagation_limit()`][crate::prelude::EventControllerExt::set_propagation_limit()].
1035 #[cfg(feature = "v4_18")]
1036 #[cfg_attr(docsrs, doc(cfg(feature = "v4_18")))]
1037 pub fn limit_events(self, limit_events: bool) -> Self {
1038 Self {
1039 builder: self.builder.property("limit-events", limit_events),
1040 }
1041 }
1042
1043 /// Margin on bottom side of widget.
1044 ///
1045 /// This property adds margin outside of the widget's normal size
1046 /// request, the margin will be added in addition to the size from
1047 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
1048 pub fn margin_bottom(self, margin_bottom: i32) -> Self {
1049 Self {
1050 builder: self.builder.property("margin-bottom", margin_bottom),
1051 }
1052 }
1053
1054 /// Margin on end of widget, horizontally.
1055 ///
1056 /// This property supports left-to-right and right-to-left text
1057 /// directions.
1058 ///
1059 /// This property adds margin outside of the widget's normal size
1060 /// request, the margin will be added in addition to the size from
1061 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
1062 pub fn margin_end(self, margin_end: i32) -> Self {
1063 Self {
1064 builder: self.builder.property("margin-end", margin_end),
1065 }
1066 }
1067
1068 /// Margin on start of widget, horizontally.
1069 ///
1070 /// This property supports left-to-right and right-to-left text
1071 /// directions.
1072 ///
1073 /// This property adds margin outside of the widget's normal size
1074 /// request, the margin will be added in addition to the size from
1075 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
1076 pub fn margin_start(self, margin_start: i32) -> Self {
1077 Self {
1078 builder: self.builder.property("margin-start", margin_start),
1079 }
1080 }
1081
1082 /// Margin on top side of widget.
1083 ///
1084 /// This property adds margin outside of the widget's normal size
1085 /// request, the margin will be added in addition to the size from
1086 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
1087 pub fn margin_top(self, margin_top: i32) -> Self {
1088 Self {
1089 builder: self.builder.property("margin-top", margin_top),
1090 }
1091 }
1092
1093 /// The name of the widget.
1094 pub fn name(self, name: impl Into<glib::GString>) -> Self {
1095 Self {
1096 builder: self.builder.property("name", name.into()),
1097 }
1098 }
1099
1100 /// The requested opacity of the widget.
1101 pub fn opacity(self, opacity: f64) -> Self {
1102 Self {
1103 builder: self.builder.property("opacity", opacity),
1104 }
1105 }
1106
1107 /// How content outside the widget's content area is treated.
1108 ///
1109 /// This property is meant to be set by widget implementations,
1110 /// typically in their instance init function.
1111 pub fn overflow(self, overflow: Overflow) -> Self {
1112 Self {
1113 builder: self.builder.property("overflow", overflow),
1114 }
1115 }
1116
1117 /// Whether the widget will receive the default action when it is focused.
1118 pub fn receives_default(self, receives_default: bool) -> Self {
1119 Self {
1120 builder: self.builder.property("receives-default", receives_default),
1121 }
1122 }
1123
1124 /// Whether the widget responds to input.
1125 pub fn sensitive(self, sensitive: bool) -> Self {
1126 Self {
1127 builder: self.builder.property("sensitive", sensitive),
1128 }
1129 }
1130
1131 /// Sets the text of tooltip to be the given string, which is marked up
1132 /// with Pango markup.
1133 ///
1134 /// Also see [`Tooltip::set_markup()`][crate::Tooltip::set_markup()].
1135 ///
1136 /// This is a convenience property which will take care of getting the
1137 /// tooltip shown if the given string is not `NULL`:
1138 /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
1139 /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
1140 /// the default signal handler.
1141 ///
1142 /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
1143 /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
1144 pub fn tooltip_markup(self, tooltip_markup: impl Into<glib::GString>) -> Self {
1145 Self {
1146 builder: self
1147 .builder
1148 .property("tooltip-markup", tooltip_markup.into()),
1149 }
1150 }
1151
1152 /// Sets the text of tooltip to be the given string.
1153 ///
1154 /// Also see [`Tooltip::set_text()`][crate::Tooltip::set_text()].
1155 ///
1156 /// This is a convenience property which will take care of getting the
1157 /// tooltip shown if the given string is not `NULL`:
1158 /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
1159 /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
1160 /// the default signal handler.
1161 ///
1162 /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
1163 /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
1164 pub fn tooltip_text(self, tooltip_text: impl Into<glib::GString>) -> Self {
1165 Self {
1166 builder: self.builder.property("tooltip-text", tooltip_text.into()),
1167 }
1168 }
1169
1170 /// How to distribute vertical space if widget gets extra space.
1171 pub fn valign(self, valign: Align) -> Self {
1172 Self {
1173 builder: self.builder.property("valign", valign),
1174 }
1175 }
1176
1177 /// Whether to expand vertically.
1178 pub fn vexpand(self, vexpand: bool) -> Self {
1179 Self {
1180 builder: self.builder.property("vexpand", vexpand),
1181 }
1182 }
1183
1184 /// Whether to use the `vexpand` property.
1185 pub fn vexpand_set(self, vexpand_set: bool) -> Self {
1186 Self {
1187 builder: self.builder.property("vexpand-set", vexpand_set),
1188 }
1189 }
1190
1191 /// Whether the widget is visible.
1192 pub fn visible(self, visible: bool) -> Self {
1193 Self {
1194 builder: self.builder.property("visible", visible),
1195 }
1196 }
1197
1198 /// Overrides for width request of the widget.
1199 ///
1200 /// If this is -1, the natural request will be used.
1201 pub fn width_request(self, width_request: i32) -> Self {
1202 Self {
1203 builder: self.builder.property("width-request", width_request),
1204 }
1205 }
1206
1207 /// The accessible role of the given [`Accessible`][crate::Accessible] implementation.
1208 ///
1209 /// The accessible role cannot be changed once set.
1210 pub fn accessible_role(self, accessible_role: AccessibleRole) -> Self {
1211 Self {
1212 builder: self.builder.property("accessible-role", accessible_role),
1213 }
1214 }
1215
1216 /// Whether the entry contents can be edited.
1217 pub fn editable(self, editable: bool) -> Self {
1218 Self {
1219 builder: self.builder.property("editable", editable),
1220 }
1221 }
1222
1223 /// If undo/redo should be enabled for the editable.
1224 pub fn enable_undo(self, enable_undo: bool) -> Self {
1225 Self {
1226 builder: self.builder.property("enable-undo", enable_undo),
1227 }
1228 }
1229
1230 /// The desired maximum width of the entry, in characters.
1231 pub fn max_width_chars(self, max_width_chars: i32) -> Self {
1232 Self {
1233 builder: self.builder.property("max-width-chars", max_width_chars),
1234 }
1235 }
1236
1237 /// The contents of the entry.
1238 pub fn text(self, text: impl Into<glib::GString>) -> Self {
1239 Self {
1240 builder: self.builder.property("text", text.into()),
1241 }
1242 }
1243
1244 /// Number of characters to leave space for in the entry.
1245 pub fn width_chars(self, width_chars: i32) -> Self {
1246 Self {
1247 builder: self.builder.property("width-chars", width_chars),
1248 }
1249 }
1250
1251 /// The horizontal alignment, from 0 (left) to 1 (right).
1252 ///
1253 /// Reversed for RTL layouts.
1254 pub fn xalign(self, xalign: f32) -> Self {
1255 Self {
1256 builder: self.builder.property("xalign", xalign),
1257 }
1258 }
1259
1260 // rustdoc-stripper-ignore-next
1261 /// Build the [`PasswordEntry`].
1262 #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
1263 pub fn build(self) -> PasswordEntry {
1264 assert_initialized_main_thread!();
1265 self.builder.build()
1266 }
1267}