Skip to main content

libadwaita/auto/
password_entry_row.rs

1// This file was generated by gir (https://github.com/gtk-rs/gir)
2// from
3// from gir-files (https://github.com/gtk-rs/gir-files.git)
4// DO NOT EDIT
5
6use crate::{EntryRow, PreferencesRow, ffi};
7use glib::{prelude::*, translate::*};
8
9#[cfg(feature = "gtk_v4_10")]
10#[cfg_attr(docsrs, doc(cfg(feature = "gtk_v4_10")))]
11glib::wrapper! {
12    ///
13    ///
14    /// It does not show its contents in clear text, does not allow to copy it to the
15    /// clipboard, and shows a warning when Caps Lock is engaged. If the underlying
16    /// platform allows it, [`PasswordEntryRow`][crate::PasswordEntryRow] will also place the text in a
17    /// non-pageable memory area, to avoid it being written out to disk by the
18    /// operating system.
19    ///
20    /// It offer a way to reveal the contents in clear text.
21    ///
22    /// ## CSS Nodes
23    ///
24    /// [`PasswordEntryRow`][crate::PasswordEntryRow] has a single CSS node with name `row` that carries
25    /// `.entry` and `.password` style classes.
26    ///
27    /// # Implements
28    ///
29    /// [`EntryRowExt`][trait@crate::prelude::EntryRowExt], [`PreferencesRowExt`][trait@crate::prelude::PreferencesRowExt], [`trait@gtk::prelude::ListBoxRowExt`], [`trait@gtk::prelude::WidgetExt`], [`trait@glib::ObjectExt`], [`trait@gtk::prelude::AccessibleExt`], [`trait@gtk::prelude::BuildableExt`], [`trait@gtk::prelude::ConstraintTargetExt`], [`trait@gtk::prelude::ActionableExt`], [`trait@gtk::prelude::EditableExt`]
30    #[doc(alias = "AdwPasswordEntryRow")]
31    pub struct PasswordEntryRow(Object<ffi::AdwPasswordEntryRow, ffi::AdwPasswordEntryRowClass>) @extends EntryRow, PreferencesRow, gtk::ListBoxRow, gtk::Widget, @implements gtk::Accessible, gtk::Buildable, gtk::ConstraintTarget, gtk::Actionable, gtk::Editable;
32
33    match fn {
34        type_ => || ffi::adw_password_entry_row_get_type(),
35    }
36}
37
38#[cfg(not(feature = "gtk_v4_10"))]
39glib::wrapper! {
40    #[doc(alias = "AdwPasswordEntryRow")]
41    pub struct PasswordEntryRow(Object<ffi::AdwPasswordEntryRow, ffi::AdwPasswordEntryRowClass>) @extends EntryRow, PreferencesRow, gtk::ListBoxRow, gtk::Widget, @implements gtk::Buildable, gtk::ConstraintTarget, gtk::Actionable, gtk::Editable;
42
43    match fn {
44        type_ => || ffi::adw_password_entry_row_get_type(),
45    }
46}
47
48impl PasswordEntryRow {
49    /// Creates a new [`PasswordEntryRow`][crate::PasswordEntryRow].
50    ///
51    /// # Returns
52    ///
53    /// the newly created [`PasswordEntryRow`][crate::PasswordEntryRow]
54    #[doc(alias = "adw_password_entry_row_new")]
55    pub fn new() -> PasswordEntryRow {
56        assert_initialized_main_thread!();
57        unsafe { gtk::Widget::from_glib_none(ffi::adw_password_entry_row_new()).unsafe_cast() }
58    }
59
60    // rustdoc-stripper-ignore-next
61    /// Creates a new builder-pattern struct instance to construct [`PasswordEntryRow`] objects.
62    ///
63    /// This method returns an instance of [`PasswordEntryRowBuilder`](crate::builders::PasswordEntryRowBuilder) which can be used to create [`PasswordEntryRow`] objects.
64    pub fn builder() -> PasswordEntryRowBuilder {
65        PasswordEntryRowBuilder::new()
66    }
67}
68
69#[cfg(feature = "v1_2")]
70#[cfg_attr(docsrs, doc(cfg(feature = "v1_2")))]
71impl Default for PasswordEntryRow {
72    fn default() -> Self {
73        Self::new()
74    }
75}
76
77// rustdoc-stripper-ignore-next
78/// A [builder-pattern] type to construct [`PasswordEntryRow`] objects.
79///
80/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
81#[must_use = "The builder must be built to be used"]
82pub struct PasswordEntryRowBuilder {
83    builder: glib::object::ObjectBuilder<'static, PasswordEntryRow>,
84}
85
86impl PasswordEntryRowBuilder {
87    fn new() -> Self {
88        Self {
89            builder: glib::object::Object::builder(),
90        }
91    }
92
93    /// Whether activating the embedded entry can activate the default widget.
94    #[cfg(feature = "v1_2")]
95    #[cfg_attr(docsrs, doc(cfg(feature = "v1_2")))]
96    pub fn activates_default(self, activates_default: bool) -> Self {
97        Self {
98            builder: self
99                .builder
100                .property("activates-default", activates_default),
101        }
102    }
103
104    /// A list of Pango attributes to apply to the text of the embedded entry.
105    ///
106    /// The `Pango::Attribute`'s `start_index` and `end_index` must refer to
107    /// the `Gtk::EntryBuffer` text, i.e. without the preedit string.
108    #[cfg(feature = "v1_2")]
109    #[cfg_attr(docsrs, doc(cfg(feature = "v1_2")))]
110    pub fn attributes(self, attributes: &pango::AttrList) -> Self {
111        Self {
112            builder: self.builder.property("attributes", attributes.clone()),
113        }
114    }
115
116    /// Whether to suggest emoji replacements on the entry row.
117    ///
118    /// Emoji replacement is done with :-delimited names, like `:heart:`.
119    #[cfg(feature = "v1_2")]
120    #[cfg_attr(docsrs, doc(cfg(feature = "v1_2")))]
121    pub fn enable_emoji_completion(self, enable_emoji_completion: bool) -> Self {
122        Self {
123            builder: self
124                .builder
125                .property("enable-emoji-completion", enable_emoji_completion),
126        }
127    }
128
129    /// Additional input hints for the entry row.
130    ///
131    /// Input hints allow input methods to fine-tune their behavior.
132    ///
133    /// See also: [`input-purpose`][struct@crate::EntryRow#input-purpose]
134    #[cfg(feature = "v1_2")]
135    #[cfg_attr(docsrs, doc(cfg(feature = "v1_2")))]
136    pub fn input_hints(self, input_hints: gtk::InputHints) -> Self {
137        Self {
138            builder: self.builder.property("input-hints", input_hints),
139        }
140    }
141
142    /// The input purpose of the entry row.
143    ///
144    /// The input purpose can be used by input methods to adjust their behavior.
145    #[cfg(feature = "v1_2")]
146    #[cfg_attr(docsrs, doc(cfg(feature = "v1_2")))]
147    pub fn input_purpose(self, input_purpose: gtk::InputPurpose) -> Self {
148        Self {
149            builder: self.builder.property("input-purpose", input_purpose),
150        }
151    }
152
153    /// Maximum number of characters for the entry.
154    #[cfg(feature = "v1_6")]
155    #[cfg_attr(docsrs, doc(cfg(feature = "v1_6")))]
156    pub fn max_length(self, max_length: i32) -> Self {
157        Self {
158            builder: self.builder.property("max-length", max_length),
159        }
160    }
161
162    ///  key will hide the button and
163    /// emit the [`apply`][struct@crate::EntryRow#apply] signal.
164    ///
165    /// This is useful if changing the entry contents can trigger an expensive
166    /// operation, e.g. network activity, to avoid triggering it after typing every
167    /// character.
168    #[cfg(feature = "v1_2")]
169    #[cfg_attr(docsrs, doc(cfg(feature = "v1_2")))]
170    pub fn show_apply_button(self, show_apply_button: bool) -> Self {
171        Self {
172            builder: self
173                .builder
174                .property("show-apply-button", show_apply_button),
175        }
176    }
177
178    /// The title of the preference represented by this row.
179    ///
180    /// The title is interpreted as Pango markup unless
181    /// [`use-markup`][struct@crate::PreferencesRow#use-markup] is set to `FALSE`.
182    pub fn title(self, title: impl Into<glib::GString>) -> Self {
183        Self {
184            builder: self.builder.property("title", title.into()),
185        }
186    }
187
188    /// Whether the user can copy the title from the label.
189    ///
190    /// See also [`selectable`][struct@crate::Gtk::Label#selectable].
191    #[cfg(feature = "v1_1")]
192    #[cfg_attr(docsrs, doc(cfg(feature = "v1_1")))]
193    pub fn title_selectable(self, title_selectable: bool) -> Self {
194        Self {
195            builder: self.builder.property("title-selectable", title_selectable),
196        }
197    }
198
199    /// Whether to use Pango markup for the title label.
200    ///
201    /// Subclasses may also use it for other labels, such as subtitle.
202    ///
203    /// See also `parse_markup()`.
204    #[cfg(feature = "v1_2")]
205    #[cfg_attr(docsrs, doc(cfg(feature = "v1_2")))]
206    pub fn use_markup(self, use_markup: bool) -> Self {
207        Self {
208            builder: self.builder.property("use-markup", use_markup),
209        }
210    }
211
212    /// Whether an embedded underline in the title indicates a mnemonic.
213    pub fn use_underline(self, use_underline: bool) -> Self {
214        Self {
215            builder: self.builder.property("use-underline", use_underline),
216        }
217    }
218
219    /// Determines whether the ::row-activated
220    /// signal will be emitted for this row.
221    pub fn activatable(self, activatable: bool) -> Self {
222        Self {
223            builder: self.builder.property("activatable", activatable),
224        }
225    }
226
227    /// The child widget.
228    pub fn child(self, child: &impl IsA<gtk::Widget>) -> Self {
229        Self {
230            builder: self.builder.property("child", child.clone().upcast()),
231        }
232    }
233
234    /// Determines whether this row can be selected.
235    pub fn selectable(self, selectable: bool) -> Self {
236        Self {
237            builder: self.builder.property("selectable", selectable),
238        }
239    }
240
241    /// Whether the widget or any of its descendents can accept
242    /// the input focus.
243    ///
244    /// This property is meant to be set by widget implementations,
245    /// typically in their instance init function.
246    pub fn can_focus(self, can_focus: bool) -> Self {
247        Self {
248            builder: self.builder.property("can-focus", can_focus),
249        }
250    }
251
252    /// Whether the widget can receive pointer events.
253    pub fn can_target(self, can_target: bool) -> Self {
254        Self {
255            builder: self.builder.property("can-target", can_target),
256        }
257    }
258
259    /// A list of css classes applied to this widget.
260    pub fn css_classes(self, css_classes: impl Into<glib::StrV>) -> Self {
261        Self {
262            builder: self.builder.property("css-classes", css_classes.into()),
263        }
264    }
265
266    /// The name of this widget in the CSS tree.
267    ///
268    /// This property is meant to be set by widget implementations,
269    /// typically in their instance init function.
270    pub fn css_name(self, css_name: impl Into<glib::GString>) -> Self {
271        Self {
272            builder: self.builder.property("css-name", css_name.into()),
273        }
274    }
275
276    /// The cursor used by @widget.
277    pub fn cursor(self, cursor: &gdk::Cursor) -> Self {
278        Self {
279            builder: self.builder.property("cursor", cursor.clone()),
280        }
281    }
282
283    /// Whether the widget should grab focus when it is clicked with the mouse.
284    ///
285    /// This property is only relevant for widgets that can take focus.
286    pub fn focus_on_click(self, focus_on_click: bool) -> Self {
287        Self {
288            builder: self.builder.property("focus-on-click", focus_on_click),
289        }
290    }
291
292    /// Whether this widget itself will accept the input focus.
293    pub fn focusable(self, focusable: bool) -> Self {
294        Self {
295            builder: self.builder.property("focusable", focusable),
296        }
297    }
298
299    /// How to distribute horizontal space if widget gets extra space.
300    pub fn halign(self, halign: gtk::Align) -> Self {
301        Self {
302            builder: self.builder.property("halign", halign),
303        }
304    }
305
306    /// Enables or disables the emission of the [`query-tooltip`][struct@crate::gtk::Widget#query-tooltip]
307    /// signal on @widget.
308    ///
309    /// A true value indicates that @widget can have a tooltip, in this case
310    /// the widget will be queried using [`query-tooltip`][struct@crate::gtk::Widget#query-tooltip] to
311    /// determine whether it will provide a tooltip or not.
312    pub fn has_tooltip(self, has_tooltip: bool) -> Self {
313        Self {
314            builder: self.builder.property("has-tooltip", has_tooltip),
315        }
316    }
317
318    /// Overrides for height request of the widget.
319    ///
320    /// If this is -1, the natural request will be used.
321    pub fn height_request(self, height_request: i32) -> Self {
322        Self {
323            builder: self.builder.property("height-request", height_request),
324        }
325    }
326
327    /// Whether to expand horizontally.
328    pub fn hexpand(self, hexpand: bool) -> Self {
329        Self {
330            builder: self.builder.property("hexpand", hexpand),
331        }
332    }
333
334    /// Whether to use the `hexpand` property.
335    pub fn hexpand_set(self, hexpand_set: bool) -> Self {
336        Self {
337            builder: self.builder.property("hexpand-set", hexpand_set),
338        }
339    }
340
341    /// The [`gtk::LayoutManager`][crate::gtk::LayoutManager] instance to use to compute
342    /// the preferred size of the widget, and allocate its children.
343    ///
344    /// This property is meant to be set by widget implementations,
345    /// typically in their instance init function.
346    pub fn layout_manager(self, layout_manager: &impl IsA<gtk::LayoutManager>) -> Self {
347        Self {
348            builder: self
349                .builder
350                .property("layout-manager", layout_manager.clone().upcast()),
351        }
352    }
353
354    /// Makes this widget act like a modal dialog, with respect to
355    /// event delivery.
356    ///
357    /// Global event controllers will not handle events with targets
358    /// inside the widget, unless they are set up to ignore propagation
359    /// limits. See `Gtk::EventController::set_propagation_limit()`.
360    #[cfg(feature = "gtk_v4_18")]
361    #[cfg_attr(docsrs, doc(cfg(feature = "gtk_v4_18")))]
362    pub fn limit_events(self, limit_events: bool) -> Self {
363        Self {
364            builder: self.builder.property("limit-events", limit_events),
365        }
366    }
367
368    /// Margin on bottom side of widget.
369    ///
370    /// This property adds margin outside of the widget's normal size
371    /// request, the margin will be added in addition to the size from
372    /// [`WidgetExtManual::set_size_request()`][crate::gtk::prelude::WidgetExtManual::set_size_request()] for example.
373    pub fn margin_bottom(self, margin_bottom: i32) -> Self {
374        Self {
375            builder: self.builder.property("margin-bottom", margin_bottom),
376        }
377    }
378
379    /// Margin on end of widget, horizontally.
380    ///
381    /// This property supports left-to-right and right-to-left text
382    /// directions.
383    ///
384    /// This property adds margin outside of the widget's normal size
385    /// request, the margin will be added in addition to the size from
386    /// [`WidgetExtManual::set_size_request()`][crate::gtk::prelude::WidgetExtManual::set_size_request()] for example.
387    pub fn margin_end(self, margin_end: i32) -> Self {
388        Self {
389            builder: self.builder.property("margin-end", margin_end),
390        }
391    }
392
393    /// Margin on start of widget, horizontally.
394    ///
395    /// This property supports left-to-right and right-to-left text
396    /// directions.
397    ///
398    /// This property adds margin outside of the widget's normal size
399    /// request, the margin will be added in addition to the size from
400    /// [`WidgetExtManual::set_size_request()`][crate::gtk::prelude::WidgetExtManual::set_size_request()] for example.
401    pub fn margin_start(self, margin_start: i32) -> Self {
402        Self {
403            builder: self.builder.property("margin-start", margin_start),
404        }
405    }
406
407    /// Margin on top side of widget.
408    ///
409    /// This property adds margin outside of the widget's normal size
410    /// request, the margin will be added in addition to the size from
411    /// [`WidgetExtManual::set_size_request()`][crate::gtk::prelude::WidgetExtManual::set_size_request()] for example.
412    pub fn margin_top(self, margin_top: i32) -> Self {
413        Self {
414            builder: self.builder.property("margin-top", margin_top),
415        }
416    }
417
418    /// The name of the widget.
419    pub fn name(self, name: impl Into<glib::GString>) -> Self {
420        Self {
421            builder: self.builder.property("name", name.into()),
422        }
423    }
424
425    /// The requested opacity of the widget.
426    pub fn opacity(self, opacity: f64) -> Self {
427        Self {
428            builder: self.builder.property("opacity", opacity),
429        }
430    }
431
432    /// How content outside the widget's content area is treated.
433    ///
434    /// This property is meant to be set by widget implementations,
435    /// typically in their instance init function.
436    pub fn overflow(self, overflow: gtk::Overflow) -> Self {
437        Self {
438            builder: self.builder.property("overflow", overflow),
439        }
440    }
441
442    /// Whether the widget will receive the default action when it is focused.
443    pub fn receives_default(self, receives_default: bool) -> Self {
444        Self {
445            builder: self.builder.property("receives-default", receives_default),
446        }
447    }
448
449    /// Whether the widget responds to input.
450    pub fn sensitive(self, sensitive: bool) -> Self {
451        Self {
452            builder: self.builder.property("sensitive", sensitive),
453        }
454    }
455
456    /// Sets the text of tooltip to be the given string, which is marked up
457    /// with Pango markup.
458    ///
459    /// Also see `Gtk::Tooltip::set_markup()`.
460    ///
461    /// This is a convenience property which will take care of getting the
462    /// tooltip shown if the given string is not `NULL`:
463    /// [`has-tooltip`][struct@crate::gtk::Widget#has-tooltip] will automatically be set to true
464    /// and there will be taken care of [`query-tooltip`][struct@crate::gtk::Widget#query-tooltip] in
465    /// the default signal handler.
466    ///
467    /// Note that if both [`tooltip-text`][struct@crate::gtk::Widget#tooltip-text] and
468    /// [`tooltip-markup`][struct@crate::gtk::Widget#tooltip-markup] are set, the last one wins.
469    pub fn tooltip_markup(self, tooltip_markup: impl Into<glib::GString>) -> Self {
470        Self {
471            builder: self
472                .builder
473                .property("tooltip-markup", tooltip_markup.into()),
474        }
475    }
476
477    /// Sets the text of tooltip to be the given string.
478    ///
479    /// Also see `Gtk::Tooltip::set_text()`.
480    ///
481    /// This is a convenience property which will take care of getting the
482    /// tooltip shown if the given string is not `NULL`:
483    /// [`has-tooltip`][struct@crate::gtk::Widget#has-tooltip] will automatically be set to true
484    /// and there will be taken care of [`query-tooltip`][struct@crate::gtk::Widget#query-tooltip] in
485    /// the default signal handler.
486    ///
487    /// Note that if both [`tooltip-text`][struct@crate::gtk::Widget#tooltip-text] and
488    /// [`tooltip-markup`][struct@crate::gtk::Widget#tooltip-markup] are set, the last one wins.
489    pub fn tooltip_text(self, tooltip_text: impl Into<glib::GString>) -> Self {
490        Self {
491            builder: self.builder.property("tooltip-text", tooltip_text.into()),
492        }
493    }
494
495    /// How to distribute vertical space if widget gets extra space.
496    pub fn valign(self, valign: gtk::Align) -> Self {
497        Self {
498            builder: self.builder.property("valign", valign),
499        }
500    }
501
502    /// Whether to expand vertically.
503    pub fn vexpand(self, vexpand: bool) -> Self {
504        Self {
505            builder: self.builder.property("vexpand", vexpand),
506        }
507    }
508
509    /// Whether to use the `vexpand` property.
510    pub fn vexpand_set(self, vexpand_set: bool) -> Self {
511        Self {
512            builder: self.builder.property("vexpand-set", vexpand_set),
513        }
514    }
515
516    /// Whether the widget is visible.
517    pub fn visible(self, visible: bool) -> Self {
518        Self {
519            builder: self.builder.property("visible", visible),
520        }
521    }
522
523    /// Overrides for width request of the widget.
524    ///
525    /// If this is -1, the natural request will be used.
526    pub fn width_request(self, width_request: i32) -> Self {
527        Self {
528            builder: self.builder.property("width-request", width_request),
529        }
530    }
531
532    /// The accessible role of the given [`gtk::Accessible`][crate::gtk::Accessible] implementation.
533    ///
534    /// The accessible role cannot be changed once set.
535    pub fn accessible_role(self, accessible_role: gtk::AccessibleRole) -> Self {
536        Self {
537            builder: self.builder.property("accessible-role", accessible_role),
538        }
539    }
540
541    /// The name of the action with which this widget should be associated.
542    pub fn action_name(self, action_name: impl Into<glib::GString>) -> Self {
543        Self {
544            builder: self.builder.property("action-name", action_name.into()),
545        }
546    }
547
548    /// The target value of the actionable widget's action.
549    pub fn action_target(self, action_target: &glib::Variant) -> Self {
550        Self {
551            builder: self
552                .builder
553                .property("action-target", action_target.clone()),
554        }
555    }
556
557    /// Whether the entry contents can be edited.
558    pub fn editable(self, editable: bool) -> Self {
559        Self {
560            builder: self.builder.property("editable", editable),
561        }
562    }
563
564    /// If undo/redo should be enabled for the editable.
565    pub fn enable_undo(self, enable_undo: bool) -> Self {
566        Self {
567            builder: self.builder.property("enable-undo", enable_undo),
568        }
569    }
570
571    /// The desired maximum width of the entry, in characters.
572    pub fn max_width_chars(self, max_width_chars: i32) -> Self {
573        Self {
574            builder: self.builder.property("max-width-chars", max_width_chars),
575        }
576    }
577
578    /// The contents of the entry.
579    pub fn text(self, text: impl Into<glib::GString>) -> Self {
580        Self {
581            builder: self.builder.property("text", text.into()),
582        }
583    }
584
585    /// Number of characters to leave space for in the entry.
586    pub fn width_chars(self, width_chars: i32) -> Self {
587        Self {
588            builder: self.builder.property("width-chars", width_chars),
589        }
590    }
591
592    /// The horizontal alignment, from 0 (left) to 1 (right).
593    ///
594    /// Reversed for RTL layouts.
595    pub fn xalign(self, xalign: f32) -> Self {
596        Self {
597            builder: self.builder.property("xalign", xalign),
598        }
599    }
600
601    // rustdoc-stripper-ignore-next
602    /// Build the [`PasswordEntryRow`].
603    #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
604    pub fn build(self) -> PasswordEntryRow {
605        assert_initialized_main_thread!();
606        self.builder.build()
607    }
608}