Skip to main content

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