libadwaita/auto/switch_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::{ffi, ActionRow, PreferencesRow};
7use glib::{
8 prelude::*,
9 signal::{connect_raw, SignalHandlerId},
10 translate::*,
11};
12use std::boxed::Box as Box_;
13
14glib::wrapper! {
15 /// A [`gtk::ListBoxRow`][crate::gtk::ListBoxRow] used to represent two states.
16 ///
17 /// <picture>
18 /// <source srcset="switch-row-dark.png" media="(prefers-color-scheme: dark)">
19 /// <img src="switch-row.png" alt="switch-row">
20 /// </picture>
21 ///
22 /// The [`SwitchRow`][crate::SwitchRow] widget contains a `Gtk::Switch` that allows the user
23 /// to select between two states: "on" or "off". When activated, the row will
24 /// invert its active state.
25 ///
26 /// The user can control the switch by activating the row or by dragging on the
27 /// switch handle.
28 ///
29 /// See `Gtk::Switch` for details.
30 ///
31 /// Example of an [`SwitchRow`][crate::SwitchRow] UI definition:
32 /// ```xml
33 /// <object class="AdwSwitchRow">
34 /// <property name="title" translatable="yes">Switch Row</property>
35 /// <signal name="notify::active" handler="switch_row_notify_active_cb"/>
36 /// </object>
37 /// ```
38 ///
39 /// The [`active`][struct@crate::SwitchRow#active] property should be connected to in order to
40 /// monitor changes to the active state.
41 ///
42 /// ## Accessibility
43 ///
44 /// [`SwitchRow`][crate::SwitchRow] uses the `GTK_ACCESSIBLE_ROLE_SWITCH` role.
45 ///
46 /// ## Properties
47 ///
48 ///
49 /// #### `active`
50 /// Whether the switch row is in the "on" or "off" position.
51 ///
52 /// Readable | Writeable
53 /// <details><summary><h4>ActionRow</h4></summary>
54 ///
55 ///
56 /// #### `activatable-widget`
57 /// The widget to activate when the row is activated.
58 ///
59 /// The row can be activated either by clicking on it, calling
60 /// [`ActionRowExt::activate()`][crate::prelude::ActionRowExt::activate()], or via mnemonics in the title.
61 /// See the [`use-underline`][struct@crate::PreferencesRow#use-underline] property to enable
62 /// mnemonics.
63 ///
64 /// The target widget will be activated by emitting the
65 /// [`mnemonic-activate`][struct@crate::gtk::Widget#mnemonic-activate] signal on it.
66 ///
67 /// Readable | Writeable
68 ///
69 ///
70 /// #### `icon-name`
71 /// The icon name for this row.
72 ///
73 /// Readable | Writeable
74 ///
75 ///
76 /// #### `subtitle`
77 /// The subtitle for this row.
78 ///
79 /// The subtitle is interpreted as Pango markup unless
80 /// [`use-markup`][struct@crate::PreferencesRow#use-markup] is set to `FALSE`.
81 ///
82 /// Readable | Writeable
83 ///
84 ///
85 /// #### `subtitle-lines`
86 /// The number of lines at the end of which the subtitle label will be
87 /// ellipsized.
88 ///
89 /// If the value is 0, the number of lines won't be limited.
90 ///
91 /// Readable | Writeable
92 ///
93 ///
94 /// #### `subtitle-selectable`
95 /// Whether the user can copy the subtitle from the label.
96 ///
97 /// See also [`selectable`][struct@crate::Gtk::Label#selectable].
98 ///
99 /// Readable | Writeable
100 ///
101 ///
102 /// #### `title-lines`
103 /// The number of lines at the end of which the title label will be ellipsized.
104 ///
105 /// If the value is 0, the number of lines won't be limited.
106 ///
107 /// Readable | Writeable
108 /// </details>
109 /// <details><summary><h4>PreferencesRow</h4></summary>
110 ///
111 ///
112 /// #### `title`
113 /// The title of the preference represented by this row.
114 ///
115 /// The title is interpreted as Pango markup unless
116 /// [`use-markup`][struct@crate::PreferencesRow#use-markup] is set to `FALSE`.
117 ///
118 /// Readable | Writeable
119 ///
120 ///
121 /// #### `title-selectable`
122 /// Whether the user can copy the title from the label.
123 ///
124 /// See also [`selectable`][struct@crate::Gtk::Label#selectable].
125 ///
126 /// Readable | Writeable
127 ///
128 ///
129 /// #### `use-markup`
130 /// Whether to use Pango markup for the title label.
131 ///
132 /// Subclasses may also use it for other labels, such as subtitle.
133 ///
134 /// See also `parse_markup()`.
135 ///
136 /// Readable | Writeable
137 ///
138 ///
139 /// #### `use-underline`
140 /// Whether an embedded underline in the title indicates a mnemonic.
141 ///
142 /// Readable | Writeable
143 /// </details>
144 /// <details><summary><h4>ListBoxRow</h4></summary>
145 ///
146 ///
147 /// #### `activatable`
148 /// Determines whether the ::row-activated
149 /// signal will be emitted for this row.
150 ///
151 /// Readable | Writeable
152 ///
153 ///
154 /// #### `child`
155 /// The child widget.
156 ///
157 /// Readable | Writeable
158 ///
159 ///
160 /// #### `selectable`
161 /// Determines whether this row can be selected.
162 ///
163 /// Readable | Writeable
164 /// </details>
165 /// <details><summary><h4>Widget</h4></summary>
166 ///
167 ///
168 /// #### `can-focus`
169 /// Whether the widget or any of its descendents can accept
170 /// the input focus.
171 ///
172 /// This property is meant to be set by widget implementations,
173 /// typically in their instance init function.
174 ///
175 /// Readable | Writeable
176 ///
177 ///
178 /// #### `can-target`
179 /// Whether the widget can receive pointer events.
180 ///
181 /// Readable | Writeable
182 ///
183 ///
184 /// #### `css-classes`
185 /// A list of css classes applied to this widget.
186 ///
187 /// Readable | Writeable
188 ///
189 ///
190 /// #### `css-name`
191 /// The name of this widget in the CSS tree.
192 ///
193 /// This property is meant to be set by widget implementations,
194 /// typically in their instance init function.
195 ///
196 /// Readable | Writeable | Construct Only
197 ///
198 ///
199 /// #### `cursor`
200 /// The cursor used by @widget.
201 ///
202 /// Readable | Writeable
203 ///
204 ///
205 /// #### `focus-on-click`
206 /// Whether the widget should grab focus when it is clicked with the mouse.
207 ///
208 /// This property is only relevant for widgets that can take focus.
209 ///
210 /// Readable | Writeable
211 ///
212 ///
213 /// #### `focusable`
214 /// Whether this widget itself will accept the input focus.
215 ///
216 /// Readable | Writeable
217 ///
218 ///
219 /// #### `halign`
220 /// How to distribute horizontal space if widget gets extra space.
221 ///
222 /// Readable | Writeable
223 ///
224 ///
225 /// #### `has-default`
226 /// Whether the widget is the default widget.
227 ///
228 /// Readable
229 ///
230 ///
231 /// #### `has-focus`
232 /// Whether the widget has the input focus.
233 ///
234 /// Readable
235 ///
236 ///
237 /// #### `has-tooltip`
238 /// Enables or disables the emission of the [`query-tooltip`][struct@crate::gtk::Widget#query-tooltip]
239 /// signal on @widget.
240 ///
241 /// A true value indicates that @widget can have a tooltip, in this case
242 /// the widget will be queried using [`query-tooltip`][struct@crate::gtk::Widget#query-tooltip] to
243 /// determine whether it will provide a tooltip or not.
244 ///
245 /// Readable | Writeable
246 ///
247 ///
248 /// #### `height-request`
249 /// Overrides for height request of the widget.
250 ///
251 /// If this is -1, the natural request will be used.
252 ///
253 /// Readable | Writeable
254 ///
255 ///
256 /// #### `hexpand`
257 /// Whether to expand horizontally.
258 ///
259 /// Readable | Writeable
260 ///
261 ///
262 /// #### `hexpand-set`
263 /// Whether to use the `hexpand` property.
264 ///
265 /// Readable | Writeable
266 ///
267 ///
268 /// #### `layout-manager`
269 /// The [`gtk::LayoutManager`][crate::gtk::LayoutManager] instance to use to compute
270 /// the preferred size of the widget, and allocate its children.
271 ///
272 /// This property is meant to be set by widget implementations,
273 /// typically in their instance init function.
274 ///
275 /// Readable | Writeable
276 ///
277 ///
278 /// #### `limit-events`
279 /// Makes this widget act like a modal dialog, with respect to
280 /// event delivery.
281 ///
282 /// Global event controllers will not handle events with targets
283 /// inside the widget, unless they are set up to ignore propagation
284 /// limits. See `Gtk::EventController::set_propagation_limit()`.
285 ///
286 /// Readable | Writeable
287 ///
288 ///
289 /// #### `margin-bottom`
290 /// Margin on bottom side of widget.
291 ///
292 /// This property adds margin outside of the widget's normal size
293 /// request, the margin will be added in addition to the size from
294 /// [`WidgetExtManual::set_size_request()`][crate::gtk::prelude::WidgetExtManual::set_size_request()] for example.
295 ///
296 /// Readable | Writeable
297 ///
298 ///
299 /// #### `margin-end`
300 /// Margin on end of widget, horizontally.
301 ///
302 /// This property supports left-to-right and right-to-left text
303 /// directions.
304 ///
305 /// This property adds margin outside of the widget's normal size
306 /// request, the margin will be added in addition to the size from
307 /// [`WidgetExtManual::set_size_request()`][crate::gtk::prelude::WidgetExtManual::set_size_request()] for example.
308 ///
309 /// Readable | Writeable
310 ///
311 ///
312 /// #### `margin-start`
313 /// Margin on start of widget, horizontally.
314 ///
315 /// This property supports left-to-right and right-to-left text
316 /// directions.
317 ///
318 /// This property adds margin outside of the widget's normal size
319 /// request, the margin will be added in addition to the size from
320 /// [`WidgetExtManual::set_size_request()`][crate::gtk::prelude::WidgetExtManual::set_size_request()] for example.
321 ///
322 /// Readable | Writeable
323 ///
324 ///
325 /// #### `margin-top`
326 /// Margin on top side of widget.
327 ///
328 /// This property adds margin outside of the widget's normal size
329 /// request, the margin will be added in addition to the size from
330 /// [`WidgetExtManual::set_size_request()`][crate::gtk::prelude::WidgetExtManual::set_size_request()] for example.
331 ///
332 /// Readable | Writeable
333 ///
334 ///
335 /// #### `name`
336 /// The name of the widget.
337 ///
338 /// Readable | Writeable
339 ///
340 ///
341 /// #### `opacity`
342 /// The requested opacity of the widget.
343 ///
344 /// Readable | Writeable
345 ///
346 ///
347 /// #### `overflow`
348 /// How content outside the widget's content area is treated.
349 ///
350 /// This property is meant to be set by widget implementations,
351 /// typically in their instance init function.
352 ///
353 /// Readable | Writeable
354 ///
355 ///
356 /// #### `parent`
357 /// The parent widget of this widget.
358 ///
359 /// Readable
360 ///
361 ///
362 /// #### `receives-default`
363 /// Whether the widget will receive the default action when it is focused.
364 ///
365 /// Readable | Writeable
366 ///
367 ///
368 /// #### `root`
369 /// The [`gtk::Root`][crate::gtk::Root] widget of the widget tree containing this widget.
370 ///
371 /// This will be `NULL` if the widget is not contained in a root widget.
372 ///
373 /// Readable
374 ///
375 ///
376 /// #### `scale-factor`
377 /// The scale factor of the widget.
378 ///
379 /// Readable
380 ///
381 ///
382 /// #### `sensitive`
383 /// Whether the widget responds to input.
384 ///
385 /// Readable | Writeable
386 ///
387 ///
388 /// #### `tooltip-markup`
389 /// Sets the text of tooltip to be the given string, which is marked up
390 /// with Pango markup.
391 ///
392 /// Also see `Gtk::Tooltip::set_markup()`.
393 ///
394 /// This is a convenience property which will take care of getting the
395 /// tooltip shown if the given string is not `NULL`:
396 /// [`has-tooltip`][struct@crate::gtk::Widget#has-tooltip] will automatically be set to true
397 /// and there will be taken care of [`query-tooltip`][struct@crate::gtk::Widget#query-tooltip] in
398 /// the default signal handler.
399 ///
400 /// Note that if both [`tooltip-text`][struct@crate::gtk::Widget#tooltip-text] and
401 /// [`tooltip-markup`][struct@crate::gtk::Widget#tooltip-markup] are set, the last one wins.
402 ///
403 /// Readable | Writeable
404 ///
405 ///
406 /// #### `tooltip-text`
407 /// Sets the text of tooltip to be the given string.
408 ///
409 /// Also see `Gtk::Tooltip::set_text()`.
410 ///
411 /// This is a convenience property which will take care of getting the
412 /// tooltip shown if the given string is not `NULL`:
413 /// [`has-tooltip`][struct@crate::gtk::Widget#has-tooltip] will automatically be set to true
414 /// and there will be taken care of [`query-tooltip`][struct@crate::gtk::Widget#query-tooltip] in
415 /// the default signal handler.
416 ///
417 /// Note that if both [`tooltip-text`][struct@crate::gtk::Widget#tooltip-text] and
418 /// [`tooltip-markup`][struct@crate::gtk::Widget#tooltip-markup] are set, the last one wins.
419 ///
420 /// Readable | Writeable
421 ///
422 ///
423 /// #### `valign`
424 /// How to distribute vertical space if widget gets extra space.
425 ///
426 /// Readable | Writeable
427 ///
428 ///
429 /// #### `vexpand`
430 /// Whether to expand vertically.
431 ///
432 /// Readable | Writeable
433 ///
434 ///
435 /// #### `vexpand-set`
436 /// Whether to use the `vexpand` property.
437 ///
438 /// Readable | Writeable
439 ///
440 ///
441 /// #### `visible`
442 /// Whether the widget is visible.
443 ///
444 /// Readable | Writeable
445 ///
446 ///
447 /// #### `width-request`
448 /// Overrides for width request of the widget.
449 ///
450 /// If this is -1, the natural request will be used.
451 ///
452 /// Readable | Writeable
453 /// </details>
454 /// <details><summary><h4>Accessible</h4></summary>
455 ///
456 ///
457 /// #### `accessible-role`
458 /// The accessible role of the given [`gtk::Accessible`][crate::gtk::Accessible] implementation.
459 ///
460 /// The accessible role cannot be changed once set.
461 ///
462 /// Readable | Writeable
463 /// </details>
464 /// <details><summary><h4>Actionable</h4></summary>
465 ///
466 ///
467 /// #### `action-name`
468 /// The name of the action with which this widget should be associated.
469 ///
470 /// Readable | Writeable
471 ///
472 ///
473 /// #### `action-target`
474 /// The target value of the actionable widget's action.
475 ///
476 /// Readable | Writeable
477 /// </details>
478 ///
479 /// # Implements
480 ///
481 /// [`ActionRowExt`][trait@crate::prelude::ActionRowExt], [`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`]
482 #[doc(alias = "AdwSwitchRow")]
483 pub struct SwitchRow(Object<ffi::AdwSwitchRow, ffi::AdwSwitchRowClass>) @extends ActionRow, PreferencesRow, gtk::ListBoxRow, gtk::Widget, @implements gtk::Accessible, gtk::Buildable, gtk::ConstraintTarget, gtk::Actionable;
484
485 match fn {
486 type_ => || ffi::adw_switch_row_get_type(),
487 }
488}
489
490impl SwitchRow {
491 /// Creates a new [`SwitchRow`][crate::SwitchRow].
492 ///
493 /// # Returns
494 ///
495 /// the newly created [`SwitchRow`][crate::SwitchRow]
496 #[doc(alias = "adw_switch_row_new")]
497 pub fn new() -> SwitchRow {
498 assert_initialized_main_thread!();
499 unsafe { gtk::Widget::from_glib_none(ffi::adw_switch_row_new()).unsafe_cast() }
500 }
501
502 // rustdoc-stripper-ignore-next
503 /// Creates a new builder-pattern struct instance to construct [`SwitchRow`] objects.
504 ///
505 /// This method returns an instance of [`SwitchRowBuilder`](crate::builders::SwitchRowBuilder) which can be used to create [`SwitchRow`] objects.
506 pub fn builder() -> SwitchRowBuilder {
507 SwitchRowBuilder::new()
508 }
509
510 /// Gets whether @self is in its "on" or "off" position.
511 ///
512 /// # Returns
513 ///
514 /// whether @self is active or not
515 #[doc(alias = "adw_switch_row_get_active")]
516 #[doc(alias = "get_active")]
517 #[doc(alias = "active")]
518 pub fn is_active(&self) -> bool {
519 unsafe { from_glib(ffi::adw_switch_row_get_active(self.to_glib_none().0)) }
520 }
521
522 /// Sets whether @self is in its "on" or "off" position
523 /// ## `is_active`
524 /// whether @self should be active
525 #[doc(alias = "adw_switch_row_set_active")]
526 #[doc(alias = "active")]
527 pub fn set_active(&self, is_active: bool) {
528 unsafe {
529 ffi::adw_switch_row_set_active(self.to_glib_none().0, is_active.into_glib());
530 }
531 }
532
533 #[cfg(feature = "v1_4")]
534 #[cfg_attr(docsrs, doc(cfg(feature = "v1_4")))]
535 #[doc(alias = "active")]
536 pub fn connect_active_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
537 unsafe extern "C" fn notify_active_trampoline<F: Fn(&SwitchRow) + 'static>(
538 this: *mut ffi::AdwSwitchRow,
539 _param_spec: glib::ffi::gpointer,
540 f: glib::ffi::gpointer,
541 ) {
542 let f: &F = &*(f as *const F);
543 f(&from_glib_borrow(this))
544 }
545 unsafe {
546 let f: Box_<F> = Box_::new(f);
547 connect_raw(
548 self.as_ptr() as *mut _,
549 c"notify::active".as_ptr() as *const _,
550 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
551 notify_active_trampoline::<F> as *const (),
552 )),
553 Box_::into_raw(f),
554 )
555 }
556 }
557}
558
559#[cfg(feature = "v1_4")]
560#[cfg_attr(docsrs, doc(cfg(feature = "v1_4")))]
561impl Default for SwitchRow {
562 fn default() -> Self {
563 Self::new()
564 }
565}
566
567// rustdoc-stripper-ignore-next
568/// A [builder-pattern] type to construct [`SwitchRow`] objects.
569///
570/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
571#[must_use = "The builder must be built to be used"]
572pub struct SwitchRowBuilder {
573 builder: glib::object::ObjectBuilder<'static, SwitchRow>,
574}
575
576impl SwitchRowBuilder {
577 fn new() -> Self {
578 Self {
579 builder: glib::object::Object::builder(),
580 }
581 }
582
583 /// Whether the switch row is in the "on" or "off" position.
584 #[cfg(feature = "v1_4")]
585 #[cfg_attr(docsrs, doc(cfg(feature = "v1_4")))]
586 pub fn active(self, active: bool) -> Self {
587 Self {
588 builder: self.builder.property("active", active),
589 }
590 }
591
592 /// The widget to activate when the row is activated.
593 ///
594 /// The row can be activated either by clicking on it, calling
595 /// [`ActionRowExt::activate()`][crate::prelude::ActionRowExt::activate()], or via mnemonics in the title.
596 /// See the [`use-underline`][struct@crate::PreferencesRow#use-underline] property to enable
597 /// mnemonics.
598 ///
599 /// The target widget will be activated by emitting the
600 /// [`mnemonic-activate`][struct@crate::gtk::Widget#mnemonic-activate] signal on it.
601 pub fn activatable_widget(self, activatable_widget: &impl IsA<gtk::Widget>) -> Self {
602 Self {
603 builder: self
604 .builder
605 .property("activatable-widget", activatable_widget.clone().upcast()),
606 }
607 }
608
609 /// The icon name for this row.
610 /// Use [`ActionRowExt::add_prefix()`][crate::prelude::ActionRowExt::add_prefix()] to add an icon.
611 #[cfg_attr(feature = "v1_3", deprecated = "Since 1.3")]
612 pub fn icon_name(self, icon_name: impl Into<glib::GString>) -> Self {
613 Self {
614 builder: self.builder.property("icon-name", icon_name.into()),
615 }
616 }
617
618 /// The subtitle for this row.
619 ///
620 /// The subtitle is interpreted as Pango markup unless
621 /// [`use-markup`][struct@crate::PreferencesRow#use-markup] is set to `FALSE`.
622 pub fn subtitle(self, subtitle: impl Into<glib::GString>) -> Self {
623 Self {
624 builder: self.builder.property("subtitle", subtitle.into()),
625 }
626 }
627
628 /// The number of lines at the end of which the subtitle label will be
629 /// ellipsized.
630 ///
631 /// If the value is 0, the number of lines won't be limited.
632 pub fn subtitle_lines(self, subtitle_lines: i32) -> Self {
633 Self {
634 builder: self.builder.property("subtitle-lines", subtitle_lines),
635 }
636 }
637
638 /// Whether the user can copy the subtitle from the label.
639 ///
640 /// See also [`selectable`][struct@crate::Gtk::Label#selectable].
641 #[cfg(feature = "v1_3")]
642 #[cfg_attr(docsrs, doc(cfg(feature = "v1_3")))]
643 pub fn subtitle_selectable(self, subtitle_selectable: bool) -> Self {
644 Self {
645 builder: self
646 .builder
647 .property("subtitle-selectable", subtitle_selectable),
648 }
649 }
650
651 /// The number of lines at the end of which the title label will be ellipsized.
652 ///
653 /// If the value is 0, the number of lines won't be limited.
654 pub fn title_lines(self, title_lines: i32) -> Self {
655 Self {
656 builder: self.builder.property("title-lines", title_lines),
657 }
658 }
659
660 /// The title of the preference represented by this row.
661 ///
662 /// The title is interpreted as Pango markup unless
663 /// [`use-markup`][struct@crate::PreferencesRow#use-markup] is set to `FALSE`.
664 pub fn title(self, title: impl Into<glib::GString>) -> Self {
665 Self {
666 builder: self.builder.property("title", title.into()),
667 }
668 }
669
670 /// Whether the user can copy the title from the label.
671 ///
672 /// See also [`selectable`][struct@crate::Gtk::Label#selectable].
673 #[cfg(feature = "v1_1")]
674 #[cfg_attr(docsrs, doc(cfg(feature = "v1_1")))]
675 pub fn title_selectable(self, title_selectable: bool) -> Self {
676 Self {
677 builder: self.builder.property("title-selectable", title_selectable),
678 }
679 }
680
681 /// Whether to use Pango markup for the title label.
682 ///
683 /// Subclasses may also use it for other labels, such as subtitle.
684 ///
685 /// See also `parse_markup()`.
686 #[cfg(feature = "v1_2")]
687 #[cfg_attr(docsrs, doc(cfg(feature = "v1_2")))]
688 pub fn use_markup(self, use_markup: bool) -> Self {
689 Self {
690 builder: self.builder.property("use-markup", use_markup),
691 }
692 }
693
694 /// Whether an embedded underline in the title indicates a mnemonic.
695 pub fn use_underline(self, use_underline: bool) -> Self {
696 Self {
697 builder: self.builder.property("use-underline", use_underline),
698 }
699 }
700
701 /// Determines whether the ::row-activated
702 /// signal will be emitted for this row.
703 pub fn activatable(self, activatable: bool) -> Self {
704 Self {
705 builder: self.builder.property("activatable", activatable),
706 }
707 }
708
709 /// The child widget.
710 pub fn child(self, child: &impl IsA<gtk::Widget>) -> Self {
711 Self {
712 builder: self.builder.property("child", child.clone().upcast()),
713 }
714 }
715
716 /// Determines whether this row can be selected.
717 pub fn selectable(self, selectable: bool) -> Self {
718 Self {
719 builder: self.builder.property("selectable", selectable),
720 }
721 }
722
723 /// Whether the widget or any of its descendents can accept
724 /// the input focus.
725 ///
726 /// This property is meant to be set by widget implementations,
727 /// typically in their instance init function.
728 pub fn can_focus(self, can_focus: bool) -> Self {
729 Self {
730 builder: self.builder.property("can-focus", can_focus),
731 }
732 }
733
734 /// Whether the widget can receive pointer events.
735 pub fn can_target(self, can_target: bool) -> Self {
736 Self {
737 builder: self.builder.property("can-target", can_target),
738 }
739 }
740
741 /// A list of css classes applied to this widget.
742 pub fn css_classes(self, css_classes: impl Into<glib::StrV>) -> Self {
743 Self {
744 builder: self.builder.property("css-classes", css_classes.into()),
745 }
746 }
747
748 /// The name of this widget in the CSS tree.
749 ///
750 /// This property is meant to be set by widget implementations,
751 /// typically in their instance init function.
752 pub fn css_name(self, css_name: impl Into<glib::GString>) -> Self {
753 Self {
754 builder: self.builder.property("css-name", css_name.into()),
755 }
756 }
757
758 /// The cursor used by @widget.
759 pub fn cursor(self, cursor: &gdk::Cursor) -> Self {
760 Self {
761 builder: self.builder.property("cursor", cursor.clone()),
762 }
763 }
764
765 /// Whether the widget should grab focus when it is clicked with the mouse.
766 ///
767 /// This property is only relevant for widgets that can take focus.
768 pub fn focus_on_click(self, focus_on_click: bool) -> Self {
769 Self {
770 builder: self.builder.property("focus-on-click", focus_on_click),
771 }
772 }
773
774 /// Whether this widget itself will accept the input focus.
775 pub fn focusable(self, focusable: bool) -> Self {
776 Self {
777 builder: self.builder.property("focusable", focusable),
778 }
779 }
780
781 /// How to distribute horizontal space if widget gets extra space.
782 pub fn halign(self, halign: gtk::Align) -> Self {
783 Self {
784 builder: self.builder.property("halign", halign),
785 }
786 }
787
788 /// Enables or disables the emission of the [`query-tooltip`][struct@crate::gtk::Widget#query-tooltip]
789 /// signal on @widget.
790 ///
791 /// A true value indicates that @widget can have a tooltip, in this case
792 /// the widget will be queried using [`query-tooltip`][struct@crate::gtk::Widget#query-tooltip] to
793 /// determine whether it will provide a tooltip or not.
794 pub fn has_tooltip(self, has_tooltip: bool) -> Self {
795 Self {
796 builder: self.builder.property("has-tooltip", has_tooltip),
797 }
798 }
799
800 /// Overrides for height request of the widget.
801 ///
802 /// If this is -1, the natural request will be used.
803 pub fn height_request(self, height_request: i32) -> Self {
804 Self {
805 builder: self.builder.property("height-request", height_request),
806 }
807 }
808
809 /// Whether to expand horizontally.
810 pub fn hexpand(self, hexpand: bool) -> Self {
811 Self {
812 builder: self.builder.property("hexpand", hexpand),
813 }
814 }
815
816 /// Whether to use the `hexpand` property.
817 pub fn hexpand_set(self, hexpand_set: bool) -> Self {
818 Self {
819 builder: self.builder.property("hexpand-set", hexpand_set),
820 }
821 }
822
823 /// The [`gtk::LayoutManager`][crate::gtk::LayoutManager] instance to use to compute
824 /// the preferred size of the widget, and allocate its children.
825 ///
826 /// This property is meant to be set by widget implementations,
827 /// typically in their instance init function.
828 pub fn layout_manager(self, layout_manager: &impl IsA<gtk::LayoutManager>) -> Self {
829 Self {
830 builder: self
831 .builder
832 .property("layout-manager", layout_manager.clone().upcast()),
833 }
834 }
835
836 /// Makes this widget act like a modal dialog, with respect to
837 /// event delivery.
838 ///
839 /// Global event controllers will not handle events with targets
840 /// inside the widget, unless they are set up to ignore propagation
841 /// limits. See `Gtk::EventController::set_propagation_limit()`.
842 #[cfg(feature = "gtk_v4_18")]
843 #[cfg_attr(docsrs, doc(cfg(feature = "gtk_v4_18")))]
844 pub fn limit_events(self, limit_events: bool) -> Self {
845 Self {
846 builder: self.builder.property("limit-events", limit_events),
847 }
848 }
849
850 /// Margin on bottom side of widget.
851 ///
852 /// This property adds margin outside of the widget's normal size
853 /// request, the margin will be added in addition to the size from
854 /// [`WidgetExtManual::set_size_request()`][crate::gtk::prelude::WidgetExtManual::set_size_request()] for example.
855 pub fn margin_bottom(self, margin_bottom: i32) -> Self {
856 Self {
857 builder: self.builder.property("margin-bottom", margin_bottom),
858 }
859 }
860
861 /// Margin on end of widget, horizontally.
862 ///
863 /// This property supports left-to-right and right-to-left text
864 /// directions.
865 ///
866 /// This property adds margin outside of the widget's normal size
867 /// request, the margin will be added in addition to the size from
868 /// [`WidgetExtManual::set_size_request()`][crate::gtk::prelude::WidgetExtManual::set_size_request()] for example.
869 pub fn margin_end(self, margin_end: i32) -> Self {
870 Self {
871 builder: self.builder.property("margin-end", margin_end),
872 }
873 }
874
875 /// Margin on start of widget, horizontally.
876 ///
877 /// This property supports left-to-right and right-to-left text
878 /// directions.
879 ///
880 /// This property adds margin outside of the widget's normal size
881 /// request, the margin will be added in addition to the size from
882 /// [`WidgetExtManual::set_size_request()`][crate::gtk::prelude::WidgetExtManual::set_size_request()] for example.
883 pub fn margin_start(self, margin_start: i32) -> Self {
884 Self {
885 builder: self.builder.property("margin-start", margin_start),
886 }
887 }
888
889 /// Margin on top side of widget.
890 ///
891 /// This property adds margin outside of the widget's normal size
892 /// request, the margin will be added in addition to the size from
893 /// [`WidgetExtManual::set_size_request()`][crate::gtk::prelude::WidgetExtManual::set_size_request()] for example.
894 pub fn margin_top(self, margin_top: i32) -> Self {
895 Self {
896 builder: self.builder.property("margin-top", margin_top),
897 }
898 }
899
900 /// The name of the widget.
901 pub fn name(self, name: impl Into<glib::GString>) -> Self {
902 Self {
903 builder: self.builder.property("name", name.into()),
904 }
905 }
906
907 /// The requested opacity of the widget.
908 pub fn opacity(self, opacity: f64) -> Self {
909 Self {
910 builder: self.builder.property("opacity", opacity),
911 }
912 }
913
914 /// How content outside the widget's content area is treated.
915 ///
916 /// This property is meant to be set by widget implementations,
917 /// typically in their instance init function.
918 pub fn overflow(self, overflow: gtk::Overflow) -> Self {
919 Self {
920 builder: self.builder.property("overflow", overflow),
921 }
922 }
923
924 /// Whether the widget will receive the default action when it is focused.
925 pub fn receives_default(self, receives_default: bool) -> Self {
926 Self {
927 builder: self.builder.property("receives-default", receives_default),
928 }
929 }
930
931 /// Whether the widget responds to input.
932 pub fn sensitive(self, sensitive: bool) -> Self {
933 Self {
934 builder: self.builder.property("sensitive", sensitive),
935 }
936 }
937
938 /// Sets the text of tooltip to be the given string, which is marked up
939 /// with Pango markup.
940 ///
941 /// Also see `Gtk::Tooltip::set_markup()`.
942 ///
943 /// This is a convenience property which will take care of getting the
944 /// tooltip shown if the given string is not `NULL`:
945 /// [`has-tooltip`][struct@crate::gtk::Widget#has-tooltip] will automatically be set to true
946 /// and there will be taken care of [`query-tooltip`][struct@crate::gtk::Widget#query-tooltip] in
947 /// the default signal handler.
948 ///
949 /// Note that if both [`tooltip-text`][struct@crate::gtk::Widget#tooltip-text] and
950 /// [`tooltip-markup`][struct@crate::gtk::Widget#tooltip-markup] are set, the last one wins.
951 pub fn tooltip_markup(self, tooltip_markup: impl Into<glib::GString>) -> Self {
952 Self {
953 builder: self
954 .builder
955 .property("tooltip-markup", tooltip_markup.into()),
956 }
957 }
958
959 /// Sets the text of tooltip to be the given string.
960 ///
961 /// Also see `Gtk::Tooltip::set_text()`.
962 ///
963 /// This is a convenience property which will take care of getting the
964 /// tooltip shown if the given string is not `NULL`:
965 /// [`has-tooltip`][struct@crate::gtk::Widget#has-tooltip] will automatically be set to true
966 /// and there will be taken care of [`query-tooltip`][struct@crate::gtk::Widget#query-tooltip] in
967 /// the default signal handler.
968 ///
969 /// Note that if both [`tooltip-text`][struct@crate::gtk::Widget#tooltip-text] and
970 /// [`tooltip-markup`][struct@crate::gtk::Widget#tooltip-markup] are set, the last one wins.
971 pub fn tooltip_text(self, tooltip_text: impl Into<glib::GString>) -> Self {
972 Self {
973 builder: self.builder.property("tooltip-text", tooltip_text.into()),
974 }
975 }
976
977 /// How to distribute vertical space if widget gets extra space.
978 pub fn valign(self, valign: gtk::Align) -> Self {
979 Self {
980 builder: self.builder.property("valign", valign),
981 }
982 }
983
984 /// Whether to expand vertically.
985 pub fn vexpand(self, vexpand: bool) -> Self {
986 Self {
987 builder: self.builder.property("vexpand", vexpand),
988 }
989 }
990
991 /// Whether to use the `vexpand` property.
992 pub fn vexpand_set(self, vexpand_set: bool) -> Self {
993 Self {
994 builder: self.builder.property("vexpand-set", vexpand_set),
995 }
996 }
997
998 /// Whether the widget is visible.
999 pub fn visible(self, visible: bool) -> Self {
1000 Self {
1001 builder: self.builder.property("visible", visible),
1002 }
1003 }
1004
1005 /// Overrides for width request of the widget.
1006 ///
1007 /// If this is -1, the natural request will be used.
1008 pub fn width_request(self, width_request: i32) -> Self {
1009 Self {
1010 builder: self.builder.property("width-request", width_request),
1011 }
1012 }
1013
1014 /// The accessible role of the given [`gtk::Accessible`][crate::gtk::Accessible] implementation.
1015 ///
1016 /// The accessible role cannot be changed once set.
1017 pub fn accessible_role(self, accessible_role: gtk::AccessibleRole) -> Self {
1018 Self {
1019 builder: self.builder.property("accessible-role", accessible_role),
1020 }
1021 }
1022
1023 /// The name of the action with which this widget should be associated.
1024 pub fn action_name(self, action_name: impl Into<glib::GString>) -> Self {
1025 Self {
1026 builder: self.builder.property("action-name", action_name.into()),
1027 }
1028 }
1029
1030 /// The target value of the actionable widget's action.
1031 pub fn action_target(self, action_target: &glib::Variant) -> Self {
1032 Self {
1033 builder: self
1034 .builder
1035 .property("action-target", action_target.clone()),
1036 }
1037 }
1038
1039 // rustdoc-stripper-ignore-next
1040 /// Build the [`SwitchRow`].
1041 #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
1042 pub fn build(self) -> SwitchRow {
1043 assert_initialized_main_thread!();
1044 self.builder.build()
1045 }
1046}