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