gtk4/auto/editable_label.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::{prelude::*, translate::*};
13
14#[cfg(feature = "v4_10")]
15#[cfg_attr(docsrs, doc(cfg(feature = "v4_10")))]
16glib::wrapper! {
17 /// Allows users to edit the displayed text by switching to an “edit mode”.
18 ///
19 /// <picture>
20 /// <source srcset="editable-label-dark.png" media="(prefers-color-scheme: dark)">
21 /// <img alt="An example GtkEditableLabel" src="editable-label.png">
22 /// </picture>
23 ///
24 /// [`EditableLabel`][crate::EditableLabel] does not have API of its own, but it
25 /// implements the [`Editable`][crate::Editable] interface.
26 ///
27 /// The default bindings for activating the edit mode is
28 /// to click or press the Enter key. The default bindings
29 /// for leaving the edit mode are the Enter key (to save
30 /// the results) or the Escape key (to cancel the editing).
31 ///
32 /// # Shortcuts and Gestures
33 ///
34 /// [`EditableLabel`][crate::EditableLabel] supports the following keyboard shortcuts:
35 ///
36 /// - <kbd>Enter</kbd> starts editing.
37 /// - <kbd>Escape</kbd> stops editing.
38 ///
39 /// # Actions
40 ///
41 /// [`EditableLabel`][crate::EditableLabel] defines a set of built-in actions:
42 ///
43 /// - `editing.starts` switches the widget into editing mode.
44 /// - `editing.stop` switches the widget out of editing mode.
45 ///
46 /// # CSS nodes
47 ///
48 /// ```text
49 /// editablelabel[.editing]
50 /// ╰── stack
51 /// ├── label
52 /// ╰── text
53 /// ```
54 ///
55 /// [`EditableLabel`][crate::EditableLabel] has a main node with the name editablelabel.
56 /// When the entry is in editing mode, it gets the .editing style
57 /// class.
58 ///
59 /// For all the subnodes added to the text node in various situations,
60 /// see [`Text`][crate::Text].
61 ///
62 /// ## Properties
63 ///
64 ///
65 /// #### `editing`
66 /// This property is [`true`] while the widget is in edit mode.
67 ///
68 /// Readable | Writable
69 /// <details><summary><h4>Widget</h4></summary>
70 ///
71 ///
72 /// #### `can-focus`
73 /// Whether the widget or any of its descendents can accept
74 /// the input focus.
75 ///
76 /// This property is meant to be set by widget implementations,
77 /// typically in their instance init function.
78 ///
79 /// Readable | Writable
80 ///
81 ///
82 /// #### `can-target`
83 /// Whether the widget can receive pointer events.
84 ///
85 /// Readable | Writable
86 ///
87 ///
88 /// #### `css-classes`
89 /// A list of css classes applied to this widget.
90 ///
91 /// Readable | Writable
92 ///
93 ///
94 /// #### `css-name`
95 /// The name of this widget in the CSS tree.
96 ///
97 /// This property is meant to be set by widget implementations,
98 /// typically in their instance init function.
99 ///
100 /// Readable | Writable | Construct Only
101 ///
102 ///
103 /// #### `cursor`
104 /// The cursor used by @widget.
105 ///
106 /// Readable | Writable
107 ///
108 ///
109 /// #### `focus-on-click`
110 /// Whether the widget should grab focus when it is clicked with the mouse.
111 ///
112 /// This property is only relevant for widgets that can take focus.
113 ///
114 /// Readable | Writable
115 ///
116 ///
117 /// #### `focusable`
118 /// Whether this widget itself will accept the input focus.
119 ///
120 /// Readable | Writable
121 ///
122 ///
123 /// #### `halign`
124 /// How to distribute horizontal space if widget gets extra space.
125 ///
126 /// Readable | Writable
127 ///
128 ///
129 /// #### `has-default`
130 /// Whether the widget is the default widget.
131 ///
132 /// Readable
133 ///
134 ///
135 /// #### `has-focus`
136 /// Whether the widget has the input focus.
137 ///
138 /// Readable
139 ///
140 ///
141 /// #### `has-tooltip`
142 /// Enables or disables the emission of the [`query-tooltip`][struct@crate::Widget#query-tooltip]
143 /// signal on @widget.
144 ///
145 /// A true value indicates that @widget can have a tooltip, in this case
146 /// the widget will be queried using [`query-tooltip`][struct@crate::Widget#query-tooltip] to
147 /// determine whether it will provide a tooltip or not.
148 ///
149 /// Readable | Writable
150 ///
151 ///
152 /// #### `height-request`
153 /// Overrides for height request of the widget.
154 ///
155 /// If this is -1, the natural request will be used.
156 ///
157 /// Readable | Writable
158 ///
159 ///
160 /// #### `hexpand`
161 /// Whether to expand horizontally.
162 ///
163 /// Readable | Writable
164 ///
165 ///
166 /// #### `hexpand-set`
167 /// Whether to use the `hexpand` property.
168 ///
169 /// Readable | Writable
170 ///
171 ///
172 /// #### `layout-manager`
173 /// The [`LayoutManager`][crate::LayoutManager] instance to use to compute
174 /// the preferred size of the widget, and allocate its children.
175 ///
176 /// This property is meant to be set by widget implementations,
177 /// typically in their instance init function.
178 ///
179 /// Readable | Writable
180 ///
181 ///
182 /// #### `limit-events`
183 /// Makes this widget act like a modal dialog, with respect to
184 /// event delivery.
185 ///
186 /// Global event controllers will not handle events with targets
187 /// inside the widget, unless they are set up to ignore propagation
188 /// limits. See [`EventControllerExt::set_propagation_limit()`][crate::prelude::EventControllerExt::set_propagation_limit()].
189 ///
190 /// Readable | Writable
191 ///
192 ///
193 /// #### `margin-bottom`
194 /// Margin on bottom side of widget.
195 ///
196 /// This property adds margin outside of the widget's normal size
197 /// request, the margin will be added in addition to the size from
198 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
199 ///
200 /// Readable | Writable
201 ///
202 ///
203 /// #### `margin-end`
204 /// Margin on end of widget, horizontally.
205 ///
206 /// This property supports left-to-right and right-to-left text
207 /// directions.
208 ///
209 /// This property adds margin outside of the widget's normal size
210 /// request, the margin will be added in addition to the size from
211 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
212 ///
213 /// Readable | Writable
214 ///
215 ///
216 /// #### `margin-start`
217 /// Margin on start of widget, horizontally.
218 ///
219 /// This property supports left-to-right and right-to-left text
220 /// directions.
221 ///
222 /// This property adds margin outside of the widget's normal size
223 /// request, the margin will be added in addition to the size from
224 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
225 ///
226 /// Readable | Writable
227 ///
228 ///
229 /// #### `margin-top`
230 /// Margin on top side of widget.
231 ///
232 /// This property adds margin outside of the widget's normal size
233 /// request, the margin will be added in addition to the size from
234 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
235 ///
236 /// Readable | Writable
237 ///
238 ///
239 /// #### `name`
240 /// The name of the widget.
241 ///
242 /// Readable | Writable
243 ///
244 ///
245 /// #### `opacity`
246 /// The requested opacity of the widget.
247 ///
248 /// Readable | Writable
249 ///
250 ///
251 /// #### `overflow`
252 /// How content outside the widget's content area is treated.
253 ///
254 /// This property is meant to be set by widget implementations,
255 /// typically in their instance init function.
256 ///
257 /// Readable | Writable
258 ///
259 ///
260 /// #### `parent`
261 /// The parent widget of this widget.
262 ///
263 /// Readable
264 ///
265 ///
266 /// #### `receives-default`
267 /// Whether the widget will receive the default action when it is focused.
268 ///
269 /// Readable | Writable
270 ///
271 ///
272 /// #### `root`
273 /// The [`Root`][crate::Root] widget of the widget tree containing this widget.
274 ///
275 /// This will be `NULL` if the widget is not contained in a root widget.
276 ///
277 /// Readable
278 ///
279 ///
280 /// #### `scale-factor`
281 /// The scale factor of the widget.
282 ///
283 /// Readable
284 ///
285 ///
286 /// #### `sensitive`
287 /// Whether the widget responds to input.
288 ///
289 /// Readable | Writable
290 ///
291 ///
292 /// #### `tooltip-markup`
293 /// Sets the text of tooltip to be the given string, which is marked up
294 /// with Pango markup.
295 ///
296 /// Also see [`Tooltip::set_markup()`][crate::Tooltip::set_markup()].
297 ///
298 /// This is a convenience property which will take care of getting the
299 /// tooltip shown if the given string is not `NULL`:
300 /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
301 /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
302 /// the default signal handler.
303 ///
304 /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
305 /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
306 ///
307 /// Readable | Writable
308 ///
309 ///
310 /// #### `tooltip-text`
311 /// Sets the text of tooltip to be the given string.
312 ///
313 /// Also see [`Tooltip::set_text()`][crate::Tooltip::set_text()].
314 ///
315 /// This is a convenience property which will take care of getting the
316 /// tooltip shown if the given string is not `NULL`:
317 /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
318 /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
319 /// the default signal handler.
320 ///
321 /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
322 /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
323 ///
324 /// Readable | Writable
325 ///
326 ///
327 /// #### `valign`
328 /// How to distribute vertical space if widget gets extra space.
329 ///
330 /// Readable | Writable
331 ///
332 ///
333 /// #### `vexpand`
334 /// Whether to expand vertically.
335 ///
336 /// Readable | Writable
337 ///
338 ///
339 /// #### `vexpand-set`
340 /// Whether to use the `vexpand` property.
341 ///
342 /// Readable | Writable
343 ///
344 ///
345 /// #### `visible`
346 /// Whether the widget is visible.
347 ///
348 /// Readable | Writable
349 ///
350 ///
351 /// #### `width-request`
352 /// Overrides for width request of the widget.
353 ///
354 /// If this is -1, the natural request will be used.
355 ///
356 /// Readable | Writable
357 /// </details>
358 /// <details><summary><h4>Accessible</h4></summary>
359 ///
360 ///
361 /// #### `accessible-role`
362 /// The accessible role of the given [`Accessible`][crate::Accessible] implementation.
363 ///
364 /// The accessible role cannot be changed once set.
365 ///
366 /// Readable | Writable
367 /// </details>
368 /// <details><summary><h4>Editable</h4></summary>
369 ///
370 ///
371 /// #### `complete-text`
372 /// The contents of the entry, including uncommited content such as the
373 /// preedit.
374 ///
375 /// Readable
376 ///
377 ///
378 /// #### `cursor-position`
379 /// The current position of the insertion cursor in chars.
380 ///
381 /// Readable
382 ///
383 ///
384 /// #### `editable`
385 /// Whether the entry contents can be edited.
386 ///
387 /// Readable | Writable
388 ///
389 ///
390 /// #### `enable-undo`
391 /// If undo/redo should be enabled for the editable.
392 ///
393 /// Readable | Writable
394 ///
395 ///
396 /// #### `input-interceptor`
397 /// The widget used to intercept input for this editable
398 ///
399 /// Readable | Writable
400 ///
401 ///
402 /// #### `max-width-chars`
403 /// The desired maximum width of the entry, in characters.
404 ///
405 /// Readable | Writable
406 ///
407 ///
408 /// #### `selection-bound`
409 /// The position of the opposite end of the selection from the cursor in chars.
410 ///
411 /// Readable
412 ///
413 ///
414 /// #### `text`
415 /// The contents of the entry.
416 ///
417 /// Readable | Writable
418 ///
419 ///
420 /// #### `width-chars`
421 /// Number of characters to leave space for in the entry.
422 ///
423 /// Readable | Writable
424 ///
425 ///
426 /// #### `xalign`
427 /// The horizontal alignment, from 0 (left) to 1 (right).
428 ///
429 /// Reversed for RTL layouts.
430 ///
431 /// Readable | Writable
432 /// </details>
433 ///
434 /// # Implements
435 ///
436 /// [`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]
437 #[doc(alias = "GtkEditableLabel")]
438 pub struct EditableLabel(Object<ffi::GtkEditableLabel, ffi::GtkEditableLabelClass>) @extends Widget, @implements Accessible, Buildable, ConstraintTarget, Editable;
439
440 match fn {
441 type_ => || ffi::gtk_editable_label_get_type(),
442 }
443}
444
445#[cfg(not(feature = "v4_10"))]
446glib::wrapper! {
447 #[doc(alias = "GtkEditableLabel")]
448 pub struct EditableLabel(Object<ffi::GtkEditableLabel, ffi::GtkEditableLabelClass>) @extends Widget, @implements Buildable, ConstraintTarget, Editable;
449
450 match fn {
451 type_ => || ffi::gtk_editable_label_get_type(),
452 }
453}
454
455impl EditableLabel {
456 /// Creates a new [`EditableLabel`][crate::EditableLabel] widget.
457 /// ## `str`
458 /// the text for the label
459 ///
460 /// # Returns
461 ///
462 /// the new [`EditableLabel`][crate::EditableLabel]
463 #[doc(alias = "gtk_editable_label_new")]
464 pub fn new(str: &str) -> EditableLabel {
465 assert_initialized_main_thread!();
466 unsafe {
467 Widget::from_glib_none(ffi::gtk_editable_label_new(str.to_glib_none().0)).unsafe_cast()
468 }
469 }
470
471 // rustdoc-stripper-ignore-next
472 /// Creates a new builder-pattern struct instance to construct [`EditableLabel`] objects.
473 ///
474 /// This method returns an instance of [`EditableLabelBuilder`](crate::builders::EditableLabelBuilder) which can be used to create [`EditableLabel`] objects.
475 pub fn builder() -> EditableLabelBuilder {
476 EditableLabelBuilder::new()
477 }
478
479 /// Returns whether the label is currently in “editing mode”.
480 ///
481 /// # Returns
482 ///
483 /// [`true`] if @self is currently in editing mode
484 #[doc(alias = "gtk_editable_label_get_editing")]
485 #[doc(alias = "get_editing")]
486 #[doc(alias = "editing")]
487 pub fn is_editing(&self) -> bool {
488 unsafe { from_glib(ffi::gtk_editable_label_get_editing(self.to_glib_none().0)) }
489 }
490
491 /// Switches the label into “editing mode”.
492 #[doc(alias = "gtk_editable_label_start_editing")]
493 pub fn start_editing(&self) {
494 unsafe {
495 ffi::gtk_editable_label_start_editing(self.to_glib_none().0);
496 }
497 }
498
499 /// Switches the label out of “editing mode”.
500 ///
501 /// If @commit is [`true`], the resulting text is kept as the
502 /// [`text`][struct@crate::Editable#text] property value, otherwise the
503 /// resulting text is discarded and the label will keep its
504 /// previous [`text`][struct@crate::Editable#text] property value.
505 /// ## `commit`
506 /// whether to set the edited text on the label
507 #[doc(alias = "gtk_editable_label_stop_editing")]
508 pub fn stop_editing(&self, commit: bool) {
509 unsafe {
510 ffi::gtk_editable_label_stop_editing(self.to_glib_none().0, commit.into_glib());
511 }
512 }
513
514 /// This property is [`true`] while the widget is in edit mode.
515 #[cfg(feature = "v4_8")]
516 #[cfg_attr(docsrs, doc(cfg(feature = "v4_8")))]
517 pub fn set_editing(&self, editing: bool) {
518 ObjectExt::set_property(self, "editing", editing)
519 }
520}
521
522impl Default for EditableLabel {
523 fn default() -> Self {
524 glib::object::Object::new::<Self>()
525 }
526}
527
528// rustdoc-stripper-ignore-next
529/// A [builder-pattern] type to construct [`EditableLabel`] objects.
530///
531/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
532#[must_use = "The builder must be built to be used"]
533pub struct EditableLabelBuilder {
534 builder: glib::object::ObjectBuilder<'static, EditableLabel>,
535}
536
537impl EditableLabelBuilder {
538 fn new() -> Self {
539 Self {
540 builder: glib::object::Object::builder(),
541 }
542 }
543
544 /// This property is [`true`] while the widget is in edit mode.
545 #[cfg(feature = "v4_8")]
546 #[cfg_attr(docsrs, doc(cfg(feature = "v4_8")))]
547 pub fn editing(self, editing: bool) -> Self {
548 Self {
549 builder: self.builder.property("editing", editing),
550 }
551 }
552
553 /// Whether the widget or any of its descendents can accept
554 /// the input focus.
555 ///
556 /// This property is meant to be set by widget implementations,
557 /// typically in their instance init function.
558 pub fn can_focus(self, can_focus: bool) -> Self {
559 Self {
560 builder: self.builder.property("can-focus", can_focus),
561 }
562 }
563
564 /// Whether the widget can receive pointer events.
565 pub fn can_target(self, can_target: bool) -> Self {
566 Self {
567 builder: self.builder.property("can-target", can_target),
568 }
569 }
570
571 /// A list of css classes applied to this widget.
572 pub fn css_classes(self, css_classes: impl Into<glib::StrV>) -> Self {
573 Self {
574 builder: self.builder.property("css-classes", css_classes.into()),
575 }
576 }
577
578 /// The name of this widget in the CSS tree.
579 ///
580 /// This property is meant to be set by widget implementations,
581 /// typically in their instance init function.
582 pub fn css_name(self, css_name: impl Into<glib::GString>) -> Self {
583 Self {
584 builder: self.builder.property("css-name", css_name.into()),
585 }
586 }
587
588 /// The cursor used by @widget.
589 pub fn cursor(self, cursor: &gdk::Cursor) -> Self {
590 Self {
591 builder: self.builder.property("cursor", cursor.clone()),
592 }
593 }
594
595 /// Whether the widget should grab focus when it is clicked with the mouse.
596 ///
597 /// This property is only relevant for widgets that can take focus.
598 pub fn focus_on_click(self, focus_on_click: bool) -> Self {
599 Self {
600 builder: self.builder.property("focus-on-click", focus_on_click),
601 }
602 }
603
604 /// Whether this widget itself will accept the input focus.
605 pub fn focusable(self, focusable: bool) -> Self {
606 Self {
607 builder: self.builder.property("focusable", focusable),
608 }
609 }
610
611 /// How to distribute horizontal space if widget gets extra space.
612 pub fn halign(self, halign: Align) -> Self {
613 Self {
614 builder: self.builder.property("halign", halign),
615 }
616 }
617
618 /// Enables or disables the emission of the [`query-tooltip`][struct@crate::Widget#query-tooltip]
619 /// signal on @widget.
620 ///
621 /// A true value indicates that @widget can have a tooltip, in this case
622 /// the widget will be queried using [`query-tooltip`][struct@crate::Widget#query-tooltip] to
623 /// determine whether it will provide a tooltip or not.
624 pub fn has_tooltip(self, has_tooltip: bool) -> Self {
625 Self {
626 builder: self.builder.property("has-tooltip", has_tooltip),
627 }
628 }
629
630 /// Overrides for height request of the widget.
631 ///
632 /// If this is -1, the natural request will be used.
633 pub fn height_request(self, height_request: i32) -> Self {
634 Self {
635 builder: self.builder.property("height-request", height_request),
636 }
637 }
638
639 /// Whether to expand horizontally.
640 pub fn hexpand(self, hexpand: bool) -> Self {
641 Self {
642 builder: self.builder.property("hexpand", hexpand),
643 }
644 }
645
646 /// Whether to use the `hexpand` property.
647 pub fn hexpand_set(self, hexpand_set: bool) -> Self {
648 Self {
649 builder: self.builder.property("hexpand-set", hexpand_set),
650 }
651 }
652
653 /// The [`LayoutManager`][crate::LayoutManager] instance to use to compute
654 /// the preferred size of the widget, and allocate its children.
655 ///
656 /// This property is meant to be set by widget implementations,
657 /// typically in their instance init function.
658 pub fn layout_manager(self, layout_manager: &impl IsA<LayoutManager>) -> Self {
659 Self {
660 builder: self
661 .builder
662 .property("layout-manager", layout_manager.clone().upcast()),
663 }
664 }
665
666 /// Makes this widget act like a modal dialog, with respect to
667 /// event delivery.
668 ///
669 /// Global event controllers will not handle events with targets
670 /// inside the widget, unless they are set up to ignore propagation
671 /// limits. See [`EventControllerExt::set_propagation_limit()`][crate::prelude::EventControllerExt::set_propagation_limit()].
672 #[cfg(feature = "v4_18")]
673 #[cfg_attr(docsrs, doc(cfg(feature = "v4_18")))]
674 pub fn limit_events(self, limit_events: bool) -> Self {
675 Self {
676 builder: self.builder.property("limit-events", limit_events),
677 }
678 }
679
680 /// Margin on bottom side of widget.
681 ///
682 /// This property adds margin outside of the widget's normal size
683 /// request, the margin will be added in addition to the size from
684 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
685 pub fn margin_bottom(self, margin_bottom: i32) -> Self {
686 Self {
687 builder: self.builder.property("margin-bottom", margin_bottom),
688 }
689 }
690
691 /// Margin on end of widget, horizontally.
692 ///
693 /// This property supports left-to-right and right-to-left text
694 /// directions.
695 ///
696 /// This property adds margin outside of the widget's normal size
697 /// request, the margin will be added in addition to the size from
698 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
699 pub fn margin_end(self, margin_end: i32) -> Self {
700 Self {
701 builder: self.builder.property("margin-end", margin_end),
702 }
703 }
704
705 /// Margin on start of widget, horizontally.
706 ///
707 /// This property supports left-to-right and right-to-left text
708 /// directions.
709 ///
710 /// This property adds margin outside of the widget's normal size
711 /// request, the margin will be added in addition to the size from
712 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
713 pub fn margin_start(self, margin_start: i32) -> Self {
714 Self {
715 builder: self.builder.property("margin-start", margin_start),
716 }
717 }
718
719 /// Margin on top side of widget.
720 ///
721 /// This property adds margin outside of the widget's normal size
722 /// request, the margin will be added in addition to the size from
723 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
724 pub fn margin_top(self, margin_top: i32) -> Self {
725 Self {
726 builder: self.builder.property("margin-top", margin_top),
727 }
728 }
729
730 /// The name of the widget.
731 pub fn name(self, name: impl Into<glib::GString>) -> Self {
732 Self {
733 builder: self.builder.property("name", name.into()),
734 }
735 }
736
737 /// The requested opacity of the widget.
738 pub fn opacity(self, opacity: f64) -> Self {
739 Self {
740 builder: self.builder.property("opacity", opacity),
741 }
742 }
743
744 /// How content outside the widget's content area is treated.
745 ///
746 /// This property is meant to be set by widget implementations,
747 /// typically in their instance init function.
748 pub fn overflow(self, overflow: Overflow) -> Self {
749 Self {
750 builder: self.builder.property("overflow", overflow),
751 }
752 }
753
754 /// Whether the widget will receive the default action when it is focused.
755 pub fn receives_default(self, receives_default: bool) -> Self {
756 Self {
757 builder: self.builder.property("receives-default", receives_default),
758 }
759 }
760
761 /// Whether the widget responds to input.
762 pub fn sensitive(self, sensitive: bool) -> Self {
763 Self {
764 builder: self.builder.property("sensitive", sensitive),
765 }
766 }
767
768 /// Sets the text of tooltip to be the given string, which is marked up
769 /// with Pango markup.
770 ///
771 /// Also see [`Tooltip::set_markup()`][crate::Tooltip::set_markup()].
772 ///
773 /// This is a convenience property which will take care of getting the
774 /// tooltip shown if the given string is not `NULL`:
775 /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
776 /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
777 /// the default signal handler.
778 ///
779 /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
780 /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
781 pub fn tooltip_markup(self, tooltip_markup: impl Into<glib::GString>) -> Self {
782 Self {
783 builder: self
784 .builder
785 .property("tooltip-markup", tooltip_markup.into()),
786 }
787 }
788
789 /// Sets the text of tooltip to be the given string.
790 ///
791 /// Also see [`Tooltip::set_text()`][crate::Tooltip::set_text()].
792 ///
793 /// This is a convenience property which will take care of getting the
794 /// tooltip shown if the given string is not `NULL`:
795 /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
796 /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
797 /// the default signal handler.
798 ///
799 /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
800 /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
801 pub fn tooltip_text(self, tooltip_text: impl Into<glib::GString>) -> Self {
802 Self {
803 builder: self.builder.property("tooltip-text", tooltip_text.into()),
804 }
805 }
806
807 /// How to distribute vertical space if widget gets extra space.
808 pub fn valign(self, valign: Align) -> Self {
809 Self {
810 builder: self.builder.property("valign", valign),
811 }
812 }
813
814 /// Whether to expand vertically.
815 pub fn vexpand(self, vexpand: bool) -> Self {
816 Self {
817 builder: self.builder.property("vexpand", vexpand),
818 }
819 }
820
821 /// Whether to use the `vexpand` property.
822 pub fn vexpand_set(self, vexpand_set: bool) -> Self {
823 Self {
824 builder: self.builder.property("vexpand-set", vexpand_set),
825 }
826 }
827
828 /// Whether the widget is visible.
829 pub fn visible(self, visible: bool) -> Self {
830 Self {
831 builder: self.builder.property("visible", visible),
832 }
833 }
834
835 /// Overrides for width request of the widget.
836 ///
837 /// If this is -1, the natural request will be used.
838 pub fn width_request(self, width_request: i32) -> Self {
839 Self {
840 builder: self.builder.property("width-request", width_request),
841 }
842 }
843
844 /// The accessible role of the given [`Accessible`][crate::Accessible] implementation.
845 ///
846 /// The accessible role cannot be changed once set.
847 pub fn accessible_role(self, accessible_role: AccessibleRole) -> Self {
848 Self {
849 builder: self.builder.property("accessible-role", accessible_role),
850 }
851 }
852
853 /// Whether the entry contents can be edited.
854 pub fn editable(self, editable: bool) -> Self {
855 Self {
856 builder: self.builder.property("editable", editable),
857 }
858 }
859
860 /// If undo/redo should be enabled for the editable.
861 pub fn enable_undo(self, enable_undo: bool) -> Self {
862 Self {
863 builder: self.builder.property("enable-undo", enable_undo),
864 }
865 }
866
867 /// The widget used to intercept input for this editable
868 #[cfg(feature = "v4_24")]
869 #[cfg_attr(docsrs, doc(cfg(feature = "v4_24")))]
870 pub fn input_interceptor(self, input_interceptor: &impl IsA<Widget>) -> Self {
871 Self {
872 builder: self
873 .builder
874 .property("input-interceptor", input_interceptor.clone().upcast()),
875 }
876 }
877
878 /// The desired maximum width of the entry, in characters.
879 pub fn max_width_chars(self, max_width_chars: i32) -> Self {
880 Self {
881 builder: self.builder.property("max-width-chars", max_width_chars),
882 }
883 }
884
885 /// The contents of the entry.
886 pub fn text(self, text: impl Into<glib::GString>) -> Self {
887 Self {
888 builder: self.builder.property("text", text.into()),
889 }
890 }
891
892 /// Number of characters to leave space for in the entry.
893 pub fn width_chars(self, width_chars: i32) -> Self {
894 Self {
895 builder: self.builder.property("width-chars", width_chars),
896 }
897 }
898
899 /// The horizontal alignment, from 0 (left) to 1 (right).
900 ///
901 /// Reversed for RTL layouts.
902 pub fn xalign(self, xalign: f32) -> Self {
903 Self {
904 builder: self.builder.property("xalign", xalign),
905 }
906 }
907
908 // rustdoc-stripper-ignore-next
909 /// Build the [`EditableLabel`].
910 #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
911 pub fn build(self) -> EditableLabel {
912 assert_initialized_main_thread!();
913 self.builder.build()
914 }
915}