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